Compare
afb1ecfeda3fc31d6300a176f4854cc62e289bf3..709ba1c547eaf37da36ded2ecf3ea4e304cdfa9a
pinctrl: qcom: ipq5018: replace gcc_plltest with pwm2 on gpio12
The pingroup table has gcc_plltest at function 5 of gpio12 and does not
offer pwm2 on that pin, so the pinmux core rejects a request for pwm2 on
gpio12 as an invalid group. On the hardware, function 5 of gpio12
carries the PWM2 output: the Xiaomi AX3000T v2 drives its blue status
LED from PWM2 on gpio12.
The vendor kernel shipped on that router (Linux 4.4, stock firmware
2.0.28) has pwm2 in this slot. Its pingroup table, as read from the
firmware image, lists these functions for gpio12:
gpio, blsp0_spi, blsp0_i2c, blsp1_uart0, _, pwm2, qdss_tracedata_a,
_, _, _
and has pwm3 at function 4 of gpio13, matching commit c6c159fcdb4e
("pinctrl: qcom: ipq5018: add missing pwm3 function on gpio13").
Measured on the board: with gpio12 set to each of the 16 function
values in turn, and PWM2 held at 0% and then at 100% duty, the pad
level read back from GPIO_IN follows PWM2 only at function 5. There it
does not follow PWM channels 0, 1 or 3, and the LED switches with PWM2.
Functions 4 and 7, which the table leaves empty, do not carry PWM2.
Put pwm2 in function 5 of gpio12 and list gpio12 in pwm2_groups. Drop
gpio12 from gcc_plltest_groups: none of its functions is gcc_plltest
any more, and selecting it would trigger the WARN_ON() in
msm_pinmux_set_mux().
Fixes: 725d1c891658 ("pinctrl: qcom: Add IPQ5018 pinctrl driver")
Assisted-by: LLM
Signed-off-by: Adriel Santos <adriel@adriel.eu>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://patch.msgid.link/20261002160958.908424-1-adriel@adriel.eu
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Adriel Santos <adriel@adriel.eu> · 2026-10-02 16:09 UTC · committed by Bartosz Golaszewski
681 files changed,
+7831
−3384
- .get_maintainer.ignore
- .mailmap
- CREDITS
- Documentation/ABI/testing/ima_policy
- Documentation/ABI/testing/sysfs-class-firmware
- Documentation/ABI/testing/sysfs-devices-platform-trackpoint
- Documentation/ABI/testing/sysfs-fs-erofs
- Documentation/admin-guide/cgroup-v1/memory.rst
- Documentation/admin-guide/cgroup-v2.rst
- Documentation/admin-guide/kernel-parameters.txt
- Documentation/admin-guide/sysctl/kernel.rst
- Documentation/arch/arm64/booting.rst
- Documentation/arch/arm64/memory-tagging-extension.rst
- Documentation/arch/riscv/hwprobe.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/input/mediatek,mt6779-keypad.yaml
- Documentation/devicetree/bindings/pinctrl/qcom,nord-tlmm.yaml
- Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
- Documentation/devicetree/bindings/riscv/cpus.yaml
- Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
- Documentation/fault-injection/nvme-fault-injection.rst
- Documentation/hwmon/cgbc-hwmon.rst
- Documentation/hwmon/gpd-fan.rst
- Documentation/hwmon/hwmon-kernel-api.rst
- Documentation/netlink/specs/conntrack.yaml
- Documentation/netlink/specs/netdev.yaml
- Documentation/netlink/specs/rt-link.yaml
- Documentation/netlink/specs/rt-neigh.yaml
- Documentation/networking/ip-sysctl.rst
- Documentation/scheduler/sched-ext.rst
- Documentation/trace/events-landlock.rst
- Documentation/translations/zh_CN/arch/riscv/patch-acceptance.rst
- Documentation/translations/zh_CN/core-api/irq/irq-domain.rst
- MAINTAINERS
- Makefile
- arch/arm/configs/sama5_defconfig
- arch/arm/mach-socfpga/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/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/crypto/aes-neonbs-glue.c
- arch/arm64/include/asm/cpu.h
- arch/arm64/include/asm/cpufeature.h
- 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/cpu_errata.c
- arch/arm64/kernel/cpufeature.c
- arch/arm64/kernel/cpuinfo.c
- arch/arm64/kernel/hibernate-asm.S
- arch/arm64/kernel/hibernate.c
- arch/arm64/kernel/machine_kexec.c
- arch/arm64/kernel/mte.c
- arch/arm64/kernel/pi/idreg-override.c
- 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/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-its.c
- arch/arm64/mm/fault.c
- arch/arm64/net/bpf_jit_comp.c
- arch/arm64/tools/sysreg
- arch/loongarch/Kconfig
- arch/loongarch/include/asm/kvm_dmsintc.h
- arch/loongarch/include/asm/kvm_eiointc.h
- arch/loongarch/include/asm/kvm_host.h
- arch/loongarch/include/asm/kvm_ipi.h
- arch/loongarch/include/asm/kvm_pch_pic.h
- arch/loongarch/kernel/kprobes.c
- arch/loongarch/kernel/rethook_trampoline.S
- arch/loongarch/kernel/smp.c
- arch/loongarch/kernel/vmlinux.lds.S
- arch/loongarch/kvm/intc/dmsintc.c
- arch/loongarch/kvm/intc/eiointc.c
- arch/loongarch/kvm/intc/ipi.c
- arch/loongarch/kvm/intc/pch_pic.c
- arch/loongarch/kvm/main.c
- arch/loongarch/kvm/mmu.c
- arch/loongarch/kvm/vcpu.c
- arch/loongarch/kvm/vm.c
- arch/loongarch/net/bpf_jit.c
- arch/mips/Kconfig
- arch/mips/bcm47xx/buttons.c
- 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/include/asm/entry-common.h
- arch/powerpc/kernel/eeh_driver.c
- arch/powerpc/kernel/interrupt.c
- arch/powerpc/kernel/iommu.c
- arch/powerpc/kernel/prom.c
- arch/powerpc/kernel/rtas_pci.c
- arch/powerpc/kernel/syscall.c
- arch/powerpc/kexec/elf_64.c
- arch/powerpc/kexec/file_load_64.c
- arch/powerpc/kvm/book3s_hv.c
- arch/powerpc/kvm/book3s_hv_nested.c
- arch/powerpc/kvm/book3s_hv_uvmem.c
- arch/powerpc/platforms/pasemi/setup.c
- arch/powerpc/platforms/powernv/pci-ioda.c
- arch/powerpc/platforms/ps3/repository.c
- arch/powerpc/platforms/pseries/htmdump.c
- arch/powerpc/platforms/pseries/pci.c
- arch/powerpc/sysdev/xive/common.c
- arch/riscv/Kconfig
- arch/riscv/include/asm/bug.h
- arch/riscv/include/asm/csr.h
- arch/riscv/include/asm/switch_to.h
- arch/riscv/kernel/cpufeature.c
- arch/riscv/kernel/patch.c
- arch/riscv/kernel/process.c
- arch/riscv/kernel/sys_hwprobe.c
- arch/riscv/kernel/usercfi.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/uaccess.S
- arch/riscv/mm/init.c
- arch/riscv/net/bpf_jit_comp64.c
- arch/s390/boot/alternative.c
- arch/s390/boot/ipl_parm.c
- arch/s390/boot/physmem_info.c
- arch/s390/crypto/Makefile
- arch/s390/crypto/aes_s390.c
- arch/s390/crypto/hmac_s390.c
- arch/s390/crypto/paes_s390.c
- arch/s390/crypto/phmac_s390.c
- arch/s390/include/asm/cpacf.h
- arch/s390/include/asm/debug.h
- arch/s390/include/asm/pai.h
- arch/s390/include/asm/processor.h
- arch/s390/include/asm/smp.h
- arch/s390/kernel/debug.c
- arch/s390/kernel/diag/diag324.c
- arch/s390/kernel/ipl.c
- arch/s390/kernel/perf_pai.c
- arch/s390/kernel/smp.c
- arch/s390/kernel/topology.c
- arch/s390/kernel/uv.c
- arch/s390/kernel/vtime.c
- 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/mm/pgalloc.c
- arch/s390/pci/pci_event.c
- arch/s390/pci/pci_report.c
- arch/s390/pci/pci_report.h
- arch/s390/pci/pci_sysfs.c
- arch/x86/Kconfig.cpu
- arch/x86/Makefile
- arch/x86/coco/sev/svsm.c
- arch/x86/crypto/aria-aesni-avx2-asm_64.S
- arch/x86/crypto/aria-gfni-avx512-asm_64.S
- arch/x86/entry/entry_fred.c
- 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/div64.h
- arch/x86/include/asm/pgtable.h
- arch/x86/include/asm/text-patching.h
- arch/x86/kernel/alternative.c
- arch/x86/kernel/amd_node.c
- arch/x86/kernel/cpu/mce/amd.c
- arch/x86/kernel/cpu/mce/core.c
- arch/x86/kernel/cpu/microcode/intel.c
- arch/x86/kernel/itmt.c
- arch/x86/kernel/kprobes/core.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/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/net/bpf_jit_comp.c
- arch/x86/pci/fixup.c
- block/bio.c
- block/blk-zoned.c
- block/genhd.c
- drivers/accel/amdxdna/aie2_message.c
- drivers/accel/amdxdna/amdxdna_ctx.c
- drivers/accel/amdxdna/amdxdna_ctx.h
- drivers/accel/amdxdna/amdxdna_gem.c
- drivers/accel/ethosu/ethosu_device.h
- drivers/accel/ethosu/ethosu_drv.c
- drivers/accel/ethosu/ethosu_gem.c
- drivers/accel/ethosu/ethosu_job.c
- drivers/accel/ivpu/ivpu_drv.c
- drivers/accel/ivpu/ivpu_drv.h
- drivers/accel/ivpu/ivpu_fw_log.c
- drivers/accel/ivpu/ivpu_gem.h
- drivers/accel/ivpu/ivpu_ipc.c
- drivers/accel/ivpu/ivpu_job.c
- drivers/accel/ivpu/ivpu_mmu.c
- drivers/accel/ivpu/ivpu_pm.c
- drivers/accel/qaic/qaic_control.c
- drivers/accel/rocket/rocket_job.c
- drivers/acpi/irq.c
- drivers/acpi/scan.c
- drivers/ata/ahci.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/base/property.c
- drivers/base/test/Kconfig
- drivers/base/test/property-entry-test.c
- drivers/block/drbd/drbd_nl_gen.c
- drivers/block/loop.c
- drivers/block/sunvdc.c
- drivers/block/ublk_drv.c
- drivers/block/zloop.c
- drivers/block/zram/backend_lz4.c
- drivers/bluetooth/btintel.c
- drivers/bluetooth/btintel_pcie.c
- drivers/bluetooth/btmtk.c
- drivers/bluetooth/btmtk.h
- drivers/bluetooth/btmtksdio.c
- drivers/bluetooth/btmtkuart.c
- drivers/bluetooth/btnxpuart.c
- drivers/bluetooth/btqcomsmd.c
- drivers/bluetooth/btrtl.c
- drivers/bluetooth/btusb.c
- drivers/bluetooth/hci_mrvl.c
- drivers/bluetooth/hci_qca.c
- drivers/char/virtio_console.c
- drivers/clk/clk-scpi.c
- drivers/clk/ti/composite.c
- drivers/clk/ti/mux.c
- drivers/cpufreq/amd-pstate.c
- drivers/cpufreq/cpufreq.c
- drivers/cpuidle/cpuidle-psci.c
- drivers/cpuidle/dt_idle_genpd.c
- drivers/crypto/caam/jr.c
- drivers/crypto/inside-secure/eip93/eip93-common.c
- drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
- drivers/crypto/ti/dthev2-aes.c
- drivers/devfreq/hisi_uncore_freq.c
- drivers/dibs/dibs_main.c
- drivers/dma-buf/Kconfig
- drivers/dma-buf/dma-buf-mapping.c
- drivers/dma-buf/dma-buf.c
- drivers/dma-buf/dma-fence.c
- drivers/dma-buf/dma-heap.c
- drivers/dma-buf/st-dma-fence.c
- drivers/dma-buf/udmabuf.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/switchtec_dma.c
- drivers/dma/ti/k3-udma-glue.c
- drivers/dma/xilinx/xilinx_dma.c
- drivers/dpll/dpll_netlink.c
- drivers/edac/al_mc_edac.c
- drivers/edac/altera_edac.c
- drivers/edac/altera_edac.h
- drivers/edac/amd64_edac.c
- drivers/edac/aspeed_edac.c
- drivers/edac/debugfs.c
- drivers/edac/edac_device.c
- drivers/edac/edac_device_sysfs.c
- drivers/edac/edac_mc_sysfs.c
- drivers/edac/edac_module.h
- drivers/edac/highbank_mc_edac.c
- drivers/edac/ie31200_edac.c
- drivers/edac/igen6_edac.c
- drivers/edac/thunderx_edac.c
- drivers/edac/versalnet_edac.c
- drivers/edac/xgene_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/firmware/qcom/qcom_tzmem.c
- drivers/firmware/ti_sci.c
- drivers/fpga/dfl-afu-dma-region.c
- drivers/gpio/gpio-aggregator.c
- drivers/gpio/gpio-arizona.c
- drivers/gpio/gpio-mpsse.c
- drivers/gpio/gpio-mvebu.c
- drivers/gpio/gpio-sim.c
- drivers/gpio/gpio-tps65219.c
- drivers/gpio/gpio-virtuser.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/buddy.c
- drivers/gpu/drm/adp/Kconfig
- drivers/gpu/drm/amd/amdgpu/amdgpu.h
- 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_dev_coredump.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_eviction_fence.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
- 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_v8_0.c
- drivers/gpu/drm/amd/amdgpu/nbio_v7_9.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/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_process_queue_manager.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_debugfs.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_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/amdgpu_dm/tests/amdgpu_dm_plane_test.c
- drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
- drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c
- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c
- drivers/gpu/drm/amd/display/dc/core/dc.c
- drivers/gpu/drm/amd/display/dc/core/dc_resource.c
- drivers/gpu/drm/amd/display/dc/core/dc_surface.c
- drivers/gpu/drm/amd/display/dc/dccg/dcn42/dcn42_dccg.c
- drivers/gpu/drm/amd/display/dc/dccg/dcn60/dcn60_dccg.c
- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c
- drivers/gpu/drm/amd/display/dc/dml/Makefile
- drivers/gpu/drm/amd/display/dc/dml2_0/Makefile
- drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn5_funcs_mode_programming.c
- drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_shared_types.h
- drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c
- drivers/gpu/drm/amd/display/dc/dml2_0/dml2_translation_helper.c
- drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
- 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/irq/dcn42/irq_service_dcn42.c
- drivers/gpu/drm/amd/display/dc/irq/dcn60/irq_service_dcn60.c
- drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_dpia_bw.c
- drivers/gpu/drm/amd/display/dc/pg/dcn42/dcn42_pg_cntl.c
- drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn302/dcn302_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn303/dcn303_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn316/dcn316_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn36/dcn36_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dcn60/dcn60_resource.c
- drivers/gpu/drm/amd/display/modules/power/power.c
- drivers/gpu/drm/amd/display/modules/power/power_abm.c
- drivers/gpu/drm/amd/pm/amdgpu_dpm.c
- drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
- drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
- drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c
- drivers/gpu/drm/amd/ras/core/cmd.c
- drivers/gpu/drm/ast/ast_cursor.c
- drivers/gpu/drm/bridge/samsung-dsim.c
- drivers/gpu/drm/bridge/tc358768.c
- drivers/gpu/drm/bridge/ti-sn65dsi83.c
- drivers/gpu/drm/ci/xfails/msm-apq8016-fails.txt
- drivers/gpu/drm/clients/drm_fbdev_client.c
- drivers/gpu/drm/drm_atomic_state_helper.c
- drivers/gpu/drm/drm_atomic_uapi.c
- drivers/gpu/drm/drm_exec.c
- drivers/gpu/drm/drm_pagemap.c
- drivers/gpu/drm/drm_panic_qr.rs
- drivers/gpu/drm/drm_prime.c
- drivers/gpu/drm/drm_syncobj.c
- drivers/gpu/drm/gud/gud_connector.c
- drivers/gpu/drm/gud/gud_drv.c
- drivers/gpu/drm/gud/gud_pipe.c
- drivers/gpu/drm/i915/display/intel_cdclk.c
- drivers/gpu/drm/i915/display/intel_cursor.c
- drivers/gpu/drm/i915/display/intel_cx0_phy.c
- drivers/gpu/drm/i915/display/intel_ddi.c
- drivers/gpu/drm/i915/display/intel_ddi.h
- drivers/gpu/drm/i915/display/intel_display_types.h
- drivers/gpu/drm/i915/display/intel_dp.c
- 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_lt_phy.c
- drivers/gpu/drm/i915/display/intel_psr.c
- drivers/gpu/drm/i915/display/intel_quirks.c
- drivers/gpu/drm/i915/display/skl_universal_plane.c
- drivers/gpu/drm/i915/gem/i915_gem_object.c
- drivers/gpu/drm/i915/i915_pci.c
- drivers/gpu/drm/i915/i915_query.c
- drivers/gpu/drm/imagination/pvr_free_list.c
- drivers/gpu/drm/imagination/pvr_mmu.c
- drivers/gpu/drm/imagination/pvr_mmu.h
- drivers/gpu/drm/imagination/pvr_vm.c
- drivers/gpu/drm/logicvc/Kconfig
- drivers/gpu/drm/loongson/lsdc_plane.c
- 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/nouveau/include/nvif/cl0080.h
- drivers/gpu/drm/nouveau/include/nvif/device.h
- drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h
- drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h
- drivers/gpu/drm/nouveau/nouveau_bo.c
- drivers/gpu/drm/nouveau/nouveau_chan.c
- drivers/gpu/drm/nouveau/nouveau_connector.c
- drivers/gpu/drm/nouveau/nouveau_dmem.c
- drivers/gpu/drm/nouveau/nouveau_drm.c
- drivers/gpu/drm/nouveau/nouveau_gem.c
- drivers/gpu/drm/nouveau/nouveau_sched.c
- drivers/gpu/drm/nouveau/nouveau_sched.h
- drivers/gpu/drm/nouveau/nouveau_sgdma.c
- drivers/gpu/drm/nouveau/nouveau_uvmm.c
- drivers/gpu/drm/nouveau/nvif/device.c
- drivers/gpu/drm/nouveau/nvif/vmm.c
- drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
- drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
- drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
- drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
- drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c
- drivers/gpu/drm/nouveau/nvkm/engine/disp/gb202.c
- drivers/gpu/drm/nouveau/nvkm/engine/disp/head.h
- drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h
- drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
- drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c
- drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
- drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
- drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/base.c
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/priv.h
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/fbsr.c
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/nvrm/gsp.h
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/disp.c
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/fbsr.c
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gsp.c
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/disp.h
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/fbsr.h
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/gsp.h
- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h
- drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
- drivers/gpu/drm/qxl/qxl_display.c
- drivers/gpu/drm/rockchip/Kconfig
- drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
- drivers/gpu/drm/scheduler/sched_entity.c
- drivers/gpu/drm/scheduler/sched_rq.c
- drivers/gpu/drm/scheduler/tests/mock_scheduler.c
- drivers/gpu/drm/sysfb/ofdrm.c
- drivers/gpu/drm/tegra/dc.c
- drivers/gpu/drm/tegra/hub.c
- drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c
- drivers/gpu/drm/tiny/cirrus-qemu.c
- drivers/gpu/drm/ttm/ttm_bo.c
- drivers/gpu/drm/vboxvideo/vbox_mode.c
- drivers/gpu/drm/vc4/vc4_kms.c
- drivers/gpu/drm/verisilicon/vs_cursor_plane.c
- drivers/gpu/drm/verisilicon/vs_hwdb.c
- drivers/gpu/drm/verisilicon/vs_hwdb.h
- drivers/gpu/drm/verisilicon/vs_plane.c
- drivers/gpu/drm/verisilicon/vs_primary_plane.c
- drivers/gpu/drm/virtio/virtgpu_display.c
- drivers/gpu/drm/virtio/virtgpu_drv.h
- drivers/gpu/drm/virtio/virtgpu_gem.c
- drivers/gpu/drm/virtio/virtgpu_ioctl.c
- drivers/gpu/drm/virtio/virtgpu_kms.c
- drivers/gpu/drm/virtio/virtgpu_object.c
- drivers/gpu/drm/virtio/virtgpu_plane.c
- drivers/gpu/drm/virtio/virtgpu_prime.c
- drivers/gpu/drm/virtio/virtgpu_submit.c
- drivers/gpu/drm/virtio/virtgpu_vq.c
- drivers/gpu/drm/virtio/virtgpu_vram.c
- drivers/gpu/drm/vkms/vkms_configfs.c
- drivers/gpu/drm/xe/instructions/xe_gpu_commands.h
- drivers/gpu/drm/xe/regs/xe_gt_regs.h
- drivers/gpu/drm/xe/xe_amc.c
- 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_mmio_gem.c
- drivers/gpu/drm/xe/xe_mmio_gem.h
- drivers/gpu/drm/xe/xe_oa.c
- drivers/gpu/drm/xe/xe_pagefault.c
- drivers/gpu/drm/xe/xe_pagefault_types.h
- drivers/gpu/drm/xe/xe_ring_ops.c
- drivers/gpu/drm/xe/xe_shrinker.c
- drivers/gpu/drm/xe/xe_tlb_inval.c
- drivers/gpu/drm/xe/xe_vm.c
- drivers/gpu/drm/xe/xe_vram.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/bpf/hid_bpf_struct_ops.c
- drivers/hid/hid-alps.c
- drivers/hid/hid-asus.c
- drivers/hid/hid-corsair-void.c
- drivers/hid/hid-elecom.c
- drivers/hid/hid-hyperv.c
- drivers/hid/hid-ids.h
- drivers/hid/hid-logitech-hidpp.c
- drivers/hid/hid-multitouch.c
- drivers/hid/hid-oxp.c
- drivers/hid/hid-quirks.c
- drivers/hid/hid-rmi.c
- drivers/hid/hid-roccat.c
- drivers/hid/hid-steam.c
- drivers/hid/hid-steelseries-arctis.c
- drivers/hid/hid-winwing.c
- drivers/hid/i2c-hid/i2c-hid-core.c
- drivers/hid/wacom_sys.c
- drivers/hid/wacom_wac.c
- drivers/hv/channel.c
- drivers/hv/hv_balloon.c
- drivers/hwmon/applesmc.c
- drivers/hwmon/aspeed-pwm-tacho.c
- drivers/hwmon/asus_rog_ryujin.c
- drivers/hwmon/cgbc-hwmon.c
- drivers/hwmon/chipcap2.c
- drivers/hwmon/corsair-cpro.c
- drivers/hwmon/gpio-fan.c
- drivers/hwmon/hp-wmi-sensors.c
- drivers/hwmon/hwmon.c
- drivers/hwmon/ina2xx.c
- drivers/hwmon/k10temp.c
- drivers/hwmon/ltc4282.c
- drivers/hwmon/mcp9982.c
- drivers/hwmon/nct6694-hwmon.c
- drivers/hwmon/pmbus/pmbus.h
- drivers/hwmon/pmbus/pmbus_core.c
- drivers/hwmon/pmbus/tps53679.c
- drivers/hwmon/pwm-fan.c
- drivers/hwmon/sht4x.c
- drivers/hwmon/w83791d.c
- drivers/hwmon/w83793.c
- drivers/hwmon/yogafan.c
- drivers/hwtracing/coresight/coresight-core.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-gpio.c
- drivers/i2c/busses/i2c-imx.c
- drivers/i2c/busses/i2c-qcom-cci.c
- drivers/i2c/busses/i2c-qcom-geni.c
- drivers/i2c/i2c-atr.c
- drivers/i3c/master/amd-i3c-master.c
- drivers/iio/adc/ad7280a.c
- drivers/iio/buffer/industrialio-buffer-dmaengine.c
- drivers/iio/inkern.c
- drivers/infiniband/core/iwpm_util.c
- drivers/infiniband/core/mad.c
- drivers/infiniband/core/nldev.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/hns/hns_roce_debugfs.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
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
| @@ -19,7 +19,8 @@ Abhinav Kumar <quic_abhinavk@quicinc.com> <abhinavk@codeaurora.org> | |||
| 19 | 19 | Ahmad Masri <quic_amasri@quicinc.com> <amasri@codeaurora.org> | |
| 20 | 20 | Adam Oldham <oldhamca@gmail.com> | |
| 21 | 21 | Adam Radford <aradford@gmail.com> | |
| 22 | - | Aditya Garg <gargaditya08@proton.me> <gargaditya08@live.com> | |
| 22 | + | Aditya Garg <aditya.garg@linux.dev> <gargaditya08@live.com> | |
| 23 | + | Aditya Garg <aditya.garg@linux.dev> <gargaditya08@proton.me> | |
| 23 | 24 | Adriana Reus <adi.reus@gmail.com> <adriana.reus@intel.com> | |
| 24 | 25 | Adrian Bunk <bunk@stusta.de> | |
| 25 | 26 | Ajay Kaher <ajay.kaher@broadcom.com> <akaher@vmware.com> | |
| @@ -210,7 +211,8 @@ Christophe Leroy <chleroy@kernel.org> <christophe.leroy@c-s.fr> | |||
| 210 | 211 | Christophe Leroy <chleroy@kernel.org> <christophe.leroy@csgroup.eu> | |
| 211 | 212 | Christophe Leroy <chleroy@kernel.org> <christophe.leroy2@cs-soprasteria.com> | |
| 212 | 213 | Christophe Ricard <christophe.ricard@gmail.com> | |
| 213 | - | Christopher Obbard <christopher.obbard@linaro.org> <chris.obbard@collabora.com> | |
| 214 | + | Christopher Obbard <chris.obbard@oss.qualcomm.com> <chris.obbard@collabora.com> | |
| 215 | + | Christopher Obbard <chris.obbard@oss.qualcomm.com> <christopher.obbard@linaro.org> | |
| 214 | 216 | Christoph Hellwig <hch@lst.de> | |
| 215 | 217 | Christoph Manszewski <c.manszewski@gmail.com> <christoph.manszewski@intel.com> | |
| 216 | 218 | Christoph Paasch <cpaasch@openai.com> <christoph.paasch@gmail.com> | |
| @@ -221,6 +223,7 @@ Chuck Lever <cel@kernel.org> <chuck.lever@oracle.com> | |||
| 221 | 223 | Chuck Lever <cel@kernel.org> <cel@netapp.com> | |
| 222 | 224 | Chuck Lever <cel@kernel.org> <cel@citi.umich.edu> | |
| 223 | 225 | Claudiu Beznea <claudiu.beznea@tuxon.dev> <claudiu.beznea@microchip.com> | |
| 226 | + | Coiby Xu <coiby.xu@gmail.com> <coxu@redhat.com> | |
| 224 | 227 | Colin Ian King <colin.i.king@gmail.com> <colin.king@canonical.com> | |
| 225 | 228 | Corey Minyard <minyard@acm.org> | |
| 226 | 229 | Damian Hobson-Garcia <dhobsong@igel.co.jp> | |
| @@ -352,6 +355,8 @@ Hans Verkuil <hverkuil@kernel.org> <hverkuil-cisco@xs4all.nl> | |||
| 352 | 355 | Hans Verkuil <hverkuil@kernel.org> <hansverk@cisco.com> | |
| 353 | 356 | Hans Verkuil <hverkuil@kernel.org> <hans.verkuil@cisco.com> | |
| 354 | 357 | Hao Ge <hao.ge@linux.dev> <gehao@kylinos.cn> | |
| 358 | + | Haowen Bai <baihaowen88@gmail.com> <baihaowen@meizu.com> | |
| 359 | + | Haowen Bai <baihaowen88@gmail.com> <calvin.bai@ugreen.com> | |
| 355 | 360 | Harry Yoo <harry.yoo@oracle.com> <42.hyeyoo@gmail.com> | |
| 356 | 361 | Harry Yoo <harry@kernel.org> <harry.yoo@oracle.com> | |
| 357 | 362 | Heiko Carstens <hca@linux.ibm.com> <h.carstens@de.ibm.com> | |
| @@ -420,6 +425,7 @@ Jens Axboe <axboe@kernel.dk> <axboe@suse.de> | |||
| 420 | 425 | Jens Axboe <axboe@kernel.dk> <jens.axboe@oracle.com> | |
| 421 | 426 | Jens Axboe <axboe@kernel.dk> <axboe@fb.com> | |
| 422 | 427 | Jens Axboe <axboe@kernel.dk> <axboe@meta.com> | |
| 428 | + | Jens Axboe <axboe@kernel.dk> <axboe@anthropic.com> | |
| 423 | 429 | Jens Osterkamp <Jens.Osterkamp@de.ibm.com> | |
| 424 | 430 | Jens Wiklander <jenswi@kernel.org> <jens.wiklander@linaro.org> | |
| 425 | 431 | Jernej Skrabec <jernej.skrabec@gmail.com> <jernej.skrabec@siol.net> | |
| @@ -550,6 +556,9 @@ Li Yang <leoyang.li@nxp.com> <leo@zh-kernel.org> | |||
| 550 | 556 | Lior David <quic_liord@quicinc.com> <liord@codeaurora.org> | |
| 551 | 557 | Loic Poulain <loic.poulain@oss.qualcomm.com> <loic.poulain@linaro.org> | |
| 552 | 558 | Loic Poulain <loic.poulain@oss.qualcomm.com> <loic.poulain@intel.com> | |
| 559 | + | Lorenzo Bianconi <lorenzo@kernel.org> <lorenzo.bianconi@redhat.com> | |
| 560 | + | Lorenzo Bianconi <lorenzo@kernel.org> <lorenzo.bianconi@st.com> | |
| 561 | + | Lorenzo Bianconi <lorenzo@kernel.org> <lorenzo.bianconi83@gmail.com> | |
| 553 | 562 | Lorenzo Pieralisi <lpieralisi@kernel.org> <lorenzo.pieralisi@arm.com> | |
| 554 | 563 | Lorenzo Stoakes <ljs@kernel.org> <lstoakes@gmail.com> | |
| 555 | 564 | Lorenzo Stoakes <ljs@kernel.org> <lorenzo.stoakes@oracle.com> | |
| @@ -699,6 +708,7 @@ Oliver Hartkopp <socketcan@hartkopp.net> <oliver.hartkopp@volkswagen.de> | |||
| 699 | 708 | Oliver Hartkopp <socketcan@hartkopp.net> <oliver@hartkopp.net> | |
| 700 | 709 | Oliver Upton <oupton@kernel.org> <oupton@google.com> | |
| 701 | 710 | Oliver Upton <oupton@kernel.org> <oliver.upton@linux.dev> | |
| 711 | + | Ondrej Mosnáček <omosnacek@gmail.com> <omosnace@redhat.com> | |
| 702 | 712 | Ondřej Jirman <megi@xff.cz> <megous@megous.com> | |
| 703 | 713 | Oza Pawandeep <quic_poza@quicinc.com> <poza@codeaurora.org> | |
| 704 | 714 | Pali Rohár <pali@kernel.org> <pali.rohar@gmail.com> | |
| @@ -898,7 +908,8 @@ Thomas Graf <tgraf@suug.ch> | |||
| 898 | 908 | Thomas Gleixner <tglx@kernel.org> <tglx@linutronix.de> | |
| 899 | 909 | Thomas Körper <socketcan@esd.eu> <thomas.koerper@esd.eu> | |
| 900 | 910 | Thomas Pedersen <twp@codeaurora.org> | |
| 901 | - | Thorsten Blum <thorsten.blum@linux.dev> <thorsten.blum@toblux.com> | |
| 911 | + | Thorsten Blum <blum@kernel.org> <thorsten.blum@toblux.com> | |
| 912 | + | Thorsten Blum <blum@kernel.org> <thorsten.blum@linux.dev> | |
| 902 | 913 | Tiezhu Yang <yangtiezhu@loongson.cn> <kernelpatch@126.com> | |
| 903 | 914 | Tingwei Zhang <quic_tingwei@quicinc.com> <tingwei@codeaurora.org> | |
| 904 | 915 | Tirupathi Reddy <quic_tirupath@quicinc.com> <tirupath@codeaurora.org> | |
| @@ -966,6 +977,7 @@ Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com> | |||
| 966 | 977 | Vlastimil Babka <vbabka@kernel.org> <vbabka@suse.cz> | |
| 967 | 978 | WangYuli <wangyuli@aosc.io> <wangyl5933@chinaunicom.cn> | |
| 968 | 979 | WangYuli <wangyuli@aosc.io> <wangyuli@deepin.org> | |
| 980 | + | Wei Wang <weiwan@google.com> <weibunny@fb.com> | |
| 969 | 981 | Weiwen Hu <huweiwen@linux.alibaba.com> <sehuww@mail.scut.edu.cn> | |
| 970 | 982 | WeiXiong Liao <gmpy.liaowx@gmail.com> <liaoweixiong@allwinnertech.com> | |
| 971 | 983 | Wen Gong <quic_wgong@quicinc.com> <wgong@codeaurora.org> | |
| @@ -973,6 +985,8 @@ Wesley Cheng <quic_wcheng@quicinc.com> <wcheng@codeaurora.org> | |||
| 973 | 985 | Will Deacon <will@kernel.org> <will.deacon@arm.com> | |
| 974 | 986 | Wolfram Sang <wsa@kernel.org> <w.sang@pengutronix.de> | |
| 975 | 987 | Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de> | |
| 988 | + | Xu Xin <xu.xin@linux.dev> <xu.xin16@zte.com.cn> | |
| 989 | + | Xu Xin <xu.xin@linux.dev> xu xin <cgel.zte@gmail.com> | |
| 976 | 990 | Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com> | |
| 977 | 991 | Yanteng Si <si.yanteng@linux.dev> <siyanteng@loongson.cn> | |
| 978 | 992 | Ying Huang <huang.ying.caritas@gmail.com> <ying.huang@intel.com> | |
modified CREDITS
| @@ -1512,6 +1512,10 @@ N: Andy Gross | |||
| 1512 | 1512 | E: agross@kernel.org | |
| 1513 | 1513 | D: Qualcomm SoC subsystem and drivers | |
| 1514 | 1514 | ||
| 1515 | + | N: Mark Gross | |
| 1516 | + | E: markgross@kernel.org | |
| 1517 | + | D: x86/mellanox platform maintenance and various x86 specific drivers | |
| 1518 | + | ||
| 1515 | 1519 | N: Grant Grundler | |
| 1516 | 1520 | E: grantgrundler@gmail.com | |
| 1517 | 1521 | W: http://obmouse.sourceforge.net/ | |
| @@ -4305,6 +4309,10 @@ N: Juergen Weigert | |||
| 4305 | 4309 | E: jnweiger@immd4.informatik.uni-erlangen.de | |
| 4306 | 4310 | D: The Linux Support Team Erlangen | |
| 4307 | 4311 | ||
| 4312 | + | N: Russ Weight | |
| 4313 | + | E: russ.weight@gmail.com | |
| 4314 | + | D: Added support for Firmware Upload to the Firmware Loader | |
| 4315 | + | ||
| 4308 | 4316 | N: David Weinehall | |
| 4309 | 4317 | E: tao@acc.umu.se | |
| 4310 | 4318 | P: 1024D/DC47CA16 7ACE 0FB0 7A74 F994 9B36 E1D1 D14E 8526 DC47 CA16 | |
modified Documentation/ABI/testing/ima_policy
| @@ -108,6 +108,9 @@ Description: | |||
| 108 | 108 | # NSFS_MAGIC | |
| 109 | 109 | dont_measure fsmagic=0x6e736673 | |
| 110 | 110 | dont_appraise fsmagic=0x6e736673 | |
| 111 | + | # CONFIGFS_MAGIC | |
| 112 | + | dont_measure fsmagic=0x62656570 | |
| 113 | + | dont_appraise fsmagic=0x62656570 | |
| 111 | 114 | ||
| 112 | 115 | measure func=BPRM_CHECK | |
| 113 | 116 | measure func=FILE_MMAP mask=MAY_EXEC | |
modified Documentation/ABI/testing/sysfs-class-firmware
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | What: /sys/class/firmware/.../data | |
| 2 | 2 | Date: July 2022 | |
| 3 | 3 | KernelVersion: 5.19 | |
| 4 | - | Contact: Russ Weight <russ.weight@linux.dev> | |
| 4 | + | Contact: driver-core@lists.linux.dev | |
| 5 | 5 | Description: The data sysfs file is used for firmware-fallback and for | |
| 6 | 6 | firmware uploads. Cat a firmware image to this sysfs file | |
| 7 | 7 | after you echo 1 to the loading sysfs file. When the firmware | |
| @@ -13,7 +13,7 @@ Description: The data sysfs file is used for firmware-fallback and for | |||
| 13 | 13 | What: /sys/class/firmware/.../cancel | |
| 14 | 14 | Date: July 2022 | |
| 15 | 15 | KernelVersion: 5.19 | |
| 16 | - | Contact: Russ Weight <russ.weight@linux.dev> | |
| 16 | + | Contact: driver-core@lists.linux.dev | |
| 17 | 17 | Description: Write-only. For firmware uploads, write a "1" to this file to | |
| 18 | 18 | request that the transfer of firmware data to the lower-level | |
| 19 | 19 | device be canceled. This request will be rejected (EBUSY) if | |
| @@ -23,7 +23,7 @@ Description: Write-only. For firmware uploads, write a "1" to this file to | |||
| 23 | 23 | What: /sys/class/firmware/.../error | |
| 24 | 24 | Date: July 2022 | |
| 25 | 25 | KernelVersion: 5.19 | |
| 26 | - | Contact: Russ Weight <russ.weight@linux.dev> | |
| 26 | + | Contact: driver-core@lists.linux.dev | |
| 27 | 27 | Description: Read-only. Returns a string describing a failed firmware | |
| 28 | 28 | upload. This string will be in the form of <STATUS>:<ERROR>, | |
| 29 | 29 | where <STATUS> will be one of the status strings described | |
| @@ -37,7 +37,7 @@ Description: Read-only. Returns a string describing a failed firmware | |||
| 37 | 37 | What: /sys/class/firmware/.../loading | |
| 38 | 38 | Date: July 2022 | |
| 39 | 39 | KernelVersion: 5.19 | |
| 40 | - | Contact: Russ Weight <russ.weight@linux.dev> | |
| 40 | + | Contact: driver-core@lists.linux.dev | |
| 41 | 41 | Description: The loading sysfs file is used for both firmware-fallback and | |
| 42 | 42 | for firmware uploads. Echo 1 onto the loading file to indicate | |
| 43 | 43 | you are writing a firmware file to the data sysfs node. Echo | |
| @@ -49,7 +49,7 @@ Description: The loading sysfs file is used for both firmware-fallback and | |||
| 49 | 49 | What: /sys/class/firmware/.../remaining_size | |
| 50 | 50 | Date: July 2022 | |
| 51 | 51 | KernelVersion: 5.19 | |
| 52 | - | Contact: Russ Weight <russ.weight@linux.dev> | |
| 52 | + | Contact: driver-core@lists.linux.dev | |
| 53 | 53 | Description: Read-only. For firmware upload, this file contains the size | |
| 54 | 54 | of the firmware data that remains to be transferred to the | |
| 55 | 55 | lower-level device driver. The size value is initialized to | |
| @@ -62,7 +62,7 @@ Description: Read-only. For firmware upload, this file contains the size | |||
| 62 | 62 | What: /sys/class/firmware/.../status | |
| 63 | 63 | Date: July 2022 | |
| 64 | 64 | KernelVersion: 5.19 | |
| 65 | - | Contact: Russ Weight <russ.weight@linux.dev> | |
| 65 | + | Contact: driver-core@lists.linux.dev | |
| 66 | 66 | Description: Read-only. Returns a string describing the current status of | |
| 67 | 67 | a firmware upload. The string will be one of the following: | |
| 68 | 68 | idle, "receiving", "preparing", "transferring", "programming". | |
| @@ -70,7 +70,7 @@ Description: Read-only. Returns a string describing the current status of | |||
| 70 | 70 | What: /sys/class/firmware/.../timeout | |
| 71 | 71 | Date: July 2022 | |
| 72 | 72 | KernelVersion: 5.19 | |
| 73 | - | Contact: Russ Weight <russ.weight@linux.dev> | |
| 73 | + | Contact: driver-core@lists.linux.dev | |
| 74 | 74 | Description: This file supports the timeout mechanism for firmware | |
| 75 | 75 | fallback. This file has no affect on firmware uploads. For | |
| 76 | 76 | more information on timeouts please see the documentation | |
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/ABI/testing/sysfs-fs-erofs
| @@ -5,7 +5,7 @@ Description: Shows all enabled kernel features. | |||
| 5 | 5 | Supported features: | |
| 6 | 6 | compr_cfgs, big_pcluster, chunked_file, device_table, | |
| 7 | 7 | compr_head2, sb_chksum, ztailpacking, dedupe, fragments, | |
| 8 | - | 48bit, metabox. | |
| 8 | + | xattr_prefixes, 48bit, metabox. | |
| 9 | 9 | ||
| 10 | 10 | What: /sys/fs/erofs/<disk>/sync_decompress | |
| 11 | 11 | Date: November 2021 | |
modified Documentation/admin-guide/cgroup-v1/memory.rst
| @@ -47,7 +47,6 @@ Features: | |||
| 47 | 47 | - pages are linked to per-memcg LRU exclusively, and there is no global LRU. | |
| 48 | 48 | - optionally, memory+swap usage can be accounted and limited. | |
| 49 | 49 | - hierarchical accounting | |
| 50 | - | - soft limit | |
| 51 | 50 | - moving (recharging) account at moving a task is selectable. | |
| 52 | 51 | - usage threshold notifier | |
| 53 | 52 | - memory pressure notifier | |
| @@ -76,10 +75,9 @@ Brief summary of control files. | |||
| 76 | 75 | memory.memsw.failcnt show the number of memory+Swap hits limits | |
| 77 | 76 | memory.max_usage_in_bytes show max memory usage recorded | |
| 78 | 77 | memory.memsw.max_usage_in_bytes show max memory+Swap usage recorded | |
| 79 | - | memory.soft_limit_in_bytes set/show soft limit of memory usage | |
| 80 | - | This knob is not available on CONFIG_PREEMPT_RT systems. | |
| 81 | - | This knob is deprecated and shouldn't be | |
| 82 | - | used. | |
| 78 | + | memory.soft_limit_in_bytes This knob is deprecated and has no effect. | |
| 79 | + | Writes are ignored and reads always | |
| 80 | + | return the maximum value. | |
| 83 | 81 | memory.stat show various statistics | |
| 84 | 82 | memory.use_hierarchy set/show hierarchical account enabled | |
| 85 | 83 | This knob is deprecated and shouldn't be | |
| @@ -340,9 +338,6 @@ memory.kmem.usage_in_bytes, or in a separate counter when it makes sense. | |||
| 340 | 338 | The main "kmem" counter is fed into the main counter, so kmem charges will | |
| 341 | 339 | also be visible from the user counter. | |
| 342 | 340 | ||
| 343 | - | Currently no soft limit is implemented for kernel memory. It is future work | |
| 344 | - | to trigger slab reclaim when those limits are reached. | |
| 345 | - | ||
| 346 | 341 | 2.7.1 Current Kernel Memory resources accounted | |
| 347 | 342 | ----------------------------------------------- | |
| 348 | 343 | ||
| @@ -710,42 +705,10 @@ For compatibility reasons writing 1 to memory.use_hierarchy will always pass:: | |||
| 710 | 705 | ||
| 711 | 706 | THIS IS DEPRECATED! | |
| 712 | 707 | ||
| 713 | - | Soft limits allow for greater sharing of memory. The idea behind soft limits | |
| 714 | - | is to allow control groups to use as much of the memory as needed, provided | |
| 715 | - | ||
| 716 | - | a. There is no memory contention | |
| 717 | - | b. They do not exceed their hard limit | |
| 718 | - | ||
| 719 | - | When the system detects memory contention or low memory, control groups | |
| 720 | - | are pushed back to their soft limits. If the soft limit of each control | |
| 721 | - | group is very high, they are pushed back as much as possible to make | |
| 722 | - | sure that one control group does not starve the others of memory. | |
| 723 | - | ||
| 724 | - | Please note that soft limits is a best-effort feature; it comes with | |
| 725 | - | no guarantees, but it does its best to make sure that when memory is | |
| 726 | - | heavily contended for, memory is allocated based on the soft limit | |
| 727 | - | hints/setup. Currently soft limit based reclaim is set up such that | |
| 728 | - | it gets invoked from balance_pgdat (kswapd). | |
| 729 | - | ||
| 730 | - | 7.1 Interface | |
| 731 | - | ------------- | |
| 732 | - | ||
| 733 | - | Soft limits can be setup by using the following commands (in this example we | |
| 734 | - | assume a soft limit of 256 MiB):: | |
| 735 | - | ||
| 736 | - | # echo 256M > memory.soft_limit_in_bytes | |
| 737 | - | ||
| 738 | - | If we want to change this to 1G, we can at any time use:: | |
| 708 | + | Writing to memory.soft_limit_in_bytes has no effect and reading it will | |
| 709 | + | always return the maximum value. | |
| 739 | 710 | ||
| 740 | - | # echo 1G > memory.soft_limit_in_bytes | |
| 741 | - | ||
| 742 | - | .. note:: | |
| 743 | - | Soft limits take effect over a long period of time, since they involve | |
| 744 | - | reclaiming memory for balancing between memory cgroups | |
| 745 | - | ||
| 746 | - | .. note:: | |
| 747 | - | It is recommended to set the soft limit always below the hard limit, | |
| 748 | - | otherwise the hard limit will take precedence. | |
| 711 | + | Use memory.low and memory.min in cgroup v2 instead. | |
| 749 | 712 | ||
| 750 | 713 | .. _cgroup-v1-memory-move-charges: | |
| 751 | 714 | ||
modified Documentation/admin-guide/cgroup-v2.rst
| @@ -1130,9 +1130,9 @@ policy and the underlying scheduler. From the point of view of the cpu controlle | |||
| 1130 | 1130 | processes can be categorized as follows: | |
| 1131 | 1131 | ||
| 1132 | 1132 | * Processes under the fair-class scheduler | |
| 1133 | - | * Processes under a BPF scheduler with the ``cgroup_set_weight`` callback | |
| 1133 | + | * Processes under a BPF scheduler with the corresponding ``cgroup_set_*`` callback | |
| 1134 | 1134 | * Everything else: ``SCHED_{FIFO,RR,DEADLINE}`` and processes under a BPF scheduler | |
| 1135 | - | without the ``cgroup_set_weight`` callback | |
| 1135 | + | without the corresponding ``cgroup_set_*`` callback | |
| 1136 | 1136 | ||
| 1137 | 1137 | For details on when a process is under the fair-class scheduler or a BPF scheduler, | |
| 1138 | 1138 | check out :ref:`Documentation/scheduler/sched-ext.rst <sched-ext>`. | |
| @@ -1223,7 +1223,9 @@ will be referred to. All time durations are in microseconds. | |||
| 1223 | 1223 | $PERIOD duration. "max" for $MAX indicates no limit. If only | |
| 1224 | 1224 | one number is written, $MAX is updated. | |
| 1225 | 1225 | ||
| 1226 | - | This file affects only processes under the fair-class scheduler. | |
| 1226 | + | This file affects only processes under the fair-class scheduler and a BPF | |
| 1227 | + | scheduler with the ``cgroup_set_bandwidth`` callback depending on what | |
| 1228 | + | the callback actually does. | |
| 1227 | 1229 | ||
| 1228 | 1230 | cpu.max.burst | |
| 1229 | 1231 | A read-write single value file which exists on non-root | |
| @@ -1231,7 +1233,9 @@ will be referred to. All time durations are in microseconds. | |||
| 1231 | 1233 | ||
| 1232 | 1234 | The burst in the range [0, $MAX]. | |
| 1233 | 1235 | ||
| 1234 | - | This file affects only processes under the fair-class scheduler. | |
| 1236 | + | This file affects only processes under the fair-class scheduler and a BPF | |
| 1237 | + | scheduler with the ``cgroup_set_bandwidth`` callback depending on what | |
| 1238 | + | the callback actually does. | |
| 1235 | 1239 | ||
| 1236 | 1240 | cpu.pressure | |
| 1237 | 1241 | A read-write nested-keyed file. | |
| @@ -1283,7 +1287,9 @@ will be referred to. All time durations are in microseconds. | |||
| 1283 | 1287 | own relative priorities, but the cgroup itself will be treated as | |
| 1284 | 1288 | very low priority relative to its peers. | |
| 1285 | 1289 | ||
| 1286 | - | This file affects only processes under the fair-class scheduler. | |
| 1290 | + | This file affects only processes under the fair-class scheduler and a BPF | |
| 1291 | + | scheduler with the ``cgroup_set_idle`` callback depending on what the | |
| 1292 | + | callback actually does. | |
| 1287 | 1293 | ||
| 1288 | 1294 | Memory | |
| 1289 | 1295 | ------ | |
| @@ -3064,7 +3070,7 @@ resources (res_a and res_b) are registered then: | |||
| 3064 | 3070 | change in this file generates a file modified event. All fields in | |
| 3065 | 3071 | this file are hierarchical. | |
| 3066 | 3072 | ||
| 3067 | - | max | |
| 3073 | + | <res>.max | |
| 3068 | 3074 | The number of times the cgroup's resource usage was | |
| 3069 | 3075 | about to go over the max boundary. | |
| 3070 | 3076 | ||
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 | ||
| @@ -4987,18 +4988,6 @@ Kernel parameters | |||
| 4987 | 4988 | Set to non-zero if a chip is present that snoops speed | |
| 4988 | 4989 | changes. Disabled by default. | |
| 4989 | 4990 | ||
| 4990 | - | pata_legacy.ht6560a= [HW,LIBATA] | |
| 4991 | - | Format: <int> | |
| 4992 | - | Set to 1, 2, or 3 for HT 6560A on the primary channel, | |
| 4993 | - | the secondary channel, or both channels respectively. | |
| 4994 | - | Disabled by default. | |
| 4995 | - | ||
| 4996 | - | pata_legacy.ht6560b= [HW,LIBATA] | |
| 4997 | - | Format: <int> | |
| 4998 | - | Set to 1, 2, or 3 for HT 6560B on the primary channel, | |
| 4999 | - | the secondary channel, or both channels respectively. | |
| 5000 | - | Disabled by default. | |
| 5001 | - | ||
| 5002 | 4991 | pata_legacy.iordy_mask= [HW,LIBATA] | |
| 5003 | 4992 | Format: <int> | |
| 5004 | 4993 | IORDY enable mask. Set individual bits to allow IORDY | |
| @@ -5011,18 +5000,6 @@ Kernel parameters | |||
| 5011 | 5000 | with the sequence. By default IORDY is allowed across | |
| 5012 | 5001 | all channels. | |
| 5013 | 5002 | ||
| 5014 | - | pata_legacy.opti82c46x= [HW,LIBATA] | |
| 5015 | - | Format: <int> | |
| 5016 | - | Set to 1, 2, or 3 for Opti 82c611A on the primary | |
| 5017 | - | channel, the secondary channel, or both channels | |
| 5018 | - | respectively. Disabled by default. | |
| 5019 | - | ||
| 5020 | - | pata_legacy.opti82c611a= [HW,LIBATA] | |
| 5021 | - | Format: <int> | |
| 5022 | - | Set to 1, 2, or 3 for Opti 82c465MV on the primary | |
| 5023 | - | channel, the secondary channel, or both channels | |
| 5024 | - | respectively. Disabled by default. | |
| 5025 | - | ||
| 5026 | 5003 | pata_legacy.pio_mask= [HW,LIBATA] | |
| 5027 | 5004 | Format: <int> | |
| 5028 | 5005 | PIO mode mask for autospeed devices. Set individual | |
| @@ -5046,19 +5023,6 @@ Kernel parameters | |||
| 5046 | 5023 | the first port in the list above (0x1f0), and so on. | |
| 5047 | 5024 | By default all supported ports are probed. | |
| 5048 | 5025 | ||
| 5049 | - | pata_legacy.qdi= [HW,LIBATA] | |
| 5050 | - | Format: <int> | |
| 5051 | - | Set to non-zero to probe QDI controllers. By default | |
| 5052 | - | set to 1 if CONFIG_PATA_QDI_MODULE, 0 otherwise. | |
| 5053 | - | ||
| 5054 | - | pata_legacy.winbond= [HW,LIBATA] | |
| 5055 | - | Format: <int> | |
| 5056 | - | Set to non-zero to probe Winbond controllers. Use | |
| 5057 | - | the standard I/O port (0x130) if 1, otherwise the | |
| 5058 | - | value given is the I/O port to use (typically 0x1b0). | |
| 5059 | - | By default set to 1 if CONFIG_PATA_WINBOND_VLB_MODULE, | |
| 5060 | - | 0 otherwise. | |
| 5061 | - | ||
| 5062 | 5026 | pata_platform.pio_mask= [HW,LIBATA] | |
| 5063 | 5027 | Format: <int> | |
| 5064 | 5028 | Supported PIO mode mask. Set individual bits to allow | |
modified Documentation/admin-guide/sysctl/kernel.rst
| @@ -1416,7 +1416,7 @@ Controls whether userspace may arm Syscall User Dispatch via | |||
| 1416 | 1416 | == =================================================================== | |
| 1417 | 1417 | ||
| 1418 | 1418 | Only present when the kernel is built with ``CONFIG_SYSCALL_USER_DISPATCH`` | |
| 1419 | - | and ``CONFIG_PROC_SYSCTL``. | |
| 1419 | + | and ``CONFIG_SYSCTL``. | |
| 1420 | 1420 | ||
| 1421 | 1421 | ||
| 1422 | 1422 | sysctl_writes_strict | |
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/riscv/hwprobe.rst
| @@ -155,7 +155,8 @@ The following keys are defined: | |||
| 155 | 155 | defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. | |
| 156 | 156 | ||
| 157 | 157 | * :c:macro:`RISCV_HWPROBE_EXT_ZFH`: The Zfh extension version 1.0 is supported | |
| 158 | - | as defined in the RISC-V ISA manual. | |
| 158 | + | as defined in the RISC-V ISA manual. Zfh is a superset of Zfhmin, so | |
| 159 | + | RISCV_HWPROBE_EXT_ZFHMIN is reported whenever RISCV_HWPROBE_EXT_ZFH is. | |
| 159 | 160 | ||
| 160 | 161 | * :c:macro:`RISCV_HWPROBE_EXT_ZFHMIN`: The Zfhmin extension version 1.0 is | |
| 161 | 162 | supported as defined in the RISC-V ISA manual. | |
| @@ -164,8 +165,9 @@ The following keys are defined: | |||
| 164 | 165 | is supported as defined in the RISC-V ISA manual. | |
| 165 | 166 | ||
| 166 | 167 | * :c:macro:`RISCV_HWPROBE_EXT_ZVFH`: The Zvfh extension is supported as | |
| 167 | - | defined in the RISC-V Vector manual starting from commit e2ccd0548d6c | |
| 168 | - | ("Remove draft warnings from Zvfh[min]"). | |
| 168 | + | defined in the RISC-V Vector manual starting from commit e2ccd0548d6c | |
| 169 | + | ("Remove draft warnings from Zvfh[min]"). Zvfh is a superset of Zvfhmin, | |
| 170 | + | so RISCV_HWPROBE_EXT_ZVFHMIN is reported whenever RISCV_HWPROBE_EXT_ZVFH is. | |
| 169 | 171 | ||
| 170 | 172 | * :c:macro:`RISCV_HWPROBE_EXT_ZVFHMIN`: The Zvfhmin extension is supported as | |
| 171 | 173 | defined in the RISC-V Vector manual starting from commit e2ccd0548d6c | |
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/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/regulator/fcs,fan53555.yaml
| @@ -23,6 +23,7 @@ properties: | |||
| 23 | 23 | - silergy,syr827 | |
| 24 | 24 | - silergy,syr828 | |
| 25 | 25 | - tcs,tcs4525 | |
| 26 | + | - tcs,tcs4526 | |
| 26 | 27 | - items: | |
| 27 | 28 | - const: rockchip,rk8601 | |
| 28 | 29 | - const: rockchip,rk8600 | |
modified Documentation/devicetree/bindings/riscv/cpus.yaml
| @@ -117,8 +117,8 @@ properties: | |||
| 117 | 117 | $ref: /schemas/types.yaml#/definitions/uint32 | |
| 118 | 118 | description: | |
| 119 | 119 | VLEN/8, the vector register length in bytes. This property is required on | |
| 120 | - | thead systems where the vector register length is not identical on all harts, or | |
| 121 | - | the vlenb CSR is not available. | |
| 120 | + | thead systems where the vector register length is not identical on all | |
| 121 | + | harts, or the vlenb CSR is not available. | |
| 122 | 122 | ||
| 123 | 123 | # RISC-V has multiple properties for cache op block sizes as the sizes | |
| 124 | 124 | # differ between individual CBO extensions | |
| @@ -151,8 +151,8 @@ anyOf: | |||
| 151 | 151 | - riscv,isa-base | |
| 152 | 152 | ||
| 153 | 153 | dependencies: | |
| 154 | - | riscv,isa-base: [ "riscv,isa-extensions" ] | |
| 155 | - | riscv,isa-extensions: [ "riscv,isa-base" ] | |
| 154 | + | riscv,isa-base: ["riscv,isa-extensions"] | |
| 155 | + | riscv,isa-extensions: ["riscv,isa-base"] | |
| 156 | 156 | ||
| 157 | 157 | required: | |
| 158 | 158 | - interrupt-controller | |
modified Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
| @@ -44,6 +44,21 @@ allOf: | |||
| 44 | 44 | else: | |
| 45 | 45 | properties: | |
| 46 | 46 | starfive,sfc-filter-syscon: false | |
| 47 | + | - if: | |
| 48 | + | properties: | |
| 49 | + | compatible: | |
| 50 | + | contains: | |
| 51 | + | const: ultrarisc,dp1000-spi | |
| 52 | + | then: | |
| 53 | + | properties: | |
| 54 | + | reg: | |
| 55 | + | maxItems: 1 | |
| 56 | + | clocks: | |
| 57 | + | minItems: 2 | |
| 58 | + | clock-names: | |
| 59 | + | minItems: 2 | |
| 60 | + | required: | |
| 61 | + | - clock-names | |
| 47 | 62 | ||
| 48 | 63 | properties: | |
| 49 | 64 | compatible: | |
| @@ -63,6 +78,7 @@ properties: | |||
| 63 | 78 | - mscc,jaguar2-spi | |
| 64 | 79 | - sophgo,sg2042-spi | |
| 65 | 80 | - thead,th1520-spi | |
| 81 | + | - ultrarisc,dp1000-spi | |
| 66 | 82 | - const: snps,dw-apb-ssi | |
| 67 | 83 | - description: Vendor controllers compatible with v1.01a | |
| 68 | 84 | items: | |
modified Documentation/fault-injection/nvme-fault-injection.rst
| @@ -176,3 +176,68 @@ Message from dmesg:: | |||
| 176 | 176 | secondary_startup_64+0xa4/0xb0 | |
| 177 | 177 | nvme nvme0: Could not set queue count (16385) | |
| 178 | 178 | nvme nvme0: IO queues not created | |
| 179 | + | ||
| 180 | + | Example 4: Inject an error into the first write command | |
| 181 | + | ------------------------------------------------------- | |
| 182 | + | ||
| 183 | + | :: | |
| 184 | + | ||
| 185 | + | echo 0x01 > /sys/kernel/debug/nvme0n1/fault_inject/opcode | |
| 186 | + | echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times | |
| 187 | + | echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability | |
| 188 | + | dd if=/dev/zero of=/dev/nvme0n1 oflag=direct bs=512 count=1 | |
| 189 | + | ||
| 190 | + | Expected Result:: | |
| 191 | + | ||
| 192 | + | The first write command sent to nvme0n1 fails | |
| 193 | + | ||
| 194 | + | Message from dmesg:: | |
| 195 | + | ||
| 196 | + | FAULT_INJECTION: forcing a failure. | |
| 197 | + | name fault_inject, interval 1, probability 100, space 0, times 1 | |
| 198 | + | CPU: 4 UID: 0 PID: 0 Comm: swapper/4 Not tainted 7.1.0+ #5 PREEMPT(full) | |
| 199 | + | Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-20240910_120124-localhost 04/01/2014 | |
| 200 | + | Call Trace: | |
| 201 | + | <IRQ> | |
| 202 | + | dump_stack_lvl+0x6e/0xa0 | |
| 203 | + | dump_stack+0x10/0x16 | |
| 204 | + | should_fail_ex+0x461/0x510 | |
| 205 | + | should_fail+0xb/0x20 | |
| 206 | + | nvme_should_fail+0x11b/0x240 [nvme_core] | |
| 207 | + | nvme_poll_cq+0x6ad/0xb30 [nvme] | |
| 208 | + | nvme_irq+0x84/0xe0 [nvme] | |
| 209 | + | ? __pfx_nvme_irq+0x10/0x10 [nvme] | |
| 210 | + | ? rcu_core+0xa40/0xa90 | |
| 211 | + | ? __pfx_sched_balance_softirq+0x10/0x10 | |
| 212 | + | ? debug_smp_processor_id+0x17/0x20 | |
| 213 | + | ? rcu_is_watching+0x13/0xa0 | |
| 214 | + | __handle_irq_event_percpu+0x396/0x610 | |
| 215 | + | handle_irq_event_percpu+0xf/0x90 | |
| 216 | + | handle_irq_event+0xab/0x110 | |
| 217 | + | handle_edge_irq+0x1a3/0x210 | |
| 218 | + | __common_interrupt+0xff/0x170 | |
| 219 | + | common_interrupt+0x90/0xc0 | |
| 220 | + | </IRQ> | |
| 221 | + | <TASK> | |
| 222 | + | asm_common_interrupt+0x27/0x40 | |
| 223 | + | RIP: 0010:pv_native_safe_halt+0x13/0x20 | |
| 224 | + | Code: 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 8b 05 0a 2a 58 01 85 c0 7e 07 0f 00 2d ff cc 0d 00 fb f4 <c3> cc 0 | |
| 225 | + | RSP: 0018:ffff888100a67e40 EFLAGS: 00000242 | |
| 226 | + | RAX: 0000000000000001 RBX: ffff888100a49c40 RCX: ffffed102b6c645b | |
| 227 | + | RDX: ffffed102b6c645b RSI: ffffffff82a0d3c0 RDI: ffffffff81428b9b | |
| 228 | + | RBP: ffff888100a67e48 R08: ffffed102b6c645b R09: 0000000000000004 | |
| 229 | + | R10: ffffed102b6c645a R11: 0000000000000001 R12: 0000000000000000 | |
| 230 | + | R13: 0000000000000000 R14: ffffed1020149388 R15: dffffc0000000000 | |
| 231 | + | ? do_idle+0x19b/0x2c0 | |
| 232 | + | ? default_idle+0x9/0x20 | |
| 233 | + | arch_cpu_idle+0x9/0x10 | |
| 234 | + | default_idle_call+0x6b/0xa0 | |
| 235 | + | do_idle+0x19b/0x2c0 | |
| 236 | + | ? __pfx_do_idle+0x10/0x10 | |
| 237 | + | ? complete_with_flags+0x63/0x70 | |
| 238 | + | cpu_startup_entry+0x55/0x60 | |
| 239 | + | start_secondary+0x1df/0x1e0 | |
| 240 | + | common_startup_64+0x13e/0x158 | |
| 241 | + | </TASK> | |
| 242 | + | nvme0n1: Write(0x1) @ LBA 0, 1 blocks, Invalid Command Opcode (sct 0x0 / sc 0x1) DNR | |
| 243 | + | operation not supported error, dev nvme0n1, sector 0 op 0x1:(WRITE) flags 0x8800 phys_seg 1 prio class 2 | |
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/hwmon/gpd-fan.rst
| @@ -67,7 +67,7 @@ pwm1_enable | |||
| 67 | 67 | at full speed. Write "1" to set to manual, write "2" to let the EC control | |
| 68 | 68 | decide fan speed. Read this attribute to see current status. | |
| 69 | 69 | ||
| 70 | - | NB:In consideration of the safety of the device, when setting to manual mode, | |
| 70 | + | NB: In consideration of the safety of the device, when setting to manual mode, | |
| 71 | 71 | the pwm speed will be set to the maximum value (255) by default. You can set | |
| 72 | 72 | a different value by writing pwm1 later. | |
| 73 | 73 | ||
modified Documentation/hwmon/hwmon-kernel-api.rst
| @@ -42,6 +42,9 @@ register/unregister functions:: | |||
| 42 | 42 | ||
| 43 | 43 | char *devm_hwmon_sanitize_name(struct device *dev, const char *name); | |
| 44 | 44 | ||
| 45 | + | int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type, | |
| 46 | + | u32 attr, int channel); | |
| 47 | + | ||
| 45 | 48 | void hwmon_lock(struct device *dev); | |
| 46 | 49 | void hwmon_unlock(struct device *dev); | |
| 47 | 50 | ||
| @@ -90,6 +93,18 @@ implemented in the driver, or debugfs functions, hwmon_lock() and hwmon_unlock() | |||
| 90 | 93 | can be used to ensure that calls to those functions are serialized. Those | |
| 91 | 94 | functions also support guard() and scoped_guard() variants. | |
| 92 | 95 | ||
| 96 | + | Drivers can call hwmon_notify_event() to notify userspace and the thermal | |
| 97 | + | subsystem when a hardware monitoring event (such as an alarm or a fault | |
| 98 | + | condition) occurs or clears. The parameters are the hwmon device, the sensor | |
| 99 | + | type, the attribute identifier associated with the event (such as | |
| 100 | + | hwmon_temp_max_alarm or hwmon_fan_fault), and the sensor channel number. | |
| 101 | + | hwmon_notify_event() generates a sysfs event (calling sysfs_notify()) and a | |
| 102 | + | udev event with the attribute name passed in the NAME environment property | |
| 103 | + | (e.g., "NAME=temp1_max_alarm"). If the event is for a temperature sensor and | |
| 104 | + | the sensor is attached to a thermal zone, it also notifies the thermal | |
| 105 | + | subsystem to update the thermal zone. hwmon_notify_event() returns 0 on | |
| 106 | + | success or a negative error code on failure. | |
| 107 | + | ||
| 93 | 108 | Using devm_hwmon_device_register_with_info() | |
| 94 | 109 | -------------------------------------------- | |
| 95 | 110 | ||
modified Documentation/netlink/specs/conntrack.yaml
| @@ -360,6 +360,17 @@ attribute-sets: | |||
| 360 | 360 | name: tsoff | |
| 361 | 361 | type: u32 | |
| 362 | 362 | byte-order: big-endian | |
| 363 | + | - | |
| 364 | + | name: filter-attrs | |
| 365 | + | attributes: | |
| 366 | + | - | |
| 367 | + | name: orig-flags | |
| 368 | + | type: u32 | |
| 369 | + | doc: bitmask of tuple fields to filter on, original direction | |
| 370 | + | - | |
| 371 | + | name: reply-flags | |
| 372 | + | type: u32 | |
| 373 | + | doc: bitmask of tuple fields to filter on, reply direction | |
| 363 | 374 | - | |
| 364 | 375 | name: conntrack-attrs | |
| 365 | 376 | attributes: | |
| @@ -466,7 +477,7 @@ attribute-sets: | |||
| 466 | 477 | - | |
| 467 | 478 | name: filter | |
| 468 | 479 | type: nest | |
| 469 | - | nested-attributes: tuple-attrs | |
| 480 | + | nested-attributes: filter-attrs | |
| 470 | 481 | - | |
| 471 | 482 | name: status-mask | |
| 472 | 483 | type: u32 | |
| @@ -591,10 +602,14 @@ operations: | |||
| 591 | 602 | request: | |
| 592 | 603 | value: 0x101 | |
| 593 | 604 | attributes: | |
| 594 | - | - mark | |
| 595 | - | - filter | |
| 605 | + | - tuple-orig | |
| 606 | + | - tuple-reply | |
| 596 | 607 | - status | |
| 608 | + | - mark | |
| 597 | 609 | - zone | |
| 610 | + | - mark-mask | |
| 611 | + | - filter | |
| 612 | + | - status-mask | |
| 598 | 613 | reply: | |
| 599 | 614 | value: 0x100 | |
| 600 | 615 | attributes: | |
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-link.yaml
| @@ -898,6 +898,8 @@ attribute-sets: | |||
| 898 | 898 | - | |
| 899 | 899 | name: txqlen | |
| 900 | 900 | type: u32 | |
| 901 | + | checks: | |
| 902 | + | max: 32767 | |
| 901 | 903 | - | |
| 902 | 904 | name: map | |
| 903 | 905 | type: binary | |
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/scheduler/sched-ext.rst
| @@ -230,7 +230,7 @@ optional. The following modified excerpt is from | |||
| 230 | 230 | ||
| 231 | 231 | void BPF_STRUCT_OPS(simple_exit, struct scx_exit_info *ei) | |
| 232 | 232 | { | |
| 233 | - | exit_type = ei->type; | |
| 233 | + | exit_type = ei->kind; | |
| 234 | 234 | } | |
| 235 | 235 | ||
| 236 | 236 | SEC(".struct_ops") | |
| @@ -242,6 +242,21 @@ optional. The following modified excerpt is from | |||
| 242 | 242 | .name = "simple", | |
| 243 | 243 | }; | |
| 244 | 244 | ||
| 245 | + | Scheduler-Dependent Knobs | |
| 246 | + | ------------------------- | |
| 247 | + | ||
| 248 | + | The fair-class scheduler enforces CPU controller settings such as | |
| 249 | + | ``cpu.max``, ``cpu.weight`` and ``cpu.idle``. For sched_ext tasks, the | |
| 250 | + | scheduler core communicates these settings to the BPF scheduler | |
| 251 | + | through ``ops.cgroup_init()`` and reports subsequent changes through | |
| 252 | + | the corresponding ``ops.cgroup_set_*()`` callbacks. Similarly, per-task | |
| 253 | + | nice changes are converted to weights and reported through | |
| 254 | + | ``ops.set_weight()``. | |
| 255 | + | ||
| 256 | + | Each BPF scheduler is responsible for implementing the scheduling | |
| 257 | + | semantics of these settings and may choose to ignore them. Consult the | |
| 258 | + | loaded scheduler's documentation before relying on these controls. | |
| 259 | + | ||
| 245 | 260 | Dispatch Queues | |
| 246 | 261 | --------------- | |
| 247 | 262 | ||
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 Documentation/translations/zh_CN/arch/riscv/patch-acceptance.rst
| @@ -15,19 +15,41 @@ arch/riscv 开发者维护指南 | |||
| 15 | 15 | ||
| 16 | 16 | 概述 | |
| 17 | 17 | ---- | |
| 18 | - | RISC-V指令集体系结构是公开开发的: | |
| 18 | + | RISC-V 指令集体系结构是公开开发的: | |
| 19 | 19 | 正在进行的草案可供所有人查看和测试实现。新模块或者扩展草案可能会在开发过程中发 | |
| 20 | - | 生更改---有时以不兼容的方式对以前的草案进行更改。这种灵活性可能会给RISC-V Linux | |
| 21 | - | 维护者带来挑战。Linux开发过程更喜欢经过良好检查和测试的代码,而不是试验代码。我 | |
| 22 | - | 们希望推广同样的规则到即将被内核合并的RISC-V相关代码。 | |
| 20 | + | 生更改 --- 有时以不兼容的方式对以前的草案进行更改。这种灵活性可能会给 RISC-V | |
| 21 | + | Linux 维护者带来挑战。Linux 维护者不赞成频繁的变更,且 Linux 开发过程更喜欢经过 | |
| 22 | + | 良好检查和测试的代码,而不是试验代码。我们希望推广同样的规则到即将被内核合并的 | |
| 23 | + | RISC-V 相关代码。 | |
| 24 | + | ||
| 25 | + | Patchwork | |
| 26 | + | --------- | |
| 27 | + | ||
| 28 | + | RISC-V 有一个 patchwork 实例,可以在那里查看补丁的状态: | |
| 29 | + | ||
| 30 | + | https://patchwork.kernel.org/project/linux-riscv/list/ | |
| 31 | + | ||
| 32 | + | 如果你的补丁不在默认视图中出现,那么 RISC-V 维护者很有可能已要求修改,或者希望 | |
| 33 | + | 将其应用到另一个代码树上。 | |
| 34 | + | ||
| 35 | + | 自动化流程会在该 patchwork 实例上运行,在每个补丁到达时立刻对其进行构建/测试。 | |
| 36 | + | 自动化流程会根据补丁是否被识别为修复,选用 RISC-V `for-next` 或 `fixes` 分支 | |
| 37 | + | 当前的 HEAD;若上述均应用失败,则使用 RISC-V `master` 分支。补丁系列被应用到的具 | |
| 38 | + | 体提交将标注在 patchwork 上。任何检查未通过的补丁通常不会被应用,并且在大多数情 | |
| 39 | + | 况下将需要重新提交。 | |
| 23 | 40 | ||
| 24 | 41 | 附加的提交检查单 | |
| 25 | 42 | ---------------- | |
| 26 | - | 我们仅接受相关标准已经被RISC-V基金会标准为“已批准”或“已冻结”的扩展或模块的补丁。 | |
| 27 | - | (开发者当然可以维护自己的Linux内核树,其中包含所需代码扩展草案的代码。) | |
| 28 | - | ||
| 29 | - | 此外,RISC-V规范允许爱好者创建自己的自定义扩展。这些自定义拓展不需要通过RISC-V | |
| 30 | - | 基金会的任何审核或批准。为了避免将爱好者一些特别的RISC-V拓展添加进内核代码带来 | |
| 31 | - | 的维护复杂性和对性能的潜在影响,我们将只接受RISC-V基金会正式冻结或批准的的扩展 | |
| 32 | - | 补丁。(开发者当然可以维护自己的Linux内核树,其中包含他们想要的任何自定义扩展 | |
| 33 | - | 的代码。) | |
| 43 | + | 我们仅接受针对新模块或扩展的补丁,前提是这些模块或扩展的规范被列为未来不太可能发 | |
| 44 | + | 生不兼容的变更。对于来自 RISC-V 基金会的规范,这意味着“已冻结”或“已批准”,对于 | |
| 45 | + | UEFI 论坛的规范,这意味着已发布的 ECR。(开发者当然可以维护自己的 Linux 内核树, | |
| 46 | + | 其中包含他们所需的任何扩展草案的代码。) | |
| 47 | + | ||
| 48 | + | 此外,RISC-V 规范允许实现者创建自己的自定义扩展。这些自定义扩展不需要通过 RISC-V | |
| 49 | + | 基金会的任何审核或批准流程。为了避免因添加实现者特定的 RISC-V 扩展带来的维护复杂 | |
| 50 | + | 性和对性能的潜在影响,我们将只考虑符合以下任一条件的扩展补丁: | |
| 51 | + | ||
| 52 | + | - 已由 RISC-V 基金会正式冻结或批准 | |
| 53 | + | - 已按照标准 Linux 惯例,在广泛可用的硬件中实现 | |
| 54 | + | ||
| 55 | + | (实现者当然可以维护自己的 Linux 内核树,其中包含他们所需的任何自定义扩展的代码。) | |
modified Documentation/translations/zh_CN/core-api/irq/irq-domain.rst
| @@ -90,10 +90,6 @@ irq_domain映射的类型 | |||
| 90 | 90 | 映射的优点是固定时间查找IRQ号,而且irq_descs只分配给在用的IRQ。 缺点是该表 | |
| 91 | 91 | 必须尽可能大的hwirq号。 | |
| 92 | 92 | ||
| 93 | - | irq_domain_add_linear()和irq_domain_create_linear()在功能上是等价的, | |
| 94 | - | 除了第一个参数不同--前者接受一个Open Firmware特定的 'struct device_node' 而 | |
| 95 | - | 后者接受一个更通用的抽象 'struct fwnode_handle' 。 | |
| 96 | - | ||
| 97 | 93 | 大多数驱动应该使用线性映射 | |
| 98 | 94 | ||
| 99 | 95 | 树状映射 | |
modified MAINTAINERS
| @@ -4512,7 +4512,7 @@ AYANEO PLATFORM EC DRIVER | |||
| 4512 | 4512 | M: Antheas Kapenekakis <lkml@antheas.dev> | |
| 4513 | 4513 | L: platform-driver-x86@vger.kernel.org | |
| 4514 | 4514 | S: Maintained | |
| 4515 | - | F: Documentation/ABI/testing/sysfs-platform-ayaneo | |
| 4515 | + | F: Documentation/ABI/testing/sysfs-platform-ayaneo-ec | |
| 4516 | 4516 | F: drivers/platform/x86/ayaneo-ec.c | |
| 4517 | 4517 | ||
| 4518 | 4518 | AZ6007 DVB DRIVER | |
| @@ -5454,6 +5454,7 @@ F: include/linux/brcmphy.h | |||
| 5454 | 5454 | BROADCOM GENET ETHERNET DRIVER | |
| 5455 | 5455 | M: Doug Berger <opendmb@gmail.com> | |
| 5456 | 5456 | M: Florian Fainelli <florian.fainelli@broadcom.com> | |
| 5457 | + | M: Nicolai Buchwitz <nb@tipi-net.de> | |
| 5457 | 5458 | R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com> | |
| 5458 | 5459 | L: netdev@vger.kernel.org | |
| 5459 | 5460 | S: Maintained | |
| @@ -5671,8 +5672,8 @@ W: http://bu3sch.de/btgpio.php | |||
| 5671 | 5672 | F: drivers/gpio/gpio-bt8xx.c | |
| 5672 | 5673 | ||
| 5673 | 5674 | BTRFS FILE SYSTEM | |
| 5674 | - | M: Chris Mason <clm@fb.com> | |
| 5675 | 5675 | M: David Sterba <dsterba@suse.com> | |
| 5676 | + | R: Chris Mason <mason@kernel.org> | |
| 5676 | 5677 | L: linux-btrfs@vger.kernel.org | |
| 5677 | 5678 | S: Maintained | |
| 5678 | 5679 | W: https://btrfs.readthedocs.io | |
| @@ -8039,7 +8040,7 @@ F: drivers/gpu/drm/sun4i/sun8i* | |||
| 8039 | 8040 | ||
| 8040 | 8041 | DRM DRIVER FOR APPLE TOUCH BARS | |
| 8041 | 8042 | M: Aun-Ali Zaidi <admin@kodeit.net> | |
| 8042 | - | M: Aditya Garg <gargaditya08@proton.me> | |
| 8043 | + | M: Aditya Garg <aditya.garg@linux.dev> | |
| 8043 | 8044 | L: dri-devel@lists.freedesktop.org | |
| 8044 | 8045 | S: Maintained | |
| 8045 | 8046 | T: git https://gitlab.freedesktop.org/drm/misc/kernel.git | |
| @@ -9324,6 +9325,7 @@ F: Documentation/devicetree/bindings/interrupt-controller/econet,en751221-intc.y | |||
| 9324 | 9325 | F: Documentation/devicetree/bindings/mips/econet.yaml | |
| 9325 | 9326 | F: Documentation/devicetree/bindings/timer/econet,en751221-timer.yaml | |
| 9326 | 9327 | F: arch/mips/boot/dts/econet/ | |
| 9328 | + | F: arch/mips/configs/econet_en751221_defconfig | |
| 9327 | 9329 | F: arch/mips/econet/ | |
| 9328 | 9330 | F: drivers/clocksource/timer-econet-en751221.c | |
| 9329 | 9331 | F: drivers/irqchip/irq-econet-en751221.c | |
| @@ -9387,9 +9389,8 @@ S: Maintained | |||
| 9387 | 9389 | F: drivers/edac/octeon_edac* | |
| 9388 | 9390 | ||
| 9389 | 9391 | EDAC-CAVIUM THUNDERX | |
| 9390 | - | M: Robert Richter <rric@kernel.org> | |
| 9391 | 9392 | L: linux-edac@vger.kernel.org | |
| 9392 | - | S: Odd Fixes | |
| 9393 | + | S: Orphan | |
| 9393 | 9394 | F: drivers/edac/thunderx_edac* | |
| 9394 | 9395 | ||
| 9395 | 9396 | EDAC-CORE | |
| @@ -9416,9 +9417,8 @@ S: Supported | |||
| 9416 | 9417 | F: drivers/edac/dmc520_edac.c | |
| 9417 | 9418 | ||
| 9418 | 9419 | EDAC-E752X | |
| 9419 | - | M: Mark Gross <markgross@kernel.org> | |
| 9420 | 9420 | L: linux-edac@vger.kernel.org | |
| 9421 | - | S: Maintained | |
| 9421 | + | S: Orphan | |
| 9422 | 9422 | F: drivers/edac/e752x_edac.c | |
| 9423 | 9423 | ||
| 9424 | 9424 | EDAC-E7XXX | |
| @@ -9493,9 +9493,8 @@ S: Maintained | |||
| 9493 | 9493 | F: drivers/edac/igen6_edac.c | |
| 9494 | 9494 | ||
| 9495 | 9495 | EDAC-MPC85XX | |
| 9496 | - | M: Johannes Thumshirn <morbidrsa@gmail.com> | |
| 9497 | 9496 | L: linux-edac@vger.kernel.org | |
| 9498 | - | S: Maintained | |
| 9497 | + | S: Orphan | |
| 9499 | 9498 | F: drivers/edac/mpc85xx_edac.[ch] | |
| 9500 | 9499 | ||
| 9501 | 9500 | EDAC-NPCM | |
| @@ -10193,7 +10192,6 @@ F: include/linux/arm_ffa.h | |||
| 10193 | 10192 | ||
| 10194 | 10193 | FIRMWARE LOADER (request_firmware) | |
| 10195 | 10194 | M: Luis Chamberlain <mcgrof@kernel.org> | |
| 10196 | - | M: Russ Weight <russ.weight@linux.dev> | |
| 10197 | 10195 | M: Danilo Krummrich <dakr@kernel.org> | |
| 10198 | 10196 | L: driver-core@lists.linux.dev | |
| 10199 | 10197 | S: Maintained | |
| @@ -12224,7 +12222,7 @@ F: drivers/tty/hvc/ | |||
| 12224 | 12222 | ||
| 12225 | 12223 | HUNG TASK DETECTOR | |
| 12226 | 12224 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 12227 | - | R: Lance Yang <lance.yang@linux.dev> | |
| 12225 | + | M: Lance Yang <lance.yang@linux.dev> | |
| 12228 | 12226 | R: Masami Hiramatsu <mhiramat@kernel.org> | |
| 12229 | 12227 | R: Petr Mladek <pmladek@suse.com> | |
| 12230 | 12228 | L: linux-kernel@vger.kernel.org | |
| @@ -13283,7 +13281,6 @@ F: drivers/crypto/intel/keembay/ocs-aes.h | |||
| 13283 | 13281 | ||
| 13284 | 13282 | INTEL KEEM BAY OCS ECC CRYPTO DRIVER | |
| 13285 | 13283 | M: Prabhjot Khurana <prabhjot.khurana@intel.com> | |
| 13286 | - | M: Mark Gross <mgross@linux.intel.com> | |
| 13287 | 13284 | S: Maintained | |
| 13288 | 13285 | F: Documentation/devicetree/bindings/crypto/intel,keembay-ocs-ecc.yaml | |
| 13289 | 13286 | F: drivers/crypto/intel/keembay/Kconfig | |
| @@ -14240,8 +14237,6 @@ F: tools/testing/selftests/ | |||
| 14240 | 14237 | KERNEL SMB3 SERVER (KSMBD) | |
| 14241 | 14238 | M: Namjae Jeon <linkinjeon@kernel.org> | |
| 14242 | 14239 | M: Namjae Jeon <linkinjeon@samba.org> | |
| 14243 | - | M: Steve French <smfrench@gmail.com> | |
| 14244 | - | M: Steve French <sfrench@samba.org> | |
| 14245 | 14240 | R: Sergey Senozhatsky <senozhatsky@chromium.org> | |
| 14246 | 14241 | R: Tom Talpey <tom@talpey.com> | |
| 14247 | 14242 | R: ChenXiaoSong <chenxiaosong@chenxiaosong.com> | |
| @@ -14911,7 +14906,7 @@ M: Damien Le Moal <dlemoal@kernel.org> | |||
| 14911 | 14906 | M: Niklas Cassel <cassel@kernel.org> | |
| 14912 | 14907 | L: linux-ide@vger.kernel.org | |
| 14913 | 14908 | S: Maintained | |
| 14914 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux.git | |
| 14909 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux.git for-next | |
| 14915 | 14910 | F: Documentation/ABI/testing/sysfs-ata | |
| 14916 | 14911 | F: Documentation/devicetree/bindings/ata/ | |
| 14917 | 14912 | F: drivers/ata/ | |
| @@ -15027,6 +15022,8 @@ M: Madhavan Srinivasan <maddy@linux.ibm.com> | |||
| 15027 | 15022 | R: Michael Ellerman <mpe@ellerman.id.au> | |
| 15028 | 15023 | R: Nicholas Piggin <npiggin@gmail.com> | |
| 15029 | 15024 | R: Christophe Leroy (CS GROUP) <chleroy@kernel.org> | |
| 15025 | + | R: Ritesh Harjani (IBM) <ritesh.list@gmail.com> | |
| 15026 | + | R: Shrikanth Hegde <sshegde@linux.ibm.com> | |
| 15030 | 15027 | L: linuxppc-dev@lists.ozlabs.org | |
| 15031 | 15028 | S: Supported | |
| 15032 | 15029 | W: https://github.com/linuxppc/wiki/wiki | |
| @@ -17036,8 +17033,8 @@ MEMBLOCK AND MEMORY MANAGEMENT INITIALIZATION | |||
| 17036 | 17033 | M: Mike Rapoport <rppt@kernel.org> | |
| 17037 | 17034 | L: linux-mm@kvack.org | |
| 17038 | 17035 | S: Maintained | |
| 17039 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git for-next | |
| 17040 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git fixes | |
| 17036 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mm/memblock.git for-next | |
| 17037 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mm/memblock.git fixes | |
| 17041 | 17038 | F: Documentation/core-api/boot-time-mm.rst | |
| 17042 | 17039 | F: include/linux/kho/abi/memblock.h | |
| 17043 | 17040 | F: include/linux/memblock.h | |
| @@ -17198,7 +17195,7 @@ F: tools/testing/selftests/mm/gup_test.c | |||
| 17198 | 17195 | MEMORY MANAGEMENT - KSM (Kernel Samepage Merging) | |
| 17199 | 17196 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17200 | 17197 | M: David Hildenbrand <david@kernel.org> | |
| 17201 | - | R: Xu Xin <xu.xin16@zte.com.cn> | |
| 17198 | + | R: Xu Xin <xu.xin@linux.dev> | |
| 17202 | 17199 | R: Chengming Zhou <chengming.zhou@linux.dev> | |
| 17203 | 17200 | L: linux-mm@kvack.org | |
| 17204 | 17201 | S: Maintained | |
| @@ -17246,6 +17243,8 @@ R: Barry Song <baohua@kernel.org> | |||
| 17246 | 17243 | R: Axel Rasmussen <axelrasmussen@google.com> | |
| 17247 | 17244 | R: Yuanchu Xie <yuanchu@google.com> | |
| 17248 | 17245 | R: Wei Xu <weixugc@google.com> | |
| 17246 | + | R: Baoquan He <baoquan.he@linux.dev> | |
| 17247 | + | R: Baolin Wang <baolin.wang@linux.alibaba.com> | |
| 17249 | 17248 | L: linux-mm@kvack.org | |
| 17250 | 17249 | S: Maintained | |
| 17251 | 17250 | W: http://www.linux-mm.org | |
| @@ -17416,7 +17415,6 @@ F: mm/swapfile.c | |||
| 17416 | 17415 | MEMORY MANAGEMENT - THP (TRANSPARENT HUGE PAGE) | |
| 17417 | 17416 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17418 | 17417 | M: David Hildenbrand <david@kernel.org> | |
| 17419 | - | M: Lorenzo Stoakes <ljs@kernel.org> | |
| 17420 | 17418 | R: Zi Yan <ziy@nvidia.com> | |
| 17421 | 17419 | R: Baolin Wang <baolin.wang@linux.alibaba.com> | |
| 17422 | 17420 | R: Liam R. Howlett <liam@infradead.org> | |
| @@ -17426,6 +17424,7 @@ R: Dev Jain <dev.jain@arm.com> | |||
| 17426 | 17424 | R: Barry Song <baohua@kernel.org> | |
| 17427 | 17425 | R: Lance Yang <lance.yang@linux.dev> | |
| 17428 | 17426 | R: Usama Arif <usama.arif@linux.dev> | |
| 17427 | + | R: Kiryl Shutsemau <kas@kernel.org> | |
| 17429 | 17428 | L: linux-mm@kvack.org | |
| 17430 | 17429 | S: Maintained | |
| 17431 | 17430 | W: http://www.linux-mm.org | |
| @@ -17698,7 +17697,7 @@ F: Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml | |||
| 17698 | 17697 | F: drivers/spi/spi-at91-usart.c | |
| 17699 | 17698 | ||
| 17700 | 17699 | MICROCHIP ATSHA204A DRIVER | |
| 17701 | - | M: Thorsten Blum <thorsten.blum@linux.dev> | |
| 17700 | + | M: Thorsten Blum <blum@kernel.org> | |
| 17702 | 17701 | L: linux-crypto@vger.kernel.org | |
| 17703 | 17702 | S: Maintained | |
| 17704 | 17703 | F: drivers/crypto/atmel-sha204a.c | |
| @@ -17722,7 +17721,7 @@ F: Documentation/devicetree/bindings/media/microchip,csi2dc.yaml | |||
| 17722 | 17721 | F: drivers/media/platform/microchip/microchip-csi2dc.c | |
| 17723 | 17722 | ||
| 17724 | 17723 | MICROCHIP ECC DRIVER | |
| 17725 | - | M: Thorsten Blum <thorsten.blum@linux.dev> | |
| 17724 | + | M: Thorsten Blum <blum@kernel.org> | |
| 17726 | 17725 | L: linux-crypto@vger.kernel.org | |
| 17727 | 17726 | S: Maintained | |
| 17728 | 17727 | F: drivers/crypto/atmel-ecc.c | |
| @@ -19569,7 +19568,7 @@ F: include/linux/platform_data/x86/nvidia-wmi-ec-backlight.h | |||
| 19569 | 19568 | ||
| 19570 | 19569 | NVM EXPRESS DRIVER | |
| 19571 | 19570 | M: Keith Busch <kbusch@kernel.org> | |
| 19572 | - | M: Jens Axboe <axboe@fb.com> | |
| 19571 | + | M: Jens Axboe <axboe@kernel.dk> | |
| 19573 | 19572 | M: Christoph Hellwig <hch@lst.de> | |
| 19574 | 19573 | M: Sagi Grimberg <sagi@grimberg.me> | |
| 19575 | 19574 | L: linux-nvme@lists.infradead.org | |
| @@ -24778,7 +24777,7 @@ K: \bsecurity_[a-z_0-9]\+\b | |||
| 24778 | 24777 | SELINUX SECURITY MODULE | |
| 24779 | 24778 | M: Paul Moore <paul@paul-moore.com> | |
| 24780 | 24779 | M: Stephen Smalley <stephen.smalley.work@gmail.com> | |
| 24781 | - | R: Ondrej Mosnacek <omosnace@redhat.com> | |
| 24780 | + | R: Ondrej Mosnáček <omosnacek@gmail.com> | |
| 24782 | 24781 | L: selinux@vger.kernel.org | |
| 24783 | 24782 | S: Supported | |
| 24784 | 24783 | W: https://github.com/SELinuxProject | |
| @@ -25236,10 +25235,9 @@ F: Documentation/admin-guide/LSM/Smack.rst | |||
| 25236 | 25235 | F: security/smack/ | |
| 25237 | 25236 | ||
| 25238 | 25237 | SMBDIRECT (RDMA Stream Transport with Read/Write-Offload, MS-SMBD) | |
| 25239 | - | M: Steve French <smfrench@gmail.com> | |
| 25240 | - | M: Steve French <sfrench@samba.org> | |
| 25241 | 25238 | M: Namjae Jeon <linkinjeon@kernel.org> | |
| 25242 | 25239 | M: Namjae Jeon <linkinjeon@samba.org> | |
| 25240 | + | M: Paulo Alcantara <pc@manguebit.org> | |
| 25243 | 25241 | R: Stefan Metzmacher <metze@samba.org> | |
| 25244 | 25242 | R: Tom Talpey <tom@talpey.com> | |
| 25245 | 25243 | L: linux-cifs@vger.kernel.org | |
| @@ -25342,8 +25340,8 @@ F: Documentation/networking/timestamping.rst | |||
| 25342 | 25340 | F: include/linux/net_tstamp.h | |
| 25343 | 25341 | F: include/uapi/linux/net_tstamp.h | |
| 25344 | 25342 | F: tools/testing/selftests/bpf/*/net_timestamping* | |
| 25343 | + | F: tools/testing/selftests/drivers/net/so_txtime.* | |
| 25345 | 25344 | F: tools/testing/selftests/net/*timestamp* | |
| 25346 | - | F: tools/testing/selftests/net/so_txtime.c | |
| 25347 | 25345 | ||
| 25348 | 25346 | SOEKRIS NET48XX LED SUPPORT | |
| 25349 | 25347 | M: Chris Boot <bootc@bootc.net> | |
| @@ -25410,7 +25408,7 @@ F: drivers/md/md* | |||
| 25410 | 25408 | F: drivers/md/raid* | |
| 25411 | 25409 | F: include/linux/raid/ | |
| 25412 | 25410 | F: include/uapi/linux/raid/ | |
| 25413 | - | F: lib/raid/raid6/ | |
| 25411 | + | F: lib/raid/ | |
| 25414 | 25412 | ||
| 25415 | 25413 | SOLIDRUN CLEARFOG SUPPORT | |
| 25416 | 25414 | M: Russell King <linux@armlinux.org.uk> | |
| @@ -26954,8 +26952,7 @@ S: Maintained | |||
| 26954 | 26952 | F: drivers/net/ethernet/tehuti/tn40* | |
| 26955 | 26953 | ||
| 26956 | 26954 | TELECOM CLOCK DRIVER FOR MCPL0010 | |
| 26957 | - | M: Mark Gross <markgross@kernel.org> | |
| 26958 | - | S: Supported | |
| 26955 | + | S: Orphan | |
| 26959 | 26956 | F: drivers/char/tlclk.c | |
| 26960 | 26957 | ||
| 26961 | 26958 | TEMPO SEMICONDUCTOR DRIVERS | |
| @@ -28616,7 +28613,6 @@ L: iommu@lists.linux.dev | |||
| 28616 | 28613 | S: Maintained | |
| 28617 | 28614 | F: Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml | |
| 28618 | 28615 | F: drivers/iommu/vsi-iommu.c | |
| 28619 | - | F: include/linux/vsi-iommu.h | |
| 28620 | 28616 | ||
| 28621 | 28617 | VF610 NAND DRIVER | |
| 28622 | 28618 | M: Stefan Agner <stefan@agner.ch> | |
| @@ -28876,8 +28872,8 @@ F: include/uapi/linux/virtio_console.h | |||
| 28876 | 28872 | VIRTIO CORE | |
| 28877 | 28873 | M: "Michael S. Tsirkin" <mst@redhat.com> | |
| 28878 | 28874 | M: Jason Wang <jasowangio@gmail.com> | |
| 28875 | + | M: Eugenio Pérez <eperezma@redhat.com> | |
| 28879 | 28876 | R: Xuan Zhuo <xuanzhuo@linux.alibaba.com> | |
| 28880 | - | R: Eugenio Pérez <eperezma@redhat.com> | |
| 28881 | 28877 | L: virtualization@lists.linux.dev | |
| 28882 | 28878 | S: Maintained | |
| 28883 | 28879 | F: Documentation/ABI/testing/sysfs-bus-vdpa | |
| @@ -28954,7 +28950,7 @@ F: include/uapi/linux/virtio_gpu.h | |||
| 28954 | 28950 | VIRTIO HOST (VHOST) | |
| 28955 | 28951 | M: "Michael S. Tsirkin" <mst@redhat.com> | |
| 28956 | 28952 | M: Jason Wang <jasowangio@gmail.com> | |
| 28957 | - | R: Eugenio Pérez <eperezma@redhat.com> | |
| 28953 | + | M: Eugenio Pérez <eperezma@redhat.com> | |
| 28958 | 28954 | L: kvm@vger.kernel.org | |
| 28959 | 28955 | L: virtualization@lists.linux.dev | |
| 28960 | 28956 | L: netdev@vger.kernel.org | |
| @@ -29009,8 +29005,8 @@ F: include/uapi/linux/virtio_mem.h | |||
| 29009 | 29005 | VIRTIO NET DRIVER | |
| 29010 | 29006 | M: "Michael S. Tsirkin" <mst@redhat.com> | |
| 29011 | 29007 | M: Jason Wang <jasowangio@gmail.com> | |
| 29008 | + | M: Eugenio Pérez <eperezma@redhat.com> | |
| 29012 | 29009 | R: Xuan Zhuo <xuanzhuo@linux.alibaba.com> | |
| 29013 | - | R: Eugenio Pérez <eperezma@redhat.com> | |
| 29014 | 29010 | L: netdev@vger.kernel.org | |
| 29015 | 29011 | L: virtualization@lists.linux.dev | |
| 29016 | 29012 | S: Maintained | |
| @@ -29026,6 +29022,13 @@ S: Maintained | |||
| 29026 | 29022 | F: drivers/nvdimm/nd_virtio.c | |
| 29027 | 29023 | F: drivers/nvdimm/virtio_pmem.c | |
| 29028 | 29024 | ||
| 29025 | + | VIRTIO RNG DRIVER | |
| 29026 | + | M: Laurent Vivier <lvivier@redhat.com> | |
| 29027 | + | L: virtualization@lists.linux.dev | |
| 29028 | + | S: Maintained | |
| 29029 | + | F: drivers/char/hw_random/virtio-rng.c | |
| 29030 | + | F: include/uapi/linux/virtio_rng.h | |
| 29031 | + | ||
| 29029 | 29032 | VIRTIO RTC DRIVER | |
| 29030 | 29033 | M: Peter Hilber <peter.hilber@oss.qualcomm.com> | |
| 29031 | 29034 | L: virtualization@lists.linux.dev | |
| @@ -29357,7 +29360,7 @@ M: Guenter Roeck <linux@roeck-us.net> | |||
| 29357 | 29360 | L: linux-watchdog@vger.kernel.org | |
| 29358 | 29361 | S: Maintained | |
| 29359 | 29362 | W: http://www.linux-watchdog.org/ | |
| 29360 | - | T: git git://www.linux-watchdog.org/linux-watchdog.git | |
| 29363 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git | |
| 29361 | 29364 | F: Documentation/devicetree/bindings/watchdog/ | |
| 29362 | 29365 | F: Documentation/watchdog/ | |
| 29363 | 29366 | F: drivers/watchdog/ | |
| @@ -29937,12 +29940,14 @@ F: include/uapi/linux/xilinx-v4l2-controls.h | |||
| 29937 | 29940 | XILINX VERSAL EDAC DRIVER | |
| 29938 | 29941 | M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com> | |
| 29939 | 29942 | M: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com> | |
| 29943 | + | R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> | |
| 29940 | 29944 | S: Maintained | |
| 29941 | 29945 | F: Documentation/devicetree/bindings/memory-controllers/xlnx,versal-ddrmc-edac.yaml | |
| 29942 | 29946 | F: drivers/edac/versal_edac.c | |
| 29943 | 29947 | ||
| 29944 | 29948 | XILINX VERSALNET EDAC DRIVER | |
| 29945 | 29949 | M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com> | |
| 29950 | + | R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> | |
| 29946 | 29951 | S: Maintained | |
| 29947 | 29952 | F: Documentation/devicetree/bindings/memory-controllers/xlnx,versal-net-ddrmc5.yaml | |
| 29948 | 29953 | F: drivers/edac/versalnet_edac.c | |
| @@ -29988,6 +29993,7 @@ F: include/dt-bindings/dma/xlnx-zynqmp-dpdma.h | |||
| 29988 | 29993 | XILINX ZYNQMP OCM EDAC DRIVER | |
| 29989 | 29994 | M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com> | |
| 29990 | 29995 | M: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com> | |
| 29996 | + | R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> | |
| 29991 | 29997 | S: Maintained | |
| 29992 | 29998 | F: Documentation/devicetree/bindings/memory-controllers/xlnx,zynqmp-ocmc-1.0.yaml | |
| 29993 | 29999 | F: drivers/edac/zynqmp_edac.c | |
modified Makefile
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | VERSION = 7 | |
| 3 | 3 | PATCHLEVEL = 3 | |
| 4 | 4 | SUBLEVEL = 0 | |
| 5 | - | EXTRAVERSION = -rc1 | |
| 5 | + | EXTRAVERSION = -rc5 | |
| 6 | 6 | NAME = Baby Opossum Posse | |
| 7 | 7 | ||
| 8 | 8 | # *DOCUMENTATION* | |
modified arch/arm/configs/sama5_defconfig
| @@ -69,8 +69,8 @@ CONFIG_BLK_DEV_SD=y | |||
| 69 | 69 | # CONFIG_BLK_DEV_BSG is not set | |
| 70 | 70 | # CONFIG_SCSI_LOWLEVEL is not set | |
| 71 | 71 | CONFIG_NETDEVICES=y | |
| 72 | - | CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON=m | |
| 73 | - | CONFIG_NET_DSA_MICROCHIP_KSZ_SPI=m | |
| 72 | + | CONFIG_NET_DSA_MICROCHIP_KSZ9477=m | |
| 73 | + | CONFIG_NET_DSA_MICROCHIP_KSZ9477_SPI=m | |
| 74 | 74 | # CONFIG_NET_VENDOR_BROADCOM is not set | |
| 75 | 75 | CONFIG_MACB=y | |
| 76 | 76 | # CONFIG_NET_VENDOR_CIRRUS is not set | |
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/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/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/crypto/aes-neonbs-glue.c
| @@ -66,7 +66,7 @@ static int aesbs_setkey(struct crypto_skcipher *tfm, const u8 *in_key, | |||
| 66 | 66 | struct crypto_aes_ctx *rk; | |
| 67 | 67 | int err; | |
| 68 | 68 | ||
| 69 | - | rk = kmalloc(sizeof(*rk), GFP_KERNEL); | |
| 69 | + | rk = kmalloc_obj(*rk); | |
| 70 | 70 | if (!rk) | |
| 71 | 71 | return -ENOMEM; | |
| 72 | 72 | ||
| @@ -128,7 +128,7 @@ static int aesbs_cbc_ctr_setkey(struct crypto_skcipher *tfm, const u8 *in_key, | |||
| 128 | 128 | struct crypto_aes_ctx *rk; | |
| 129 | 129 | int err; | |
| 130 | 130 | ||
| 131 | - | rk = kmalloc(sizeof(*rk), GFP_KERNEL); | |
| 131 | + | rk = kmalloc_obj(*rk); | |
| 132 | 132 | if (!rk) | |
| 133 | 133 | return -ENOMEM; | |
| 134 | 134 | ||
modified arch/arm64/include/asm/cpu.h
| @@ -78,5 +78,6 @@ void __init cpuinfo_store_boot_cpu(void); | |||
| 78 | 78 | void __init init_cpu_features(struct cpuinfo_arm64 *info); | |
| 79 | 79 | void update_cpu_features(int cpu, struct cpuinfo_arm64 *info, | |
| 80 | 80 | struct cpuinfo_arm64 *boot); | |
| 81 | + | bool gmid_el1_accessible(const struct cpuinfo_arm64 *info); | |
| 81 | 82 | ||
| 82 | 83 | #endif /* __ASM_CPU_H */ | |
modified arch/arm64/include/asm/cpufeature.h
| @@ -627,13 +627,6 @@ static inline bool id_aa64pfr1_mpamfrac(u64 pfr1) | |||
| 627 | 627 | return val > 0; | |
| 628 | 628 | } | |
| 629 | 629 | ||
| 630 | - | static inline bool id_aa64pfr1_mte(u64 pfr1) | |
| 631 | - | { | |
| 632 | - | u32 val = cpuid_feature_extract_unsigned_field(pfr1, ID_AA64PFR1_EL1_MTE_SHIFT); | |
| 633 | - | ||
| 634 | - | return val >= ID_AA64PFR1_EL1_MTE_MTE2; | |
| 635 | - | } | |
| 636 | - | ||
| 637 | 630 | void __init setup_boot_cpu_features(void); | |
| 638 | 631 | void __init setup_system_features(void); | |
| 639 | 632 | void __init setup_user_features(void); | |
modified arch/arm64/include/asm/el2_setup.h
| @@ -418,6 +418,7 @@ | |||
| 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 | 424 | cmp x1, #ID_AA64DFR0_EL1_PMUVer_V3P9 | |
| @@ -426,6 +427,11 @@ | |||
| 426 | 427 | orr x0, x0, #HDFGRTR2_EL2_nPMICNTR_EL0 | |
| 427 | 428 | orr x0, x0, #HDFGRTR2_EL2_nPMICFILTR_EL0 | |
| 428 | 429 | orr x0, x0, #HDFGRTR2_EL2_nPMUACR_EL1 | |
| 430 | + | orr x2, x2, #HDFGWTR2_EL2_nPMICNTR_EL0 | |
| 431 | + | orr x2, x2, #HDFGWTR2_EL2_nPMICFILTR_EL0 | |
| 432 | + | orr x2, x2, #HDFGWTR2_EL2_nPMUACR_EL1 | |
| 433 | + | /* PMZR_EL0 is write-only, so it has no read trap to disable */ | |
| 434 | + | orr x2, x2, #HDFGWTR2_EL2_nPMZR_EL0 | |
| 429 | 435 | .Lskip_pmuv3p9_\@: | |
| 430 | 436 | /* If SPE is implemented, */ | |
| 431 | 437 | __spe_vers_imp .Lskip_spefds_\@, ID_AA64DFR0_EL1_PMSVer_IMP, x1 | |
| @@ -436,10 +442,11 @@ | |||
| 436 | 442 | cbz x1, .Lskip_spefds_\@ | |
| 437 | 443 | /* disable traps of PMSDSFR to EL2. */ | |
| 438 | 444 | orr x0, x0, #HDFGRTR2_EL2_nPMSDSFR_EL1 | |
| 445 | + | orr x2, x2, #HDFGWTR2_EL2_nPMSDSFR_EL1 | |
| 439 | 446 | ||
| 440 | 447 | .Lskip_spefds_\@: | |
| 441 | 448 | msr_s SYS_HDFGRTR2_EL2, x0 | |
| 442 | - | msr_s SYS_HDFGWTR2_EL2, x0 | |
| 449 | + | msr_s SYS_HDFGWTR2_EL2, x2 | |
| 443 | 450 | msr_s SYS_HFGRTR2_EL2, xzr | |
| 444 | 451 | msr_s SYS_HFGWTR2_EL2, xzr | |
| 445 | 452 | 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/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; | |
| @@ -82,7 +85,7 @@ is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope) | |||
| 82 | 85 | ||
| 83 | 86 | for (i = 0; i < target_impl_cpu_num; i++) { | |
| 84 | 87 | if (__is_affected_midr_range(entry, target_impl_cpus[i].midr, | |
| 85 | - | target_impl_cpus[i].midr)) | |
| 88 | + | target_impl_cpus[i].revidr)) | |
| 86 | 89 | return true; | |
| 87 | 90 | } | |
| 88 | 91 | return false; | |
modified arch/arm64/kernel/cpufeature.c
| @@ -1178,6 +1178,33 @@ static bool detect_ftr_has_mpam(void) | |||
| 1178 | 1178 | return id_aa64pfr0_mpam(pfr0) || id_aa64pfr1_mpamfrac(pfr1); | |
| 1179 | 1179 | } | |
| 1180 | 1180 | ||
| 1181 | + | bool gmid_el1_accessible(const struct cpuinfo_arm64 *info) | |
| 1182 | + | { | |
| 1183 | + | const struct arm64_ftr_bits *ftrp; | |
| 1184 | + | s64 mte, ovr; | |
| 1185 | + | u64 ftr_mask; | |
| 1186 | + | ||
| 1187 | + | /* No ID register reflects CONFIG_ARM64_MTE. */ | |
| 1188 | + | if (!IS_ENABLED(CONFIG_ARM64_MTE)) | |
| 1189 | + | return false; | |
| 1190 | + | ||
| 1191 | + | for (ftrp = ftr_id_aa64pfr1; ftrp->width; ftrp++) { | |
| 1192 | + | if (ftrp->shift == ID_AA64PFR1_EL1_MTE_SHIFT) | |
| 1193 | + | break; | |
| 1194 | + | } | |
| 1195 | + | ||
| 1196 | + | ftr_mask = arm64_ftr_mask(ftrp); | |
| 1197 | + | mte = arm64_ftr_value(ftrp, info->reg_id_aa64pfr1); | |
| 1198 | + | ||
| 1199 | + | /* The boot CPU runs before init_cpu_ftr_reg() strips unsafe overrides. */ | |
| 1200 | + | if ((id_aa64pfr1_override.mask & ftr_mask) == ftr_mask) { | |
| 1201 | + | ovr = arm64_ftr_value(ftrp, id_aa64pfr1_override.val); | |
| 1202 | + | mte = arm64_ftr_safe_value(ftrp, ovr, mte); | |
| 1203 | + | } | |
| 1204 | + | ||
| 1205 | + | return mte >= ID_AA64PFR1_EL1_MTE_MTE2; | |
| 1206 | + | } | |
| 1207 | + | ||
| 1181 | 1208 | void __init init_cpu_features(struct cpuinfo_arm64 *info) | |
| 1182 | 1209 | { | |
| 1183 | 1210 | /* Before we start using the tables, make sure it is sorted */ | |
| @@ -1230,7 +1257,7 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info) | |||
| 1230 | 1257 | init_cpu_ftr_reg(SYS_MPAMIDR_EL1, info->reg_mpamidr); | |
| 1231 | 1258 | } | |
| 1232 | 1259 | ||
| 1233 | - | if (id_aa64pfr1_mte(info->reg_id_aa64pfr1)) | |
| 1260 | + | if (gmid_el1_accessible(info)) | |
| 1234 | 1261 | init_cpu_ftr_reg(SYS_GMID_EL1, info->reg_gmid); | |
| 1235 | 1262 | } | |
| 1236 | 1263 | ||
| @@ -1492,11 +1519,9 @@ void update_cpu_features(int cpu, | |||
| 1492 | 1519 | * they read/write depends on the GMID_EL1.BS field. Check that the | |
| 1493 | 1520 | * value is the same on all CPUs. | |
| 1494 | 1521 | */ | |
| 1495 | - | if (IS_ENABLED(CONFIG_ARM64_MTE) && | |
| 1496 | - | id_aa64pfr1_mte(info->reg_id_aa64pfr1)) { | |
| 1522 | + | if (gmid_el1_accessible(info)) | |
| 1497 | 1523 | taint |= check_update_ftr_reg(SYS_GMID_EL1, cpu, | |
| 1498 | 1524 | info->reg_gmid, boot->reg_gmid); | |
| 1499 | - | } | |
| 1500 | 1525 | ||
| 1501 | 1526 | /* | |
| 1502 | 1527 | * If we don't have AArch32 at all then skip the checks entirely | |
modified arch/arm64/kernel/cpuinfo.c
| @@ -502,7 +502,7 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info) | |||
| 502 | 502 | info->reg_id_aa64smfr0 = read_cpuid(ID_AA64SMFR0_EL1); | |
| 503 | 503 | info->reg_id_aa64fpfr0 = read_cpuid(ID_AA64FPFR0_EL1); | |
| 504 | 504 | ||
| 505 | - | if (id_aa64pfr1_mte(info->reg_id_aa64pfr1)) | |
| 505 | + | if (gmid_el1_accessible(info)) | |
| 506 | 506 | info->reg_gmid = read_cpuid(GMID_EL1); | |
| 507 | 507 | ||
| 508 | 508 | if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0)) | |
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/machine_kexec.c
| @@ -129,7 +129,8 @@ int machine_kexec_post_load(struct kimage *kimage) | |||
| 129 | 129 | } | |
| 130 | 130 | ||
| 131 | 131 | /* Create a copy of the linear map */ | |
| 132 | - | rc = trans_pgd_create_copy(&info, &trans_pgd, PAGE_OFFSET, PAGE_END); | |
| 132 | + | rc = trans_pgd_create_copy(&info, &trans_pgd, | |
| 133 | + | _PAGE_OFFSET(vabits_actual), PAGE_END); | |
| 133 | 134 | if (rc) | |
| 134 | 135 | return rc; | |
| 135 | 136 | kimage->arch.ttbr1 = __pa(trans_pgd); | |
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/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), | |
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/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
| @@ -360,7 +360,7 @@ static void pkvm_init_features_from_host(struct pkvm_hyp_vm *hyp_vm, const struc | |||
| 360 | 360 | if (test_bit(KVM_ARCH_FLAG_WRITABLE_IMP_ID_REGS, &host_arch_flags)) | |
| 361 | 361 | hyp_vm->kvm.arch.midr_el1 = host_kvm->arch.midr_el1; | |
| 362 | 362 | ||
| 363 | - | return; | |
| 363 | + | goto out; | |
| 364 | 364 | } | |
| 365 | 365 | ||
| 366 | 366 | if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_MTE)) | |
| @@ -379,13 +379,14 @@ static void pkvm_init_features_from_host(struct pkvm_hyp_vm *hyp_vm, const struc | |||
| 379 | 379 | if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC)) | |
| 380 | 380 | set_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, allowed_features); | |
| 381 | 381 | ||
| 382 | - | if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_SVE)) { | |
| 382 | + | if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_SVE)) | |
| 383 | 383 | set_bit(KVM_ARM_VCPU_SVE, allowed_features); | |
| 384 | - | kvm->arch.flags |= host_arch_flags & BIT(KVM_ARCH_FLAG_GUEST_HAS_SVE); | |
| 385 | - | } | |
| 386 | 384 | ||
| 387 | 385 | bitmap_and(kvm->arch.vcpu_features, host_kvm->arch.vcpu_features, | |
| 388 | 386 | allowed_features, KVM_VCPU_MAX_FEATURES); | |
| 387 | + | out: | |
| 388 | + | __assign_bit(KVM_ARCH_FLAG_GUEST_HAS_SVE, &kvm->arch.flags, | |
| 389 | + | kvm_vcpu_has_feature(kvm, KVM_ARM_VCPU_SVE)); | |
| 389 | 390 | } | |
| 390 | 391 | ||
| 391 | 392 | static void unpin_host_vcpu(struct kvm_vcpu *host_vcpu) | |
| @@ -398,10 +399,10 @@ static void unpin_host_sve_state(struct pkvm_hyp_vcpu *hyp_vcpu) | |||
| 398 | 399 | { | |
| 399 | 400 | void *sve_state; | |
| 400 | 401 | ||
| 401 | - | if (!vcpu_has_feature(&hyp_vcpu->vcpu, KVM_ARM_VCPU_SVE)) | |
| 402 | + | sve_state = hyp_vcpu->vcpu.arch.sve_state; | |
| 403 | + | if (!sve_state) | |
| 402 | 404 | return; | |
| 403 | 405 | ||
| 404 | - | sve_state = hyp_vcpu->vcpu.arch.sve_state; | |
| 405 | 406 | hyp_unpin_shared_mem(sve_state, | |
| 406 | 407 | sve_state + vcpu_sve_state_size(&hyp_vcpu->vcpu)); | |
| 407 | 408 | } | |
| @@ -450,7 +451,7 @@ static int pkvm_vcpu_init_sve(struct pkvm_hyp_vcpu *hyp_vcpu, struct kvm_vcpu *h | |||
| 450 | 451 | unsigned int sve_max_vl; | |
| 451 | 452 | size_t sve_state_size; | |
| 452 | 453 | void *sve_state; | |
| 453 | - | int ret = 0; | |
| 454 | + | int ret; | |
| 454 | 455 | ||
| 455 | 456 | if (!vcpu_has_feature(vcpu, KVM_ARM_VCPU_SVE)) { | |
| 456 | 457 | vcpu_clear_flag(vcpu, VCPU_SVE_FINALIZED); | |
| @@ -459,25 +460,21 @@ static int pkvm_vcpu_init_sve(struct pkvm_hyp_vcpu *hyp_vcpu, struct kvm_vcpu *h | |||
| 459 | 460 | ||
| 460 | 461 | /* Limit guest vector length to the maximum supported by the host. */ | |
| 461 | 462 | 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 | 463 | sve_state = kern_hyp_va(READ_ONCE(host_vcpu->arch.sve_state)); | |
| 464 | 464 | ||
| 465 | - | if (!sve_state || !sve_state_size) { | |
| 466 | - | ret = -EINVAL; | |
| 467 | - | goto err; | |
| 468 | - | } | |
| 465 | + | if (!sve_vl_valid(sve_max_vl) || !sve_state) | |
| 466 | + | return -EINVAL; | |
| 467 | + | ||
| 468 | + | sve_state_size = sve_state_size_from_vl(sve_max_vl); | |
| 469 | 469 | ||
| 470 | 470 | ret = hyp_pin_shared_mem(sve_state, sve_state + sve_state_size); | |
| 471 | 471 | if (ret) | |
| 472 | - | goto err; | |
| 472 | + | return ret; | |
| 473 | 473 | ||
| 474 | 474 | vcpu->arch.sve_state = sve_state; | |
| 475 | 475 | vcpu->arch.sve_max_vl = sve_max_vl; | |
| 476 | 476 | ||
| 477 | 477 | return 0; | |
| 478 | - | err: | |
| 479 | - | clear_bit(KVM_ARM_VCPU_SVE, vcpu->kvm->arch.vcpu_features); | |
| 480 | - | return ret; | |
| 481 | 478 | } | |
| 482 | 479 | ||
| 483 | 480 | 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; | |
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 = kvcalloc(num_mmus, sizeof(*tmp), 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-its.c
| @@ -1658,7 +1658,7 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm, | |||
| 1658 | 1658 | unsigned long val) | |
| 1659 | 1659 | { | |
| 1660 | 1660 | const struct vgic_its_abi *abi = vgic_its_get_abi(its); | |
| 1661 | - | u64 entry_size, table_type; | |
| 1661 | + | u64 old, entry_size, table_type; | |
| 1662 | 1662 | u64 reg, *regptr, clearbits = 0; | |
| 1663 | 1663 | ||
| 1664 | 1664 | /* When GITS_CTLR.Enable is 1, we ignore write accesses. */ | |
| @@ -1681,7 +1681,9 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm, | |||
| 1681 | 1681 | return; | |
| 1682 | 1682 | } | |
| 1683 | 1683 | ||
| 1684 | - | reg = update_64bit_reg(*regptr, addr & 7, len, val); | |
| 1684 | + | old = *regptr; | |
| 1685 | + | ||
| 1686 | + | reg = update_64bit_reg(old, addr & 7, len, val); | |
| 1685 | 1687 | reg &= ~GITS_BASER_RO_MASK; | |
| 1686 | 1688 | reg &= ~clearbits; | |
| 1687 | 1689 | ||
| @@ -1691,7 +1693,8 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm, | |||
| 1691 | 1693 | ||
| 1692 | 1694 | *regptr = reg; | |
| 1693 | 1695 | ||
| 1694 | - | if (!(reg & GITS_BASER_VALID)) { | |
| 1696 | + | /* The ITS driver rewrites an unchanged GITS_BASER<n> on resume. */ | |
| 1697 | + | if (reg != old) { | |
| 1695 | 1698 | /* Take the its_lock to prevent a race with a save/restore */ | |
| 1696 | 1699 | mutex_lock(&its->its_lock); | |
| 1697 | 1700 | switch (table_type) { | |
| @@ -1702,6 +1705,8 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm, | |||
| 1702 | 1705 | vgic_its_free_collection_list(kvm, its); | |
| 1703 | 1706 | break; | |
| 1704 | 1707 | } | |
| 1708 | + | /* A concurrent injection may have cached a translation. */ | |
| 1709 | + | vgic_its_invalidate_cache(its); | |
| 1705 | 1710 | mutex_unlock(&its->its_lock); | |
| 1706 | 1711 | } | |
| 1707 | 1712 | } | |
| @@ -2019,18 +2024,22 @@ out: | |||
| 2019 | 2024 | return ret; | |
| 2020 | 2025 | } | |
| 2021 | 2026 | ||
| 2022 | - | static u32 compute_next_devid_offset(struct list_head *h, | |
| 2027 | + | static u32 compute_next_devid_offset(struct vgic_its *its, u64 baser, | |
| 2023 | 2028 | struct its_device *dev) | |
| 2024 | 2029 | { | |
| 2025 | - | struct its_device *next; | |
| 2026 | - | u32 next_offset; | |
| 2030 | + | struct its_device *next = dev; | |
| 2027 | 2031 | ||
| 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; | |
| 2032 | + | /* | |
| 2033 | + | * Point at the next device vgic_its_save_device_tables() saves. It | |
| 2034 | + | * sorts device_list first, so the subtraction cannot underflow. | |
| 2035 | + | */ | |
| 2036 | + | list_for_each_entry_continue(next, &its->device_list, dev_list) { | |
| 2037 | + | if (vgic_its_check_id(its, baser, next->device_id, NULL)) | |
| 2038 | + | return min_t(u32, next->device_id - dev->device_id, | |
| 2039 | + | VITS_DTE_MAX_DEVID_OFFSET); | |
| 2040 | + | } | |
| 2032 | 2041 | ||
| 2033 | - | return min_t(u32, next_offset, VITS_DTE_MAX_DEVID_OFFSET); | |
| 2042 | + | return 0; | |
| 2034 | 2043 | } | |
| 2035 | 2044 | ||
| 2036 | 2045 | static u32 compute_next_eventid_offset(struct list_head *h, struct its_ite *ite) | |
| @@ -2271,17 +2280,18 @@ static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev) | |||
| 2271 | 2280 | * vgic_its_save_dte - Save a device table entry at a given GPA | |
| 2272 | 2281 | * | |
| 2273 | 2282 | * @its: ITS handle | |
| 2283 | + | * @baser: GITS_BASER<dev> the caller is saving against | |
| 2274 | 2284 | * @dev: ITS device | |
| 2275 | 2285 | * @ptr: GPA | |
| 2276 | 2286 | */ | |
| 2277 | - | static int vgic_its_save_dte(struct vgic_its *its, struct its_device *dev, | |
| 2278 | - | gpa_t ptr) | |
| 2287 | + | static int vgic_its_save_dte(struct vgic_its *its, u64 baser, | |
| 2288 | + | struct its_device *dev, gpa_t ptr) | |
| 2279 | 2289 | { | |
| 2280 | 2290 | u64 val, itt_addr_field; | |
| 2281 | 2291 | u32 next_offset; | |
| 2282 | 2292 | ||
| 2283 | 2293 | itt_addr_field = dev->itt_addr >> 8; | |
| 2284 | - | next_offset = compute_next_devid_offset(&its->device_list, dev); | |
| 2294 | + | next_offset = compute_next_devid_offset(its, baser, dev); | |
| 2285 | 2295 | val = (1ULL << KVM_ITS_DTE_VALID_SHIFT | | |
| 2286 | 2296 | ((u64)next_offset << KVM_ITS_DTE_NEXT_SHIFT) | | |
| 2287 | 2297 | (itt_addr_field << KVM_ITS_DTE_ITTADDR_SHIFT) | | |
| @@ -2380,15 +2390,16 @@ static int vgic_its_save_device_tables(struct vgic_its *its) | |||
| 2380 | 2390 | int ret; | |
| 2381 | 2391 | gpa_t eaddr; | |
| 2382 | 2392 | ||
| 2393 | + | /* Don't fail a save that userspace must be able to issue. */ | |
| 2383 | 2394 | if (!vgic_its_check_id(its, baser, | |
| 2384 | 2395 | dev->device_id, &eaddr)) | |
| 2385 | - | return -EINVAL; | |
| 2396 | + | continue; | |
| 2386 | 2397 | ||
| 2387 | 2398 | ret = vgic_its_save_itt(its, dev); | |
| 2388 | 2399 | if (ret) | |
| 2389 | 2400 | return ret; | |
| 2390 | 2401 | ||
| 2391 | - | ret = vgic_its_save_dte(its, dev, eaddr); | |
| 2402 | + | ret = vgic_its_save_dte(its, baser, dev, eaddr); | |
| 2392 | 2403 | if (ret) | |
| 2393 | 2404 | return ret; | |
| 2394 | 2405 | } | |
| @@ -2541,9 +2552,6 @@ static int vgic_its_save_collection_table(struct vgic_its *its) | |||
| 2541 | 2552 | max_size = GITS_BASER_NR_PAGES(baser) * SZ_64K; | |
| 2542 | 2553 | ||
| 2543 | 2554 | 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 | 2555 | ret = vgic_its_save_cte(its, collection, gpa); | |
| 2548 | 2556 | if (ret) | |
| 2549 | 2557 | return ret; | |
modified arch/arm64/mm/fault.c
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | #include <linux/mm.h> | |
| 17 | 17 | #include <linux/hardirq.h> | |
| 18 | 18 | #include <linux/init.h> | |
| 19 | + | #include <linux/irqflags.h> | |
| 19 | 20 | #include <linux/kasan.h> | |
| 20 | 21 | #include <linux/kprobes.h> | |
| 21 | 22 | #include <linux/uaccess.h> | |
| @@ -154,6 +155,9 @@ static void show_pte(unsigned long addr) | |||
| 154 | 155 | pr_alert("%s pgtable: %luk pages, %llu-bit VAs, pgdp=%016lx\n", | |
| 155 | 156 | mm == &init_mm ? "swapper" : "user", PAGE_SIZE / SZ_1K, | |
| 156 | 157 | vabits_actual, mm_to_pgd_phys(mm)); | |
| 158 | + | ||
| 159 | + | guard(irqsave)(); | |
| 160 | + | ||
| 157 | 161 | pgdp = pgd_offset(mm, addr); | |
| 158 | 162 | pgd = READ_ONCE(*pgdp); | |
| 159 | 163 | pr_alert("[%016lx] pgd=%016llx", addr, pgd_val(pgd)); | |
| @@ -167,25 +171,25 @@ static void show_pte(unsigned long addr) | |||
| 167 | 171 | if (pgd_none(pgd) || pgd_bad(pgd)) | |
| 168 | 172 | break; | |
| 169 | 173 | ||
| 170 | - | p4dp = p4d_offset(pgdp, addr); | |
| 174 | + | p4dp = p4d_offset_lockless(pgdp, pgd, addr); | |
| 171 | 175 | p4d = READ_ONCE(*p4dp); | |
| 172 | 176 | pr_cont(", p4d=%016llx", p4d_val(p4d)); | |
| 173 | 177 | if (p4d_none(p4d) || p4d_bad(p4d)) | |
| 174 | 178 | break; | |
| 175 | 179 | ||
| 176 | - | pudp = pud_offset(p4dp, addr); | |
| 180 | + | pudp = pud_offset_lockless(p4dp, p4d, addr); | |
| 177 | 181 | pud = READ_ONCE(*pudp); | |
| 178 | 182 | pr_cont(", pud=%016llx", pud_val(pud)); | |
| 179 | 183 | if (pud_none(pud) || pud_bad(pud)) | |
| 180 | 184 | break; | |
| 181 | 185 | ||
| 182 | - | pmdp = pmd_offset(pudp, addr); | |
| 186 | + | pmdp = pmd_offset_lockless(pudp, pud, addr); | |
| 183 | 187 | pmd = READ_ONCE(*pmdp); | |
| 184 | 188 | pr_cont(", pmd=%016llx", pmd_val(pmd)); | |
| 185 | 189 | if (pmd_none(pmd) || pmd_bad(pmd)) | |
| 186 | 190 | break; | |
| 187 | 191 | ||
| 188 | - | ptep = pte_offset_map(pmdp, addr); | |
| 192 | + | ptep = pte_offset_map(&pmd, addr); | |
| 189 | 193 | if (!ptep) | |
| 190 | 194 | break; | |
| 191 | 195 | ||
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 */ | |
modified arch/arm64/tools/sysreg
| @@ -3761,7 +3761,9 @@ Sysreg ICC_CR0_EL1 3 1 12 0 1 | |||
| 3761 | 3761 | Res0 63:39 | |
| 3762 | 3762 | Field 38 PID | |
| 3763 | 3763 | Field 37:32 IPPT | |
| 3764 | - | Res0 31:1 | |
| 3764 | + | Res0 31:3 | |
| 3765 | + | Field 2 LINK_IDLE | |
| 3766 | + | Field 1 LINK | |
| 3765 | 3767 | Field 0 EN | |
| 3766 | 3768 | EndSysreg | |
| 3767 | 3769 | ||
modified arch/loongarch/Kconfig
| @@ -175,7 +175,7 @@ config LOONGARCH | |||
| 175 | 175 | select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC | |
| 176 | 176 | select HAVE_RETHOOK | |
| 177 | 177 | select HAVE_RSEQ | |
| 178 | - | select HAVE_RUST | |
| 178 | + | select HAVE_RUST if !KASAN | |
| 179 | 179 | select HAVE_SAMPLE_FTRACE_DIRECT | |
| 180 | 180 | select HAVE_SAMPLE_FTRACE_DIRECT_MULTI | |
| 181 | 181 | select HAVE_SETUP_PER_CPU_AREA if NUMA | |
modified arch/loongarch/include/asm/kvm_dmsintc.h
| @@ -20,6 +20,7 @@ struct dmsintc_state { | |||
| 20 | 20 | }; | |
| 21 | 21 | ||
| 22 | 22 | int kvm_loongarch_register_dmsintc_device(void); | |
| 23 | + | void kvm_loongarch_unregister_dmsintc_device(void); | |
| 23 | 24 | void dmsintc_inject_irq(struct kvm_vcpu *vcpu); | |
| 24 | 25 | int dmsintc_set_irq(struct kvm *kvm, u64 addr, int data, int level); | |
| 25 | 26 | int dmsintc_deliver_msi_to_vcpu(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 vector, int level); | |
modified arch/loongarch/include/asm/kvm_eiointc.h
| @@ -79,6 +79,7 @@ struct loongarch_eiointc { | |||
| 79 | 79 | }; | |
| 80 | 80 | ||
| 81 | 81 | int kvm_loongarch_register_eiointc_device(void); | |
| 82 | + | void kvm_loongarch_unregister_eiointc_device(void); | |
| 82 | 83 | void eiointc_set_irq(struct loongarch_eiointc *s, int irq, int level); | |
| 83 | 84 | ||
| 84 | 85 | #endif /* __ASM_KVM_EIOINTC_H */ | |
modified arch/loongarch/include/asm/kvm_host.h
| @@ -125,6 +125,7 @@ struct kvm_arch { | |||
| 125 | 125 | unsigned int pte_shifts[MAX_PGTABLE_LEVELS]; | |
| 126 | 126 | unsigned int root_level; | |
| 127 | 127 | spinlock_t phyid_map_lock; | |
| 128 | + | spinlock_t pv_setting_lock; | |
| 128 | 129 | struct kvm_phyid_map *phyid_map; | |
| 129 | 130 | /* Enabled PV features */ | |
| 130 | 131 | unsigned long pv_features; | |
| @@ -350,7 +351,6 @@ static inline void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu) {} | |||
| 350 | 351 | static inline void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) {} | |
| 351 | 352 | void kvm_check_vpid(struct kvm_vcpu *vcpu); | |
| 352 | 353 | enum hrtimer_restart kvm_swtimer_wakeup(struct hrtimer *timer); | |
| 353 | - | void kvm_arch_flush_remote_tlbs_memslot(struct kvm *kvm, const struct kvm_memory_slot *memslot); | |
| 354 | 354 | void kvm_init_vmcs(struct kvm *kvm); | |
| 355 | 355 | void kvm_exc_entry(void); | |
| 356 | 356 | int kvm_enter_guest(struct kvm_run *run, struct kvm_vcpu *vcpu); | |
modified arch/loongarch/include/asm/kvm_ipi.h
| @@ -41,5 +41,6 @@ struct ipi_state { | |||
| 41 | 41 | #define IOCSR_ANY_SEND 0x158 | |
| 42 | 42 | ||
| 43 | 43 | int kvm_loongarch_register_ipi_device(void); | |
| 44 | + | void kvm_loongarch_unregister_ipi_device(void); | |
| 44 | 45 | ||
| 45 | 46 | #endif | |
modified arch/loongarch/include/asm/kvm_pch_pic.h
| @@ -70,6 +70,7 @@ struct loongarch_pch_pic { | |||
| 70 | 70 | ||
| 71 | 71 | struct kvm_kernel_irq_routing_entry; | |
| 72 | 72 | int kvm_loongarch_register_pch_pic_device(void); | |
| 73 | + | void kvm_loongarch_unregister_pch_pic_device(void); | |
| 73 | 74 | void pch_pic_set_irq(struct loongarch_pch_pic *s, int irq, int level); | |
| 74 | 75 | int pch_msi_set_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e, int level); | |
| 75 | 76 | ||
modified arch/loongarch/kernel/kprobes.c
| @@ -275,6 +275,9 @@ bool kprobe_singlestep_handler(struct pt_regs *regs) | |||
| 275 | 275 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); | |
| 276 | 276 | unsigned long addr = instruction_pointer(regs); | |
| 277 | 277 | ||
| 278 | + | if (!cur) | |
| 279 | + | return false; | |
| 280 | + | ||
| 278 | 281 | if (cur && (kcb->kprobe_status & (KPROBE_HIT_SS | KPROBE_REENTER)) && | |
| 279 | 282 | ((unsigned long)&cur->ainsn.insn[1] == addr)) { | |
| 280 | 283 | restore_local_irqflag(kcb, regs); | |
modified arch/loongarch/kernel/rethook_trampoline.S
| @@ -24,7 +24,6 @@ | |||
| 24 | 24 | cfi_st t6, PT_R18 | |
| 25 | 25 | cfi_st t7, PT_R19 | |
| 26 | 26 | cfi_st t8, PT_R20 | |
| 27 | - | cfi_st u0, PT_R21 | |
| 28 | 27 | cfi_st fp, PT_R22 | |
| 29 | 28 | cfi_st s0, PT_R23 | |
| 30 | 29 | cfi_st s1, PT_R24 | |
| @@ -59,7 +58,6 @@ | |||
| 59 | 58 | cfi_ld t6, PT_R18 | |
| 60 | 59 | cfi_ld t7, PT_R19 | |
| 61 | 60 | cfi_ld t8, PT_R20 | |
| 62 | - | cfi_ld u0, PT_R21 | |
| 63 | 61 | cfi_ld fp, PT_R22 | |
| 64 | 62 | cfi_ld s0, PT_R23 | |
| 65 | 63 | cfi_ld s1, PT_R24 | |
modified arch/loongarch/kernel/smp.c
| @@ -14,7 +14,6 @@ | |||
| 14 | 14 | #include <linux/init.h> | |
| 15 | 15 | #include <linux/interrupt.h> | |
| 16 | 16 | #include <linux/irq_work.h> | |
| 17 | - | #include <linux/profile.h> | |
| 18 | 17 | #include <linux/seq_file.h> | |
| 19 | 18 | #include <linux/smp.h> | |
| 20 | 19 | #include <linux/threads.h> | |
| @@ -716,13 +715,6 @@ void smp_send_stop(void) | |||
| 716 | 715 | smp_call_function(stop_this_cpu, NULL, 0); | |
| 717 | 716 | } | |
| 718 | 717 | ||
| 719 | - | #ifdef CONFIG_PROFILING | |
| 720 | - | int setup_profiling_timer(unsigned int multiplier) | |
| 721 | - | { | |
| 722 | - | return 0; | |
| 723 | - | } | |
| 724 | - | #endif | |
| 725 | - | ||
| 726 | 718 | static void flush_tlb_all_ipi(void *info) | |
| 727 | 719 | { | |
| 728 | 720 | local_flush_tlb_all(); | |
modified arch/loongarch/kernel/vmlinux.lds.S
| @@ -23,7 +23,7 @@ | |||
| 23 | 23 | #include "image-vars.h" | |
| 24 | 24 | ||
| 25 | 25 | /* | |
| 26 | - | * Max avaliable Page Size is 64K, so we set SectionAlignment | |
| 26 | + | * Max available Page Size is 64K, so we set SectionAlignment | |
| 27 | 27 | * field of EFI application to 64K. | |
| 28 | 28 | */ | |
| 29 | 29 | PECOFF_FILE_ALIGN = 0x200; | |
modified arch/loongarch/kvm/intc/dmsintc.c
| @@ -149,7 +149,7 @@ static int kvm_dmsintc_create(struct kvm_device *dev, u32 type) | |||
| 149 | 149 | return -EINVAL; | |
| 150 | 150 | } | |
| 151 | 151 | ||
| 152 | - | s = kzalloc(sizeof(struct loongarch_dmsintc), GFP_KERNEL); | |
| 152 | + | s = kzalloc_obj(struct loongarch_dmsintc); | |
| 153 | 153 | if (!s) | |
| 154 | 154 | return -ENOMEM; | |
| 155 | 155 | ||
| @@ -180,3 +180,8 @@ int kvm_loongarch_register_dmsintc_device(void) | |||
| 180 | 180 | { | |
| 181 | 181 | return kvm_register_device_ops(&kvm_dmsintc_dev_ops, KVM_DEV_TYPE_LOONGARCH_DMSINTC); | |
| 182 | 182 | } | |
| 183 | + | ||
| 184 | + | void kvm_loongarch_unregister_dmsintc_device(void) | |
| 185 | + | { | |
| 186 | + | kvm_unregister_device_ops(KVM_DEV_TYPE_LOONGARCH_DMSINTC); | |
| 187 | + | } | |
modified arch/loongarch/kvm/intc/eiointc.c
| @@ -695,3 +695,8 @@ int kvm_loongarch_register_eiointc_device(void) | |||
| 695 | 695 | { | |
| 696 | 696 | return kvm_register_device_ops(&kvm_eiointc_dev_ops, KVM_DEV_TYPE_LOONGARCH_EIOINTC); | |
| 697 | 697 | } | |
| 698 | + | ||
| 699 | + | void kvm_loongarch_unregister_eiointc_device(void) | |
| 700 | + | { | |
| 701 | + | kvm_unregister_device_ops(KVM_DEV_TYPE_LOONGARCH_EIOINTC); | |
| 702 | + | } | |
modified arch/loongarch/kvm/intc/ipi.c
| @@ -463,3 +463,8 @@ int kvm_loongarch_register_ipi_device(void) | |||
| 463 | 463 | { | |
| 464 | 464 | return kvm_register_device_ops(&kvm_ipi_dev_ops, KVM_DEV_TYPE_LOONGARCH_IPI); | |
| 465 | 465 | } | |
| 466 | + | ||
| 467 | + | void kvm_loongarch_unregister_ipi_device(void) | |
| 468 | + | { | |
| 469 | + | kvm_unregister_device_ops(KVM_DEV_TYPE_LOONGARCH_IPI); | |
| 470 | + | } | |
modified arch/loongarch/kvm/intc/pch_pic.c
| @@ -78,6 +78,9 @@ int pch_msi_set_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e, int | |||
| 78 | 78 | return dmsintc_set_irq(kvm, msg_addr, e->msi.data, level); | |
| 79 | 79 | } | |
| 80 | 80 | ||
| 81 | + | if (e->msi.data >= EIOINTC_IRQS) | |
| 82 | + | return -EINVAL; | |
| 83 | + | ||
| 81 | 84 | eiointc_set_irq(kvm->arch.eiointc, e->msi.data, level); | |
| 82 | 85 | ||
| 83 | 86 | return 0; | |
| @@ -500,3 +503,8 @@ int kvm_loongarch_register_pch_pic_device(void) | |||
| 500 | 503 | { | |
| 501 | 504 | return kvm_register_device_ops(&kvm_pch_pic_dev_ops, KVM_DEV_TYPE_LOONGARCH_PCHPIC); | |
| 502 | 505 | } | |
| 506 | + | ||
| 507 | + | void kvm_loongarch_unregister_pch_pic_device(void) | |
| 508 | + | { | |
| 509 | + | kvm_unregister_device_ops(KVM_DEV_TYPE_LOONGARCH_PCHPIC); | |
| 510 | + | } | |
modified arch/loongarch/kvm/main.c
| @@ -385,27 +385,52 @@ static int kvm_loongarch_env_init(void) | |||
| 385 | 385 | /* Register LoongArch IPI interrupt controller interface. */ | |
| 386 | 386 | ret = kvm_loongarch_register_ipi_device(); | |
| 387 | 387 | if (ret) | |
| 388 | - | return ret; | |
| 388 | + | goto err_env; | |
| 389 | 389 | ||
| 390 | 390 | /* Register LoongArch EIOINTC interrupt controller interface. */ | |
| 391 | 391 | ret = kvm_loongarch_register_eiointc_device(); | |
| 392 | 392 | if (ret) | |
| 393 | - | return ret; | |
| 393 | + | goto err_ipi; | |
| 394 | 394 | ||
| 395 | 395 | /* Register LoongArch PCH-PIC interrupt controller interface. */ | |
| 396 | 396 | ret = kvm_loongarch_register_pch_pic_device(); | |
| 397 | 397 | if (ret) | |
| 398 | - | return ret; | |
| 398 | + | goto err_eiointc; | |
| 399 | 399 | ||
| 400 | 400 | /* Register LoongArch DMSINTC interrupt contrroller interface */ | |
| 401 | - | if (cpu_has_msgint) | |
| 401 | + | if (cpu_has_msgint) { | |
| 402 | 402 | ret = kvm_loongarch_register_dmsintc_device(); | |
| 403 | + | if (ret) | |
| 404 | + | goto err_pch_pic; | |
| 405 | + | } | |
| 406 | + | ||
| 407 | + | return 0; | |
| 408 | + | ||
| 409 | + | err_pch_pic: | |
| 410 | + | kvm_loongarch_unregister_pch_pic_device(); | |
| 411 | + | err_eiointc: | |
| 412 | + | kvm_loongarch_unregister_eiointc_device(); | |
| 413 | + | err_ipi: | |
| 414 | + | kvm_loongarch_unregister_ipi_device(); | |
| 415 | + | err_env: | |
| 416 | + | kvm_unregister_perf_callbacks(); | |
| 417 | + | kfree(kvm_loongarch_ops); | |
| 418 | + | kvm_loongarch_ops = NULL; | |
| 419 | + | free_percpu(vmcs); | |
| 420 | + | vmcs = NULL; | |
| 403 | 421 | ||
| 404 | 422 | return ret; | |
| 405 | 423 | } | |
| 406 | 424 | ||
| 407 | 425 | static void kvm_loongarch_env_exit(void) | |
| 408 | 426 | { | |
| 427 | + | if (cpu_has_msgint) | |
| 428 | + | kvm_loongarch_unregister_dmsintc_device(); | |
| 429 | + | ||
| 430 | + | kvm_loongarch_unregister_pch_pic_device(); | |
| 431 | + | kvm_loongarch_unregister_eiointc_device(); | |
| 432 | + | kvm_loongarch_unregister_ipi_device(); | |
| 433 | + | ||
| 409 | 434 | if (vmcs) | |
| 410 | 435 | free_percpu(vmcs); | |
| 411 | 436 | ||
| @@ -428,7 +453,11 @@ static int kvm_loongarch_init(void) | |||
| 428 | 453 | if (r) | |
| 429 | 454 | return r; | |
| 430 | 455 | ||
| 431 | - | return kvm_init(sizeof(struct kvm_vcpu), 0, THIS_MODULE); | |
| 456 | + | r = kvm_init(sizeof(struct kvm_vcpu), 0, THIS_MODULE); | |
| 457 | + | if (r) | |
| 458 | + | kvm_loongarch_env_exit(); | |
| 459 | + | ||
| 460 | + | return r; | |
| 432 | 461 | } | |
| 433 | 462 | ||
| 434 | 463 | static void kvm_loongarch_exit(void) | |
modified arch/loongarch/kvm/mmu.c
| @@ -383,6 +383,16 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, const struct kvm_memory_slot | |||
| 383 | 383 | hva_t hva_start; | |
| 384 | 384 | size_t size, gpa_offset, hva_offset; | |
| 385 | 385 | ||
| 386 | + | /* | |
| 387 | + | * The generic code allocates a fresh, zeroed memslot for every change, | |
| 388 | + | * so the arch flags computed below must be carried over when only the | |
| 389 | + | * userspace flags change, e.g. when dirty logging is toggled. | |
| 390 | + | */ | |
| 391 | + | if (change == KVM_MR_FLAGS_ONLY) { | |
| 392 | + | new->arch = old->arch; | |
| 393 | + | return 0; | |
| 394 | + | } | |
| 395 | + | ||
| 386 | 396 | if ((change != KVM_MR_MOVE) && (change != KVM_MR_CREATE)) | |
| 387 | 397 | return 0; | |
| 388 | 398 | /* | |
| @@ -939,9 +949,3 @@ int kvm_handle_mm_fault(struct kvm_vcpu *vcpu, unsigned long gpa, bool write, in | |||
| 939 | 949 | void kvm_arch_sync_dirty_log(struct kvm *kvm, struct kvm_memory_slot *memslot) | |
| 940 | 950 | { | |
| 941 | 951 | } | |
| 942 | - | ||
| 943 | - | void kvm_arch_flush_remote_tlbs_memslot(struct kvm *kvm, | |
| 944 | - | const struct kvm_memory_slot *memslot) | |
| 945 | - | { | |
| 946 | - | kvm_flush_remote_tlbs(kvm); | |
| 947 | - | } | |
modified arch/loongarch/kvm/vcpu.c
| @@ -1165,10 +1165,14 @@ static int kvm_loongarch_cpucfg_set_attr(struct kvm_vcpu *vcpu, | |||
| 1165 | 1165 | return -EINVAL; | |
| 1166 | 1166 | ||
| 1167 | 1167 | /* All vCPUs need set the same PV features */ | |
| 1168 | + | spin_lock(&kvm->arch.pv_setting_lock); | |
| 1168 | 1169 | if ((kvm->arch.pv_features & LOONGARCH_PV_FEAT_UPDATED) | |
| 1169 | - | && ((kvm->arch.pv_features & valid) != val)) | |
| 1170 | + | && ((kvm->arch.pv_features & valid) != val)) { | |
| 1171 | + | spin_unlock(&kvm->arch.pv_setting_lock); | |
| 1170 | 1172 | return -EINVAL; | |
| 1173 | + | } | |
| 1171 | 1174 | kvm->arch.pv_features = val | LOONGARCH_PV_FEAT_UPDATED; | |
| 1175 | + | spin_unlock(&kvm->arch.pv_setting_lock); | |
| 1172 | 1176 | return 0; | |
| 1173 | 1177 | default: | |
| 1174 | 1178 | return -ENXIO; | |
modified arch/loongarch/kvm/vm.c
| @@ -76,6 +76,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) | |||
| 76 | 76 | return -ENOMEM; | |
| 77 | 77 | } | |
| 78 | 78 | spin_lock_init(&kvm->arch.phyid_map_lock); | |
| 79 | + | spin_lock_init(&kvm->arch.pv_setting_lock); | |
| 79 | 80 | ||
| 80 | 81 | kvm_init_vmcs(kvm); | |
| 81 | 82 | kvm_vm_init_features(kvm); | |
modified arch/loongarch/net/bpf_jit.c
| @@ -717,7 +717,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext | |||
| 717 | 717 | move_reg(ctx, t1, src); | |
| 718 | 718 | emit_zext_32(ctx, t1, true); | |
| 719 | 719 | move_imm(ctx, dst, (ctx->user_vm_start >> 32) << 32, false); | |
| 720 | - | emit_insn(ctx, beq, t1, LOONGARCH_GPR_ZERO, 1); | |
| 720 | + | emit_insn(ctx, beq, t1, LOONGARCH_GPR_ZERO, 2); | |
| 721 | 721 | emit_insn(ctx, or, t1, dst, t1); | |
| 722 | 722 | move_reg(ctx, dst, t1); | |
| 723 | 723 | break; | |
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/include/asm/entry-common.h
| @@ -222,8 +222,6 @@ static inline void arch_interrupt_enter_prepare(struct pt_regs *regs) | |||
| 222 | 222 | ||
| 223 | 223 | if (user_mode(regs)) { | |
| 224 | 224 | kuap_lock(); | |
| 225 | - | account_cpu_user_entry(); | |
| 226 | - | account_stolen_time(); | |
| 227 | 225 | } else { | |
| 228 | 226 | kuap_save_and_lock(regs); | |
| 229 | 227 | /* | |
| @@ -270,7 +268,7 @@ static inline void arch_interrupt_exit_prepare(struct pt_regs *regs) | |||
| 270 | 268 | } | |
| 271 | 269 | ||
| 272 | 270 | /* irqentry_exit expects to be called with interrupts disabled */ | |
| 273 | - | local_irq_disable(); | |
| 271 | + | hard_irq_disable(); | |
| 274 | 272 | } | |
| 275 | 273 | ||
| 276 | 274 | static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs) | |
| @@ -515,8 +513,14 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, | |||
| 515 | 513 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | |
| 516 | 514 | local_paca->tm_scratch = regs->msr; | |
| 517 | 515 | #endif | |
| 518 | - | /* Restore user access locks last */ | |
| 519 | - | kuap_user_restore(regs); | |
| 516 | + | /* | |
| 517 | + | * Do not restore KUAP here. Generic entry might treat this as the last | |
| 518 | + | * arch step before userspace but PowerPC still has kernel work after | |
| 519 | + | * irqentry_exit()/syscall_exit_to_user_mode() i.e. in | |
| 520 | + | * interrupt_exit_user_prepare() / syscall_exit_prepare() may enable | |
| 521 | + | * IRQs and retry. Those functions restore KUAP immediately before rfi, | |
| 522 | + | * which is where it should belong. | |
| 523 | + | */ | |
| 520 | 524 | } | |
| 521 | 525 | ||
| 522 | 526 | #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare | |
modified arch/powerpc/kernel/eeh_driver.c
| @@ -533,9 +533,7 @@ static void eeh_rmv_device(struct eeh_dev *edev, void *userdata) | |||
| 533 | 533 | if (rmv_data) | |
| 534 | 534 | list_add(&edev->rmv_entry, &rmv_data->removed_vf_list); | |
| 535 | 535 | } else { | |
| 536 | - | pci_lock_rescan_remove(); | |
| 537 | 536 | pci_stop_and_remove_bus_device(dev); | |
| 538 | - | pci_unlock_rescan_remove(); | |
| 539 | 537 | } | |
| 540 | 538 | } | |
| 541 | 539 | ||
modified arch/powerpc/kernel/interrupt.c
| @@ -175,7 +175,7 @@ again: | |||
| 175 | 175 | current_thread_info()->exit_flags &= ~_TIF_RESTOREALL; | |
| 176 | 176 | regs->exit_result |= ret; | |
| 177 | 177 | ||
| 178 | - | return ret; | |
| 178 | + | return regs->exit_result; | |
| 179 | 179 | } | |
| 180 | 180 | #endif | |
| 181 | 181 | ||
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/prom.c
| @@ -824,7 +824,6 @@ void __init early_init_devtree(void *params) | |||
| 824 | 824 | fadump_append_bootargs(); | |
| 825 | 825 | ||
| 826 | 826 | /* Scan memory nodes and rebuild MEMBLOCKs */ | |
| 827 | - | early_init_dt_scan_root(); | |
| 828 | 827 | early_init_dt_scan_memory_ppc(); | |
| 829 | 828 | ||
| 830 | 829 | /* | |
modified arch/powerpc/kernel/rtas_pci.c
| @@ -54,6 +54,10 @@ int rtas_pci_dn_read_config(struct pci_dn *pdn, int where, int size, u32 *val) | |||
| 54 | 54 | if (!config_access_valid(pdn, where)) | |
| 55 | 55 | return PCIBIOS_BAD_REGISTER_NUMBER; | |
| 56 | 56 | #ifdef CONFIG_EEH | |
| 57 | + | if (pdn->edev && | |
| 58 | + | (pdn->edev->mode & EEH_DEV_REMOVED)) | |
| 59 | + | return PCIBIOS_DEVICE_NOT_FOUND; | |
| 60 | + | ||
| 57 | 61 | if (pdn->edev && pdn->edev->pe && | |
| 58 | 62 | (pdn->edev->pe->state & EEH_PE_CFG_BLOCKED)) | |
| 59 | 63 | return PCIBIOS_SET_FAILED; | |
| @@ -105,6 +109,10 @@ int rtas_pci_dn_write_config(struct pci_dn *pdn, int where, int size, u32 val) | |||
| 105 | 109 | if (!config_access_valid(pdn, where)) | |
| 106 | 110 | return PCIBIOS_BAD_REGISTER_NUMBER; | |
| 107 | 111 | #ifdef CONFIG_EEH | |
| 112 | + | if (pdn->edev && | |
| 113 | + | (pdn->edev->mode & EEH_DEV_REMOVED)) | |
| 114 | + | return PCIBIOS_DEVICE_NOT_FOUND; | |
| 115 | + | ||
| 108 | 116 | if (pdn->edev && pdn->edev->pe && | |
| 109 | 117 | (pdn->edev->pe->state & EEH_PE_CFG_BLOCKED)) | |
| 110 | 118 | return PCIBIOS_SET_FAILED; | |
modified arch/powerpc/kernel/syscall.c
| @@ -18,8 +18,10 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0) | |||
| 18 | 18 | long ret; | |
| 19 | 19 | syscall_fn f; | |
| 20 | 20 | ||
| 21 | - | if (unlikely(!syscall_enter_from_user_mode_randomize_stack(regs, &r0))) | |
| 21 | + | if (unlikely(!syscall_enter_from_user_mode_randomize_stack(regs, &r0))) { | |
| 22 | + | clear_thread_flag(TIF_SYSCALL_RET); | |
| 22 | 23 | return syscall_get_error(current, regs); | |
| 24 | + | } | |
| 23 | 25 | ||
| 24 | 26 | if (unlikely(test_and_clear_thread_flag(TIF_SYSCALL_RET))) | |
| 25 | 27 | return syscall_get_error(current, regs); | |
modified arch/powerpc/kexec/elf_64.c
| @@ -94,6 +94,8 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, | |||
| 94 | 94 | cmdline = modified_cmdline; | |
| 95 | 95 | } | |
| 96 | 96 | ||
| 97 | + | kexec_dprintk("Command line: %s", cmdline ? cmdline : ""); | |
| 98 | + | ||
| 97 | 99 | if (initrd != NULL) { | |
| 98 | 100 | kbuf.buffer = initrd; | |
| 99 | 101 | kbuf.bufsz = kbuf.memsz = initrd_len; | |
modified arch/powerpc/kexec/file_load_64.c
| @@ -57,7 +57,7 @@ int arch_check_excluded_range(struct kimage *image, unsigned long start, | |||
| 57 | 57 | ||
| 58 | 58 | emem = image->arch.exclude_ranges; | |
| 59 | 59 | for (i = 0; i < emem->nr_ranges; i++) | |
| 60 | - | if (start < emem->ranges[i].end && end > emem->ranges[i].start) | |
| 60 | + | if (start <= emem->ranges[i].end && end >= emem->ranges[i].start) | |
| 61 | 61 | return 1; | |
| 62 | 62 | ||
| 63 | 63 | return 0; | |
| @@ -113,7 +113,7 @@ static int add_usable_mem(struct umem_info *um_info, u64 base, u64 end) | |||
| 113 | 113 | loc_end = um_info->ranges[i].end; | |
| 114 | 114 | if (loc_base >= base && loc_end <= end) | |
| 115 | 115 | add = true; | |
| 116 | - | else if (base < loc_end && end > loc_base) { | |
| 116 | + | else if (base <= loc_end && end >= loc_base) { | |
| 117 | 117 | if (loc_base < base) | |
| 118 | 118 | loc_base = base; | |
| 119 | 119 | if (loc_end > end) | |
| @@ -377,16 +377,12 @@ static int load_backup_segment(struct kimage *image, struct kexec_buf *kbuf) | |||
| 377 | 377 | static unsigned int kdump_extra_elfcorehdr_size(struct crash_mem *cmem) | |
| 378 | 378 | { | |
| 379 | 379 | #if defined(CONFIG_CRASH_HOTPLUG) && defined(CONFIG_MEMORY_HOTPLUG) | |
| 380 | - | unsigned int extra_sz = 0; | |
| 381 | - | ||
| 382 | 380 | if (CONFIG_CRASH_MAX_MEMORY_RANGES > (unsigned int)PN_XNUM) | |
| 383 | 381 | pr_warn("Number of Phdrs %u exceeds max\n", CONFIG_CRASH_MAX_MEMORY_RANGES); | |
| 384 | 382 | else if (cmem->nr_ranges >= CONFIG_CRASH_MAX_MEMORY_RANGES) | |
| 385 | 383 | pr_warn("Configured crash mem ranges may not be enough\n"); | |
| 386 | 384 | else | |
| 387 | - | extra_sz = (CONFIG_CRASH_MAX_MEMORY_RANGES - cmem->nr_ranges) * sizeof(Elf64_Phdr); | |
| 388 | - | ||
| 389 | - | return extra_sz; | |
| 385 | + | return (CONFIG_CRASH_MAX_MEMORY_RANGES - cmem->nr_ranges) * sizeof(Elf64_Phdr); | |
| 390 | 386 | #endif | |
| 391 | 387 | return 0; | |
| 392 | 388 | } | |
modified arch/powerpc/kvm/book3s_hv.c
| @@ -6140,12 +6140,12 @@ static int kvmppc_irq_bypass_add_producer_hv(struct irq_bypass_consumer *cons, | |||
| 6140 | 6140 | struct kvm_kernel_irqfd *irqfd = | |
| 6141 | 6141 | container_of(cons, struct kvm_kernel_irqfd, consumer); | |
| 6142 | 6142 | ||
| 6143 | - | irqfd->producer = prod; | |
| 6144 | - | ||
| 6145 | 6143 | ret = kvmppc_set_passthru_irq(irqfd->kvm, prod->irq, irqfd->gsi); | |
| 6146 | 6144 | if (ret) | |
| 6147 | 6145 | pr_info("kvmppc_set_passthru_irq (irq %d, gsi %d) fails: %d\n", | |
| 6148 | 6146 | prod->irq, irqfd->gsi, ret); | |
| 6147 | + | else | |
| 6148 | + | irqfd->producer = prod; | |
| 6149 | 6149 | ||
| 6150 | 6150 | return ret; | |
| 6151 | 6151 | } | |
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/platforms/pasemi/setup.c
| @@ -165,6 +165,8 @@ static int __init pas_setup_mce_regs(void) | |||
| 165 | 165 | while (dev && reg < MAX_MCE_REGS) { | |
| 166 | 166 | mce_regs[reg].name = kasprintf(GFP_KERNEL, | |
| 167 | 167 | "mc%d_mcdebug_errsta", reg); | |
| 168 | + | if (!mce_regs[reg].name) | |
| 169 | + | return -ENOMEM; | |
| 168 | 170 | mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0x730); | |
| 169 | 171 | dev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa00a, dev); | |
| 170 | 172 | reg++; | |
modified arch/powerpc/platforms/powernv/pci-ioda.c
| @@ -1623,15 +1623,13 @@ int64_t pnv_opal_pci_msi_eoi(struct irq_data *d) | |||
| 1623 | 1623 | return opal_pci_msi_eoi(phb->opal_id, d->parent_data->hwirq); | |
| 1624 | 1624 | } | |
| 1625 | 1625 | ||
| 1626 | - | static struct irq_chip pnv_pci_msi_irq_chip; | |
| 1627 | - | ||
| 1628 | 1626 | /* | |
| 1629 | 1627 | * Returns true iff chip is something that we could call | |
| 1630 | 1628 | * pnv_opal_pci_msi_eoi for. | |
| 1631 | 1629 | */ | |
| 1632 | 1630 | bool is_pnv_opal_msi(struct irq_chip *chip) | |
| 1633 | 1631 | { | |
| 1634 | - | return chip == &pnv_pci_msi_irq_chip; | |
| 1632 | + | return chip && chip->name && str_has_prefix(chip->name, "PNV-"); | |
| 1635 | 1633 | } | |
| 1636 | 1634 | EXPORT_SYMBOL_GPL(is_pnv_opal_msi); | |
| 1637 | 1635 | ||
| @@ -1728,7 +1726,7 @@ static const struct msi_parent_ops pnv_msi_parent_ops = { | |||
| 1728 | 1726 | .chip_flags = MSI_CHIP_FLAG_SET_EOI, | |
| 1729 | 1727 | .bus_select_token = DOMAIN_BUS_NEXUS, | |
| 1730 | 1728 | .bus_select_mask = MATCH_PCI_MSI, | |
| 1731 | - | .prefix = "PNV-", | |
| 1729 | + | .prefix = "PNV-", /* Note: is_pnv_opal_msi() uses this */ | |
| 1732 | 1730 | .init_dev_msi_info = pnv_init_dev_msi_info, | |
| 1733 | 1731 | }; | |
| 1734 | 1732 | ||
modified arch/powerpc/platforms/ps3/repository.c
| @@ -6,6 +6,8 @@ | |||
| 6 | 6 | * Copyright 2006 Sony Corp. | |
| 7 | 7 | */ | |
| 8 | 8 | ||
| 9 | + | #include <linux/minmax.h> | |
| 10 | + | ||
| 9 | 11 | #include <asm/lv1call.h> | |
| 10 | 12 | ||
| 11 | 13 | #include "platform.h" | |
| @@ -74,8 +76,9 @@ static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4, | |||
| 74 | 76 | static u64 make_first_field(const char *text, u64 index) | |
| 75 | 77 | { | |
| 76 | 78 | u64 n = 0; | |
| 79 | + | size_t len = min(strlen(text), sizeof(n)); | |
| 77 | 80 | ||
| 78 | - | memcpy((char *)&n, text, strnlen(text, sizeof(n))); | |
| 81 | + | memcpy(&n, text, len); | |
| 79 | 82 | return PS3_VENDOR_ID_NONE + (n >> 32) + index; | |
| 80 | 83 | } | |
| 81 | 84 | ||
modified arch/powerpc/platforms/pseries/htmdump.c
| @@ -527,28 +527,28 @@ static int htmdump_init_debugfs(void) | |||
| 527 | 527 | htm_status_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | |
| 528 | 528 | if (!htm_status_buf) { | |
| 529 | 529 | pr_err("Failed to allocate htmstatus buf\n"); | |
| 530 | - | return -ENOMEM; | |
| 530 | + | goto htm_status_buf_err; | |
| 531 | 531 | } | |
| 532 | 532 | ||
| 533 | 533 | /* Debugfs interface file to present System Processor Configuration */ | |
| 534 | 534 | htm_info_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | |
| 535 | 535 | if (!htm_info_buf) { | |
| 536 | 536 | pr_err("Failed to allocate htm info buf\n"); | |
| 537 | - | return -ENOMEM; | |
| 537 | + | goto htm_info_buf_err; | |
| 538 | 538 | } | |
| 539 | 539 | ||
| 540 | 540 | /* Debugfs interface file to present HTM capabilities */ | |
| 541 | 541 | htm_caps_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | |
| 542 | 542 | if (!htm_caps_buf) { | |
| 543 | 543 | pr_err("Failed to allocate htm caps buf\n"); | |
| 544 | - | return -ENOMEM; | |
| 544 | + | goto htm_caps_buf_err; | |
| 545 | 545 | } | |
| 546 | 546 | ||
| 547 | 547 | /* Memory to present HTM system memory configuration */ | |
| 548 | 548 | htm_mem_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | |
| 549 | 549 | if (!htm_mem_buf) { | |
| 550 | 550 | pr_err("Failed to allocate htm mem buf\n"); | |
| 551 | - | return -ENOMEM; | |
| 551 | + | goto htm_mem_buf_err; | |
| 552 | 552 | } | |
| 553 | 553 | ||
| 554 | 554 | debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops); | |
| @@ -557,6 +557,17 @@ static int htmdump_init_debugfs(void) | |||
| 557 | 557 | debugfs_create_file("htmsystem_mem", 0400, htmdump_debugfs_dir, htm_mem_buf, &htmsystem_mem_fops); | |
| 558 | 558 | ||
| 559 | 559 | return 0; | |
| 560 | + | ||
| 561 | + | htm_mem_buf_err: | |
| 562 | + | kfree(htm_caps_buf); | |
| 563 | + | htm_caps_buf_err: | |
| 564 | + | kfree(htm_info_buf); | |
| 565 | + | htm_info_buf_err: | |
| 566 | + | kfree(htm_status_buf); | |
| 567 | + | htm_status_buf_err: | |
| 568 | + | debugfs_remove_recursive(htmdump_debugfs_dir); | |
| 569 | + | kfree(htm_buf); | |
| 570 | + | return -ENOMEM; | |
| 560 | 571 | } | |
| 561 | 572 | ||
| 562 | 573 | static int __init htmdump_init(void) | |
modified arch/powerpc/platforms/pseries/pci.c
| @@ -132,11 +132,14 @@ static int pseries_pci_sriov_enable(struct pci_dev *pdev, u16 num_vfs) | |||
| 132 | 132 | ||
| 133 | 133 | /* First integer stores max config */ | |
| 134 | 134 | max_config_vfs = of_read_number(&max_vfs[0], 1); | |
| 135 | - | if (max_config_vfs < num_vfs || num_vfs > MAX_VFS_FOR_MAP_PE) { | |
| 136 | - | dev_err(&pdev->dev, | |
| 137 | - | "Num VFs %x > %x Configurable VFs\n", | |
| 138 | - | num_vfs, (num_vfs > MAX_VFS_FOR_MAP_PE) ? | |
| 139 | - | MAX_VFS_FOR_MAP_PE : max_config_vfs); | |
| 135 | + | if (max_config_vfs < num_vfs) { | |
| 136 | + | dev_err(&pdev->dev, "Num VFs %x > %x Configurable VFs\n", | |
| 137 | + | num_vfs, max_config_vfs); | |
| 138 | + | return -EINVAL; | |
| 139 | + | } | |
| 140 | + | if (num_vfs > MAX_VFS_FOR_MAP_PE) { | |
| 141 | + | dev_err(&pdev->dev, "Num VFs %x > %x PE mapping limit\n", | |
| 142 | + | num_vfs, MAX_VFS_FOR_MAP_PE); | |
| 140 | 143 | return -EINVAL; | |
| 141 | 144 | } | |
| 142 | 145 | ||
modified arch/powerpc/sysdev/xive/common.c
| @@ -1134,7 +1134,7 @@ static int __init xive_init_ipis(void) | |||
| 1134 | 1134 | if (!ipi_domain) | |
| 1135 | 1135 | goto out_free_fwnode; | |
| 1136 | 1136 | ||
| 1137 | - | xive_ipis = kzalloc_objs(*xive_ipis, nr_node_ids, GFP_KERNEL); | |
| 1137 | + | xive_ipis = kzalloc_objs(*xive_ipis, nr_node_ids); | |
| 1138 | 1138 | if (!xive_ipis) | |
| 1139 | 1139 | goto out_free_domain; | |
| 1140 | 1140 | ||
modified arch/riscv/Kconfig
| @@ -326,7 +326,7 @@ config STACKTRACE_SUPPORT | |||
| 326 | 326 | config GENERIC_BUG | |
| 327 | 327 | def_bool y | |
| 328 | 328 | depends on BUG | |
| 329 | - | select GENERIC_BUG_RELATIVE_POINTERS if 64BIT | |
| 329 | + | select GENERIC_BUG_RELATIVE_POINTERS | |
| 330 | 330 | ||
| 331 | 331 | config GENERIC_BUG_RELATIVE_POINTERS | |
| 332 | 332 | bool | |
modified arch/riscv/include/asm/bug.h
| @@ -29,13 +29,8 @@ | |||
| 29 | 29 | ||
| 30 | 30 | typedef u32 bug_insn_t; | |
| 31 | 31 | ||
| 32 | - | #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS | |
| 33 | 32 | #define __BUG_ENTRY_ADDR RISCV_INT " 1b - ." | |
| 34 | 33 | #define __BUG_ENTRY_FILE(file) RISCV_INT " " file " - ." | |
| 35 | - | #else | |
| 36 | - | #define __BUG_ENTRY_ADDR RISCV_PTR " 1b" | |
| 37 | - | #define __BUG_ENTRY_FILE(file) RISCV_PTR " " file | |
| 38 | - | #endif | |
| 39 | 34 | ||
| 40 | 35 | #ifdef CONFIG_DEBUG_BUGVERBOSE | |
| 41 | 36 | #define __BUG_ENTRY(file, line, flags) \ | |
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/switch_to.h
| @@ -61,8 +61,8 @@ static inline void __switch_to_fpu(struct task_struct *prev, | |||
| 61 | 61 | ||
| 62 | 62 | static __always_inline bool has_fpu(void) | |
| 63 | 63 | { | |
| 64 | - | return riscv_has_extension_likely(RISCV_ISA_EXT_F) || | |
| 65 | - | riscv_has_extension_likely(RISCV_ISA_EXT_D); | |
| 64 | + | /* D extension depends on F, so checking D alone is sufficient. */ | |
| 65 | + | return riscv_has_extension_likely(RISCV_ISA_EXT_D); | |
| 66 | 66 | } | |
| 67 | 67 | #else | |
| 68 | 68 | static __always_inline bool has_fpu(void) { return false; } | |
modified arch/riscv/kernel/cpufeature.c
| @@ -412,6 +412,19 @@ static const unsigned int riscv_zvbb_exts[] = { | |||
| 412 | 412 | RISCV_ISA_EXT_ZVKB | |
| 413 | 413 | }; | |
| 414 | 414 | ||
| 415 | + | /* | |
| 416 | + | * The RISC-V ISA manual specifies that Zfh implies Zfhmin and Zvfh implies | |
| 417 | + | * Zvfhmin. Report the implied subset extensions whenever the supersets are | |
| 418 | + | * detected (see https://github.com/riscv/riscv-isa-manual/pull/3070). | |
| 419 | + | */ | |
| 420 | + | static const unsigned int riscv_zfh_exts[] = { | |
| 421 | + | RISCV_ISA_EXT_ZFHMIN | |
| 422 | + | }; | |
| 423 | + | ||
| 424 | + | static const unsigned int riscv_zvfh_exts[] = { | |
| 425 | + | RISCV_ISA_EXT_ZVFHMIN | |
| 426 | + | }; | |
| 427 | + | ||
| 415 | 428 | #define RISCV_ISA_EXT_ZVE64F_IMPLY_LIST \ | |
| 416 | 429 | RISCV_ISA_EXT_ZVE64X, \ | |
| 417 | 430 | RISCV_ISA_EXT_ZVE32F, \ | |
| @@ -550,7 +563,8 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { | |||
| 550 | 563 | __RISCV_ISA_EXT_DATA(zawrs, RISCV_ISA_EXT_ZAWRS), | |
| 551 | 564 | __RISCV_ISA_EXT_DATA_VALIDATE(zfa, RISCV_ISA_EXT_ZFA, riscv_ext_f_depends), | |
| 552 | 565 | __RISCV_ISA_EXT_DATA_VALIDATE(zfbfmin, RISCV_ISA_EXT_ZFBFMIN, riscv_ext_f_depends), | |
| 553 | - | __RISCV_ISA_EXT_DATA_VALIDATE(zfh, RISCV_ISA_EXT_ZFH, riscv_ext_f_depends), | |
| 566 | + | __RISCV_ISA_EXT_SUPERSET_VALIDATE(zfh, RISCV_ISA_EXT_ZFH, | |
| 567 | + | riscv_zfh_exts, riscv_ext_f_depends), | |
| 554 | 568 | __RISCV_ISA_EXT_DATA_VALIDATE(zfhmin, RISCV_ISA_EXT_ZFHMIN, riscv_ext_f_depends), | |
| 555 | 569 | __RISCV_ISA_EXT_DATA(zca, RISCV_ISA_EXT_ZCA), | |
| 556 | 570 | __RISCV_ISA_EXT_DATA_VALIDATE(zcb, RISCV_ISA_EXT_ZCB, riscv_ext_zca_depends), | |
| @@ -586,7 +600,9 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { | |||
| 586 | 600 | __RISCV_ISA_EXT_SUPERSET_VALIDATE(zve64x, RISCV_ISA_EXT_ZVE64X, riscv_zve64x_exts, riscv_ext_vector_x_validate), | |
| 587 | 601 | __RISCV_ISA_EXT_DATA_VALIDATE(zvfbfmin, RISCV_ISA_EXT_ZVFBFMIN, riscv_vector_f_validate), | |
| 588 | 602 | __RISCV_ISA_EXT_DATA_VALIDATE(zvfbfwma, RISCV_ISA_EXT_ZVFBFWMA, riscv_ext_zvfbfwma_validate), | |
| 589 | - | __RISCV_ISA_EXT_DATA(zvfh, RISCV_ISA_EXT_ZVFH), | |
| 603 | + | __RISCV_ISA_EXT_SUPERSET_VALIDATE(zvfh, RISCV_ISA_EXT_ZVFH, | |
| 604 | + | riscv_zvfh_exts, | |
| 605 | + | riscv_ext_vector_float_validate), | |
| 590 | 606 | __RISCV_ISA_EXT_DATA(zvfhmin, RISCV_ISA_EXT_ZVFHMIN), | |
| 591 | 607 | __RISCV_ISA_EXT_DATA_VALIDATE(zvkb, RISCV_ISA_EXT_ZVKB, riscv_ext_vector_crypto_validate), | |
| 592 | 608 | __RISCV_ISA_EXT_DATA_VALIDATE(zvkg, RISCV_ISA_EXT_ZVKG, riscv_ext_vector_crypto_validate), | |
modified arch/riscv/kernel/patch.c
| @@ -45,6 +45,8 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap) | |||
| 45 | 45 | phys_addr_t phys; | |
| 46 | 46 | ||
| 47 | 47 | if (core_kernel_text(uintaddr) || is_kernel_exittext(uintaddr)) { | |
| 48 | + | if (!IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)) | |
| 49 | + | return addr; | |
| 48 | 50 | phys = __pa_symbol(addr); | |
| 49 | 51 | } else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) { | |
| 50 | 52 | struct page *page = vmalloc_to_page(addr); | |
modified arch/riscv/kernel/process.c
| @@ -349,10 +349,8 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg) | |||
| 349 | 349 | if (arg & PR_TAGGED_ADDR_ENABLE && (tagged_addr_disabled || !pmlen)) | |
| 350 | 350 | return -EINVAL; | |
| 351 | 351 | ||
| 352 | - | if (!(arg & PR_TAGGED_ADDR_ENABLE)) { | |
| 352 | + | if (!(arg & PR_TAGGED_ADDR_ENABLE)) | |
| 353 | 353 | pmlen = PMLEN_0; | |
| 354 | - | pmm = ENVCFG_PMM_PMLEN_0; | |
| 355 | - | } | |
| 356 | 354 | ||
| 357 | 355 | if (mmap_write_lock_killable(mm)) | |
| 358 | 356 | return -EINTR; | |
modified arch/riscv/kernel/sys_hwprobe.c
| @@ -297,6 +297,8 @@ static u64 hwprobe_vec_misaligned(const struct cpumask *cpus) | |||
| 297 | 297 | static void hwprobe_one_pair(struct riscv_hwprobe *pair, | |
| 298 | 298 | const struct cpumask *cpus) | |
| 299 | 299 | { | |
| 300 | + | pair->value = 0; | |
| 301 | + | ||
| 300 | 302 | switch (pair->key) { | |
| 301 | 303 | case RISCV_HWPROBE_KEY_MVENDORID: | |
| 302 | 304 | case RISCV_HWPROBE_KEY_MARCHID: | |
| @@ -331,17 +333,14 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair, | |||
| 331 | 333 | break; | |
| 332 | 334 | ||
| 333 | 335 | case RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE: | |
| 334 | - | pair->value = 0; | |
| 335 | 336 | if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOZ)) | |
| 336 | 337 | pair->value = riscv_cboz_block_size; | |
| 337 | 338 | break; | |
| 338 | 339 | case RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE: | |
| 339 | - | pair->value = 0; | |
| 340 | 340 | if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOM)) | |
| 341 | 341 | pair->value = riscv_cbom_block_size; | |
| 342 | 342 | break; | |
| 343 | 343 | case RISCV_HWPROBE_KEY_ZICBOP_BLOCK_SIZE: | |
| 344 | - | pair->value = 0; | |
| 345 | 344 | if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOP)) | |
| 346 | 345 | pair->value = riscv_cbop_block_size; | |
| 347 | 346 | break; | |
modified arch/riscv/kernel/usercfi.c
| @@ -525,9 +525,8 @@ static int __init setup_global_riscv_enable(char *str) | |||
| 525 | 525 | ||
| 526 | 526 | if (riscv_nousercfi) | |
| 527 | 527 | pr_info("RISC-V user CFI disabled via cmdline - shadow stack status : %s, landing pad status : %s\n", | |
| 528 | - | (riscv_nousercfi & CMDLINE_DISABLE_RISCV_USERCFI_BCFI) ? "disabled" : | |
| 529 | - | "enabled", (riscv_nousercfi & CMDLINE_DISABLE_RISCV_USERCFI_FCFI) ? | |
| 530 | - | "disabled" : "enabled"); | |
| 528 | + | str_disabled_enabled(riscv_nousercfi & CMDLINE_DISABLE_RISCV_USERCFI_BCFI), | |
| 529 | + | str_disabled_enabled(riscv_nousercfi & CMDLINE_DISABLE_RISCV_USERCFI_FCFI)); | |
| 531 | 530 | ||
| 532 | 531 | return 1; | |
| 533 | 532 | } | |
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; | |
| @@ -503,8 +512,8 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low | |||
| 503 | 512 | } | |
| 504 | 513 | } | |
| 505 | 514 | ||
| 506 | - | einfo = kvcalloc(num_events, sizeof(*einfo), | |
| 507 | - | GFP_KERNEL_ACCOUNT | __GFP_NOWARN); | |
| 515 | + | einfo = kvzalloc_objs(*einfo, num_events, | |
| 516 | + | GFP_KERNEL_ACCOUNT | __GFP_NOWARN); | |
| 508 | 517 | if (!einfo) { | |
| 509 | 518 | ret = SBI_ERR_FAILURE; | |
| 510 | 519 | goto out; | |
| @@ -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/uaccess.S
| @@ -76,6 +76,7 @@ SYM_FUNC_START(fallback_scalar_usercopy_sum_enabled) | |||
| 76 | 76 | li a3, 9*SZREG-1 /* size must >= (word_copy stride + SZREG-1) */ | |
| 77 | 77 | bltu a2, a3, .Lbyte_copy_tail | |
| 78 | 78 | ||
| 79 | + | #if !defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) | |
| 79 | 80 | /* | |
| 80 | 81 | * Copy first bytes until dst is aligned to word boundary. | |
| 81 | 82 | * a0 - start of dst | |
| @@ -103,7 +104,7 @@ SYM_FUNC_START(fallback_scalar_usercopy_sum_enabled) | |||
| 103 | 104 | /* a1 - start of src */ | |
| 104 | 105 | andi a3, a1, SZREG-1 | |
| 105 | 106 | bnez a3, .Lshift_copy | |
| 106 | - | ||
| 107 | + | #endif | |
| 107 | 108 | .Lword_copy: | |
| 108 | 109 | /* | |
| 109 | 110 | * Both src and dst are aligned, unrolled word copy | |
| @@ -137,6 +138,7 @@ SYM_FUNC_START(fallback_scalar_usercopy_sum_enabled) | |||
| 137 | 138 | addi t0, t0, 8*SZREG /* revert to original value */ | |
| 138 | 139 | j .Lbyte_copy_tail | |
| 139 | 140 | ||
| 141 | + | #if !defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) | |
| 140 | 142 | .Lshift_copy: | |
| 141 | 143 | ||
| 142 | 144 | /* | |
| @@ -189,6 +191,7 @@ SYM_FUNC_START(fallback_scalar_usercopy_sum_enabled) | |||
| 189 | 191 | ||
| 190 | 192 | /* Revert src to original unaligned value */ | |
| 191 | 193 | add a1, a1, a3 | |
| 194 | + | #endif | |
| 192 | 195 | ||
| 193 | 196 | .Lbyte_copy_tail: | |
| 194 | 197 | /* | |
modified arch/riscv/mm/init.c
| @@ -1465,7 +1465,9 @@ struct execmem_info __init *execmem_arch_setup(void) | |||
| 1465 | 1465 | [EXECMEM_KPROBES] = { | |
| 1466 | 1466 | .start = VMALLOC_START, | |
| 1467 | 1467 | .end = VMALLOC_END, | |
| 1468 | - | .pgprot = PAGE_KERNEL_READ_EXEC, | |
| 1468 | + | .pgprot = IS_ENABLED(CONFIG_STRICT_MODULE_RWX) ? | |
| 1469 | + | PAGE_KERNEL_READ_EXEC : | |
| 1470 | + | PAGE_KERNEL_EXEC, | |
| 1469 | 1471 | .alignment = 1, | |
| 1470 | 1472 | }, | |
| 1471 | 1473 | [EXECMEM_BPF] = { | |
modified arch/riscv/net/bpf_jit_comp64.c
| @@ -2128,7 +2128,15 @@ bool bpf_jit_supports_ptr_xchg(void) | |||
| 2128 | 2128 | ||
| 2129 | 2129 | bool bpf_jit_supports_arena(void) | |
| 2130 | 2130 | { | |
| 2131 | - | return true; | |
| 2131 | + | /* | |
| 2132 | + | * The arena range tree uses kmalloc_nolock(), which needs | |
| 2133 | + | * cmpxchg128, provided by ZACAS on riscv. | |
| 2134 | + | */ | |
| 2135 | + | #ifdef system_has_cmpxchg128 | |
| 2136 | + | return system_has_cmpxchg128(); | |
| 2137 | + | #else | |
| 2138 | + | return false; | |
| 2139 | + | #endif | |
| 2132 | 2140 | } | |
| 2133 | 2141 | ||
| 2134 | 2142 | bool bpf_jit_supports_insn(struct bpf_insn *insn, bool in_arena) | |
modified arch/s390/boot/alternative.c
| @@ -45,11 +45,12 @@ static void alt_debug_modify(int type, unsigned int nr, bool clear) | |||
| 45 | 45 | ||
| 46 | 46 | static char *alt_debug_parse(int type, char *str) | |
| 47 | 47 | { | |
| 48 | - | unsigned long val, endval; | |
| 48 | + | unsigned long val, endval, limit; | |
| 49 | 49 | char *endp; | |
| 50 | 50 | bool clear; | |
| 51 | 51 | int i; | |
| 52 | 52 | ||
| 53 | + | limit = type == ALT_TYPE_FACILITY ? MAX_FACILITY_BIT : MAX_MFEATURE_BIT; | |
| 53 | 54 | if (*str == ':') { | |
| 54 | 55 | str++; | |
| 55 | 56 | } else { | |
| @@ -73,7 +74,7 @@ static char *alt_debug_parse(int type, char *str) | |||
| 73 | 74 | if (str == endp) | |
| 74 | 75 | break; | |
| 75 | 76 | str = endp; | |
| 76 | - | while (val <= endval) { | |
| 77 | + | while (val <= endval && val < limit) { | |
| 77 | 78 | alt_debug_modify(type, val, clear); | |
| 78 | 79 | val++; | |
| 79 | 80 | } | |
modified arch/s390/boot/ipl_parm.c
| @@ -23,6 +23,7 @@ struct parmarea parmarea __section(".parmarea") = { | |||
| 23 | 23 | }; | |
| 24 | 24 | ||
| 25 | 25 | char __bootdata(early_command_line)[COMMAND_LINE_SIZE]; | |
| 26 | + | static char command_line_buf[COMMAND_LINE_SIZE]; | |
| 26 | 27 | ||
| 27 | 28 | unsigned int __bootdata_preserved(zlib_dfltcc_support) = ZLIB_DFLTCC_FULL; | |
| 28 | 29 | struct ipl_parameter_block __bootdata_preserved(ipl_block); | |
| @@ -135,31 +136,29 @@ out: | |||
| 135 | 136 | ||
| 136 | 137 | static void append_ipl_block_parm(void) | |
| 137 | 138 | { | |
| 138 | - | char *parm, *delim; | |
| 139 | - | size_t len, rc = 0; | |
| 139 | + | size_t len, extra = 0; | |
| 140 | + | char *delim; | |
| 140 | 141 | ||
| 141 | 142 | len = strlen(early_command_line); | |
| 142 | - | ||
| 143 | - | delim = early_command_line + len; /* '\0' character position */ | |
| 144 | - | parm = early_command_line + len + 1; /* append right after '\0' */ | |
| 143 | + | delim = early_command_line + len; /* '\0' character position */ | |
| 145 | 144 | ||
| 146 | 145 | switch (ipl_block.pb0_hdr.pbt) { | |
| 147 | 146 | case IPL_PBT_CCW: | |
| 148 | - | rc = ipl_block_get_ascii_vmparm( | |
| 149 | - | parm, COMMAND_LINE_SIZE - len - 1, &ipl_block); | |
| 147 | + | extra = ipl_block_get_ascii_vmparm(command_line_buf, sizeof(command_line_buf), &ipl_block); | |
| 150 | 148 | break; | |
| 151 | 149 | case IPL_PBT_FCP: | |
| 152 | 150 | case IPL_PBT_NVME: | |
| 153 | 151 | case IPL_PBT_ECKD: | |
| 154 | - | rc = ipl_block_get_ascii_scpdata( | |
| 155 | - | parm, COMMAND_LINE_SIZE - len - 1, &ipl_block); | |
| 152 | + | extra = ipl_block_get_ascii_scpdata(command_line_buf, sizeof(command_line_buf), &ipl_block); | |
| 156 | 153 | break; | |
| 157 | 154 | } | |
| 158 | - | if (rc) { | |
| 159 | - | if (*parm == '=') | |
| 160 | - | memmove(early_command_line, parm + 1, rc); | |
| 161 | - | else | |
| 155 | + | if (extra) { | |
| 156 | + | if (command_line_buf[0] == '=') { | |
| 157 | + | memmove(early_command_line, command_line_buf + 1, extra); | |
| 158 | + | } else if (len < COMMAND_LINE_SIZE - 2) { | |
| 162 | 159 | *delim = ' '; /* replace '\0' with space */ | |
| 160 | + | sized_strscpy(delim + 1, command_line_buf, COMMAND_LINE_SIZE - len - 1); | |
| 161 | + | } | |
| 163 | 162 | } | |
| 164 | 163 | } | |
| 165 | 164 | ||
| @@ -231,7 +230,7 @@ static void modify_fac_list(char *str) | |||
| 231 | 230 | if (str == endp) | |
| 232 | 231 | break; | |
| 233 | 232 | str = endp; | |
| 234 | - | while (val <= endval) { | |
| 233 | + | while (val <= endval && val < MAX_FACILITY_BIT) { | |
| 235 | 234 | modify_facility(val, clear); | |
| 236 | 235 | val++; | |
| 237 | 236 | } | |
| @@ -245,7 +244,6 @@ static void modify_fac_list(char *str) | |||
| 245 | 244 | check_cleared_facilities(); | |
| 246 | 245 | } | |
| 247 | 246 | ||
| 248 | - | static char command_line_buf[COMMAND_LINE_SIZE]; | |
| 249 | 247 | void parse_boot_command_line(void) | |
| 250 | 248 | { | |
| 251 | 249 | char *param, *val; | |
modified arch/s390/boot/physmem_info.c
| @@ -141,7 +141,7 @@ static int tprot(unsigned long addr) | |||
| 141 | 141 | ||
| 142 | 142 | static unsigned long search_mem_end(void) | |
| 143 | 143 | { | |
| 144 | - | unsigned long range = 1 << (MAX_PHYSMEM_BITS - 20); /* in 1MB blocks */ | |
| 144 | + | unsigned long range = 1UL << (MAX_PHYSMEM_BITS - 20); /* in 1MB blocks */ | |
| 145 | 145 | unsigned long offset = 0; | |
| 146 | 146 | unsigned long pivot; | |
| 147 | 147 | ||
modified arch/s390/crypto/Makefile
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | # Cryptographic API | |
| 4 | 4 | # | |
| 5 | 5 | ||
| 6 | + | CONTEXT_ANALYSIS := y | |
| 7 | + | ||
| 6 | 8 | obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o | |
| 7 | 9 | obj-$(CONFIG_CRYPTO_PAES_S390) += paes_s390.o | |
| 8 | 10 | obj-$(CONFIG_S390_PRNG) += prng.o | |
modified arch/s390/crypto/aes_s390.c
| @@ -26,14 +26,14 @@ | |||
| 26 | 26 | #include <linux/module.h> | |
| 27 | 27 | #include <linux/cpufeature.h> | |
| 28 | 28 | #include <linux/init.h> | |
| 29 | - | #include <linux/mutex.h> | |
| 30 | 29 | #include <linux/fips.h> | |
| 30 | + | #include <linux/semaphore.h> | |
| 31 | 31 | #include <linux/string.h> | |
| 32 | 32 | #include <crypto/xts.h> | |
| 33 | 33 | #include <asm/cpacf.h> | |
| 34 | 34 | ||
| 35 | 35 | static u8 *ctrblk; | |
| 36 | - | static DEFINE_MUTEX(ctrblk_lock); | |
| 36 | + | static DEFINE_SEMAPHORE(ctrblk_sem, 1); | |
| 37 | 37 | ||
| 38 | 38 | static cpacf_mask_t km_functions, kmc_functions, kmctr_functions, | |
| 39 | 39 | kma_functions; | |
| @@ -129,7 +129,7 @@ static int ecb_aes_crypt(struct skcipher_request *req, unsigned long modifier) | |||
| 129 | 129 | return fallback_skcipher_crypt(sctx, req, modifier); | |
| 130 | 130 | ||
| 131 | 131 | ret = skcipher_walk_virt(&walk, req, false); | |
| 132 | - | while ((nbytes = walk.nbytes) != 0) { | |
| 132 | + | while (!ret && ((nbytes = walk.nbytes) != 0)) { | |
| 133 | 133 | /* only use complete blocks */ | |
| 134 | 134 | n = nbytes & ~(AES_BLOCK_SIZE - 1); | |
| 135 | 135 | cpacf_km(sctx->fc | modifier, sctx->key, | |
| @@ -233,7 +233,7 @@ static int cbc_aes_crypt(struct skcipher_request *req, unsigned long modifier) | |||
| 233 | 233 | return ret; | |
| 234 | 234 | memcpy(param.iv, walk.iv, AES_BLOCK_SIZE); | |
| 235 | 235 | memcpy(param.key, sctx->key, sctx->key_len); | |
| 236 | - | while ((nbytes = walk.nbytes) != 0) { | |
| 236 | + | while (!ret && ((nbytes = walk.nbytes) != 0)) { | |
| 237 | 237 | /* only use complete blocks */ | |
| 238 | 238 | n = nbytes & ~(AES_BLOCK_SIZE - 1); | |
| 239 | 239 | cpacf_kmc(sctx->fc | modifier, ¶m, | |
| @@ -359,7 +359,7 @@ static int xts_aes_crypt(struct skcipher_request *req, unsigned long modifier) | |||
| 359 | 359 | memcpy(xts_param.key + offset, xts_ctx->key, xts_ctx->key_len); | |
| 360 | 360 | memcpy(xts_param.init, pcc_param.xts, 16); | |
| 361 | 361 | ||
| 362 | - | while ((nbytes = walk.nbytes) != 0) { | |
| 362 | + | while (!ret && ((nbytes = walk.nbytes) != 0)) { | |
| 363 | 363 | /* only use complete blocks */ | |
| 364 | 364 | n = nbytes & ~(AES_BLOCK_SIZE - 1); | |
| 365 | 365 | cpacf_km(xts_ctx->fc | modifier, xts_param.key + offset, | |
| @@ -487,7 +487,7 @@ static int fullxts_aes_crypt(struct skcipher_request *req, unsigned long modifi | |||
| 487 | 487 | memcpy(fxts_param.tweak, req->iv, AES_BLOCK_SIZE); | |
| 488 | 488 | fxts_param.nap[0] = 0x01; /* initial alpha power (1, little-endian) */ | |
| 489 | 489 | ||
| 490 | - | while ((nbytes = walk.nbytes) != 0) { | |
| 490 | + | while (!ret && ((nbytes = walk.nbytes) != 0)) { | |
| 491 | 491 | /* only use complete blocks */ | |
| 492 | 492 | n = nbytes & ~(AES_BLOCK_SIZE - 1); | |
| 493 | 493 | cpacf_km(xts_ctx->fc | modifier, fxts_param.key + offset, | |
| @@ -562,48 +562,64 @@ static unsigned int __ctrblk_init(u8 *ctrptr, u8 *iv, unsigned int nbytes) | |||
| 562 | 562 | return n; | |
| 563 | 563 | } | |
| 564 | 564 | ||
| 565 | + | static int __ctr_aes_crypt(struct s390_aes_ctx *sctx, | |
| 566 | + | struct skcipher_walk *walk, bool locked) | |
| 567 | + | { | |
| 568 | + | unsigned int n, nbytes; | |
| 569 | + | int ret = 0; | |
| 570 | + | u8 *ctrptr; | |
| 571 | + | ||
| 572 | + | while (!ret && ((nbytes = walk->nbytes) >= AES_BLOCK_SIZE)) { | |
| 573 | + | n = AES_BLOCK_SIZE; | |
| 574 | + | if (nbytes >= 2 * AES_BLOCK_SIZE && locked) | |
| 575 | + | n = __ctrblk_init(ctrblk, walk->iv, nbytes); | |
| 576 | + | ctrptr = (n > AES_BLOCK_SIZE) ? ctrblk : walk->iv; | |
| 577 | + | cpacf_kmctr(sctx->fc, sctx->key, walk->dst.virt.addr, | |
| 578 | + | walk->src.virt.addr, n, ctrptr); | |
| 579 | + | if (ctrptr == ctrblk) | |
| 580 | + | memcpy(walk->iv, ctrptr + n - AES_BLOCK_SIZE, | |
| 581 | + | AES_BLOCK_SIZE); | |
| 582 | + | crypto_inc(walk->iv, AES_BLOCK_SIZE); | |
| 583 | + | ret = skcipher_walk_done(walk, nbytes - n); | |
| 584 | + | } | |
| 585 | + | ||
| 586 | + | return ret; | |
| 587 | + | } | |
| 588 | + | ||
| 565 | 589 | static int ctr_aes_crypt(struct skcipher_request *req) | |
| 566 | 590 | { | |
| 567 | 591 | struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); | |
| 568 | 592 | struct s390_aes_ctx *sctx = crypto_skcipher_ctx(tfm); | |
| 569 | - | u8 buf[AES_BLOCK_SIZE], *ctrptr; | |
| 570 | 593 | struct skcipher_walk walk; | |
| 571 | - | unsigned int n, nbytes; | |
| 572 | - | int ret, locked; | |
| 594 | + | u8 buf[AES_BLOCK_SIZE]; | |
| 595 | + | int ret; | |
| 573 | 596 | ||
| 574 | 597 | if (unlikely(!sctx->fc)) | |
| 575 | 598 | return fallback_skcipher_crypt(sctx, req, 0); | |
| 576 | 599 | ||
| 577 | - | locked = mutex_trylock(&ctrblk_lock); | |
| 578 | - | ||
| 579 | 600 | ret = skcipher_walk_virt(&walk, req, false); | |
| 580 | - | while ((nbytes = walk.nbytes) >= AES_BLOCK_SIZE) { | |
| 581 | - | n = AES_BLOCK_SIZE; | |
| 601 | + | if (ret) | |
| 602 | + | return ret; | |
| 582 | 603 | ||
| 583 | - | if (nbytes >= 2*AES_BLOCK_SIZE && locked) | |
| 584 | - | n = __ctrblk_init(ctrblk, walk.iv, nbytes); | |
| 585 | - | ctrptr = (n > AES_BLOCK_SIZE) ? ctrblk : walk.iv; | |
| 586 | - | cpacf_kmctr(sctx->fc, sctx->key, walk.dst.virt.addr, | |
| 587 | - | walk.src.virt.addr, n, ctrptr); | |
| 588 | - | if (ctrptr == ctrblk) | |
| 589 | - | memcpy(walk.iv, ctrptr + n - AES_BLOCK_SIZE, | |
| 590 | - | AES_BLOCK_SIZE); | |
| 591 | - | crypto_inc(walk.iv, AES_BLOCK_SIZE); | |
| 592 | - | ret = skcipher_walk_done(&walk, nbytes - n); | |
| 604 | + | if (down_trylock(&ctrblk_sem) == 0) { | |
| 605 | + | ret = __ctr_aes_crypt(sctx, &walk, true); | |
| 606 | + | up(&ctrblk_sem); | |
| 607 | + | } else { | |
| 608 | + | ret = __ctr_aes_crypt(sctx, &walk, false); | |
| 593 | 609 | } | |
| 594 | - | if (locked) | |
| 595 | - | mutex_unlock(&ctrblk_lock); | |
| 610 | + | ||
| 596 | 611 | /* | |
| 597 | 612 | * final block may be < AES_BLOCK_SIZE, copy only nbytes | |
| 598 | 613 | */ | |
| 599 | - | if (nbytes) { | |
| 614 | + | if (!ret && walk.nbytes > 0) { | |
| 600 | 615 | memset(buf, 0, AES_BLOCK_SIZE); | |
| 601 | - | memcpy(buf, walk.src.virt.addr, nbytes); | |
| 616 | + | memcpy(buf, walk.src.virt.addr, walk.nbytes); | |
| 602 | 617 | cpacf_kmctr(sctx->fc, sctx->key, buf, buf, | |
| 603 | 618 | AES_BLOCK_SIZE, walk.iv); | |
| 604 | - | memcpy(walk.dst.virt.addr, buf, nbytes); | |
| 619 | + | memcpy(walk.dst.virt.addr, buf, walk.nbytes); | |
| 605 | 620 | crypto_inc(walk.iv, AES_BLOCK_SIZE); | |
| 606 | 621 | ret = skcipher_walk_done(&walk, 0); | |
| 622 | + | memzero_explicit(buf, sizeof(buf)); | |
| 607 | 623 | } | |
| 608 | 624 | ||
| 609 | 625 | return ret; | |
| @@ -895,10 +911,14 @@ static int gcm_aes_crypt(struct aead_request *req, unsigned int flags) | |||
| 895 | 911 | gw_in.ptr, aad_bytes); | |
| 896 | 912 | ||
| 897 | 913 | n = aad_bytes + pc_bytes; | |
| 898 | - | if (gcm_in_walk_done(&gw_in, n) != n) | |
| 899 | - | return -ENOMEM; | |
| 900 | - | if (gcm_out_walk_done(&gw_out, n) != n) | |
| 901 | - | return -ENOMEM; | |
| 914 | + | if (gcm_in_walk_done(&gw_in, n) != n) { | |
| 915 | + | ret = -ENOMEM; | |
| 916 | + | goto out; | |
| 917 | + | } | |
| 918 | + | if (gcm_out_walk_done(&gw_out, n) != n) { | |
| 919 | + | ret = -ENOMEM; | |
| 920 | + | goto out; | |
| 921 | + | } | |
| 902 | 922 | aadlen -= aad_bytes; | |
| 903 | 923 | pclen -= pc_bytes; | |
| 904 | 924 | } while (aadlen + pclen > 0); | |
| @@ -910,7 +930,10 @@ static int gcm_aes_crypt(struct aead_request *req, unsigned int flags) | |||
| 910 | 930 | } else | |
| 911 | 931 | scatterwalk_map_and_copy(param.t, req->dst, len, taglen, 1); | |
| 912 | 932 | ||
| 933 | + | out: | |
| 913 | 934 | memzero_explicit(¶m, sizeof(param)); | |
| 935 | + | memzero_explicit(gw_in.buf, sizeof(gw_in.buf)); | |
| 936 | + | memzero_explicit(gw_out.buf, sizeof(gw_out.buf)); | |
| 914 | 937 | return ret; | |
| 915 | 938 | } | |
| 916 | 939 | ||
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/crypto/paes_s390.c
| @@ -19,7 +19,7 @@ | |||
| 19 | 19 | #include <linux/init.h> | |
| 20 | 20 | #include <linux/miscdevice.h> | |
| 21 | 21 | #include <linux/module.h> | |
| 22 | - | #include <linux/mutex.h> | |
| 22 | + | #include <linux/semaphore.h> | |
| 23 | 23 | #include <linux/spinlock.h> | |
| 24 | 24 | #include <crypto/aes.h> | |
| 25 | 25 | #include <crypto/algapi.h> | |
| @@ -45,7 +45,7 @@ module_param_named(clrkey, pkey_clrkey_allowed, bool, 0444); | |||
| 45 | 45 | MODULE_PARM_DESC(clrkey, "Allow clear key material (default N)"); | |
| 46 | 46 | ||
| 47 | 47 | static u8 *ctrblk; | |
| 48 | - | static DEFINE_MUTEX(ctrblk_lock); | |
| 48 | + | static DEFINE_SEMAPHORE(ctrblk_sem, 1); | |
| 49 | 49 | ||
| 50 | 50 | static cpacf_mask_t km_functions, kmc_functions, kmctr_functions; | |
| 51 | 51 | ||
| @@ -220,6 +220,10 @@ static inline int convert_key(const u8 *key, unsigned int keylen, | |||
| 220 | 220 | xflags); | |
| 221 | 221 | } | |
| 222 | 222 | ||
| 223 | + | /* But finally map -EBUSY to -EIO to indicate an IO failure */ | |
| 224 | + | if (rc == -EBUSY) | |
| 225 | + | rc = -EIO; | |
| 226 | + | ||
| 223 | 227 | out: | |
| 224 | 228 | pr_debug("rc=%d\n", rc); | |
| 225 | 229 | return rc; | |
| @@ -432,8 +436,11 @@ static int ecb_paes_do_crypt(struct s390_paes_ctx *ctx, | |||
| 432 | 436 | n = nbytes & ~(AES_BLOCK_SIZE - 1); | |
| 433 | 437 | k = cpacf_km(ctx->fc | req_ctx->modifier, param, | |
| 434 | 438 | walk->dst.virt.addr, walk->src.virt.addr, n); | |
| 435 | - | if (k) | |
| 439 | + | if (k) { | |
| 436 | 440 | rc = skcipher_walk_done(walk, nbytes - k); | |
| 441 | + | if (rc) | |
| 442 | + | goto out; | |
| 443 | + | } | |
| 437 | 444 | if (k < n) { | |
| 438 | 445 | if (!maysleep) { | |
| 439 | 446 | rc = -EKEYEXPIRED; | |
| @@ -460,6 +467,7 @@ static int ecb_paes_crypt(struct skcipher_request *req, unsigned long modifier) | |||
| 460 | 467 | struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm); | |
| 461 | 468 | struct skcipher_walk *walk = &req_ctx->walk; | |
| 462 | 469 | bool tested = crypto_skcipher_tested(tfm); | |
| 470 | + | bool cleanup = true; | |
| 463 | 471 | int rc; | |
| 464 | 472 | ||
| 465 | 473 | /* | |
| @@ -491,15 +499,17 @@ static int ecb_paes_crypt(struct skcipher_request *req, unsigned long modifier) | |||
| 491 | 499 | if (rc == 0 || rc == -EKEYEXPIRED) { | |
| 492 | 500 | atomic_inc(&ctx->via_engine_ctr); | |
| 493 | 501 | rc = crypto_transfer_skcipher_request_to_engine(paes_crypto_engine, req); | |
| 494 | - | if (rc != -EINPROGRESS) | |
| 502 | + | if (rc == -EINPROGRESS || rc == -EBUSY) | |
| 503 | + | cleanup = false; | |
| 504 | + | else | |
| 495 | 505 | atomic_dec(&ctx->via_engine_ctr); | |
| 496 | 506 | } | |
| 497 | 507 | ||
| 498 | - | if (rc != -EINPROGRESS) | |
| 508 | + | if (cleanup && walk->nbytes) | |
| 499 | 509 | skcipher_walk_done(walk, rc); | |
| 500 | 510 | ||
| 501 | 511 | out: | |
| 502 | - | if (rc != -EINPROGRESS) | |
| 512 | + | if (cleanup) | |
| 503 | 513 | memzero_explicit(&req_ctx->param, sizeof(req_ctx->param)); | |
| 504 | 514 | pr_debug("rc=%d\n", rc); | |
| 505 | 515 | return rc; | |
| @@ -549,7 +559,7 @@ static int ecb_paes_do_one_request(struct crypto_engine *engine, void *areq) | |||
| 549 | 559 | rc = ecb_paes_do_crypt(ctx, req_ctx, tested, true); | |
| 550 | 560 | if (rc == -EKEYEXPIRED) { | |
| 551 | 561 | return pkey_handle_expired(); | |
| 552 | - | } else if (rc) { | |
| 562 | + | } else if (rc && walk->nbytes) { | |
| 553 | 563 | skcipher_walk_done(walk, rc); | |
| 554 | 564 | } | |
| 555 | 565 | ||
| @@ -559,7 +569,7 @@ static int ecb_paes_do_one_request(struct crypto_engine *engine, void *areq) | |||
| 559 | 569 | atomic_dec(&ctx->via_engine_ctr); | |
| 560 | 570 | crypto_finalize_skcipher_request(engine, req, rc); | |
| 561 | 571 | local_bh_enable(); | |
| 562 | - | return rc; | |
| 572 | + | return 0; | |
| 563 | 573 | } | |
| 564 | 574 | ||
| 565 | 575 | static struct skcipher_engine_alg ecb_paes_alg = { | |
| @@ -567,6 +577,7 @@ static struct skcipher_engine_alg ecb_paes_alg = { | |||
| 567 | 577 | .base.cra_name = "ecb(paes)", | |
| 568 | 578 | .base.cra_driver_name = "ecb-paes-s390", | |
| 569 | 579 | .base.cra_priority = 401, /* combo: aes + ecb + 1 */ | |
| 580 | + | .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NO_FALLBACK, | |
| 570 | 581 | .base.cra_blocksize = AES_BLOCK_SIZE, | |
| 571 | 582 | .base.cra_ctxsize = sizeof(struct s390_paes_ctx), | |
| 572 | 583 | .base.cra_module = THIS_MODULE, | |
| @@ -690,6 +701,8 @@ static int cbc_paes_do_crypt(struct s390_paes_ctx *ctx, | |||
| 690 | 701 | if (k) { | |
| 691 | 702 | memcpy(walk->iv, param->iv, AES_BLOCK_SIZE); | |
| 692 | 703 | rc = skcipher_walk_done(walk, nbytes - k); | |
| 704 | + | if (rc) | |
| 705 | + | goto out; | |
| 693 | 706 | } | |
| 694 | 707 | if (k < n) { | |
| 695 | 708 | if (!maysleep) { | |
| @@ -717,6 +730,7 @@ static int cbc_paes_crypt(struct skcipher_request *req, unsigned long modifier) | |||
| 717 | 730 | struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm); | |
| 718 | 731 | struct skcipher_walk *walk = &req_ctx->walk; | |
| 719 | 732 | bool tested = crypto_skcipher_tested(tfm); | |
| 733 | + | bool cleanup = true; | |
| 720 | 734 | int rc; | |
| 721 | 735 | ||
| 722 | 736 | /* | |
| @@ -748,15 +762,17 @@ static int cbc_paes_crypt(struct skcipher_request *req, unsigned long modifier) | |||
| 748 | 762 | if (rc == 0 || rc == -EKEYEXPIRED) { | |
| 749 | 763 | atomic_inc(&ctx->via_engine_ctr); | |
| 750 | 764 | rc = crypto_transfer_skcipher_request_to_engine(paes_crypto_engine, req); | |
| 751 | - | if (rc != -EINPROGRESS) | |
| 765 | + | if (rc == -EINPROGRESS || rc == -EBUSY) | |
| 766 | + | cleanup = false; | |
| 767 | + | else | |
| 752 | 768 | atomic_dec(&ctx->via_engine_ctr); | |
| 753 | 769 | } | |
| 754 | 770 | ||
| 755 | - | if (rc != -EINPROGRESS) | |
| 771 | + | if (cleanup && walk->nbytes) | |
| 756 | 772 | skcipher_walk_done(walk, rc); | |
| 757 | 773 | ||
| 758 | 774 | out: | |
| 759 | - | if (rc != -EINPROGRESS) | |
| 775 | + | if (cleanup) | |
| 760 | 776 | memzero_explicit(&req_ctx->param, sizeof(req_ctx->param)); | |
| 761 | 777 | pr_debug("rc=%d\n", rc); | |
| 762 | 778 | return rc; | |
| @@ -806,7 +822,7 @@ static int cbc_paes_do_one_request(struct crypto_engine *engine, void *areq) | |||
| 806 | 822 | rc = cbc_paes_do_crypt(ctx, req_ctx, tested, true); | |
| 807 | 823 | if (rc == -EKEYEXPIRED) { | |
| 808 | 824 | return pkey_handle_expired(); | |
| 809 | - | } else if (rc) { | |
| 825 | + | } else if (rc && walk->nbytes) { | |
| 810 | 826 | skcipher_walk_done(walk, rc); | |
| 811 | 827 | } | |
| 812 | 828 | ||
| @@ -816,7 +832,7 @@ static int cbc_paes_do_one_request(struct crypto_engine *engine, void *areq) | |||
| 816 | 832 | atomic_dec(&ctx->via_engine_ctr); | |
| 817 | 833 | crypto_finalize_skcipher_request(engine, req, rc); | |
| 818 | 834 | local_bh_enable(); | |
| 819 | - | return rc; | |
| 835 | + | return 0; | |
| 820 | 836 | } | |
| 821 | 837 | ||
| 822 | 838 | static struct skcipher_engine_alg cbc_paes_alg = { | |
| @@ -824,6 +840,7 @@ static struct skcipher_engine_alg cbc_paes_alg = { | |||
| 824 | 840 | .base.cra_name = "cbc(paes)", | |
| 825 | 841 | .base.cra_driver_name = "cbc-paes-s390", | |
| 826 | 842 | .base.cra_priority = 402, /* cbc-paes-s390 + 1 */ | |
| 843 | + | .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NO_FALLBACK, | |
| 827 | 844 | .base.cra_blocksize = AES_BLOCK_SIZE, | |
| 828 | 845 | .base.cra_ctxsize = sizeof(struct s390_paes_ctx), | |
| 829 | 846 | .base.cra_module = THIS_MODULE, | |
| @@ -914,41 +931,14 @@ static inline unsigned int __ctrblk_init(u8 *ctrptr, u8 *iv, unsigned int nbytes | |||
| 914 | 931 | return n; | |
| 915 | 932 | } | |
| 916 | 933 | ||
| 917 | - | static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx, | |
| 918 | - | struct s390_pctr_req_ctx *req_ctx, | |
| 919 | - | bool tested, bool maysleep) | |
| 934 | + | static int __ctr_paes_do_crypt(struct s390_paes_ctx *ctx, | |
| 935 | + | struct ctr_param *param, | |
| 936 | + | struct skcipher_walk *walk, | |
| 937 | + | bool tested, bool maysleep, bool locked) | |
| 920 | 938 | { | |
| 921 | - | struct ctr_param *param = &req_ctx->param; | |
| 922 | - | struct skcipher_walk *walk = &req_ctx->walk; | |
| 923 | - | u8 buf[AES_BLOCK_SIZE], *ctrptr; | |
| 924 | 939 | unsigned int nbytes, n, k; | |
| 925 | - | int pk_state, locked, rc = 0; | |
| 926 | - | ||
| 927 | - | if (!req_ctx->param_init_done) { | |
| 928 | - | /* fetch and check protected key state */ | |
| 929 | - | spin_lock_bh(&ctx->pk_lock); | |
| 930 | - | pk_state = ctx->pk_state; | |
| 931 | - | switch (pk_state) { | |
| 932 | - | case PK_STATE_NO_KEY: | |
| 933 | - | rc = -ENOKEY; | |
| 934 | - | break; | |
| 935 | - | case PK_STATE_CONVERT_IN_PROGRESS: | |
| 936 | - | rc = -EKEYEXPIRED; | |
| 937 | - | break; | |
| 938 | - | case PK_STATE_VALID: | |
| 939 | - | memcpy(param->key, ctx->pk.protkey, sizeof(param->key)); | |
| 940 | - | req_ctx->param_init_done = true; | |
| 941 | - | break; | |
| 942 | - | default: | |
| 943 | - | rc = pk_state < 0 ? pk_state : -EIO; | |
| 944 | - | break; | |
| 945 | - | } | |
| 946 | - | spin_unlock_bh(&ctx->pk_lock); | |
| 947 | - | } | |
| 948 | - | if (rc) | |
| 949 | - | goto out; | |
| 950 | - | ||
| 951 | - | locked = mutex_trylock(&ctrblk_lock); | |
| 940 | + | u8 *ctrptr; | |
| 941 | + | int rc = 0; | |
| 952 | 942 | ||
| 953 | 943 | /* | |
| 954 | 944 | * Note that in case of partial processing or failure the walk | |
| @@ -968,32 +958,71 @@ static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx, | |||
| 968 | 958 | AES_BLOCK_SIZE); | |
| 969 | 959 | crypto_inc(walk->iv, AES_BLOCK_SIZE); | |
| 970 | 960 | rc = skcipher_walk_done(walk, nbytes - k); | |
| 961 | + | if (rc) | |
| 962 | + | goto out; | |
| 971 | 963 | } | |
| 972 | 964 | if (k < n) { | |
| 973 | 965 | if (!maysleep) { | |
| 974 | - | if (locked) | |
| 975 | - | mutex_unlock(&ctrblk_lock); | |
| 976 | 966 | rc = -EKEYEXPIRED; | |
| 977 | 967 | goto out; | |
| 978 | 968 | } | |
| 979 | 969 | rc = paes_convert_key(ctx, tested); | |
| 980 | - | if (rc) { | |
| 981 | - | if (locked) | |
| 982 | - | mutex_unlock(&ctrblk_lock); | |
| 970 | + | if (rc) | |
| 983 | 971 | goto out; | |
| 984 | - | } | |
| 985 | 972 | spin_lock_bh(&ctx->pk_lock); | |
| 986 | 973 | memcpy(param->key, ctx->pk.protkey, sizeof(param->key)); | |
| 987 | 974 | spin_unlock_bh(&ctx->pk_lock); | |
| 988 | 975 | } | |
| 989 | 976 | } | |
| 990 | - | if (locked) | |
| 991 | - | mutex_unlock(&ctrblk_lock); | |
| 977 | + | ||
| 978 | + | out: | |
| 979 | + | return rc; | |
| 980 | + | } | |
| 981 | + | ||
| 982 | + | static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx, | |
| 983 | + | struct s390_pctr_req_ctx *req_ctx, | |
| 984 | + | bool tested, bool maysleep) | |
| 985 | + | { | |
| 986 | + | struct ctr_param *param = &req_ctx->param; | |
| 987 | + | struct skcipher_walk *walk = &req_ctx->walk; | |
| 988 | + | u8 buf[AES_BLOCK_SIZE]; | |
| 989 | + | int pk_state, rc = 0; | |
| 990 | + | ||
| 991 | + | if (!req_ctx->param_init_done) { | |
| 992 | + | /* fetch and check protected key state */ | |
| 993 | + | spin_lock_bh(&ctx->pk_lock); | |
| 994 | + | pk_state = ctx->pk_state; | |
| 995 | + | switch (pk_state) { | |
| 996 | + | case PK_STATE_NO_KEY: | |
| 997 | + | rc = -ENOKEY; | |
| 998 | + | break; | |
| 999 | + | case PK_STATE_CONVERT_IN_PROGRESS: | |
| 1000 | + | rc = -EKEYEXPIRED; | |
| 1001 | + | break; | |
| 1002 | + | case PK_STATE_VALID: | |
| 1003 | + | memcpy(param->key, ctx->pk.protkey, sizeof(param->key)); | |
| 1004 | + | req_ctx->param_init_done = true; | |
| 1005 | + | break; | |
| 1006 | + | default: | |
| 1007 | + | rc = pk_state < 0 ? pk_state : -EIO; | |
| 1008 | + | break; | |
| 1009 | + | } | |
| 1010 | + | spin_unlock_bh(&ctx->pk_lock); | |
| 1011 | + | } | |
| 1012 | + | if (rc) | |
| 1013 | + | goto out; | |
| 1014 | + | ||
| 1015 | + | if (down_trylock(&ctrblk_sem) == 0) { | |
| 1016 | + | rc = __ctr_paes_do_crypt(ctx, param, walk, tested, maysleep, true); | |
| 1017 | + | up(&ctrblk_sem); | |
| 1018 | + | } else { | |
| 1019 | + | rc = __ctr_paes_do_crypt(ctx, param, walk, tested, maysleep, false); | |
| 1020 | + | } | |
| 992 | 1021 | ||
| 993 | 1022 | /* final block may be < AES_BLOCK_SIZE, copy only nbytes */ | |
| 994 | - | if (nbytes) { | |
| 1023 | + | if (!rc && walk->nbytes > 0) { | |
| 995 | 1024 | memset(buf, 0, AES_BLOCK_SIZE); | |
| 996 | - | memcpy(buf, walk->src.virt.addr, nbytes); | |
| 1025 | + | memcpy(buf, walk->src.virt.addr, walk->nbytes); | |
| 997 | 1026 | while (1) { | |
| 998 | 1027 | if (cpacf_kmctr(ctx->fc, param, buf, | |
| 999 | 1028 | buf, AES_BLOCK_SIZE, | |
| @@ -1010,12 +1039,13 @@ static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx, | |||
| 1010 | 1039 | memcpy(param->key, ctx->pk.protkey, sizeof(param->key)); | |
| 1011 | 1040 | spin_unlock_bh(&ctx->pk_lock); | |
| 1012 | 1041 | } | |
| 1013 | - | memcpy(walk->dst.virt.addr, buf, nbytes); | |
| 1042 | + | memcpy(walk->dst.virt.addr, buf, walk->nbytes); | |
| 1014 | 1043 | crypto_inc(walk->iv, AES_BLOCK_SIZE); | |
| 1015 | 1044 | rc = skcipher_walk_done(walk, 0); | |
| 1016 | 1045 | } | |
| 1017 | 1046 | ||
| 1018 | 1047 | out: | |
| 1048 | + | memzero_explicit(buf, sizeof(buf)); | |
| 1019 | 1049 | pr_debug("rc=%d\n", rc); | |
| 1020 | 1050 | return rc; | |
| 1021 | 1051 | } | |
| @@ -1027,6 +1057,7 @@ static int ctr_paes_crypt(struct skcipher_request *req) | |||
| 1027 | 1057 | struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm); | |
| 1028 | 1058 | struct skcipher_walk *walk = &req_ctx->walk; | |
| 1029 | 1059 | bool tested = crypto_skcipher_tested(tfm); | |
| 1060 | + | bool cleanup = true; | |
| 1030 | 1061 | int rc; | |
| 1031 | 1062 | ||
| 1032 | 1063 | /* | |
| @@ -1057,15 +1088,17 @@ static int ctr_paes_crypt(struct skcipher_request *req) | |||
| 1057 | 1088 | if (rc == 0 || rc == -EKEYEXPIRED) { | |
| 1058 | 1089 | atomic_inc(&ctx->via_engine_ctr); | |
| 1059 | 1090 | rc = crypto_transfer_skcipher_request_to_engine(paes_crypto_engine, req); | |
| 1060 | - | if (rc != -EINPROGRESS) | |
| 1091 | + | if (rc == -EINPROGRESS || rc == -EBUSY) | |
| 1092 | + | cleanup = false; | |
| 1093 | + | else | |
| 1061 | 1094 | atomic_dec(&ctx->via_engine_ctr); | |
| 1062 | 1095 | } | |
| 1063 | 1096 | ||
| 1064 | - | if (rc != -EINPROGRESS) | |
| 1097 | + | if (cleanup && walk->nbytes) | |
| 1065 | 1098 | skcipher_walk_done(walk, rc); | |
| 1066 | 1099 | ||
| 1067 | 1100 | out: | |
| 1068 | - | if (rc != -EINPROGRESS) | |
| 1101 | + | if (cleanup) | |
| 1069 | 1102 | memzero_explicit(&req_ctx->param, sizeof(req_ctx->param)); | |
| 1070 | 1103 | pr_debug("rc=%d\n", rc); | |
| 1071 | 1104 | return rc; | |
| @@ -1105,7 +1138,7 @@ static int ctr_paes_do_one_request(struct crypto_engine *engine, void *areq) | |||
| 1105 | 1138 | rc = ctr_paes_do_crypt(ctx, req_ctx, tested, true); | |
| 1106 | 1139 | if (rc == -EKEYEXPIRED) { | |
| 1107 | 1140 | return pkey_handle_expired(); | |
| 1108 | - | } else if (rc) { | |
| 1141 | + | } else if (rc && walk->nbytes) { | |
| 1109 | 1142 | skcipher_walk_done(walk, rc); | |
| 1110 | 1143 | } | |
| 1111 | 1144 | ||
| @@ -1115,7 +1148,7 @@ static int ctr_paes_do_one_request(struct crypto_engine *engine, void *areq) | |||
| 1115 | 1148 | atomic_dec(&ctx->via_engine_ctr); | |
| 1116 | 1149 | crypto_finalize_skcipher_request(engine, req, rc); | |
| 1117 | 1150 | local_bh_enable(); | |
| 1118 | - | return rc; | |
| 1151 | + | return 0; | |
| 1119 | 1152 | } | |
| 1120 | 1153 | ||
| 1121 | 1154 | static struct skcipher_engine_alg ctr_paes_alg = { | |
| @@ -1123,6 +1156,7 @@ static struct skcipher_engine_alg ctr_paes_alg = { | |||
| 1123 | 1156 | .base.cra_name = "ctr(paes)", | |
| 1124 | 1157 | .base.cra_driver_name = "ctr-paes-s390", | |
| 1125 | 1158 | .base.cra_priority = 402, /* ecb-paes-s390 + 1 */ | |
| 1159 | + | .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NO_FALLBACK, | |
| 1126 | 1160 | .base.cra_blocksize = 1, | |
| 1127 | 1161 | .base.cra_ctxsize = sizeof(struct s390_paes_ctx), | |
| 1128 | 1162 | .base.cra_module = THIS_MODULE, | |
| @@ -1283,8 +1317,11 @@ static int xts_paes_do_crypt_fullkey(struct s390_pxts_ctx *ctx, | |||
| 1283 | 1317 | n = nbytes & ~(AES_BLOCK_SIZE - 1); | |
| 1284 | 1318 | k = cpacf_km(ctx->fc | req_ctx->modifier, param->key + offset, | |
| 1285 | 1319 | walk->dst.virt.addr, walk->src.virt.addr, n); | |
| 1286 | - | if (k) | |
| 1320 | + | if (k) { | |
| 1287 | 1321 | rc = skcipher_walk_done(walk, nbytes - k); | |
| 1322 | + | if (rc) | |
| 1323 | + | goto out; | |
| 1324 | + | } | |
| 1288 | 1325 | if (k < n) { | |
| 1289 | 1326 | if (!maysleep) { | |
| 1290 | 1327 | rc = -EKEYEXPIRED; | |
| @@ -1337,7 +1374,7 @@ static inline int __xts_2keys_prep_param(struct s390_pxts_ctx *ctx, | |||
| 1337 | 1374 | memcpy(param->init, pcc_param.xts, 16); | |
| 1338 | 1375 | } | |
| 1339 | 1376 | ||
| 1340 | - | memzero_explicit(pcc_param.key, sizeof(pcc_param.key)); | |
| 1377 | + | memzero_explicit(&pcc_param, sizeof(pcc_param)); | |
| 1341 | 1378 | return rc; | |
| 1342 | 1379 | } | |
| 1343 | 1380 | ||
| @@ -1377,8 +1414,11 @@ static int xts_paes_do_crypt_2keys(struct s390_pxts_ctx *ctx, | |||
| 1377 | 1414 | n = nbytes & ~(AES_BLOCK_SIZE - 1); | |
| 1378 | 1415 | k = cpacf_km(ctx->fc | req_ctx->modifier, param->key + offset, | |
| 1379 | 1416 | walk->dst.virt.addr, walk->src.virt.addr, n); | |
| 1380 | - | if (k) | |
| 1417 | + | if (k) { | |
| 1381 | 1418 | rc = skcipher_walk_done(walk, nbytes - k); | |
| 1419 | + | if (rc) | |
| 1420 | + | goto out; | |
| 1421 | + | } | |
| 1382 | 1422 | if (k < n) { | |
| 1383 | 1423 | if (!maysleep) { | |
| 1384 | 1424 | rc = -EKEYEXPIRED; | |
| @@ -1450,6 +1490,7 @@ static inline int xts_paes_crypt(struct skcipher_request *req, unsigned long mod | |||
| 1450 | 1490 | struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm); | |
| 1451 | 1491 | struct skcipher_walk *walk = &req_ctx->walk; | |
| 1452 | 1492 | bool tested = crypto_skcipher_tested(tfm); | |
| 1493 | + | bool cleanup = true; | |
| 1453 | 1494 | int rc; | |
| 1454 | 1495 | ||
| 1455 | 1496 | /* | |
| @@ -1481,15 +1522,17 @@ static inline int xts_paes_crypt(struct skcipher_request *req, unsigned long mod | |||
| 1481 | 1522 | if (rc == 0 || rc == -EKEYEXPIRED) { | |
| 1482 | 1523 | atomic_inc(&ctx->via_engine_ctr); | |
| 1483 | 1524 | rc = crypto_transfer_skcipher_request_to_engine(paes_crypto_engine, req); | |
| 1484 | - | if (rc != -EINPROGRESS) | |
| 1525 | + | if (rc == -EINPROGRESS || rc == -EBUSY) | |
| 1526 | + | cleanup = false; | |
| 1527 | + | else | |
| 1485 | 1528 | atomic_dec(&ctx->via_engine_ctr); | |
| 1486 | 1529 | } | |
| 1487 | 1530 | ||
| 1488 | - | if (rc != -EINPROGRESS) | |
| 1531 | + | if (cleanup && walk->nbytes) | |
| 1489 | 1532 | skcipher_walk_done(walk, rc); | |
| 1490 | 1533 | ||
| 1491 | 1534 | out: | |
| 1492 | - | if (rc != -EINPROGRESS) | |
| 1535 | + | if (cleanup) | |
| 1493 | 1536 | memzero_explicit(&req_ctx->param, sizeof(req_ctx->param)); | |
| 1494 | 1537 | pr_debug("rc=%d\n", rc); | |
| 1495 | 1538 | return rc; | |
| @@ -1539,7 +1582,7 @@ static int xts_paes_do_one_request(struct crypto_engine *engine, void *areq) | |||
| 1539 | 1582 | rc = xts_paes_do_crypt(ctx, req_ctx, tested, true); | |
| 1540 | 1583 | if (rc == -EKEYEXPIRED) { | |
| 1541 | 1584 | return pkey_handle_expired(); | |
| 1542 | - | } else if (rc) { | |
| 1585 | + | } else if (rc && walk->nbytes) { | |
| 1543 | 1586 | skcipher_walk_done(walk, rc); | |
| 1544 | 1587 | } | |
| 1545 | 1588 | ||
| @@ -1549,7 +1592,7 @@ static int xts_paes_do_one_request(struct crypto_engine *engine, void *areq) | |||
| 1549 | 1592 | atomic_dec(&ctx->via_engine_ctr); | |
| 1550 | 1593 | crypto_finalize_skcipher_request(engine, req, rc); | |
| 1551 | 1594 | local_bh_enable(); | |
| 1552 | - | return rc; | |
| 1595 | + | return 0; | |
| 1553 | 1596 | } | |
| 1554 | 1597 | ||
| 1555 | 1598 | static struct skcipher_engine_alg xts_paes_alg = { | |
| @@ -1557,6 +1600,7 @@ static struct skcipher_engine_alg xts_paes_alg = { | |||
| 1557 | 1600 | .base.cra_name = "xts(paes)", | |
| 1558 | 1601 | .base.cra_driver_name = "xts-paes-s390", | |
| 1559 | 1602 | .base.cra_priority = 402, /* ecb-paes-s390 + 1 */ | |
| 1603 | + | .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NO_FALLBACK, | |
| 1560 | 1604 | .base.cra_blocksize = AES_BLOCK_SIZE, | |
| 1561 | 1605 | .base.cra_ctxsize = sizeof(struct s390_pxts_ctx), | |
| 1562 | 1606 | .base.cra_module = THIS_MODULE, | |
modified arch/s390/crypto/phmac_s390.c
| @@ -62,8 +62,10 @@ static inline int hwh_prepare(struct ahash_request *req, | |||
| 62 | 62 | */ | |
| 63 | 63 | static inline int hwh_advance(struct hash_walk_helper *hwh, int n) | |
| 64 | 64 | { | |
| 65 | - | if (n < 0) | |
| 65 | + | if (n < 0) { | |
| 66 | + | hwh->walkbytes = n; | |
| 66 | 67 | return crypto_hash_walk_done(&hwh->walk, n); | |
| 68 | + | } | |
| 67 | 69 | ||
| 68 | 70 | hwh->walkbytes -= n; | |
| 69 | 71 | hwh->walkaddr += n; | |
| @@ -339,6 +341,10 @@ static inline int convert_key(const u8 *key, unsigned int keylen, | |||
| 339 | 341 | xflags); | |
| 340 | 342 | } | |
| 341 | 343 | ||
| 344 | + | /* But finally map -EBUSY to -EIO to indicate an IO failure */ | |
| 345 | + | if (rc == -EBUSY) | |
| 346 | + | rc = -EIO; | |
| 347 | + | ||
| 342 | 348 | out: | |
| 343 | 349 | pr_debug("rc=%d\n", rc); | |
| 344 | 350 | return rc; | |
| @@ -606,6 +612,7 @@ static int phmac_update(struct ahash_request *req) | |||
| 606 | 612 | struct phmac_tfm_ctx *tfm_ctx = crypto_ahash_ctx(tfm); | |
| 607 | 613 | struct kmac_sha2_ctx *kmac_ctx = &req_ctx->kmac_ctx; | |
| 608 | 614 | struct hash_walk_helper *hwh = &req_ctx->hwh; | |
| 615 | + | bool cleanup = true; | |
| 609 | 616 | int rc; | |
| 610 | 617 | ||
| 611 | 618 | /* prep the walk in the request context */ | |
| @@ -629,12 +636,15 @@ static int phmac_update(struct ahash_request *req) | |||
| 629 | 636 | req_ctx->async_op = OP_UPDATE; | |
| 630 | 637 | atomic_inc(&tfm_ctx->via_engine_ctr); | |
| 631 | 638 | rc = crypto_transfer_hash_request_to_engine(phmac_crypto_engine, req); | |
| 632 | - | if (rc != -EINPROGRESS) | |
| 639 | + | if (rc == -EINPROGRESS || rc == -EBUSY) | |
| 640 | + | cleanup = false; | |
| 641 | + | else | |
| 633 | 642 | atomic_dec(&tfm_ctx->via_engine_ctr); | |
| 634 | 643 | } | |
| 635 | 644 | ||
| 636 | - | if (rc != -EINPROGRESS) { | |
| 637 | - | hwh_advance(hwh, rc); | |
| 645 | + | if (cleanup) { | |
| 646 | + | if (hwh->walkbytes > 0) | |
| 647 | + | hwh_advance(hwh, rc); | |
| 638 | 648 | memzero_explicit(kmac_ctx, sizeof(*kmac_ctx)); | |
| 639 | 649 | } | |
| 640 | 650 | ||
| @@ -649,6 +659,7 @@ static int phmac_final(struct ahash_request *req) | |||
| 649 | 659 | struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); | |
| 650 | 660 | struct phmac_tfm_ctx *tfm_ctx = crypto_ahash_ctx(tfm); | |
| 651 | 661 | struct kmac_sha2_ctx *kmac_ctx = &req_ctx->kmac_ctx; | |
| 662 | + | bool cleanup = true; | |
| 652 | 663 | int rc = 0; | |
| 653 | 664 | ||
| 654 | 665 | /* Try synchronous operation if no active engine usage */ | |
| @@ -667,12 +678,14 @@ static int phmac_final(struct ahash_request *req) | |||
| 667 | 678 | req_ctx->async_op = OP_FINAL; | |
| 668 | 679 | atomic_inc(&tfm_ctx->via_engine_ctr); | |
| 669 | 680 | rc = crypto_transfer_hash_request_to_engine(phmac_crypto_engine, req); | |
| 670 | - | if (rc != -EINPROGRESS) | |
| 681 | + | if (rc == -EINPROGRESS || rc == -EBUSY) | |
| 682 | + | cleanup = false; | |
| 683 | + | else | |
| 671 | 684 | atomic_dec(&tfm_ctx->via_engine_ctr); | |
| 672 | 685 | } | |
| 673 | 686 | ||
| 674 | 687 | out: | |
| 675 | - | if (rc != -EINPROGRESS) | |
| 688 | + | if (cleanup) | |
| 676 | 689 | memzero_explicit(kmac_ctx, sizeof(*kmac_ctx)); | |
| 677 | 690 | pr_debug("rc=%d\n", rc); | |
| 678 | 691 | return rc; | |
| @@ -685,6 +698,7 @@ static int phmac_finup(struct ahash_request *req) | |||
| 685 | 698 | struct phmac_tfm_ctx *tfm_ctx = crypto_ahash_ctx(tfm); | |
| 686 | 699 | struct kmac_sha2_ctx *kmac_ctx = &req_ctx->kmac_ctx; | |
| 687 | 700 | struct hash_walk_helper *hwh = &req_ctx->hwh; | |
| 701 | + | bool cleanup = true; | |
| 688 | 702 | int rc; | |
| 689 | 703 | ||
| 690 | 704 | /* prep the walk in the request context */ | |
| @@ -716,15 +730,17 @@ static int phmac_finup(struct ahash_request *req) | |||
| 716 | 730 | /* req->async_op has been set to either OP_FINUP or OP_FINAL */ | |
| 717 | 731 | atomic_inc(&tfm_ctx->via_engine_ctr); | |
| 718 | 732 | rc = crypto_transfer_hash_request_to_engine(phmac_crypto_engine, req); | |
| 719 | - | if (rc != -EINPROGRESS) | |
| 733 | + | if (rc == -EINPROGRESS || rc == -EBUSY) | |
| 734 | + | cleanup = false; | |
| 735 | + | else | |
| 720 | 736 | atomic_dec(&tfm_ctx->via_engine_ctr); | |
| 721 | 737 | } | |
| 722 | 738 | ||
| 723 | - | if (rc != -EINPROGRESS) | |
| 739 | + | if (cleanup && hwh->walkbytes > 0) | |
| 724 | 740 | hwh_advance(hwh, rc); | |
| 725 | 741 | ||
| 726 | 742 | out: | |
| 727 | - | if (rc != -EINPROGRESS) | |
| 743 | + | if (cleanup) | |
| 728 | 744 | memzero_explicit(kmac_ctx, sizeof(*kmac_ctx)); | |
| 729 | 745 | pr_debug("rc=%d\n", rc); | |
| 730 | 746 | return rc; | |
| @@ -914,7 +930,7 @@ out: | |||
| 914 | 930 | atomic_dec(&tfm_ctx->via_engine_ctr); | |
| 915 | 931 | crypto_finalize_hash_request(engine, req, rc); | |
| 916 | 932 | local_bh_enable(); | |
| 917 | - | return rc; | |
| 933 | + | return 0; | |
| 918 | 934 | } | |
| 919 | 935 | ||
| 920 | 936 | #define S390_ASYNC_PHMAC_ALG(x) \ | |
modified arch/s390/include/asm/cpacf.h
| @@ -301,6 +301,7 @@ static __always_inline void __cpacf_query(unsigned int opcode, | |||
| 301 | 301 | cpacf_mask_t *mask) | |
| 302 | 302 | { | |
| 303 | 303 | __cpacf_query_insn(opcode, mask, CPACF_FC_QUERY); | |
| 304 | + | kmsan_unpoison_memory(mask, sizeof(*mask)); | |
| 304 | 305 | } | |
| 305 | 306 | ||
| 306 | 307 | static __always_inline int __cpacf_check_opcode(unsigned int opcode) | |
| @@ -370,6 +371,7 @@ static __always_inline int cpacf_query_func(unsigned int opcode, | |||
| 370 | 371 | static __always_inline void __cpacf_qai(unsigned int opcode, cpacf_qai_t *qai) | |
| 371 | 372 | { | |
| 372 | 373 | __cpacf_query_insn(opcode, qai, CPACF_FC_QUERY_AUTH_INFO); | |
| 374 | + | kmsan_unpoison_memory(qai, sizeof(*qai)); | |
| 373 | 375 | } | |
| 374 | 376 | ||
| 375 | 377 | /** | |
| @@ -422,6 +424,7 @@ static inline int cpacf_km(unsigned long func, void *param, | |||
| 422 | 424 | [opc] "i" (CPACF_KM) | |
| 423 | 425 | : "cc", "memory", "0", "1"); | |
| 424 | 426 | ||
| 427 | + | kmsan_unpoison_memory(dest, src_len - s.odd); | |
| 425 | 428 | return src_len - s.odd; | |
| 426 | 429 | } | |
| 427 | 430 | ||
| @@ -454,6 +457,7 @@ static inline int cpacf_kmc(unsigned long func, void *param, | |||
| 454 | 457 | [opc] "i" (CPACF_KMC) | |
| 455 | 458 | : "cc", "memory", "0", "1"); | |
| 456 | 459 | ||
| 460 | + | kmsan_unpoison_memory(dest, src_len - s.odd); | |
| 457 | 461 | return src_len - s.odd; | |
| 458 | 462 | } | |
| 459 | 463 | ||
| @@ -587,6 +591,7 @@ static inline int cpacf_kmctr(unsigned long func, void *param, u8 *dest, | |||
| 587 | 591 | [opc] "i" (CPACF_KMCTR) | |
| 588 | 592 | : "cc", "memory", "0", "1"); | |
| 589 | 593 | ||
| 594 | + | kmsan_unpoison_memory(dest, src_len - s.odd); | |
| 590 | 595 | return src_len - s.odd; | |
| 591 | 596 | } | |
| 592 | 597 | ||
| @@ -619,6 +624,7 @@ static inline void cpacf_prno(unsigned long func, void *param, | |||
| 619 | 624 | : [fc] "d" (func), [pba] "d" ((unsigned long)param), | |
| 620 | 625 | [seed] "d" (s.pair), [opc] "i" (CPACF_PRNO) | |
| 621 | 626 | : "cc", "memory", "0", "1"); | |
| 627 | + | kmsan_unpoison_memory(dest, dest_len); | |
| 622 | 628 | } | |
| 623 | 629 | ||
| 624 | 630 | /** | |
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/include/asm/pai.h
| @@ -76,7 +76,6 @@ static __always_inline void pai_kernel_exit(struct pt_regs *regs) | |||
| 76 | 76 | } | |
| 77 | 77 | ||
| 78 | 78 | #define PAI_SAVE_AREA(x) ((x)->hw.event_base) | |
| 79 | - | #define PAI_CPU_MASK(x) ((x)->hw.addr_filters) | |
| 80 | 79 | #define PAI_PMU_IDX(x) ((x)->hw.last_tag) | |
| 81 | 80 | #define PAI_SWLIST(x) (&(x)->hw.tp_list) | |
| 82 | 81 | ||
modified arch/s390/include/asm/processor.h
| @@ -46,7 +46,6 @@ struct pcpu { | |||
| 46 | 46 | unsigned long ec_mask; /* bit mask for ec_xxx functions */ | |
| 47 | 47 | unsigned long ec_clk; /* sigp timestamp for ec_xxx */ | |
| 48 | 48 | unsigned long flags; /* per CPU flags */ | |
| 49 | - | unsigned long capacity; /* cpu capacity for scheduler */ | |
| 50 | 49 | signed char state; /* physical cpu state */ | |
| 51 | 50 | signed char polarization; /* physical polarization */ | |
| 52 | 51 | u16 address; /* physical cpu address */ | |
modified arch/s390/include/asm/smp.h
| @@ -30,7 +30,7 @@ static __always_inline unsigned int raw_smp_processor_id(void) | |||
| 30 | 30 | return cpu; | |
| 31 | 31 | } | |
| 32 | 32 | ||
| 33 | - | #define arch_scale_cpu_capacity smp_cpu_get_capacity | |
| 33 | + | #define arch_scale_cpu_capacity topology_get_cpu_scale | |
| 34 | 34 | ||
| 35 | 35 | extern struct mutex smp_cpu_state_mutex; | |
| 36 | 36 | extern unsigned int smp_cpu_mt_shift; | |
| @@ -53,9 +53,7 @@ extern void smp_save_dump_secondary_cpus(void); | |||
| 53 | 53 | extern void smp_yield_cpu(int cpu); | |
| 54 | 54 | extern void smp_cpu_set_polarization(int cpu, int val); | |
| 55 | 55 | extern int smp_cpu_get_polarization(int cpu); | |
| 56 | - | extern void smp_cpu_set_capacity(int cpu, unsigned long val); | |
| 57 | 56 | extern void smp_set_core_capacity(int cpu, unsigned long val); | |
| 58 | - | extern unsigned long smp_cpu_get_capacity(int cpu); | |
| 59 | 57 | extern int smp_cpu_get_cpu_address(int cpu); | |
| 60 | 58 | extern void smp_fill_possible_mask(void); | |
| 61 | 59 | extern void smp_detect_cpus(void); | |
modified arch/s390/kernel/debug.c
| @@ -182,7 +182,7 @@ static struct debug_param_t { | |||
| 182 | 182 | static int debug_param_num; | |
| 183 | 183 | ||
| 184 | 184 | /* functions */ | |
| 185 | - | static void debug_get_param(const char *name, int *level, int *pages) | |
| 185 | + | static void debug_get_param(const char *name, int *level, int *pages, bool quiet) | |
| 186 | 186 | { | |
| 187 | 187 | struct debug_param_t *p; | |
| 188 | 188 | int i; | |
| @@ -192,11 +192,13 @@ static void debug_get_param(const char *name, int *level, int *pages) | |||
| 192 | 192 | if (!glob_match(p->name, name)) | |
| 193 | 193 | continue; | |
| 194 | 194 | if (level && p->level != PARAM_UNSET) { | |
| 195 | - | pr_info("%s: override level to %d\n", name, p->level); | |
| 195 | + | if (!quiet) | |
| 196 | + | pr_info("%s: override level to %d\n", name, p->level); | |
| 196 | 197 | *level = p->level; | |
| 197 | 198 | } | |
| 198 | 199 | if (pages && p->pages != PARAM_UNSET) { | |
| 199 | - | pr_info("%s: override pages to %d\n", name, p->pages); | |
| 200 | + | if (!quiet) | |
| 201 | + | pr_info("%s: override pages to %d\n", name, p->pages); | |
| 200 | 202 | *pages = p->pages; | |
| 201 | 203 | } | |
| 202 | 204 | } | |
| @@ -251,7 +253,7 @@ static int __init s390dbf_parse(char *arg) | |||
| 251 | 253 | * regular memory allocations are possible. | |
| 252 | 254 | */ | |
| 253 | 255 | for (i = 0, id = __s390dbf_info; &id[i] < __s390dbf_info_end; i++) | |
| 254 | - | debug_get_param(id[i]->name, &id[i]->level, NULL); | |
| 256 | + | debug_get_param(id[i]->name, &id[i]->level, NULL, false); | |
| 255 | 257 | ||
| 256 | 258 | return rc; | |
| 257 | 259 | } | |
| @@ -395,7 +397,7 @@ static debug_info_t *debug_info_create(const char *name, int pages_per_area, | |||
| 395 | 397 | int level = DEBUG_DEFAULT_LEVEL; | |
| 396 | 398 | debug_info_t *rc; | |
| 397 | 399 | ||
| 398 | - | debug_get_param(name, &level, &pages_per_area); | |
| 400 | + | debug_get_param(name, &level, &pages_per_area, false); | |
| 399 | 401 | rc = debug_info_alloc(name, pages_per_area, nr_areas, buf_size, level, ALL_AREAS); | |
| 400 | 402 | if (!rc) | |
| 401 | 403 | goto out; | |
| @@ -432,7 +434,8 @@ static debug_info_t *debug_info_copy(debug_info_t *in, int mode) | |||
| 432 | 434 | debug_info_free(rc); | |
| 433 | 435 | } while (1); | |
| 434 | 436 | ||
| 435 | - | if (mode == NO_AREAS) | |
| 437 | + | /* debug_register_static() failure leaves areas NULL, bounds intact */ | |
| 438 | + | if (mode == NO_AREAS || !in->areas) | |
| 436 | 439 | goto out; | |
| 437 | 440 | ||
| 438 | 441 | for (i = 0; i < in->nr_areas; i++) { | |
| @@ -821,6 +824,9 @@ ssize_t debug_dump(debug_info_t *id, struct debug_view *view, | |||
| 821 | 824 | file_private_info_t *p_info; | |
| 822 | 825 | size_t size, offset = 0; | |
| 823 | 826 | ||
| 827 | + | if (!id) | |
| 828 | + | return -EINVAL; | |
| 829 | + | ||
| 824 | 830 | /* Need space for '\0' byte */ | |
| 825 | 831 | if (buf_size < 1) | |
| 826 | 832 | return 0; | |
| @@ -948,8 +954,12 @@ EXPORT_SYMBOL(debug_register); | |||
| 948 | 954 | * | |
| 949 | 955 | * Note: This function is called automatically via an initcall generated by | |
| 950 | 956 | * DEFINE_STATIC_DEBUG_INFO. | |
| 957 | + | * | |
| 958 | + | * Return: | |
| 959 | + | * - 0 on success | |
| 960 | + | * - negative error code on failure | |
| 951 | 961 | */ | |
| 952 | - | 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) | |
| 953 | 963 | { | |
| 954 | 964 | unsigned long flags; | |
| 955 | 965 | debug_info_t *copy; | |
| @@ -957,10 +967,10 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas) | |||
| 957 | 967 | if (!initialized) { | |
| 958 | 968 | pr_err("Tried to register debug feature %s too early\n", | |
| 959 | 969 | id->name); | |
| 960 | - | return; | |
| 970 | + | return -EINVAL; | |
| 961 | 971 | } | |
| 962 | 972 | ||
| 963 | - | debug_get_param(id->name, &id->level, &pages_per_area); | |
| 973 | + | debug_get_param(id->name, &id->level, &pages_per_area, false); | |
| 964 | 974 | copy = debug_info_alloc("", pages_per_area, nr_areas, id->buf_size, | |
| 965 | 975 | id->level, ALL_AREAS); | |
| 966 | 976 | if (!copy) { | |
| @@ -973,7 +983,7 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas) | |||
| 973 | 983 | id->active_entries = NULL; | |
| 974 | 984 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 975 | 985 | ||
| 976 | - | return; | |
| 986 | + | return -ENOMEM; | |
| 977 | 987 | } | |
| 978 | 988 | ||
| 979 | 989 | /* Replace static trace area with dynamic copy. */ | |
| @@ -991,6 +1001,8 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas) | |||
| 991 | 1001 | mutex_lock(&debug_mutex); | |
| 992 | 1002 | _debug_register(id); | |
| 993 | 1003 | mutex_unlock(&debug_mutex); | |
| 1004 | + | ||
| 1005 | + | return 0; | |
| 994 | 1006 | } | |
| 995 | 1007 | ||
| 996 | 1008 | /* Remove debugfs entries. */ | |
| @@ -1074,9 +1086,6 @@ static void _debug_set_level(debug_info_t *id, int new_level) | |||
| 1074 | 1086 | { | |
| 1075 | 1087 | unsigned long flags; | |
| 1076 | 1088 | ||
| 1077 | - | if (!id) | |
| 1078 | - | return; | |
| 1079 | - | ||
| 1080 | 1089 | if (new_level == DEBUG_OFF_LEVEL) { | |
| 1081 | 1090 | pr_info("%s: switched off\n", id->name); | |
| 1082 | 1091 | } else if ((new_level > DEBUG_MAX_LEVEL) || (new_level < 0)) { | |
| @@ -1101,8 +1110,14 @@ static void _debug_set_level(debug_info_t *id, int new_level) | |||
| 1101 | 1110 | */ | |
| 1102 | 1111 | void debug_set_level(debug_info_t *id, int new_level) | |
| 1103 | 1112 | { | |
| 1104 | - | /* Level specified via kernel parameter takes precedence */ | |
| 1105 | - | debug_get_param(id->name, &new_level, NULL); | |
| 1113 | + | if (!id) | |
| 1114 | + | return; | |
| 1115 | + | ||
| 1116 | + | /* | |
| 1117 | + | * Level specified via kernel parameter takes precedence. The override | |
| 1118 | + | * was already announced during registration, so stay quiet here. | |
| 1119 | + | */ | |
| 1120 | + | debug_get_param(id->name, &new_level, NULL, true); | |
| 1106 | 1121 | ||
| 1107 | 1122 | _debug_set_level(id, new_level); | |
| 1108 | 1123 | } | |
| @@ -1278,7 +1293,7 @@ void debug_set_critical(void) | |||
| 1278 | 1293 | debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf, | |
| 1279 | 1294 | int len) | |
| 1280 | 1295 | { | |
| 1281 | - | debug_entry_t *active; | |
| 1296 | + | debug_entry_t *active = NULL; | |
| 1282 | 1297 | unsigned long flags; | |
| 1283 | 1298 | ||
| 1284 | 1299 | if (!debug_active || !id->areas) | |
| @@ -1289,6 +1304,8 @@ debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf, | |||
| 1289 | 1304 | } else { | |
| 1290 | 1305 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1291 | 1306 | } | |
| 1307 | + | if (!id->areas) | |
| 1308 | + | goto out; | |
| 1292 | 1309 | do { | |
| 1293 | 1310 | active = get_active_entry(id); | |
| 1294 | 1311 | memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size)); | |
| @@ -1298,7 +1315,7 @@ debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf, | |||
| 1298 | 1315 | len -= id->buf_size; | |
| 1299 | 1316 | buf += id->buf_size; | |
| 1300 | 1317 | } while (len > 0); | |
| 1301 | - | ||
| 1318 | + | out: | |
| 1302 | 1319 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1303 | 1320 | return active; | |
| 1304 | 1321 | } | |
| @@ -1311,7 +1328,7 @@ EXPORT_SYMBOL(debug_event_common); | |||
| 1311 | 1328 | debug_entry_t *debug_exception_common(debug_info_t *id, int level, | |
| 1312 | 1329 | const void *buf, int len) | |
| 1313 | 1330 | { | |
| 1314 | - | debug_entry_t *active; | |
| 1331 | + | debug_entry_t *active = NULL; | |
| 1315 | 1332 | unsigned long flags; | |
| 1316 | 1333 | ||
| 1317 | 1334 | if (!debug_active || !id->areas) | |
| @@ -1322,6 +1339,8 @@ debug_entry_t *debug_exception_common(debug_info_t *id, int level, | |||
| 1322 | 1339 | } else { | |
| 1323 | 1340 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1324 | 1341 | } | |
| 1342 | + | if (!id->areas) | |
| 1343 | + | goto out; | |
| 1325 | 1344 | do { | |
| 1326 | 1345 | active = get_active_entry(id); | |
| 1327 | 1346 | memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size)); | |
| @@ -1331,7 +1350,7 @@ debug_entry_t *debug_exception_common(debug_info_t *id, int level, | |||
| 1331 | 1350 | len -= id->buf_size; | |
| 1332 | 1351 | buf += id->buf_size; | |
| 1333 | 1352 | } while (len > 0); | |
| 1334 | - | ||
| 1353 | + | out: | |
| 1335 | 1354 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1336 | 1355 | return active; | |
| 1337 | 1356 | } | |
| @@ -1357,7 +1376,7 @@ static inline int debug_count_numargs(char *string) | |||
| 1357 | 1376 | debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, ...) | |
| 1358 | 1377 | { | |
| 1359 | 1378 | debug_sprintf_entry_t *curr_event; | |
| 1360 | - | debug_entry_t *active; | |
| 1379 | + | debug_entry_t *active = NULL; | |
| 1361 | 1380 | unsigned long flags; | |
| 1362 | 1381 | int numargs, idx; | |
| 1363 | 1382 | va_list ap; | |
| @@ -1372,6 +1391,8 @@ debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, | |||
| 1372 | 1391 | } else { | |
| 1373 | 1392 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1374 | 1393 | } | |
| 1394 | + | if (!id->areas) | |
| 1395 | + | goto out; | |
| 1375 | 1396 | active = get_active_entry(id); | |
| 1376 | 1397 | curr_event = (debug_sprintf_entry_t *) DEBUG_DATA(active); | |
| 1377 | 1398 | va_start(ap, string); | |
| @@ -1380,6 +1401,7 @@ debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, | |||
| 1380 | 1401 | curr_event->args[idx] = va_arg(ap, long); | |
| 1381 | 1402 | va_end(ap); | |
| 1382 | 1403 | debug_finish_entry(id, active, level, 0); | |
| 1404 | + | out: | |
| 1383 | 1405 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1384 | 1406 | ||
| 1385 | 1407 | return active; | |
| @@ -1392,7 +1414,7 @@ EXPORT_SYMBOL(__debug_sprintf_event); | |||
| 1392 | 1414 | debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *string, ...) | |
| 1393 | 1415 | { | |
| 1394 | 1416 | debug_sprintf_entry_t *curr_event; | |
| 1395 | - | debug_entry_t *active; | |
| 1417 | + | debug_entry_t *active = NULL; | |
| 1396 | 1418 | unsigned long flags; | |
| 1397 | 1419 | int numargs, idx; | |
| 1398 | 1420 | va_list ap; | |
| @@ -1408,6 +1430,8 @@ debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *stri | |||
| 1408 | 1430 | } else { | |
| 1409 | 1431 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1410 | 1432 | } | |
| 1433 | + | if (!id->areas) | |
| 1434 | + | goto out; | |
| 1411 | 1435 | active = get_active_entry(id); | |
| 1412 | 1436 | curr_event = (debug_sprintf_entry_t *)DEBUG_DATA(active); | |
| 1413 | 1437 | va_start(ap, string); | |
| @@ -1416,6 +1440,7 @@ debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *stri | |||
| 1416 | 1440 | curr_event->args[idx] = va_arg(ap, long); | |
| 1417 | 1441 | va_end(ap); | |
| 1418 | 1442 | debug_finish_entry(id, active, level, 1); | |
| 1443 | + | out: | |
| 1419 | 1444 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1420 | 1445 | ||
| 1421 | 1446 | return active; | |
| @@ -1658,9 +1683,11 @@ static void debug_flush(debug_info_t *id, int area) | |||
| 1658 | 1683 | unsigned long flags; | |
| 1659 | 1684 | int i, j; | |
| 1660 | 1685 | ||
| 1661 | - | if (!id || !id->areas) | |
| 1686 | + | if (!id) | |
| 1662 | 1687 | return; | |
| 1663 | 1688 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1689 | + | if (!id->areas) | |
| 1690 | + | goto out; | |
| 1664 | 1691 | if (area == DEBUG_FLUSH_ALL) { | |
| 1665 | 1692 | id->active_area = 0; | |
| 1666 | 1693 | memset(id->active_entries, 0, id->nr_areas * sizeof(int)); | |
| @@ -1675,6 +1702,7 @@ static void debug_flush(debug_info_t *id, int area) | |||
| 1675 | 1702 | for (i = 0; i < id->pages_per_area; i++) | |
| 1676 | 1703 | memset(id->areas[area][i], 0, PAGE_SIZE); | |
| 1677 | 1704 | } | |
| 1705 | + | out: | |
| 1678 | 1706 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1679 | 1707 | } | |
| 1680 | 1708 | ||
modified arch/s390/kernel/diag/diag324.c
| @@ -182,8 +182,7 @@ long diag324_pibbuf(unsigned long arg) | |||
| 182 | 182 | goto out; | |
| 183 | 183 | rc = copy_to_user((void __user *)address, data->pib, data->pib->len); | |
| 184 | 184 | rc |= put_user(data->sequence, &udata->sequence); | |
| 185 | - | if (rc) | |
| 186 | - | rc = -EFAULT; | |
| 185 | + | rc = rc ? -EFAULT : data->rc; | |
| 187 | 186 | out: | |
| 188 | 187 | mutex_unlock(&pibmutex); | |
| 189 | 188 | return rc; | |
modified arch/s390/kernel/ipl.c
| @@ -1157,6 +1157,8 @@ static struct attribute_group reipl_nss_attr_group = { | |||
| 1157 | 1157 | ||
| 1158 | 1158 | void set_os_info_reipl_block(void) | |
| 1159 | 1159 | { | |
| 1160 | + | if (!reipl_block_actual) | |
| 1161 | + | return; | |
| 1160 | 1162 | os_info_entry_add_data(OS_INFO_REIPL_BLOCK, reipl_block_actual, | |
| 1161 | 1163 | reipl_block_actual->hdr.len); | |
| 1162 | 1164 | } | |
| @@ -1927,7 +1929,8 @@ static struct shutdown_action __refdata dump_action = { | |||
| 1927 | 1929 | static void dump_reipl_run(struct shutdown_trigger *trigger) | |
| 1928 | 1930 | { | |
| 1929 | 1931 | struct lowcore *abs_lc; | |
| 1930 | - | unsigned int csum; | |
| 1932 | + | unsigned long ipib = 0; | |
| 1933 | + | unsigned int csum = 0; | |
| 1931 | 1934 | ||
| 1932 | 1935 | /* | |
| 1933 | 1936 | * Set REIPL_CLEAR flag in os_info flags entry indicating | |
| @@ -1943,9 +1946,12 @@ static void dump_reipl_run(struct shutdown_trigger *trigger) | |||
| 1943 | 1946 | reipl_type == IPL_TYPE_UNKNOWN) | |
| 1944 | 1947 | os_info_flags |= OS_INFO_FLAG_REIPL_CLEAR; | |
| 1945 | 1948 | os_info_entry_add_data(OS_INFO_FLAGS_ENTRY, &os_info_flags, sizeof(os_info_flags)); | |
| 1946 | - | csum = (__force unsigned int)cksm(reipl_block_actual, reipl_block_actual->hdr.len, 0); | |
| 1949 | + | if (reipl_block_actual) { | |
| 1950 | + | ipib = __pa(reipl_block_actual); | |
| 1951 | + | csum = (__force unsigned int)cksm(reipl_block_actual, reipl_block_actual->hdr.len, 0); | |
| 1952 | + | } | |
| 1947 | 1953 | abs_lc = get_abs_lowcore(); | |
| 1948 | - | abs_lc->ipib = __pa(reipl_block_actual); | |
| 1954 | + | abs_lc->ipib = ipib; | |
| 1949 | 1955 | abs_lc->ipib_checksum = csum; | |
| 1950 | 1956 | put_abs_lowcore(abs_lc); | |
| 1951 | 1957 | dump_run(trigger); | |
modified arch/s390/kernel/perf_pai.c
| @@ -67,6 +67,7 @@ struct pai_mapptr { | |||
| 67 | 67 | ||
| 68 | 68 | static struct pai_root { /* Anchor to per CPU data */ | |
| 69 | 69 | refcount_t refcnt; /* Overall active events */ | |
| 70 | + | atomic_t tskctx; /* Overall per-task events */ | |
| 70 | 71 | struct pai_mapptr __percpu *mapptr; | |
| 71 | 72 | } pai_root[PAI_PMU_MAX]; | |
| 72 | 73 | ||
| @@ -93,14 +94,15 @@ struct pai_pmu { /* Define PAI PMU characteristics */ | |||
| 93 | 94 | static struct pai_pmu pai_pmu[]; /* Forward declaration */ | |
| 94 | 95 | ||
| 95 | 96 | /* Free per CPU data when the last event is removed. */ | |
| 96 | - | static void pai_root_free(int idx) | |
| 97 | + | static void pai_root_free(int idx, int tasks) | |
| 97 | 98 | { | |
| 98 | - | if (refcount_dec_and_test(&pai_root[idx].refcnt)) { | |
| 99 | + | if (refcount_sub_and_test(tasks, &pai_root[idx].refcnt)) { | |
| 99 | 100 | free_percpu(pai_root[idx].mapptr); | |
| 100 | 101 | pai_root[idx].mapptr = NULL; | |
| 101 | 102 | } | |
| 102 | - | debug_sprintf_event(paidbg, 5, "%s root[%d].refcount %d\n", __func__, | |
| 103 | - | idx, refcount_read(&pai_root[idx].refcnt)); | |
| 103 | + | debug_sprintf_event(paidbg, 5, "%s root[%d].refcount %d tskctx %d\n", | |
| 104 | + | __func__, idx, refcount_read(&pai_root[idx].refcnt), | |
| 105 | + | atomic_read(&pai_root[idx].tskctx)); | |
| 104 | 106 | } | |
| 105 | 107 | ||
| 106 | 108 | /* | |
| @@ -137,40 +139,54 @@ static void pai_free(struct pai_mapptr *mp) | |||
| 137 | 139 | mp->mapptr = NULL; | |
| 138 | 140 | } | |
| 139 | 141 | ||
| 140 | - | /* Adjust usage counters and remove allocated memory when all users are | |
| 141 | - | * gone. | |
| 142 | - | */ | |
| 143 | - | static void pai_event_destroy_cpu(struct perf_event *event, int cpu) | |
| 142 | + | /* Called under mutex_lock */ | |
| 143 | + | static void pai_event_destroy_cpu(int idx, int cpu, bool hotplug) | |
| 144 | 144 | { | |
| 145 | - | int idx = PAI_PMU_IDX(event); | |
| 146 | - | struct pai_mapptr *mp = per_cpu_ptr(pai_root[idx].mapptr, cpu); | |
| 147 | - | struct pai_map *cpump = mp->mapptr; | |
| 145 | + | struct pai_mapptr *mp; | |
| 146 | + | struct pai_map *cpump; | |
| 147 | + | int tasks = 1; | |
| 148 | 148 | ||
| 149 | - | mutex_lock(&pai_reserve_mutex); | |
| 150 | - | debug_sprintf_event(paidbg, 5, "%s event %#llx idx %d cpu %d users %d " | |
| 151 | - | "refcnt %u\n", __func__, event->attr.config, idx, | |
| 152 | - | event->cpu, cpump->active_events, | |
| 153 | - | refcount_read(&cpump->refcnt)); | |
| 154 | - | if (refcount_dec_and_test(&cpump->refcnt)) | |
| 149 | + | /* Check reference count and return when all gone. | |
| 150 | + | * 1. An event is installed on online CPU X. | |
| 151 | + | * 2. CPU x is offlined and the per-CPU data is removed. | |
| 152 | + | * 3. Event is destroyed via close system call. | |
| 153 | + | */ | |
| 154 | + | if (!refcount_read(&pai_root[idx].refcnt)) | |
| 155 | + | return; /* No events at all */ | |
| 156 | + | mp = per_cpu_ptr(pai_root[idx].mapptr, cpu); | |
| 157 | + | if (!mp || !mp->mapptr) /* No events on that CPU */ | |
| 158 | + | return; | |
| 159 | + | ||
| 160 | + | /* When hotplug is true, invocation is from CPU hotplug callback. | |
| 161 | + | * Delete per-CPU resource and adjust refcnt when per-task events | |
| 162 | + | * are currently active. This can be more than one. | |
| 163 | + | * In this case adjust counters. | |
| 164 | + | */ | |
| 165 | + | if (hotplug) | |
| 166 | + | tasks = atomic_read(&pai_root[idx].tskctx); | |
| 167 | + | ||
| 168 | + | cpump = mp->mapptr; | |
| 169 | + | if (refcount_sub_and_test(tasks, &cpump->refcnt)) | |
| 155 | 170 | pai_free(mp); | |
| 156 | - | pai_root_free(idx); | |
| 157 | - | mutex_unlock(&pai_reserve_mutex); | |
| 171 | + | pai_root_free(idx, tasks); | |
| 158 | 172 | } | |
| 159 | 173 | ||
| 160 | 174 | static void pai_event_destroy(struct perf_event *event) | |
| 161 | 175 | { | |
| 162 | - | int cpu; | |
| 176 | + | int cpu = 0, idx = PAI_PMU_IDX(event); | |
| 163 | 177 | ||
| 164 | 178 | free_page(PAI_SAVE_AREA(event)); | |
| 179 | + | cpus_read_lock(); | |
| 180 | + | mutex_lock(&pai_reserve_mutex); | |
| 165 | 181 | if (event->cpu == -1) { | |
| 166 | - | struct cpumask *mask = PAI_CPU_MASK(event); | |
| 167 | - | ||
| 168 | - | for_each_cpu(cpu, mask) | |
| 169 | - | pai_event_destroy_cpu(event, cpu); | |
| 170 | - | kfree(mask); | |
| 182 | + | atomic_dec(&pai_root[idx].tskctx); | |
| 183 | + | for_each_online_cpu(cpu) | |
| 184 | + | pai_event_destroy_cpu(idx, cpu, false); | |
| 171 | 185 | } else { | |
| 172 | - | pai_event_destroy_cpu(event, event->cpu); | |
| 186 | + | pai_event_destroy_cpu(idx, event->cpu, false); | |
| 173 | 187 | } | |
| 188 | + | mutex_unlock(&pai_reserve_mutex); | |
| 189 | + | cpus_read_unlock(); | |
| 174 | 190 | } | |
| 175 | 191 | ||
| 176 | 192 | static void paicrypt_event_destroy(struct perf_event *event) | |
| @@ -234,25 +250,30 @@ static u64 paicrypt_getall(struct perf_event *event) | |||
| 234 | 250 | return sum; | |
| 235 | 251 | } | |
| 236 | 252 | ||
| 237 | - | /* Check concurrent access of counting and sampling for crypto events. | |
| 238 | - | * This function is called in process context and it is save to block. | |
| 239 | - | * When the event initialization functions fails, no other call back will | |
| 240 | - | * be invoked. | |
| 241 | - | * | |
| 242 | - | * Allocate the memory for the event. | |
| 243 | - | */ | |
| 244 | - | static int pai_alloc_cpu(struct perf_event *event, int cpu) | |
| 253 | + | /* Called under mutex_lock */ | |
| 254 | + | static int pai_alloc_cpu(int idx, int cpu, bool hotplug) | |
| 245 | 255 | { | |
| 246 | - | int rc, idx = PAI_PMU_IDX(event); | |
| 247 | 256 | struct pai_map *cpump = NULL; | |
| 248 | 257 | bool need_paiext_cb = false; | |
| 249 | 258 | struct pai_mapptr *mp; | |
| 259 | + | int tasks = 1, rc = 0; | |
| 260 | + | ||
| 261 | + | /* When hotplug is true, invocation is from CPU hotplug callback. | |
| 262 | + | * Allocate per-CPU resource when per-task events are currently active. | |
| 263 | + | * This can be more than one. In this case adjust all reference | |
| 264 | + | * counters. Otherwise return, this ensures memory is only allocated | |
| 265 | + | * when needed. | |
| 266 | + | */ | |
| 267 | + | if (hotplug) { | |
| 268 | + | tasks = atomic_read(&pai_root[idx].tskctx); | |
| 269 | + | if (!tasks) | |
| 270 | + | goto out; | |
| 271 | + | } | |
| 250 | 272 | ||
| 251 | - | mutex_lock(&pai_reserve_mutex); | |
| 252 | 273 | /* Allocate root node */ | |
| 253 | 274 | rc = pai_root_alloc(idx); | |
| 254 | 275 | if (rc) | |
| 255 | - | goto unlock; | |
| 276 | + | goto out; | |
| 256 | 277 | ||
| 257 | 278 | /* Allocate node for this event */ | |
| 258 | 279 | mp = per_cpu_ptr(pai_root[idx].mapptr, cpu); | |
| @@ -296,28 +317,45 @@ static int pai_alloc_cpu(struct perf_event *event, int cpu) | |||
| 296 | 317 | goto undo; | |
| 297 | 318 | } | |
| 298 | 319 | INIT_LIST_HEAD(&cpump->syswide_list); | |
| 299 | - | refcount_set(&cpump->refcnt, 1); | |
| 320 | + | refcount_set(&cpump->refcnt, tasks); | |
| 300 | 321 | rc = 0; | |
| 301 | 322 | } else { | |
| 302 | - | refcount_inc(&cpump->refcnt); | |
| 323 | + | refcount_add(tasks, &cpump->refcnt); | |
| 303 | 324 | } | |
| 325 | + | /* If tasks is greater than 1, we are called from CPU hotplug path | |
| 326 | + | * and need to adjust the pai_root[idx].refcnt by the number of | |
| 327 | + | * per-process events. Function pai_root_alloc(idx) already | |
| 328 | + | * incremented by one. Adjust for the rest. | |
| 329 | + | */ | |
| 330 | + | if (tasks > 1) | |
| 331 | + | refcount_add(tasks - 1, &pai_root[idx].refcnt); | |
| 304 | 332 | ||
| 305 | 333 | undo: | |
| 306 | 334 | if (rc) { | |
| 307 | 335 | /* Error in allocation of event, decrement anchor. Since | |
| 308 | 336 | * the event in not created, its destroy() function is never | |
| 309 | 337 | * invoked. Adjust the reference counter for the anchor. | |
| 338 | + | * The failure happened in the case of variable | |
| 339 | + | * cpump == NULL branch above. The pai_root[XXX].refcnt has | |
| 340 | + | * been incremented by one. Then the per-CPU allocation | |
| 341 | + | * failed, so decrement it by one, regardless of tasks. | |
| 310 | 342 | */ | |
| 311 | - | pai_root_free(idx); | |
| 343 | + | pai_root_free(idx, 1); | |
| 312 | 344 | } | |
| 313 | - | unlock: | |
| 314 | - | mutex_unlock(&pai_reserve_mutex); | |
| 345 | + | out: | |
| 315 | 346 | /* If rc is non-zero, no increment of counter/sampler was done. */ | |
| 316 | 347 | return rc; | |
| 317 | 348 | } | |
| 318 | 349 | ||
| 350 | + | /* Check concurrent access of counting and sampling for PAI events. | |
| 351 | + | * This function is called in process context and it is safe to block. | |
| 352 | + | * When the event initialization functions fails, no other call back will | |
| 353 | + | * be invoked. | |
| 354 | + | * Called under mutex_lock. | |
| 355 | + | */ | |
| 319 | 356 | static int pai_alloc(struct perf_event *event) | |
| 320 | 357 | { | |
| 358 | + | int idx = PAI_PMU_IDX(event); | |
| 321 | 359 | struct cpumask *maskptr; | |
| 322 | 360 | int cpu, rc = -ENOMEM; | |
| 323 | 361 | ||
| @@ -326,24 +364,20 @@ static int pai_alloc(struct perf_event *event) | |||
| 326 | 364 | goto out; | |
| 327 | 365 | ||
| 328 | 366 | for_each_online_cpu(cpu) { | |
| 329 | - | rc = pai_alloc_cpu(event, cpu); | |
| 367 | + | rc = pai_alloc_cpu(idx, cpu, false); | |
| 330 | 368 | if (rc) { | |
| 331 | 369 | for_each_cpu(cpu, maskptr) | |
| 332 | - | pai_event_destroy_cpu(event, cpu); | |
| 333 | - | kfree(maskptr); | |
| 334 | - | goto out; | |
| 370 | + | pai_event_destroy_cpu(idx, cpu, false); | |
| 371 | + | goto undo; | |
| 335 | 372 | } | |
| 336 | 373 | cpumask_set_cpu(cpu, maskptr); | |
| 337 | 374 | } | |
| 338 | 375 | ||
| 339 | - | /* | |
| 340 | - | * On error all cpumask are freed and all events have been destroyed. | |
| 341 | - | * Save of which CPUs data structures have been allocated for. | |
| 342 | - | * Release them in pai_event_destroy call back function | |
| 343 | - | * for this event. | |
| 344 | - | */ | |
| 345 | - | PAI_CPU_MASK(event) = maskptr; | |
| 346 | 376 | rc = 0; | |
| 377 | + | /* Trace per-task events for CPU hotplug. */ | |
| 378 | + | atomic_inc(&pai_root[idx].tskctx); | |
| 379 | + | undo: | |
| 380 | + | kfree(maskptr); | |
| 347 | 381 | out: | |
| 348 | 382 | return rc; | |
| 349 | 383 | } | |
| @@ -391,10 +425,14 @@ static int pai_event_init(struct perf_event *event, int idx) | |||
| 391 | 425 | } | |
| 392 | 426 | } | |
| 393 | 427 | ||
| 428 | + | cpus_read_lock(); | |
| 429 | + | mutex_lock(&pai_reserve_mutex); | |
| 394 | 430 | if (event->cpu >= 0) | |
| 395 | - | rc = pai_alloc_cpu(event, event->cpu); | |
| 431 | + | rc = pai_alloc_cpu(idx, event->cpu, false); | |
| 396 | 432 | else | |
| 397 | 433 | rc = pai_alloc(event); | |
| 434 | + | mutex_unlock(&pai_reserve_mutex); | |
| 435 | + | cpus_read_unlock(); | |
| 398 | 436 | if (rc) { | |
| 399 | 437 | free_page(PAI_SAVE_AREA(event)); | |
| 400 | 438 | goto out; | |
| @@ -464,6 +502,7 @@ static void pai_start(struct perf_event *event, int flags, | |||
| 464 | 502 | cpump->event = event; | |
| 465 | 503 | } | |
| 466 | 504 | } | |
| 505 | + | event->hw.state &= ~PERF_HES_STOPPED; | |
| 467 | 506 | } | |
| 468 | 507 | ||
| 469 | 508 | static void paicrypt_start(struct perf_event *event, int flags) | |
| @@ -510,6 +549,13 @@ static void pai_stop(struct perf_event *event, int flags) | |||
| 510 | 549 | struct pai_mapptr *mp = this_cpu_ptr(pai_root[idx].mapptr); | |
| 511 | 550 | struct pai_map *cpump = mp->mapptr; | |
| 512 | 551 | ||
| 552 | + | /* Cope with multiple invocations: | |
| 553 | + | * 1. perf_event_throttle() --> PMU->stop() | |
| 554 | + | * 2. task schedules out --> PMU->stop() | |
| 555 | + | * Check for event already stopped. | |
| 556 | + | */ | |
| 557 | + | if (event->hw.state & PERF_HES_STOPPED) | |
| 558 | + | return; | |
| 513 | 559 | if (!event->attr.sample_period) { /* Counting */ | |
| 514 | 560 | pai_pmu[idx].pmu->read(event); | |
| 515 | 561 | } else { /* Sampling */ | |
| @@ -672,9 +718,9 @@ static void pai_have_samples(int idx) | |||
| 672 | 718 | { | |
| 673 | 719 | struct pai_mapptr *mp = this_cpu_ptr(pai_root[idx].mapptr); | |
| 674 | 720 | struct pai_map *cpump = mp->mapptr; | |
| 675 | - | struct perf_event *event; | |
| 721 | + | struct perf_event *event, *e2; | |
| 676 | 722 | ||
| 677 | - | list_for_each_entry(event, &cpump->syswide_list, hw.tp_list) | |
| 723 | + | list_for_each_entry_safe(event, e2, &cpump->syswide_list, hw.tp_list) | |
| 678 | 724 | pai_have_sample(event, cpump); | |
| 679 | 725 | } | |
| 680 | 726 | ||
| @@ -691,6 +737,17 @@ static void paicrypt_sched_task(struct perf_event_pmu_context *pmu_ctx, | |||
| 691 | 737 | pai_have_samples(PAI_PMU_CRYPTO); | |
| 692 | 738 | } | |
| 693 | 739 | ||
| 740 | + | /* Prevent ioctl(fd, PERF_EVENT_IOC_PERIOD, ...) call. | |
| 741 | + | * It sets perf_event::event_limit to a positive value and causes | |
| 742 | + | * perf_event_overflow() to invoke pai_stop() call back function when | |
| 743 | + | * perf_event::event_limit hits zero. This is not supported because the | |
| 744 | + | * sample events CRYPTO_ALL and NNPA_ALL are always taken at schedule out | |
| 745 | + | * of a task. | |
| 746 | + | */ | |
| 747 | + | static int pai_check_period(struct perf_event *event, u64 value) | |
| 748 | + | { | |
| 749 | + | return -EINVAL; | |
| 750 | + | } | |
| 694 | 751 | /* ============================= paiext ====================================*/ | |
| 695 | 752 | ||
| 696 | 753 | static void paiext_event_destroy(struct perf_event *event) | |
| @@ -804,6 +861,7 @@ static struct pmu paicrypt = { | |||
| 804 | 861 | .stop = paicrypt_stop, | |
| 805 | 862 | .read = paicrypt_read, | |
| 806 | 863 | .sched_task = paicrypt_sched_task, | |
| 864 | + | .check_period = pai_check_period, | |
| 807 | 865 | .attr_groups = paicrypt_attr_groups | |
| 808 | 866 | }; | |
| 809 | 867 | ||
| @@ -1015,6 +1073,7 @@ static struct pmu paiext = { | |||
| 1015 | 1073 | .stop = paiext_stop, | |
| 1016 | 1074 | .read = paiext_read, | |
| 1017 | 1075 | .sched_task = paiext_sched_task, | |
| 1076 | + | .check_period = pai_check_period, | |
| 1018 | 1077 | .attr_groups = paiext_attr_groups, | |
| 1019 | 1078 | }; | |
| 1020 | 1079 | ||
| @@ -1218,23 +1277,61 @@ static int __init paipmu_setup(void) | |||
| 1218 | 1277 | return install_ok; | |
| 1219 | 1278 | } | |
| 1220 | 1279 | ||
| 1280 | + | static int pai_online_cpu(unsigned int cpu) | |
| 1281 | + | { | |
| 1282 | + | int rc; | |
| 1283 | + | ||
| 1284 | + | mutex_lock(&pai_reserve_mutex); | |
| 1285 | + | rc = pai_alloc_cpu(PAI_PMU_CRYPTO, cpu, true); | |
| 1286 | + | if (rc) | |
| 1287 | + | goto out; | |
| 1288 | + | rc = pai_alloc_cpu(PAI_PMU_EXT, cpu, true); | |
| 1289 | + | if (rc) | |
| 1290 | + | pai_event_destroy_cpu(PAI_PMU_CRYPTO, cpu, true); | |
| 1291 | + | out: | |
| 1292 | + | mutex_unlock(&pai_reserve_mutex); | |
| 1293 | + | return rc; | |
| 1294 | + | } | |
| 1295 | + | ||
| 1296 | + | static int pai_offline_cpu(unsigned int cpu) | |
| 1297 | + | { | |
| 1298 | + | mutex_lock(&pai_reserve_mutex); | |
| 1299 | + | pai_event_destroy_cpu(PAI_PMU_CRYPTO, cpu, true); | |
| 1300 | + | pai_event_destroy_cpu(PAI_PMU_EXT, cpu, true); | |
| 1301 | + | mutex_unlock(&pai_reserve_mutex); | |
| 1302 | + | return 0; | |
| 1303 | + | } | |
| 1304 | + | ||
| 1221 | 1305 | static int __init pai_init(void) | |
| 1222 | 1306 | { | |
| 1307 | + | int state, rc; | |
| 1308 | + | ||
| 1223 | 1309 | /* Setup s390dbf facility */ | |
| 1224 | - | paidbg = debug_register("pai", 32, 256, 128); | |
| 1310 | + | paidbg = debug_register("pai", 1, 1, 128); | |
| 1225 | 1311 | if (!paidbg) { | |
| 1226 | 1312 | pr_err("Registration of s390dbf pai failed\n"); | |
| 1227 | 1313 | return -ENOMEM; | |
| 1228 | 1314 | } | |
| 1229 | 1315 | debug_register_view(paidbg, &debug_sprintf_view); | |
| 1230 | 1316 | ||
| 1231 | - | if (!paipmu_setup()) { | |
| 1232 | - | /* No PMU registration, no need for debug buffer */ | |
| 1233 | - | debug_unregister_view(paidbg, &debug_sprintf_view); | |
| 1234 | - | debug_unregister(paidbg); | |
| 1235 | - | return -ENODEV; | |
| 1236 | - | } | |
| 1317 | + | /* CPUHP_BP_PREPARE_DYN --> before CPU is brought online */ | |
| 1318 | + | state = cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "perf/pai:prepare", | |
| 1319 | + | pai_online_cpu, pai_offline_cpu); | |
| 1320 | + | rc = state < 0 ? state : 0; | |
| 1321 | + | if (rc < 0) | |
| 1322 | + | goto out_debug; | |
| 1323 | + | ||
| 1324 | + | rc = -ENODEV; | |
| 1325 | + | if (!paipmu_setup()) | |
| 1326 | + | goto out_cpuhp; | |
| 1237 | 1327 | return 0; | |
| 1328 | + | ||
| 1329 | + | out_cpuhp: | |
| 1330 | + | cpuhp_remove_state(state); | |
| 1331 | + | out_debug: | |
| 1332 | + | debug_unregister_view(paidbg, &debug_sprintf_view); | |
| 1333 | + | debug_unregister(paidbg); | |
| 1334 | + | return rc; | |
| 1238 | 1335 | } | |
| 1239 | 1336 | ||
| 1240 | 1337 | device_initcall(pai_init); | |
modified arch/s390/kernel/smp.c
| @@ -659,23 +659,13 @@ int smp_cpu_get_polarization(int cpu) | |||
| 659 | 659 | return per_cpu(pcpu_devices, cpu).polarization; | |
| 660 | 660 | } | |
| 661 | 661 | ||
| 662 | - | void smp_cpu_set_capacity(int cpu, unsigned long val) | |
| 663 | - | { | |
| 664 | - | per_cpu(pcpu_devices, cpu).capacity = val; | |
| 665 | - | } | |
| 666 | - | ||
| 667 | - | unsigned long smp_cpu_get_capacity(int cpu) | |
| 668 | - | { | |
| 669 | - | return per_cpu(pcpu_devices, cpu).capacity; | |
| 670 | - | } | |
| 671 | - | ||
| 672 | 662 | void smp_set_core_capacity(int cpu, unsigned long val) | |
| 673 | 663 | { | |
| 674 | 664 | int i; | |
| 675 | 665 | ||
| 676 | 666 | cpu = smp_get_base_cpu(cpu); | |
| 677 | 667 | for (i = cpu; (i <= cpu + smp_cpu_mtid) && (i < nr_cpu_ids); i++) | |
| 678 | - | smp_cpu_set_capacity(i, val); | |
| 668 | + | topology_set_cpu_scale(i, val); | |
| 679 | 669 | } | |
| 680 | 670 | ||
| 681 | 671 | int smp_cpu_get_cpu_address(int cpu) | |
| @@ -727,7 +717,7 @@ static int smp_add_core(struct sclp_core_entry *core, cpumask_t *avail, | |||
| 727 | 717 | else | |
| 728 | 718 | pcpu->state = CPU_STATE_STANDBY; | |
| 729 | 719 | smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); | |
| 730 | - | smp_cpu_set_capacity(cpu, CPU_CAPACITY_HIGH); | |
| 720 | + | topology_set_cpu_scale(cpu, CPU_CAPACITY_HIGH); | |
| 731 | 721 | set_cpu_present(cpu, true); | |
| 732 | 722 | if (!early && arch_register_cpu(cpu)) | |
| 733 | 723 | set_cpu_present(cpu, false); | |
| @@ -967,7 +957,7 @@ void __init smp_prepare_boot_cpu(void) | |||
| 967 | 957 | ipl_pcpu->state = CPU_STATE_CONFIGURED; | |
| 968 | 958 | lc->pcpu = (unsigned long)ipl_pcpu; | |
| 969 | 959 | smp_cpu_set_polarization(0, POLARIZATION_UNKNOWN); | |
| 970 | - | smp_cpu_set_capacity(0, CPU_CAPACITY_HIGH); | |
| 960 | + | topology_set_cpu_scale(0, CPU_CAPACITY_HIGH); | |
| 971 | 961 | } | |
| 972 | 962 | ||
| 973 | 963 | void __init smp_setup_processor_id(void) | |
modified arch/s390/kernel/topology.c
| @@ -147,7 +147,7 @@ static void add_cpus_to_mask(struct topology_core *tl_core, | |||
| 147 | 147 | cpumask_set_cpu(cpu, &book->mask); | |
| 148 | 148 | cpumask_set_cpu(cpu, &socket->mask); | |
| 149 | 149 | smp_cpu_set_polarization(cpu, tl_core->pp); | |
| 150 | - | smp_cpu_set_capacity(cpu, CPU_CAPACITY_HIGH); | |
| 150 | + | topology_set_cpu_scale(cpu, CPU_CAPACITY_HIGH); | |
| 151 | 151 | } | |
| 152 | 152 | } | |
| 153 | 153 | } | |
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/vtime.c
| @@ -32,7 +32,7 @@ static atomic64_t virt_timer_elapsed; | |||
| 32 | 32 | DEFINE_PER_CPU(u64, mt_cycles[8]); | |
| 33 | 33 | static DEFINE_PER_CPU(u64, mt_scaling_mult) = { 1 }; | |
| 34 | 34 | static DEFINE_PER_CPU(u64, mt_scaling_div) = { 1 }; | |
| 35 | - | static DEFINE_PER_CPU(u64, mt_scaling_jiffies); | |
| 35 | + | static DEFINE_PER_CPU(unsigned long, mt_scaling_jiffies); | |
| 36 | 36 | ||
| 37 | 37 | static inline void set_vtimer(u64 expires) | |
| 38 | 38 | { | |
| @@ -81,7 +81,7 @@ static void update_mt_scaling(void) | |||
| 81 | 81 | memcpy(cycles_old, cycles_new, | |
| 82 | 82 | sizeof(u64) * (smp_cpu_mtid + 1)); | |
| 83 | 83 | } | |
| 84 | - | __this_cpu_write(mt_scaling_jiffies, jiffies_64); | |
| 84 | + | __this_cpu_write(mt_scaling_jiffies, jiffies); | |
| 85 | 85 | } | |
| 86 | 86 | ||
| 87 | 87 | static inline u64 update_tsk_timer(unsigned long *tsk_vtime, u64 new) | |
| @@ -144,7 +144,7 @@ static int do_account_vtime(struct task_struct *tsk) | |||
| 144 | 144 | lc->system_timer += timer; | |
| 145 | 145 | ||
| 146 | 146 | /* Update MT utilization calculation */ | |
| 147 | - | if (smp_cpu_mtid && time_after64(jiffies_64, __this_cpu_read(mt_scaling_jiffies))) | |
| 147 | + | if (smp_cpu_mtid && time_after(jiffies, __this_cpu_read(mt_scaling_jiffies))) | |
| 148 | 148 | update_mt_scaling(); | |
| 149 | 149 | ||
| 150 | 150 | /* Calculate cputime delta */ | |
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
| @@ -2168,7 +2168,7 @@ static int kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args) | |||
| 2168 | 2168 | if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX) | |
| 2169 | 2169 | return -EINVAL; | |
| 2170 | 2170 | ||
| 2171 | - | keys = kvmalloc_array(args->count, sizeof(*keys), GFP_KERNEL_ACCOUNT); | |
| 2171 | + | keys = kvmalloc_objs(*keys, args->count, GFP_KERNEL_ACCOUNT); | |
| 2172 | 2172 | if (!keys) | |
| 2173 | 2173 | return -ENOMEM; | |
| 2174 | 2174 | ||
| @@ -2205,7 +2205,7 @@ static int kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args) | |||
| 2205 | 2205 | if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX) | |
| 2206 | 2206 | return -EINVAL; | |
| 2207 | 2207 | ||
| 2208 | - | keys = kvmalloc_array(args->count, sizeof(*keys), GFP_KERNEL_ACCOUNT); | |
| 2208 | + | keys = kvmalloc_objs(*keys, args->count, GFP_KERNEL_ACCOUNT); | |
| 2209 | 2209 | if (!keys) | |
| 2210 | 2210 | return -ENOMEM; | |
| 2211 | 2211 | ||
| @@ -5766,7 +5766,7 @@ static long cmma_d_count_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_ | |||
| 5766 | 5766 | return 0; | |
| 5767 | 5767 | } | |
| 5768 | 5768 | ||
| 5769 | - | void kvm_s390_update_cmma_dirty(struct kvm *kvm, struct kvm_memory_slot *old) | |
| 5769 | + | void kvm_s390_update_cmma_dirty(struct kvm *kvm, const struct kvm_memory_slot *old) | |
| 5770 | 5770 | { | |
| 5771 | 5771 | const struct dat_walk_ops ops = { .pte_entry = cmma_d_count_pte, }; | |
| 5772 | 5772 | ||
| @@ -5781,7 +5781,6 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, struct kvm_memory_slot *old, | |||
| 5781 | 5781 | const struct kvm_memory_slot *new, | |
| 5782 | 5782 | enum kvm_mr_change change) | |
| 5783 | 5783 | { | |
| 5784 | - | s390_kvm_mmu_commit_memory_region(kvm, old, new, change); | |
| 5785 | 5784 | } | |
| 5786 | 5785 | ||
| 5787 | 5786 | /** | |
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/mm/pgalloc.c
| @@ -55,63 +55,46 @@ static void __crst_table_upgrade(void *arg) | |||
| 55 | 55 | ||
| 56 | 56 | int crst_table_upgrade(struct mm_struct *mm, unsigned long end) | |
| 57 | 57 | { | |
| 58 | - | unsigned long *pgd = NULL, *p4d = NULL, *__pgd; | |
| 59 | - | unsigned long asce_limit = mm->context.asce_limit; | |
| 58 | + | unsigned long *table, *pgd; | |
| 59 | + | int rc, notify; | |
| 60 | 60 | ||
| 61 | 61 | mmap_assert_write_locked(mm); | |
| 62 | - | ||
| 63 | 62 | /* upgrade should only happen from 3 to 4, 3 to 5, or 4 to 5 levels */ | |
| 64 | - | VM_BUG_ON(asce_limit < _REGION2_SIZE); | |
| 65 | - | ||
| 66 | - | if (end <= asce_limit) | |
| 67 | - | return 0; | |
| 68 | - | ||
| 69 | - | if (asce_limit == _REGION2_SIZE) { | |
| 70 | - | p4d = crst_table_alloc(mm); | |
| 71 | - | if (unlikely(!p4d)) | |
| 72 | - | goto err_p4d; | |
| 73 | - | crst_table_init(p4d, _REGION2_ENTRY_EMPTY); | |
| 74 | - | pagetable_p4d_ctor(virt_to_ptdesc(p4d)); | |
| 75 | - | } | |
| 76 | - | if (end > _REGION1_SIZE) { | |
| 77 | - | pgd = crst_table_alloc(mm); | |
| 78 | - | if (unlikely(!pgd)) | |
| 79 | - | goto err_pgd; | |
| 80 | - | crst_table_init(pgd, _REGION1_ENTRY_EMPTY); | |
| 81 | - | pagetable_pgd_ctor(virt_to_ptdesc(pgd)); | |
| 82 | - | } | |
| 83 | - | ||
| 84 | - | spin_lock_bh(&mm->page_table_lock); | |
| 85 | - | ||
| 86 | - | if (p4d) { | |
| 87 | - | __pgd = (unsigned long *) mm->pgd; | |
| 88 | - | p4d_populate(mm, (p4d_t *) p4d, (pud_t *) __pgd); | |
| 89 | - | mm->pgd = (pgd_t *) p4d; | |
| 90 | - | mm->context.asce_limit = _REGION1_SIZE; | |
| 91 | - | mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | | |
| 92 | - | _ASCE_USER_BITS | _ASCE_TYPE_REGION2; | |
| 93 | - | mm_inc_nr_puds(mm); | |
| 94 | - | } | |
| 95 | - | if (pgd) { | |
| 96 | - | __pgd = (unsigned long *) mm->pgd; | |
| 97 | - | pgd_populate(mm, (pgd_t *) pgd, (p4d_t *) __pgd); | |
| 98 | - | mm->pgd = (pgd_t *) pgd; | |
| 99 | - | mm->context.asce_limit = TASK_SIZE_MAX; | |
| 100 | - | mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | | |
| 101 | - | _ASCE_USER_BITS | _ASCE_TYPE_REGION1; | |
| 63 | + | VM_BUG_ON(mm->context.asce_limit < _REGION2_SIZE); | |
| 64 | + | rc = 0; | |
| 65 | + | notify = 0; | |
| 66 | + | while (mm->context.asce_limit < end) { | |
| 67 | + | table = crst_table_alloc(mm); | |
| 68 | + | if (!table) { | |
| 69 | + | rc = -ENOMEM; | |
| 70 | + | break; | |
| 71 | + | } | |
| 72 | + | spin_lock_bh(&mm->page_table_lock); | |
| 73 | + | pgd = (unsigned long *)mm->pgd; | |
| 74 | + | if (mm->context.asce_limit == _REGION2_SIZE) { | |
| 75 | + | crst_table_init(table, _REGION2_ENTRY_EMPTY); | |
| 76 | + | p4d_populate(mm, (p4d_t *)table, (pud_t *)pgd); | |
| 77 | + | pagetable_p4d_ctor(virt_to_ptdesc(table)); | |
| 78 | + | mm->pgd = (pgd_t *)table; | |
| 79 | + | mm->context.asce_limit = _REGION1_SIZE; | |
| 80 | + | mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | | |
| 81 | + | _ASCE_USER_BITS | _ASCE_TYPE_REGION2; | |
| 82 | + | mm_inc_nr_puds(mm); | |
| 83 | + | } else { | |
| 84 | + | crst_table_init(table, _REGION1_ENTRY_EMPTY); | |
| 85 | + | pgd_populate(mm, (pgd_t *)table, (p4d_t *)pgd); | |
| 86 | + | pagetable_pgd_ctor(virt_to_ptdesc(table)); | |
| 87 | + | mm->pgd = (pgd_t *)table; | |
| 88 | + | mm->context.asce_limit = TASK_SIZE_MAX; | |
| 89 | + | mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | | |
| 90 | + | _ASCE_USER_BITS | _ASCE_TYPE_REGION1; | |
| 91 | + | } | |
| 92 | + | notify = 1; | |
| 93 | + | spin_unlock_bh(&mm->page_table_lock); | |
| 102 | 94 | } | |
| 103 | - | ||
| 104 | - | spin_unlock_bh(&mm->page_table_lock); | |
| 105 | - | ||
| 106 | - | on_each_cpu(__crst_table_upgrade, mm, 0); | |
| 107 | - | ||
| 108 | - | return 0; | |
| 109 | - | ||
| 110 | - | err_pgd: | |
| 111 | - | pagetable_dtor(virt_to_ptdesc(p4d)); | |
| 112 | - | crst_table_free(mm, p4d); | |
| 113 | - | err_p4d: | |
| 114 | - | return -ENOMEM; | |
| 95 | + | if (notify) | |
| 96 | + | on_each_cpu(__crst_table_upgrade, mm, 0); | |
| 97 | + | return rc; | |
| 115 | 98 | } | |
| 116 | 99 | ||
| 117 | 100 | unsigned long *page_table_alloc_noprof(struct mm_struct *mm) | |
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/s390/pci/pci_sysfs.c
| @@ -153,6 +153,9 @@ static ssize_t report_error_write(struct file *filp, struct kobject *kobj, | |||
| 153 | 153 | if (off || (count < sizeof(*report))) | |
| 154 | 154 | return -EINVAL; | |
| 155 | 155 | ||
| 156 | + | if (count < (report->length + sizeof(*report))) | |
| 157 | + | return -EINVAL; | |
| 158 | + | ||
| 156 | 159 | ret = sclp_pci_report(report, zdev->fh, zdev->fid); | |
| 157 | 160 | ||
| 158 | 161 | return ret ? ret : count; | |
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/aria-aesni-avx2-asm_64.S
| @@ -982,6 +982,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_encrypt_32way) | |||
| 982 | 982 | %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, | |
| 983 | 983 | %ymm15, %rax); | |
| 984 | 984 | ||
| 985 | + | vzeroupper; | |
| 985 | 986 | FRAME_END | |
| 986 | 987 | RET; | |
| 987 | 988 | SYM_FUNC_END(aria_aesni_avx2_encrypt_32way) | |
| @@ -1007,6 +1008,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_decrypt_32way) | |||
| 1007 | 1008 | %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, | |
| 1008 | 1009 | %ymm15, %rax); | |
| 1009 | 1010 | ||
| 1011 | + | vzeroupper; | |
| 1010 | 1012 | FRAME_END | |
| 1011 | 1013 | RET; | |
| 1012 | 1014 | SYM_FUNC_END(aria_aesni_avx2_decrypt_32way) | |
| @@ -1209,6 +1211,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_ctr_crypt_32way) | |||
| 1209 | 1211 | %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, | |
| 1210 | 1212 | %ymm15, %r10); | |
| 1211 | 1213 | ||
| 1214 | + | vzeroupper; | |
| 1212 | 1215 | FRAME_END | |
| 1213 | 1216 | RET; | |
| 1214 | 1217 | SYM_FUNC_END(aria_aesni_avx2_ctr_crypt_32way) | |
| @@ -1359,6 +1362,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_gfni_encrypt_32way) | |||
| 1359 | 1362 | %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, | |
| 1360 | 1363 | %ymm15, %rax); | |
| 1361 | 1364 | ||
| 1365 | + | vzeroupper; | |
| 1362 | 1366 | FRAME_END | |
| 1363 | 1367 | RET; | |
| 1364 | 1368 | SYM_FUNC_END(aria_aesni_avx2_gfni_encrypt_32way) | |
| @@ -1384,6 +1388,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_gfni_decrypt_32way) | |||
| 1384 | 1388 | %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, | |
| 1385 | 1389 | %ymm15, %rax); | |
| 1386 | 1390 | ||
| 1391 | + | vzeroupper; | |
| 1387 | 1392 | FRAME_END | |
| 1388 | 1393 | RET; | |
| 1389 | 1394 | SYM_FUNC_END(aria_aesni_avx2_gfni_decrypt_32way) | |
| @@ -1428,6 +1433,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_gfni_ctr_crypt_32way) | |||
| 1428 | 1433 | %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, | |
| 1429 | 1434 | %ymm15, %r10); | |
| 1430 | 1435 | ||
| 1436 | + | vzeroupper; | |
| 1431 | 1437 | FRAME_END | |
| 1432 | 1438 | RET; | |
| 1433 | 1439 | SYM_FUNC_END(aria_aesni_avx2_gfni_ctr_crypt_32way) | |
modified arch/x86/crypto/aria-gfni-avx512-asm_64.S
| @@ -800,6 +800,7 @@ SYM_TYPED_FUNC_START(aria_gfni_avx512_encrypt_64way) | |||
| 800 | 800 | %zmm9, %zmm8, %zmm11, %zmm10, %zmm12, %zmm13, %zmm14, | |
| 801 | 801 | %zmm15, %rax); | |
| 802 | 802 | ||
| 803 | + | vzeroupper; | |
| 803 | 804 | FRAME_END | |
| 804 | 805 | RET; | |
| 805 | 806 | SYM_FUNC_END(aria_gfni_avx512_encrypt_64way) | |
| @@ -825,6 +826,7 @@ SYM_TYPED_FUNC_START(aria_gfni_avx512_decrypt_64way) | |||
| 825 | 826 | %zmm9, %zmm8, %zmm11, %zmm10, %zmm12, %zmm13, %zmm14, | |
| 826 | 827 | %zmm15, %rax); | |
| 827 | 828 | ||
| 829 | + | vzeroupper; | |
| 828 | 830 | FRAME_END | |
| 829 | 831 | RET; | |
| 830 | 832 | SYM_FUNC_END(aria_gfni_avx512_decrypt_64way) | |
| @@ -966,6 +968,7 @@ SYM_TYPED_FUNC_START(aria_gfni_avx512_ctr_crypt_64way) | |||
| 966 | 968 | %zmm9, %zmm8, %zmm11, %zmm10, %zmm12, %zmm13, %zmm14, | |
| 967 | 969 | %zmm15, %r10); | |
| 968 | 970 | ||
| 971 | + | vzeroupper; | |
| 969 | 972 | FRAME_END | |
| 970 | 973 | RET; | |
| 971 | 974 | SYM_FUNC_END(aria_gfni_avx512_ctr_crypt_64way) | |
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/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), | |
| @@ -3125,6 +3135,27 @@ static void intel_pmu_del_event(struct perf_event *event) | |||
| 3125 | 3135 | this_cpu_ptr(&cpu_hw_events)->n_late_setup--; | |
| 3126 | 3136 | } | |
| 3127 | 3137 | ||
| 3138 | + | int __intel_pmu_quiesce(void) | |
| 3139 | + | { | |
| 3140 | + | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | |
| 3141 | + | int pmu_enabled = cpuc->enabled; | |
| 3142 | + | ||
| 3143 | + | cpuc->enabled = 0; | |
| 3144 | + | if (pmu_enabled) | |
| 3145 | + | intel_pmu_disable_all(); | |
| 3146 | + | ||
| 3147 | + | return pmu_enabled; | |
| 3148 | + | } | |
| 3149 | + | ||
| 3150 | + | void __intel_pmu_resume(int pmu_enabled) | |
| 3151 | + | { | |
| 3152 | + | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | |
| 3153 | + | ||
| 3154 | + | cpuc->enabled = pmu_enabled; | |
| 3155 | + | if (pmu_enabled) | |
| 3156 | + | intel_pmu_enable_all(0); | |
| 3157 | + | } | |
| 3158 | + | ||
| 3128 | 3159 | static int icl_set_topdown_event_period(struct perf_event *event) | |
| 3129 | 3160 | { | |
| 3130 | 3161 | struct hw_perf_event *hwc = &event->hw; | |
| @@ -3316,16 +3347,13 @@ static void intel_pmu_read_event(struct perf_event *event) | |||
| 3316 | 3347 | if (event->hw.flags & (PERF_X86_EVENT_AUTO_RELOAD | PERF_X86_EVENT_TOPDOWN) || | |
| 3317 | 3348 | is_pebs_counter_event_group(event)) { | |
| 3318 | 3349 | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | |
| 3319 | - | bool pmu_enabled = cpuc->enabled; | |
| 3350 | + | int pmu_enabled; | |
| 3320 | 3351 | ||
| 3321 | 3352 | /* Only need to call update_topdown_event() once for group read. */ | |
| 3322 | 3353 | if (is_metric_event(event) && (cpuc->txn_flags & PERF_PMU_TXN_READ)) | |
| 3323 | 3354 | return; | |
| 3324 | 3355 | ||
| 3325 | - | cpuc->enabled = 0; | |
| 3326 | - | if (pmu_enabled) | |
| 3327 | - | intel_pmu_disable_all(); | |
| 3328 | - | ||
| 3356 | + | pmu_enabled = __intel_pmu_quiesce(); | |
| 3329 | 3357 | /* | |
| 3330 | 3358 | * If the PEBS counters snapshotting is enabled, | |
| 3331 | 3359 | * the topdown event is available in PEBS records. | |
| @@ -3334,10 +3362,7 @@ static void intel_pmu_read_event(struct perf_event *event) | |||
| 3334 | 3362 | static_call(intel_pmu_update_topdown_event)(event, NULL); | |
| 3335 | 3363 | else | |
| 3336 | 3364 | intel_pmu_drain_pebs_buffer(); | |
| 3337 | - | ||
| 3338 | - | cpuc->enabled = pmu_enabled; | |
| 3339 | - | if (pmu_enabled) | |
| 3340 | - | intel_pmu_enable_all(0); | |
| 3365 | + | __intel_pmu_resume(pmu_enabled); | |
| 3341 | 3366 | ||
| 3342 | 3367 | return; | |
| 3343 | 3368 | } | |
| @@ -5277,12 +5302,15 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) | |||
| 5277 | 5302 | struct kvm_pmu *kvm_pmu = (struct kvm_pmu *)data; | |
| 5278 | 5303 | u64 intel_ctrl = hybrid(cpuc->pmu, intel_ctrl); | |
| 5279 | 5304 | u64 pebs_mask = cpuc->pebs_enabled & x86_pmu.pebs_capable; | |
| 5280 | - | int global_ctrl, pebs_enable; | |
| 5305 | + | u64 guest_pebs_mask; | |
| 5306 | + | int global_ctrl; | |
| 5281 | 5307 | ||
| 5282 | 5308 | /* | |
| 5283 | 5309 | * In addition to obeying exclude_guest/exclude_host, remove bits being | |
| 5284 | 5310 | * used for PEBS when running a guest, because PEBS writes to virtual | |
| 5285 | - | * 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. | |
| 5286 | 5314 | */ | |
| 5287 | 5315 | *nr = 0; | |
| 5288 | 5316 | global_ctrl = (*nr)++; | |
| @@ -5312,41 +5340,68 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) | |||
| 5312 | 5340 | return arr; | |
| 5313 | 5341 | } | |
| 5314 | 5342 | ||
| 5315 | - | 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) | |
| 5316 | 5349 | return arr; | |
| 5317 | 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 | + | */ | |
| 5318 | 5382 | arr[(*nr)++] = (struct perf_guest_switch_msr){ | |
| 5319 | 5383 | .msr = MSR_IA32_DS_AREA, | |
| 5320 | 5384 | .host = (unsigned long)cpuc->ds, | |
| 5321 | - | .guest = kvm_pmu->ds_area, | |
| 5385 | + | .guest = guest_pebs_mask ? kvm_pmu->ds_area : (unsigned long)cpuc->ds, | |
| 5322 | 5386 | }; | |
| 5323 | 5387 | ||
| 5324 | 5388 | if (x86_pmu.intel_cap.pebs_baseline) { | |
| 5325 | 5389 | arr[(*nr)++] = (struct perf_guest_switch_msr){ | |
| 5326 | 5390 | .msr = MSR_PEBS_DATA_CFG, | |
| 5327 | 5391 | .host = cpuc->active_pebs_data_cfg, | |
| 5328 | - | .guest = kvm_pmu->pebs_data_cfg, | |
| 5392 | + | .guest = guest_pebs_mask ? kvm_pmu->pebs_data_cfg : | |
| 5393 | + | cpuc->active_pebs_data_cfg, | |
| 5329 | 5394 | }; | |
| 5330 | 5395 | } | |
| 5331 | 5396 | ||
| 5332 | - | pebs_enable = (*nr)++; | |
| 5333 | - | arr[pebs_enable] = (struct perf_guest_switch_msr){ | |
| 5334 | - | .msr = MSR_IA32_PEBS_ENABLE, | |
| 5335 | - | .host = cpuc->pebs_enabled & ~cpuc->intel_ctrl_guest_mask, | |
| 5336 | - | .guest = pebs_mask & ~cpuc->intel_ctrl_host_mask & kvm_pmu->pebs_enable, | |
| 5337 | - | }; | |
| 5338 | - | ||
| 5339 | - | if (arr[pebs_enable].host) { | |
| 5340 | - | /* Disable guest PEBS if host PEBS is enabled. */ | |
| 5341 | - | arr[pebs_enable].guest = 0; | |
| 5342 | - | } else { | |
| 5343 | - | /* Disable guest PEBS thoroughly for cross-mapped PEBS counters. */ | |
| 5344 | - | arr[pebs_enable].guest &= ~kvm_pmu->host_cross_mapped_mask; | |
| 5345 | - | arr[global_ctrl].guest &= ~kvm_pmu->host_cross_mapped_mask; | |
| 5346 | - | /* Set hw GLOBAL_CTRL bits for PEBS counter when it runs for guest */ | |
| 5347 | - | arr[global_ctrl].guest |= arr[pebs_enable].guest; | |
| 5348 | - | } | |
| 5349 | - | ||
| 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; | |
| 5350 | 5405 | return arr; | |
| 5351 | 5406 | } | |
| 5352 | 5407 | ||
| @@ -6546,6 +6601,8 @@ static void intel_pmu_filter(struct pmu *pmu, int cpu, bool *ret) | |||
| 6546 | 6601 | ||
| 6547 | 6602 | PMU_FORMAT_ATTR(offcore_rsp, "config1:0-63"); | |
| 6548 | 6603 | ||
| 6604 | + | PMU_FORMAT_ATTR(offmodule_rsp, "config1:0-63"); | |
| 6605 | + | ||
| 6549 | 6606 | PMU_FORMAT_ATTR(ldlat, "config1:0-15"); | |
| 6550 | 6607 | ||
| 6551 | 6608 | PMU_FORMAT_ATTR(frontend, "config1:0-23"); | |
| @@ -6594,6 +6651,20 @@ static struct attribute *skl_format_attr[] = { | |||
| 6594 | 6651 | NULL, | |
| 6595 | 6652 | }; | |
| 6596 | 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 | + | ||
| 6597 | 6668 | static __initconst const struct x86_pmu core_pmu = { | |
| 6598 | 6669 | .name = "core", | |
| 6599 | 6670 | .handle_irq = x86_pmu_handle_irq, | |
| @@ -7459,6 +7530,7 @@ static struct attribute *adl_hybrid_tsx_attrs[] = { | |||
| 7459 | 7530 | FORMAT_ATTR_HYBRID(in_tx, hybrid_big); | |
| 7460 | 7531 | FORMAT_ATTR_HYBRID(in_tx_cp, hybrid_big); | |
| 7461 | 7532 | FORMAT_ATTR_HYBRID(offcore_rsp, hybrid_big_small_tiny); | |
| 7533 | + | FORMAT_ATTR_HYBRID(offmodule_rsp, hybrid_big_small_tiny); | |
| 7462 | 7534 | FORMAT_ATTR_HYBRID(ldlat, hybrid_big_small_tiny); | |
| 7463 | 7535 | FORMAT_ATTR_HYBRID(frontend, hybrid_big); | |
| 7464 | 7536 | ||
| @@ -7497,6 +7569,23 @@ static struct attribute *mtl_hybrid_extra_attr[] = { | |||
| 7497 | 7569 | NULL | |
| 7498 | 7570 | }; | |
| 7499 | 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 | + | ||
| 7500 | 7589 | static bool is_attr_for_this_pmu(struct kobject *kobj, struct attribute *attr) | |
| 7501 | 7590 | { | |
| 7502 | 7591 | struct device *dev = kobj_to_dev(kobj); | |
| @@ -8534,6 +8623,8 @@ __init int intel_pmu_init(void) | |||
| 8534 | 8623 | case INTEL_DIAMONDRAPIDS_X: | |
| 8535 | 8624 | intel_pmu_init_pnc(NULL); | |
| 8536 | 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; | |
| 8537 | 8628 | ||
| 8538 | 8629 | pr_cont("Panthercove events, "); | |
| 8539 | 8630 | name = "panthercove"; | |
| @@ -8542,13 +8633,12 @@ __init int intel_pmu_init(void) | |||
| 8542 | 8633 | glc_common: | |
| 8543 | 8634 | intel_pmu_init_glc(NULL); | |
| 8544 | 8635 | intel_pmu_pebs_data_source_skl(true); | |
| 8545 | - | ||
| 8636 | + | extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? | |
| 8637 | + | hsw_format_attr : nhm_format_attr; | |
| 8546 | 8638 | glc_base: | |
| 8547 | 8639 | x86_pmu.pebs_ept = 1; | |
| 8548 | 8640 | x86_pmu.hw_config = hsw_hw_config; | |
| 8549 | 8641 | x86_pmu.get_event_constraints = glc_get_event_constraints; | |
| 8550 | - | extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? | |
| 8551 | - | hsw_format_attr : nhm_format_attr; | |
| 8552 | 8642 | extra_skl_attr = skl_format_attr; | |
| 8553 | 8643 | mem_attr = glc_events_attrs; | |
| 8554 | 8644 | td_attr = glc_td_events_attrs; | |
| @@ -8770,7 +8860,7 @@ __init int intel_pmu_init(void) | |||
| 8770 | 8860 | mem_attr = mtl_hybrid_mem_attrs; | |
| 8771 | 8861 | tsx_attr = adl_hybrid_tsx_attrs; | |
| 8772 | 8862 | extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? | |
| 8773 | - | mtl_hybrid_extra_attr_rtm : mtl_hybrid_extra_attr; | |
| 8863 | + | nvl_hybrid_extra_attr_rtm : nvl_hybrid_extra_attr; | |
| 8774 | 8864 | ||
| 8775 | 8865 | /* Initialize big core specific PerfMon capabilities.*/ | |
| 8776 | 8866 | pmu = &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX]; | |
| @@ -8779,8 +8869,6 @@ __init int intel_pmu_init(void) | |||
| 8779 | 8869 | /* Initialize Atom core specific PerfMon capabilities.*/ | |
| 8780 | 8870 | pmu = &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_ATOM_IDX]; | |
| 8781 | 8871 | intel_pmu_init_arw(&pmu->pmu); | |
| 8782 | - | ||
| 8783 | - | intel_pmu_pebs_data_source_lnl(); | |
| 8784 | 8872 | break; | |
| 8785 | 8873 | ||
| 8786 | 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; | |
| @@ -1242,8 +1264,11 @@ unlock: | |||
| 1242 | 1264 | ||
| 1243 | 1265 | void intel_pmu_drain_pebs_buffer(void) | |
| 1244 | 1266 | { | |
| 1267 | + | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | |
| 1245 | 1268 | struct perf_sample_data data; | |
| 1246 | 1269 | ||
| 1270 | + | WARN_ON_ONCE(cpuc->enabled); | |
| 1271 | + | ||
| 1247 | 1272 | static_call(x86_pmu_drain_pebs)(NULL, &data); | |
| 1248 | 1273 | } | |
| 1249 | 1274 | ||
| @@ -1288,22 +1313,22 @@ struct event_constraint intel_glm_pebs_event_constraints[] = { | |||
| 1288 | 1313 | ||
| 1289 | 1314 | struct event_constraint intel_grt_pebs_event_constraints[] = { | |
| 1290 | 1315 | /* Allow all events as PEBS with no flags */ | |
| 1291 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x5d0, 0x3), | |
| 1292 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x6d0, 0x3f), | |
| 1316 | + | INTEL_HYBRID_LDLAT_CONSTRAINT(0x5d0, 0x3), | |
| 1317 | + | INTEL_HYBRID_STLAT_CONSTRAINT(0x6d0, 0x3f), | |
| 1293 | 1318 | EVENT_CONSTRAINT_END | |
| 1294 | 1319 | }; | |
| 1295 | 1320 | ||
| 1296 | 1321 | struct event_constraint intel_cmt_pebs_event_constraints[] = { | |
| 1297 | 1322 | /* Allow all events as PEBS with no flags */ | |
| 1298 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x5d0, 0x3), | |
| 1299 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x6d0, 0xff), | |
| 1323 | + | INTEL_HYBRID_LDLAT_CONSTRAINT(0x5d0, 0x3), | |
| 1324 | + | INTEL_HYBRID_STLAT_CONSTRAINT(0x6d0, 0xff), | |
| 1300 | 1325 | EVENT_CONSTRAINT_END | |
| 1301 | 1326 | }; | |
| 1302 | 1327 | ||
| 1303 | 1328 | struct event_constraint intel_dkt_pebs_event_constraints[] = { | |
| 1304 | 1329 | /* Allow all events as PEBS with no flags */ | |
| 1305 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x5d0, 0xff), | |
| 1306 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x6d0, 0xff), | |
| 1330 | + | INTEL_HYBRID_LDLAT_CONSTRAINT(0x5d0, 0xff), | |
| 1331 | + | INTEL_HYBRID_STLAT_CONSTRAINT(0x6d0, 0xff), | |
| 1307 | 1332 | EVENT_CONSTRAINT_END | |
| 1308 | 1333 | }; | |
| 1309 | 1334 | ||
| @@ -1493,24 +1518,8 @@ struct event_constraint intel_lnc_pebs_event_constraints[] = { | |||
| 1493 | 1518 | INTEL_FLAGS_UEVENT_CONSTRAINT(0x012a, 0x1), /* OCR.* events */ | |
| 1494 | 1519 | INTEL_FLAGS_UEVENT_CONSTRAINT(0x012b, 0x1), /* OCR.* events */ | |
| 1495 | 1520 | ||
| 1496 | - | INTEL_FLAGS_UEVENT_CONSTRAINT(0x04a4, 0x1), /* TOPDOWN.BAD_SPEC_SLOTS */ | |
| 1497 | - | INTEL_FLAGS_UEVENT_CONSTRAINT(0x08a4, 0x1), /* TOPDOWN.BR_MISPREDICT_SLOTS */ | |
| 1498 | - | INTEL_FLAGS_UEVENT_CONSTRAINT(0x10a4, 0x8), /* TOPDOWN.MEMORY_BOUND_SLOTS */ | |
| 1499 | - | ||
| 1500 | 1521 | INTEL_HYBRID_LDLAT_CONSTRAINT(0x1cd, 0x3fc), | |
| 1501 | 1522 | INTEL_HYBRID_STLAT_CONSTRAINT(0x2cd, 0x3), | |
| 1502 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x11d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_LOADS */ | |
| 1503 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x12d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_STORES */ | |
| 1504 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x21d0, 0xf), /* MEM_INST_RETIRED.LOCK_LOADS */ | |
| 1505 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x41d0, 0xf), /* MEM_INST_RETIRED.SPLIT_LOADS */ | |
| 1506 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x42d0, 0xf), /* MEM_INST_RETIRED.SPLIT_STORES */ | |
| 1507 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x81d0, 0xf), /* MEM_INST_RETIRED.ALL_LOADS */ | |
| 1508 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x82d0, 0xf), /* MEM_INST_RETIRED.ALL_STORES */ | |
| 1509 | - | INTEL_FLAGS_UEVENT_CONSTRAINT(0x87d0, 0x3ff), /* MEM_INST_RETIRED.ANY */ | |
| 1510 | - | ||
| 1511 | - | INTEL_FLAGS_EVENT_CONSTRAINT_DATALA_LD_RANGE(0xd1, 0xd4, 0xf), | |
| 1512 | - | ||
| 1513 | - | INTEL_FLAGS_EVENT_CONSTRAINT(0xd0, 0xf), | |
| 1514 | 1523 | ||
| 1515 | 1524 | /* | |
| 1516 | 1525 | * Everything else is handled by PMU_FL_PEBS_ALL, because we | |
| @@ -1523,18 +1532,6 @@ struct event_constraint intel_lnc_pebs_event_constraints[] = { | |||
| 1523 | 1532 | struct event_constraint intel_pnc_pebs_event_constraints[] = { | |
| 1524 | 1533 | INTEL_HYBRID_LDLAT_CONSTRAINT(0x1cd, 0xfc), | |
| 1525 | 1534 | INTEL_HYBRID_STLAT_CONSTRAINT(0x2cd, 0x3), | |
| 1526 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x11d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_LOADS */ | |
| 1527 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x12d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_STORES */ | |
| 1528 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x21d0, 0xf), /* MEM_INST_RETIRED.LOCK_LOADS */ | |
| 1529 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x41d0, 0xf), /* MEM_INST_RETIRED.SPLIT_LOADS */ | |
| 1530 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x42d0, 0xf), /* MEM_INST_RETIRED.SPLIT_STORES */ | |
| 1531 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x81d0, 0xf), /* MEM_INST_RETIRED.ALL_LOADS */ | |
| 1532 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x82d0, 0xf), /* MEM_INST_RETIRED.ALL_STORES */ | |
| 1533 | - | ||
| 1534 | - | INTEL_FLAGS_EVENT_CONSTRAINT_DATALA_LD_RANGE(0xd1, 0xd4, 0xf), | |
| 1535 | - | ||
| 1536 | - | INTEL_FLAGS_EVENT_CONSTRAINT(0xd0, 0xf), | |
| 1537 | - | INTEL_FLAGS_EVENT_CONSTRAINT(0xd6, 0xf), | |
| 1538 | 1535 | ||
| 1539 | 1536 | /* | |
| 1540 | 1537 | * Everything else is handled by PMU_FL_PEBS_ALL, because we | |
| @@ -1864,8 +1861,11 @@ static void intel_pmu_pebs_via_pt_enable(struct perf_event *event) | |||
| 1864 | 1861 | static inline void intel_pmu_drain_large_pebs(struct cpu_hw_events *cpuc) | |
| 1865 | 1862 | { | |
| 1866 | 1863 | if (cpuc->n_pebs == cpuc->n_large_pebs && | |
| 1867 | - | cpuc->n_pebs != cpuc->n_pebs_via_pt) | |
| 1864 | + | cpuc->n_pebs != cpuc->n_pebs_via_pt) { | |
| 1865 | + | int enabled = __intel_pmu_quiesce(); | |
| 1868 | 1866 | intel_pmu_drain_pebs_buffer(); | |
| 1867 | + | __intel_pmu_resume(enabled); | |
| 1868 | + | } | |
| 1869 | 1869 | } | |
| 1870 | 1870 | ||
| 1871 | 1871 | static void __intel_pmu_pebs_enable(struct perf_event *event) | |
| @@ -2432,7 +2432,7 @@ static inline void __setup_pebs_basic_group(struct perf_event *event, | |||
| 2432 | 2432 | { | |
| 2433 | 2433 | /* The ip in basic is EventingIP */ | |
| 2434 | 2434 | set_linear_ip(regs, ip); | |
| 2435 | - | regs->flags = PERF_EFLAGS_EXACT; | |
| 2435 | + | regs->flags |= PERF_EFLAGS_EXACT; | |
| 2436 | 2436 | setup_pebs_time(event, data, tsc); | |
| 2437 | 2437 | ||
| 2438 | 2438 | if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) | |
| @@ -2444,9 +2444,17 @@ static inline void __setup_pebs_gpr_group(struct perf_event *event, | |||
| 2444 | 2444 | struct pebs_gprs *gprs, | |
| 2445 | 2445 | u64 sample_type) | |
| 2446 | 2446 | { | |
| 2447 | + | /* | |
| 2448 | + | * Update flags with PEBS data. PERF_EFLAGS_EXACT must be set | |
| 2449 | + | * in previous basic group handling. | |
| 2450 | + | */ | |
| 2451 | + | regs->flags = gprs->flags | PERF_EFLAGS_EXACT; | |
| 2452 | + | ||
| 2447 | 2453 | if (event->attr.precise_ip < 2) { | |
| 2448 | 2454 | set_linear_ip(regs, gprs->ip); | |
| 2449 | 2455 | regs->flags &= ~PERF_EFLAGS_EXACT; | |
| 2456 | + | } else if (regs->flags & X86_VM_MASK) { | |
| 2457 | + | regs->flags ^= (PERF_EFLAGS_VM | X86_VM_MASK); | |
| 2450 | 2458 | } | |
| 2451 | 2459 | ||
| 2452 | 2460 | if (sample_type & (PERF_SAMPLE_REGS_INTR | PERF_SAMPLE_REGS_USER)) | |
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) | |
| @@ -1638,6 +1634,9 @@ static __always_inline void __intel_pmu_lbr_disable(void) | |||
| 1638 | 1634 | wrmsrq(MSR_IA32_DEBUGCTLMSR, debugctl); | |
| 1639 | 1635 | } | |
| 1640 | 1636 | ||
| 1637 | + | extern int __intel_pmu_quiesce(void); | |
| 1638 | + | extern void __intel_pmu_resume(int pmu_enabled); | |
| 1639 | + | ||
| 1641 | 1640 | int intel_pmu_save_and_restart(struct perf_event *event); | |
| 1642 | 1641 | ||
| 1643 | 1642 | struct event_constraint * | |
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/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
| @@ -38,7 +38,6 @@ static struct pci_dev **amd_roots; | |||
| 38 | 38 | ||
| 39 | 39 | /* Protect the PCI config register pairs used for SMN. */ | |
| 40 | 40 | static DEFINE_MUTEX(smn_mutex); | |
| 41 | - | static bool smn_exclusive; | |
| 42 | 41 | ||
| 43 | 42 | #define SMN_INDEX_OFFSET 0x60 | |
| 44 | 43 | #define SMN_DATA_OFFSET 0x64 | |
| @@ -91,11 +90,16 @@ static int __amd_smn_rw(u8 i_off, u8 d_off, u16 node, u32 address, u32 *value, b | |||
| 91 | 90 | if (node >= amd_num_nodes()) | |
| 92 | 91 | return err; | |
| 93 | 92 | ||
| 94 | - | root = amd_roots[node]; | |
| 95 | - | if (!root) | |
| 93 | + | /* | |
| 94 | + | * Uninitialized amd_roots indicates pci_request_config_region_exclusive() | |
| 95 | + | * didn't run or failed and thus the kernel cannot rely on having | |
| 96 | + | * exclusive access to SMN registers so prevent that. | |
| 97 | + | */ | |
| 98 | + | if (!amd_roots) | |
| 96 | 99 | return err; | |
| 97 | 100 | ||
| 98 | - | if (!smn_exclusive) | |
| 101 | + | root = amd_roots[node]; | |
| 102 | + | if (!root) | |
| 99 | 103 | return err; | |
| 100 | 104 | ||
| 101 | 105 | guard(mutex)(&smn_mutex); | |
| @@ -247,7 +251,7 @@ __setup("amd_smn_debugfs_enable", amd_smn_enable_dfs); | |||
| 247 | 251 | static int __init amd_smn_init(void) | |
| 248 | 252 | { | |
| 249 | 253 | u16 count, num_roots, roots_per_node, node, num_nodes; | |
| 250 | - | struct pci_dev *root; | |
| 254 | + | struct pci_dev *root __free(pci_dev_put) = NULL; | |
| 251 | 255 | ||
| 252 | 256 | if (!cpu_feature_enabled(X86_FEATURE_ZEN)) | |
| 253 | 257 | return 0; | |
| @@ -258,7 +262,6 @@ static int __init amd_smn_init(void) | |||
| 258 | 262 | return 0; | |
| 259 | 263 | ||
| 260 | 264 | num_roots = 0; | |
| 261 | - | root = NULL; | |
| 262 | 265 | while ((root = get_next_root(root))) { | |
| 263 | 266 | pci_dbg(root, "Reserving PCI config space\n"); | |
| 264 | 267 | ||
| @@ -287,17 +290,21 @@ static int __init amd_smn_init(void) | |||
| 287 | 290 | return -ENOMEM; | |
| 288 | 291 | ||
| 289 | 292 | roots_per_node = num_roots / num_nodes; | |
| 293 | + | if (!roots_per_node) { | |
| 294 | + | if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) | |
| 295 | + | pr_warn(FW_BUG "Error detecting roots per node.\n"); | |
| 296 | + | roots_per_node = 1; | |
| 297 | + | } | |
| 290 | 298 | ||
| 291 | 299 | count = 0; | |
| 292 | 300 | node = 0; | |
| 293 | - | root = NULL; | |
| 294 | 301 | while (node < num_nodes && (root = get_next_root(root))) { | |
| 295 | 302 | /* Use one root for each node and skip the rest. */ | |
| 296 | 303 | if (count++ % roots_per_node) | |
| 297 | 304 | continue; | |
| 298 | 305 | ||
| 299 | 306 | pci_dbg(root, "is root for AMD node %u\n", node); | |
| 300 | - | amd_roots[node++] = root; | |
| 307 | + | amd_roots[node++] = pci_dev_get(root); | |
| 301 | 308 | } | |
| 302 | 309 | ||
| 303 | 310 | if (enable_dfs) { | |
| @@ -308,8 +315,6 @@ static int __init amd_smn_init(void) | |||
| 308 | 315 | debugfs_create_file("value", 0600, debugfs_dir, NULL, &smn_value_fops); | |
| 309 | 316 | } | |
| 310 | 317 | ||
| 311 | - | smn_exclusive = true; | |
| 312 | - | ||
| 313 | 318 | return 0; | |
| 314 | 319 | } | |
| 315 | 320 | ||
modified arch/x86/kernel/cpu/mce/amd.c
| @@ -865,7 +865,7 @@ static void amd_deferred_error_interrupt(void) | |||
| 865 | 865 | ||
| 866 | 866 | void mce_amd_handle_storm(unsigned int bank, bool on) | |
| 867 | 867 | { | |
| 868 | - | threshold_restart_bank(bank, on); | |
| 868 | + | threshold_restart_bank(bank, !on); | |
| 869 | 869 | } | |
| 870 | 870 | ||
| 871 | 871 | static void amd_reset_thr_limit(unsigned int bank) | |
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/itmt.c
| @@ -110,18 +110,14 @@ int sched_set_itmt_support(void) | |||
| 110 | 110 | arch_debugfs_dir, | |
| 111 | 111 | &sysctl_sched_itmt_enabled, | |
| 112 | 112 | &dfs_sched_itmt_fops); | |
| 113 | - | if (IS_ERR_OR_NULL(dfs_sched_itmt)) { | |
| 113 | + | if (IS_ERR(dfs_sched_itmt)) | |
| 114 | 114 | dfs_sched_itmt = NULL; | |
| 115 | - | return -ENOMEM; | |
| 116 | - | } | |
| 117 | 115 | ||
| 118 | 116 | dfs_sched_core_prio = debugfs_create_file("sched_core_priority", 0644, | |
| 119 | 117 | arch_debugfs_dir, NULL, | |
| 120 | 118 | &sched_core_priority_fops); | |
| 121 | - | if (IS_ERR_OR_NULL(dfs_sched_core_prio)) { | |
| 119 | + | if (IS_ERR(dfs_sched_core_prio)) | |
| 122 | 120 | dfs_sched_core_prio = NULL; | |
| 123 | - | return -ENOMEM; | |
| 124 | - | } | |
| 125 | 121 | ||
| 126 | 122 | sched_itmt_capable = true; | |
| 127 | 123 | ||
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/kvm/mmu/mmu.c
| @@ -5058,7 +5058,7 @@ static int kvm_tdp_page_prefault(struct kvm_vcpu *vcpu, gpa_t gpa, | |||
| 5058 | 5058 | if (signal_pending(current)) | |
| 5059 | 5059 | return -EINTR; | |
| 5060 | 5060 | ||
| 5061 | - | if (kvm_check_request(KVM_REQ_VM_DEAD, vcpu)) | |
| 5061 | + | if (kvm_test_request(KVM_REQ_VM_DEAD, vcpu)) | |
| 5062 | 5062 | return -EIO; | |
| 5063 | 5063 | ||
| 5064 | 5064 | 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
| @@ -2048,6 +2048,12 @@ static void sev_migrate_from(struct kvm *dst_kvm, struct kvm *src_kvm) | |||
| 2048 | 2048 | src->pages_locked = 0; | |
| 2049 | 2049 | src->es_active = false; | |
| 2050 | 2050 | ||
| 2051 | + | /* | |
| 2052 | + | * Do cache maintenance on the source VM as it is no longer an SEV VM, | |
| 2053 | + | * i.e. memory reclaim flows won't trigger cache maintenance on the VM. | |
| 2054 | + | */ | |
| 2055 | + | sev_writeback_caches(src_kvm); | |
| 2056 | + | ||
| 2051 | 2057 | list_cut_before(&dst->regions_list, &src->regions_list, &src->regions_list); | |
| 2052 | 2058 | ||
| 2053 | 2059 | mutex_lock(&sev_mirror_lock); | |
| @@ -2187,6 +2193,10 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd) | |||
| 2187 | 2193 | * the set of CPUs from the source. If a CPU was used to run a vCPU in | |
| 2188 | 2194 | * the source VM but is never used for the destination VM, then the CPU | |
| 2189 | 2195 | * can only have cached memory that was accessible to the source VM. | |
| 2196 | + | * Furthermore, KVM *must* perform cache maintenance on the source VM, | |
| 2197 | + | * as the source VM may have access to memory that the destination VM | |
| 2198 | + | * does not, i.e. KVM could skip flushes if memory is reclaimed from | |
| 2199 | + | * the old VM but not the new VM. | |
| 2190 | 2200 | */ | |
| 2191 | 2201 | if (!zalloc_cpumask_var(&dst_sev->have_run_cpus, GFP_KERNEL_ACCOUNT)) { | |
| 2192 | 2202 | ret = -ENOMEM; | |
| @@ -2980,13 +2990,17 @@ void sev_vm_destroy(struct kvm *kvm) | |||
| 2980 | 2990 | struct list_head *head = &sev->regions_list; | |
| 2981 | 2991 | struct list_head *pos, *q; | |
| 2982 | 2992 | ||
| 2993 | + | /* | |
| 2994 | + | * Free the mask even if the VM is not *currently* an SEV VM, as it may | |
| 2995 | + | * have been an SEV VM prior to intra-host migration. | |
| 2996 | + | */ | |
| 2997 | + | free_cpumask_var(sev->have_run_cpus); | |
| 2998 | + | ||
| 2983 | 2999 | if (!sev_guest(kvm)) | |
| 2984 | 3000 | return; | |
| 2985 | 3001 | ||
| 2986 | 3002 | WARN_ON(!list_empty(&sev->mirror_vms)); | |
| 2987 | 3003 | ||
| 2988 | - | free_cpumask_var(sev->have_run_cpus); | |
| 2989 | - | ||
| 2990 | 3004 | /* | |
| 2991 | 3005 | * If this is a mirror VM, remove it from the owner's list of a mirrors | |
| 2992 | 3006 | * and skip ASID cleanup (the ASID is tied to the lifetime of the owner). | |
modified arch/x86/kvm/vmx/nested.c
| @@ -3465,10 +3465,6 @@ static bool nested_get_vmcs12_pages(struct kvm_vcpu *vcpu) | |||
| 3465 | 3465 | } else { | |
| 3466 | 3466 | pr_debug_ratelimited("%s: no backing for APIC-access address in vmcs12\n", | |
| 3467 | 3467 | __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 | 3468 | return false; | |
| 3473 | 3469 | } | |
| 3474 | 3470 | } | |
| @@ -3539,11 +3535,6 @@ static bool vmx_get_nested_state_pages(struct kvm_vcpu *vcpu) | |||
| 3539 | 3535 | if (!nested_get_evmcs_page(vcpu)) { | |
| 3540 | 3536 | pr_debug_ratelimited("%s: enlightened vmptrld failed\n", | |
| 3541 | 3537 | __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 | 3538 | return false; | |
| 3548 | 3539 | } | |
| 3549 | 3540 | #endif | |
| @@ -3915,8 +3906,12 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) | |||
| 3915 | 3906 | ||
| 3916 | 3907 | vmentry_failed: | |
| 3917 | 3908 | vcpu->arch.nested_run_pending = 0; | |
| 3918 | - | if (status == NVMX_VMENTRY_KVM_INTERNAL_ERROR) | |
| 3909 | + | if (status == NVMX_VMENTRY_KVM_INTERNAL_ERROR) { | |
| 3910 | + | vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | |
| 3911 | + | vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; | |
| 3912 | + | vcpu->run->internal.ndata = 0; | |
| 3919 | 3913 | return 0; | |
| 3914 | + | } | |
| 3920 | 3915 | if (status == NVMX_VMENTRY_VMEXIT) | |
| 3921 | 3916 | return 1; | |
| 3922 | 3917 | 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 | } | |
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/net/bpf_jit_comp.c
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | #include <linux/bpf_verifier.h> | |
| 14 | 14 | #include <linux/memory.h> | |
| 15 | 15 | #include <linux/sort.h> | |
| 16 | + | #include <linux/execmem.h> | |
| 16 | 17 | #include <asm/extable.h> | |
| 17 | 18 | #include <asm/ftrace.h> | |
| 18 | 19 | #include <asm/set_memory.h> | |
| @@ -3818,15 +3819,16 @@ int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |||
| 3818 | 3819 | * | |
| 3819 | 3820 | * We cannot use kvmalloc here, because we need image to be in | |
| 3820 | 3821 | * module memory range. | |
| 3821 | - | * Since it must be writable use bpf_jit_alloc_exec_rw(). | |
| 3822 | + | * Since it must be writable use execmem_alloc(EXECMEM_MODULE_DATA) | |
| 3823 | + | * that returns writable memory in the module address space. | |
| 3822 | 3824 | */ | |
| 3823 | - | image = bpf_jit_alloc_exec_rw(PAGE_SIZE); | |
| 3825 | + | image = execmem_alloc(EXECMEM_MODULE_DATA, PAGE_SIZE); | |
| 3824 | 3826 | if (!image) | |
| 3825 | 3827 | return -ENOMEM; | |
| 3826 | 3828 | ||
| 3827 | 3829 | ret = __arch_prepare_bpf_trampoline(&im, image, image + PAGE_SIZE, image, | |
| 3828 | 3830 | m, flags, tnodes, func_addr); | |
| 3829 | - | bpf_jit_free_exec(image); | |
| 3831 | + | execmem_free(image); | |
| 3830 | 3832 | return ret; | |
| 3831 | 3833 | } | |
| 3832 | 3834 | ||
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 block/bio.c
| @@ -859,6 +859,7 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp) | |||
| 859 | 859 | bio->bi_ioprio = bio_src->bi_ioprio; | |
| 860 | 860 | bio->bi_write_hint = bio_src->bi_write_hint; | |
| 861 | 861 | bio->bi_write_stream = bio_src->bi_write_stream; | |
| 862 | + | bio->bi_bvec_gap_bit = bio_src->bi_bvec_gap_bit; | |
| 862 | 863 | bio->bi_iter = bio_src->bi_iter; | |
| 863 | 864 | bio->bi_io_vec = bio_src->bi_io_vec; | |
| 864 | 865 | ||
| @@ -1972,6 +1973,14 @@ struct bio *bio_split(struct bio *bio, int sectors, | |||
| 1972 | 1973 | ||
| 1973 | 1974 | bio_advance(bio, split->bi_iter.bi_size); | |
| 1974 | 1975 | ||
| 1976 | + | /* | |
| 1977 | + | * The gap bit is set when splitting to limits and only applies to the | |
| 1978 | + | * front bio that was split off. The remaining bio will calcualte its | |
| 1979 | + | * gap value when it is subsequently split to limits, so it is safe to | |
| 1980 | + | * re-initialize the value back to 0. | |
| 1981 | + | */ | |
| 1982 | + | bio->bi_bvec_gap_bit = 0; | |
| 1983 | + | ||
| 1975 | 1984 | if (bio_flagged(bio, BIO_TRACE_COMPLETION)) | |
| 1976 | 1985 | bio_set_flag(split, BIO_TRACE_COMPLETION); | |
| 1977 | 1986 | ||
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/genhd.c
| @@ -447,6 +447,13 @@ static int __add_disk(struct device *parent, struct gendisk *disk, | |||
| 447 | 447 | bdev_set_flag(disk->part0, BD_HAS_SUBMIT_BIO); | |
| 448 | 448 | } | |
| 449 | 449 | ||
| 450 | + | /* | |
| 451 | + | * We do not support partitions with zoned block devices, so do not try | |
| 452 | + | * to scan the partitions table. | |
| 453 | + | */ | |
| 454 | + | if (blk_queue_is_zoned(disk->queue)) | |
| 455 | + | disk->flags |= GENHD_FL_NO_PART; | |
| 456 | + | ||
| 450 | 457 | /* | |
| 451 | 458 | * If the driver provides an explicit major number it also must provide | |
| 452 | 459 | * the number of minors numbers supported, and those will be used to | |
modified drivers/accel/amdxdna/aie2_message.c
| @@ -994,7 +994,7 @@ int aie2_cmdlist_multi_execbuf(struct amdxdna_hwctx *hwctx, | |||
| 994 | 994 | } | |
| 995 | 995 | ||
| 996 | 996 | ccnt = payload->command_count; | |
| 997 | - | if (payload_len < struct_size(payload, data, ccnt)) { | |
| 997 | + | if (!ccnt || payload_len < struct_size(payload, data, ccnt)) { | |
| 998 | 998 | XDNA_DBG(xdna, "Invalid command count %d", ccnt); | |
| 999 | 999 | return -EINVAL; | |
| 1000 | 1000 | } | |
modified drivers/accel/amdxdna/amdxdna_ctx.c
| @@ -183,8 +183,10 @@ int amdxdna_cmd_set_error(struct amdxdna_gem_obj *abo, | |||
| 183 | 183 | if (!abo) | |
| 184 | 184 | return -EINVAL; | |
| 185 | 185 | cmd = amdxdna_gem_vmap(abo); | |
| 186 | - | if (!cmd) | |
| 186 | + | if (!cmd) { | |
| 187 | + | amdxdna_gem_put_obj(abo); | |
| 187 | 188 | return -ENOMEM; | |
| 189 | + | } | |
| 188 | 190 | } | |
| 189 | 191 | ||
| 190 | 192 | memset(cmd->data, 0xff, abo->mem.size - sizeof(*cmd)); | |
modified drivers/accel/amdxdna/amdxdna_ctx.h
| @@ -55,7 +55,7 @@ struct amdxdna_cmd_chain { | |||
| 55 | 55 | u32 submit_index; | |
| 56 | 56 | u32 error_index; | |
| 57 | 57 | u32 reserved[3]; | |
| 58 | - | u64 data[] __counted_by(command_count); | |
| 58 | + | u64 data[]; | |
| 59 | 59 | }; | |
| 60 | 60 | ||
| 61 | 61 | /* | |
modified drivers/accel/amdxdna/amdxdna_gem.c
| @@ -1246,6 +1246,9 @@ static int amdxdna_flush_bo(struct amdxdna_gem_obj *abo, u64 offset, u64 size) | |||
| 1246 | 1246 | { | |
| 1247 | 1247 | u64 end; | |
| 1248 | 1248 | ||
| 1249 | + | if (is_import_bo(abo)) | |
| 1250 | + | return -EOPNOTSUPP; | |
| 1251 | + | ||
| 1249 | 1252 | if (offset >= abo->mem.size) | |
| 1250 | 1253 | return -EINVAL; | |
| 1251 | 1254 | ||
| @@ -1253,9 +1256,10 @@ static int amdxdna_flush_bo(struct amdxdna_gem_obj *abo, u64 offset, u64 size) | |||
| 1253 | 1256 | return -EINVAL; | |
| 1254 | 1257 | ||
| 1255 | 1258 | size = min(abo->mem.size, end) - offset; | |
| 1256 | - | if (is_import_bo(abo)) | |
| 1257 | - | drm_clflush_sg(abo->base.sgt); | |
| 1258 | - | else if (amdxdna_gem_vmap(abo)) | |
| 1259 | + | if (!size) | |
| 1260 | + | return 0; | |
| 1261 | + | ||
| 1262 | + | if (amdxdna_gem_vmap(abo)) | |
| 1259 | 1263 | drm_clflush_virt_range(amdxdna_gem_vmap(abo) + offset, size); | |
| 1260 | 1264 | else if (abo->base.pages) | |
| 1261 | 1265 | drm_clflush_pages(abo->base.pages, abo->mem.size >> PAGE_SHIFT); | |
modified drivers/accel/ethosu/ethosu_device.h
| @@ -87,6 +87,7 @@ struct gen_pool; | |||
| 87 | 87 | #define PMU_EV_TYPE_IDLE 0x20 | |
| 88 | 88 | ||
| 89 | 89 | enum ethosu_cmds { | |
| 90 | + | NPU_OP_STOP = 0x0, | |
| 90 | 91 | NPU_OP_CONV = 0x2, | |
| 91 | 92 | NPU_OP_DEPTHWISE = 0x3, | |
| 92 | 93 | NPU_OP_POOL = 0x5, | |
modified drivers/accel/ethosu/ethosu_drv.c
| @@ -281,8 +281,6 @@ static int ethosu_device_suspend(struct device *dev) | |||
| 281 | 281 | ||
| 282 | 282 | static int ethosu_sram_init(struct ethosu_device *ethosudev) | |
| 283 | 283 | { | |
| 284 | - | ethosudev->npu_info.sram_size = 0; | |
| 285 | - | ||
| 286 | 284 | ethosudev->srampool = of_gen_pool_get(ethosudev->base.dev->of_node, "sram", 0); | |
| 287 | 285 | if (!ethosudev->srampool) | |
| 288 | 286 | return 0; | |
| @@ -293,6 +291,7 @@ static int ethosu_sram_init(struct ethosu_device *ethosudev) | |||
| 293 | 291 | ethosudev->npu_info.sram_size, | |
| 294 | 292 | ðosudev->sramphys); | |
| 295 | 293 | if (!ethosudev->sram) { | |
| 294 | + | ethosudev->npu_info.sram_size = 0; | |
| 296 | 295 | dev_err(ethosudev->base.dev, "failed to allocate from SRAM pool\n"); | |
| 297 | 296 | return -ENOMEM; | |
| 298 | 297 | } | |
| @@ -356,6 +355,8 @@ static int ethosu_probe(struct platform_device *pdev) | |||
| 356 | 355 | dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40)); | |
| 357 | 356 | ||
| 358 | 357 | ethosudev->regs = devm_platform_ioremap_resource(pdev, 0); | |
| 358 | + | if (IS_ERR(ethosudev->regs)) | |
| 359 | + | return PTR_ERR(ethosudev->regs); | |
| 359 | 360 | ethosudev->pmu_regs = ethosudev->regs; | |
| 360 | 361 | ||
| 361 | 362 | ethosudev->num_clks = devm_clk_bulk_get_all(&pdev->dev, ðosudev->clks); | |
modified drivers/accel/ethosu/ethosu_gem.c
| @@ -204,7 +204,7 @@ static u64 feat_matrix_length(struct ethosu_device *edev, | |||
| 204 | 204 | struct feat_matrix *fm, | |
| 205 | 205 | u32 x, u32 y, u32 c, bool ofm) | |
| 206 | 206 | { | |
| 207 | - | u32 element_size, storage = fm->precision >> 14; | |
| 207 | + | u32 element_size, storage = ethosu_is_u65(edev) ? 0 : fm->precision >> 14; | |
| 208 | 208 | int tile = 0; | |
| 209 | 209 | u64 addr; | |
| 210 | 210 | ||
| @@ -390,6 +390,7 @@ static int ethosu_gem_cmdstream_copy_and_validate(struct drm_device *ddev, | |||
| 390 | 390 | struct ethosu_validated_cmdstream_info __free(kfree) *info = kzalloc_obj(*info); | |
| 391 | 391 | struct ethosu_device *edev = to_ethosu_device(ddev); | |
| 392 | 392 | u32 *bocmds = bo->base.vaddr; | |
| 393 | + | bool ends_with_stop = false; | |
| 393 | 394 | struct cmd_state st; | |
| 394 | 395 | int i, ret; | |
| 395 | 396 | ||
| @@ -426,6 +427,11 @@ static int ethosu_gem_cmdstream_copy_and_validate(struct drm_device *ddev, | |||
| 426 | 427 | } | |
| 427 | 428 | ||
| 428 | 429 | switch (cmd) { | |
| 430 | + | case NPU_OP_STOP: | |
| 431 | + | if (i != size / 4 - 1) | |
| 432 | + | return -EINVAL; | |
| 433 | + | ends_with_stop = true; | |
| 434 | + | break; | |
| 429 | 435 | case NPU_OP_DMA_START: | |
| 430 | 436 | srclen = dma_length(info, &st.dma, &st.dma.src); | |
| 431 | 437 | dstlen = dma_length(info, &st.dma, &st.dma.dst); | |
| @@ -688,6 +694,9 @@ static int ethosu_gem_cmdstream_copy_and_validate(struct drm_device *ddev, | |||
| 688 | 694 | } | |
| 689 | 695 | } | |
| 690 | 696 | ||
| 697 | + | if (!ends_with_stop) | |
| 698 | + | return -EINVAL; | |
| 699 | + | ||
| 691 | 700 | for (i = 0; i < NPU_BASEP_REGION_MAX; i++) { | |
| 692 | 701 | if (!info->region_size[i]) | |
| 693 | 702 | continue; | |
modified drivers/accel/ethosu/ethosu_job.c
| @@ -154,6 +154,13 @@ static void ethosu_job_err_cleanup(struct ethosu_job *job) | |||
| 154 | 154 | ||
| 155 | 155 | drm_gem_object_put(job->cmd_bo); | |
| 156 | 156 | ||
| 157 | + | if (job->done_fence) { | |
| 158 | + | if (dma_fence_was_initialized(job->done_fence)) | |
| 159 | + | dma_fence_put(job->done_fence); | |
| 160 | + | else | |
| 161 | + | dma_fence_free(job->done_fence); | |
| 162 | + | } | |
| 163 | + | ||
| 157 | 164 | kfree(job); | |
| 158 | 165 | } | |
| 159 | 166 | ||
| @@ -164,7 +171,6 @@ static void ethosu_job_cleanup(struct kref *ref) | |||
| 164 | 171 | ||
| 165 | 172 | pm_runtime_put_autosuspend(job->dev->base.dev); | |
| 166 | 173 | ||
| 167 | - | dma_fence_put(job->done_fence); | |
| 168 | 174 | dma_fence_put(job->inference_done_fence); | |
| 169 | 175 | ||
| 170 | 176 | ethosu_job_err_cleanup(job); | |
| @@ -337,7 +343,7 @@ int ethosu_job_init(struct ethosu_device *edev) | |||
| 337 | 343 | ret = devm_request_threaded_irq(dev, edev->irq, | |
| 338 | 344 | ethosu_job_irq_handler, | |
| 339 | 345 | ethosu_job_irq_handler_thread, | |
| 340 | - | IRQF_SHARED, KBUILD_MODNAME, | |
| 346 | + | 0, KBUILD_MODNAME, | |
| 341 | 347 | edev); | |
| 342 | 348 | if (ret) { | |
| 343 | 349 | dev_err(dev, "failed to request irq\n"); | |
| @@ -368,12 +374,10 @@ int ethosu_job_open(struct ethosu_file_priv *ethosu_priv) | |||
| 368 | 374 | { | |
| 369 | 375 | struct ethosu_device *dev = ethosu_priv->edev; | |
| 370 | 376 | struct drm_gpu_scheduler *sched = &dev->sched; | |
| 371 | - | int ret; | |
| 372 | 377 | ||
| 373 | - | ret = drm_sched_entity_init(ðosu_priv->sched_entity, | |
| 374 | - | DRM_SCHED_PRIORITY_NORMAL, | |
| 375 | - | &sched, 1, NULL); | |
| 376 | - | return WARN_ON(ret); | |
| 378 | + | return drm_sched_entity_init(ðosu_priv->sched_entity, | |
| 379 | + | DRM_SCHED_PRIORITY_NORMAL, | |
| 380 | + | &sched, 1, NULL); | |
| 377 | 381 | } | |
| 378 | 382 | ||
| 379 | 383 | void ethosu_job_close(struct ethosu_file_priv *ethosu_priv) | |
| @@ -415,7 +419,7 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file | |||
| 415 | 419 | ejob->done_fence = kzalloc_obj(*ejob->done_fence); | |
| 416 | 420 | if (!ejob->done_fence) { | |
| 417 | 421 | ret = -ENOMEM; | |
| 418 | - | goto out_cleanup_job; | |
| 422 | + | goto out_put_job; | |
| 419 | 423 | } | |
| 420 | 424 | ||
| 421 | 425 | ret = drm_sched_job_init(&ejob->base, | |
| @@ -443,13 +447,13 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file | |||
| 443 | 447 | if (!cmd_info->region_size[i]) | |
| 444 | 448 | continue; | |
| 445 | 449 | if (i == ETHOSU_SRAM_REGION) { | |
| 446 | - | if (cmd_info->region_size[i] <= edev->npu_info.sram_size) | |
| 450 | + | if (cmd_info->region_size[i] <= ejob->sram_size) | |
| 447 | 451 | continue; | |
| 448 | 452 | ||
| 449 | 453 | dev_err(dev->dev, | |
| 450 | - | "cmd stream region %d size greater than SRAM size (%llu > %u)\n", | |
| 454 | + | "cmd stream region %d size greater than job SRAM size (%llu > %u)\n", | |
| 451 | 455 | i, cmd_info->region_size[i], | |
| 452 | - | edev->npu_info.sram_size); | |
| 456 | + | ejob->sram_size); | |
| 453 | 457 | ret = -EINVAL; | |
| 454 | 458 | goto out_cleanup_job; | |
| 455 | 459 | } | |
modified drivers/accel/ivpu/ivpu_drv.c
| @@ -515,6 +515,7 @@ void ivpu_prepare_for_reset(struct ivpu_device *vdev) | |||
| 515 | 515 | { | |
| 516 | 516 | ivpu_hw_irq_disable(vdev); | |
| 517 | 517 | disable_irq(vdev->irq); | |
| 518 | + | atomic_set(&vdev->job_timeout_detected, 0); | |
| 518 | 519 | flush_work(&vdev->irq_dct_work); | |
| 519 | 520 | flush_work(&vdev->context_abort_work); | |
| 520 | 521 | flush_work(&vdev->job_destroy_work); | |
| @@ -710,7 +711,7 @@ static int ivpu_dev_init(struct ivpu_device *vdev) | |||
| 710 | 711 | vdev->context_xa_limit.max = IVPU_USER_CONTEXT_MAX_SSID; | |
| 711 | 712 | atomic64_set(&vdev->unique_id_counter, 0); | |
| 712 | 713 | atomic_set(&vdev->job_timeout_counter, 0); | |
| 713 | - | atomic_set(&vdev->faults_detected, 0); | |
| 714 | + | atomic_set(&vdev->job_timeout_detected, 0); | |
| 714 | 715 | xa_init_flags(&vdev->context_xa, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_IRQ); | |
| 715 | 716 | xa_init_flags(&vdev->submitted_jobs_xa, XA_FLAGS_ALLOC1); | |
| 716 | 717 | xa_init_flags(&vdev->db_xa, XA_FLAGS_ALLOC1); | |
modified drivers/accel/ivpu/ivpu_drv.h
| @@ -171,7 +171,7 @@ struct ivpu_device { | |||
| 171 | 171 | struct xarray submitted_jobs_xa; | |
| 172 | 172 | struct ivpu_ipc_consumer job_done_consumer; | |
| 173 | 173 | atomic_t job_timeout_counter; | |
| 174 | - | atomic_t faults_detected; | |
| 174 | + | atomic_t job_timeout_detected; | |
| 175 | 175 | ||
| 176 | 176 | atomic64_t unique_id_counter; | |
| 177 | 177 | ||
modified drivers/accel/ivpu/ivpu_fw_log.c
| @@ -26,10 +26,17 @@ MODULE_PARM_DESC(fw_log_level, | |||
| 26 | 26 | " error=" __stringify(IVPU_FW_LOG_ERROR) | |
| 27 | 27 | " fatal=" __stringify(IVPU_FW_LOG_FATAL)); | |
| 28 | 28 | ||
| 29 | + | struct ivpu_fw_log_desc { | |
| 30 | + | struct vpu_tracing_buffer_header *log; | |
| 31 | + | u32 header_size; | |
| 32 | + | u32 size; | |
| 33 | + | }; | |
| 34 | + | ||
| 29 | 35 | static int fw_log_from_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, u32 *offset, | |
| 30 | - | struct vpu_tracing_buffer_header **out_log) | |
| 36 | + | struct ivpu_fw_log_desc *desc) | |
| 31 | 37 | { | |
| 32 | 38 | struct vpu_tracing_buffer_header *log; | |
| 39 | + | u32 header_size, size; | |
| 33 | 40 | ||
| 34 | 41 | if ((*offset + sizeof(*log)) > ivpu_bo_size(bo)) | |
| 35 | 42 | return -EINVAL; | |
| @@ -39,26 +46,32 @@ static int fw_log_from_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, u32 *off | |||
| 39 | 46 | if (log->vpu_canary_start != VPU_TRACING_BUFFER_CANARY) | |
| 40 | 47 | return -EINVAL; | |
| 41 | 48 | ||
| 42 | - | if (log->header_size < sizeof(*log) || log->header_size > 1024) { | |
| 43 | - | ivpu_dbg(vdev, FW_BOOT, "Invalid header size 0x%x\n", log->header_size); | |
| 49 | + | header_size = READ_ONCE(log->header_size); | |
| 50 | + | size = READ_ONCE(log->size); | |
| 51 | + | ||
| 52 | + | if (header_size < sizeof(*log) || header_size > 1024) { | |
| 53 | + | ivpu_dbg(vdev, FW_BOOT, "Invalid header size 0x%x\n", header_size); | |
| 44 | 54 | return -EINVAL; | |
| 45 | 55 | } | |
| 46 | - | if (log->size < log->header_size) { | |
| 47 | - | ivpu_dbg(vdev, FW_BOOT, "Invalid log size 0x%x\n", log->size); | |
| 56 | + | if ((char *)log + size > (char *)ivpu_bo_vaddr(bo) + ivpu_bo_size(bo)) { | |
| 57 | + | ivpu_dbg(vdev, FW_BOOT, "Invalid log size 0x%x\n", size); | |
| 48 | 58 | return -EINVAL; | |
| 49 | 59 | } | |
| 50 | - | if ((char *)log + log->size > (char *)ivpu_bo_vaddr(bo) + ivpu_bo_size(bo)) { | |
| 51 | - | ivpu_dbg(vdev, FW_BOOT, "Invalid log size 0x%x\n", log->size); | |
| 60 | + | if (size < header_size) { | |
| 61 | + | ivpu_dbg(vdev, FW_BOOT, "Invalid log size 0x%x < header size 0x%x\n", | |
| 62 | + | size, header_size); | |
| 52 | 63 | return -EINVAL; | |
| 53 | 64 | } | |
| 54 | 65 | ||
| 55 | - | *out_log = log; | |
| 56 | - | *offset += log->size; | |
| 66 | + | desc->log = log; | |
| 67 | + | desc->header_size = header_size; | |
| 68 | + | desc->size = size; | |
| 69 | + | *offset += size; | |
| 57 | 70 | ||
| 58 | 71 | ivpu_dbg(vdev, FW_BOOT, | |
| 59 | - | "FW log name \"%s\", write offset 0x%x size 0x%x, wrap count %d, hdr version %d size %d format %d, alignment %d", | |
| 60 | - | log->name, log->write_index, log->size, log->wrap_count, log->header_version, | |
| 61 | - | log->header_size, log->format, log->alignment); | |
| 72 | + | "FW log name \"%.*s\", write offset 0x%x size 0x%x, wrap count %d, hdr version %d size %d format %d, alignment %d", | |
| 73 | + | (int)ARRAY_SIZE(log->name), log->name, log->write_index, size, log->wrap_count, | |
| 74 | + | log->header_version, header_size, log->format, log->alignment); | |
| 62 | 75 | ||
| 63 | 76 | return 0; | |
| 64 | 77 | } | |
| @@ -94,11 +107,12 @@ static void fw_log_print_lines(char *buffer, u32 size, struct drm_printer *p) | |||
| 94 | 107 | drm_printf(p, "%s", line); | |
| 95 | 108 | } | |
| 96 | 109 | ||
| 97 | - | static void fw_log_print_buffer(struct vpu_tracing_buffer_header *log, const char *prefix, | |
| 110 | + | static void fw_log_print_buffer(struct ivpu_fw_log_desc *desc, const char *prefix, | |
| 98 | 111 | bool only_new_msgs, struct drm_printer *p) | |
| 99 | 112 | { | |
| 100 | - | char *log_data = (void *)log + log->header_size; | |
| 101 | - | u32 data_size = log->size - log->header_size; | |
| 113 | + | struct vpu_tracing_buffer_header *log = desc->log; | |
| 114 | + | char *log_data = (void *)log + desc->header_size; | |
| 115 | + | u32 data_size = desc->size - desc->header_size; | |
| 102 | 116 | u32 log_start = only_new_msgs ? READ_ONCE(log->read_index) : 0; | |
| 103 | 117 | u32 log_end = READ_ONCE(log->write_index); | |
| 104 | 118 | ||
| @@ -109,7 +123,8 @@ static void fw_log_print_buffer(struct vpu_tracing_buffer_header *log, const cha | |||
| 109 | 123 | ||
| 110 | 124 | if (log->wrap_count == log->read_wrap_count) { | |
| 111 | 125 | if (log_end <= log_start) { | |
| 112 | - | drm_printf(p, "==== %s \"%s\" log empty ====\n", prefix, log->name); | |
| 126 | + | drm_printf(p, "==== %s \"%.*s\" log empty ====\n", prefix, | |
| 127 | + | (int)ARRAY_SIZE(log->name), log->name); | |
| 113 | 128 | return; | |
| 114 | 129 | } | |
| 115 | 130 | } else if (log->wrap_count == log->read_wrap_count + 1) { | |
| @@ -119,7 +134,8 @@ static void fw_log_print_buffer(struct vpu_tracing_buffer_header *log, const cha | |||
| 119 | 134 | log_start = log_end; | |
| 120 | 135 | } | |
| 121 | 136 | ||
| 122 | - | drm_printf(p, "==== %s \"%s\" log start ====\n", prefix, log->name); | |
| 137 | + | drm_printf(p, "==== %s \"%.*s\" log start ====\n", prefix, (int)ARRAY_SIZE(log->name), | |
| 138 | + | log->name); | |
| 123 | 139 | if (log_end > log_start) { | |
| 124 | 140 | fw_log_print_lines(log_data + log_start, log_end - log_start, p); | |
| 125 | 141 | } else { | |
| @@ -127,18 +143,19 @@ static void fw_log_print_buffer(struct vpu_tracing_buffer_header *log, const cha | |||
| 127 | 143 | fw_log_print_lines(log_data, log_end, p); | |
| 128 | 144 | } | |
| 129 | 145 | drm_printf(p, "\n\x1b[0m"); /* add new line and clear formatting */ | |
| 130 | - | drm_printf(p, "==== %s \"%s\" log end ====\n", prefix, log->name); | |
| 146 | + | drm_printf(p, "==== %s \"%.*s\" log end ====\n", prefix, (int)ARRAY_SIZE(log->name), | |
| 147 | + | log->name); | |
| 131 | 148 | } | |
| 132 | 149 | ||
| 133 | 150 | static void | |
| 134 | 151 | fw_log_print_all_in_bo(struct ivpu_device *vdev, const char *name, | |
| 135 | 152 | struct ivpu_bo *bo, bool only_new_msgs, struct drm_printer *p) | |
| 136 | 153 | { | |
| 137 | - | struct vpu_tracing_buffer_header *log; | |
| 154 | + | struct ivpu_fw_log_desc desc; | |
| 138 | 155 | u32 next = 0; | |
| 139 | 156 | ||
| 140 | - | while (fw_log_from_bo(vdev, bo, &next, &log) == 0) | |
| 141 | - | fw_log_print_buffer(log, name, only_new_msgs, p); | |
| 157 | + | while (fw_log_from_bo(vdev, bo, &next, &desc) == 0) | |
| 158 | + | fw_log_print_buffer(&desc, name, only_new_msgs, p); | |
| 142 | 159 | } | |
| 143 | 160 | ||
| 144 | 161 | void ivpu_fw_log_print(struct ivpu_device *vdev, bool only_new_msgs, struct drm_printer *p) | |
| @@ -149,36 +166,36 @@ void ivpu_fw_log_print(struct ivpu_device *vdev, bool only_new_msgs, struct drm_ | |||
| 149 | 166 | ||
| 150 | 167 | void ivpu_fw_log_mark_read(struct ivpu_device *vdev) | |
| 151 | 168 | { | |
| 152 | - | struct vpu_tracing_buffer_header *log; | |
| 169 | + | struct ivpu_fw_log_desc desc; | |
| 153 | 170 | u32 next; | |
| 154 | 171 | ||
| 155 | 172 | next = 0; | |
| 156 | - | while (fw_log_from_bo(vdev, vdev->fw->mem_log_crit, &next, &log) == 0) { | |
| 157 | - | log->read_index = READ_ONCE(log->write_index); | |
| 158 | - | log->read_wrap_count = READ_ONCE(log->wrap_count); | |
| 173 | + | while (fw_log_from_bo(vdev, vdev->fw->mem_log_crit, &next, &desc) == 0) { | |
| 174 | + | desc.log->read_index = READ_ONCE(desc.log->write_index); | |
| 175 | + | desc.log->read_wrap_count = READ_ONCE(desc.log->wrap_count); | |
| 159 | 176 | } | |
| 160 | 177 | ||
| 161 | 178 | next = 0; | |
| 162 | - | while (fw_log_from_bo(vdev, vdev->fw->mem_log_verb, &next, &log) == 0) { | |
| 163 | - | log->read_index = READ_ONCE(log->write_index); | |
| 164 | - | log->read_wrap_count = READ_ONCE(log->wrap_count); | |
| 179 | + | while (fw_log_from_bo(vdev, vdev->fw->mem_log_verb, &next, &desc) == 0) { | |
| 180 | + | desc.log->read_index = READ_ONCE(desc.log->write_index); | |
| 181 | + | desc.log->read_wrap_count = READ_ONCE(desc.log->wrap_count); | |
| 165 | 182 | } | |
| 166 | 183 | } | |
| 167 | 184 | ||
| 168 | 185 | void ivpu_fw_log_reset(struct ivpu_device *vdev) | |
| 169 | 186 | { | |
| 170 | - | struct vpu_tracing_buffer_header *log; | |
| 187 | + | struct ivpu_fw_log_desc desc; | |
| 171 | 188 | u32 next; | |
| 172 | 189 | ||
| 173 | 190 | next = 0; | |
| 174 | - | while (fw_log_from_bo(vdev, vdev->fw->mem_log_crit, &next, &log) == 0) { | |
| 175 | - | log->read_index = 0; | |
| 176 | - | log->read_wrap_count = 0; | |
| 191 | + | while (fw_log_from_bo(vdev, vdev->fw->mem_log_crit, &next, &desc) == 0) { | |
| 192 | + | desc.log->read_index = 0; | |
| 193 | + | desc.log->read_wrap_count = 0; | |
| 177 | 194 | } | |
| 178 | 195 | ||
| 179 | 196 | next = 0; | |
| 180 | - | while (fw_log_from_bo(vdev, vdev->fw->mem_log_verb, &next, &log) == 0) { | |
| 181 | - | log->read_index = 0; | |
| 182 | - | log->read_wrap_count = 0; | |
| 197 | + | while (fw_log_from_bo(vdev, vdev->fw->mem_log_verb, &next, &desc) == 0) { | |
| 198 | + | desc.log->read_index = 0; | |
| 199 | + | desc.log->read_wrap_count = 0; | |
| 183 | 200 | } | |
| 184 | 201 | } | |
modified drivers/accel/ivpu/ivpu_gem.h
| @@ -87,15 +87,23 @@ static inline bool ivpu_bo_is_resident(struct ivpu_bo *bo) | |||
| 87 | 87 | return !!bo->base.pages; | |
| 88 | 88 | } | |
| 89 | 89 | ||
| 90 | - | static inline void *ivpu_to_cpu_addr(struct ivpu_bo *bo, u32 vpu_addr) | |
| 90 | + | static inline void *ivpu_to_cpu_addr(struct ivpu_bo *bo, u64 vpu_addr, u64 size) | |
| 91 | 91 | { | |
| 92 | + | u64 bo_size = ivpu_bo_size(bo); | |
| 93 | + | u64 offset; | |
| 94 | + | ||
| 92 | 95 | if (vpu_addr < bo->vpu_addr) | |
| 93 | 96 | return NULL; | |
| 94 | 97 | ||
| 95 | - | if (vpu_addr >= (bo->vpu_addr + ivpu_bo_size(bo))) | |
| 98 | + | if (size > bo_size) | |
| 99 | + | return NULL; | |
| 100 | + | ||
| 101 | + | offset = vpu_addr - bo->vpu_addr; | |
| 102 | + | ||
| 103 | + | if (offset > bo_size - size) | |
| 96 | 104 | return NULL; | |
| 97 | 105 | ||
| 98 | - | return ivpu_bo_vaddr(bo) + (vpu_addr - bo->vpu_addr); | |
| 106 | + | return ivpu_bo_vaddr(bo) + offset; | |
| 99 | 107 | } | |
| 100 | 108 | ||
| 101 | 109 | static inline u32 cpu_to_vpu_addr(struct ivpu_bo *bo, void *cpu_addr) | |
modified drivers/accel/ivpu/ivpu_ipc.c
| @@ -79,7 +79,7 @@ ivpu_ipc_tx_prepare(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons, | |||
| 79 | 79 | return -ENOMEM; | |
| 80 | 80 | } | |
| 81 | 81 | ||
| 82 | - | tx_buf = ivpu_to_cpu_addr(ipc->mem_tx, tx_buf_vpu_addr); | |
| 82 | + | tx_buf = ivpu_to_cpu_addr(ipc->mem_tx, tx_buf_vpu_addr, sizeof(*tx_buf)); | |
| 83 | 83 | if (drm_WARN_ON(&vdev->drm, !tx_buf)) { | |
| 84 | 84 | gen_pool_free(ipc->mm_tx, tx_buf_vpu_addr, sizeof(*tx_buf)); | |
| 85 | 85 | return -EIO; | |
| @@ -420,7 +420,7 @@ void ivpu_ipc_irq_handler(struct ivpu_device *vdev) | |||
| 420 | 420 | return; | |
| 421 | 421 | } | |
| 422 | 422 | ||
| 423 | - | ipc_hdr = ivpu_to_cpu_addr(ipc->mem_rx, vpu_addr); | |
| 423 | + | ipc_hdr = ivpu_to_cpu_addr(ipc->mem_rx, vpu_addr, sizeof(*ipc_hdr)); | |
| 424 | 424 | if (!ipc_hdr) { | |
| 425 | 425 | ivpu_warn_ratelimited(vdev, "IPC msg 0x%x out of range\n", vpu_addr); | |
| 426 | 426 | continue; | |
| @@ -429,7 +429,8 @@ void ivpu_ipc_irq_handler(struct ivpu_device *vdev) | |||
| 429 | 429 | ||
| 430 | 430 | jsm_msg = NULL; | |
| 431 | 431 | if (ipc_hdr->channel != IVPU_IPC_CHAN_BOOT_MSG) { | |
| 432 | - | jsm_msg = ivpu_to_cpu_addr(ipc->mem_rx, ipc_hdr->data_addr); | |
| 432 | + | jsm_msg = ivpu_to_cpu_addr(ipc->mem_rx, ipc_hdr->data_addr, | |
| 433 | + | sizeof(*jsm_msg)); | |
| 433 | 434 | if (!jsm_msg) { | |
| 434 | 435 | ivpu_warn_ratelimited(vdev, "JSM msg 0x%x out of range\n", | |
| 435 | 436 | ipc_hdr->data_addr); | |
modified drivers/accel/ivpu/ivpu_job.c
| @@ -621,7 +621,6 @@ bool ivpu_job_handle_engine_error(struct ivpu_device *vdev, u32 job_id, u32 job_ | |||
| 621 | 621 | * status and ensure both are handled in the same way | |
| 622 | 622 | */ | |
| 623 | 623 | job->file_priv->has_mmu_faults = true; | |
| 624 | - | atomic_set(&vdev->faults_detected, 1); | |
| 625 | 624 | queue_work(system_percpu_wq, &vdev->context_abort_work); | |
| 626 | 625 | return true; | |
| 627 | 626 | } | |
| @@ -1175,10 +1174,10 @@ static int reset_engine_and_mark_faulty_contexts(struct ivpu_device *vdev) | |||
| 1175 | 1174 | return ret; | |
| 1176 | 1175 | ||
| 1177 | 1176 | /* | |
| 1178 | - | * If faults are detected, ignore guilty contexts from engine reset as NPU may not be stuck | |
| 1179 | - | * and could return currently running good context and faulty contexts are already marked | |
| 1177 | + | * If job timeout is detected, read guilty context from engine reset, for other reasons | |
| 1178 | + | * faulty context is already known | |
| 1180 | 1179 | */ | |
| 1181 | - | if (atomic_cmpxchg(&vdev->faults_detected, 1, 0) == 1) | |
| 1180 | + | if (atomic_cmpxchg(&vdev->job_timeout_detected, 1, 0) == 0) | |
| 1182 | 1181 | return 0; | |
| 1183 | 1182 | ||
| 1184 | 1183 | num_impacted_contexts = resp.payload.engine_reset_done.num_impacted_contexts; | |
modified drivers/accel/ivpu/ivpu_mmu.c
| @@ -964,7 +964,6 @@ void ivpu_mmu_irq_evtq_handler(struct ivpu_device *vdev) | |||
| 964 | 964 | file_priv = xa_load(&vdev->context_xa, ssid); | |
| 965 | 965 | if (file_priv) { | |
| 966 | 966 | if (!READ_ONCE(file_priv->has_mmu_faults)) { | |
| 967 | - | atomic_set(&vdev->faults_detected, 1); | |
| 968 | 967 | ivpu_mmu_dump_event(vdev, event); | |
| 969 | 968 | WRITE_ONCE(file_priv->has_mmu_faults, true); | |
| 970 | 969 | } | |
modified drivers/accel/ivpu/ivpu_pm.c
| @@ -229,6 +229,7 @@ abort: | |||
| 229 | 229 | ||
| 230 | 230 | ivpu_jsm_state_dump(vdev); | |
| 231 | 231 | ivpu_dev_coredump(vdev); | |
| 232 | + | atomic_set(&vdev->job_timeout_detected, 1); | |
| 232 | 233 | queue_work(system_percpu_wq, &vdev->context_abort_work); | |
| 233 | 234 | } | |
| 234 | 235 | ||
modified drivers/accel/qaic/qaic_control.c
| @@ -963,11 +963,13 @@ static int decode_status(struct qaic_device *qdev, void *trans, struct manage_ms | |||
| 963 | 963 | ||
| 964 | 964 | static int decode_message(struct qaic_device *qdev, struct manage_msg *user_msg, | |
| 965 | 965 | struct wire_msg *msg, struct ioctl_resources *resources, | |
| 966 | - | struct qaic_user *usr) | |
| 966 | + | struct qaic_user *usr, bool orphaned_deactivate) | |
| 967 | 967 | { | |
| 968 | + | u32 msg_hdr_count = le32_to_cpu(msg->hdr.count); | |
| 968 | 969 | u32 msg_hdr_len = le32_to_cpu(msg->hdr.len); | |
| 969 | 970 | struct wire_trans_hdr *trans_hdr; | |
| 970 | 971 | u32 msg_len = 0; | |
| 972 | + | int trans_type; | |
| 971 | 973 | int ret; | |
| 972 | 974 | int i; | |
| 973 | 975 | ||
| @@ -975,10 +977,12 @@ static int decode_message(struct qaic_device *qdev, struct manage_msg *user_msg, | |||
| 975 | 977 | msg_hdr_len > QAIC_MANAGE_MAX_MSG_LENGTH) | |
| 976 | 978 | return -EINVAL; | |
| 977 | 979 | ||
| 978 | - | user_msg->len = 0; | |
| 979 | - | user_msg->count = le32_to_cpu(msg->hdr.count); | |
| 980 | + | if (user_msg) { | |
| 981 | + | user_msg->len = 0; | |
| 982 | + | user_msg->count = msg_hdr_count; | |
| 983 | + | } | |
| 980 | 984 | ||
| 981 | - | for (i = 0; i < user_msg->count; ++i) { | |
| 985 | + | for (i = 0; i < msg_hdr_count; ++i) { | |
| 982 | 986 | u32 hdr_len; | |
| 983 | 987 | ||
| 984 | 988 | if (msg_len > msg_hdr_len - sizeof(*trans_hdr)) | |
| @@ -990,7 +994,20 @@ static int decode_message(struct qaic_device *qdev, struct manage_msg *user_msg, | |||
| 990 | 994 | size_add(msg_len, hdr_len) > msg_hdr_len) | |
| 991 | 995 | return -EINVAL; | |
| 992 | 996 | ||
| 993 | - | switch (le32_to_cpu(trans_hdr->type)) { | |
| 997 | + | trans_type = le32_to_cpu(trans_hdr->type); | |
| 998 | + | /* | |
| 999 | + | * orphaned_deactivate is the case where a deactivate response | |
| 1000 | + | * is received from the device after the user owning the DBC, | |
| 1001 | + | * and the message requesting deactivation, has gone away. | |
| 1002 | + | * In this case, only process QAIC_TRANS_DEACTIVATE_FROM_DEV | |
| 1003 | + | * transaction and skip the others. | |
| 1004 | + | */ | |
| 1005 | + | if (orphaned_deactivate && trans_type != QAIC_TRANS_DEACTIVATE_FROM_DEV) { | |
| 1006 | + | msg_len += hdr_len; | |
| 1007 | + | continue; | |
| 1008 | + | } | |
| 1009 | + | ||
| 1010 | + | switch (trans_type) { | |
| 994 | 1011 | case QAIC_TRANS_PASSTHROUGH_FROM_DEV: | |
| 995 | 1012 | ret = decode_passthrough(qdev, trans_hdr, user_msg, &msg_len); | |
| 996 | 1013 | break; | |
| @@ -1281,7 +1298,7 @@ dma_xfer_continue: | |||
| 1281 | 1298 | goto dma_cont_failed; | |
| 1282 | 1299 | } | |
| 1283 | 1300 | ||
| 1284 | - | ret = decode_message(qdev, user_msg, rsp, &resources, usr); | |
| 1301 | + | ret = decode_message(qdev, user_msg, rsp, &resources, usr, false); | |
| 1285 | 1302 | ||
| 1286 | 1303 | dma_cont_failed: | |
| 1287 | 1304 | free_dbc_buf(qdev, &resources); | |
| @@ -1446,22 +1463,7 @@ static void resp_worker(struct work_struct *work) | |||
| 1446 | 1463 | * response to the QAIC_TRANS_TERMINATE_TO_DEV transaction, | |
| 1447 | 1464 | * otherwise, the user can issue an soc_reset to the device. | |
| 1448 | 1465 | */ | |
| 1449 | - | u32 msg_count = le32_to_cpu(msg->hdr.count); | |
| 1450 | - | u32 msg_len = le32_to_cpu(msg->hdr.len); | |
| 1451 | - | u32 len = 0; | |
| 1452 | - | int j; | |
| 1453 | - | ||
| 1454 | - | for (j = 0; j < msg_count && len < msg_len; ++j) { | |
| 1455 | - | struct wire_trans_hdr *trans_hdr; | |
| 1456 | - | ||
| 1457 | - | trans_hdr = (struct wire_trans_hdr *)(msg->data + len); | |
| 1458 | - | if (le32_to_cpu(trans_hdr->type) == QAIC_TRANS_DEACTIVATE_FROM_DEV) { | |
| 1459 | - | if (decode_deactivate(qdev, trans_hdr, &len, NULL)) | |
| 1460 | - | len += le32_to_cpu(trans_hdr->len); | |
| 1461 | - | } else { | |
| 1462 | - | len += le32_to_cpu(trans_hdr->len); | |
| 1463 | - | } | |
| 1464 | - | } | |
| 1466 | + | decode_message(qdev, NULL, msg, NULL, NULL, true); | |
| 1465 | 1467 | /* request must have timed out, drop packet */ | |
| 1466 | 1468 | kfree(msg); | |
| 1467 | 1469 | } | |
modified drivers/accel/rocket/rocket_job.c
| @@ -196,7 +196,7 @@ static int rocket_job_push(struct rocket_job *job) | |||
| 196 | 196 | if (check_add_overflow(job->in_bo_count, job->out_bo_count, &bo_count)) | |
| 197 | 197 | return -EINVAL; | |
| 198 | 198 | ||
| 199 | - | bos = kvmalloc_array(bo_count, sizeof(*bos), GFP_KERNEL); | |
| 199 | + | bos = kvmalloc_objs(*bos, bo_count); | |
| 200 | 200 | if (!bos) | |
| 201 | 201 | return -ENOMEM; | |
| 202 | 202 | memcpy(bos, job->in_bos, job->in_bo_count * sizeof(void *)); | |
modified drivers/acpi/irq.c
| @@ -486,7 +486,8 @@ static u32 acpi_add_prt_dep(acpi_handle handle) | |||
| 486 | 486 | if (ACPI_FAILURE(status)) | |
| 487 | 487 | continue; | |
| 488 | 488 | dep_devices.count = 1; | |
| 489 | - | dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL); | |
| 489 | + | dep_devices.handles = kzalloc_objs(*dep_devices.handles, | |
| 490 | + | 1); | |
| 490 | 491 | if (!dep_devices.handles) { | |
| 491 | 492 | acpi_handle_err(handle, "failed to allocate memory\n"); | |
| 492 | 493 | continue; | |
| @@ -499,7 +500,8 @@ static u32 acpi_add_prt_dep(acpi_handle handle) | |||
| 499 | 500 | if (!gsi_handle) | |
| 500 | 501 | continue; | |
| 501 | 502 | dep_devices.count = 1; | |
| 502 | - | dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL); | |
| 503 | + | dep_devices.handles = kzalloc_objs(*dep_devices.handles, | |
| 504 | + | 1); | |
| 503 | 505 | if (!dep_devices.handles) { | |
| 504 | 506 | acpi_handle_err(handle, "failed to allocate memory\n"); | |
| 505 | 507 | continue; | |
| @@ -526,7 +528,7 @@ static u32 acpi_add_irq_dep(acpi_handle handle) | |||
| 526 | 528 | continue; | |
| 527 | 529 | ||
| 528 | 530 | dep_devices.count = 1; | |
| 529 | - | dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL); | |
| 531 | + | dep_devices.handles = kzalloc_objs(*dep_devices.handles, 1); | |
| 530 | 532 | if (!dep_devices.handles) { | |
| 531 | 533 | acpi_handle_err(handle, "failed to allocate memory\n"); | |
| 532 | 534 | continue; | |
modified drivers/acpi/scan.c
| @@ -28,9 +28,7 @@ | |||
| 28 | 28 | #include "internal.h" | |
| 29 | 29 | #include "sleep.h" | |
| 30 | 30 | ||
| 31 | - | #define ACPI_BUS_CLASS "system_bus" | |
| 32 | 31 | #define ACPI_BUS_HID "LNXSYBUS" | |
| 33 | - | #define ACPI_BUS_DEVICE_NAME "System Bus" | |
| 34 | 32 | ||
| 35 | 33 | #define INVALID_ACPI_HANDLE ((acpi_handle)ZERO_PAGE(0)) | |
| 36 | 34 | ||
| @@ -1450,8 +1448,6 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, | |||
| 1450 | 1448 | acpi_object_is_system_bus(handle)) { | |
| 1451 | 1449 | /* \_SB, \_TZ, LNXSYBUS */ | |
| 1452 | 1450 | acpi_add_id(pnp, ACPI_BUS_HID); | |
| 1453 | - | strscpy(pnp->device_name, ACPI_BUS_DEVICE_NAME); | |
| 1454 | - | strscpy(pnp->device_class, ACPI_BUS_CLASS); | |
| 1455 | 1451 | } | |
| 1456 | 1452 | ||
| 1457 | 1453 | break; | |
modified drivers/ata/ahci.c
| @@ -2614,6 +2614,51 @@ static irqreturn_t ahci_thunderx_irq_handler(int irq, void *dev_instance) | |||
| 2614 | 2614 | } | |
| 2615 | 2615 | #endif | |
| 2616 | 2616 | ||
| 2617 | + | /* | |
| 2618 | + | * The Marvell 88SE6111/6121/6145 ("Thor") family stops reporting interrupts | |
| 2619 | + | * for a port when HOST_IRQ_STAT is cleared while PxIS still holds bits: PxIS | |
| 2620 | + | * keeps its content, HOST_IRQ_STAT reads back as 0, the port is never looked | |
| 2621 | + | * at again and the command in flight only ends in a timeout. On a 88SE6121 | |
| 2622 | + | * this makes every SATA-2 or SATA-3 disk fail to IDENTIFY, while SATA-1 disks | |
| 2623 | + | * happen to win the race often enough to work. | |
| 2624 | + | * | |
| 2625 | + | * Clearing the host status before servicing the ports avoids it. Marvell's | |
| 2626 | + | * own driver for these chips does the same and says so ("clear global before | |
| 2627 | + | * channel"), and ahci_xgene handles its broken edge latch the same way. The | |
| 2628 | + | * price is at most one spurious interrupt per valid one, which is why this is | |
| 2629 | + | * not the generic behaviour - see AHCI 1.1 section 10.6.2. | |
| 2630 | + | * | |
| 2631 | + | * Link: https://bugzilla.kernel.org/show_bug.cgi?id=216094 | |
| 2632 | + | */ | |
| 2633 | + | static irqreturn_t ahci_mv_irq_handler(int irq, void *dev_instance) | |
| 2634 | + | { | |
| 2635 | + | struct ata_host *host = dev_instance; | |
| 2636 | + | struct ahci_host_priv *hpriv = host->private_data; | |
| 2637 | + | void __iomem *mmio = hpriv->mmio; | |
| 2638 | + | unsigned int rc; | |
| 2639 | + | u32 irq_stat, irq_masked; | |
| 2640 | + | ||
| 2641 | + | irq_stat = readl(mmio + HOST_IRQ_STAT); | |
| 2642 | + | if (!irq_stat) | |
| 2643 | + | return IRQ_NONE; | |
| 2644 | + | ||
| 2645 | + | irq_masked = irq_stat & hpriv->port_map; | |
| 2646 | + | ||
| 2647 | + | spin_lock(&host->lock); | |
| 2648 | + | ||
| 2649 | + | /* | |
| 2650 | + | * Use the unmasked value to clear the interrupt, as a spurious pending | |
| 2651 | + | * event on a dummy port might cause a screaming IRQ. | |
| 2652 | + | */ | |
| 2653 | + | writel(irq_stat, mmio + HOST_IRQ_STAT); | |
| 2654 | + | ||
| 2655 | + | rc = ahci_handle_port_intr(host, irq_masked); | |
| 2656 | + | ||
| 2657 | + | spin_unlock(&host->lock); | |
| 2658 | + | ||
| 2659 | + | return IRQ_RETVAL(rc); | |
| 2660 | + | } | |
| 2661 | + | ||
| 2617 | 2662 | static void ahci_remap_check(struct pci_dev *pdev, int bar, | |
| 2618 | 2663 | struct ahci_host_priv *hpriv) | |
| 2619 | 2664 | { | |
| @@ -2917,6 +2962,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 2917 | 2962 | return -ENOMEM; | |
| 2918 | 2963 | hpriv->flags |= (unsigned long)pi.private_data; | |
| 2919 | 2964 | ||
| 2965 | + | /* the Marvell "Thor" family needs HOST_IRQ_STAT cleared first */ | |
| 2966 | + | if (board_id == board_ahci_mv) | |
| 2967 | + | hpriv->irq_handler = ahci_mv_irq_handler; | |
| 2968 | + | ||
| 2920 | 2969 | /* MCP65 revision A1 and A2 can't do MSI */ | |
| 2921 | 2970 | if (board_id == board_ahci_mcp65 && | |
| 2922 | 2971 | (pdev->revision == 0xa1 || pdev->revision == 0xa2)) | |
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 | { | |
| @@ -4823,28 +4828,6 @@ ata_scsi_get_phys_element_status_xlat(struct ata_queued_cmd *qc) | |||
| 4823 | 4828 | return 0; | |
| 4824 | 4829 | } | |
| 4825 | 4830 | ||
| 4826 | - | static void ata_scsi_depop_ua_cap_changed_complete(struct ata_queued_cmd *qc) | |
| 4827 | - | { | |
| 4828 | - | struct scsi_cmnd *scmd = qc->scsicmd; | |
| 4829 | - | u8 *cdb = scmd->cmnd; | |
| 4830 | - | bool is_ata_passthru = cdb[0] == ATA_16 || cdb[0] == ATA_12; | |
| 4831 | - | bool is_success = qc->err_mask == 0; | |
| 4832 | - | ||
| 4833 | - | /* | |
| 4834 | - | * For successful non-passthrough commands, raise a UNIT ATTENTION with | |
| 4835 | - | * the additional sense code set to CAPACITY DATA HAS CHANGED to be | |
| 4836 | - | * raised. Note that this should be done only if the capacity has | |
| 4837 | - | * actually changed, which may not be the case if the element that was | |
| 4838 | - | * specified for depopulation was already depopulated, or we did not | |
| 4839 | - | * restore any removed element. But a capacity change unit attention is | |
| 4840 | - | * harmless, so always raise the unit attention. | |
| 4841 | - | */ | |
| 4842 | - | if (is_success && !is_ata_passthru) | |
| 4843 | - | ata_scsi_set_sense(qc->dev, scmd, UNIT_ATTENTION, | |
| 4844 | - | UA_CHANGED_ASC, CAPACITY_CHANGED_ASCQ); | |
| 4845 | - | ata_scsi_qc_complete(qc); | |
| 4846 | - | } | |
| 4847 | - | ||
| 4848 | 4831 | static unsigned int | |
| 4849 | 4832 | ata_scsi_remove_element_and_truncate_xlat(struct ata_queued_cmd *qc) | |
| 4850 | 4833 | { | |
| @@ -4884,7 +4867,6 @@ ata_scsi_remove_element_and_truncate_xlat(struct ata_queued_cmd *qc) | |||
| 4884 | 4867 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48; | |
| 4885 | 4868 | ||
| 4886 | 4869 | qc->flags |= ATA_QCFLAG_RESULT_TF; | |
| 4887 | - | qc->complete_fn = ata_scsi_depop_ua_cap_changed_complete; | |
| 4888 | 4870 | ||
| 4889 | 4871 | return 0; | |
| 4890 | 4872 | } | |
| @@ -4937,7 +4919,6 @@ ata_scsi_restore_elements_and_rebuild_xlat(struct ata_queued_cmd *qc) | |||
| 4937 | 4919 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48; | |
| 4938 | 4920 | ||
| 4939 | 4921 | qc->flags |= ATA_QCFLAG_RESULT_TF; | |
| 4940 | - | qc->complete_fn = ata_scsi_depop_ua_cap_changed_complete; | |
| 4941 | 4922 | ||
| 4942 | 4923 | return 0; | |
| 4943 | 4924 | } | |
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/base/property.c
| @@ -526,7 +526,7 @@ int fwnode_property_match_string(const struct fwnode_handle *fwnode, | |||
| 526 | 526 | if (nval == 0) | |
| 527 | 527 | return -ENODATA; | |
| 528 | 528 | ||
| 529 | - | const char **values __free(kfree) = kcalloc(nval, sizeof(*values), GFP_KERNEL); | |
| 529 | + | const char **values __free(kfree) = kzalloc_objs(*values, nval); | |
| 530 | 530 | if (!values) | |
| 531 | 531 | return -ENOMEM; | |
| 532 | 532 | ||
modified drivers/base/test/Kconfig
| @@ -17,7 +17,6 @@ config DM_KUNIT_TEST | |||
| 17 | 17 | config DRIVER_PE_KUNIT_TEST | |
| 18 | 18 | tristate "KUnit Tests for property entry API" if !KUNIT_ALL_TESTS | |
| 19 | 19 | depends on KUNIT | |
| 20 | - | select OF | |
| 21 | 20 | default KUNIT_ALL_TESTS | |
| 22 | 21 | ||
| 23 | 22 | config DRIVER_SWNODE_KUNIT_TEST | |
modified drivers/base/test/property-entry-test.c
| @@ -523,6 +523,9 @@ static void pe_test_child_iteration(struct kunit *test) | |||
| 523 | 523 | struct fwnode_handle *child; | |
| 524 | 524 | int error, i, num; | |
| 525 | 525 | ||
| 526 | + | if (!IS_ENABLED(CONFIG_OF)) | |
| 527 | + | kunit_skip(test, "requires CONFIG_OF"); | |
| 528 | + | ||
| 526 | 529 | static const struct software_node node = { .name = "sw" }; | |
| 527 | 530 | static const struct software_node node1 = { .name = "sw-1", .parent = &node}; | |
| 528 | 531 | static const struct software_node node2 = { .name = "sw-2", .parent = &node}; | |
modified drivers/block/drbd/drbd_nl_gen.c
| @@ -656,7 +656,7 @@ static int __drbd_cfg_context_from_attrs(struct drbd_cfg_context *s, | |||
| 656 | 656 | *ret_nested_attribute_table = NULL; | |
| 657 | 657 | if (!tla) | |
| 658 | 658 | return -ENOMSG; | |
| 659 | - | ntb = kcalloc(DRBD_A_DRBD_CFG_CONTEXT_CTX_PEER_ADDR + 1, sizeof(*ntb), GFP_KERNEL); | |
| 659 | + | ntb = kzalloc_objs(*ntb, DRBD_A_DRBD_CFG_CONTEXT_CTX_PEER_ADDR + 1); | |
| 660 | 660 | if (!ntb) | |
| 661 | 661 | return -ENOMEM; | |
| 662 | 662 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_drbd_cfg_context_nl_policy, NULL); | |
| @@ -714,7 +714,7 @@ static int __disk_conf_from_attrs(struct disk_conf *s, | |||
| 714 | 714 | *ret_nested_attribute_table = NULL; | |
| 715 | 715 | if (!tla) | |
| 716 | 716 | return -ENOMSG; | |
| 717 | - | ntb = kcalloc(DRBD_A_DISK_CONF_DISABLE_WRITE_SAME + 1, sizeof(*ntb), GFP_KERNEL); | |
| 717 | + | ntb = kzalloc_objs(*ntb, DRBD_A_DISK_CONF_DISABLE_WRITE_SAME + 1); | |
| 718 | 718 | if (!ntb) | |
| 719 | 719 | return -ENOMEM; | |
| 720 | 720 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_disk_conf_nl_policy, NULL); | |
| @@ -871,7 +871,7 @@ static int __res_opts_from_attrs(struct res_opts *s, | |||
| 871 | 871 | *ret_nested_attribute_table = NULL; | |
| 872 | 872 | if (!tla) | |
| 873 | 873 | return -ENOMSG; | |
| 874 | - | ntb = kcalloc(DRBD_A_RES_OPTS_ON_NO_DATA + 1, sizeof(*ntb), GFP_KERNEL); | |
| 874 | + | ntb = kzalloc_objs(*ntb, DRBD_A_RES_OPTS_ON_NO_DATA + 1); | |
| 875 | 875 | if (!ntb) | |
| 876 | 876 | return -ENOMEM; | |
| 877 | 877 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_res_opts_nl_policy, NULL); | |
| @@ -921,7 +921,7 @@ static int __net_conf_from_attrs(struct net_conf *s, | |||
| 921 | 921 | *ret_nested_attribute_table = NULL; | |
| 922 | 922 | if (!tla) | |
| 923 | 923 | return -ENOMSG; | |
| 924 | - | ntb = kcalloc(DRBD_A_NET_CONF_SOCK_CHECK_TIMEO + 1, sizeof(*ntb), GFP_KERNEL); | |
| 924 | + | ntb = kzalloc_objs(*ntb, DRBD_A_NET_CONF_SOCK_CHECK_TIMEO + 1); | |
| 925 | 925 | if (!ntb) | |
| 926 | 926 | return -ENOMEM; | |
| 927 | 927 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_net_conf_nl_policy, NULL); | |
| @@ -1087,7 +1087,7 @@ static int __set_role_parms_from_attrs(struct set_role_parms *s, | |||
| 1087 | 1087 | *ret_nested_attribute_table = NULL; | |
| 1088 | 1088 | if (!tla) | |
| 1089 | 1089 | return -ENOMSG; | |
| 1090 | - | ntb = kcalloc(DRBD_A_SET_ROLE_PARMS_ASSUME_UPTODATE + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1090 | + | ntb = kzalloc_objs(*ntb, DRBD_A_SET_ROLE_PARMS_ASSUME_UPTODATE + 1); | |
| 1091 | 1091 | if (!ntb) | |
| 1092 | 1092 | return -ENOMEM; | |
| 1093 | 1093 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_set_role_parms_nl_policy, NULL); | |
| @@ -1133,7 +1133,7 @@ static int __resize_parms_from_attrs(struct resize_parms *s, | |||
| 1133 | 1133 | *ret_nested_attribute_table = NULL; | |
| 1134 | 1134 | if (!tla) | |
| 1135 | 1135 | return -ENOMSG; | |
| 1136 | - | ntb = kcalloc(DRBD_A_RESIZE_PARMS_AL_STRIPE_SIZE + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1136 | + | ntb = kzalloc_objs(*ntb, DRBD_A_RESIZE_PARMS_AL_STRIPE_SIZE + 1); | |
| 1137 | 1137 | if (!ntb) | |
| 1138 | 1138 | return -ENOMEM; | |
| 1139 | 1139 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_resize_parms_nl_policy, NULL); | |
| @@ -1195,7 +1195,7 @@ static int __start_ov_parms_from_attrs(struct start_ov_parms *s, | |||
| 1195 | 1195 | *ret_nested_attribute_table = NULL; | |
| 1196 | 1196 | if (!tla) | |
| 1197 | 1197 | return -ENOMSG; | |
| 1198 | - | ntb = kcalloc(DRBD_A_START_OV_PARMS_OV_STOP_SECTOR + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1198 | + | ntb = kzalloc_objs(*ntb, DRBD_A_START_OV_PARMS_OV_STOP_SECTOR + 1); | |
| 1199 | 1199 | if (!ntb) | |
| 1200 | 1200 | return -ENOMEM; | |
| 1201 | 1201 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_start_ov_parms_nl_policy, NULL); | |
| @@ -1245,7 +1245,7 @@ static int __new_c_uuid_parms_from_attrs(struct new_c_uuid_parms *s, | |||
| 1245 | 1245 | *ret_nested_attribute_table = NULL; | |
| 1246 | 1246 | if (!tla) | |
| 1247 | 1247 | return -ENOMSG; | |
| 1248 | - | ntb = kcalloc(DRBD_A_NEW_C_UUID_PARMS_CLEAR_BM + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1248 | + | ntb = kzalloc_objs(*ntb, DRBD_A_NEW_C_UUID_PARMS_CLEAR_BM + 1); | |
| 1249 | 1249 | if (!ntb) | |
| 1250 | 1250 | return -ENOMEM; | |
| 1251 | 1251 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_new_c_uuid_parms_nl_policy, NULL); | |
| @@ -1291,7 +1291,7 @@ static int __disconnect_parms_from_attrs(struct disconnect_parms *s, | |||
| 1291 | 1291 | *ret_nested_attribute_table = NULL; | |
| 1292 | 1292 | if (!tla) | |
| 1293 | 1293 | return -ENOMSG; | |
| 1294 | - | ntb = kcalloc(DRBD_A_DISCONNECT_PARMS_FORCE_DISCONNECT + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1294 | + | ntb = kzalloc_objs(*ntb, DRBD_A_DISCONNECT_PARMS_FORCE_DISCONNECT + 1); | |
| 1295 | 1295 | if (!ntb) | |
| 1296 | 1296 | return -ENOMEM; | |
| 1297 | 1297 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_disconnect_parms_nl_policy, NULL); | |
| @@ -1337,7 +1337,7 @@ static int __detach_parms_from_attrs(struct detach_parms *s, | |||
| 1337 | 1337 | *ret_nested_attribute_table = NULL; | |
| 1338 | 1338 | if (!tla) | |
| 1339 | 1339 | return -ENOMSG; | |
| 1340 | - | ntb = kcalloc(DRBD_A_DETACH_PARMS_FORCE_DETACH + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1340 | + | ntb = kzalloc_objs(*ntb, DRBD_A_DETACH_PARMS_FORCE_DETACH + 1); | |
| 1341 | 1341 | if (!ntb) | |
| 1342 | 1342 | return -ENOMEM; | |
| 1343 | 1343 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_detach_parms_nl_policy, NULL); | |
| @@ -1383,7 +1383,7 @@ static int __resource_info_from_attrs(struct resource_info *s, | |||
| 1383 | 1383 | *ret_nested_attribute_table = NULL; | |
| 1384 | 1384 | if (!tla) | |
| 1385 | 1385 | return -ENOMSG; | |
| 1386 | - | ntb = kcalloc(DRBD_A_RESOURCE_INFO_RES_SUSP_FEN + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1386 | + | ntb = kzalloc_objs(*ntb, DRBD_A_RESOURCE_INFO_RES_SUSP_FEN + 1); | |
| 1387 | 1387 | if (!ntb) | |
| 1388 | 1388 | return -ENOMEM; | |
| 1389 | 1389 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_resource_info_nl_policy, NULL); | |
| @@ -1441,7 +1441,7 @@ static int __device_info_from_attrs(struct device_info *s, | |||
| 1441 | 1441 | *ret_nested_attribute_table = NULL; | |
| 1442 | 1442 | if (!tla) | |
| 1443 | 1443 | return -ENOMSG; | |
| 1444 | - | ntb = kcalloc(DRBD_A_DEVICE_INFO_DEV_DISK_STATE + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1444 | + | ntb = kzalloc_objs(*ntb, DRBD_A_DEVICE_INFO_DEV_DISK_STATE + 1); | |
| 1445 | 1445 | if (!ntb) | |
| 1446 | 1446 | return -ENOMEM; | |
| 1447 | 1447 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_device_info_nl_policy, NULL); | |
| @@ -1487,7 +1487,7 @@ static int __connection_info_from_attrs(struct connection_info *s, | |||
| 1487 | 1487 | *ret_nested_attribute_table = NULL; | |
| 1488 | 1488 | if (!tla) | |
| 1489 | 1489 | return -ENOMSG; | |
| 1490 | - | ntb = kcalloc(DRBD_A_CONNECTION_INFO_CONN_ROLE + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1490 | + | ntb = kzalloc_objs(*ntb, DRBD_A_CONNECTION_INFO_CONN_ROLE + 1); | |
| 1491 | 1491 | if (!ntb) | |
| 1492 | 1492 | return -ENOMEM; | |
| 1493 | 1493 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_connection_info_nl_policy, NULL); | |
| @@ -1537,7 +1537,8 @@ static int __peer_device_info_from_attrs(struct peer_device_info *s, | |||
| 1537 | 1537 | *ret_nested_attribute_table = NULL; | |
| 1538 | 1538 | if (!tla) | |
| 1539 | 1539 | return -ENOMSG; | |
| 1540 | - | ntb = kcalloc(DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_DEPENDENCY + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1540 | + | ntb = kzalloc_objs(*ntb, | |
| 1541 | + | DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_DEPENDENCY + 1); | |
| 1541 | 1542 | if (!ntb) | |
| 1542 | 1543 | return -ENOMEM; | |
| 1543 | 1544 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_peer_device_info_nl_policy, NULL); | |
| @@ -1599,7 +1600,8 @@ static int __resource_statistics_from_attrs(struct resource_statistics *s, | |||
| 1599 | 1600 | *ret_nested_attribute_table = NULL; | |
| 1600 | 1601 | if (!tla) | |
| 1601 | 1602 | return -ENOMSG; | |
| 1602 | - | ntb = kcalloc(DRBD_A_RESOURCE_STATISTICS_RES_STAT_WRITE_ORDERING + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1603 | + | ntb = kzalloc_objs(*ntb, | |
| 1604 | + | DRBD_A_RESOURCE_STATISTICS_RES_STAT_WRITE_ORDERING + 1); | |
| 1603 | 1605 | if (!ntb) | |
| 1604 | 1606 | return -ENOMEM; | |
| 1605 | 1607 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_resource_statistics_nl_policy, NULL); | |
| @@ -1645,7 +1647,7 @@ static int __device_statistics_from_attrs(struct device_statistics *s, | |||
| 1645 | 1647 | *ret_nested_attribute_table = NULL; | |
| 1646 | 1648 | if (!tla) | |
| 1647 | 1649 | return -ENOMSG; | |
| 1648 | - | ntb = kcalloc(DRBD_A_DEVICE_STATISTICS_HISTORY_UUIDS + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1650 | + | ntb = kzalloc_objs(*ntb, DRBD_A_DEVICE_STATISTICS_HISTORY_UUIDS + 1); | |
| 1649 | 1651 | if (!ntb) | |
| 1650 | 1652 | return -ENOMEM; | |
| 1651 | 1653 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_device_statistics_nl_policy, NULL); | |
| @@ -1743,7 +1745,8 @@ static int __connection_statistics_from_attrs(struct connection_statistics *s, | |||
| 1743 | 1745 | *ret_nested_attribute_table = NULL; | |
| 1744 | 1746 | if (!tla) | |
| 1745 | 1747 | return -ENOMSG; | |
| 1746 | - | ntb = kcalloc(DRBD_A_CONNECTION_STATISTICS_CONN_CONGESTED + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1748 | + | ntb = kzalloc_objs(*ntb, | |
| 1749 | + | DRBD_A_CONNECTION_STATISTICS_CONN_CONGESTED + 1); | |
| 1747 | 1750 | if (!ntb) | |
| 1748 | 1751 | return -ENOMEM; | |
| 1749 | 1752 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_connection_statistics_nl_policy, NULL); | |
| @@ -1789,7 +1792,8 @@ static int __peer_device_statistics_from_attrs(struct peer_device_statistics *s, | |||
| 1789 | 1792 | *ret_nested_attribute_table = NULL; | |
| 1790 | 1793 | if (!tla) | |
| 1791 | 1794 | return -ENOMSG; | |
| 1792 | - | ntb = kcalloc(DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_FLAGS + 1, sizeof(*ntb), GFP_KERNEL); | |
| 1795 | + | ntb = kzalloc_objs(*ntb, | |
| 1796 | + | DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_FLAGS + 1); | |
| 1793 | 1797 | if (!ntb) | |
| 1794 | 1798 | return -ENOMEM; | |
| 1795 | 1799 | err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_peer_device_statistics_nl_policy, NULL); | |
modified drivers/block/loop.c
| @@ -458,12 +458,14 @@ static void loop_update_dio_alignment(struct loop_device *lo) | |||
| 458 | 458 | * Use the dio alignment of the file system if provided. The incomoing | |
| 459 | 459 | * request's bio_vec is forwarded to the backing file unchanged, so its | |
| 460 | 460 | * required memory alignment becomes the device's dma_alignment when | |
| 461 | - | * used for direct-io. | |
| 461 | + | * used for direct-io. The file system reports zeroed alignments if the | |
| 462 | + | * file can't be used for direct-io at all, so fall back to the block | |
| 463 | + | * device limits in that case. | |
| 462 | 464 | */ | |
| 463 | 465 | if (!vfs_getattr(&file->f_path, &st, STATX_DIOALIGN, 0) && | |
| 464 | - | (st.result_mask & STATX_DIOALIGN)) { | |
| 466 | + | (st.result_mask & STATX_DIOALIGN) && st.dio_mem_align) { | |
| 465 | 467 | lo->lo_min_dio_size = st.dio_offset_align; | |
| 466 | - | lo->lo_dio_mem_align = st.dio_mem_align - 1; | |
| 468 | + | lo->lo_dio_mem_align = min(st.dio_mem_align - 1, PAGE_SIZE - 1); | |
| 467 | 469 | return; | |
| 468 | 470 | } | |
| 469 | 471 | ||
modified drivers/block/sunvdc.c
| @@ -525,6 +525,23 @@ static int __send_request(struct request *req) | |||
| 525 | 525 | err = __vdc_tx_trigger(port); | |
| 526 | 526 | if (err < 0) { | |
| 527 | 527 | printk(KERN_ERR PFX "vdc_tx_trigger() failure, err=%d\n", err); | |
| 528 | + | /* | |
| 529 | + | * If the port was reset (-ENOTCONN), the dring and the | |
| 530 | + | * LDC channel including all of its mappings are already | |
| 531 | + | * torn down and reallocated - there is nothing to undo | |
| 532 | + | * and @desc must not be touched. | |
| 533 | + | * | |
| 534 | + | * For any other failure the descriptor was never handed | |
| 535 | + | * to the peer: unmap the cookies and free the descriptor | |
| 536 | + | * again, so that a later retry of the request does not | |
| 537 | + | * leak LDC map table entries. | |
| 538 | + | */ | |
| 539 | + | if (err != -ENOTCONN) { | |
| 540 | + | ldc_unmap(port->vio.lp, desc->cookies, | |
| 541 | + | desc->ncookies); | |
| 542 | + | desc->hdr.state = VIO_DESC_FREE; | |
| 543 | + | rqe->req = NULL; | |
| 544 | + | } | |
| 528 | 545 | } else { | |
| 529 | 546 | port->req_id++; | |
| 530 | 547 | dr->prod = vio_dring_next(dr, dr->prod); | |
| @@ -539,6 +556,7 @@ static blk_status_t vdc_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
| 539 | 556 | struct vdc_port *port = hctx->queue->queuedata; | |
| 540 | 557 | struct vio_dring_state *dr; | |
| 541 | 558 | unsigned long flags; | |
| 559 | + | int ret; | |
| 542 | 560 | ||
| 543 | 561 | dr = &port->vio.drings[VIO_DRIVER_TX_RING]; | |
| 544 | 562 | ||
| @@ -560,7 +578,13 @@ static blk_status_t vdc_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
| 560 | 578 | return BLK_STS_DEV_RESOURCE; | |
| 561 | 579 | } | |
| 562 | 580 | ||
| 563 | - | if (__send_request(bd->rq) < 0) { | |
| 581 | + | ret = __send_request(bd->rq); | |
| 582 | + | if (ret == -EAGAIN) { | |
| 583 | + | spin_unlock_irqrestore(&port->vio.lock, flags); | |
| 584 | + | /* already spun for 10msec, defer 10msec and retry */ | |
| 585 | + | blk_mq_delay_kick_requeue_list(hctx->queue, 10); | |
| 586 | + | return BLK_STS_DEV_RESOURCE; | |
| 587 | + | } else if (ret < 0) { | |
| 564 | 588 | spin_unlock_irqrestore(&port->vio.lock, flags); | |
| 565 | 589 | return BLK_STS_IOERR; | |
| 566 | 590 | } | |
modified drivers/block/ublk_drv.c
| @@ -2653,6 +2653,12 @@ static int ublk_ch_mmap(struct file *filp, struct vm_area_struct *vma) | |||
| 2653 | 2653 | if (vma->vm_flags & VM_WRITE) | |
| 2654 | 2654 | return -EPERM; | |
| 2655 | 2655 | ||
| 2656 | + | /* | |
| 2657 | + | * The per-queue command buffer is kernel-written ABI; prevent | |
| 2658 | + | * the daemon from upgrading to writable via mprotect(). | |
| 2659 | + | */ | |
| 2660 | + | vm_flags_clear(vma, VM_MAYWRITE); | |
| 2661 | + | ||
| 2656 | 2662 | end = UBLKSRV_CMD_BUF_OFFSET + ub->dev_info.nr_hw_queues * max_sz; | |
| 2657 | 2663 | if (phys_off < UBLKSRV_CMD_BUF_OFFSET || phys_off >= end) | |
| 2658 | 2664 | return -EINVAL; | |
| @@ -3024,6 +3030,7 @@ static void ublk_queue_reset_io_flags(struct ublk_queue *ubq) | |||
| 3024 | 3030 | ubq->canceling = false; | |
| 3025 | 3031 | spin_unlock(&ubq->cancel_lock); | |
| 3026 | 3032 | ubq->fail_io = false; | |
| 3033 | + | ubq->force_abort = false; | |
| 3027 | 3034 | } | |
| 3028 | 3035 | ||
| 3029 | 3036 | /* device can only be started after all IOs are ready */ | |
| @@ -5390,7 +5397,7 @@ static int __ublk_ctrl_reg_buf(struct ublk_device *ub, | |||
| 5390 | 5397 | page_to_pfn(pages[i + 1]) == pfn + (i - start) + 1) | |
| 5391 | 5398 | i++; | |
| 5392 | 5399 | ||
| 5393 | - | range = kzalloc(sizeof(*range), GFP_KERNEL); | |
| 5400 | + | range = kzalloc_obj(*range); | |
| 5394 | 5401 | if (!range) { | |
| 5395 | 5402 | ret = -ENOMEM; | |
| 5396 | 5403 | goto unwind; | |
| @@ -5453,7 +5460,7 @@ static int ublk_ctrl_reg_buf(struct ublk_device *ub, | |||
| 5453 | 5460 | nr_pages = buf_reg.len >> PAGE_SHIFT; | |
| 5454 | 5461 | ||
| 5455 | 5462 | /* Pin pages before any locks (may sleep) */ | |
| 5456 | - | pages = kvmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL); | |
| 5463 | + | pages = kvmalloc_objs(*pages, nr_pages); | |
| 5457 | 5464 | if (!pages) | |
| 5458 | 5465 | return -ENOMEM; | |
| 5459 | 5466 | ||
modified drivers/block/zloop.c
| @@ -1042,12 +1042,14 @@ static int zloop_get_block_size(struct zloop_device *zlo, | |||
| 1042 | 1042 | * Use the dio alignment of the file system if provided. The incoming | |
| 1043 | 1043 | * request's bio_vec is forwarded to the backing file unchanged, so its | |
| 1044 | 1044 | * required memory alignment becomes the device's dma_alignment when | |
| 1045 | - | * used for direct-io. | |
| 1045 | + | * used for direct-io. The file system reports zeroed alignments if the | |
| 1046 | + | * file can't be used for direct-io at all, so fall back to the block | |
| 1047 | + | * device limits in that case. | |
| 1046 | 1048 | */ | |
| 1047 | 1049 | if (!vfs_getattr(&zone->file->f_path, &st, STATX_DIOALIGN, 0) && | |
| 1048 | - | (st.result_mask & STATX_DIOALIGN)) { | |
| 1050 | + | (st.result_mask & STATX_DIOALIGN) && st.dio_mem_align) { | |
| 1049 | 1051 | zlo->block_size = st.dio_offset_align; | |
| 1050 | - | zlo->dio_mem_align = st.dio_mem_align - 1; | |
| 1052 | + | zlo->dio_mem_align = min(st.dio_mem_align - 1, PAGE_SIZE - 1); | |
| 1051 | 1053 | } else if (sb_bdev) { | |
| 1052 | 1054 | zlo->block_size = bdev_physical_block_size(sb_bdev); | |
| 1053 | 1055 | zlo->dio_mem_align = bdev_dma_alignment(sb_bdev); | |
modified drivers/block/zram/backend_lz4.c
| @@ -42,7 +42,7 @@ static int lz4_setup_params(struct zcomp_params *params) | |||
| 42 | 42 | if (!params->dict || !params->dict_sz) | |
| 43 | 43 | return 0; | |
| 44 | 44 | ||
| 45 | - | dict_stream = kzalloc_obj(*dict_stream, GFP_KERNEL); | |
| 45 | + | dict_stream = kzalloc_obj(*dict_stream); | |
| 46 | 46 | if (!dict_stream) | |
| 47 | 47 | return -ENOMEM; | |
| 48 | 48 | ||
modified drivers/bluetooth/btintel.c
| @@ -571,12 +571,44 @@ int btintel_version_info_tlv(struct hci_dev *hdev, | |||
| 571 | 571 | } | |
| 572 | 572 | EXPORT_SYMBOL_GPL(btintel_version_info_tlv); | |
| 573 | 573 | ||
| 574 | + | static u8 btintel_version_tlv_min_len(u8 type) | |
| 575 | + | { | |
| 576 | + | switch (type) { | |
| 577 | + | case INTEL_TLV_CNVI_TOP: | |
| 578 | + | case INTEL_TLV_CNVR_TOP: | |
| 579 | + | case INTEL_TLV_CNVI_BT: | |
| 580 | + | case INTEL_TLV_CNVR_BT: | |
| 581 | + | case INTEL_TLV_BUILD_NUM: | |
| 582 | + | case INTEL_TLV_GIT_SHA1: | |
| 583 | + | return sizeof(u32); | |
| 584 | + | case INTEL_TLV_DEV_REV_ID: | |
| 585 | + | case INTEL_TLV_TIME_STAMP: | |
| 586 | + | return sizeof(u16); | |
| 587 | + | case INTEL_TLV_IMAGE_TYPE: | |
| 588 | + | case INTEL_TLV_BUILD_TYPE: | |
| 589 | + | case INTEL_TLV_SECURE_BOOT: | |
| 590 | + | case INTEL_TLV_OTP_LOCK: | |
| 591 | + | case INTEL_TLV_API_LOCK: | |
| 592 | + | case INTEL_TLV_DEBUG_LOCK: | |
| 593 | + | case INTEL_TLV_LIMITED_CCE: | |
| 594 | + | case INTEL_TLV_SBE_TYPE: | |
| 595 | + | return sizeof(u8); | |
| 596 | + | case INTEL_TLV_MIN_FW: | |
| 597 | + | return 3; | |
| 598 | + | case INTEL_TLV_OTP_BDADDR: | |
| 599 | + | return sizeof(bdaddr_t); | |
| 600 | + | default: | |
| 601 | + | return 0; | |
| 602 | + | } | |
| 603 | + | } | |
| 604 | + | ||
| 574 | 605 | int btintel_parse_version_tlv(struct hci_dev *hdev, | |
| 575 | 606 | struct intel_version_tlv *version, | |
| 576 | 607 | struct sk_buff *skb) | |
| 577 | 608 | { | |
| 578 | 609 | /* Consume Command Complete Status field */ | |
| 579 | - | skb_pull(skb, 1); | |
| 610 | + | if (!skb_pull(skb, 1)) | |
| 611 | + | return -EINVAL; | |
| 580 | 612 | ||
| 581 | 613 | /* Event parameters contain multiple TLVs. Read each of them | |
| 582 | 614 | * and only keep the required data. Also, it use existing legacy | |
| @@ -596,6 +628,9 @@ int btintel_parse_version_tlv(struct hci_dev *hdev, | |||
| 596 | 628 | if (skb->len < tlv->len + sizeof(*tlv)) | |
| 597 | 629 | return -EINVAL; | |
| 598 | 630 | ||
| 631 | + | if (tlv->len < btintel_version_tlv_min_len(tlv->type)) | |
| 632 | + | return -EINVAL; | |
| 633 | + | ||
| 599 | 634 | switch (tlv->type) { | |
| 600 | 635 | case INTEL_TLV_CNVI_TOP: | |
| 601 | 636 | version->cnvi_top = get_unaligned_le32(tlv->val); | |
| @@ -667,7 +702,7 @@ int btintel_parse_version_tlv(struct hci_dev *hdev, | |||
| 667 | 702 | break; | |
| 668 | 703 | case INTEL_TLV_FW_ID: | |
| 669 | 704 | snprintf(version->fw_id, sizeof(version->fw_id), | |
| 670 | - | "%s", tlv->val); | |
| 705 | + | "%.*s", tlv->len, tlv->val); | |
| 671 | 706 | break; | |
| 672 | 707 | default: | |
| 673 | 708 | /* Ignore rest of information */ | |
| @@ -686,6 +721,7 @@ static int btintel_read_version_tlv(struct hci_dev *hdev, | |||
| 686 | 721 | { | |
| 687 | 722 | struct sk_buff *skb; | |
| 688 | 723 | const u8 param[1] = { 0xFF }; | |
| 724 | + | int err; | |
| 689 | 725 | ||
| 690 | 726 | if (!version) | |
| 691 | 727 | return -EINVAL; | |
| @@ -704,10 +740,10 @@ static int btintel_read_version_tlv(struct hci_dev *hdev, | |||
| 704 | 740 | return -EIO; | |
| 705 | 741 | } | |
| 706 | 742 | ||
| 707 | - | btintel_parse_version_tlv(hdev, version, skb); | |
| 743 | + | err = btintel_parse_version_tlv(hdev, version, skb); | |
| 708 | 744 | ||
| 709 | 745 | kfree_skb(skb); | |
| 710 | - | return 0; | |
| 746 | + | return err; | |
| 711 | 747 | } | |
| 712 | 748 | ||
| 713 | 749 | /* ------- REGMAP IBT SUPPORT ------- */ | |
modified drivers/bluetooth/btintel_pcie.c
| @@ -404,6 +404,12 @@ static int btintel_pcie_send_sync(struct btintel_pcie_data *data, | |||
| 404 | 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,13 +1099,18 @@ 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); | |
| 1099 | 1110 | ||
| 1100 | 1111 | urbd0 = &txq->urbd0s[cr_tia]; | |
| 1101 | 1112 | ||
| 1102 | - | if (urbd0->tfd_index > txq->count) | |
| 1113 | + | if (urbd0->tfd_index >= txq->count) | |
| 1103 | 1114 | return; | |
| 1104 | 1115 | ||
| 1105 | 1116 | cr_tia = (cr_tia + 1) % txq->count; | |
| @@ -1599,7 +1610,9 @@ static int btintel_pcie_submit_rx_work(struct btintel_pcie_data *data, u8 status | |||
| 1599 | 1610 | rfh_hdr = buf; | |
| 1600 | 1611 | ||
| 1601 | 1612 | len = rfh_hdr->packet_len; | |
| 1602 | - | if (len <= 0) { | |
| 1613 | + | if (len == 0 || len > BTINTEL_PCIE_BUFFER_SIZE - sizeof(*rfh_hdr)) { | |
| 1614 | + | bt_dev_err(data->hdev, "Invalid packet_len %d (max %zu)", len, | |
| 1615 | + | BTINTEL_PCIE_BUFFER_SIZE - sizeof(*rfh_hdr)); | |
| 1603 | 1616 | ret = -EINVAL; | |
| 1604 | 1617 | goto resubmit; | |
| 1605 | 1618 | } | |
| @@ -1642,6 +1655,11 @@ static void btintel_pcie_msix_rx_handle(struct btintel_pcie_data *data) | |||
| 1642 | 1655 | ||
| 1643 | 1656 | rxq = &data->rxq; | |
| 1644 | 1657 | ||
| 1658 | + | if (cr_hia >= rxq->count) { | |
| 1659 | + | bt_dev_err(hdev, "RXQ: invalid cr_hia %u", cr_hia); | |
| 1660 | + | return; | |
| 1661 | + | } | |
| 1662 | + | ||
| 1645 | 1663 | /* The firmware sends multiple CD in a single MSI-X and it needs to | |
| 1646 | 1664 | * process all received CDs in this interrupt. | |
| 1647 | 1665 | */ | |
| @@ -1649,6 +1667,12 @@ static void btintel_pcie_msix_rx_handle(struct btintel_pcie_data *data) | |||
| 1649 | 1667 | urbd1 = &rxq->urbd1s[cr_tia]; | |
| 1650 | 1668 | ipc_print_urbd1(data->hdev, urbd1, cr_tia); | |
| 1651 | 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 | + | ||
| 1652 | 1676 | buf = &rxq->bufs[urbd1->frbd_tag]; | |
| 1653 | 1677 | if (!buf) { | |
| 1654 | 1678 | bt_dev_err(hdev, "RXQ: failed to get the DMA buffer for %d", | |
| @@ -1696,6 +1720,9 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id) | |||
| 1696 | 1720 | ||
| 1697 | 1721 | if (unlikely(!(intr_fh | intr_hw))) { | |
| 1698 | 1722 | /* Ignore interrupt, inta == 0 */ | |
| 1723 | + | bt_warn_ratelimited("Bluetooth: btintel_pcie: Received spurious interrupt\n"); | |
| 1724 | + | btintel_pcie_wr_reg32(data, BTINTEL_PCIE_CSR_MSIX_AUTOMASK_ST, | |
| 1725 | + | BIT(entry->entry)); | |
| 1699 | 1726 | return IRQ_NONE; | |
| 1700 | 1727 | } | |
| 1701 | 1728 | ||
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 | ||
| @@ -1374,16 +1379,6 @@ int btmtk_usb_setup(struct hci_dev *hdev) | |||
| 1374 | 1379 | break; | |
| 1375 | 1380 | case 0x7922: | |
| 1376 | 1381 | case 0x7925: | |
| 1377 | - | /* | |
| 1378 | - | * A remote wakeup could cause the device completely unresponsive, and | |
| 1379 | - | * recovering from such a state needs a power cycle. | |
| 1380 | - | * | |
| 1381 | - | * Since the remote wakeup capability is super broken, just disable it | |
| 1382 | - | * to get rid of the troubles. The device can still be autosuspended | |
| 1383 | - | * when the bluetooth interface is closed. | |
| 1384 | - | */ | |
| 1385 | - | device_set_wakeup_capable(&btmtk_data->udev->dev, false); | |
| 1386 | - | fallthrough; | |
| 1387 | 1382 | case 0x7961: | |
| 1388 | 1383 | case 0x7902: | |
| 1389 | 1384 | case 0x6639: | |
| @@ -1587,5 +1582,6 @@ MODULE_FIRMWARE(FIRMWARE_MT7663); | |||
| 1587 | 1582 | MODULE_FIRMWARE(FIRMWARE_MT7668); | |
| 1588 | 1583 | MODULE_FIRMWARE(FIRMWARE_MT7922); | |
| 1589 | 1584 | MODULE_FIRMWARE(FIRMWARE_MT7961); | |
| 1585 | + | MODULE_FIRMWARE(FIRMWARE_MT7920); | |
| 1590 | 1586 | MODULE_FIRMWARE(FIRMWARE_MT7925); | |
| 1591 | 1587 | MODULE_FIRMWARE(FIRMWARE_MT7927); | |
modified drivers/bluetooth/btmtk.h
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | #define FIRMWARE_MT7922 "mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin" | |
| 8 | 8 | #define FIRMWARE_MT7902 "mediatek/BT_RAM_CODE_MT7902_1_1_hdr.bin" | |
| 9 | 9 | #define FIRMWARE_MT7961 "mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin" | |
| 10 | + | #define FIRMWARE_MT7920 "mediatek/BT_RAM_CODE_MT7961_1a_2_hdr.bin" | |
| 10 | 11 | #define FIRMWARE_MT7925 "mediatek/mt7925/BT_RAM_CODE_MT7925_1_1_hdr.bin" | |
| 11 | 12 | #define FIRMWARE_MT7927 "mediatek/mt7927/BT_RAM_CODE_MT6639_2_1_hdr.bin" | |
| 12 | 13 | ||
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/btqcomsmd.c
| @@ -188,7 +188,10 @@ static int btqcomsmd_probe(struct platform_device *pdev) | |||
| 188 | 188 | return 0; | |
| 189 | 189 | ||
| 190 | 190 | hci_free_dev: | |
| 191 | + | rpmsg_destroy_ept(btq->cmd_channel); | |
| 192 | + | rpmsg_destroy_ept(btq->acl_channel); | |
| 191 | 193 | hci_free_dev(hdev); | |
| 194 | + | return ret; | |
| 192 | 195 | destroy_cmd_channel: | |
| 193 | 196 | rpmsg_destroy_ept(btq->cmd_channel); | |
| 194 | 197 | destroy_acl_channel: | |
| @@ -202,10 +205,11 @@ static void btqcomsmd_remove(struct platform_device *pdev) | |||
| 202 | 205 | struct btqcomsmd *btq = platform_get_drvdata(pdev); | |
| 203 | 206 | ||
| 204 | 207 | hci_unregister_dev(btq->hdev); | |
| 205 | - | hci_free_dev(btq->hdev); | |
| 206 | 208 | ||
| 207 | 209 | rpmsg_destroy_ept(btq->cmd_channel); | |
| 208 | 210 | rpmsg_destroy_ept(btq->acl_channel); | |
| 211 | + | ||
| 212 | + | hci_free_dev(btq->hdev); | |
| 209 | 213 | } | |
| 210 | 214 | ||
| 211 | 215 | static const struct of_device_id btqcomsmd_of_match[] = { | |
modified drivers/bluetooth/btrtl.c
| @@ -591,7 +591,7 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev, | |||
| 591 | 591 | * headers. | |
| 592 | 592 | */ | |
| 593 | 593 | if (!key_id) | |
| 594 | - | break; | |
| 594 | + | continue; | |
| 595 | 595 | rc = btrtl_parse_section(hdev, btrtl_dev, opcode, | |
| 596 | 596 | ptr, section_len); | |
| 597 | 597 | break; | |
| @@ -600,8 +600,7 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev, | |||
| 600 | 600 | ptr, section_len); | |
| 601 | 601 | break; | |
| 602 | 602 | default: | |
| 603 | - | rc = 0; | |
| 604 | - | break; | |
| 603 | + | continue; | |
| 605 | 604 | } | |
| 606 | 605 | if (rc < 0) { | |
| 607 | 606 | rtl_dev_err(hdev, "RTL: Parse section (%u) err %d", | |
modified drivers/bluetooth/btusb.c
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org> | |
| 7 | 7 | */ | |
| 8 | 8 | ||
| 9 | + | #include <linux/cpufeature.h> | |
| 9 | 10 | #include <linux/dmi.h> | |
| 10 | 11 | #include <linux/module.h> | |
| 11 | 12 | #include <linux/usb.h> | |
| @@ -70,6 +71,15 @@ static struct usb_driver btusb_driver; | |||
| 70 | 71 | #define BTUSB_BROKEN_EXT_SCAN BIT(29) | |
| 71 | 72 | ||
| 72 | 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 | + | ||
| 73 | 83 | /* Generic Bluetooth USB device */ | |
| 74 | 84 | { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, | |
| 75 | 85 | ||
| @@ -476,6 +486,14 @@ static const struct usb_device_id quirks_table[] = { | |||
| 476 | 486 | { USB_DEVICE(0x1286, 0x2046), .driver_info = BTUSB_MARVELL }, | |
| 477 | 487 | { USB_DEVICE(0x1286, 0x204e), .driver_info = BTUSB_MARVELL }, | |
| 478 | 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 | + | ||
| 479 | 497 | /* Intel Bluetooth devices */ | |
| 480 | 498 | { USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED }, | |
| 481 | 499 | { USB_DEVICE(0x8087, 0x0026), .driver_info = BTUSB_INTEL_COMBINED }, | |
| @@ -980,6 +998,8 @@ struct btqca_data { | |||
| 980 | 998 | #define BTUSB_USE_ALT3_FOR_WBS 15 | |
| 981 | 999 | #define BTUSB_ALT6_CONTINUOUS_TX 16 | |
| 982 | 1000 | #define BTUSB_HW_SSR_ACTIVE 17 | |
| 1001 | + | #define BTUSB_WAKEUP_BROKEN 18 | |
| 1002 | + | #define BTUSB_RESET 19 | |
| 983 | 1003 | ||
| 984 | 1004 | struct btusb_data { | |
| 985 | 1005 | struct hci_dev *hdev; | |
| @@ -1054,13 +1074,15 @@ static void btusb_reset(struct hci_dev *hdev) | |||
| 1054 | 1074 | int err; | |
| 1055 | 1075 | ||
| 1056 | 1076 | data = hci_get_drvdata(hdev); | |
| 1057 | - | /* This is not an unbalanced PM reference since the device will reset */ | |
| 1058 | 1077 | err = usb_autopm_get_interface(data->intf); | |
| 1059 | 1078 | if (err) { | |
| 1060 | 1079 | bt_dev_err(hdev, "Failed usb_autopm_get_interface: %d", err); | |
| 1061 | 1080 | return; | |
| 1062 | 1081 | } | |
| 1063 | 1082 | ||
| 1083 | + | if (test_and_set_bit(BTUSB_RESET, &data->flags)) | |
| 1084 | + | usb_autopm_put_interface_no_suspend(data->intf); | |
| 1085 | + | ||
| 1064 | 1086 | bt_dev_err(hdev, "Resetting usb device."); | |
| 1065 | 1087 | usb_queue_reset_device(data->intf); | |
| 1066 | 1088 | } | |
| @@ -2092,18 +2114,24 @@ static int btusb_close(struct hci_dev *hdev) | |||
| 2092 | 2114 | ||
| 2093 | 2115 | BT_DBG("%s", hdev->name); | |
| 2094 | 2116 | ||
| 2095 | - | cancel_delayed_work(&data->rx_work); | |
| 2096 | 2117 | cancel_work_sync(&data->work); | |
| 2097 | 2118 | cancel_work_sync(&data->waker); | |
| 2098 | 2119 | ||
| 2099 | - | skb_queue_purge(&data->acl_q); | |
| 2100 | - | ||
| 2101 | 2120 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); | |
| 2102 | 2121 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); | |
| 2103 | 2122 | clear_bit(BTUSB_INTR_RUNNING, &data->flags); | |
| 2104 | 2123 | clear_bit(BTUSB_DIAG_RUNNING, &data->flags); | |
| 2105 | 2124 | ||
| 2106 | 2125 | btusb_stop_traffic(data); | |
| 2126 | + | ||
| 2127 | + | /* rx_work must only be canceled once the URBs that can rearm it are | |
| 2128 | + | * gone, and it must be canceled synchronously since btusb_disconnect() | |
| 2129 | + | * frees the btusb_data it dereferences right after hci_unregister_dev(). | |
| 2130 | + | */ | |
| 2131 | + | cancel_delayed_work_sync(&data->rx_work); | |
| 2132 | + | ||
| 2133 | + | skb_queue_purge(&data->acl_q); | |
| 2134 | + | ||
| 2107 | 2135 | btusb_free_frags(data); | |
| 2108 | 2136 | ||
| 2109 | 2137 | err = usb_autopm_get_interface(data->intf); | |
| @@ -2129,7 +2157,7 @@ static int btusb_flush(struct hci_dev *hdev) | |||
| 2129 | 2157 | ||
| 2130 | 2158 | BT_DBG("%s", hdev->name); | |
| 2131 | 2159 | ||
| 2132 | - | cancel_delayed_work(&data->rx_work); | |
| 2160 | + | cancel_delayed_work_sync(&data->rx_work); | |
| 2133 | 2161 | ||
| 2134 | 2162 | skb_queue_purge(&data->acl_q); | |
| 2135 | 2163 | ||
| @@ -2923,8 +2951,11 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data) | |||
| 2923 | 2951 | } | |
| 2924 | 2952 | ||
| 2925 | 2953 | err = usb_autopm_get_interface(data->intf); | |
| 2926 | - | if (err < 0) | |
| 2954 | + | if (err < 0) { | |
| 2955 | + | bt_dev_err(hdev, "Failed usb_autopm_get_interface: %d", err); | |
| 2956 | + | clear_bit(BTMTK_HW_RESET_ACTIVE, &btmtk_data->flags); | |
| 2927 | 2957 | return err; | |
| 2958 | + | } | |
| 2928 | 2959 | ||
| 2929 | 2960 | /* Release MediaTek ISO data interface */ | |
| 2930 | 2961 | btusb_mtk_release_iso_intf(hdev); | |
| @@ -2946,6 +2977,11 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data) | |||
| 2946 | 2977 | ||
| 2947 | 2978 | err = btmtk_usb_subsys_reset(hdev, btmtk_data->dev_id); | |
| 2948 | 2979 | ||
| 2980 | + | if (test_and_set_bit(BTUSB_RESET, &data->flags)) { | |
| 2981 | + | bt_dev_err(hdev, "last usb reset failed? Resetting again"); | |
| 2982 | + | usb_autopm_put_interface_no_suspend(data->intf); | |
| 2983 | + | } | |
| 2984 | + | ||
| 2949 | 2985 | usb_queue_reset_device(data->intf); | |
| 2950 | 2986 | clear_bit(BTMTK_HW_RESET_ACTIVE, &btmtk_data->flags); | |
| 2951 | 2987 | ||
| @@ -2969,10 +3005,25 @@ static int btusb_send_frame_mtk(struct hci_dev *hdev, struct sk_buff *skb) | |||
| 2969 | 3005 | } | |
| 2970 | 3006 | } | |
| 2971 | 3007 | ||
| 3008 | + | static inline bool platform_is_ryzen(void) | |
| 3009 | + | { | |
| 3010 | + | #ifdef CONFIG_X86 | |
| 3011 | + | return boot_cpu_has(X86_FEATURE_ZEN); | |
| 3012 | + | #else | |
| 3013 | + | return false; | |
| 3014 | + | #endif | |
| 3015 | + | } | |
| 3016 | + | ||
| 3017 | + | static inline bool is_direct_child_of_root_hub(struct usb_device *udev) | |
| 3018 | + | { | |
| 3019 | + | return udev->parent == udev->bus->root_hub; | |
| 3020 | + | } | |
| 3021 | + | ||
| 2972 | 3022 | static int btusb_mtk_setup(struct hci_dev *hdev) | |
| 2973 | 3023 | { | |
| 2974 | 3024 | struct btusb_data *data = hci_get_drvdata(hdev); | |
| 2975 | 3025 | struct btmtk_data *btmtk_data = hci_get_priv(hdev); | |
| 3026 | + | int err; | |
| 2976 | 3027 | ||
| 2977 | 3028 | /* MediaTek WMT vendor cmd requiring below USB resources to | |
| 2978 | 3029 | * complete the handshake. | |
| @@ -2989,7 +3040,40 @@ static int btusb_mtk_setup(struct hci_dev *hdev) | |||
| 2989 | 3040 | btusb_mtk_claim_iso_intf(data); | |
| 2990 | 3041 | } | |
| 2991 | 3042 | ||
| 2992 | - | return btmtk_usb_setup(hdev); | |
| 3043 | + | err = btmtk_usb_setup(hdev); | |
| 3044 | + | if (err) | |
| 3045 | + | return err; | |
| 3046 | + | ||
| 3047 | + | switch (btmtk_data->dev_id) { | |
| 3048 | + | case 0x7922: | |
| 3049 | + | case 0x7925: | |
| 3050 | + | /* | |
| 3051 | + | * All reports seen to be relevant to Ryzen-based laptops. These | |
| 3052 | + | * NICs are usually used as OEM components thanks to some sort | |
| 3053 | + | * of reference designs. | |
| 3054 | + | * | |
| 3055 | + | * Their popularity on other platforms is unclear. While there | |
| 3056 | + | * is still a chance that the quirk may exist on other | |
| 3057 | + | * platforms, be cautious and only apply the quirk to direct | |
| 3058 | + | * children of Ryzen platforms's root hubs for the time being. | |
| 3059 | + | * | |
| 3060 | + | * In most cases the root hub is on the SoC or PCH, which needs | |
| 3061 | + | * the quirk. Unfortunately, this can't distinguish root hubs on | |
| 3062 | + | * PCIe add-in cards. Such roughness should be acceptable, as | |
| 3063 | + | * PCIe USB controller add-in cards are less commonly used | |
| 3064 | + | * nowadays. On the other hand, applying the quirk doesn't hurt | |
| 3065 | + | * any functionalities either, as the device can still be used | |
| 3066 | + | * as a wakeup source if desired. | |
| 3067 | + | * | |
| 3068 | + | * Theoretically, we could retrieve the root hub's PCI vendor ID | |
| 3069 | + | * with some hierarchy magic, but that's too intrusive... | |
| 3070 | + | */ | |
| 3071 | + | if (platform_is_ryzen() && is_direct_child_of_root_hub(data->udev)) | |
| 3072 | + | set_bit(BTUSB_WAKEUP_BROKEN, &data->flags); | |
| 3073 | + | break; | |
| 3074 | + | } | |
| 3075 | + | ||
| 3076 | + | return 0; | |
| 2993 | 3077 | } | |
| 2994 | 3078 | ||
| 2995 | 3079 | static int btusb_mtk_shutdown(struct hci_dev *hdev) | |
| @@ -4540,6 +4624,9 @@ static void btusb_disconnect(struct usb_interface *intf) | |||
| 4540 | 4624 | if (data->reset_gpio) | |
| 4541 | 4625 | gpiod_put(data->reset_gpio); | |
| 4542 | 4626 | ||
| 4627 | + | if (test_and_clear_bit(BTUSB_RESET, &data->flags)) | |
| 4628 | + | usb_autopm_put_interface_no_suspend(data->intf); | |
| 4629 | + | ||
| 4543 | 4630 | if (intf == data->intf) { | |
| 4544 | 4631 | if (data->isoc) | |
| 4545 | 4632 | usb_driver_release_interface(&btusb_driver, data->isoc); | |
| @@ -4565,11 +4652,26 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message) | |||
| 4565 | 4652 | ||
| 4566 | 4653 | BT_DBG("intf %p", intf); | |
| 4567 | 4654 | ||
| 4568 | - | /* Don't auto-suspend if there are connections or discovery in | |
| 4569 | - | * progress; external suspend calls shall never fail. | |
| 4655 | + | /* | |
| 4656 | + | * It is reported that remote wakeup events could sometimes cause some | |
| 4657 | + | * adapters completely unresponsive. Resetting the xHCI root hub doesn't | |
| 4658 | + | * help at all, and recovering from such a state needs a power cycle. | |
| 4659 | + | * Since disabling remote wakeup simply causes the USB core to gate | |
| 4660 | + | * runtime autosuspend as well due to needs_remote_wakeup == 1, let's do | |
| 4661 | + | * this ourselves to make our life easier. The interface can be safely | |
| 4662 | + | * autosuspended as long as remote wakeup is disabled, i.e., after | |
| 4663 | + | * closing the HCI device. | |
| 4664 | + | * | |
| 4665 | + | * Don't auto-suspend if there are connections or discovery in progress. | |
| 4666 | + | * | |
| 4667 | + | * External suspend calls shall never fail. Specifically, a device with | |
| 4668 | + | * broken remote wakeup may still take the advantage of remote wakeup in | |
| 4669 | + | * order to wake up the system from sleep if userspace has enabled it as | |
| 4670 | + | * a wakeup source. | |
| 4570 | 4671 | */ | |
| 4571 | 4672 | if (PMSG_IS_AUTO(message) && | |
| 4572 | - | (hci_conn_count(data->hdev) || hci_discovery_active(data->hdev))) | |
| 4673 | + | ((test_bit(BTUSB_WAKEUP_BROKEN, &data->flags) && data->intf->needs_remote_wakeup) || | |
| 4674 | + | hci_conn_count(data->hdev) || hci_discovery_active(data->hdev))) | |
| 4573 | 4675 | return -EBUSY; | |
| 4574 | 4676 | ||
| 4575 | 4677 | if (data->suspend_count++) | |
modified drivers/bluetooth/hci_mrvl.c
| @@ -307,9 +307,8 @@ static int mrvl_load_firmware(struct hci_dev *hdev, const char *name) | |||
| 307 | 307 | err = wait_on_bit_timeout(&mrvl->flags, STATE_FW_REQ_PENDING, | |
| 308 | 308 | TASK_INTERRUPTIBLE, | |
| 309 | 309 | msecs_to_jiffies(2000)); | |
| 310 | - | if (err == 1) { | |
| 310 | + | if (err == -EINTR) { | |
| 311 | 311 | bt_dev_err(hdev, "Firmware load interrupted"); | |
| 312 | - | err = -EINTR; | |
| 313 | 312 | break; | |
| 314 | 313 | } else if (err) { | |
| 315 | 314 | bt_dev_err(hdev, "Firmware request timeout"); | |
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/virtio_console.c
| @@ -426,7 +426,7 @@ static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size | |||
| 426 | 426 | * Allocate buffer and the sg list. The sg list array is allocated | |
| 427 | 427 | * directly after the port_buffer struct. | |
| 428 | 428 | */ | |
| 429 | - | buf = kmalloc_flex(*buf, sg, pages); | |
| 429 | + | buf = kmalloc_flex(*buf, sg, pages, gfp); | |
| 430 | 430 | if (!buf) | |
| 431 | 431 | goto fail; | |
| 432 | 432 | ||
| @@ -1964,13 +1964,28 @@ static const struct file_operations portdev_fops = { | |||
| 1964 | 1964 | static void remove_vqs(struct ports_device *portdev) | |
| 1965 | 1965 | { | |
| 1966 | 1966 | struct virtqueue *vq; | |
| 1967 | + | bool multiport = use_multiport(portdev); | |
| 1967 | 1968 | ||
| 1968 | 1969 | virtio_device_for_each_vq(portdev->vdev, vq) { | |
| 1969 | 1970 | struct port_buffer *buf; | |
| 1971 | + | unsigned int len; | |
| 1970 | 1972 | ||
| 1971 | - | flush_bufs(vq, true); | |
| 1972 | - | while ((buf = virtqueue_detach_unused_buf(vq))) | |
| 1973 | - | free_buf(buf, true); | |
| 1973 | + | /* | |
| 1974 | + | * c_ovq cookies are &portdev->cpkt, not port_buffer. | |
| 1975 | + | * Detach them but do not free_buf(). | |
| 1976 | + | */ | |
| 1977 | + | if (multiport && vq == portdev->c_ovq) { | |
| 1978 | + | spin_lock(&portdev->c_ovq_lock); | |
| 1979 | + | while (virtqueue_get_buf(vq, &len)) | |
| 1980 | + | ; | |
| 1981 | + | while (virtqueue_detach_unused_buf(vq)) | |
| 1982 | + | ; | |
| 1983 | + | spin_unlock(&portdev->c_ovq_lock); | |
| 1984 | + | } else { | |
| 1985 | + | flush_bufs(vq, true); | |
| 1986 | + | while ((buf = virtqueue_detach_unused_buf(vq))) | |
| 1987 | + | free_buf(buf, true); | |
| 1988 | + | } | |
| 1974 | 1989 | cond_resched(); | |
| 1975 | 1990 | } | |
| 1976 | 1991 | portdev->vdev->config->del_vqs(portdev->vdev); | |
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/ti/composite.c
| @@ -248,7 +248,7 @@ int __init ti_clk_add_component(struct device_node *node, struct clk_hw *hw, | |||
| 248 | 248 | return -EINVAL; | |
| 249 | 249 | } | |
| 250 | 250 | ||
| 251 | - | parent_data = kcalloc(num_parents, sizeof(*parent_data), GFP_KERNEL); | |
| 251 | + | parent_data = kzalloc_objs(*parent_data, num_parents); | |
| 252 | 252 | if (!parent_data) | |
| 253 | 253 | return -ENOMEM; | |
| 254 | 254 | ||
modified drivers/clk/ti/mux.c
| @@ -181,7 +181,7 @@ static void of_mux_clk_setup(struct device_node *node) | |||
| 181 | 181 | pr_err("mux-clock %pOFn must have parents\n", node); | |
| 182 | 182 | return; | |
| 183 | 183 | } | |
| 184 | - | parent_data = kcalloc(num_parents, sizeof(*parent_data), GFP_KERNEL); | |
| 184 | + | parent_data = kzalloc_objs(*parent_data, num_parents); | |
| 185 | 185 | if (!parent_data) | |
| 186 | 186 | return; | |
| 187 | 187 | ||
modified drivers/cpufreq/amd-pstate.c
| @@ -1624,7 +1624,7 @@ static struct freq_attr **get_freq_attrs(void) | |||
| 1624 | 1624 | /* amd_pstate_{max_freq, lowest_nonlinear_freq, highest_perf} should always be visible */ | |
| 1625 | 1625 | BUG_ON(!count); | |
| 1626 | 1626 | ||
| 1627 | - | attrs = kcalloc(count + 1, sizeof(struct freq_attr *), GFP_KERNEL); | |
| 1627 | + | attrs = kzalloc_objs(struct freq_attr *, count + 1); | |
| 1628 | 1628 | if (!attrs) | |
| 1629 | 1629 | return ERR_PTR(-ENOMEM); | |
| 1630 | 1630 | ||
modified drivers/cpufreq/cpufreq.c
| @@ -1249,7 +1249,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) | |||
| 1249 | 1249 | if (!policy) | |
| 1250 | 1250 | return NULL; | |
| 1251 | 1251 | ||
| 1252 | - | if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) | |
| 1252 | + | if (!zalloc_cpumask_var(&policy->cpus, GFP_KERNEL)) | |
| 1253 | 1253 | goto err_free_policy; | |
| 1254 | 1254 | ||
| 1255 | 1255 | if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) | |
| @@ -1258,6 +1258,8 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) | |||
| 1258 | 1258 | if (!zalloc_cpumask_var(&policy->real_cpus, GFP_KERNEL)) | |
| 1259 | 1259 | goto err_free_rcpumask; | |
| 1260 | 1260 | ||
| 1261 | + | init_rwsem(&policy->rwsem); | |
| 1262 | + | ||
| 1261 | 1263 | init_completion(&policy->kobj_unregister); | |
| 1262 | 1264 | ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, | |
| 1263 | 1265 | cpufreq_global_kobject, "policy%u", cpu); | |
| @@ -1272,8 +1274,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) | |||
| 1272 | 1274 | goto err_free_real_cpus; | |
| 1273 | 1275 | } | |
| 1274 | 1276 | ||
| 1275 | - | init_rwsem(&policy->rwsem); | |
| 1276 | - | ||
| 1277 | 1277 | freq_constraints_init(&policy->constraints); | |
| 1278 | 1278 | ||
| 1279 | 1279 | policy->nb_min.notifier_call = cpufreq_notifier_min; | |
modified drivers/cpuidle/cpuidle-psci.c
| @@ -16,7 +16,7 @@ | |||
| 16 | 16 | #include <linux/kernel.h> | |
| 17 | 17 | #include <linux/module.h> | |
| 18 | 18 | #include <linux/of.h> | |
| 19 | - | #include <linux/device/faux.h> | |
| 19 | + | #include <linux/platform_device.h> | |
| 20 | 20 | #include <linux/psci.h> | |
| 21 | 21 | #include <linux/pm_domain.h> | |
| 22 | 22 | #include <linux/pm_runtime.h> | |
| @@ -428,14 +428,14 @@ deinit: | |||
| 428 | 428 | * to register cpuidle driver then rollback to cancel all CPUs | |
| 429 | 429 | * registration. | |
| 430 | 430 | */ | |
| 431 | - | static int psci_cpuidle_probe(struct faux_device *fdev) | |
| 431 | + | static int psci_cpuidle_probe(struct platform_device *pdev) | |
| 432 | 432 | { | |
| 433 | 433 | int cpu, ret; | |
| 434 | 434 | struct cpuidle_driver *drv; | |
| 435 | 435 | struct cpuidle_device *dev; | |
| 436 | 436 | ||
| 437 | 437 | for_each_present_cpu(cpu) { | |
| 438 | - | ret = psci_idle_init_cpu(&fdev->dev, cpu); | |
| 438 | + | ret = psci_idle_init_cpu(&pdev->dev, cpu); | |
| 439 | 439 | if (ret) | |
| 440 | 440 | goto out_fail; | |
| 441 | 441 | } | |
| @@ -455,36 +455,26 @@ out_fail: | |||
| 455 | 455 | return ret; | |
| 456 | 456 | } | |
| 457 | 457 | ||
| 458 | - | static struct faux_device_ops psci_cpuidle_ops = { | |
| 458 | + | static struct platform_driver psci_cpuidle_driver = { | |
| 459 | 459 | .probe = psci_cpuidle_probe, | |
| 460 | + | .driver = { | |
| 461 | + | .name = "psci-cpuidle", | |
| 462 | + | }, | |
| 460 | 463 | }; | |
| 461 | 464 | ||
| 462 | - | static bool __init dt_idle_state_present(void) | |
| 463 | - | { | |
| 464 | - | struct device_node *cpu_node __free(device_node) = | |
| 465 | - | of_cpu_device_node_get(cpumask_first(cpu_possible_mask)); | |
| 466 | - | if (!cpu_node) | |
| 467 | - | return false; | |
| 468 | - | ||
| 469 | - | struct device_node *state_node __free(device_node) = | |
| 470 | - | of_get_cpu_state_node(cpu_node, 0); | |
| 471 | - | if (!state_node) | |
| 472 | - | return false; | |
| 473 | - | ||
| 474 | - | return !!of_match_node(psci_idle_state_match, state_node); | |
| 475 | - | } | |
| 476 | - | ||
| 477 | 465 | static int __init psci_idle_init(void) | |
| 478 | 466 | { | |
| 479 | - | struct faux_device *fdev; | |
| 467 | + | struct platform_device *pdev; | |
| 468 | + | int ret; | |
| 480 | 469 | ||
| 481 | - | if (!dt_idle_state_present()) | |
| 482 | - | return 0; | |
| 470 | + | ret = platform_driver_register(&psci_cpuidle_driver); | |
| 471 | + | if (ret) | |
| 472 | + | return ret; | |
| 483 | 473 | ||
| 484 | - | fdev = faux_device_create("psci-cpuidle", NULL, &psci_cpuidle_ops); | |
| 485 | - | if (!fdev) { | |
| 486 | - | pr_err("Failed to create psci-cpuidle device\n"); | |
| 487 | - | return -ENODEV; | |
| 474 | + | pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0); | |
| 475 | + | if (IS_ERR(pdev)) { | |
| 476 | + | platform_driver_unregister(&psci_cpuidle_driver); | |
| 477 | + | return PTR_ERR(pdev); | |
| 488 | 478 | } | |
| 489 | 479 | ||
| 490 | 480 | return 0; | |
modified drivers/cpuidle/dt_idle_genpd.c
| @@ -99,7 +99,7 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np, | |||
| 99 | 99 | if (!pd) | |
| 100 | 100 | goto out; | |
| 101 | 101 | ||
| 102 | - | pd->name = kasprintf(GFP_KERNEL, "%pOF", np); | |
| 102 | + | pd->name = kstrdup(kbasename(of_node_full_name(np)), GFP_KERNEL); | |
| 103 | 103 | if (!pd->name) | |
| 104 | 104 | goto free_pd; | |
| 105 | 105 | ||
| @@ -112,7 +112,6 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np, | |||
| 112 | 112 | goto free_name; | |
| 113 | 113 | ||
| 114 | 114 | pd->free_states = pd_free_states; | |
| 115 | - | pd->name = kbasename(pd->name); | |
| 116 | 115 | pd->states = states; | |
| 117 | 116 | pd->state_count = state_count; | |
| 118 | 117 | ||
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/crypto/inside-secure/eip93/eip93-common.c
| @@ -533,7 +533,7 @@ int eip93_send_req(struct crypto_async_request *async, | |||
| 533 | 533 | ||
| 534 | 534 | memcpy(iv, reqiv, rctx->ivsize); | |
| 535 | 535 | ||
| 536 | - | rctx->sa_state = kzalloc(sizeof(*rctx->sa_state), GFP_KERNEL); | |
| 536 | + | rctx->sa_state = kzalloc_obj(*rctx->sa_state); | |
| 537 | 537 | if (!rctx->sa_state) | |
| 538 | 538 | return -ENOMEM; | |
| 539 | 539 | ||
| @@ -561,8 +561,7 @@ int eip93_send_req(struct crypto_async_request *async, | |||
| 561 | 561 | iv[3] = 0xffffffff; | |
| 562 | 562 | crypto_inc((u8 *)iv, AES_BLOCK_SIZE); | |
| 563 | 563 | ||
| 564 | - | rctx->sa_state_ctr = kzalloc(sizeof(*rctx->sa_state_ctr), | |
| 565 | - | GFP_KERNEL); | |
| 564 | + | rctx->sa_state_ctr = kzalloc_obj(*rctx->sa_state_ctr); | |
| 566 | 565 | if (!rctx->sa_state_ctr) { | |
| 567 | 566 | err = -ENOMEM; | |
| 568 | 567 | goto free_sa_state; | |
modified drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
| @@ -59,8 +59,7 @@ static void *qat_zstd_alloc_scratch(void) | |||
| 59 | 59 | if (!scratch->literals) | |
| 60 | 60 | goto error; | |
| 61 | 61 | ||
| 62 | - | scratch->out_seqs = kvcalloc(QAT_MAX_SEQUENCES, sizeof(ZSTD_Sequence), | |
| 63 | - | GFP_KERNEL); | |
| 62 | + | scratch->out_seqs = kvzalloc_objs(ZSTD_Sequence, QAT_MAX_SEQUENCES); | |
| 64 | 63 | if (!scratch->out_seqs) | |
| 65 | 64 | goto error; | |
| 66 | 65 | ||
modified drivers/crypto/ti/dthev2-aes.c
| @@ -387,7 +387,7 @@ static int dthe_aes_run(struct crypto_engine *engine, void *areq) | |||
| 387 | 387 | src_nents++; | |
| 388 | 388 | dst_nents++; | |
| 389 | 389 | ||
| 390 | - | src = kmalloc_array(src_nents, sizeof(*src), GFP_ATOMIC); | |
| 390 | + | src = kmalloc_objs(*src, src_nents, GFP_ATOMIC); | |
| 391 | 391 | if (!src) { | |
| 392 | 392 | ret = -ENOMEM; | |
| 393 | 393 | goto aes_ctr_src_alloc_err; | |
| @@ -399,7 +399,7 @@ static int dthe_aes_run(struct crypto_engine *engine, void *areq) | |||
| 399 | 399 | sg_set_buf(sg, pad_buf, pad_size); | |
| 400 | 400 | ||
| 401 | 401 | if (diff_dst) { | |
| 402 | - | dst = kmalloc_array(dst_nents, sizeof(*dst), GFP_ATOMIC); | |
| 402 | + | dst = kmalloc_objs(*dst, dst_nents, GFP_ATOMIC); | |
| 403 | 403 | if (!dst) { | |
| 404 | 404 | ret = -ENOMEM; | |
| 405 | 405 | goto aes_ctr_dst_alloc_err; | |
| @@ -624,7 +624,7 @@ static struct scatterlist *dthe_aead_prep_aad(struct scatterlist *sg, | |||
| 624 | 624 | if (assoclen % AES_BLOCK_SIZE) | |
| 625 | 625 | aad_nents++; | |
| 626 | 626 | ||
| 627 | - | aad_sg = kmalloc_array(aad_nents, sizeof(struct scatterlist), GFP_ATOMIC); | |
| 627 | + | aad_sg = kmalloc_objs(struct scatterlist, aad_nents, GFP_ATOMIC); | |
| 628 | 628 | if (!aad_sg) | |
| 629 | 629 | return ERR_PTR(-ENOMEM); | |
| 630 | 630 | ||
| @@ -680,7 +680,7 @@ static struct scatterlist *dthe_aead_prep_crypt(struct scatterlist *sg, | |||
| 680 | 680 | if (cryptlen % AES_BLOCK_SIZE) | |
| 681 | 681 | crypt_nents++; | |
| 682 | 682 | ||
| 683 | - | crypt_sg = kmalloc_array(crypt_nents, sizeof(struct scatterlist), GFP_ATOMIC); | |
| 683 | + | crypt_sg = kmalloc_objs(struct scatterlist, crypt_nents, GFP_ATOMIC); | |
| 684 | 684 | if (!crypt_sg) { | |
| 685 | 685 | err = -ENOMEM; | |
| 686 | 686 | goto dthe_aead_prep_crypt_mem_err; | |
modified drivers/devfreq/hisi_uncore_freq.c
| @@ -474,7 +474,7 @@ static int hisi_uncore_mark_related_cpus(struct hisi_uncore_freq *uncore, | |||
| 474 | 474 | return -EINVAL; | |
| 475 | 475 | ||
| 476 | 476 | len = rc; | |
| 477 | - | u32 *num __free(kfree) = kcalloc(len, sizeof(*num), GFP_KERNEL); | |
| 477 | + | u32 *num __free(kfree) = kzalloc_objs(*num, len); | |
| 478 | 478 | if (!num) | |
| 479 | 479 | return -ENOMEM; | |
| 480 | 480 | ||
modified drivers/dibs/dibs_main.c
| @@ -251,13 +251,19 @@ static int __init dibs_init(void) | |||
| 251 | 251 | ||
| 252 | 252 | rc = class_register(&dibs_class); | |
| 253 | 253 | if (rc) | |
| 254 | - | return rc; | |
| 254 | + | goto err; | |
| 255 | 255 | ||
| 256 | 256 | rc = dibs_loopback_init(); | |
| 257 | 257 | if (rc) | |
| 258 | - | pr_err("%s fails with %d\n", __func__, rc); | |
| 258 | + | goto err_unregister; | |
| 259 | 259 | ||
| 260 | 260 | return rc; | |
| 261 | + | ||
| 262 | + | err_unregister: | |
| 263 | + | class_unregister(&dibs_class); | |
| 264 | + | err: | |
| 265 | + | pr_err("%s fails with %d\n", __func__, rc); | |
| 266 | + | return rc; | |
| 261 | 267 | } | |
| 262 | 268 | ||
| 263 | 269 | static void __exit dibs_exit(void) | |
modified drivers/dma-buf/Kconfig
| @@ -43,7 +43,7 @@ config UDMABUF | |||
| 43 | 43 | config DMABUF_DEBUG | |
| 44 | 44 | bool "DMA-BUF debug checks" | |
| 45 | 45 | depends on DMA_SHARED_BUFFER | |
| 46 | - | default y if DEBUG | |
| 46 | + | default y if DEBUG_KERNEL | |
| 47 | 47 | help | |
| 48 | 48 | This option enables additional checks for DMA-BUF importers and | |
| 49 | 49 | exporters. Specifically it validates that importers do not peek at the | |
modified drivers/dma-buf/dma-buf-mapping.c
| @@ -5,16 +5,18 @@ | |||
| 5 | 5 | */ | |
| 6 | 6 | #include <linux/dma-buf-mapping.h> | |
| 7 | 7 | #include <linux/dma-resv.h> | |
| 8 | + | #include <linux/overflow.h> | |
| 9 | + | #include <linux/align.h> | |
| 10 | + | ||
| 11 | + | #define MAX_SG_ENT_SZ ALIGN_DOWN(UINT_MAX, PAGE_SIZE) | |
| 8 | 12 | ||
| 9 | 13 | static struct scatterlist *fill_sg_entry(struct scatterlist *sgl, size_t length, | |
| 10 | 14 | dma_addr_t addr) | |
| 11 | 15 | { | |
| 12 | - | unsigned int len, nents; | |
| 13 | - | int i; | |
| 16 | + | size_t len; | |
| 14 | 17 | ||
| 15 | - | nents = DIV_ROUND_UP(length, UINT_MAX); | |
| 16 | - | for (i = 0; i < nents; i++) { | |
| 17 | - | len = min_t(size_t, length, UINT_MAX); | |
| 18 | + | while (length) { | |
| 19 | + | len = min(length, MAX_SG_ENT_SZ); | |
| 18 | 20 | length -= len; | |
| 19 | 21 | /* | |
| 20 | 22 | * DMABUF abuses scatterlist to create a scatterlist | |
| @@ -24,8 +26,10 @@ static struct scatterlist *fill_sg_entry(struct scatterlist *sgl, size_t length, | |||
| 24 | 26 | * does not require the CPU list for mapping or unmapping. | |
| 25 | 27 | */ | |
| 26 | 28 | sg_set_page(sgl, NULL, 0, 0); | |
| 27 | - | sg_dma_address(sgl) = addr + (dma_addr_t)i * UINT_MAX; | |
| 29 | + | sg_dma_address(sgl) = addr; | |
| 28 | 30 | sg_dma_len(sgl) = len; | |
| 31 | + | addr += len; | |
| 32 | + | /* Unconditionally advance. On last segment, this becomes NULL */ | |
| 29 | 33 | sgl = sg_next(sgl); | |
| 30 | 34 | } | |
| 31 | 35 | ||
| @@ -40,15 +44,19 @@ static unsigned int calc_sg_nents(struct dma_iova_state *state, | |||
| 40 | 44 | size_t i; | |
| 41 | 45 | ||
| 42 | 46 | if (!state || !dma_use_iova(state)) { | |
| 43 | - | for (i = 0; i < nr_ranges; i++) | |
| 44 | - | nents += DIV_ROUND_UP(phys_vec[i].len, UINT_MAX); | |
| 47 | + | for (i = 0; i < nr_ranges; i++) { | |
| 48 | + | unsigned int added = DIV_ROUND_UP(phys_vec[i].len, MAX_SG_ENT_SZ); | |
| 49 | + | ||
| 50 | + | if (check_add_overflow(nents, added, &nents)) | |
| 51 | + | return 0; | |
| 52 | + | } | |
| 45 | 53 | } else { | |
| 46 | 54 | /* | |
| 47 | 55 | * In IOVA case, there is only one SG entry which spans | |
| 48 | 56 | * for whole IOVA address space, but we need to make sure | |
| 49 | 57 | * that it fits sg->length, maybe we need more. | |
| 50 | 58 | */ | |
| 51 | - | nents = DIV_ROUND_UP(size, UINT_MAX); | |
| 59 | + | nents = DIV_ROUND_UP(size, MAX_SG_ENT_SZ); | |
| 52 | 60 | } | |
| 53 | 61 | ||
| 54 | 62 | return nents; | |
| @@ -95,9 +103,10 @@ struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach, | |||
| 95 | 103 | size_t nr_ranges, size_t size, | |
| 96 | 104 | enum dma_data_direction dir) | |
| 97 | 105 | { | |
| 98 | - | unsigned int nents, mapped_len = 0; | |
| 99 | 106 | struct dma_buf_dma *dma; | |
| 100 | 107 | struct scatterlist *sgl; | |
| 108 | + | size_t mapped_len = 0; | |
| 109 | + | unsigned int nents; | |
| 101 | 110 | dma_addr_t addr; | |
| 102 | 111 | size_t i; | |
| 103 | 112 | int ret; | |
| @@ -133,6 +142,8 @@ struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach, | |||
| 133 | 142 | } | |
| 134 | 143 | ||
| 135 | 144 | nents = calc_sg_nents(dma->state, phys_vec, nr_ranges, size); | |
| 145 | + | ||
| 146 | + | /* sg_alloc_table will cleanly fail and return -EINVAL if nents == 0 */ | |
| 136 | 147 | ret = sg_alloc_table(&dma->sgt, nents, GFP_KERNEL | __GFP_ZERO); | |
| 137 | 148 | if (ret) | |
| 138 | 149 | goto err_free_state; | |
modified drivers/dma-buf/dma-buf.c
| @@ -803,6 +803,26 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags) | |||
| 803 | 803 | } | |
| 804 | 804 | EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF"); | |
| 805 | 805 | ||
| 806 | + | /** | |
| 807 | + | * dma_buf_fd_install - install a reserved fd for a dma-buf | |
| 808 | + | * @dmabuf: [in] pointer to dma_buf | |
| 809 | + | * @fd: [in] fd reserved with get_unused_fd_flags() | |
| 810 | + | * | |
| 811 | + | * Publishes a previously reserved fd into the caller's fd table. | |
| 812 | + | * Must only be called after all fallible work (e.g. copy_to_user) | |
| 813 | + | * has succeeded, as it cannot be undone safely once called. | |
| 814 | + | * | |
| 815 | + | * The caller is responsible for having emitted the trace event | |
| 816 | + | * (via dma_buf_fd() or get_unused_fd_flags() + this function) | |
| 817 | + | * before calling this. | |
| 818 | + | */ | |
| 819 | + | void dma_buf_fd_install(struct dma_buf *dmabuf, int fd) | |
| 820 | + | { | |
| 821 | + | DMA_BUF_TRACE(trace_dma_buf_fd, dmabuf, fd); | |
| 822 | + | fd_install(fd, dmabuf->file); | |
| 823 | + | } | |
| 824 | + | EXPORT_SYMBOL_NS_GPL(dma_buf_fd_install, "DMA_BUF"); | |
| 825 | + | ||
| 806 | 826 | /** | |
| 807 | 827 | * dma_buf_get - returns the struct dma_buf related to an fd | |
| 808 | 828 | * @fd: [in] fd associated with the struct dma_buf to be returned | |
modified drivers/dma-buf/dma-fence.c
| @@ -1170,7 +1170,12 @@ const char __rcu *dma_fence_driver_name(struct dma_fence *fence) | |||
| 1170 | 1170 | ||
| 1171 | 1171 | /* RCU protection is required for safe access to returned string */ | |
| 1172 | 1172 | ops = rcu_dereference(fence->ops); | |
| 1173 | - | if (ops) | |
| 1173 | + | ||
| 1174 | + | /* | |
| 1175 | + | * Make load ordering irrelevant by checking both signaled state and ops | |
| 1176 | + | * pointer and ops pointer is only set to NULL on newer implementations. | |
| 1177 | + | */ | |
| 1178 | + | if (!dma_fence_test_signaled_flag(fence) && ops) | |
| 1174 | 1179 | return (const char __rcu *)ops->get_driver_name(fence); | |
| 1175 | 1180 | else | |
| 1176 | 1181 | return (const char __rcu *)"detached-driver"; | |
| @@ -1203,7 +1208,12 @@ const char __rcu *dma_fence_timeline_name(struct dma_fence *fence) | |||
| 1203 | 1208 | ||
| 1204 | 1209 | /* RCU protection is required for safe access to returned string */ | |
| 1205 | 1210 | ops = rcu_dereference(fence->ops); | |
| 1206 | - | if (ops) | |
| 1211 | + | ||
| 1212 | + | /* | |
| 1213 | + | * Make load ordering irrelevant by checking both signaled state and ops | |
| 1214 | + | * pointer and ops pointer is only set to NULL on newer implementations. | |
| 1215 | + | */ | |
| 1216 | + | if (!dma_fence_test_signaled_flag(fence) && ops) | |
| 1207 | 1217 | return (const char __rcu *)ops->get_timeline_name(fence); | |
| 1208 | 1218 | else | |
| 1209 | 1219 | return (const char __rcu *)"signaled-timeline"; | |
modified drivers/dma-buf/dma-heap.c
| @@ -56,33 +56,6 @@ MODULE_PARM_DESC(mem_accounting, | |||
| 56 | 56 | "Enable cgroup-based memory accounting for dma-buf heap allocations (default=false)."); | |
| 57 | 57 | EXPORT_SYMBOL_NS_GPL(mem_accounting, "DMA_BUF_HEAP"); | |
| 58 | 58 | ||
| 59 | - | static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, | |
| 60 | - | u32 fd_flags, | |
| 61 | - | u64 heap_flags) | |
| 62 | - | { | |
| 63 | - | struct dma_buf *dmabuf; | |
| 64 | - | int fd; | |
| 65 | - | ||
| 66 | - | /* | |
| 67 | - | * Allocations from all heaps have to begin | |
| 68 | - | * and end on page boundaries. | |
| 69 | - | */ | |
| 70 | - | len = PAGE_ALIGN(len); | |
| 71 | - | if (!len) | |
| 72 | - | return -EINVAL; | |
| 73 | - | ||
| 74 | - | dmabuf = heap->ops->allocate(heap, len, fd_flags, heap_flags); | |
| 75 | - | if (IS_ERR(dmabuf)) | |
| 76 | - | return PTR_ERR(dmabuf); | |
| 77 | - | ||
| 78 | - | fd = dma_buf_fd(dmabuf, fd_flags); | |
| 79 | - | if (fd < 0) { | |
| 80 | - | dma_buf_put(dmabuf); | |
| 81 | - | /* just return, as put will call release and that will free */ | |
| 82 | - | } | |
| 83 | - | return fd; | |
| 84 | - | } | |
| 85 | - | ||
| 86 | 59 | static int dma_heap_open(struct inode *inode, struct file *file) | |
| 87 | 60 | { | |
| 88 | 61 | struct dma_heap *heap; | |
| @@ -100,30 +73,42 @@ static int dma_heap_open(struct inode *inode, struct file *file) | |||
| 100 | 73 | return 0; | |
| 101 | 74 | } | |
| 102 | 75 | ||
| 103 | - | static long dma_heap_ioctl_allocate(struct file *file, void *data) | |
| 76 | + | static struct dma_buf *dma_heap_ioctl_allocate(struct file *file, void *data) | |
| 104 | 77 | { | |
| 105 | 78 | struct dma_heap_allocation_data *heap_allocation = data; | |
| 106 | 79 | struct dma_heap *heap = file->private_data; | |
| 80 | + | struct dma_buf *dmabuf; | |
| 107 | 81 | int fd; | |
| 82 | + | size_t len; | |
| 108 | 83 | ||
| 109 | 84 | if (heap_allocation->fd) | |
| 110 | - | return -EINVAL; | |
| 85 | + | return ERR_PTR(-EINVAL); | |
| 111 | 86 | ||
| 112 | 87 | if (heap_allocation->fd_flags & ~DMA_HEAP_VALID_FD_FLAGS) | |
| 113 | - | return -EINVAL; | |
| 88 | + | return ERR_PTR(-EINVAL); | |
| 114 | 89 | ||
| 115 | 90 | if (heap_allocation->heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS) | |
| 116 | - | return -EINVAL; | |
| 91 | + | return ERR_PTR(-EINVAL); | |
| 92 | + | ||
| 93 | + | len = PAGE_ALIGN(heap_allocation->len); | |
| 94 | + | if (!len) | |
| 95 | + | return ERR_PTR(-EINVAL); | |
| 96 | + | ||
| 97 | + | dmabuf = heap->ops->allocate(heap, len, heap_allocation->fd_flags, | |
| 98 | + | heap_allocation->heap_flags); | |
| 117 | 99 | ||
| 118 | - | fd = dma_heap_buffer_alloc(heap, heap_allocation->len, | |
| 119 | - | heap_allocation->fd_flags, | |
| 120 | - | heap_allocation->heap_flags); | |
| 121 | - | if (fd < 0) | |
| 122 | - | return fd; | |
| 100 | + | if (IS_ERR(dmabuf)) | |
| 101 | + | return dmabuf; | |
| 102 | + | ||
| 103 | + | fd = get_unused_fd_flags(heap_allocation->fd_flags); | |
| 104 | + | if (fd < 0) { | |
| 105 | + | dma_buf_put(dmabuf); | |
| 106 | + | return ERR_PTR(fd); | |
| 107 | + | } | |
| 123 | 108 | ||
| 124 | 109 | heap_allocation->fd = fd; | |
| 125 | 110 | ||
| 126 | - | return 0; | |
| 111 | + | return dmabuf; | |
| 127 | 112 | } | |
| 128 | 113 | ||
| 129 | 114 | static unsigned int dma_heap_ioctl_cmds[] = { | |
| @@ -139,6 +124,8 @@ static long dma_heap_ioctl(struct file *file, unsigned int ucmd, | |||
| 139 | 124 | unsigned int in_size, out_size, drv_size, ksize; | |
| 140 | 125 | int nr = _IOC_NR(ucmd); | |
| 141 | 126 | int ret = 0; | |
| 127 | + | int fd; | |
| 128 | + | struct dma_buf *dmabuf; | |
| 142 | 129 | ||
| 143 | 130 | if (nr >= ARRAY_SIZE(dma_heap_ioctl_cmds)) | |
| 144 | 131 | return -EINVAL; | |
| @@ -175,15 +162,28 @@ static long dma_heap_ioctl(struct file *file, unsigned int ucmd, | |||
| 175 | 162 | ||
| 176 | 163 | switch (kcmd) { | |
| 177 | 164 | case DMA_HEAP_IOCTL_ALLOC: | |
| 178 | - | ret = dma_heap_ioctl_allocate(file, kdata); | |
| 165 | + | dmabuf = dma_heap_ioctl_allocate(file, kdata); | |
| 166 | + | ||
| 167 | + | if (IS_ERR(dmabuf)) { | |
| 168 | + | ret = PTR_ERR(dmabuf); | |
| 169 | + | break; | |
| 170 | + | } | |
| 171 | + | ||
| 172 | + | fd = ((struct dma_heap_allocation_data *)kdata)->fd; | |
| 173 | + | if (copy_to_user((void __user *)arg, kdata, out_size) != 0) { | |
| 174 | + | put_unused_fd(fd); | |
| 175 | + | dma_buf_put(dmabuf); | |
| 176 | + | ret = -EFAULT; | |
| 177 | + | } else { | |
| 178 | + | dma_buf_fd_install(dmabuf, fd); | |
| 179 | + | } | |
| 180 | + | ||
| 179 | 181 | break; | |
| 180 | 182 | default: | |
| 181 | 183 | ret = -ENOTTY; | |
| 182 | 184 | goto err; | |
| 183 | 185 | } | |
| 184 | 186 | ||
| 185 | - | if (copy_to_user((void __user *)arg, kdata, out_size) != 0) | |
| 186 | - | ret = -EFAULT; | |
| 187 | 187 | err: | |
| 188 | 188 | if (kdata != stack_kdata) | |
| 189 | 189 | kfree(kdata); | |
modified drivers/dma-buf/st-dma-fence.c
| @@ -27,7 +27,7 @@ static struct dma_fence *mock_fence(void) | |||
| 27 | 27 | { | |
| 28 | 28 | struct dma_fence *f; | |
| 29 | 29 | ||
| 30 | - | f = kmalloc(sizeof(*f), GFP_KERNEL); | |
| 30 | + | f = kmalloc_obj(*f); | |
| 31 | 31 | if (!f) | |
| 32 | 32 | return NULL; | |
| 33 | 33 | ||
modified drivers/dma-buf/udmabuf.c
| @@ -359,7 +359,7 @@ static long udmabuf_create(struct miscdevice *device, | |||
| 359 | 359 | long ret = -EINVAL; | |
| 360 | 360 | u32 i, flags; | |
| 361 | 361 | ||
| 362 | - | ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL); | |
| 362 | + | ubuf = kzalloc_obj(*ubuf); | |
| 363 | 363 | if (!ubuf) | |
| 364 | 364 | return -ENOMEM; | |
| 365 | 365 | ||
| @@ -387,7 +387,7 @@ static long udmabuf_create(struct miscdevice *device, | |||
| 387 | 387 | if (ret) | |
| 388 | 388 | goto err; | |
| 389 | 389 | ||
| 390 | - | folios = kvmalloc_array(max_nr_folios, sizeof(*folios), GFP_KERNEL); | |
| 390 | + | folios = kvmalloc_objs(*folios, max_nr_folios); | |
| 391 | 391 | if (!folios) { | |
| 392 | 392 | ret = -ENOMEM; | |
| 393 | 393 | goto err; | |
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/switchtec_dma.c
| @@ -1056,7 +1056,7 @@ static int switchtec_dma_chan_init(struct switchtec_dma_dev *swdma_dev, | |||
| 1056 | 1056 | int se_buf_len, irq, rc; | |
| 1057 | 1057 | struct dma_chan *chan; | |
| 1058 | 1058 | ||
| 1059 | - | swdma_chan = kzalloc_obj(*swdma_chan, GFP_KERNEL); | |
| 1059 | + | swdma_chan = kzalloc_obj(*swdma_chan); | |
| 1060 | 1060 | if (!swdma_chan) | |
| 1061 | 1061 | return -ENOMEM; | |
| 1062 | 1062 | ||
| @@ -1162,8 +1162,7 @@ static int switchtec_dma_chans_enumerate(struct switchtec_dma_dev *swdma_dev, | |||
| 1162 | 1162 | struct dma_device *dma = &swdma_dev->dma_dev; | |
| 1163 | 1163 | int base, cnt, rc, i; | |
| 1164 | 1164 | ||
| 1165 | - | swdma_dev->swdma_chans = kcalloc(chan_cnt, sizeof(*swdma_dev->swdma_chans), | |
| 1166 | - | GFP_KERNEL); | |
| 1165 | + | swdma_dev->swdma_chans = kzalloc_objs(*swdma_dev->swdma_chans, chan_cnt); | |
| 1167 | 1166 | ||
| 1168 | 1167 | if (!swdma_dev->swdma_chans) | |
| 1169 | 1168 | return -ENOMEM; | |
| @@ -1222,7 +1221,7 @@ static int switchtec_dma_create(struct pci_dev *pdev) | |||
| 1222 | 1221 | /* | |
| 1223 | 1222 | * Create the switchtec dma device | |
| 1224 | 1223 | */ | |
| 1225 | - | swdma_dev = kzalloc_obj(*swdma_dev, GFP_KERNEL); | |
| 1224 | + | swdma_dev = kzalloc_obj(*swdma_dev); | |
| 1226 | 1225 | if (!swdma_dev) | |
| 1227 | 1226 | return -ENOMEM; | |
| 1228 | 1227 | ||
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/al_mc_edac.c
| @@ -302,12 +302,8 @@ static int al_mc_edac_probe(struct platform_device *pdev) | |||
| 302 | 302 | IRQF_SHARED, | |
| 303 | 303 | pdev->name, | |
| 304 | 304 | pdev); | |
| 305 | - | if (ret != 0) { | |
| 306 | - | dev_err(&pdev->dev, | |
| 307 | - | "failed to request UE IRQ %d (%d)\n", | |
| 308 | - | al_mc->irq_ue, ret); | |
| 305 | + | if (ret != 0) | |
| 309 | 306 | return ret; | |
| 310 | - | } | |
| 311 | 307 | } | |
| 312 | 308 | ||
| 313 | 309 | if (al_mc->irq_ce > 0) { | |
| @@ -317,12 +313,8 @@ static int al_mc_edac_probe(struct platform_device *pdev) | |||
| 317 | 313 | IRQF_SHARED, | |
| 318 | 314 | pdev->name, | |
| 319 | 315 | pdev); | |
| 320 | - | if (ret != 0) { | |
| 321 | - | dev_err(&pdev->dev, | |
| 322 | - | "failed to request CE IRQ %d (%d)\n", | |
| 323 | - | al_mc->irq_ce, ret); | |
| 316 | + | if (ret != 0) | |
| 324 | 317 | return ret; | |
| 325 | - | } | |
| 326 | 318 | } | |
| 327 | 319 | ||
| 328 | 320 | return 0; | |
modified drivers/edac/altera_edac.c
| @@ -1507,6 +1507,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1507 | 1507 | int edac_idx, rc; | |
| 1508 | 1508 | struct device_node *np; | |
| 1509 | 1509 | const struct edac_device_prv_data *prv = &a10_sdmmceccb_data; | |
| 1510 | + | bool is_s10 = device->edac->is_s10; | |
| 1510 | 1511 | ||
| 1511 | 1512 | rc = altr_check_ecc_deps(device); | |
| 1512 | 1513 | if (rc) | |
| @@ -1533,7 +1534,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1533 | 1534 | altdev = dci->pvt_info; | |
| 1534 | 1535 | *altdev = *device; | |
| 1535 | 1536 | ||
| 1536 | - | if (!devres_open_group(&altdev->ddev, altr_portb_setup, GFP_KERNEL)) | |
| 1537 | + | if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL)) | |
| 1537 | 1538 | return -ENOMEM; | |
| 1538 | 1539 | ||
| 1539 | 1540 | /* Update PortB specific values */ | |
| @@ -1548,21 +1549,20 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1548 | 1549 | ||
| 1549 | 1550 | /* | |
| 1550 | 1551 | * Update the PortB IRQs - A10 has 4, S10 has 2, Index accordingly | |
| 1551 | - | * | |
| 1552 | - | * FIXME: Instead of ifdefs with different architectures the driver | |
| 1553 | - | * should properly use compatibles. | |
| 1554 | 1552 | */ | |
| 1555 | - | #ifdef CONFIG_64BIT | |
| 1556 | - | altdev->sb_irq = irq_of_parse_and_map(np, 1); | |
| 1557 | - | #else | |
| 1558 | - | altdev->sb_irq = irq_of_parse_and_map(np, 2); | |
| 1559 | - | #endif | |
| 1553 | + | ||
| 1554 | + | /* Using compatibles to determine the IRQ Index */ | |
| 1555 | + | if (is_s10) | |
| 1556 | + | altdev->sb_irq = irq_of_parse_and_map(np, 1); | |
| 1557 | + | else | |
| 1558 | + | altdev->sb_irq = irq_of_parse_and_map(np, 2); | |
| 1559 | + | ||
| 1560 | 1560 | if (!altdev->sb_irq) { | |
| 1561 | 1561 | edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB SBIRQ alloc\n"); | |
| 1562 | 1562 | rc = -ENODEV; | |
| 1563 | 1563 | goto err_release_group_1; | |
| 1564 | 1564 | } | |
| 1565 | - | rc = devm_request_irq(&altdev->ddev, altdev->sb_irq, | |
| 1565 | + | rc = devm_request_irq(device->edac->dev, altdev->sb_irq, | |
| 1566 | 1566 | prv->ecc_irq_handler, IRQF_TRIGGER_HIGH, | |
| 1567 | 1567 | ecc_name, altdev); | |
| 1568 | 1568 | if (rc) { | |
| @@ -1570,29 +1570,28 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1570 | 1570 | goto err_release_group_1; | |
| 1571 | 1571 | } | |
| 1572 | 1572 | ||
| 1573 | - | #ifdef CONFIG_64BIT | |
| 1574 | - | /* Use IRQ to determine SError origin instead of assigning IRQ */ | |
| 1575 | - | rc = of_property_read_u32_index(np, "interrupts", 1, &altdev->db_irq); | |
| 1576 | - | if (rc) { | |
| 1577 | - | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 1578 | - | "Error PortB DBIRQ alloc\n"); | |
| 1579 | - | goto err_release_group_1; | |
| 1580 | - | } | |
| 1581 | - | #else | |
| 1582 | - | altdev->db_irq = irq_of_parse_and_map(np, 3); | |
| 1583 | - | if (!altdev->db_irq) { | |
| 1584 | - | edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB DBIRQ alloc\n"); | |
| 1585 | - | rc = -ENODEV; | |
| 1586 | - | goto err_release_group_1; | |
| 1587 | - | } | |
| 1588 | - | rc = devm_request_irq(&altdev->ddev, altdev->db_irq, | |
| 1589 | - | prv->ecc_irq_handler, IRQF_TRIGGER_HIGH, | |
| 1590 | - | ecc_name, altdev); | |
| 1591 | - | if (rc) { | |
| 1592 | - | edac_printk(KERN_ERR, EDAC_DEVICE, "PortB DBERR IRQ error\n"); | |
| 1593 | - | goto err_release_group_1; | |
| 1573 | + | if (is_s10) { | |
| 1574 | + | /* Use IRQ to determine SError origin instead of assigning IRQ */ | |
| 1575 | + | rc = of_property_read_u32_index(np, "interrupts", 1, &altdev->db_irq); | |
| 1576 | + | if (rc) { | |
| 1577 | + | edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB DBIRQ alloc\n"); | |
| 1578 | + | goto err_release_group_1; | |
| 1579 | + | } | |
| 1580 | + | } else { | |
| 1581 | + | altdev->db_irq = irq_of_parse_and_map(np, 3); | |
| 1582 | + | if (!altdev->db_irq) { | |
| 1583 | + | edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB DBIRQ alloc\n"); | |
| 1584 | + | rc = -ENODEV; | |
| 1585 | + | goto err_release_group_1; | |
| 1586 | + | } | |
| 1587 | + | rc = devm_request_irq(device->edac->dev, altdev->db_irq, | |
| 1588 | + | prv->ecc_irq_handler, IRQF_TRIGGER_HIGH, | |
| 1589 | + | ecc_name, altdev); | |
| 1590 | + | if (rc) { | |
| 1591 | + | edac_printk(KERN_ERR, EDAC_DEVICE, "PortB DBERR IRQ error\n"); | |
| 1592 | + | goto err_release_group_1; | |
| 1593 | + | } | |
| 1594 | 1594 | } | |
| 1595 | - | #endif | |
| 1596 | 1595 | ||
| 1597 | 1596 | rc = edac_device_add_device(dci); | |
| 1598 | 1597 | if (rc) { | |
| @@ -1605,13 +1604,13 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1605 | 1604 | ||
| 1606 | 1605 | list_add(&altdev->next, &altdev->edac->a10_ecc_devices); | |
| 1607 | 1606 | ||
| 1608 | - | devres_remove_group(&altdev->ddev, altr_portb_setup); | |
| 1607 | + | devres_remove_group(device->edac->dev, altr_portb_setup); | |
| 1609 | 1608 | ||
| 1610 | 1609 | return 0; | |
| 1611 | 1610 | ||
| 1612 | 1611 | err_release_group_1: | |
| 1613 | 1612 | edac_device_free_ctl_info(dci); | |
| 1614 | - | devres_release_group(&altdev->ddev, altr_portb_setup); | |
| 1613 | + | devres_release_group(device->edac->dev, altr_portb_setup); | |
| 1615 | 1614 | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 1616 | 1615 | "%s:Error setting up EDAC device: %d\n", ecc_name, rc); | |
| 1617 | 1616 | return rc; | |
| @@ -1974,29 +1973,29 @@ static int altr_edac_a10_device_add(struct altr_arria10_edac *edac, | |||
| 1974 | 1973 | goto err_release_group1; | |
| 1975 | 1974 | } | |
| 1976 | 1975 | ||
| 1977 | - | #ifdef CONFIG_64BIT | |
| 1978 | - | /* Use IRQ to determine SError origin instead of assigning IRQ */ | |
| 1979 | - | rc = of_property_read_u32_index(np, "interrupts", 0, &altdev->db_irq); | |
| 1980 | - | if (rc) { | |
| 1981 | - | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 1982 | - | "Unable to parse DB IRQ index\n"); | |
| 1983 | - | goto err_release_group1; | |
| 1984 | - | } | |
| 1985 | - | #else | |
| 1986 | - | altdev->db_irq = irq_of_parse_and_map(np, 1); | |
| 1987 | - | if (!altdev->db_irq) { | |
| 1988 | - | edac_printk(KERN_ERR, EDAC_DEVICE, "Error allocating DBIRQ\n"); | |
| 1989 | - | rc = -ENODEV; | |
| 1990 | - | goto err_release_group1; | |
| 1991 | - | } | |
| 1992 | - | rc = devm_request_irq(edac->dev, altdev->db_irq, prv->ecc_irq_handler, | |
| 1993 | - | IRQF_TRIGGER_HIGH, | |
| 1994 | - | ecc_name, altdev); | |
| 1995 | - | if (rc) { | |
| 1996 | - | edac_printk(KERN_ERR, EDAC_DEVICE, "No DBERR IRQ resource\n"); | |
| 1997 | - | goto err_release_group1; | |
| 1976 | + | if (edac->is_s10) { | |
| 1977 | + | /* Use IRQ to determine SError origin instead of assigning IRQ */ | |
| 1978 | + | rc = of_property_read_u32_index(np, "interrupts", 0, &altdev->db_irq); | |
| 1979 | + | if (rc) { | |
| 1980 | + | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 1981 | + | "Unable to parse DB IRQ index\n"); | |
| 1982 | + | goto err_release_group1; | |
| 1983 | + | } | |
| 1984 | + | } else { | |
| 1985 | + | altdev->db_irq = irq_of_parse_and_map(np, 1); | |
| 1986 | + | if (!altdev->db_irq) { | |
| 1987 | + | edac_printk(KERN_ERR, EDAC_DEVICE, "Error allocating DBIRQ\n"); | |
| 1988 | + | rc = -ENODEV; | |
| 1989 | + | goto err_release_group1; | |
| 1990 | + | } | |
| 1991 | + | rc = devm_request_irq(edac->dev, altdev->db_irq, prv->ecc_irq_handler, | |
| 1992 | + | IRQF_TRIGGER_HIGH, | |
| 1993 | + | ecc_name, altdev); | |
| 1994 | + | if (rc) { | |
| 1995 | + | edac_printk(KERN_ERR, EDAC_DEVICE, "No DBERR IRQ resource\n"); | |
| 1996 | + | goto err_release_group1; | |
| 1997 | + | } | |
| 1998 | 1998 | } | |
| 1999 | - | #endif | |
| 2000 | 1999 | ||
| 2001 | 2000 | rc = edac_device_add_device(dci); | |
| 2002 | 2001 | if (rc) { | |
| @@ -2059,7 +2058,6 @@ static const struct irq_domain_ops a10_eccmgr_ic_ops = { | |||
| 2059 | 2058 | /************** Stratix 10 EDAC Double Bit Error Handler ************/ | |
| 2060 | 2059 | #define to_a10edac(p, m) container_of(p, struct altr_arria10_edac, m) | |
| 2061 | 2060 | ||
| 2062 | - | #ifdef CONFIG_64BIT | |
| 2063 | 2061 | /* panic routine issues reboot on non-zero panic_timeout */ | |
| 2064 | 2062 | extern int panic_timeout; | |
| 2065 | 2063 | ||
| @@ -2106,7 +2104,6 @@ static int s10_edac_dberr_handler(struct notifier_block *this, | |||
| 2106 | 2104 | ||
| 2107 | 2105 | return NOTIFY_DONE; | |
| 2108 | 2106 | } | |
| 2109 | - | #endif | |
| 2110 | 2107 | ||
| 2111 | 2108 | /****************** Arria 10 EDAC Probe Function *********************/ | |
| 2112 | 2109 | static int altr_edac_a10_probe(struct platform_device *pdev) | |
| @@ -2122,6 +2119,8 @@ static int altr_edac_a10_probe(struct platform_device *pdev) | |||
| 2122 | 2119 | platform_set_drvdata(pdev, edac); | |
| 2123 | 2120 | INIT_LIST_HEAD(&edac->a10_ecc_devices); | |
| 2124 | 2121 | ||
| 2122 | + | edac->is_s10 = !!device_get_match_data(&pdev->dev); | |
| 2123 | + | ||
| 2125 | 2124 | edac->ecc_mgr_map = | |
| 2126 | 2125 | altr_sysmgr_regmap_lookup_by_phandle(pdev->dev.of_node, | |
| 2127 | 2126 | "altr,sysmgr-syscon"); | |
| @@ -2153,8 +2152,7 @@ static int altr_edac_a10_probe(struct platform_device *pdev) | |||
| 2153 | 2152 | irq_set_chained_handler_and_data(edac->sb_irq, | |
| 2154 | 2153 | altr_edac_a10_irq_handler, | |
| 2155 | 2154 | edac); | |
| 2156 | - | ||
| 2157 | - | #ifdef CONFIG_64BIT | |
| 2155 | + | if (edac->is_s10) | |
| 2158 | 2156 | { | |
| 2159 | 2157 | int dberror, err_addr; | |
| 2160 | 2158 | ||
| @@ -2177,15 +2175,14 @@ static int altr_edac_a10_probe(struct platform_device *pdev) | |||
| 2177 | 2175 | regmap_write(edac->ecc_mgr_map, | |
| 2178 | 2176 | S10_SYSMGR_UE_ADDR_OFST, 0); | |
| 2179 | 2177 | } | |
| 2180 | - | } | |
| 2181 | - | #else | |
| 2182 | - | edac->db_irq = platform_get_irq(pdev, 1); | |
| 2183 | - | if (edac->db_irq < 0) | |
| 2184 | - | return edac->db_irq; | |
| 2178 | + | } else { | |
| 2179 | + | edac->db_irq = platform_get_irq(pdev, 1); | |
| 2180 | + | if (edac->db_irq < 0) | |
| 2181 | + | return edac->db_irq; | |
| 2185 | 2182 | ||
| 2186 | - | irq_set_chained_handler_and_data(edac->db_irq, | |
| 2187 | - | altr_edac_a10_irq_handler, edac); | |
| 2188 | - | #endif | |
| 2183 | + | irq_set_chained_handler_and_data(edac->db_irq, | |
| 2184 | + | altr_edac_a10_irq_handler, edac); | |
| 2185 | + | } | |
| 2189 | 2186 | ||
| 2190 | 2187 | for_each_child_of_node(pdev->dev.of_node, child) { | |
| 2191 | 2188 | if (!of_device_is_available(child)) | |
| @@ -2207,7 +2204,7 @@ static int altr_edac_a10_probe(struct platform_device *pdev) | |||
| 2207 | 2204 | ||
| 2208 | 2205 | static const struct of_device_id altr_edac_a10_of_match[] = { | |
| 2209 | 2206 | { .compatible = "altr,socfpga-a10-ecc-manager" }, | |
| 2210 | - | { .compatible = "altr,socfpga-s10-ecc-manager" }, | |
| 2207 | + | { .compatible = "altr,socfpga-s10-ecc-manager", .data = (void *)1 }, | |
| 2211 | 2208 | {}, | |
| 2212 | 2209 | }; | |
| 2213 | 2210 | MODULE_DEVICE_TABLE(of, altr_edac_a10_of_match); | |
modified drivers/edac/altera_edac.h
| @@ -394,6 +394,7 @@ struct altr_arria10_edac { | |||
| 394 | 394 | struct irq_chip irq_chip; | |
| 395 | 395 | struct list_head a10_ecc_devices; | |
| 396 | 396 | struct notifier_block panic_notifier; | |
| 397 | + | bool is_s10; | |
| 397 | 398 | }; | |
| 398 | 399 | ||
| 399 | 400 | #endif /* #ifndef _ALTERA_EDAC_H */ | |
modified drivers/edac/amd64_edac.c
| @@ -4173,6 +4173,8 @@ static int __init amd64_edac_init(void) | |||
| 4173 | 4173 | goto err_pci; | |
| 4174 | 4174 | } | |
| 4175 | 4175 | ||
| 4176 | + | request_module_nowait("amd_atl"); | |
| 4177 | + | ||
| 4176 | 4178 | /* register stuff with EDAC MCE */ | |
| 4177 | 4179 | if (boot_cpu_data.x86 >= 0x17) { | |
| 4178 | 4180 | amd_register_ecc_decoder(decode_umc_error); | |
modified drivers/edac/aspeed_edac.c
| @@ -214,10 +214,8 @@ static int config_irq(void *ctx, struct platform_device *pdev) | |||
| 214 | 214 | ||
| 215 | 215 | rc = devm_request_irq(&pdev->dev, irq, mcr_isr, IRQF_TRIGGER_HIGH, | |
| 216 | 216 | DRV_NAME, ctx); | |
| 217 | - | if (rc) { | |
| 218 | - | dev_err(&pdev->dev, "unable to request irq %d\n", irq); | |
| 217 | + | if (rc) | |
| 219 | 218 | return rc; | |
| 220 | - | } | |
| 221 | 219 | ||
| 222 | 220 | /* enable interrupts */ | |
| 223 | 221 | regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL, | |
modified drivers/edac/debugfs.c
| @@ -1,50 +1,9 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0-only | |
| 2 | 2 | ||
| 3 | - | #include <linux/string_choices.h> | |
| 4 | - | ||
| 5 | 3 | #include "edac_module.h" | |
| 6 | 4 | ||
| 7 | 5 | static struct dentry *edac_debugfs; | |
| 8 | 6 | ||
| 9 | - | static ssize_t edac_fake_inject_write(struct file *file, | |
| 10 | - | const char __user *data, | |
| 11 | - | size_t count, loff_t *ppos) | |
| 12 | - | { | |
| 13 | - | struct device *dev = file->private_data; | |
| 14 | - | struct mem_ctl_info *mci = to_mci(dev); | |
| 15 | - | static enum hw_event_mc_err_type type; | |
| 16 | - | u16 errcount = mci->fake_inject_count; | |
| 17 | - | ||
| 18 | - | if (!errcount) | |
| 19 | - | errcount = 1; | |
| 20 | - | ||
| 21 | - | type = mci->fake_inject_ue ? HW_EVENT_ERR_UNCORRECTED | |
| 22 | - | : HW_EVENT_ERR_CORRECTED; | |
| 23 | - | ||
| 24 | - | printk(KERN_DEBUG | |
| 25 | - | "Generating %d %s fake error%s to %d.%d.%d to test core handling. NOTE: this won't test the driver-specific decoding logic.\n", | |
| 26 | - | errcount, | |
| 27 | - | (type == HW_EVENT_ERR_UNCORRECTED) ? "UE" : "CE", | |
| 28 | - | str_plural(errcount), | |
| 29 | - | mci->fake_inject_layer[0], | |
| 30 | - | mci->fake_inject_layer[1], | |
| 31 | - | mci->fake_inject_layer[2] | |
| 32 | - | ); | |
| 33 | - | edac_mc_handle_error(type, mci, errcount, 0, 0, 0, | |
| 34 | - | mci->fake_inject_layer[0], | |
| 35 | - | mci->fake_inject_layer[1], | |
| 36 | - | mci->fake_inject_layer[2], | |
| 37 | - | "FAKE ERROR", "for EDAC testing only"); | |
| 38 | - | ||
| 39 | - | return count; | |
| 40 | - | } | |
| 41 | - | ||
| 42 | - | static const struct file_operations debug_fake_inject_fops = { | |
| 43 | - | .open = simple_open, | |
| 44 | - | .write = edac_fake_inject_write, | |
| 45 | - | .llseek = generic_file_llseek, | |
| 46 | - | }; | |
| 47 | - | ||
| 48 | 7 | void __init edac_debugfs_init(void) | |
| 49 | 8 | { | |
| 50 | 9 | edac_debugfs = debugfs_create_dir("edac", NULL); | |
| @@ -57,29 +16,7 @@ void edac_debugfs_exit(void) | |||
| 57 | 16 | ||
| 58 | 17 | void edac_create_debugfs_nodes(struct mem_ctl_info *mci) | |
| 59 | 18 | { | |
| 60 | - | struct dentry *parent; | |
| 61 | - | char name[80]; | |
| 62 | - | int i; | |
| 63 | - | ||
| 64 | - | parent = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs); | |
| 65 | - | ||
| 66 | - | for (i = 0; i < mci->n_layers; i++) { | |
| 67 | - | sprintf(name, "fake_inject_%s", | |
| 68 | - | edac_layer_name[mci->layers[i].type]); | |
| 69 | - | debugfs_create_u8(name, S_IRUGO | S_IWUSR, parent, | |
| 70 | - | &mci->fake_inject_layer[i]); | |
| 71 | - | } | |
| 72 | - | ||
| 73 | - | debugfs_create_bool("fake_inject_ue", S_IRUGO | S_IWUSR, parent, | |
| 74 | - | &mci->fake_inject_ue); | |
| 75 | - | ||
| 76 | - | debugfs_create_u16("fake_inject_count", S_IRUGO | S_IWUSR, parent, | |
| 77 | - | &mci->fake_inject_count); | |
| 78 | - | ||
| 79 | - | debugfs_create_file("fake_inject", S_IWUSR, parent, &mci->dev, | |
| 80 | - | &debug_fake_inject_fops); | |
| 81 | - | ||
| 82 | - | mci->debugfs = parent; | |
| 19 | + | mci->debugfs = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs); | |
| 83 | 20 | } | |
| 84 | 21 | ||
| 85 | 22 | /* Create a toplevel dir under EDAC's debugfs hierarchy */ | |
modified drivers/edac/edac_device.c
| @@ -342,14 +342,10 @@ static void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev) | |||
| 342 | 342 | } | |
| 343 | 343 | ||
| 344 | 344 | /* | |
| 345 | - | * edac_device_reset_delay_period | |
| 346 | - | * | |
| 347 | - | * need to stop any outstanding workq queued up at this time | |
| 348 | - | * because we will be resetting the sleep time. | |
| 349 | - | * Then restart the workq on the new delay | |
| 345 | + | * Stop any outstanding workq queued up at this time because sleep time will | |
| 346 | + | * be reset. Then restart the workq on the new delay. | |
| 350 | 347 | */ | |
| 351 | - | void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev, | |
| 352 | - | unsigned long msec) | |
| 348 | + | void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev, unsigned int msec) | |
| 353 | 349 | { | |
| 354 | 350 | edac_dev->poll_msec = msec; | |
| 355 | 351 | edac_dev->delay = msecs_to_jiffies(msec); | |
modified drivers/edac/edac_device_sysfs.c
| @@ -84,18 +84,23 @@ static ssize_t edac_device_ctl_poll_msec_show(struct edac_device_ctl_info | |||
| 84 | 84 | return sprintf(data, "%u\n", ctl_info->poll_msec); | |
| 85 | 85 | } | |
| 86 | 86 | ||
| 87 | - | static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info | |
| 88 | - | *ctl_info, const char *data, | |
| 89 | - | size_t count) | |
| 87 | + | static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info *ctl_info, | |
| 88 | + | const char *data, size_t count) | |
| 90 | 89 | { | |
| 91 | - | unsigned long value; | |
| 90 | + | unsigned int value; | |
| 91 | + | int ret; | |
| 92 | 92 | ||
| 93 | - | /* get the value and enforce that it is non-zero, must be at least | |
| 94 | - | * one millisecond for the delay period, between scans | |
| 95 | - | * Then cancel last outstanding delay for the work request | |
| 96 | - | * and set a new one. | |
| 93 | + | /* | |
| 94 | + | * Get the value, make sure it is non-zero, must be at least one millisecond | |
| 95 | + | * for the delay period between scans. | |
| 97 | 96 | */ | |
| 98 | - | value = simple_strtoul(data, NULL, 0); | |
| 97 | + | ret = kstrtouint(data, 0, &value); | |
| 98 | + | if (ret < 0) | |
| 99 | + | return ret; | |
| 100 | + | ||
| 101 | + | if (value < 1) | |
| 102 | + | return -EINVAL; | |
| 103 | + | ||
| 99 | 104 | edac_device_reset_delay_period(ctl_info, value); | |
| 100 | 105 | ||
| 101 | 106 | return count; | |
modified drivers/edac/edac_mc_sysfs.c
| @@ -129,7 +129,7 @@ static ssize_t dimmdev_location_show(struct device *dev, | |||
| 129 | 129 | ssize_t count; | |
| 130 | 130 | ||
| 131 | 131 | count = edac_dimm_info_location(dimm, data, PAGE_SIZE); | |
| 132 | - | count += scnprintf(data + count, PAGE_SIZE - count, "\n"); | |
| 132 | + | count += sysfs_emit_at(data, count, "\n"); | |
| 133 | 133 | ||
| 134 | 134 | return count; | |
| 135 | 135 | } | |
modified drivers/edac/edac_module.h
| @@ -52,8 +52,7 @@ bool edac_queue_work(struct delayed_work *work, unsigned long delay); | |||
| 52 | 52 | bool edac_stop_work(struct delayed_work *work); | |
| 53 | 53 | bool edac_mod_work(struct delayed_work *work, unsigned long delay); | |
| 54 | 54 | ||
| 55 | - | extern void edac_device_reset_delay_period(struct edac_device_ctl_info | |
| 56 | - | *edac_dev, unsigned long msec); | |
| 55 | + | extern void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev, unsigned int msec); | |
| 57 | 56 | extern void edac_mc_reset_delay_period(unsigned long value); | |
| 58 | 57 | ||
| 59 | 58 | /* | |
modified drivers/edac/highbank_mc_edac.c
| @@ -235,10 +235,8 @@ static int highbank_mc_probe(struct platform_device *pdev) | |||
| 235 | 235 | irq = platform_get_irq(pdev, 0); | |
| 236 | 236 | res = devm_request_irq(&pdev->dev, irq, highbank_mc_err_handler, | |
| 237 | 237 | 0, dev_name(&pdev->dev), mci); | |
| 238 | - | if (res < 0) { | |
| 239 | - | dev_err(&pdev->dev, "Unable to request irq %d\n", irq); | |
| 238 | + | if (res < 0) | |
| 240 | 239 | goto err2; | |
| 241 | - | } | |
| 242 | 240 | ||
| 243 | 241 | devres_close_group(&pdev->dev, NULL); | |
| 244 | 242 | return 0; | |
modified drivers/edac/ie31200_edac.c
| @@ -416,7 +416,23 @@ static void populate_dimm_info(struct dimm_data *dd, u32 addr_decode, int dimm, | |||
| 416 | 416 | { | |
| 417 | 417 | dd->size = field_get(cfg->reg_mad_dimm_size_mask[dimm], addr_decode) * cfg->reg_mad_dimm_size_granularity; | |
| 418 | 418 | dd->ranks = field_get(cfg->reg_mad_dimm_rank_mask[dimm], addr_decode) + 1; | |
| 419 | - | dd->dtype = field_get(cfg->reg_mad_dimm_width_mask[dimm], addr_decode) + DEV_X8; | |
| 419 | + | ||
| 420 | + | switch (field_get(cfg->reg_mad_dimm_width_mask[dimm], addr_decode)) { | |
| 421 | + | case 0: | |
| 422 | + | dd->dtype = DEV_X8; | |
| 423 | + | break; | |
| 424 | + | case 1: | |
| 425 | + | dd->dtype = DEV_X16; | |
| 426 | + | break; | |
| 427 | + | case 2: | |
| 428 | + | dd->dtype = DEV_X32; | |
| 429 | + | break; | |
| 430 | + | case 3: | |
| 431 | + | dd->dtype = DEV_X64; | |
| 432 | + | break; | |
| 433 | + | default: | |
| 434 | + | dd->dtype = DEV_UNKNOWN; | |
| 435 | + | } | |
| 420 | 436 | } | |
| 421 | 437 | ||
| 422 | 438 | static void ie31200_get_dimm_config(struct mem_ctl_info *mci, void __iomem *window, | |
modified drivers/edac/igen6_edac.c
| @@ -42,7 +42,8 @@ | |||
| 42 | 42 | ||
| 43 | 43 | #define GET_BITFIELD(v, lo, hi) (((v) & GENMASK_ULL(hi, lo)) >> (lo)) | |
| 44 | 44 | ||
| 45 | - | #define NUM_IMC 2 /* Max memory controllers */ | |
| 45 | + | /* Probing upper bound, not a hardware capability limit. */ | |
| 46 | + | #define MAX_IMC_TO_PROBE 8 | |
| 46 | 47 | #define NUM_CHANNELS 2 /* Max channels */ | |
| 47 | 48 | #define NUM_DIMMS 2 /* Max DIMMs per channel */ | |
| 48 | 49 | ||
| @@ -122,6 +123,43 @@ | |||
| 122 | 123 | #define MEM_SLICE_HASH_MASK(v) (GET_BITFIELD(v, 6, 19) << 6) | |
| 123 | 124 | #define MEM_SLICE_HASH_LSB_MASK_BIT(v) GET_BITFIELD(v, 24, 26) | |
| 124 | 125 | ||
| 126 | + | /* | |
| 127 | + | * A slice represents a portion of memory space participating in an | |
| 128 | + | * interleave relationship within the memory hierarchy. | |
| 129 | + | * | |
| 130 | + | * It can represent in different levels such as: | |
| 131 | + | * | |
| 132 | + | * - a pair of memory controllers | |
| 133 | + | * - a memory controller | |
| 134 | + | * - a memory channel | |
| 135 | + | * - a memory sub-channel / DIMM | |
| 136 | + | * | |
| 137 | + | * +--------+ | |
| 138 | + | * | | | |
| 139 | + | * | Zone 1 | | |
| 140 | + | * | | | |
| 141 | + | * +--------+ +--------+ | |
| 142 | + | * | | | | | |
| 143 | + | * | | | | | |
| 144 | + | * | Zone 0 | | Zone 0 | | |
| 145 | + | * | | | | | |
| 146 | + | * | | | | | |
| 147 | + | * +--------+ +--------+ | |
| 148 | + | * | |
| 149 | + | * Slice L Slice S | |
| 150 | + | * | |
| 151 | + | * Memory space is divided into: | |
| 152 | + | * | |
| 153 | + | * - Zone 0 : Interleaved region | |
| 154 | + | * - Zone 1 : Non-interleaved region (upper part of the large slice). | |
| 155 | + | */ | |
| 156 | + | struct slice { | |
| 157 | + | /* Slice address. */ | |
| 158 | + | u64 addr; | |
| 159 | + | /* Slice that @addr belongs to. */ | |
| 160 | + | int id; | |
| 161 | + | }; | |
| 162 | + | ||
| 125 | 163 | struct igen6_imc { | |
| 126 | 164 | int mc; | |
| 127 | 165 | struct mem_ctl_info *mci; | |
| @@ -175,8 +213,6 @@ static struct res_config { | |||
| 175 | 213 | /* Set imc->dimm_{l_size,s_size,l_map}[chan]. */ | |
| 176 | 214 | void (*set_dimm_params)(struct igen6_imc *imc, int chan); | |
| 177 | 215 | bool (*ibecc_available)(struct pci_dev *pdev); | |
| 178 | - | /* Extract error address logged in IBECC */ | |
| 179 | - | u64 (*err_addr)(u64 ecclog); | |
| 180 | 216 | /* Convert error address logged in IBECC to system physical address */ | |
| 181 | 217 | u64 (*err_addr_to_sys_addr)(u64 eaddr, int mc); | |
| 182 | 218 | /* Convert error address logged in IBECC to integrated memory controller address */ | |
| @@ -184,11 +220,11 @@ static struct res_config { | |||
| 184 | 220 | } *res_cfg; | |
| 185 | 221 | ||
| 186 | 222 | static struct igen6_pvt { | |
| 187 | - | struct igen6_imc imc[NUM_IMC]; | |
| 188 | 223 | void __iomem *memss_pma_cr; | |
| 189 | 224 | u64 ms_hash; | |
| 190 | 225 | u64 ms_s_size; | |
| 191 | 226 | int ms_l_map; | |
| 227 | + | struct igen6_imc imc[]; | |
| 192 | 228 | } *igen6_pvt; | |
| 193 | 229 | ||
| 194 | 230 | /* The top of low usable DRAM */ | |
| @@ -225,7 +261,8 @@ static char ecclog_buf[ECCLOG_POOL_SIZE]; | |||
| 225 | 261 | static struct irq_work ecclog_irq_work; | |
| 226 | 262 | static struct work_struct ecclog_work; | |
| 227 | 263 | ||
| 228 | - | /* Compute die IDs for Elkhart Lake with IBECC */ | |
| 264 | + | /* SoC compute die IDs with IBECC capability. */ | |
| 265 | + | /* Elkhart Lake */ | |
| 229 | 266 | #define DID_EHL_SKU5 0x4514 | |
| 230 | 267 | #define DID_EHL_SKU6 0x4528 | |
| 231 | 268 | #define DID_EHL_SKU7 0x452a | |
| @@ -238,22 +275,22 @@ static struct work_struct ecclog_work; | |||
| 238 | 275 | #define DID_EHL_SKU14 0x4534 | |
| 239 | 276 | #define DID_EHL_SKU15 0x4536 | |
| 240 | 277 | ||
| 241 | - | /* Compute die IDs for ICL-NNPI with IBECC */ | |
| 278 | + | /* ICL-NNPI */ | |
| 242 | 279 | #define DID_ICL_SKU8 0x4581 | |
| 243 | 280 | #define DID_ICL_SKU10 0x4585 | |
| 244 | 281 | #define DID_ICL_SKU11 0x4589 | |
| 245 | 282 | #define DID_ICL_SKU12 0x458d | |
| 246 | 283 | ||
| 247 | - | /* Compute die IDs for Tiger Lake with IBECC */ | |
| 284 | + | /* Tiger Lake */ | |
| 248 | 285 | #define DID_TGL_SKU 0x9a14 | |
| 249 | 286 | ||
| 250 | - | /* Compute die IDs for Alder Lake with IBECC */ | |
| 287 | + | /* Alder Lake */ | |
| 251 | 288 | #define DID_ADL_SKU1 0x4601 | |
| 252 | 289 | #define DID_ADL_SKU2 0x4602 | |
| 253 | 290 | #define DID_ADL_SKU3 0x4621 | |
| 254 | 291 | #define DID_ADL_SKU4 0x4641 | |
| 255 | 292 | ||
| 256 | - | /* Compute die IDs for Alder Lake-N with IBECC */ | |
| 293 | + | /* Alder Lake-N */ | |
| 257 | 294 | #define DID_ADL_N_SKU1 0x4614 | |
| 258 | 295 | #define DID_ADL_N_SKU2 0x4617 | |
| 259 | 296 | #define DID_ADL_N_SKU3 0x461b | |
| @@ -267,38 +304,38 @@ static struct work_struct ecclog_work; | |||
| 267 | 304 | #define DID_ADL_N_SKU11 0x467c | |
| 268 | 305 | #define DID_ADL_N_SKU12 0x4632 | |
| 269 | 306 | ||
| 270 | - | /* Compute die IDs for Arizona Beach with IBECC */ | |
| 307 | + | /* Arizona Beach */ | |
| 271 | 308 | #define DID_AZB_SKU1 0x4676 | |
| 272 | 309 | ||
| 273 | - | /* Compute did IDs for Amston Lake with IBECC */ | |
| 310 | + | /* Amston Lake */ | |
| 274 | 311 | #define DID_ASL_SKU1 0x464a | |
| 275 | 312 | #define DID_ASL_SKU2 0x4646 | |
| 276 | 313 | #define DID_ASL_SKU3 0x4652 | |
| 277 | 314 | ||
| 278 | - | /* Compute die IDs for Raptor Lake-P with IBECC */ | |
| 315 | + | /* Raptor Lake-P */ | |
| 279 | 316 | #define DID_RPL_P_SKU1 0xa706 | |
| 280 | 317 | #define DID_RPL_P_SKU2 0xa707 | |
| 281 | 318 | #define DID_RPL_P_SKU3 0xa708 | |
| 282 | 319 | #define DID_RPL_P_SKU4 0xa716 | |
| 283 | 320 | #define DID_RPL_P_SKU5 0xa718 | |
| 284 | 321 | ||
| 285 | - | /* Compute die IDs for Meteor Lake-PS with IBECC */ | |
| 322 | + | /* Meteor Lake-PS */ | |
| 286 | 323 | #define DID_MTL_PS_SKU1 0x7d21 | |
| 287 | 324 | #define DID_MTL_PS_SKU2 0x7d22 | |
| 288 | 325 | #define DID_MTL_PS_SKU3 0x7d23 | |
| 289 | 326 | #define DID_MTL_PS_SKU4 0x7d24 | |
| 290 | 327 | ||
| 291 | - | /* Compute die IDs for Meteor Lake-P with IBECC */ | |
| 328 | + | /* Meteor Lake-P */ | |
| 292 | 329 | #define DID_MTL_P_SKU1 0x7d01 | |
| 293 | 330 | #define DID_MTL_P_SKU2 0x7d02 | |
| 294 | 331 | #define DID_MTL_P_SKU3 0x7d14 | |
| 295 | 332 | ||
| 296 | - | /* Compute die IDs for Arrow Lake-UH with IBECC */ | |
| 333 | + | /* Arrow Lake-UH */ | |
| 297 | 334 | #define DID_ARL_UH_SKU1 0x7d06 | |
| 298 | 335 | #define DID_ARL_UH_SKU2 0x7d20 | |
| 299 | 336 | #define DID_ARL_UH_SKU3 0x7d30 | |
| 300 | 337 | ||
| 301 | - | /* Compute die IDs for Panther Lake-H with IBECC */ | |
| 338 | + | /* Panther Lake-H */ | |
| 302 | 339 | #define DID_PTL_H_SKU1 0xb000 | |
| 303 | 340 | #define DID_PTL_H_SKU2 0xb001 | |
| 304 | 341 | #define DID_PTL_H_SKU3 0xb002 | |
| @@ -314,15 +351,114 @@ static struct work_struct ecclog_work; | |||
| 314 | 351 | #define DID_PTL_H_SKU13 0xb02a | |
| 315 | 352 | #define DID_PTL_H_SKU14 0xb00a | |
| 316 | 353 | ||
| 317 | - | /* Compute die IDs for Wildcat Lake with IBECC */ | |
| 354 | + | /* Starfire */ | |
| 355 | + | #define DID_STF_SKU1 0xb02b | |
| 356 | + | ||
| 357 | + | /* Wildcat Lake */ | |
| 318 | 358 | #define DID_WCL_SKU1 0xfd00 | |
| 319 | 359 | ||
| 320 | - | /* Compute die IDs for Nova Lake-H/HX with IBECC */ | |
| 360 | + | /* Nova Lake-H/HX */ | |
| 321 | 361 | #define DID_NVL_H_SKU1 0xd701 | |
| 322 | 362 | #define DID_NVL_H_SKU2 0xd702 | |
| 323 | 363 | #define DID_NVL_H_SKU3 0xd704 | |
| 324 | 364 | #define DID_NVL_H_SKU4 0xd705 | |
| 325 | 365 | ||
| 366 | + | /* Remove the interleave bit and shift upper part down to fill gap. */ | |
| 367 | + | static u64 squeeze_addr(u64 addr, int intlv_bit) | |
| 368 | + | { | |
| 369 | + | u64 slice_addr; | |
| 370 | + | ||
| 371 | + | slice_addr = GET_BITFIELD(addr, intlv_bit + 1, 63) << intlv_bit; | |
| 372 | + | slice_addr |= GET_BITFIELD(addr, 0, intlv_bit - 1); | |
| 373 | + | ||
| 374 | + | return slice_addr; | |
| 375 | + | } | |
| 376 | + | ||
| 377 | + | /* Shift the upper bits up and insert a zero at the @intlv_bit bit position. */ | |
| 378 | + | static u64 inflate_addr(u64 addr, int intlv_bit) | |
| 379 | + | { | |
| 380 | + | u64 inflated_addr; | |
| 381 | + | ||
| 382 | + | /* Insert a zero at @intlv_bit position. */ | |
| 383 | + | inflated_addr = GET_BITFIELD(addr, intlv_bit, 63) << (intlv_bit + 1); | |
| 384 | + | inflated_addr |= GET_BITFIELD(addr, 0, intlv_bit - 1); | |
| 385 | + | ||
| 386 | + | return inflated_addr; | |
| 387 | + | } | |
| 388 | + | ||
| 389 | + | static u64 compute_hash(u64 addr, u64 hash_mask, u64 hash_base, int intlv_bit) | |
| 390 | + | { | |
| 391 | + | u64 hash_addr; | |
| 392 | + | int i; | |
| 393 | + | ||
| 394 | + | /* | |
| 395 | + | * In hash mode, @intlv_bit is the lowest selected bit of @addr | |
| 396 | + | * to be XORed. While @mask may or may not include this @intlv_bit, | |
| 397 | + | * we enforce that @mask includes @intlv_bit to ensure @intlv_bit is | |
| 398 | + | * XORed exactly once. | |
| 399 | + | */ | |
| 400 | + | hash_mask |= BIT_ULL(intlv_bit); | |
| 401 | + | hash_addr = addr & hash_mask; | |
| 402 | + | ||
| 403 | + | for (i = 6; i < 20; i++) | |
| 404 | + | hash_base ^= (hash_addr >> i) & 1; | |
| 405 | + | ||
| 406 | + | return hash_base; | |
| 407 | + | } | |
| 408 | + | ||
| 409 | + | /* | |
| 410 | + | * Converts a higher-level address (system / IMC / channel) into a lower-level | |
| 411 | + | * slice address and identifier. | |
| 412 | + | */ | |
| 413 | + | static void translate_to_lower_level(u64 addr, u64 hash_mask, u64 hash_base, | |
| 414 | + | int intlv_bit, u64 s_size, int l_map, | |
| 415 | + | struct slice *slice) | |
| 416 | + | { | |
| 417 | + | /* In non-interleave zone. */ | |
| 418 | + | if (addr >= 2 * s_size) { | |
| 419 | + | slice->addr = addr - s_size; | |
| 420 | + | slice->id = l_map; | |
| 421 | + | return; | |
| 422 | + | } | |
| 423 | + | ||
| 424 | + | /* In interleave zone. */ | |
| 425 | + | slice->addr = squeeze_addr(addr, intlv_bit); | |
| 426 | + | ||
| 427 | + | /* Non-hash mode. */ | |
| 428 | + | if (!hash_mask) { | |
| 429 | + | slice->id = GET_BITFIELD(addr, intlv_bit, intlv_bit); | |
| 430 | + | return; | |
| 431 | + | } | |
| 432 | + | ||
| 433 | + | /* Hash mode. */ | |
| 434 | + | slice->id = compute_hash(addr, hash_mask, hash_base, intlv_bit); | |
| 435 | + | } | |
| 436 | + | ||
| 437 | + | /* Reconstruct address for upper memory hierarchy level. */ | |
| 438 | + | static u64 translate_to_upper_level(u64 addr, u64 hash_mask, u64 hash_base, | |
| 439 | + | int intlv_bit, u64 s_size) | |
| 440 | + | { | |
| 441 | + | u64 inflated_addr, hash_val; | |
| 442 | + | ||
| 443 | + | /* In non-interleave zone. */ | |
| 444 | + | if (addr >= s_size) | |
| 445 | + | return addr + s_size; | |
| 446 | + | ||
| 447 | + | /* | |
| 448 | + | * In interleave zone. | |
| 449 | + | * | |
| 450 | + | * Insert a zero at @intlv_bit position. | |
| 451 | + | */ | |
| 452 | + | inflated_addr = inflate_addr(addr, intlv_bit); | |
| 453 | + | ||
| 454 | + | /* | |
| 455 | + | * Reconstruct the removed interleave bit and use it to replace | |
| 456 | + | * the zero at @intlv_bit position. | |
| 457 | + | */ | |
| 458 | + | hash_val = compute_hash(inflated_addr, hash_mask, hash_base, intlv_bit); | |
| 459 | + | return inflated_addr | (hash_val << intlv_bit); | |
| 460 | + | } | |
| 461 | + | ||
| 326 | 462 | static int get_mchbar(struct pci_dev *pdev, u64 *mchbar) | |
| 327 | 463 | { | |
| 328 | 464 | union { | |
| @@ -354,6 +490,46 @@ static int get_mchbar(struct pci_dev *pdev, u64 *mchbar) | |||
| 354 | 490 | return 0; | |
| 355 | 491 | } | |
| 356 | 492 | ||
| 493 | + | /* Check whether the memory controller is absent. */ | |
| 494 | + | static bool imc_absent(void __iomem *window) | |
| 495 | + | { | |
| 496 | + | return readl(window + MAD_INTER_CHANNEL_OFFSET) == ~0; | |
| 497 | + | } | |
| 498 | + | ||
| 499 | + | /* Return MMIO base address of the memory controller if it's present, otherwise return NULL. */ | |
| 500 | + | static void __iomem *map_imc_window(u64 mchbar, int pmc) | |
| 501 | + | { | |
| 502 | + | void __iomem *window; | |
| 503 | + | ||
| 504 | + | window = ioremap(mchbar + pmc * MCHBAR_SIZE, MCHBAR_SIZE); | |
| 505 | + | if (!window) | |
| 506 | + | return NULL; | |
| 507 | + | ||
| 508 | + | if (imc_absent(window)) { | |
| 509 | + | iounmap(window); | |
| 510 | + | return NULL; | |
| 511 | + | } | |
| 512 | + | ||
| 513 | + | return window; | |
| 514 | + | } | |
| 515 | + | ||
| 516 | + | /* Return the number of present memory controllers. */ | |
| 517 | + | static int get_imc_num(u64 mchbar) | |
| 518 | + | { | |
| 519 | + | void __iomem *window; | |
| 520 | + | int lmc, pmc; | |
| 521 | + | ||
| 522 | + | for (lmc = 0, pmc = 0; pmc < MAX_IMC_TO_PROBE; pmc++) { | |
| 523 | + | window = map_imc_window(mchbar, pmc); | |
| 524 | + | if (window) { | |
| 525 | + | iounmap(window); | |
| 526 | + | lmc++; | |
| 527 | + | } | |
| 528 | + | } | |
| 529 | + | ||
| 530 | + | return lmc; | |
| 531 | + | } | |
| 532 | + | ||
| 357 | 533 | static bool ehl_ibecc_available(struct pci_dev *pdev) | |
| 358 | 534 | { | |
| 359 | 535 | u32 v; | |
| @@ -450,21 +626,9 @@ static u64 mem_addr_to_sys_addr(u64 maddr) | |||
| 450 | 626 | return maddr; | |
| 451 | 627 | } | |
| 452 | 628 | ||
| 453 | - | static u64 mem_slice_hash(u64 addr, u64 mask, u64 hash_init, int intlv_bit) | |
| 454 | - | { | |
| 455 | - | u64 hash_addr = addr & mask, hash = hash_init; | |
| 456 | - | u64 intlv = (addr >> intlv_bit) & 1; | |
| 457 | - | int i; | |
| 458 | - | ||
| 459 | - | for (i = 6; i < 20; i++) | |
| 460 | - | hash ^= (hash_addr >> i) & 1; | |
| 461 | - | ||
| 462 | - | return hash ^ intlv; | |
| 463 | - | } | |
| 464 | - | ||
| 465 | 629 | static u64 tgl_err_addr_to_mem_addr(u64 eaddr, int mc) | |
| 466 | 630 | { | |
| 467 | - | u64 maddr, hash, mask, ms_s_size; | |
| 631 | + | u64 mask, ms_s_size; | |
| 468 | 632 | int intlv_bit; | |
| 469 | 633 | u32 ms_hash; | |
| 470 | 634 | ||
| @@ -477,12 +641,7 @@ static u64 tgl_err_addr_to_mem_addr(u64 eaddr, int mc) | |||
| 477 | 641 | mask = MEM_SLICE_HASH_MASK(ms_hash); | |
| 478 | 642 | intlv_bit = MEM_SLICE_HASH_LSB_MASK_BIT(ms_hash) + 6; | |
| 479 | 643 | ||
| 480 | - | maddr = GET_BITFIELD(eaddr, intlv_bit, 63) << (intlv_bit + 1) | | |
| 481 | - | GET_BITFIELD(eaddr, 0, intlv_bit - 1); | |
| 482 | - | ||
| 483 | - | hash = mem_slice_hash(maddr, mask, mc, intlv_bit); | |
| 484 | - | ||
| 485 | - | return maddr | (hash << intlv_bit); | |
| 644 | + | return translate_to_upper_level(eaddr, mask, mc, intlv_bit, ms_s_size); | |
| 486 | 645 | } | |
| 487 | 646 | ||
| 488 | 647 | static u64 tgl_err_addr_to_sys_addr(u64 eaddr, int mc) | |
| @@ -504,8 +663,9 @@ static u64 adl_err_addr_to_sys_addr(u64 eaddr, int mc) | |||
| 504 | 663 | ||
| 505 | 664 | static u64 adl_err_addr_to_imc_addr(u64 eaddr, int mc) | |
| 506 | 665 | { | |
| 507 | - | u64 imc_addr, ms_s_size = igen6_pvt->ms_s_size; | |
| 666 | + | u64 ms_s_size = igen6_pvt->ms_s_size; | |
| 508 | 667 | struct igen6_imc *imc = &igen6_pvt->imc[mc]; | |
| 668 | + | struct slice slice; | |
| 509 | 669 | int intlv_bit; | |
| 510 | 670 | u32 mc_hash; | |
| 511 | 671 | ||
| @@ -516,15 +676,8 @@ static u64 adl_err_addr_to_imc_addr(u64 eaddr, int mc) | |||
| 516 | 676 | ||
| 517 | 677 | intlv_bit = MAC_MC_HASH_LSB(mc_hash) + 6; | |
| 518 | 678 | ||
| 519 | - | imc_addr = GET_BITFIELD(eaddr, intlv_bit + 1, 63) << intlv_bit | | |
| 520 | - | GET_BITFIELD(eaddr, 0, intlv_bit - 1); | |
| 521 | - | ||
| 522 | - | return imc_addr; | |
| 523 | - | } | |
| 524 | - | ||
| 525 | - | static u64 rpl_p_err_addr(u64 ecclog) | |
| 526 | - | { | |
| 527 | - | return field_get(res_cfg->reg_eccerrlog_addr_mask, ecclog); | |
| 679 | + | translate_to_lower_level(eaddr, 0, 0, intlv_bit, ms_s_size, 0, &slice); | |
| 680 | + | return slice.addr; | |
| 528 | 681 | } | |
| 529 | 682 | ||
| 530 | 683 | static enum mem_type ptl_h_get_mem_type(struct igen6_imc *imc) | |
| @@ -686,6 +839,7 @@ static struct res_config tgl_cfg = { | |||
| 686 | 839 | .err_addr_to_imc_addr = tgl_err_addr_to_imc_addr, | |
| 687 | 840 | }; | |
| 688 | 841 | ||
| 842 | + | /* Shared by Alder Lake, Alder Lake-N, Arizona Beach, Amston Lake, and Raptor Lake-P */ | |
| 689 | 843 | static struct res_config adl_cfg = { | |
| 690 | 844 | .machine_check = true, | |
| 691 | 845 | .num_imc = 2, | |
| @@ -701,37 +855,6 @@ static struct res_config adl_cfg = { | |||
| 701 | 855 | .err_addr_to_imc_addr = adl_err_addr_to_imc_addr, | |
| 702 | 856 | }; | |
| 703 | 857 | ||
| 704 | - | static struct res_config adl_n_cfg = { | |
| 705 | - | .machine_check = true, | |
| 706 | - | .num_imc = 1, | |
| 707 | - | .reg_mchbar_mask = GENMASK_ULL(41, 17), | |
| 708 | - | .reg_tom_mask = GENMASK_ULL(41, 20), | |
| 709 | - | .reg_touud_mask = GENMASK_ULL(41, 20), | |
| 710 | - | .reg_eccerrlog_addr_mask = GENMASK_ULL(45, 5), | |
| 711 | - | .imc_base = 0xd800, | |
| 712 | - | .ibecc_base = 0xd400, | |
| 713 | - | .ibecc_error_log_offset = 0x68, | |
| 714 | - | .ibecc_available = tgl_ibecc_available, | |
| 715 | - | .err_addr_to_sys_addr = adl_err_addr_to_sys_addr, | |
| 716 | - | .err_addr_to_imc_addr = adl_err_addr_to_imc_addr, | |
| 717 | - | }; | |
| 718 | - | ||
| 719 | - | static struct res_config rpl_p_cfg = { | |
| 720 | - | .machine_check = true, | |
| 721 | - | .num_imc = 2, | |
| 722 | - | .reg_mchbar_mask = GENMASK_ULL(41, 17), | |
| 723 | - | .reg_tom_mask = GENMASK_ULL(41, 20), | |
| 724 | - | .reg_touud_mask = GENMASK_ULL(41, 20), | |
| 725 | - | .reg_eccerrlog_addr_mask = GENMASK_ULL(45, 5), | |
| 726 | - | .imc_base = 0xd800, | |
| 727 | - | .ibecc_base = 0xd400, | |
| 728 | - | .ibecc_error_log_offset = 0x68, | |
| 729 | - | .ibecc_available = tgl_ibecc_available, | |
| 730 | - | .err_addr = rpl_p_err_addr, | |
| 731 | - | .err_addr_to_sys_addr = adl_err_addr_to_sys_addr, | |
| 732 | - | .err_addr_to_imc_addr = adl_err_addr_to_imc_addr, | |
| 733 | - | }; | |
| 734 | - | ||
| 735 | 858 | static struct res_config mtl_ps_cfg = { | |
| 736 | 859 | .machine_check = true, | |
| 737 | 860 | .num_imc = 2, | |
| @@ -749,6 +872,7 @@ static struct res_config mtl_ps_cfg = { | |||
| 749 | 872 | .err_addr_to_imc_addr = adl_err_addr_to_imc_addr, | |
| 750 | 873 | }; | |
| 751 | 874 | ||
| 875 | + | /* Shared by Meteor Lake-P, Arrow Lake-UH, and Wildcat Lake */ | |
| 752 | 876 | static struct res_config mtl_p_cfg = { | |
| 753 | 877 | .machine_check = true, | |
| 754 | 878 | .num_imc = 2, | |
| @@ -764,6 +888,7 @@ static struct res_config mtl_p_cfg = { | |||
| 764 | 888 | .err_addr_to_imc_addr = adl_err_addr_to_imc_addr, | |
| 765 | 889 | }; | |
| 766 | 890 | ||
| 891 | + | /* Shared by Panther Lake-H and Starfire */ | |
| 767 | 892 | static struct res_config ptl_h_cfg = { | |
| 768 | 893 | .machine_check = true, | |
| 769 | 894 | .num_imc = 2, | |
| @@ -794,21 +919,6 @@ static struct res_config ptl_h_cfg = { | |||
| 794 | 919 | .err_addr_to_imc_addr = adl_err_addr_to_imc_addr, | |
| 795 | 920 | }; | |
| 796 | 921 | ||
| 797 | - | static struct res_config wcl_cfg = { | |
| 798 | - | .machine_check = true, | |
| 799 | - | .num_imc = 1, | |
| 800 | - | .reg_mchbar_mask = GENMASK_ULL(41, 17), | |
| 801 | - | .reg_tom_mask = GENMASK_ULL(41, 20), | |
| 802 | - | .reg_touud_mask = GENMASK_ULL(41, 20), | |
| 803 | - | .reg_eccerrlog_addr_mask = GENMASK_ULL(38, 5), | |
| 804 | - | .imc_base = 0xd800, | |
| 805 | - | .ibecc_base = 0xd400, | |
| 806 | - | .ibecc_error_log_offset = 0x170, | |
| 807 | - | .ibecc_available = mtl_p_ibecc_available, | |
| 808 | - | .err_addr_to_sys_addr = adl_err_addr_to_sys_addr, | |
| 809 | - | .err_addr_to_imc_addr = adl_err_addr_to_imc_addr, | |
| 810 | - | }; | |
| 811 | - | ||
| 812 | 922 | static struct res_config nvl_h_cfg = { | |
| 813 | 923 | .machine_check = true, | |
| 814 | 924 | .num_imc = 2, | |
| @@ -861,27 +971,27 @@ static struct pci_device_id igen6_pci_tbl[] = { | |||
| 861 | 971 | { PCI_VDEVICE(INTEL, DID_ADL_SKU2), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 862 | 972 | { PCI_VDEVICE(INTEL, DID_ADL_SKU3), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 863 | 973 | { PCI_VDEVICE(INTEL, DID_ADL_SKU4), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 864 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU1), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 865 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU2), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 866 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU3), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 867 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU4), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 868 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU5), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 869 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU6), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 870 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU7), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 871 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU8), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 872 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU9), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 873 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU10), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 874 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU11), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 875 | - | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU12), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 876 | - | { PCI_VDEVICE(INTEL, DID_AZB_SKU1), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 877 | - | { PCI_VDEVICE(INTEL, DID_ASL_SKU1), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 878 | - | { PCI_VDEVICE(INTEL, DID_ASL_SKU2), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 879 | - | { PCI_VDEVICE(INTEL, DID_ASL_SKU3), .driver_data = (kernel_ulong_t)&adl_n_cfg }, | |
| 880 | - | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU1), .driver_data = (kernel_ulong_t)&rpl_p_cfg }, | |
| 881 | - | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU2), .driver_data = (kernel_ulong_t)&rpl_p_cfg }, | |
| 882 | - | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU3), .driver_data = (kernel_ulong_t)&rpl_p_cfg }, | |
| 883 | - | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU4), .driver_data = (kernel_ulong_t)&rpl_p_cfg }, | |
| 884 | - | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU5), .driver_data = (kernel_ulong_t)&rpl_p_cfg }, | |
| 974 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU1), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 975 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU2), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 976 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU3), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 977 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU4), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 978 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU5), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 979 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU6), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 980 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU7), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 981 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU8), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 982 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU9), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 983 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU10), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 984 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU11), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 985 | + | { PCI_VDEVICE(INTEL, DID_ADL_N_SKU12), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 986 | + | { PCI_VDEVICE(INTEL, DID_AZB_SKU1), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 987 | + | { PCI_VDEVICE(INTEL, DID_ASL_SKU1), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 988 | + | { PCI_VDEVICE(INTEL, DID_ASL_SKU2), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 989 | + | { PCI_VDEVICE(INTEL, DID_ASL_SKU3), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 990 | + | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU1), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 991 | + | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU2), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 992 | + | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU3), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 993 | + | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU4), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 994 | + | { PCI_VDEVICE(INTEL, DID_RPL_P_SKU5), .driver_data = (kernel_ulong_t)&adl_cfg }, | |
| 885 | 995 | { PCI_VDEVICE(INTEL, DID_MTL_PS_SKU1), .driver_data = (kernel_ulong_t)&mtl_ps_cfg }, | |
| 886 | 996 | { PCI_VDEVICE(INTEL, DID_MTL_PS_SKU2), .driver_data = (kernel_ulong_t)&mtl_ps_cfg }, | |
| 887 | 997 | { PCI_VDEVICE(INTEL, DID_MTL_PS_SKU3), .driver_data = (kernel_ulong_t)&mtl_ps_cfg }, | |
| @@ -892,6 +1002,7 @@ static struct pci_device_id igen6_pci_tbl[] = { | |||
| 892 | 1002 | { PCI_VDEVICE(INTEL, DID_ARL_UH_SKU1), .driver_data = (kernel_ulong_t)&mtl_p_cfg }, | |
| 893 | 1003 | { PCI_VDEVICE(INTEL, DID_ARL_UH_SKU2), .driver_data = (kernel_ulong_t)&mtl_p_cfg }, | |
| 894 | 1004 | { PCI_VDEVICE(INTEL, DID_ARL_UH_SKU3), .driver_data = (kernel_ulong_t)&mtl_p_cfg }, | |
| 1005 | + | { PCI_VDEVICE(INTEL, DID_WCL_SKU1), .driver_data = (kernel_ulong_t)&mtl_p_cfg }, | |
| 895 | 1006 | { PCI_VDEVICE(INTEL, DID_PTL_H_SKU1), .driver_data = (kernel_ulong_t)&ptl_h_cfg }, | |
| 896 | 1007 | { PCI_VDEVICE(INTEL, DID_PTL_H_SKU2), .driver_data = (kernel_ulong_t)&ptl_h_cfg }, | |
| 897 | 1008 | { PCI_VDEVICE(INTEL, DID_PTL_H_SKU3), .driver_data = (kernel_ulong_t)&ptl_h_cfg }, | |
| @@ -906,7 +1017,7 @@ static struct pci_device_id igen6_pci_tbl[] = { | |||
| 906 | 1017 | { PCI_VDEVICE(INTEL, DID_PTL_H_SKU12), .driver_data = (kernel_ulong_t)&ptl_h_cfg }, | |
| 907 | 1018 | { PCI_VDEVICE(INTEL, DID_PTL_H_SKU13), .driver_data = (kernel_ulong_t)&ptl_h_cfg }, | |
| 908 | 1019 | { PCI_VDEVICE(INTEL, DID_PTL_H_SKU14), .driver_data = (kernel_ulong_t)&ptl_h_cfg }, | |
| 909 | - | { PCI_VDEVICE(INTEL, DID_WCL_SKU1), .driver_data = (kernel_ulong_t)&wcl_cfg }, | |
| 1020 | + | { PCI_VDEVICE(INTEL, DID_STF_SKU1), .driver_data = (kernel_ulong_t)&ptl_h_cfg }, | |
| 910 | 1021 | { PCI_VDEVICE(INTEL, DID_NVL_H_SKU1), .driver_data = (kernel_ulong_t)&nvl_h_cfg }, | |
| 911 | 1022 | { PCI_VDEVICE(INTEL, DID_NVL_H_SKU2), .driver_data = (kernel_ulong_t)&nvl_h_cfg }, | |
| 912 | 1023 | { PCI_VDEVICE(INTEL, DID_NVL_H_SKU3), .driver_data = (kernel_ulong_t)&nvl_h_cfg }, | |
| @@ -1007,55 +1118,13 @@ static void set_dimm_params(struct igen6_imc *imc, int chan) | |||
| 1007 | 1118 | imc->dimm_s_size[chan] = MAD_DIMM_CH_DIMM_S_SIZE(val); | |
| 1008 | 1119 | } | |
| 1009 | 1120 | ||
| 1010 | - | static int decode_chan_idx(u64 addr, u64 mask, int intlv_bit) | |
| 1011 | - | { | |
| 1012 | - | u64 hash_addr = addr & mask, hash = 0; | |
| 1013 | - | u64 intlv = (addr >> intlv_bit) & 1; | |
| 1014 | - | int i; | |
| 1015 | - | ||
| 1016 | - | for (i = 6; i < 20; i++) | |
| 1017 | - | hash ^= (hash_addr >> i) & 1; | |
| 1018 | - | ||
| 1019 | - | return (int)hash ^ intlv; | |
| 1020 | - | } | |
| 1021 | - | ||
| 1022 | - | static u64 decode_channel_addr(u64 addr, int intlv_bit) | |
| 1023 | - | { | |
| 1024 | - | u64 channel_addr; | |
| 1025 | - | ||
| 1026 | - | /* Remove the interleave bit and shift upper part down to fill gap */ | |
| 1027 | - | channel_addr = GET_BITFIELD(addr, intlv_bit + 1, 63) << intlv_bit; | |
| 1028 | - | channel_addr |= GET_BITFIELD(addr, 0, intlv_bit - 1); | |
| 1029 | - | ||
| 1030 | - | return channel_addr; | |
| 1031 | - | } | |
| 1032 | - | ||
| 1033 | - | static void decode_addr(u64 addr, u32 hash, u64 s_size, int l_map, | |
| 1034 | - | int *idx, u64 *sub_addr) | |
| 1035 | - | { | |
| 1036 | - | int intlv_bit = CHANNEL_HASH_LSB_MASK_BIT(hash) + 6; | |
| 1037 | - | ||
| 1038 | - | if (addr > 2 * s_size) { | |
| 1039 | - | *sub_addr = addr - s_size; | |
| 1040 | - | *idx = l_map; | |
| 1041 | - | return; | |
| 1042 | - | } | |
| 1043 | - | ||
| 1044 | - | if (CHANNEL_HASH_MODE(hash)) { | |
| 1045 | - | *sub_addr = decode_channel_addr(addr, intlv_bit); | |
| 1046 | - | *idx = decode_chan_idx(addr, CHANNEL_HASH_MASK(hash), intlv_bit); | |
| 1047 | - | } else { | |
| 1048 | - | *sub_addr = decode_channel_addr(addr, 6); | |
| 1049 | - | *idx = GET_BITFIELD(addr, 6, 6); | |
| 1050 | - | } | |
| 1051 | - | } | |
| 1052 | - | ||
| 1053 | 1121 | static int igen6_decode(struct decoded_addr *res) | |
| 1054 | 1122 | { | |
| 1055 | 1123 | struct igen6_imc *imc = &igen6_pvt->imc[res->mc]; | |
| 1056 | - | u64 addr = res->imc_addr, sub_addr, s_size; | |
| 1057 | - | int idx, l_map; | |
| 1058 | - | u32 hash; | |
| 1124 | + | u64 addr = res->imc_addr, s_size; | |
| 1125 | + | int intlv_bit, l_map; | |
| 1126 | + | u32 hash, hash_mask; | |
| 1127 | + | struct slice slice; | |
| 1059 | 1128 | ||
| 1060 | 1129 | if (addr >= igen6_tom) { | |
| 1061 | 1130 | edac_dbg(0, "Address 0x%llx out of range\n", addr); | |
| @@ -1066,17 +1135,25 @@ static int igen6_decode(struct decoded_addr *res) | |||
| 1066 | 1135 | hash = readl(imc->window + CHANNEL_HASH_OFFSET); | |
| 1067 | 1136 | s_size = imc->ch_s_size; | |
| 1068 | 1137 | l_map = imc->ch_l_map; | |
| 1069 | - | decode_addr(addr, hash, s_size, l_map, &idx, &sub_addr); | |
| 1070 | - | res->channel_idx = idx; | |
| 1071 | - | res->channel_addr = sub_addr; | |
| 1138 | + | hash_mask = CHANNEL_HASH_MODE(hash) ? CHANNEL_HASH_MASK(hash) : 0; | |
| 1139 | + | intlv_bit = CHANNEL_HASH_LSB_MASK_BIT(hash) + 6; | |
| 1140 | + | ||
| 1141 | + | translate_to_lower_level(addr, hash_mask, 0, intlv_bit, s_size, l_map, &slice); | |
| 1142 | + | ||
| 1143 | + | res->channel_idx = slice.id; | |
| 1144 | + | res->channel_addr = slice.addr; | |
| 1072 | 1145 | ||
| 1073 | 1146 | /* Decode sub-channel/DIMM */ | |
| 1074 | 1147 | hash = readl(imc->window + CHANNEL_EHASH_OFFSET); | |
| 1075 | - | s_size = imc->dimm_s_size[idx]; | |
| 1076 | - | l_map = imc->dimm_l_map[idx]; | |
| 1077 | - | decode_addr(res->channel_addr, hash, s_size, l_map, &idx, &sub_addr); | |
| 1078 | - | res->sub_channel_idx = idx; | |
| 1079 | - | res->sub_channel_addr = sub_addr; | |
| 1148 | + | s_size = imc->dimm_s_size[res->channel_idx]; | |
| 1149 | + | l_map = imc->dimm_l_map[res->channel_idx]; | |
| 1150 | + | hash_mask = CHANNEL_HASH_MODE(hash) ? CHANNEL_HASH_MASK(hash) : 0; | |
| 1151 | + | intlv_bit = CHANNEL_HASH_LSB_MASK_BIT(hash) + 6; | |
| 1152 | + | ||
| 1153 | + | translate_to_lower_level(res->channel_addr, hash_mask, 0, intlv_bit, s_size, l_map, &slice); | |
| 1154 | + | ||
| 1155 | + | res->sub_channel_idx = slice.id; | |
| 1156 | + | res->sub_channel_addr = slice.addr; | |
| 1080 | 1157 | ||
| 1081 | 1158 | return 0; | |
| 1082 | 1159 | } | |
| @@ -1230,11 +1307,7 @@ static void ecclog_work_cb(struct work_struct *work) | |||
| 1230 | 1307 | ||
| 1231 | 1308 | llist_for_each_entry_safe(node, tmp, head, llnode) { | |
| 1232 | 1309 | memset(&res, 0, sizeof(res)); | |
| 1233 | - | if (res_cfg->err_addr) | |
| 1234 | - | eaddr = res_cfg->err_addr(node->ecclog); | |
| 1235 | - | else | |
| 1236 | - | eaddr = node->ecclog & res_cfg->reg_eccerrlog_addr_mask; | |
| 1237 | - | ||
| 1310 | + | eaddr = node->ecclog & res_cfg->reg_eccerrlog_addr_mask; | |
| 1238 | 1311 | res.mc = node->mc; | |
| 1239 | 1312 | res.sys_addr = res_cfg->err_addr_to_sys_addr(eaddr, res.mc); | |
| 1240 | 1313 | res.imc_addr = res_cfg->err_addr_to_imc_addr(eaddr, res.mc); | |
| @@ -1476,18 +1549,27 @@ static struct igen6_pvt *igen6_pvt_setup(struct pci_dev *pdev) | |||
| 1476 | 1549 | { | |
| 1477 | 1550 | void __iomem *memss_pma_cr; | |
| 1478 | 1551 | struct igen6_pvt *pvt; | |
| 1552 | + | int imc_num, rc; | |
| 1479 | 1553 | u64 mchbar; | |
| 1480 | - | int rc; | |
| 1481 | 1554 | ||
| 1482 | - | pvt = kzalloc_obj(*igen6_pvt); | |
| 1483 | - | if (!pvt) | |
| 1555 | + | rc = get_mchbar(pdev, &mchbar); | |
| 1556 | + | if (rc) | |
| 1484 | 1557 | return NULL; | |
| 1485 | 1558 | ||
| 1486 | - | rc = get_mchbar(pdev, &mchbar); | |
| 1487 | - | if (rc) { | |
| 1488 | - | kfree(pvt); | |
| 1559 | + | imc_num = get_imc_num(mchbar); | |
| 1560 | + | if (!imc_num) { | |
| 1561 | + | igen6_printk(KERN_ERR, "No mc found.\n"); | |
| 1489 | 1562 | return NULL; | |
| 1490 | 1563 | } | |
| 1564 | + | edac_dbg(2, "%d mcs found.\n", imc_num); | |
| 1565 | + | ||
| 1566 | + | /* Use the runtime detected IMC count. */ | |
| 1567 | + | if (res_cfg->num_imc != imc_num) | |
| 1568 | + | res_cfg->num_imc = imc_num; | |
| 1569 | + | ||
| 1570 | + | pvt = kzalloc_flex(*pvt, imc, imc_num); | |
| 1571 | + | if (!pvt) | |
| 1572 | + | return NULL; | |
| 1491 | 1573 | ||
| 1492 | 1574 | memss_pma_cr = ioremap(mchbar, MCHBAR_SIZE * 2); | |
| 1493 | 1575 | if (!memss_pma_cr) { | |
| @@ -1572,12 +1654,6 @@ static void igen6_check(struct mem_ctl_info *mci) | |||
| 1572 | 1654 | irq_work_queue(&ecclog_irq_work); | |
| 1573 | 1655 | } | |
| 1574 | 1656 | ||
| 1575 | - | /* Check whether the memory controller is absent. */ | |
| 1576 | - | static bool igen6_imc_absent(void __iomem *window) | |
| 1577 | - | { | |
| 1578 | - | return readl(window + MAD_INTER_CHANNEL_OFFSET) == ~0; | |
| 1579 | - | } | |
| 1580 | - | ||
| 1581 | 1657 | static void imc_release(struct device *dev) | |
| 1582 | 1658 | { | |
| 1583 | 1659 | /* Nothing to do, the 'imc' owns the 'dev' and will also release it. */ | |
| @@ -1689,26 +1765,15 @@ static int igen6_register_mcis(struct pci_dev *pdev, u64 mchbar) | |||
| 1689 | 1765 | { | |
| 1690 | 1766 | void __iomem *window; | |
| 1691 | 1767 | int lmc, pmc, rc; | |
| 1692 | - | u64 base; | |
| 1693 | - | ||
| 1694 | - | for (lmc = 0, pmc = 0; pmc < NUM_IMC; pmc++) { | |
| 1695 | - | base = mchbar + pmc * MCHBAR_SIZE; | |
| 1696 | - | window = ioremap(base, MCHBAR_SIZE); | |
| 1697 | - | if (!window) { | |
| 1698 | - | igen6_printk(KERN_ERR, "Failed to ioremap 0x%llx for mc%d\n", base, pmc); | |
| 1699 | - | rc = -ENOMEM; | |
| 1700 | - | goto out_unregister_mcis; | |
| 1701 | - | } | |
| 1702 | 1768 | ||
| 1703 | - | if (igen6_imc_absent(window)) { | |
| 1704 | - | iounmap(window); | |
| 1705 | - | edac_dbg(2, "Skip absent mc%d\n", pmc); | |
| 1769 | + | for (lmc = 0, pmc = 0; pmc < MAX_IMC_TO_PROBE; pmc++) { | |
| 1770 | + | window = map_imc_window(mchbar, pmc); | |
| 1771 | + | if (!window) | |
| 1706 | 1772 | continue; | |
| 1707 | - | } | |
| 1708 | 1773 | ||
| 1709 | 1774 | rc = igen6_register_mci(lmc, window, pdev); | |
| 1710 | 1775 | if (rc) | |
| 1711 | - | goto out_iounmap; | |
| 1776 | + | goto err_unregister; | |
| 1712 | 1777 | ||
| 1713 | 1778 | /* Done, if all present MCs are detected and registered. */ | |
| 1714 | 1779 | if (++lmc >= res_cfg->num_imc) | |
| @@ -1728,10 +1793,8 @@ static int igen6_register_mcis(struct pci_dev *pdev, u64 mchbar) | |||
| 1728 | 1793 | ||
| 1729 | 1794 | return 0; | |
| 1730 | 1795 | ||
| 1731 | - | out_iounmap: | |
| 1796 | + | err_unregister: | |
| 1732 | 1797 | iounmap(window); | |
| 1733 | - | ||
| 1734 | - | out_unregister_mcis: | |
| 1735 | 1798 | igen6_unregister_mcis(); | |
| 1736 | 1799 | ||
| 1737 | 1800 | return rc; | |
modified drivers/edac/thunderx_edac.c
| @@ -729,10 +729,8 @@ static int thunderx_lmc_probe(struct pci_dev *pdev, | |||
| 729 | 729 | thunderx_lmc_err_isr, | |
| 730 | 730 | thunderx_lmc_threaded_isr, 0, | |
| 731 | 731 | "[EDAC] ThunderX LMC", mci); | |
| 732 | - | if (ret) { | |
| 733 | - | dev_err(&pdev->dev, "Cannot set ISR: %d\n", ret); | |
| 732 | + | if (ret) | |
| 734 | 733 | goto err_free; | |
| 735 | - | } | |
| 736 | 734 | ||
| 737 | 735 | lmc->node = FIELD_GET(THUNDERX_NODE, pci_resource_start(pdev, 0)); | |
| 738 | 736 | ||
modified drivers/edac/versalnet_edac.c
| @@ -813,7 +813,7 @@ static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i | |||
| 813 | 813 | layers[1].is_virt_csrow = false; | |
| 814 | 814 | ||
| 815 | 815 | rc = -ENOMEM; | |
| 816 | - | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | |
| 816 | + | dev = kzalloc_obj(*dev); | |
| 817 | 817 | if (!dev) | |
| 818 | 818 | return rc; | |
| 819 | 819 | ||
modified drivers/edac/xgene_edac.c
| @@ -1924,11 +1924,8 @@ static int xgene_edac_probe(struct platform_device *pdev) | |||
| 1924 | 1924 | rc = devm_request_irq(&pdev->dev, irq, | |
| 1925 | 1925 | xgene_edac_isr, IRQF_SHARED, | |
| 1926 | 1926 | dev_name(&pdev->dev), edac); | |
| 1927 | - | if (rc) { | |
| 1928 | - | dev_err(&pdev->dev, | |
| 1929 | - | "Could not request IRQ %d\n", irq); | |
| 1927 | + | if (rc) | |
| 1930 | 1928 | goto out_err; | |
| 1931 | - | } | |
| 1932 | 1929 | } | |
| 1933 | 1930 | } | |
| 1934 | 1931 | ||
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 | * | |
| @@ -1792,7 +1792,7 @@ static void *scmi_iterator_init(const struct scmi_protocol_handle *ph, | |||
| 1792 | 1792 | { | |
| 1793 | 1793 | int ret; | |
| 1794 | 1794 | ||
| 1795 | - | struct scmi_iterator *i __free(kfree) = kzalloc(sizeof(*i), GFP_KERNEL); | |
| 1795 | + | struct scmi_iterator *i __free(kfree) = kzalloc_obj(*i); | |
| 1796 | 1796 | if (!i) | |
| 1797 | 1797 | return ERR_PTR(-ENOMEM); | |
| 1798 | 1798 | ||
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/firmware/qcom/qcom_tzmem.c
| @@ -169,7 +169,7 @@ static int qcom_tzmem_init_area(struct qcom_tzmem_area *area) | |||
| 169 | 169 | { | |
| 170 | 170 | int ret; | |
| 171 | 171 | ||
| 172 | - | u64 *handle __free(kfree) = kzalloc(sizeof(*handle), GFP_KERNEL); | |
| 172 | + | u64 *handle __free(kfree) = kzalloc_obj(*handle); | |
| 173 | 173 | if (!handle) | |
| 174 | 174 | return -ENOMEM; | |
| 175 | 175 | ||
| @@ -197,8 +197,7 @@ static int qcom_tzmem_pool_add_memory(struct qcom_tzmem_pool *pool, | |||
| 197 | 197 | { | |
| 198 | 198 | int ret; | |
| 199 | 199 | ||
| 200 | - | struct qcom_tzmem_area *area __free(kfree) = kzalloc(sizeof(*area), | |
| 201 | - | gfp); | |
| 200 | + | struct qcom_tzmem_area *area __free(kfree) = kzalloc_obj(*area, gfp); | |
| 202 | 201 | if (!area) | |
| 203 | 202 | return -ENOMEM; | |
| 204 | 203 | ||
| @@ -415,8 +414,7 @@ void *qcom_tzmem_alloc(struct qcom_tzmem_pool *pool, size_t size, gfp_t gfp) | |||
| 415 | 414 | ||
| 416 | 415 | size = PAGE_ALIGN(size); | |
| 417 | 416 | ||
| 418 | - | struct qcom_tzmem_chunk *chunk __free(kfree) = kzalloc(sizeof(*chunk), | |
| 419 | - | gfp); | |
| 417 | + | struct qcom_tzmem_chunk *chunk __free(kfree) = kzalloc_obj(*chunk, gfp); | |
| 420 | 418 | if (!chunk) | |
| 421 | 419 | return NULL; | |
| 422 | 420 | ||
modified drivers/firmware/ti_sci.c
| @@ -2386,7 +2386,7 @@ static int ti_sci_set_irq(const struct ti_sci_handle *handle, u32 valid_params, | |||
| 2386 | 2386 | if (ret || !(info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST)) | |
| 2387 | 2387 | goto end; | |
| 2388 | 2388 | ||
| 2389 | - | irq = kzalloc_obj(*irq, GFP_KERNEL); | |
| 2389 | + | irq = kzalloc_obj(*irq); | |
| 2390 | 2390 | if (!irq) { | |
| 2391 | 2391 | ti_sci_manage_irq(handle, valid_params, src_id, src_index, | |
| 2392 | 2392 | dst_id, dst_host_irq, ia_id, vint, | |
modified drivers/fpga/dfl-afu-dma-region.c
| @@ -316,7 +316,7 @@ int afu_dma_map_region(struct dfl_feature_dev_data *fdata, | |||
| 316 | 316 | if (user_addr + length < user_addr) | |
| 317 | 317 | return -EINVAL; | |
| 318 | 318 | ||
| 319 | - | region = kzalloc(sizeof(*region), GFP_KERNEL); | |
| 319 | + | region = kzalloc_obj(*region); | |
| 320 | 320 | if (!region) | |
| 321 | 321 | return -ENOMEM; | |
| 322 | 322 | ||
modified drivers/gpio/gpio-aggregator.c
| @@ -886,8 +886,8 @@ gpio_aggregator_make_device_sw_node(struct gpio_aggregator *aggr) | |||
| 886 | 886 | if (num_lines == 0) | |
| 887 | 887 | return NULL; | |
| 888 | 888 | ||
| 889 | - | const char **line_names __free(kfree) = kcalloc( | |
| 890 | - | num_lines, sizeof(*line_names), GFP_KERNEL); | |
| 889 | + | const char **line_names __free(kfree) = kzalloc_objs(*line_names, | |
| 890 | + | num_lines); | |
| 891 | 891 | if (!line_names) | |
| 892 | 892 | return ERR_PTR(-ENOMEM); | |
| 893 | 893 | ||
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-mpsse.c
| @@ -518,7 +518,7 @@ static void gpio_mpsse_irq_enable(struct irq_data *irqd) | |||
| 518 | 518 | * Can't be devm because it uses a non-raw spinlock (illegal in | |
| 519 | 519 | * this context, where a raw spinlock is held by our caller) | |
| 520 | 520 | */ | |
| 521 | - | worker = kzalloc(sizeof(*worker), GFP_NOWAIT); | |
| 521 | + | worker = kzalloc_obj(*worker, GFP_NOWAIT); | |
| 522 | 522 | if (!worker) | |
| 523 | 523 | return; | |
| 524 | 524 | ||
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-sim.c
| @@ -790,8 +790,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank, | |||
| 790 | 790 | ||
| 791 | 791 | line_names_size = gpio_sim_get_line_names_size(bank); | |
| 792 | 792 | if (line_names_size) { | |
| 793 | - | line_names = kcalloc(line_names_size, sizeof(*line_names), | |
| 794 | - | GFP_KERNEL); | |
| 793 | + | line_names = kzalloc_objs(*line_names, line_names_size); | |
| 795 | 794 | if (!line_names) | |
| 796 | 795 | return ERR_PTR(-ENOMEM); | |
| 797 | 796 | ||
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; | |
| @@ -1429,8 +1430,7 @@ gpio_virtuser_make_device_swnode(struct gpio_virtuser_device *dev) | |||
| 1429 | 1430 | memset(properties, 0, sizeof(properties)); | |
| 1430 | 1431 | ||
| 1431 | 1432 | num_ids = list_count_nodes(&dev->lookup_list); | |
| 1432 | - | char **ids __free(kfree) = kcalloc(num_ids + 1, sizeof(*ids), | |
| 1433 | - | GFP_KERNEL); | |
| 1433 | + | char **ids __free(kfree) = kzalloc_objs(*ids, num_ids + 1); | |
| 1434 | 1434 | if (!ids) | |
| 1435 | 1435 | return ERR_PTR(-ENOMEM); | |
| 1436 | 1436 | ||
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; | |
| @@ -2653,7 +2671,7 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file) | |||
| 2653 | 2671 | struct gpio_chardev_data *cdev; | |
| 2654 | 2672 | int ret = -ENOMEM; | |
| 2655 | 2673 | ||
| 2656 | - | cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); | |
| 2674 | + | cdev = kzalloc_obj(*cdev); | |
| 2657 | 2675 | if (!cdev) | |
| 2658 | 2676 | return -ENOMEM; | |
| 2659 | 2677 | ||
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 | |
| @@ -1178,7 +1185,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, | |||
| 1178 | 1185 | int base = 0; | |
| 1179 | 1186 | int ret; | |
| 1180 | 1187 | ||
| 1181 | - | gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); | |
| 1188 | + | gdev = kzalloc_obj(*gdev); | |
| 1182 | 1189 | if (!gdev) | |
| 1183 | 1190 | return -ENOMEM; | |
| 1184 | 1191 | gc->gpiodev = gdev; | |
| @@ -1218,7 +1225,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, | |||
| 1218 | 1225 | goto err_put_device; | |
| 1219 | 1226 | gdev->ngpio = gc->ngpio; | |
| 1220 | 1227 | ||
| 1221 | - | gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL); | |
| 1228 | + | gdev->descs = kzalloc_objs(*gdev->descs, gc->ngpio); | |
| 1222 | 1229 | if (!gdev->descs) { | |
| 1223 | 1230 | ret = -ENOMEM; | |
| 1224 | 1231 | goto err_put_device; | |
modified drivers/gpu/buddy.c
| @@ -411,16 +411,13 @@ int gpu_buddy_init(struct gpu_buddy *mm, u64 size, u64 chunk_size) | |||
| 411 | 411 | if (!mm->used_scoreboard) | |
| 412 | 412 | goto out_free_free_scoreboard; | |
| 413 | 413 | ||
| 414 | - | mm->free_trees = kmalloc_array(GPU_BUDDY_MAX_FREE_TREES, | |
| 415 | - | sizeof(*mm->free_trees), | |
| 416 | - | GFP_KERNEL); | |
| 414 | + | mm->free_trees = kmalloc_objs(*mm->free_trees, GPU_BUDDY_MAX_FREE_TREES); | |
| 417 | 415 | if (!mm->free_trees) | |
| 418 | 416 | goto out_free_used_scoreboard; | |
| 419 | 417 | ||
| 420 | 418 | for_each_free_tree(i) { | |
| 421 | - | mm->free_trees[i] = kmalloc_array(mm->max_order + 1, | |
| 422 | - | sizeof(struct rb_root), | |
| 423 | - | GFP_KERNEL); | |
| 419 | + | mm->free_trees[i] = kmalloc_objs(struct rb_root, | |
| 420 | + | mm->max_order + 1); | |
| 424 | 421 | if (!mm->free_trees[i]) | |
| 425 | 422 | goto out_free_tree; | |
| 426 | 423 | ||
| @@ -430,9 +427,7 @@ int gpu_buddy_init(struct gpu_buddy *mm, u64 size, u64 chunk_size) | |||
| 430 | 427 | ||
| 431 | 428 | mm->n_roots = hweight64(size); | |
| 432 | 429 | ||
| 433 | - | mm->roots = kmalloc_array(mm->n_roots, | |
| 434 | - | sizeof(struct gpu_buddy_block *), | |
| 435 | - | GFP_KERNEL); | |
| 430 | + | mm->roots = kmalloc_objs(struct gpu_buddy_block *, mm->n_roots); | |
| 436 | 431 | if (!mm->roots) | |
| 437 | 432 | goto out_free_tree; | |
| 438 | 433 | ||
modified drivers/gpu/drm/adp/Kconfig
| @@ -6,7 +6,6 @@ config DRM_ADP | |||
| 6 | 6 | select DRM_KMS_HELPER | |
| 7 | 7 | select DRM_BRIDGE_CONNECTOR | |
| 8 | 8 | select DRM_DISPLAY_HELPER | |
| 9 | - | select DRM_KMS_DMA_HELPER | |
| 10 | 9 | select DRM_GEM_DMA_HELPER | |
| 11 | 10 | select DRM_PANEL_BRIDGE | |
| 12 | 11 | select VIDEOMODE_HELPERS | |
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_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++) { | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
| @@ -1780,8 +1780,10 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) | |||
| 1780 | 1780 | ||
| 1781 | 1781 | /* Avoid accidently unparking the sched thread during GPU reset */ | |
| 1782 | 1782 | r = down_write_killable(&adev->reset_domain->sem); | |
| 1783 | - | if (r) | |
| 1783 | + | if (r) { | |
| 1784 | + | pm_runtime_put_autosuspend(dev->dev); | |
| 1784 | 1785 | return r; | |
| 1786 | + | } | |
| 1785 | 1787 | ||
| 1786 | 1788 | /* hold on the scheduler */ | |
| 1787 | 1789 | for (i = 0; i < AMDGPU_MAX_RINGS; i++) { | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
| @@ -299,10 +299,10 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p, | |||
| 299 | 299 | amdgpu_res_first(abo->tbo.resource, offset, | |
| 300 | 300 | coredump->ibs[i].ib_size_dw * 4, &cursor); | |
| 301 | 301 | while (cursor.remaining) { | |
| 302 | - | amdgpu_device_mm_access(adev, cursor.start / 4, | |
| 303 | - | &ib_content[off], cursor.size / 4, | |
| 302 | + | amdgpu_device_mm_access(adev, cursor.start, | |
| 303 | + | &ib_content[off], cursor.size, | |
| 304 | 304 | false); | |
| 305 | - | off += cursor.size; | |
| 305 | + | off += cursor.size / 4; | |
| 306 | 306 | amdgpu_res_next(&cursor, cursor.size); | |
| 307 | 307 | } | |
| 308 | 308 | emit_content = true; | |
| @@ -603,9 +603,8 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, | |||
| 603 | 603 | ring_count++; | |
| 604 | 604 | } | |
| 605 | 605 | if (ring_count) | |
| 606 | - | coredump->rings = kvcalloc(ring_count, | |
| 607 | - | sizeof(struct amdgpu_coredump_ring), | |
| 608 | - | GFP_NOWAIT); | |
| 606 | + | coredump->rings = kvzalloc_objs(struct amdgpu_coredump_ring, | |
| 607 | + | ring_count, GFP_NOWAIT); | |
| 609 | 608 | if (coredump->rings) { | |
| 610 | 609 | for (i = 0, idx = 0; i < adev->num_rings && idx < ring_count; i++) { | |
| 611 | 610 | struct amdgpu_coredump_ring *cdump_ring; | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
| @@ -771,6 +771,9 @@ static int amdgpu_device_read_fb_via_bar0(struct amdgpu_device *adev, | |||
| 771 | 771 | if (!buf || !size) | |
| 772 | 772 | return -EINVAL; | |
| 773 | 773 | ||
| 774 | + | if (!amdgpu_sriov_vf(adev)) | |
| 775 | + | return -EINVAL; | |
| 776 | + | ||
| 774 | 777 | flags = pci_resource_flags(adev->pdev, 0); | |
| 775 | 778 | if ((flags & IORESOURCE_UNSET) || !(flags & IORESOURCE_MEM)) | |
| 776 | 779 | return -EINVAL; | |
| @@ -1951,18 +1954,17 @@ static void amdgpu_uid_fini(struct amdgpu_device *adev) | |||
| 1951 | 1954 | adev->uid_info = NULL; | |
| 1952 | 1955 | } | |
| 1953 | 1956 | ||
| 1954 | - | static struct pci_dev *amdgpu_device_find_parent(struct amdgpu_device *adev) | |
| 1957 | + | static void amdgpu_device_init_pcie_links(struct amdgpu_device *adev) | |
| 1955 | 1958 | { | |
| 1956 | - | struct pci_dev *parent = adev->pdev; | |
| 1959 | + | adev->link_dev = adev->pdev; | |
| 1960 | + | adev->link_partner = pci_upstream_bridge(adev->link_dev); | |
| 1957 | 1961 | ||
| 1958 | - | /* skip upstream/downstream switches internal to dGPU */ | |
| 1959 | - | while ((parent = pci_upstream_bridge(parent))) { | |
| 1960 | - | if (parent->vendor == PCI_VENDOR_ID_ATI) | |
| 1961 | - | continue; | |
| 1962 | - | 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); | |
| 1963 | 1967 | } | |
| 1964 | - | ||
| 1965 | - | return parent; | |
| 1966 | 1968 | } | |
| 1967 | 1969 | ||
| 1968 | 1970 | /** | |
| @@ -1978,7 +1980,6 @@ static struct pci_dev *amdgpu_device_find_parent(struct amdgpu_device *adev) | |||
| 1978 | 1980 | static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) | |
| 1979 | 1981 | { | |
| 1980 | 1982 | struct amdgpu_ip_block *ip_block; | |
| 1981 | - | struct pci_dev *parent; | |
| 1982 | 1983 | bool total, skip_bios, early_full_gpu_access = false; | |
| 1983 | 1984 | uint32_t bios_flags; | |
| 1984 | 1985 | int i, r; | |
| @@ -2074,10 +2075,9 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) | |||
| 2074 | 2075 | !dev_is_removable(&adev->pdev->dev)) | |
| 2075 | 2076 | adev->flags |= AMD_IS_PX; | |
| 2076 | 2077 | ||
| 2077 | - | if (!(adev->flags & AMD_IS_APU)) { | |
| 2078 | - | parent = amdgpu_device_find_parent(adev); | |
| 2079 | - | adev->has_pr3 = parent ? pci_pr3_present(parent) : false; | |
| 2080 | - | } | |
| 2078 | + | if (!(adev->flags & AMD_IS_APU)) | |
| 2079 | + | adev->has_pr3 = adev->link_partner && | |
| 2080 | + | pci_pr3_present(adev->link_partner); | |
| 2081 | 2081 | ||
| 2082 | 2082 | adev->pm.pp_feature = amdgpu_pp_feature_mask; | |
| 2083 | 2083 | if (amdgpu_sriov_vf(adev) || sched_policy == KFD_SCHED_POLICY_NO_HWS) | |
| @@ -3773,6 +3773,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
| 3773 | 3773 | ||
| 3774 | 3774 | adev->shutdown = false; | |
| 3775 | 3775 | adev->flags = flags; | |
| 3776 | + | amdgpu_device_init_pcie_links(adev); | |
| 3776 | 3777 | ||
| 3777 | 3778 | if (amdgpu_force_asic_type >= 0 && amdgpu_force_asic_type < CHIP_LAST) | |
| 3778 | 3779 | adev->asic_type = amdgpu_force_asic_type; | |
| @@ -4334,7 +4335,7 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) | |||
| 4334 | 4335 | ||
| 4335 | 4336 | void amdgpu_device_fini_sw(struct amdgpu_device *adev) | |
| 4336 | 4337 | { | |
| 4337 | - | int i, idx; | |
| 4338 | + | int i; | |
| 4338 | 4339 | bool px; | |
| 4339 | 4340 | ||
| 4340 | 4341 | amdgpu_device_ip_fini(adev); | |
| @@ -4376,11 +4377,9 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev) | |||
| 4376 | 4377 | if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) | |
| 4377 | 4378 | vga_client_unregister(adev->pdev); | |
| 4378 | 4379 | ||
| 4379 | - | if (drm_dev_enter(adev_to_drm(adev), &idx)) { | |
| 4380 | - | ||
| 4380 | + | if (adev->rmmio) { | |
| 4381 | 4381 | iounmap(adev->rmmio); | |
| 4382 | 4382 | adev->rmmio = NULL; | |
| 4383 | - | drm_dev_exit(idx); | |
| 4384 | 4383 | } | |
| 4385 | 4384 | ||
| 4386 | 4385 | if (IS_ENABLED(CONFIG_PERF_EVENTS)) | |
| @@ -5869,11 +5868,9 @@ static void amdgpu_device_partner_bandwidth(struct amdgpu_device *adev, | |||
| 5869 | 5868 | *width = PCIE_LNK_WIDTH_UNKNOWN; | |
| 5870 | 5869 | ||
| 5871 | 5870 | if (amdgpu_device_pcie_dynamic_switching_supported(adev)) { | |
| 5872 | - | struct pci_dev *parent = amdgpu_device_find_parent(adev); | |
| 5873 | - | ||
| 5874 | - | if (parent) { | |
| 5875 | - | *speed = pcie_get_speed_cap(parent); | |
| 5876 | - | *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); | |
| 5877 | 5874 | } | |
| 5878 | 5875 | } else { | |
| 5879 | 5876 | /* use the current speeds rather than max if switching is not supported */ | |
| @@ -5895,21 +5892,11 @@ static void amdgpu_device_gpu_bandwidth(struct amdgpu_device *adev, | |||
| 5895 | 5892 | enum pci_bus_speed *speed, | |
| 5896 | 5893 | enum pcie_link_width *width) | |
| 5897 | 5894 | { | |
| 5898 | - | struct pci_dev *parent = adev->pdev; | |
| 5899 | - | ||
| 5900 | 5895 | if (!speed || !width) | |
| 5901 | 5896 | return; | |
| 5902 | 5897 | ||
| 5903 | - | /* use the device itself */ | |
| 5904 | - | *speed = pcie_get_speed_cap(adev->pdev); | |
| 5905 | - | *width = pcie_get_width_cap(adev->pdev); | |
| 5906 | - | ||
| 5907 | - | /* use the link outside the device */ | |
| 5908 | - | parent = amdgpu_device_find_parent(adev); | |
| 5909 | - | if (parent) { | |
| 5910 | - | *speed = pcie_get_speed_cap(parent); | |
| 5911 | - | *width = pcie_get_width_cap(parent); | |
| 5912 | - | } | |
| 5898 | + | *speed = pcie_get_speed_cap(adev->link_dev); | |
| 5899 | + | *width = pcie_get_width_cap(adev->link_dev); | |
| 5913 | 5900 | } | |
| 5914 | 5901 | ||
| 5915 | 5902 | /** | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
| @@ -1608,11 +1608,11 @@ int amdgpu_discovery_sysfs_early_init(struct amdgpu_device *adev, struct pci_dev | |||
| 1608 | 1608 | ||
| 1609 | 1609 | discovery_bin = adev->discovery.bin; | |
| 1610 | 1610 | ||
| 1611 | - | early_entry = kzalloc(sizeof(*early_entry), GFP_KERNEL); | |
| 1611 | + | early_entry = kzalloc_obj(*early_entry); | |
| 1612 | 1612 | if (!early_entry) | |
| 1613 | 1613 | return -ENOMEM; | |
| 1614 | 1614 | ||
| 1615 | - | ip_top = kzalloc(sizeof(*ip_top), GFP_KERNEL); | |
| 1615 | + | ip_top = kzalloc_obj(*ip_top); | |
| 1616 | 1616 | if (!ip_top) { | |
| 1617 | 1617 | kfree(early_entry); | |
| 1618 | 1618 | return -ENOMEM; | |
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_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_lockdep.c
| @@ -98,7 +98,7 @@ int amdgpu_lockdep_init(void) | |||
| 98 | 98 | struct amdgpu_lockdep_dummy_locks *locks; | |
| 99 | 99 | unsigned long flags; | |
| 100 | 100 | ||
| 101 | - | locks = kzalloc(sizeof(*locks), GFP_KERNEL); | |
| 101 | + | locks = kzalloc_obj(*locks); | |
| 102 | 102 | if (!locks) | |
| 103 | 103 | return -ENOMEM; | |
| 104 | 104 | ||
modified drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
| @@ -879,7 +879,7 @@ bool amdgpu_mes_queue_reset_by_mes_supported(struct amdgpu_device *adev) | |||
| 879 | 879 | ||
| 880 | 880 | return (ip_maj == 11 && mes_sched >= 0x8c) || | |
| 881 | 881 | ((ip_maj == 12 && ip_min == 0) && mes_sched >= 0x8d) || | |
| 882 | - | ((ip_maj == 12 && ip_min == 1) && mes_sched >= 0x73); | |
| 882 | + | ((ip_maj == 12 && ip_min == 1) && mes_sched >= 0x7b); | |
| 883 | 883 | } | |
| 884 | 884 | ||
| 885 | 885 | /* Fix me -- node_id is used to identify the correct MES instances in the future */ | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
| @@ -1701,9 +1701,8 @@ u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m) | |||
| 1701 | 1701 | if (dma_resv_trylock(bo->tbo.base.resv)) { | |
| 1702 | 1702 | dma_resv_describe(bo->tbo.base.resv, m); | |
| 1703 | 1703 | dma_resv_unlock(bo->tbo.base.resv); | |
| 1704 | - | } else { | |
| 1705 | - | seq_puts(m, "\n"); | |
| 1706 | 1704 | } | |
| 1705 | + | seq_puts(m, "\n"); | |
| 1707 | 1706 | ||
| 1708 | 1707 | return size; | |
| 1709 | 1708 | } | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
| @@ -396,6 +396,12 @@ static bool psp_get_runtime_db_entry(struct amdgpu_device *adev, | |||
| 396 | 396 | bool ret = false; | |
| 397 | 397 | int i; | |
| 398 | 398 | ||
| 399 | + | /* | |
| 400 | + | * Runtime DB is for dGPUs only. | |
| 401 | + | */ | |
| 402 | + | if (adev->flags & AMD_IS_APU) | |
| 403 | + | return false; | |
| 404 | + | ||
| 399 | 405 | if (amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 6) || | |
| 400 | 406 | amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 12) || | |
| 401 | 407 | amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 14) || | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
| @@ -1293,7 +1293,7 @@ amdgpu_ras_debugfs_table_read_uniras(struct amdgpu_device *adev, | |||
| 1293 | 1293 | return -ENOMEM; | |
| 1294 | 1294 | ||
| 1295 | 1295 | if (num_recs) { | |
| 1296 | - | records = kvcalloc(num_recs, sizeof(*records), GFP_KERNEL); | |
| 1296 | + | records = kvzalloc_objs(*records, num_recs); | |
| 1297 | 1297 | if (!records) { | |
| 1298 | 1298 | res = -ENOMEM; | |
| 1299 | 1299 | goto out; | |
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
| @@ -191,6 +191,8 @@ amdgpu_ttm_job_submit(struct amdgpu_device *adev, struct amdgpu_ttm_buffer_entit | |||
| 191 | 191 | * @tmz: if we should setup a TMZ enabled mapping | |
| 192 | 192 | * @size: in number of bytes to map, out number of bytes mapped | |
| 193 | 193 | * @addr: resulting address inside the MC address space | |
| 194 | + | * @vm_needs_flush: out, set true if a GART window was programmed (VMID 0 flush | |
| 195 | + | * needed) or false for a direct address | |
| 194 | 196 | * | |
| 195 | 197 | * Setup one of the GART windows to access a specific piece of memory or return | |
| 196 | 198 | * the physical address for local memory. | |
| @@ -200,7 +202,8 @@ static int amdgpu_ttm_map_buffer(struct amdgpu_ttm_buffer_entity *entity, | |||
| 200 | 202 | struct ttm_resource *mem, | |
| 201 | 203 | struct amdgpu_res_cursor *mm_cur, | |
| 202 | 204 | unsigned int window, | |
| 203 | - | bool tmz, uint64_t *size, uint64_t *addr) | |
| 205 | + | bool tmz, uint64_t *size, uint64_t *addr, | |
| 206 | + | bool *vm_needs_flush) | |
| 204 | 207 | { | |
| 205 | 208 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); | |
| 206 | 209 | unsigned int offset, num_pages, num_dw, num_bytes; | |
| @@ -221,9 +224,12 @@ static int amdgpu_ttm_map_buffer(struct amdgpu_ttm_buffer_entity *entity, | |||
| 221 | 224 | if (!tmz && mem->start != AMDGPU_BO_INVALID_OFFSET) { | |
| 222 | 225 | *addr = amdgpu_ttm_domain_start(adev, mem->mem_type) + | |
| 223 | 226 | mm_cur->start; | |
| 227 | + | *vm_needs_flush = false; | |
| 224 | 228 | return 0; | |
| 225 | 229 | } | |
| 226 | 230 | ||
| 231 | + | /* A GART window is programmed below, so its VMID 0 TLB needs a flush */ | |
| 232 | + | *vm_needs_flush = true; | |
| 227 | 233 | ||
| 228 | 234 | /* | |
| 229 | 235 | * If start begins at an offset inside the page, then adjust the size | |
| @@ -324,6 +330,7 @@ static int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev, | |||
| 324 | 330 | while (src_mm.remaining) { | |
| 325 | 331 | uint64_t from, to, cur_size, tiling_flags; | |
| 326 | 332 | uint32_t num_type, data_format, max_com, write_compress_disable; | |
| 333 | + | bool src_vm_flush, dst_vm_flush; | |
| 327 | 334 | struct dma_fence *next; | |
| 328 | 335 | ||
| 329 | 336 | /* Never copy more than 256MiB at once to avoid a timeout */ | |
| @@ -331,12 +338,12 @@ static int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev, | |||
| 331 | 338 | ||
| 332 | 339 | /* Map src to window 0 and dst to window 1. */ | |
| 333 | 340 | r = amdgpu_ttm_map_buffer(entity, src->bo, src->mem, &src_mm, | |
| 334 | - | 0, tmz, &cur_size, &from); | |
| 341 | + | 0, tmz, &cur_size, &from, &src_vm_flush); | |
| 335 | 342 | if (r) | |
| 336 | 343 | goto error; | |
| 337 | 344 | ||
| 338 | 345 | r = amdgpu_ttm_map_buffer(entity, dst->bo, dst->mem, &dst_mm, | |
| 339 | - | 1, tmz, &cur_size, &to); | |
| 346 | + | 1, tmz, &cur_size, &to, &dst_vm_flush); | |
| 340 | 347 | if (r) | |
| 341 | 348 | goto error; | |
| 342 | 349 | ||
| @@ -364,7 +371,7 @@ static int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev, | |||
| 364 | 371 | } | |
| 365 | 372 | ||
| 366 | 373 | r = amdgpu_copy_buffer(adev, entity, from, to, cur_size, resv, | |
| 367 | - | &next, true, copy_flags); | |
| 374 | + | &next, src_vm_flush || dst_vm_flush, copy_flags); | |
| 368 | 375 | if (r) | |
| 369 | 376 | goto error; | |
| 370 | 377 | ||
| @@ -2361,9 +2368,8 @@ void amdgpu_ttm_enable_buffer_funcs(struct amdgpu_device *adev) | |||
| 2361 | 2368 | num_clear_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES); | |
| 2362 | 2369 | num_move_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES); | |
| 2363 | 2370 | ||
| 2364 | - | adev->mman.clear_entities = kcalloc(num_clear_entities, | |
| 2365 | - | sizeof(struct amdgpu_ttm_buffer_entity), | |
| 2366 | - | GFP_KERNEL); | |
| 2371 | + | adev->mman.clear_entities = kzalloc_objs(struct amdgpu_ttm_buffer_entity, | |
| 2372 | + | num_clear_entities); | |
| 2367 | 2373 | atomic_set(&adev->mman.next_clear_entity, 0); | |
| 2368 | 2374 | if (!adev->mman.clear_entities) | |
| 2369 | 2375 | goto error_free_default_entity; | |
| @@ -2625,6 +2631,7 @@ int amdgpu_ttm_clear_buffer(struct amdgpu_ttm_buffer_entity *entity, | |||
| 2625 | 2631 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); | |
| 2626 | 2632 | struct dma_fence *fence = NULL; | |
| 2627 | 2633 | struct amdgpu_res_cursor dst; | |
| 2634 | + | bool vm_needs_flush = false; | |
| 2628 | 2635 | int r; | |
| 2629 | 2636 | ||
| 2630 | 2637 | if (!entity) | |
| @@ -2646,13 +2653,13 @@ int amdgpu_ttm_clear_buffer(struct amdgpu_ttm_buffer_entity *entity, | |||
| 2646 | 2653 | cur_size = min(dst.size, 256ULL << 20); | |
| 2647 | 2654 | ||
| 2648 | 2655 | r = amdgpu_ttm_map_buffer(entity, &bo->tbo, bo->tbo.resource, &dst, | |
| 2649 | - | 0, false, &cur_size, &to); | |
| 2656 | + | 0, false, &cur_size, &to, &vm_needs_flush); | |
| 2650 | 2657 | if (r) | |
| 2651 | 2658 | goto error; | |
| 2652 | 2659 | ||
| 2653 | 2660 | r = amdgpu_ttm_fill_mem(adev, entity, | |
| 2654 | 2661 | 0, to, cur_size, resv, | |
| 2655 | - | &next, true, k_job_id); | |
| 2662 | + | &next, vm_needs_flush, k_job_id); | |
| 2656 | 2663 | if (r) | |
| 2657 | 2664 | goto error; | |
| 2658 | 2665 | ||
modified drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c
| @@ -159,8 +159,8 @@ void amdgpu_umc_handle_bad_pages(struct amdgpu_device *adev, | |||
| 159 | 159 | adev->umc.ras->ecc_info_query_ras_error_address && | |
| 160 | 160 | adev->umc.max_ras_err_cnt_per_query) { | |
| 161 | 161 | err_data->err_addr = | |
| 162 | - | kcalloc(adev->umc.max_ras_err_cnt_per_query, | |
| 163 | - | sizeof(struct eeprom_table_record), GFP_KERNEL); | |
| 162 | + | kzalloc_objs(struct eeprom_table_record, | |
| 163 | + | adev->umc.max_ras_err_cnt_per_query); | |
| 164 | 164 | ||
| 165 | 165 | /* still call query_ras_error_address to clear error status | |
| 166 | 166 | * even NOMEM error is encountered | |
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) | |
| @@ -1272,7 +1272,7 @@ amdgpu_userq_evict_all(struct amdgpu_userq_mgr *uq_mgr) | |||
| 1272 | 1272 | return ret; | |
| 1273 | 1273 | } | |
| 1274 | 1274 | ||
| 1275 | - | static void | |
| 1275 | + | void | |
| 1276 | 1276 | amdgpu_userq_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr) | |
| 1277 | 1277 | { | |
| 1278 | 1278 | struct amdgpu_usermode_queue *queue; | |
| @@ -1291,8 +1291,6 @@ amdgpu_userq_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr) | |||
| 1291 | 1291 | void | |
| 1292 | 1292 | amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr) | |
| 1293 | 1293 | { | |
| 1294 | - | /* Wait for any pending userqueue fence work to finish */ | |
| 1295 | - | amdgpu_userq_wait_for_signal(uq_mgr); | |
| 1296 | 1294 | amdgpu_userq_evict_all(uq_mgr); | |
| 1297 | 1295 | } | |
| 1298 | 1296 | ||
| @@ -1544,7 +1542,7 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost) | |||
| 1544 | 1542 | struct amdgpu_usermode_queue *queue; | |
| 1545 | 1543 | const struct amdgpu_userq_funcs *userq_funcs; | |
| 1546 | 1544 | unsigned long queue_id; | |
| 1547 | - | int r = 0; | |
| 1545 | + | int ret = 0, r; | |
| 1548 | 1546 | ||
| 1549 | 1547 | xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) { | |
| 1550 | 1548 | if (queue->state == AMDGPU_USERQ_STATE_HUNG && !vram_lost) { | |
| @@ -1555,6 +1553,7 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost) | |||
| 1555 | 1553 | r = userq_funcs->map(queue); | |
| 1556 | 1554 | if (r) { | |
| 1557 | 1555 | dev_err(adev->dev, "Failed to remap queue %ld\n", queue_id); | |
| 1556 | + | ret = r; | |
| 1558 | 1557 | continue; | |
| 1559 | 1558 | } | |
| 1560 | 1559 | trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_MAPPED); | |
| @@ -1562,5 +1561,5 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost) | |||
| 1562 | 1561 | } | |
| 1563 | 1562 | } | |
| 1564 | 1563 | ||
| 1565 | - | return r; | |
| 1564 | + | return ret; | |
| 1566 | 1565 | } | |
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_userq_fence.c
| @@ -227,7 +227,7 @@ static int amdgpu_userq_fence_alloc(struct amdgpu_usermode_queue *userq, | |||
| 227 | 227 | struct amdgpu_userq_fence *userq_fence; | |
| 228 | 228 | void *entry; | |
| 229 | 229 | ||
| 230 | - | userq_fence = kmalloc(sizeof(*userq_fence), GFP_KERNEL); | |
| 230 | + | userq_fence = kmalloc_obj(*userq_fence); | |
| 231 | 231 | if (!userq_fence) | |
| 232 | 232 | return -ENOMEM; | |
| 233 | 233 | ||
| @@ -244,9 +244,7 @@ static int amdgpu_userq_fence_alloc(struct amdgpu_usermode_queue *userq, | |||
| 244 | 244 | } while (xas_retry(&xas, entry)); | |
| 245 | 245 | rcu_read_unlock(); | |
| 246 | 246 | ||
| 247 | - | userq_fence->fence_drv_array = kvmalloc_array(xas.xa_index, | |
| 248 | - | sizeof(fence_drv), | |
| 249 | - | GFP_KERNEL); | |
| 247 | + | userq_fence->fence_drv_array = kvmalloc_objs(fence_drv, xas.xa_index); | |
| 250 | 248 | if (!userq_fence->fence_drv_array) { | |
| 251 | 249 | mutex_unlock(&userq->fence_drv_lock); | |
| 252 | 250 | kfree(userq_fence); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
| @@ -316,8 +316,8 @@ static int amdgpu_virt_ras_realloc_eh_data_space(struct amdgpu_device *adev, | |||
| 316 | 316 | if (align_space > AMDGPU_VIRT_RAS_BAD_PAGE_TABLE_MAX_CAPACITY) | |
| 317 | 317 | return -ENOMEM; | |
| 318 | 318 | ||
| 319 | - | new_bps = kmalloc_array(align_space, sizeof(*data->bps), GFP_KERNEL); | |
| 320 | - | new_bo = kcalloc(align_space, sizeof(*data->bps_bo), GFP_KERNEL); | |
| 319 | + | new_bps = kmalloc_objs(*data->bps, align_space); | |
| 320 | + | new_bo = kzalloc_objs(*data->bps_bo, align_space); | |
| 321 | 321 | if (!new_bps || !new_bo) { | |
| 322 | 322 | kfree(new_bps); | |
| 323 | 323 | kfree(new_bo); | |
| @@ -355,7 +355,7 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev) | |||
| 355 | 355 | if (!bps) | |
| 356 | 356 | goto bps_failure; | |
| 357 | 357 | ||
| 358 | - | bps_bo = kcalloc(align_space, sizeof(*(*data)->bps_bo), GFP_KERNEL); | |
| 358 | + | bps_bo = kzalloc_objs(*(*data)->bps_bo, align_space); | |
| 359 | 359 | if (!bps_bo) | |
| 360 | 360 | goto bps_bo_failure; | |
| 361 | 361 | ||
modified drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
| @@ -2090,7 +2090,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, | |||
| 2090 | 2090 | after->start = eaddr + 1; | |
| 2091 | 2091 | after->last = tmp->last; | |
| 2092 | 2092 | after->offset = tmp->offset; | |
| 2093 | - | after->offset += (after->start - tmp->start) << PAGE_SHIFT; | |
| 2093 | + | after->offset += (after->start - tmp->start) << AMDGPU_GPU_PAGE_SHIFT; | |
| 2094 | 2094 | after->flags = tmp->flags; | |
| 2095 | 2095 | after->bo_va = tmp->bo_va; | |
| 2096 | 2096 | list_add(&after->list, &tmp->bo_va->invalids); | |
| @@ -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); | |
| @@ -3122,7 +3123,7 @@ static void amdgpu_debugfs_vm_bo_status_info(struct seq_file *m, | |||
| 3122 | 3123 | ||
| 3123 | 3124 | id = 0; | |
| 3124 | 3125 | seq_puts(m, "\tIdle BOs:\n"); | |
| 3125 | - | list_for_each_entry(base, &lists->needs_update, vm_status) { | |
| 3126 | + | list_for_each_entry(base, &lists->idle, vm_status) { | |
| 3126 | 3127 | if (!base->bo) | |
| 3127 | 3128 | continue; | |
| 3128 | 3129 | ||
modified drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
| @@ -1651,10 +1651,10 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block) | |||
| 1651 | 1651 | case IP_VERSION(11, 0, 2): | |
| 1652 | 1652 | case IP_VERSION(11, 0, 3): | |
| 1653 | 1653 | if (!adev->gfx.disable_uq && | |
| 1654 | - | adev->gfx.me_fw_version >= 2420 && | |
| 1655 | - | adev->gfx.pfp_fw_version >= 2580 && | |
| 1656 | - | adev->gfx.mec_fw_version >= 2650 && | |
| 1657 | - | adev->mes.fw_version[0] >= 120) { | |
| 1654 | + | adev->gfx.me_fw_version >= 3090 && | |
| 1655 | + | adev->gfx.pfp_fw_version >= 3190 && | |
| 1656 | + | adev->gfx.mec_fw_version >= 3450 && | |
| 1657 | + | adev->mes.fw_version[0] >= 147) { | |
| 1658 | 1658 | adev->userq_funcs[AMDGPU_HW_IP_GFX] = &userq_mes_funcs; | |
| 1659 | 1659 | adev->userq_funcs[AMDGPU_HW_IP_COMPUTE] = &userq_mes_funcs; | |
| 1660 | 1660 | } | |
modified drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
| @@ -1436,10 +1436,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block) | |||
| 1436 | 1436 | case IP_VERSION(12, 0, 0): | |
| 1437 | 1437 | case IP_VERSION(12, 0, 1): | |
| 1438 | 1438 | if (!adev->gfx.disable_uq && | |
| 1439 | - | adev->gfx.me_fw_version >= 2780 && | |
| 1440 | - | adev->gfx.pfp_fw_version >= 2840 && | |
| 1441 | - | adev->gfx.mec_fw_version >= 3050 && | |
| 1442 | - | adev->mes.fw_version[0] >= 123) { | |
| 1439 | + | adev->gfx.me_fw_version >= 3090 && | |
| 1440 | + | adev->gfx.pfp_fw_version >= 3190 && | |
| 1441 | + | adev->gfx.mec_fw_version >= 3450 && | |
| 1442 | + | adev->mes.fw_version[0] >= 147) { | |
| 1443 | 1443 | adev->userq_funcs[AMDGPU_HW_IP_GFX] = &userq_mes_funcs; | |
| 1444 | 1444 | adev->userq_funcs[AMDGPU_HW_IP_COMPUTE] = &userq_mes_funcs; | |
| 1445 | 1445 | } | |
modified drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
| @@ -4546,9 +4546,11 @@ static int gfx_v8_0_mqd_init(struct amdgpu_ring *ring) | |||
| 4546 | 4546 | /* set static priority for a queue/ring */ | |
| 4547 | 4547 | gfx_v8_0_mqd_set_priority(ring, mqd); | |
| 4548 | 4548 | tmp = RREG32(mmCP_HQD_QUANTUM); | |
| 4549 | - | tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_EN, 1); | |
| 4550 | - | tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1); | |
| 4551 | - | tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 10); | |
| 4549 | + | if (ring != &adev->gfx.kiq[0].ring) { | |
| 4550 | + | tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_EN, 1); | |
| 4551 | + | tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1); | |
| 4552 | + | tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 10); | |
| 4553 | + | } | |
| 4552 | 4554 | mqd->cp_hqd_quantum = tmp; | |
| 4553 | 4555 | ||
| 4554 | 4556 | /* map_queues packet doesn't need activate the queue, | |
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/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/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 | ||
| @@ -1921,13 +1964,13 @@ static int criu_checkpoint_devices(struct kfd_process *p, | |||
| 1921 | 1964 | struct kfd_criu_device_bucket *device_buckets = NULL; | |
| 1922 | 1965 | int ret = 0, i; | |
| 1923 | 1966 | ||
| 1924 | - | device_buckets = kvcalloc(num_devices, sizeof(*device_buckets), GFP_KERNEL); | |
| 1967 | + | device_buckets = kvzalloc_objs(*device_buckets, num_devices); | |
| 1925 | 1968 | if (!device_buckets) { | |
| 1926 | 1969 | ret = -ENOMEM; | |
| 1927 | 1970 | goto exit; | |
| 1928 | 1971 | } | |
| 1929 | 1972 | ||
| 1930 | - | device_priv = kvcalloc(num_devices, sizeof(*device_priv), GFP_KERNEL); | |
| 1973 | + | device_priv = kvzalloc_objs(*device_priv, num_devices); | |
| 1931 | 1974 | if (!device_priv) { | |
| 1932 | 1975 | ret = -ENOMEM; | |
| 1933 | 1976 | goto exit; | |
| @@ -2047,17 +2090,17 @@ static int criu_checkpoint_bos(struct kfd_process *p, | |||
| 2047 | 2090 | int ret = 0, pdd_index, bo_index = 0, id; | |
| 2048 | 2091 | void *mem; | |
| 2049 | 2092 | ||
| 2050 | - | bo_buckets = kvcalloc(num_bos, sizeof(*bo_buckets), GFP_KERNEL); | |
| 2093 | + | bo_buckets = kvzalloc_objs(*bo_buckets, num_bos); | |
| 2051 | 2094 | if (!bo_buckets) | |
| 2052 | 2095 | return -ENOMEM; | |
| 2053 | 2096 | ||
| 2054 | - | bo_privs = kvcalloc(num_bos, sizeof(*bo_privs), GFP_KERNEL); | |
| 2097 | + | bo_privs = kvzalloc_objs(*bo_privs, num_bos); | |
| 2055 | 2098 | if (!bo_privs) { | |
| 2056 | 2099 | ret = -ENOMEM; | |
| 2057 | 2100 | goto exit; | |
| 2058 | 2101 | } | |
| 2059 | 2102 | ||
| 2060 | - | files = kvcalloc(num_bos, sizeof(struct file *), GFP_KERNEL); | |
| 2103 | + | files = kvzalloc_objs(struct file *, num_bos); | |
| 2061 | 2104 | if (!files) { | |
| 2062 | 2105 | ret = -ENOMEM; | |
| 2063 | 2106 | goto exit; | |
| @@ -2588,7 +2631,7 @@ static int criu_restore_bos(struct kfd_process *p, | |||
| 2588 | 2631 | if (!bo_buckets) | |
| 2589 | 2632 | return -ENOMEM; | |
| 2590 | 2633 | ||
| 2591 | - | files = kvcalloc(args->num_bos, sizeof(struct file *), GFP_KERNEL); | |
| 2634 | + | files = kvzalloc_objs(struct file *, args->num_bos); | |
| 2592 | 2635 | if (!files) { | |
| 2593 | 2636 | ret = -ENOMEM; | |
| 2594 | 2637 | goto exit; | |
modified drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
| @@ -770,10 +770,12 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm, | |||
| 770 | 770 | mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type( | |
| 771 | 771 | q->properties.type)]; | |
| 772 | 772 | if (qd && !mqd_mgr->restore_mqd) { | |
| 773 | - | pr_debug("restore_mqd not implemented for this GPU\n"); | |
| 773 | + | pr_debug("restore_mqd not implemented for queue type %d\n", | |
| 774 | + | q->properties.type); | |
| 774 | 775 | retval = -EOPNOTSUPP; | |
| 775 | 776 | goto deallocate_vmid; | |
| 776 | 777 | } | |
| 778 | + | ||
| 777 | 779 | if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE) { | |
| 778 | 780 | retval = allocate_hqd(dqm, q); | |
| 779 | 781 | if (retval) | |
| @@ -1455,6 +1457,14 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm, | |||
| 1455 | 1457 | dqm_evict_mqd_bo(dqm, q); | |
| 1456 | 1458 | } | |
| 1457 | 1459 | ||
| 1460 | + | /* | |
| 1461 | + | * Heavy-weight TLB flush after MES removes queues to ensure | |
| 1462 | + | * in-flight memory accesses complete before memory is freed/migrated. | |
| 1463 | + | * HWS does this automatically, MES does not. | |
| 1464 | + | */ | |
| 1465 | + | if (dqm->dev->kfd->shared_resources.enable_mes) | |
| 1466 | + | kfd_flush_tlb(pdd); | |
| 1467 | + | ||
| 1458 | 1468 | if (!dqm->dev->kfd->shared_resources.enable_mes) { | |
| 1459 | 1469 | pdd->last_evict_timestamp = get_jiffies_64(); | |
| 1460 | 1470 | retval = execute_queues_cpsch(dqm, | |
| @@ -2242,7 +2252,8 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, | |||
| 2242 | 2252 | mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type( | |
| 2243 | 2253 | q->properties.type)]; | |
| 2244 | 2254 | if (qd && !mqd_mgr->restore_mqd) { | |
| 2245 | - | pr_debug("restore_mqd not implemented for this GPU\n"); | |
| 2255 | + | pr_debug("restore_mqd not implemented for queue type %d\n", | |
| 2256 | + | q->properties.type); | |
| 2246 | 2257 | retval = -EOPNOTSUPP; | |
| 2247 | 2258 | goto out_deallocate_doorbell; | |
| 2248 | 2259 | } | |
| @@ -3746,8 +3757,11 @@ int suspend_queues(struct kfd_process *p, | |||
| 3746 | 3757 | if (!per_device_suspended) { | |
| 3747 | 3758 | dqm_unlock(dqm); | |
| 3748 | 3759 | mutex_unlock(&p->event_mutex); | |
| 3749 | - | if (total_suspended) | |
| 3760 | + | if (total_suspended) { | |
| 3750 | 3761 | amdgpu_amdkfd_debug_mem_fence(dqm->dev->adev); | |
| 3762 | + | /* Heavy-weight TLB flush after MES suspends queues */ | |
| 3763 | + | kfd_flush_tlb(pdd); | |
| 3764 | + | } | |
| 3751 | 3765 | continue; | |
| 3752 | 3766 | } | |
| 3753 | 3767 | ||
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_process_queue_manager.c
| @@ -1169,13 +1169,13 @@ int pqm_debugfs_mqds(struct seq_file *m, void *data) | |||
| 1169 | 1169 | mqd_mgr = q->device->dqm->mqd_mgrs[mqd_type]; | |
| 1170 | 1170 | size = mqd_mgr->mqd_stride(mqd_mgr, | |
| 1171 | 1171 | &q->properties); | |
| 1172 | - | } | |
| 1173 | 1172 | ||
| 1174 | - | for (xcc = 0; xcc < num_xccs; xcc++) { | |
| 1175 | - | mqd = q->mqd + size * xcc; | |
| 1176 | - | r = mqd_mgr->debugfs_show_mqd(m, mqd); | |
| 1177 | - | if (r != 0) | |
| 1178 | - | break; | |
| 1173 | + | for (xcc = 0; xcc < num_xccs; xcc++) { | |
| 1174 | + | mqd = q->mqd + size * xcc; | |
| 1175 | + | r = mqd_mgr->debugfs_show_mqd(m, mqd); | |
| 1176 | + | if (r != 0) | |
| 1177 | + | break; | |
| 1178 | + | } | |
| 1179 | 1179 | } | |
| 1180 | 1180 | } | |
| 1181 | 1181 | ||
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
| @@ -747,9 +747,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev) | |||
| 747 | 747 | } | |
| 748 | 748 | if (adev->dm.dc->caps.max_links > 0) { | |
| 749 | 749 | adev->dm.hdmi_frl_status_polling_wq = | |
| 750 | - | create_singlethread_workqueue("hdmi_frl_status_polling_workqueue"); | |
| 750 | + | create_singlethread_workqueue("hdmi_frl_status_polling_wq"); | |
| 751 | 751 | if (!adev->dm.hdmi_frl_status_polling_wq) | |
| 752 | - | drm_err(adev_to_drm(adev), "failed to initialize hdmi_frl_status_polling_workqueue\n"); | |
| 752 | + | drm_err(adev_to_drm(adev), "failed to initialize hdmi_frl_status_polling_wq\n"); | |
| 753 | 753 | } | |
| 754 | 754 | if (dc_is_dmub_outbox_supported(adev->dm.dc)) { | |
| 755 | 755 | init_completion(&adev->dm.dmub_aux_transfer_done); | |
| @@ -1420,7 +1420,7 @@ static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev, | |||
| 1420 | 1420 | if (acrtc && state->stream_status[i].plane_count != 0 && | |
| 1421 | 1421 | amdgpu_ip_version(adev, DCE_HWIP, 0) == 0) { | |
| 1422 | 1422 | irq_source = IRQ_TYPE_PFLIP + acrtc->otg_inst; | |
| 1423 | - | rc = dc_interrupt_set(adev->dm.dc, irq_source, enable) ? 0 : -EBUSY; | |
| 1423 | + | rc = amdgpu_dm_irq_set(adev, irq_source, enable) ? 0 : -EBUSY; | |
| 1424 | 1424 | if (rc) | |
| 1425 | 1425 | drm_warn(adev_to_drm(adev), "Failed to %s pflip interrupts\n", | |
| 1426 | 1426 | enable ? "enable" : "disable"); | |
| @@ -1444,7 +1444,7 @@ static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev, | |||
| 1444 | 1444 | /* During gpu-reset we disable and then enable vblank irq, so | |
| 1445 | 1445 | * don't use amdgpu_irq_get/put() to avoid refcount change. | |
| 1446 | 1446 | */ | |
| 1447 | - | if (!dc_interrupt_set(adev->dm.dc, irq_source, enable)) | |
| 1447 | + | if (!amdgpu_dm_irq_set(adev, irq_source, enable)) | |
| 1448 | 1448 | drm_warn(adev_to_drm(adev), "Failed to %sable vblank interrupt\n", enable ? "en" : "dis"); | |
| 1449 | 1449 | ||
| 1450 | 1450 | } else if (acrtc && state->stream_status[i].plane_count != 0) { | |
| @@ -1972,6 +1972,10 @@ static int dm_resume(struct amdgpu_ip_block *ip_block) | |||
| 1972 | 1972 | /* On resume we need to rewrite the MSTM control bits to enable MST*/ | |
| 1973 | 1973 | s3_handle_mst(ddev, false); | |
| 1974 | 1974 | ||
| 1975 | + | /* Exit IPS before the detection loop's first AUX/DDC access. */ | |
| 1976 | + | scoped_guard(mutex, &dm->dc_lock) | |
| 1977 | + | dc_exit_ips_for_hw_access(dm->dc); | |
| 1978 | + | ||
| 1975 | 1979 | /* Do detection*/ | |
| 1976 | 1980 | drm_connector_list_iter_begin(ddev, &iter); | |
| 1977 | 1981 | drm_for_each_connector_iter(connector, &iter) { | |
| @@ -3879,7 +3883,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state, | |||
| 3879 | 3883 | continue; | |
| 3880 | 3884 | ||
| 3881 | 3885 | bundle->surface_updates[planes_count].surface = dc_plane; | |
| 3882 | - | if (new_pcrtc_state->color_mgmt_changed) { | |
| 3886 | + | if (new_pcrtc_state->color_mgmt_changed || new_plane_state->color_mgmt_changed) { | |
| 3883 | 3887 | bundle->surface_updates[planes_count].gamma = &dc_plane->gamma_correction; | |
| 3884 | 3888 | bundle->surface_updates[planes_count].in_transfer_func = &dc_plane->in_transfer_func; | |
| 3885 | 3889 | bundle->surface_updates[planes_count].gamut_remap_matrix = &dc_plane->gamut_remap_matrix; | |
| @@ -5579,8 +5583,10 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm, | |||
| 5579 | 5583 | ||
| 5580 | 5584 | skip_modeset: | |
| 5581 | 5585 | /* Release extra reference */ | |
| 5582 | - | if (new_stream) | |
| 5586 | + | if (new_stream) { | |
| 5583 | 5587 | dc_stream_release(new_stream); | |
| 5588 | + | new_stream = NULL; | |
| 5589 | + | } | |
| 5584 | 5590 | new_stream = NULL; | |
| 5585 | 5591 | ||
| 5586 | 5592 | /* | |
| @@ -5698,6 +5704,10 @@ static bool should_reset_plane(struct drm_atomic_commit *state, | |||
| 5698 | 5704 | if (new_crtc_state->color_mgmt_changed) | |
| 5699 | 5705 | return true; | |
| 5700 | 5706 | ||
| 5707 | + | /* Plane color pipeline or its colorop changes. */ | |
| 5708 | + | if (new_plane_state->color_mgmt_changed) | |
| 5709 | + | return true; | |
| 5710 | + | ||
| 5701 | 5711 | /* | |
| 5702 | 5712 | * On zpos change, planes need to be reordered by removing and re-adding | |
| 5703 | 5713 | * them one by one to the dc state, in order of descending zpos. | |
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
| @@ -534,8 +534,12 @@ void amdgpu_dm_update_connector_ext_caps(struct amdgpu_dm_connector *aconnector) | |||
| 534 | 534 | else if (!IS_ERR_OR_NULL(panel_backlight_quirk) && | |
| 535 | 535 | panel_backlight_quirk->force_pwm) | |
| 536 | 536 | caps->aux_support = false; | |
| 537 | - | if (caps->aux_support) | |
| 538 | - | aconnector->dc_link->backlight_control_type = BACKLIGHT_CONTROL_AMD_AUX; | |
| 537 | + | if (caps->aux_support) { | |
| 538 | + | if (aconnector->dc_link->dpcd_caps.panel_luminance_control) | |
| 539 | + | aconnector->dc_link->backlight_control_type = BACKLIGHT_CONTROL_VESA_AUX; | |
| 540 | + | else | |
| 541 | + | aconnector->dc_link->backlight_control_type = BACKLIGHT_CONTROL_AMD_AUX; | |
| 542 | + | } | |
| 539 | 543 | ||
| 540 | 544 | luminance_range = &conn_base->display_info.luminance_range; | |
| 541 | 545 | ||
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
| @@ -756,10 +756,14 @@ amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing, | |||
| 756 | 756 | break; | |
| 757 | 757 | case DRM_MODE_COLORIMETRY_BT2020_RGB: | |
| 758 | 758 | case DRM_MODE_COLORIMETRY_BT2020_YCC: | |
| 759 | - | if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) | |
| 760 | - | color_space = COLOR_SPACE_2020_RGB_FULLRANGE; | |
| 761 | - | else | |
| 759 | + | if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) { | |
| 760 | + | if (connector_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED) | |
| 761 | + | color_space = COLOR_SPACE_2020_RGB_LIMITEDRANGE; | |
| 762 | + | else | |
| 763 | + | color_space = COLOR_SPACE_2020_RGB_FULLRANGE; | |
| 764 | + | } else { | |
| 762 | 765 | color_space = COLOR_SPACE_2020_YCBCR_LIMITED; | |
| 766 | + | } | |
| 763 | 767 | break; | |
| 764 | 768 | case DRM_MODE_COLORIMETRY_DEFAULT: /* ITU601 */ | |
| 765 | 769 | default: | |
| @@ -3937,17 +3941,15 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, | |||
| 3937 | 3941 | } | |
| 3938 | 3942 | ||
| 3939 | 3943 | /* Handle MCCS */ | |
| 3940 | - | if (do_mccs) | |
| 3944 | + | if (do_mccs) { | |
| 3941 | 3945 | dm_helpers_read_mccs_caps(adev->dm.dc->ctx, amdgpu_dm_connector->dc_link, sink); | |
| 3942 | 3946 | ||
| 3943 | - | if ((sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A || | |
| 3944 | - | as_type == FREESYNC_TYPE_PCON_IN_WHITELIST) && | |
| 3945 | - | (!sink->edid_caps.freesync_vcp_code || | |
| 3946 | - | (sink->edid_caps.freesync_vcp_code && !sink->mccs_caps.freesync_supported))) | |
| 3947 | - | freesync_capable = false; | |
| 3947 | + | if (sink->edid_caps.freesync_vcp_code && !sink->mccs_caps.freesync_supported) | |
| 3948 | + | freesync_capable = false; | |
| 3948 | 3949 | ||
| 3949 | - | if (do_mccs && sink->mccs_caps.freesync_supported && freesync_capable) | |
| 3950 | - | dm_helpers_mccs_vcp_set(adev->dm.dc->ctx, amdgpu_dm_connector->dc_link, sink); | |
| 3950 | + | if (sink->mccs_caps.freesync_supported && freesync_capable) | |
| 3951 | + | dm_helpers_mccs_vcp_set(adev->dm.dc->ctx, amdgpu_dm_connector->dc_link, sink); | |
| 3952 | + | } | |
| 3951 | 3953 | ||
| 3952 | 3954 | update: | |
| 3953 | 3955 | if (dm_con_state) | |
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_debugfs.c
| @@ -196,7 +196,6 @@ static ssize_t dp_link_settings_read(struct file *f, char __user *buf, | |||
| 196 | 196 | char *rd_buf_ptr = NULL; | |
| 197 | 197 | const uint32_t rd_buf_size = 100; | |
| 198 | 198 | uint32_t result = 0; | |
| 199 | - | uint8_t str_len = 0; | |
| 200 | 199 | int r; | |
| 201 | 200 | ||
| 202 | 201 | if (*pos & 3 || size & 3) | |
| @@ -208,29 +207,26 @@ static ssize_t dp_link_settings_read(struct file *f, char __user *buf, | |||
| 208 | 207 | ||
| 209 | 208 | rd_buf_ptr = rd_buf; | |
| 210 | 209 | ||
| 211 | - | str_len = strlen("Current: %d 0x%x %d "); | |
| 212 | - | snprintf(rd_buf_ptr, str_len, "Current: %d 0x%x %d ", | |
| 210 | + | rd_buf_ptr += scnprintf(rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), | |
| 211 | + | "Current: %d 0x%x %d ", | |
| 213 | 212 | link->cur_link_settings.lane_count, | |
| 214 | 213 | link->cur_link_settings.link_rate, | |
| 215 | 214 | link->cur_link_settings.link_spread); | |
| 216 | - | rd_buf_ptr += str_len; | |
| 217 | 215 | ||
| 218 | - | str_len = strlen("Verified: %d 0x%x %d "); | |
| 219 | - | snprintf(rd_buf_ptr, str_len, "Verified: %d 0x%x %d ", | |
| 216 | + | rd_buf_ptr += scnprintf(rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), | |
| 217 | + | "Verified: %d 0x%x %d ", | |
| 220 | 218 | link->verified_link_cap.lane_count, | |
| 221 | 219 | link->verified_link_cap.link_rate, | |
| 222 | 220 | link->verified_link_cap.link_spread); | |
| 223 | - | rd_buf_ptr += str_len; | |
| 224 | 221 | ||
| 225 | - | str_len = strlen("Reported: %d 0x%x %d "); | |
| 226 | - | snprintf(rd_buf_ptr, str_len, "Reported: %d 0x%x %d ", | |
| 222 | + | rd_buf_ptr += scnprintf(rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), | |
| 223 | + | "Reported: %d 0x%x %d ", | |
| 227 | 224 | link->reported_link_cap.lane_count, | |
| 228 | 225 | link->reported_link_cap.link_rate, | |
| 229 | 226 | link->reported_link_cap.link_spread); | |
| 230 | - | rd_buf_ptr += str_len; | |
| 231 | 227 | ||
| 232 | - | str_len = strlen("Preferred: %d 0x%x %d "); | |
| 233 | - | snprintf(rd_buf_ptr, str_len, "Preferred: %d 0x%x %d\n", | |
| 228 | + | rd_buf_ptr += scnprintf(rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), | |
| 229 | + | "Preferred: %d 0x%x %d\n", | |
| 234 | 230 | link->preferred_link_setting.lane_count, | |
| 235 | 231 | link->preferred_link_setting.link_rate, | |
| 236 | 232 | link->preferred_link_setting.link_spread); | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
| @@ -200,6 +200,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps( | |||
| 200 | 200 | edid_caps->edid_hdmi = connector->display_info.is_hdmi; | |
| 201 | 201 | ||
| 202 | 202 | if (edid_caps->edid_hdmi) { | |
| 203 | + | edid_caps->qs_bit = connector->display_info.rgb_quant_range_selectable; | |
| 203 | 204 | populate_hdmi_info_from_connector(link->dc->config.enable_frl, &connector->display_info.hdmi, edid_caps); | |
| 204 | 205 | drm_dbg_driver(connector->dev, "%s: HDMI_FRL [%s] max_frl_rate %d\n", __func__, connector->name, edid_caps->max_frl_rate); | |
| 205 | 206 | if (edid_caps->frl_dsc_support) | |
| @@ -1202,9 +1203,10 @@ void populate_hdmi_info_from_connector(bool enable_frl, struct drm_hdmi_info *hd | |||
| 1202 | 1203 | edid_caps->max_frl_rate = get_max_frl_rate(hdmi->max_lanes, hdmi->max_frl_rate_per_lane); | |
| 1203 | 1204 | edid_caps->frl_dsc_support = hdmi->dsc_cap.v_1p2; | |
| 1204 | 1205 | if (edid_caps->frl_dsc_support) { | |
| 1205 | - | if (hdmi->dsc_cap.bpc_supported == 10) | |
| 1206 | + | /* HF-VSDB DSC max bpc is cumulative: >=12 implies 10 and 8. */ | |
| 1207 | + | if (hdmi->dsc_cap.bpc_supported >= 10) | |
| 1206 | 1208 | edid_caps->frl_dsc_10bpc = true; | |
| 1207 | - | else if (hdmi->dsc_cap.bpc_supported == 12) | |
| 1209 | + | if (hdmi->dsc_cap.bpc_supported >= 12) | |
| 1208 | 1210 | edid_caps->frl_dsc_12bpc = true; | |
| 1209 | 1211 | edid_caps->frl_dsc_all_bpp = hdmi->dsc_cap.all_bpp; | |
| 1210 | 1212 | edid_caps->frl_dsc_native_420 = hdmi->dsc_cap.native_420; | |
| @@ -1437,12 +1439,13 @@ void dm_helpers_free_gpu_mem( | |||
| 1437 | 1439 | ||
| 1438 | 1440 | bool dm_helpers_dmub_outbox_interrupt_control(struct dc_context *ctx, bool enable) | |
| 1439 | 1441 | { | |
| 1442 | + | struct amdgpu_device *adev = ctx->driver_context; | |
| 1440 | 1443 | enum dc_irq_source irq_source; | |
| 1441 | 1444 | bool ret; | |
| 1442 | 1445 | ||
| 1443 | 1446 | irq_source = DC_IRQ_SOURCE_DMCUB_OUTBOX; | |
| 1444 | 1447 | ||
| 1445 | - | ret = dc_interrupt_set(ctx->dc, irq_source, enable); | |
| 1448 | + | ret = amdgpu_dm_irq_set(adev, irq_source, enable); | |
| 1446 | 1449 | ||
| 1447 | 1450 | DRM_DEBUG_DRIVER("Dmub trace irq %sabling: r=%d\n", | |
| 1448 | 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_plane.c
| @@ -2208,16 +2208,41 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm, | |||
| 2208 | 2208 | if (res) | |
| 2209 | 2209 | return res; | |
| 2210 | 2210 | ||
| 2211 | - | if (plane->type == DRM_PLANE_TYPE_OVERLAY && | |
| 2212 | - | plane_cap && plane_cap->per_pixel_alpha) { | |
| 2211 | + | /* Blend mode support varies on DCE generations according to HW caps | |
| 2212 | + | * and number of planes per CRTC. However, as current driver | |
| 2213 | + | * implementation only creates one primary and one cursor plane per | |
| 2214 | + | * CRTC for DCE (overlay is only created if | |
| 2215 | + | * DC_PLANE_TYPE_DCN_UNIVERSAL), the primary plane blend mode is | |
| 2216 | + | * ignored across DCE versions. Keep PREMULTI to avoid uAPI | |
| 2217 | + | * regressions: it was the default/mandatory mode for many years and, | |
| 2218 | + | * with no overlay plane, primary composes on top of a black | |
| 2219 | + | * background, where PREMULTI and PIXEL_NONE are equivalent. | |
| 2220 | + | */ | |
| 2221 | + | if (plane_cap && plane_cap->type != DC_PLANE_TYPE_DCN_UNIVERSAL) { | |
| 2222 | + | unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) | | |
| 2223 | + | BIT(DRM_MODE_BLEND_PREMULTI); | |
| 2224 | + | ||
| 2225 | + | drm_plane_create_blend_mode_property(plane, blend_caps); | |
| 2226 | + | } else if ((plane->type == DRM_PLANE_TYPE_OVERLAY || | |
| 2227 | + | plane->type == DRM_PLANE_TYPE_PRIMARY) && | |
| 2228 | + | plane_cap && plane_cap->per_pixel_alpha) { | |
| 2213 | 2229 | unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) | | |
| 2214 | 2230 | BIT(DRM_MODE_BLEND_PREMULTI) | | |
| 2215 | 2231 | BIT(DRM_MODE_BLEND_COVERAGE); | |
| 2216 | 2232 | ||
| 2217 | - | drm_plane_create_alpha_property(plane); | |
| 2218 | 2233 | drm_plane_create_blend_mode_property(plane, blend_caps); | |
| 2234 | + | ||
| 2235 | + | if (plane->type == DRM_PLANE_TYPE_OVERLAY) | |
| 2236 | + | drm_plane_create_alpha_property(plane); | |
| 2219 | 2237 | } | |
| 2220 | 2238 | ||
| 2239 | + | /* Cursor color format is set to CURSOR_MODE_COLOR_PRE_MULTIPLIED_ALPHA | |
| 2240 | + | * by default, so only advertise DRM_MODE_BLEND_PREMULTI blend mode for | |
| 2241 | + | * this type of plane. | |
| 2242 | + | */ | |
| 2243 | + | if (plane->type == DRM_PLANE_TYPE_CURSOR) | |
| 2244 | + | drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_PREMULTI)); | |
| 2245 | + | ||
| 2221 | 2246 | if (plane->type == DRM_PLANE_TYPE_PRIMARY) { | |
| 2222 | 2247 | /* | |
| 2223 | 2248 | * Allow OVERLAY planes to be used as underlays by assigning an | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
| @@ -567,6 +567,23 @@ static void dm_test_output_color_space_bt2020_rgb(struct kunit *test) | |||
| 567 | 567 | (int)COLOR_SPACE_2020_RGB_FULLRANGE); | |
| 568 | 568 | } | |
| 569 | 569 | ||
| 570 | + | /** | |
| 571 | + | * dm_test_output_color_space_bt2020_rgb_limited - Test limited BT.2020 RGB | |
| 572 | + | * @test: The KUnit test context | |
| 573 | + | */ | |
| 574 | + | static void dm_test_output_color_space_bt2020_rgb_limited(struct kunit *test) | |
| 575 | + | { | |
| 576 | + | struct dc_crtc_timing timing = {}; | |
| 577 | + | struct drm_connector_state state = {}; | |
| 578 | + | ||
| 579 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 580 | + | state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB; | |
| 581 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_LIMITED; | |
| 582 | + | ||
| 583 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 584 | + | (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE); | |
| 585 | + | } | |
| 586 | + | ||
| 570 | 587 | /** | |
| 571 | 588 | * dm_test_output_color_space_bt2020_ycc - Test Output color space bt2020 ycc | |
| 572 | 589 | * @test: The KUnit test context | |
| @@ -638,6 +655,24 @@ static void dm_test_output_color_space_bt2020_ycc_rgb_encoding(struct kunit *tes | |||
| 638 | 655 | (int)COLOR_SPACE_2020_RGB_FULLRANGE); | |
| 639 | 656 | } | |
| 640 | 657 | ||
| 658 | + | /** | |
| 659 | + | * dm_test_output_color_space_bt2020_ycc_rgb_encoding_limited - Test limited | |
| 660 | + | * BT.2020 RGB output selected through the BT.2020 YCC connector colorspace | |
| 661 | + | * @test: The KUnit test context | |
| 662 | + | */ | |
| 663 | + | static void dm_test_output_color_space_bt2020_ycc_rgb_encoding_limited(struct kunit *test) | |
| 664 | + | { | |
| 665 | + | struct dc_crtc_timing timing = {}; | |
| 666 | + | struct drm_connector_state state = {}; | |
| 667 | + | ||
| 668 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 669 | + | state.colorspace = DRM_MODE_COLORIMETRY_BT2020_YCC; | |
| 670 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_LIMITED; | |
| 671 | + | ||
| 672 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 673 | + | (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE); | |
| 674 | + | } | |
| 675 | + | ||
| 641 | 676 | /** | |
| 642 | 677 | * dm_test_output_color_space_bt2020_rgb_ycc_encoding - Test Output color space | |
| 643 | 678 | * bt2020 rgb with non-rgb pixel encoding falls back to limited ycbcr | |
| @@ -4180,7 +4215,7 @@ dm_test_destroy_connector(struct kunit *test, struct drm_device *drm) | |||
| 4180 | 4215 | { | |
| 4181 | 4216 | struct amdgpu_dm_connector *aconnector; | |
| 4182 | 4217 | ||
| 4183 | - | aconnector = kzalloc(sizeof(*aconnector), GFP_KERNEL); | |
| 4218 | + | aconnector = kzalloc_obj(*aconnector); | |
| 4184 | 4219 | KUNIT_ASSERT_NOT_NULL(test, aconnector); | |
| 4185 | 4220 | ||
| 4186 | 4221 | KUNIT_ASSERT_EQ(test, | |
| @@ -5422,10 +5457,12 @@ static struct kunit_case amdgpu_dm_connector_tests[] = { | |||
| 5422 | 5457 | KUNIT_CASE(dm_test_output_color_space_bt709_y_only), | |
| 5423 | 5458 | KUNIT_CASE(dm_test_output_color_space_oprgb), | |
| 5424 | 5459 | KUNIT_CASE(dm_test_output_color_space_bt2020_rgb), | |
| 5460 | + | KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_limited), | |
| 5425 | 5461 | KUNIT_CASE(dm_test_output_color_space_bt2020_ycc), | |
| 5426 | 5462 | KUNIT_CASE(dm_test_output_color_space_default_ycbcr709_y_only), | |
| 5427 | 5463 | KUNIT_CASE(dm_test_output_color_space_default_ycbcr601), | |
| 5428 | 5464 | KUNIT_CASE(dm_test_output_color_space_bt2020_ycc_rgb_encoding), | |
| 5465 | + | KUNIT_CASE(dm_test_output_color_space_bt2020_ycc_rgb_encoding_limited), | |
| 5429 | 5466 | KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_ycc_encoding), | |
| 5430 | 5467 | /* Tests for amdgpu_dm_convert_dc_color_depth_into_bpc */ | |
| 5431 | 5468 | KUNIT_CASE(dm_test_convert_color_depth_bpc_mappings), | |
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); | |
| @@ -1445,7 +1449,7 @@ static void dm_test_crtc_destroy_state_no_stream(struct kunit *test) | |||
| 1445 | 1449 | struct dm_crtc_state *dm_state; | |
| 1446 | 1450 | ||
| 1447 | 1451 | /* destroy_state kfree()s the state, so use a plain (unmanaged) alloc. */ | |
| 1448 | - | dm_state = kzalloc_obj(*dm_state, GFP_KERNEL); | |
| 1452 | + | dm_state = kzalloc_obj(*dm_state); | |
| 1449 | 1453 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm_state); | |
| 1450 | 1454 | ||
| 1451 | 1455 | amdgpu_dm_crtc_destroy_state(NULL, &dm_state->base); | |
| @@ -1475,7 +1479,7 @@ static void dm_test_crtc_destroy_state_releases_stream(struct kunit *test) | |||
| 1475 | 1479 | kref_get(&stream->refcount); | |
| 1476 | 1480 | ||
| 1477 | 1481 | /* destroy_state kfree()s the state, so use a plain (unmanaged) alloc. */ | |
| 1478 | - | dm_state = kzalloc_obj(*dm_state, GFP_KERNEL); | |
| 1482 | + | dm_state = kzalloc_obj(*dm_state); | |
| 1479 | 1483 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm_state); | |
| 1480 | 1484 | dm_state->stream = stream; | |
| 1481 | 1485 | ||
| @@ -1569,7 +1573,7 @@ static void dm_test_crtc_handle_vblank_completes_cursor_only(struct kunit *test) | |||
| 1569 | 1573 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, acrtc); | |
| 1570 | 1574 | ||
| 1571 | 1575 | /* drm_crtc_send_vblank_event() consumes (kfree()s) the event. */ | |
| 1572 | - | event = kzalloc_obj(*event, GFP_KERNEL); | |
| 1576 | + | event = kzalloc_obj(*event); | |
| 1573 | 1577 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, event); | |
| 1574 | 1578 | ||
| 1575 | 1579 | acrtc->base.dev = &adev->ddev; | |
| @@ -1628,7 +1632,7 @@ dm_test_vblank_control_worker_setup(struct kunit *test, bool enable, | |||
| 1628 | 1632 | kref_get(&stream->refcount); | |
| 1629 | 1633 | ||
| 1630 | 1634 | /* Worker kfree()s the work item, so it must be a plain allocation. */ | |
| 1631 | - | work = kzalloc_obj(*work, GFP_KERNEL); | |
| 1635 | + | work = kzalloc_obj(*work); | |
| 1632 | 1636 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, work); | |
| 1633 | 1637 | work->dm = &adev->dm; | |
| 1634 | 1638 | work->acrtc = acrtc; | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_helpers_test.c
| @@ -358,12 +358,14 @@ static void dm_test_parse_edid_caps_hdmi_frl(struct kunit *test) | |||
| 358 | 358 | ||
| 359 | 359 | /* Drive the HDMI/FRL branch */ | |
| 360 | 360 | connector->display_info.is_hdmi = true; | |
| 361 | + | connector->display_info.rgb_quant_range_selectable = true; | |
| 361 | 362 | connector->display_info.hdmi.scdc.supported = true; | |
| 362 | 363 | connector->display_info.hdmi.max_lanes = 4; | |
| 363 | 364 | connector->display_info.hdmi.max_frl_rate_per_lane = 12; | |
| 364 | 365 | ||
| 365 | 366 | KUNIT_EXPECT_EQ(test, dm_helpers_parse_edid_caps(link, dc_edid, edid_caps), EDID_OK); | |
| 366 | 367 | KUNIT_EXPECT_TRUE(test, edid_caps->edid_hdmi); | |
| 368 | + | KUNIT_EXPECT_EQ(test, edid_caps->qs_bit, 1); | |
| 367 | 369 | KUNIT_EXPECT_TRUE(test, edid_caps->scdc_present); | |
| 368 | 370 | /* max_lanes 4 + max_frl_rate_per_lane 12 -> rate index 6 */ | |
| 369 | 371 | KUNIT_EXPECT_EQ(test, edid_caps->max_frl_rate, 6); | |
| @@ -909,7 +911,7 @@ static void dm_test_populate_hdmi_frl_dsc_12bpc(struct kunit *test) | |||
| 909 | 911 | ||
| 910 | 912 | KUNIT_EXPECT_EQ(test, caps->max_frl_rate, 2); | |
| 911 | 913 | KUNIT_EXPECT_TRUE(test, caps->frl_dsc_support); | |
| 912 | - | KUNIT_EXPECT_FALSE(test, caps->frl_dsc_10bpc); | |
| 914 | + | KUNIT_EXPECT_TRUE(test, caps->frl_dsc_10bpc); | |
| 913 | 915 | KUNIT_EXPECT_TRUE(test, caps->frl_dsc_12bpc); | |
| 914 | 916 | KUNIT_EXPECT_EQ(test, caps->frl_dsc_max_slices, 7); | |
| 915 | 917 | KUNIT_EXPECT_EQ(test, caps->frl_dsc_max_frl_rate, 1); | |
| @@ -2440,17 +2442,21 @@ static void dm_test_is_dp_sink_present_null_priv(struct kunit *test) | |||
| 2440 | 2442 | * dm_test_dmub_outbox_interrupt_control_null_dc - Test outbox irq control with NULL dc | |
| 2441 | 2443 | * @test: The KUnit test context | |
| 2442 | 2444 | * | |
| 2443 | - | * 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 | |
| 2444 | 2446 | * helper returns false without touching real interrupt hardware. | |
| 2445 | 2447 | */ | |
| 2446 | 2448 | static void dm_test_dmub_outbox_interrupt_control_null_dc(struct kunit *test) | |
| 2447 | 2449 | { | |
| 2450 | + | struct amdgpu_device *adev; | |
| 2448 | 2451 | struct dc_context *ctx; | |
| 2449 | 2452 | ||
| 2453 | + | adev = kunit_kzalloc(test, sizeof(*adev), GFP_KERNEL); | |
| 2454 | + | KUNIT_ASSERT_NOT_NULL(test, adev); | |
| 2450 | 2455 | ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); | |
| 2451 | 2456 | KUNIT_ASSERT_NOT_NULL(test, ctx); | |
| 2457 | + | ctx->driver_context = adev; | |
| 2452 | 2458 | ||
| 2453 | - | /* ctx->dc is NULL → dc_interrupt_set returns false */ | |
| 2459 | + | /* adev->dm.dc is NULL → amdgpu_dm_irq_set returns false */ | |
| 2454 | 2460 | KUNIT_EXPECT_FALSE(test, dm_helpers_dmub_outbox_interrupt_control(ctx, true)); | |
| 2455 | 2461 | KUNIT_EXPECT_FALSE(test, dm_helpers_dmub_outbox_interrupt_control(ctx, false)); | |
| 2456 | 2462 | } | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
| @@ -103,7 +103,7 @@ static enum dc_status dm_test_dp_read_hpd_rx_irq_data_ok(struct dc_link *link, | |||
| 103 | 103 | */ | |
| 104 | 104 | static struct dc_sink *dm_test_sink_create(struct dc_link *link) | |
| 105 | 105 | { | |
| 106 | - | struct dc_sink *sink = kzalloc(sizeof(*sink), GFP_KERNEL); | |
| 106 | + | struct dc_sink *sink = kzalloc_obj(*sink); | |
| 107 | 107 | ||
| 108 | 108 | if (!sink) | |
| 109 | 109 | return NULL; | |
| @@ -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 | */ | |
| @@ -2131,7 +2131,7 @@ static void dm_test_hpd_rx_offload_work_no_connector(struct kunit *test) | |||
| 2131 | 2131 | offload_wq = kunit_kzalloc(test, sizeof(*offload_wq), GFP_KERNEL); | |
| 2132 | 2132 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_wq); | |
| 2133 | 2133 | ||
| 2134 | - | offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL); | |
| 2134 | + | offload_work = kzalloc_obj(*offload_work); | |
| 2135 | 2135 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work); | |
| 2136 | 2136 | offload_work->offload_wq = offload_wq; | |
| 2137 | 2137 | offload_work->adev = adev; | |
| @@ -2177,7 +2177,7 @@ static void dm_test_hpd_rx_offload_work_no_connection(struct kunit *test) | |||
| 2177 | 2177 | link->dc = dc; | |
| 2178 | 2178 | aconn->dc_link = link; | |
| 2179 | 2179 | ||
| 2180 | - | offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL); | |
| 2180 | + | offload_work = kzalloc_obj(*offload_work); | |
| 2181 | 2181 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work); | |
| 2182 | 2182 | offload_work->offload_wq = offload_wq; | |
| 2183 | 2183 | offload_work->adev = adev; | |
| @@ -2244,7 +2244,7 @@ static void dm_test_hpd_rx_offload_work_automated_test(struct kunit *test) | |||
| 2244 | 2244 | link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT; | |
| 2245 | 2245 | aconn->dc_link = link; | |
| 2246 | 2246 | ||
| 2247 | - | offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL); | |
| 2247 | + | offload_work = kzalloc_obj(*offload_work); | |
| 2248 | 2248 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work); | |
| 2249 | 2249 | offload_work->offload_wq = offload_wq; | |
| 2250 | 2250 | offload_work->adev = adev; | |
| @@ -2315,7 +2315,7 @@ static void dm_test_hpd_rx_offload_work_link_loss(struct kunit *test) | |||
| 2315 | 2315 | link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT; | |
| 2316 | 2316 | aconn->dc_link = link; | |
| 2317 | 2317 | ||
| 2318 | - | offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL); | |
| 2318 | + | offload_work = kzalloc_obj(*offload_work); | |
| 2319 | 2319 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work); | |
| 2320 | 2320 | offload_work->offload_wq = offload_wq; | |
| 2321 | 2321 | offload_work->adev = adev; | |
| @@ -3452,9 +3452,9 @@ static void dm_test_handle_hpd_work_out_of_range(struct kunit *test) | |||
| 3452 | 3452 | struct amdgpu_device *adev; | |
| 3453 | 3453 | ||
| 3454 | 3454 | adev = dm_kunit_alloc_adev(test); | |
| 3455 | - | hpd_work = kzalloc(sizeof(*hpd_work), GFP_KERNEL); | |
| 3455 | + | hpd_work = kzalloc_obj(*hpd_work); | |
| 3456 | 3456 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hpd_work); | |
| 3457 | - | hpd_work->dmub_notify = kzalloc(sizeof(*hpd_work->dmub_notify), GFP_KERNEL); | |
| 3457 | + | hpd_work->dmub_notify = kzalloc_obj(*hpd_work->dmub_notify); | |
| 3458 | 3458 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hpd_work->dmub_notify); | |
| 3459 | 3459 | hpd_work->dmub_notify->type = | |
| 3460 | 3460 | (enum dmub_notification_type)ARRAY_SIZE(adev->dm.dmub_callback); | |
| @@ -3899,9 +3899,9 @@ static void dm_test_handle_vmin_vmax_update(struct kunit *test) | |||
| 3899 | 3899 | kref_get(&stream->refcount); | |
| 3900 | 3900 | ||
| 3901 | 3901 | /* The worker kfree()s both, so they must come from the slab. */ | |
| 3902 | - | work = kzalloc(sizeof(*work), GFP_KERNEL); | |
| 3902 | + | work = kzalloc_obj(*work); | |
| 3903 | 3903 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, work); | |
| 3904 | - | adjust = kzalloc(sizeof(*adjust), GFP_KERNEL); | |
| 3904 | + | adjust = kzalloc_obj(*adjust); | |
| 3905 | 3905 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adjust); | |
| 3906 | 3906 | ||
| 3907 | 3907 | work->adev = adev; | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c
| @@ -2945,7 +2945,7 @@ static void dm_test_plane_reset_initializes_state(struct kunit *test) | |||
| 2945 | 2945 | * destroy-existing-state path. The destroy hook frees this state, so it | |
| 2946 | 2946 | * must be a plain (non-KUnit-managed) allocation. | |
| 2947 | 2947 | */ | |
| 2948 | - | old_state = kzalloc(sizeof(*old_state), GFP_KERNEL); | |
| 2948 | + | old_state = kzalloc_obj(*old_state); | |
| 2949 | 2949 | KUNIT_ASSERT_NOT_NULL(test, old_state); | |
| 2950 | 2950 | plane->funcs = &dm_test_plane_reset_funcs; | |
| 2951 | 2951 | plane->state = &old_state->base; | |
| @@ -3018,7 +3018,7 @@ static void dm_test_plane_destroy_state_minimal(struct kunit *test) | |||
| 3018 | 3018 | KUNIT_ASSERT_NOT_NULL(test, plane); | |
| 3019 | 3019 | ||
| 3020 | 3020 | /* destroy_state frees the state itself, so use a plain allocation. */ | |
| 3021 | - | dm_plane_state = kzalloc(sizeof(*dm_plane_state), GFP_KERNEL); | |
| 3021 | + | dm_plane_state = kzalloc_obj(*dm_plane_state); | |
| 3022 | 3022 | KUNIT_ASSERT_NOT_NULL(test, dm_plane_state); | |
| 3023 | 3023 | ||
| 3024 | 3024 | amdgpu_dm_plane_drm_plane_destroy_state(plane, &dm_plane_state->base); | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
| @@ -239,7 +239,7 @@ static void dm_test_atomic_destroy_state_no_context(struct kunit *test) | |||
| 239 | 239 | * Use kzalloc(), not kunit_kzalloc(): dm_atomic_destroy_state() frees | |
| 240 | 240 | * the state itself, so KUnit-managed memory would be double-freed. | |
| 241 | 241 | */ | |
| 242 | - | dm_state = kzalloc(sizeof(*dm_state), GFP_KERNEL); | |
| 242 | + | dm_state = kzalloc_obj(*dm_state); | |
| 243 | 243 | KUNIT_ASSERT_NOT_NULL(test, dm_state); | |
| 244 | 244 | ||
| 245 | 245 | /* context == NULL: dc_state_release() is skipped and the state is freed. */ | |
modified drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c
| @@ -377,7 +377,7 @@ struct clk_mgr *dc_clk_mgr_create(struct dc_context *ctx, struct pp_smu_funcs *p | |||
| 377 | 377 | } | |
| 378 | 378 | break; | |
| 379 | 379 | case AMDGPU_FAMILY_GC_11_5_4: { | |
| 380 | - | struct clk_mgr_dcn42 *clk_mgr = kzalloc(sizeof(*clk_mgr), GFP_KERNEL); | |
| 380 | + | struct clk_mgr_dcn42 *clk_mgr = kzalloc_obj(*clk_mgr); | |
| 381 | 381 | ||
| 382 | 382 | if (clk_mgr == NULL) { | |
| 383 | 383 | BREAK_TO_DEBUGGER(); | |
modified drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c
| @@ -1595,7 +1595,7 @@ struct clk_mgr_internal *dcn60_clk_mgr_construct( | |||
| 1595 | 1595 | struct dccg *dccg) | |
| 1596 | 1596 | { | |
| 1597 | 1597 | struct clk_log_info log_info = {0}; | |
| 1598 | - | struct dcn60_clk_mgr *clk_mgr60 = kzalloc(sizeof(struct dcn60_clk_mgr), GFP_KERNEL); | |
| 1598 | + | struct dcn60_clk_mgr *clk_mgr60 = kzalloc_obj(struct dcn60_clk_mgr); | |
| 1599 | 1599 | struct clk_mgr_internal *clk_mgr; | |
| 1600 | 1600 | ||
| 1601 | 1601 | if (!clk_mgr60) | |
| @@ -1644,7 +1644,7 @@ struct clk_mgr_internal *dcn60_clk_mgr_construct( | |||
| 1644 | 1644 | ||
| 1645 | 1645 | clk_mgr->smu_present = false; | |
| 1646 | 1646 | ||
| 1647 | - | clk_mgr->base.bw_params = kzalloc(sizeof(*clk_mgr->base.bw_params), GFP_KERNEL); | |
| 1647 | + | clk_mgr->base.bw_params = kzalloc_obj(*clk_mgr->base.bw_params); | |
| 1648 | 1648 | if (!clk_mgr->base.bw_params) | |
| 1649 | 1649 | goto fail; | |
| 1650 | 1650 | ||
modified drivers/gpu/drm/amd/display/dc/core/dc.c
| @@ -914,8 +914,7 @@ static bool dc_construct_update_scratch_pool(struct dc *dc) | |||
| 914 | 914 | unsigned int i; | |
| 915 | 915 | ||
| 916 | 916 | for (i = 0; i < ARRAY_SIZE(dc->update_scratch_pool); i++) { | |
| 917 | - | dc->update_scratch_pool[i] = kzalloc( | |
| 918 | - | sizeof(struct dc_update_scratch_space), GFP_KERNEL); | |
| 917 | + | dc->update_scratch_pool[i] = kzalloc_obj(struct dc_update_scratch_space); | |
| 919 | 918 | if (!dc->update_scratch_pool[i]) | |
| 920 | 919 | return false; | |
| 921 | 920 | dc->update_scratch_in_use[i] = false; | |
| @@ -3199,6 +3198,7 @@ static struct dc_update_descriptor check_update_surfaces_for_stream( | |||
| 3199 | 3198 | } | |
| 3200 | 3199 | ||
| 3201 | 3200 | if ((stream_update->hdr_static_metadata && !stream_update->stream->use_dynamic_meta) || | |
| 3201 | + | stream_update->output_color_space || | |
| 3202 | 3202 | stream_update->vrr_infopacket || | |
| 3203 | 3203 | stream_update->vsc_infopacket || | |
| 3204 | 3204 | stream_update->vsp_infopacket || | |
| @@ -4189,6 +4189,7 @@ static void commit_planes_do_stream_update_sequence(struct dc *dc, | |||
| 4189 | 4189 | hwss_add_setup_periodic_interrupt(&seq_state, dc, pipe_ctx); | |
| 4190 | 4190 | ||
| 4191 | 4191 | if ((stream_update->hdr_static_metadata && !stream->use_dynamic_meta) || | |
| 4192 | + | stream_update->output_color_space || | |
| 4192 | 4193 | stream_update->vrr_infopacket || | |
| 4193 | 4194 | stream_update->vsc_infopacket || | |
| 4194 | 4195 | stream_update->vsp_infopacket || | |
| @@ -4371,6 +4372,7 @@ static void commit_planes_do_stream_update(struct dc *dc, | |||
| 4371 | 4372 | dc->hwss.setup_periodic_interrupt(dc, pipe_ctx); | |
| 4372 | 4373 | ||
| 4373 | 4374 | if ((stream_update->hdr_static_metadata && !stream->use_dynamic_meta) || | |
| 4375 | + | stream_update->output_color_space || | |
| 4374 | 4376 | stream_update->vrr_infopacket || | |
| 4375 | 4377 | stream_update->vsc_infopacket || | |
| 4376 | 4378 | stream_update->vsp_infopacket || | |
modified drivers/gpu/drm/amd/display/dc/core/dc_resource.c
| @@ -1797,7 +1797,11 @@ bool resource_can_pipe_disable_cursor(struct pipe_ctx *pipe_ctx) | |||
| 1797 | 1797 | * pipe-split, merge together per same height. | |
| 1798 | 1798 | */ | |
| 1799 | 1799 | for (split_pipe = pipe_ctx->top_pipe; split_pipe; | |
| 1800 | - | split_pipe = split_pipe->top_pipe) | |
| 1800 | + | split_pipe = split_pipe->top_pipe) { | |
| 1801 | + | ||
| 1802 | + | if (split_pipe == test_pipe) | |
| 1803 | + | continue; | |
| 1804 | + | ||
| 1801 | 1805 | if (split_pipe->plane_state->layer_index == test_pipe->plane_state->layer_index) { | |
| 1802 | 1806 | struct rect r2_half; | |
| 1803 | 1807 | ||
| @@ -1809,6 +1813,7 @@ bool resource_can_pipe_disable_cursor(struct pipe_ctx *pipe_ctx) | |||
| 1809 | 1813 | r2_bottom = min(r2_bottom, r2_half.y + r2_half.height); | |
| 1810 | 1814 | break; | |
| 1811 | 1815 | } | |
| 1816 | + | } | |
| 1812 | 1817 | ||
| 1813 | 1818 | if (r1.x >= r2.x && r1.y >= r2.y && r1_right <= r2_right && r1_bottom <= r2_bottom) | |
| 1814 | 1819 | return true; | |
modified drivers/gpu/drm/amd/display/dc/core/dc_surface.c
| @@ -290,7 +290,7 @@ static void dc_plane_cm_free(struct kref *kref) | |||
| 290 | 290 | ||
| 291 | 291 | struct dc_plane_cm *dc_plane_cm_create(void) | |
| 292 | 292 | { | |
| 293 | - | struct dc_plane_cm *cm = kvzalloc(sizeof(*cm), GFP_KERNEL); | |
| 293 | + | struct dc_plane_cm *cm = kvzalloc_obj(*cm); | |
| 294 | 294 | ||
| 295 | 295 | if (cm == NULL) | |
| 296 | 296 | goto alloc_fail; | |
modified drivers/gpu/drm/amd/display/dc/dccg/dcn42/dcn42_dccg.c
| @@ -358,7 +358,7 @@ struct dccg *dccg42_create( | |||
| 358 | 358 | const struct dccg_shift *dccg_shift, | |
| 359 | 359 | const struct dccg_mask *dccg_mask) | |
| 360 | 360 | { | |
| 361 | - | struct dcn_dccg *dccg_dcn = kzalloc(sizeof(*dccg_dcn), GFP_KERNEL); | |
| 361 | + | struct dcn_dccg *dccg_dcn = kzalloc_obj(*dccg_dcn); | |
| 362 | 362 | struct dccg *base; | |
| 363 | 363 | ||
| 364 | 364 | if (dccg_dcn == NULL) { | |
modified drivers/gpu/drm/amd/display/dc/dccg/dcn60/dcn60_dccg.c
| @@ -167,7 +167,7 @@ struct dccg *dccg60_create( | |||
| 167 | 167 | const struct dccg_shift *dccg_shift, | |
| 168 | 168 | const struct dccg_mask *dccg_mask) | |
| 169 | 169 | { | |
| 170 | - | struct dcn_dccg *dccg_dcn = kzalloc(sizeof(*dccg_dcn), GFP_KERNEL); | |
| 170 | + | struct dcn_dccg *dccg_dcn = kzalloc_obj(*dccg_dcn); | |
| 171 | 171 | struct dccg *base; | |
| 172 | 172 | ||
| 173 | 173 | if (dccg_dcn == NULL) { | |
modified drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c
| @@ -320,6 +320,8 @@ static struct fixed31_32 interp_tf_pts(const struct fixed31_32 *output_tf_channe | |||
| 320 | 320 | return value; | |
| 321 | 321 | } | |
| 322 | 322 | ||
| 323 | + | #define NUM_DEGAMMA_REGIONS 9 | |
| 324 | + | ||
| 323 | 325 | bool cm3_helper_translate_curve_to_degamma_hw_format( | |
| 324 | 326 | const struct dc_transfer_func *output_tf, | |
| 325 | 327 | struct pwl_params *lut_params) | |
| @@ -343,31 +345,15 @@ bool cm3_helper_translate_curve_to_degamma_hw_format( | |||
| 343 | 345 | memset(lut_params, 0, sizeof(struct pwl_params)); | |
| 344 | 346 | memset(seg_distr, 0, sizeof(seg_distr)); | |
| 345 | 347 | ||
| 346 | - | if (output_tf->tf == TRANSFER_FUNCTION_PQ || | |
| 347 | - | output_tf->tf == TRANSFER_FUNCTION_SRGB) { | |
| 348 | - | /* 9 segments | |
| 349 | - | * segments are from 2^-9 to 0 | |
| 350 | - | */ | |
| 351 | - | const uint8_t SEG_COUNT = 9; | |
| 352 | - | seg_distr[0] = 0; // Since we only have one point in darkest region | |
| 353 | - | for (k = 1; k < SEG_COUNT; k++) | |
| 354 | - | seg_distr[k] = k - 1; // 2^(k-1) points per region; halves as k decreases | |
| 355 | - | ||
| 356 | - | region_start = -SEG_COUNT; | |
| 357 | - | region_end = 0; | |
| 358 | - | } else { | |
| 359 | - | /* 12 segments | |
| 360 | - | * segments are from 2^-12 to 2^0 | |
| 361 | - | * There are less than 256 points, for optimization | |
| 362 | - | */ | |
| 363 | - | const uint8_t SEG_COUNT = 12; | |
| 364 | - | ||
| 365 | - | for (i = 0; i < SEG_COUNT; i++) | |
| 366 | - | seg_distr[i] = 4; | |
| 348 | + | /* 9 segments | |
| 349 | + | * segments are from 2^-9 to 2^0 | |
| 350 | + | */ | |
| 351 | + | seg_distr[0] = 0; // Since we only have one point in darkest region | |
| 352 | + | for (k = 1; k < NUM_DEGAMMA_REGIONS; k++) | |
| 353 | + | seg_distr[k] = k - 1; // 2^(k-1) points per region; halves as k decreases | |
| 367 | 354 | ||
| 368 | - | region_start = -SEG_COUNT; | |
| 369 | - | region_end = 0; | |
| 370 | - | } | |
| 355 | + | region_start = -NUM_DEGAMMA_REGIONS; | |
| 356 | + | region_end = 0; | |
| 371 | 357 | ||
| 372 | 358 | for (i = region_end - region_start; i < MAX_REGIONS_NUMBER ; i++) | |
| 373 | 359 | seg_distr[i] = -1; | |
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 | + | ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)$(CONFIG_UBSAN)),y) | |
| 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 | + | ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)$(CONFIG_UBSAN)),y) | |
| 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/dml2_0/dml21/src/dml2_core/dml2_core_dcn5_funcs_mode_programming.c
| @@ -1128,8 +1128,8 @@ static bool dcn5_mode_programming(struct dml2_core_calcs_mode_programming_ex *in | |||
| 1128 | 1128 | CalculateWatermarks_params->USRRetrainingSupport = &mode_lib->mp.USRRetrainingSupport; | |
| 1129 | 1129 | CalculateWatermarks_params->temp_read_or_ppt_support = mode_lib->mp.temp_read_or_ppt_support; | |
| 1130 | 1130 | CalculateWatermarks_params->global_temp_read_or_ppt_supported = &mode_lib->mp.global_temp_read_or_ppt_supported; | |
| 1131 | - | CalculateWatermarks_params->VActiveLatencyHidingMargin = 0; | |
| 1132 | - | CalculateWatermarks_params->VActiveLatencyHidingUs = 0; | |
| 1131 | + | CalculateWatermarks_params->VActiveLatencyHidingMargin = NULL; | |
| 1132 | + | CalculateWatermarks_params->VActiveLatencyHidingUs = NULL; | |
| 1133 | 1133 | ||
| 1134 | 1134 | dcn5_calculate_watermarks_and_dram_speed_change_support(&mode_lib->scratch, CalculateWatermarks_params); | |
| 1135 | 1135 | ||
modified drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c
| @@ -1414,7 +1414,7 @@ static bool find_shift_for_valid_cache_id_assignment(const int *mcache_boundarie | |||
| 1414 | 1414 | success = true; | |
| 1415 | 1415 | for (pipe_index = 0; pipe_index < pipe_count; pipe_index++) { | |
| 1416 | 1416 | if (!calculate_first_second_splitting(mcache_boundaries, num_boundaries, *shift, | |
| 1417 | - | pipe_vp_startx[pipe_index], pipe_vp_endx[pipe_index], 0, 0)) { | |
| 1417 | + | pipe_vp_startx[pipe_index], pipe_vp_endx[pipe_index], NULL, NULL)) { | |
| 1418 | 1418 | success = false; | |
| 1419 | 1419 | break; | |
| 1420 | 1420 | } | |
modified drivers/gpu/drm/amd/display/dc/dml2_0/dml2_translation_helper.c
| @@ -301,6 +301,7 @@ void dml2_init_socbb_params(struct dml2_context *dml2, const struct dc *in_dc, s | |||
| 301 | 301 | out->smn_latency_us = 2; | |
| 302 | 302 | out->dispclk_dppclk_vco_speed_mhz = 3600; | |
| 303 | 303 | out->pct_ideal_dram_bw_after_urgent_pixel_only = 65.0; | |
| 304 | + | out->gpuvm_min_page_size_kbytes = 4; | |
| 304 | 305 | break; | |
| 305 | 306 | ||
| 306 | 307 | ||
modified drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
| @@ -542,7 +542,7 @@ void dal_hw_ddc_init_i3cpad( | |||
| 542 | 542 | *hw_ddc = NULL; | |
| 543 | 543 | } | |
| 544 | 544 | ||
| 545 | - | *hw_ddc = kzalloc(sizeof(struct hw_ddc), GFP_KERNEL); | |
| 545 | + | *hw_ddc = kzalloc_obj(struct hw_ddc); | |
| 546 | 546 | if (!*hw_ddc) { | |
| 547 | 547 | ASSERT_CRITICAL(false); | |
| 548 | 548 | return; | |
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/irq/dcn42/irq_service_dcn42.c
| @@ -405,7 +405,7 @@ static void dcn42_irq_construct(struct irq_service *irq_service, | |||
| 405 | 405 | ||
| 406 | 406 | struct irq_service *dal_irq_service_dcn42_create(struct irq_service_init_data *init_data) | |
| 407 | 407 | { | |
| 408 | - | struct irq_service *irq_service = kzalloc(sizeof(*irq_service), GFP_KERNEL); | |
| 408 | + | struct irq_service *irq_service = kzalloc_obj(*irq_service); | |
| 409 | 409 | ||
| 410 | 410 | if (!irq_service) | |
| 411 | 411 | return NULL; | |
modified drivers/gpu/drm/amd/display/dc/irq/dcn60/irq_service_dcn60.c
| @@ -406,8 +406,7 @@ static void dcn60_irq_construct( | |||
| 406 | 406 | struct irq_service *dal_irq_service_dcn60_create( | |
| 407 | 407 | struct irq_service_init_data *init_data) | |
| 408 | 408 | { | |
| 409 | - | struct irq_service *irq_service = kzalloc(sizeof(*irq_service), | |
| 410 | - | GFP_KERNEL); | |
| 409 | + | struct irq_service *irq_service = kzalloc_obj(*irq_service); | |
| 411 | 410 | ||
| 412 | 411 | if (!irq_service) | |
| 413 | 412 | return NULL; | |
modified drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_dpia_bw.c
| @@ -103,6 +103,11 @@ static int get_estimated_bw(struct dc_link *link) | |||
| 103 | 103 | { | |
| 104 | 104 | uint8_t bw_estimated_bw = 0; | |
| 105 | 105 | ||
| 106 | + | if (link->dpia_bw_alloc_config.bw_granularity == 0) { | |
| 107 | + | DC_LOG_ERROR("%s: BW granularity is zero!\n", __func__); | |
| 108 | + | return 0; | |
| 109 | + | } | |
| 110 | + | ||
| 106 | 111 | core_link_read_dpcd( | |
| 107 | 112 | link, | |
| 108 | 113 | ESTIMATED_BW, | |
modified drivers/gpu/drm/amd/display/dc/pg/dcn42/dcn42_pg_cntl.c
| @@ -615,7 +615,7 @@ struct pg_cntl *pg_cntl42_create( | |||
| 615 | 615 | const struct pg_cntl_shift *pg_cntl_shift, | |
| 616 | 616 | const struct pg_cntl_mask *pg_cntl_mask) | |
| 617 | 617 | { | |
| 618 | - | struct dcn_pg_cntl *pg_cntl_dcn = kzalloc(sizeof(*pg_cntl_dcn), GFP_KERNEL); | |
| 618 | + | struct dcn_pg_cntl *pg_cntl_dcn = kzalloc_obj(*pg_cntl_dcn); | |
| 619 | 619 | struct pg_cntl *base; | |
| 620 | 620 | ||
| 621 | 621 | if (pg_cntl_dcn == NULL) { | |
modified drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c
| @@ -1135,7 +1135,7 @@ static struct hpo_frl_stream_encoder *dcn30_hpo_frl_stream_encoder_create(enum e | |||
| 1135 | 1135 | } | |
| 1136 | 1136 | ||
| 1137 | 1137 | /* allocate HPO stream encoder and create VPG sub-block */ | |
| 1138 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1138 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1139 | 1139 | vpg = dcn30_vpg_create(ctx, vpg_inst); | |
| 1140 | 1140 | afmt = dcn30_afmt_create(ctx, afmt_inst); | |
| 1141 | 1141 | ||
| @@ -1166,7 +1166,7 @@ static struct hpo_frl_link_encoder *dcn30_hpo_frl_link_encoder_create(enum engin | |||
| 1166 | 1166 | ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1)); | |
| 1167 | 1167 | ||
| 1168 | 1168 | /* allocate HPO link encoder */ | |
| 1169 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1169 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1170 | 1170 | if (!hpo_enc3) | |
| 1171 | 1171 | return NULL; /* out of memory */ | |
| 1172 | 1172 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn302/dcn302_resource.c
| @@ -492,7 +492,7 @@ static struct hpo_frl_stream_encoder *dcn302_hpo_frl_stream_encoder_create(enum | |||
| 492 | 492 | return NULL; | |
| 493 | 493 | ||
| 494 | 494 | /* allocate HPO stream encoder and create VPG sub-block */ | |
| 495 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 495 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 496 | 496 | vpg = dcn302_vpg_create(ctx, vpg_inst); | |
| 497 | 497 | afmt = dcn302_afmt_create(ctx, afmt_inst); | |
| 498 | 498 | ||
| @@ -531,7 +531,7 @@ static struct hpo_frl_link_encoder *dcn302_hpo_frl_link_encoder_create(enum engi | |||
| 531 | 531 | ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1)); | |
| 532 | 532 | ||
| 533 | 533 | /* allocate HPO link encoder */ | |
| 534 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 534 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 535 | 535 | if (!hpo_enc3) | |
| 536 | 536 | return NULL; /* out of memory */ | |
| 537 | 537 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn303/dcn303_resource.c
| @@ -479,7 +479,7 @@ static struct hpo_frl_stream_encoder *dcn303_hpo_frl_stream_encoder_create(enum | |||
| 479 | 479 | return NULL; | |
| 480 | 480 | ||
| 481 | 481 | /* allocate HPO stream encoder and create VPG sub-block */ | |
| 482 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 482 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 483 | 483 | vpg = dcn303_vpg_create(ctx, vpg_inst); | |
| 484 | 484 | afmt = dcn303_afmt_create(ctx, afmt_inst); | |
| 485 | 485 | ||
| @@ -518,7 +518,7 @@ static struct hpo_frl_link_encoder *dcn303_hpo_frl_link_encoder_create(enum engi | |||
| 518 | 518 | ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1)); | |
| 519 | 519 | ||
| 520 | 520 | /* allocate HPO link encoder */ | |
| 521 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 521 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 522 | 522 | if (!hpo_enc3) | |
| 523 | 523 | return NULL; /* out of memory */ | |
| 524 | 524 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c
| @@ -1346,7 +1346,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e | |||
| 1346 | 1346 | } | |
| 1347 | 1347 | ||
| 1348 | 1348 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1349 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1349 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1350 | 1350 | vpg = dcn31_vpg_create(ctx, vpg_inst); | |
| 1351 | 1351 | afmt = dcn31_afmt_create(ctx, afmt_inst); | |
| 1352 | 1352 | ||
| @@ -1377,7 +1377,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin | |||
| 1377 | 1377 | ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1)); | |
| 1378 | 1378 | ||
| 1379 | 1379 | /* allocate HPO link encoder */ | |
| 1380 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1380 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1381 | 1381 | if (!hpo_enc3) | |
| 1382 | 1382 | return NULL; /* out of memory */ | |
| 1383 | 1383 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c
| @@ -1404,7 +1404,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e | |||
| 1404 | 1404 | } | |
| 1405 | 1405 | ||
| 1406 | 1406 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1407 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1407 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1408 | 1408 | vpg = dcn31_vpg_create(ctx, vpg_inst); | |
| 1409 | 1409 | afmt = dcn31_afmt_create(ctx, afmt_inst); | |
| 1410 | 1410 | ||
| @@ -1436,7 +1436,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin | |||
| 1436 | 1436 | ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1)); | |
| 1437 | 1437 | ||
| 1438 | 1438 | /* allocate HPO link encoder */ | |
| 1439 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1439 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1440 | 1440 | if (!hpo_enc3) | |
| 1441 | 1441 | return NULL; /* out of memory */ | |
| 1442 | 1442 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
| @@ -1347,7 +1347,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e | |||
| 1347 | 1347 | } | |
| 1348 | 1348 | ||
| 1349 | 1349 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1350 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1350 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1351 | 1351 | vpg = dcn31_vpg_create(ctx, vpg_inst); | |
| 1352 | 1352 | afmt = dcn31_afmt_create(ctx, afmt_inst); | |
| 1353 | 1353 | ||
| @@ -1379,7 +1379,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin | |||
| 1379 | 1379 | ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1)); | |
| 1380 | 1380 | ||
| 1381 | 1381 | /* allocate HPO link encoder */ | |
| 1382 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1382 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1383 | 1383 | if (!hpo_enc3) | |
| 1384 | 1384 | return NULL; /* out of memory */ | |
| 1385 | 1385 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn316/dcn316_resource.c
| @@ -1340,7 +1340,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e | |||
| 1340 | 1340 | } | |
| 1341 | 1341 | ||
| 1342 | 1342 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1343 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1343 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1344 | 1344 | vpg = dcn31_vpg_create(ctx, vpg_inst); | |
| 1345 | 1345 | afmt = dcn31_afmt_create(ctx, afmt_inst); | |
| 1346 | 1346 | ||
| @@ -1372,7 +1372,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin | |||
| 1372 | 1372 | ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1)); | |
| 1373 | 1373 | ||
| 1374 | 1374 | /* allocate HPO link encoder */ | |
| 1375 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1375 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1376 | 1376 | if (!hpo_enc3) | |
| 1377 | 1377 | return NULL; /* out of memory */ | |
| 1378 | 1378 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
| @@ -1339,7 +1339,7 @@ static struct hpo_frl_stream_encoder *dcn32_hpo_frl_stream_encoder_create(enum e | |||
| 1339 | 1339 | } | |
| 1340 | 1340 | ||
| 1341 | 1341 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1342 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1342 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1343 | 1343 | vpg = dcn32_vpg_create(ctx, vpg_inst); | |
| 1344 | 1344 | afmt = dcn32_afmt_create(ctx, afmt_inst); | |
| 1345 | 1345 | ||
| @@ -1375,7 +1375,7 @@ static struct hpo_frl_link_encoder *dcn32_hpo_frl_link_encoder_create(enum engin | |||
| 1375 | 1375 | hpo_frl_link_encoder_reg_list(0); | |
| 1376 | 1376 | ||
| 1377 | 1377 | /* allocate HPO link encoder */ | |
| 1378 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1378 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1379 | 1379 | if (!hpo_enc3) | |
| 1380 | 1380 | return NULL; /* out of memory */ | |
| 1381 | 1381 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
| @@ -1314,7 +1314,7 @@ static struct hpo_frl_stream_encoder *dcn321_hpo_frl_stream_encoder_create(enum | |||
| 1314 | 1314 | } | |
| 1315 | 1315 | ||
| 1316 | 1316 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1317 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1317 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1318 | 1318 | vpg = dcn321_vpg_create(ctx, vpg_inst); | |
| 1319 | 1319 | afmt = dcn321_afmt_create(ctx, afmt_inst); | |
| 1320 | 1320 | ||
| @@ -1350,7 +1350,7 @@ static struct hpo_frl_link_encoder *dcn321_hpo_frl_link_encoder_create(enum engi | |||
| 1350 | 1350 | hpo_frl_link_encoder_reg_list(0); | |
| 1351 | 1351 | ||
| 1352 | 1352 | /* allocate HPO link encoder */ | |
| 1353 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1353 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1354 | 1354 | if (!hpo_enc3) | |
| 1355 | 1355 | return NULL; /* out of memory */ | |
| 1356 | 1356 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
| @@ -1398,7 +1398,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create( | |||
| 1398 | 1398 | return NULL; | |
| 1399 | 1399 | ||
| 1400 | 1400 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1401 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1401 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1402 | 1402 | vpg = dcn31_vpg_create(ctx, vpg_inst); | |
| 1403 | 1403 | afmt = dcn31_afmt_create(ctx, afmt_inst); | |
| 1404 | 1404 | ||
| @@ -1430,7 +1430,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create( | |||
| 1430 | 1430 | hpo_frl_link_encoder_reg_list(0); | |
| 1431 | 1431 | ||
| 1432 | 1432 | /* allocate HPO link encoder */ | |
| 1433 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1433 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1434 | 1434 | if (!hpo_enc3) | |
| 1435 | 1435 | return NULL; /* out of memory */ | |
| 1436 | 1436 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c
| @@ -1378,7 +1378,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create( | |||
| 1378 | 1378 | return NULL; | |
| 1379 | 1379 | ||
| 1380 | 1380 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1381 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1381 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1382 | 1382 | vpg = dcn31_vpg_create(ctx, vpg_inst); | |
| 1383 | 1383 | afmt = dcn31_afmt_create(ctx, afmt_inst); | |
| 1384 | 1384 | ||
| @@ -1410,7 +1410,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create( | |||
| 1410 | 1410 | hpo_frl_link_encoder_reg_list(0); | |
| 1411 | 1411 | ||
| 1412 | 1412 | /* allocate HPO link encoder */ | |
| 1413 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1413 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1414 | 1414 | if (!hpo_enc3) | |
| 1415 | 1415 | return NULL; /* out of memory */ | |
| 1416 | 1416 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn36/dcn36_resource.c
| @@ -1385,7 +1385,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create( | |||
| 1385 | 1385 | return NULL; | |
| 1386 | 1386 | ||
| 1387 | 1387 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1388 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1388 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder); | |
| 1389 | 1389 | vpg = dcn31_vpg_create(ctx, vpg_inst); | |
| 1390 | 1390 | afmt = dcn31_afmt_create(ctx, afmt_inst); | |
| 1391 | 1391 | ||
| @@ -1417,7 +1417,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create( | |||
| 1417 | 1417 | hpo_frl_link_encoder_reg_list(0); | |
| 1418 | 1418 | ||
| 1419 | 1419 | /* allocate HPO link encoder */ | |
| 1420 | - | hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1420 | + | hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1421 | 1421 | if (!hpo_enc3) | |
| 1422 | 1422 | return NULL; /* out of memory */ | |
| 1423 | 1423 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c
| @@ -1322,7 +1322,7 @@ static struct hpo_frl_stream_encoder *dcn401_hpo_frl_stream_encoder_create( | |||
| 1322 | 1322 | return NULL; | |
| 1323 | 1323 | ||
| 1324 | 1324 | /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */ | |
| 1325 | - | hpo_enc401 = kzalloc(sizeof(struct dcn401_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1325 | + | hpo_enc401 = kzalloc_obj(struct dcn401_hpo_frl_stream_encoder); | |
| 1326 | 1326 | vpg = dcn401_vpg_create(ctx, vpg_inst); | |
| 1327 | 1327 | afmt = dcn401_afmt_create(ctx, afmt_inst); | |
| 1328 | 1328 | ||
| @@ -1353,7 +1353,7 @@ static struct hpo_frl_link_encoder *dcn401_hpo_frl_link_encoder_create( | |||
| 1353 | 1353 | hpo_frl_link_encoder_reg_list(0); | |
| 1354 | 1354 | ||
| 1355 | 1355 | /* allocate HPO link encoder */ | |
| 1356 | - | hpo_link_enc = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1356 | + | hpo_link_enc = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1357 | 1357 | if (!hpo_link_enc) | |
| 1358 | 1358 | return NULL; /* out of memory */ | |
| 1359 | 1359 | ||
modified drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c
| @@ -818,7 +818,7 @@ static struct dce_aux *dcn42_aux_engine_create( | |||
| 818 | 818 | uint32_t inst) | |
| 819 | 819 | { | |
| 820 | 820 | struct aux_engine_dce110 *aux_engine = | |
| 821 | - | kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL); | |
| 821 | + | kzalloc_obj(struct aux_engine_dce110); | |
| 822 | 822 | ||
| 823 | 823 | if (!aux_engine) | |
| 824 | 824 | return NULL; | |
| @@ -884,7 +884,7 @@ static struct dce_i2c_hw *dcn42_i2c_hw_create( | |||
| 884 | 884 | uint32_t inst) | |
| 885 | 885 | { | |
| 886 | 886 | struct dce_i2c_hw *dce_i2c_hw = | |
| 887 | - | kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); | |
| 887 | + | kzalloc_obj(struct dce_i2c_hw); | |
| 888 | 888 | ||
| 889 | 889 | if (!dce_i2c_hw) | |
| 890 | 890 | return NULL; | |
| @@ -910,7 +910,7 @@ static struct clock_source *dcn42_clock_source_create( | |||
| 910 | 910 | bool dp_clk_src) | |
| 911 | 911 | { | |
| 912 | 912 | struct dce110_clk_src *clk_src = | |
| 913 | - | kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL); | |
| 913 | + | kzalloc_obj(struct dce110_clk_src); | |
| 914 | 914 | ||
| 915 | 915 | if (!clk_src) | |
| 916 | 916 | return NULL; | |
| @@ -929,8 +929,7 @@ static struct hubbub *dcn42_hubbub_create(struct dc_context *ctx) | |||
| 929 | 929 | { | |
| 930 | 930 | int i; | |
| 931 | 931 | ||
| 932 | - | struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub), | |
| 933 | - | GFP_KERNEL); | |
| 932 | + | struct dcn20_hubbub *hubbub3 = kzalloc_obj(struct dcn20_hubbub); | |
| 934 | 933 | ||
| 935 | 934 | if (!hubbub3) | |
| 936 | 935 | return NULL; | |
| @@ -983,7 +982,7 @@ static struct hubp *dcn42_hubp_create( | |||
| 983 | 982 | uint32_t inst) | |
| 984 | 983 | { | |
| 985 | 984 | struct dcn20_hubp *hubp2 = | |
| 986 | - | kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL); | |
| 985 | + | kzalloc_obj(struct dcn20_hubp); | |
| 987 | 986 | ||
| 988 | 987 | if (!hubp2) | |
| 989 | 988 | return NULL; | |
| @@ -1025,7 +1024,7 @@ static struct dpp *dcn42_dpp_create( | |||
| 1025 | 1024 | uint32_t inst) | |
| 1026 | 1025 | { | |
| 1027 | 1026 | struct dcn42_dpp *dpp42 = | |
| 1028 | - | kzalloc(sizeof(struct dcn42_dpp), GFP_KERNEL); | |
| 1027 | + | kzalloc_obj(struct dcn42_dpp); | |
| 1029 | 1028 | ||
| 1030 | 1029 | if (!dpp42) | |
| 1031 | 1030 | return NULL; | |
| @@ -1051,8 +1050,7 @@ static struct mpc *dcn42_mpc_create( | |||
| 1051 | 1050 | int num_mpcc, | |
| 1052 | 1051 | int num_rmu) | |
| 1053 | 1052 | { | |
| 1054 | - | struct dcn42_mpc *mpc401 = kzalloc(sizeof(struct dcn42_mpc), | |
| 1055 | - | GFP_KERNEL); | |
| 1053 | + | struct dcn42_mpc *mpc401 = kzalloc_obj(struct dcn42_mpc); | |
| 1056 | 1054 | ||
| 1057 | 1055 | if (!mpc401) | |
| 1058 | 1056 | return NULL; | |
| @@ -1075,7 +1073,7 @@ static struct output_pixel_processor *dcn42_opp_create( | |||
| 1075 | 1073 | struct dc_context *ctx, uint32_t inst) | |
| 1076 | 1074 | { | |
| 1077 | 1075 | struct dcn20_opp *opp4 = | |
| 1078 | - | kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL); | |
| 1076 | + | kzalloc_obj(struct dcn20_opp); | |
| 1079 | 1077 | ||
| 1080 | 1078 | if (!opp4) { | |
| 1081 | 1079 | BREAK_TO_DEBUGGER(); | |
| @@ -1098,7 +1096,7 @@ static struct timing_generator *dcn42_timing_generator_create( | |||
| 1098 | 1096 | uint32_t instance) | |
| 1099 | 1097 | { | |
| 1100 | 1098 | struct optc *tgn10 = | |
| 1101 | - | kzalloc(sizeof(struct optc), GFP_KERNEL); | |
| 1099 | + | kzalloc_obj(struct optc); | |
| 1102 | 1100 | ||
| 1103 | 1101 | if (!tgn10) | |
| 1104 | 1102 | return NULL; | |
| @@ -1136,7 +1134,7 @@ static struct link_encoder *dcn42_link_encoder_create( | |||
| 1136 | 1134 | const struct encoder_init_data *enc_init_data) | |
| 1137 | 1135 | { | |
| 1138 | 1136 | struct dcn20_link_encoder *enc20 = | |
| 1139 | - | kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); | |
| 1137 | + | kzalloc_obj(struct dcn20_link_encoder); | |
| 1140 | 1138 | ||
| 1141 | 1139 | if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) | |
| 1142 | 1140 | return NULL; | |
| @@ -1202,7 +1200,7 @@ static struct vpg *dcn42_vpg_create( | |||
| 1202 | 1200 | struct dc_context *ctx, | |
| 1203 | 1201 | uint32_t inst) | |
| 1204 | 1202 | { | |
| 1205 | - | struct dcn31_vpg *vpg4 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL); | |
| 1203 | + | struct dcn31_vpg *vpg4 = kzalloc_obj(struct dcn31_vpg); | |
| 1206 | 1204 | ||
| 1207 | 1205 | if (!vpg4) | |
| 1208 | 1206 | return NULL; | |
| @@ -1231,7 +1229,7 @@ static struct apg *dcn42_apg_create( | |||
| 1231 | 1229 | struct dc_context *ctx, | |
| 1232 | 1230 | uint32_t inst) | |
| 1233 | 1231 | { | |
| 1234 | - | struct dcn31_apg *apg31 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL); | |
| 1232 | + | struct dcn31_apg *apg31 = kzalloc_obj(struct dcn31_apg); | |
| 1235 | 1233 | ||
| 1236 | 1234 | if (!apg31) | |
| 1237 | 1235 | return NULL; | |
| @@ -1275,7 +1273,7 @@ static struct stream_encoder *dcn42_stream_encoder_create( | |||
| 1275 | 1273 | } else | |
| 1276 | 1274 | return NULL; | |
| 1277 | 1275 | ||
| 1278 | - | enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL); | |
| 1276 | + | enc1 = kzalloc_obj(struct dcn10_stream_encoder); | |
| 1279 | 1277 | vpg = dcn42_vpg_create(ctx, vpg_inst); | |
| 1280 | 1278 | apg = dcn42_apg_create(ctx, apg_inst); | |
| 1281 | 1279 | ||
| @@ -1325,7 +1323,7 @@ static struct hpo_frl_stream_encoder *dcn42_hpo_frl_stream_encoder_create( | |||
| 1325 | 1323 | return NULL; | |
| 1326 | 1324 | ||
| 1327 | 1325 | /* allocate HPO stream encoder and create VPG sub-block */ | |
| 1328 | - | hpo_enc42 = kzalloc(sizeof(struct dcn42_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1326 | + | hpo_enc42 = kzalloc_obj(struct dcn42_hpo_frl_stream_encoder); | |
| 1329 | 1327 | vpg = dcn42_vpg_create(ctx, vpg_inst); | |
| 1330 | 1328 | apg = dcn42_apg_create(ctx, apg_inst); | |
| 1331 | 1329 | ||
| @@ -1357,7 +1355,7 @@ static struct hpo_frl_link_encoder *dcn42_hpo_frl_link_encoder_create( | |||
| 1357 | 1355 | hpo_frl_link_encoder_reg_list(0); | |
| 1358 | 1356 | ||
| 1359 | 1357 | /* allocate HPO link encoder */ | |
| 1360 | - | hpo_link_enc = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1358 | + | hpo_link_enc = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1361 | 1359 | if (!hpo_link_enc) | |
| 1362 | 1360 | return NULL; /* out of memory */ | |
| 1363 | 1361 | ||
| @@ -1399,7 +1397,7 @@ static struct hpo_dp_stream_encoder *dcn42_hpo_dp_stream_encoder_create( | |||
| 1399 | 1397 | apg_inst = hpo_dp_inst + 5; | |
| 1400 | 1398 | ||
| 1401 | 1399 | /* allocate HPO stream encoder and create VPG sub-block */ | |
| 1402 | - | hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL); | |
| 1400 | + | hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_stream_encoder); | |
| 1403 | 1401 | vpg = dcn42_vpg_create(ctx, vpg_inst); | |
| 1404 | 1402 | apg = dcn42_apg_create(ctx, apg_inst); | |
| 1405 | 1403 | ||
| @@ -1432,7 +1430,7 @@ static struct hpo_dp_link_encoder *dcn42_hpo_dp_link_encoder_create( | |||
| 1432 | 1430 | struct dcn31_hpo_dp_link_encoder *hpo_dp_enc31; | |
| 1433 | 1431 | ||
| 1434 | 1432 | /* allocate HPO link encoder */ | |
| 1435 | - | hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL); | |
| 1433 | + | hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_link_encoder); | |
| 1436 | 1434 | if (!hpo_dp_enc31) | |
| 1437 | 1435 | return NULL; /* out of memory */ | |
| 1438 | 1436 | ||
| @@ -1453,7 +1451,7 @@ static struct hpo_dp_link_encoder *dcn42_hpo_dp_link_encoder_create( | |||
| 1453 | 1451 | static struct dce_hwseq *dcn42_hwseq_create( | |
| 1454 | 1452 | struct dc_context *ctx) | |
| 1455 | 1453 | { | |
| 1456 | - | struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL); | |
| 1454 | + | struct dce_hwseq *hws = kzalloc_obj(struct dce_hwseq); | |
| 1457 | 1455 | ||
| 1458 | 1456 | #undef REG_STRUCT | |
| 1459 | 1457 | #define REG_STRUCT hwseq_reg | |
| @@ -1727,8 +1725,7 @@ static bool dcn42_dwbc_create(struct dc_context *ctx, struct resource_pool *pool | |||
| 1727 | 1725 | uint32_t dwb_count = pool->res_cap->num_dwb; | |
| 1728 | 1726 | ||
| 1729 | 1727 | for (i = 0; i < dwb_count; i++) { | |
| 1730 | - | struct dcn30_dwbc *dwbc42 = kzalloc(sizeof(struct dcn30_dwbc), | |
| 1731 | - | GFP_KERNEL); | |
| 1728 | + | struct dcn30_dwbc *dwbc42 = kzalloc_obj(struct dcn30_dwbc); | |
| 1732 | 1729 | ||
| 1733 | 1730 | if (!dwbc42) { | |
| 1734 | 1731 | dm_error("DC: failed to create dwbc42!\n"); | |
| @@ -1764,8 +1761,7 @@ static bool dcn42_mmhubbub_create(struct dc_context *ctx, struct resource_pool * | |||
| 1764 | 1761 | uint32_t pipe_count = pool->res_cap->num_dwb; | |
| 1765 | 1762 | ||
| 1766 | 1763 | for (i = 0; i < pipe_count; i++) { | |
| 1767 | - | struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub), | |
| 1768 | - | GFP_KERNEL); | |
| 1764 | + | struct dcn30_mmhubbub *mcif_wb30 = kzalloc_obj(struct dcn30_mmhubbub); | |
| 1769 | 1765 | ||
| 1770 | 1766 | if (!mcif_wb30) { | |
| 1771 | 1767 | dm_error("DC: failed to create mcif_wb30!\n"); | |
| @@ -1793,7 +1789,7 @@ static struct display_stream_compressor *dcn42_dsc_create( | |||
| 1793 | 1789 | struct dc_context *ctx, uint32_t inst) | |
| 1794 | 1790 | { | |
| 1795 | 1791 | struct dcn401_dsc *dsc = | |
| 1796 | - | kzalloc(sizeof(struct dcn401_dsc), GFP_KERNEL); | |
| 1792 | + | kzalloc_obj(struct dcn401_dsc); | |
| 1797 | 1793 | ||
| 1798 | 1794 | if (!dsc) { | |
| 1799 | 1795 | BREAK_TO_DEBUGGER(); | |
| @@ -1890,7 +1886,7 @@ static struct link_encoder *dcn42_link_enc_create_minimal( | |||
| 1890 | 1886 | if ((unsigned int)(eng_id - ENGINE_ID_DIGA) >= ctx->dc->res_pool->res_cap->num_dig_link_enc) | |
| 1891 | 1887 | return NULL; | |
| 1892 | 1888 | ||
| 1893 | - | enc20 = kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); | |
| 1889 | + | enc20 = kzalloc_obj(struct dcn20_link_encoder); | |
| 1894 | 1890 | if (!enc20) | |
| 1895 | 1891 | return NULL; | |
| 1896 | 1892 | ||
| @@ -2441,7 +2437,7 @@ struct resource_pool *dcn42_create_resource_pool( | |||
| 2441 | 2437 | struct dc *dc) | |
| 2442 | 2438 | { | |
| 2443 | 2439 | struct dcn42_resource_pool *pool = | |
| 2444 | - | kzalloc(sizeof(struct dcn401_resource_pool), GFP_KERNEL); | |
| 2440 | + | kzalloc_obj(struct dcn42_resource_pool); | |
| 2445 | 2441 | ||
| 2446 | 2442 | if (!pool) | |
| 2447 | 2443 | return NULL; | |
modified drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c
| @@ -870,7 +870,7 @@ static struct dce_aux *dcn42b_aux_engine_create( | |||
| 870 | 870 | uint32_t inst) | |
| 871 | 871 | { | |
| 872 | 872 | struct aux_engine_dce110 *aux_engine = | |
| 873 | - | kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL); | |
| 873 | + | kzalloc_obj(struct aux_engine_dce110); | |
| 874 | 874 | ||
| 875 | 875 | if (!aux_engine) | |
| 876 | 876 | return NULL; | |
| @@ -940,7 +940,7 @@ static struct dce_i2c_hw *dcn42b_i2c_hw_create( | |||
| 940 | 940 | uint32_t inst) | |
| 941 | 941 | { | |
| 942 | 942 | struct dce_i2c_hw *dce_i2c_hw = | |
| 943 | - | kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); | |
| 943 | + | kzalloc_obj(struct dce_i2c_hw); | |
| 944 | 944 | ||
| 945 | 945 | if (!dce_i2c_hw) | |
| 946 | 946 | return NULL; | |
| @@ -968,7 +968,7 @@ static struct clock_source *dcn42b_clock_source_create( | |||
| 968 | 968 | bool dp_clk_src) | |
| 969 | 969 | { | |
| 970 | 970 | struct dce110_clk_src *clk_src = | |
| 971 | - | kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL); | |
| 971 | + | kzalloc_obj(struct dce110_clk_src); | |
| 972 | 972 | ||
| 973 | 973 | if (!clk_src) | |
| 974 | 974 | return NULL; | |
| @@ -988,8 +988,7 @@ static struct hubbub *dcn42b_hubbub_create(struct dc_context *ctx) | |||
| 988 | 988 | { | |
| 989 | 989 | int i; | |
| 990 | 990 | ||
| 991 | - | struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub), | |
| 992 | - | GFP_KERNEL); | |
| 991 | + | struct dcn20_hubbub *hubbub3 = kzalloc_obj(struct dcn20_hubbub); | |
| 993 | 992 | ||
| 994 | 993 | if (!hubbub3) | |
| 995 | 994 | return NULL; | |
| @@ -1042,7 +1041,7 @@ static struct hubp *dcn42b_hubp_create( | |||
| 1042 | 1041 | uint32_t inst) | |
| 1043 | 1042 | { | |
| 1044 | 1043 | struct dcn20_hubp *hubp2 = | |
| 1045 | - | kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL); | |
| 1044 | + | kzalloc_obj(struct dcn20_hubp); | |
| 1046 | 1045 | ||
| 1047 | 1046 | if (!hubp2) | |
| 1048 | 1047 | return NULL; | |
| @@ -1084,7 +1083,7 @@ static struct dpp *dcn42b_dpp_create( | |||
| 1084 | 1083 | uint32_t inst) | |
| 1085 | 1084 | { | |
| 1086 | 1085 | struct dcn42_dpp *dpp42b = | |
| 1087 | - | kzalloc(sizeof(struct dcn42_dpp), GFP_KERNEL); | |
| 1086 | + | kzalloc_obj(struct dcn42_dpp); | |
| 1088 | 1087 | ||
| 1089 | 1088 | if (!dpp42b) | |
| 1090 | 1089 | return NULL; | |
| @@ -1110,8 +1109,7 @@ static struct mpc *dcn42b_mpc_create( | |||
| 1110 | 1109 | int num_mpcc, | |
| 1111 | 1110 | int num_rmu) | |
| 1112 | 1111 | { | |
| 1113 | - | struct dcn42_mpc *mpc42b = kzalloc(sizeof(struct dcn42_mpc), | |
| 1114 | - | GFP_KERNEL); | |
| 1112 | + | struct dcn42_mpc *mpc42b = kzalloc_obj(struct dcn42_mpc); | |
| 1115 | 1113 | ||
| 1116 | 1114 | if (!mpc42b) | |
| 1117 | 1115 | return NULL; | |
| @@ -1134,7 +1132,7 @@ static struct output_pixel_processor *dcn42b_opp_create( | |||
| 1134 | 1132 | struct dc_context *ctx, uint32_t inst) | |
| 1135 | 1133 | { | |
| 1136 | 1134 | struct dcn20_opp *opp4 = | |
| 1137 | - | kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL); | |
| 1135 | + | kzalloc_obj(struct dcn20_opp); | |
| 1138 | 1136 | ||
| 1139 | 1137 | if (!opp4) { | |
| 1140 | 1138 | BREAK_TO_DEBUGGER(); | |
| @@ -1158,7 +1156,7 @@ static struct timing_generator *dcn42b_timing_generator_create( | |||
| 1158 | 1156 | uint32_t instance) | |
| 1159 | 1157 | { | |
| 1160 | 1158 | struct optc *tgn10 = | |
| 1161 | - | kzalloc(sizeof(struct optc), GFP_KERNEL); | |
| 1159 | + | kzalloc_obj(struct optc); | |
| 1162 | 1160 | ||
| 1163 | 1161 | if (!tgn10) | |
| 1164 | 1162 | return NULL; | |
| @@ -1196,7 +1194,7 @@ static struct link_encoder *dcn42b_link_encoder_create( | |||
| 1196 | 1194 | const struct encoder_init_data *enc_init_data) | |
| 1197 | 1195 | { | |
| 1198 | 1196 | struct dcn20_link_encoder *enc20 = | |
| 1199 | - | kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); | |
| 1197 | + | kzalloc_obj(struct dcn20_link_encoder); | |
| 1200 | 1198 | ||
| 1201 | 1199 | if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) | |
| 1202 | 1200 | return NULL; | |
| @@ -1271,7 +1269,7 @@ static struct vpg *dcn42b_vpg_create( | |||
| 1271 | 1269 | struct dc_context *ctx, | |
| 1272 | 1270 | uint32_t inst) | |
| 1273 | 1271 | { | |
| 1274 | - | struct dcn31_vpg *vpg4 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL); | |
| 1272 | + | struct dcn31_vpg *vpg4 = kzalloc_obj(struct dcn31_vpg); | |
| 1275 | 1273 | ||
| 1276 | 1274 | if (!vpg4) | |
| 1277 | 1275 | return NULL; | |
| @@ -1300,7 +1298,7 @@ static struct apg *dcn42b_apg_create( | |||
| 1300 | 1298 | struct dc_context *ctx, | |
| 1301 | 1299 | uint32_t inst) | |
| 1302 | 1300 | { | |
| 1303 | - | struct dcn31_apg *apg31 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL); | |
| 1301 | + | struct dcn31_apg *apg31 = kzalloc_obj(struct dcn31_apg); | |
| 1304 | 1302 | ||
| 1305 | 1303 | if (!apg31) | |
| 1306 | 1304 | return NULL; | |
| @@ -1344,7 +1342,7 @@ static struct stream_encoder *dcn42b_stream_encoder_create( | |||
| 1344 | 1342 | } else | |
| 1345 | 1343 | return NULL; | |
| 1346 | 1344 | ||
| 1347 | - | enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL); | |
| 1345 | + | enc1 = kzalloc_obj(struct dcn10_stream_encoder); | |
| 1348 | 1346 | vpg = dcn42b_vpg_create(ctx, vpg_inst); | |
| 1349 | 1347 | apg = dcn42b_apg_create(ctx, apg_inst); | |
| 1350 | 1348 | ||
| @@ -1404,7 +1402,7 @@ static struct hpo_dp_stream_encoder *dcn42b_hpo_dp_stream_encoder_create( | |||
| 1404 | 1402 | apg_inst = hpo_dp_inst + 6; | |
| 1405 | 1403 | ||
| 1406 | 1404 | /* allocate HPO stream encoder and create VPG sub-block */ | |
| 1407 | - | hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL); | |
| 1405 | + | hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_stream_encoder); | |
| 1408 | 1406 | vpg = dcn42b_vpg_create(ctx, vpg_inst); | |
| 1409 | 1407 | apg = dcn42b_apg_create(ctx, apg_inst); | |
| 1410 | 1408 | ||
| @@ -1437,7 +1435,7 @@ static struct hpo_dp_link_encoder *dcn42b_hpo_dp_link_encoder_create( | |||
| 1437 | 1435 | struct dcn31_hpo_dp_link_encoder *hpo_dp_enc31; | |
| 1438 | 1436 | ||
| 1439 | 1437 | /* allocate HPO link encoder */ | |
| 1440 | - | hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL); | |
| 1438 | + | hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_link_encoder); | |
| 1441 | 1439 | if (!hpo_dp_enc31) | |
| 1442 | 1440 | return NULL; /* out of memory */ | |
| 1443 | 1441 | ||
| @@ -1457,7 +1455,7 @@ static struct hpo_dp_link_encoder *dcn42b_hpo_dp_link_encoder_create( | |||
| 1457 | 1455 | static struct dce_hwseq *dcn42b_hwseq_create( | |
| 1458 | 1456 | struct dc_context *ctx) | |
| 1459 | 1457 | { | |
| 1460 | - | struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL); | |
| 1458 | + | struct dce_hwseq *hws = kzalloc_obj(struct dce_hwseq); | |
| 1461 | 1459 | ||
| 1462 | 1460 | #undef REG_STRUCT | |
| 1463 | 1461 | #define REG_STRUCT hwseq_reg | |
| @@ -1716,8 +1714,7 @@ static bool dcn42b_dwbc_create(struct dc_context *ctx, struct resource_pool *poo | |||
| 1716 | 1714 | uint32_t dwb_count = pool->res_cap->num_dwb; | |
| 1717 | 1715 | ||
| 1718 | 1716 | for (i = 0; i < dwb_count; i++) { | |
| 1719 | - | struct dcn30_dwbc *dwbc42 = kzalloc(sizeof(struct dcn30_dwbc), | |
| 1720 | - | GFP_KERNEL); | |
| 1717 | + | struct dcn30_dwbc *dwbc42 = kzalloc_obj(struct dcn30_dwbc); | |
| 1721 | 1718 | ||
| 1722 | 1719 | if (!dwbc42) { | |
| 1723 | 1720 | dm_error("DC: failed to create dwbc42!\n"); | |
| @@ -1753,8 +1750,7 @@ static bool dcn42b_mmhubbub_create(struct dc_context *ctx, struct resource_pool | |||
| 1753 | 1750 | uint32_t pipe_count = pool->res_cap->num_dwb; | |
| 1754 | 1751 | ||
| 1755 | 1752 | for (i = 0; i < pipe_count; i++) { | |
| 1756 | - | struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub), | |
| 1757 | - | GFP_KERNEL); | |
| 1753 | + | struct dcn30_mmhubbub *mcif_wb30 = kzalloc_obj(struct dcn30_mmhubbub); | |
| 1758 | 1754 | ||
| 1759 | 1755 | if (!mcif_wb30) { | |
| 1760 | 1756 | dm_error("DC: failed to create mcif_wb30!\n"); | |
| @@ -1782,7 +1778,7 @@ static struct display_stream_compressor *dcn42b_dsc_create( | |||
| 1782 | 1778 | struct dc_context *ctx, uint32_t inst) | |
| 1783 | 1779 | { | |
| 1784 | 1780 | struct dcn401_dsc *dsc = | |
| 1785 | - | kzalloc(sizeof(struct dcn401_dsc), GFP_KERNEL); | |
| 1781 | + | kzalloc_obj(struct dcn401_dsc); | |
| 1786 | 1782 | ||
| 1787 | 1783 | if (!dsc) { | |
| 1788 | 1784 | BREAK_TO_DEBUGGER(); | |
| @@ -1875,7 +1871,7 @@ static struct link_encoder *dcn42b_link_enc_create_minimal( | |||
| 1875 | 1871 | if ((unsigned int)(eng_id - ENGINE_ID_DIGA) >= ctx->dc->res_pool->res_cap->num_dig_link_enc) | |
| 1876 | 1872 | return NULL; | |
| 1877 | 1873 | ||
| 1878 | - | enc20 = kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); | |
| 1874 | + | enc20 = kzalloc_obj(struct dcn20_link_encoder); | |
| 1879 | 1875 | if (!enc20) | |
| 1880 | 1876 | return NULL; | |
| 1881 | 1877 | ||
| @@ -2439,7 +2435,7 @@ struct resource_pool *dcn42b_create_resource_pool( | |||
| 2439 | 2435 | struct dc *dc) | |
| 2440 | 2436 | { | |
| 2441 | 2437 | struct dcn42b_resource_pool *pool = | |
| 2442 | - | kzalloc(sizeof(struct dcn42b_resource_pool), GFP_KERNEL); | |
| 2438 | + | kzalloc_obj(struct dcn42b_resource_pool); | |
| 2443 | 2439 | ||
| 2444 | 2440 | if (!pool) | |
| 2445 | 2441 | return NULL; | |
modified drivers/gpu/drm/amd/display/dc/resource/dcn60/dcn60_resource.c
| @@ -998,7 +998,7 @@ static struct dce_aux *dcn60_aux_engine_create( | |||
| 998 | 998 | uint32_t inst) | |
| 999 | 999 | { | |
| 1000 | 1000 | struct aux_engine_dce110 *aux_engine = | |
| 1001 | - | kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL); | |
| 1001 | + | kzalloc_obj(struct aux_engine_dce110); | |
| 1002 | 1002 | ||
| 1003 | 1003 | if (!aux_engine) | |
| 1004 | 1004 | return NULL; | |
| @@ -1037,7 +1037,7 @@ static struct dce_i2c_hw *dcn60_i2c_hw_create( | |||
| 1037 | 1037 | uint32_t inst) | |
| 1038 | 1038 | { | |
| 1039 | 1039 | struct dce_i2c_hw *dce_i2c_hw = | |
| 1040 | - | kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); | |
| 1040 | + | kzalloc_obj(struct dce_i2c_hw); | |
| 1041 | 1041 | ||
| 1042 | 1042 | if (!dce_i2c_hw) | |
| 1043 | 1043 | return NULL; | |
| @@ -1061,7 +1061,7 @@ static struct clock_source *dcn60_clock_source_create( | |||
| 1061 | 1061 | bool dp_clk_src) | |
| 1062 | 1062 | { | |
| 1063 | 1063 | struct dce110_clk_src *clk_src = | |
| 1064 | - | kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL); | |
| 1064 | + | kzalloc_obj(struct dce110_clk_src); | |
| 1065 | 1065 | ||
| 1066 | 1066 | if (!clk_src) | |
| 1067 | 1067 | return NULL; | |
| @@ -1081,8 +1081,7 @@ static struct hubbub *dcn60_hubbub_create(struct dc_context *ctx) | |||
| 1081 | 1081 | { | |
| 1082 | 1082 | int i; | |
| 1083 | 1083 | ||
| 1084 | - | struct dcn20_hubbub *hubbub2 = kzalloc(sizeof(struct dcn20_hubbub), | |
| 1085 | - | GFP_KERNEL); | |
| 1084 | + | struct dcn20_hubbub *hubbub2 = kzalloc_obj(struct dcn20_hubbub); | |
| 1086 | 1085 | ||
| 1087 | 1086 | if (!hubbub2) | |
| 1088 | 1087 | return NULL; | |
| @@ -1136,7 +1135,7 @@ static struct hubp *dcn60_hubp_create( | |||
| 1136 | 1135 | uint32_t inst) | |
| 1137 | 1136 | { | |
| 1138 | 1137 | struct dcn20_hubp *hubp2 = | |
| 1139 | - | kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL); | |
| 1138 | + | kzalloc_obj(struct dcn20_hubp); | |
| 1140 | 1139 | ||
| 1141 | 1140 | if (!hubp2) | |
| 1142 | 1141 | return NULL; | |
| @@ -1168,7 +1167,7 @@ static struct dpp *dcn60_dpp_create( | |||
| 1168 | 1167 | uint32_t inst) | |
| 1169 | 1168 | { | |
| 1170 | 1169 | struct dcn60_dpp *dpp60 = | |
| 1171 | - | kzalloc(sizeof(struct dcn60_dpp), GFP_KERNEL); | |
| 1170 | + | kzalloc_obj(struct dcn60_dpp); | |
| 1172 | 1171 | ||
| 1173 | 1172 | if (!dpp60) | |
| 1174 | 1173 | return NULL; | |
| @@ -1194,8 +1193,7 @@ static struct mpc *dcn60_mpc_create( | |||
| 1194 | 1193 | int num_mpcc, | |
| 1195 | 1194 | int num_rmu) | |
| 1196 | 1195 | { | |
| 1197 | - | struct dcn60_mpc *mpc60 = kzalloc(sizeof(struct dcn60_mpc), | |
| 1198 | - | GFP_KERNEL); | |
| 1196 | + | struct dcn60_mpc *mpc60 = kzalloc_obj(struct dcn60_mpc); | |
| 1199 | 1197 | ||
| 1200 | 1198 | if (!mpc60) | |
| 1201 | 1199 | return NULL; | |
| @@ -1218,7 +1216,7 @@ static struct output_pixel_processor *dcn60_opp_create( | |||
| 1218 | 1216 | struct dc_context *ctx, uint32_t inst) | |
| 1219 | 1217 | { | |
| 1220 | 1218 | struct dcn20_opp *opp2 = | |
| 1221 | - | kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL); | |
| 1219 | + | kzalloc_obj(struct dcn20_opp); | |
| 1222 | 1220 | ||
| 1223 | 1221 | if (!opp2) { | |
| 1224 | 1222 | BREAK_TO_DEBUGGER(); | |
| @@ -1242,7 +1240,7 @@ static struct timing_generator *dcn60_timing_generator_create( | |||
| 1242 | 1240 | uint32_t instance) | |
| 1243 | 1241 | { | |
| 1244 | 1242 | struct optc *tgn10 = | |
| 1245 | - | kzalloc(sizeof(struct optc), GFP_KERNEL); | |
| 1243 | + | kzalloc_obj(struct optc); | |
| 1246 | 1244 | ||
| 1247 | 1245 | if (!tgn10) | |
| 1248 | 1246 | return NULL; | |
| @@ -1282,7 +1280,7 @@ static struct link_encoder *dcn60_link_encoder_create( | |||
| 1282 | 1280 | const struct encoder_init_data *enc_init_data) | |
| 1283 | 1281 | { | |
| 1284 | 1282 | struct dcn20_link_encoder *enc20 = | |
| 1285 | - | kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); | |
| 1283 | + | kzalloc_obj(struct dcn20_link_encoder); | |
| 1286 | 1284 | ||
| 1287 | 1285 | if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) { | |
| 1288 | 1286 | kfree(enc20); | |
| @@ -1349,7 +1347,7 @@ static struct vpg *dcn60_vpg_create( | |||
| 1349 | 1347 | struct dc_context *ctx, | |
| 1350 | 1348 | uint32_t inst) | |
| 1351 | 1349 | { | |
| 1352 | - | struct dcn31_vpg *vpg6 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL); | |
| 1350 | + | struct dcn31_vpg *vpg6 = kzalloc_obj(struct dcn31_vpg); | |
| 1353 | 1351 | ||
| 1354 | 1352 | if (!vpg6) | |
| 1355 | 1353 | return NULL; | |
| @@ -1378,7 +1376,7 @@ static struct apg *dcn60_apg_create( | |||
| 1378 | 1376 | struct dc_context *ctx, | |
| 1379 | 1377 | uint32_t inst) | |
| 1380 | 1378 | { | |
| 1381 | - | struct dcn31_apg *apg60 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL); | |
| 1379 | + | struct dcn31_apg *apg60 = kzalloc_obj(struct dcn31_apg); | |
| 1382 | 1380 | ||
| 1383 | 1381 | if (!apg60) | |
| 1384 | 1382 | return NULL; | |
| @@ -1415,7 +1413,7 @@ static struct stream_encoder *dcn60_stream_encoder_create( | |||
| 1415 | 1413 | } else | |
| 1416 | 1414 | return NULL; | |
| 1417 | 1415 | ||
| 1418 | - | enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL); | |
| 1416 | + | enc1 = kzalloc_obj(struct dcn10_stream_encoder); | |
| 1419 | 1417 | vpg = dcn60_vpg_create(ctx, vpg_inst); | |
| 1420 | 1418 | apg = dcn60_apg_create(ctx, apg_inst); | |
| 1421 | 1419 | ||
| @@ -1462,7 +1460,7 @@ static struct hpo_frl_stream_encoder *dcn60_hpo_frl_stream_encoder_create( | |||
| 1462 | 1460 | return NULL; | |
| 1463 | 1461 | ||
| 1464 | 1462 | /* allocate HPO stream encoder and create VPG, APG sub-blocks */ | |
| 1465 | - | hpo_enc60 = kzalloc(sizeof(struct dcn401_hpo_frl_stream_encoder), GFP_KERNEL); | |
| 1463 | + | hpo_enc60 = kzalloc_obj(struct dcn401_hpo_frl_stream_encoder); | |
| 1466 | 1464 | vpg = dcn60_vpg_create(ctx, vpg_inst); | |
| 1467 | 1465 | apg = dcn60_apg_create(ctx, apg_inst); | |
| 1468 | 1466 | ||
| @@ -1493,7 +1491,7 @@ static struct hpo_frl_link_encoder *dcn60_hpo_frl_link_encoder_create( | |||
| 1493 | 1491 | hpo_frl_link_encoder_reg_list(0); | |
| 1494 | 1492 | ||
| 1495 | 1493 | /* allocate HPO link encoder */ | |
| 1496 | - | hpo_link_enc = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL); | |
| 1494 | + | hpo_link_enc = kzalloc_obj(struct dcn30_hpo_frl_link_encoder); | |
| 1497 | 1495 | if (!hpo_link_enc) | |
| 1498 | 1496 | return NULL; /* out of memory */ | |
| 1499 | 1497 | ||
| @@ -1535,7 +1533,7 @@ static struct hpo_dp_stream_encoder *dcn60_hpo_dp_stream_encoder_create( | |||
| 1535 | 1533 | apg_inst = hpo_dp_inst; | |
| 1536 | 1534 | ||
| 1537 | 1535 | /* allocate HPO stream encoder and create VPG sub-block */ | |
| 1538 | - | hpo_dp_enc60 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL); | |
| 1536 | + | hpo_dp_enc60 = kzalloc_obj(struct dcn31_hpo_dp_stream_encoder); | |
| 1539 | 1537 | vpg = dcn60_vpg_create(ctx, vpg_inst); | |
| 1540 | 1538 | apg = dcn60_apg_create(ctx, apg_inst); | |
| 1541 | 1539 | ||
| @@ -1568,7 +1566,7 @@ static struct hpo_dp_link_encoder *dcn60_hpo_dp_link_encoder_create( | |||
| 1568 | 1566 | struct dcn31_hpo_dp_link_encoder *hpo_dp_enc60; | |
| 1569 | 1567 | ||
| 1570 | 1568 | /* allocate HPO link encoder */ | |
| 1571 | - | hpo_dp_enc60 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL); | |
| 1569 | + | hpo_dp_enc60 = kzalloc_obj(struct dcn31_hpo_dp_link_encoder); | |
| 1572 | 1570 | if (!hpo_dp_enc60) | |
| 1573 | 1571 | return NULL; /* out of memory */ | |
| 1574 | 1572 | ||
| @@ -1589,7 +1587,7 @@ static struct hpo_dp_link_encoder *dcn60_hpo_dp_link_encoder_create( | |||
| 1589 | 1587 | static struct dce_hwseq *dcn60_hwseq_create( | |
| 1590 | 1588 | struct dc_context *ctx) | |
| 1591 | 1589 | { | |
| 1592 | - | struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL); | |
| 1590 | + | struct dce_hwseq *hws = kzalloc_obj(struct dce_hwseq); | |
| 1593 | 1591 | ||
| 1594 | 1592 | #undef REG_STRUCT | |
| 1595 | 1593 | #define REG_STRUCT hwseq_reg | |
| @@ -1784,7 +1782,7 @@ static struct display_stream_compressor *dcn60_dsc_create( | |||
| 1784 | 1782 | struct dc_context *ctx, uint32_t inst) | |
| 1785 | 1783 | { | |
| 1786 | 1784 | struct dcn60_dsc *dsc = | |
| 1787 | - | kzalloc(sizeof(struct dcn60_dsc), GFP_KERNEL); | |
| 1785 | + | kzalloc_obj(struct dcn60_dsc); | |
| 1788 | 1786 | ||
| 1789 | 1787 | if (!dsc) { | |
| 1790 | 1788 | BREAK_TO_DEBUGGER(); | |
| @@ -2363,7 +2361,7 @@ struct resource_pool *dcn60_create_resource_pool( | |||
| 2363 | 2361 | struct dc *dc) | |
| 2364 | 2362 | { | |
| 2365 | 2363 | struct dcn60_resource_pool *pool = | |
| 2366 | - | kzalloc(sizeof(struct dcn60_resource_pool), GFP_KERNEL); | |
| 2364 | + | kzalloc_obj(struct dcn60_resource_pool); | |
| 2367 | 2365 | ||
| 2368 | 2366 | if (!pool) | |
| 2369 | 2367 | return NULL; | |
modified drivers/gpu/drm/amd/display/modules/power/power.c
| @@ -111,7 +111,7 @@ struct mod_power *mod_power_create(struct dc *dc, | |||
| 111 | 111 | if (dc == NULL) | |
| 112 | 112 | goto fail_dc_null; | |
| 113 | 113 | ||
| 114 | - | core_power = kzalloc(sizeof(struct core_power), GFP_KERNEL); | |
| 114 | + | core_power = kzalloc_obj(struct core_power); | |
| 115 | 115 | ||
| 116 | 116 | if (core_power == NULL) | |
| 117 | 117 | goto fail_alloc_context; | |
| @@ -129,8 +129,7 @@ struct mod_power *mod_power_create(struct dc *dc, | |||
| 129 | 129 | ||
| 130 | 130 | for (i = 0; i < MOD_POWER_MAX_CONCURRENT_STREAMS; i++) { | |
| 131 | 131 | core_power->map[i].psr_context = | |
| 132 | - | kzalloc(sizeof(struct mod_power_psr_context), | |
| 133 | - | GFP_KERNEL); | |
| 132 | + | kzalloc_obj(struct mod_power_psr_context); | |
| 134 | 133 | if (core_power->map[i].psr_context == NULL) | |
| 135 | 134 | goto fail_construct; | |
| 136 | 135 | } | |
modified drivers/gpu/drm/amd/display/modules/power/power_abm.c
| @@ -705,8 +705,7 @@ void initialize_backlight_caps(struct core_power *core_power, unsigned int inst) | |||
| 705 | 705 | * (do not want to use 256 bytes on the stack) | |
| 706 | 706 | */ | |
| 707 | 707 | ext_backlight_caps = (struct dm_acpi_atif_backlight_caps *) | |
| 708 | - | (kzalloc(sizeof(struct dm_acpi_atif_backlight_caps), | |
| 709 | - | GFP_KERNEL)); | |
| 708 | + | (kzalloc_obj(struct dm_acpi_atif_backlight_caps)); | |
| 710 | 709 | ||
| 711 | 710 | if (ext_backlight_caps == NULL) | |
| 712 | 711 | return; | |
modified drivers/gpu/drm/amd/pm/amdgpu_dpm.c
| @@ -348,7 +348,8 @@ int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, | |||
| 348 | 348 | const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; | |
| 349 | 349 | int ret = 0; | |
| 350 | 350 | ||
| 351 | - | if (amdgpu_sriov_vf(adev)) | |
| 351 | + | if (amdgpu_sriov_vf(adev) || | |
| 352 | + | amdgpu_in_reset(adev)) | |
| 352 | 353 | return 0; | |
| 353 | 354 | ||
| 354 | 355 | if (pp_funcs && pp_funcs->switch_power_profile) { | |
| @@ -367,7 +368,8 @@ int amdgpu_dpm_pause_power_profile(struct amdgpu_device *adev, | |||
| 367 | 368 | const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; | |
| 368 | 369 | int ret = 0; | |
| 369 | 370 | ||
| 370 | - | if (amdgpu_sriov_vf(adev)) | |
| 371 | + | if (amdgpu_sriov_vf(adev) || | |
| 372 | + | amdgpu_in_reset(adev)) | |
| 371 | 373 | return 0; | |
| 372 | 374 | ||
| 373 | 375 | if (pp_funcs && pp_funcs->pause_power_profile) { | |
modified drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
| @@ -2988,7 +2988,7 @@ static int smu7_init_voltage_dependency_on_display_clock_table(struct pp_hwmgr * | |||
| 2988 | 2988 | if (!amdgpu_device_ip_get_ip_block(hwmgr->adev, AMD_IP_BLOCK_TYPE_DCE)) | |
| 2989 | 2989 | return 0; | |
| 2990 | 2990 | ||
| 2991 | - | table = kzalloc(struct_size(table, entries, 4), GFP_KERNEL); | |
| 2991 | + | table = kzalloc_flex(*table, entries, 4); | |
| 2992 | 2992 | if (!table) | |
| 2993 | 2993 | return -ENOMEM; | |
| 2994 | 2994 | ||
modified drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
| @@ -2092,11 +2092,11 @@ static ssize_t smu_v13_0_0_get_gpu_metrics(struct smu_context *smu, | |||
| 2092 | 2092 | ||
| 2093 | 2093 | gpu_metrics->average_socket_power = metrics->AverageSocketPower; | |
| 2094 | 2094 | ||
| 2095 | - | if ((mp1_ver == IP_VERSION(13, 0, 0) && smu->smc_fw_version <= 0x004e1e00) || | |
| 2096 | - | (mp1_ver == IP_VERSION(13, 0, 10) && smu->smc_fw_version <= 0x00500800)) | |
| 2095 | + | if ((mp1_ver == IP_VERSION(13, 0, 0) && | |
| 2096 | + | (smu->smc_fw_version <= 0x004e1e00 || smu->smc_fw_version >= 0x004e8600)) || | |
| 2097 | + | (mp1_ver == IP_VERSION(13, 0, 10) && | |
| 2098 | + | smu->smc_fw_version <= 0x00500800)) | |
| 2097 | 2099 | gpu_metrics->energy_accumulator = metrics->EnergyAccumulator; | |
| 2098 | - | else | |
| 2099 | - | gpu_metrics->energy_accumulator = UINT_MAX; | |
| 2100 | 2100 | ||
| 2101 | 2101 | if (metrics->AverageGfxActivity <= SMU_13_0_0_BUSY_THRESHOLD) | |
| 2102 | 2102 | gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPostDs; | |
modified drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
| @@ -2097,8 +2097,8 @@ static ssize_t smu_v13_0_7_get_gpu_metrics(struct smu_context *smu, | |||
| 2097 | 2097 | metrics->Vcn1ActivityPercentage); | |
| 2098 | 2098 | ||
| 2099 | 2099 | gpu_metrics->average_socket_power = metrics->AverageSocketPower; | |
| 2100 | - | gpu_metrics->energy_accumulator = smu->smc_fw_version <= 0x00521400 ? | |
| 2101 | - | metrics->EnergyAccumulator : UINT_MAX; | |
| 2100 | + | if (smu->smc_fw_version <= 0x00521400) | |
| 2101 | + | gpu_metrics->energy_accumulator = metrics->EnergyAccumulator; | |
| 2102 | 2102 | ||
| 2103 | 2103 | if (metrics->AverageGfxActivity <= SMU_13_0_7_BUSY_THRESHOLD) | |
| 2104 | 2104 | gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPostDs; | |
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/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c
| @@ -222,7 +222,7 @@ static int smu_v15_0_8_tables_init(struct smu_context *smu) | |||
| 222 | 222 | ||
| 223 | 223 | smu_table->metrics_time = 0; | |
| 224 | 224 | ||
| 225 | - | driver_pptable = kzalloc(sizeof(PPTable_t), GFP_KERNEL); | |
| 225 | + | driver_pptable = kzalloc_obj(PPTable_t); | |
| 226 | 226 | if (!driver_pptable) | |
| 227 | 227 | return -ENOMEM; | |
| 228 | 228 | ||
| @@ -1026,7 +1026,7 @@ static int smu_v15_0_8_fru_get_product_info(struct smu_context *smu, | |||
| 1026 | 1026 | struct amdgpu_device *adev = smu->adev; | |
| 1027 | 1027 | ||
| 1028 | 1028 | if (!adev->fru_info) { | |
| 1029 | - | adev->fru_info = kzalloc(sizeof(*adev->fru_info), GFP_KERNEL); | |
| 1029 | + | adev->fru_info = kzalloc_obj(*adev->fru_info); | |
| 1030 | 1030 | if (!adev->fru_info) | |
| 1031 | 1031 | return -ENOMEM; | |
| 1032 | 1032 | } | |
modified drivers/gpu/drm/amd/ras/core/cmd.c
| @@ -222,7 +222,7 @@ static int ras_cmd_get_cper_records(struct ras_core_context *ras_core, | |||
| 222 | 222 | if (!buffer) | |
| 223 | 223 | return RAS_CMD__ERROR_GENERIC; | |
| 224 | 224 | ||
| 225 | - | trace = kcalloc(trace_count, sizeof(*trace), GFP_KERNEL); | |
| 225 | + | trace = kzalloc_objs(*trace, trace_count); | |
| 226 | 226 | if (!trace) { | |
| 227 | 227 | ret = RAS_CMD__ERROR_GENERIC; | |
| 228 | 228 | goto out; | |
| @@ -316,7 +316,7 @@ static int ras_cmd_get_batch_trace_records(struct ras_core_context *ras_core, | |||
| 316 | 316 | (input_data->start_batch_id >= overview.last_batch_id)) | |
| 317 | 317 | return RAS_CMD__ERROR_INVALID_INPUT_SIZE; | |
| 318 | 318 | ||
| 319 | - | trace_arry = kcalloc(trace_count, sizeof(*trace_arry), GFP_KERNEL); | |
| 319 | + | trace_arry = kzalloc_objs(*trace_arry, trace_count); | |
| 320 | 320 | if (!trace_arry) | |
| 321 | 321 | return RAS_CMD__ERROR_GENERIC; | |
| 322 | 322 | ||
modified drivers/gpu/drm/ast/ast_cursor.c
| @@ -25,6 +25,7 @@ | |||
| 25 | 25 | #include <linux/sizes.h> | |
| 26 | 26 | ||
| 27 | 27 | #include <drm/drm_atomic.h> | |
| 28 | + | #include <drm/drm_blend.h> | |
| 28 | 29 | #include <drm/drm_damage_helper.h> | |
| 29 | 30 | #include <drm/drm_format_helper.h> | |
| 30 | 31 | #include <drm/drm_gem_atomic_helper.h> | |
| @@ -355,6 +356,8 @@ int ast_cursor_plane_init(struct ast_device *ast) | |||
| 355 | 356 | } | |
| 356 | 357 | drm_plane_helper_add(cursor_plane, &ast_cursor_plane_helper_funcs); | |
| 357 | 358 | drm_plane_enable_fb_damage_clips(cursor_plane); | |
| 359 | + | drm_plane_create_blend_mode_property(cursor_plane, | |
| 360 | + | BIT(DRM_MODE_BLEND_COVERAGE)); | |
| 358 | 361 | ||
| 359 | 362 | return 0; | |
| 360 | 363 | } | |
modified drivers/gpu/drm/bridge/samsung-dsim.c
| @@ -1862,7 +1862,7 @@ static int samsung_dsim_register_te_irq(struct samsung_dsim *dsi, struct device | |||
| 1862 | 1862 | int te_gpio_irq; | |
| 1863 | 1863 | int ret; | |
| 1864 | 1864 | ||
| 1865 | - | dsi->te_gpio = devm_gpiod_get_optional(dev, "te", GPIOD_IN); | |
| 1865 | + | dsi->te_gpio = gpiod_get_optional(dev, "te", GPIOD_IN); | |
| 1866 | 1866 | if (!dsi->te_gpio) | |
| 1867 | 1867 | return 0; | |
| 1868 | 1868 | else if (IS_ERR(dsi->te_gpio)) | |
modified drivers/gpu/drm/bridge/tc358768.c
| @@ -1263,10 +1263,13 @@ tc358768_atomic_get_input_bus_fmts(struct drm_bridge *bridge, | |||
| 1263 | 1263 | return input_fmts; | |
| 1264 | 1264 | } | |
| 1265 | 1265 | ||
| 1266 | - | static bool tc358768_mode_fixup(struct drm_bridge *bridge, | |
| 1267 | - | const struct drm_display_mode *mode, | |
| 1268 | - | struct drm_display_mode *adjusted_mode) | |
| 1266 | + | static int tc358768_bridge_atomic_check(struct drm_bridge *bridge, | |
| 1267 | + | struct drm_bridge_state *bridge_state, | |
| 1268 | + | struct drm_crtc_state *crtc_state, | |
| 1269 | + | struct drm_connector_state *conn_state) | |
| 1269 | 1270 | { | |
| 1271 | + | struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode; | |
| 1272 | + | ||
| 1270 | 1273 | /* Default to positive sync */ | |
| 1271 | 1274 | ||
| 1272 | 1275 | if (!(adjusted_mode->flags & | |
| @@ -1277,13 +1280,15 @@ static bool tc358768_mode_fixup(struct drm_bridge *bridge, | |||
| 1277 | 1280 | (DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC))) | |
| 1278 | 1281 | adjusted_mode->flags |= DRM_MODE_FLAG_PVSYNC; | |
| 1279 | 1282 | ||
| 1280 | - | return true; | |
| 1283 | + | bridge_state->input_bus_cfg.flags = bridge->timings->input_bus_flags; | |
| 1284 | + | ||
| 1285 | + | return 0; | |
| 1281 | 1286 | } | |
| 1282 | 1287 | ||
| 1283 | 1288 | static const struct drm_bridge_funcs tc358768_bridge_funcs = { | |
| 1284 | 1289 | .attach = tc358768_bridge_attach, | |
| 1285 | 1290 | .mode_valid = tc358768_bridge_mode_valid, | |
| 1286 | - | .mode_fixup = tc358768_mode_fixup, | |
| 1291 | + | .atomic_check = tc358768_bridge_atomic_check, | |
| 1287 | 1292 | .atomic_pre_enable = tc358768_bridge_atomic_pre_enable, | |
| 1288 | 1293 | .atomic_enable = tc358768_bridge_atomic_enable, | |
| 1289 | 1294 | .atomic_disable = tc358768_bridge_atomic_disable, | |
modified drivers/gpu/drm/bridge/ti-sn65dsi83.c
| @@ -403,7 +403,7 @@ retry: | |||
| 403 | 403 | drm_modeset_drop_locks(&ctx); | |
| 404 | 404 | drm_modeset_acquire_fini(&ctx); | |
| 405 | 405 | ||
| 406 | - | return 0; | |
| 406 | + | return err; | |
| 407 | 407 | } | |
| 408 | 408 | ||
| 409 | 409 | static void sn65dsi83_reset_work(struct work_struct *ws) | |
| @@ -419,11 +419,13 @@ static void sn65dsi83_reset_work(struct work_struct *ws) | |||
| 419 | 419 | ret = sn65dsi83_reset_pipe(ctx); | |
| 420 | 420 | if (ret) { | |
| 421 | 421 | dev_err(ctx->dev, "reset pipe failed %pe\n", ERR_PTR(ret)); | |
| 422 | - | return; | |
| 422 | + | goto bridge_exit; | |
| 423 | 423 | } | |
| 424 | + | ||
| 424 | 425 | if (ctx->irq) | |
| 425 | 426 | enable_irq(ctx->irq); | |
| 426 | 427 | ||
| 428 | + | bridge_exit: | |
| 427 | 429 | drm_bridge_exit(idx); | |
| 428 | 430 | } | |
| 429 | 431 | ||
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/clients/drm_fbdev_client.c
| @@ -42,6 +42,14 @@ static int drm_fbdev_client_restore(struct drm_client_dev *client, bool force) | |||
| 42 | 42 | { | |
| 43 | 43 | struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client); | |
| 44 | 44 | ||
| 45 | + | /* | |
| 46 | + | * The client is registered before the initial fbdev probe. | |
| 47 | + | * If probing failed, the client remains registered but there | |
| 48 | + | * is no valid fbdev framebuffer to restore. | |
| 49 | + | */ | |
| 50 | + | if (!fb_helper->info || !fb_helper->fb) | |
| 51 | + | return 0; | |
| 52 | + | ||
| 45 | 53 | drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper, force); | |
| 46 | 54 | ||
| 47 | 55 | return 0; | |
modified drivers/gpu/drm/drm_atomic_state_helper.c
| @@ -278,7 +278,14 @@ void __drm_atomic_helper_plane_state_init(struct drm_plane_state *plane_state, | |||
| 278 | 278 | plane_state->rotation = DRM_MODE_ROTATE_0; | |
| 279 | 279 | ||
| 280 | 280 | plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE; | |
| 281 | + | ||
| 281 | 282 | plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; | |
| 283 | + | if (plane->blend_mode_property) { | |
| 284 | + | if (!drm_object_property_get_default_value(&plane->base, | |
| 285 | + | plane->blend_mode_property, | |
| 286 | + | &val)) | |
| 287 | + | plane_state->pixel_blend_mode = val; | |
| 288 | + | } | |
| 282 | 289 | ||
| 283 | 290 | if (plane->color_encoding_property) { | |
| 284 | 291 | if (!drm_object_property_get_default_value(&plane->base, | |
modified drivers/gpu/drm/drm_atomic_uapi.c
| @@ -1449,9 +1449,6 @@ static int prepare_signaling(struct drm_device *dev, | |||
| 1449 | 1449 | if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) { | |
| 1450 | 1450 | struct drm_pending_vblank_event *e = crtc_state->event; | |
| 1451 | 1451 | ||
| 1452 | - | if (!file_priv) | |
| 1453 | - | continue; | |
| 1454 | - | ||
| 1455 | 1452 | ret = drm_event_reserve_init(dev, file_priv, &e->base, | |
| 1456 | 1453 | &e->event.base); | |
| 1457 | 1454 | if (ret) { | |
| @@ -1465,10 +1462,12 @@ static int prepare_signaling(struct drm_device *dev, | |||
| 1465 | 1462 | struct dma_fence *fence; | |
| 1466 | 1463 | struct drm_out_fence_state *f; | |
| 1467 | 1464 | ||
| 1465 | + | ret = -ENOMEM; | |
| 1466 | + | ||
| 1468 | 1467 | f = krealloc(*fence_state, sizeof(**fence_state) * | |
| 1469 | 1468 | (*num_fences + 1), GFP_KERNEL); | |
| 1470 | 1469 | if (!f) | |
| 1471 | - | return -ENOMEM; | |
| 1470 | + | goto err_free_event; | |
| 1472 | 1471 | ||
| 1473 | 1472 | memset(&f[*num_fences], 0, sizeof(*f)); | |
| 1474 | 1473 | ||
| @@ -1477,12 +1476,12 @@ static int prepare_signaling(struct drm_device *dev, | |||
| 1477 | 1476 | ||
| 1478 | 1477 | fence = drm_crtc_create_fence(crtc); | |
| 1479 | 1478 | if (!fence) | |
| 1480 | - | return -ENOMEM; | |
| 1479 | + | goto err_free_event; | |
| 1481 | 1480 | ||
| 1482 | 1481 | ret = setup_out_fence(&f[(*num_fences)++], fence); | |
| 1483 | 1482 | if (ret) { | |
| 1484 | 1483 | dma_fence_put(fence); | |
| 1485 | - | return ret; | |
| 1484 | + | goto err_free_event; | |
| 1486 | 1485 | } | |
| 1487 | 1486 | ||
| 1488 | 1487 | crtc_state->event->base.fence = fence; | |
| @@ -1538,6 +1537,11 @@ static int prepare_signaling(struct drm_device *dev, | |||
| 1538 | 1537 | } | |
| 1539 | 1538 | ||
| 1540 | 1539 | return 0; | |
| 1540 | + | ||
| 1541 | + | err_free_event: | |
| 1542 | + | drm_event_cancel_free(dev, &crtc_state->event->base); | |
| 1543 | + | crtc_state->event = NULL; | |
| 1544 | + | return ret; | |
| 1541 | 1545 | } | |
| 1542 | 1546 | ||
| 1543 | 1547 | static void complete_signaling(struct drm_device *dev, | |
| @@ -1567,6 +1571,8 @@ static void complete_signaling(struct drm_device *dev, | |||
| 1567 | 1571 | * to prevent a double free in drm_atomic_commit_clear. | |
| 1568 | 1572 | */ | |
| 1569 | 1573 | if (event && (event->base.fence || event->base.file_priv)) { | |
| 1574 | + | if (crtc_state->commit && crtc_state->commit->abort_completion) | |
| 1575 | + | drm_crtc_commit_put(crtc_state->commit); | |
| 1570 | 1576 | drm_event_cancel_free(dev, &event->base); | |
| 1571 | 1577 | crtc_state->event = NULL; | |
| 1572 | 1578 | } | |
modified drivers/gpu/drm/drm_exec.c
| @@ -79,7 +79,7 @@ void drm_exec_init(struct drm_exec *exec, u32 flags, unsigned nr) | |||
| 79 | 79 | nr = PAGE_SIZE / sizeof(void *); | |
| 80 | 80 | ||
| 81 | 81 | exec->flags = flags; | |
| 82 | - | exec->objects = kvmalloc_objs(*exec->objects, nr, GFP_KERNEL); | |
| 82 | + | exec->objects = kvmalloc_objs(*exec->objects, nr); | |
| 83 | 83 | ||
| 84 | 84 | /* If allocation here fails, just delay that till the first use */ | |
| 85 | 85 | exec->max_objects = exec->objects ? nr : 0; | |
| @@ -322,6 +322,19 @@ int drm_exec_prepare_array(struct drm_exec *exec, | |||
| 322 | 322 | { | |
| 323 | 323 | int ret; | |
| 324 | 324 | ||
| 325 | + | /* | |
| 326 | + | * Make sure to lock a contended object even when no objects are | |
| 327 | + | * given, otherwise drm_exec_retry_on_contention() would loop | |
| 328 | + | * forever on patterns like: | |
| 329 | + | * | |
| 330 | + | * ret = drm_exec_prepare_array(exec, objs, num_objects, ...); | |
| 331 | + | * drm_exec_retry_on_contention(exec); | |
| 332 | + | * | |
| 333 | + | * with num_objects == 0. | |
| 334 | + | */ | |
| 335 | + | if (!num_objects) | |
| 336 | + | return drm_exec_lock_contended(exec); | |
| 337 | + | ||
| 325 | 338 | for (unsigned int i = 0; i < num_objects; ++i) { | |
| 326 | 339 | ret = drm_exec_prepare_obj(exec, objects[i], num_fences); | |
| 327 | 340 | if (unlikely(ret)) | |
modified drivers/gpu/drm/drm_pagemap.c
| @@ -383,6 +383,58 @@ next: | |||
| 383 | 383 | return 0; | |
| 384 | 384 | } | |
| 385 | 385 | ||
| 386 | + | /** | |
| 387 | + | * drm_pagemap_migrate_populate_src_pages() - Populate the source page array | |
| 388 | + | * @pages: Array of source pages to populate | |
| 389 | + | * @src_mpfn: Source array of migrate PFNs | |
| 390 | + | * @dst_mpfn: Destination array of migrate PFNs | |
| 391 | + | * @npages: Number of pages in the arrays | |
| 392 | + | * | |
| 393 | + | * Populate @pages with the device pages the copy callback is to read from. | |
| 394 | + | * | |
| 395 | + | * Entries are normally only populated at the head of each source folio, with | |
| 396 | + | * the copy callback deriving the rest of the folio from the order recorded in | |
| 397 | + | * the corresponding drm_pagemap_addr. That does not work where | |
| 398 | + | * drm_pagemap_migrate_populate_ram_pfn() had to demote a higher-order source | |
| 399 | + | * folio to order-0 destination folios: the drm_pagemap_addr entries are then | |
| 400 | + | * per-page, and the copy callback needs a source page for each of them. | |
| 401 | + | * Populate every entry for those ranges. | |
| 402 | + | * | |
| 403 | + | * Note that the source folio itself is only split later, by | |
| 404 | + | * migrate_vma_pages() / migrate_device_pages(), so its order cannot be used to | |
| 405 | + | * detect the demotion - the destination has to be inspected instead. | |
| 406 | + | */ | |
| 407 | + | static void drm_pagemap_migrate_populate_src_pages(struct page **pages, | |
| 408 | + | unsigned long *src_mpfn, | |
| 409 | + | unsigned long *dst_mpfn, | |
| 410 | + | unsigned long npages) | |
| 411 | + | { | |
| 412 | + | unsigned long i; | |
| 413 | + | ||
| 414 | + | for (i = 0; i < npages;) { | |
| 415 | + | struct page *page = migrate_pfn_to_page(src_mpfn[i]); | |
| 416 | + | unsigned int order = 0; | |
| 417 | + | unsigned long j, nr; | |
| 418 | + | ||
| 419 | + | if (!page) { | |
| 420 | + | i++; | |
| 421 | + | continue; | |
| 422 | + | } | |
| 423 | + | ||
| 424 | + | order = folio_order(page_folio(page)); | |
| 425 | + | nr = NR_PAGES(order); | |
| 426 | + | ||
| 427 | + | if (order && !(dst_mpfn[i] & MIGRATE_PFN_COMPOUND)) { | |
| 428 | + | for (j = 0; j < nr && i + j < npages; j++) | |
| 429 | + | pages[i + j] = folio_page(page_folio(page), j); | |
| 430 | + | } else { | |
| 431 | + | pages[i] = page; | |
| 432 | + | } | |
| 433 | + | ||
| 434 | + | i += nr; | |
| 435 | + | } | |
| 436 | + | } | |
| 437 | + | ||
| 386 | 438 | /** | |
| 387 | 439 | * drm_pagemap_migrate_unmap_pages() - Unmap pages previously mapped for GPU SVM migration | |
| 388 | 440 | * @dev: The device for which the pages were mapped | |
| @@ -875,6 +927,7 @@ static int drm_pagemap_migrate_populate_ram_pfn(struct vm_area_struct *vas, | |||
| 875 | 927 | struct page *page = NULL, *src_page; | |
| 876 | 928 | struct folio *folio; | |
| 877 | 929 | unsigned int order = 0; | |
| 930 | + | gfp_t gfp = GFP_HIGHUSER; | |
| 878 | 931 | ||
| 879 | 932 | if (!(src_mpfn[i] & MIGRATE_PFN_MIGRATE)) | |
| 880 | 933 | goto next; | |
| @@ -891,11 +944,51 @@ static int drm_pagemap_migrate_populate_ram_pfn(struct vm_area_struct *vas, | |||
| 891 | 944 | ||
| 892 | 945 | order = folio_order(page_folio(src_page)); | |
| 893 | 946 | ||
| 894 | - | /* TODO: Support fallback to single pages if THP allocation fails */ | |
| 947 | + | /* | |
| 948 | + | * A large source folio is always collected whole, at its head | |
| 949 | + | * page, PMD aligned and flagged MIGRATE_PFN_COMPOUND: anything | |
| 950 | + | * else is split before it reaches us, either by | |
| 951 | + | * migrate_vma_collect_pmd() or, for the eviction path, by | |
| 952 | + | * migrate_device_pfns(). Both the order-0 fallback below and | |
| 953 | + | * drm_pagemap_migrate_populate_src_pages() rely on that, as | |
| 954 | + | * they index the folio from @i. | |
| 955 | + | */ | |
| 956 | + | WARN_ON_ONCE(order && | |
| 957 | + | (src_page != folio_page(page_folio(src_page), 0) || | |
| 958 | + | !(src_mpfn[i] & MIGRATE_PFN_COMPOUND))); | |
| 959 | + | ||
| 960 | + | if (order) | |
| 961 | + | gfp |= __GFP_NOWARN; | |
| 962 | + | ||
| 895 | 963 | if (vas) | |
| 896 | - | folio = vma_alloc_folio(GFP_HIGHUSER, order, vas, addr); | |
| 964 | + | folio = vma_alloc_folio(gfp, order, vas, addr); | |
| 897 | 965 | else | |
| 898 | - | folio = folio_alloc(GFP_HIGHUSER, order); | |
| 966 | + | folio = folio_alloc(gfp, order); | |
| 967 | + | ||
| 968 | + | if (!folio && order) { | |
| 969 | + | /* | |
| 970 | + | * Higher-order allocation failed, fall back to | |
| 971 | + | * order-0 allocations for the entire range covered | |
| 972 | + | * by the original higher-order allocation, without | |
| 973 | + | * setting MIGRATE_PFN_COMPOUND, until we move past | |
| 974 | + | * that range. | |
| 975 | + | */ | |
| 976 | + | unsigned long nr = NR_PAGES(order); | |
| 977 | + | unsigned long j; | |
| 978 | + | ||
| 979 | + | gfp &= ~__GFP_NOWARN; | |
| 980 | + | for (j = 0; j < nr && i < npages; j++, i++, addr += PAGE_SIZE) { | |
| 981 | + | folio = vas ? | |
| 982 | + | vma_alloc_folio(gfp, 0, vas, addr) : | |
| 983 | + | folio_alloc(gfp, 0); | |
| 984 | + | if (!folio) | |
| 985 | + | goto free_pages; | |
| 986 | + | ||
| 987 | + | page = folio_page(folio, 0); | |
| 988 | + | mpfn[i] = migrate_pfn(page_to_pfn(page)); | |
| 989 | + | } | |
| 990 | + | continue; | |
| 991 | + | } | |
| 899 | 992 | ||
| 900 | 993 | if (!folio) | |
| 901 | 994 | goto free_pages; | |
| @@ -940,11 +1033,11 @@ free_pages: | |||
| 940 | 1033 | if (!page) | |
| 941 | 1034 | goto next_put; | |
| 942 | 1035 | ||
| 1036 | + | order = folio_order(page_folio(page)); | |
| 1037 | + | ||
| 943 | 1038 | put_page(page); | |
| 944 | 1039 | mpfn[i] = 0; | |
| 945 | 1040 | ||
| 946 | - | order = folio_order(page_folio(page)); | |
| 947 | - | ||
| 948 | 1041 | next_put: | |
| 949 | 1042 | i += NR_PAGES(order); | |
| 950 | 1043 | } | |
| @@ -1102,12 +1195,117 @@ void drm_pagemap_put(struct drm_pagemap *dpagemap) | |||
| 1102 | 1195 | } | |
| 1103 | 1196 | EXPORT_SYMBOL(drm_pagemap_put); | |
| 1104 | 1197 | ||
| 1198 | + | /** | |
| 1199 | + | * drm_pagemap_page_get_flags() - Read flags from a device-private folio | |
| 1200 | + | * @page: Pointer to a page of the device-private folio | |
| 1201 | + | * | |
| 1202 | + | * Return: The DRM_PAGEMAP_ZDD_FLAG_* bits encoded in zone_device_data. | |
| 1203 | + | */ | |
| 1204 | + | static unsigned long drm_pagemap_page_get_flags(struct page *page) | |
| 1205 | + | { | |
| 1206 | + | struct folio *folio = page_folio(page); | |
| 1207 | + | ||
| 1208 | + | return (unsigned long)folio_zone_device_data(folio) & | |
| 1209 | + | DRM_PAGEMAP_ZDD_FLAG_MASK; | |
| 1210 | + | } | |
| 1211 | + | ||
| 1212 | + | /** | |
| 1213 | + | * drm_pagemap_page_set_flags() - Set flags on a device-private folio | |
| 1214 | + | * @page: Pointer to a page of the device-private folio | |
| 1215 | + | * @flags: DRM_PAGEMAP_ZDD_FLAG_* bits to set | |
| 1216 | + | * | |
| 1217 | + | * Preserve any flags already encoded alongside the ZDD pointer. | |
| 1218 | + | */ | |
| 1219 | + | static void drm_pagemap_page_set_flags(struct page *page, | |
| 1220 | + | unsigned long flags) | |
| 1221 | + | { | |
| 1222 | + | struct folio *folio = page_folio(page); | |
| 1223 | + | unsigned long old; | |
| 1224 | + | ||
| 1225 | + | if (WARN_ON_ONCE(flags & ~DRM_PAGEMAP_ZDD_FLAG_MASK)) | |
| 1226 | + | return; | |
| 1227 | + | ||
| 1228 | + | old = (unsigned long)folio_zone_device_data(folio); | |
| 1229 | + | folio_set_zone_device_data(folio, (void *)(old | flags)); | |
| 1230 | + | } | |
| 1231 | + | ||
| 1232 | + | /** | |
| 1233 | + | * drm_pagemap_retire_migrated_pages() - Record migrated device-private folios | |
| 1234 | + | * @src_pfns: source array after migrate_vma_pages() or migrate_device_pages() | |
| 1235 | + | * @npages: number of entries in @src_pfns | |
| 1236 | + | * | |
| 1237 | + | * Flag device-private folios successfully migrated to RAM before finalize | |
| 1238 | + | * unlocks the sources. The migrated state is stored in the physical folio, so | |
| 1239 | + | * it survives later folio splits and subsequent migrations can skip it. | |
| 1240 | + | */ | |
| 1241 | + | static void drm_pagemap_retire_migrated_pages(unsigned long *src_pfns, | |
| 1242 | + | unsigned long npages) | |
| 1243 | + | { | |
| 1244 | + | unsigned long i = 0; | |
| 1245 | + | ||
| 1246 | + | while (i < npages) { | |
| 1247 | + | struct page *page = migrate_pfn_to_page(src_pfns[i]); | |
| 1248 | + | unsigned long nr = 1; | |
| 1249 | + | ||
| 1250 | + | if (!page) { | |
| 1251 | + | i++; | |
| 1252 | + | continue; | |
| 1253 | + | } | |
| 1254 | + | ||
| 1255 | + | if (src_pfns[i] & MIGRATE_PFN_COMPOUND) | |
| 1256 | + | nr = folio_nr_pages(page_folio(page)); | |
| 1257 | + | ||
| 1258 | + | if ((src_pfns[i] & MIGRATE_PFN_MIGRATE) && | |
| 1259 | + | is_device_private_page(page)) | |
| 1260 | + | drm_pagemap_page_set_flags(page, | |
| 1261 | + | DRM_PAGEMAP_ZDD_FLAG_MIGRATED); | |
| 1262 | + | ||
| 1263 | + | i += nr; | |
| 1264 | + | } | |
| 1265 | + | } | |
| 1266 | + | ||
| 1267 | + | /** | |
| 1268 | + | * drm_pagemap_skip_retired_pages() - Skip retired device-private folios | |
| 1269 | + | * @src_pfns: MIGRATE_PFN-encoded source array | |
| 1270 | + | * @npages: number of entries in @src_pfns | |
| 1271 | + | * | |
| 1272 | + | * Skip source folios already migrated to RAM, identified by the migrated flag | |
| 1273 | + | * stored in the physical folio's zone_device_data. | |
| 1274 | + | */ | |
| 1275 | + | static void drm_pagemap_skip_retired_pages(unsigned long *src_pfns, | |
| 1276 | + | unsigned long npages) | |
| 1277 | + | { | |
| 1278 | + | unsigned long i = 0; | |
| 1279 | + | ||
| 1280 | + | while (i < npages) { | |
| 1281 | + | struct page *page = migrate_pfn_to_page(src_pfns[i]); | |
| 1282 | + | unsigned long nr = 1; | |
| 1283 | + | ||
| 1284 | + | if (!page) { | |
| 1285 | + | i++; | |
| 1286 | + | continue; | |
| 1287 | + | } | |
| 1288 | + | ||
| 1289 | + | if (src_pfns[i] & MIGRATE_PFN_COMPOUND) | |
| 1290 | + | nr = folio_nr_pages(page_folio(page)); | |
| 1291 | + | ||
| 1292 | + | if ((src_pfns[i] & MIGRATE_PFN_MIGRATE) && | |
| 1293 | + | is_device_private_page(page) && | |
| 1294 | + | (drm_pagemap_page_get_flags(page) & | |
| 1295 | + | DRM_PAGEMAP_ZDD_FLAG_MIGRATED)) | |
| 1296 | + | src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; | |
| 1297 | + | ||
| 1298 | + | i += nr; | |
| 1299 | + | } | |
| 1300 | + | } | |
| 1301 | + | ||
| 1105 | 1302 | /** | |
| 1106 | 1303 | * drm_pagemap_evict_to_ram() - Evict GPU SVM range to RAM | |
| 1107 | 1304 | * @devmem_allocation: Pointer to the device memory allocation | |
| 1108 | 1305 | * | |
| 1109 | - | * Similar to __drm_pagemap_migrate_to_ram but does not require mmap lock and | |
| 1110 | - | * migration done via migrate_device_* functions. | |
| 1306 | + | * Similar to __drm_pagemap_migrate_to_ram(), but uses the | |
| 1307 | + | * migrate_device_* helpers and does not require the mmap lock. | |
| 1308 | + | * Device-private PFNs already migrated to RAM by either path are skipped. | |
| 1111 | 1309 | * | |
| 1112 | 1310 | * Return: 0 on success, negative error code on failure. | |
| 1113 | 1311 | */ | |
| @@ -1115,17 +1313,18 @@ int drm_pagemap_evict_to_ram(struct drm_pagemap_devmem *devmem_allocation) | |||
| 1115 | 1313 | { | |
| 1116 | 1314 | const struct drm_pagemap_devmem_ops *ops = devmem_allocation->ops; | |
| 1117 | 1315 | struct drm_pagemap_iova_state state = {}; | |
| 1118 | - | unsigned long npages, mpages = 0; | |
| 1316 | + | unsigned long npages, mpages; | |
| 1119 | 1317 | struct page **pages; | |
| 1120 | 1318 | unsigned long *src, *dst; | |
| 1121 | 1319 | struct drm_pagemap_addr *pagemap_addr; | |
| 1122 | 1320 | void *buf; | |
| 1123 | - | int i, err = 0; | |
| 1321 | + | int err = 0; | |
| 1124 | 1322 | unsigned int retry_count = 2; | |
| 1125 | 1323 | ||
| 1126 | 1324 | npages = devmem_allocation->size >> PAGE_SHIFT; | |
| 1127 | 1325 | ||
| 1128 | 1326 | retry: | |
| 1327 | + | mpages = 0; | |
| 1129 | 1328 | if (!mmget_not_zero(devmem_allocation->mm)) | |
| 1130 | 1329 | return -EFAULT; | |
| 1131 | 1330 | ||
| @@ -1148,6 +1347,8 @@ retry: | |||
| 1148 | 1347 | if (err) | |
| 1149 | 1348 | goto err_free; | |
| 1150 | 1349 | ||
| 1350 | + | drm_pagemap_skip_retired_pages(src, npages); | |
| 1351 | + | ||
| 1151 | 1352 | err = drm_pagemap_migrate_populate_ram_pfn(NULL, NULL, npages, &mpages, | |
| 1152 | 1353 | src, dst, 0); | |
| 1153 | 1354 | if (err || !mpages) | |
| @@ -1160,27 +1361,20 @@ retry: | |||
| 1160 | 1361 | if (err) | |
| 1161 | 1362 | goto err_finalize; | |
| 1162 | 1363 | ||
| 1163 | - | for (i = 0; i < npages;) { | |
| 1164 | - | unsigned int order = 0; | |
| 1165 | - | ||
| 1166 | - | pages[i] = migrate_pfn_to_page(src[i]); | |
| 1167 | - | if (pages[i]) | |
| 1168 | - | order = folio_order(page_folio(pages[i])); | |
| 1169 | - | ||
| 1170 | - | i += NR_PAGES(order); | |
| 1171 | - | } | |
| 1364 | + | drm_pagemap_migrate_populate_src_pages(pages, src, dst, npages); | |
| 1172 | 1365 | ||
| 1173 | 1366 | err = ops->copy_to_ram(pages, pagemap_addr, npages, NULL); | |
| 1174 | 1367 | if (err) | |
| 1175 | 1368 | goto err_finalize; | |
| 1176 | 1369 | ||
| 1177 | 1370 | err_finalize: | |
| 1371 | + | drm_pagemap_migrate_unmap_pages(devmem_allocation->dev, pagemap_addr, dst, npages, | |
| 1372 | + | DMA_FROM_DEVICE, &state); | |
| 1178 | 1373 | if (err) | |
| 1179 | 1374 | drm_pagemap_migration_unlock_put_pages(npages, dst); | |
| 1180 | 1375 | migrate_device_pages(src, dst, npages); | |
| 1376 | + | drm_pagemap_retire_migrated_pages(src, npages); | |
| 1181 | 1377 | migrate_device_finalize(src, dst, npages); | |
| 1182 | - | drm_pagemap_migrate_unmap_pages(devmem_allocation->dev, pagemap_addr, dst, npages, | |
| 1183 | - | DMA_FROM_DEVICE, &state); | |
| 1184 | 1378 | ||
| 1185 | 1379 | err_free: | |
| 1186 | 1380 | kvfree(buf); | |
| @@ -1235,7 +1429,7 @@ static int __drm_pagemap_migrate_to_ram(struct vm_area_struct *vas, | |||
| 1235 | 1429 | struct drm_pagemap_addr *pagemap_addr; | |
| 1236 | 1430 | unsigned long start, end; | |
| 1237 | 1431 | void *buf; | |
| 1238 | - | int i, err = 0; | |
| 1432 | + | int err = 0; | |
| 1239 | 1433 | ||
| 1240 | 1434 | zdd = drm_pagemap_page_zone_device_data(page); | |
| 1241 | 1435 | if (time_before64(get_jiffies_64(), zdd->devmem_allocation->timeslice_expiration)) | |
| @@ -1275,13 +1469,15 @@ static int __drm_pagemap_migrate_to_ram(struct vm_area_struct *vas, | |||
| 1275 | 1469 | if (!migrate.cpages) | |
| 1276 | 1470 | goto err_free; | |
| 1277 | 1471 | ||
| 1472 | + | drm_pagemap_skip_retired_pages(migrate.src, npages); | |
| 1473 | + | ||
| 1278 | 1474 | ops = zdd->devmem_allocation->ops; | |
| 1279 | 1475 | dev = zdd->devmem_allocation->dev; | |
| 1280 | 1476 | ||
| 1281 | 1477 | err = drm_pagemap_migrate_populate_ram_pfn(vas, page, npages, &mpages, | |
| 1282 | 1478 | migrate.src, migrate.dst, | |
| 1283 | 1479 | start); | |
| 1284 | - | if (err) | |
| 1480 | + | if (err || !mpages) | |
| 1285 | 1481 | goto err_finalize; | |
| 1286 | 1482 | ||
| 1287 | 1483 | err = drm_pagemap_migrate_map_system_pages(dev, pagemap_addr, | |
| @@ -1290,29 +1486,23 @@ static int __drm_pagemap_migrate_to_ram(struct vm_area_struct *vas, | |||
| 1290 | 1486 | if (err) | |
| 1291 | 1487 | goto err_finalize; | |
| 1292 | 1488 | ||
| 1293 | - | for (i = 0; i < npages;) { | |
| 1294 | - | unsigned int order = 0; | |
| 1295 | - | ||
| 1296 | - | pages[i] = migrate_pfn_to_page(migrate.src[i]); | |
| 1297 | - | if (pages[i]) | |
| 1298 | - | order = folio_order(page_folio(pages[i])); | |
| 1299 | - | ||
| 1300 | - | i += NR_PAGES(order); | |
| 1301 | - | } | |
| 1489 | + | drm_pagemap_migrate_populate_src_pages(pages, migrate.src, migrate.dst, | |
| 1490 | + | npages); | |
| 1302 | 1491 | ||
| 1303 | 1492 | err = ops->copy_to_ram(pages, pagemap_addr, npages, NULL); | |
| 1304 | 1493 | if (err) | |
| 1305 | 1494 | goto err_finalize; | |
| 1306 | 1495 | ||
| 1307 | 1496 | err_finalize: | |
| 1308 | - | if (err) | |
| 1309 | - | drm_pagemap_migration_unlock_put_pages(npages, migrate.dst); | |
| 1310 | - | migrate_vma_pages(&migrate); | |
| 1311 | - | migrate_vma_finalize(&migrate); | |
| 1312 | 1497 | if (dev) | |
| 1313 | 1498 | drm_pagemap_migrate_unmap_pages(dev, pagemap_addr, migrate.dst, | |
| 1314 | 1499 | npages, DMA_FROM_DEVICE, | |
| 1315 | 1500 | &state); | |
| 1501 | + | if (err) | |
| 1502 | + | drm_pagemap_migration_unlock_put_pages(npages, migrate.dst); | |
| 1503 | + | migrate_vma_pages(&migrate); | |
| 1504 | + | drm_pagemap_retire_migrated_pages(migrate.src, npages); | |
| 1505 | + | migrate_vma_finalize(&migrate); | |
| 1316 | 1506 | err_free: | |
| 1317 | 1507 | kvfree(buf); | |
| 1318 | 1508 | err_out: | |
| @@ -1360,13 +1550,19 @@ static vm_fault_t drm_pagemap_migrate_to_ram(struct vm_fault *vmf) | |||
| 1360 | 1550 | static void drm_pagemap_folio_split(struct folio *orig_folio, struct folio *new_folio) | |
| 1361 | 1551 | { | |
| 1362 | 1552 | struct drm_pagemap_zdd *zdd; | |
| 1553 | + | unsigned long orig_data, new_data; | |
| 1363 | 1554 | ||
| 1364 | 1555 | if (!new_folio) | |
| 1365 | 1556 | return; | |
| 1366 | 1557 | ||
| 1367 | 1558 | new_folio->pgmap = orig_folio->pgmap; | |
| 1368 | - | zdd = folio_zone_device_data(orig_folio); | |
| 1369 | - | folio_set_zone_device_data(new_folio, drm_pagemap_zdd_get(zdd)); | |
| 1559 | + | ||
| 1560 | + | orig_data = (unsigned long)folio_zone_device_data(orig_folio); | |
| 1561 | + | zdd = (struct drm_pagemap_zdd *)(orig_data & ~DRM_PAGEMAP_ZDD_FLAG_MASK); | |
| 1562 | + | ||
| 1563 | + | new_data = (unsigned long)drm_pagemap_zdd_get(zdd); | |
| 1564 | + | new_data |= orig_data & DRM_PAGEMAP_ZDD_FLAG_MASK; | |
| 1565 | + | folio_set_zone_device_data(new_folio, (void *)new_data); | |
| 1370 | 1566 | } | |
| 1371 | 1567 | ||
| 1372 | 1568 | static const struct dev_pagemap_ops drm_pagemap_pagemap_ops = { | |
modified drivers/gpu/drm/drm_panic_qr.rs
| @@ -407,8 +407,8 @@ impl DecFifo { | |||
| 407 | 407 | for i in (0..self.len).rev() { | |
| 408 | 408 | self.decimals[i + len] = self.decimals[i]; | |
| 409 | 409 | } | |
| 410 | - | for i in 0..len { | |
| 411 | - | self.decimals[i] = (chunk % 10) as u8; | |
| 410 | + | for decimal in &mut self.decimals[..len] { | |
| 411 | + | *decimal = (chunk % 10) as u8; | |
| 412 | 412 | chunk = div10(chunk); | |
| 413 | 413 | } | |
| 414 | 414 | self.len += len; | |
modified drivers/gpu/drm/drm_prime.c
| @@ -524,7 +524,7 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev, | |||
| 524 | 524 | return PTR_ERR(dmabuf); | |
| 525 | 525 | } | |
| 526 | 526 | ||
| 527 | - | fd_install(fd, dmabuf->file); | |
| 527 | + | dma_buf_fd_install(dmabuf, fd); | |
| 528 | 528 | *prime_fd = fd; | |
| 529 | 529 | return 0; | |
| 530 | 530 | } | |
modified drivers/gpu/drm/drm_syncobj.c
| @@ -1619,7 +1619,7 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, | |||
| 1619 | 1619 | goto err_points; | |
| 1620 | 1620 | } | |
| 1621 | 1621 | ||
| 1622 | - | chains = kmalloc_objs(*chains, args->count_handles, GFP_KERNEL); | |
| 1622 | + | chains = kmalloc_objs(*chains, args->count_handles); | |
| 1623 | 1623 | if (!chains) { | |
| 1624 | 1624 | ret = -ENOMEM; | |
| 1625 | 1625 | goto err_points; | |
modified drivers/gpu/drm/gud/gud_connector.c
| @@ -396,8 +396,16 @@ static int gud_connector_add_tv_mode(struct gud_device *gdrm, struct drm_connect | |||
| 396 | 396 | } | |
| 397 | 397 | ||
| 398 | 398 | num_modes = ret / GUD_CONNECTOR_TV_MODE_NAME_LEN; | |
| 399 | - | for (i = 0; i < num_modes; i++) | |
| 400 | - | modes[i] = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN]; | |
| 399 | + | for (i = 0; i < num_modes; i++) { | |
| 400 | + | char *mode = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN]; | |
| 401 | + | ||
| 402 | + | if (!memchr(mode, '\0', GUD_CONNECTOR_TV_MODE_NAME_LEN)) { | |
| 403 | + | ret = -EIO; | |
| 404 | + | goto free; | |
| 405 | + | } | |
| 406 | + | ||
| 407 | + | modes[i] = mode; | |
| 408 | + | } | |
| 401 | 409 | ||
| 402 | 410 | ret = drm_mode_create_tv_properties_legacy(connector->dev, num_modes, modes); | |
| 403 | 411 | free: | |
modified drivers/gpu/drm/gud/gud_drv.c
| @@ -289,6 +289,8 @@ static int gud_plane_add_properties(struct gud_device *gdrm) | |||
| 289 | 289 | * but mask out any additions on future devices. | |
| 290 | 290 | */ | |
| 291 | 291 | val &= GUD_ROTATION_MASK; | |
| 292 | + | if (!(val & GUD_ROTATION_0)) | |
| 293 | + | continue; | |
| 292 | 294 | ret = drm_plane_create_rotation_property(&gdrm->plane, | |
| 293 | 295 | DRM_MODE_ROTATE_0, val); | |
| 294 | 296 | break; | |
modified drivers/gpu/drm/gud/gud_pipe.c
| @@ -482,6 +482,9 @@ int gud_plane_atomic_check(struct drm_plane *plane, | |||
| 482 | 482 | if (!new_plane_state->visible) | |
| 483 | 483 | return 0; | |
| 484 | 484 | ||
| 485 | + | if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE) | |
| 486 | + | new_plane_state->ignore_damage_clips = true; | |
| 487 | + | ||
| 485 | 488 | if (old_plane_state->rotation != new_plane_state->rotation) | |
| 486 | 489 | crtc_state->mode_changed = true; | |
| 487 | 490 | ||
| @@ -562,8 +565,8 @@ int gud_plane_atomic_check(struct drm_plane *plane, | |||
| 562 | 565 | goto out; | |
| 563 | 566 | } | |
| 564 | 567 | ||
| 565 | - | req->properties[num_properties + i].prop = cpu_to_le16(prop); | |
| 566 | - | req->properties[num_properties + i].val = cpu_to_le64(val); | |
| 568 | + | req->properties[num_properties].prop = cpu_to_le16(prop); | |
| 569 | + | req->properties[num_properties].val = cpu_to_le64(val); | |
| 567 | 570 | num_properties++; | |
| 568 | 571 | } | |
| 569 | 572 | ||
modified drivers/gpu/drm/i915/display/intel_cdclk.c
| @@ -2381,8 +2381,10 @@ static void bxt_sanitize_cdclk(struct intel_display *display) | |||
| 2381 | 2381 | * dividers both syncing to an active pipe, or asynchronously | |
| 2382 | 2382 | * (PIPE_NONE). | |
| 2383 | 2383 | */ | |
| 2384 | - | cdctl &= ~bxt_cdclk_cd2x_pipe_mask(display); | |
| 2385 | - | cdctl |= bxt_cdclk_cd2x_pipe(display, INVALID_PIPE); | |
| 2384 | + | if (DISPLAY_VER(display) < 30) { | |
| 2385 | + | cdctl &= ~bxt_cdclk_cd2x_pipe_mask(display); | |
| 2386 | + | cdctl |= bxt_cdclk_cd2x_pipe(display, INVALID_PIPE); | |
| 2387 | + | } | |
| 2386 | 2388 | ||
| 2387 | 2389 | if (cdctl != expected) { | |
| 2388 | 2390 | if (DISPLAY_VER(display) < 20) { | |
| @@ -2713,8 +2715,8 @@ static void intel_set_cdclk(struct intel_display *display, | |||
| 2713 | 2715 | } | |
| 2714 | 2716 | } | |
| 2715 | 2717 | ||
| 2716 | - | static bool dg2_power_well_count(struct intel_display *display, | |
| 2717 | - | const struct intel_cdclk_state *cdclk_state) | |
| 2718 | + | static int dg2_power_well_count(struct intel_display *display, | |
| 2719 | + | const struct intel_cdclk_state *cdclk_state) | |
| 2718 | 2720 | { | |
| 2719 | 2721 | return display->platform.dg2 ? hweight8(cdclk_state->active_pipes) : 0; | |
| 2720 | 2722 | } | |
modified drivers/gpu/drm/i915/display/intel_cursor.c
| @@ -536,7 +536,8 @@ static void i9xx_cursor_disable_sel_fetch_arm(struct intel_dsb *dsb, | |||
| 536 | 536 | struct intel_display *display = to_intel_display(plane); | |
| 537 | 537 | enum pipe pipe = plane->pipe; | |
| 538 | 538 | ||
| 539 | - | if (!crtc_state->enable_psr2_sel_fetch) | |
| 539 | + | if (!crtc_state->enable_psr2_sel_fetch && | |
| 540 | + | !crtc_state->clear_psr2_sel_fetch) | |
| 540 | 541 | return; | |
| 541 | 542 | ||
| 542 | 543 | intel_de_write_dsb(display, dsb, SEL_FETCH_CUR_CTL(pipe), 0); | |
| @@ -569,8 +570,10 @@ static void i9xx_cursor_update_sel_fetch_arm(struct intel_dsb *dsb, | |||
| 569 | 570 | struct intel_display *display = to_intel_display(plane); | |
| 570 | 571 | enum pipe pipe = plane->pipe; | |
| 571 | 572 | ||
| 572 | - | 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); | |
| 573 | 575 | return; | |
| 576 | + | } | |
| 574 | 577 | ||
| 575 | 578 | if (drm_rect_height(&plane_state->psr2_sel_fetch_area) > 0) { | |
| 576 | 579 | if (crtc_state->enable_psr2_su_region_et) { | |
modified drivers/gpu/drm/i915/display/intel_cx0_phy.c
| @@ -3233,7 +3233,8 @@ static void intel_cx0pll_enable(struct intel_encoder *encoder, | |||
| 3233 | 3233 | * 8. Program DDI_CLK_VALFREQ to match intended DDI | |
| 3234 | 3234 | * clock frequency. | |
| 3235 | 3235 | */ | |
| 3236 | - | intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), port_clock); | |
| 3236 | + | intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), | |
| 3237 | + | intel_ddi_link_symbol_clock(encoder, port_clock)); | |
| 3237 | 3238 | ||
| 3238 | 3239 | /* | |
| 3239 | 3240 | * 9. Set PORT_CLOCK_CTL register PCLK PLL Request | |
| @@ -3406,7 +3407,7 @@ void intel_mtl_tbt_pll_enable_clock(struct intel_encoder *encoder, int port_cloc | |||
| 3406 | 3407 | * clock frequency. | |
| 3407 | 3408 | */ | |
| 3408 | 3409 | intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), | |
| 3409 | - | port_clock); | |
| 3410 | + | intel_ddi_link_symbol_clock(encoder, port_clock)); | |
| 3410 | 3411 | } | |
| 3411 | 3412 | ||
| 3412 | 3413 | void intel_mtl_pll_enable(struct intel_encoder *encoder, | |
modified drivers/gpu/drm/i915/display/intel_ddi.c
| @@ -1529,6 +1529,17 @@ int intel_ddi_level(struct intel_encoder *encoder, | |||
| 1529 | 1529 | return level; | |
| 1530 | 1530 | } | |
| 1531 | 1531 | ||
| 1532 | + | int intel_ddi_link_symbol_clock(struct intel_encoder *encoder, int clock) | |
| 1533 | + | { | |
| 1534 | + | if (intel_encoder_is_dp(encoder)) | |
| 1535 | + | return intel_dp_link_symbol_clock(clock); | |
| 1536 | + | ||
| 1537 | + | if (intel_hdmi_is_frl(clock)) | |
| 1538 | + | return DIV_ROUND_CLOSEST(clock * 10, 18); | |
| 1539 | + | ||
| 1540 | + | return clock; | |
| 1541 | + | } | |
| 1542 | + | ||
| 1532 | 1543 | static void | |
| 1533 | 1544 | hsw_set_signal_levels(struct intel_encoder *encoder, | |
| 1534 | 1545 | const struct intel_crtc_state *crtc_state) | |
modified drivers/gpu/drm/i915/display/intel_ddi.h
| @@ -81,6 +81,7 @@ void intel_ddi_sanitize_encoder_pll_mapping(struct intel_encoder *encoder); | |||
| 81 | 81 | int intel_ddi_level(struct intel_encoder *encoder, | |
| 82 | 82 | const struct intel_crtc_state *crtc_state, | |
| 83 | 83 | int lane); | |
| 84 | + | int intel_ddi_link_symbol_clock(struct intel_encoder *encoder, int clock); | |
| 84 | 85 | void intel_ddi_update_active_dpll(struct intel_atomic_state *state, | |
| 85 | 86 | struct intel_encoder *encoder, | |
| 86 | 87 | struct intel_crtc *crtc); | |
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; | |
| @@ -1946,6 +1948,8 @@ struct intel_dp { | |||
| 1946 | 1948 | ||
| 1947 | 1949 | bool colorimetry_support; | |
| 1948 | 1950 | ||
| 1951 | + | bool sst_split_sdp_support; | |
| 1952 | + | ||
| 1949 | 1953 | struct { | |
| 1950 | 1954 | enum transcoder transcoder; | |
| 1951 | 1955 | struct mutex lock; | |
modified drivers/gpu/drm/i915/display/intel_dp.c
| @@ -3409,12 +3409,22 @@ intel_dp_audio_compute_config(struct intel_encoder *encoder, | |||
| 3409 | 3409 | struct intel_crtc_state *pipe_config, | |
| 3410 | 3410 | struct drm_connector_state *conn_state) | |
| 3411 | 3411 | { | |
| 3412 | + | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); | |
| 3413 | + | ||
| 3412 | 3414 | pipe_config->has_audio = | |
| 3413 | 3415 | intel_dp_has_audio(encoder, conn_state) && | |
| 3414 | 3416 | intel_audio_compute_config(encoder, pipe_config, conn_state); | |
| 3415 | 3417 | ||
| 3416 | 3418 | pipe_config->sdp_split_enable = pipe_config->has_audio && | |
| 3417 | 3419 | intel_dp_is_uhbr(pipe_config); | |
| 3420 | + | ||
| 3421 | + | /* | |
| 3422 | + | * SDP splitting for UHBR audio requires explicit sink capability in | |
| 3423 | + | * SST mode, whereas in MST mode it is inherently supported. | |
| 3424 | + | */ | |
| 3425 | + | if (pipe_config->sdp_split_enable && | |
| 3426 | + | !intel_crtc_has_type(pipe_config, INTEL_OUTPUT_DP_MST)) | |
| 3427 | + | pipe_config->sdp_split_enable = intel_dp->sst_split_sdp_support; | |
| 3418 | 3428 | } | |
| 3419 | 3429 | ||
| 3420 | 3430 | void | |
| @@ -4462,16 +4472,25 @@ void intel_dp_configure_protocol_converter(struct intel_dp *intel_dp, | |||
| 4462 | 4472 | str_enable_disable(tmp)); | |
| 4463 | 4473 | } | |
| 4464 | 4474 | ||
| 4465 | - | static bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp) | |
| 4475 | + | static u8 intel_dp_read_dprx_feature_enum(struct intel_dp *intel_dp) | |
| 4466 | 4476 | { | |
| 4467 | 4477 | u8 dprx = 0; | |
| 4468 | 4478 | ||
| 4469 | - | if (drm_dp_dpcd_readb(&intel_dp->aux, DP_DPRX_FEATURE_ENUMERATION_LIST, | |
| 4470 | - | &dprx) != 1) | |
| 4471 | - | return false; | |
| 4479 | + | drm_dp_dpcd_read_data(&intel_dp->aux, DP_DPRX_FEATURE_ENUMERATION_LIST, | |
| 4480 | + | &dprx, sizeof(dprx)); | |
| 4481 | + | return dprx; | |
| 4482 | + | } | |
| 4483 | + | ||
| 4484 | + | static bool intel_dp_get_colorimetry_status(u8 dprx) | |
| 4485 | + | { | |
| 4472 | 4486 | return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED; | |
| 4473 | 4487 | } | |
| 4474 | 4488 | ||
| 4489 | + | static bool intel_dp_get_sst_split_sdp_status(u8 dprx) | |
| 4490 | + | { | |
| 4491 | + | return dprx & DP_SST_SPLIT_SDP_CAP; | |
| 4492 | + | } | |
| 4493 | + | ||
| 4475 | 4494 | static int intel_dp_read_dsc_dpcd(struct drm_dp_aux *aux, | |
| 4476 | 4495 | u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE]) | |
| 4477 | 4496 | { | |
| @@ -4771,6 +4790,7 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp, struct intel_connector *connector | |||
| 4771 | 4790 | { | |
| 4772 | 4791 | struct intel_display *display = to_intel_display(intel_dp); | |
| 4773 | 4792 | int ret; | |
| 4793 | + | u8 dprx; | |
| 4774 | 4794 | ||
| 4775 | 4795 | /* this function is meant to be called only once */ | |
| 4776 | 4796 | drm_WARN_ON(display->drm, intel_dp->dpcd[DP_DPCD_REV] != 0); | |
| @@ -4782,8 +4802,13 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp, struct intel_connector *connector | |||
| 4782 | 4802 | drm_dp_is_branch(intel_dp->dpcd)); | |
| 4783 | 4803 | intel_init_dpcd_quirks(intel_dp, &intel_dp->desc.ident); | |
| 4784 | 4804 | ||
| 4805 | + | dprx = intel_dp_read_dprx_feature_enum(intel_dp); | |
| 4806 | + | ||
| 4785 | 4807 | intel_dp->colorimetry_support = | |
| 4786 | - | intel_dp_get_colorimetry_status(intel_dp); | |
| 4808 | + | intel_dp_get_colorimetry_status(dprx); | |
| 4809 | + | ||
| 4810 | + | intel_dp->sst_split_sdp_support = | |
| 4811 | + | intel_dp_get_sst_split_sdp_status(dprx); | |
| 4787 | 4812 | ||
| 4788 | 4813 | /* | |
| 4789 | 4814 | * Read the eDP display control registers. | |
| @@ -4874,13 +4899,20 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp) | |||
| 4874 | 4899 | * the OUI/ID since we know it won't change. | |
| 4875 | 4900 | */ | |
| 4876 | 4901 | if (!intel_dp_is_edp(intel_dp)) { | |
| 4902 | + | u8 dprx; | |
| 4903 | + | ||
| 4877 | 4904 | drm_dp_read_desc(&intel_dp->aux, &intel_dp->desc, | |
| 4878 | 4905 | drm_dp_is_branch(intel_dp->dpcd)); | |
| 4879 | 4906 | ||
| 4880 | 4907 | intel_init_dpcd_quirks(intel_dp, &intel_dp->desc.ident); | |
| 4881 | 4908 | ||
| 4909 | + | dprx = intel_dp_read_dprx_feature_enum(intel_dp); | |
| 4910 | + | ||
| 4882 | 4911 | intel_dp->colorimetry_support = | |
| 4883 | - | intel_dp_get_colorimetry_status(intel_dp); | |
| 4912 | + | intel_dp_get_colorimetry_status(dprx); | |
| 4913 | + | ||
| 4914 | + | intel_dp->sst_split_sdp_support = | |
| 4915 | + | intel_dp_get_sst_split_sdp_status(dprx); | |
| 4884 | 4916 | ||
| 4885 | 4917 | intel_dp_update_sink_caps(intel_dp); | |
| 4886 | 4918 | } | |
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
| @@ -761,10 +761,6 @@ static int mst_stream_compute_config(struct intel_atomic_state *state, | |||
| 761 | 761 | pipe_config->sink_format = INTEL_OUTPUT_FORMAT_RGB; | |
| 762 | 762 | pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB; | |
| 763 | 763 | ||
| 764 | - | ret = intel_pfit_compute_config(pipe_config, conn_state); | |
| 765 | - | if (ret) | |
| 766 | - | return ret; | |
| 767 | - | ||
| 768 | 764 | ret = intel_pfit_compute_config(pipe_config, conn_state); | |
| 769 | 765 | if (ret) | |
| 770 | 766 | return ret; | |
| @@ -856,7 +852,8 @@ static u8 get_pipes_downstream_of_mst_port(struct intel_atomic_state *state, | |||
| 856 | 852 | if (&connector->mst.dp->mst.mgr != mst_mgr) | |
| 857 | 853 | continue; | |
| 858 | 854 | ||
| 859 | - | if (connector->mst.port != parent_port && | |
| 855 | + | if (parent_port && | |
| 856 | + | connector->mst.port != parent_port && | |
| 860 | 857 | !drm_dp_mst_port_downstream_of_parent(mst_mgr, | |
| 861 | 858 | connector->mst.port, | |
| 862 | 859 | parent_port)) | |
| @@ -2171,6 +2168,27 @@ bool intel_dp_mst_crtc_needs_modeset(struct intel_atomic_state *state, | |||
| 2171 | 2168 | return false; | |
| 2172 | 2169 | } | |
| 2173 | 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 | + | ||
| 2174 | 2192 | /** | |
| 2175 | 2193 | * intel_dp_mst_prepare_probe - Prepare an MST link for topology probing | |
| 2176 | 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_lt_phy.c
| @@ -1976,7 +1976,8 @@ void intel_lt_phy_pll_enable(struct intel_encoder *encoder, | |||
| 1976 | 1976 | * Change. We handle this step in bxt_set_cdclk(). | |
| 1977 | 1977 | */ | |
| 1978 | 1978 | /* 10. Program DDI_CLK_VALFREQ to match intended DDI clock frequency. */ | |
| 1979 | - | intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), port_clock); | |
| 1979 | + | intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), | |
| 1980 | + | intel_ddi_link_symbol_clock(encoder, port_clock)); | |
| 1980 | 1981 | ||
| 1981 | 1982 | /* 11. Program PORT_CLOCK_CTL[PCLK PLL Request LN0] = 1. */ | |
| 1982 | 1983 | intel_de_rmw(display, XELPDP_PORT_CLOCK_CTL(display, port), | |
| @@ -2023,7 +2024,8 @@ void intel_lt_phy_pll_enable(struct intel_encoder *encoder, | |||
| 2023 | 2024 | lane_phy_pulse_status, | |
| 2024 | 2025 | lane_phy_pulse_status); | |
| 2025 | 2026 | } else { | |
| 2026 | - | intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), port_clock); | |
| 2027 | + | intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), | |
| 2028 | + | intel_ddi_link_symbol_clock(encoder, port_clock)); | |
| 2027 | 2029 | } | |
| 2028 | 2030 | ||
| 2029 | 2031 | /* | |
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/skl_universal_plane.c
| @@ -885,7 +885,8 @@ static void icl_plane_disable_sel_fetch_arm(struct intel_dsb *dsb, | |||
| 885 | 885 | struct intel_display *display = to_intel_display(plane); | |
| 886 | 886 | enum pipe pipe = plane->pipe; | |
| 887 | 887 | ||
| 888 | - | if (!crtc_state->enable_psr2_sel_fetch) | |
| 888 | + | if (!crtc_state->enable_psr2_sel_fetch && | |
| 889 | + | !crtc_state->clear_psr2_sel_fetch) | |
| 889 | 890 | return; | |
| 890 | 891 | ||
| 891 | 892 | intel_de_write_dsb(display, dsb, SEL_FETCH_PLANE_CTL(pipe, plane->id), 0); | |
| @@ -1634,10 +1635,8 @@ static void icl_plane_update_sel_fetch_arm(struct intel_dsb *dsb, | |||
| 1634 | 1635 | struct intel_display *display = to_intel_display(plane); | |
| 1635 | 1636 | enum pipe pipe = plane->pipe; | |
| 1636 | 1637 | ||
| 1637 | - | if (!crtc_state->enable_psr2_sel_fetch) | |
| 1638 | - | return; | |
| 1639 | - | ||
| 1640 | - | 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) | |
| 1641 | 1640 | intel_de_write_dsb(display, dsb, SEL_FETCH_PLANE_CTL(pipe, plane->id), | |
| 1642 | 1641 | SEL_FETCH_PLANE_CTL_ENABLE); | |
| 1643 | 1642 | else | |
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/i915_pci.c
| @@ -958,6 +958,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 958 | 958 | (struct intel_device_info *) ent->driver_data; | |
| 959 | 959 | int err; | |
| 960 | 960 | ||
| 961 | + | if (!intel_info) | |
| 962 | + | return -ENODEV; | |
| 963 | + | ||
| 961 | 964 | if (intel_info->require_force_probe && !id_forced(pdev->device)) { | |
| 962 | 965 | dev_info(&pdev->dev, | |
| 963 | 966 | "Your graphics device %04x is not properly supported by i915 in this\n" | |
modified drivers/gpu/drm/i915/i915_query.c
| @@ -403,8 +403,10 @@ static int query_perf_config_list(struct drm_i915_private *i915, | |||
| 403 | 403 | ids = krealloc(oa_config_ids, | |
| 404 | 404 | n_configs * sizeof(*oa_config_ids), | |
| 405 | 405 | GFP_KERNEL); | |
| 406 | - | if (!ids) | |
| 406 | + | if (!ids) { | |
| 407 | + | kfree(oa_config_ids); | |
| 407 | 408 | return -ENOMEM; | |
| 409 | + | } | |
| 408 | 410 | ||
| 409 | 411 | alloc = fetch_and_zero(&n_configs); | |
| 410 | 412 | ||
modified drivers/gpu/drm/imagination/pvr_free_list.c
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | #include "pvr_vm.h" | |
| 9 | 9 | ||
| 10 | 10 | #include <drm/drm_gem.h> | |
| 11 | + | #include <drm/drm_print.h> | |
| 11 | 12 | #include <linux/slab.h> | |
| 12 | 13 | #include <linux/xarray.h> | |
| 13 | 14 | #include <uapi/drm/pvr_drm.h> | |
| @@ -612,13 +613,21 @@ pvr_free_list_process_reconstruct_req(struct pvr_device *pvr_dev, | |||
| 612 | 613 | }; | |
| 613 | 614 | struct rogue_fwif_freelists_reconstruction_data *resp = | |
| 614 | 615 | &resp_cmd.cmd_data.free_lists_reconstruction_data; | |
| 616 | + | u32 count = min_t(u32, req->freelist_count, | |
| 617 | + | ARRAY_SIZE(req->freelist_ids)); | |
| 615 | 618 | ||
| 616 | - | for (u32 i = 0; i < req->freelist_count; i++) | |
| 619 | + | if (count != req->freelist_count) { | |
| 620 | + | drm_warn_once(from_pvr_device(pvr_dev), | |
| 621 | + | "Requested reconstruction of %u freelists, limiting to %u\n", | |
| 622 | + | req->freelist_count, count); | |
| 623 | + | } | |
| 624 | + | ||
| 625 | + | for (u32 i = 0; i < count; i++) | |
| 617 | 626 | pvr_free_list_reconstruct(pvr_dev, req->freelist_ids[i]); | |
| 618 | 627 | ||
| 619 | - | resp->freelist_count = req->freelist_count; | |
| 628 | + | resp->freelist_count = count; | |
| 620 | 629 | memcpy(resp->freelist_ids, req->freelist_ids, | |
| 621 | - | req->freelist_count * sizeof(resp->freelist_ids[0])); | |
| 630 | + | count * sizeof(resp->freelist_ids[0])); | |
| 622 | 631 | ||
| 623 | 632 | WARN_ON(pvr_kccb_send_cmd(pvr_dev, &resp_cmd, NULL)); | |
| 624 | 633 | } | |
modified drivers/gpu/drm/imagination/pvr_mmu.c
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | #include "pvr_rogue_mmu_defs.h" | |
| 13 | 13 | ||
| 14 | 14 | #include <drm/drm_drv.h> | |
| 15 | + | #include <drm/drm_print.h> | |
| 15 | 16 | #include <linux/atomic.h> | |
| 16 | 17 | #include <linux/bitops.h> | |
| 17 | 18 | #include <linux/dma-mapping.h> | |
| @@ -2335,6 +2336,7 @@ void pvr_mmu_op_context_destroy(struct pvr_mmu_op_context *op_ctx) | |||
| 2335 | 2336 | * pvr_mmu_op_context_create() - Create an MMU op context. | |
| 2336 | 2337 | * @ctx: MMU context associated with owning VM context. | |
| 2337 | 2338 | * @sgt: Scatter gather table containing pages pinned for use by this context. | |
| 2339 | + | * @device_addr: Virtual device address at the start of the requested mapping. | |
| 2338 | 2340 | * @sgt_offset: Start offset of the requested device-virtual memory mapping. | |
| 2339 | 2341 | * @size: Size in bytes of the requested device-virtual memory mapping. For an | |
| 2340 | 2342 | * unmapping, this should be zero so that no page tables are allocated. | |
| @@ -2346,8 +2348,9 @@ void pvr_mmu_op_context_destroy(struct pvr_mmu_op_context *op_ctx) | |||
| 2346 | 2348 | */ | |
| 2347 | 2349 | struct pvr_mmu_op_context * | |
| 2348 | 2350 | pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, struct sg_table *sgt, | |
| 2349 | - | u64 sgt_offset, u64 size) | |
| 2351 | + | u64 device_addr, u64 sgt_offset, u64 size) | |
| 2350 | 2352 | { | |
| 2353 | + | u64 start_addr = device_addr + sgt_offset; | |
| 2351 | 2354 | int err; | |
| 2352 | 2355 | ||
| 2353 | 2356 | struct pvr_mmu_op_context *op_ctx = kzalloc_obj(*op_ctx); | |
| @@ -2363,16 +2366,16 @@ pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, struct sg_table *sgt, | |||
| 2363 | 2366 | if (size) { | |
| 2364 | 2367 | /* | |
| 2365 | 2368 | * The number of page table objects we need to prealloc is | |
| 2366 | - | * indicated by the mapping size, start offset and the sizes | |
| 2369 | + | * indicated by the mapping size, start address and the sizes | |
| 2367 | 2370 | * of the areas mapped per PT or PD. The range calculation is | |
| 2368 | 2371 | * identical to that for the index into a table for a device | |
| 2369 | 2372 | * address, so we reuse those functions here. | |
| 2370 | 2373 | */ | |
| 2371 | - | const u32 l1_start_idx = pvr_page_table_l2_idx(sgt_offset); | |
| 2372 | - | const u32 l1_end_idx = pvr_page_table_l2_idx(sgt_offset + size); | |
| 2374 | + | const u32 l1_start_idx = pvr_page_table_l2_idx(start_addr); | |
| 2375 | + | const u32 l1_end_idx = pvr_page_table_l2_idx(start_addr + size); | |
| 2373 | 2376 | const u32 l1_count = l1_end_idx - l1_start_idx + 1; | |
| 2374 | - | const u32 l0_start_idx = pvr_page_table_l1_idx(sgt_offset); | |
| 2375 | - | const u32 l0_end_idx = pvr_page_table_l1_idx(sgt_offset + size); | |
| 2377 | + | const u32 l0_start_idx = pvr_page_table_l1_idx(start_addr); | |
| 2378 | + | const u32 l0_end_idx = pvr_page_table_l1_idx(start_addr + size); | |
| 2376 | 2379 | const u32 l0_count = l0_end_idx - l0_start_idx + 1; | |
| 2377 | 2380 | ||
| 2378 | 2381 | /* | |
| @@ -2553,7 +2556,9 @@ pvr_mmu_map_sgl(struct pvr_mmu_op_context *op_ctx, struct scatterlist *sgl, | |||
| 2553 | 2556 | ||
| 2554 | 2557 | err_destroy_pages: | |
| 2555 | 2558 | memcpy(&op_ctx->curr_page, &ptr_copy, sizeof(op_ctx->curr_page)); | |
| 2556 | - | err = pvr_mmu_op_context_unmap_curr_page(op_ctx, page); | |
| 2559 | + | if (pvr_mmu_op_context_unmap_curr_page(op_ctx, page)) | |
| 2560 | + | drm_err(from_pvr_device(op_ctx->mmu_ctx->pvr_dev), | |
| 2561 | + | "%s : Failure in unmapping pages\n", __func__); | |
| 2557 | 2562 | ||
| 2558 | 2563 | return err; | |
| 2559 | 2564 | } | |
modified drivers/gpu/drm/imagination/pvr_mmu.h
| @@ -99,7 +99,7 @@ dma_addr_t pvr_mmu_get_root_table_dma_addr(struct pvr_mmu_context *ctx); | |||
| 99 | 99 | void pvr_mmu_op_context_destroy(struct pvr_mmu_op_context *op_ctx); | |
| 100 | 100 | struct pvr_mmu_op_context * | |
| 101 | 101 | pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, | |
| 102 | - | struct sg_table *sgt, u64 sgt_offset, u64 size); | |
| 102 | + | struct sg_table *sgt, u64 device_addr, u64 sgt_offset, u64 size); | |
| 103 | 103 | ||
| 104 | 104 | int pvr_mmu_map(struct pvr_mmu_op_context *op_ctx, u64 size, u64 flags, | |
| 105 | 105 | u64 device_addr); | |
modified drivers/gpu/drm/imagination/pvr_vm.c
| @@ -276,7 +276,7 @@ pvr_vm_bind_op_map_init(struct pvr_vm_bind_op *bind_op, | |||
| 276 | 276 | goto err_bind_op_fini; | |
| 277 | 277 | ||
| 278 | 278 | bind_op->mmu_op_ctx = | |
| 279 | - | pvr_mmu_op_context_create(vm_ctx->mmu_ctx, sgt, offset, size); | |
| 279 | + | pvr_mmu_op_context_create(vm_ctx->mmu_ctx, sgt, device_addr, offset, size); | |
| 280 | 280 | err = PTR_ERR_OR_ZERO(bind_op->mmu_op_ctx); | |
| 281 | 281 | if (err) { | |
| 282 | 282 | bind_op->mmu_op_ctx = NULL; | |
| @@ -318,7 +318,7 @@ pvr_vm_bind_op_unmap_init(struct pvr_vm_bind_op *bind_op, | |||
| 318 | 318 | } | |
| 319 | 319 | ||
| 320 | 320 | bind_op->mmu_op_ctx = | |
| 321 | - | pvr_mmu_op_context_create(vm_ctx->mmu_ctx, NULL, 0, 0); | |
| 321 | + | pvr_mmu_op_context_create(vm_ctx->mmu_ctx, NULL, device_addr, 0, 0); | |
| 322 | 322 | err = PTR_ERR_OR_ZERO(bind_op->mmu_op_ctx); | |
| 323 | 323 | if (err) { | |
| 324 | 324 | bind_op->mmu_op_ctx = NULL; | |
modified drivers/gpu/drm/logicvc/Kconfig
| @@ -4,7 +4,6 @@ config DRM_LOGICVC | |||
| 4 | 4 | depends on OF || COMPILE_TEST | |
| 5 | 5 | select DRM_CLIENT_SELECTION | |
| 6 | 6 | select DRM_KMS_HELPER | |
| 7 | - | select DRM_KMS_DMA_HELPER | |
| 8 | 7 | select DRM_GEM_DMA_HELPER | |
| 9 | 8 | select REGMAP | |
| 10 | 9 | select REGMAP_MMIO | |
modified drivers/gpu/drm/loongson/lsdc_plane.c
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | 8 | #include <drm/drm_atomic.h> | |
| 9 | 9 | #include <drm/drm_atomic_helper.h> | |
| 10 | + | #include <drm/drm_blend.h> | |
| 10 | 11 | #include <drm/drm_framebuffer.h> | |
| 11 | 12 | #include <drm/drm_gem_atomic_helper.h> | |
| 12 | 13 | #include <drm/drm_print.h> | |
| @@ -765,7 +766,7 @@ int ls7a1000_cursor_plane_init(struct drm_device *ddev, | |||
| 765 | 766 | ||
| 766 | 767 | drm_plane_helper_add(plane, &ls7a1000_cursor_plane_helper_funcs); | |
| 767 | 768 | ||
| 768 | - | return 0; | |
| 769 | + | return drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_COVERAGE)); | |
| 769 | 770 | } | |
| 770 | 771 | ||
| 771 | 772 | int ls7a2000_cursor_plane_init(struct drm_device *ddev, | |
| @@ -790,5 +791,5 @@ int ls7a2000_cursor_plane_init(struct drm_device *ddev, | |||
| 790 | 791 | ||
| 791 | 792 | drm_plane_helper_add(plane, &ls7a2000_cursor_plane_helper_funcs); | |
| 792 | 793 | ||
| 793 | - | return 0; | |
| 794 | + | return drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_COVERAGE)); | |
| 794 | 795 | } | |
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/nouveau/include/nvif/cl0080.h
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | #define NV_DEVICE_V0_INFO 0x00 | |
| 6 | 6 | #define NV_DEVICE_V0_TIME 0x01 | |
| 7 | + | #define NV_DEVICE_V0_GCX_READY 0x02 | |
| 7 | 8 | ||
| 8 | 9 | struct nv_device_info_v0 { | |
| 9 | 10 | __u8 version; | |
| @@ -55,6 +56,15 @@ struct nv_device_time_v0 { | |||
| 55 | 56 | __u64 time; | |
| 56 | 57 | }; | |
| 57 | 58 | ||
| 59 | + | #define NV_DEVICE_GC6_READY BIT(0) | |
| 60 | + | #define NV_DEVICE_GCOFF_READY BIT(1) | |
| 61 | + | ||
| 62 | + | struct nv_device_gcx_ready_v0 { | |
| 63 | + | __u8 version; | |
| 64 | + | __u8 pad01[6]; | |
| 65 | + | __u8 ready; | |
| 66 | + | }; | |
| 67 | + | ||
| 58 | 68 | #define NV_DEVICE_INFO_UNIT (0xffffffffULL << 32) | |
| 59 | 69 | #define NV_DEVICE_INFO(n) ((n) | (0x00000000ULL << 32)) | |
| 60 | 70 | #define NV_DEVICE_HOST(n) ((n) | (0x00000001ULL << 32)) | |
modified drivers/gpu/drm/nouveau/include/nvif/device.h
| @@ -22,4 +22,5 @@ int nvif_device_ctor(struct nvif_client *, const char *name, struct nvif_device | |||
| 22 | 22 | void nvif_device_dtor(struct nvif_device *); | |
| 23 | 23 | int nvif_device_map(struct nvif_device *); | |
| 24 | 24 | u64 nvif_device_time(struct nvif_device *); | |
| 25 | + | int nvif_device_gcx_ready(struct nvif_device *); | |
| 25 | 26 | #endif | |
modified drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h
| @@ -87,4 +87,5 @@ int gp102_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct | |||
| 87 | 87 | int gv100_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_disp **); | |
| 88 | 88 | int tu102_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_disp **); | |
| 89 | 89 | int ga102_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_disp **); | |
| 90 | + | int gb202_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_disp **); | |
| 90 | 91 | #endif | |
modified drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h
| @@ -156,6 +156,10 @@ struct nvkm_gsp { | |||
| 156 | 156 | struct sg_table fbsr; | |
| 157 | 157 | } sr; | |
| 158 | 158 | ||
| 159 | + | struct { | |
| 160 | + | bool use_raw_mode_comptagline_alloc; | |
| 161 | + | } memsys; | |
| 162 | + | ||
| 159 | 163 | struct { | |
| 160 | 164 | struct nvkm_gsp_mem mem; | |
| 161 | 165 | ||
| @@ -495,6 +499,8 @@ nvkm_gsp_event_dtor(struct nvkm_gsp_event *event) | |||
| 495 | 499 | int nvkm_gsp_intr_stall(struct nvkm_gsp *, enum nvkm_subdev_type, int); | |
| 496 | 500 | int nvkm_gsp_intr_nonstall(struct nvkm_gsp *, enum nvkm_subdev_type, int); | |
| 497 | 501 | ||
| 502 | + | int nvkm_gsp_gcx_ready(struct nvkm_gsp *gsp); | |
| 503 | + | ||
| 498 | 504 | int gv100_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **); | |
| 499 | 505 | int tu102_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **); | |
| 500 | 506 | int tu116_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **); | |
modified drivers/gpu/drm/nouveau/nouveau_bo.c
| @@ -578,8 +578,9 @@ int nouveau_bo_pin_locked(struct nouveau_bo *nvbo, uint32_t domain, bool contig) | |||
| 578 | 578 | "0x%08x vs 0x%08x\n", bo, | |
| 579 | 579 | bo->resource->mem_type, domain); | |
| 580 | 580 | ret = -EBUSY; | |
| 581 | + | } else { | |
| 582 | + | ttm_bo_pin(&nvbo->bo); | |
| 581 | 583 | } | |
| 582 | - | ttm_bo_pin(&nvbo->bo); | |
| 583 | 584 | goto out; | |
| 584 | 585 | } | |
| 585 | 586 | ||
modified drivers/gpu/drm/nouveau/nouveau_chan.c
| @@ -90,6 +90,14 @@ nouveau_channel_del(struct nouveau_channel **pchan) | |||
| 90 | 90 | { | |
| 91 | 91 | struct nouveau_channel *chan = *pchan; | |
| 92 | 92 | if (chan) { | |
| 93 | + | /* | |
| 94 | + | * Drop the kill-event subscription first. Its handler | |
| 95 | + | * dereferences chan->fence, which the fence context teardown | |
| 96 | + | * below frees, so leaving it armed across the teardown leaves | |
| 97 | + | * a window for a use-after-free. | |
| 98 | + | */ | |
| 99 | + | nvif_event_dtor(&chan->kill); | |
| 100 | + | ||
| 93 | 101 | if (chan->fence) | |
| 94 | 102 | nouveau_fence(chan->cli->drm)->context_del(chan); | |
| 95 | 103 | ||
| @@ -100,7 +108,6 @@ nouveau_channel_del(struct nouveau_channel **pchan) | |||
| 100 | 108 | nvif_object_dtor(&chan->nvsw); | |
| 101 | 109 | nvif_object_dtor(&chan->gart); | |
| 102 | 110 | nvif_object_dtor(&chan->vram); | |
| 103 | - | nvif_event_dtor(&chan->kill); | |
| 104 | 111 | nvif_object_dtor(&chan->user); | |
| 105 | 112 | nvif_mem_dtor(&chan->mem_userd); | |
| 106 | 113 | nouveau_vma_del(&chan->sema.vma); | |
modified drivers/gpu/drm/nouveau/nouveau_connector.c
| @@ -600,8 +600,11 @@ nouveau_connector_detect(struct drm_connector *connector, bool force) | |||
| 600 | 600 | new_edid = drm_get_edid(connector, nv_encoder->i2c); | |
| 601 | 601 | } else { | |
| 602 | 602 | ret = nvif_outp_edid_get(&nv_encoder->outp, (u8 **)&new_edid); | |
| 603 | - | if (ret < 0) | |
| 603 | + | if (ret < 0) { | |
| 604 | + | pm_runtime_mark_last_busy(dev->dev); | |
| 605 | + | pm_runtime_put_autosuspend(dev->dev); | |
| 604 | 606 | return connector_status_disconnected; | |
| 607 | + | } | |
| 605 | 608 | } | |
| 606 | 609 | ||
| 607 | 610 | nouveau_connector_set_edid(nv_connector, new_edid); | |
modified drivers/gpu/drm/nouveau/nouveau_dmem.c
| @@ -267,7 +267,7 @@ static vm_fault_t nouveau_dmem_migrate_to_ram(struct vm_fault *vmf) | |||
| 267 | 267 | nouveau_fence_new(&fence, dmem->migrate.chan); | |
| 268 | 268 | migrate_vma_pages(&args); | |
| 269 | 269 | nouveau_dmem_fence_done(&fence); | |
| 270 | - | dma_unmap_page(drm->dev->dev, dma_info.dma_addr, PAGE_SIZE, | |
| 270 | + | dma_unmap_page(drm->dev->dev, dma_info.dma_addr, dma_info.size, | |
| 271 | 271 | DMA_BIDIRECTIONAL); | |
| 272 | 272 | done: | |
| 273 | 273 | migrate_vma_finalize(&args); | |
| @@ -279,11 +279,25 @@ err: | |||
| 279 | 279 | ||
| 280 | 280 | static void nouveau_dmem_folio_split(struct folio *head, struct folio *tail) | |
| 281 | 281 | { | |
| 282 | + | struct nouveau_dmem_chunk *chunk; | |
| 283 | + | struct nouveau_dmem *dmem; | |
| 284 | + | ||
| 282 | 285 | if (tail == NULL) | |
| 283 | 286 | return; | |
| 284 | 287 | tail->pgmap = head->pgmap; | |
| 285 | 288 | tail->mapping = head->mapping; | |
| 286 | 289 | folio_set_zone_device_data(tail, folio_zone_device_data(head)); | |
| 290 | + | ||
| 291 | + | /* | |
| 292 | + | * The split hands out a new independently-freeable folio that will | |
| 293 | + | * later be released via nouveau_dmem_folio_free(); account for it so | |
| 294 | + | * chunk->callocated stays balanced. | |
| 295 | + | */ | |
| 296 | + | chunk = nouveau_page_to_chunk(&head->page); | |
| 297 | + | dmem = chunk->drm->dmem; | |
| 298 | + | spin_lock(&dmem->lock); | |
| 299 | + | chunk->callocated++; | |
| 300 | + | spin_unlock(&dmem->lock); | |
| 287 | 301 | } | |
| 288 | 302 | ||
| 289 | 303 | static const struct dev_pagemap_ops nouveau_dmem_pagemap_ops = { | |
| @@ -325,8 +339,8 @@ nouveau_dmem_chunk_alloc(struct nouveau_drm *drm, struct page **ppage, | |||
| 325 | 339 | chunk->pagemap.ops = &nouveau_dmem_pagemap_ops; | |
| 326 | 340 | chunk->pagemap.owner = drm->dev; | |
| 327 | 341 | ||
| 328 | - | ret = nouveau_bo_new_pin(&drm->client, NOUVEAU_GEM_DOMAIN_VRAM, DMEM_CHUNK_SIZE, | |
| 329 | - | &chunk->bo); | |
| 342 | + | ret = nouveau_bo_new_pin(&drm->client, NOUVEAU_GEM_DOMAIN_VRAM, | |
| 343 | + | DMEM_CHUNK_SIZE * NR_CHUNKS, &chunk->bo); | |
| 330 | 344 | if (ret) | |
| 331 | 345 | goto out_release; | |
| 332 | 346 | ||
| @@ -772,7 +786,7 @@ static unsigned long nouveau_dmem_migrate_copy_one(struct nouveau_drm *drm, | |||
| 772 | 786 | return mpfn; | |
| 773 | 787 | ||
| 774 | 788 | out_dma_unmap: | |
| 775 | - | dma_unmap_page(dev, dma_info->dma_addr, PAGE_SIZE, DMA_BIDIRECTIONAL); | |
| 789 | + | dma_unmap_page(dev, dma_info->dma_addr, dma_info->size, DMA_BIDIRECTIONAL); | |
| 776 | 790 | out_free_page: | |
| 777 | 791 | nouveau_dmem_page_free_locked(drm, dpage); | |
| 778 | 792 | out: | |
modified drivers/gpu/drm/nouveau/nouveau_drm.c
| @@ -585,6 +585,7 @@ nouveau_drm_device_fini(struct nouveau_drm *drm) | |||
| 585 | 585 | if (nouveau_pmops_runtime()) { | |
| 586 | 586 | pm_runtime_get_sync(dev->dev); | |
| 587 | 587 | pm_runtime_forbid(dev->dev); | |
| 588 | + | pm_runtime_dont_use_autosuspend(dev->dev); | |
| 588 | 589 | } | |
| 589 | 590 | ||
| 590 | 591 | nouveau_led_fini(dev); | |
| @@ -1148,6 +1149,7 @@ nouveau_pmops_runtime_suspend(struct device *dev) | |||
| 1148 | 1149 | { | |
| 1149 | 1150 | struct pci_dev *pdev = to_pci_dev(dev); | |
| 1150 | 1151 | struct nouveau_drm *drm = pci_get_drvdata(pdev); | |
| 1152 | + | struct nvif_device *nvif = &drm->client.device; | |
| 1151 | 1153 | int ret; | |
| 1152 | 1154 | ||
| 1153 | 1155 | if (!nouveau_pmops_runtime()) { | |
| @@ -1155,6 +1157,18 @@ nouveau_pmops_runtime_suspend(struct device *dev) | |||
| 1155 | 1157 | return -EBUSY; | |
| 1156 | 1158 | } | |
| 1157 | 1159 | ||
| 1160 | + | // Check if the GPU itself is ready for runtime suspend, otherwise mark as busy and check | |
| 1161 | + | // again in a bit. | |
| 1162 | + | ret = nvif_device_gcx_ready(nvif); | |
| 1163 | + | if (ret < 0) { | |
| 1164 | + | NV_ERROR(drm, "Failed to query GCX readiness (returned %d)\n", ret); | |
| 1165 | + | return -EBUSY; | |
| 1166 | + | } else if (!(ret & NV_DEVICE_GCOFF_READY)) { | |
| 1167 | + | NV_DEBUG(drm, "GPU isn't ready for suspend yet, delaying...\n"); | |
| 1168 | + | pm_runtime_mark_last_busy(dev); | |
| 1169 | + | return -EBUSY; | |
| 1170 | + | } | |
| 1171 | + | ||
| 1158 | 1172 | nouveau_switcheroo_optimus_dsm(); | |
| 1159 | 1173 | ret = nouveau_do_suspend(drm, true); | |
| 1160 | 1174 | pci_save_state(pdev); | |
| @@ -1250,10 +1264,8 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) | |||
| 1250 | 1264 | mutex_unlock(&drm->clients_lock); | |
| 1251 | 1265 | ||
| 1252 | 1266 | done: | |
| 1253 | - | if (ret && cli) { | |
| 1254 | - | nouveau_cli_fini(cli); | |
| 1267 | + | if (ret && cli) | |
| 1255 | 1268 | kfree(cli); | |
| 1256 | - | } | |
| 1257 | 1269 | ||
| 1258 | 1270 | pm_runtime_mark_last_busy(dev->dev); | |
| 1259 | 1271 | pm_runtime_put_autosuspend(dev->dev); | |
modified drivers/gpu/drm/nouveau/nouveau_gem.c
| @@ -522,6 +522,7 @@ retry: | |||
| 522 | 522 | if (unlikely(ret)) { | |
| 523 | 523 | if (ret != -ERESTARTSYS) | |
| 524 | 524 | NV_PRINTK(err, cli, "fail reserve\n"); | |
| 525 | + | drm_gem_object_put(gem); | |
| 525 | 526 | break; | |
| 526 | 527 | } | |
| 527 | 528 | } | |
| @@ -531,6 +532,7 @@ retry: | |||
| 531 | 532 | struct nouveau_vma *vma = nouveau_vma_find(nvbo, vmm); | |
| 532 | 533 | if (!vma) { | |
| 533 | 534 | NV_PRINTK(err, cli, "vma not found!\n"); | |
| 535 | + | drm_gem_object_put(gem); | |
| 534 | 536 | ret = -EINVAL; | |
| 535 | 537 | break; | |
| 536 | 538 | } | |
modified drivers/gpu/drm/nouveau/nouveau_sched.c
| @@ -517,7 +517,7 @@ nouveau_sched_destroy(struct nouveau_sched **psched) | |||
| 517 | 517 | struct nouveau_sched *sched = *psched; | |
| 518 | 518 | ||
| 519 | 519 | nouveau_sched_fini(sched); | |
| 520 | - | kfree(sched); | |
| 520 | + | kfree_rcu(sched, rcu); | |
| 521 | 521 | ||
| 522 | 522 | *psched = NULL; | |
| 523 | 523 | } | |
modified drivers/gpu/drm/nouveau/nouveau_sched.h
| @@ -98,6 +98,7 @@ void nouveau_job_free(struct nouveau_job *job); | |||
| 98 | 98 | ||
| 99 | 99 | struct nouveau_sched { | |
| 100 | 100 | struct drm_gpu_scheduler base; | |
| 101 | + | struct rcu_head rcu; | |
| 101 | 102 | struct drm_sched_entity entity; | |
| 102 | 103 | struct workqueue_struct *wq; | |
| 103 | 104 | struct mutex mutex; | |
modified drivers/gpu/drm/nouveau/nouveau_sgdma.c
| @@ -72,9 +72,7 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags) | |||
| 72 | 72 | struct nouveau_sgdma_be *nvbe; | |
| 73 | 73 | enum ttm_caching caching; | |
| 74 | 74 | ||
| 75 | - | if (nvbo->force_coherent) | |
| 76 | - | caching = ttm_uncached; | |
| 77 | - | else if (drm->agp.bridge) | |
| 75 | + | if (nvbo->force_coherent || drm->agp.bridge) | |
| 78 | 76 | caching = ttm_write_combined; | |
| 79 | 77 | else | |
| 80 | 78 | caching = ttm_cached; | |
modified drivers/gpu/drm/nouveau/nouveau_uvmm.c
| @@ -846,6 +846,9 @@ op_map(struct nouveau_uvma *uvma) | |||
| 846 | 846 | { | |
| 847 | 847 | struct nouveau_bo *nvbo = nouveau_gem_object(uvma->va.gem.obj); | |
| 848 | 848 | ||
| 849 | + | if (drm_gpuva_invalidated(&uvma->va)) | |
| 850 | + | return; | |
| 851 | + | ||
| 849 | 852 | nouveau_uvma_map(uvma, nouveau_mem(nvbo->bo.resource)); | |
| 850 | 853 | } | |
| 851 | 854 | ||
| @@ -1232,6 +1235,7 @@ bind_lock_validate(struct nouveau_job *job, struct drm_exec *exec, | |||
| 1232 | 1235 | ||
| 1233 | 1236 | drm_gpuva_for_each_op(va_op, op->ops) { | |
| 1234 | 1237 | struct drm_gem_object *obj = op_gem_obj(va_op); | |
| 1238 | + | struct nouveau_bo *nvbo; | |
| 1235 | 1239 | ||
| 1236 | 1240 | if (unlikely(!obj)) | |
| 1237 | 1241 | continue; | |
| @@ -1246,8 +1250,13 @@ bind_lock_validate(struct nouveau_job *job, struct drm_exec *exec, | |||
| 1246 | 1250 | if (va_op->op == DRM_GPUVA_OP_UNMAP) | |
| 1247 | 1251 | continue; | |
| 1248 | 1252 | ||
| 1249 | - | ret = nouveau_bo_validate(nouveau_gem_object(obj), | |
| 1250 | - | true, false); | |
| 1253 | + | nvbo = nouveau_gem_object(obj); | |
| 1254 | + | if (!(nvbo->valid_domains & | |
| 1255 | + | (NOUVEAU_GEM_DOMAIN_VRAM | NOUVEAU_GEM_DOMAIN_GART))) | |
| 1256 | + | return -EINVAL; | |
| 1257 | + | ||
| 1258 | + | nouveau_bo_placement_set(nvbo, nvbo->valid_domains, 0); | |
| 1259 | + | ret = nouveau_bo_validate(nvbo, true, false); | |
| 1251 | 1260 | if (ret) | |
| 1252 | 1261 | return ret; | |
| 1253 | 1262 | } | |
| @@ -1319,6 +1328,7 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job, | |||
| 1319 | 1328 | op->va.range); | |
| 1320 | 1329 | if (!op->reg || op->reg->dirty) { | |
| 1321 | 1330 | ret = -ENOENT; | |
| 1331 | + | op->reg = NULL; | |
| 1322 | 1332 | goto unwind_continue; | |
| 1323 | 1333 | } | |
| 1324 | 1334 | ||
| @@ -1327,6 +1337,7 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job, | |||
| 1327 | 1337 | op->va.range); | |
| 1328 | 1338 | if (IS_ERR(op->ops)) { | |
| 1329 | 1339 | ret = PTR_ERR(op->ops); | |
| 1340 | + | op->reg = NULL; | |
| 1330 | 1341 | goto unwind_continue; | |
| 1331 | 1342 | } | |
| 1332 | 1343 | ||
| @@ -1473,6 +1484,7 @@ unwind: | |||
| 1473 | 1484 | op->va.range); | |
| 1474 | 1485 | break; | |
| 1475 | 1486 | case OP_UNMAP_SPARSE: | |
| 1487 | + | op->reg->dirty = false; | |
| 1476 | 1488 | __nouveau_uvma_region_insert(uvmm, op->reg); | |
| 1477 | 1489 | nouveau_uvmm_sm_unmap_prepare_unwind(uvmm, &op->new, | |
| 1478 | 1490 | op->ops); | |
| @@ -1489,7 +1501,8 @@ unwind: | |||
| 1489 | 1501 | break; | |
| 1490 | 1502 | } | |
| 1491 | 1503 | ||
| 1492 | - | drm_gpuva_ops_free(&uvmm->base, op->ops); | |
| 1504 | + | if (!IS_ERR_OR_NULL(op->ops)) | |
| 1505 | + | drm_gpuva_ops_free(&uvmm->base, op->ops); | |
| 1493 | 1506 | op->ops = NULL; | |
| 1494 | 1507 | op->reg = NULL; | |
| 1495 | 1508 | } | |
modified drivers/gpu/drm/nouveau/nvif/device.c
| @@ -38,6 +38,19 @@ nvif_device_time(struct nvif_device *device) | |||
| 38 | 38 | return device->user.func->time(&device->user); | |
| 39 | 39 | } | |
| 40 | 40 | ||
| 41 | + | int | |
| 42 | + | nvif_device_gcx_ready(struct nvif_device *device) | |
| 43 | + | { | |
| 44 | + | struct nv_device_gcx_ready_v0 args = {}; | |
| 45 | + | int ret; | |
| 46 | + | ||
| 47 | + | ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_GCX_READY, &args, sizeof(args)); | |
| 48 | + | if (ret) | |
| 49 | + | return ret; | |
| 50 | + | ||
| 51 | + | return args.ready; | |
| 52 | + | } | |
| 53 | + | ||
| 41 | 54 | int | |
| 42 | 55 | nvif_device_map(struct nvif_device *device) | |
| 43 | 56 | { | |
modified drivers/gpu/drm/nouveau/nvif/vmm.c
| @@ -192,6 +192,7 @@ void | |||
| 192 | 192 | nvif_vmm_dtor(struct nvif_vmm *vmm) | |
| 193 | 193 | { | |
| 194 | 194 | kfree(vmm->page); | |
| 195 | + | vmm->page = NULL; | |
| 195 | 196 | nvif_object_dtor(&vmm->object); | |
| 196 | 197 | } | |
| 197 | 198 | ||
modified drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
| @@ -2846,7 +2846,7 @@ nv1b2_chipset = { | |||
| 2846 | 2846 | .pci = { 0x00000001, gh100_pci_new }, | |
| 2847 | 2847 | .timer = { 0x00000001, gk20a_timer_new }, | |
| 2848 | 2848 | .vfn = { 0x00000001, ga100_vfn_new }, | |
| 2849 | - | .disp = { 0x00000001, ga102_disp_new }, | |
| 2849 | + | .disp = { 0x00000001, gb202_disp_new }, | |
| 2850 | 2850 | .fifo = { 0x00000001, ga102_fifo_new }, | |
| 2851 | 2851 | }; | |
| 2852 | 2852 | ||
| @@ -2862,7 +2862,7 @@ nv1b3_chipset = { | |||
| 2862 | 2862 | .pci = { 0x00000001, gh100_pci_new }, | |
| 2863 | 2863 | .timer = { 0x00000001, gk20a_timer_new }, | |
| 2864 | 2864 | .vfn = { 0x00000001, ga100_vfn_new }, | |
| 2865 | - | .disp = { 0x00000001, ga102_disp_new }, | |
| 2865 | + | .disp = { 0x00000001, gb202_disp_new }, | |
| 2866 | 2866 | .fifo = { 0x00000001, ga102_fifo_new }, | |
| 2867 | 2867 | }; | |
| 2868 | 2868 | ||
| @@ -2878,7 +2878,7 @@ nv1b5_chipset = { | |||
| 2878 | 2878 | .pci = { 0x00000001, gh100_pci_new }, | |
| 2879 | 2879 | .timer = { 0x00000001, gk20a_timer_new }, | |
| 2880 | 2880 | .vfn = { 0x00000001, ga100_vfn_new }, | |
| 2881 | - | .disp = { 0x00000001, ga102_disp_new }, | |
| 2881 | + | .disp = { 0x00000001, gb202_disp_new }, | |
| 2882 | 2882 | .fifo = { 0x00000001, ga102_fifo_new }, | |
| 2883 | 2883 | }; | |
| 2884 | 2884 | ||
| @@ -2894,7 +2894,7 @@ nv1b6_chipset = { | |||
| 2894 | 2894 | .pci = { 0x00000001, gh100_pci_new }, | |
| 2895 | 2895 | .timer = { 0x00000001, gk20a_timer_new }, | |
| 2896 | 2896 | .vfn = { 0x00000001, ga100_vfn_new }, | |
| 2897 | - | .disp = { 0x00000001, ga102_disp_new }, | |
| 2897 | + | .disp = { 0x00000001, gb202_disp_new }, | |
| 2898 | 2898 | .fifo = { 0x00000001, ga102_fifo_new }, | |
| 2899 | 2899 | }; | |
| 2900 | 2900 | ||
| @@ -2910,7 +2910,7 @@ nv1b7_chipset = { | |||
| 2910 | 2910 | .pci = { 0x00000001, gh100_pci_new }, | |
| 2911 | 2911 | .timer = { 0x00000001, gk20a_timer_new }, | |
| 2912 | 2912 | .vfn = { 0x00000001, ga100_vfn_new }, | |
| 2913 | - | .disp = { 0x00000001, ga102_disp_new }, | |
| 2913 | + | .disp = { 0x00000001, gb202_disp_new }, | |
| 2914 | 2914 | .fifo = { 0x00000001, ga102_fifo_new }, | |
| 2915 | 2915 | }; | |
| 2916 | 2916 | ||
modified drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
| @@ -74,6 +74,7 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size) | |||
| 74 | 74 | const struct nvkm_domain *domain; | |
| 75 | 75 | struct nvkm_pstate *pstate; | |
| 76 | 76 | struct nvkm_cstate *cstate; | |
| 77 | + | bool found = false; | |
| 77 | 78 | int i = 0, j = -1; | |
| 78 | 79 | u32 lo, hi; | |
| 79 | 80 | int ret = -ENOSYS; | |
| @@ -104,10 +105,15 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size) | |||
| 104 | 105 | ||
| 105 | 106 | if (args->v0.state != NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT) { | |
| 106 | 107 | list_for_each_entry(pstate, &clk->states, head) { | |
| 107 | - | if (i++ == args->v0.state) | |
| 108 | + | if (i++ == args->v0.state) { | |
| 109 | + | found = true; | |
| 108 | 110 | break; | |
| 111 | + | } | |
| 109 | 112 | } | |
| 110 | 113 | ||
| 114 | + | if (!found) | |
| 115 | + | return -EINVAL; | |
| 116 | + | ||
| 111 | 117 | lo = pstate->base.domain[domain->name]; | |
| 112 | 118 | hi = lo; | |
| 113 | 119 | list_for_each_entry(cstate, &pstate->list, head) { | |
modified drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
| @@ -27,6 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | 28 | #include <core/client.h> | |
| 29 | 29 | #include <subdev/fb.h> | |
| 30 | + | #include <subdev/gsp.h> | |
| 30 | 31 | #include <subdev/instmem.h> | |
| 31 | 32 | #include <subdev/timer.h> | |
| 32 | 33 | ||
| @@ -189,6 +190,38 @@ nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size) | |||
| 189 | 190 | return ret; | |
| 190 | 191 | } | |
| 191 | 192 | ||
| 193 | + | static int | |
| 194 | + | nvkm_udevice_gcx_ready(struct nvkm_udevice *udev, void *data, u32 size) | |
| 195 | + | { | |
| 196 | + | struct nvkm_object *object = &udev->object; | |
| 197 | + | struct nvkm_device *device = udev->device; | |
| 198 | + | struct nvkm_gsp *gsp = device->gsp; | |
| 199 | + | union { | |
| 200 | + | struct nv_device_gcx_ready_v0 v0; | |
| 201 | + | } *args = data; | |
| 202 | + | int ret = -ENOSYS; | |
| 203 | + | ||
| 204 | + | if (!gsp) { | |
| 205 | + | args->v0.ready = NV_DEVICE_GC6_READY | NV_DEVICE_GCOFF_READY; | |
| 206 | + | return 0; | |
| 207 | + | } | |
| 208 | + | ||
| 209 | + | nvif_ioctl(object, "device gcx ready size %d\n", size); | |
| 210 | + | ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false); | |
| 211 | + | if (!ret) { | |
| 212 | + | nvif_ioctl(object, "device gcx ready vers %d\n", args->v0.version); | |
| 213 | + | ||
| 214 | + | ret = nvkm_gsp_gcx_ready(gsp); | |
| 215 | + | if (ret < 0) | |
| 216 | + | return ret; | |
| 217 | + | ||
| 218 | + | args->v0.ready = ret; | |
| 219 | + | ret = 0; | |
| 220 | + | } | |
| 221 | + | ||
| 222 | + | return ret; | |
| 223 | + | } | |
| 224 | + | ||
| 192 | 225 | static int | |
| 193 | 226 | nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) | |
| 194 | 227 | { | |
| @@ -199,6 +232,8 @@ nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) | |||
| 199 | 232 | return nvkm_udevice_info(udev, data, size); | |
| 200 | 233 | case NV_DEVICE_V0_TIME: | |
| 201 | 234 | return nvkm_udevice_time(udev, data, size); | |
| 235 | + | case NV_DEVICE_V0_GCX_READY: | |
| 236 | + | return nvkm_udevice_gcx_ready(udev, data, size); | |
| 202 | 237 | default: | |
| 203 | 238 | break; | |
| 204 | 239 | } | |
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
| @@ -27,6 +27,7 @@ nvkm-y += nvkm/engine/disp/gp102.o | |||
| 27 | 27 | nvkm-y += nvkm/engine/disp/gv100.o | |
| 28 | 28 | nvkm-y += nvkm/engine/disp/tu102.o | |
| 29 | 29 | nvkm-y += nvkm/engine/disp/ga102.o | |
| 30 | + | nvkm-y += nvkm/engine/disp/gb202.o | |
| 30 | 31 | ||
| 31 | 32 | nvkm-y += nvkm/engine/disp/udisp.o | |
| 32 | 33 | nvkm-y += nvkm/engine/disp/uconn.o | |
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c
| @@ -144,12 +144,23 @@ ga102_disp = { | |||
| 144 | 144 | }, | |
| 145 | 145 | }; | |
| 146 | 146 | ||
| 147 | + | static const struct nvkm_disp_func | |
| 148 | + | ga102_gsp_disp = { | |
| 149 | + | .uevent = &gv100_disp_chan_uevent, | |
| 150 | + | .ramht_size = 0x2000, | |
| 151 | + | .gsp.intr = tu102_disp_intr, | |
| 152 | + | .gsp.head = &tu102_gsp_head, | |
| 153 | + | .gsp.hdmi_gcp = tu102_sor_hdmi_gcp, | |
| 154 | + | .gsp.hdmi_infoframe_avi = gv100_sor_hdmi_infoframe_avi, | |
| 155 | + | .gsp.hdmi_infoframe_vsi = gv100_sor_hdmi_infoframe_vsi, | |
| 156 | + | }; | |
| 157 | + | ||
| 147 | 158 | int | |
| 148 | 159 | ga102_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, | |
| 149 | 160 | struct nvkm_disp **pdisp) | |
| 150 | 161 | { | |
| 151 | 162 | if (nvkm_gsp_rm(device->gsp)) | |
| 152 | - | return r535_disp_new(&ga102_disp, device, type, inst, pdisp); | |
| 163 | + | return r535_disp_new(&ga102_gsp_disp, device, type, inst, pdisp); | |
| 153 | 164 | ||
| 154 | 165 | return nvkm_disp_new_(&ga102_disp, device, type, inst, pdisp); | |
| 155 | 166 | } | |
added drivers/gpu/drm/nouveau/nvkm/engine/disp/gb202.c mode 100644
| @@ -0,0 +1,191 @@ | |||
| 1 | + | // SPDX-License-Identifier: MIT | |
| 2 | + | /* | |
| 3 | + | * Copyright 2026 Valve Corp. | |
| 4 | + | */ | |
| 5 | + | #include "priv.h" | |
| 6 | + | #include "head.h" | |
| 7 | + | #include "ior.h" | |
| 8 | + | ||
| 9 | + | #include <subdev/timer.h> | |
| 10 | + | ||
| 11 | + | /* GB20x (NVD5.0) reorganised the SF HDMI packet units. The AVI unit is | |
| 12 | + | * unchanged from GV100, but the legacy VSI unit is gone. Vendor infoframes | |
| 13 | + | * are sent through the shared generic infoframe units instead. Register | |
| 14 | + | * layout per NVIDIA's clc971.h/clca71.h, programming sequence per | |
| 15 | + | * nvhdmipkt_C971.c:programAdvancedInfoframeC971(). | |
| 16 | + | */ | |
| 17 | + | static void | |
| 18 | + | gb202_sor_hdmi_infoframe_vsi(struct nvkm_ior *ior, int head, void *data, u32 size) | |
| 19 | + | { | |
| 20 | + | struct nvkm_device *device = ior->disp->engine.subdev.device; | |
| 21 | + | const u32 hoff = head * 0x400; | |
| 22 | + | /* Generic infoframe unit 1, the slot NVIDIA's driver uses for the VSI. */ | |
| 23 | + | const u32 ctrl = 0x6f0138 + hoff; | |
| 24 | + | u8 buf[36] = {}; | |
| 25 | + | int i; | |
| 26 | + | ||
| 27 | + | /* Disable the unit and wait for it to go idle. */ | |
| 28 | + | nvkm_mask(device, ctrl, 0x00000001, 0x00000000); | |
| 29 | + | if (nvkm_msec(device, 2000, | |
| 30 | + | if (!(nvkm_rd32(device, ctrl) & 0x00400000)) | |
| 31 | + | break; | |
| 32 | + | ) < 0) | |
| 33 | + | return; | |
| 34 | + | ||
| 35 | + | if (!size) | |
| 36 | + | return; | |
| 37 | + | ||
| 38 | + | /* Clear SENT status, and point the data port at unit 1's slot. */ | |
| 39 | + | nvkm_mask(device, ctrl, 0x00800000, 0x00800000); | |
| 40 | + | nvkm_wr32(device, 0x6f03f0 + hoff, 0x00000001); | |
| 41 | + | ||
| 42 | + | /* The data port takes the raw packet, except that a zero is inserted | |
| 43 | + | * in HB3 after the three header bytes. A slot is 9 dwords (HB0-3 plus | |
| 44 | + | * up to 32 payload bytes). An HDMI infoframe carries at most PB0-27, | |
| 45 | + | * so the tail stays zero, and we always write the whole slot. | |
| 46 | + | */ | |
| 47 | + | size = min_t(u32, size, 31); | |
| 48 | + | memcpy(buf, data, min_t(u32, size, 3)); | |
| 49 | + | if (size > 3) | |
| 50 | + | memcpy(&buf[4], (u8 *)data + 3, size - 3); | |
| 51 | + | ||
| 52 | + | for (i = 0; i < 36; i += 4) { | |
| 53 | + | nvkm_wr32(device, 0x6f03f4 + hoff, buf[i + 0] | buf[i + 1] << 8 | | |
| 54 | + | buf[i + 2] << 16 | | |
| 55 | + | (u32)buf[i + 3] << 24); | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | /* No flip ID or scanline matching. */ | |
| 59 | + | nvkm_wr32(device, 0x6f013c + hoff, 0x00000000); | |
| 60 | + | ||
| 61 | + | /* ENABLE | RUN_MODE=ALWAYS | LOC=VBLANK | OFFSET=1 | SIZE=0. */ | |
| 62 | + | nvkm_wr32(device, ctrl, 0x00000041); | |
| 63 | + | ||
| 64 | + | /* Audio priority low (the init value). */ | |
| 65 | + | nvkm_wr32(device, 0x6f03f8 + hoff, 0x00000002); | |
| 66 | + | } | |
| 67 | + | ||
| 68 | + | /* General Control Packet AVMute bracket. The GCP unit moved to slot 1 on | |
| 69 | + | * NVD5.0. Only SB0 (the AVMute bit) is ours to write so we must not do a | |
| 70 | + | * full write here: SB1 carries the deep-color CD/PP fields, and SB1_CTRL | |
| 71 | + | * (bit 24, new with clc871.h) controls where their generation happens (HW | |
| 72 | + | * or driver) on these chips, with the default being HW. | |
| 73 | + | */ | |
| 74 | + | static void | |
| 75 | + | gb202_sor_hdmi_gcp(struct nvkm_ior *sor, int head, bool enable) | |
| 76 | + | { | |
| 77 | + | struct nvkm_device *device = sor->disp->engine.subdev.device; | |
| 78 | + | const u32 hdmi = head * 0x400; | |
| 79 | + | ||
| 80 | + | nvkm_mask(device, 0x6f0040 + hdmi, 0x00000001, 0x00000000); | |
| 81 | + | nvkm_mask(device, 0x6f004c + hdmi, 0x000000ff, !enable ? 0x00000001 : | |
| 82 | + | 0x00000010); | |
| 83 | + | nvkm_mask(device, 0x6f0040 + hdmi, 0x00000001, 0x00000001); | |
| 84 | + | } | |
| 85 | + | ||
| 86 | + | /* Same core-channel state mirror as gv100_head_state() (assembly at 0x680000, | |
| 87 | + | * armed at +0x8000, per-head method offsets unchanged), but NVD5.0 spaces | |
| 88 | + | * heads 0x800 apart (see NVCA7D_HEAD_SET_*(a) in clca7d.h). | |
| 89 | + | */ | |
| 90 | + | static void | |
| 91 | + | gb202_head_state(struct nvkm_head *head, struct nvkm_head_state *state) | |
| 92 | + | { | |
| 93 | + | struct nvkm_device *device = head->disp->engine.subdev.device; | |
| 94 | + | const u32 hoff = (state == &head->arm) * 0x8000 + head->id * 0x800; | |
| 95 | + | u32 data; | |
| 96 | + | ||
| 97 | + | data = nvkm_rd32(device, 0x682064 + hoff); | |
| 98 | + | state->vtotal = (data & 0xffff0000) >> 16; | |
| 99 | + | state->htotal = (data & 0x0000ffff); | |
| 100 | + | data = nvkm_rd32(device, 0x682068 + hoff); | |
| 101 | + | state->vsynce = (data & 0xffff0000) >> 16; | |
| 102 | + | state->hsynce = (data & 0x0000ffff); | |
| 103 | + | data = nvkm_rd32(device, 0x68206c + hoff); | |
| 104 | + | state->vblanke = (data & 0xffff0000) >> 16; | |
| 105 | + | state->hblanke = (data & 0x0000ffff); | |
| 106 | + | data = nvkm_rd32(device, 0x682070 + hoff); | |
| 107 | + | state->vblanks = (data & 0xffff0000) >> 16; | |
| 108 | + | state->hblanks = (data & 0x0000ffff); | |
| 109 | + | /* Bit 31 is ADJ1000DIV1001, not a HERTZ bit. We don't have enough bits | |
| 110 | + | * to add the full clock in hz on Blackwell (35 bits), but state->hz | |
| 111 | + | * is unused and obsolete under GSP so this is fine. | |
| 112 | + | */ | |
| 113 | + | state->hz = nvkm_rd32(device, 0x68200c + hoff) & 0x7fffffff; | |
| 114 | + | ||
| 115 | + | data = nvkm_rd32(device, 0x682004 + hoff); | |
| 116 | + | switch ((data & 0x000000f0) >> 4) { | |
| 117 | + | case 5: state->or.depth = 30; break; | |
| 118 | + | case 4: state->or.depth = 24; break; | |
| 119 | + | case 1: state->or.depth = 18; break; | |
| 120 | + | default: | |
| 121 | + | state->or.depth = 18; | |
| 122 | + | WARN_ON(1); | |
| 123 | + | break; | |
| 124 | + | } | |
| 125 | + | } | |
| 126 | + | ||
| 127 | + | /* NVD5.0 (GB20x and later) moved the RM head-timing interrupt enable to | |
| 128 | + | * the low-latency vector's EN1 block. The event latch is unchanged. | |
| 129 | + | */ | |
| 130 | + | static void | |
| 131 | + | gb202_head_vblank_put(struct nvkm_head *head) | |
| 132 | + | { | |
| 133 | + | struct nvkm_device *device = head->disp->engine.subdev.device; | |
| 134 | + | ||
| 135 | + | nvkm_mask(device, 0x611ef0 + (head->id * 4), 0x00000002, 0x00000000); | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | static void | |
| 139 | + | gb202_head_vblank_get(struct nvkm_head *head) | |
| 140 | + | { | |
| 141 | + | struct nvkm_device *device = head->disp->engine.subdev.device; | |
| 142 | + | ||
| 143 | + | nvkm_wr32(device, 0x611800 + (head->id * 4), 0x00000002); | |
| 144 | + | nvkm_mask(device, 0x611ef0 + (head->id * 4), 0x00000002, 0x00000002); | |
| 145 | + | } | |
| 146 | + | ||
| 147 | + | static irqreturn_t | |
| 148 | + | gb202_disp_intr(struct nvkm_inth *inth) | |
| 149 | + | { | |
| 150 | + | struct nvkm_disp *disp = container_of(inth, typeof(*disp), engine.subdev.inth); | |
| 151 | + | irqreturn_t ret = tu102_disp_intr(inth); | |
| 152 | + | ||
| 153 | + | /* The FE interrupt vectors are message-based on NVD5.0. Re-arm the | |
| 154 | + | * low-latency vector so it fires again for any event that latched | |
| 155 | + | * while we were servicing. | |
| 156 | + | */ | |
| 157 | + | nvkm_wr32(disp->engine.subdev.device, 0x611f34, 0x00000001); | |
| 158 | + | return ret; | |
| 159 | + | } | |
| 160 | + | ||
| 161 | + | static const struct nvkm_head_func | |
| 162 | + | gb202_gsp_head = { | |
| 163 | + | .state = gb202_head_state, | |
| 164 | + | .rgpos = gv100_head_rgpos, | |
| 165 | + | .vblank_get = gb202_head_vblank_get, | |
| 166 | + | .vblank_put = gb202_head_vblank_put, | |
| 167 | + | }; | |
| 168 | + | ||
| 169 | + | /* GB20x is GSP-only. This table supplies the register programming the | |
| 170 | + | * GSP-RM display path needs from the chip. | |
| 171 | + | */ | |
| 172 | + | static const struct nvkm_disp_func | |
| 173 | + | gb202_gsp_disp = { | |
| 174 | + | .uevent = &gv100_disp_chan_uevent, | |
| 175 | + | .ramht_size = 0x2000, | |
| 176 | + | /* Head timing arrives on the dedicated low-latency vector. */ | |
| 177 | + | .gsp.intr = gb202_disp_intr, | |
| 178 | + | .gsp.intr_low_latency = true, | |
| 179 | + | .gsp.head = &gb202_gsp_head, | |
| 180 | + | .gsp.hdmi_gcp = gb202_sor_hdmi_gcp, | |
| 181 | + | /* The legacy AVI unit is unchanged on GB20x. */ | |
| 182 | + | .gsp.hdmi_infoframe_avi = gv100_sor_hdmi_infoframe_avi, | |
| 183 | + | .gsp.hdmi_infoframe_vsi = gb202_sor_hdmi_infoframe_vsi, | |
| 184 | + | }; | |
| 185 | + | ||
| 186 | + | int | |
| 187 | + | gb202_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, | |
| 188 | + | struct nvkm_disp **pdisp) | |
| 189 | + | { | |
| 190 | + | return r535_disp_new(&gb202_gsp_disp, device, type, inst, pdisp); | |
| 191 | + | } | |
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/head.h
| @@ -56,6 +56,8 @@ int gv100_head_new(struct nvkm_disp *, int id); | |||
| 56 | 56 | void gv100_head_state(struct nvkm_head *head, struct nvkm_head_state *state); | |
| 57 | 57 | void gv100_head_rgpos(struct nvkm_head *head, u16 *hline, u16 *vline); | |
| 58 | 58 | ||
| 59 | + | extern const struct nvkm_head_func tu102_gsp_head; | |
| 60 | + | ||
| 59 | 61 | #define HEAD_MSG(h,l,f,a...) do { \ | |
| 60 | 62 | struct nvkm_head *_h = (h); \ | |
| 61 | 63 | nvkm_##l(&_h->disp->engine.subdev, "head-%d: "f"\n", _h->id, ##a); \ | |
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h
| @@ -194,6 +194,7 @@ void gv100_sor_dp_audio_sym(struct nvkm_ior *, int, u16, u32); | |||
| 194 | 194 | void gv100_sor_dp_watermark(struct nvkm_ior *, int, u8); | |
| 195 | 195 | extern const struct nvkm_ior_func_hda gv100_sor_hda; | |
| 196 | 196 | ||
| 197 | + | void tu102_sor_hdmi_gcp(struct nvkm_ior *, int, bool); | |
| 197 | 198 | void tu102_sor_dp_vcpi(struct nvkm_ior *, int, u8, u8, u16, u16); | |
| 198 | 199 | ||
| 199 | 200 | int nv50_pior_cnt(struct nvkm_disp *, unsigned long *); | |
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
| @@ -5,6 +5,8 @@ | |||
| 5 | 5 | #include <engine/disp.h> | |
| 6 | 6 | #include <core/enum.h> | |
| 7 | 7 | struct nvkm_head; | |
| 8 | + | struct nvkm_head_func; | |
| 9 | + | struct nvkm_ior; | |
| 8 | 10 | struct nvkm_outp; | |
| 9 | 11 | struct dcb_output; | |
| 10 | 12 | ||
| @@ -34,6 +36,20 @@ struct nvkm_disp_func { | |||
| 34 | 36 | int (*new)(struct nvkm_disp *, int id); | |
| 35 | 37 | } wndw, head, dac, sor, pior; | |
| 36 | 38 | ||
| 39 | + | /* Register programming that the GSP-RM display path (rm/r535) needs from | |
| 40 | + | * the chip, everything else on that path goes through RM. The hooks are | |
| 41 | + | * called unconditionally and the head table is handed to nvkm_head_new_(). | |
| 42 | + | */ | |
| 43 | + | struct { | |
| 44 | + | irqreturn_t (*intr)(struct nvkm_inth *); | |
| 45 | + | /* Head-timing interrupts arrive on a second DISP vector. */ | |
| 46 | + | bool intr_low_latency; | |
| 47 | + | const struct nvkm_head_func *head; | |
| 48 | + | void (*hdmi_gcp)(struct nvkm_ior *, int head, bool enable); | |
| 49 | + | void (*hdmi_infoframe_avi)(struct nvkm_ior *, int head, void *data, u32 size); | |
| 50 | + | void (*hdmi_infoframe_vsi)(struct nvkm_ior *, int head, void *data, u32 size); | |
| 51 | + | } gsp; | |
| 52 | + | ||
| 37 | 53 | u16 ramht_size; | |
| 38 | 54 | ||
| 39 | 55 | struct nvkm_sclass root; | |
| @@ -72,6 +88,7 @@ int gv100_disp_wndw_cnt(struct nvkm_disp *, unsigned long *); | |||
| 72 | 88 | int gv100_disp_caps_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **); | |
| 73 | 89 | ||
| 74 | 90 | int tu102_disp_init(struct nvkm_disp *); | |
| 91 | + | irqreturn_t tu102_disp_intr(struct nvkm_inth *); | |
| 75 | 92 | ||
| 76 | 93 | void nv50_disp_dptmds_war_2(struct nvkm_disp *, struct dcb_output *); | |
| 77 | 94 | void nv50_disp_dptmds_war_3(struct nvkm_disp *, struct dcb_output *); | |
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c
| @@ -30,6 +30,21 @@ | |||
| 30 | 30 | ||
| 31 | 31 | #include <nvif/class.h> | |
| 32 | 32 | ||
| 33 | + | /* General Control Packet: bracket an audio enable/disable with AVMute | |
| 34 | + | * through the legacy GCP SF unit. Used by the GSP-RM path, which sends the | |
| 35 | + | * equivalent packet via RM as well but keeps the direct write in sync. | |
| 36 | + | */ | |
| 37 | + | void | |
| 38 | + | tu102_sor_hdmi_gcp(struct nvkm_ior *sor, int head, bool enable) | |
| 39 | + | { | |
| 40 | + | struct nvkm_device *device = sor->disp->engine.subdev.device; | |
| 41 | + | const u32 hdmi = head * 0x400; | |
| 42 | + | ||
| 43 | + | nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000000); | |
| 44 | + | nvkm_wr32(device, 0x6f00cc + hdmi, !enable ? 0x00000001 : 0x00000010); | |
| 45 | + | nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000001); | |
| 46 | + | } | |
| 47 | + | ||
| 33 | 48 | void | |
| 34 | 49 | tu102_sor_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned) | |
| 35 | 50 | { | |
| @@ -104,6 +119,64 @@ tu102_sor_new(struct nvkm_disp *disp, int id) | |||
| 104 | 119 | return nvkm_ior_new_(&tu102_sor, disp, SOR, id, hda & BIT(id)); | |
| 105 | 120 | } | |
| 106 | 121 | ||
| 122 | + | /* The GSP-RM display path leaves head-timing (vblank) interrupts and their | |
| 123 | + | * enables to us. These program the RM head-timing line (bit 1 of the | |
| 124 | + | * per-head enable, not the bit nvkm's own gv100 path uses). | |
| 125 | + | */ | |
| 126 | + | static void | |
| 127 | + | tu102_head_vblank_put(struct nvkm_head *head) | |
| 128 | + | { | |
| 129 | + | struct nvkm_device *device = head->disp->engine.subdev.device; | |
| 130 | + | ||
| 131 | + | nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000002, 0x00000000); | |
| 132 | + | } | |
| 133 | + | ||
| 134 | + | static void | |
| 135 | + | tu102_head_vblank_get(struct nvkm_head *head) | |
| 136 | + | { | |
| 137 | + | struct nvkm_device *device = head->disp->engine.subdev.device; | |
| 138 | + | ||
| 139 | + | nvkm_wr32(device, 0x611800 + (head->id * 4), 0x00000002); | |
| 140 | + | nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000002, 0x00000002); | |
| 141 | + | } | |
| 142 | + | ||
| 143 | + | const struct nvkm_head_func | |
| 144 | + | tu102_gsp_head = { | |
| 145 | + | .state = gv100_head_state, | |
| 146 | + | .rgpos = gv100_head_rgpos, | |
| 147 | + | .vblank_get = tu102_head_vblank_get, | |
| 148 | + | .vblank_put = tu102_head_vblank_put, | |
| 149 | + | }; | |
| 150 | + | ||
| 151 | + | static void | |
| 152 | + | tu102_disp_intr_head_timing(struct nvkm_disp *disp, int head) | |
| 153 | + | { | |
| 154 | + | struct nvkm_subdev *subdev = &disp->engine.subdev; | |
| 155 | + | struct nvkm_device *device = subdev->device; | |
| 156 | + | u32 stat = nvkm_rd32(device, 0x611c00 + (head * 0x04)); | |
| 157 | + | ||
| 158 | + | if (stat & 0x00000002) { | |
| 159 | + | nvkm_disp_vblank(disp, head); | |
| 160 | + | ||
| 161 | + | nvkm_wr32(device, 0x611800 + (head * 0x04), 0x00000002); | |
| 162 | + | } | |
| 163 | + | } | |
| 164 | + | ||
| 165 | + | irqreturn_t | |
| 166 | + | tu102_disp_intr(struct nvkm_inth *inth) | |
| 167 | + | { | |
| 168 | + | struct nvkm_disp *disp = container_of(inth, typeof(*disp), engine.subdev.inth); | |
| 169 | + | struct nvkm_subdev *subdev = &disp->engine.subdev; | |
| 170 | + | struct nvkm_device *device = subdev->device; | |
| 171 | + | unsigned long mask = nvkm_rd32(device, 0x611ec0) & 0x000000ff; | |
| 172 | + | int head; | |
| 173 | + | ||
| 174 | + | for_each_set_bit(head, &mask, 8) | |
| 175 | + | tu102_disp_intr_head_timing(disp, head); | |
| 176 | + | ||
| 177 | + | return IRQ_HANDLED; | |
| 178 | + | } | |
| 179 | + | ||
| 107 | 180 | int | |
| 108 | 181 | tu102_disp_init(struct nvkm_disp *disp) | |
| 109 | 182 | { | |
| @@ -230,12 +303,23 @@ tu102_disp = { | |||
| 230 | 303 | }, | |
| 231 | 304 | }; | |
| 232 | 305 | ||
| 306 | + | static const struct nvkm_disp_func | |
| 307 | + | tu102_gsp_disp = { | |
| 308 | + | .uevent = &gv100_disp_chan_uevent, | |
| 309 | + | .ramht_size = 0x2000, | |
| 310 | + | .gsp.intr = tu102_disp_intr, | |
| 311 | + | .gsp.head = &tu102_gsp_head, | |
| 312 | + | .gsp.hdmi_gcp = tu102_sor_hdmi_gcp, | |
| 313 | + | .gsp.hdmi_infoframe_avi = gv100_sor_hdmi_infoframe_avi, | |
| 314 | + | .gsp.hdmi_infoframe_vsi = gv100_sor_hdmi_infoframe_vsi, | |
| 315 | + | }; | |
| 316 | + | ||
| 233 | 317 | int | |
| 234 | 318 | tu102_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, | |
| 235 | 319 | struct nvkm_disp **pdisp) | |
| 236 | 320 | { | |
| 237 | 321 | if (nvkm_gsp_rm(device->gsp)) | |
| 238 | - | return r535_disp_new(&tu102_disp, device, type, inst, pdisp); | |
| 322 | + | return r535_disp_new(&tu102_gsp_disp, device, type, inst, pdisp); | |
| 239 | 323 | ||
| 240 | 324 | return nvkm_disp_new_(&tu102_disp, device, type, inst, pdisp); | |
| 241 | 325 | } | |
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
| @@ -253,8 +253,7 @@ nvkm_uoutp_mthd_hdmi(struct nvkm_outp *outp, void *argv, u32 argc) | |||
| 253 | 253 | ||
| 254 | 254 | if (!ior->func->hdmi || | |
| 255 | 255 | args->v0.max_ac_packet > 0x1f || | |
| 256 | - | args->v0.rekey > 0x7f || | |
| 257 | - | (args->v0.scdc && !ior->func->hdmi->scdc)) | |
| 256 | + | args->v0.rekey > 0x7f) | |
| 258 | 257 | return -EINVAL; | |
| 259 | 258 | ||
| 260 | 259 | if (!args->v0.enable) { | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
| @@ -199,16 +199,18 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei) | |||
| 199 | 199 | } | |
| 200 | 200 | ||
| 201 | 201 | if (volt) { | |
| 202 | - | ret = nvkm_volt_set_id(volt, cstate->voltage, | |
| 203 | - | pstate->base.voltage, clk->temp, -1); | |
| 204 | - | if (ret && ret != -ENODEV) | |
| 205 | - | nvkm_error(subdev, "failed to lower voltage: %d\n", ret); | |
| 202 | + | int err = nvkm_volt_set_id(volt, cstate->voltage, | |
| 203 | + | pstate->base.voltage, clk->temp, -1); | |
| 204 | + | ||
| 205 | + | if (err && err != -ENODEV) | |
| 206 | + | nvkm_error(subdev, "failed to lower voltage: %d\n", err); | |
| 206 | 207 | } | |
| 207 | 208 | ||
| 208 | 209 | if (therm) { | |
| 209 | - | ret = nvkm_therm_cstate(therm, pstate->fanspeed, -1); | |
| 210 | - | if (ret && ret != -ENODEV) | |
| 211 | - | nvkm_error(subdev, "failed to lower fan speed: %d\n", ret); | |
| 210 | + | int err = nvkm_therm_cstate(therm, pstate->fanspeed, -1); | |
| 211 | + | ||
| 212 | + | if (err && err != -ENODEV) | |
| 213 | + | nvkm_error(subdev, "failed to lower fan speed: %d\n", err); | |
| 212 | 214 | } | |
| 213 | 215 | ||
| 214 | 216 | return ret; | |
| @@ -270,13 +272,19 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei) | |||
| 270 | 272 | struct nvkm_fb *fb = subdev->device->fb; | |
| 271 | 273 | struct nvkm_pci *pci = subdev->device->pci; | |
| 272 | 274 | struct nvkm_pstate *pstate; | |
| 275 | + | bool found = false; | |
| 273 | 276 | int ret, idx = 0; | |
| 274 | 277 | ||
| 275 | 278 | list_for_each_entry(pstate, &clk->states, head) { | |
| 276 | - | if (idx++ == pstatei) | |
| 279 | + | if (idx++ == pstatei) { | |
| 280 | + | found = true; | |
| 277 | 281 | break; | |
| 282 | + | } | |
| 278 | 283 | } | |
| 279 | 284 | ||
| 285 | + | if (!found) | |
| 286 | + | return -EINVAL; | |
| 287 | + | ||
| 280 | 288 | nvkm_debug(subdev, "setting performance state %d\n", pstatei); | |
| 281 | 289 | clk->pstate = pstatei; | |
| 282 | 290 | ||
| @@ -473,6 +481,7 @@ static int | |||
| 473 | 481 | nvkm_clk_ustate_update(struct nvkm_clk *clk, int req) | |
| 474 | 482 | { | |
| 475 | 483 | struct nvkm_pstate *pstate; | |
| 484 | + | bool found = false; | |
| 476 | 485 | int i = 0; | |
| 477 | 486 | ||
| 478 | 487 | if (!clk->allow_reclock) | |
| @@ -480,12 +489,14 @@ nvkm_clk_ustate_update(struct nvkm_clk *clk, int req) | |||
| 480 | 489 | ||
| 481 | 490 | if (req != -1 && req != -2) { | |
| 482 | 491 | list_for_each_entry(pstate, &clk->states, head) { | |
| 483 | - | if (pstate->pstate == req) | |
| 492 | + | if (pstate->pstate == req) { | |
| 493 | + | found = true; | |
| 484 | 494 | break; | |
| 495 | + | } | |
| 485 | 496 | i++; | |
| 486 | 497 | } | |
| 487 | 498 | ||
| 488 | - | if (pstate->pstate != req) | |
| 499 | + | if (!found) | |
| 489 | 500 | return -EINVAL; | |
| 490 | 501 | req = i; | |
| 491 | 502 | } | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c
| @@ -51,6 +51,8 @@ nv1a_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram) | |||
| 51 | 51 | mib = ((mem >> 4) & 127) + 1; | |
| 52 | 52 | } | |
| 53 | 53 | ||
| 54 | + | pci_dev_put(bridge); | |
| 55 | + | ||
| 54 | 56 | return nvkm_ram_new_(&nv04_ram_func, fb, NVKM_RAM_TYPE_STOLEN, | |
| 55 | 57 | mib * 1024 * 1024, pram); | |
| 56 | 58 | } | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/base.c
| @@ -20,6 +20,7 @@ | |||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. | |
| 21 | 21 | */ | |
| 22 | 22 | #include "priv.h" | |
| 23 | + | #include <nvif/cl0080.h> | |
| 23 | 24 | ||
| 24 | 25 | int | |
| 25 | 26 | nvkm_gsp_intr_nonstall(struct nvkm_gsp *gsp, enum nvkm_subdev_type type, int inst) | |
| @@ -47,6 +48,15 @@ nvkm_gsp_intr_stall(struct nvkm_gsp *gsp, enum nvkm_subdev_type type, int inst) | |||
| 47 | 48 | return -ENOENT; | |
| 48 | 49 | } | |
| 49 | 50 | ||
| 51 | + | int | |
| 52 | + | nvkm_gsp_gcx_ready(struct nvkm_gsp *gsp) | |
| 53 | + | { | |
| 54 | + | if (!gsp->rm->api->gsp->gcx_ready) | |
| 55 | + | return NV_DEVICE_GC6_READY | NV_DEVICE_GCOFF_READY; | |
| 56 | + | ||
| 57 | + | return gsp->rm->api->gsp->gcx_ready(gsp); | |
| 58 | + | } | |
| 59 | + | ||
| 50 | 60 | static int | |
| 51 | 61 | nvkm_gsp_fini(struct nvkm_subdev *subdev, enum nvkm_suspend_state suspend) | |
| 52 | 62 | { | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/priv.h
| @@ -93,6 +93,7 @@ void r535_gsp_dtor(struct nvkm_gsp *); | |||
| 93 | 93 | int r535_gsp_oneinit(struct nvkm_gsp *); | |
| 94 | 94 | int r535_gsp_init(struct nvkm_gsp *); | |
| 95 | 95 | int r535_gsp_fini(struct nvkm_gsp *, enum nvkm_suspend_state suspend); | |
| 96 | + | int r535_gsp_gcx_ready(struct nvkm_gsp *gsp); | |
| 96 | 97 | ||
| 97 | 98 | int nvkm_gsp_new_(const struct nvkm_gsp_fwif *, struct nvkm_device *, enum nvkm_subdev_type, int, | |
| 98 | 99 | struct nvkm_gsp **); | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
| @@ -400,16 +400,16 @@ r535_sor_dp_audio(struct nvkm_ior *sor, int head, bool enable) | |||
| 400 | 400 | r535_sor_dp_audio_mute(sor, false); | |
| 401 | 401 | } | |
| 402 | 402 | ||
| 403 | - | static void | |
| 404 | - | r535_sor_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn) | |
| 403 | + | static int | |
| 404 | + | r535_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn) | |
| 405 | 405 | { | |
| 406 | 406 | struct nvkm_disp *disp = sor->disp; | |
| 407 | 407 | struct NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS *ctrl; | |
| 408 | 408 | ||
| 409 | 409 | ctrl = nvkm_gsp_rm_ctrl_get(&disp->rm.objcom, | |
| 410 | 410 | NV0073_CTRL_CMD_DP_CONFIG_STREAM, sizeof(*ctrl)); | |
| 411 | - | if (WARN_ON(IS_ERR(ctrl))) | |
| 412 | - | return; | |
| 411 | + | if (IS_ERR(ctrl)) | |
| 412 | + | return PTR_ERR(ctrl); | |
| 413 | 413 | ||
| 414 | 414 | ctrl->subDeviceInstance = 0; | |
| 415 | 415 | ctrl->head = head; | |
| @@ -429,12 +429,20 @@ r535_sor_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u | |||
| 429 | 429 | ctrl->MST.sendACT = 0; | |
| 430 | 430 | ctrl->MST.singleHeadMSTPipeline = 0; | |
| 431 | 431 | ctrl->MST.bEnableAudioOverRightPanel = 0; | |
| 432 | - | WARN_ON(nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl)); | |
| 432 | + | return nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl); | |
| 433 | + | } | |
| 434 | + | ||
| 435 | + | static void | |
| 436 | + | r535_sor_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn) | |
| 437 | + | { | |
| 438 | + | const struct nvkm_rm_api *rmapi = sor->disp->engine.subdev.device->gsp->rm->api; | |
| 439 | + | ||
| 440 | + | WARN_ON(rmapi->disp->dp.vcpi(sor, head, slot, slot_nr, pbn, aligned_pbn)); | |
| 433 | 441 | } | |
| 434 | 442 | ||
| 435 | 443 | static int | |
| 436 | - | r535_sor_dp_sst(struct nvkm_ior *sor, int head, bool ef, | |
| 437 | - | u32 watermark, u32 hblanksym, u32 vblanksym) | |
| 444 | + | r535_dp_sst(struct nvkm_ior *sor, int head, bool ef, | |
| 445 | + | u32 watermark, u32 hblanksym, u32 vblanksym) | |
| 438 | 446 | { | |
| 439 | 447 | struct nvkm_disp *disp = sor->disp; | |
| 440 | 448 | struct NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS *ctrl; | |
| @@ -461,6 +469,15 @@ r535_sor_dp_sst(struct nvkm_ior *sor, int head, bool ef, | |||
| 461 | 469 | return nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl); | |
| 462 | 470 | } | |
| 463 | 471 | ||
| 472 | + | static int | |
| 473 | + | r535_sor_dp_sst(struct nvkm_ior *sor, int head, bool ef, | |
| 474 | + | u32 watermark, u32 hblanksym, u32 vblanksym) | |
| 475 | + | { | |
| 476 | + | const struct nvkm_rm_api *rmapi = sor->disp->engine.subdev.device->gsp->rm->api; | |
| 477 | + | ||
| 478 | + | return rmapi->disp->dp.sst(sor, head, ef, watermark, hblanksym, vblanksym); | |
| 479 | + | } | |
| 480 | + | ||
| 464 | 481 | static const struct nvkm_ior_func_dp | |
| 465 | 482 | r535_sor_dp = { | |
| 466 | 483 | .sst = r535_sor_dp_sst, | |
| @@ -545,16 +562,21 @@ r535_sor_hdmi_ctrl_audio(struct nvkm_outp *outp, bool enable) | |||
| 545 | 562 | static void | |
| 546 | 563 | r535_sor_hdmi_audio(struct nvkm_ior *sor, int head, bool enable) | |
| 547 | 564 | { | |
| 548 | - | struct nvkm_device *device = sor->disp->engine.subdev.device; | |
| 549 | - | const u32 hdmi = head * 0x400; | |
| 550 | - | ||
| 551 | 565 | r535_sor_hdmi_ctrl_audio(sor->asy.outp, enable); | |
| 552 | 566 | r535_sor_hdmi_ctrl_audio_mute(sor->asy.outp, !enable); | |
| 567 | + | sor->disp->func->gsp.hdmi_gcp(sor, head, enable); | |
| 568 | + | } | |
| 569 | + | ||
| 570 | + | static void | |
| 571 | + | r535_sor_hdmi_infoframe_avi(struct nvkm_ior *sor, int head, void *data, u32 size) | |
| 572 | + | { | |
| 573 | + | sor->disp->func->gsp.hdmi_infoframe_avi(sor, head, data, size); | |
| 574 | + | } | |
| 553 | 575 | ||
| 554 | - | /* General Control (GCP). */ | |
| 555 | - | nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000000); | |
| 556 | - | nvkm_wr32(device, 0x6f00cc + hdmi, !enable ? 0x00000001 : 0x00000010); | |
| 557 | - | nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000001); | |
| 576 | + | static void | |
| 577 | + | r535_sor_hdmi_infoframe_vsi(struct nvkm_ior *sor, int head, void *data, u32 size) | |
| 578 | + | { | |
| 579 | + | sor->disp->func->gsp.hdmi_infoframe_vsi(sor, head, data, size); | |
| 558 | 580 | } | |
| 559 | 581 | ||
| 560 | 582 | static void | |
| @@ -582,8 +604,8 @@ r535_sor_hdmi = { | |||
| 582 | 604 | .ctrl = r535_sor_hdmi_ctrl, | |
| 583 | 605 | .scdc = r535_sor_hdmi_scdc, | |
| 584 | 606 | /*TODO: SF_USER -> KMS. */ | |
| 585 | - | .infoframe_avi = gv100_sor_hdmi_infoframe_avi, | |
| 586 | - | .infoframe_vsi = gv100_sor_hdmi_infoframe_vsi, | |
| 607 | + | .infoframe_avi = r535_sor_hdmi_infoframe_avi, | |
| 608 | + | .infoframe_vsi = r535_sor_hdmi_infoframe_vsi, | |
| 587 | 609 | .audio = r535_sor_hdmi_audio, | |
| 588 | 610 | }; | |
| 589 | 611 | ||
| @@ -608,31 +630,6 @@ r535_sor_cnt(struct nvkm_disp *disp, unsigned long *pmask) | |||
| 608 | 630 | return 4; | |
| 609 | 631 | } | |
| 610 | 632 | ||
| 611 | - | static void | |
| 612 | - | r535_head_vblank_put(struct nvkm_head *head) | |
| 613 | - | { | |
| 614 | - | struct nvkm_device *device = head->disp->engine.subdev.device; | |
| 615 | - | ||
| 616 | - | nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000002, 0x00000000); | |
| 617 | - | } | |
| 618 | - | ||
| 619 | - | static void | |
| 620 | - | r535_head_vblank_get(struct nvkm_head *head) | |
| 621 | - | { | |
| 622 | - | struct nvkm_device *device = head->disp->engine.subdev.device; | |
| 623 | - | ||
| 624 | - | nvkm_wr32(device, 0x611800 + (head->id * 4), 0x00000002); | |
| 625 | - | nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000002, 0x00000002); | |
| 626 | - | } | |
| 627 | - | ||
| 628 | - | static const struct nvkm_head_func | |
| 629 | - | r535_head = { | |
| 630 | - | .state = gv100_head_state, | |
| 631 | - | .rgpos = gv100_head_rgpos, | |
| 632 | - | .vblank_get = r535_head_vblank_get, | |
| 633 | - | .vblank_put = r535_head_vblank_put, | |
| 634 | - | }; | |
| 635 | - | ||
| 636 | 633 | static struct nvkm_conn * | |
| 637 | 634 | r535_conn_new(struct nvkm_disp *disp, u32 id) | |
| 638 | 635 | { | |
| @@ -1404,35 +1401,6 @@ static const struct nvkm_event_func | |||
| 1404 | 1401 | r535_disp_event = { | |
| 1405 | 1402 | }; | |
| 1406 | 1403 | ||
| 1407 | - | static void | |
| 1408 | - | r535_disp_intr_head_timing(struct nvkm_disp *disp, int head) | |
| 1409 | - | { | |
| 1410 | - | struct nvkm_subdev *subdev = &disp->engine.subdev; | |
| 1411 | - | struct nvkm_device *device = subdev->device; | |
| 1412 | - | u32 stat = nvkm_rd32(device, 0x611c00 + (head * 0x04)); | |
| 1413 | - | ||
| 1414 | - | if (stat & 0x00000002) { | |
| 1415 | - | nvkm_disp_vblank(disp, head); | |
| 1416 | - | ||
| 1417 | - | nvkm_wr32(device, 0x611800 + (head * 0x04), 0x00000002); | |
| 1418 | - | } | |
| 1419 | - | } | |
| 1420 | - | ||
| 1421 | - | static irqreturn_t | |
| 1422 | - | r535_disp_intr(struct nvkm_inth *inth) | |
| 1423 | - | { | |
| 1424 | - | struct nvkm_disp *disp = container_of(inth, typeof(*disp), engine.subdev.inth); | |
| 1425 | - | struct nvkm_subdev *subdev = &disp->engine.subdev; | |
| 1426 | - | struct nvkm_device *device = subdev->device; | |
| 1427 | - | unsigned long mask = nvkm_rd32(device, 0x611ec0) & 0x000000ff; | |
| 1428 | - | int head; | |
| 1429 | - | ||
| 1430 | - | for_each_set_bit(head, &mask, 8) | |
| 1431 | - | r535_disp_intr_head_timing(disp, head); | |
| 1432 | - | ||
| 1433 | - | return IRQ_HANDLED; | |
| 1434 | - | } | |
| 1435 | - | ||
| 1436 | 1404 | static void | |
| 1437 | 1405 | r535_disp_fini(struct nvkm_disp *disp, bool suspend) | |
| 1438 | 1406 | { | |
| @@ -1659,7 +1627,7 @@ r535_disp_oneinit(struct nvkm_disp *disp) | |||
| 1659 | 1627 | nvkm_gsp_rm_ctrl_done(&disp->rm.objcom, ctrl); | |
| 1660 | 1628 | ||
| 1661 | 1629 | for_each_set_bit(i, &disp->head.mask, disp->head.nr) { | |
| 1662 | - | ret = nvkm_head_new_(&r535_head, disp, i); | |
| 1630 | + | ret = nvkm_head_new_(disp->func->gsp.head, disp, i); | |
| 1663 | 1631 | if (ret) | |
| 1664 | 1632 | return ret; | |
| 1665 | 1633 | } | |
| @@ -1703,12 +1671,20 @@ r535_disp_oneinit(struct nvkm_disp *disp) | |||
| 1703 | 1671 | if (ret) | |
| 1704 | 1672 | return ret; | |
| 1705 | 1673 | ||
| 1706 | - | ret = nvkm_gsp_intr_stall(gsp, disp->engine.subdev.type, disp->engine.subdev.inst); | |
| 1674 | + | /* Chips that raise head-timing interrupts on a separate low-latency | |
| 1675 | + | * vector report it as a second DISP interrupt table entry, exposed | |
| 1676 | + | * as instance 1 by the RM engine-index translation (see | |
| 1677 | + | * r570_gsp_xlat_mc_engine_idx()). Their high-latency vector | |
| 1678 | + | * (instance 0) is left unhandled as no event nouveau enables is | |
| 1679 | + | * routed to it, and without a handler it stays masked. | |
| 1680 | + | */ | |
| 1681 | + | ret = nvkm_gsp_intr_stall(gsp, disp->engine.subdev.type, | |
| 1682 | + | disp->func->gsp.intr_low_latency ? 1 : disp->engine.subdev.inst); | |
| 1707 | 1683 | if (ret < 0) | |
| 1708 | 1684 | return ret; | |
| 1709 | 1685 | ||
| 1710 | 1686 | ret = nvkm_inth_add(&device->vfn->intr, ret, NVKM_INTR_PRIO_NORMAL, &disp->engine.subdev, | |
| 1711 | - | r535_disp_intr, &disp->engine.subdev.inth); | |
| 1687 | + | disp->func->gsp.intr, &disp->engine.subdev.inth); | |
| 1712 | 1688 | if (ret) | |
| 1713 | 1689 | return ret; | |
| 1714 | 1690 | ||
| @@ -1741,6 +1717,7 @@ r535_disp_new(const struct nvkm_disp_func *hw, struct nvkm_device *device, | |||
| 1741 | 1717 | rm->uevent = hw->uevent; | |
| 1742 | 1718 | rm->sor.cnt = r535_sor_cnt; | |
| 1743 | 1719 | rm->sor.new = r535_sor_new; | |
| 1720 | + | rm->gsp = hw->gsp; | |
| 1744 | 1721 | rm->ramht_size = hw->ramht_size; | |
| 1745 | 1722 | ||
| 1746 | 1723 | rm->root.oclass = gpu->disp.class.root; | |
| @@ -1782,6 +1759,8 @@ r535_disp = { | |||
| 1782 | 1759 | .dp = { | |
| 1783 | 1760 | .get_caps = r535_dp_get_caps, | |
| 1784 | 1761 | .set_indexed_link_rates = r535_dp_set_indexed_link_rates, | |
| 1762 | + | .sst = r535_dp_sst, | |
| 1763 | + | .vcpi = r535_dp_vcpi, | |
| 1785 | 1764 | }, | |
| 1786 | 1765 | .chan = { | |
| 1787 | 1766 | .set_pushbuf = r535_disp_chan_set_pushbuf, | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/fbsr.c
| @@ -208,7 +208,7 @@ r535_fbsr_resume(struct nvkm_gsp *gsp) | |||
| 208 | 208 | } | |
| 209 | 209 | ||
| 210 | 210 | static int | |
| 211 | - | r535_fbsr_suspend(struct nvkm_gsp *gsp, bool runtime) | |
| 211 | + | r535_fbsr_suspend(struct nvkm_gsp *gsp) | |
| 212 | 212 | { | |
| 213 | 213 | struct nvkm_subdev *subdev = &gsp->subdev; | |
| 214 | 214 | struct nvkm_device *device = subdev->device; | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c
| @@ -1749,7 +1749,7 @@ r535_gsp_fini(struct nvkm_gsp *gsp, enum nvkm_suspend_state suspend) | |||
| 1749 | 1749 | sr->sysmemAddrOfSuspendResumeData = gsp->sr.radix3.lvl0.addr; | |
| 1750 | 1750 | sr->sizeOfSuspendResumeData = len; | |
| 1751 | 1751 | ||
| 1752 | - | ret = rm->api->fbsr->suspend(gsp, suspend == NVKM_RUNTIME_SUSPEND); | |
| 1752 | + | ret = rm->api->fbsr->suspend(gsp); | |
| 1753 | 1753 | if (ret) { | |
| 1754 | 1754 | nvkm_gsp_mem_dtor(&gsp->sr.meta); | |
| 1755 | 1755 | nvkm_gsp_radix3_dtor(gsp, &gsp->sr.radix3); | |
| @@ -1761,8 +1761,12 @@ r535_gsp_fini(struct nvkm_gsp *gsp, enum nvkm_suspend_state suspend) | |||
| 1761 | 1761 | * TODO: Debug the GSP firmware / RPC handling to find out why | |
| 1762 | 1762 | * without this Turing (but none of the other architectures) | |
| 1763 | 1763 | * ends up resetting all channels after resume. | |
| 1764 | + | * Additionally, runtime suspend on other architectures quickly | |
| 1765 | + | * becomes unreliable without this sleep. If you're experiencing | |
| 1766 | + | * issues with runtime suspend, try bumping this delay up and | |
| 1767 | + | * sending a patch if it fixes your GPU. | |
| 1764 | 1768 | */ | |
| 1765 | - | msleep(50); | |
| 1769 | + | msleep(200); | |
| 1766 | 1770 | } | |
| 1767 | 1771 | ||
| 1768 | 1772 | ret = r535_gsp_rpc_unloading_guest_driver(gsp, suspend); | |
| @@ -1778,6 +1782,23 @@ r535_gsp_fini(struct nvkm_gsp *gsp, enum nvkm_suspend_state suspend) | |||
| 1778 | 1782 | return 0; | |
| 1779 | 1783 | } | |
| 1780 | 1784 | ||
| 1785 | + | int | |
| 1786 | + | r535_gsp_get_static_memsys_info(struct nvkm_gsp *gsp) | |
| 1787 | + | { | |
| 1788 | + | NV2080_CTRL_INTERNAL_MEMSYS_GET_STATIC_CONFIG_PARAMS *ctrl; | |
| 1789 | + | ||
| 1790 | + | ctrl = nvkm_gsp_rm_ctrl_rd(&gsp->internal.device.subdevice, | |
| 1791 | + | NV2080_CTRL_CMD_INTERNAL_MEMSYS_GET_STATIC_CONFIG, | |
| 1792 | + | sizeof(*ctrl)); | |
| 1793 | + | if (IS_ERR(ctrl)) | |
| 1794 | + | return PTR_ERR(ctrl); | |
| 1795 | + | ||
| 1796 | + | gsp->memsys.use_raw_mode_comptagline_alloc = ctrl->bUseRawModeComptaglineAllocation; | |
| 1797 | + | ||
| 1798 | + | nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, ctrl); | |
| 1799 | + | return 0; | |
| 1800 | + | } | |
| 1801 | + | ||
| 1781 | 1802 | int | |
| 1782 | 1803 | r535_gsp_init(struct nvkm_gsp *gsp) | |
| 1783 | 1804 | { | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/nvrm/gsp.h
| @@ -782,6 +782,51 @@ typedef struct NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_PARAMS { | |||
| 782 | 782 | ||
| 783 | 783 | #define GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE ((48 << 10) * 2048) // Support 2048 channels | |
| 784 | 784 | ||
| 785 | + | typedef struct NV2080_CTRL_INTERNAL_MEMSYS_GET_STATIC_CONFIG_PARAMS { | |
| 786 | + | /*! Determines if RM should use 1 to 1 Comptagline allocation policy */ | |
| 787 | + | NvBool bOneToOneComptagLineAllocation; | |
| 788 | + | ||
| 789 | + | /*! Determines if RM should use 1 to 4 Comptagline allocation policy */ | |
| 790 | + | NvBool bUseOneToFourComptagLineAllocation; | |
| 791 | + | ||
| 792 | + | /*! Determines if RM should use raw Comptagline allocation policy */ | |
| 793 | + | NvBool bUseRawModeComptaglineAllocation; | |
| 794 | + | ||
| 795 | + | /*! Has COMPBIT_BACKING_SIZE been overridden to zero (i.e. disabled)? */ | |
| 796 | + | NvBool bDisableCompbitBacking; | |
| 797 | + | ||
| 798 | + | /*! Determine if we need to disable post L2 compression */ | |
| 799 | + | NvBool bDisablePostL2Compression; | |
| 800 | + | ||
| 801 | + | /*! Is ECC DRAM feature supported? */ | |
| 802 | + | NvBool bEnabledEccFBPA; | |
| 803 | + | ||
| 804 | + | NvBool bL2PreFill; | |
| 805 | + | ||
| 806 | + | /*! L2 cache size */ | |
| 807 | + | NV_DECLARE_ALIGNED(NvU64 l2CacheSize, 8); | |
| 808 | + | ||
| 809 | + | /*! Indicate whether fpba is present or not */ | |
| 810 | + | NvBool bFbpaPresent; | |
| 811 | + | ||
| 812 | + | /*! Size covered by one comptag */ | |
| 813 | + | NvU32 comprPageSize; | |
| 814 | + | ||
| 815 | + | /*! log32(comprPageSize) */ | |
| 816 | + | NvU32 comprPageShift; | |
| 817 | + | ||
| 818 | + | /*! RAM type */ | |
| 819 | + | NvU32 ramType; | |
| 820 | + | ||
| 821 | + | /*! LTC count */ | |
| 822 | + | NvU32 ltcCount; | |
| 823 | + | ||
| 824 | + | /*! LTS per LTC count */ | |
| 825 | + | NvU32 ltsPerLtcCount; | |
| 826 | + | } NV2080_CTRL_INTERNAL_MEMSYS_GET_STATIC_CONFIG_PARAMS; | |
| 827 | + | ||
| 828 | + | #define NV2080_CTRL_CMD_INTERNAL_MEMSYS_GET_STATIC_CONFIG (0x20800a1c) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_MEMSYS_GET_STATIC_CONFIG_PARAMS_MESSAGE_ID" */ | |
| 829 | + | ||
| 785 | 830 | typedef union rpc_message_rpc_union_field_v03_00 | |
| 786 | 831 | { | |
| 787 | 832 | NvU32 spare; | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/disp.c
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | #include <rm/rm.h> | |
| 6 | 6 | ||
| 7 | 7 | #include <engine/disp.h> | |
| 8 | + | #include <engine/disp/ior.h> | |
| 8 | 9 | #include <engine/disp/outp.h> | |
| 9 | 10 | ||
| 10 | 11 | #include "nvhw/drf.h" | |
| @@ -74,6 +75,67 @@ r570_disp_chan_set_pushbuf(struct nvkm_disp *disp, s32 oclass, int inst, struct | |||
| 74 | 75 | return nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl); | |
| 75 | 76 | } | |
| 76 | 77 | ||
| 78 | + | static int | |
| 79 | + | r570_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn) | |
| 80 | + | { | |
| 81 | + | struct nvkm_disp *disp = sor->disp; | |
| 82 | + | NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS *ctrl; | |
| 83 | + | ||
| 84 | + | ctrl = nvkm_gsp_rm_ctrl_get(&disp->rm.objcom, | |
| 85 | + | NV0073_CTRL_CMD_DP_CONFIG_STREAM, sizeof(*ctrl)); | |
| 86 | + | if (IS_ERR(ctrl)) | |
| 87 | + | return PTR_ERR(ctrl); | |
| 88 | + | ||
| 89 | + | ctrl->subDeviceInstance = 0; | |
| 90 | + | ctrl->head = head; | |
| 91 | + | ctrl->sorIndex = sor->id; | |
| 92 | + | ctrl->dpLink = sor->asy.link == 2; | |
| 93 | + | ctrl->bEnableOverride = 1; | |
| 94 | + | ctrl->bMST = 1; | |
| 95 | + | ctrl->hBlankSym = 0; | |
| 96 | + | ctrl->vBlankSym = 0; | |
| 97 | + | ctrl->colorFormat = 0; | |
| 98 | + | ctrl->bEnableTwoHeadOneOr = 0; | |
| 99 | + | ctrl->singleHeadMultistreamMode = 0; | |
| 100 | + | ctrl->MST.slotStart = slot; | |
| 101 | + | ctrl->MST.slotEnd = slot + slot_nr - 1; | |
| 102 | + | ctrl->MST.PBN = pbn; | |
| 103 | + | ctrl->MST.Timeslice = aligned_pbn; | |
| 104 | + | ctrl->MST.sendACT = 0; | |
| 105 | + | ctrl->MST.singleHeadMSTPipeline = 0; | |
| 106 | + | ctrl->MST.bEnableAudioOverRightPanel = 0; | |
| 107 | + | return nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl); | |
| 108 | + | } | |
| 109 | + | ||
| 110 | + | static int | |
| 111 | + | r570_dp_sst(struct nvkm_ior *sor, int head, bool ef, | |
| 112 | + | u32 watermark, u32 hblanksym, u32 vblanksym) | |
| 113 | + | { | |
| 114 | + | struct nvkm_disp *disp = sor->disp; | |
| 115 | + | NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS *ctrl; | |
| 116 | + | ||
| 117 | + | ctrl = nvkm_gsp_rm_ctrl_get(&disp->rm.objcom, | |
| 118 | + | NV0073_CTRL_CMD_DP_CONFIG_STREAM, sizeof(*ctrl)); | |
| 119 | + | if (IS_ERR(ctrl)) | |
| 120 | + | return PTR_ERR(ctrl); | |
| 121 | + | ||
| 122 | + | ctrl->subDeviceInstance = 0; | |
| 123 | + | ctrl->head = head; | |
| 124 | + | ctrl->sorIndex = sor->id; | |
| 125 | + | ctrl->dpLink = sor->asy.link == 2; | |
| 126 | + | ctrl->bEnableOverride = 1; | |
| 127 | + | ctrl->bMST = 0; | |
| 128 | + | ctrl->hBlankSym = hblanksym; | |
| 129 | + | ctrl->vBlankSym = vblanksym; | |
| 130 | + | ctrl->colorFormat = 0; | |
| 131 | + | ctrl->bEnableTwoHeadOneOr = 0; | |
| 132 | + | ctrl->SST.bEnhancedFraming = ef; | |
| 133 | + | ctrl->SST.tuSize = 64; | |
| 134 | + | ctrl->SST.waterMark = watermark; | |
| 135 | + | ctrl->SST.bEnableAudioOverRightPanel = 0; | |
| 136 | + | return nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl); | |
| 137 | + | } | |
| 138 | + | ||
| 77 | 139 | static int | |
| 78 | 140 | r570_dp_set_indexed_link_rates(struct nvkm_outp *outp) | |
| 79 | 141 | { | |
| @@ -255,6 +317,8 @@ r570_disp = { | |||
| 255 | 317 | .dp = { | |
| 256 | 318 | .get_caps = r570_dp_get_caps, | |
| 257 | 319 | .set_indexed_link_rates = r570_dp_set_indexed_link_rates, | |
| 320 | + | .sst = r570_dp_sst, | |
| 321 | + | .vcpi = r570_dp_vcpi, | |
| 258 | 322 | }, | |
| 259 | 323 | .chan = { | |
| 260 | 324 | .set_pushbuf = r570_disp_chan_set_pushbuf, | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/fbsr.c
| @@ -26,6 +26,52 @@ r570_fbsr_suspend_channels(struct nvkm_gsp *gsp, bool suspend) | |||
| 26 | 26 | return nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl); | |
| 27 | 27 | } | |
| 28 | 28 | ||
| 29 | + | static int | |
| 30 | + | r570_fb_get_compbit_store_size(struct nvkm_gsp *gsp, u64 *size) | |
| 31 | + | { | |
| 32 | + | NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS *ctrl; | |
| 33 | + | ||
| 34 | + | ctrl = nvkm_gsp_rm_ctrl_rd(&gsp->internal.device.object, | |
| 35 | + | NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO, | |
| 36 | + | sizeof(*ctrl)); | |
| 37 | + | if (IS_ERR(ctrl)) | |
| 38 | + | return PTR_ERR(ctrl); | |
| 39 | + | ||
| 40 | + | *size = ctrl->Size; | |
| 41 | + | ||
| 42 | + | nvkm_gsp_rm_ctrl_done(&gsp->internal.device.object, ctrl); | |
| 43 | + | return 0; | |
| 44 | + | } | |
| 45 | + | ||
| 46 | + | static int | |
| 47 | + | r570_memsys_enable_raw_comp_mode(struct nvkm_gsp *gsp, bool enable) | |
| 48 | + | { | |
| 49 | + | NV2080_CTRL_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE_PARAMS *ctrl; | |
| 50 | + | int ret; | |
| 51 | + | ||
| 52 | + | ctrl = nvkm_gsp_rm_ctrl_get(&gsp->internal.device.subdevice, | |
| 53 | + | NV2080_CTRL_CMD_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE, | |
| 54 | + | sizeof(*ctrl)); | |
| 55 | + | if (IS_ERR(ctrl)) | |
| 56 | + | return PTR_ERR(ctrl); | |
| 57 | + | ||
| 58 | + | ctrl->bRawMode = enable; | |
| 59 | + | ||
| 60 | + | ret = nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl); | |
| 61 | + | if (!ret) | |
| 62 | + | nvkm_debug(&gsp->subdev, "memsys: Raw compression mode %s\n", | |
| 63 | + | str_enabled_disabled(enable)); | |
| 64 | + | ||
| 65 | + | return ret; | |
| 66 | + | } | |
| 67 | + | ||
| 68 | + | static bool | |
| 69 | + | r570_need_raw_comp_war(struct nvkm_gsp *gsp, struct nvkm_device *device) | |
| 70 | + | { | |
| 71 | + | return (device->card_type == GA100 || device->card_type == AD100) && | |
| 72 | + | gsp->memsys.use_raw_mode_comptagline_alloc; | |
| 73 | + | } | |
| 74 | + | ||
| 29 | 75 | static void | |
| 30 | 76 | r570_fbsr_resume(struct nvkm_gsp *gsp) | |
| 31 | 77 | { | |
| @@ -33,6 +79,7 @@ r570_fbsr_resume(struct nvkm_gsp *gsp) | |||
| 33 | 79 | struct nvkm_instmem *imem = device->imem; | |
| 34 | 80 | struct nvkm_instobj *iobj; | |
| 35 | 81 | struct nvkm_vmm *vmm; | |
| 82 | + | int ret; | |
| 36 | 83 | ||
| 37 | 84 | /* Restore BAR2 page tables via BAR0 window, and re-enable BAR2. */ | |
| 38 | 85 | list_for_each_entry(iobj, &imem->boot, head) { | |
| @@ -54,6 +101,13 @@ r570_fbsr_resume(struct nvkm_gsp *gsp) | |||
| 54 | 101 | vmm = nvkm_bar_bar1_vmm(device); | |
| 55 | 102 | vmm->func->flush(vmm, 0); | |
| 56 | 103 | ||
| 104 | + | /* Re-enable raw mode if it was previously disabled */ | |
| 105 | + | if (r570_need_raw_comp_war(gsp, device)) { | |
| 106 | + | ret = r570_memsys_enable_raw_comp_mode(gsp, true); | |
| 107 | + | if (ret) | |
| 108 | + | nvkm_error(&gsp->subdev, "Failed to re-enable raw comp mode\n"); | |
| 109 | + | } | |
| 110 | + | ||
| 57 | 111 | /* Resume channel scheduling. */ | |
| 58 | 112 | r570_fbsr_suspend_channels(device->gsp, false); | |
| 59 | 113 | ||
| @@ -62,7 +116,7 @@ r570_fbsr_resume(struct nvkm_gsp *gsp) | |||
| 62 | 116 | } | |
| 63 | 117 | ||
| 64 | 118 | static int | |
| 65 | - | r570_fbsr_init(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size, bool runtime) | |
| 119 | + | r570_fbsr_init(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size) | |
| 66 | 120 | { | |
| 67 | 121 | NV2080_CTRL_INTERNAL_FBSR_INIT_PARAMS *ctrl; | |
| 68 | 122 | struct nvkm_gsp_object memlist; | |
| @@ -81,7 +135,7 @@ r570_fbsr_init(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size, bool runtim | |||
| 81 | 135 | ctrl->hClient = gsp->internal.client.object.handle; | |
| 82 | 136 | ctrl->hSysMem = memlist.handle; | |
| 83 | 137 | ctrl->sysmemAddrOfSuspendResumeData = gsp->sr.meta.addr; | |
| 84 | - | ctrl->bEnteringGcoffState = runtime ? 1 : 0; | |
| 138 | + | ctrl->bEnteringGcoffState = 1; | |
| 85 | 139 | ||
| 86 | 140 | ret = nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl); | |
| 87 | 141 | if (ret) | |
| @@ -92,18 +146,35 @@ r570_fbsr_init(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size, bool runtim | |||
| 92 | 146 | } | |
| 93 | 147 | ||
| 94 | 148 | static int | |
| 95 | - | r570_fbsr_suspend(struct nvkm_gsp *gsp, bool runtime) | |
| 149 | + | r570_fbsr_suspend(struct nvkm_gsp *gsp) | |
| 96 | 150 | { | |
| 97 | 151 | struct nvkm_subdev *subdev = &gsp->subdev; | |
| 98 | 152 | struct nvkm_device *device = subdev->device; | |
| 99 | 153 | struct nvkm_instmem *imem = device->imem; | |
| 100 | 154 | struct nvkm_instobj *iobj; | |
| 101 | - | u64 size; | |
| 155 | + | u64 size, compbit_store_size; | |
| 102 | 156 | int ret; | |
| 103 | 157 | ||
| 104 | 158 | /* Stop channel scheduling. */ | |
| 105 | 159 | r570_fbsr_suspend_channels(gsp, true); | |
| 106 | 160 | ||
| 161 | + | /* Temporarily disable raw mode to prevent FBSR restore operations from corrupting | |
| 162 | + | * compressed surfaces. Required for ampere and ada. | |
| 163 | + | * | |
| 164 | + | * Nvidia bug #3172217 | |
| 165 | + | */ | |
| 166 | + | if (r570_need_raw_comp_war(gsp, device)) { | |
| 167 | + | ret = r570_memsys_enable_raw_comp_mode(gsp, false); | |
| 168 | + | if (ret) | |
| 169 | + | return ret; | |
| 170 | + | } | |
| 171 | + | ||
| 172 | + | ret = r570_fb_get_compbit_store_size(gsp, &compbit_store_size); | |
| 173 | + | if (ret < 0) | |
| 174 | + | return ret; | |
| 175 | + | nvkm_debug(&gsp->subdev, "fbsr: Compbit backing store size: 0x%llx bytes\n", | |
| 176 | + | compbit_store_size); | |
| 177 | + | ||
| 107 | 178 | /* Save BAR2 allocations to system memory. */ | |
| 108 | 179 | list_for_each_entry(iobj, &imem->list, head) { | |
| 109 | 180 | if (iobj->preserve) { | |
| @@ -126,6 +197,8 @@ r570_fbsr_suspend(struct nvkm_gsp *gsp, bool runtime) | |||
| 126 | 197 | size = gsp->fb.heap.size; | |
| 127 | 198 | size += gsp->fb.rsvd_size; | |
| 128 | 199 | size += gsp->fb.bios.vga_workspace.size; | |
| 200 | + | size += compbit_store_size; | |
| 201 | + | ||
| 129 | 202 | nvkm_debug(subdev, "fbsr: size: 0x%llx bytes\n", size); | |
| 130 | 203 | ||
| 131 | 204 | ret = nvkm_gsp_sg(device, size, &gsp->sr.fbsr); | |
| @@ -133,7 +206,7 @@ r570_fbsr_suspend(struct nvkm_gsp *gsp, bool runtime) | |||
| 133 | 206 | return ret; | |
| 134 | 207 | ||
| 135 | 208 | /* Initialise FBSR on RM. */ | |
| 136 | - | ret = r570_fbsr_init(gsp, &gsp->sr.fbsr, size, runtime); | |
| 209 | + | ret = r570_fbsr_init(gsp, &gsp->sr.fbsr, size); | |
| 137 | 210 | if (ret) { | |
| 138 | 211 | nvkm_gsp_sg_free(device, &gsp->sr.fbsr); | |
| 139 | 212 | return ret; | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gsp.c
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | #include "nvrm/gsp.h" | |
| 11 | 11 | #include "nvrm/rpcfn.h" | |
| 12 | 12 | #include "nvrm/msgfn.h" | |
| 13 | + | #include "nvif/cl0080.h" | |
| 13 | 14 | ||
| 14 | 15 | #include <core/pci.h> | |
| 15 | 16 | #include <subdev/pci/priv.h> | |
| @@ -44,6 +45,15 @@ r570_gsp_xlat_mc_engine_idx(u32 mc_engine_idx, enum nvkm_subdev_type *ptype, int | |||
| 44 | 45 | *ptype = NVKM_ENGINE_DISP; | |
| 45 | 46 | *pinst = 0; | |
| 46 | 47 | return true; | |
| 48 | + | case MC_ENGINE_IDX_DISP_LOW: | |
| 49 | + | /* GB20x+ report a separate low-latency display vector, used | |
| 50 | + | * for head-timing interrupts. Expose it as a second DISP | |
| 51 | + | * interrupt instance. r535_disp_oneinit() attaches the | |
| 52 | + | * handler to it when the chip's gsp.intr_low_latency is set. | |
| 53 | + | */ | |
| 54 | + | *ptype = NVKM_ENGINE_DISP; | |
| 55 | + | *pinst = 1; | |
| 56 | + | return true; | |
| 47 | 57 | case MC_ENGINE_IDX_CE0 ... MC_ENGINE_IDX_CE19: | |
| 48 | 58 | *ptype = NVKM_ENGINE_CE; | |
| 49 | 59 | *pinst = mc_engine_idx - MC_ENGINE_IDX_CE0; | |
| @@ -128,6 +138,14 @@ r570_gsp_get_static_info(struct nvkm_gsp *gsp) | |||
| 128 | 138 | } | |
| 129 | 139 | } | |
| 130 | 140 | ||
| 141 | + | ret = r535_gsp_get_static_memsys_info(gsp); | |
| 142 | + | if (ret) { | |
| 143 | + | nvkm_error(&gsp->subdev, "Retrieving static memsys info failed\n"); | |
| 144 | + | return ret; | |
| 145 | + | } | |
| 146 | + | nvkm_debug(&gsp->subdev, "memsys: Use raw mode for comptag allocations? %s\n", | |
| 147 | + | str_yes_no(gsp->memsys.use_raw_mode_comptagline_alloc)); | |
| 148 | + | ||
| 131 | 149 | return 0; | |
| 132 | 150 | } | |
| 133 | 151 | ||
| @@ -198,13 +216,40 @@ r570_gsp_set_rmargs(struct nvkm_gsp *gsp, bool resume) | |||
| 198 | 216 | args->srInitArguments.bInPMTransition = 0; | |
| 199 | 217 | } else { | |
| 200 | 218 | args->srInitArguments.oldLevel = NV2080_CTRL_GPU_SET_POWER_STATE_GPU_LEVEL_3; | |
| 201 | - | args->srInitArguments.flags = 0; | |
| 219 | + | args->srInitArguments.flags = | |
| 220 | + | GPU_STATE_FLAGS_PRESERVING | GPU_STATE_FLAGS_PM_TRANSITION; | |
| 202 | 221 | args->srInitArguments.bInPMTransition = 1; | |
| 203 | 222 | } | |
| 204 | 223 | ||
| 205 | 224 | args->bDmemStack = 1; | |
| 206 | 225 | } | |
| 207 | 226 | ||
| 227 | + | int | |
| 228 | + | r570_gsp_gcx_ready(struct nvkm_gsp *gsp) | |
| 229 | + | { | |
| 230 | + | NV2080_CTRL_INTERNAL_GCX_ENTRY_PREREQUISITE_PARAMS *ctrl; | |
| 231 | + | int ret = 0; | |
| 232 | + | ||
| 233 | + | ctrl = nvkm_gsp_rm_ctrl_rd(&gsp->internal.device.subdevice, | |
| 234 | + | NV2080_CTRL_CMD_INTERNAL_GCX_ENTRY_PREREQUISITE, | |
| 235 | + | sizeof(*ctrl)); | |
| 236 | + | if (IS_ERR(ctrl)) | |
| 237 | + | return PTR_ERR(ctrl); | |
| 238 | + | ||
| 239 | + | if (ctrl->bIsGC6Satisfied) | |
| 240 | + | ret |= NV_DEVICE_GC6_READY; | |
| 241 | + | if (ctrl->bIsGCOFFSatisfied) | |
| 242 | + | ret |= NV_DEVICE_GCOFF_READY; | |
| 243 | + | ||
| 244 | + | nvkm_debug(&gsp->subdev, | |
| 245 | + | "GCX ready status: GC6=%s GCOFF=%s\n", | |
| 246 | + | str_yes_no(ctrl->bIsGC6Satisfied), str_yes_no(ctrl->bIsGCOFFSatisfied)); | |
| 247 | + | ||
| 248 | + | nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, ctrl); | |
| 249 | + | return ret; | |
| 250 | + | } | |
| 251 | + | ||
| 252 | + | ||
| 208 | 253 | const struct nvkm_rm_api_gsp | |
| 209 | 254 | r570_gsp = { | |
| 210 | 255 | .set_rmargs = r570_gsp_set_rmargs, | |
| @@ -213,4 +258,5 @@ r570_gsp = { | |||
| 213 | 258 | .xlat_mc_engine_idx = r570_gsp_xlat_mc_engine_idx, | |
| 214 | 259 | .drop_post_nocat_record = r570_gsp_drop_post_nocat_record, | |
| 215 | 260 | .sr_data_size = r570_gsp_sr_data_size, | |
| 261 | + | .gcx_ready = r570_gsp_gcx_ready, | |
| 216 | 262 | }; | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/disp.h
| @@ -256,6 +256,8 @@ typedef struct NV0073_CTRL_DP_CTRL_PARAMS { | |||
| 256 | 256 | NvU32 eightLaneDpcdBaseAddr; | |
| 257 | 257 | } NV0073_CTRL_DP_CTRL_PARAMS; | |
| 258 | 258 | ||
| 259 | + | #define NV0073_CTRL_CMD_DP_CONFIG_STREAM (0x731362U) /* finn: Evaluated from "(FINN_NV04_DISPLAY_COMMON_DP_INTERFACE_ID << 8) | NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS_MESSAGE_ID" */ | |
| 260 | + | ||
| 259 | 261 | typedef struct NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS { | |
| 260 | 262 | NvU32 subDeviceInstance; | |
| 261 | 263 | NvU32 head; | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/fbsr.h
| @@ -16,4 +16,33 @@ typedef struct NV2080_CTRL_INTERNAL_FBSR_INIT_PARAMS { | |||
| 16 | 16 | NV_DECLARE_ALIGNED(NvU64 sysmemAddrOfSuspendResumeData, 8); | |
| 17 | 17 | } NV2080_CTRL_INTERNAL_FBSR_INIT_PARAMS; | |
| 18 | 18 | ||
| 19 | + | #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO (0x801306) /* finn: Evaluated from "(FINN_NV01_DEVICE_0_FB_INTERFACE_ID << 8) | NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS_MESSAGE_ID" */ | |
| 20 | + | ||
| 21 | + | typedef struct NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS { | |
| 22 | + | NV_DECLARE_ALIGNED(NvU64 Size, 8); | |
| 23 | + | NV_DECLARE_ALIGNED(NvU64 Address, 8); | |
| 24 | + | NvU32 AddressSpace; | |
| 25 | + | NvU32 MaxCompbitLine; | |
| 26 | + | NvU32 comptagsPerCacheLine; | |
| 27 | + | NvU32 cacheLineSize; | |
| 28 | + | NvU32 cacheLineSizePerSlice; | |
| 29 | + | NvU32 cacheLineFetchAlignment; | |
| 30 | + | NV_DECLARE_ALIGNED(NvU64 backingStoreBase, 8); | |
| 31 | + | NvU32 gobsPerComptagPerSlice; | |
| 32 | + | NvU32 backingStoreCbcBase; | |
| 33 | + | NvU32 comptaglineAllocationPolicy; | |
| 34 | + | NV_DECLARE_ALIGNED(NvU64 privRegionStartOffset, 8); | |
| 35 | + | NvU32 cbcCoveragePerSlice; | |
| 36 | + | } NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS; | |
| 37 | + | ||
| 38 | + | #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_ADDRESS_SPACE_UNKNOWN 0 // ADDR_UNKNOWN | |
| 39 | + | #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_ADDRESS_SPACE_SYSMEM 1 // ADDR_SYSMEM | |
| 40 | + | #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_ADDRESS_SPACE_FBMEM 2 // ADDR_FBMEM | |
| 41 | + | ||
| 42 | + | #define NV2080_CTRL_CMD_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE (0x20800a6f) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE_PARAMS_MESSAGE_ID" */ | |
| 43 | + | ||
| 44 | + | typedef struct NV2080_CTRL_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE_PARAMS { | |
| 45 | + | NvBool bRawMode; | |
| 46 | + | } NV2080_CTRL_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE_PARAMS; | |
| 47 | + | ||
| 19 | 48 | #endif | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/gsp.h
| @@ -523,6 +523,14 @@ typedef struct | |||
| 523 | 523 | ||
| 524 | 524 | #define NV2080_CTRL_GPU_SET_POWER_STATE_GPU_LEVEL_3 (0x00000003U) | |
| 525 | 525 | ||
| 526 | + | #define GPU_STATE_FLAGS_PRESERVING BIT(0) // GPU state is preserved | |
| 527 | + | #define GPU_STATE_FLAGS_VGA_TRANSITION BIT(1) // To be used with GPU_STATE_FLAGS_PRESERVING. | |
| 528 | + | #define GPU_STATE_FLAGS_PM_TRANSITION BIT(2) // To be used with GPU_STATE_FLAGS_PRESERVING. | |
| 529 | + | #define GPU_STATE_FLAGS_PM_SUSPEND BIT(3) | |
| 530 | + | #define GPU_STATE_FLAGS_PM_HIBERNATE BIT(4) | |
| 531 | + | #define GPU_STATE_FLAGS_GC6_TRANSITION BIT(5) // To be used with GPU_STATE_FLAGS_PRESERVING. | |
| 532 | + | #define GPU_STATE_FLAGS_FAST_UNLOAD BIT(6) // Used during windows restart, skips stateDestroy steps | |
| 533 | + | ||
| 526 | 534 | typedef struct | |
| 527 | 535 | { | |
| 528 | 536 | // Magic for verification by secure ucode | |
| @@ -631,4 +639,11 @@ typedef struct GSP_FMC_BOOT_PARAMS | |||
| 631 | 639 | } GSP_FMC_BOOT_PARAMS; | |
| 632 | 640 | ||
| 633 | 641 | #define GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100 (14 << 20) // Hopper+ | |
| 642 | + | ||
| 643 | + | #define NV2080_CTRL_CMD_INTERNAL_GCX_ENTRY_PREREQUISITE (0x2080a7d7) | |
| 644 | + | ||
| 645 | + | typedef struct NV2080_CTRL_INTERNAL_GCX_ENTRY_PREREQUISITE_PARAMS { | |
| 646 | + | NvBool bIsGC6Satisfied; | |
| 647 | + | NvBool bIsGCOFFSatisfied; | |
| 648 | + | } NV2080_CTRL_INTERNAL_GCX_ENTRY_PREREQUISITE_PARAMS; | |
| 634 | 649 | #endif | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | #ifndef __NVKM_RM_H__ | |
| 7 | 7 | #define __NVKM_RM_H__ | |
| 8 | 8 | #include "handles.h" | |
| 9 | + | struct nvkm_ior; | |
| 9 | 10 | struct nvkm_outp; | |
| 10 | 11 | struct r535_gr; | |
| 11 | 12 | ||
| @@ -39,6 +40,7 @@ struct nvkm_rm_api { | |||
| 39 | 40 | void (*drop_send_user_shared_data)(struct nvkm_gsp *); | |
| 40 | 41 | void (*drop_post_nocat_record)(struct nvkm_gsp *); | |
| 41 | 42 | u32 (*sr_data_size)(struct nvkm_gsp *); | |
| 43 | + | int (*gcx_ready)(struct nvkm_gsp *gsp); | |
| 42 | 44 | } *gsp; | |
| 43 | 45 | ||
| 44 | 46 | const struct nvkm_rm_api_rpc { | |
| @@ -78,7 +80,7 @@ struct nvkm_rm_api { | |||
| 78 | 80 | } *device; | |
| 79 | 81 | ||
| 80 | 82 | const struct nvkm_rm_api_fbsr { | |
| 81 | - | int (*suspend)(struct nvkm_gsp *, bool runtime); | |
| 83 | + | int (*suspend)(struct nvkm_gsp *); | |
| 82 | 84 | void (*resume)(struct nvkm_gsp *); | |
| 83 | 85 | } *fbsr; | |
| 84 | 86 | ||
| @@ -93,6 +95,10 @@ struct nvkm_rm_api { | |||
| 93 | 95 | struct { | |
| 94 | 96 | int (*get_caps)(struct nvkm_disp *, int *link_bw, bool *mst, bool *wm); | |
| 95 | 97 | int (*set_indexed_link_rates)(struct nvkm_outp *); | |
| 98 | + | int (*sst)(struct nvkm_ior *, int head, bool ef, | |
| 99 | + | u32 watermark, u32 hblanksym, u32 vblanksym); | |
| 100 | + | int (*vcpi)(struct nvkm_ior *, int head, | |
| 101 | + | u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn); | |
| 96 | 102 | } dp; | |
| 97 | 103 | ||
| 98 | 104 | struct { | |
| @@ -169,6 +175,8 @@ int r535_gr_chan_new(struct nvkm_gr *, struct nvkm_chan *, const struct nvkm_ocl | |||
| 169 | 175 | int r535_gr_promote_ctx(struct r535_gr *, bool golden, struct nvkm_vmm *, | |
| 170 | 176 | struct nvkm_memory **pctxbuf_mem, struct nvkm_vma **pctxbuf_vma, | |
| 171 | 177 | struct nvkm_gsp_object *chan); | |
| 178 | + | int r570_gsp_gcx_ready(struct nvkm_gsp *gsp); | |
| 179 | + | int r535_gsp_get_static_memsys_info(struct nvkm_gsp *gsp); | |
| 172 | 180 | extern const struct nvkm_rm_api_engine r535_nvdec; | |
| 173 | 181 | extern const struct nvkm_rm_api_engine r535_nvenc; | |
| 174 | 182 | extern const struct nvkm_rm_api_engine r535_nvjpg; | |
modified drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
| @@ -195,6 +195,9 @@ check_io_mapping(struct nv50_instmem *imem) | |||
| 195 | 195 | { | |
| 196 | 196 | struct nvkm_device *device = imem->base.subdev.device; | |
| 197 | 197 | ||
| 198 | + | if (imem->iomap.size) | |
| 199 | + | return true; | |
| 200 | + | ||
| 198 | 201 | return io_mapping_init_wc(&imem->iomap, | |
| 199 | 202 | device->func->resource_addr(device, NVKM_BAR2_INST), | |
| 200 | 203 | device->func->resource_size(device, NVKM_BAR2_INST)) != NULL; | |
modified drivers/gpu/drm/qxl/qxl_display.c
| @@ -30,6 +30,7 @@ | |||
| 30 | 30 | #include <drm/drm_drv.h> | |
| 31 | 31 | #include <drm/drm_atomic.h> | |
| 32 | 32 | #include <drm/drm_atomic_helper.h> | |
| 33 | + | #include <drm/drm_blend.h> | |
| 33 | 34 | #include <drm/drm_edid.h> | |
| 34 | 35 | #include <drm/drm_encoder.h> | |
| 35 | 36 | #include <drm/drm_framebuffer.h> | |
| @@ -981,7 +982,7 @@ static struct drm_plane *qxl_create_plane(struct qxl_device *qdev, | |||
| 981 | 982 | return ERR_PTR(-EINVAL); | |
| 982 | 983 | } | |
| 983 | 984 | ||
| 984 | - | plane = kzalloc(sizeof(*plane), GFP_KERNEL); | |
| 985 | + | plane = kzalloc_obj(*plane); | |
| 985 | 986 | if (!plane) | |
| 986 | 987 | return ERR_PTR(-ENOMEM); | |
| 987 | 988 | ||
| @@ -993,6 +994,9 @@ static struct drm_plane *qxl_create_plane(struct qxl_device *qdev, | |||
| 993 | 994 | ||
| 994 | 995 | drm_plane_helper_add(plane, helper_funcs); | |
| 995 | 996 | ||
| 997 | + | drm_plane_create_blend_mode_property(plane, | |
| 998 | + | BIT(DRM_MODE_BLEND_PREMULTI)); | |
| 999 | + | ||
| 996 | 1000 | return plane; | |
| 997 | 1001 | ||
| 998 | 1002 | free_plane: | |
modified drivers/gpu/drm/rockchip/Kconfig
| @@ -68,6 +68,7 @@ config ROCKCHIP_CDN_DP | |||
| 68 | 68 | ||
| 69 | 69 | config ROCKCHIP_DW_DP | |
| 70 | 70 | bool "Rockchip specific extensions for Synopsys DW DP" | |
| 71 | + | select DRM_BRIDGE_CONNECTOR | |
| 71 | 72 | help | |
| 72 | 73 | This selects support for Rockchip SoC specific extensions | |
| 73 | 74 | to enable Synopsys DesignWare Cores based DisplayPort transmit | |
| @@ -145,6 +146,8 @@ config ROCKCHIP_RGB | |||
| 145 | 146 | config ROCKCHIP_RK3066_HDMI | |
| 146 | 147 | bool "Rockchip specific extensions for RK3066 HDMI" | |
| 147 | 148 | depends on DRM_ROCKCHIP | |
| 149 | + | select DRM_DISPLAY_HELPER | |
| 150 | + | select DRM_BRIDGE_CONNECTOR | |
| 148 | 151 | help | |
| 149 | 152 | This selects support for Rockchip SoC specific extensions | |
| 150 | 153 | for the RK3066 HDMI driver. If you want to enable | |
modified drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
| @@ -241,10 +241,11 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder, | |||
| 241 | 241 | of_graph_get_remote_port(endpoint.local_node); | |
| 242 | 242 | ||
| 243 | 243 | of_property_read_u32(remote_port, "reg", &port_id); | |
| 244 | - | sprintf(name, "%s vp%d", remote_port_parent->full_name, port_id); | |
| 244 | + | snprintf(name, sizeof(name), "%s vp%d", | |
| 245 | + | remote_port_parent->full_name, port_id); | |
| 245 | 246 | } else { | |
| 246 | - | sprintf(name, "%s %s", | |
| 247 | - | remote_port_parent->full_name, endpoint.id ? "vopl" : "vopb"); | |
| 247 | + | snprintf(name, sizeof(name), "%s %s", | |
| 248 | + | remote_port_parent->full_name, endpoint.id ? "vopl" : "vopb"); | |
| 248 | 249 | } | |
| 249 | 250 | ||
| 250 | 251 | DRM_DEV_DEBUG(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG"); | |
modified drivers/gpu/drm/scheduler/sched_entity.c
| @@ -559,9 +559,10 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity) | |||
| 559 | 559 | */ | |
| 560 | 560 | smp_wmb(); | |
| 561 | 561 | ||
| 562 | + | spin_lock(&entity->lock); | |
| 562 | 563 | spsc_queue_pop(&entity->job_queue); | |
| 563 | - | ||
| 564 | 564 | drm_sched_rq_pop_entity(entity); | |
| 565 | + | spin_unlock(&entity->lock); | |
| 565 | 566 | ||
| 566 | 567 | /* Jobs and entities might have different lifecycles. Since we're | |
| 567 | 568 | * removing the job from the entities queue, set the jobs entity pointer | |
| @@ -647,6 +648,9 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job) | |||
| 647 | 648 | * Make sure to set the submit_ts first, to avoid a race. | |
| 648 | 649 | */ | |
| 649 | 650 | sched_job->submit_ts = submit_ts = ktime_get(); | |
| 651 | + | ||
| 652 | + | spin_lock(&entity->lock); | |
| 653 | + | ||
| 650 | 654 | first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node); | |
| 651 | 655 | ||
| 652 | 656 | /* first job wakes up scheduler */ | |
| @@ -657,5 +661,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job) | |||
| 657 | 661 | if (sched) | |
| 658 | 662 | drm_sched_wakeup(sched); | |
| 659 | 663 | } | |
| 664 | + | ||
| 665 | + | spin_unlock(&entity->lock); | |
| 660 | 666 | } | |
| 661 | 667 | EXPORT_SYMBOL(drm_sched_entity_push_job); | |
modified drivers/gpu/drm/scheduler/sched_rq.c
| @@ -257,19 +257,17 @@ static ktime_t drm_sched_entity_get_job_ts(struct drm_sched_entity *entity) | |||
| 257 | 257 | struct drm_gpu_scheduler * | |
| 258 | 258 | drm_sched_rq_add_entity(struct drm_sched_entity *entity, ktime_t ts) | |
| 259 | 259 | { | |
| 260 | + | struct drm_sched_rq *rq = entity->rq; | |
| 260 | 261 | struct drm_gpu_scheduler *sched; | |
| 261 | - | struct drm_sched_rq *rq; | |
| 262 | 262 | ||
| 263 | 263 | /* Add the entity to the run queue */ | |
| 264 | - | spin_lock(&entity->lock); | |
| 265 | - | if (entity->stopped) { | |
| 266 | - | spin_unlock(&entity->lock); | |
| 264 | + | lockdep_assert_held(&entity->lock); | |
| 267 | 265 | ||
| 266 | + | if (entity->stopped) { | |
| 268 | 267 | DRM_ERROR("Trying to push to a killed entity\n"); | |
| 269 | 268 | return NULL; | |
| 270 | 269 | } | |
| 271 | 270 | ||
| 272 | - | rq = entity->rq; | |
| 273 | 271 | spin_lock(&rq->lock); | |
| 274 | 272 | sched = rq->sched; | |
| 275 | 273 | ||
| @@ -289,7 +287,6 @@ drm_sched_rq_add_entity(struct drm_sched_entity *entity, ktime_t ts) | |||
| 289 | 287 | drm_sched_rq_update_fifo_locked(entity, rq, ts); | |
| 290 | 288 | ||
| 291 | 289 | spin_unlock(&rq->lock); | |
| 292 | - | spin_unlock(&entity->lock); | |
| 293 | 290 | ||
| 294 | 291 | return sched; | |
| 295 | 292 | } | |
| @@ -343,16 +340,17 @@ drm_sched_rq_next_rr_ts(struct drm_sched_rq *rq, | |||
| 343 | 340 | */ | |
| 344 | 341 | void drm_sched_rq_pop_entity(struct drm_sched_entity *entity) | |
| 345 | 342 | { | |
| 343 | + | struct drm_sched_rq *rq = entity->rq; | |
| 346 | 344 | struct drm_sched_job *next_job; | |
| 347 | - | struct drm_sched_rq *rq; | |
| 345 | + | ||
| 346 | + | lockdep_assert_held(&entity->lock); | |
| 347 | + | ||
| 348 | + | spin_lock(&rq->lock); | |
| 348 | 349 | ||
| 349 | 350 | /* | |
| 350 | 351 | * Update the entity's location in the min heap according to | |
| 351 | 352 | * the timestamp of the next job, if any. | |
| 352 | 353 | */ | |
| 353 | - | spin_lock(&entity->lock); | |
| 354 | - | rq = entity->rq; | |
| 355 | - | spin_lock(&rq->lock); | |
| 356 | 354 | next_job = drm_sched_entity_queue_peek(entity); | |
| 357 | 355 | if (next_job) { | |
| 358 | 356 | ktime_t ts; | |
| @@ -375,8 +373,8 @@ void drm_sched_rq_pop_entity(struct drm_sched_entity *entity) | |||
| 375 | 373 | drm_sched_entity_save_vruntime(entity, min_vruntime); | |
| 376 | 374 | } | |
| 377 | 375 | } | |
| 376 | + | ||
| 378 | 377 | spin_unlock(&rq->lock); | |
| 379 | - | spin_unlock(&entity->lock); | |
| 380 | 378 | } | |
| 381 | 379 | ||
| 382 | 380 | /** | |
modified drivers/gpu/drm/scheduler/tests/mock_scheduler.c
| @@ -1,6 +1,8 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 | |
| 2 | 2 | /* Copyright (c) 2025 Valve Corporation */ | |
| 3 | 3 | ||
| 4 | + | #include <kunit/device.h> | |
| 5 | + | ||
| 4 | 6 | #include "sched_tests.h" | |
| 5 | 7 | ||
| 6 | 8 | /* | |
| @@ -288,6 +290,7 @@ static const struct drm_sched_backend_ops drm_mock_scheduler_ops = { | |||
| 288 | 290 | */ | |
| 289 | 291 | struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test, long timeout) | |
| 290 | 292 | { | |
| 293 | + | static unsigned int instance; | |
| 291 | 294 | struct drm_sched_init_args args = { | |
| 292 | 295 | .ops = &drm_mock_scheduler_ops, | |
| 293 | 296 | .num_rqs = DRM_SCHED_PRIORITY_COUNT, | |
| @@ -297,11 +300,19 @@ struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test, long timeout) | |||
| 297 | 300 | .name = "drm-mock-scheduler", | |
| 298 | 301 | }; | |
| 299 | 302 | struct drm_mock_scheduler *sched; | |
| 303 | + | struct device *dev; | |
| 304 | + | char name[64]; | |
| 300 | 305 | int ret; | |
| 301 | 306 | ||
| 302 | 307 | sched = kunit_kzalloc(test, sizeof(*sched), GFP_KERNEL); | |
| 303 | 308 | KUNIT_ASSERT_NOT_NULL(test, sched); | |
| 304 | 309 | ||
| 310 | + | snprintf(name, sizeof(name), "%s-%u", args.name, instance++); | |
| 311 | + | dev = kunit_device_register(test, name); | |
| 312 | + | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); | |
| 313 | + | ||
| 314 | + | args.dev = dev; | |
| 315 | + | ||
| 305 | 316 | ret = drm_sched_init(&sched->base, &args); | |
| 306 | 317 | KUNIT_ASSERT_EQ(test, ret, 0); | |
| 307 | 318 | ||
modified drivers/gpu/drm/sysfb/ofdrm.c
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | #include <linux/aperture.h> | |
| 4 | 4 | #include <linux/of_address.h> | |
| 5 | + | #include <linux/overflow.h> | |
| 5 | 6 | #include <linux/pci.h> | |
| 6 | 7 | #include <linux/platform_device.h> | |
| 7 | 8 | #include <linux/pm.h> | |
| @@ -238,7 +239,7 @@ static bool is_avivo(u32 vendor, u32 device) | |||
| 238 | 239 | /* This will match most R5xx */ | |
| 239 | 240 | return (vendor == PCI_VENDOR_ID_ATI) && | |
| 240 | 241 | ((device >= PCI_VENDOR_ID_ATI_R520 && device < 0x7800) || | |
| 241 | - | (PCI_VENDOR_ID_ATI_R600 >= 0x9400)); | |
| 242 | + | (device >= PCI_VENDOR_ID_ATI_R600)); | |
| 242 | 243 | } | |
| 243 | 244 | ||
| 244 | 245 | static enum ofdrm_model display_get_model_of(struct drm_device *dev, struct device_node *of_node) | |
| @@ -913,7 +914,10 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, | |||
| 913 | 914 | return ERR_PTR(-EINVAL); | |
| 914 | 915 | } | |
| 915 | 916 | ||
| 916 | - | fb_size = linebytes * height; | |
| 917 | + | if (check_mul_overflow(linebytes, height, &fb_size)) { | |
| 918 | + | drm_err(dev, "framebuffer size exceeds maximum\n"); | |
| 919 | + | return ERR_PTR(-EINVAL); | |
| 920 | + | } | |
| 917 | 921 | ||
| 918 | 922 | /* | |
| 919 | 923 | * Try to figure out the address of the framebuffer. Unfortunately, Open | |
modified drivers/gpu/drm/tegra/dc.c
| @@ -904,6 +904,7 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm, | |||
| 904 | 904 | struct tegra_dc *dc) | |
| 905 | 905 | { | |
| 906 | 906 | unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm); | |
| 907 | + | unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE); | |
| 907 | 908 | enum drm_plane_type type = DRM_PLANE_TYPE_PRIMARY; | |
| 908 | 909 | struct tegra_plane *plane; | |
| 909 | 910 | unsigned int num_formats; | |
| @@ -939,6 +940,7 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm, | |||
| 939 | 940 | } | |
| 940 | 941 | ||
| 941 | 942 | drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs); | |
| 943 | + | drm_plane_create_blend_mode_property(&plane->base, blend_caps); | |
| 942 | 944 | drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255); | |
| 943 | 945 | ||
| 944 | 946 | err = drm_plane_create_rotation_property(&plane->base, | |
| @@ -1209,6 +1211,7 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm, | |||
| 1209 | 1211 | struct tegra_dc *dc) | |
| 1210 | 1212 | { | |
| 1211 | 1213 | unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm); | |
| 1214 | + | unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE); | |
| 1212 | 1215 | struct tegra_plane *plane; | |
| 1213 | 1216 | unsigned int num_formats; | |
| 1214 | 1217 | const u32 *formats; | |
| @@ -1252,6 +1255,7 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm, | |||
| 1252 | 1255 | } | |
| 1253 | 1256 | ||
| 1254 | 1257 | drm_plane_helper_add(&plane->base, &tegra_cursor_plane_helper_funcs); | |
| 1258 | + | drm_plane_create_blend_mode_property(&plane->base, blend_caps); | |
| 1255 | 1259 | drm_plane_create_zpos_immutable_property(&plane->base, 255); | |
| 1256 | 1260 | ||
| 1257 | 1261 | return &plane->base; | |
| @@ -1356,6 +1360,7 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm, | |||
| 1356 | 1360 | bool cursor) | |
| 1357 | 1361 | { | |
| 1358 | 1362 | unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm); | |
| 1363 | + | unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE); | |
| 1359 | 1364 | struct tegra_plane *plane; | |
| 1360 | 1365 | unsigned int num_formats; | |
| 1361 | 1366 | enum drm_plane_type type; | |
| @@ -1394,6 +1399,7 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm, | |||
| 1394 | 1399 | } | |
| 1395 | 1400 | ||
| 1396 | 1401 | drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs); | |
| 1402 | + | drm_plane_create_blend_mode_property(&plane->base, blend_caps); | |
| 1397 | 1403 | drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255); | |
| 1398 | 1404 | ||
| 1399 | 1405 | err = drm_plane_create_rotation_property(&plane->base, | |
modified drivers/gpu/drm/tegra/hub.c
| @@ -759,6 +759,7 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm, | |||
| 759 | 759 | unsigned int index, | |
| 760 | 760 | enum drm_plane_type type) | |
| 761 | 761 | { | |
| 762 | + | unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE); | |
| 762 | 763 | struct tegra_drm *tegra = drm->dev_private; | |
| 763 | 764 | struct tegra_display_hub *hub = tegra->hub; | |
| 764 | 765 | struct tegra_shared_plane *plane; | |
| @@ -797,6 +798,7 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm, | |||
| 797 | 798 | } | |
| 798 | 799 | ||
| 799 | 800 | drm_plane_helper_add(p, &tegra_shared_plane_helper_funcs); | |
| 801 | + | drm_plane_create_blend_mode_property(p, blend_caps); | |
| 800 | 802 | drm_plane_create_zpos_property(p, 0, 0, 255); | |
| 801 | 803 | ||
| 802 | 804 | return p; | |
modified drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c
| @@ -22,7 +22,7 @@ tilcdc_panel_update_prop(struct of_changeset *ocs, struct device_node *node, | |||
| 22 | 22 | { | |
| 23 | 23 | struct property *prop; | |
| 24 | 24 | ||
| 25 | - | prop = kzalloc(sizeof(*prop), GFP_KERNEL); | |
| 25 | + | prop = kzalloc_obj(*prop); | |
| 26 | 26 | if (!prop) | |
| 27 | 27 | return -ENOMEM; | |
| 28 | 28 | ||
modified drivers/gpu/drm/tiny/cirrus-qemu.c
| @@ -582,6 +582,9 @@ static int cirrus_pci_probe(struct pci_dev *pdev, | |||
| 582 | 582 | struct cirrus_device *cirrus; | |
| 583 | 583 | int ret; | |
| 584 | 584 | ||
| 585 | + | if (pci_resource_len(pdev, 0) < CIRRUS_VRAM_SIZE) | |
| 586 | + | return -ENODEV; | |
| 587 | + | ||
| 585 | 588 | ret = aperture_remove_conflicting_pci_devices(pdev, cirrus_driver.name); | |
| 586 | 589 | if (ret) | |
| 587 | 590 | return ret; | |
modified drivers/gpu/drm/ttm/ttm_bo.c
| @@ -1434,7 +1434,7 @@ ttm_bo_swapout_cb(struct ttm_lru_walk *walk, struct ttm_buffer_object *bo) | |||
| 1434 | 1434 | ||
| 1435 | 1435 | if (ttm_tt_is_populated(tt)) { | |
| 1436 | 1436 | ret = ttm_tt_swapout(bdev, tt, swapout_walk->gfp_flags); | |
| 1437 | - | if (!ret) { | |
| 1437 | + | if (ret > 0) { | |
| 1438 | 1438 | spin_lock(&bdev->lru_lock); | |
| 1439 | 1439 | ttm_resource_del_bulk_move_unevictable(bo->resource, bo); | |
| 1440 | 1440 | ttm_resource_move_to_lru_tail(bo->resource); | |
modified drivers/gpu/drm/vboxvideo/vbox_mode.c
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | 16 | #include <drm/drm_atomic.h> | |
| 17 | 17 | #include <drm/drm_atomic_helper.h> | |
| 18 | + | #include <drm/drm_blend.h> | |
| 18 | 19 | #include <drm/drm_edid.h> | |
| 19 | 20 | #include <drm/drm_fb_helper.h> | |
| 20 | 21 | #include <drm/drm_fourcc.h> | |
| @@ -540,6 +541,9 @@ static struct drm_plane *vbox_create_plane(struct vbox_private *vbox, | |||
| 540 | 541 | ||
| 541 | 542 | drm_plane_helper_add(plane, helper_funcs); | |
| 542 | 543 | ||
| 544 | + | drm_plane_create_blend_mode_property(plane, | |
| 545 | + | BIT(DRM_MODE_BLEND_COVERAGE)); | |
| 546 | + | ||
| 543 | 547 | return plane; | |
| 544 | 548 | ||
| 545 | 549 | free_plane: | |
modified drivers/gpu/drm/vc4/vc4_kms.c
| @@ -1188,7 +1188,7 @@ int vc4_kms_load(struct drm_device *dev) | |||
| 1188 | 1188 | ||
| 1189 | 1189 | drm_mode_config_reset(dev); | |
| 1190 | 1190 | ||
| 1191 | - | drm_kms_helper_poll_init(dev); | |
| 1191 | + | drmm_kms_helper_poll_init(dev); | |
| 1192 | 1192 | ||
| 1193 | 1193 | return 0; | |
| 1194 | 1194 | } | |
modified drivers/gpu/drm/verisilicon/vs_cursor_plane.c
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | 12 | #include <drm/drm_atomic.h> | |
| 13 | 13 | #include <drm/drm_atomic_helper.h> | |
| 14 | + | #include <drm/drm_blend.h> | |
| 14 | 15 | #include <drm/drm_crtc.h> | |
| 15 | 16 | #include <drm/drm_fourcc.h> | |
| 16 | 17 | #include <drm/drm_framebuffer.h> | |
| @@ -267,6 +268,7 @@ struct drm_plane *vs_cursor_plane_init(struct drm_device *drm_dev, | |||
| 267 | 268 | return plane; | |
| 268 | 269 | ||
| 269 | 270 | drm_plane_helper_add(plane, &vs_cursor_plane_helper_funcs); | |
| 271 | + | drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_COVERAGE)); | |
| 270 | 272 | ||
| 271 | 273 | return plane; | |
| 272 | 274 | } | |
modified drivers/gpu/drm/verisilicon/vs_hwdb.c
| @@ -10,82 +10,50 @@ | |||
| 10 | 10 | #include "vs_dc_top_regs.h" | |
| 11 | 11 | #include "vs_hwdb.h" | |
| 12 | 12 | ||
| 13 | - | static const u32 vs_formats_array_no_yuv444[] = { | |
| 13 | + | static const u32 vs_primary_formats_array_no_yuv444[] = { | |
| 14 | 14 | DRM_FORMAT_XRGB4444, | |
| 15 | 15 | DRM_FORMAT_XBGR4444, | |
| 16 | 16 | DRM_FORMAT_RGBX4444, | |
| 17 | 17 | DRM_FORMAT_BGRX4444, | |
| 18 | - | DRM_FORMAT_ARGB4444, | |
| 19 | - | DRM_FORMAT_ABGR4444, | |
| 20 | - | DRM_FORMAT_RGBA4444, | |
| 21 | - | DRM_FORMAT_BGRA4444, | |
| 22 | 18 | DRM_FORMAT_XRGB1555, | |
| 23 | 19 | DRM_FORMAT_XBGR1555, | |
| 24 | 20 | DRM_FORMAT_RGBX5551, | |
| 25 | 21 | DRM_FORMAT_BGRX5551, | |
| 26 | - | DRM_FORMAT_ARGB1555, | |
| 27 | - | DRM_FORMAT_ABGR1555, | |
| 28 | - | DRM_FORMAT_RGBA5551, | |
| 29 | - | DRM_FORMAT_BGRA5551, | |
| 30 | 22 | DRM_FORMAT_RGB565, | |
| 31 | 23 | DRM_FORMAT_BGR565, | |
| 32 | 24 | DRM_FORMAT_XRGB8888, | |
| 33 | 25 | DRM_FORMAT_XBGR8888, | |
| 34 | 26 | DRM_FORMAT_RGBX8888, | |
| 35 | 27 | DRM_FORMAT_BGRX8888, | |
| 36 | - | DRM_FORMAT_ARGB8888, | |
| 37 | - | DRM_FORMAT_ABGR8888, | |
| 38 | - | DRM_FORMAT_RGBA8888, | |
| 39 | - | DRM_FORMAT_BGRA8888, | |
| 40 | - | DRM_FORMAT_ARGB2101010, | |
| 41 | - | DRM_FORMAT_ABGR2101010, | |
| 42 | - | DRM_FORMAT_RGBA1010102, | |
| 43 | - | DRM_FORMAT_BGRA1010102, | |
| 44 | 28 | /* TODO: non-RGB formats */ | |
| 45 | 29 | }; | |
| 46 | 30 | ||
| 47 | - | static const u32 vs_formats_array_with_yuv444[] = { | |
| 31 | + | static const u32 vs_primary_formats_array_with_yuv444[] = { | |
| 48 | 32 | DRM_FORMAT_XRGB4444, | |
| 49 | 33 | DRM_FORMAT_XBGR4444, | |
| 50 | 34 | DRM_FORMAT_RGBX4444, | |
| 51 | 35 | DRM_FORMAT_BGRX4444, | |
| 52 | - | DRM_FORMAT_ARGB4444, | |
| 53 | - | DRM_FORMAT_ABGR4444, | |
| 54 | - | DRM_FORMAT_RGBA4444, | |
| 55 | - | DRM_FORMAT_BGRA4444, | |
| 56 | 36 | DRM_FORMAT_XRGB1555, | |
| 57 | 37 | DRM_FORMAT_XBGR1555, | |
| 58 | 38 | DRM_FORMAT_RGBX5551, | |
| 59 | 39 | DRM_FORMAT_BGRX5551, | |
| 60 | - | DRM_FORMAT_ARGB1555, | |
| 61 | - | DRM_FORMAT_ABGR1555, | |
| 62 | - | DRM_FORMAT_RGBA5551, | |
| 63 | - | DRM_FORMAT_BGRA5551, | |
| 64 | 40 | DRM_FORMAT_RGB565, | |
| 65 | 41 | DRM_FORMAT_BGR565, | |
| 66 | 42 | DRM_FORMAT_XRGB8888, | |
| 67 | 43 | DRM_FORMAT_XBGR8888, | |
| 68 | 44 | DRM_FORMAT_RGBX8888, | |
| 69 | 45 | DRM_FORMAT_BGRX8888, | |
| 70 | - | DRM_FORMAT_ARGB8888, | |
| 71 | - | DRM_FORMAT_ABGR8888, | |
| 72 | - | DRM_FORMAT_RGBA8888, | |
| 73 | - | DRM_FORMAT_BGRA8888, | |
| 74 | - | DRM_FORMAT_ARGB2101010, | |
| 75 | - | DRM_FORMAT_ABGR2101010, | |
| 76 | - | DRM_FORMAT_RGBA1010102, | |
| 77 | - | DRM_FORMAT_BGRA1010102, | |
| 78 | 46 | /* TODO: non-RGB formats */ | |
| 79 | 47 | }; | |
| 80 | 48 | ||
| 81 | 49 | static const struct vs_formats vs_formats_no_yuv444 = { | |
| 82 | - | .array = vs_formats_array_no_yuv444, | |
| 83 | - | .num = ARRAY_SIZE(vs_formats_array_no_yuv444) | |
| 50 | + | .primary_array = vs_primary_formats_array_no_yuv444, | |
| 51 | + | .primary_num = ARRAY_SIZE(vs_primary_formats_array_no_yuv444) | |
| 84 | 52 | }; | |
| 85 | 53 | ||
| 86 | 54 | static const struct vs_formats vs_formats_with_yuv444 = { | |
| 87 | - | .array = vs_formats_array_with_yuv444, | |
| 88 | - | .num = ARRAY_SIZE(vs_formats_array_with_yuv444) | |
| 55 | + | .primary_array = vs_primary_formats_array_with_yuv444, | |
| 56 | + | .primary_num = ARRAY_SIZE(vs_primary_formats_array_with_yuv444) | |
| 89 | 57 | }; | |
| 90 | 58 | ||
| 91 | 59 | static struct vs_chip_identity vs_chip_identities[] = { | |
modified drivers/gpu/drm/verisilicon/vs_hwdb.h
| @@ -10,8 +10,8 @@ | |||
| 10 | 10 | #include <linux/types.h> | |
| 11 | 11 | ||
| 12 | 12 | struct vs_formats { | |
| 13 | - | const u32 *array; | |
| 14 | - | unsigned int num; | |
| 13 | + | const u32 *primary_array; | |
| 14 | + | unsigned int primary_num; | |
| 15 | 15 | }; | |
| 16 | 16 | ||
| 17 | 17 | struct vs_chip_identity { | |
modified drivers/gpu/drm/verisilicon/vs_plane.c
| @@ -136,7 +136,7 @@ struct drm_plane_state *vs_plane_duplicate_state(struct drm_plane *plane) | |||
| 136 | 136 | ||
| 137 | 137 | vs_state_old = to_vs_plane_state(plane->state); | |
| 138 | 138 | ||
| 139 | - | vs_state = kzalloc_obj(*vs_state, GFP_KERNEL); | |
| 139 | + | vs_state = kzalloc_obj(*vs_state); | |
| 140 | 140 | if (!vs_state) | |
| 141 | 141 | return NULL; | |
| 142 | 142 | ||
| @@ -166,7 +166,7 @@ void vs_plane_reset(struct drm_plane *plane) | |||
| 166 | 166 | plane->state = NULL; | |
| 167 | 167 | } | |
| 168 | 168 | ||
| 169 | - | vs_state = kzalloc_obj(*vs_state, GFP_KERNEL); | |
| 169 | + | vs_state = kzalloc_obj(*vs_state); | |
| 170 | 170 | if (!vs_state) | |
| 171 | 171 | return; | |
| 172 | 172 | ||
modified drivers/gpu/drm/verisilicon/vs_primary_plane.c
| @@ -168,8 +168,8 @@ struct drm_plane *vs_primary_plane_init(struct drm_device *drm_dev, struct vs_dc | |||
| 168 | 168 | ||
| 169 | 169 | plane = drmm_universal_plane_alloc(drm_dev, struct drm_plane, dev, 0, | |
| 170 | 170 | &vs_primary_plane_funcs, | |
| 171 | - | dc->identity.formats->array, | |
| 172 | - | dc->identity.formats->num, | |
| 171 | + | dc->identity.formats->primary_array, | |
| 172 | + | dc->identity.formats->primary_num, | |
| 173 | 173 | NULL, | |
| 174 | 174 | DRM_PLANE_TYPE_PRIMARY, | |
| 175 | 175 | NULL); | |
modified drivers/gpu/drm/virtio/virtgpu_display.c
| @@ -344,7 +344,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev, | |||
| 344 | 344 | if (ret) { | |
| 345 | 345 | kfree(virtio_gpu_fb); | |
| 346 | 346 | drm_gem_object_put(obj); | |
| 347 | - | return NULL; | |
| 347 | + | return ERR_PTR(ret); | |
| 348 | 348 | } | |
| 349 | 349 | ||
| 350 | 350 | return &virtio_gpu_fb->base; | |
| @@ -378,8 +378,11 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev) | |||
| 378 | 378 | ||
| 379 | 379 | vgdev->ddev->mode_config.fb_modifiers_not_supported = true; | |
| 380 | 380 | ||
| 381 | - | for (i = 0 ; i < vgdev->num_scanouts; ++i) | |
| 382 | - | vgdev_output_init(vgdev, i); | |
| 381 | + | for (i = 0; i < vgdev->num_scanouts; ++i) { | |
| 382 | + | ret = vgdev_output_init(vgdev, i); | |
| 383 | + | if (ret) | |
| 384 | + | return ret; | |
| 385 | + | } | |
| 383 | 386 | ||
| 384 | 387 | ret = drm_vblank_init(vgdev->ddev, vgdev->num_scanouts); | |
| 385 | 388 | if (ret) | |
modified drivers/gpu/drm/virtio/virtgpu_drv.h
| @@ -43,6 +43,8 @@ | |||
| 43 | 43 | #include <drm/drm_probe_helper.h> | |
| 44 | 44 | #include <drm/virtgpu_drm.h> | |
| 45 | 45 | ||
| 46 | + | #include <xen/xen.h> | |
| 47 | + | ||
| 46 | 48 | #define DRIVER_NAME "virtio_gpu" | |
| 47 | 49 | #define DRIVER_DESC "virtio GPU" | |
| 48 | 50 | ||
| @@ -60,6 +62,24 @@ | |||
| 60 | 62 | /* See virtio_gpu_ctx_create. One additional character for NULL terminator. */ | |
| 61 | 63 | #define DEBUG_NAME_MAX_LEN 65 | |
| 62 | 64 | ||
| 65 | + | /* | |
| 66 | + | * Whether the host must be told about resource backing pages by DMA address | |
| 67 | + | * rather than guest-physical address. | |
| 68 | + | * | |
| 69 | + | * This mirrors vring_use_map_api() in drivers/virtio/virtio_ring.c, including | |
| 70 | + | * its xen_domain() case. | |
| 71 | + | */ | |
| 72 | + | static inline bool virtio_gpu_use_dma_api(const struct virtio_device *vdev) | |
| 73 | + | { | |
| 74 | + | if (!virtio_has_dma_quirk(vdev)) | |
| 75 | + | return true; | |
| 76 | + | ||
| 77 | + | if (xen_domain()) | |
| 78 | + | return true; | |
| 79 | + | ||
| 80 | + | return false; | |
| 81 | + | } | |
| 82 | + | ||
| 63 | 83 | struct virtio_gpu_object_params { | |
| 64 | 84 | unsigned long size; | |
| 65 | 85 | bool dumb; | |
| @@ -94,6 +114,8 @@ struct virtio_gpu_object { | |||
| 94 | 114 | bool dumb; | |
| 95 | 115 | bool created; | |
| 96 | 116 | bool attached; | |
| 117 | + | /* a guest-bound transfer is queued and its mapping not yet synced */ | |
| 118 | + | bool from_host_pending; | |
| 97 | 119 | bool host3d_blob, guest_blob; | |
| 98 | 120 | uint32_t blob_mem, blob_flags; | |
| 99 | 121 | ||
| @@ -176,6 +198,9 @@ struct virtio_gpu_vbuffer { | |||
| 176 | 198 | struct list_head list; | |
| 177 | 199 | ||
| 178 | 200 | uint32_t seqno; | |
| 201 | + | ||
| 202 | + | /* guest-bound transfer whose shmem backing needs a CPU sync */ | |
| 203 | + | bool sync_for_cpu; | |
| 179 | 204 | }; | |
| 180 | 205 | ||
| 181 | 206 | struct virtio_gpu_output { | |
| @@ -343,6 +368,7 @@ void virtio_gpu_array_put_free_work(struct work_struct *work); | |||
| 343 | 368 | /* virtgpu_vq.c */ | |
| 344 | 369 | int virtio_gpu_alloc_vbufs(struct virtio_gpu_device *vgdev); | |
| 345 | 370 | void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev); | |
| 371 | + | void virtio_gpu_reclaim_vbufs(struct virtio_gpu_device *vgdev); | |
| 346 | 372 | void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, | |
| 347 | 373 | struct virtio_gpu_object *bo, | |
| 348 | 374 | struct virtio_gpu_object_params *params, | |
modified drivers/gpu/drm/virtio/virtgpu_gem.c
| @@ -45,7 +45,7 @@ static int virtio_gpu_gem_create(struct drm_file *file, | |||
| 45 | 45 | ||
| 46 | 46 | ret = drm_gem_handle_create(file, &obj->base.base, &handle); | |
| 47 | 47 | if (ret) { | |
| 48 | - | drm_gem_object_release(&obj->base.base); | |
| 48 | + | drm_gem_object_put(&obj->base.base); | |
| 49 | 49 | return ret; | |
| 50 | 50 | } | |
| 51 | 51 | ||
modified drivers/gpu/drm/virtio/virtgpu_ioctl.c
| @@ -185,7 +185,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, | |||
| 185 | 185 | ||
| 186 | 186 | ret = drm_gem_handle_create(file, obj, &handle); | |
| 187 | 187 | if (ret) { | |
| 188 | - | drm_gem_object_release(obj); | |
| 188 | + | drm_gem_object_put(obj); | |
| 189 | 189 | return ret; | |
| 190 | 190 | } | |
| 191 | 191 | ||
| @@ -261,6 +261,27 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev, | |||
| 261 | 261 | if (ret != 0) | |
| 262 | 262 | goto err_put_free; | |
| 263 | 263 | ||
| 264 | + | if (virtio_gpu_is_shmem(bo) && virtio_gpu_use_dma_api(vgdev->vdev)) { | |
| 265 | + | /* | |
| 266 | + | * The sync on completion restores the whole mapping, so an | |
| 267 | + | * earlier transfer has to be done before this one snapshots it. | |
| 268 | + | * Otherwise the snapshot predates anything the CPU wrote once | |
| 269 | + | * that transfer's fence signalled, and the later sync would | |
| 270 | + | * discard it. Nothing can add a fence behind our back here, | |
| 271 | + | * since doing so takes the reservation we already hold. | |
| 272 | + | * This writes the pages, so it waits as a writer does. READ | |
| 273 | + | * usage covers existing readers. | |
| 274 | + | */ | |
| 275 | + | long wait = dma_resv_wait_timeout(objs->objs[0]->resv, | |
| 276 | + | DMA_RESV_USAGE_READ, true, | |
| 277 | + | MAX_SCHEDULE_TIMEOUT); | |
| 278 | + | ||
| 279 | + | if (wait < 0) { | |
| 280 | + | ret = wait; | |
| 281 | + | goto err_unlock; | |
| 282 | + | } | |
| 283 | + | } | |
| 284 | + | ||
| 264 | 285 | fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context, 0); | |
| 265 | 286 | if (!fence) { | |
| 266 | 287 | ret = -ENOMEM; | |
| @@ -320,6 +341,28 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, | |||
| 320 | 341 | if (ret != 0) | |
| 321 | 342 | goto err_put_free; | |
| 322 | 343 | ||
| 344 | + | /* | |
| 345 | + | * A transfer the other way may have queued without yet syncing | |
| 346 | + | * its mapping. Pushing the guest pages into it now would | |
| 347 | + | * discard what the device wrote there, so wait for that sync: | |
| 348 | + | * it runs before the fence it belongs to is signalled. The | |
| 349 | + | * flag is only set under this reservation, so it cannot appear | |
| 350 | + | * behind our back, and the acquire pairs with the release in | |
| 351 | + | * that sync, so finding it clear means the pages it wrote are | |
| 352 | + | * visible here too. | |
| 353 | + | */ | |
| 354 | + | if (smp_load_acquire(&bo->from_host_pending)) { | |
| 355 | + | long wait = dma_resv_wait_timeout(objs->objs[0]->resv, | |
| 356 | + | DMA_RESV_USAGE_WRITE, | |
| 357 | + | true, | |
| 358 | + | MAX_SCHEDULE_TIMEOUT); | |
| 359 | + | ||
| 360 | + | if (wait < 0) { | |
| 361 | + | ret = wait; | |
| 362 | + | goto err_unlock; | |
| 363 | + | } | |
| 364 | + | } | |
| 365 | + | ||
| 323 | 366 | ret = -ENOMEM; | |
| 324 | 367 | fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context, | |
| 325 | 368 | 0); | |
| @@ -557,14 +600,14 @@ static int virtio_gpu_resource_create_blob_ioctl(struct drm_device *dev, | |||
| 557 | 600 | if (params.blob_flags & VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) { | |
| 558 | 601 | ret = virtio_gpu_resource_assign_uuid(vgdev, bo); | |
| 559 | 602 | if (ret) { | |
| 560 | - | drm_gem_object_release(obj); | |
| 603 | + | drm_gem_object_put(obj); | |
| 561 | 604 | return ret; | |
| 562 | 605 | } | |
| 563 | 606 | } | |
| 564 | 607 | ||
| 565 | 608 | ret = drm_gem_handle_create(file, obj, &handle); | |
| 566 | 609 | if (ret) { | |
| 567 | - | drm_gem_object_release(obj); | |
| 610 | + | drm_gem_object_put(obj); | |
| 568 | 611 | return ret; | |
| 569 | 612 | } | |
| 570 | 613 | ||
modified drivers/gpu/drm/virtio/virtgpu_kms.c
| @@ -352,6 +352,7 @@ void virtio_gpu_deinit(struct drm_device *dev) | |||
| 352 | 352 | flush_work(&vgdev->cursorq.dequeue_work); | |
| 353 | 353 | flush_work(&vgdev->config_changed_work); | |
| 354 | 354 | virtio_reset_device(vgdev->vdev); | |
| 355 | + | virtio_gpu_reclaim_vbufs(vgdev); | |
| 355 | 356 | vgdev->vdev->config->del_vqs(vgdev->vdev); | |
| 356 | 357 | mutex_destroy(&vgdev->obj_restore_lock); | |
| 357 | 358 | } | |
modified drivers/gpu/drm/virtio/virtgpu_object.c
| @@ -173,7 +173,7 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev, | |||
| 173 | 173 | struct virtio_gpu_mem_entry **ents, | |
| 174 | 174 | unsigned int *nents) | |
| 175 | 175 | { | |
| 176 | - | bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev); | |
| 176 | + | bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev); | |
| 177 | 177 | struct scatterlist *sg; | |
| 178 | 178 | struct sg_table *pages; | |
| 179 | 179 | int si; | |
modified drivers/gpu/drm/virtio/virtgpu_plane.c
| @@ -24,6 +24,7 @@ | |||
| 24 | 24 | */ | |
| 25 | 25 | ||
| 26 | 26 | #include <drm/drm_atomic_helper.h> | |
| 27 | + | #include <drm/drm_blend.h> | |
| 27 | 28 | #include <drm/drm_damage_helper.h> | |
| 28 | 29 | #include <drm/drm_fourcc.h> | |
| 29 | 30 | #include <drm/drm_gem_atomic_helper.h> | |
| @@ -588,6 +589,7 @@ struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev, | |||
| 588 | 589 | struct drm_plane *plane; | |
| 589 | 590 | const uint32_t *formats; | |
| 590 | 591 | int nformats; | |
| 592 | + | int ret; | |
| 591 | 593 | ||
| 592 | 594 | if (type == DRM_PLANE_TYPE_CURSOR) { | |
| 593 | 595 | formats = virtio_gpu_cursor_formats; | |
| @@ -609,6 +611,21 @@ struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev, | |||
| 609 | 611 | ||
| 610 | 612 | if (type == DRM_PLANE_TYPE_PRIMARY) | |
| 611 | 613 | drm_plane_enable_fb_damage_clips(plane); | |
| 614 | + | else if (type == DRM_PLANE_TYPE_CURSOR) | |
| 615 | + | drm_plane_create_blend_mode_property(plane, | |
| 616 | + | BIT(DRM_MODE_BLEND_PREMULTI)); | |
| 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 | + | } | |
| 612 | 629 | ||
| 613 | 630 | return plane; | |
| 614 | 631 | } | |
modified drivers/gpu/drm/virtio/virtgpu_prime.c
| @@ -293,9 +293,7 @@ int virtgpu_dma_buf_obj_resubmit(struct virtio_gpu_device *vgdev, | |||
| 293 | 293 | return -ENOMEM; | |
| 294 | 294 | } | |
| 295 | 295 | ||
| 296 | - | ents = kvmalloc_array(bo->sgt->nents, | |
| 297 | - | sizeof(struct virtio_gpu_mem_entry), | |
| 298 | - | GFP_KERNEL); | |
| 296 | + | ents = kvmalloc_objs(struct virtio_gpu_mem_entry, bo->sgt->nents); | |
| 299 | 297 | if (!ents) { | |
| 300 | 298 | DRM_ERROR("failed to allocate ent list\n"); | |
| 301 | 299 | return -ENOMEM; | |
| @@ -351,7 +349,7 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, | |||
| 351 | 349 | } | |
| 352 | 350 | } | |
| 353 | 351 | ||
| 354 | - | if (!vgdev->has_resource_blob) | |
| 352 | + | if (!vgdev->has_resource_blob || vgdev->has_virgl_3d) | |
| 355 | 353 | return drm_gem_prime_import(dev, buf); | |
| 356 | 354 | ||
| 357 | 355 | bo = kzalloc_obj(*bo); | |
modified drivers/gpu/drm/virtio/virtgpu_submit.c
| @@ -389,10 +389,13 @@ static int virtio_gpu_init_submit(struct virtio_gpu_submit *submit, | |||
| 389 | 389 | if ((exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_OUT) || | |
| 390 | 390 | exbuf->num_out_syncobjs || | |
| 391 | 391 | exbuf->num_bo_handles || | |
| 392 | - | drm_fence_event) | |
| 392 | + | drm_fence_event) { | |
| 393 | 393 | out_fence = virtio_gpu_fence_alloc(vgdev, fence_ctx, ring_idx); | |
| 394 | - | else | |
| 394 | + | if (!out_fence) | |
| 395 | + | return -ENOMEM; | |
| 396 | + | } else { | |
| 395 | 397 | out_fence = NULL; | |
| 398 | + | } | |
| 396 | 399 | ||
| 397 | 400 | if (drm_fence_event) { | |
| 398 | 401 | err = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx); | |
| @@ -538,6 +541,10 @@ int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, | |||
| 538 | 541 | virtio_gpu_process_post_deps(&submit); | |
| 539 | 542 | virtio_gpu_complete_submit(&submit); | |
| 540 | 543 | cleanup: | |
| 544 | + | if (ret && submit.out_fence && submit.out_fence->e) { | |
| 545 | + | drm_event_cancel_free(dev, &submit.out_fence->e->base); | |
| 546 | + | submit.out_fence->e = NULL; | |
| 547 | + | } | |
| 541 | 548 | virtio_gpu_cleanup_submit(&submit); | |
| 542 | 549 | ||
| 543 | 550 | return ret; | |
modified drivers/gpu/drm/virtio/virtgpu_vq.c
| @@ -208,6 +208,21 @@ static void free_vbuf(struct virtio_gpu_device *vgdev, | |||
| 208 | 208 | kmem_cache_free(vgdev->vbufs, vbuf); | |
| 209 | 209 | } | |
| 210 | 210 | ||
| 211 | + | void virtio_gpu_reclaim_vbufs(struct virtio_gpu_device *vgdev) | |
| 212 | + | { | |
| 213 | + | struct virtio_gpu_vbuffer *vbuf; | |
| 214 | + | ||
| 215 | + | while ((vbuf = virtqueue_detach_unused_buf(vgdev->ctrlq.vq))) { | |
| 216 | + | if (vbuf->objs) | |
| 217 | + | virtio_gpu_array_put_free(vbuf->objs); | |
| 218 | + | if (vbuf->resp_cb_data) | |
| 219 | + | virtio_gpu_cleanup_object(vbuf->resp_cb_data); | |
| 220 | + | free_vbuf(vgdev, vbuf); | |
| 221 | + | } | |
| 222 | + | while ((vbuf = virtqueue_detach_unused_buf(vgdev->cursorq.vq))) | |
| 223 | + | free_vbuf(vgdev, vbuf); | |
| 224 | + | } | |
| 225 | + | ||
| 211 | 226 | static void reclaim_vbufs(struct virtqueue *vq, struct list_head *reclaim_list) | |
| 212 | 227 | { | |
| 213 | 228 | struct virtio_gpu_vbuffer *vbuf; | |
| @@ -241,6 +256,33 @@ void virtio_gpu_dequeue_ctrl_func(struct work_struct *work) | |||
| 241 | 256 | } while (!virtqueue_enable_cb(vgdev->ctrlq.vq)); | |
| 242 | 257 | spin_unlock(&vgdev->ctrlq.qlock); | |
| 243 | 258 | ||
| 259 | + | /* | |
| 260 | + | * Sync guest-bound transfers before signalling anything, so that a | |
| 261 | + | * waiter cannot read the backing pages while what the device wrote is | |
| 262 | + | * still in a bounce buffer. This cannot be folded into the loop below: | |
| 263 | + | * virtio_gpu_fence_event_process() also signals every earlier fence in | |
| 264 | + | * the same context, so any entry there may signal this entry's fence. | |
| 265 | + | */ | |
| 266 | + | list_for_each_entry(entry, &reclaim_list, list) { | |
| 267 | + | if (entry->sync_for_cpu) { | |
| 268 | + | struct virtio_gpu_object *bo = | |
| 269 | + | gem_to_virtio_gpu_obj(entry->objs->objs[0]); | |
| 270 | + | ||
| 271 | + | dma_sync_sgtable_for_cpu(vgdev->vdev->dev.parent, | |
| 272 | + | bo->base.sgt, DMA_FROM_DEVICE); | |
| 273 | + | /* | |
| 274 | + | * Release, so a transfer the other way that skips its | |
| 275 | + | * wait on the strength of this cannot go on to read | |
| 276 | + | * the backing pages before the sync above is visible. | |
| 277 | + | * Nothing orders the two otherwise: where the mapping | |
| 278 | + | * bounces on a coherent device the sync is a plain | |
| 279 | + | * copy, and dma_direct_sync_sg_for_cpu() emits its | |
| 280 | + | * barrier only for the non-coherent case. | |
| 281 | + | */ | |
| 282 | + | smp_store_release(&bo->from_host_pending, false); | |
| 283 | + | } | |
| 284 | + | } | |
| 285 | + | ||
| 244 | 286 | list_for_each_entry(entry, &reclaim_list, list) { | |
| 245 | 287 | resp = (struct virtio_gpu_ctrl_hdr *)entry->resp_buf; | |
| 246 | 288 | ||
| @@ -764,7 +806,7 @@ int virtio_gpu_panic_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev, | |||
| 764 | 806 | struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]); | |
| 765 | 807 | struct virtio_gpu_transfer_to_host_2d *cmd_p; | |
| 766 | 808 | struct virtio_gpu_vbuffer *vbuf; | |
| 767 | - | bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev); | |
| 809 | + | bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev); | |
| 768 | 810 | ||
| 769 | 811 | if (virtio_gpu_is_shmem(bo) && use_dma_api) | |
| 770 | 812 | dma_sync_sgtable_for_device(vgdev->vdev->dev.parent, | |
| @@ -795,7 +837,7 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev, | |||
| 795 | 837 | struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]); | |
| 796 | 838 | struct virtio_gpu_transfer_to_host_2d *cmd_p; | |
| 797 | 839 | struct virtio_gpu_vbuffer *vbuf; | |
| 798 | - | bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev); | |
| 840 | + | bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev); | |
| 799 | 841 | ||
| 800 | 842 | if (virtio_gpu_is_shmem(bo) && use_dma_api) | |
| 801 | 843 | dma_sync_sgtable_for_device(vgdev->vdev->dev.parent, | |
| @@ -1228,7 +1270,7 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev, | |||
| 1228 | 1270 | struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]); | |
| 1229 | 1271 | struct virtio_gpu_transfer_host_3d *cmd_p; | |
| 1230 | 1272 | struct virtio_gpu_vbuffer *vbuf; | |
| 1231 | - | bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev); | |
| 1273 | + | bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev); | |
| 1232 | 1274 | ||
| 1233 | 1275 | if (virtio_gpu_is_shmem(bo) && use_dma_api) | |
| 1234 | 1276 | dma_sync_sgtable_for_device(vgdev->vdev->dev.parent, | |
| @@ -1263,12 +1305,31 @@ void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev, | |||
| 1263 | 1305 | struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]); | |
| 1264 | 1306 | struct virtio_gpu_transfer_host_3d *cmd_p; | |
| 1265 | 1307 | struct virtio_gpu_vbuffer *vbuf; | |
| 1308 | + | bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev); | |
| 1266 | 1309 | ||
| 1267 | 1310 | cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); | |
| 1268 | 1311 | memset(cmd_p, 0, sizeof(*cmd_p)); | |
| 1269 | 1312 | ||
| 1270 | 1313 | vbuf->objs = objs; | |
| 1271 | 1314 | ||
| 1315 | + | if (virtio_gpu_is_shmem(bo) && use_dma_api) { | |
| 1316 | + | /* | |
| 1317 | + | * The device writes only the requested box, so prime the | |
| 1318 | + | * mapping with the current contents: otherwise the sync on | |
| 1319 | + | * completion would hand back whatever a bounce buffer held for | |
| 1320 | + | * the regions the device does not touch. | |
| 1321 | + | */ | |
| 1322 | + | dma_sync_sgtable_for_device(vgdev->vdev->dev.parent, | |
| 1323 | + | bo->base.sgt, DMA_TO_DEVICE); | |
| 1324 | + | vbuf->sync_for_cpu = true; | |
| 1325 | + | /* | |
| 1326 | + | * Set under the reservation the caller holds, so a transfer | |
| 1327 | + | * the other way cannot miss it and push the guest pages into | |
| 1328 | + | * the mapping while the device still owns it. | |
| 1329 | + | */ | |
| 1330 | + | WRITE_ONCE(bo->from_host_pending, true); | |
| 1331 | + | } | |
| 1332 | + | ||
| 1272 | 1333 | cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D); | |
| 1273 | 1334 | cmd_p->hdr.ctx_id = cpu_to_le32(ctx_id); | |
| 1274 | 1335 | cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); | |
modified drivers/gpu/drm/virtio/virtgpu_vram.c
| @@ -215,16 +215,12 @@ int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev, | |||
| 215 | 215 | ||
| 216 | 216 | /* Create fake offset */ | |
| 217 | 217 | ret = drm_gem_create_mmap_offset(obj); | |
| 218 | - | if (ret) { | |
| 219 | - | kfree(vram); | |
| 220 | - | return ret; | |
| 221 | - | } | |
| 218 | + | if (ret) | |
| 219 | + | goto err_release_obj; | |
| 222 | 220 | ||
| 223 | 221 | ret = virtio_gpu_resource_id_get(vgdev, &vram->base.hw_res_handle); | |
| 224 | - | if (ret) { | |
| 225 | - | kfree(vram); | |
| 226 | - | return ret; | |
| 227 | - | } | |
| 222 | + | if (ret) | |
| 223 | + | goto err_release_obj; | |
| 228 | 224 | ||
| 229 | 225 | virtio_gpu_cmd_resource_create_blob(vgdev, &vram->base, params, NULL, | |
| 230 | 226 | 0); | |
| @@ -240,6 +236,11 @@ int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev, | |||
| 240 | 236 | ||
| 241 | 237 | *bo_ptr = &vram->base; | |
| 242 | 238 | return 0; | |
| 239 | + | ||
| 240 | + | err_release_obj: | |
| 241 | + | drm_gem_object_release(obj); | |
| 242 | + | kfree(vram); | |
| 243 | + | return ret; | |
| 243 | 244 | } | |
| 244 | 245 | ||
| 245 | 246 | void virtio_gpu_vram_map_deferred(struct virtio_gpu_object_vram *vram) | |
modified drivers/gpu/drm/vkms/vkms_configfs.c
| @@ -212,7 +212,7 @@ static struct config_group *make_crtc_group(struct config_group *group, | |||
| 212 | 212 | if (dev->enabled) | |
| 213 | 213 | return ERR_PTR(-EBUSY); | |
| 214 | 214 | ||
| 215 | - | crtc = kzalloc(sizeof(*crtc), GFP_KERNEL); | |
| 215 | + | crtc = kzalloc_obj(*crtc); | |
| 216 | 216 | if (!crtc) | |
| 217 | 217 | return ERR_PTR(-ENOMEM); | |
| 218 | 218 | ||
| @@ -368,7 +368,7 @@ static struct config_group *make_plane_group(struct config_group *group, | |||
| 368 | 368 | if (dev->enabled) | |
| 369 | 369 | return ERR_PTR(-EBUSY); | |
| 370 | 370 | ||
| 371 | - | plane = kzalloc(sizeof(*plane), GFP_KERNEL); | |
| 371 | + | plane = kzalloc_obj(*plane); | |
| 372 | 372 | if (!plane) | |
| 373 | 373 | return ERR_PTR(-ENOMEM); | |
| 374 | 374 | ||
| @@ -484,7 +484,7 @@ static struct config_group *make_encoder_group(struct config_group *group, | |||
| 484 | 484 | if (dev->enabled) | |
| 485 | 485 | return ERR_PTR(-EBUSY); | |
| 486 | 486 | ||
| 487 | - | encoder = kzalloc(sizeof(*encoder), GFP_KERNEL); | |
| 487 | + | encoder = kzalloc_obj(*encoder); | |
| 488 | 488 | if (!encoder) | |
| 489 | 489 | return ERR_PTR(-ENOMEM); | |
| 490 | 490 | ||
| @@ -651,7 +651,7 @@ static struct config_group *make_connector_group(struct config_group *group, | |||
| 651 | 651 | if (dev->enabled) | |
| 652 | 652 | return ERR_PTR(-EBUSY); | |
| 653 | 653 | ||
| 654 | - | connector = kzalloc(sizeof(*connector), GFP_KERNEL); | |
| 654 | + | connector = kzalloc_obj(*connector); | |
| 655 | 655 | if (!connector) | |
| 656 | 656 | return ERR_PTR(-ENOMEM); | |
| 657 | 657 | ||
modified drivers/gpu/drm/xe/instructions/xe_gpu_commands.h
| @@ -46,6 +46,7 @@ | |||
| 46 | 46 | #define GFX_OP_PIPE_CONTROL(len) ((0x3<<29)|(0x3<<27)|(0x2<<24)|((len)-2)) | |
| 47 | 47 | ||
| 48 | 48 | #define PIPE_CONTROL0_QUEUE_DRAIN_MODE BIT(12) | |
| 49 | + | #define PIPE_CONTROL0_UNTYPED_DATAPORT_CACHE_FLUSH BIT(11) /* gen12 */ | |
| 49 | 50 | #define PIPE_CONTROL0_L3_READ_ONLY_CACHE_INVALIDATE BIT(10) /* gen12 */ | |
| 50 | 51 | #define PIPE_CONTROL0_HDC_PIPELINE_FLUSH BIT(9) /* gen12 */ | |
| 51 | 52 | ||
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_amc.c
| @@ -177,7 +177,7 @@ int xe_amc_init(struct xe_i2c *i2c) | |||
| 177 | 177 | { | |
| 178 | 178 | struct xe_amc *amc; | |
| 179 | 179 | ||
| 180 | - | amc = kzalloc(sizeof(*amc), GFP_KERNEL); | |
| 180 | + | amc = kzalloc_obj(*amc); | |
| 181 | 181 | if (!amc) | |
| 182 | 182 | return -ENOMEM; | |
| 183 | 183 | ||
modified drivers/gpu/drm/xe/xe_bo.c
| @@ -1037,6 +1037,13 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict, | |||
| 1037 | 1037 | } else { | |
| 1038 | 1038 | drm_dbg(&xe->drm, "Evict system allocator BO failed=%pe\n", | |
| 1039 | 1039 | ERR_PTR(ret)); | |
| 1040 | + | /* | |
| 1041 | + | * The semantic we want upon SVM eviction failure | |
| 1042 | + | * because of racing access is keep walking for | |
| 1043 | + | * eviction, which is -ENOSPC. | |
| 1044 | + | */ | |
| 1045 | + | if (ret == -EBUSY) | |
| 1046 | + | ret = -ENOSPC; | |
| 1040 | 1047 | } | |
| 1041 | 1048 | ||
| 1042 | 1049 | goto out; | |
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" | |
| @@ -575,6 +577,23 @@ static inline unsigned int xe_sg_segment_size(struct device *dev) | |||
| 575 | 577 | struct scatterlist __maybe_unused sg; | |
| 576 | 578 | size_t max = BIT_ULL(sizeof(sg.length) * 8) - 1; | |
| 577 | 579 | ||
| 580 | + | /* | |
| 581 | + | * For Xen PV guests pages aren't contiguous in DMA (machine) address | |
| 582 | + | * space. The DMA API takes care of that both in dma_alloc_* (by | |
| 583 | + | * calling into the hypervisor to make the pages contiguous) and in | |
| 584 | + | * dma_map_* (by bounce buffering). But xe (like i915, see commit | |
| 585 | + | * 78a07fe777c4) ignores the coherency aspects of the DMA API and thus | |
| 586 | + | * can't cope with bounce buffering actually happening, so add a hack | |
| 587 | + | * here to force small allocations and mappings when running in PV | |
| 588 | + | * mode on Xen. | |
| 589 | + | * | |
| 590 | + | * Note this will still break if bounce buffering is required for other | |
| 591 | + | * reasons, like confidential computing hypervisors or PCIe root ports | |
| 592 | + | * with addressing limitations. | |
| 593 | + | */ | |
| 594 | + | if (xen_pv_domain()) | |
| 595 | + | return PAGE_SIZE; | |
| 596 | + | ||
| 578 | 597 | max = min_t(size_t, max, dma_max_mapping_size(dev)); | |
| 579 | 598 | ||
| 580 | 599 | /* | |
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,8 +318,10 @@ 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 | ||
| 325 | 327 | for (i = 0; i < XE_I2C_MAX_CLIENTS; i++) { | |
| @@ -329,6 +331,7 @@ static void xe_i2c_remove(void *data) | |||
| 329 | 331 | ||
| 330 | 332 | bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier); | |
| 331 | 333 | xe_i2c_unregister_adapter(i2c); | |
| 334 | + | xe->i2c = NULL; | |
| 332 | 335 | } | |
| 333 | 336 | ||
| 334 | 337 | /** | |
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_oa.c
| @@ -2435,9 +2435,9 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi | |||
| 2435 | 2435 | ||
| 2436 | 2436 | oa_config->id = idr_alloc(&oa->metrics_idr, oa_config, 1, 0, GFP_KERNEL); | |
| 2437 | 2437 | if (oa_config->id < 0) { | |
| 2438 | - | drm_dbg(&oa->xe->drm, "Failed to create sysfs entry for OA config\n"); | |
| 2438 | + | drm_dbg(&oa->xe->drm, "Failed to allocate id for OA config\n"); | |
| 2439 | 2439 | err = oa_config->id; | |
| 2440 | - | goto sysfs_err; | |
| 2440 | + | goto id_alloc_err; | |
| 2441 | 2441 | } | |
| 2442 | 2442 | ||
| 2443 | 2443 | id = oa_config->id; | |
| @@ -2448,6 +2448,8 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi | |||
| 2448 | 2448 | ||
| 2449 | 2449 | return id; | |
| 2450 | 2450 | ||
| 2451 | + | id_alloc_err: | |
| 2452 | + | sysfs_remove_group(oa->metrics_kobj, &oa_config->sysfs_metric); | |
| 2451 | 2453 | sysfs_err: | |
| 2452 | 2454 | mutex_unlock(&oa->metrics_lock); | |
| 2453 | 2455 | reg_err: | |
modified drivers/gpu/drm/xe/xe_pagefault.c
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | #include "xe_hw_engine.h" | |
| 17 | 17 | #include "xe_pagefault.h" | |
| 18 | 18 | #include "xe_pagefault_types.h" | |
| 19 | + | #include "xe_pm.h" | |
| 19 | 20 | #include "xe_svm.h" | |
| 20 | 21 | #include "xe_trace_bo.h" | |
| 21 | 22 | #include "xe_vm.h" | |
| @@ -292,9 +293,17 @@ static void xe_pagefault_queue_work(struct work_struct *w) | |||
| 292 | 293 | { | |
| 293 | 294 | struct xe_pagefault_queue *pf_queue = | |
| 294 | 295 | container_of(w, typeof(*pf_queue), worker); | |
| 296 | + | struct xe_device *xe = pf_queue->xe; | |
| 295 | 297 | struct xe_pagefault pf; | |
| 296 | 298 | unsigned long threshold; | |
| 297 | 299 | ||
| 300 | + | /* | |
| 301 | + | * A live VM holds a PM reference, but a torn-down VM does not. | |
| 302 | + | * Guard the entire worker loop to safely drain stale faults and | |
| 303 | + | * prevent autosuspends from desyncing batched CT flushes. | |
| 304 | + | */ | |
| 305 | + | guard(xe_pm_runtime)(xe); | |
| 306 | + | ||
| 298 | 307 | #define USM_QUEUE_MAX_RUNTIME_MS 20 | |
| 299 | 308 | threshold = jiffies + msecs_to_jiffies(USM_QUEUE_MAX_RUNTIME_MS); | |
| 300 | 309 | ||
| @@ -365,6 +374,7 @@ static int xe_pagefault_queue_init(struct xe_device *xe, | |||
| 365 | 374 | drm_dbg(&xe->drm, "xe_pagefault_entry_size=%d, total_num_eus=%d, pf_queue->size=%u", | |
| 366 | 375 | xe_pagefault_entry_size(), total_num_eus, pf_queue->size); | |
| 367 | 376 | ||
| 377 | + | pf_queue->xe = xe; | |
| 368 | 378 | spin_lock_init(&pf_queue->lock); | |
| 369 | 379 | INIT_WORK(&pf_queue->worker, xe_pagefault_queue_work); | |
| 370 | 380 | ||
modified drivers/gpu/drm/xe/xe_pagefault_types.h
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | 9 | #include <linux/workqueue.h> | |
| 10 | 10 | ||
| 11 | + | struct xe_device; | |
| 11 | 12 | struct xe_gt; | |
| 12 | 13 | struct xe_pagefault; | |
| 13 | 14 | ||
| @@ -118,6 +119,8 @@ struct xe_pagefault { | |||
| 118 | 119 | * queue to absorb the device’s worst-case number of outstanding faults. | |
| 119 | 120 | */ | |
| 120 | 121 | struct xe_pagefault_queue { | |
| 122 | + | /** @xe: Back-pointer to the Xe device */ | |
| 123 | + | struct xe_device *xe; | |
| 121 | 124 | /** | |
| 122 | 125 | * @data: Data in queue containing struct xe_pagefault, protected by | |
| 123 | 126 | * @lock | |
modified drivers/gpu/drm/xe/xe_ring_ops.c
| @@ -212,6 +212,7 @@ static int emit_render_cache_flush(struct xe_sched_job *job, u32 *dw, int i) | |||
| 212 | 212 | { | |
| 213 | 213 | struct xe_exec_queue *q = job->q; | |
| 214 | 214 | struct xe_gt *gt = q->gt; | |
| 215 | + | struct xe_device *xe = gt_to_xe(gt); | |
| 215 | 216 | bool lacks_render = !(gt->info.engine_mask & XE_HW_ENGINE_RCS_MASK); | |
| 216 | 217 | u32 flags0, flags1; | |
| 217 | 218 | ||
| @@ -220,6 +221,16 @@ static int emit_render_cache_flush(struct xe_sched_job *job, u32 *dw, int i) | |||
| 220 | 221 | LRC_PPHWSP_FLUSH_INVAL_SCRATCH_ADDR, 0); | |
| 221 | 222 | ||
| 222 | 223 | flags0 = PIPE_CONTROL0_HDC_PIPELINE_FLUSH; | |
| 224 | + | /* | |
| 225 | + | * Prior to MTL, HDC Pipeline Flush reliably also flushes the LSC | |
| 226 | + | * untyped L1 dataport cache, provided HDC_CHICKEN0 is programmed | |
| 227 | + | * correctly. Starting with MTL that coupling no longer holds | |
| 228 | + | * regardless of how HDC_CHICKEN0 is programmed, but explicitly | |
| 229 | + | * requesting the flush via PIPE_CONTROL is itself only reliable | |
| 230 | + | * from Xe2 onward, so only gate it in on Xe2+. | |
| 231 | + | */ | |
| 232 | + | if (GRAPHICS_VERx100(xe) >= 2000) | |
| 233 | + | flags0 |= PIPE_CONTROL0_UNTYPED_DATAPORT_CACHE_FLUSH; | |
| 223 | 234 | flags1 = (PIPE_CONTROL_TILE_CACHE_FLUSH | | |
| 224 | 235 | PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH | | |
| 225 | 236 | PIPE_CONTROL_DEPTH_CACHE_FLUSH | | |
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_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); | |
| @@ -4148,7 +4145,7 @@ static int fill_faults(struct xe_vm *vm, | |||
| 4148 | 4145 | entry_size = sizeof(struct xe_vm_fault); | |
| 4149 | 4146 | count = args->size / entry_size; | |
| 4150 | 4147 | ||
| 4151 | - | fault_list = kcalloc(count, sizeof(struct xe_vm_fault), GFP_KERNEL); | |
| 4148 | + | fault_list = kzalloc_objs(struct xe_vm_fault, count); | |
| 4152 | 4149 | if (!fault_list) | |
| 4153 | 4150 | return -ENOMEM; | |
| 4154 | 4151 | ||
modified drivers/gpu/drm/xe/xe_vram.c
| @@ -90,6 +90,9 @@ static int get_flat_ccs_offset(struct xe_gt *gt, u64 tile_size, u64 *poffset) | |||
| 90 | 90 | offset |= offset_lo << 6; /* HW view bits 31:6 */ | |
| 91 | 91 | offset *= num_enabled; /* convert to SW view */ | |
| 92 | 92 | ||
| 93 | + | drm_info(&xe->drm, "FLAT_CCS base:%llx, aligned:%s\n", offset, | |
| 94 | + | str_yes_no(IS_ALIGNED(offset, SZ_128K))); | |
| 95 | + | ||
| 93 | 96 | /* | |
| 94 | 97 | * Everything below this offset is handed to the VRAM | |
| 95 | 98 | * allocator, so it has to be the *first* address the | |
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" | |
| @@ -1253,7 +1254,7 @@ config HID_HYPERV_MOUSE | |||
| 1253 | 1254 | ||
| 1254 | 1255 | config HID_HYPERV_MOUSE_KUNIT_TEST | |
| 1255 | 1256 | bool "KUnit tests for Hyper-V mouse driver" if !KUNIT_ALL_TESTS | |
| 1256 | - | depends on KUNIT && HID_HYPERV_MOUSE | |
| 1257 | + | depends on KUNIT && (HID_HYPERV_MOUSE = KUNIT || KUNIT = y) | |
| 1257 | 1258 | default KUNIT_ALL_TESTS | |
| 1258 | 1259 | help | |
| 1259 | 1260 | Builds unit tests for the Hyper-V synthetic HID driver. | |
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 | ||
| @@ -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/bpf/hid_bpf_struct_ops.c
| @@ -62,6 +62,10 @@ struct hid_bpf_offset_write_range { | |||
| 62 | 62 | u32 end; | |
| 63 | 63 | }; | |
| 64 | 64 | ||
| 65 | + | struct hid_bpf_ctx__safe_trusted { | |
| 66 | + | struct hid_device *hid; | |
| 67 | + | }; | |
| 68 | + | ||
| 65 | 69 | static int hid_bpf_ops_btf_struct_access(struct bpf_verifier_log *log, | |
| 66 | 70 | const struct bpf_reg_state *reg, | |
| 67 | 71 | int off, int size) | |
| @@ -86,6 +90,8 @@ static int hid_bpf_ops_btf_struct_access(struct bpf_verifier_log *log, | |||
| 86 | 90 | const char *cur = NULL; | |
| 87 | 91 | int i; | |
| 88 | 92 | ||
| 93 | + | BTF_TYPE_EMIT(struct hid_bpf_ctx__safe_trusted); | |
| 94 | + | ||
| 89 | 95 | t = btf_type_by_id(reg->btf, reg->btf_id); | |
| 90 | 96 | ||
| 91 | 97 | for (i = 0; i < ARRAY_SIZE(write_ranges); i++) { | |
| @@ -250,6 +256,11 @@ static void hid_bpf_unreg(void *kdata, struct bpf_link *link) | |||
| 250 | 256 | ||
| 251 | 257 | mutex_lock(&hdev->bpf.prog_list_lock); | |
| 252 | 258 | ||
| 259 | + | if (!ops->hdev) { | |
| 260 | + | mutex_unlock(&hdev->bpf.prog_list_lock); | |
| 261 | + | return; | |
| 262 | + | } | |
| 263 | + | ||
| 253 | 264 | list_del_rcu(&ops->list); | |
| 254 | 265 | synchronize_srcu(&hdev->bpf.srcu); | |
| 255 | 266 | ops->hdev = NULL; | |
| @@ -310,13 +321,17 @@ static struct bpf_struct_ops bpf_hid_bpf_ops = { | |||
| 310 | 321 | void __hid_bpf_ops_destroy_device(struct hid_device *hdev) | |
| 311 | 322 | { | |
| 312 | 323 | struct hid_bpf_ops *e; | |
| 324 | + | int count = 0; | |
| 313 | 325 | ||
| 314 | - | rcu_read_lock(); | |
| 315 | - | list_for_each_entry_rcu(e, &hdev->bpf.prog_list, list) { | |
| 316 | - | hid_put_device(hdev); | |
| 326 | + | mutex_lock(&hdev->bpf.prog_list_lock); | |
| 327 | + | list_for_each_entry(e, &hdev->bpf.prog_list, list) { | |
| 317 | 328 | e->hdev = NULL; | |
| 329 | + | count++; | |
| 318 | 330 | } | |
| 319 | - | rcu_read_unlock(); | |
| 331 | + | mutex_unlock(&hdev->bpf.prog_list_lock); | |
| 332 | + | ||
| 333 | + | while (count--) | |
| 334 | + | hid_put_device(hdev); | |
| 320 | 335 | } | |
| 321 | 336 | ||
| 322 | 337 | static int __init hid_bpf_struct_ops_init(void) | |
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-asus.c
| @@ -406,7 +406,7 @@ static int asus_kbd_fn_lock_set(struct asus_drvdata *drvdata, bool enabled) | |||
| 406 | 406 | struct asus_work_action *action; | |
| 407 | 407 | unsigned long flags; | |
| 408 | 408 | ||
| 409 | - | action = kzalloc(sizeof(struct asus_work_action), GFP_ATOMIC); | |
| 409 | + | action = kzalloc_obj(struct asus_work_action, GFP_ATOMIC); | |
| 410 | 410 | if (!action) | |
| 411 | 411 | return -ENOMEM; | |
| 412 | 412 | ||
| @@ -433,7 +433,7 @@ static int asus_kbd_wmi_fan_send(struct asus_drvdata *drvdata, u8 *report_data, | |||
| 433 | 433 | return -EINVAL; | |
| 434 | 434 | } | |
| 435 | 435 | ||
| 436 | - | action = kzalloc(sizeof(struct asus_work_action), GFP_NOWAIT); | |
| 436 | + | action = kzalloc_obj(struct asus_work_action, GFP_NOWAIT); | |
| 437 | 437 | if (!action) | |
| 438 | 438 | return -ENOMEM; | |
| 439 | 439 | ||
| @@ -746,7 +746,7 @@ static void asus_kbd_backlight_set(struct asus_hid_listener *listener, int brigh | |||
| 746 | 746 | ||
| 747 | 747 | drvdata->kbd_backlight_brightness = brightness; | |
| 748 | 748 | ||
| 749 | - | action = kzalloc(sizeof(struct asus_work_action), GFP_NOWAIT); | |
| 749 | + | action = kzalloc_obj(struct asus_work_action, GFP_NOWAIT); | |
| 750 | 750 | if (!action) | |
| 751 | 751 | return; | |
| 752 | 752 | ||
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-hyperv.c
| @@ -687,7 +687,7 @@ static void mousevsc_device_info_valid_descriptor(struct kunit *test) | |||
| 687 | 687 | ||
| 688 | 688 | info->hid_descriptor.bLength = sizeof(struct hid_descriptor); | |
| 689 | 689 | info->hid_descriptor.rpt_desc.wDescriptorLength = cpu_to_le16(4); | |
| 690 | - | report = ((u8 *)&info->hid_descriptor) + info->hid_descriptor.bLength; | |
| 690 | + | report = (u8 *)(info + 1); | |
| 691 | 691 | memset(report, 0x42, 4); | |
| 692 | 692 | ||
| 693 | 693 | mousevsc_on_receive_device_info(input_dev, info, sizeof(*info) + 4); | |
| @@ -713,7 +713,7 @@ static void mousevsc_device_info_report_desc_oob(struct kunit *test) | |||
| 713 | 713 | ||
| 714 | 714 | info->hid_descriptor.bLength = sizeof(struct hid_descriptor); | |
| 715 | 715 | info->hid_descriptor.rpt_desc.wDescriptorLength = cpu_to_le16(64); | |
| 716 | - | report = ((u8 *)&info->hid_descriptor) + info->hid_descriptor.bLength; | |
| 716 | + | report = (u8 *)(info + 1); | |
| 717 | 717 | memset(report, 0x42, 8); | |
| 718 | 718 | ||
| 719 | 719 | mousevsc_on_receive_device_info(input_dev, info, sizeof(*info) + 8); | |
modified drivers/hid/hid-ids.h
| @@ -338,6 +338,7 @@ | |||
| 338 | 338 | ||
| 339 | 339 | #define I2C_VENDOR_ID_CIRQUE 0x0488 | |
| 340 | 340 | #define I2C_PRODUCT_ID_CIRQUE_1063 0x1063 | |
| 341 | + | #define I2C_PRODUCT_ID_CIRQUE_D0C1 0xD0C1 | |
| 341 | 342 | ||
| 342 | 343 | #define USB_VENDOR_ID_CJTOUCH 0x24b8 | |
| 343 | 344 | #define USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0020 0x0020 | |
| @@ -476,7 +477,8 @@ | |||
| 476 | 477 | #define USB_DEVICE_ID_ELECOM_M_XT3URBK_018F 0x018f | |
| 477 | 478 | #define USB_DEVICE_ID_ELECOM_M_XT3DRBK_00FC 0x00fc | |
| 478 | 479 | #define USB_DEVICE_ID_ELECOM_M_XT3DRBK_018C 0x018c | |
| 479 | - | #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 | |
| 480 | 482 | #define USB_DEVICE_ID_ELECOM_M_DT1URBK 0x00fe | |
| 481 | 483 | #define USB_DEVICE_ID_ELECOM_M_DT1DRBK 0x00ff | |
| 482 | 484 | #define USB_DEVICE_ID_ELECOM_M_DT2DRBK 0x018d | |
| @@ -764,6 +766,7 @@ | |||
| 764 | 766 | #define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720 0x837a | |
| 765 | 767 | #define USB_DEVICE_ID_ITE_LENOVO_YOGA900 0x8396 | |
| 766 | 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 | |
| 767 | 770 | #define USB_DEVICE_ID_ITE8595 0x8595 | |
| 768 | 771 | #define USB_DEVICE_ID_ITE_MEDION_E1239T 0xce50 | |
| 769 | 772 | ||
| @@ -1295,6 +1298,9 @@ | |||
| 1295 | 1298 | #define USB_DEVICE_ID_SAMSUNG_WIRELESS_UNIVERSAL_KBD 0xa006 | |
| 1296 | 1299 | #define USB_DEVICE_ID_SAMSUNG_WIRELESS_MULTI_HOGP_KBD 0xa064 | |
| 1297 | 1300 | ||
| 1301 | + | #define USB_VENDOR_ID_SDINNOVATION 0x36ae | |
| 1302 | + | #define USB_DEVICE_ID_SDINNOVATION_GAMING_KBD 0xfeab | |
| 1303 | + | ||
| 1298 | 1304 | #define USB_VENDOR_ID_SEMICO 0x1a2c | |
| 1299 | 1305 | #define USB_DEVICE_ID_SEMICO_USB_KEYKOARD 0x0023 | |
| 1300 | 1306 | #define USB_DEVICE_ID_SEMICO_USB_KEYKOARD2 0x0027 | |
| @@ -1394,6 +1400,7 @@ | |||
| 1394 | 1400 | #define USB_VENDOR_ID_STEELSERIES 0x1038 | |
| 1395 | 1401 | #define USB_DEVICE_ID_STEELSERIES_SRWS1 0x1410 | |
| 1396 | 1402 | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_1_X 0x12b6 | |
| 1403 | + | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_7_2018 0x12ad | |
| 1397 | 1404 | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_9 0x12c2 | |
| 1398 | 1405 | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_NOVA_5_X 0x2253 | |
| 1399 | 1406 | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_NOVA_7 0x2202 | |
modified drivers/hid/hid-logitech-hidpp.c
| @@ -4924,6 +4924,8 @@ static const struct hid_device_id hidpp_devices[] = { | |||
| 4924 | 4924 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC08D) }, | |
| 4925 | 4925 | { /* Logitech G502 X Plus Wireless Gaming Mouse over USB */ | |
| 4926 | 4926 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC095) }, | |
| 4927 | + | { /* Logitech G502 X Lightspeed Wireless Gaming Mouse over USB */ | |
| 4928 | + | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC098) }, | |
| 4927 | 4929 | { /* Logitech G703 Gaming Mouse over USB */ | |
| 4928 | 4930 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC087) }, | |
| 4929 | 4931 | { /* 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 | } | |
| @@ -1321,21 +1340,18 @@ static void mt_touch_report(struct hid_device *hid, | |||
| 1321 | 1340 | * Includes multi-packet support where subsequent | |
| 1322 | 1341 | * packets are sent with zero contactcount. | |
| 1323 | 1342 | */ | |
| 1324 | - | if (contact_count >= 0) { | |
| 1343 | + | if (contact_count > 0) | |
| 1344 | + | app->num_expected = contact_count; | |
| 1345 | + | else if (app->num_received == 0 && app->prev_scantime != scantime) { | |
| 1325 | 1346 | /* | |
| 1347 | + | * New multi-report frame: | |
| 1348 | + | * | |
| 1326 | 1349 | * For Win8 PTPs the first packet (td->num_received == 0) may | |
| 1327 | 1350 | * have a contactcount of 0 if there only is a button event. | |
| 1328 | - | * We double check that this is not a continuation packet | |
| 1329 | - | * of a possible multi-packet frame be checking that the | |
| 1330 | - | * timestamp has changed. | |
| 1351 | + | * | |
| 1352 | + | * Some other devices use a sentinel frame with 0 to release all contacts | |
| 1331 | 1353 | */ | |
| 1332 | - | if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && | |
| 1333 | - | app->num_received == 0 && | |
| 1334 | - | app->prev_scantime != scantime) | |
| 1335 | - | app->num_expected = contact_count; | |
| 1336 | - | /* A non 0 contact count always indicates a first packet */ | |
| 1337 | - | else if (contact_count) | |
| 1338 | - | app->num_expected = contact_count; | |
| 1354 | + | app->num_expected = 0; | |
| 1339 | 1355 | } | |
| 1340 | 1356 | app->prev_scantime = scantime; | |
| 1341 | 1357 | ||
| @@ -2718,6 +2734,12 @@ static const struct hid_device_id mt_devices[] = { | |||
| 2718 | 2734 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, | |
| 2719 | 2735 | I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288) }, | |
| 2720 | 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 | + | ||
| 2721 | 2743 | /* Generic MT device */ | |
| 2722 | 2744 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) }, | |
| 2723 | 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-rmi.c
| @@ -235,7 +235,23 @@ static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr, | |||
| 235 | 235 | break; | |
| 236 | 236 | } | |
| 237 | 237 | ||
| 238 | - | read_input_count = data->readReport[1]; | |
| 238 | + | read_input_count = min_t(int, data->readReport[1], | |
| 239 | + | data->input_report_size - 2); | |
| 240 | + | if (!read_input_count) { | |
| 241 | + | /* | |
| 242 | + | * A zero length reply advances neither | |
| 243 | + | * bytes_read nor bytes_needed, and because a | |
| 244 | + | * reply did arrive the wait above does not | |
| 245 | + | * time out either, so a device answering 0 | |
| 246 | + | * forever would spin here indefinitely with | |
| 247 | + | * page_mutex held. | |
| 248 | + | */ | |
| 249 | + | hid_warn(hdev, "%s: zero-length read reply\n", | |
| 250 | + | __func__); | |
| 251 | + | clear_bit(RMI_READ_DATA_PENDING, &data->flags); | |
| 252 | + | ret = -EIO; | |
| 253 | + | break; | |
| 254 | + | } | |
| 239 | 255 | memcpy(buf + bytes_read, &data->readReport[2], | |
| 240 | 256 | min(read_input_count, bytes_needed)); | |
| 241 | 257 | ||
| @@ -271,6 +287,11 @@ static int rmi_hid_write_block(struct rmi_transport_dev *xport, u16 addr, | |||
| 271 | 287 | goto exit; | |
| 272 | 288 | } | |
| 273 | 289 | ||
| 290 | + | if (len + 4 > data->output_report_size) { | |
| 291 | + | ret = -EINVAL; | |
| 292 | + | goto exit; | |
| 293 | + | } | |
| 294 | + | ||
| 274 | 295 | data->writeReport[0] = RMI_WRITE_REPORT_ID; | |
| 275 | 296 | data->writeReport[1] = len; | |
| 276 | 297 | data->writeReport[2] = addr & 0xFF; | |
| @@ -666,8 +687,16 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 666 | 687 | return ret; | |
| 667 | 688 | } | |
| 668 | 689 | ||
| 669 | - | if (id->driver_data) | |
| 670 | - | data->device_flags = id->driver_data; | |
| 690 | + | /* | |
| 691 | + | * RMI_DEVICE can only mean "this probe validated the RMI reports and | |
| 692 | + | * allocated writeReport": every bail-out to start below skips that | |
| 693 | + | * allocation, and device_flags left carrying RMI_DEVICE from | |
| 694 | + | * driver_data would send rmi_input_configured() into rmi_set_page() | |
| 695 | + | * with writeReport still NULL. A bind through the new_id sysfs | |
| 696 | + | * attribute can supply driver_data with the bit set, so do not let | |
| 697 | + | * driver_data grant it. | |
| 698 | + | */ | |
| 699 | + | data->device_flags = id->driver_data & ~RMI_DEVICE; | |
| 671 | 700 | ||
| 672 | 701 | /* | |
| 673 | 702 | * Check for the RMI specific report ids. If they are misisng | |
| @@ -696,6 +725,17 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 696 | 725 | ||
| 697 | 726 | data->output_report_size = hid_report_len(output_report); | |
| 698 | 727 | ||
| 728 | + | /* | |
| 729 | + | * The write reports built by this driver occupy 6 bytes and the read | |
| 730 | + | * handshake looks at the first 3 bytes of an input report, so refuse | |
| 731 | + | * to drive a device whose reports cannot hold them. | |
| 732 | + | */ | |
| 733 | + | if (data->output_report_size < 6 || data->input_report_size < 3) { | |
| 734 | + | hid_err(hdev, "rmi reports too small (out=%u in=%u)\n", | |
| 735 | + | data->output_report_size, data->input_report_size); | |
| 736 | + | goto start; | |
| 737 | + | } | |
| 738 | + | ||
| 699 | 739 | data->device_flags |= RMI_DEVICE; | |
| 700 | 740 | alloc_size = data->output_report_size + data->input_report_size; | |
| 701 | 741 | ||
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-steam.c
| @@ -759,7 +759,7 @@ static inline int steam_haptic_pulse(struct steam_device *steam, u8 pad, | |||
| 759 | 759 | ||
| 760 | 760 | if (steam->quirks & STEAM_QUIRK_IBEX) { | |
| 761 | 761 | struct steam_ibex_output_report *report = | |
| 762 | - | kzalloc(sizeof(struct steam_ibex_output_report), GFP_KERNEL); | |
| 762 | + | kzalloc_obj(struct steam_ibex_output_report); | |
| 763 | 763 | ||
| 764 | 764 | if (!report) | |
| 765 | 765 | return -ENOMEM; | |
| @@ -798,7 +798,7 @@ static inline int steam_haptic_rumble(struct steam_device *steam, | |||
| 798 | 798 | ||
| 799 | 799 | if (steam->quirks & STEAM_QUIRK_IBEX) { | |
| 800 | 800 | struct steam_ibex_output_report *report = | |
| 801 | - | kzalloc(sizeof(struct steam_ibex_output_report), GFP_KERNEL); | |
| 801 | + | kzalloc_obj(struct steam_ibex_output_report); | |
| 802 | 802 | ||
| 803 | 803 | if (!report) | |
| 804 | 804 | return -ENOMEM; | |
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, | |
| @@ -469,7 +510,7 @@ static int steelseries_arctis_probe(struct hid_device *hdev, | |||
| 469 | 510 | return hid_hw_start(hdev, HID_CONNECT_DEFAULT); | |
| 470 | 511 | ||
| 471 | 512 | if (interface_num == info->sync_interface) { | |
| 472 | - | sd = kzalloc_obj(*sd, GFP_KERNEL); | |
| 513 | + | sd = kzalloc_obj(*sd); | |
| 473 | 514 | if (!sd) | |
| 474 | 515 | return -ENOMEM; | |
| 475 | 516 | ||
| @@ -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-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, | |
| @@ -136,6 +138,8 @@ static const struct i2c_hid_quirks { | |||
| 136 | 138 | I2C_HID_QUIRK_BAD_INPUT_SIZE }, | |
| 137 | 139 | { I2C_VENDOR_ID_CIRQUE, I2C_PRODUCT_ID_CIRQUE_1063, | |
| 138 | 140 | I2C_HID_QUIRK_NO_SLEEP_ON_SUSPEND }, | |
| 141 | + | { I2C_VENDOR_ID_CIRQUE, I2C_PRODUCT_ID_CIRQUE_D0C1, | |
| 142 | + | I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, | |
| 139 | 143 | /* | |
| 140 | 144 | * Without additional power on command, at least some QTEC devices send garbage | |
| 141 | 145 | */ | |
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/hid/wacom_wac.c
| @@ -1550,6 +1550,19 @@ static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len) | |||
| 1550 | 1550 | return 0; | |
| 1551 | 1551 | } | |
| 1552 | 1552 | ||
| 1553 | + | if (wacom->features.type == INTUOSP2_BT || | |
| 1554 | + | wacom->features.type == INTUOSP2S_BT) { | |
| 1555 | + | if (len < 286) { | |
| 1556 | + | dev_warn(wacom->pen_input->dev.parent, | |
| 1557 | + | "Pro2 BT report too short: %zu bytes\n", len); | |
| 1558 | + | return 0; | |
| 1559 | + | } | |
| 1560 | + | } else if (len < 46) { | |
| 1561 | + | dev_warn(wacom->pen_input->dev.parent, | |
| 1562 | + | "Pro2 BT report too short: %zu bytes\n", len); | |
| 1563 | + | return 0; | |
| 1564 | + | } | |
| 1565 | + | ||
| 1553 | 1566 | wacom_intuos_pro2_bt_pen(wacom); | |
| 1554 | 1567 | if (wacom->features.type == INTUOSP2_BT || | |
| 1555 | 1568 | wacom->features.type == INTUOSP2S_BT) { | |
modified drivers/hv/channel.c
| @@ -694,12 +694,11 @@ void *vmbus_alloc_buffer(struct vmbus_channel *channel, | |||
| 694 | 694 | return vzalloc(nr_pages << PAGE_SHIFT); | |
| 695 | 695 | ||
| 696 | 696 | /* Worst case: every chunk is a single page. */ | |
| 697 | - | chunks = kvmalloc_array(nr_pages, sizeof(*chunks), | |
| 698 | - | GFP_KERNEL | __GFP_ZERO); | |
| 697 | + | chunks = kvmalloc_objs(*chunks, nr_pages, GFP_KERNEL | __GFP_ZERO); | |
| 699 | 698 | if (!chunks) | |
| 700 | 699 | goto err; | |
| 701 | 700 | ||
| 702 | - | pages = kvmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL); | |
| 701 | + | pages = kvmalloc_objs(*pages, nr_pages); | |
| 703 | 702 | if (!pages) | |
| 704 | 703 | goto err; | |
| 705 | 704 | ||
modified drivers/hv/hv_balloon.c
| @@ -939,7 +939,7 @@ static unsigned long process_hot_add(unsigned long pg_start, | |||
| 939 | 939 | */ | |
| 940 | 940 | ||
| 941 | 941 | if (rg_size != 0) { | |
| 942 | - | ha_region = kzalloc(sizeof(struct hv_hotadd_state), GFP_KERNEL); | |
| 942 | + | ha_region = kzalloc_obj(struct hv_hotadd_state); | |
| 943 | 943 | if (!ha_region) | |
| 944 | 944 | return 0; | |
| 945 | 945 | ||
modified drivers/hwmon/applesmc.c
| @@ -1128,12 +1128,17 @@ static void applesmc_release_light_sensor(void) | |||
| 1128 | 1128 | ||
| 1129 | 1129 | static int applesmc_create_key_backlight(void) | |
| 1130 | 1130 | { | |
| 1131 | + | int ret; | |
| 1132 | + | ||
| 1131 | 1133 | if (!smcreg.has_key_backlight) | |
| 1132 | 1134 | return 0; | |
| 1133 | 1135 | applesmc_led_wq = create_singlethread_workqueue("applesmc-led"); | |
| 1134 | 1136 | if (!applesmc_led_wq) | |
| 1135 | 1137 | return -ENOMEM; | |
| 1136 | - | return led_classdev_register(&pdev->dev, &applesmc_backlight); | |
| 1138 | + | ret = led_classdev_register(&pdev->dev, &applesmc_backlight); | |
| 1139 | + | if (ret) | |
| 1140 | + | destroy_workqueue(applesmc_led_wq); | |
| 1141 | + | return ret; | |
| 1137 | 1142 | } | |
| 1138 | 1143 | ||
| 1139 | 1144 | static void applesmc_release_key_backlight(void) | |
| @@ -1476,9 +1481,9 @@ static int __init applesmc_init(void) | |||
| 1476 | 1481 | applesmc_fan_config[smcreg.fan_count] = 0; | |
| 1477 | 1482 | applesmc_pwm_config[smcreg.fan_count] = 0; | |
| 1478 | 1483 | ||
| 1479 | - | applesmc_info_temp = kzalloc_obj(*applesmc_info_temp, GFP_KERNEL); | |
| 1480 | - | applesmc_info_fan = kzalloc_obj(*applesmc_info_fan, GFP_KERNEL); | |
| 1481 | - | applesmc_info_pwm = kzalloc_obj(*applesmc_info_pwm, GFP_KERNEL); | |
| 1484 | + | applesmc_info_temp = kzalloc_obj(*applesmc_info_temp); | |
| 1485 | + | applesmc_info_fan = kzalloc_obj(*applesmc_info_fan); | |
| 1486 | + | applesmc_info_pwm = kzalloc_obj(*applesmc_info_pwm); | |
| 1482 | 1487 | if (!applesmc_info_temp || !applesmc_info_fan || !applesmc_info_pwm) { | |
| 1483 | 1488 | ret = -ENOMEM; | |
| 1484 | 1489 | goto out_info; | |
| @@ -1493,7 +1498,7 @@ static int __init applesmc_init(void) | |||
| 1493 | 1498 | applesmc_info_pwm->type = hwmon_pwm; | |
| 1494 | 1499 | applesmc_info_pwm->config = applesmc_pwm_config; | |
| 1495 | 1500 | ||
| 1496 | - | applesmc_info_arr = kcalloc(4, sizeof(*applesmc_info_arr), GFP_KERNEL); | |
| 1501 | + | applesmc_info_arr = kzalloc_objs(*applesmc_info_arr, 4); | |
| 1497 | 1502 | if (!applesmc_info_arr) { | |
| 1498 | 1503 | ret = -ENOMEM; | |
| 1499 | 1504 | goto out_info; | |
| @@ -1504,7 +1509,7 @@ static int __init applesmc_init(void) | |||
| 1504 | 1509 | applesmc_info_arr[2] = applesmc_info_pwm; | |
| 1505 | 1510 | applesmc_info_arr[3] = NULL; | |
| 1506 | 1511 | ||
| 1507 | - | applesmc_chip = kzalloc_obj(*applesmc_chip, GFP_KERNEL); | |
| 1512 | + | applesmc_chip = kzalloc_obj(*applesmc_chip); | |
| 1508 | 1513 | if (!applesmc_chip) { | |
| 1509 | 1514 | ret = -ENOMEM; | |
| 1510 | 1515 | goto out_info; | |
| @@ -1514,10 +1519,9 @@ static int __init applesmc_init(void) | |||
| 1514 | 1519 | applesmc_chip->info = applesmc_info_arr; | |
| 1515 | 1520 | ||
| 1516 | 1521 | /* Create non-standard fanX_safe attributes group */ | |
| 1517 | - | fan_safe_attrs = kcalloc(smcreg.fan_count, | |
| 1518 | - | sizeof(*fan_safe_attrs), GFP_KERNEL); | |
| 1519 | - | fan_safe_attr_list = kcalloc(smcreg.fan_count + 1, | |
| 1520 | - | sizeof(*fan_safe_attr_list), GFP_KERNEL); | |
| 1522 | + | fan_safe_attrs = kzalloc_objs(*fan_safe_attrs, smcreg.fan_count); | |
| 1523 | + | fan_safe_attr_list = kzalloc_objs(*fan_safe_attr_list, | |
| 1524 | + | smcreg.fan_count + 1); | |
| 1521 | 1525 | if (!fan_safe_attrs || !fan_safe_attr_list) { | |
| 1522 | 1526 | ret = -ENOMEM; | |
| 1523 | 1527 | goto out_info; | |
modified drivers/hwmon/aspeed-pwm-tacho.c
| @@ -934,7 +934,9 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev) | |||
| 934 | 934 | "missing or invalid reset controller device tree entry"); | |
| 935 | 935 | return PTR_ERR(priv->rst); | |
| 936 | 936 | } | |
| 937 | - | reset_control_deassert(priv->rst); | |
| 937 | + | ret = reset_control_deassert(priv->rst); | |
| 938 | + | if (ret) | |
| 939 | + | return ret; | |
| 938 | 940 | ||
| 939 | 941 | ret = devm_add_action_or_reset(dev, aspeed_pwm_tacho_remove, priv); | |
| 940 | 942 | if (ret) | |
modified drivers/hwmon/asus_rog_ryujin.c
| @@ -184,6 +184,7 @@ static int rog_ryujin_write_expanded(struct rog_ryujin_data *priv, const u8 *cmd | |||
| 184 | 184 | static int rog_ryujin_execute_cmd(struct rog_ryujin_data *priv, const u8 *cmd, int cmd_length, | |
| 185 | 185 | struct completion *status_completion) | |
| 186 | 186 | { | |
| 187 | + | unsigned long flags; | |
| 187 | 188 | int ret; | |
| 188 | 189 | ||
| 189 | 190 | /* | |
| @@ -191,9 +192,9 @@ static int rog_ryujin_execute_cmd(struct rog_ryujin_data *priv, const u8 *cmd, i | |||
| 191 | 192 | * completion. Reinit is done because hidraw could have triggered | |
| 192 | 193 | * the raw event parsing and marked the passed in completion as done. | |
| 193 | 194 | */ | |
| 194 | - | spin_lock_bh(&priv->status_report_request_lock); | |
| 195 | + | spin_lock_irqsave(&priv->status_report_request_lock, flags); | |
| 195 | 196 | reinit_completion(status_completion); | |
| 196 | - | spin_unlock_bh(&priv->status_report_request_lock); | |
| 197 | + | spin_unlock_irqrestore(&priv->status_report_request_lock, flags); | |
| 197 | 198 | ||
| 198 | 199 | /* Send command for getting data */ | |
| 199 | 200 | ret = rog_ryujin_write_expanded(priv, cmd, cmd_length); | |
| @@ -421,11 +422,19 @@ static int rog_ryujin_raw_event(struct hid_device *hdev, struct hid_report *repo | |||
| 421 | 422 | int size) | |
| 422 | 423 | { | |
| 423 | 424 | struct rog_ryujin_data *priv = hid_get_drvdata(hdev); | |
| 425 | + | unsigned long flags; | |
| 424 | 426 | ||
| 425 | - | if (data[0] != RYUJIN_CMD_PREFIX) | |
| 427 | + | if (size < 2 || data[0] != RYUJIN_CMD_PREFIX) | |
| 426 | 428 | return 0; | |
| 427 | 429 | ||
| 430 | + | spin_lock_irqsave(&priv->status_report_request_lock, flags); | |
| 431 | + | ||
| 428 | 432 | if (data[1] == RYUJIN_GET_COOLER_STATUS_CMD_RESPONSE) { | |
| 433 | + | if (size <= priv->info->temp_offset + 1 || | |
| 434 | + | size <= priv->info->pump_speed_offset + 1 || | |
| 435 | + | size <= priv->info->fan_speed_offset + 1) | |
| 436 | + | goto unlock; | |
| 437 | + | ||
| 429 | 438 | /* Received coolant temp and speeds of pump and internal fan */ | |
| 430 | 439 | priv->temp_input[0] = data[priv->info->temp_offset] * 1000 + | |
| 431 | 440 | data[priv->info->temp_offset + 1] * 100; | |
| @@ -437,6 +446,9 @@ static int rog_ryujin_raw_event(struct hid_device *hdev, struct hid_report *repo | |||
| 437 | 446 | if (!completion_done(&priv->cooler_status_received)) | |
| 438 | 447 | complete_all(&priv->cooler_status_received); | |
| 439 | 448 | } else if (data[1] == RYUJIN_GET_CONTROLLER_SPEED_CMD_RESPONSE) { | |
| 449 | + | if (size <= RYUJIN_CONTROLLER_SPEED_3 + 1) | |
| 450 | + | goto unlock; | |
| 451 | + | ||
| 440 | 452 | /* Received speeds of four fans attached to the controller */ | |
| 441 | 453 | priv->speed_input[2] = get_unaligned_le16(data + RYUJIN_CONTROLLER_SPEED_1); | |
| 442 | 454 | priv->speed_input[3] = get_unaligned_le16(data + RYUJIN_CONTROLLER_SPEED_2); | |
| @@ -446,6 +458,9 @@ static int rog_ryujin_raw_event(struct hid_device *hdev, struct hid_report *repo | |||
| 446 | 458 | if (!completion_done(&priv->controller_status_received)) | |
| 447 | 459 | complete_all(&priv->controller_status_received); | |
| 448 | 460 | } else if (data[1] == RYUJIN_GET_COOLER_DUTY_CMD_RESPONSE) { | |
| 461 | + | if (size <= RYUJIN_INTERNAL_FAN_DUTY) | |
| 462 | + | goto unlock; | |
| 463 | + | ||
| 449 | 464 | /* Received report for pump and internal fan duties (in %) */ | |
| 450 | 465 | if (data[RYUJIN_PUMP_DUTY] == 0 && data[RYUJIN_INTERNAL_FAN_DUTY] == 0) { | |
| 451 | 466 | /* | |
| @@ -463,7 +478,7 @@ static int rog_ryujin_raw_event(struct hid_device *hdev, struct hid_report *repo | |||
| 463 | 478 | * We're expecting a report, so parse it. | |
| 464 | 479 | */ | |
| 465 | 480 | goto read_cooler_duty; | |
| 466 | - | return 0; | |
| 481 | + | goto unlock; | |
| 467 | 482 | } | |
| 468 | 483 | read_cooler_duty: | |
| 469 | 484 | priv->duty_input[0] = rog_ryujin_percent_to_pwm(data[RYUJIN_PUMP_DUTY]); | |
| @@ -472,6 +487,9 @@ read_cooler_duty: | |||
| 472 | 487 | if (!completion_done(&priv->cooler_duty_received)) | |
| 473 | 488 | complete_all(&priv->cooler_duty_received); | |
| 474 | 489 | } else if (data[1] == RYUJIN_GET_CONTROLLER_DUTY_CMD_RESPONSE) { | |
| 490 | + | if (size <= RYUJIN_CONTROLLER_DUTY) | |
| 491 | + | goto unlock; | |
| 492 | + | ||
| 475 | 493 | /* Received report for controller duty for fans (in PWM) */ | |
| 476 | 494 | if (data[RYUJIN_CONTROLLER_DUTY] == 0) { | |
| 477 | 495 | /* | |
| @@ -489,7 +507,7 @@ read_cooler_duty: | |||
| 489 | 507 | * We're expecting a report, so parse it. | |
| 490 | 508 | */ | |
| 491 | 509 | goto read_controller_duty; | |
| 492 | - | return 0; | |
| 510 | + | goto unlock; | |
| 493 | 511 | } | |
| 494 | 512 | read_controller_duty: | |
| 495 | 513 | priv->duty_input[2] = data[RYUJIN_CONTROLLER_DUTY]; | |
| @@ -498,6 +516,8 @@ read_controller_duty: | |||
| 498 | 516 | complete_all(&priv->controller_duty_received); | |
| 499 | 517 | } | |
| 500 | 518 | ||
| 519 | + | unlock: | |
| 520 | + | spin_unlock_irqrestore(&priv->status_report_request_lock, flags); | |
| 501 | 521 | return 0; | |
| 502 | 522 | } | |
| 503 | 523 | ||
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/chipcap2.c
| @@ -92,11 +92,6 @@ struct cc2_data { | |||
| 92 | 92 | bool process_irqs; | |
| 93 | 93 | }; | |
| 94 | 94 | ||
| 95 | - | enum cc2_chan_addr { | |
| 96 | - | CC2_CHAN_TEMP = 0, | |
| 97 | - | CC2_CHAN_HUMIDITY, | |
| 98 | - | }; | |
| 99 | - | ||
| 100 | 95 | /* %RH as a per cent mille from a register value */ | |
| 101 | 96 | static long cc2_rh_convert(u16 data) | |
| 102 | 97 | { | |
| @@ -499,7 +494,7 @@ static irqreturn_t cc2_low_interrupt(int irq, void *data) | |||
| 499 | 494 | ||
| 500 | 495 | if (cc2->process_irqs) { | |
| 501 | 496 | hwmon_notify_event(cc2->hwmon, hwmon_humidity, | |
| 502 | - | hwmon_humidity_min_alarm, CC2_CHAN_HUMIDITY); | |
| 497 | + | hwmon_humidity_min_alarm, 0); | |
| 503 | 498 | cc2->rh_alarm.low_alarm = true; | |
| 504 | 499 | } | |
| 505 | 500 | ||
| @@ -512,7 +507,7 @@ static irqreturn_t cc2_high_interrupt(int irq, void *data) | |||
| 512 | 507 | ||
| 513 | 508 | if (cc2->process_irqs) { | |
| 514 | 509 | hwmon_notify_event(cc2->hwmon, hwmon_humidity, | |
| 515 | - | hwmon_humidity_max_alarm, CC2_CHAN_HUMIDITY); | |
| 510 | + | hwmon_humidity_max_alarm, 0); | |
| 516 | 511 | cc2->rh_alarm.high_alarm = true; | |
| 517 | 512 | } | |
| 518 | 513 | ||
modified drivers/hwmon/corsair-cpro.c
| @@ -566,21 +566,18 @@ static int bootloader_show(struct seq_file *seqf, void *unused) | |||
| 566 | 566 | } | |
| 567 | 567 | DEFINE_SHOW_ATTRIBUTE(bootloader); | |
| 568 | 568 | ||
| 569 | - | static void ccp_debugfs_init(struct ccp_device *ccp) | |
| 569 | + | static void ccp_debugfs_init(struct ccp_device *ccp, bool fw_valid, bool bl_valid) | |
| 570 | 570 | { | |
| 571 | 571 | char name[32]; | |
| 572 | - | int ret; | |
| 573 | 572 | ||
| 574 | 573 | scnprintf(name, sizeof(name), "corsaircpro-%s", dev_name(&ccp->hdev->dev)); | |
| 575 | 574 | ccp->debugfs = debugfs_create_dir(name, NULL); | |
| 576 | 575 | ||
| 577 | - | ret = get_fw_version(ccp); | |
| 578 | - | if (!ret) | |
| 576 | + | if (fw_valid) | |
| 579 | 577 | debugfs_create_file("firmware_version", 0444, | |
| 580 | 578 | ccp->debugfs, ccp, &firmware_fops); | |
| 581 | 579 | ||
| 582 | - | ret = get_bl_version(ccp); | |
| 583 | - | if (!ret) | |
| 580 | + | if (bl_valid) | |
| 584 | 581 | debugfs_create_file("bootloader_version", 0444, | |
| 585 | 582 | ccp->debugfs, ccp, &bootloader_fops); | |
| 586 | 583 | } | |
| @@ -588,6 +585,7 @@ static void ccp_debugfs_init(struct ccp_device *ccp) | |||
| 588 | 585 | static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |
| 589 | 586 | { | |
| 590 | 587 | struct ccp_device *ccp; | |
| 588 | + | bool fw_valid, bl_valid; | |
| 591 | 589 | int ret; | |
| 592 | 590 | ||
| 593 | 591 | ccp = devm_kzalloc(&hdev->dev, sizeof(*ccp), GFP_KERNEL); | |
| @@ -632,17 +630,27 @@ static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 632 | 630 | if (ret) | |
| 633 | 631 | goto out_hw_close; | |
| 634 | 632 | ||
| 635 | - | ccp_debugfs_init(ccp); | |
| 633 | + | /* | |
| 634 | + | * Query the versions before registering the hwmon device: they send | |
| 635 | + | * USB commands without holding ccp->mutex, which is only safe while | |
| 636 | + | * nothing else can call send_usb_cmd(). | |
| 637 | + | */ | |
| 638 | + | fw_valid = !get_fw_version(ccp); | |
| 639 | + | bl_valid = !get_bl_version(ccp); | |
| 636 | 640 | ||
| 637 | 641 | ccp->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "corsaircpro", | |
| 638 | 642 | ccp, &ccp_chip_info, NULL); | |
| 639 | 643 | if (IS_ERR(ccp->hwmon_dev)) { | |
| 640 | 644 | ret = PTR_ERR(ccp->hwmon_dev); | |
| 641 | - | goto out_hw_close; | |
| 645 | + | goto out_debugfs_remove; | |
| 642 | 646 | } | |
| 643 | 647 | ||
| 648 | + | ccp_debugfs_init(ccp, fw_valid, bl_valid); | |
| 649 | + | ||
| 644 | 650 | return 0; | |
| 645 | 651 | ||
| 652 | + | out_debugfs_remove: | |
| 653 | + | debugfs_remove_recursive(ccp->debugfs); | |
| 646 | 654 | out_hw_close: | |
| 647 | 655 | hid_hw_close(hdev); | |
| 648 | 656 | hid_device_io_stop(hdev); | |
modified drivers/hwmon/gpio-fan.c
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | #include <linux/slab.h> | |
| 13 | 13 | #include <linux/interrupt.h> | |
| 14 | 14 | #include <linux/irq.h> | |
| 15 | + | #include <linux/devm-helpers.h> | |
| 15 | 16 | #include <linux/platform_device.h> | |
| 16 | 17 | #include <linux/err.h> | |
| 17 | 18 | #include <linux/kstrtox.h> | |
| @@ -67,7 +68,7 @@ static irqreturn_t fan_alarm_irq_handler(int irq, void *dev_id) | |||
| 67 | 68 | ||
| 68 | 69 | schedule_work(&fan_data->alarm_work); | |
| 69 | 70 | ||
| 70 | - | return IRQ_NONE; | |
| 71 | + | return IRQ_HANDLED; | |
| 71 | 72 | } | |
| 72 | 73 | ||
| 73 | 74 | static ssize_t fan1_alarm_show(struct device *dev, | |
| @@ -84,6 +85,7 @@ static DEVICE_ATTR_RO(fan1_alarm); | |||
| 84 | 85 | static int fan_alarm_init(struct gpio_fan_data *fan_data) | |
| 85 | 86 | { | |
| 86 | 87 | int alarm_irq; | |
| 88 | + | int err; | |
| 87 | 89 | struct device *dev = fan_data->dev; | |
| 88 | 90 | ||
| 89 | 91 | /* | |
| @@ -94,10 +96,14 @@ static int fan_alarm_init(struct gpio_fan_data *fan_data) | |||
| 94 | 96 | if (alarm_irq <= 0) | |
| 95 | 97 | return 0; | |
| 96 | 98 | ||
| 97 | - | INIT_WORK(&fan_data->alarm_work, fan_alarm_notify); | |
| 99 | + | err = devm_work_autocancel(dev, &fan_data->alarm_work, | |
| 100 | + | fan_alarm_notify); | |
| 101 | + | if (err) | |
| 102 | + | return err; | |
| 103 | + | ||
| 98 | 104 | irq_set_irq_type(alarm_irq, IRQ_TYPE_EDGE_BOTH); | |
| 99 | 105 | return devm_request_irq(dev, alarm_irq, fan_alarm_irq_handler, | |
| 100 | - | IRQF_SHARED, "GPIO fan alarm", fan_data); | |
| 106 | + | 0, "GPIO fan alarm", fan_data); | |
| 101 | 107 | } | |
| 102 | 108 | ||
| 103 | 109 | /* | |
| @@ -606,8 +612,11 @@ static void gpio_fan_shutdown(struct platform_device *pdev) | |||
| 606 | 612 | { | |
| 607 | 613 | struct gpio_fan_data *fan_data = platform_get_drvdata(pdev); | |
| 608 | 614 | ||
| 609 | - | if (fan_data->gpios) | |
| 615 | + | if (fan_data->gpios) { | |
| 616 | + | mutex_lock(&fan_data->lock); | |
| 610 | 617 | set_fan_speed(fan_data, 0); | |
| 618 | + | mutex_unlock(&fan_data->lock); | |
| 619 | + | } | |
| 611 | 620 | } | |
| 612 | 621 | ||
| 613 | 622 | static int gpio_fan_runtime_suspend(struct device *dev) | |
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/hwmon.c
| @@ -318,6 +318,11 @@ static int hwmon_attr_base(enum hwmon_sensor_types type) | |||
| 318 | 318 | return 1; | |
| 319 | 319 | } | |
| 320 | 320 | ||
| 321 | + | static bool is_hwmon_device(struct device *dev) | |
| 322 | + | { | |
| 323 | + | return dev->class == &hwmon_class; | |
| 324 | + | } | |
| 325 | + | ||
| 321 | 326 | #if IS_REACHABLE(CONFIG_I2C) | |
| 322 | 327 | ||
| 323 | 328 | /* | |
| @@ -338,7 +343,7 @@ static int hwmon_attr_base(enum hwmon_sensor_types type) | |||
| 338 | 343 | ||
| 339 | 344 | static int hwmon_match_device(struct device *dev, const void *data) | |
| 340 | 345 | { | |
| 341 | - | return dev->class == &hwmon_class; | |
| 346 | + | return is_hwmon_device(dev); | |
| 342 | 347 | } | |
| 343 | 348 | ||
| 344 | 349 | static ssize_t pec_show(struct device *dev, const struct device_attribute *dummy, | |
| @@ -371,18 +376,17 @@ static ssize_t pec_store(struct device *dev, const struct device_attribute *deva | |||
| 371 | 376 | * handling is not required. | |
| 372 | 377 | */ | |
| 373 | 378 | hwdev = to_hwmon_device(hdev); | |
| 374 | - | guard(mutex)(&hwdev->lock); | |
| 375 | - | if (hwdev->chip->ops->write) { | |
| 376 | - | err = hwdev->chip->ops->write(hdev, hwmon_chip, hwmon_chip_pec, 0, val); | |
| 377 | - | if (err && err != -EOPNOTSUPP) | |
| 378 | - | goto put; | |
| 379 | + | scoped_guard(mutex, &hwdev->lock) { | |
| 380 | + | if (hwdev->chip->ops->write) { | |
| 381 | + | err = hwdev->chip->ops->write(hdev, hwmon_chip, hwmon_chip_pec, 0, val); | |
| 382 | + | if (err && err != -EOPNOTSUPP) | |
| 383 | + | goto put; | |
| 384 | + | } | |
| 385 | + | if (!val) | |
| 386 | + | client->flags &= ~I2C_CLIENT_PEC; | |
| 387 | + | else | |
| 388 | + | client->flags |= I2C_CLIENT_PEC; | |
| 379 | 389 | } | |
| 380 | - | ||
| 381 | - | if (!val) | |
| 382 | - | client->flags &= ~I2C_CLIENT_PEC; | |
| 383 | - | else | |
| 384 | - | client->flags |= I2C_CLIENT_PEC; | |
| 385 | - | ||
| 386 | 390 | err = count; | |
| 387 | 391 | put: | |
| 388 | 392 | put_device(hdev); | |
| @@ -782,6 +786,9 @@ int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type, | |||
| 782 | 786 | const char *template; | |
| 783 | 787 | int base; | |
| 784 | 788 | ||
| 789 | + | if (WARN(!is_hwmon_device(dev), "%s is not a hardware monitoring device\n", | |
| 790 | + | dev_name(dev))) | |
| 791 | + | return -EINVAL; | |
| 785 | 792 | if (type >= ARRAY_SIZE(__templates)) | |
| 786 | 793 | return -EINVAL; | |
| 787 | 794 | if (attr >= __templates_size[type]) | |
modified drivers/hwmon/ina2xx.c
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | */ | |
| 9 | 9 | ||
| 10 | 10 | #include <linux/bitfield.h> | |
| 11 | + | #include <linux/bitops.h> | |
| 11 | 12 | #include <linux/bits.h> | |
| 12 | 13 | #include <linux/delay.h> | |
| 13 | 14 | #include <linux/device.h> | |
| @@ -129,6 +130,17 @@ enum ina2xx_ids { | |||
| 129 | 130 | sy24655 | |
| 130 | 131 | }; | |
| 131 | 132 | ||
| 133 | + | enum ina2xx_alert_type { | |
| 134 | + | INA2XX_ALERT_NONE, | |
| 135 | + | INA2XX_ALERT_CURRENT_LOW, | |
| 136 | + | INA2XX_ALERT_CURRENT_HIGH, | |
| 137 | + | INA2XX_ALERT_POWER_HIGH, | |
| 138 | + | INA2XX_ALERT_BUS_VOLTAGE_LOW, | |
| 139 | + | INA2XX_ALERT_BUS_VOLTAGE_HIGH, | |
| 140 | + | INA2XX_ALERT_SHUNT_VOLTAGE_LOW, | |
| 141 | + | INA2XX_ALERT_SHUNT_VOLTAGE_HIGH, | |
| 142 | + | }; | |
| 143 | + | ||
| 132 | 144 | struct ina2xx_config { | |
| 133 | 145 | u16 config_default; | |
| 134 | 146 | bool has_alerts; /* chip supports alerts and limits */ | |
| @@ -148,6 +160,7 @@ struct ina2xx_data { | |||
| 148 | 160 | const struct ina2xx_config *config; | |
| 149 | 161 | enum ina2xx_ids chip; | |
| 150 | 162 | ||
| 163 | + | enum ina2xx_alert_type active_alert; | |
| 151 | 164 | long rshunt; | |
| 152 | 165 | long current_lsb_uA; | |
| 153 | 166 | long power_lsb_uW; | |
| @@ -428,16 +441,78 @@ static u16 ina226_alert_to_reg(struct ina2xx_data *data, int reg, long val) | |||
| 428 | 441 | } | |
| 429 | 442 | } | |
| 430 | 443 | ||
| 431 | - | static int ina226_alert_limit_read(struct ina2xx_data *data, u32 mask, int reg, long *val) | |
| 444 | + | static u32 ina2xx_alert_type_to_mask(enum ina2xx_alert_type alert) | |
| 445 | + | { | |
| 446 | + | switch (alert) { | |
| 447 | + | case INA2XX_ALERT_CURRENT_LOW: | |
| 448 | + | case INA2XX_ALERT_SHUNT_VOLTAGE_LOW: | |
| 449 | + | return INA226_SHUNT_UNDER_VOLTAGE_MASK; | |
| 450 | + | case INA2XX_ALERT_CURRENT_HIGH: | |
| 451 | + | case INA2XX_ALERT_SHUNT_VOLTAGE_HIGH: | |
| 452 | + | return INA226_SHUNT_OVER_VOLTAGE_MASK; | |
| 453 | + | case INA2XX_ALERT_BUS_VOLTAGE_LOW: | |
| 454 | + | return INA226_BUS_UNDER_VOLTAGE_MASK; | |
| 455 | + | case INA2XX_ALERT_BUS_VOLTAGE_HIGH: | |
| 456 | + | return INA226_BUS_OVER_VOLTAGE_MASK; | |
| 457 | + | case INA2XX_ALERT_POWER_HIGH: | |
| 458 | + | return INA226_POWER_OVER_LIMIT_MASK; | |
| 459 | + | case INA2XX_ALERT_NONE: | |
| 460 | + | return 0; | |
| 461 | + | default: | |
| 462 | + | /* programmer error */ | |
| 463 | + | WARN_ON_ONCE(1); | |
| 464 | + | return 0; | |
| 465 | + | } | |
| 466 | + | } | |
| 467 | + | ||
| 468 | + | static enum ina2xx_alert_type ina2xx_mask_to_alert_type(u32 mask) | |
| 469 | + | { | |
| 470 | + | int top_bit = fls(mask & INA226_ALERT_CONFIG_MASK); | |
| 471 | + | ||
| 472 | + | if (!top_bit) | |
| 473 | + | return INA2XX_ALERT_NONE; | |
| 474 | + | ||
| 475 | + | /* | |
| 476 | + | * Multiple bits may be set, with the highest-set function taking | |
| 477 | + | * precedence according to the datasheet. Shunt voltage masks are | |
| 478 | + | * assumed to map to voltage monitoring rather than current monitoring, | |
| 479 | + | * since the latter isn't directly implemented in the hardware. | |
| 480 | + | */ | |
| 481 | + | switch (BIT(top_bit - 1)) { | |
| 482 | + | case INA226_SHUNT_OVER_VOLTAGE_MASK: | |
| 483 | + | return INA2XX_ALERT_SHUNT_VOLTAGE_HIGH; | |
| 484 | + | case INA226_SHUNT_UNDER_VOLTAGE_MASK: | |
| 485 | + | return INA2XX_ALERT_SHUNT_VOLTAGE_LOW; | |
| 486 | + | case INA226_BUS_OVER_VOLTAGE_MASK: | |
| 487 | + | return INA2XX_ALERT_BUS_VOLTAGE_HIGH; | |
| 488 | + | case INA226_BUS_UNDER_VOLTAGE_MASK: | |
| 489 | + | return INA2XX_ALERT_BUS_VOLTAGE_LOW; | |
| 490 | + | case INA226_POWER_OVER_LIMIT_MASK: | |
| 491 | + | return INA2XX_ALERT_POWER_HIGH; | |
| 492 | + | default: | |
| 493 | + | return INA2XX_ALERT_NONE; | |
| 494 | + | } | |
| 495 | + | } | |
| 496 | + | ||
| 497 | + | static int ina226_alert_limit_read(struct ina2xx_data *data, enum ina2xx_alert_type alert, | |
| 498 | + | int reg, long *val) | |
| 432 | 499 | { | |
| 433 | 500 | struct regmap *regmap = data->regmap; | |
| 434 | 501 | int regval; | |
| 502 | + | u32 mask; | |
| 435 | 503 | int ret; | |
| 436 | 504 | ||
| 505 | + | /* Avoid nonzero reads from inactive alerts caused by shared limit register */ | |
| 506 | + | if (data->active_alert != alert) { | |
| 507 | + | *val = 0; | |
| 508 | + | return 0; | |
| 509 | + | } | |
| 510 | + | ||
| 437 | 511 | ret = regmap_read(regmap, INA226_MASK_ENABLE, ®val); | |
| 438 | 512 | if (ret) | |
| 439 | 513 | return ret; | |
| 440 | 514 | ||
| 515 | + | mask = ina2xx_alert_type_to_mask(alert); | |
| 441 | 516 | if (regval & mask) { | |
| 442 | 517 | ret = regmap_read(regmap, INA226_ALERT_LIMIT, ®val); | |
| 443 | 518 | if (ret) | |
| @@ -449,9 +524,11 @@ static int ina226_alert_limit_read(struct ina2xx_data *data, u32 mask, int reg, | |||
| 449 | 524 | return 0; | |
| 450 | 525 | } | |
| 451 | 526 | ||
| 452 | - | static int ina226_alert_limit_write(struct ina2xx_data *data, u32 mask, int reg, long val) | |
| 527 | + | static int ina226_alert_limit_write(struct ina2xx_data *data, enum ina2xx_alert_type alert, | |
| 528 | + | int reg, long val) | |
| 453 | 529 | { | |
| 454 | 530 | struct regmap *regmap = data->regmap; | |
| 531 | + | u32 mask; | |
| 455 | 532 | int ret; | |
| 456 | 533 | ||
| 457 | 534 | if (val < 0) | |
| @@ -466,15 +543,22 @@ static int ina226_alert_limit_write(struct ina2xx_data *data, u32 mask, int reg, | |||
| 466 | 543 | INA226_ALERT_CONFIG_MASK, 0); | |
| 467 | 544 | if (ret < 0) | |
| 468 | 545 | return ret; | |
| 546 | + | data->active_alert = INA2XX_ALERT_NONE; | |
| 469 | 547 | ||
| 470 | 548 | ret = regmap_write(regmap, INA226_ALERT_LIMIT, | |
| 471 | 549 | ina226_alert_to_reg(data, reg, val)); | |
| 472 | 550 | if (ret < 0) | |
| 473 | 551 | return ret; | |
| 474 | 552 | ||
| 475 | - | if (val) | |
| 476 | - | return regmap_update_bits(regmap, INA226_MASK_ENABLE, | |
| 477 | - | INA226_ALERT_CONFIG_MASK, mask); | |
| 553 | + | if (val) { | |
| 554 | + | mask = ina2xx_alert_type_to_mask(alert); | |
| 555 | + | ret = regmap_update_bits(regmap, INA226_MASK_ENABLE, | |
| 556 | + | INA226_ALERT_CONFIG_MASK, mask); | |
| 557 | + | if (ret < 0) | |
| 558 | + | return ret; | |
| 559 | + | data->active_alert = alert; | |
| 560 | + | } | |
| 561 | + | ||
| 478 | 562 | return 0; | |
| 479 | 563 | } | |
| 480 | 564 | ||
| @@ -498,15 +582,26 @@ static int ina2xx_chip_read(struct device *dev, u32 attr, long *val) | |||
| 498 | 582 | return 0; | |
| 499 | 583 | } | |
| 500 | 584 | ||
| 501 | - | static int ina226_alert_read(struct regmap *regmap, u32 mask, long *val) | |
| 585 | + | static int ina226_alert_read(struct ina2xx_data *data, enum ina2xx_alert_type alert, long *val) | |
| 502 | 586 | { | |
| 503 | 587 | unsigned int regval; | |
| 588 | + | u32 mask; | |
| 504 | 589 | int ret; | |
| 505 | 590 | ||
| 506 | - | ret = regmap_read_bypassed(regmap, INA226_MASK_ENABLE, ®val); | |
| 591 | + | /* | |
| 592 | + | * With alert latching, reading alerts from hardware also clears the | |
| 593 | + | * alert, so return early if the alert is inactive. | |
| 594 | + | */ | |
| 595 | + | if (data->active_alert != alert) { | |
| 596 | + | *val = 0; | |
| 597 | + | return 0; | |
| 598 | + | } | |
| 599 | + | ||
| 600 | + | ret = regmap_read_bypassed(data->regmap, INA226_MASK_ENABLE, ®val); | |
| 507 | 601 | if (ret) | |
| 508 | 602 | return ret; | |
| 509 | 603 | ||
| 604 | + | mask = ina2xx_alert_type_to_mask(alert); | |
| 510 | 605 | *val = (regval & mask) && (regval & INA226_ALERT_FUNCTION_FLAG); | |
| 511 | 606 | ||
| 512 | 607 | return 0; | |
| @@ -515,10 +610,10 @@ static int ina226_alert_read(struct regmap *regmap, u32 mask, long *val) | |||
| 515 | 610 | static int ina2xx_in_read(struct device *dev, u32 attr, int channel, long *val) | |
| 516 | 611 | { | |
| 517 | 612 | int voltage_reg = channel ? INA2XX_BUS_VOLTAGE : INA2XX_SHUNT_VOLTAGE; | |
| 518 | - | u32 under_voltage_mask = channel ? INA226_BUS_UNDER_VOLTAGE_MASK | |
| 519 | - | : INA226_SHUNT_UNDER_VOLTAGE_MASK; | |
| 520 | - | u32 over_voltage_mask = channel ? INA226_BUS_OVER_VOLTAGE_MASK | |
| 521 | - | : INA226_SHUNT_OVER_VOLTAGE_MASK; | |
| 613 | + | enum ina2xx_alert_type under_voltage_alert = channel ? INA2XX_ALERT_BUS_VOLTAGE_LOW | |
| 614 | + | : INA2XX_ALERT_SHUNT_VOLTAGE_LOW; | |
| 615 | + | enum ina2xx_alert_type over_voltage_alert = channel ? INA2XX_ALERT_BUS_VOLTAGE_HIGH | |
| 616 | + | : INA2XX_ALERT_SHUNT_VOLTAGE_HIGH; | |
| 522 | 617 | struct ina2xx_data *data = dev_get_drvdata(dev); | |
| 523 | 618 | struct regmap *regmap = data->regmap; | |
| 524 | 619 | unsigned int regval; | |
| @@ -532,15 +627,15 @@ static int ina2xx_in_read(struct device *dev, u32 attr, int channel, long *val) | |||
| 532 | 627 | *val = ina2xx_get_value(data, voltage_reg, regval); | |
| 533 | 628 | break; | |
| 534 | 629 | case hwmon_in_lcrit: | |
| 535 | - | return ina226_alert_limit_read(data, under_voltage_mask, | |
| 630 | + | return ina226_alert_limit_read(data, under_voltage_alert, | |
| 536 | 631 | voltage_reg, val); | |
| 537 | 632 | case hwmon_in_crit: | |
| 538 | - | return ina226_alert_limit_read(data, over_voltage_mask, | |
| 633 | + | return ina226_alert_limit_read(data, over_voltage_alert, | |
| 539 | 634 | voltage_reg, val); | |
| 540 | 635 | case hwmon_in_lcrit_alarm: | |
| 541 | - | return ina226_alert_read(regmap, under_voltage_mask, val); | |
| 636 | + | return ina226_alert_read(data, under_voltage_alert, val); | |
| 542 | 637 | case hwmon_in_crit_alarm: | |
| 543 | - | return ina226_alert_read(regmap, over_voltage_mask, val); | |
| 638 | + | return ina226_alert_read(data, over_voltage_alert, val); | |
| 544 | 639 | default: | |
| 545 | 640 | return -EOPNOTSUPP; | |
| 546 | 641 | } | |
| @@ -594,10 +689,10 @@ static int ina2xx_power_read(struct device *dev, u32 attr, long *val) | |||
| 594 | 689 | case hwmon_power_average: | |
| 595 | 690 | return sy24655_average_power_read(data, SY24655_EIN, val); | |
| 596 | 691 | case hwmon_power_crit: | |
| 597 | - | return ina226_alert_limit_read(data, INA226_POWER_OVER_LIMIT_MASK, | |
| 692 | + | return ina226_alert_limit_read(data, INA2XX_ALERT_POWER_HIGH, | |
| 598 | 693 | INA2XX_POWER, val); | |
| 599 | 694 | case hwmon_power_crit_alarm: | |
| 600 | - | return ina226_alert_read(data->regmap, INA226_POWER_OVER_LIMIT_MASK, val); | |
| 695 | + | return ina226_alert_read(data, INA2XX_ALERT_POWER_HIGH, val); | |
| 601 | 696 | default: | |
| 602 | 697 | return -EOPNOTSUPP; | |
| 603 | 698 | } | |
| @@ -633,15 +728,15 @@ static int ina2xx_curr_read(struct device *dev, u32 attr, long *val) | |||
| 633 | 728 | *val = ina2xx_get_value(data, INA2XX_CURRENT, regval); | |
| 634 | 729 | return 0; | |
| 635 | 730 | case hwmon_curr_lcrit: | |
| 636 | - | return ina226_alert_limit_read(data, INA226_SHUNT_UNDER_VOLTAGE_MASK, | |
| 731 | + | return ina226_alert_limit_read(data, INA2XX_ALERT_CURRENT_LOW, | |
| 637 | 732 | INA2XX_CURRENT, val); | |
| 638 | 733 | case hwmon_curr_crit: | |
| 639 | - | return ina226_alert_limit_read(data, INA226_SHUNT_OVER_VOLTAGE_MASK, | |
| 734 | + | return ina226_alert_limit_read(data, INA2XX_ALERT_CURRENT_HIGH, | |
| 640 | 735 | INA2XX_CURRENT, val); | |
| 641 | 736 | case hwmon_curr_lcrit_alarm: | |
| 642 | - | return ina226_alert_read(regmap, INA226_SHUNT_UNDER_VOLTAGE_MASK, val); | |
| 737 | + | return ina226_alert_read(data, INA2XX_ALERT_CURRENT_LOW, val); | |
| 643 | 738 | case hwmon_curr_crit_alarm: | |
| 644 | - | return ina226_alert_read(regmap, INA226_SHUNT_OVER_VOLTAGE_MASK, val); | |
| 739 | + | return ina226_alert_read(data, INA2XX_ALERT_CURRENT_HIGH, val); | |
| 645 | 740 | default: | |
| 646 | 741 | return -EOPNOTSUPP; | |
| 647 | 742 | } | |
| @@ -685,12 +780,12 @@ static int ina2xx_in_write(struct device *dev, u32 attr, int channel, long val) | |||
| 685 | 780 | switch (attr) { | |
| 686 | 781 | case hwmon_in_lcrit: | |
| 687 | 782 | return ina226_alert_limit_write(data, | |
| 688 | - | channel ? INA226_BUS_UNDER_VOLTAGE_MASK : INA226_SHUNT_UNDER_VOLTAGE_MASK, | |
| 783 | + | channel ? INA2XX_ALERT_BUS_VOLTAGE_LOW : INA2XX_ALERT_SHUNT_VOLTAGE_LOW, | |
| 689 | 784 | channel ? INA2XX_BUS_VOLTAGE : INA2XX_SHUNT_VOLTAGE, | |
| 690 | 785 | val); | |
| 691 | 786 | case hwmon_in_crit: | |
| 692 | 787 | return ina226_alert_limit_write(data, | |
| 693 | - | channel ? INA226_BUS_OVER_VOLTAGE_MASK : INA226_SHUNT_OVER_VOLTAGE_MASK, | |
| 788 | + | channel ? INA2XX_ALERT_BUS_VOLTAGE_HIGH : INA2XX_ALERT_SHUNT_VOLTAGE_HIGH, | |
| 694 | 789 | channel ? INA2XX_BUS_VOLTAGE : INA2XX_SHUNT_VOLTAGE, | |
| 695 | 790 | val); | |
| 696 | 791 | default: | |
| @@ -705,7 +800,7 @@ static int ina2xx_power_write(struct device *dev, u32 attr, long val) | |||
| 705 | 800 | ||
| 706 | 801 | switch (attr) { | |
| 707 | 802 | case hwmon_power_crit: | |
| 708 | - | return ina226_alert_limit_write(data, INA226_POWER_OVER_LIMIT_MASK, | |
| 803 | + | return ina226_alert_limit_write(data, INA2XX_ALERT_POWER_HIGH, | |
| 709 | 804 | INA2XX_POWER, val); | |
| 710 | 805 | default: | |
| 711 | 806 | return -EOPNOTSUPP; | |
| @@ -719,10 +814,10 @@ static int ina2xx_curr_write(struct device *dev, u32 attr, long val) | |||
| 719 | 814 | ||
| 720 | 815 | switch (attr) { | |
| 721 | 816 | case hwmon_curr_lcrit: | |
| 722 | - | return ina226_alert_limit_write(data, INA226_SHUNT_UNDER_VOLTAGE_MASK, | |
| 817 | + | return ina226_alert_limit_write(data, INA2XX_ALERT_CURRENT_LOW, | |
| 723 | 818 | INA2XX_CURRENT, val); | |
| 724 | 819 | case hwmon_curr_crit: | |
| 725 | - | return ina226_alert_limit_write(data, INA226_SHUNT_OVER_VOLTAGE_MASK, | |
| 820 | + | return ina226_alert_limit_write(data, INA2XX_ALERT_CURRENT_HIGH, | |
| 726 | 821 | INA2XX_CURRENT, val); | |
| 727 | 822 | default: | |
| 728 | 823 | return -EOPNOTSUPP; | |
| @@ -883,8 +978,12 @@ static ssize_t shunt_resistor_show(struct device *dev, | |||
| 883 | 978 | struct device_attribute *da, char *buf) | |
| 884 | 979 | { | |
| 885 | 980 | struct ina2xx_data *data = dev_get_drvdata(dev); | |
| 981 | + | long rshunt; | |
| 886 | 982 | ||
| 887 | - | return sysfs_emit(buf, "%li\n", data->rshunt); | |
| 983 | + | scoped_guard(hwmon_lock, dev) { | |
| 984 | + | rshunt = data->rshunt; | |
| 985 | + | } | |
| 986 | + | return sysfs_emit(buf, "%li\n", rshunt); | |
| 888 | 987 | } | |
| 889 | 988 | ||
| 890 | 989 | static ssize_t shunt_resistor_store(struct device *dev, | |
| @@ -940,6 +1039,16 @@ static int ina2xx_init(struct device *dev, struct ina2xx_data *data) | |||
| 940 | 1039 | ||
| 941 | 1040 | if (data->config->has_alerts) { | |
| 942 | 1041 | bool active_high = device_property_read_bool(dev, "ti,alert-polarity-active-high"); | |
| 1042 | + | unsigned int mask_enable; | |
| 1043 | + | ||
| 1044 | + | /* | |
| 1045 | + | * Infer active alert from MASK_ENABLE in case it's already | |
| 1046 | + | * configured (e.g., by a past probe or firmware) | |
| 1047 | + | */ | |
| 1048 | + | ret = regmap_read(regmap, INA226_MASK_ENABLE, &mask_enable); | |
| 1049 | + | if (ret < 0) | |
| 1050 | + | return ret; | |
| 1051 | + | data->active_alert = ina2xx_mask_to_alert_type(mask_enable); | |
| 943 | 1052 | ||
| 944 | 1053 | regmap_update_bits(regmap, INA226_MASK_ENABLE, | |
| 945 | 1054 | INA226_ALERT_LATCH_ENABLE | INA226_ALERT_POLARITY, | |
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/ltc4282.c
| @@ -1106,7 +1106,7 @@ static const struct clk_ops ltc4282_ops = { | |||
| 1106 | 1106 | static int ltc428_clk_provider_setup(struct ltc4282_state *st, | |
| 1107 | 1107 | struct device *dev) | |
| 1108 | 1108 | { | |
| 1109 | - | struct clk_init_data init; | |
| 1109 | + | struct clk_init_data init = {}; | |
| 1110 | 1110 | int ret; | |
| 1111 | 1111 | ||
| 1112 | 1112 | if (!IS_ENABLED(CONFIG_COMMON_CLK)) | |
modified drivers/hwmon/mcp9982.c
| @@ -395,6 +395,8 @@ static int mcp9982_read(struct device *dev, enum hwmon_sensor_types type, u32 at | |||
| 395 | 395 | reg_status, !(reg_status & MCP9982_STATUS_BUSY), | |
| 396 | 396 | MCP9982_WAKE_UP_TIME_US, | |
| 397 | 397 | MCP9982_WAKE_UP_TIME_US * 10); | |
| 398 | + | if (ret) | |
| 399 | + | return ret; | |
| 398 | 400 | break; | |
| 399 | 401 | } | |
| 400 | 402 | break; | |
modified drivers/hwmon/nct6694-hwmon.c
| @@ -159,6 +159,9 @@ static inline s8 temp_to_reg(long val) | |||
| 159 | 159 | #define NCT6694_HWMON_TEMP_CONFIG (HWMON_T_INPUT | HWMON_T_ENABLE | \ | |
| 160 | 160 | HWMON_T_MAX | HWMON_T_MAX_HYST | \ | |
| 161 | 161 | HWMON_T_MAX_ALARM) | |
| 162 | + | #define NCT6694_HWMON_DTIN_CONFIG (HWMON_T_INPUT | \ | |
| 163 | + | HWMON_T_MAX | HWMON_T_MAX_HYST | \ | |
| 164 | + | HWMON_T_MAX_ALARM) | |
| 162 | 165 | #define NCT6694_HWMON_FAN_CONFIG (HWMON_F_INPUT | HWMON_F_ENABLE | \ | |
| 163 | 166 | HWMON_F_MIN | HWMON_F_MIN_ALARM) | |
| 164 | 167 | #define NCT6694_HWMON_PWM_CONFIG (HWMON_PWM_INPUT | HWMON_PWM_ENABLE | \ | |
| @@ -193,22 +196,22 @@ static const struct hwmon_channel_info *nct6694_info[] = { | |||
| 193 | 196 | NCT6694_HWMON_TEMP_CONFIG, /* TDP2 */ | |
| 194 | 197 | NCT6694_HWMON_TEMP_CONFIG, /* TDP3 */ | |
| 195 | 198 | NCT6694_HWMON_TEMP_CONFIG, /* TDP4 */ | |
| 196 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN0 */ | |
| 197 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN1 */ | |
| 198 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN2 */ | |
| 199 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN3 */ | |
| 200 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN4 */ | |
| 201 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN5 */ | |
| 202 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN6 */ | |
| 203 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN7 */ | |
| 204 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN8 */ | |
| 205 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN9 */ | |
| 206 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN10 */ | |
| 207 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN11 */ | |
| 208 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN12 */ | |
| 209 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN13 */ | |
| 210 | - | NCT6694_HWMON_TEMP_CONFIG, /* DTIN14 */ | |
| 211 | - | NCT6694_HWMON_TEMP_CONFIG), /* DTIN15 */ | |
| 199 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN0 */ | |
| 200 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN1 */ | |
| 201 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN2 */ | |
| 202 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN3 */ | |
| 203 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN4 */ | |
| 204 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN5 */ | |
| 205 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN6 */ | |
| 206 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN7 */ | |
| 207 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN8 */ | |
| 208 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN9 */ | |
| 209 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN10 */ | |
| 210 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN11 */ | |
| 211 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN12 */ | |
| 212 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN13 */ | |
| 213 | + | NCT6694_HWMON_DTIN_CONFIG, /* DTIN14 */ | |
| 214 | + | NCT6694_HWMON_DTIN_CONFIG), /* DTIN15 */ | |
| 212 | 215 | ||
| 213 | 216 | HWMON_CHANNEL_INFO(fan, | |
| 214 | 217 | NCT6694_HWMON_FAN_CONFIG, /* FIN0 */ | |
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/pmbus_core.c
| @@ -1275,7 +1275,9 @@ static int pmbus_get_boolean(struct i2c_client *client, struct pmbus_boolean *b, | |||
| 1275 | 1275 | ||
| 1276 | 1276 | regval = status & mask; | |
| 1277 | 1277 | if (regval) { | |
| 1278 | - | if (data->revision >= PMBUS_REV_12) { | |
| 1278 | + | /* Generic STATUS_WORD alarms are not individually clearable. */ | |
| 1279 | + | if (data->revision >= PMBUS_REV_12 && | |
| 1280 | + | reg != PMBUS_STATUS_WORD) { | |
| 1279 | 1281 | ret = _pmbus_write_byte_data(client, page, reg, regval); | |
| 1280 | 1282 | if (ret) | |
| 1281 | 1283 | return ret; | |
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/sht4x.c
| @@ -277,6 +277,8 @@ static ssize_t heater_enable_store(struct device *dev, | |||
| 277 | 277 | heating_time_bound = 1100; | |
| 278 | 278 | } | |
| 279 | 279 | ||
| 280 | + | guard(hwmon_lock)(dev); | |
| 281 | + | ||
| 280 | 282 | if (time_before(jiffies, data->heating_complete)) | |
| 281 | 283 | return -EBUSY; | |
| 282 | 284 | ||
| @@ -286,7 +288,7 @@ static ssize_t heater_enable_store(struct device *dev, | |||
| 286 | 288 | ||
| 287 | 289 | data->heating_complete = jiffies + msecs_to_jiffies(heating_time_bound); | |
| 288 | 290 | data->data_pending = true; | |
| 289 | - | return 0; | |
| 291 | + | return count; | |
| 290 | 292 | } | |
| 291 | 293 | ||
| 292 | 294 | static ssize_t heater_power_show(struct device *dev, | |
| @@ -314,6 +316,8 @@ static ssize_t heater_power_store(struct device *dev, | |||
| 314 | 316 | if (power != 20 && power != 110 && power != 200) | |
| 315 | 317 | return -EINVAL; | |
| 316 | 318 | ||
| 319 | + | guard(hwmon_lock)(dev); | |
| 320 | + | ||
| 317 | 321 | data->heater_power = power; | |
| 318 | 322 | ||
| 319 | 323 | return count; | |
| @@ -344,6 +348,8 @@ static ssize_t heater_time_store(struct device *dev, | |||
| 344 | 348 | if (time != 100 && time != 1000) | |
| 345 | 349 | return -EINVAL; | |
| 346 | 350 | ||
| 351 | + | guard(hwmon_lock)(dev); | |
| 352 | + | ||
| 347 | 353 | data->heater_time = time; | |
| 348 | 354 | ||
| 349 | 355 | return count; | |
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/hwmon/yogafan.c
| @@ -1,5 +1,5 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0-only | |
| 2 | - | /** | |
| 2 | + | /* | |
| 3 | 3 | * yoga_fan.c - Lenovo Yoga/Legion Fan Hardware Monitoring Driver | |
| 4 | 4 | * | |
| 5 | 5 | * Provides fan speed monitoring for Lenovo Yoga, Legion, and IdeaPad | |
modified drivers/hwtracing/coresight/coresight-core.c
| @@ -1679,7 +1679,7 @@ coresight_allocate_device_list(const char *prefix) | |||
| 1679 | 1679 | return list; | |
| 1680 | 1680 | } | |
| 1681 | 1681 | ||
| 1682 | - | list = kzalloc(sizeof(*list), GFP_KERNEL); | |
| 1682 | + | list = kzalloc_obj(*list); | |
| 1683 | 1683 | if (!list) | |
| 1684 | 1684 | return NULL; | |
| 1685 | 1685 | ||
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, | |
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-gpio.c
| @@ -418,7 +418,7 @@ static struct i2c_gpio_scl_data *i2c_gpio_create_scl(struct device *dev) | |||
| 418 | 418 | } | |
| 419 | 419 | } | |
| 420 | 420 | ||
| 421 | - | scl = kzalloc(sizeof(*scl), GFP_KERNEL); | |
| 421 | + | scl = kzalloc_obj(*scl); | |
| 422 | 422 | if (!scl) { | |
| 423 | 423 | if (sharable) | |
| 424 | 424 | fwnode_handle_put(args.fwnode); | |
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); | |
| @@ -1111,8 +1140,7 @@ static int geni_i2c_resources_init(struct geni_se *se) | |||
| 1111 | 1140 | ||
| 1112 | 1141 | ret = geni_i2c_clk_map_idx(gi2c); | |
| 1113 | 1142 | if (ret) | |
| 1114 | - | return dev_err_probe(gi2c->se.dev, ret, "Invalid clk frequency %d Hz\n", | |
| 1115 | - | gi2c->clk_freq_out); | |
| 1143 | + | return ret; | |
| 1116 | 1144 | ||
| 1117 | 1145 | return geni_icc_set_bw_ab(&gi2c->se, GENI_DEFAULT_BW, GENI_DEFAULT_BW, | |
| 1118 | 1146 | Bps_to_icc(gi2c->clk_freq_out)); | |
| @@ -1189,8 +1217,10 @@ static int geni_i2c_probe(struct platform_device *pdev) | |||
| 1189 | 1217 | return ret; | |
| 1190 | 1218 | ||
| 1191 | 1219 | ret = i2c_add_adapter(&gi2c->adap); | |
| 1192 | - | if (ret) | |
| 1220 | + | if (ret) { | |
| 1221 | + | release_gpi_dma(gi2c); | |
| 1193 | 1222 | return dev_err_probe(dev, ret, "Error adding i2c adapter\n"); | |
| 1223 | + | } | |
| 1194 | 1224 | ||
| 1195 | 1225 | dev_dbg(dev, "Geni-I2C adaptor successfully added\n"); | |
| 1196 | 1226 | ||
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/i3c/master/amd-i3c-master.c
| @@ -376,7 +376,7 @@ static struct xi3c_xfer *xi3c_master_alloc_xfer(unsigned int ncmds) | |||
| 376 | 376 | { | |
| 377 | 377 | struct xi3c_xfer *xfer; | |
| 378 | 378 | ||
| 379 | - | xfer = kzalloc_flex(*xfer, cmds, ncmds, GFP_KERNEL); | |
| 379 | + | xfer = kzalloc_flex(*xfer, cmds, ncmds); | |
| 380 | 380 | if (!xfer) | |
| 381 | 381 | return NULL; | |
| 382 | 382 | ||
| @@ -735,7 +735,7 @@ static int xi3c_master_send_bdcast_ccc_cmd(struct xi3c_master *master, | |||
| 735 | 735 | if (!xfer) | |
| 736 | 736 | return -ENOMEM; | |
| 737 | 737 | ||
| 738 | - | buf = kmalloc_objs(*buf, xfer_len, GFP_KERNEL); | |
| 738 | + | buf = kmalloc_objs(*buf, xfer_len); | |
| 739 | 739 | if (!buf) | |
| 740 | 740 | return -ENOMEM; | |
| 741 | 741 | ||
modified drivers/iio/adc/ad7280a.c
| @@ -796,8 +796,8 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) | |||
| 796 | 796 | struct ad7280_state *st = iio_priv(indio_dev); | |
| 797 | 797 | int i, ret; | |
| 798 | 798 | ||
| 799 | - | unsigned int *channels __free(kfree) = kcalloc(st->scan_cnt, sizeof(*channels), | |
| 800 | - | GFP_KERNEL); | |
| 799 | + | unsigned int *channels __free(kfree) = kzalloc_objs(*channels, | |
| 800 | + | st->scan_cnt); | |
| 801 | 801 | if (!channels) | |
| 802 | 802 | return IRQ_HANDLED; | |
| 803 | 803 | ||
modified drivers/iio/buffer/industrialio-buffer-dmaengine.c
| @@ -109,7 +109,7 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, | |||
| 109 | 109 | if (nents < 0) | |
| 110 | 110 | return nents; | |
| 111 | 111 | ||
| 112 | - | vecs = kmalloc_array(nents, sizeof(*vecs), GFP_ATOMIC); | |
| 112 | + | vecs = kmalloc_objs(*vecs, nents, GFP_ATOMIC); | |
| 113 | 113 | if (!vecs) | |
| 114 | 114 | return -ENOMEM; | |
| 115 | 115 | ||
modified drivers/iio/inkern.c
| @@ -345,7 +345,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name, | |||
| 345 | 345 | return ERR_PTR(-ENODEV); | |
| 346 | 346 | ||
| 347 | 347 | struct iio_channel *channel __free(kfree) = | |
| 348 | - | kzalloc(sizeof(*channel), GFP_KERNEL); | |
| 348 | + | kzalloc_obj(*channel); | |
| 349 | 349 | if (!channel) { | |
| 350 | 350 | err = -ENOMEM; | |
| 351 | 351 | goto error_no_mem; | |
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/nldev.c
| @@ -2943,7 +2943,7 @@ static int nldev_frmr_pools_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
| 2943 | 2943 | u32 aging_period; | |
| 2944 | 2944 | int err; | |
| 2945 | 2945 | ||
| 2946 | - | tb = kzalloc_objs(*tb, RDMA_NLDEV_ATTR_MAX, GFP_KERNEL); | |
| 2946 | + | tb = kzalloc_objs(*tb, RDMA_NLDEV_ATTR_MAX); | |
| 2947 | 2947 | if (!tb) | |
| 2948 | 2948 | return -ENOMEM; | |
| 2949 | 2949 | ||
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/hns/hns_roce_debugfs.c
| @@ -267,8 +267,7 @@ static int hns_roce_alloc_scc_param(struct hns_roce_dev *hr_dev) | |||
| 267 | 267 | struct hns_roce_scc_param *scc_param; | |
| 268 | 268 | int i; | |
| 269 | 269 | ||
| 270 | - | scc_param = kvcalloc(HNS_ROCE_SCC_ALGO_TOTAL, sizeof(*scc_param), | |
| 271 | - | GFP_KERNEL); | |
| 270 | + | scc_param = kvzalloc_objs(*scc_param, HNS_ROCE_SCC_ALGO_TOTAL); | |
| 272 | 271 | if (!scc_param) | |
| 273 | 272 | return -ENOMEM; | |
| 274 | 273 | ||
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 | ||
This diff is too large to show in full - only the first part is shown.