Compare
0f70fd6f4c1d6c1f2ea298d8dd07c4a4d5dff9af..6eff1d69dae808a1518aee5a58d0853a8db3f1be
accel/rocket: search every core slot when a core is removed
rocket_remove() decrements rdev->num_cores for each core it removes,
while find_core_for_dev() searches slots 0 to num_cores - 1. Unbinding
the cores in the order they were bound therefore loses the last one: by
the time it is removed the search range has already shrunk past its
slot, so find_core_for_dev() returns -1 and rocket_remove() gives up
without doing anything.
num_cores never reaches zero, rocket_device_fini() never runs, and the
file-scoped rdev keeps pointing at a device that is going away. Binding
the cores again starts from that stale count, because rocket_probe()
takes rdev->num_cores as the slot to fill. On an RK3588, which describes
three cores, the second round lands on slots 1, 2 and 3 while rdev->cores
was allocated with room for three:
rocket fdab0000.npu: Rockchip NPU core 1 version: 1179210309
rocket fdac0000.npu: Rockchip NPU core 2 version: 1179210309
rocket fdad0000.npu: Rockchip NPU core 3 version: 1179210309
The write to rdev->cores[3] is past the end of the array.
Nothing in tree reads the core array often enough to notice, so the
overrun is silent today. It turned up while testing a devfreq series on
top of this, where a worker walks every core a few times a second, and
UBSAN caught the first bool it read out of the overrun entry:
UBSAN: invalid-load in drivers/accel/rocket/rocket_devfreq.c:47:10
load of value 5 is not a valid value for type '_Bool'
Workqueue: devfreq_wq devfreq_monitor
Record how many slots were allocated and search all of them. Every core
is then found on removal, num_cores reaches zero, the device is torn down
and a later bind starts from a clean rdev.
This does not make unbinding a single core out of several work. probe
still takes num_cores as the slot to fill, so rebinding one core while
its siblings stay bound would write over a slot that is already in use,
and rocket_open() still reaches for cores[0] whether or not anything is
there. Both of those want more thought than a fix should carry.
Found by unbinding and rebinding all three cores on an Orange Pi 5 Plus.
With this applied, 25 unbind/rebind rounds and 5 module unload/reload
rounds run clean there: the cores land in slots 0, 1 and 2 every time,
whichever order they are bound in, and the shared supply goes back to a
single user after each round.
Fixes: ed98261b4168 ("accel/rocket: Add a new driver for Rockchip's NPU")
Cc: stable@vger.kernel.org
Signed-off-by: Igor Paunovic <royalnet026@gmail.com>
Assisted-by: LLM sparse checkpatch
Tested-by: Jiaxing Hu <gahing@gahingwoo.com> # RK3576, two cores
Tested-by: Sidong Yang <sidong.yang@furiosa.ai> # RK3588, 3 cores
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patch.msgid.link/20260904125936.26234-1-royalnet026@gmail.com
Igor Paunovic <royalnet026@gmail.com> · 2026-09-04 12:59 UTC · committed by Heiko Stuebner
713 files changed,
+7024
−3633
- .mailmap
- CREDITS
- Documentation/ABI/testing/ima_policy
- Documentation/ABI/testing/sysfs-class-firmware
- 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/riscv/hwprobe.rst
- 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/gpd-fan.rst
- Documentation/hwmon/hwmon-kernel-api.rst
- Documentation/netlink/specs/conntrack.yaml
- Documentation/netlink/specs/rt-link.yaml
- Documentation/scheduler/sched-ext.rst
- Documentation/translations/zh_CN/arch/riscv/patch-acceptance.rst
- Documentation/translations/zh_CN/core-api/irq/irq-domain.rst
- MAINTAINERS
- Makefile
- arch/arm64/crypto/aes-neonbs-glue.c
- arch/arm64/include/asm/cpu.h
- arch/arm64/include/asm/cpufeature.h
- arch/arm64/kernel/cpu_errata.c
- arch/arm64/kernel/cpufeature.c
- arch/arm64/kernel/cpuinfo.c
- arch/arm64/kernel/machine_kexec.c
- arch/arm64/kvm/nested.c
- arch/arm64/mm/fault.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/bcm47xx/buttons.c
- arch/powerpc/include/asm/entry-common.h
- arch/powerpc/kernel/eeh_driver.c
- arch/powerpc/kernel/interrupt.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/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/boot/dts/microchip/mpfs-beaglev-fire.dts
- arch/riscv/include/asm/bug.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/vcpu_pmu.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/paes_s390.c
- arch/s390/crypto/phmac_s390.c
- arch/s390/include/asm/cpacf.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/vtime.c
- arch/s390/kvm/s390/s390.c
- arch/s390/mm/pgalloc.c
- arch/s390/pci/pci_sysfs.c
- arch/x86/crypto/aria-aesni-avx2-asm_64.S
- arch/x86/crypto/aria-gfni-avx512-asm_64.S
- arch/x86/events/intel/core.c
- arch/x86/events/intel/ds.c
- arch/x86/events/perf_event.h
- arch/x86/kernel/amd_node.c
- arch/x86/kernel/cpu/mce/amd.c
- arch/x86/kernel/itmt.c
- arch/x86/net/bpf_jit_comp.c
- block/bio.c
- block/genhd.c
- drivers/accel/amdxdna/Kconfig
- 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_device.c
- drivers/accel/rocket/rocket_device.h
- drivers/accel/rocket/rocket_drv.c
- drivers/accel/rocket/rocket_job.c
- drivers/acpi/irq.c
- drivers/acpi/scan.c
- drivers/ata/ahci.c
- drivers/ata/libata-scsi.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/btqcomsmd.c
- drivers/bluetooth/btrtl.c
- drivers/bluetooth/btusb.c
- drivers/bluetooth/hci_mrvl.c
- drivers/char/virtio_console.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/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/switchtec_dma.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/firmware/arm_scmi/driver.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-mpsse.c
- drivers/gpio/gpio-sim.c
- drivers/gpio/gpio-virtuser.c
- drivers/gpio/gpiolib-cdev.c
- drivers/gpio/gpiolib.c
- drivers/gpu/buddy.c
- drivers/gpu/drm/adp/Kconfig
- 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_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_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_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/amdkfd/kfd_chardev.c
- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.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_backlight.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.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_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/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/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/smu15/smu_v15_0_8_ppt.c
- drivers/gpu/drm/amd/ras/core/cmd.c
- drivers/gpu/drm/aspeed/aspeed_gfx_drv.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/th1520-dw-hdmi.c
- drivers/gpu/drm/bridge/ti-sn65dsi83.c
- drivers/gpu/drm/clients/drm_fbdev_client.c
- drivers/gpu/drm/display/drm_dp_helper.c
- drivers/gpu/drm/drm_atomic_state_helper.c
- drivers/gpu/drm/drm_atomic_uapi.c
- drivers/gpu/drm/drm_bridge.c
- drivers/gpu/drm/drm_exec.c
- drivers/gpu/drm/drm_fb_helper.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_mst.c
- drivers/gpu/drm/i915/display/intel_lt_phy.c
- drivers/gpu/drm/i915/display/skl_universal_plane.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/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_abi16.c
- 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/panthor/panthor_sched.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_bo.c
- drivers/gpu/drm/vc4/vc4_drv.c
- drivers/gpu/drm/vc4/vc4_drv.h
- drivers/gpu/drm/vc4/vc4_gem.c
- drivers/gpu/drm/vc4/vc4_hdmi.c
- drivers/gpu/drm/vc4/vc4_irq.c
- drivers/gpu/drm/vc4/vc4_kms.c
- drivers/gpu/drm/vc4/vc4_v3d.c
- drivers/gpu/drm/vc4/vc4_validate.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/vmwgfx/vmwgfx_cursor_plane.c
- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
- drivers/gpu/drm/xe/instructions/xe_gpu_commands.h
- drivers/gpu/drm/xe/xe_amc.c
- 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_vm.c
- drivers/gpu/drm/xe/xe_vram.c
- drivers/hid/Kconfig
- drivers/hid/bpf/hid_bpf_struct_ops.c
- drivers/hid/hid-asus.c
- drivers/hid/hid-hyperv.c
- drivers/hid/hid-ids.h
- drivers/hid/hid-multitouch.c
- drivers/hid/hid-rmi.c
- drivers/hid/hid-steam.c
- drivers/hid/hid-steelseries-arctis.c
- drivers/hid/i2c-hid/i2c-hid-core.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/chipcap2.c
- drivers/hwmon/corsair-cpro.c
- drivers/hwmon/gpio-fan.c
- drivers/hwmon/hwmon.c
- drivers/hwmon/ina2xx.c
- drivers/hwmon/ltc4282.c
- drivers/hwmon/mcp9982.c
- drivers/hwmon/nct6694-hwmon.c
- drivers/hwmon/pmbus/pmbus_core.c
- drivers/hwmon/sht4x.c
- drivers/hwmon/yogafan.c
- drivers/hwtracing/coresight/coresight-core.c
- drivers/i2c/busses/i2c-gpio.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/nldev.c
- drivers/infiniband/hw/hns/hns_roce_debugfs.c
- drivers/input/input.c
- drivers/input/keyboard/adp5585-keys.c
- drivers/input/keyboard/atkbd.c
- drivers/input/misc/ims-pcu.c
- drivers/input/mouse/psmouse-smbus.c
- drivers/input/serio/serio_raw.c
- drivers/iommu/amd/amd_iommu.h
- drivers/iommu/amd/amd_iommu_types.h
- drivers/iommu/amd/init.c
- drivers/iommu/amd/iommu.c
- drivers/iommu/amd/nested.c
- drivers/iommu/amd/pasid.c
- drivers/iommu/amd/ppr.c
- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
- drivers/iommu/iommufd/device.c
- drivers/iommu/iommufd/driver.c
- drivers/iommu/iommufd/hwpt_noiommu.c
- drivers/iommu/riscv/iommu.c
- drivers/iommu/riscv/iommu.h
- drivers/iommu/s390-iommu.c
- drivers/iommu/vsi-iommu.c
- drivers/irqchip/irq-gic-v5-irs.c
- drivers/irqchip/irq-gic-v5.c
- drivers/irqchip/irq-loongarch-ir.c
- drivers/irqchip/irq-mbigen.c
- drivers/irqchip/irq-realtek-rtl.c
- drivers/irqchip/irq-stm32mp-exti.c
- drivers/mailbox/riscv-sbi-mpxy-mbox.c
- drivers/md/dm-cache-target.c
- drivers/md/dm-crypt.c
- drivers/md/dm-ebs-target.c
- drivers/md/dm-inlinecrypt.c
- drivers/md/dm-integrity.c
- drivers/md/md-llbitmap.c
- drivers/media/pci/intel/ipu-bridge.c
- drivers/media/platform/allegro-dvt/allegro-core.c
- drivers/media/platform/amd/isp4/isp4_interface.c
- drivers/media/platform/dreamchip/rppx1/rpp_params.c
- drivers/media/platform/dreamchip/rppx1/rppx1_bls.c
- drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c
- drivers/media/platform/renesas/rcar-isp/core.c
- drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
- drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c
- drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
- drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c
- drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
- drivers/media/rc/igorplugusb.c
- drivers/media/v4l2-core/v4l2-ctrls-core.c
- drivers/media/v4l2-core/v4l2-h264.c
- drivers/mfd/mfd-core.c
- drivers/mfd/ucb1x00-assabet.c
- drivers/misc/fastrpc.c
- drivers/mtd/mtd_virt_concat.c
- drivers/mtd/mtdconcat.c
- drivers/net/bonding/bond_alb.c
- drivers/net/bonding/bond_main.c
- drivers/net/bonding/bond_options.c
- drivers/net/dsa/bcm_sf2_cfp.c
- drivers/net/dsa/lantiq/lantiq_gswip.h
- drivers/net/dsa/mt7530.c
- drivers/net/dsa/mv88e6xxx/chip.c
- drivers/net/dsa/mv88e6xxx/tcflower.c
- drivers/net/ethernet/airoha/airoha_eth.h
- drivers/net/ethernet/alibaba/eea/eea_adminq.c
- drivers/net/ethernet/alibaba/eea/eea_net.c
- drivers/net/ethernet/alibaba/eea/eea_pci.c
- drivers/net/ethernet/alibaba/eea/eea_ring.c
- drivers/net/ethernet/alibaba/eea/eea_rx.c
- drivers/net/ethernet/alibaba/eea/eea_tx.c
- drivers/net/ethernet/allwinner/sun4i-emac.c
- drivers/net/ethernet/amd/pds_core/core.c
- drivers/net/ethernet/amd/pds_core/fw.c
- drivers/net/ethernet/amd/pds_core/main.c
- drivers/net/ethernet/amd/xgbe/xgbe-dev.c
- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
- drivers/net/ethernet/broadcom/bnxt/bnxt.c
- drivers/net/ethernet/broadcom/bnxt/bnxt.h
- drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c
- drivers/net/ethernet/broadcom/bnxt/bnxt_gso.h
- drivers/net/ethernet/cadence/macb.h
- drivers/net/ethernet/cadence/macb_main.c
- drivers/net/ethernet/cadence/macb_ptp.c
- drivers/net/ethernet/cisco/enic/enic.h
- drivers/net/ethernet/cisco/enic/enic_admin.c
- drivers/net/ethernet/cisco/enic/enic_main.c
- drivers/net/ethernet/cisco/enic/enic_mbox.c
- drivers/net/ethernet/cisco/enic/enic_mbox.h
- drivers/net/ethernet/cortina/gemini.c
- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
- drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c
- drivers/net/ethernet/intel/ice/ice_common.c
- drivers/net/ethernet/intel/ice/ice_sched.c
- drivers/net/ethernet/intel/ice/ice_trace.h
- drivers/net/ethernet/intel/ice/ice_type.h
- drivers/net/ethernet/intel/idpf/idpf_main.c
- drivers/net/ethernet/intel/idpf/idpf_txrx.c
- drivers/net/ethernet/intel/libie/controlq.c
- drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
- drivers/net/ethernet/marvell/octeontx2/af/mcs.c
- drivers/net/ethernet/marvell/octeontx2/af/rvu.c
- drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
- drivers/net/ethernet/marvell/octeontx2/nic/qos.c
- drivers/net/ethernet/mediatek/mtk_eth_soc.c
- drivers/net/ethernet/mediatek/mtk_eth_soc.h
- drivers/net/ethernet/mellanox/mlx5/core/en/port.c
- drivers/net/ethernet/mellanox/mlx5/core/en/port.h
- drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c
- drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c
- drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
- drivers/net/ethernet/mellanox/mlx5/core/en_rep.h
- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
- drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
- drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c
- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
- drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
- drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c
- drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
- drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
- drivers/net/ethernet/meta/fbnic/fbnic_irq.c
- drivers/net/ethernet/micrel/ks8851_common.c
- drivers/net/ethernet/microsoft/mana/gdma_main.c
- drivers/net/ethernet/microsoft/mana/mana_bpf.c
- drivers/net/ethernet/microsoft/mana/mana_en.c
- drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
- drivers/net/ethernet/oa_tc6.c
- drivers/net/ethernet/pensando/ionic/ionic_txrx.c
- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
- drivers/net/gtp.c
- drivers/net/ieee802154/cc2520.c
- drivers/net/ieee802154/mac802154_hwsim.c
- drivers/net/ipvlan/ipvlan_main.c
- drivers/net/mctp/mctp-i3c.c
- drivers/net/net_failover.c
- drivers/net/ntb_netdev.c
- drivers/net/phy/dp83867.c
- drivers/net/phy/dp83td510.c
- drivers/net/phy/mediatek/mtk-ge.c
- drivers/net/phy/phylink.c
- drivers/net/ppp/ppp_async.c
- drivers/net/ppp/ppp_synctty.c
- drivers/net/usb/cx82310_eth.c
- drivers/net/usb/hso.c
- drivers/net/usb/qmi_wwan.c
- drivers/net/vxlan/vxlan_core.c
- drivers/net/vxlan/vxlan_mdb.c
- drivers/net/wireless/ath/ath12k/ahb.c
- drivers/net/wireless/intel/iwlwifi/mld/regulatory.c
- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
- drivers/net/wireless/mediatek/mt76/mt7921/regd.c
- drivers/net/wireless/mediatek/mt76/mt7925/main.c
- drivers/net/wireless/mediatek/mt76/mt7925/regd.c
- drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
- drivers/net/wireless/morsemicro/mm81x/mac.c
- drivers/net/wireless/morsemicro/mm81x/yaps.c
- drivers/net/wireless/nxp/nxpwifi/cfg80211.c
- drivers/net/wireless/nxp/nxpwifi/cmdevt.c
- drivers/net/wireless/nxp/nxpwifi/ie.c
- drivers/net/wireless/nxp/nxpwifi/init.c
- drivers/net/wireless/nxp/nxpwifi/main.c
- drivers/net/wireless/nxp/nxpwifi/scan.c
- drivers/net/wireless/nxp/nxpwifi/sta_cfg.c
- drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
- drivers/net/wireless/nxp/nxpwifi/uap_event.c
- drivers/nvdimm/region_devs.c
- drivers/nvme/host/core.c
- drivers/nvme/host/fabrics.c
- drivers/nvme/host/fault_inject.c
- drivers/nvme/host/fc.c
- drivers/nvme/host/nvme.h
- drivers/nvme/host/pci.c
- drivers/nvme/host/rdma.c
- drivers/nvme/host/sysfs.c
- drivers/nvme/host/tcp.c
- drivers/nvme/host/zns.c
- drivers/nvme/target/auth.c
- drivers/nvme/target/configfs.c
- drivers/nvme/target/core.c
- drivers/nvme/target/nvmet.h
- drivers/nvme/target/pr.c
- drivers/nvme/target/rdma.c
- drivers/nvme/target/tcp.c
- drivers/opp/core.c
- drivers/opp/of.c
- drivers/pci/endpoint/pci-ep-msi.c
- drivers/perf/riscv_pmu_legacy.c
- drivers/perf/riscv_pmu_sbi.c
- drivers/platform/x86/amd/hsmp/acpi.c
- drivers/platform/x86/amd/pmf/spc.c
- drivers/platform/x86/asus-laptop.c
- drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
- drivers/platform/x86/hp/hp-wmi.c
- drivers/platform/x86/intel/pmc/pwrm_telemetry.c
- drivers/platform/x86/x86-android-tablets/core.c
- drivers/platform/x86/x86-android-tablets/lenovo.c
- drivers/platform/x86/x86-android-tablets/x86-android-tablets.h
- drivers/pmdomain/core.c
- drivers/pmdomain/mediatek/Kconfig
- drivers/pmdomain/qcom/rpmhpd.c
- drivers/power/reset/reboot-mode.c
- drivers/power/sequencing/core.c
- drivers/power/sequencing/pwrseq-pcie-m2.c
- drivers/power/supply/power_supply_core.c
- drivers/ptp/ptp_chardev.c
- drivers/ras/amd/atl/core.c
- drivers/ras/amd/atl/map.c
- drivers/regulator/pf1550-regulator.c
- drivers/s390/block/dasd.c
- drivers/s390/crypto/zcrypt_cca_key.h
- drivers/s390/crypto/zcrypt_ccamisc.c
- drivers/s390/net/ctcm_mpc.c
- drivers/s390/net/ism_drv.c
- drivers/s390/net/qeth_l2.h
- drivers/s390/net/qeth_l2_main.c
- drivers/s390/net/qeth_l2_sys.c
- drivers/scsi/fnic/fnic_debugfs.c
- drivers/scsi/fnic/fnic_nvme.c
- drivers/scsi/ibmvscsi/ibmvfc-core.c
- drivers/scsi/leapraid/leapraid_func.c
- drivers/scsi/megaraid/megaraid_sas_base.c
- drivers/scsi/mpi3mr/mpi3mr_os.c
- drivers/scsi/mpi3mr/mpi3mr_transport.c
- drivers/scsi/mpt3sas/mpt3sas_base.c
- drivers/scsi/pm8001/pm8001_init.c
- drivers/scsi/scsi_bsg.c
- drivers/scsi/scsi_scan.c
- drivers/soc/bcm/brcmstb/common.c
- drivers/spi/spi-offload.c
- drivers/staging/fbtft/fbtft-core.c
- drivers/staging/greybus/raw.c
- drivers/staging/media/atomisp/pci/sh_css.c
- drivers/staging/media/atomisp/pci/sh_css_firmware.c
- drivers/staging/rtl8723bs/core/rtw_ieee80211.c
- drivers/staging/rtl8723bs/core/rtw_mlme.c
- drivers/staging/sm750fb/sm750.c
- drivers/staging/sm750fb/sm750.h
- drivers/staging/sm750fb/sm750_accel.c
- drivers/staging/sm750fb/sm750_accel.h
- drivers/target/iscsi/iscsi_target.c
- drivers/target/iscsi/iscsi_target_login.c
- drivers/tee/qcomtee/user_obj.c
- drivers/thermal/thermal_sysfs.c
- drivers/thunderbolt/stream.c
- drivers/tty/moxa.c
- drivers/tty/vt/consolemap.c
- drivers/tty/vt/vt.c
- drivers/ufs/core/ufs-txeq.c
- drivers/ufs/host/ufs-qcom.c
- drivers/ufs/host/ufs-qcom.h
- drivers/ufs/host/ufshcd-pci.c
- drivers/usb/cdns3/cdnsp-gadget.c
- drivers/usb/cdns3/cdnsp-gadget.h
- drivers/usb/cdns3/cdnsp-mem.c
- drivers/usb/dwc3/dwc3-google.c
- drivers/usb/dwc3/ep0.c
- drivers/usb/dwc3/gadget.c
- drivers/usb/gadget/function/f_mass_storage.c
- drivers/usb/gadget/function/f_midi.c
- drivers/usb/gadget/function/f_midi2.c
- drivers/usb/gadget/function/f_ncm.c
- drivers/usb/gadget/functions.c
- drivers/usb/gadget/legacy/inode.c
- drivers/usb/host/xhci-mem.c
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> | |
| @@ -420,6 +421,7 @@ Jens Axboe <axboe@kernel.dk> <axboe@suse.de> | |||
| 420 | 421 | Jens Axboe <axboe@kernel.dk> <jens.axboe@oracle.com> | |
| 421 | 422 | Jens Axboe <axboe@kernel.dk> <axboe@fb.com> | |
| 422 | 423 | Jens Axboe <axboe@kernel.dk> <axboe@meta.com> | |
| 424 | + | Jens Axboe <axboe@kernel.dk> <axboe@anthropic.com> | |
| 423 | 425 | Jens Osterkamp <Jens.Osterkamp@de.ibm.com> | |
| 424 | 426 | Jens Wiklander <jenswi@kernel.org> <jens.wiklander@linaro.org> | |
| 425 | 427 | Jernej Skrabec <jernej.skrabec@gmail.com> <jernej.skrabec@siol.net> | |
| @@ -550,6 +552,9 @@ Li Yang <leoyang.li@nxp.com> <leo@zh-kernel.org> | |||
| 550 | 552 | Lior David <quic_liord@quicinc.com> <liord@codeaurora.org> | |
| 551 | 553 | Loic Poulain <loic.poulain@oss.qualcomm.com> <loic.poulain@linaro.org> | |
| 552 | 554 | Loic Poulain <loic.poulain@oss.qualcomm.com> <loic.poulain@intel.com> | |
| 555 | + | Lorenzo Bianconi <lorenzo@kernel.org> <lorenzo.bianconi@redhat.com> | |
| 556 | + | Lorenzo Bianconi <lorenzo@kernel.org> <lorenzo.bianconi@st.com> | |
| 557 | + | Lorenzo Bianconi <lorenzo@kernel.org> <lorenzo.bianconi83@gmail.com> | |
| 553 | 558 | Lorenzo Pieralisi <lpieralisi@kernel.org> <lorenzo.pieralisi@arm.com> | |
| 554 | 559 | Lorenzo Stoakes <ljs@kernel.org> <lstoakes@gmail.com> | |
| 555 | 560 | Lorenzo Stoakes <ljs@kernel.org> <lorenzo.stoakes@oracle.com> | |
| @@ -699,6 +704,7 @@ Oliver Hartkopp <socketcan@hartkopp.net> <oliver.hartkopp@volkswagen.de> | |||
| 699 | 704 | Oliver Hartkopp <socketcan@hartkopp.net> <oliver@hartkopp.net> | |
| 700 | 705 | Oliver Upton <oupton@kernel.org> <oupton@google.com> | |
| 701 | 706 | Oliver Upton <oupton@kernel.org> <oliver.upton@linux.dev> | |
| 707 | + | Ondrej Mosnáček <omosnacek@gmail.com> <omosnace@redhat.com> | |
| 702 | 708 | Ondřej Jirman <megi@xff.cz> <megous@megous.com> | |
| 703 | 709 | Oza Pawandeep <quic_poza@quicinc.com> <poza@codeaurora.org> | |
| 704 | 710 | Pali Rohár <pali@kernel.org> <pali.rohar@gmail.com> | |
| @@ -898,7 +904,8 @@ Thomas Graf <tgraf@suug.ch> | |||
| 898 | 904 | Thomas Gleixner <tglx@kernel.org> <tglx@linutronix.de> | |
| 899 | 905 | Thomas Körper <socketcan@esd.eu> <thomas.koerper@esd.eu> | |
| 900 | 906 | Thomas Pedersen <twp@codeaurora.org> | |
| 901 | - | Thorsten Blum <thorsten.blum@linux.dev> <thorsten.blum@toblux.com> | |
| 907 | + | Thorsten Blum <blum@kernel.org> <thorsten.blum@toblux.com> | |
| 908 | + | Thorsten Blum <blum@kernel.org> <thorsten.blum@linux.dev> | |
| 902 | 909 | Tiezhu Yang <yangtiezhu@loongson.cn> <kernelpatch@126.com> | |
| 903 | 910 | Tingwei Zhang <quic_tingwei@quicinc.com> <tingwei@codeaurora.org> | |
| 904 | 911 | Tirupathi Reddy <quic_tirupath@quicinc.com> <tirupath@codeaurora.org> | |
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-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
| @@ -4987,18 +4987,6 @@ Kernel parameters | |||
| 4987 | 4987 | Set to non-zero if a chip is present that snoops speed | |
| 4988 | 4988 | changes. Disabled by default. | |
| 4989 | 4989 | ||
| 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 | 4990 | pata_legacy.iordy_mask= [HW,LIBATA] | |
| 5003 | 4991 | Format: <int> | |
| 5004 | 4992 | IORDY enable mask. Set individual bits to allow IORDY | |
| @@ -5011,18 +4999,6 @@ Kernel parameters | |||
| 5011 | 4999 | with the sequence. By default IORDY is allowed across | |
| 5012 | 5000 | all channels. | |
| 5013 | 5001 | ||
| 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 | 5002 | pata_legacy.pio_mask= [HW,LIBATA] | |
| 5027 | 5003 | Format: <int> | |
| 5028 | 5004 | PIO mode mask for autospeed devices. Set individual | |
| @@ -5046,19 +5022,6 @@ Kernel parameters | |||
| 5046 | 5022 | the first port in the list above (0x1f0), and so on. | |
| 5047 | 5023 | By default all supported ports are probed. | |
| 5048 | 5024 | ||
| 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 | 5025 | pata_platform.pio_mask= [HW,LIBATA] | |
| 5063 | 5026 | Format: <int> | |
| 5064 | 5027 | 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/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/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/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/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/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/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 | |
| @@ -5671,8 +5671,8 @@ W: http://bu3sch.de/btgpio.php | |||
| 5671 | 5671 | F: drivers/gpio/gpio-bt8xx.c | |
| 5672 | 5672 | ||
| 5673 | 5673 | BTRFS FILE SYSTEM | |
| 5674 | - | M: Chris Mason <clm@fb.com> | |
| 5675 | 5674 | M: David Sterba <dsterba@suse.com> | |
| 5675 | + | R: Chris Mason <mason@kernel.org> | |
| 5676 | 5676 | L: linux-btrfs@vger.kernel.org | |
| 5677 | 5677 | S: Maintained | |
| 5678 | 5678 | W: https://btrfs.readthedocs.io | |
| @@ -8039,7 +8039,7 @@ F: drivers/gpu/drm/sun4i/sun8i* | |||
| 8039 | 8039 | ||
| 8040 | 8040 | DRM DRIVER FOR APPLE TOUCH BARS | |
| 8041 | 8041 | M: Aun-Ali Zaidi <admin@kodeit.net> | |
| 8042 | - | M: Aditya Garg <gargaditya08@proton.me> | |
| 8042 | + | M: Aditya Garg <aditya.garg@linux.dev> | |
| 8043 | 8043 | L: dri-devel@lists.freedesktop.org | |
| 8044 | 8044 | S: Maintained | |
| 8045 | 8045 | T: git https://gitlab.freedesktop.org/drm/misc/kernel.git | |
| @@ -8573,7 +8573,7 @@ F: Documentation/devicetree/bindings/display/panel/synaptics,r63353.yaml | |||
| 8573 | 8573 | F: drivers/gpu/drm/panel/panel-synaptics-r63353.c | |
| 8574 | 8574 | ||
| 8575 | 8575 | DRM DRIVER FOR SYNOPSYS DESIGNWARE DISPLAYPORT BRIDGE | |
| 8576 | - | M: Andy Yan <andy.yan@rock-chips.com> | |
| 8576 | + | M: Andy Yan <andyshrk@163.com> | |
| 8577 | 8577 | S: Maintained | |
| 8578 | 8578 | T: git https://gitlab.freedesktop.org/drm/misc/kernel.git | |
| 8579 | 8579 | F: Documentation/devicetree/bindings/display/rockchip/rockchip,dw-dp.yaml | |
| @@ -8926,7 +8926,7 @@ F: include/linux/platform_data/shmob_drm.h | |||
| 8926 | 8926 | DRM DRIVERS FOR ROCKCHIP | |
| 8927 | 8927 | M: Sandy Huang <hjc@rock-chips.com> | |
| 8928 | 8928 | M: Heiko Stübner <heiko@sntech.de> | |
| 8929 | - | M: Andy Yan <andy.yan@rock-chips.com> | |
| 8929 | + | M: Andy Yan <andyshrk@163.com> | |
| 8930 | 8930 | L: dri-devel@lists.freedesktop.org | |
| 8931 | 8931 | L: linux-rockchip@lists.infradead.org | |
| 8932 | 8932 | S: Maintained | |
| @@ -9387,9 +9387,8 @@ S: Maintained | |||
| 9387 | 9387 | F: drivers/edac/octeon_edac* | |
| 9388 | 9388 | ||
| 9389 | 9389 | EDAC-CAVIUM THUNDERX | |
| 9390 | - | M: Robert Richter <rric@kernel.org> | |
| 9391 | 9390 | L: linux-edac@vger.kernel.org | |
| 9392 | - | S: Odd Fixes | |
| 9391 | + | S: Orphan | |
| 9393 | 9392 | F: drivers/edac/thunderx_edac* | |
| 9394 | 9393 | ||
| 9395 | 9394 | EDAC-CORE | |
| @@ -9416,9 +9415,8 @@ S: Supported | |||
| 9416 | 9415 | F: drivers/edac/dmc520_edac.c | |
| 9417 | 9416 | ||
| 9418 | 9417 | EDAC-E752X | |
| 9419 | - | M: Mark Gross <markgross@kernel.org> | |
| 9420 | 9418 | L: linux-edac@vger.kernel.org | |
| 9421 | - | S: Maintained | |
| 9419 | + | S: Orphan | |
| 9422 | 9420 | F: drivers/edac/e752x_edac.c | |
| 9423 | 9421 | ||
| 9424 | 9422 | EDAC-E7XXX | |
| @@ -9493,9 +9491,8 @@ S: Maintained | |||
| 9493 | 9491 | F: drivers/edac/igen6_edac.c | |
| 9494 | 9492 | ||
| 9495 | 9493 | EDAC-MPC85XX | |
| 9496 | - | M: Johannes Thumshirn <morbidrsa@gmail.com> | |
| 9497 | 9494 | L: linux-edac@vger.kernel.org | |
| 9498 | - | S: Maintained | |
| 9495 | + | S: Orphan | |
| 9499 | 9496 | F: drivers/edac/mpc85xx_edac.[ch] | |
| 9500 | 9497 | ||
| 9501 | 9498 | EDAC-NPCM | |
| @@ -10193,7 +10190,6 @@ F: include/linux/arm_ffa.h | |||
| 10193 | 10190 | ||
| 10194 | 10191 | FIRMWARE LOADER (request_firmware) | |
| 10195 | 10192 | M: Luis Chamberlain <mcgrof@kernel.org> | |
| 10196 | - | M: Russ Weight <russ.weight@linux.dev> | |
| 10197 | 10193 | M: Danilo Krummrich <dakr@kernel.org> | |
| 10198 | 10194 | L: driver-core@lists.linux.dev | |
| 10199 | 10195 | S: Maintained | |
| @@ -12224,7 +12220,7 @@ F: drivers/tty/hvc/ | |||
| 12224 | 12220 | ||
| 12225 | 12221 | HUNG TASK DETECTOR | |
| 12226 | 12222 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 12227 | - | R: Lance Yang <lance.yang@linux.dev> | |
| 12223 | + | M: Lance Yang <lance.yang@linux.dev> | |
| 12228 | 12224 | R: Masami Hiramatsu <mhiramat@kernel.org> | |
| 12229 | 12225 | R: Petr Mladek <pmladek@suse.com> | |
| 12230 | 12226 | L: linux-kernel@vger.kernel.org | |
| @@ -12884,7 +12880,7 @@ S: Maintained | |||
| 12884 | 12880 | F: drivers/power/supply/ip5xxx_power.c | |
| 12885 | 12881 | ||
| 12886 | 12882 | INNOSILICON HDMI BRIDGE DRIVER | |
| 12887 | - | M: Andy Yan <andy.yan@rock-chips.com> | |
| 12883 | + | M: Andy Yan <andyshrk@163.com> | |
| 12888 | 12884 | L: dri-devel@lists.freedesktop.org | |
| 12889 | 12885 | S: Maintained | |
| 12890 | 12886 | T: git https://gitlab.freedesktop.org/drm/misc/kernel.git | |
| @@ -13283,7 +13279,6 @@ F: drivers/crypto/intel/keembay/ocs-aes.h | |||
| 13283 | 13279 | ||
| 13284 | 13280 | INTEL KEEM BAY OCS ECC CRYPTO DRIVER | |
| 13285 | 13281 | M: Prabhjot Khurana <prabhjot.khurana@intel.com> | |
| 13286 | - | M: Mark Gross <mgross@linux.intel.com> | |
| 13287 | 13282 | S: Maintained | |
| 13288 | 13283 | F: Documentation/devicetree/bindings/crypto/intel,keembay-ocs-ecc.yaml | |
| 13289 | 13284 | F: drivers/crypto/intel/keembay/Kconfig | |
| @@ -14240,8 +14235,6 @@ F: tools/testing/selftests/ | |||
| 14240 | 14235 | KERNEL SMB3 SERVER (KSMBD) | |
| 14241 | 14236 | M: Namjae Jeon <linkinjeon@kernel.org> | |
| 14242 | 14237 | M: Namjae Jeon <linkinjeon@samba.org> | |
| 14243 | - | M: Steve French <smfrench@gmail.com> | |
| 14244 | - | M: Steve French <sfrench@samba.org> | |
| 14245 | 14238 | R: Sergey Senozhatsky <senozhatsky@chromium.org> | |
| 14246 | 14239 | R: Tom Talpey <tom@talpey.com> | |
| 14247 | 14240 | R: ChenXiaoSong <chenxiaosong@chenxiaosong.com> | |
| @@ -15027,6 +15020,8 @@ M: Madhavan Srinivasan <maddy@linux.ibm.com> | |||
| 15027 | 15020 | R: Michael Ellerman <mpe@ellerman.id.au> | |
| 15028 | 15021 | R: Nicholas Piggin <npiggin@gmail.com> | |
| 15029 | 15022 | R: Christophe Leroy (CS GROUP) <chleroy@kernel.org> | |
| 15023 | + | R: Ritesh Harjani (IBM) <ritesh.list@gmail.com> | |
| 15024 | + | R: Shrikanth Hegde <sshegde@linux.ibm.com> | |
| 15030 | 15025 | L: linuxppc-dev@lists.ozlabs.org | |
| 15031 | 15026 | S: Supported | |
| 15032 | 15027 | W: https://github.com/linuxppc/wiki/wiki | |
| @@ -17416,7 +17411,6 @@ F: mm/swapfile.c | |||
| 17416 | 17411 | MEMORY MANAGEMENT - THP (TRANSPARENT HUGE PAGE) | |
| 17417 | 17412 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17418 | 17413 | M: David Hildenbrand <david@kernel.org> | |
| 17419 | - | M: Lorenzo Stoakes <ljs@kernel.org> | |
| 17420 | 17414 | R: Zi Yan <ziy@nvidia.com> | |
| 17421 | 17415 | R: Baolin Wang <baolin.wang@linux.alibaba.com> | |
| 17422 | 17416 | R: Liam R. Howlett <liam@infradead.org> | |
| @@ -17426,6 +17420,7 @@ R: Dev Jain <dev.jain@arm.com> | |||
| 17426 | 17420 | R: Barry Song <baohua@kernel.org> | |
| 17427 | 17421 | R: Lance Yang <lance.yang@linux.dev> | |
| 17428 | 17422 | R: Usama Arif <usama.arif@linux.dev> | |
| 17423 | + | R: Kiryl Shutsemau <kas@kernel.org> | |
| 17429 | 17424 | L: linux-mm@kvack.org | |
| 17430 | 17425 | S: Maintained | |
| 17431 | 17426 | W: http://www.linux-mm.org | |
| @@ -17698,7 +17693,7 @@ F: Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml | |||
| 17698 | 17693 | F: drivers/spi/spi-at91-usart.c | |
| 17699 | 17694 | ||
| 17700 | 17695 | MICROCHIP ATSHA204A DRIVER | |
| 17701 | - | M: Thorsten Blum <thorsten.blum@linux.dev> | |
| 17696 | + | M: Thorsten Blum <blum@kernel.org> | |
| 17702 | 17697 | L: linux-crypto@vger.kernel.org | |
| 17703 | 17698 | S: Maintained | |
| 17704 | 17699 | F: drivers/crypto/atmel-sha204a.c | |
| @@ -17722,7 +17717,7 @@ F: Documentation/devicetree/bindings/media/microchip,csi2dc.yaml | |||
| 17722 | 17717 | F: drivers/media/platform/microchip/microchip-csi2dc.c | |
| 17723 | 17718 | ||
| 17724 | 17719 | MICROCHIP ECC DRIVER | |
| 17725 | - | M: Thorsten Blum <thorsten.blum@linux.dev> | |
| 17720 | + | M: Thorsten Blum <blum@kernel.org> | |
| 17726 | 17721 | L: linux-crypto@vger.kernel.org | |
| 17727 | 17722 | S: Maintained | |
| 17728 | 17723 | F: drivers/crypto/atmel-ecc.c | |
| @@ -19569,7 +19564,7 @@ F: include/linux/platform_data/x86/nvidia-wmi-ec-backlight.h | |||
| 19569 | 19564 | ||
| 19570 | 19565 | NVM EXPRESS DRIVER | |
| 19571 | 19566 | M: Keith Busch <kbusch@kernel.org> | |
| 19572 | - | M: Jens Axboe <axboe@fb.com> | |
| 19567 | + | M: Jens Axboe <axboe@kernel.dk> | |
| 19573 | 19568 | M: Christoph Hellwig <hch@lst.de> | |
| 19574 | 19569 | M: Sagi Grimberg <sagi@grimberg.me> | |
| 19575 | 19570 | L: linux-nvme@lists.infradead.org | |
| @@ -24778,7 +24773,7 @@ K: \bsecurity_[a-z_0-9]\+\b | |||
| 24778 | 24773 | SELINUX SECURITY MODULE | |
| 24779 | 24774 | M: Paul Moore <paul@paul-moore.com> | |
| 24780 | 24775 | M: Stephen Smalley <stephen.smalley.work@gmail.com> | |
| 24781 | - | R: Ondrej Mosnacek <omosnace@redhat.com> | |
| 24776 | + | R: Ondrej Mosnáček <omosnacek@gmail.com> | |
| 24782 | 24777 | L: selinux@vger.kernel.org | |
| 24783 | 24778 | S: Supported | |
| 24784 | 24779 | W: https://github.com/SELinuxProject | |
| @@ -25236,10 +25231,9 @@ F: Documentation/admin-guide/LSM/Smack.rst | |||
| 25236 | 25231 | F: security/smack/ | |
| 25237 | 25232 | ||
| 25238 | 25233 | 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 | 25234 | M: Namjae Jeon <linkinjeon@kernel.org> | |
| 25242 | 25235 | M: Namjae Jeon <linkinjeon@samba.org> | |
| 25236 | + | M: Paulo Alcantara <pc@manguebit.org> | |
| 25243 | 25237 | R: Stefan Metzmacher <metze@samba.org> | |
| 25244 | 25238 | R: Tom Talpey <tom@talpey.com> | |
| 25245 | 25239 | L: linux-cifs@vger.kernel.org | |
| @@ -25342,8 +25336,8 @@ F: Documentation/networking/timestamping.rst | |||
| 25342 | 25336 | F: include/linux/net_tstamp.h | |
| 25343 | 25337 | F: include/uapi/linux/net_tstamp.h | |
| 25344 | 25338 | F: tools/testing/selftests/bpf/*/net_timestamping* | |
| 25339 | + | F: tools/testing/selftests/drivers/net/so_txtime.* | |
| 25345 | 25340 | F: tools/testing/selftests/net/*timestamp* | |
| 25346 | - | F: tools/testing/selftests/net/so_txtime.c | |
| 25347 | 25341 | ||
| 25348 | 25342 | SOEKRIS NET48XX LED SUPPORT | |
| 25349 | 25343 | M: Chris Boot <bootc@bootc.net> | |
| @@ -25410,7 +25404,7 @@ F: drivers/md/md* | |||
| 25410 | 25404 | F: drivers/md/raid* | |
| 25411 | 25405 | F: include/linux/raid/ | |
| 25412 | 25406 | F: include/uapi/linux/raid/ | |
| 25413 | - | F: lib/raid/raid6/ | |
| 25407 | + | F: lib/raid/ | |
| 25414 | 25408 | ||
| 25415 | 25409 | SOLIDRUN CLEARFOG SUPPORT | |
| 25416 | 25410 | M: Russell King <linux@armlinux.org.uk> | |
| @@ -26954,8 +26948,7 @@ S: Maintained | |||
| 26954 | 26948 | F: drivers/net/ethernet/tehuti/tn40* | |
| 26955 | 26949 | ||
| 26956 | 26950 | TELECOM CLOCK DRIVER FOR MCPL0010 | |
| 26957 | - | M: Mark Gross <markgross@kernel.org> | |
| 26958 | - | S: Supported | |
| 26951 | + | S: Orphan | |
| 26959 | 26952 | F: drivers/char/tlclk.c | |
| 26960 | 26953 | ||
| 26961 | 26954 | TEMPO SEMICONDUCTOR DRIVERS | |
| @@ -28616,7 +28609,6 @@ L: iommu@lists.linux.dev | |||
| 28616 | 28609 | S: Maintained | |
| 28617 | 28610 | F: Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml | |
| 28618 | 28611 | F: drivers/iommu/vsi-iommu.c | |
| 28619 | - | F: include/linux/vsi-iommu.h | |
| 28620 | 28612 | ||
| 28621 | 28613 | VF610 NAND DRIVER | |
| 28622 | 28614 | M: Stefan Agner <stefan@agner.ch> | |
| @@ -28876,8 +28868,8 @@ F: include/uapi/linux/virtio_console.h | |||
| 28876 | 28868 | VIRTIO CORE | |
| 28877 | 28869 | M: "Michael S. Tsirkin" <mst@redhat.com> | |
| 28878 | 28870 | M: Jason Wang <jasowangio@gmail.com> | |
| 28871 | + | M: Eugenio Pérez <eperezma@redhat.com> | |
| 28879 | 28872 | R: Xuan Zhuo <xuanzhuo@linux.alibaba.com> | |
| 28880 | - | R: Eugenio Pérez <eperezma@redhat.com> | |
| 28881 | 28873 | L: virtualization@lists.linux.dev | |
| 28882 | 28874 | S: Maintained | |
| 28883 | 28875 | F: Documentation/ABI/testing/sysfs-bus-vdpa | |
| @@ -28954,7 +28946,7 @@ F: include/uapi/linux/virtio_gpu.h | |||
| 28954 | 28946 | VIRTIO HOST (VHOST) | |
| 28955 | 28947 | M: "Michael S. Tsirkin" <mst@redhat.com> | |
| 28956 | 28948 | M: Jason Wang <jasowangio@gmail.com> | |
| 28957 | - | R: Eugenio Pérez <eperezma@redhat.com> | |
| 28949 | + | M: Eugenio Pérez <eperezma@redhat.com> | |
| 28958 | 28950 | L: kvm@vger.kernel.org | |
| 28959 | 28951 | L: virtualization@lists.linux.dev | |
| 28960 | 28952 | L: netdev@vger.kernel.org | |
| @@ -29009,8 +29001,8 @@ F: include/uapi/linux/virtio_mem.h | |||
| 29009 | 29001 | VIRTIO NET DRIVER | |
| 29010 | 29002 | M: "Michael S. Tsirkin" <mst@redhat.com> | |
| 29011 | 29003 | M: Jason Wang <jasowangio@gmail.com> | |
| 29004 | + | M: Eugenio Pérez <eperezma@redhat.com> | |
| 29012 | 29005 | R: Xuan Zhuo <xuanzhuo@linux.alibaba.com> | |
| 29013 | - | R: Eugenio Pérez <eperezma@redhat.com> | |
| 29014 | 29006 | L: netdev@vger.kernel.org | |
| 29015 | 29007 | L: virtualization@lists.linux.dev | |
| 29016 | 29008 | S: Maintained | |
| @@ -29026,6 +29018,13 @@ S: Maintained | |||
| 29026 | 29018 | F: drivers/nvdimm/nd_virtio.c | |
| 29027 | 29019 | F: drivers/nvdimm/virtio_pmem.c | |
| 29028 | 29020 | ||
| 29021 | + | VIRTIO RNG DRIVER | |
| 29022 | + | M: Laurent Vivier <lvivier@redhat.com> | |
| 29023 | + | L: virtualization@lists.linux.dev | |
| 29024 | + | S: Maintained | |
| 29025 | + | F: drivers/char/hw_random/virtio-rng.c | |
| 29026 | + | F: include/uapi/linux/virtio_rng.h | |
| 29027 | + | ||
| 29029 | 29028 | VIRTIO RTC DRIVER | |
| 29030 | 29029 | M: Peter Hilber <peter.hilber@oss.qualcomm.com> | |
| 29031 | 29030 | L: virtualization@lists.linux.dev | |
| @@ -29357,7 +29356,7 @@ M: Guenter Roeck <linux@roeck-us.net> | |||
| 29357 | 29356 | L: linux-watchdog@vger.kernel.org | |
| 29358 | 29357 | S: Maintained | |
| 29359 | 29358 | W: http://www.linux-watchdog.org/ | |
| 29360 | - | T: git git://www.linux-watchdog.org/linux-watchdog.git | |
| 29359 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git | |
| 29361 | 29360 | F: Documentation/devicetree/bindings/watchdog/ | |
| 29362 | 29361 | F: Documentation/watchdog/ | |
| 29363 | 29362 | F: drivers/watchdog/ | |
| @@ -29937,12 +29936,14 @@ F: include/uapi/linux/xilinx-v4l2-controls.h | |||
| 29937 | 29936 | XILINX VERSAL EDAC DRIVER | |
| 29938 | 29937 | M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com> | |
| 29939 | 29938 | M: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com> | |
| 29939 | + | R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> | |
| 29940 | 29940 | S: Maintained | |
| 29941 | 29941 | F: Documentation/devicetree/bindings/memory-controllers/xlnx,versal-ddrmc-edac.yaml | |
| 29942 | 29942 | F: drivers/edac/versal_edac.c | |
| 29943 | 29943 | ||
| 29944 | 29944 | XILINX VERSALNET EDAC DRIVER | |
| 29945 | 29945 | M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com> | |
| 29946 | + | R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> | |
| 29946 | 29947 | S: Maintained | |
| 29947 | 29948 | F: Documentation/devicetree/bindings/memory-controllers/xlnx,versal-net-ddrmc5.yaml | |
| 29948 | 29949 | F: drivers/edac/versalnet_edac.c | |
| @@ -29988,6 +29989,7 @@ F: include/dt-bindings/dma/xlnx-zynqmp-dpdma.h | |||
| 29988 | 29989 | XILINX ZYNQMP OCM EDAC DRIVER | |
| 29989 | 29990 | M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com> | |
| 29990 | 29991 | M: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com> | |
| 29992 | + | R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> | |
| 29991 | 29993 | S: Maintained | |
| 29992 | 29994 | F: Documentation/devicetree/bindings/memory-controllers/xlnx,zynqmp-ocmc-1.0.yaml | |
| 29993 | 29995 | 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 = -rc3 | |
| 6 | 6 | NAME = Baby Opossum Posse | |
| 7 | 7 | ||
| 8 | 8 | # *DOCUMENTATION* | |
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/kernel/cpu_errata.c
| @@ -82,7 +82,7 @@ is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope) | |||
| 82 | 82 | ||
| 83 | 83 | for (i = 0; i < target_impl_cpu_num; i++) { | |
| 84 | 84 | if (__is_affected_midr_range(entry, target_impl_cpus[i].midr, | |
| 85 | - | target_impl_cpus[i].midr)) | |
| 85 | + | target_impl_cpus[i].revidr)) | |
| 86 | 86 | return true; | |
| 87 | 87 | } | |
| 88 | 88 | 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/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/kvm/nested.c
| @@ -93,7 +93,7 @@ int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu) | |||
| 93 | 93 | num_mmus = atomic_read(&kvm->online_vcpus) * S2_MMU_PER_VCPU; | |
| 94 | 94 | ||
| 95 | 95 | if (num_mmus > kvm->arch.nested_mmus_size) { | |
| 96 | - | tmp = kvcalloc(num_mmus, sizeof(*tmp), GFP_KERNEL_ACCOUNT); | |
| 96 | + | tmp = kvzalloc_objs(*tmp, num_mmus, GFP_KERNEL_ACCOUNT); | |
| 97 | 97 | if (!tmp) | |
| 98 | 98 | return -ENOMEM; | |
| 99 | 99 | ||
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/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/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/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/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/boot/dts/microchip/mpfs-beaglev-fire.dts
| @@ -90,6 +90,10 @@ | |||
| 90 | 90 | }; | |
| 91 | 91 | ||
| 92 | 92 | &gpio0 { | |
| 93 | + | interrupts = <13>, <14>, <15>, <16>, | |
| 94 | + | <17>, <18>, <19>, <20>, | |
| 95 | + | <21>, <22>, <23>, <24>, | |
| 96 | + | <25>, <26>; | |
| 93 | 97 | ngpios = <14>; | |
| 94 | 98 | gpio-line-names = "", "", "", "", "", "", "", | |
| 95 | 99 | "", "", "", "", "", "SD_CARD_CS", "USER_BUTTON"; | |
| @@ -97,6 +101,12 @@ | |||
| 97 | 101 | }; | |
| 98 | 102 | ||
| 99 | 103 | &gpio1 { | |
| 104 | + | interrupts = <27>, <28>, <29>, <30>, | |
| 105 | + | <31>, <32>, <33>, <34>, | |
| 106 | + | <35>, <36>, <37>, <38>, | |
| 107 | + | <39>, <40>, <41>, <42>, | |
| 108 | + | <43>, <44>, <45>, <46>, | |
| 109 | + | <47>, <48>, <49>, <50>; | |
| 100 | 110 | ngpios = <24>; | |
| 101 | 111 | gpio-line-names = "", "", "", "", "", "", "", "", "", "", | |
| 102 | 112 | "", "", "", "", "", "", "", "", "", "", | |
| @@ -105,6 +115,14 @@ | |||
| 105 | 115 | }; | |
| 106 | 116 | ||
| 107 | 117 | &gpio2 { | |
| 118 | + | interrupts = <53>, <53>, <53>, <53>, | |
| 119 | + | <53>, <53>, <53>, <53>, | |
| 120 | + | <53>, <53>, <53>, <53>, | |
| 121 | + | <53>, <53>, <53>, <53>, | |
| 122 | + | <53>, <53>, <53>, <53>, | |
| 123 | + | <53>, <53>, <53>, <53>, | |
| 124 | + | <53>, <53>, <53>, <53>, | |
| 125 | + | <53>, <53>, <53>, <53>; | |
| 108 | 126 | ngpios = <32>; | |
| 109 | 127 | gpio-line-names = "P8_PIN3_USER_LED_0", "P8_PIN4_USER_LED_1", "P8_PIN5_USER_LED_2", | |
| 110 | 128 | "P8_PIN6_USER_LED_3", "P8_PIN7_USER_LED_4", "P8_PIN8_USER_LED_5", | |
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/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/vcpu_pmu.c
| @@ -503,8 +503,8 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low | |||
| 503 | 503 | } | |
| 504 | 504 | } | |
| 505 | 505 | ||
| 506 | - | einfo = kvcalloc(num_events, sizeof(*einfo), | |
| 507 | - | GFP_KERNEL_ACCOUNT | __GFP_NOWARN); | |
| 506 | + | einfo = kvzalloc_objs(*einfo, num_events, | |
| 507 | + | GFP_KERNEL_ACCOUNT | __GFP_NOWARN); | |
| 508 | 508 | if (!einfo) { | |
| 509 | 509 | ret = SBI_ERR_FAILURE; | |
| 510 | 510 | goto out; | |
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/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/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; | |
| @@ -960,7 +962,7 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas) | |||
| 960 | 962 | return; | |
| 961 | 963 | } | |
| 962 | 964 | ||
| 963 | - | debug_get_param(id->name, &id->level, &pages_per_area); | |
| 965 | + | debug_get_param(id->name, &id->level, &pages_per_area, false); | |
| 964 | 966 | copy = debug_info_alloc("", pages_per_area, nr_areas, id->buf_size, | |
| 965 | 967 | id->level, ALL_AREAS); | |
| 966 | 968 | if (!copy) { | |
| @@ -1074,9 +1076,6 @@ static void _debug_set_level(debug_info_t *id, int new_level) | |||
| 1074 | 1076 | { | |
| 1075 | 1077 | unsigned long flags; | |
| 1076 | 1078 | ||
| 1077 | - | if (!id) | |
| 1078 | - | return; | |
| 1079 | - | ||
| 1080 | 1079 | if (new_level == DEBUG_OFF_LEVEL) { | |
| 1081 | 1080 | pr_info("%s: switched off\n", id->name); | |
| 1082 | 1081 | } else if ((new_level > DEBUG_MAX_LEVEL) || (new_level < 0)) { | |
| @@ -1101,8 +1100,14 @@ static void _debug_set_level(debug_info_t *id, int new_level) | |||
| 1101 | 1100 | */ | |
| 1102 | 1101 | void debug_set_level(debug_info_t *id, int new_level) | |
| 1103 | 1102 | { | |
| 1104 | - | /* Level specified via kernel parameter takes precedence */ | |
| 1105 | - | debug_get_param(id->name, &new_level, NULL); | |
| 1103 | + | if (!id) | |
| 1104 | + | return; | |
| 1105 | + | ||
| 1106 | + | /* | |
| 1107 | + | * Level specified via kernel parameter takes precedence. The override | |
| 1108 | + | * was already announced during registration, so stay quiet here. | |
| 1109 | + | */ | |
| 1110 | + | debug_get_param(id->name, &new_level, NULL, true); | |
| 1106 | 1111 | ||
| 1107 | 1112 | _debug_set_level(id, new_level); | |
| 1108 | 1113 | } | |
| @@ -1278,7 +1283,7 @@ void debug_set_critical(void) | |||
| 1278 | 1283 | debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf, | |
| 1279 | 1284 | int len) | |
| 1280 | 1285 | { | |
| 1281 | - | debug_entry_t *active; | |
| 1286 | + | debug_entry_t *active = NULL; | |
| 1282 | 1287 | unsigned long flags; | |
| 1283 | 1288 | ||
| 1284 | 1289 | if (!debug_active || !id->areas) | |
| @@ -1289,6 +1294,8 @@ debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf, | |||
| 1289 | 1294 | } else { | |
| 1290 | 1295 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1291 | 1296 | } | |
| 1297 | + | if (!id->areas) | |
| 1298 | + | goto out; | |
| 1292 | 1299 | do { | |
| 1293 | 1300 | active = get_active_entry(id); | |
| 1294 | 1301 | memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size)); | |
| @@ -1298,7 +1305,7 @@ debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf, | |||
| 1298 | 1305 | len -= id->buf_size; | |
| 1299 | 1306 | buf += id->buf_size; | |
| 1300 | 1307 | } while (len > 0); | |
| 1301 | - | ||
| 1308 | + | out: | |
| 1302 | 1309 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1303 | 1310 | return active; | |
| 1304 | 1311 | } | |
| @@ -1311,7 +1318,7 @@ EXPORT_SYMBOL(debug_event_common); | |||
| 1311 | 1318 | debug_entry_t *debug_exception_common(debug_info_t *id, int level, | |
| 1312 | 1319 | const void *buf, int len) | |
| 1313 | 1320 | { | |
| 1314 | - | debug_entry_t *active; | |
| 1321 | + | debug_entry_t *active = NULL; | |
| 1315 | 1322 | unsigned long flags; | |
| 1316 | 1323 | ||
| 1317 | 1324 | if (!debug_active || !id->areas) | |
| @@ -1322,6 +1329,8 @@ debug_entry_t *debug_exception_common(debug_info_t *id, int level, | |||
| 1322 | 1329 | } else { | |
| 1323 | 1330 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1324 | 1331 | } | |
| 1332 | + | if (!id->areas) | |
| 1333 | + | goto out; | |
| 1325 | 1334 | do { | |
| 1326 | 1335 | active = get_active_entry(id); | |
| 1327 | 1336 | memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size)); | |
| @@ -1331,7 +1340,7 @@ debug_entry_t *debug_exception_common(debug_info_t *id, int level, | |||
| 1331 | 1340 | len -= id->buf_size; | |
| 1332 | 1341 | buf += id->buf_size; | |
| 1333 | 1342 | } while (len > 0); | |
| 1334 | - | ||
| 1343 | + | out: | |
| 1335 | 1344 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1336 | 1345 | return active; | |
| 1337 | 1346 | } | |
| @@ -1357,7 +1366,7 @@ static inline int debug_count_numargs(char *string) | |||
| 1357 | 1366 | debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, ...) | |
| 1358 | 1367 | { | |
| 1359 | 1368 | debug_sprintf_entry_t *curr_event; | |
| 1360 | - | debug_entry_t *active; | |
| 1369 | + | debug_entry_t *active = NULL; | |
| 1361 | 1370 | unsigned long flags; | |
| 1362 | 1371 | int numargs, idx; | |
| 1363 | 1372 | va_list ap; | |
| @@ -1372,6 +1381,8 @@ debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, | |||
| 1372 | 1381 | } else { | |
| 1373 | 1382 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1374 | 1383 | } | |
| 1384 | + | if (!id->areas) | |
| 1385 | + | goto out; | |
| 1375 | 1386 | active = get_active_entry(id); | |
| 1376 | 1387 | curr_event = (debug_sprintf_entry_t *) DEBUG_DATA(active); | |
| 1377 | 1388 | va_start(ap, string); | |
| @@ -1380,6 +1391,7 @@ debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, | |||
| 1380 | 1391 | curr_event->args[idx] = va_arg(ap, long); | |
| 1381 | 1392 | va_end(ap); | |
| 1382 | 1393 | debug_finish_entry(id, active, level, 0); | |
| 1394 | + | out: | |
| 1383 | 1395 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1384 | 1396 | ||
| 1385 | 1397 | return active; | |
| @@ -1392,7 +1404,7 @@ EXPORT_SYMBOL(__debug_sprintf_event); | |||
| 1392 | 1404 | debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *string, ...) | |
| 1393 | 1405 | { | |
| 1394 | 1406 | debug_sprintf_entry_t *curr_event; | |
| 1395 | - | debug_entry_t *active; | |
| 1407 | + | debug_entry_t *active = NULL; | |
| 1396 | 1408 | unsigned long flags; | |
| 1397 | 1409 | int numargs, idx; | |
| 1398 | 1410 | va_list ap; | |
| @@ -1408,6 +1420,8 @@ debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *stri | |||
| 1408 | 1420 | } else { | |
| 1409 | 1421 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1410 | 1422 | } | |
| 1423 | + | if (!id->areas) | |
| 1424 | + | goto out; | |
| 1411 | 1425 | active = get_active_entry(id); | |
| 1412 | 1426 | curr_event = (debug_sprintf_entry_t *)DEBUG_DATA(active); | |
| 1413 | 1427 | va_start(ap, string); | |
| @@ -1416,6 +1430,7 @@ debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *stri | |||
| 1416 | 1430 | curr_event->args[idx] = va_arg(ap, long); | |
| 1417 | 1431 | va_end(ap); | |
| 1418 | 1432 | debug_finish_entry(id, active, level, 1); | |
| 1433 | + | out: | |
| 1419 | 1434 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1420 | 1435 | ||
| 1421 | 1436 | return active; | |
| @@ -1658,9 +1673,11 @@ static void debug_flush(debug_info_t *id, int area) | |||
| 1658 | 1673 | unsigned long flags; | |
| 1659 | 1674 | int i, j; | |
| 1660 | 1675 | ||
| 1661 | - | if (!id || !id->areas) | |
| 1676 | + | if (!id) | |
| 1662 | 1677 | return; | |
| 1663 | 1678 | raw_spin_lock_irqsave(&id->lock, flags); | |
| 1679 | + | if (!id->areas) | |
| 1680 | + | goto out; | |
| 1664 | 1681 | if (area == DEBUG_FLUSH_ALL) { | |
| 1665 | 1682 | id->active_area = 0; | |
| 1666 | 1683 | memset(id->active_entries, 0, id->nr_areas * sizeof(int)); | |
| @@ -1675,6 +1692,7 @@ static void debug_flush(debug_info_t *id, int area) | |||
| 1675 | 1692 | for (i = 0; i < id->pages_per_area; i++) | |
| 1676 | 1693 | memset(id->areas[area][i], 0, PAGE_SIZE); | |
| 1677 | 1694 | } | |
| 1695 | + | out: | |
| 1678 | 1696 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 1679 | 1697 | } | |
| 1680 | 1698 | ||
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/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/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 | ||
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_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/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/events/intel/core.c
| @@ -3125,6 +3125,27 @@ static void intel_pmu_del_event(struct perf_event *event) | |||
| 3125 | 3125 | this_cpu_ptr(&cpu_hw_events)->n_late_setup--; | |
| 3126 | 3126 | } | |
| 3127 | 3127 | ||
| 3128 | + | int __intel_pmu_quiesce(void) | |
| 3129 | + | { | |
| 3130 | + | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | |
| 3131 | + | int pmu_enabled = cpuc->enabled; | |
| 3132 | + | ||
| 3133 | + | cpuc->enabled = 0; | |
| 3134 | + | if (pmu_enabled) | |
| 3135 | + | intel_pmu_disable_all(); | |
| 3136 | + | ||
| 3137 | + | return pmu_enabled; | |
| 3138 | + | } | |
| 3139 | + | ||
| 3140 | + | void __intel_pmu_resume(int pmu_enabled) | |
| 3141 | + | { | |
| 3142 | + | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | |
| 3143 | + | ||
| 3144 | + | cpuc->enabled = pmu_enabled; | |
| 3145 | + | if (pmu_enabled) | |
| 3146 | + | intel_pmu_enable_all(0); | |
| 3147 | + | } | |
| 3148 | + | ||
| 3128 | 3149 | static int icl_set_topdown_event_period(struct perf_event *event) | |
| 3129 | 3150 | { | |
| 3130 | 3151 | struct hw_perf_event *hwc = &event->hw; | |
| @@ -3316,16 +3337,13 @@ static void intel_pmu_read_event(struct perf_event *event) | |||
| 3316 | 3337 | if (event->hw.flags & (PERF_X86_EVENT_AUTO_RELOAD | PERF_X86_EVENT_TOPDOWN) || | |
| 3317 | 3338 | is_pebs_counter_event_group(event)) { | |
| 3318 | 3339 | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | |
| 3319 | - | bool pmu_enabled = cpuc->enabled; | |
| 3340 | + | int pmu_enabled; | |
| 3320 | 3341 | ||
| 3321 | 3342 | /* Only need to call update_topdown_event() once for group read. */ | |
| 3322 | 3343 | if (is_metric_event(event) && (cpuc->txn_flags & PERF_PMU_TXN_READ)) | |
| 3323 | 3344 | return; | |
| 3324 | 3345 | ||
| 3325 | - | cpuc->enabled = 0; | |
| 3326 | - | if (pmu_enabled) | |
| 3327 | - | intel_pmu_disable_all(); | |
| 3328 | - | ||
| 3346 | + | pmu_enabled = __intel_pmu_quiesce(); | |
| 3329 | 3347 | /* | |
| 3330 | 3348 | * If the PEBS counters snapshotting is enabled, | |
| 3331 | 3349 | * the topdown event is available in PEBS records. | |
| @@ -3334,10 +3352,7 @@ static void intel_pmu_read_event(struct perf_event *event) | |||
| 3334 | 3352 | static_call(intel_pmu_update_topdown_event)(event, NULL); | |
| 3335 | 3353 | else | |
| 3336 | 3354 | intel_pmu_drain_pebs_buffer(); | |
| 3337 | - | ||
| 3338 | - | cpuc->enabled = pmu_enabled; | |
| 3339 | - | if (pmu_enabled) | |
| 3340 | - | intel_pmu_enable_all(0); | |
| 3355 | + | __intel_pmu_resume(pmu_enabled); | |
| 3341 | 3356 | ||
| 3342 | 3357 | return; | |
| 3343 | 3358 | } | |
modified arch/x86/events/intel/ds.c
| @@ -1242,8 +1242,11 @@ unlock: | |||
| 1242 | 1242 | ||
| 1243 | 1243 | void intel_pmu_drain_pebs_buffer(void) | |
| 1244 | 1244 | { | |
| 1245 | + | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | |
| 1245 | 1246 | struct perf_sample_data data; | |
| 1246 | 1247 | ||
| 1248 | + | WARN_ON_ONCE(cpuc->enabled); | |
| 1249 | + | ||
| 1247 | 1250 | static_call(x86_pmu_drain_pebs)(NULL, &data); | |
| 1248 | 1251 | } | |
| 1249 | 1252 | ||
| @@ -1864,8 +1867,11 @@ static void intel_pmu_pebs_via_pt_enable(struct perf_event *event) | |||
| 1864 | 1867 | static inline void intel_pmu_drain_large_pebs(struct cpu_hw_events *cpuc) | |
| 1865 | 1868 | { | |
| 1866 | 1869 | if (cpuc->n_pebs == cpuc->n_large_pebs && | |
| 1867 | - | cpuc->n_pebs != cpuc->n_pebs_via_pt) | |
| 1870 | + | cpuc->n_pebs != cpuc->n_pebs_via_pt) { | |
| 1871 | + | int enabled = __intel_pmu_quiesce(); | |
| 1868 | 1872 | intel_pmu_drain_pebs_buffer(); | |
| 1873 | + | __intel_pmu_resume(enabled); | |
| 1874 | + | } | |
| 1869 | 1875 | } | |
| 1870 | 1876 | ||
| 1871 | 1877 | static void __intel_pmu_pebs_enable(struct perf_event *event) | |
| @@ -2432,7 +2438,7 @@ static inline void __setup_pebs_basic_group(struct perf_event *event, | |||
| 2432 | 2438 | { | |
| 2433 | 2439 | /* The ip in basic is EventingIP */ | |
| 2434 | 2440 | set_linear_ip(regs, ip); | |
| 2435 | - | regs->flags = PERF_EFLAGS_EXACT; | |
| 2441 | + | regs->flags |= PERF_EFLAGS_EXACT; | |
| 2436 | 2442 | setup_pebs_time(event, data, tsc); | |
| 2437 | 2443 | ||
| 2438 | 2444 | if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) | |
| @@ -2444,9 +2450,17 @@ static inline void __setup_pebs_gpr_group(struct perf_event *event, | |||
| 2444 | 2450 | struct pebs_gprs *gprs, | |
| 2445 | 2451 | u64 sample_type) | |
| 2446 | 2452 | { | |
| 2453 | + | /* | |
| 2454 | + | * Update flags with PEBS data. PERF_EFLAGS_EXACT must be set | |
| 2455 | + | * in previous basic group handling. | |
| 2456 | + | */ | |
| 2457 | + | regs->flags = gprs->flags | PERF_EFLAGS_EXACT; | |
| 2458 | + | ||
| 2447 | 2459 | if (event->attr.precise_ip < 2) { | |
| 2448 | 2460 | set_linear_ip(regs, gprs->ip); | |
| 2449 | 2461 | regs->flags &= ~PERF_EFLAGS_EXACT; | |
| 2462 | + | } else if (regs->flags & X86_VM_MASK) { | |
| 2463 | + | regs->flags ^= (PERF_EFLAGS_VM | X86_VM_MASK); | |
| 2450 | 2464 | } | |
| 2451 | 2465 | ||
| 2452 | 2466 | if (sample_type & (PERF_SAMPLE_REGS_INTR | PERF_SAMPLE_REGS_USER)) | |
modified arch/x86/events/perf_event.h
| @@ -1638,6 +1638,9 @@ static __always_inline void __intel_pmu_lbr_disable(void) | |||
| 1638 | 1638 | wrmsrq(MSR_IA32_DEBUGCTLMSR, debugctl); | |
| 1639 | 1639 | } | |
| 1640 | 1640 | ||
| 1641 | + | extern int __intel_pmu_quiesce(void); | |
| 1642 | + | extern void __intel_pmu_resume(int pmu_enabled); | |
| 1643 | + | ||
| 1641 | 1644 | int intel_pmu_save_and_restart(struct perf_event *event); | |
| 1642 | 1645 | ||
| 1643 | 1646 | struct event_constraint * | |
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); | |
| @@ -287,6 +291,11 @@ static int __init amd_smn_init(void) | |||
| 287 | 291 | return -ENOMEM; | |
| 288 | 292 | ||
| 289 | 293 | roots_per_node = num_roots / num_nodes; | |
| 294 | + | if (!roots_per_node) { | |
| 295 | + | if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) | |
| 296 | + | pr_warn(FW_BUG "Error detecting roots per node.\n"); | |
| 297 | + | roots_per_node = 1; | |
| 298 | + | } | |
| 290 | 299 | ||
| 291 | 300 | count = 0; | |
| 292 | 301 | node = 0; | |
| @@ -308,8 +317,6 @@ static int __init amd_smn_init(void) | |||
| 308 | 317 | debugfs_create_file("value", 0600, debugfs_dir, NULL, &smn_value_fops); | |
| 309 | 318 | } | |
| 310 | 319 | ||
| 311 | - | smn_exclusive = true; | |
| 312 | - | ||
| 313 | 320 | return 0; | |
| 314 | 321 | } | |
| 315 | 322 | ||
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/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/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 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/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/Kconfig
| @@ -6,6 +6,7 @@ config DRM_ACCEL_AMDXDNA | |||
| 6 | 6 | depends on DRM_ACCEL | |
| 7 | 7 | depends on PCI && HAS_IOMEM | |
| 8 | 8 | depends on X86_64 | |
| 9 | + | depends on AMD_PMF || !AMD_PMF | |
| 9 | 10 | select DRM_SCHED | |
| 10 | 11 | select DRM_GEM_SHMEM_HELPER | |
| 11 | 12 | select FW_LOADER | |
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_device.c
| @@ -31,6 +31,8 @@ struct rocket_device *rocket_device_init(struct platform_device *pdev, | |||
| 31 | 31 | if (of_device_is_available(core_node)) | |
| 32 | 32 | num_cores++; | |
| 33 | 33 | ||
| 34 | + | rdev->max_cores = num_cores; | |
| 35 | + | ||
| 34 | 36 | rdev->cores = devm_kcalloc(dev, num_cores, sizeof(*rdev->cores), GFP_KERNEL); | |
| 35 | 37 | if (!rdev->cores) | |
| 36 | 38 | return ERR_PTR(-ENOMEM); | |
modified drivers/accel/rocket/rocket_device.h
| @@ -19,6 +19,7 @@ struct rocket_device { | |||
| 19 | 19 | ||
| 20 | 20 | struct rocket_core *cores; | |
| 21 | 21 | unsigned int num_cores; | |
| 22 | + | unsigned int max_cores; | |
| 22 | 23 | }; | |
| 23 | 24 | ||
| 24 | 25 | struct rocket_device *rocket_device_init(struct platform_device *pdev, | |
modified drivers/accel/rocket/rocket_drv.c
| @@ -165,8 +165,11 @@ static int rocket_probe(struct platform_device *pdev) | |||
| 165 | 165 | /* First core probing, initialize DRM device. */ | |
| 166 | 166 | rdev = rocket_device_init(drm_dev, &rocket_drm_driver); | |
| 167 | 167 | if (IS_ERR(rdev)) { | |
| 168 | + | int err = PTR_ERR(rdev); | |
| 169 | + | ||
| 168 | 170 | dev_err(&pdev->dev, "failed to initialize rocket device\n"); | |
| 169 | - | return PTR_ERR(rdev); | |
| 171 | + | rdev = NULL; | |
| 172 | + | return err; | |
| 170 | 173 | } | |
| 171 | 174 | } | |
| 172 | 175 | ||
| @@ -223,7 +226,7 @@ static int find_core_for_dev(struct device *dev) | |||
| 223 | 226 | { | |
| 224 | 227 | struct rocket_device *rdev = dev_get_drvdata(dev); | |
| 225 | 228 | ||
| 226 | - | for (unsigned int core = 0; core < rdev->num_cores; core++) { | |
| 229 | + | for (unsigned int core = 0; core < rdev->max_cores; core++) { | |
| 227 | 230 | if (dev == rdev->cores[core].dev) | |
| 228 | 231 | return core; | |
| 229 | 232 | } | |
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/libata-scsi.c
| @@ -4823,28 +4823,6 @@ ata_scsi_get_phys_element_status_xlat(struct ata_queued_cmd *qc) | |||
| 4823 | 4823 | return 0; | |
| 4824 | 4824 | } | |
| 4825 | 4825 | ||
| 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 | 4826 | static unsigned int | |
| 4849 | 4827 | ata_scsi_remove_element_and_truncate_xlat(struct ata_queued_cmd *qc) | |
| 4850 | 4828 | { | |
| @@ -4884,7 +4862,6 @@ ata_scsi_remove_element_and_truncate_xlat(struct ata_queued_cmd *qc) | |||
| 4884 | 4862 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48; | |
| 4885 | 4863 | ||
| 4886 | 4864 | qc->flags |= ATA_QCFLAG_RESULT_TF; | |
| 4887 | - | qc->complete_fn = ata_scsi_depop_ua_cap_changed_complete; | |
| 4888 | 4865 | ||
| 4889 | 4866 | return 0; | |
| 4890 | 4867 | } | |
| @@ -4937,7 +4914,6 @@ ata_scsi_restore_elements_and_rebuild_xlat(struct ata_queued_cmd *qc) | |||
| 4937 | 4914 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48; | |
| 4938 | 4915 | ||
| 4939 | 4916 | qc->flags |= ATA_QCFLAG_RESULT_TF; | |
| 4940 | - | qc->complete_fn = ata_scsi_depop_ua_cap_changed_complete; | |
| 4941 | 4917 | ||
| 4942 | 4918 | return 0; | |
| 4943 | 4919 | } | |
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
| @@ -1099,7 +1099,7 @@ static void btintel_pcie_msix_tx_handle(struct btintel_pcie_data *data) | |||
| 1099 | 1099 | ||
| 1100 | 1100 | urbd0 = &txq->urbd0s[cr_tia]; | |
| 1101 | 1101 | ||
| 1102 | - | if (urbd0->tfd_index > txq->count) | |
| 1102 | + | if (urbd0->tfd_index >= txq->count) | |
| 1103 | 1103 | return; | |
| 1104 | 1104 | ||
| 1105 | 1105 | cr_tia = (cr_tia + 1) % txq->count; | |
| @@ -1599,7 +1599,9 @@ static int btintel_pcie_submit_rx_work(struct btintel_pcie_data *data, u8 status | |||
| 1599 | 1599 | rfh_hdr = buf; | |
| 1600 | 1600 | ||
| 1601 | 1601 | len = rfh_hdr->packet_len; | |
| 1602 | - | if (len <= 0) { | |
| 1602 | + | if (len == 0 || len > BTINTEL_PCIE_BUFFER_SIZE - sizeof(*rfh_hdr)) { | |
| 1603 | + | bt_dev_err(data->hdev, "Invalid packet_len %d (max %zu)", len, | |
| 1604 | + | BTINTEL_PCIE_BUFFER_SIZE - sizeof(*rfh_hdr)); | |
| 1603 | 1605 | ret = -EINVAL; | |
| 1604 | 1606 | goto resubmit; | |
| 1605 | 1607 | } | |
| @@ -1696,6 +1698,9 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id) | |||
| 1696 | 1698 | ||
| 1697 | 1699 | if (unlikely(!(intr_fh | intr_hw))) { | |
| 1698 | 1700 | /* Ignore interrupt, inta == 0 */ | |
| 1701 | + | bt_warn_ratelimited("Bluetooth: btintel_pcie: Received spurious interrupt\n"); | |
| 1702 | + | btintel_pcie_wr_reg32(data, BTINTEL_PCIE_CSR_MSIX_AUTOMASK_ST, | |
| 1703 | + | BIT(entry->entry)); | |
| 1699 | 1704 | return IRQ_NONE; | |
| 1700 | 1705 | } | |
| 1701 | 1706 | ||
modified drivers/bluetooth/btmtk.c
| @@ -1374,16 +1374,6 @@ int btmtk_usb_setup(struct hci_dev *hdev) | |||
| 1374 | 1374 | break; | |
| 1375 | 1375 | case 0x7922: | |
| 1376 | 1376 | 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 | 1377 | case 0x7961: | |
| 1388 | 1378 | case 0x7902: | |
| 1389 | 1379 | case 0x6639: | |
| @@ -1587,5 +1577,6 @@ MODULE_FIRMWARE(FIRMWARE_MT7663); | |||
| 1587 | 1577 | MODULE_FIRMWARE(FIRMWARE_MT7668); | |
| 1588 | 1578 | MODULE_FIRMWARE(FIRMWARE_MT7922); | |
| 1589 | 1579 | MODULE_FIRMWARE(FIRMWARE_MT7961); | |
| 1580 | + | MODULE_FIRMWARE(FIRMWARE_MT7920); | |
| 1590 | 1581 | MODULE_FIRMWARE(FIRMWARE_MT7925); | |
| 1591 | 1582 | 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/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> | |
| @@ -980,6 +981,8 @@ struct btqca_data { | |||
| 980 | 981 | #define BTUSB_USE_ALT3_FOR_WBS 15 | |
| 981 | 982 | #define BTUSB_ALT6_CONTINUOUS_TX 16 | |
| 982 | 983 | #define BTUSB_HW_SSR_ACTIVE 17 | |
| 984 | + | #define BTUSB_WAKEUP_BROKEN 18 | |
| 985 | + | #define BTUSB_RESET 19 | |
| 983 | 986 | ||
| 984 | 987 | struct btusb_data { | |
| 985 | 988 | struct hci_dev *hdev; | |
| @@ -1054,13 +1057,15 @@ static void btusb_reset(struct hci_dev *hdev) | |||
| 1054 | 1057 | int err; | |
| 1055 | 1058 | ||
| 1056 | 1059 | data = hci_get_drvdata(hdev); | |
| 1057 | - | /* This is not an unbalanced PM reference since the device will reset */ | |
| 1058 | 1060 | err = usb_autopm_get_interface(data->intf); | |
| 1059 | 1061 | if (err) { | |
| 1060 | 1062 | bt_dev_err(hdev, "Failed usb_autopm_get_interface: %d", err); | |
| 1061 | 1063 | return; | |
| 1062 | 1064 | } | |
| 1063 | 1065 | ||
| 1066 | + | if (test_and_set_bit(BTUSB_RESET, &data->flags)) | |
| 1067 | + | usb_autopm_put_interface_no_suspend(data->intf); | |
| 1068 | + | ||
| 1064 | 1069 | bt_dev_err(hdev, "Resetting usb device."); | |
| 1065 | 1070 | usb_queue_reset_device(data->intf); | |
| 1066 | 1071 | } | |
| @@ -2092,18 +2097,24 @@ static int btusb_close(struct hci_dev *hdev) | |||
| 2092 | 2097 | ||
| 2093 | 2098 | BT_DBG("%s", hdev->name); | |
| 2094 | 2099 | ||
| 2095 | - | cancel_delayed_work(&data->rx_work); | |
| 2096 | 2100 | cancel_work_sync(&data->work); | |
| 2097 | 2101 | cancel_work_sync(&data->waker); | |
| 2098 | 2102 | ||
| 2099 | - | skb_queue_purge(&data->acl_q); | |
| 2100 | - | ||
| 2101 | 2103 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); | |
| 2102 | 2104 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); | |
| 2103 | 2105 | clear_bit(BTUSB_INTR_RUNNING, &data->flags); | |
| 2104 | 2106 | clear_bit(BTUSB_DIAG_RUNNING, &data->flags); | |
| 2105 | 2107 | ||
| 2106 | 2108 | btusb_stop_traffic(data); | |
| 2109 | + | ||
| 2110 | + | /* rx_work must only be canceled once the URBs that can rearm it are | |
| 2111 | + | * gone, and it must be canceled synchronously since btusb_disconnect() | |
| 2112 | + | * frees the btusb_data it dereferences right after hci_unregister_dev(). | |
| 2113 | + | */ | |
| 2114 | + | cancel_delayed_work_sync(&data->rx_work); | |
| 2115 | + | ||
| 2116 | + | skb_queue_purge(&data->acl_q); | |
| 2117 | + | ||
| 2107 | 2118 | btusb_free_frags(data); | |
| 2108 | 2119 | ||
| 2109 | 2120 | err = usb_autopm_get_interface(data->intf); | |
| @@ -2129,7 +2140,7 @@ static int btusb_flush(struct hci_dev *hdev) | |||
| 2129 | 2140 | ||
| 2130 | 2141 | BT_DBG("%s", hdev->name); | |
| 2131 | 2142 | ||
| 2132 | - | cancel_delayed_work(&data->rx_work); | |
| 2143 | + | cancel_delayed_work_sync(&data->rx_work); | |
| 2133 | 2144 | ||
| 2134 | 2145 | skb_queue_purge(&data->acl_q); | |
| 2135 | 2146 | ||
| @@ -2923,8 +2934,11 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data) | |||
| 2923 | 2934 | } | |
| 2924 | 2935 | ||
| 2925 | 2936 | err = usb_autopm_get_interface(data->intf); | |
| 2926 | - | if (err < 0) | |
| 2937 | + | if (err < 0) { | |
| 2938 | + | bt_dev_err(hdev, "Failed usb_autopm_get_interface: %d", err); | |
| 2939 | + | clear_bit(BTMTK_HW_RESET_ACTIVE, &btmtk_data->flags); | |
| 2927 | 2940 | return err; | |
| 2941 | + | } | |
| 2928 | 2942 | ||
| 2929 | 2943 | /* Release MediaTek ISO data interface */ | |
| 2930 | 2944 | btusb_mtk_release_iso_intf(hdev); | |
| @@ -2946,6 +2960,11 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data) | |||
| 2946 | 2960 | ||
| 2947 | 2961 | err = btmtk_usb_subsys_reset(hdev, btmtk_data->dev_id); | |
| 2948 | 2962 | ||
| 2963 | + | if (test_and_set_bit(BTUSB_RESET, &data->flags)) { | |
| 2964 | + | bt_dev_err(hdev, "last usb reset failed? Resetting again"); | |
| 2965 | + | usb_autopm_put_interface_no_suspend(data->intf); | |
| 2966 | + | } | |
| 2967 | + | ||
| 2949 | 2968 | usb_queue_reset_device(data->intf); | |
| 2950 | 2969 | clear_bit(BTMTK_HW_RESET_ACTIVE, &btmtk_data->flags); | |
| 2951 | 2970 | ||
| @@ -2969,10 +2988,25 @@ static int btusb_send_frame_mtk(struct hci_dev *hdev, struct sk_buff *skb) | |||
| 2969 | 2988 | } | |
| 2970 | 2989 | } | |
| 2971 | 2990 | ||
| 2991 | + | static inline bool platform_is_ryzen(void) | |
| 2992 | + | { | |
| 2993 | + | #ifdef CONFIG_X86 | |
| 2994 | + | return boot_cpu_has(X86_FEATURE_ZEN); | |
| 2995 | + | #else | |
| 2996 | + | return false; | |
| 2997 | + | #endif | |
| 2998 | + | } | |
| 2999 | + | ||
| 3000 | + | static inline bool is_direct_child_of_root_hub(struct usb_device *udev) | |
| 3001 | + | { | |
| 3002 | + | return udev->parent == udev->bus->root_hub; | |
| 3003 | + | } | |
| 3004 | + | ||
| 2972 | 3005 | static int btusb_mtk_setup(struct hci_dev *hdev) | |
| 2973 | 3006 | { | |
| 2974 | 3007 | struct btusb_data *data = hci_get_drvdata(hdev); | |
| 2975 | 3008 | struct btmtk_data *btmtk_data = hci_get_priv(hdev); | |
| 3009 | + | int err; | |
| 2976 | 3010 | ||
| 2977 | 3011 | /* MediaTek WMT vendor cmd requiring below USB resources to | |
| 2978 | 3012 | * complete the handshake. | |
| @@ -2989,7 +3023,40 @@ static int btusb_mtk_setup(struct hci_dev *hdev) | |||
| 2989 | 3023 | btusb_mtk_claim_iso_intf(data); | |
| 2990 | 3024 | } | |
| 2991 | 3025 | ||
| 2992 | - | return btmtk_usb_setup(hdev); | |
| 3026 | + | err = btmtk_usb_setup(hdev); | |
| 3027 | + | if (err) | |
| 3028 | + | return err; | |
| 3029 | + | ||
| 3030 | + | switch (btmtk_data->dev_id) { | |
| 3031 | + | case 0x7922: | |
| 3032 | + | case 0x7925: | |
| 3033 | + | /* | |
| 3034 | + | * All reports seen to be relevant to Ryzen-based laptops. These | |
| 3035 | + | * NICs are usually used as OEM components thanks to some sort | |
| 3036 | + | * of reference designs. | |
| 3037 | + | * | |
| 3038 | + | * Their popularity on other platforms is unclear. While there | |
| 3039 | + | * is still a chance that the quirk may exist on other | |
| 3040 | + | * platforms, be cautious and only apply the quirk to direct | |
| 3041 | + | * children of Ryzen platforms's root hubs for the time being. | |
| 3042 | + | * | |
| 3043 | + | * In most cases the root hub is on the SoC or PCH, which needs | |
| 3044 | + | * the quirk. Unfortunately, this can't distinguish root hubs on | |
| 3045 | + | * PCIe add-in cards. Such roughness should be acceptable, as | |
| 3046 | + | * PCIe USB controller add-in cards are less commonly used | |
| 3047 | + | * nowadays. On the other hand, applying the quirk doesn't hurt | |
| 3048 | + | * any functionalities either, as the device can still be used | |
| 3049 | + | * as a wakeup source if desired. | |
| 3050 | + | * | |
| 3051 | + | * Theoretically, we could retrieve the root hub's PCI vendor ID | |
| 3052 | + | * with some hierarchy magic, but that's too intrusive... | |
| 3053 | + | */ | |
| 3054 | + | if (platform_is_ryzen() && is_direct_child_of_root_hub(data->udev)) | |
| 3055 | + | set_bit(BTUSB_WAKEUP_BROKEN, &data->flags); | |
| 3056 | + | break; | |
| 3057 | + | } | |
| 3058 | + | ||
| 3059 | + | return 0; | |
| 2993 | 3060 | } | |
| 2994 | 3061 | ||
| 2995 | 3062 | static int btusb_mtk_shutdown(struct hci_dev *hdev) | |
| @@ -4540,6 +4607,9 @@ static void btusb_disconnect(struct usb_interface *intf) | |||
| 4540 | 4607 | if (data->reset_gpio) | |
| 4541 | 4608 | gpiod_put(data->reset_gpio); | |
| 4542 | 4609 | ||
| 4610 | + | if (test_and_clear_bit(BTUSB_RESET, &data->flags)) | |
| 4611 | + | usb_autopm_put_interface_no_suspend(data->intf); | |
| 4612 | + | ||
| 4543 | 4613 | if (intf == data->intf) { | |
| 4544 | 4614 | if (data->isoc) | |
| 4545 | 4615 | usb_driver_release_interface(&btusb_driver, data->isoc); | |
| @@ -4565,11 +4635,26 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message) | |||
| 4565 | 4635 | ||
| 4566 | 4636 | BT_DBG("intf %p", intf); | |
| 4567 | 4637 | ||
| 4568 | - | /* Don't auto-suspend if there are connections or discovery in | |
| 4569 | - | * progress; external suspend calls shall never fail. | |
| 4638 | + | /* | |
| 4639 | + | * It is reported that remote wakeup events could sometimes cause some | |
| 4640 | + | * adapters completely unresponsive. Resetting the xHCI root hub doesn't | |
| 4641 | + | * help at all, and recovering from such a state needs a power cycle. | |
| 4642 | + | * Since disabling remote wakeup simply causes the USB core to gate | |
| 4643 | + | * runtime autosuspend as well due to needs_remote_wakeup == 1, let's do | |
| 4644 | + | * this ourselves to make our life easier. The interface can be safely | |
| 4645 | + | * autosuspended as long as remote wakeup is disabled, i.e., after | |
| 4646 | + | * closing the HCI device. | |
| 4647 | + | * | |
| 4648 | + | * Don't auto-suspend if there are connections or discovery in progress. | |
| 4649 | + | * | |
| 4650 | + | * External suspend calls shall never fail. Specifically, a device with | |
| 4651 | + | * broken remote wakeup may still take the advantage of remote wakeup in | |
| 4652 | + | * order to wake up the system from sleep if userspace has enabled it as | |
| 4653 | + | * a wakeup source. | |
| 4570 | 4654 | */ | |
| 4571 | 4655 | if (PMSG_IS_AUTO(message) && | |
| 4572 | - | (hci_conn_count(data->hdev) || hci_discovery_active(data->hdev))) | |
| 4656 | + | ((test_bit(BTUSB_WAKEUP_BROKEN, &data->flags) && data->intf->needs_remote_wakeup) || | |
| 4657 | + | hci_conn_count(data->hdev) || hci_discovery_active(data->hdev))) | |
| 4573 | 4658 | return -EBUSY; | |
| 4574 | 4659 | ||
| 4575 | 4660 | 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/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/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/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/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/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/firmware/arm_scmi/driver.c
| @@ -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/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-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-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-virtuser.c
| @@ -1429,8 +1429,7 @@ gpio_virtuser_make_device_swnode(struct gpio_virtuser_device *dev) | |||
| 1429 | 1429 | memset(properties, 0, sizeof(properties)); | |
| 1430 | 1430 | ||
| 1431 | 1431 | num_ids = list_count_nodes(&dev->lookup_list); | |
| 1432 | - | char **ids __free(kfree) = kcalloc(num_ids + 1, sizeof(*ids), | |
| 1433 | - | GFP_KERNEL); | |
| 1432 | + | char **ids __free(kfree) = kzalloc_objs(*ids, num_ids + 1); | |
| 1434 | 1433 | if (!ids) | |
| 1435 | 1434 | return ERR_PTR(-ENOMEM); | |
| 1436 | 1435 | ||
modified drivers/gpio/gpiolib-cdev.c
| @@ -2653,7 +2653,7 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file) | |||
| 2653 | 2653 | struct gpio_chardev_data *cdev; | |
| 2654 | 2654 | int ret = -ENOMEM; | |
| 2655 | 2655 | ||
| 2656 | - | cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); | |
| 2656 | + | cdev = kzalloc_obj(*cdev); | |
| 2657 | 2657 | if (!cdev) | |
| 2658 | 2658 | return -ENOMEM; | |
| 2659 | 2659 | ||
modified drivers/gpio/gpiolib.c
| @@ -1178,7 +1178,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, | |||
| 1178 | 1178 | int base = 0; | |
| 1179 | 1179 | int ret; | |
| 1180 | 1180 | ||
| 1181 | - | gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); | |
| 1181 | + | gdev = kzalloc_obj(*gdev); | |
| 1182 | 1182 | if (!gdev) | |
| 1183 | 1183 | return -ENOMEM; | |
| 1184 | 1184 | gc->gpiodev = gdev; | |
| @@ -1218,7 +1218,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, | |||
| 1218 | 1218 | goto err_put_device; | |
| 1219 | 1219 | gdev->ngpio = gc->ngpio; | |
| 1220 | 1220 | ||
| 1221 | - | gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL); | |
| 1221 | + | gdev->descs = kzalloc_objs(*gdev->descs, gc->ngpio); | |
| 1222 | 1222 | if (!gdev->descs) { | |
| 1223 | 1223 | ret = -ENOMEM; | |
| 1224 | 1224 | 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_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; | |
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_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_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
| @@ -1544,7 +1544,7 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost) | |||
| 1544 | 1544 | struct amdgpu_usermode_queue *queue; | |
| 1545 | 1545 | const struct amdgpu_userq_funcs *userq_funcs; | |
| 1546 | 1546 | unsigned long queue_id; | |
| 1547 | - | int r = 0; | |
| 1547 | + | int ret = 0, r; | |
| 1548 | 1548 | ||
| 1549 | 1549 | xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) { | |
| 1550 | 1550 | if (queue->state == AMDGPU_USERQ_STATE_HUNG && !vram_lost) { | |
| @@ -1555,6 +1555,7 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost) | |||
| 1555 | 1555 | r = userq_funcs->map(queue); | |
| 1556 | 1556 | if (r) { | |
| 1557 | 1557 | dev_err(adev->dev, "Failed to remap queue %ld\n", queue_id); | |
| 1558 | + | ret = r; | |
| 1558 | 1559 | continue; | |
| 1559 | 1560 | } | |
| 1560 | 1561 | trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_MAPPED); | |
| @@ -1562,5 +1563,5 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost) | |||
| 1562 | 1563 | } | |
| 1563 | 1564 | } | |
| 1564 | 1565 | ||
| 1565 | - | return r; | |
| 1566 | + | return ret; | |
| 1566 | 1567 | } | |
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); | |
| @@ -3122,7 +3122,7 @@ static void amdgpu_debugfs_vm_bo_status_info(struct seq_file *m, | |||
| 3122 | 3122 | ||
| 3123 | 3123 | id = 0; | |
| 3124 | 3124 | seq_puts(m, "\tIdle BOs:\n"); | |
| 3125 | - | list_for_each_entry(base, &lists->needs_update, vm_status) { | |
| 3125 | + | list_for_each_entry(base, &lists->idle, vm_status) { | |
| 3126 | 3126 | if (!base->bo) | |
| 3127 | 3127 | continue; | |
| 3128 | 3128 | ||
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/amdkfd/kfd_chardev.c
| @@ -1921,13 +1921,13 @@ static int criu_checkpoint_devices(struct kfd_process *p, | |||
| 1921 | 1921 | struct kfd_criu_device_bucket *device_buckets = NULL; | |
| 1922 | 1922 | int ret = 0, i; | |
| 1923 | 1923 | ||
| 1924 | - | device_buckets = kvcalloc(num_devices, sizeof(*device_buckets), GFP_KERNEL); | |
| 1924 | + | device_buckets = kvzalloc_objs(*device_buckets, num_devices); | |
| 1925 | 1925 | if (!device_buckets) { | |
| 1926 | 1926 | ret = -ENOMEM; | |
| 1927 | 1927 | goto exit; | |
| 1928 | 1928 | } | |
| 1929 | 1929 | ||
| 1930 | - | device_priv = kvcalloc(num_devices, sizeof(*device_priv), GFP_KERNEL); | |
| 1930 | + | device_priv = kvzalloc_objs(*device_priv, num_devices); | |
| 1931 | 1931 | if (!device_priv) { | |
| 1932 | 1932 | ret = -ENOMEM; | |
| 1933 | 1933 | goto exit; | |
| @@ -2047,17 +2047,17 @@ static int criu_checkpoint_bos(struct kfd_process *p, | |||
| 2047 | 2047 | int ret = 0, pdd_index, bo_index = 0, id; | |
| 2048 | 2048 | void *mem; | |
| 2049 | 2049 | ||
| 2050 | - | bo_buckets = kvcalloc(num_bos, sizeof(*bo_buckets), GFP_KERNEL); | |
| 2050 | + | bo_buckets = kvzalloc_objs(*bo_buckets, num_bos); | |
| 2051 | 2051 | if (!bo_buckets) | |
| 2052 | 2052 | return -ENOMEM; | |
| 2053 | 2053 | ||
| 2054 | - | bo_privs = kvcalloc(num_bos, sizeof(*bo_privs), GFP_KERNEL); | |
| 2054 | + | bo_privs = kvzalloc_objs(*bo_privs, num_bos); | |
| 2055 | 2055 | if (!bo_privs) { | |
| 2056 | 2056 | ret = -ENOMEM; | |
| 2057 | 2057 | goto exit; | |
| 2058 | 2058 | } | |
| 2059 | 2059 | ||
| 2060 | - | files = kvcalloc(num_bos, sizeof(struct file *), GFP_KERNEL); | |
| 2060 | + | files = kvzalloc_objs(struct file *, num_bos); | |
| 2061 | 2061 | if (!files) { | |
| 2062 | 2062 | ret = -ENOMEM; | |
| 2063 | 2063 | goto exit; | |
| @@ -2588,7 +2588,7 @@ static int criu_restore_bos(struct kfd_process *p, | |||
| 2588 | 2588 | if (!bo_buckets) | |
| 2589 | 2589 | return -ENOMEM; | |
| 2590 | 2590 | ||
| 2591 | - | files = kvcalloc(args->num_bos, sizeof(struct file *), GFP_KERNEL); | |
| 2591 | + | files = kvzalloc_objs(struct file *, args->num_bos); | |
| 2592 | 2592 | if (!files) { | |
| 2593 | 2593 | ret = -ENOMEM; | |
| 2594 | 2594 | goto exit; | |
modified drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
| @@ -1455,6 +1455,14 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm, | |||
| 1455 | 1455 | dqm_evict_mqd_bo(dqm, q); | |
| 1456 | 1456 | } | |
| 1457 | 1457 | ||
| 1458 | + | /* | |
| 1459 | + | * Heavy-weight TLB flush after MES removes queues to ensure | |
| 1460 | + | * in-flight memory accesses complete before memory is freed/migrated. | |
| 1461 | + | * HWS does this automatically, MES does not. | |
| 1462 | + | */ | |
| 1463 | + | if (dqm->dev->kfd->shared_resources.enable_mes) | |
| 1464 | + | kfd_flush_tlb(pdd); | |
| 1465 | + | ||
| 1458 | 1466 | if (!dqm->dev->kfd->shared_resources.enable_mes) { | |
| 1459 | 1467 | pdd->last_evict_timestamp = get_jiffies_64(); | |
| 1460 | 1468 | retval = execute_queues_cpsch(dqm, | |
| @@ -3746,8 +3754,11 @@ int suspend_queues(struct kfd_process *p, | |||
| 3746 | 3754 | if (!per_device_suspended) { | |
| 3747 | 3755 | dqm_unlock(dqm); | |
| 3748 | 3756 | mutex_unlock(&p->event_mutex); | |
| 3749 | - | if (total_suspended) | |
| 3757 | + | if (total_suspended) { | |
| 3750 | 3758 | amdgpu_amdkfd_debug_mem_fence(dqm->dev->adev); | |
| 3759 | + | /* Heavy-weight TLB flush after MES suspends queues */ | |
| 3760 | + | kfd_flush_tlb(pdd); | |
| 3761 | + | } | |
| 3751 | 3762 | continue; | |
| 3752 | 3763 | } | |
| 3753 | 3764 | ||
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); | |
| @@ -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; | |
| @@ -5698,6 +5702,10 @@ static bool should_reset_plane(struct drm_atomic_commit *state, | |||
| 5698 | 5702 | if (new_crtc_state->color_mgmt_changed) | |
| 5699 | 5703 | return true; | |
| 5700 | 5704 | ||
| 5705 | + | /* Plane color pipeline or its colorop changes. */ | |
| 5706 | + | if (new_plane_state->color_mgmt_changed) | |
| 5707 | + | return true; | |
| 5708 | + | ||
| 5701 | 5709 | /* | |
| 5702 | 5710 | * On zpos change, planes need to be reordered by removing and re-adding | |
| 5703 | 5711 | * them one by one to the dc state, in order of descending zpos. | |
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_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; | |
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
| @@ -1445,7 +1445,7 @@ static void dm_test_crtc_destroy_state_no_stream(struct kunit *test) | |||
| 1445 | 1445 | struct dm_crtc_state *dm_state; | |
| 1446 | 1446 | ||
| 1447 | 1447 | /* destroy_state kfree()s the state, so use a plain (unmanaged) alloc. */ | |
| 1448 | - | dm_state = kzalloc_obj(*dm_state, GFP_KERNEL); | |
| 1448 | + | dm_state = kzalloc_obj(*dm_state); | |
| 1449 | 1449 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm_state); | |
| 1450 | 1450 | ||
| 1451 | 1451 | amdgpu_dm_crtc_destroy_state(NULL, &dm_state->base); | |
| @@ -1475,7 +1475,7 @@ static void dm_test_crtc_destroy_state_releases_stream(struct kunit *test) | |||
| 1475 | 1475 | kref_get(&stream->refcount); | |
| 1476 | 1476 | ||
| 1477 | 1477 | /* destroy_state kfree()s the state, so use a plain (unmanaged) alloc. */ | |
| 1478 | - | dm_state = kzalloc_obj(*dm_state, GFP_KERNEL); | |
| 1478 | + | dm_state = kzalloc_obj(*dm_state); | |
| 1479 | 1479 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm_state); | |
| 1480 | 1480 | dm_state->stream = stream; | |
| 1481 | 1481 | ||
| @@ -1569,7 +1569,7 @@ static void dm_test_crtc_handle_vblank_completes_cursor_only(struct kunit *test) | |||
| 1569 | 1569 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, acrtc); | |
| 1570 | 1570 | ||
| 1571 | 1571 | /* drm_crtc_send_vblank_event() consumes (kfree()s) the event. */ | |
| 1572 | - | event = kzalloc_obj(*event, GFP_KERNEL); | |
| 1572 | + | event = kzalloc_obj(*event); | |
| 1573 | 1573 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, event); | |
| 1574 | 1574 | ||
| 1575 | 1575 | acrtc->base.dev = &adev->ddev; | |
| @@ -1628,7 +1628,7 @@ dm_test_vblank_control_worker_setup(struct kunit *test, bool enable, | |||
| 1628 | 1628 | kref_get(&stream->refcount); | |
| 1629 | 1629 | ||
| 1630 | 1630 | /* Worker kfree()s the work item, so it must be a plain allocation. */ | |
| 1631 | - | work = kzalloc_obj(*work, GFP_KERNEL); | |
| 1631 | + | work = kzalloc_obj(*work); | |
| 1632 | 1632 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, work); | |
| 1633 | 1633 | work->dm = &adev->dm; | |
| 1634 | 1634 | 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); | |
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; | |
| @@ -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/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/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/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/aspeed/aspeed_gfx_drv.c
| @@ -189,13 +189,12 @@ static int aspeed_gfx_load(struct drm_device *drm) | |||
| 189 | 189 | } | |
| 190 | 190 | reset_control_deassert(priv->rst); | |
| 191 | 191 | ||
| 192 | - | priv->clk = devm_clk_get(drm->dev, NULL); | |
| 192 | + | priv->clk = devm_clk_get_enabled(drm->dev, NULL); | |
| 193 | 193 | if (IS_ERR(priv->clk)) { | |
| 194 | 194 | dev_err(&pdev->dev, | |
| 195 | - | "missing or invalid clk device tree entry"); | |
| 195 | + | "failed to get and enable clock\n"); | |
| 196 | 196 | return PTR_ERR(priv->clk); | |
| 197 | 197 | } | |
| 198 | - | clk_prepare_enable(priv->clk); | |
| 199 | 198 | ||
| 200 | 199 | /* Sanitize control registers */ | |
| 201 | 200 | writel(0, priv->base + CRT_CTRL1); | |
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/th1520-dw-hdmi.c
| @@ -135,8 +135,8 @@ static int th1520_dw_hdmi_probe(struct platform_device *pdev) | |||
| 135 | 135 | plat_data->priv_data = hdmi; | |
| 136 | 136 | ||
| 137 | 137 | hdmi->dw_hdmi = dw_hdmi_probe(pdev, plat_data); | |
| 138 | - | if (IS_ERR(hdmi)) | |
| 139 | - | return PTR_ERR(hdmi); | |
| 138 | + | if (IS_ERR(hdmi->dw_hdmi)) | |
| 139 | + | return PTR_ERR(hdmi->dw_hdmi); | |
| 140 | 140 | ||
| 141 | 141 | platform_set_drvdata(pdev, hdmi); | |
| 142 | 142 | ||
| @@ -145,9 +145,9 @@ static int th1520_dw_hdmi_probe(struct platform_device *pdev) | |||
| 145 | 145 | ||
| 146 | 146 | static void th1520_dw_hdmi_remove(struct platform_device *pdev) | |
| 147 | 147 | { | |
| 148 | - | struct dw_hdmi *hdmi = platform_get_drvdata(pdev); | |
| 148 | + | struct th1520_hdmi *hdmi = platform_get_drvdata(pdev); | |
| 149 | 149 | ||
| 150 | - | dw_hdmi_remove(hdmi); | |
| 150 | + | dw_hdmi_remove(hdmi->dw_hdmi); | |
| 151 | 151 | } | |
| 152 | 152 | ||
| 153 | 153 | static const struct of_device_id th1520_dw_hdmi_of_table[] = { | |
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/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/display/drm_dp_helper.c
| @@ -4634,7 +4634,9 @@ static int dp_aux_backlight_update_status(struct backlight_device *bd) | |||
| 4634 | 4634 | ||
| 4635 | 4635 | if (!backlight_is_blank(bd)) { | |
| 4636 | 4636 | if (!bl->enabled) { | |
| 4637 | - | drm_edp_backlight_enable(bl->aux, &bl->info, brightness); | |
| 4637 | + | ret = drm_edp_backlight_enable(bl->aux, &bl->info, brightness); | |
| 4638 | + | if (ret) | |
| 4639 | + | return ret; | |
| 4638 | 4640 | bl->enabled = true; | |
| 4639 | 4641 | return 0; | |
| 4640 | 4642 | } | |
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_bridge.c
| @@ -454,8 +454,10 @@ void drm_bridge_add(struct drm_bridge *bridge) | |||
| 454 | 454 | * in bridge_lingering_list. Remove it or bridge_lingering_list will be | |
| 455 | 455 | * corrupted when adding this bridge to bridge_list below. | |
| 456 | 456 | */ | |
| 457 | + | mutex_lock(&bridge_lock); | |
| 457 | 458 | if (!list_empty(&bridge->list)) | |
| 458 | 459 | list_del_init(&bridge->list); | |
| 460 | + | mutex_unlock(&bridge_lock); | |
| 459 | 461 | ||
| 460 | 462 | mutex_init(&bridge->hpd_state_mutex); | |
| 461 | 463 | mutex_init(&bridge->hpd_mutex); | |
| @@ -593,8 +595,10 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, | |||
| 593 | 595 | if (!bridge->container) | |
| 594 | 596 | DRM_WARN("DRM bridge corrupted or not allocated by devm_drm_bridge_alloc()\n"); | |
| 595 | 597 | ||
| 596 | - | if (list_empty(&bridge->list)) | |
| 597 | - | DRM_WARN("Missing drm_bridge_add() before attach\n"); | |
| 598 | + | scoped_guard(mutex, &bridge_lock) { | |
| 599 | + | if (list_empty(&bridge->list)) | |
| 600 | + | DRM_WARN("Missing drm_bridge_add() before attach\n"); | |
| 601 | + | } | |
| 598 | 602 | ||
| 599 | 603 | drm_bridge_get(bridge); | |
| 600 | 604 | ||
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_fb_helper.c
| @@ -1724,10 +1724,10 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper) | |||
| 1724 | 1724 | ||
| 1725 | 1725 | ret = drm_fb_helper_single_fb_probe(fb_helper); | |
| 1726 | 1726 | if (ret < 0) { | |
| 1727 | - | if (ret == -EAGAIN) { | |
| 1728 | - | fb_helper->deferred_setup = true; | |
| 1727 | + | /* modesets are probed but fb_helper->fb isn't; defer restore too */ | |
| 1728 | + | fb_helper->deferred_setup = true; | |
| 1729 | + | if (ret == -EAGAIN) | |
| 1729 | 1730 | ret = 0; | |
| 1730 | - | } | |
| 1731 | 1731 | mutex_unlock(&fb_helper->lock); | |
| 1732 | 1732 | ||
| 1733 | 1733 | goto err_drm_fb_helper_release_info; | |
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 | ||
| @@ -504,6 +507,7 @@ int gud_plane_atomic_check(struct drm_plane *plane, | |||
| 504 | 507 | for_each_new_connector_in_state(state, connector, connector_state, i) { | |
| 505 | 508 | if (connector_state->crtc) | |
| 506 | 509 | break; | |
| 510 | + | connector_state = NULL; | |
| 507 | 511 | } | |
| 508 | 512 | ||
| 509 | 513 | /* | |
| @@ -562,8 +566,8 @@ int gud_plane_atomic_check(struct drm_plane *plane, | |||
| 562 | 566 | goto out; | |
| 563 | 567 | } | |
| 564 | 568 | ||
| 565 | - | req->properties[num_properties + i].prop = cpu_to_le16(prop); | |
| 566 | - | req->properties[num_properties + i].val = cpu_to_le64(val); | |
| 569 | + | req->properties[num_properties].prop = cpu_to_le16(prop); | |
| 570 | + | req->properties[num_properties].val = cpu_to_le64(val); | |
| 567 | 571 | num_properties++; | |
| 568 | 572 | } | |
| 569 | 573 | ||
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
| @@ -530,13 +530,18 @@ static int i9xx_check_cursor(struct intel_crtc_state *crtc_state, | |||
| 530 | 530 | } | |
| 531 | 531 | ||
| 532 | 532 | static void i9xx_cursor_disable_sel_fetch_arm(struct intel_dsb *dsb, | |
| 533 | - | struct intel_plane *plane, | |
| 534 | - | const struct intel_crtc_state *crtc_state) | |
| 533 | + | struct intel_plane *plane) | |
| 535 | 534 | { | |
| 536 | 535 | struct intel_display *display = to_intel_display(plane); | |
| 537 | 536 | enum pipe pipe = plane->pipe; | |
| 538 | 537 | ||
| 539 | - | if (!crtc_state->enable_psr2_sel_fetch) | |
| 538 | + | /* | |
| 539 | + | * Clear this whenever the hardware has selective fetch, not just when | |
| 540 | + | * the current state uses it. The cursor may have been enabled with | |
| 541 | + | * selective fetch earlier and had its enable bit orphaned when the | |
| 542 | + | * feature was switched off. | |
| 543 | + | */ | |
| 544 | + | if (!HAS_PSR2_SEL_FETCH(display)) | |
| 540 | 545 | return; | |
| 541 | 546 | ||
| 542 | 547 | intel_de_write_dsb(display, dsb, SEL_FETCH_CUR_CTL(pipe), 0); | |
| @@ -586,7 +591,7 @@ static void i9xx_cursor_update_sel_fetch_arm(struct intel_dsb *dsb, | |||
| 586 | 591 | if (crtc_state->enable_psr2_su_region_et) | |
| 587 | 592 | wa_16021440873(dsb, plane, crtc_state, plane_state); | |
| 588 | 593 | else | |
| 589 | - | i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state); | |
| 594 | + | i9xx_cursor_disable_sel_fetch_arm(dsb, plane); | |
| 590 | 595 | } | |
| 591 | 596 | } | |
| 592 | 597 | ||
| @@ -695,7 +700,7 @@ static void i9xx_cursor_update_arm(struct intel_dsb *dsb, | |||
| 695 | 700 | if (plane_state) | |
| 696 | 701 | i9xx_cursor_update_sel_fetch_arm(dsb, plane, crtc_state, plane_state); | |
| 697 | 702 | else | |
| 698 | - | i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state); | |
| 703 | + | i9xx_cursor_disable_sel_fetch_arm(dsb, plane); | |
| 699 | 704 | ||
| 700 | 705 | if (plane->cursor.base != base || | |
| 701 | 706 | plane->cursor.size != fbc_ctl || | |
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
| @@ -1946,6 +1946,8 @@ struct intel_dp { | |||
| 1946 | 1946 | ||
| 1947 | 1947 | bool colorimetry_support; | |
| 1948 | 1948 | ||
| 1949 | + | bool sst_split_sdp_support; | |
| 1950 | + | ||
| 1949 | 1951 | struct { | |
| 1950 | 1952 | enum transcoder transcoder; | |
| 1951 | 1953 | 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_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; | |
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/skl_universal_plane.c
| @@ -879,13 +879,18 @@ skl_plane_disable_arm(struct intel_dsb *dsb, | |||
| 879 | 879 | } | |
| 880 | 880 | ||
| 881 | 881 | static void icl_plane_disable_sel_fetch_arm(struct intel_dsb *dsb, | |
| 882 | - | struct intel_plane *plane, | |
| 883 | - | const struct intel_crtc_state *crtc_state) | |
| 882 | + | struct intel_plane *plane) | |
| 884 | 883 | { | |
| 885 | 884 | struct intel_display *display = to_intel_display(plane); | |
| 886 | 885 | enum pipe pipe = plane->pipe; | |
| 887 | 886 | ||
| 888 | - | if (!crtc_state->enable_psr2_sel_fetch) | |
| 887 | + | /* | |
| 888 | + | * Clear this whenever the hardware has selective fetch, not just when | |
| 889 | + | * the current state uses it. The plane may have been enabled with | |
| 890 | + | * selective fetch earlier and had its enable bit orphaned when the | |
| 891 | + | * feature was switched off. | |
| 892 | + | */ | |
| 893 | + | if (!HAS_PSR2_SEL_FETCH(display)) | |
| 889 | 894 | return; | |
| 890 | 895 | ||
| 891 | 896 | intel_de_write_dsb(display, dsb, SEL_FETCH_PLANE_CTL(pipe, plane->id), 0); | |
| @@ -921,7 +926,7 @@ icl_plane_disable_arm(struct intel_dsb *dsb, | |||
| 921 | 926 | ||
| 922 | 927 | skl_write_plane_wm(dsb, plane, crtc_state); | |
| 923 | 928 | ||
| 924 | - | icl_plane_disable_sel_fetch_arm(dsb, plane, crtc_state); | |
| 929 | + | icl_plane_disable_sel_fetch_arm(dsb, plane); | |
| 925 | 930 | ||
| 926 | 931 | if (plane_has_normalizer(plane)) | |
| 927 | 932 | intel_de_write_dsb(display, dsb, | |
| @@ -1641,7 +1646,7 @@ static void icl_plane_update_sel_fetch_arm(struct intel_dsb *dsb, | |||
| 1641 | 1646 | intel_de_write_dsb(display, dsb, SEL_FETCH_PLANE_CTL(pipe, plane->id), | |
| 1642 | 1647 | SEL_FETCH_PLANE_CTL_ENABLE); | |
| 1643 | 1648 | else | |
| 1644 | - | icl_plane_disable_sel_fetch_arm(dsb, plane, crtc_state); | |
| 1649 | + | icl_plane_disable_sel_fetch_arm(dsb, plane); | |
| 1645 | 1650 | } | |
| 1646 | 1651 | ||
| 1647 | 1652 | static void | |
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,7 +2336,8 @@ 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. | |
| 2338 | - | * @sgt_offset: Start offset of the requested device-virtual memory mapping. | |
| 2339 | + | * @device_addr: Virtual device address at the start of the requested mapping. | |
| 2340 | + | * @sgt_offset: Offset into @sgt of the start of the requested 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. | |
| 2341 | 2343 | * | |
| @@ -2346,7 +2348,7 @@ 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 | { | |
| 2351 | 2353 | int err; | |
| 2352 | 2354 | ||
| @@ -2362,18 +2364,18 @@ pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, struct sg_table *sgt, | |||
| 2362 | 2364 | ||
| 2363 | 2365 | if (size) { | |
| 2364 | 2366 | /* | |
| 2365 | - | * The number of page table objects we need to prealloc is | |
| 2366 | - | * indicated by the mapping size, start offset and the sizes | |
| 2367 | - | * of the areas mapped per PT or PD. The range calculation is | |
| 2368 | - | * identical to that for the index into a table for a device | |
| 2369 | - | * address, so we reuse those functions here. | |
| 2367 | + | * The page tables needed are set by the device-virtual range | |
| 2368 | + | * being mapped: one level 1 table per 1GiB region and one | |
| 2369 | + | * level 0 table per 2MiB region the range touches. Tables that | |
| 2370 | + | * already exist are not consumed, so this is an upper bound. | |
| 2370 | 2371 | */ | |
| 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); | |
| 2373 | - | 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); | |
| 2376 | - | const u32 l0_count = l0_end_idx - l0_start_idx + 1; | |
| 2372 | + | const u64 last_addr = device_addr + size - 1; | |
| 2373 | + | const u64 l1_count = | |
| 2374 | + | (last_addr >> ROGUE_MMUCTRL_VADDR_PC_INDEX_SHIFT) - | |
| 2375 | + | (device_addr >> ROGUE_MMUCTRL_VADDR_PC_INDEX_SHIFT) + 1; | |
| 2376 | + | const u64 l0_count = | |
| 2377 | + | (last_addr >> ROGUE_MMUCTRL_VADDR_PD_INDEX_SHIFT) - | |
| 2378 | + | (device_addr >> ROGUE_MMUCTRL_VADDR_PD_INDEX_SHIFT) + 1; | |
| 2377 | 2379 | ||
| 2378 | 2380 | /* | |
| 2379 | 2381 | * Alloc and push page table entries until we have enough of | |
| @@ -2553,7 +2555,9 @@ pvr_mmu_map_sgl(struct pvr_mmu_op_context *op_ctx, struct scatterlist *sgl, | |||
| 2553 | 2555 | ||
| 2554 | 2556 | err_destroy_pages: | |
| 2555 | 2557 | memcpy(&op_ctx->curr_page, &ptr_copy, sizeof(op_ctx->curr_page)); | |
| 2556 | - | err = pvr_mmu_op_context_unmap_curr_page(op_ctx, page); | |
| 2558 | + | if (pvr_mmu_op_context_unmap_curr_page(op_ctx, page)) | |
| 2559 | + | drm_err(from_pvr_device(op_ctx->mmu_ctx->pvr_dev), | |
| 2560 | + | "%s : Failure in unmapping pages\n", __func__); | |
| 2557 | 2561 | ||
| 2558 | 2562 | return err; | |
| 2559 | 2563 | } | |
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; | |
| @@ -418,6 +418,8 @@ pvr_vm_gpuva_unmap(struct drm_gpuva_op *op, void *op_ctx) | |||
| 418 | 418 | static int | |
| 419 | 419 | pvr_vm_gpuva_remap(struct drm_gpuva_op *op, void *op_ctx) | |
| 420 | 420 | { | |
| 421 | + | /* The split parts belong to the object of the mapping being split. */ | |
| 422 | + | struct drm_gpuvm_bo *vm_bo = op->remap.unmap->va->vm_bo; | |
| 421 | 423 | struct pvr_vm_bind_op *ctx = op_ctx; | |
| 422 | 424 | u64 va_start = 0, va_range = 0; | |
| 423 | 425 | int err; | |
| @@ -433,14 +435,12 @@ pvr_vm_gpuva_remap(struct drm_gpuva_op *op, void *op_ctx) | |||
| 433 | 435 | drm_gpuva_remap(&ctx->prev_va->base, &ctx->next_va->base, &op->remap); | |
| 434 | 436 | ||
| 435 | 437 | if (op->remap.prev) { | |
| 436 | - | pvr_gem_object_get(gem_to_pvr_gem(ctx->prev_va->base.gem.obj)); | |
| 437 | - | drm_gpuva_link(&ctx->prev_va->base, ctx->gpuvm_bo); | |
| 438 | + | drm_gpuva_link(&ctx->prev_va->base, vm_bo); | |
| 438 | 439 | ctx->prev_va = NULL; | |
| 439 | 440 | } | |
| 440 | 441 | ||
| 441 | 442 | if (op->remap.next) { | |
| 442 | - | pvr_gem_object_get(gem_to_pvr_gem(ctx->next_va->base.gem.obj)); | |
| 443 | - | drm_gpuva_link(&ctx->next_va->base, ctx->gpuvm_bo); | |
| 443 | + | drm_gpuva_link(&ctx->next_va->base, vm_bo); | |
| 444 | 444 | ctx->next_va = NULL; | |
| 445 | 445 | } | |
| 446 | 446 | ||
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/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_abi16.c
| @@ -488,7 +488,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) | |||
| 488 | 488 | goto done; | |
| 489 | 489 | break; | |
| 490 | 490 | case NV_DEVICE_INFO_V0_TURING: | |
| 491 | - | if (engine != NV_DEVICE_HOST_RUNLIST_ENGINES_NVDEC) { | |
| 491 | + | if (engine == NV_DEVICE_HOST_RUNLIST_ENGINES_GR) { | |
| 492 | 492 | ret = nvif_object_ctor(&chan->chan->user, "abi16CeWar", | |
| 493 | 493 | 0, TURING_DMA_COPY_A, NULL, 0, | |
| 494 | 494 | &chan->ce); | |
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 || !gsp->rm) { | |
| 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/panthor/panthor_sched.c
| @@ -3674,6 +3674,9 @@ int panthor_group_create(struct panthor_file *pfile, | |||
| 3674 | 3674 | hweight64(group_args->tiler_core_mask) < group_args->max_tiler_cores) | |
| 3675 | 3675 | return -EINVAL; | |
| 3676 | 3676 | ||
| 3677 | + | if (group_args->queues.count > sched->cs_slot_count) | |
| 3678 | + | return -EINVAL; | |
| 3679 | + | ||
| 3677 | 3680 | group = kzalloc_obj(*group); | |
| 3678 | 3681 | if (!group) | |
| 3679 | 3682 | return -ENOMEM; | |
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_bo.c
| @@ -204,7 +204,7 @@ static struct list_head *vc4_get_cache_list_for_size(struct drm_device *dev, | |||
| 204 | 204 | struct list_head *new_list; | |
| 205 | 205 | uint32_t i; | |
| 206 | 206 | ||
| 207 | - | new_list = kmalloc_objs(struct list_head, new_size); | |
| 207 | + | new_list = kvmalloc_objs(struct list_head, new_size); | |
| 208 | 208 | if (!new_list) | |
| 209 | 209 | return NULL; | |
| 210 | 210 | ||
| @@ -224,7 +224,7 @@ static struct list_head *vc4_get_cache_list_for_size(struct drm_device *dev, | |||
| 224 | 224 | for (i = vc4->bo_cache.size_list_size; i < new_size; i++) | |
| 225 | 225 | INIT_LIST_HEAD(&new_list[i]); | |
| 226 | 226 | ||
| 227 | - | kfree(vc4->bo_cache.size_list); | |
| 227 | + | kvfree(vc4->bo_cache.size_list); | |
| 228 | 228 | vc4->bo_cache.size_list = new_list; | |
| 229 | 229 | vc4->bo_cache.size_list_size = new_size; | |
| 230 | 230 | } | |
| @@ -1052,6 +1052,7 @@ static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused) | |||
| 1052 | 1052 | cancel_work_sync(&vc4->bo_cache.time_work); | |
| 1053 | 1053 | ||
| 1054 | 1054 | vc4_bo_cache_purge(dev); | |
| 1055 | + | kvfree(vc4->bo_cache.size_list); | |
| 1055 | 1056 | ||
| 1056 | 1057 | for (i = 0; i < vc4->num_labels; i++) { | |
| 1057 | 1058 | if (vc4->bo_labels[i].num_allocated) { | |
modified drivers/gpu/drm/vc4/vc4_drv.c
| @@ -360,8 +360,11 @@ static int vc4_drm_bind(struct device *dev) | |||
| 360 | 360 | } | |
| 361 | 361 | ||
| 362 | 362 | ret = aperture_remove_all_conflicting_devices(driver->name); | |
| 363 | - | if (ret) | |
| 363 | + | if (ret) { | |
| 364 | + | if (firmware) | |
| 365 | + | rpi_firmware_put(firmware); | |
| 364 | 366 | goto err; | |
| 367 | + | } | |
| 365 | 368 | ||
| 366 | 369 | if (firmware) { | |
| 367 | 370 | ret = rpi_firmware_property(firmware, | |
modified drivers/gpu/drm/vc4/vc4_drv.h
| @@ -1051,7 +1051,7 @@ void vc4_plane_async_set_fb(struct drm_plane *plane, | |||
| 1051 | 1051 | /* vc4_v3d.c */ | |
| 1052 | 1052 | extern struct platform_driver vc4_v3d_driver; | |
| 1053 | 1053 | extern const struct of_device_id vc4_v3d_dt_match[]; | |
| 1054 | - | int vc4_v3d_get_bin_slot(struct vc4_dev *vc4); | |
| 1054 | + | int vc4_v3d_get_bin_slot(struct vc4_dev *vc4, long timeout); | |
| 1055 | 1055 | int vc4_v3d_bin_bo_get(struct vc4_dev *vc4, bool *used); | |
| 1056 | 1056 | void vc4_v3d_bin_bo_put(struct vc4_dev *vc4); | |
| 1057 | 1057 | int vc4_v3d_pm_get(struct vc4_dev *vc4); | |
modified drivers/gpu/drm/vc4/vc4_gem.c
| @@ -877,11 +877,17 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) | |||
| 877 | 877 | drm_gem_object_put(&bo->base.base); | |
| 878 | 878 | } | |
| 879 | 879 | ||
| 880 | - | /* Free up the allocation of any bin slots we used. */ | |
| 880 | + | /* Free up the allocation of any bin slots we used. Jobs that ran to | |
| 881 | + | * completion had their slots released in vc4_irq_finish_render_job(). | |
| 882 | + | * Only jobs that never completed still have slots to be released here. | |
| 883 | + | */ | |
| 881 | 884 | spin_lock_irqsave(&vc4->job_lock, irqflags); | |
| 882 | 885 | vc4->bin_alloc_used &= ~exec->bin_slots; | |
| 883 | 886 | spin_unlock_irqrestore(&vc4->job_lock, irqflags); | |
| 884 | 887 | ||
| 888 | + | /* Let anyone waiting on the binner pool retry. */ | |
| 889 | + | wake_up_all(&vc4->job_wait_queue); | |
| 890 | + | ||
| 885 | 891 | /* Release the reference on the binner BO if needed. */ | |
| 886 | 892 | if (exec->bin_bo_used) | |
| 887 | 893 | vc4_v3d_bin_bo_put(vc4); | |
modified drivers/gpu/drm/vc4/vc4_hdmi.c
| @@ -894,7 +894,7 @@ static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder, | |||
| 894 | 894 | ||
| 895 | 895 | spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); | |
| 896 | 896 | ||
| 897 | - | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0); | |
| 897 | + | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, VC4_HDMI_RAM_PACKET_ENABLE); | |
| 898 | 898 | ||
| 899 | 899 | HDMI_WRITE(HDMI_VID_CTL, HDMI_READ(HDMI_VID_CTL) | VC4_HD_VID_CTL_CLRRGB); | |
| 900 | 900 | ||
| @@ -1663,9 +1663,6 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder, | |||
| 1663 | 1663 | WARN_ONCE(ret, "Timeout waiting for " | |
| 1664 | 1664 | "VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE\n"); | |
| 1665 | 1665 | } else { | |
| 1666 | - | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, | |
| 1667 | - | HDMI_READ(HDMI_RAM_PACKET_CONFIG) & | |
| 1668 | - | ~(VC4_HDMI_RAM_PACKET_ENABLE)); | |
| 1669 | 1666 | HDMI_WRITE(HDMI_SCHEDULER_CONTROL, | |
| 1670 | 1667 | HDMI_READ(HDMI_SCHEDULER_CONTROL) & | |
| 1671 | 1668 | ~VC4_HDMI_SCHEDULER_CONTROL_MODE_HDMI); | |
| @@ -1684,9 +1681,6 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder, | |||
| 1684 | 1681 | WARN_ON(!(HDMI_READ(HDMI_SCHEDULER_CONTROL) & | |
| 1685 | 1682 | VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE)); | |
| 1686 | 1683 | ||
| 1687 | - | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, | |
| 1688 | - | VC4_HDMI_RAM_PACKET_ENABLE); | |
| 1689 | - | ||
| 1690 | 1684 | spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); | |
| 1691 | 1685 | vc4_hdmi->packet_ram_enabled = true; | |
| 1692 | 1686 | ||
| @@ -3143,6 +3137,11 @@ static int vc5_hdmi_init_resources(struct drm_device *drm, | |||
| 3143 | 3137 | static int vc4_hdmi_runtime_suspend(struct device *dev) | |
| 3144 | 3138 | { | |
| 3145 | 3139 | struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); | |
| 3140 | + | unsigned long flags; | |
| 3141 | + | ||
| 3142 | + | spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); | |
| 3143 | + | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0); | |
| 3144 | + | spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); | |
| 3146 | 3145 | ||
| 3147 | 3146 | clk_disable_unprepare(vc4_hdmi->audio_clock); | |
| 3148 | 3147 | clk_disable_unprepare(vc4_hdmi->hsm_clock); | |
| @@ -3153,9 +3152,8 @@ static int vc4_hdmi_runtime_suspend(struct device *dev) | |||
| 3153 | 3152 | static int vc4_hdmi_runtime_resume(struct device *dev) | |
| 3154 | 3153 | { | |
| 3155 | 3154 | struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); | |
| 3156 | - | unsigned long __maybe_unused flags; | |
| 3155 | + | unsigned long rate, flags; | |
| 3157 | 3156 | u32 __maybe_unused value; | |
| 3158 | - | unsigned long rate; | |
| 3159 | 3157 | int ret; | |
| 3160 | 3158 | ||
| 3161 | 3159 | ret = clk_prepare_enable(vc4_hdmi->hsm_clock); | |
| @@ -3201,6 +3199,10 @@ static int vc4_hdmi_runtime_resume(struct device *dev) | |||
| 3201 | 3199 | } | |
| 3202 | 3200 | #endif | |
| 3203 | 3201 | ||
| 3202 | + | spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); | |
| 3203 | + | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, VC4_HDMI_RAM_PACKET_ENABLE); | |
| 3204 | + | spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); | |
| 3205 | + | ||
| 3204 | 3206 | return 0; | |
| 3205 | 3207 | ||
| 3206 | 3208 | err_disable_clk: | |
modified drivers/gpu/drm/vc4/vc4_irq.c
| @@ -74,7 +74,7 @@ vc4_overflow_mem_work(struct work_struct *work) | |||
| 74 | 74 | ||
| 75 | 75 | bo = vc4->bin_bo; | |
| 76 | 76 | ||
| 77 | - | bin_bo_slot = vc4_v3d_get_bin_slot(vc4); | |
| 77 | + | bin_bo_slot = vc4_v3d_get_bin_slot(vc4, msecs_to_jiffies(500)); | |
| 78 | 78 | if (bin_bo_slot < 0) { | |
| 79 | 79 | drm_err(&vc4->base, "Couldn't allocate binner overflow mem\n"); | |
| 80 | 80 | goto complete; | |
| @@ -165,6 +165,10 @@ vc4_irq_finish_render_job(struct drm_device *dev) | |||
| 165 | 165 | trace_vc4_rcl_end_irq(dev, exec->seqno); | |
| 166 | 166 | ||
| 167 | 167 | vc4->finished_seqno++; | |
| 168 | + | ||
| 169 | + | vc4->bin_alloc_used &= ~exec->bin_slots; | |
| 170 | + | exec->bin_slots = 0; | |
| 171 | + | ||
| 168 | 172 | list_move_tail(&exec->head, &vc4->job_done_list); | |
| 169 | 173 | ||
| 170 | 174 | nextbin = vc4_first_bin_job(vc4); | |
| @@ -276,7 +280,7 @@ vc4_irq_disable(struct drm_device *dev) | |||
| 276 | 280 | V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS); | |
| 277 | 281 | ||
| 278 | 282 | /* Finish any interrupt handler still in flight. */ | |
| 279 | - | synchronize_irq(vc4->irq); | |
| 283 | + | disable_irq(vc4->irq); | |
| 280 | 284 | ||
| 281 | 285 | cancel_work_sync(&vc4->overflow_mem_work); | |
| 282 | 286 | } | |
| @@ -284,7 +288,6 @@ vc4_irq_disable(struct drm_device *dev) | |||
| 284 | 288 | int vc4_irq_install(struct drm_device *dev, int irq) | |
| 285 | 289 | { | |
| 286 | 290 | struct vc4_dev *vc4 = to_vc4_dev(dev); | |
| 287 | - | int ret; | |
| 288 | 291 | ||
| 289 | 292 | if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4)) | |
| 290 | 293 | return -ENODEV; | |
| @@ -298,19 +301,8 @@ int vc4_irq_install(struct drm_device *dev, int irq) | |||
| 298 | 301 | init_waitqueue_head(&vc4->job_wait_queue); | |
| 299 | 302 | INIT_WORK(&vc4->overflow_mem_work, vc4_overflow_mem_work); | |
| 300 | 303 | ||
| 301 | - | /* Clear any pending interrupts someone might have left around | |
| 302 | - | * for us. | |
| 303 | - | */ | |
| 304 | - | V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS); | |
| 305 | - | ||
| 306 | - | ret = devm_request_irq(dev->dev, irq, vc4_irq, 0, | |
| 307 | - | dev_name(dev->dev), dev); | |
| 308 | - | if (ret) | |
| 309 | - | return ret; | |
| 310 | - | ||
| 311 | - | vc4_irq_enable(dev); | |
| 312 | - | ||
| 313 | - | return 0; | |
| 304 | + | return devm_request_irq(dev->dev, irq, vc4_irq, IRQF_NO_AUTOEN, | |
| 305 | + | dev_name(dev->dev), dev); | |
| 314 | 306 | } | |
| 315 | 307 | ||
| 316 | 308 | void vc4_irq_uninstall(struct drm_device *dev) | |
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/vc4/vc4_v3d.c
| @@ -9,6 +9,7 @@ | |||
| 9 | 9 | #include <linux/component.h> | |
| 10 | 10 | #include <linux/platform_device.h> | |
| 11 | 11 | #include <linux/pm_runtime.h> | |
| 12 | + | #include <linux/timer.h> | |
| 12 | 13 | ||
| 13 | 14 | #include <drm/drm_print.h> | |
| 14 | 15 | ||
| @@ -172,46 +173,42 @@ static void vc4_v3d_init_hw(struct drm_device *dev) | |||
| 172 | 173 | V3D_WRITE(V3D_VPMBASE, 0); | |
| 173 | 174 | } | |
| 174 | 175 | ||
| 175 | - | int vc4_v3d_get_bin_slot(struct vc4_dev *vc4) | |
| 176 | + | static int bin_slot_try_alloc(struct vc4_dev *vc4) | |
| 176 | 177 | { | |
| 177 | - | struct drm_device *dev = &vc4->base; | |
| 178 | - | unsigned long irqflags; | |
| 179 | 178 | int slot; | |
| 180 | - | uint64_t seqno = 0; | |
| 181 | - | struct vc4_exec_info *exec; | |
| 182 | 179 | ||
| 183 | - | if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4)) | |
| 184 | - | return -ENODEV; | |
| 180 | + | guard(spinlock_irqsave)(&vc4->job_lock); | |
| 185 | 181 | ||
| 186 | - | try_again: | |
| 187 | - | spin_lock_irqsave(&vc4->job_lock, irqflags); | |
| 188 | 182 | slot = ffs(~vc4->bin_alloc_used); | |
| 189 | 183 | if (slot != 0) { | |
| 190 | 184 | /* Switch from ffs() bit index to a 0-based index. */ | |
| 191 | 185 | slot--; | |
| 192 | 186 | vc4->bin_alloc_used |= BIT(slot); | |
| 193 | - | spin_unlock_irqrestore(&vc4->job_lock, irqflags); | |
| 194 | - | return slot; | |
| 187 | + | } else { | |
| 188 | + | slot = -ENOMEM; | |
| 195 | 189 | } | |
| 196 | 190 | ||
| 197 | - | /* Couldn't find an open slot. Wait for render to complete | |
| 198 | - | * and try again. | |
| 199 | - | */ | |
| 200 | - | exec = vc4_last_render_job(vc4); | |
| 201 | - | if (exec) | |
| 202 | - | seqno = exec->seqno; | |
| 203 | - | spin_unlock_irqrestore(&vc4->job_lock, irqflags); | |
| 191 | + | return slot; | |
| 192 | + | } | |
| 204 | 193 | ||
| 205 | - | if (seqno) { | |
| 206 | - | int ret = vc4_wait_for_seqno(dev, seqno, ~0ull, true); | |
| 194 | + | int vc4_v3d_get_bin_slot(struct vc4_dev *vc4, long timeout) | |
| 195 | + | { | |
| 196 | + | int slot; | |
| 197 | + | long ret; | |
| 207 | 198 | ||
| 208 | - | if (ret == 0) | |
| 209 | - | goto try_again; | |
| 199 | + | if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4)) | |
| 200 | + | return -ENODEV; | |
| 210 | 201 | ||
| 202 | + | /* If the pool is full, wait for a job to release its slots. */ | |
| 203 | + | ret = wait_event_interruptible_timeout(vc4->job_wait_queue, | |
| 204 | + | (slot = bin_slot_try_alloc(vc4)) >= 0, | |
| 205 | + | timeout); | |
| 206 | + | if (ret < 0) | |
| 211 | 207 | return ret; | |
| 212 | - | } | |
| 208 | + | if (ret == 0) | |
| 209 | + | return -ENOMEM; | |
| 213 | 210 | ||
| 214 | - | return -ENOMEM; | |
| 211 | + | return slot; | |
| 215 | 212 | } | |
| 216 | 213 | ||
| 217 | 214 | /* | |
| @@ -396,6 +393,7 @@ static int vc4_v3d_runtime_resume(struct device *dev) | |||
| 396 | 393 | vc4_v3d_init_hw(&vc4->base); | |
| 397 | 394 | ||
| 398 | 395 | vc4_irq_enable(&vc4->base); | |
| 396 | + | enable_irq(vc4->irq); | |
| 399 | 397 | ||
| 400 | 398 | return 0; | |
| 401 | 399 | } | |
| @@ -452,6 +450,12 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data) | |||
| 452 | 450 | return ret; | |
| 453 | 451 | vc4->irq = ret; | |
| 454 | 452 | ||
| 453 | + | ret = vc4_irq_install(drm, vc4->irq); | |
| 454 | + | if (ret) { | |
| 455 | + | drm_err(drm, "Failed to install IRQ handler\n"); | |
| 456 | + | return ret; | |
| 457 | + | } | |
| 458 | + | ||
| 455 | 459 | ret = devm_pm_runtime_enable(dev); | |
| 456 | 460 | if (ret) | |
| 457 | 461 | return ret; | |
| @@ -473,12 +477,6 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data) | |||
| 473 | 477 | V3D_WRITE(V3D_BPOA, 0); | |
| 474 | 478 | V3D_WRITE(V3D_BPOS, 0); | |
| 475 | 479 | ||
| 476 | - | ret = vc4_irq_install(drm, vc4->irq); | |
| 477 | - | if (ret) { | |
| 478 | - | drm_err(drm, "Failed to install IRQ handler\n"); | |
| 479 | - | goto err_put_runtime_pm; | |
| 480 | - | } | |
| 481 | - | ||
| 482 | 480 | pm_runtime_use_autosuspend(dev); | |
| 483 | 481 | pm_runtime_set_autosuspend_delay(dev, 40); /* a little over 2 frames. */ | |
| 484 | 482 | pm_runtime_put_autosuspend(dev); | |
| @@ -497,8 +495,15 @@ static void vc4_v3d_unbind(struct device *dev, struct device *master, | |||
| 497 | 495 | struct drm_device *drm = data; | |
| 498 | 496 | struct vc4_dev *vc4 = to_vc4_dev(drm); | |
| 499 | 497 | ||
| 498 | + | /* A straggler vc4_reset() re-enables the interrupt. */ | |
| 499 | + | timer_shutdown_sync(&vc4->hangcheck.timer); | |
| 500 | + | cancel_work_sync(&vc4->hangcheck.reset_work); | |
| 501 | + | ||
| 500 | 502 | vc4_irq_uninstall(drm); | |
| 501 | 503 | ||
| 504 | + | /* Flush rather than cancel, so queued completions release their jobs. */ | |
| 505 | + | flush_work(&vc4->job_done_work); | |
| 506 | + | ||
| 502 | 507 | /* Disable the binner's overflow memory address, so the next | |
| 503 | 508 | * driver probe (if any) doesn't try to reuse our old | |
| 504 | 509 | * allocation. | |
modified drivers/gpu/drm/vc4/vc4_validate.c
| @@ -402,7 +402,7 @@ validate_tile_binning_config(VALIDATE_ARGS) | |||
| 402 | 402 | return -EINVAL; | |
| 403 | 403 | } | |
| 404 | 404 | ||
| 405 | - | bin_slot = vc4_v3d_get_bin_slot(vc4); | |
| 405 | + | bin_slot = vc4_v3d_get_bin_slot(vc4, MAX_SCHEDULE_TIMEOUT); | |
| 406 | 406 | if (bin_slot < 0) { | |
| 407 | 407 | if (bin_slot != -EINTR && bin_slot != -ERESTARTSYS) { | |
| 408 | 408 | drm_err(dev, "Failed to allocate binner memory: %d\n", | |
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> | |
| @@ -609,6 +610,9 @@ struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev, | |||
| 609 | 610 | ||
| 610 | 611 | if (type == DRM_PLANE_TYPE_PRIMARY) | |
| 611 | 612 | drm_plane_enable_fb_damage_clips(plane); | |
| 613 | + | else if (type == DRM_PLANE_TYPE_CURSOR) | |
| 614 | + | drm_plane_create_blend_mode_property(plane, | |
| 615 | + | BIT(DRM_MODE_BLEND_PREMULTI)); | |
| 612 | 616 | ||
| 613 | 617 | return plane; | |
| 614 | 618 | } | |
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/vmwgfx/vmwgfx_cursor_plane.c
| @@ -324,6 +324,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, | |||
| 324 | 324 | unsigned long kmap_num; | |
| 325 | 325 | SVGA3dCopyBox *box; | |
| 326 | 326 | u32 box_count; | |
| 327 | + | u64 src_extent; | |
| 327 | 328 | void *virtual; | |
| 328 | 329 | bool is_iomem; | |
| 329 | 330 | struct vmw_dma_cmd { | |
| @@ -335,6 +336,8 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, | |||
| 335 | 336 | vmw_surface_get_desc(VMW_CURSOR_SNOOP_FORMAT); | |
| 336 | 337 | const u32 image_pitch = VMW_CURSOR_SNOOP_WIDTH * desc->pitchBytesPerBlock; | |
| 337 | 338 | ||
| 339 | + | BUILD_BUG_ON(sizeof(*srf->snooper.image) != desc->pitchBytesPerBlock); | |
| 340 | + | ||
| 338 | 341 | cmd = container_of(header, struct vmw_dma_cmd, header); | |
| 339 | 342 | ||
| 340 | 343 | /* No snooper installed, nothing to copy */ | |
| @@ -372,8 +375,19 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, | |||
| 372 | 375 | return; | |
| 373 | 376 | } | |
| 374 | 377 | ||
| 378 | + | if (box->w == 0 || box->h == 0) | |
| 379 | + | return; | |
| 380 | + | ||
| 381 | + | src_extent = (u64)(box->h - 1) * cmd->dma.guest.pitch + | |
| 382 | + | (u64)box->w * desc->pitchBytesPerBlock; | |
| 383 | + | if (src_extent > bo->base.size) { | |
| 384 | + | DRM_ERROR("Cursor snoop source of %llu bytes exceeds the %zu byte buffer\n", | |
| 385 | + | src_extent, bo->base.size); | |
| 386 | + | return; | |
| 387 | + | } | |
| 388 | + | ||
| 375 | 389 | kmap_offset = cmd->dma.guest.ptr.offset >> PAGE_SHIFT; | |
| 376 | - | kmap_num = (VMW_CURSOR_SNOOP_HEIGHT * image_pitch) >> PAGE_SHIFT; | |
| 390 | + | kmap_num = PFN_UP(src_extent); | |
| 377 | 391 | ||
| 378 | 392 | ret = ttm_bo_reserve(bo, true, false, NULL); | |
| 379 | 393 | if (unlikely(ret != 0)) { | |
| @@ -387,14 +401,16 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, | |||
| 387 | 401 | ||
| 388 | 402 | virtual = ttm_kmap_obj_virtual(&map, &is_iomem); | |
| 389 | 403 | ||
| 390 | - | if (box->w == VMW_CURSOR_SNOOP_WIDTH && cmd->dma.guest.pitch == image_pitch) { | |
| 404 | + | if (box->w == VMW_CURSOR_SNOOP_WIDTH && | |
| 405 | + | box->h == VMW_CURSOR_SNOOP_HEIGHT && | |
| 406 | + | cmd->dma.guest.pitch == image_pitch) { | |
| 391 | 407 | memcpy(srf->snooper.image, virtual, | |
| 392 | 408 | VMW_CURSOR_SNOOP_HEIGHT * image_pitch); | |
| 393 | 409 | } else { | |
| 394 | - | /* Image is unsigned pointer. */ | |
| 410 | + | /* The destination stride is in pixels. */ | |
| 395 | 411 | for (i = 0; i < box->h; i++) | |
| 396 | - | memcpy(srf->snooper.image + i * image_pitch, | |
| 397 | - | virtual + i * cmd->dma.guest.pitch, | |
| 412 | + | memcpy(srf->snooper.image + i * VMW_CURSOR_SNOOP_WIDTH, | |
| 413 | + | virtual + (size_t)i * cmd->dma.guest.pitch, | |
| 398 | 414 | box->w * desc->pitchBytesPerBlock); | |
| 399 | 415 | } | |
| 400 | 416 | srf->snooper.id++; | |
modified drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
| @@ -20,10 +20,18 @@ | |||
| 20 | 20 | #include <drm/drm_rect.h> | |
| 21 | 21 | #include <drm/drm_sysfs.h> | |
| 22 | 22 | #include <drm/drm_edid.h> | |
| 23 | + | #include <drm/drm_blend.h> | |
| 23 | 24 | ||
| 24 | 25 | void vmw_du_init(struct vmw_display_unit *du) | |
| 25 | 26 | { | |
| 26 | 27 | vmw_vkms_crtc_init(&du->crtc); | |
| 28 | + | drm_plane_create_blend_mode_property(&du->primary, | |
| 29 | + | BIT(DRM_MODE_BLEND_PIXEL_NONE) | | |
| 30 | + | BIT(DRM_MODE_BLEND_PREMULTI)); | |
| 31 | + | // Check that the cursor plane was actually initialized | |
| 32 | + | if (du->crtc.cursor == &du->cursor.base) | |
| 33 | + | drm_plane_create_blend_mode_property(&du->cursor.base, | |
| 34 | + | BIT(DRM_MODE_BLEND_PREMULTI)); | |
| 27 | 35 | } | |
| 28 | 36 | ||
| 29 | 37 | void vmw_du_cleanup(struct vmw_display_unit *du) | |
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/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_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_vm.c
| @@ -4148,7 +4148,7 @@ static int fill_faults(struct xe_vm *vm, | |||
| 4148 | 4148 | entry_size = sizeof(struct xe_vm_fault); | |
| 4149 | 4149 | count = args->size / entry_size; | |
| 4150 | 4150 | ||
| 4151 | - | fault_list = kcalloc(count, sizeof(struct xe_vm_fault), GFP_KERNEL); | |
| 4151 | + | fault_list = kzalloc_objs(struct xe_vm_fault, count); | |
| 4152 | 4152 | if (!fault_list) | |
| 4153 | 4153 | return -ENOMEM; | |
| 4154 | 4154 | ||
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/hid/Kconfig
| @@ -1253,7 +1253,7 @@ config HID_HYPERV_MOUSE | |||
| 1253 | 1253 | ||
| 1254 | 1254 | config HID_HYPERV_MOUSE_KUNIT_TEST | |
| 1255 | 1255 | bool "KUnit tests for Hyper-V mouse driver" if !KUNIT_ALL_TESTS | |
| 1256 | - | depends on KUNIT && HID_HYPERV_MOUSE | |
| 1256 | + | depends on KUNIT && (HID_HYPERV_MOUSE = KUNIT || KUNIT = y) | |
| 1257 | 1257 | default KUNIT_ALL_TESTS | |
| 1258 | 1258 | help | |
| 1259 | 1259 | Builds unit tests for the Hyper-V synthetic HID driver. | |
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-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-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 | |
modified drivers/hid/hid-multitouch.c
| @@ -1321,21 +1321,18 @@ static void mt_touch_report(struct hid_device *hid, | |||
| 1321 | 1321 | * Includes multi-packet support where subsequent | |
| 1322 | 1322 | * packets are sent with zero contactcount. | |
| 1323 | 1323 | */ | |
| 1324 | - | if (contact_count >= 0) { | |
| 1324 | + | if (contact_count > 0) | |
| 1325 | + | app->num_expected = contact_count; | |
| 1326 | + | else if (app->num_received == 0 && app->prev_scantime != scantime) { | |
| 1325 | 1327 | /* | |
| 1328 | + | * New multi-report frame: | |
| 1329 | + | * | |
| 1326 | 1330 | * For Win8 PTPs the first packet (td->num_received == 0) may | |
| 1327 | 1331 | * 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. | |
| 1332 | + | * | |
| 1333 | + | * Some other devices use a sentinel frame with 0 to release all contacts | |
| 1331 | 1334 | */ | |
| 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; | |
| 1335 | + | app->num_expected = 0; | |
| 1339 | 1336 | } | |
| 1340 | 1337 | app->prev_scantime = scantime; | |
| 1341 | 1338 | ||
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-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
| @@ -469,7 +469,7 @@ static int steelseries_arctis_probe(struct hid_device *hdev, | |||
| 469 | 469 | return hid_hw_start(hdev, HID_CONNECT_DEFAULT); | |
| 470 | 470 | ||
| 471 | 471 | if (interface_num == info->sync_interface) { | |
| 472 | - | sd = kzalloc_obj(*sd, GFP_KERNEL); | |
| 472 | + | sd = kzalloc_obj(*sd); | |
| 473 | 473 | if (!sd) | |
| 474 | 474 | return -ENOMEM; | |
| 475 | 475 | ||
modified drivers/hid/i2c-hid/i2c-hid-core.c
| @@ -136,6 +136,8 @@ static const struct i2c_hid_quirks { | |||
| 136 | 136 | I2C_HID_QUIRK_BAD_INPUT_SIZE }, | |
| 137 | 137 | { I2C_VENDOR_ID_CIRQUE, I2C_PRODUCT_ID_CIRQUE_1063, | |
| 138 | 138 | I2C_HID_QUIRK_NO_SLEEP_ON_SUSPEND }, | |
| 139 | + | { I2C_VENDOR_ID_CIRQUE, I2C_PRODUCT_ID_CIRQUE_D0C1, | |
| 140 | + | I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, | |
| 139 | 141 | /* | |
| 140 | 142 | * Without additional power on command, at least some QTEC devices send garbage | |
| 141 | 143 | */ | |
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/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> | |
| @@ -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,7 +96,11 @@ 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 | 106 | IRQF_SHARED, "GPIO fan alarm", fan_data); | |
| @@ -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/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/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_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/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/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-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/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/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/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/input/input.c
| @@ -2344,7 +2344,7 @@ static int input_device_tune_vals(struct input_dev *dev) | |||
| 2344 | 2344 | if (dev->max_vals >= max_vals) | |
| 2345 | 2345 | return 0; | |
| 2346 | 2346 | ||
| 2347 | - | vals = kcalloc(max_vals, sizeof(*vals), GFP_KERNEL); | |
| 2347 | + | vals = kzalloc_objs(*vals, max_vals); | |
| 2348 | 2348 | if (!vals) | |
| 2349 | 2349 | return -ENOMEM; | |
| 2350 | 2350 | ||
modified drivers/input/keyboard/adp5585-keys.c
| @@ -115,8 +115,8 @@ static int adp5585_keys_parse_fw(const struct adp5585_dev *adp5585, | |||
| 115 | 115 | "Too many keypad pins (%d) defined (max=%d)\n", | |
| 116 | 116 | n_pins, adp5585->n_pins); | |
| 117 | 117 | ||
| 118 | - | unsigned int *keypad_pins __free(kfree) = kcalloc(n_pins, sizeof(*keypad_pins), | |
| 119 | - | GFP_KERNEL); | |
| 118 | + | unsigned int *keypad_pins __free(kfree) = kzalloc_objs(*keypad_pins, | |
| 119 | + | n_pins); | |
| 120 | 120 | if (!keypad_pins) | |
| 121 | 121 | return -ENOMEM; | |
| 122 | 122 | ||
modified drivers/input/keyboard/atkbd.c
| @@ -1070,7 +1070,7 @@ static int atkbd_get_keymap_from_fwnode(struct atkbd *atkbd) | |||
| 1070 | 1070 | if (n <= 0 || n > ATKBD_KEYMAP_SIZE) | |
| 1071 | 1071 | return -ENXIO; | |
| 1072 | 1072 | ||
| 1073 | - | u32 *ptr __free(kfree) = kcalloc(n, sizeof(*ptr), GFP_KERNEL); | |
| 1073 | + | u32 *ptr __free(kfree) = kzalloc_objs(*ptr, n); | |
| 1074 | 1074 | if (!ptr) | |
| 1075 | 1075 | return -ENOMEM; | |
| 1076 | 1076 | ||
modified drivers/input/misc/ims-pcu.c
| @@ -1844,7 +1844,7 @@ static int ims_pcu_line_setup(struct ims_pcu *pcu) | |||
| 1844 | 1844 | { | |
| 1845 | 1845 | struct usb_host_interface *interface = pcu->ctrl_intf->cur_altsetting; | |
| 1846 | 1846 | struct usb_cdc_line_coding *line __free(kfree) = | |
| 1847 | - | kmalloc(sizeof(*line), GFP_KERNEL); | |
| 1847 | + | kmalloc_obj(*line); | |
| 1848 | 1848 | int error; | |
| 1849 | 1849 | ||
| 1850 | 1850 | if (!line) | |
modified drivers/input/mouse/psmouse-smbus.c
| @@ -232,7 +232,7 @@ int psmouse_smbus_init(struct psmouse *psmouse, | |||
| 232 | 232 | struct psmouse_smbus_dev *smbdev; | |
| 233 | 233 | int error; | |
| 234 | 234 | ||
| 235 | - | smbdev = kzalloc(sizeof(*smbdev), GFP_KERNEL); | |
| 235 | + | smbdev = kzalloc_obj(*smbdev); | |
| 236 | 236 | if (!smbdev) | |
| 237 | 237 | return -ENOMEM; | |
| 238 | 238 | ||
modified drivers/input/serio/serio_raw.c
| @@ -84,7 +84,7 @@ static int serio_raw_open(struct inode *inode, struct file *file) | |||
| 84 | 84 | if (serio_raw->dead) | |
| 85 | 85 | return -ENODEV; | |
| 86 | 86 | ||
| 87 | - | client = kzalloc(sizeof(*client), GFP_KERNEL); | |
| 87 | + | client = kzalloc_obj(*client); | |
| 88 | 88 | if (!client) | |
| 89 | 89 | return -ENOMEM; | |
| 90 | 90 | ||
modified drivers/iommu/amd/amd_iommu.h
| @@ -54,9 +54,6 @@ struct protection_domain *protection_domain_alloc(void); | |||
| 54 | 54 | struct iommu_domain *amd_iommu_domain_alloc_sva(struct device *dev, | |
| 55 | 55 | struct mm_struct *mm); | |
| 56 | 56 | void amd_iommu_domain_free(struct iommu_domain *dom); | |
| 57 | - | int iommu_sva_set_dev_pasid(struct iommu_domain *domain, | |
| 58 | - | struct device *dev, ioasid_t pasid, | |
| 59 | - | struct iommu_domain *old); | |
| 60 | 57 | void amd_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid, | |
| 61 | 58 | struct iommu_domain *domain); | |
| 62 | 59 | ||
modified drivers/iommu/amd/amd_iommu_types.h
| @@ -39,18 +39,6 @@ | |||
| 39 | 39 | #define MMIO_RANGE_OFFSET 0x0c | |
| 40 | 40 | #define MMIO_MISC_OFFSET 0x10 | |
| 41 | 41 | ||
| 42 | - | /* Masks, shifts and macros to parse the device range capability */ | |
| 43 | - | #define MMIO_RANGE_LD_MASK 0xff000000 | |
| 44 | - | #define MMIO_RANGE_FD_MASK 0x00ff0000 | |
| 45 | - | #define MMIO_RANGE_BUS_MASK 0x0000ff00 | |
| 46 | - | #define MMIO_RANGE_LD_SHIFT 24 | |
| 47 | - | #define MMIO_RANGE_FD_SHIFT 16 | |
| 48 | - | #define MMIO_RANGE_BUS_SHIFT 8 | |
| 49 | - | #define MMIO_GET_LD(x) (((x) & MMIO_RANGE_LD_MASK) >> MMIO_RANGE_LD_SHIFT) | |
| 50 | - | #define MMIO_GET_FD(x) (((x) & MMIO_RANGE_FD_MASK) >> MMIO_RANGE_FD_SHIFT) | |
| 51 | - | #define MMIO_GET_BUS(x) (((x) & MMIO_RANGE_BUS_MASK) >> MMIO_RANGE_BUS_SHIFT) | |
| 52 | - | #define MMIO_MSI_NUM(x) ((x) & 0x1f) | |
| 53 | - | ||
| 54 | 42 | /* Used offsets into the MMIO space */ | |
| 55 | 43 | #define MMIO_DEV_TABLE_OFFSET 0x0000 | |
| 56 | 44 | #define MMIO_CMD_BUF_OFFSET 0x0008 | |
| @@ -247,7 +235,6 @@ | |||
| 247 | 235 | ||
| 248 | 236 | /* constants to configure the command buffer */ | |
| 249 | 237 | #define CMD_BUFFER_SIZE 8192 | |
| 250 | - | #define CMD_BUFFER_UNINITIALIZED 1 | |
| 251 | 238 | #define CMD_BUFFER_ENTRIES 512 | |
| 252 | 239 | #define MMIO_CMD_SIZE_SHIFT 56 | |
| 253 | 240 | #define MMIO_CMD_SIZE_512 (0x9ULL << MMIO_CMD_SIZE_SHIFT) | |
| @@ -434,9 +421,6 @@ struct irq_remap_table { | |||
| 434 | 421 | u32 *table; | |
| 435 | 422 | }; | |
| 436 | 423 | ||
| 437 | - | /* Interrupt remapping feature used? */ | |
| 438 | - | extern bool amd_iommu_irq_remap; | |
| 439 | - | ||
| 440 | 424 | extern const struct iommu_ops amd_iommu_ops; | |
| 441 | 425 | ||
| 442 | 426 | /* IVRS indicates that pre-boot remapping was enabled */ | |
modified drivers/iommu/amd/init.c
| @@ -152,7 +152,7 @@ struct ivmd_header { | |||
| 152 | 152 | } __attribute__((packed)); | |
| 153 | 153 | ||
| 154 | 154 | bool amd_iommu_dump; | |
| 155 | - | bool amd_iommu_irq_remap __read_mostly; | |
| 155 | + | static bool amd_iommu_irq_remap __read_mostly; | |
| 156 | 156 | ||
| 157 | 157 | enum protection_domain_mode amd_iommu_pgtable = PD_MODE_V1; | |
| 158 | 158 | /* Virtual address size */ | |
| @@ -909,7 +909,9 @@ static void free_ga_log(struct amd_iommu *iommu) | |||
| 909 | 909 | { | |
| 910 | 910 | #ifdef CONFIG_IRQ_REMAP | |
| 911 | 911 | iommu_free_pages(iommu->ga_log); | |
| 912 | + | iommu->ga_log = NULL; | |
| 912 | 913 | iommu_free_pages(iommu->ga_log_tail); | |
| 914 | + | iommu->ga_log_tail = NULL; | |
| 913 | 915 | #endif | |
| 914 | 916 | } | |
| 915 | 917 | ||
| @@ -956,6 +958,9 @@ static int iommu_init_ga_log(struct amd_iommu *iommu) | |||
| 956 | 958 | if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))) | |
| 957 | 959 | return -EINVAL; | |
| 958 | 960 | ||
| 961 | + | if (iommu->ga_log && iommu->ga_log_tail) | |
| 962 | + | return 0; | |
| 963 | + | ||
| 959 | 964 | iommu->ga_log = iommu_alloc_pages_node_sz(nid, GFP_KERNEL, GA_LOG_SIZE); | |
| 960 | 965 | if (!iommu->ga_log) | |
| 961 | 966 | goto err_out; | |
| @@ -1917,19 +1922,20 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h, | |||
| 1917 | 1922 | else | |
| 1918 | 1923 | iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET; | |
| 1919 | 1924 | ||
| 1925 | + | if (h->efr_attr & BIT(IOMMU_IVHD_ATTR_HATDIS_SHIFT)) { | |
| 1926 | + | pr_warn_once("Host Address Translation is not supported.\n"); | |
| 1927 | + | amd_iommu_hatdis = true; | |
| 1928 | + | } | |
| 1929 | + | ||
| 1920 | 1930 | /* XT and GAM require GA mode. */ | |
| 1921 | 1931 | if ((h->efr_reg & (0x1 << IOMMU_EFR_GASUP_SHIFT)) == 0) { | |
| 1922 | 1932 | amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY; | |
| 1933 | + | break; | |
| 1923 | 1934 | } else { | |
| 1924 | 1935 | if (h->efr_reg & BIT(IOMMU_EFR_XTSUP_SHIFT)) | |
| 1925 | 1936 | amd_iommu_xt_mode = IRQ_REMAP_X2APIC_MODE; | |
| 1926 | 1937 | } | |
| 1927 | 1938 | ||
| 1928 | - | if (h->efr_attr & BIT(IOMMU_IVHD_ATTR_HATDIS_SHIFT)) { | |
| 1929 | - | pr_warn_once("Host Address Translation is not supported.\n"); | |
| 1930 | - | amd_iommu_hatdis = true; | |
| 1931 | - | } | |
| 1932 | - | ||
| 1933 | 1939 | early_iommu_features_init(iommu, h); | |
| 1934 | 1940 | ||
| 1935 | 1941 | break; | |
modified drivers/iommu/amd/iommu.c
| @@ -1076,9 +1076,6 @@ static void iommu_poll_ga_log(struct amd_iommu *iommu) | |||
| 1076 | 1076 | { | |
| 1077 | 1077 | u32 head, tail; | |
| 1078 | 1078 | ||
| 1079 | - | if (iommu->ga_log == NULL) | |
| 1080 | - | return; | |
| 1081 | - | ||
| 1082 | 1079 | head = readl(iommu->mmio_base + MMIO_GA_HEAD_OFFSET); | |
| 1083 | 1080 | tail = readl(iommu->mmio_base + MMIO_GA_TAIL_OFFSET); | |
| 1084 | 1081 | ||
| @@ -3976,9 +3973,6 @@ static int irq_remapping_select(struct irq_domain *d, struct irq_fwspec *fwspec, | |||
| 3976 | 3973 | struct amd_iommu *iommu; | |
| 3977 | 3974 | int devid = -1; | |
| 3978 | 3975 | ||
| 3979 | - | if (!amd_iommu_irq_remap) | |
| 3980 | - | return 0; | |
| 3981 | - | ||
| 3982 | 3976 | if (x86_fwspec_is_ioapic(fwspec)) | |
| 3983 | 3977 | devid = get_ioapic_devid(fwspec->param[0]); | |
| 3984 | 3978 | else if (x86_fwspec_is_hpet(fwspec)) | |
modified drivers/iommu/amd/nested.c
| @@ -96,7 +96,7 @@ struct iommu_domain * | |||
| 96 | 96 | amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags, | |
| 97 | 97 | const struct iommu_user_data *user_data) | |
| 98 | 98 | { | |
| 99 | - | int ret; | |
| 99 | + | int ret, hdom_id; | |
| 100 | 100 | unsigned long irqflags; | |
| 101 | 101 | struct nested_domain *ndom; | |
| 102 | 102 | struct guest_domain_mapping_info *gdom_info; | |
| @@ -161,8 +161,8 @@ amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags, | |||
| 161 | 161 | } | |
| 162 | 162 | ||
| 163 | 163 | /* The gDomID does not exist. We allocate new hdom_id */ | |
| 164 | - | gdom_info->hdom_id = amd_iommu_pdom_id_alloc(); | |
| 165 | - | if (gdom_info->hdom_id <= 0) { | |
| 164 | + | hdom_id = amd_iommu_pdom_id_alloc(); | |
| 165 | + | if (hdom_id <= 0) { | |
| 166 | 166 | __xa_cmpxchg(&aviommu->gdomid_array, | |
| 167 | 167 | ndom->gdom_id, gdom_info, NULL, GFP_ATOMIC); | |
| 168 | 168 | xa_unlock_irqrestore(&aviommu->gdomid_array, irqflags); | |
| @@ -170,6 +170,7 @@ amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags, | |||
| 170 | 170 | goto out_err_gdom_info; | |
| 171 | 171 | } | |
| 172 | 172 | ||
| 173 | + | gdom_info->hdom_id = hdom_id; | |
| 173 | 174 | ndom->gdom_info = gdom_info; | |
| 174 | 175 | refcount_set(&gdom_info->users, 1); | |
| 175 | 176 | ||
modified drivers/iommu/amd/pasid.c
| @@ -99,9 +99,9 @@ static const struct mmu_notifier_ops sva_mn = { | |||
| 99 | 99 | .release = sva_mn_release, | |
| 100 | 100 | }; | |
| 101 | 101 | ||
| 102 | - | int iommu_sva_set_dev_pasid(struct iommu_domain *domain, | |
| 103 | - | struct device *dev, ioasid_t pasid, | |
| 104 | - | struct iommu_domain *old) | |
| 102 | + | static int iommu_sva_set_dev_pasid(struct iommu_domain *domain, | |
| 103 | + | struct device *dev, ioasid_t pasid, | |
| 104 | + | struct iommu_domain *old) | |
| 105 | 105 | { | |
| 106 | 106 | struct pdom_dev_data *pdom_dev_data; | |
| 107 | 107 | struct protection_domain *sva_pdom = to_pdomain(domain); | |
modified drivers/iommu/amd/ppr.c
| @@ -165,9 +165,6 @@ void amd_iommu_poll_ppr_log(struct amd_iommu *iommu) | |||
| 165 | 165 | { | |
| 166 | 166 | u32 head, tail; | |
| 167 | 167 | ||
| 168 | - | if (iommu->ppr_log == NULL) | |
| 169 | - | return; | |
| 170 | - | ||
| 171 | 168 | head = readl(iommu->mmio_base + MMIO_PPR_HEAD_OFFSET); | |
| 172 | 169 | tail = readl(iommu->mmio_base + MMIO_PPR_TAIL_OFFSET); | |
| 173 | 170 | ||
modified drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
| @@ -796,7 +796,7 @@ static inline struct arm_smmu_invs *arm_smmu_invs_alloc(size_t num_invs) | |||
| 796 | 796 | { | |
| 797 | 797 | struct arm_smmu_invs *new_invs; | |
| 798 | 798 | ||
| 799 | - | new_invs = kzalloc(struct_size(new_invs, inv, num_invs), GFP_KERNEL); | |
| 799 | + | new_invs = kzalloc_flex(*new_invs, inv, num_invs); | |
| 800 | 800 | if (!new_invs) | |
| 801 | 801 | return NULL; | |
| 802 | 802 | new_invs->max_invs = num_invs; | |
modified drivers/iommu/iommufd/device.c
| @@ -76,7 +76,7 @@ static struct iommufd_group *iommufd_alloc_group(struct iommufd_ctx *ictx, | |||
| 76 | 76 | { | |
| 77 | 77 | struct iommufd_group *new_igroup; | |
| 78 | 78 | ||
| 79 | - | new_igroup = kzalloc_obj(*new_igroup, GFP_KERNEL); | |
| 79 | + | new_igroup = kzalloc_obj(*new_igroup); | |
| 80 | 80 | if (!new_igroup) | |
| 81 | 81 | return ERR_PTR(-ENOMEM); | |
| 82 | 82 | ||
modified drivers/iommu/iommufd/driver.c
| @@ -49,7 +49,7 @@ int _iommufd_alloc_mmap(struct iommufd_ctx *ictx, struct iommufd_object *owner, | |||
| 49 | 49 | if (!length || !PAGE_ALIGNED(length)) | |
| 50 | 50 | return -EINVAL; | |
| 51 | 51 | ||
| 52 | - | immap = kzalloc(sizeof(*immap), GFP_KERNEL); | |
| 52 | + | immap = kzalloc_obj(*immap); | |
| 53 | 53 | if (!immap) | |
| 54 | 54 | return -ENOMEM; | |
| 55 | 55 | immap->owner = owner; | |
modified drivers/iommu/iommufd/hwpt_noiommu.c
| @@ -54,7 +54,7 @@ noiommu_alloc_paging_flags(struct device *dev, u32 flags, | |||
| 54 | 54 | (BIT(PT_FEAT_DYNAMIC_TOP) | BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) | | |
| 55 | 55 | BIT(PT_FEAT_AMDV1_FORCE_COHERENCE)); | |
| 56 | 56 | ||
| 57 | - | dom = kzalloc(sizeof(*dom), GFP_KERNEL); | |
| 57 | + | dom = kzalloc_obj(*dom); | |
| 58 | 58 | if (!dom) | |
| 59 | 59 | return ERR_PTR(-ENOMEM); | |
| 60 | 60 | ||
modified drivers/iommu/riscv/iommu.c
| @@ -382,78 +382,97 @@ static int riscv_iommu_queue_wait(struct riscv_iommu_queue *queue, | |||
| 382 | 382 | (int)(cons - index) > 0, 0, timeout_us); | |
| 383 | 383 | } | |
| 384 | 384 | ||
| 385 | - | /* Enqueue an entry and wait to be processed if timeout_us > 0 | |
| 386 | - | * | |
| 387 | - | * Error handling for IOMMU hardware not responding in reasonable time | |
| 388 | - | * will be added as separate patch series along with other RAS features. | |
| 389 | - | * For now, only report hardware failure and continue. | |
| 390 | - | */ | |
| 391 | - | static unsigned int riscv_iommu_queue_send(struct riscv_iommu_queue *queue, | |
| 392 | - | void *entry, size_t entry_size) | |
| 385 | + | static int riscv_iommu_queue_wait_for_space(struct riscv_iommu_queue *queue, | |
| 386 | + | unsigned int last) | |
| 393 | 387 | { | |
| 394 | - | unsigned int prod; | |
| 395 | 388 | unsigned int head; | |
| 396 | 389 | unsigned int tail; | |
| 390 | + | unsigned int hw_head; | |
| 397 | 391 | unsigned long flags; | |
| 392 | + | int ret; | |
| 398 | 393 | ||
| 399 | - | /* Do not preempt submission flow. */ | |
| 400 | - | local_irq_save(flags); | |
| 394 | + | ret = riscv_iommu_readl_timeout(queue->iommu, Q_HEAD(queue), hw_head, | |
| 395 | + | !(hw_head & ~queue->mask) && hw_head != last, | |
| 396 | + | 0, RISCV_IOMMU_QUEUE_TIMEOUT); | |
| 397 | + | if (ret) | |
| 398 | + | return ret; | |
| 401 | 399 | ||
| 402 | - | /* 1. Allocate some space in the queue */ | |
| 403 | - | prod = atomic_inc_return(&queue->prod) - 1; | |
| 400 | + | raw_spin_lock_irqsave(&queue->lock, flags); | |
| 404 | 401 | head = atomic_read(&queue->head); | |
| 402 | + | tail = atomic_read(&queue->tail); | |
| 403 | + | if ((tail - head) >= queue->mask) { | |
| 404 | + | last = Q_ITEM(queue, head); | |
| 405 | + | /* | |
| 406 | + | * Re-read hw_head under the lock so that it is consistent with | |
| 407 | + | * the freshly computed 'last'. Using the pre-lock snapshot | |
| 408 | + | * could produce a stale value that wraps around relative to the | |
| 409 | + | * new 'last', advancing the shadow head past entries that have | |
| 410 | + | * not yet been consumed by the hardware. | |
| 411 | + | */ | |
| 412 | + | hw_head = riscv_iommu_readl(queue->iommu, Q_HEAD(queue)); | |
| 413 | + | if (!(hw_head & ~queue->mask) && hw_head != last) | |
| 414 | + | atomic_add((hw_head - last) & queue->mask, &queue->head); | |
| 415 | + | } | |
| 416 | + | raw_spin_unlock_irqrestore(&queue->lock, flags); | |
| 405 | 417 | ||
| 406 | - | /* 2. Wait for space availability. */ | |
| 407 | - | if ((prod - head) > queue->mask) { | |
| 408 | - | if (readx_poll_timeout(atomic_read, &queue->head, | |
| 409 | - | head, (prod - head) < queue->mask, | |
| 410 | - | 0, RISCV_IOMMU_QUEUE_TIMEOUT)) | |
| 411 | - | goto err_busy; | |
| 412 | - | } else if ((prod - head) == queue->mask) { | |
| 413 | - | const unsigned int last = Q_ITEM(queue, head); | |
| 418 | + | return 0; | |
| 419 | + | } | |
| 420 | + | ||
| 421 | + | /* Enqueue an entry and publish it to the hardware queue. */ | |
| 422 | + | static int riscv_iommu_queue_send(struct riscv_iommu_queue *queue, | |
| 423 | + | void *entry, size_t entry_size, | |
| 424 | + | unsigned int *out_prod) | |
| 425 | + | { | |
| 426 | + | unsigned int prod; | |
| 427 | + | unsigned int head; | |
| 428 | + | unsigned long flags; | |
| 429 | + | int ret; | |
| 430 | + | ||
| 431 | + | /* 1. Wait for space availability and reserve the next slot. */ | |
| 432 | + | for (;;) { | |
| 433 | + | raw_spin_lock_irqsave(&queue->lock, flags); | |
| 434 | + | ||
| 435 | + | prod = atomic_read(&queue->tail); | |
| 436 | + | head = atomic_read(&queue->head); | |
| 437 | + | ||
| 438 | + | if ((prod - head) < queue->mask) | |
| 439 | + | break; | |
| 440 | + | ||
| 441 | + | head = Q_ITEM(queue, head); | |
| 442 | + | raw_spin_unlock_irqrestore(&queue->lock, flags); | |
| 414 | 443 | ||
| 415 | - | if (riscv_iommu_readl_timeout(queue->iommu, Q_HEAD(queue), head, | |
| 416 | - | !(head & ~queue->mask) && head != last, | |
| 417 | - | 0, RISCV_IOMMU_QUEUE_TIMEOUT)) | |
| 444 | + | ret = riscv_iommu_queue_wait_for_space(queue, head); | |
| 445 | + | if (ret) | |
| 418 | 446 | goto err_busy; | |
| 419 | - | atomic_add((head - last) & queue->mask, &queue->head); | |
| 420 | 447 | } | |
| 421 | 448 | ||
| 422 | - | /* 3. Store entry in the ring buffer */ | |
| 449 | + | /* 2. Store entry in the ring buffer. */ | |
| 423 | 450 | memcpy(queue->base + Q_ITEM(queue, prod) * entry_size, entry, entry_size); | |
| 424 | 451 | ||
| 425 | - | /* 4. Wait for all previous entries to be ready */ | |
| 426 | - | if (readx_poll_timeout(atomic_read, &queue->tail, tail, prod == tail, | |
| 427 | - | 0, RISCV_IOMMU_QUEUE_TIMEOUT)) | |
| 428 | - | goto err_busy; | |
| 429 | - | ||
| 430 | - | /* | |
| 431 | - | * 5. Make sure the ring buffer update (whether in normal or I/O memory) is | |
| 432 | - | * completed and visible before signaling the tail doorbell to fetch | |
| 433 | - | * the next command. 'fence ow, ow' | |
| 434 | - | */ | |
| 452 | + | /* 3. Make sure the entry is visible before updating the queue tail. */ | |
| 435 | 453 | dma_wmb(); | |
| 436 | 454 | riscv_iommu_writel(queue->iommu, Q_TAIL(queue), Q_ITEM(queue, prod + 1)); | |
| 437 | 455 | ||
| 438 | 456 | /* | |
| 439 | - | * 6. Make sure the doorbell write to the device has finished before updating | |
| 440 | - | * the shadow tail index in normal memory. 'fence o, w' | |
| 457 | + | * 4. Make sure the doorbell write to the device has finished before | |
| 458 | + | * updating the shadow tail index in normal memory. 'fence o, w' | |
| 441 | 459 | */ | |
| 442 | 460 | #ifdef CONFIG_MMIOWB | |
| 443 | 461 | mmiowb(); | |
| 444 | 462 | #endif | |
| 445 | - | atomic_inc(&queue->tail); | |
| 463 | + | atomic_set(&queue->tail, prod + 1); | |
| 464 | + | atomic_set(&queue->prod, prod + 1); | |
| 446 | 465 | ||
| 447 | - | /* 7. Complete submission and restore local interrupts */ | |
| 448 | - | local_irq_restore(flags); | |
| 466 | + | if (out_prod) | |
| 467 | + | *out_prod = prod; | |
| 449 | 468 | ||
| 450 | - | return prod; | |
| 469 | + | raw_spin_unlock_irqrestore(&queue->lock, flags); | |
| 470 | + | return 0; | |
| 451 | 471 | ||
| 452 | 472 | err_busy: | |
| 453 | - | local_irq_restore(flags); | |
| 473 | + | /* Report the failure and continue; full RAS recovery is not implemented. */ | |
| 454 | 474 | dev_err_once(queue->iommu->dev, "Hardware error: command enqueue failed\n"); | |
| 455 | - | ||
| 456 | - | return prod; | |
| 475 | + | return ret; | |
| 457 | 476 | } | |
| 458 | 477 | ||
| 459 | 478 | /* | |
| @@ -492,7 +511,7 @@ static irqreturn_t riscv_iommu_cmdq_process(int irq, void *data) | |||
| 492 | 511 | static void riscv_iommu_cmd_send(struct riscv_iommu_device *iommu, | |
| 493 | 512 | struct riscv_iommu_command *cmd) | |
| 494 | 513 | { | |
| 495 | - | riscv_iommu_queue_send(&iommu->cmdq, cmd, sizeof(*cmd)); | |
| 514 | + | riscv_iommu_queue_send(&iommu->cmdq, cmd, sizeof(*cmd), NULL); | |
| 496 | 515 | } | |
| 497 | 516 | ||
| 498 | 517 | /* Send IOFENCE.C command and wait for all scheduled commands to complete. */ | |
| @@ -501,9 +520,12 @@ static void riscv_iommu_cmd_sync(struct riscv_iommu_device *iommu, | |||
| 501 | 520 | { | |
| 502 | 521 | struct riscv_iommu_command cmd; | |
| 503 | 522 | unsigned int prod; | |
| 523 | + | int ret; | |
| 504 | 524 | ||
| 505 | 525 | riscv_iommu_cmd_iofence(&cmd); | |
| 506 | - | prod = riscv_iommu_queue_send(&iommu->cmdq, &cmd, sizeof(cmd)); | |
| 526 | + | ret = riscv_iommu_queue_send(&iommu->cmdq, &cmd, sizeof(cmd), &prod); | |
| 527 | + | if (ret) | |
| 528 | + | return; | |
| 507 | 529 | ||
| 508 | 530 | if (!timeout_us) | |
| 509 | 531 | return; | |
| @@ -1560,6 +1582,7 @@ int riscv_iommu_init(struct riscv_iommu_device *iommu) | |||
| 1560 | 1582 | int rc; | |
| 1561 | 1583 | ||
| 1562 | 1584 | RISCV_IOMMU_QUEUE_INIT(&iommu->cmdq, CQ); | |
| 1585 | + | raw_spin_lock_init(&iommu->cmdq.lock); | |
| 1563 | 1586 | RISCV_IOMMU_QUEUE_INIT(&iommu->fltq, FQ); | |
| 1564 | 1587 | ||
| 1565 | 1588 | rc = riscv_iommu_init_check(iommu); | |
modified drivers/iommu/riscv/iommu.h
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | #define _RISCV_IOMMU_H_ | |
| 13 | 13 | ||
| 14 | 14 | #include <linux/iommu.h> | |
| 15 | + | #include <linux/spinlock.h> | |
| 15 | 16 | #include <linux/types.h> | |
| 16 | 17 | #include <linux/iopoll.h> | |
| 17 | 18 | ||
| @@ -23,6 +24,7 @@ struct riscv_iommu_queue { | |||
| 23 | 24 | atomic_t prod; /* unbounded producer allocation index */ | |
| 24 | 25 | atomic_t head; /* unbounded shadow ring buffer consumer index */ | |
| 25 | 26 | atomic_t tail; /* unbounded shadow ring buffer producer index */ | |
| 27 | + | raw_spinlock_t lock; /* serialize queue publishing */ | |
| 26 | 28 | unsigned int mask; /* index mask, queue length - 1 */ | |
| 27 | 29 | unsigned int irq; /* allocated interrupt number */ | |
| 28 | 30 | struct riscv_iommu_device *iommu; /* iommu device handling the queue when active */ | |
modified drivers/iommu/s390-iommu.c
| @@ -974,6 +974,8 @@ static unsigned long *get_rto_from_iova(struct s390_domain *domain, | |||
| 974 | 974 | case ZPCI_TABLE_TYPE_RFX: | |
| 975 | 975 | case ZPCI_TABLE_TYPE_RSX: | |
| 976 | 976 | rso = get_rso_from_iova(domain, iova); | |
| 977 | + | if (!rso) | |
| 978 | + | return NULL; | |
| 977 | 979 | rsx = calc_rsx(iova); | |
| 978 | 980 | rse = READ_ONCE(rso[rsx]); | |
| 979 | 981 | if (!reg_entry_isvalid(rse)) | |
modified drivers/iommu/vsi-iommu.c
| @@ -231,7 +231,7 @@ static struct iommu_domain *vsi_iommu_domain_alloc_paging(struct device *dev) | |||
| 231 | 231 | struct vsi_iommu *iommu = dev_iommu_priv_get(dev); | |
| 232 | 232 | struct vsi_iommu_domain *vsi_domain; | |
| 233 | 233 | ||
| 234 | - | vsi_domain = kzalloc(sizeof(*vsi_domain), GFP_KERNEL); | |
| 234 | + | vsi_domain = kzalloc_obj(*vsi_domain); | |
| 235 | 235 | if (!vsi_domain) | |
| 236 | 236 | return NULL; | |
| 237 | 237 | ||
modified drivers/irqchip/irq-gic-v5-irs.c
| @@ -618,7 +618,7 @@ static int __init gicv5_irs_of_init_affinity(struct device_node *node, | |||
| 618 | 618 | if (niaffids != ncpus) | |
| 619 | 619 | return -EINVAL; | |
| 620 | 620 | ||
| 621 | - | u16 *iaffids __free(kfree) = kcalloc(niaffids, sizeof(*iaffids), GFP_KERNEL); | |
| 621 | + | u16 *iaffids __free(kfree) = kzalloc_objs(*iaffids, niaffids); | |
| 622 | 622 | if (!iaffids) | |
| 623 | 623 | return -ENOMEM; | |
| 624 | 624 | ||
modified drivers/irqchip/irq-gic-v5.c
| @@ -974,7 +974,8 @@ static void gicv5_cpu_disable_interrupts(void) | |||
| 974 | 974 | { | |
| 975 | 975 | u64 cr0; | |
| 976 | 976 | ||
| 977 | - | cr0 = FIELD_PREP(ICC_CR0_EL1_EN, 0); | |
| 977 | + | cr0 = read_sysreg_s(SYS_ICC_CR0_EL1); | |
| 978 | + | cr0 &= ~ICC_CR0_EL1_EN_MASK; | |
| 978 | 979 | write_sysreg_s(cr0, SYS_ICC_CR0_EL1); | |
| 979 | 980 | isb(); | |
| 980 | 981 | } | |
| @@ -991,7 +992,8 @@ static void gicv5_cpu_enable_interrupts(void) | |||
| 991 | 992 | pcr = FIELD_PREP(ICC_PCR_EL1_PRIORITY, GICV5_IRQ_PRI_MI); | |
| 992 | 993 | write_sysreg_s(pcr, SYS_ICC_PCR_EL1); | |
| 993 | 994 | ||
| 994 | - | cr0 = FIELD_PREP(ICC_CR0_EL1_EN, 1); | |
| 995 | + | cr0 = read_sysreg_s(SYS_ICC_CR0_EL1); | |
| 996 | + | cr0 |= ICC_CR0_EL1_EN_MASK; | |
| 995 | 997 | write_sysreg_s(cr0, SYS_ICC_CR0_EL1); | |
| 996 | 998 | } | |
| 997 | 999 | ||
modified drivers/irqchip/irq-loongarch-ir.c
| @@ -331,7 +331,7 @@ static int redirect_domain_alloc(struct irq_domain *domain, unsigned int virq, | |||
| 331 | 331 | struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq + i); | |
| 332 | 332 | struct redirect_item *item; | |
| 333 | 333 | ||
| 334 | - | item = kzalloc(sizeof(*item), GFP_KERNEL); | |
| 334 | + | item = kzalloc_obj(*item); | |
| 335 | 335 | if (!item) { | |
| 336 | 336 | pr_err("Alloc redirect descriptor failed\n"); | |
| 337 | 337 | goto out_free_resources; | |
modified drivers/irqchip/irq-mbigen.c
| @@ -64,20 +64,6 @@ struct mbigen_device { | |||
| 64 | 64 | void __iomem *base; | |
| 65 | 65 | }; | |
| 66 | 66 | ||
| 67 | - | static inline unsigned int get_mbigen_node_offset(unsigned int nid) | |
| 68 | - | { | |
| 69 | - | unsigned int offset = nid * MBIGEN_NODE_OFFSET; | |
| 70 | - | ||
| 71 | - | /* | |
| 72 | - | * To avoid touched clear register in unexpected way, we need to directly | |
| 73 | - | * skip clear register when access to more than 10 mbigen nodes. | |
| 74 | - | */ | |
| 75 | - | if (nid >= (REG_MBIGEN_CLEAR_OFFSET / MBIGEN_NODE_OFFSET)) | |
| 76 | - | offset += MBIGEN_NODE_OFFSET; | |
| 77 | - | ||
| 78 | - | return offset; | |
| 79 | - | } | |
| 80 | - | ||
| 81 | 67 | static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq) | |
| 82 | 68 | { | |
| 83 | 69 | unsigned int nid, pin; | |
| @@ -86,7 +72,8 @@ static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq) | |||
| 86 | 72 | nid = hwirq / IRQS_PER_MBIGEN_NODE + 1; | |
| 87 | 73 | pin = hwirq % IRQS_PER_MBIGEN_NODE; | |
| 88 | 74 | ||
| 89 | - | return pin * 4 + get_mbigen_node_offset(nid) + REG_MBIGEN_VEC_OFFSET; | |
| 75 | + | return pin * 4 + nid * MBIGEN_NODE_OFFSET | |
| 76 | + | + REG_MBIGEN_VEC_OFFSET; | |
| 90 | 77 | } | |
| 91 | 78 | ||
| 92 | 79 | static inline void get_mbigen_type_reg(irq_hw_number_t hwirq, | |
| @@ -101,7 +88,8 @@ static inline void get_mbigen_type_reg(irq_hw_number_t hwirq, | |||
| 101 | 88 | *mask = 1 << (irq_ofst % 32); | |
| 102 | 89 | ofst = irq_ofst / 32 * 4; | |
| 103 | 90 | ||
| 104 | - | *addr = ofst + get_mbigen_node_offset(nid) + REG_MBIGEN_TYPE_OFFSET; | |
| 91 | + | *addr = ofst + nid * MBIGEN_NODE_OFFSET | |
| 92 | + | + REG_MBIGEN_TYPE_OFFSET; | |
| 105 | 93 | } | |
| 106 | 94 | ||
| 107 | 95 | static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq, | |
modified drivers/irqchip/irq-realtek-rtl.c
| @@ -188,7 +188,7 @@ static int __init realtek_setup_parents(struct device_node *node) | |||
| 188 | 188 | struct irq_domain *domain; | |
| 189 | 189 | ||
| 190 | 190 | cnt = max(1, num_parents); | |
| 191 | - | output = kcalloc(cnt, sizeof(*output), GFP_KERNEL); | |
| 191 | + | output = kzalloc_objs(*output, cnt); | |
| 192 | 192 | if (!output) | |
| 193 | 193 | return -ENOMEM; | |
| 194 | 194 | ||
modified drivers/irqchip/irq-stm32mp-exti.c
| @@ -22,7 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | 23 | #define IRQS_PER_BANK 32 | |
| 24 | 24 | ||
| 25 | - | #define HWSPNLCK_TIMEOUT 1000 /* usec */ | |
| 25 | + | #define HWSPNLCK_TIMEOUT_MS 1 | |
| 26 | 26 | ||
| 27 | 27 | #define EXTI_EnCIDCFGR(n) (0x180 + (n) * 4) | |
| 28 | 28 | #define EXTI_HWCFGR1 0x3f0 | |
| @@ -376,7 +376,7 @@ static int stm32mp_exti_set_type(struct irq_data *d, unsigned int type) | |||
| 376 | 376 | raw_spin_lock(&chip_data->rlock); | |
| 377 | 377 | ||
| 378 | 378 | if (hwlock) { | |
| 379 | - | err = hwspin_lock_timeout_in_atomic(hwlock, HWSPNLCK_TIMEOUT); | |
| 379 | + | err = hwspin_lock_timeout_in_atomic(hwlock, HWSPNLCK_TIMEOUT_MS); | |
| 380 | 380 | if (err) { | |
| 381 | 381 | pr_err("%s can't get hwspinlock (%d)\n", __func__, err); | |
| 382 | 382 | goto unlock; | |
modified drivers/mailbox/riscv-sbi-mpxy-mbox.c
| @@ -783,7 +783,7 @@ static int mpxy_mbox_populate_channels(struct mpxy_mbox *mbox) | |||
| 783 | 783 | return dev_err_probe(mbox->dev, -ENODEV, "no MPXY channels available\n"); | |
| 784 | 784 | ||
| 785 | 785 | /* Allocate and fetch all channel IDs */ | |
| 786 | - | channel_ids = kcalloc(mbox->channel_count, sizeof(*channel_ids), GFP_KERNEL); | |
| 786 | + | channel_ids = kzalloc_objs(*channel_ids, mbox->channel_count); | |
| 787 | 787 | if (!channel_ids) | |
| 788 | 788 | return -ENOMEM; | |
| 789 | 789 | rc = mpxy_get_channel_ids(mbox->channel_count, channel_ids); | |
modified drivers/md/dm-cache-target.c
| @@ -340,8 +340,6 @@ struct cache { | |||
| 340 | 340 | struct list_head invalidation_requests; | |
| 341 | 341 | ||
| 342 | 342 | sector_t migration_threshold; | |
| 343 | - | wait_queue_head_t migration_wait; | |
| 344 | - | atomic_t nr_allocated_migrations; | |
| 345 | 343 | ||
| 346 | 344 | /* | |
| 347 | 345 | * The number of in flight migrations that are performing | |
| @@ -397,7 +395,11 @@ struct cache { | |||
| 397 | 395 | bool loaded_mappings:1; | |
| 398 | 396 | bool loaded_discards:1; | |
| 399 | 397 | ||
| 400 | - | struct rw_semaphore background_work_lock; | |
| 398 | + | /* background work management */ | |
| 399 | + | bool background_work_allowed; | |
| 400 | + | unsigned background_work_nr; | |
| 401 | + | spinlock_t background_work_lock; | |
| 402 | + | wait_queue_head_t background_work_wait; | |
| 401 | 403 | ||
| 402 | 404 | struct batcher committer; | |
| 403 | 405 | struct work_struct commit_ws; | |
| @@ -488,19 +490,13 @@ static struct dm_cache_migration *alloc_migration(struct cache *cache) | |||
| 488 | 490 | memset(mg, 0, sizeof(*mg)); | |
| 489 | 491 | ||
| 490 | 492 | mg->cache = cache; | |
| 491 | - | atomic_inc(&cache->nr_allocated_migrations); | |
| 492 | 493 | ||
| 493 | 494 | return mg; | |
| 494 | 495 | } | |
| 495 | 496 | ||
| 496 | 497 | static void free_migration(struct dm_cache_migration *mg) | |
| 497 | 498 | { | |
| 498 | - | struct cache *cache = mg->cache; | |
| 499 | - | ||
| 500 | - | if (atomic_dec_and_test(&cache->nr_allocated_migrations)) | |
| 501 | - | wake_up(&cache->migration_wait); | |
| 502 | - | ||
| 503 | - | mempool_free(mg, &cache->migration_pool); | |
| 499 | + | mempool_free(mg, &mg->cache->migration_pool); | |
| 504 | 500 | } | |
| 505 | 501 | ||
| 506 | 502 | /*----------------------------------------------------------------*/ | |
| @@ -1030,34 +1026,39 @@ static void calc_discard_block_range(struct cache *cache, struct bio *bio, | |||
| 1030 | 1026 | ||
| 1031 | 1027 | static void prevent_background_work(struct cache *cache) | |
| 1032 | 1028 | { | |
| 1033 | - | lockdep_off(); | |
| 1034 | - | down_write(&cache->background_work_lock); | |
| 1035 | - | lockdep_on(); | |
| 1029 | + | spin_lock_irq(&cache->background_work_lock); | |
| 1030 | + | cache->background_work_allowed = false; | |
| 1031 | + | wait_event_lock_irq(cache->background_work_wait, | |
| 1032 | + | cache->background_work_nr == 0, | |
| 1033 | + | cache->background_work_lock); | |
| 1034 | + | spin_unlock_irq(&cache->background_work_lock); | |
| 1036 | 1035 | } | |
| 1037 | 1036 | ||
| 1038 | 1037 | static void allow_background_work(struct cache *cache) | |
| 1039 | 1038 | { | |
| 1040 | - | lockdep_off(); | |
| 1041 | - | up_write(&cache->background_work_lock); | |
| 1042 | - | lockdep_on(); | |
| 1039 | + | spin_lock_irq(&cache->background_work_lock); | |
| 1040 | + | cache->background_work_allowed = true; | |
| 1041 | + | spin_unlock_irq(&cache->background_work_lock); | |
| 1043 | 1042 | } | |
| 1044 | 1043 | ||
| 1045 | 1044 | static bool background_work_begin(struct cache *cache) | |
| 1046 | 1045 | { | |
| 1047 | 1046 | bool r; | |
| 1048 | 1047 | ||
| 1049 | - | lockdep_off(); | |
| 1050 | - | r = down_read_trylock(&cache->background_work_lock); | |
| 1051 | - | lockdep_on(); | |
| 1052 | - | ||
| 1048 | + | spin_lock_irq(&cache->background_work_lock); | |
| 1049 | + | r = cache->background_work_allowed; | |
| 1050 | + | if (r) | |
| 1051 | + | cache->background_work_nr++; | |
| 1052 | + | spin_unlock_irq(&cache->background_work_lock); | |
| 1053 | 1053 | return r; | |
| 1054 | 1054 | } | |
| 1055 | 1055 | ||
| 1056 | 1056 | static void background_work_end(struct cache *cache) | |
| 1057 | 1057 | { | |
| 1058 | - | lockdep_off(); | |
| 1059 | - | up_read(&cache->background_work_lock); | |
| 1060 | - | lockdep_on(); | |
| 1058 | + | spin_lock_irq(&cache->background_work_lock); | |
| 1059 | + | if (--cache->background_work_nr == 0) | |
| 1060 | + | wake_up(&cache->background_work_wait); | |
| 1061 | + | spin_unlock_irq(&cache->background_work_lock); | |
| 1061 | 1062 | } | |
| 1062 | 1063 | ||
| 1063 | 1064 | /*----------------------------------------------------------------*/ | |
| @@ -1462,6 +1463,9 @@ static void invalidate_complete(struct dm_cache_migration *mg, bool success) | |||
| 1462 | 1463 | struct bio_list bios; | |
| 1463 | 1464 | struct cache *cache = mg->cache; | |
| 1464 | 1465 | ||
| 1466 | + | if (success) | |
| 1467 | + | atomic_inc(&cache->stats.demotion); | |
| 1468 | + | ||
| 1465 | 1469 | bio_list_init(&bios); | |
| 1466 | 1470 | if (mg->cell) { | |
| 1467 | 1471 | if (dm_cell_unlock_v2(cache->prison, mg->cell, &bios)) | |
| @@ -1733,7 +1737,6 @@ static int map_bio(struct cache *cache, struct bio *bio, dm_oblock_t block, | |||
| 1733 | 1737 | if (passthrough_mode(cache)) { | |
| 1734 | 1738 | if (bio_data_dir(bio) == WRITE) { | |
| 1735 | 1739 | bio_drop_shared_lock(cache, bio); | |
| 1736 | - | atomic_inc(&cache->stats.demotion); | |
| 1737 | 1740 | invalidate_start(cache, cblock, block, bio); | |
| 1738 | 1741 | return DM_MAPIO_SUBMITTED; | |
| 1739 | 1742 | } else | |
| @@ -2507,9 +2510,7 @@ static int cache_create(struct cache_args *ca, struct cache **result) | |||
| 2507 | 2510 | ||
| 2508 | 2511 | spin_lock_init(&cache->lock); | |
| 2509 | 2512 | bio_list_init(&cache->deferred_bios); | |
| 2510 | - | atomic_set(&cache->nr_allocated_migrations, 0); | |
| 2511 | 2513 | atomic_set(&cache->nr_io_migrations, 0); | |
| 2512 | - | init_waitqueue_head(&cache->migration_wait); | |
| 2513 | 2514 | ||
| 2514 | 2515 | r = -ENOMEM; | |
| 2515 | 2516 | atomic_set(&cache->nr_dirty, 0); | |
| @@ -2592,8 +2593,10 @@ static int cache_create(struct cache_args *ca, struct cache **result) | |||
| 2592 | 2593 | issue_op, cache, cache->wq); | |
| 2593 | 2594 | dm_iot_init(&cache->tracker); | |
| 2594 | 2595 | ||
| 2595 | - | init_rwsem(&cache->background_work_lock); | |
| 2596 | - | prevent_background_work(cache); | |
| 2596 | + | init_waitqueue_head(&cache->background_work_wait); | |
| 2597 | + | spin_lock_init(&cache->background_work_lock); | |
| 2598 | + | cache->background_work_allowed = false; | |
| 2599 | + | cache->background_work_nr = 0; | |
| 2597 | 2600 | ||
| 2598 | 2601 | *result = cache; | |
| 2599 | 2602 | return 0; | |
modified drivers/md/dm-crypt.c
| @@ -1745,7 +1745,6 @@ static void crypt_dec_pending(struct dm_crypt_io *io) | |||
| 1745 | 1745 | { | |
| 1746 | 1746 | struct crypt_config *cc = io->cc; | |
| 1747 | 1747 | struct bio *base_bio = io->base_bio; | |
| 1748 | - | blk_status_t error = io->error; | |
| 1749 | 1748 | ||
| 1750 | 1749 | if (!atomic_dec_and_test(&io->io_pending)) | |
| 1751 | 1750 | return; | |
| @@ -1767,7 +1766,7 @@ static void crypt_dec_pending(struct dm_crypt_io *io) | |||
| 1767 | 1766 | else | |
| 1768 | 1767 | kfree(io->integrity_metadata); | |
| 1769 | 1768 | ||
| 1770 | - | base_bio->bi_status = error; | |
| 1769 | + | base_bio->bi_status = io->error; | |
| 1771 | 1770 | ||
| 1772 | 1771 | bio_endio(base_bio); | |
| 1773 | 1772 | } | |
modified drivers/md/dm-ebs-target.c
| @@ -265,8 +265,7 @@ static int ebs_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 265 | 265 | ||
| 266 | 266 | r = -EINVAL; | |
| 267 | 267 | if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1 || | |
| 268 | - | tmp != (sector_t)tmp || | |
| 269 | - | (sector_t)tmp >= ti->len) { | |
| 268 | + | tmp != (sector_t)tmp) { | |
| 270 | 269 | ti->error = "Invalid device offset sector"; | |
| 271 | 270 | goto bad; | |
| 272 | 271 | } | |
modified drivers/md/dm-inlinecrypt.c
| @@ -322,7 +322,7 @@ static int inlinecrypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 322 | 322 | return -EINVAL; | |
| 323 | 323 | } | |
| 324 | 324 | ||
| 325 | - | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); | |
| 325 | + | ctx = kzalloc_obj(*ctx); | |
| 326 | 326 | if (!ctx) { | |
| 327 | 327 | ti->error = "Out of memory"; | |
| 328 | 328 | return -ENOMEM; | |
modified drivers/md/dm-integrity.c
| @@ -1979,8 +1979,8 @@ static void integrity_metadata(struct work_struct *w) | |||
| 1979 | 1979 | ||
| 1980 | 1980 | if (unlikely(dio->op == REQ_OP_DISCARD)) { | |
| 1981 | 1981 | unsigned int bi_size = dio->bio_details.bi_iter.bi_size; | |
| 1982 | - | unsigned int max_size = likely(checksums != checksums_onstack) ? PAGE_SIZE : HASH_MAX_DIGESTSIZE; | |
| 1983 | - | unsigned int max_blocks = max_size / ic->tag_size; | |
| 1982 | + | unsigned int max_size = likely(checksums != checksums_onstack) ? PAGE_SIZE : sizeof(checksums_onstack); | |
| 1983 | + | unsigned int max_blocks = (max_size - extra_space) / ic->tag_size; | |
| 1984 | 1984 | sector_t sector = dio->range.logical_sector; | |
| 1985 | 1985 | ||
| 1986 | 1986 | if (!ic->discard_keyed) | |
| @@ -3875,6 +3875,10 @@ static void dm_integrity_resume(struct dm_target *ti) | |||
| 3875 | 3875 | r = sync_rw_sb(ic, REQ_OP_READ); | |
| 3876 | 3876 | if (r) | |
| 3877 | 3877 | dm_integrity_io_error(ic, "reading superblock", r); | |
| 3878 | + | ||
| 3879 | + | if (ic->mode == 'R') | |
| 3880 | + | goto skip_writes; | |
| 3881 | + | ||
| 3878 | 3882 | if ((ic->sb->flags & flags) != flags) { | |
| 3879 | 3883 | ic->sb->flags |= flags; | |
| 3880 | 3884 | r = sync_rw_sb(ic, REQ_OP_WRITE | REQ_FUA); | |
| @@ -3984,6 +3988,7 @@ static void dm_integrity_resume(struct dm_target *ti) | |||
| 3984 | 3988 | } | |
| 3985 | 3989 | } | |
| 3986 | 3990 | ||
| 3991 | + | skip_writes: | |
| 3987 | 3992 | ic->reboot_notifier.notifier_call = dm_integrity_reboot; | |
| 3988 | 3993 | ic->reboot_notifier.next = NULL; | |
| 3989 | 3994 | ic->reboot_notifier.priority = INT_MAX - 1; /* be notified after md and before hardware drivers */ | |
| @@ -4130,6 +4135,10 @@ static void dm_integrity_io_hints(struct dm_target *ti, struct queue_limits *lim | |||
| 4130 | 4135 | limits->dma_alignment = limits->logical_block_size - 1; | |
| 4131 | 4136 | limits->discard_granularity = ic->sectors_per_block << SECTOR_SHIFT; | |
| 4132 | 4137 | ||
| 4138 | + | if (ic->internal_hash && | |
| 4139 | + | (ic->mode == 'D' || ic->mode == 'B' || ic->mode == 'I')) | |
| 4140 | + | limits->features |= BLK_FEAT_STABLE_WRITES; | |
| 4141 | + | ||
| 4133 | 4142 | if (!ic->internal_hash) { | |
| 4134 | 4143 | struct blk_integrity *bi = &limits->integrity; | |
| 4135 | 4144 | ||
modified drivers/md/md-llbitmap.c
| @@ -810,7 +810,7 @@ static int llbitmap_expand_pages(struct llbitmap *llbitmap, | |||
| 810 | 810 | if (nr_pages <= old_nr_pages) | |
| 811 | 811 | return 0; | |
| 812 | 812 | ||
| 813 | - | pctl = kcalloc(nr_pages, sizeof(*pctl), GFP_NOIO); | |
| 813 | + | pctl = kzalloc_objs(*pctl, nr_pages, GFP_NOIO); | |
| 814 | 814 | if (!pctl) | |
| 815 | 815 | return -ENOMEM; | |
| 816 | 816 | ||
| @@ -846,7 +846,7 @@ static int llbitmap_alloc_pages(struct llbitmap *llbitmap) | |||
| 846 | 846 | unsigned int nr_pages = max(used_pages, llbitmap_reserved_pages(llbitmap)); | |
| 847 | 847 | int i; | |
| 848 | 848 | ||
| 849 | - | llbitmap->pctl = kcalloc(nr_pages, sizeof(*llbitmap->pctl), GFP_NOIO); | |
| 849 | + | llbitmap->pctl = kzalloc_objs(*llbitmap->pctl, nr_pages, GFP_NOIO); | |
| 850 | 850 | if (!llbitmap->pctl) | |
| 851 | 851 | return -ENOMEM; | |
| 852 | 852 | ||
modified drivers/media/pci/intel/ipu-bridge.c
| @@ -232,6 +232,19 @@ static const struct acpi_device_id ivsc_acpi_ids[] = { | |||
| 232 | 232 | { "INTC10FA" }, /* NVL */ | |
| 233 | 233 | }; | |
| 234 | 234 | ||
| 235 | + | /* | |
| 236 | + | * The subset of ivsc_acpi_ids[] which are IVSC, rather than CVS, devices. The | |
| 237 | + | * CVS IDs are deliberately not listed here: new ones keep being added, whereas | |
| 238 | + | * this list is complete. | |
| 239 | + | */ | |
| 240 | + | static const struct acpi_device_id ivsc_only_acpi_ids[] = { | |
| 241 | + | { "INTC1059" }, | |
| 242 | + | { "INTC1095" }, | |
| 243 | + | { "INTC100A" }, | |
| 244 | + | { "INTC10CF" }, | |
| 245 | + | { } | |
| 246 | + | }; | |
| 247 | + | ||
| 235 | 248 | static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev(struct acpi_device *adev) | |
| 236 | 249 | { | |
| 237 | 250 | unsigned int i; | |
| @@ -283,6 +296,17 @@ static struct device *ipu_bridge_get_ivsc_csi_dev(struct acpi_device *adev) | |||
| 283 | 296 | return csi_dev; | |
| 284 | 297 | } | |
| 285 | 298 | ||
| 299 | + | /* | |
| 300 | + | * The lookups below match on the ACPI companion alone. That is fine for | |
| 301 | + | * CVS, which binds a driver to that very device, but not for IVSC: there | |
| 302 | + | * the ACPI device also has a driverless platform device, which would be | |
| 303 | + | * returned instead of the mei-csi client. Return NULL for IVSC so that | |
| 304 | + | * the caller fails and the probe is retried once the IVSC device shows | |
| 305 | + | * up. | |
| 306 | + | */ | |
| 307 | + | if (!acpi_match_device_ids(adev, ivsc_only_acpi_ids)) | |
| 308 | + | return NULL; | |
| 309 | + | ||
| 286 | 310 | /* Try to locate CVS device on the I2C bus */ | |
| 287 | 311 | csi_dev = bus_find_device_by_acpi_dev(&i2c_bus_type, adev); | |
| 288 | 312 | if (csi_dev) | |
modified drivers/media/platform/allegro-dvt/allegro-core.c
| @@ -3105,7 +3105,7 @@ static int allegro_open(struct file *file) | |||
| 3105 | 3105 | unsigned int cpb_size_max; | |
| 3106 | 3106 | unsigned int cpb_size_def; | |
| 3107 | 3107 | ||
| 3108 | - | channel = kzalloc(sizeof(*channel), GFP_KERNEL); | |
| 3108 | + | channel = kzalloc_obj(*channel); | |
| 3109 | 3109 | if (!channel) | |
| 3110 | 3110 | return -ENOMEM; | |
| 3111 | 3111 | ||
modified drivers/media/platform/amd/isp4/isp4_interface.c
| @@ -127,7 +127,7 @@ isp4if_gpu_mem_alloc(struct isp4_interface *ispif, u32 mem_size) | |||
| 127 | 127 | struct device *dev = ispif->dev; | |
| 128 | 128 | int ret; | |
| 129 | 129 | ||
| 130 | - | mem_info = kmalloc_obj(*mem_info, GFP_KERNEL); | |
| 130 | + | mem_info = kmalloc_obj(*mem_info); | |
| 131 | 131 | if (!mem_info) | |
| 132 | 132 | return NULL; | |
| 133 | 133 | ||
| @@ -368,7 +368,7 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id, | |||
| 368 | 368 | ||
| 369 | 369 | /* Allocate the sync command object early and outside of the lock */ | |
| 370 | 370 | if (sync) { | |
| 371 | - | ele = kmalloc_obj(*ele, GFP_KERNEL); | |
| 371 | + | ele = kmalloc_obj(*ele); | |
| 372 | 372 | if (!ele) | |
| 373 | 373 | return -ENOMEM; | |
| 374 | 374 | ||
| @@ -738,7 +738,7 @@ isp4if_alloc_buffer_node(struct isp4if_img_buf_info *buf_info) | |||
| 738 | 738 | { | |
| 739 | 739 | struct isp4if_img_buf_node *node; | |
| 740 | 740 | ||
| 741 | - | node = kmalloc_obj(*node, GFP_KERNEL); | |
| 741 | + | node = kmalloc_obj(*node); | |
| 742 | 742 | if (node) | |
| 743 | 743 | node->buf_info = *buf_info; | |
| 744 | 744 | ||
modified drivers/media/platform/dreamchip/rppx1/rpp_params.c
| @@ -25,6 +25,7 @@ rppx1_ext_params_blocks_info[] = { | |||
| 25 | 25 | RPPX1_PARAMS_BLOCK_INFO(LSC_PRE2, lsc), | |
| 26 | 26 | RPPX1_PARAMS_BLOCK_INFO(AWBG_PRE1, awbg), | |
| 27 | 27 | RPPX1_PARAMS_BLOCK_INFO(AWBG_PRE2, awbg), | |
| 28 | + | RPPX1_PARAMS_BLOCK_INFO(AWBG_POST, awbg), | |
| 28 | 29 | RPPX1_PARAMS_BLOCK_INFO(CCOR_POST, ccor), | |
| 29 | 30 | RPPX1_PARAMS_BLOCK_INFO(HIST_PRE1, hist), | |
| 30 | 31 | RPPX1_PARAMS_BLOCK_INFO(HIST_PRE2, hist), | |
modified drivers/media/platform/dreamchip/rppx1/rppx1_bls.c
| @@ -70,7 +70,7 @@ rppx1_bls_swap_regs(struct rpp_module *mod, const u32 input[4], u32 output[4]) | |||
| 70 | 70 | ||
| 71 | 71 | /* Swap to pattern used in our path, PRE1 or PRE2. */ | |
| 72 | 72 | struct rpp_module *acq = mod == &mod->rpp->pre1.bls ? | |
| 73 | - | &mod->rpp->pre1.acq : &mod->rpp->pre2.bls; | |
| 73 | + | &mod->rpp->pre1.acq : &mod->rpp->pre2.acq; | |
| 74 | 74 | enum rpp_raw_pattern pattern = acq->info.acq.raw_pattern; | |
| 75 | 75 | ||
| 76 | 76 | for (unsigned int i = 0; i < 4; ++i) | |
modified drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c
| @@ -1299,11 +1299,12 @@ static void vdec_av1_slice_setup_tile(struct vdec_av1_slice_frame *frame, | |||
| 1299 | 1299 | tile->uniform_tile_spacing_flag = | |
| 1300 | 1300 | BIT_FLAG(ctrl_tile, V4L2_AV1_TILE_INFO_FLAG_UNIFORM_TILE_SPACING); | |
| 1301 | 1301 | ||
| 1302 | - | for (i = 0; i < tile->tile_cols + 1; i++) | |
| 1302 | + | /* Bound the copy to the mi_col_starts[]/mi_row_starts[] capacity. */ | |
| 1303 | + | for (i = 0; i < tile->tile_cols + 1 && i < V4L2_AV1_MAX_TILE_COLS + 1; i++) | |
| 1303 | 1304 | tile->mi_col_starts[i] = | |
| 1304 | 1305 | ALIGN(ctrl_tile->mi_col_starts[i], BIT(mib_size_log2)) >> mib_size_log2; | |
| 1305 | 1306 | ||
| 1306 | - | for (i = 0; i < tile->tile_rows + 1; i++) | |
| 1307 | + | for (i = 0; i < tile->tile_rows + 1 && i < V4L2_AV1_MAX_TILE_ROWS + 1; i++) | |
| 1307 | 1308 | tile->mi_row_starts[i] = | |
| 1308 | 1309 | ALIGN(ctrl_tile->mi_row_starts[i], BIT(mib_size_log2)) >> mib_size_log2; | |
| 1309 | 1310 | } | |
modified drivers/media/platform/renesas/rcar-isp/core.c
| @@ -232,7 +232,7 @@ int risp_core_job_prepare(struct rcar_isp_core *core) | |||
| 232 | 232 | } | |
| 233 | 233 | ||
| 234 | 234 | /* Memory is released when the job is consumed. */ | |
| 235 | - | job = kzalloc(sizeof(*job), GFP_KERNEL); | |
| 235 | + | job = kzalloc_obj(*job); | |
| 236 | 236 | if (!job) | |
| 237 | 237 | return -ENOMEM; | |
| 238 | 238 | ||
modified drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | */ | |
| 17 | 17 | ||
| 18 | 18 | #include <linux/v4l2-common.h> | |
| 19 | + | #include <media/v4l2-hevc.h> | |
| 19 | 20 | #include <media/v4l2-mem2mem.h> | |
| 20 | 21 | ||
| 21 | 22 | #include "rkvdec.h" | |
| @@ -37,15 +38,17 @@ void compute_tiles_uniform(struct rkvdec_hevc_run *run, u16 log2_min_cb_size, | |||
| 37 | 38 | s32 pic_in_cts_height, u16 *column_width, u16 *row_height) | |
| 38 | 39 | { | |
| 39 | 40 | const struct v4l2_ctrl_hevc_pps *pps = run->pps; | |
| 41 | + | unsigned int num_cols = v4l2_hevc_pps_num_tile_columns(pps); | |
| 42 | + | unsigned int num_rows = v4l2_hevc_pps_num_tile_rows(pps); | |
| 40 | 43 | int i; | |
| 41 | 44 | ||
| 42 | - | for (i = 0; i < pps->num_tile_columns_minus1 + 1; i++) | |
| 45 | + | for (i = 0; i < num_cols; i++) | |
| 43 | 46 | column_width[i] = ((i + 1) * pic_in_cts_width) / | |
| 44 | 47 | (pps->num_tile_columns_minus1 + 1) - | |
| 45 | 48 | (i * pic_in_cts_width) / | |
| 46 | 49 | (pps->num_tile_columns_minus1 + 1); | |
| 47 | 50 | ||
| 48 | - | for (i = 0; i < pps->num_tile_rows_minus1 + 1; i++) | |
| 51 | + | for (i = 0; i < num_rows; i++) | |
| 49 | 52 | row_height[i] = ((i + 1) * pic_in_cts_height) / | |
| 50 | 53 | (pps->num_tile_rows_minus1 + 1) - | |
| 51 | 54 | (i * pic_in_cts_height) / | |
| @@ -57,17 +60,20 @@ void compute_tiles_non_uniform(struct rkvdec_hevc_run *run, u16 log2_min_cb_size | |||
| 57 | 60 | s32 pic_in_cts_height, u16 *column_width, u16 *row_height) | |
| 58 | 61 | { | |
| 59 | 62 | const struct v4l2_ctrl_hevc_pps *pps = run->pps; | |
| 63 | + | unsigned int num_cols = v4l2_hevc_pps_num_tile_columns(pps); | |
| 64 | + | unsigned int num_rows = v4l2_hevc_pps_num_tile_rows(pps); | |
| 60 | 65 | s32 sum = 0; | |
| 61 | 66 | int i; | |
| 62 | 67 | ||
| 63 | - | for (i = 0; i < pps->num_tile_columns_minus1; i++) { | |
| 68 | + | /* The last tile entry is written after the loop, so iterate one less. */ | |
| 69 | + | for (i = 0; i < num_cols - 1; i++) { | |
| 64 | 70 | column_width[i] = pps->column_width_minus1[i] + 1; | |
| 65 | 71 | sum += column_width[i]; | |
| 66 | 72 | } | |
| 67 | 73 | column_width[i] = pic_in_cts_width - sum; | |
| 68 | 74 | ||
| 69 | 75 | sum = 0; | |
| 70 | - | for (i = 0; i < pps->num_tile_rows_minus1; i++) { | |
| 76 | + | for (i = 0; i < num_rows - 1; i++) { | |
| 71 | 77 | row_height[i] = pps->row_height_minus1[i] + 1; | |
| 72 | 78 | sum += row_height[i]; | |
| 73 | 79 | } | |
modified drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | * Jeffy Chen <jeffy.chen@rock-chips.com> | |
| 13 | 13 | */ | |
| 14 | 14 | ||
| 15 | + | #include <media/v4l2-hevc.h> | |
| 15 | 16 | #include <media/v4l2-mem2mem.h> | |
| 16 | 17 | ||
| 17 | 18 | #include "rkvdec.h" | |
| @@ -135,6 +136,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, | |||
| 135 | 136 | * packet unit). so the driver copy SPS/PPS information to the exact PPS | |
| 136 | 137 | * packet unit for HW accessing. | |
| 137 | 138 | */ | |
| 139 | + | if (pps->pic_parameter_set_id >= ARRAY_SIZE(priv_tbl->param_set)) | |
| 140 | + | return; | |
| 138 | 141 | hw_ps = &priv_tbl->param_set[pps->pic_parameter_set_id]; | |
| 139 | 142 | memset(hw_ps, 0, sizeof(*hw_ps)); | |
| 140 | 143 | ||
| @@ -253,9 +256,9 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, | |||
| 253 | 256 | ||
| 254 | 257 | if (pps->flags & V4L2_HEVC_PPS_FLAG_TILES_ENABLED) { | |
| 255 | 258 | /* Userspace also provide column width and row height for uniform spacing */ | |
| 256 | - | for (i = 0; i <= pps->num_tile_columns_minus1; i++) | |
| 259 | + | for (i = 0; i < v4l2_hevc_pps_num_tile_columns(pps); i++) | |
| 257 | 260 | WRITE_PPS(pps->column_width_minus1[i], COLUMN_WIDTH(i)); | |
| 258 | - | for (i = 0; i <= pps->num_tile_rows_minus1; i++) | |
| 261 | + | for (i = 0; i < v4l2_hevc_pps_num_tile_rows(pps); i++) | |
| 259 | 262 | WRITE_PPS(pps->row_height_minus1[i], ROW_HEIGHT(i)); | |
| 260 | 263 | } else { | |
| 261 | 264 | WRITE_PPS(DIV_ROUND_UP(sps->pic_width_in_luma_samples, ctb_size_y) - 1, | |
modified drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
| @@ -145,6 +145,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, | |||
| 145 | 145 | * packet unit). so the driver copy SPS/PPS information to the exact PPS | |
| 146 | 146 | * packet unit for HW accessing. | |
| 147 | 147 | */ | |
| 148 | + | if (pps->pic_parameter_set_id >= ARRAY_SIZE(priv_tbl->param_set)) | |
| 149 | + | return; | |
| 148 | 150 | hw_ps = &priv_tbl->param_set[pps->pic_parameter_set_id]; | |
| 149 | 151 | memset(hw_ps, 0, sizeof(*hw_ps)); | |
| 150 | 152 | ||
modified drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c
| @@ -5,6 +5,8 @@ | |||
| 5 | 5 | * Copyright (C) 2020 Safran Passenger Innovations LLC | |
| 6 | 6 | */ | |
| 7 | 7 | ||
| 8 | + | #include <media/v4l2-hevc.h> | |
| 9 | + | ||
| 8 | 10 | #include "hantro_hw.h" | |
| 9 | 11 | #include "hantro_g2_regs.h" | |
| 10 | 12 | ||
| @@ -15,8 +17,8 @@ static void prepare_tile_info_buffer(struct hantro_ctx *ctx) | |||
| 15 | 17 | const struct v4l2_ctrl_hevc_pps *pps = ctrls->pps; | |
| 16 | 18 | const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps; | |
| 17 | 19 | u16 *p = (u16 *)((u8 *)ctx->hevc_dec.tile_sizes.cpu); | |
| 18 | - | unsigned int num_tile_rows = pps->num_tile_rows_minus1 + 1; | |
| 19 | - | unsigned int num_tile_cols = pps->num_tile_columns_minus1 + 1; | |
| 20 | + | unsigned int num_tile_rows = v4l2_hevc_pps_num_tile_rows(pps); | |
| 21 | + | unsigned int num_tile_cols = v4l2_hevc_pps_num_tile_columns(pps); | |
| 20 | 22 | unsigned int pic_width_in_ctbs, pic_height_in_ctbs; | |
| 21 | 23 | unsigned int max_log2_ctb_size, ctb_size; | |
| 22 | 24 | bool tiles_enabled, uniform_spacing; | |
modified drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
| @@ -431,20 +431,39 @@ static int rockchip_vpu981_av1_dec_prepare_run(struct hantro_ctx *ctx) | |||
| 431 | 431 | { | |
| 432 | 432 | struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec; | |
| 433 | 433 | struct hantro_av1_dec_ctrls *ctrls = &av1_dec->ctrls; | |
| 434 | + | const struct v4l2_av1_tile_info *tile_info; | |
| 435 | + | struct v4l2_ctrl *tge; | |
| 436 | + | u32 num_tiles; | |
| 434 | 437 | ||
| 435 | 438 | ctrls->sequence = hantro_get_ctrl(ctx, V4L2_CID_STATELESS_AV1_SEQUENCE); | |
| 436 | 439 | if (WARN_ON(!ctrls->sequence)) | |
| 437 | 440 | return -EINVAL; | |
| 438 | 441 | ||
| 439 | - | ctrls->tile_group_entry = | |
| 440 | - | hantro_get_ctrl(ctx, V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY); | |
| 441 | - | if (WARN_ON(!ctrls->tile_group_entry)) | |
| 442 | + | tge = v4l2_ctrl_find(&ctx->ctrl_handler, | |
| 443 | + | V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY); | |
| 444 | + | if (WARN_ON(!tge)) | |
| 442 | 445 | return -EINVAL; | |
| 446 | + | ctrls->tile_group_entry = tge->p_cur.p; | |
| 443 | 447 | ||
| 444 | 448 | ctrls->frame = hantro_get_ctrl(ctx, V4L2_CID_STATELESS_AV1_FRAME); | |
| 445 | 449 | if (WARN_ON(!ctrls->frame)) | |
| 446 | 450 | return -EINVAL; | |
| 447 | 451 | ||
| 452 | + | /* | |
| 453 | + | * rockchip_vpu981_av1_dec_set_tile_info() indexes the tile group | |
| 454 | + | * entry array by tile1 * tile_cols + tile0, so it reads up to | |
| 455 | + | * tile_cols * tile_rows entries, and lays out one descriptor per tile | |
| 456 | + | * in the AV1_MAX_TILES tile_info buffer while programming the real | |
| 457 | + | * tile geometry into the hardware. Reject a frame that claims more | |
| 458 | + | * tiles than userspace submitted, or more than the hardware tile | |
| 459 | + | * buffer holds, so the read stays in bounds and the programmed | |
| 460 | + | * geometry matches the descriptors written. | |
| 461 | + | */ | |
| 462 | + | tile_info = &ctrls->frame->tile_info; | |
| 463 | + | num_tiles = (u32)tile_info->tile_cols * tile_info->tile_rows; | |
| 464 | + | if (num_tiles > tge->elems || num_tiles > AV1_MAX_TILES) | |
| 465 | + | return -EINVAL; | |
| 466 | + | ||
| 448 | 467 | ctrls->film_grain = | |
| 449 | 468 | hantro_get_ctrl(ctx, V4L2_CID_STATELESS_AV1_FILM_GRAIN); | |
| 450 | 469 | ||
| @@ -578,16 +597,30 @@ static void rockchip_vpu981_av1_dec_set_tile_info(struct hantro_ctx *ctx) | |||
| 578 | 597 | const struct v4l2_av1_tile_info *tile_info = &ctrls->frame->tile_info; | |
| 579 | 598 | const struct v4l2_ctrl_av1_tile_group_entry *group_entry = | |
| 580 | 599 | ctrls->tile_group_entry; | |
| 581 | - | int context_update_y = | |
| 582 | - | tile_info->context_update_tile_id / tile_info->tile_cols; | |
| 583 | - | int context_update_x = | |
| 584 | - | tile_info->context_update_tile_id % tile_info->tile_cols; | |
| 585 | - | int context_update_tile_id = | |
| 586 | - | context_update_x * tile_info->tile_rows + context_update_y; | |
| 600 | + | int context_update_y = 0; | |
| 601 | + | int context_update_x = 0; | |
| 602 | + | int context_update_tile_id = 0; | |
| 587 | 603 | u8 *dst = av1_dec->tile_info.cpu; | |
| 604 | + | u8 *dst_end = dst + av1_dec->tile_info.size; | |
| 588 | 605 | struct hantro_dev *vpu = ctx->dev; | |
| 589 | 606 | int tile0, tile1; | |
| 590 | 607 | ||
| 608 | + | /* | |
| 609 | + | * tile_cols and tile_rows are bounded by the V4L2 control validation | |
| 610 | + | * (V4L2_AV1_MAX_TILE_{COLS,ROWS} and V4L2_AV1_MAX_TILE_COUNT). Guard | |
| 611 | + | * the divisor here, and keep the descriptor writes within the | |
| 612 | + | * AV1_MAX_TILES tile_info buffer below; the register values use the | |
| 613 | + | * unmodified tile geometry. | |
| 614 | + | */ | |
| 615 | + | if (tile_info->tile_cols) { | |
| 616 | + | context_update_y = | |
| 617 | + | tile_info->context_update_tile_id / tile_info->tile_cols; | |
| 618 | + | context_update_x = | |
| 619 | + | tile_info->context_update_tile_id % tile_info->tile_cols; | |
| 620 | + | context_update_tile_id = | |
| 621 | + | context_update_x * tile_info->tile_rows + context_update_y; | |
| 622 | + | } | |
| 623 | + | ||
| 591 | 624 | memset(dst, 0, av1_dec->tile_info.size); | |
| 592 | 625 | ||
| 593 | 626 | for (tile0 = 0; tile0 < tile_info->tile_cols; tile0++) { | |
| @@ -598,6 +631,10 @@ static void rockchip_vpu981_av1_dec_set_tile_info(struct hantro_ctx *ctx) | |||
| 598 | 631 | tile_info->height_in_sbs_minus_1[tile1] + 1; | |
| 599 | 632 | u32 x0 = tile_info->width_in_sbs_minus_1[tile0] + 1; | |
| 600 | 633 | ||
| 634 | + | /* Stop once the tile_info descriptor buffer is full. */ | |
| 635 | + | if (dst + 16 > dst_end) | |
| 636 | + | break; | |
| 637 | + | ||
| 601 | 638 | /* tile size in SB units (width,height) */ | |
| 602 | 639 | *dst++ = x0; | |
| 603 | 640 | *dst++ = 0; | |
| @@ -622,6 +659,8 @@ static void rockchip_vpu981_av1_dec_set_tile_info(struct hantro_ctx *ctx) | |||
| 622 | 659 | *dst++ = (end >> 16) & 255; | |
| 623 | 660 | *dst++ = (end >> 24) & 255; | |
| 624 | 661 | } | |
| 662 | + | if (dst + 16 > dst_end) | |
| 663 | + | break; | |
| 625 | 664 | } | |
| 626 | 665 | ||
| 627 | 666 | hantro_reg_write(vpu, &av1_multicore_expect_context_update, !!(context_update_x == 0)); | |
modified drivers/media/rc/igorplugusb.c
| @@ -164,7 +164,7 @@ static int igorplugusb_probe(struct usb_interface *intf, | |||
| 164 | 164 | if (!ir) | |
| 165 | 165 | return -ENOMEM; | |
| 166 | 166 | ||
| 167 | - | ir->request = kzalloc_obj(*ir->request, GFP_KERNEL); | |
| 167 | + | ir->request = kzalloc_obj(*ir->request); | |
| 168 | 168 | if (!ir->request) | |
| 169 | 169 | goto fail; | |
| 170 | 170 | ||
modified drivers/media/v4l2-core/v4l2-ctrls-core.c
| @@ -793,10 +793,30 @@ static int validate_av1_film_grain(struct v4l2_ctrl_av1_film_grain *fg) | |||
| 793 | 793 | return 0; | |
| 794 | 794 | } | |
| 795 | 795 | ||
| 796 | + | static int validate_av1_tile_info(struct v4l2_av1_tile_info *t) | |
| 797 | + | { | |
| 798 | + | /* | |
| 799 | + | * tile_cols and tile_rows index the per-tile descriptor arrays and | |
| 800 | + | * bound the tile loops in the stateless AV1 drivers; the product | |
| 801 | + | * bounds the total tile descriptor count. | |
| 802 | + | */ | |
| 803 | + | if (t->tile_cols > V4L2_AV1_MAX_TILE_COLS || | |
| 804 | + | t->tile_rows > V4L2_AV1_MAX_TILE_ROWS) | |
| 805 | + | return -EINVAL; | |
| 806 | + | ||
| 807 | + | if ((u32)t->tile_cols * t->tile_rows > V4L2_AV1_MAX_TILE_COUNT) | |
| 808 | + | return -EINVAL; | |
| 809 | + | ||
| 810 | + | return 0; | |
| 811 | + | } | |
| 812 | + | ||
| 796 | 813 | static int validate_av1_frame(struct v4l2_ctrl_av1_frame *f) | |
| 797 | 814 | { | |
| 798 | 815 | int ret = 0; | |
| 799 | 816 | ||
| 817 | + | ret = validate_av1_tile_info(&f->tile_info); | |
| 818 | + | if (ret) | |
| 819 | + | return ret; | |
| 800 | 820 | ret = validate_av1_quantization(&f->quantization); | |
| 801 | 821 | if (ret) | |
| 802 | 822 | return ret; | |
| @@ -1253,6 +1273,18 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, | |||
| 1253 | 1273 | ||
| 1254 | 1274 | p_hevc_pps->flags &= | |
| 1255 | 1275 | ~V4L2_HEVC_PPS_FLAG_LOOP_FILTER_ACROSS_TILES_ENABLED; | |
| 1276 | + | } else { | |
| 1277 | + | /* | |
| 1278 | + | * These count the entries the stateless HEVC drivers | |
| 1279 | + | * read from column_width_minus1[] / row_height_minus1[] | |
| 1280 | + | * and use as tile-loop bounds. | |
| 1281 | + | */ | |
| 1282 | + | if (p_hevc_pps->num_tile_columns_minus1 >= | |
| 1283 | + | ARRAY_SIZE(p_hevc_pps->column_width_minus1)) | |
| 1284 | + | return -EINVAL; | |
| 1285 | + | if (p_hevc_pps->num_tile_rows_minus1 >= | |
| 1286 | + | ARRAY_SIZE(p_hevc_pps->row_height_minus1)) | |
| 1287 | + | return -EINVAL; | |
| 1256 | 1288 | } | |
| 1257 | 1289 | ||
| 1258 | 1290 | if (p_hevc_pps->flags & | |
modified drivers/media/v4l2-core/v4l2-h264.c
| @@ -440,7 +440,8 @@ v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder, | |||
| 440 | 440 | } | |
| 441 | 441 | ||
| 442 | 442 | if (builder->num_valid > 1 && | |
| 443 | - | !memcmp(b1_reflist, b0_reflist, builder->num_valid)) | |
| 443 | + | !memcmp(b1_reflist, b0_reflist, | |
| 444 | + | sizeof(b1_reflist[0]) * builder->num_valid)) | |
| 444 | 445 | swap(b1_reflist[0], b1_reflist[1]); | |
| 445 | 446 | ||
| 446 | 447 | print_ref_list_b(builder, b0_reflist, 0); | |
modified drivers/mfd/mfd-core.c
| @@ -135,7 +135,7 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev, | |||
| 135 | 135 | return -EAGAIN; | |
| 136 | 136 | ||
| 137 | 137 | allocate_of_node: | |
| 138 | - | of_entry = kzalloc(sizeof(*of_entry), GFP_KERNEL); | |
| 138 | + | of_entry = kzalloc_obj(*of_entry); | |
| 139 | 139 | if (!of_entry) | |
| 140 | 140 | return -ENOMEM; | |
| 141 | 141 | ||
| @@ -174,7 +174,7 @@ static int mfd_add_device(struct device *parent, int id, | |||
| 174 | 174 | if (!pdev->mfd_cell) | |
| 175 | 175 | goto fail_device; | |
| 176 | 176 | ||
| 177 | - | res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL); | |
| 177 | + | res = kzalloc_objs(*res, cell->num_resources); | |
| 178 | 178 | if (!res) | |
| 179 | 179 | goto fail_device; | |
| 180 | 180 | ||
modified drivers/mfd/ucb1x00-assabet.c
| @@ -96,7 +96,7 @@ static int ucb1x00_assabet_add(struct ucb1x00_dev *dev) | |||
| 96 | 96 | ||
| 97 | 97 | struct ucb1x00_assabet_priv *priv; | |
| 98 | 98 | ||
| 99 | - | priv = kzalloc_obj(*priv, GFP_KERNEL); | |
| 99 | + | priv = kzalloc_obj(*priv); | |
| 100 | 100 | if (!priv) | |
| 101 | 101 | return -ENOMEM; | |
| 102 | 102 | ||
modified drivers/misc/fastrpc.c
| @@ -1822,24 +1822,20 @@ static int fastrpc_dmabuf_alloc(struct fastrpc_user *fl, char __user *argp) | |||
| 1822 | 1822 | return err; | |
| 1823 | 1823 | } | |
| 1824 | 1824 | ||
| 1825 | - | bp.fd = dma_buf_fd(buf->dmabuf, O_ACCMODE); | |
| 1825 | + | bp.fd = get_unused_fd_flags(O_ACCMODE); | |
| 1826 | 1826 | if (bp.fd < 0) { | |
| 1827 | 1827 | dma_buf_put(buf->dmabuf); | |
| 1828 | - | return -EINVAL; | |
| 1828 | + | return bp.fd; | |
| 1829 | 1829 | } | |
| 1830 | 1830 | ||
| 1831 | 1831 | if (copy_to_user(argp, &bp, sizeof(bp))) { | |
| 1832 | - | /* | |
| 1833 | - | * The usercopy failed, but we can't do much about it, as | |
| 1834 | - | * dma_buf_fd() already called fd_install() and made the | |
| 1835 | - | * file descriptor accessible for the current process. It | |
| 1836 | - | * might already be closed and dmabuf no longer valid when | |
| 1837 | - | * we reach this point. Therefore "leak" the fd and rely on | |
| 1838 | - | * the process exit path to do any required cleanup. | |
| 1839 | - | */ | |
| 1832 | + | put_unused_fd(bp.fd); | |
| 1833 | + | dma_buf_put(buf->dmabuf); | |
| 1840 | 1834 | return -EFAULT; | |
| 1841 | 1835 | } | |
| 1842 | 1836 | ||
| 1837 | + | dma_buf_fd_install(buf->dmabuf, bp.fd); | |
| 1838 | + | ||
| 1843 | 1839 | return 0; | |
| 1844 | 1840 | } | |
| 1845 | 1841 | ||
modified drivers/mtd/mtd_virt_concat.c
| @@ -166,7 +166,7 @@ static int mtd_virt_concat_create_item(struct device_node *parts, | |||
| 166 | 166 | return 0; | |
| 167 | 167 | } | |
| 168 | 168 | ||
| 169 | - | item = kzalloc_flex(*item, nodes, count, GFP_KERNEL); | |
| 169 | + | item = kzalloc_flex(*item, nodes, count); | |
| 170 | 170 | if (!item) | |
| 171 | 171 | return -ENOMEM; | |
| 172 | 172 | ||
| @@ -182,7 +182,7 @@ static int mtd_virt_concat_create_item(struct device_node *parts, | |||
| 182 | 182 | for (i = 1; i < count; i++) | |
| 183 | 183 | item->nodes[i] = of_parse_phandle(parts, CONCAT_PROP, (i - 1)); | |
| 184 | 184 | ||
| 185 | - | concat = kzalloc_flex(*concat, subdev, count, GFP_KERNEL); | |
| 185 | + | concat = kzalloc_flex(*concat, subdev, count); | |
| 186 | 186 | if (!concat) { | |
| 187 | 187 | kfree(item); | |
| 188 | 188 | return -ENOMEM; | |
modified drivers/mtd/mtdconcat.c
| @@ -639,7 +639,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
| 639 | 639 | printk(KERN_NOTICE "into device \"%s\"\n", name); | |
| 640 | 640 | ||
| 641 | 641 | /* allocate the device structure */ | |
| 642 | - | concat = kzalloc_flex(*concat, subdev, num_devs, GFP_KERNEL); | |
| 642 | + | concat = kzalloc_flex(*concat, subdev, num_devs); | |
| 643 | 643 | if (!concat) { | |
| 644 | 644 | printk | |
| 645 | 645 | ("memory allocation error while creating concatenated device \"%s\"\n", | |
modified drivers/net/bonding/bond_alb.c
| @@ -678,9 +678,15 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond) | |||
| 678 | 678 | if (arp->op_code == htons(ARPOP_REPLY)) { | |
| 679 | 679 | /* the arp must be sent on the selected rx channel */ | |
| 680 | 680 | tx_slave = rlb_choose_channel(skb, bond, arp); | |
| 681 | - | if (tx_slave) | |
| 681 | + | if (tx_slave && | |
| 682 | + | !ether_addr_equal_64bits(arp->mac_src, | |
| 683 | + | tx_slave->dev->dev_addr)) { | |
| 684 | + | if (unlikely(skb_cow_head(skb, 0))) | |
| 685 | + | return NULL; | |
| 686 | + | arp = (struct arp_pkt *)skb_network_header(skb); | |
| 682 | 687 | bond_hw_addr_copy(arp->mac_src, tx_slave->dev->dev_addr, | |
| 683 | 688 | tx_slave->dev->addr_len); | |
| 689 | + | } | |
| 684 | 690 | netdev_dbg(bond->dev, "(slave %s): Server sent ARP Reply packet\n", | |
| 685 | 691 | tx_slave ? tx_slave->dev->name : "NULL"); | |
| 686 | 692 | } else if (arp->op_code == htons(ARPOP_REQUEST)) { | |
| @@ -875,7 +881,7 @@ static int rlb_initialize(struct bonding *bond) | |||
| 875 | 881 | spin_unlock_bh(&bond->mode_lock); | |
| 876 | 882 | ||
| 877 | 883 | /* register to receive ARPs */ | |
| 878 | - | bond->recv_probe = rlb_arp_recv; | |
| 884 | + | WRITE_ONCE(bond->recv_probe, rlb_arp_recv); | |
| 879 | 885 | ||
| 880 | 886 | return 0; | |
| 881 | 887 | } | |
| @@ -1281,10 +1287,10 @@ unwind: | |||
| 1281 | 1287 | } | |
| 1282 | 1288 | ||
| 1283 | 1289 | /* determine if the packet is NA or NS */ | |
| 1284 | - | static bool alb_determine_nd(struct sk_buff *skb, struct bonding *bond) | |
| 1290 | + | static bool alb_determine_nd(struct sk_buff *skb) | |
| 1285 | 1291 | { | |
| 1286 | - | struct ipv6hdr *ip6hdr; | |
| 1287 | - | struct icmp6hdr *hdr; | |
| 1292 | + | const struct ipv6hdr *ip6hdr; | |
| 1293 | + | const struct icmp6hdr *hdr; | |
| 1288 | 1294 | ||
| 1289 | 1295 | if (!pskb_network_may_pull(skb, sizeof(*ip6hdr))) | |
| 1290 | 1296 | return true; | |
| @@ -1296,7 +1302,8 @@ static bool alb_determine_nd(struct sk_buff *skb, struct bonding *bond) | |||
| 1296 | 1302 | if (!pskb_network_may_pull(skb, sizeof(*ip6hdr) + sizeof(*hdr))) | |
| 1297 | 1303 | return true; | |
| 1298 | 1304 | ||
| 1299 | - | hdr = icmp6_hdr(skb); | |
| 1305 | + | ip6hdr = ipv6_hdr(skb); | |
| 1306 | + | hdr = (const struct icmp6hdr *)(ip6hdr + 1); | |
| 1300 | 1307 | return hdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT || | |
| 1301 | 1308 | hdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION; | |
| 1302 | 1309 | } | |
| @@ -1339,7 +1346,6 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, | |||
| 1339 | 1346 | struct slave *tx_slave) | |
| 1340 | 1347 | { | |
| 1341 | 1348 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | |
| 1342 | - | struct ethhdr *eth_data = eth_hdr(skb); | |
| 1343 | 1349 | ||
| 1344 | 1350 | if (!tx_slave) { | |
| 1345 | 1351 | /* unbalanced or unassigned, send through primary */ | |
| @@ -1350,7 +1356,9 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, | |||
| 1350 | 1356 | ||
| 1351 | 1357 | if (tx_slave && bond_slave_can_tx(tx_slave)) { | |
| 1352 | 1358 | if (tx_slave != rcu_access_pointer(bond->curr_active_slave)) { | |
| 1353 | - | ether_addr_copy(eth_data->h_source, | |
| 1359 | + | if (unlikely(skb_cow_head(skb, 0))) | |
| 1360 | + | return bond_tx_drop(bond->dev, skb); | |
| 1361 | + | ether_addr_copy(skb_eth_hdr(skb)->h_source, | |
| 1354 | 1362 | tx_slave->dev->dev_addr); | |
| 1355 | 1363 | } | |
| 1356 | 1364 | ||
| @@ -1374,14 +1382,13 @@ struct slave *bond_xmit_tlb_slave_get(struct bonding *bond, | |||
| 1374 | 1382 | struct ethhdr *eth_data; | |
| 1375 | 1383 | u32 hash_index; | |
| 1376 | 1384 | ||
| 1377 | - | skb_reset_mac_header(skb); | |
| 1378 | - | eth_data = eth_hdr(skb); | |
| 1385 | + | eth_data = skb_eth_hdr(skb); | |
| 1379 | 1386 | ||
| 1380 | 1387 | /* Do not TX balance any multicast or broadcast */ | |
| 1381 | 1388 | if (!is_multicast_ether_addr(eth_data->h_dest)) { | |
| 1382 | 1389 | switch (skb->protocol) { | |
| 1383 | 1390 | case htons(ETH_P_IPV6): | |
| 1384 | - | if (alb_determine_nd(skb, bond)) | |
| 1391 | + | if (alb_determine_nd(skb)) | |
| 1385 | 1392 | break; | |
| 1386 | 1393 | fallthrough; | |
| 1387 | 1394 | case htons(ETH_P_IP): | |
| @@ -1427,8 +1434,7 @@ struct slave *bond_xmit_alb_slave_get(struct bonding *bond, | |||
| 1427 | 1434 | u32 hash_index = 0; | |
| 1428 | 1435 | int hash_size = 0; | |
| 1429 | 1436 | ||
| 1430 | - | skb_reset_mac_header(skb); | |
| 1431 | - | eth_data = eth_hdr(skb); | |
| 1437 | + | eth_data = skb_eth_hdr(skb); | |
| 1432 | 1438 | ||
| 1433 | 1439 | switch (ntohs(skb->protocol)) { | |
| 1434 | 1440 | case ETH_P_IP: { | |
| @@ -1467,7 +1473,7 @@ struct slave *bond_xmit_alb_slave_get(struct bonding *bond, | |||
| 1467 | 1473 | break; | |
| 1468 | 1474 | } | |
| 1469 | 1475 | ||
| 1470 | - | if (alb_determine_nd(skb, bond)) { | |
| 1476 | + | if (alb_determine_nd(skb)) { | |
| 1471 | 1477 | do_tx_balance = false; | |
| 1472 | 1478 | break; | |
| 1473 | 1479 | } | |
modified drivers/net/bonding/bond_main.c
| @@ -1245,7 +1245,7 @@ static void bond_peer_notify_may_events(struct bonding *bond, bool force) | |||
| 1245 | 1245 | } | |
| 1246 | 1246 | ||
| 1247 | 1247 | if (notified || force) | |
| 1248 | - | bond->send_peer_notif--; | |
| 1248 | + | WRITE_ONCE(bond->send_peer_notif, bond->send_peer_notif - 1); | |
| 1249 | 1249 | } | |
| 1250 | 1250 | ||
| 1251 | 1251 | /** | |
| @@ -2284,7 +2284,7 @@ skip_mac_set: | |||
| 2284 | 2284 | } | |
| 2285 | 2285 | } | |
| 2286 | 2286 | ||
| 2287 | - | bond->slave_cnt++; | |
| 2287 | + | WRITE_ONCE(bond->slave_cnt, bond->slave_cnt + 1); | |
| 2288 | 2288 | netdev_compute_master_upper_features(bond->dev, true); | |
| 2289 | 2289 | bond_set_carrier(bond); | |
| 2290 | 2290 | ||
| @@ -2517,9 +2517,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
| 2517 | 2517 | bond_alb_deinit_slave(bond, slave); | |
| 2518 | 2518 | } | |
| 2519 | 2519 | ||
| 2520 | - | if (all) { | |
| 2521 | - | RCU_INIT_POINTER(bond->curr_active_slave, NULL); | |
| 2522 | - | } else if (oldcurrent == slave) { | |
| 2520 | + | if (!all && oldcurrent == slave) { | |
| 2523 | 2521 | /* Note that we hold RTNL over this sequence, so there | |
| 2524 | 2522 | * is no concern that another slave add/remove event | |
| 2525 | 2523 | * will interfere. | |
| @@ -2533,7 +2531,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
| 2533 | 2531 | ||
| 2534 | 2532 | unblock_netpoll_tx(); | |
| 2535 | 2533 | synchronize_rcu(); | |
| 2536 | - | bond->slave_cnt--; | |
| 2534 | + | WRITE_ONCE(bond->slave_cnt, bond->slave_cnt - 1); | |
| 2537 | 2535 | ||
| 2538 | 2536 | if (!bond_has_slaves(bond)) { | |
| 2539 | 2537 | call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev); | |
| @@ -4385,13 +4383,13 @@ static int bond_open(struct net_device *bond_dev) | |||
| 4385 | 4383 | ||
| 4386 | 4384 | if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ | |
| 4387 | 4385 | queue_delayed_work(bond->wq, &bond->arp_work, 0); | |
| 4388 | - | bond->recv_probe = bond_rcv_validate; | |
| 4386 | + | WRITE_ONCE(bond->recv_probe, bond_rcv_validate); | |
| 4389 | 4387 | } | |
| 4390 | 4388 | ||
| 4391 | 4389 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { | |
| 4392 | 4390 | queue_delayed_work(bond->wq, &bond->ad_work, 0); | |
| 4393 | 4391 | /* register to receive LACPDUs */ | |
| 4394 | - | bond->recv_probe = bond_3ad_lacpdu_recv; | |
| 4392 | + | WRITE_ONCE(bond->recv_probe, bond_3ad_lacpdu_recv); | |
| 4395 | 4393 | bond_3ad_initiate_agg_selection(bond, 1); | |
| 4396 | 4394 | ||
| 4397 | 4395 | bond_for_each_slave(bond, slave, iter) | |
| @@ -4413,7 +4411,7 @@ static int bond_close(struct net_device *bond_dev) | |||
| 4413 | 4411 | struct slave *slave; | |
| 4414 | 4412 | ||
| 4415 | 4413 | bond_work_cancel_all(bond); | |
| 4416 | - | bond->send_peer_notif = 0; | |
| 4414 | + | WRITE_ONCE(bond->send_peer_notif, 0); | |
| 4417 | 4415 | WRITE_ONCE(bond->recv_probe, NULL); | |
| 4418 | 4416 | ||
| 4419 | 4417 | /* Wait for any in-flight RX handlers */ | |
| @@ -5118,7 +5116,7 @@ static void bond_skip_slave(struct bond_up_slave *slaves, | |||
| 5118 | 5116 | if (skipslave == slaves->arr[idx]) { | |
| 5119 | 5117 | slaves->arr[idx] = | |
| 5120 | 5118 | slaves->arr[slaves->count - 1]; | |
| 5121 | - | slaves->count--; | |
| 5119 | + | WRITE_ONCE(slaves->count, slaves->count - 1); | |
| 5122 | 5120 | break; | |
| 5123 | 5121 | } | |
| 5124 | 5122 | } | |
modified drivers/net/bonding/bond_options.c
| @@ -1147,11 +1147,11 @@ static int bond_option_arp_interval_set(struct bonding *bond, | |||
| 1147 | 1147 | */ | |
| 1148 | 1148 | if (!newval->value) { | |
| 1149 | 1149 | if (bond->params.arp_validate) | |
| 1150 | - | bond->recv_probe = NULL; | |
| 1150 | + | WRITE_ONCE(bond->recv_probe, NULL); | |
| 1151 | 1151 | cancel_delayed_work_sync(&bond->arp_work); | |
| 1152 | 1152 | } else { | |
| 1153 | 1153 | /* arp_validate can be set only in active-backup mode */ | |
| 1154 | - | bond->recv_probe = bond_rcv_validate; | |
| 1154 | + | WRITE_ONCE(bond->recv_probe, bond_rcv_validate); | |
| 1155 | 1155 | cancel_delayed_work_sync(&bond->mii_work); | |
| 1156 | 1156 | queue_delayed_work(bond->wq, &bond->arp_work, 0); | |
| 1157 | 1157 | } | |
modified drivers/net/dsa/bcm_sf2_cfp.c
| @@ -1088,6 +1088,8 @@ static int bcm_sf2_cfp_rule_get_all(struct bcm_sf2_priv *priv, | |||
| 1088 | 1088 | unsigned int index = 1, rules_cnt = 0; | |
| 1089 | 1089 | ||
| 1090 | 1090 | for_each_set_bit_from(index, priv->cfp.unique, priv->num_cfp_rules) { | |
| 1091 | + | if (rules_cnt == nfc->rule_cnt) | |
| 1092 | + | return -EMSGSIZE; | |
| 1091 | 1093 | rule_locs[rules_cnt] = index; | |
| 1092 | 1094 | rules_cnt++; | |
| 1093 | 1095 | } | |
modified drivers/net/dsa/lantiq/lantiq_gswip.h
| @@ -42,7 +42,7 @@ | |||
| 42 | 42 | #define GSWIP_MDIO_PHY_FDUP_DIS 0x0600 | |
| 43 | 43 | #define GSWIP_MDIO_PHY_FCONTX_MASK 0x0180 | |
| 44 | 44 | #define GSWIP_MDIO_PHY_FCONTX_AUTO 0x0000 | |
| 45 | - | #define GSWIP_MDIO_PHY_FCONTX_EN 0x0100 | |
| 45 | + | #define GSWIP_MDIO_PHY_FCONTX_EN 0x0080 | |
| 46 | 46 | #define GSWIP_MDIO_PHY_FCONTX_DIS 0x0180 | |
| 47 | 47 | #define GSWIP_MDIO_PHY_FCONRX_MASK 0x0060 | |
| 48 | 48 | #define GSWIP_MDIO_PHY_FCONRX_AUTO 0x0000 | |
modified drivers/net/dsa/mt7530.c
| @@ -3172,23 +3172,31 @@ static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port, | |||
| 3172 | 3172 | ||
| 3173 | 3173 | config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE; | |
| 3174 | 3174 | ||
| 3175 | + | priv->info->mac_port_get_caps(ds, port, config); | |
| 3176 | + | ||
| 3175 | 3177 | /* The EN7528 GPHYs report EEE capability, but negotiating EEE with | |
| 3176 | 3178 | * common link partners (e.g. Realtek GbE NICs) results in an unstable | |
| 3177 | 3179 | * link with dropped frames. Leave the LPI capabilities empty so that | |
| 3178 | 3180 | * phylink disables EEE on these PHYs and refuses to enable it from | |
| 3179 | 3181 | * userspace. | |
| 3180 | 3182 | */ | |
| 3181 | - | if (priv->id != ID_EN7528) { | |
| 3183 | + | if (priv->id != ID_EN7528 && | |
| 3184 | + | config->mac_capabilities & (MAC_100FD | MAC_1000FD)) { | |
| 3182 | 3185 | u32 eeecr = mt7530_read(priv, MT753X_PMEEECR_P(port)); | |
| 3183 | 3186 | ||
| 3184 | - | config->lpi_capabilities = MAC_100FD | MAC_1000FD | MAC_2500FD; | |
| 3187 | + | /* LPI above 1 Gbps is not supported */ | |
| 3188 | + | config->lpi_capabilities = config->mac_capabilities & | |
| 3189 | + | (MAC_100FD | MAC_1000FD); | |
| 3190 | + | phy_interface_copy(config->lpi_interfaces, | |
| 3191 | + | config->supported_interfaces); | |
| 3192 | + | __clear_bit(PHY_INTERFACE_MODE_2500BASEX, | |
| 3193 | + | config->lpi_interfaces); | |
| 3194 | + | ||
| 3185 | 3195 | /* tx_lpi_timer should be in microseconds. The time units for | |
| 3186 | 3196 | * LPI threshold are unspecified. | |
| 3187 | 3197 | */ | |
| 3188 | 3198 | config->lpi_timer_default = FIELD_GET(LPI_THRESH_MASK, eeecr); | |
| 3189 | 3199 | } | |
| 3190 | - | ||
| 3191 | - | priv->info->mac_port_get_caps(ds, port, config); | |
| 3192 | 3200 | } | |
| 3193 | 3201 | ||
| 3194 | 3202 | static int mt753x_pcs_validate(struct phylink_pcs *pcs, | |
modified drivers/net/dsa/mv88e6xxx/chip.c
| @@ -2438,6 +2438,7 @@ static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port, | |||
| 2438 | 2438 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; | |
| 2439 | 2439 | struct mv88e6xxx_chip *chip = ds->priv; | |
| 2440 | 2440 | struct mv88e6xxx_policy *policy; | |
| 2441 | + | u32 cnt = 0; | |
| 2441 | 2442 | int err; | |
| 2442 | 2443 | int id; | |
| 2443 | 2444 | ||
| @@ -2463,11 +2464,18 @@ static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port, | |||
| 2463 | 2464 | break; | |
| 2464 | 2465 | case ETHTOOL_GRXCLSRLALL: | |
| 2465 | 2466 | rxnfc->data = 0; | |
| 2466 | - | rxnfc->rule_cnt = 0; | |
| 2467 | - | idr_for_each_entry(&chip->policies, policy, id) | |
| 2468 | - | if (policy->port == port) | |
| 2469 | - | rule_locs[rxnfc->rule_cnt++] = id; | |
| 2470 | 2467 | err = 0; | |
| 2468 | + | idr_for_each_entry(&chip->policies, policy, id) { | |
| 2469 | + | if (policy->port != port) | |
| 2470 | + | continue; | |
| 2471 | + | if (cnt == rxnfc->rule_cnt) { | |
| 2472 | + | err = -EMSGSIZE; | |
| 2473 | + | break; | |
| 2474 | + | } | |
| 2475 | + | rule_locs[cnt++] = id; | |
| 2476 | + | } | |
| 2477 | + | if (!err) | |
| 2478 | + | rxnfc->rule_cnt = cnt; | |
| 2471 | 2479 | break; | |
| 2472 | 2480 | default: | |
| 2473 | 2481 | err = -EOPNOTSUPP; | |
modified drivers/net/dsa/mv88e6xxx/tcflower.c
| @@ -97,7 +97,7 @@ int mv88e6xxx_cls_flower_add(struct dsa_switch *ds, int port, | |||
| 97 | 97 | goto err_unlock; | |
| 98 | 98 | } | |
| 99 | 99 | ||
| 100 | - | entry = kzalloc(sizeof(*entry), GFP_KERNEL); | |
| 100 | + | entry = kzalloc_obj(*entry); | |
| 101 | 101 | if (!entry) { | |
| 102 | 102 | err = -ENOMEM; | |
| 103 | 103 | goto err_unlock; | |
modified drivers/net/ethernet/airoha/airoha_eth.h
| @@ -538,7 +538,7 @@ struct airoha_wdma_info { | |||
| 538 | 538 | ||
| 539 | 539 | /* RX queue to IRQ mapping: BIT(q) in IRQ(n) */ | |
| 540 | 540 | #define RX_IRQ0_BANK_PIN_MASK 0x839f | |
| 541 | - | #define RX_IRQ1_BANK_PIN_MASK 0x7fe00000 | |
| 541 | + | #define RX_IRQ1_BANK_PIN_MASK 0xffe00000 | |
| 542 | 542 | #define RX_IRQ2_BANK_PIN_MASK 0x20 | |
| 543 | 543 | #define RX_IRQ3_BANK_PIN_MASK 0x40 | |
| 544 | 544 | #define RX_IRQ_BANK_PIN_MASK(_n) \ | |
modified drivers/net/ethernet/alibaba/eea/eea_adminq.c
| @@ -439,8 +439,7 @@ int eea_adminq_dev_status(struct eea_net *enet, | |||
| 439 | 439 | q_num = enet->cfg.rx_ring_num + enet->cfg.tx_ring_num + 1; | |
| 440 | 440 | io_num = enet->cfg.rx_ring_num + enet->cfg.tx_ring_num; | |
| 441 | 441 | ||
| 442 | - | req = kcalloc(q_num, sizeof(struct eea_aq_queue_drv_status), | |
| 443 | - | GFP_KERNEL); | |
| 442 | + | req = kzalloc_objs(struct eea_aq_queue_drv_status, q_num); | |
| 444 | 443 | if (!req) | |
| 445 | 444 | return -ENOMEM; | |
| 446 | 445 | ||
| @@ -486,11 +485,11 @@ void eea_adminq_config_host_info(struct eea_net *enet) | |||
| 486 | 485 | struct eea_aq_host_info_rep *rep; | |
| 487 | 486 | int rc = -ENOMEM; | |
| 488 | 487 | ||
| 489 | - | cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); | |
| 488 | + | cfg = kzalloc_obj(*cfg); | |
| 490 | 489 | if (!cfg) | |
| 491 | 490 | return; | |
| 492 | 491 | ||
| 493 | - | rep = kzalloc(sizeof(*rep), GFP_KERNEL); | |
| 492 | + | rep = kzalloc_obj(*rep); | |
| 494 | 493 | if (!rep) | |
| 495 | 494 | goto err_free_cfg; | |
| 496 | 495 | ||
modified drivers/net/ethernet/alibaba/eea/eea_net.c
| @@ -62,7 +62,7 @@ static int eea_alloc_irq_blks(struct eea_net *enet) | |||
| 62 | 62 | ||
| 63 | 63 | num = enet->edev->rx_num; | |
| 64 | 64 | ||
| 65 | - | irq_blks = kvcalloc(num, sizeof(*blk), GFP_KERNEL); | |
| 65 | + | irq_blks = kvzalloc_objs(*blk, num); | |
| 66 | 66 | if (!irq_blks) | |
| 67 | 67 | return -ENOMEM; | |
| 68 | 68 | ||
| @@ -194,11 +194,11 @@ static int eea_alloc_rxtx_q_mem(struct eea_net_init_ctx *ctx) | |||
| 194 | 194 | struct eea_net_tx *tx; | |
| 195 | 195 | int err, i; | |
| 196 | 196 | ||
| 197 | - | ctx->tx = kvcalloc(ctx->cfg.tx_ring_num, sizeof(*ctx->tx), GFP_KERNEL); | |
| 197 | + | ctx->tx = kvzalloc_objs(*ctx->tx, ctx->cfg.tx_ring_num); | |
| 198 | 198 | if (!ctx->tx) | |
| 199 | 199 | return -ENOMEM; | |
| 200 | 200 | ||
| 201 | - | ctx->rx = kvcalloc(ctx->cfg.rx_ring_num, sizeof(*ctx->rx), GFP_KERNEL); | |
| 201 | + | ctx->rx = kvzalloc_objs(*ctx->rx, ctx->cfg.rx_ring_num); | |
| 202 | 202 | if (!ctx->rx) | |
| 203 | 203 | goto err_free_tx; | |
| 204 | 204 | ||
| @@ -601,7 +601,7 @@ static int eea_netdev_init_features(struct net_device *netdev, | |||
| 601 | 601 | int err; | |
| 602 | 602 | u32 mtu; | |
| 603 | 603 | ||
| 604 | - | cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); | |
| 604 | + | cfg = kzalloc_obj(*cfg); | |
| 605 | 605 | if (!cfg) | |
| 606 | 606 | return -ENOMEM; | |
| 607 | 607 | ||
modified drivers/net/ethernet/alibaba/eea/eea_pci.c
| @@ -651,7 +651,7 @@ static int eea_pci_probe(struct pci_dev *pci_dev, | |||
| 651 | 651 | struct eea_device *edev; | |
| 652 | 652 | int err; | |
| 653 | 653 | ||
| 654 | - | ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL); | |
| 654 | + | ep_dev = kzalloc_obj(*ep_dev); | |
| 655 | 655 | if (!ep_dev) | |
| 656 | 656 | return -ENOMEM; | |
| 657 | 657 | ||
modified drivers/net/ethernet/alibaba/eea/eea_ring.c
| @@ -217,7 +217,7 @@ struct eea_ring *eea_ering_alloc(u32 index, u32 num, struct eea_device *edev, | |||
| 217 | 217 | if (!cq_desc_size || !is_power_of_2(cq_desc_size)) | |
| 218 | 218 | return NULL; | |
| 219 | 219 | ||
| 220 | - | ering = kzalloc(sizeof(*ering), GFP_KERNEL); | |
| 220 | + | ering = kzalloc_obj(*ering); | |
| 221 | 221 | if (!ering) | |
| 222 | 222 | return NULL; | |
| 223 | 223 | ||
modified drivers/net/ethernet/alibaba/eea/eea_rx.c
| @@ -764,7 +764,7 @@ struct eea_net_rx *eea_alloc_rx(struct eea_net_init_ctx *ctx, u32 idx) | |||
| 764 | 764 | struct eea_net_rx *rx; | |
| 765 | 765 | int err; | |
| 766 | 766 | ||
| 767 | - | rx = kzalloc(sizeof(*rx), GFP_KERNEL); | |
| 767 | + | rx = kzalloc_obj(*rx); | |
| 768 | 768 | if (!rx) | |
| 769 | 769 | return rx; | |
| 770 | 770 | ||
| @@ -786,8 +786,7 @@ struct eea_net_rx *eea_alloc_rx(struct eea_net_init_ctx *ctx, u32 idx) | |||
| 786 | 786 | rx->dma_dev = ctx->edev->dma_dev; | |
| 787 | 787 | ||
| 788 | 788 | /* meta */ | |
| 789 | - | rx->meta = kvcalloc(ctx->cfg.rx_ring_depth, | |
| 790 | - | sizeof(*rx->meta), GFP_KERNEL); | |
| 789 | + | rx->meta = kvzalloc_objs(*rx->meta, ctx->cfg.rx_ring_depth); | |
| 791 | 790 | if (!rx->meta) | |
| 792 | 791 | goto err_free_rx; | |
| 793 | 792 | ||
modified drivers/net/ethernet/alibaba/eea/eea_tx.c
| @@ -480,8 +480,7 @@ int eea_alloc_tx(struct eea_net_init_ctx *ctx, struct eea_net_tx *tx, u32 idx) | |||
| 480 | 480 | tx->dma_dev = ctx->edev->dma_dev; | |
| 481 | 481 | ||
| 482 | 482 | /* meta */ | |
| 483 | - | tx->meta = kvcalloc(ctx->cfg.tx_ring_depth, | |
| 484 | - | sizeof(*tx->meta), GFP_KERNEL); | |
| 483 | + | tx->meta = kvzalloc_objs(*tx->meta, ctx->cfg.tx_ring_depth); | |
| 485 | 484 | if (!tx->meta) | |
| 486 | 485 | goto err_free_tx; | |
| 487 | 486 | ||
modified drivers/net/ethernet/allwinner/sun4i-emac.c
| @@ -1067,6 +1067,7 @@ static int emac_probe(struct platform_device *pdev) | |||
| 1067 | 1067 | return 0; | |
| 1068 | 1068 | ||
| 1069 | 1069 | out_release_sram: | |
| 1070 | + | of_node_put(db->phy_node); | |
| 1070 | 1071 | sunxi_sram_release(&pdev->dev); | |
| 1071 | 1072 | out_clk_disable_unprepare: | |
| 1072 | 1073 | clk_disable_unprepare(db->clk); | |
| @@ -1094,6 +1095,7 @@ static void emac_remove(struct platform_device *pdev) | |||
| 1094 | 1095 | } | |
| 1095 | 1096 | ||
| 1096 | 1097 | unregister_netdev(ndev); | |
| 1098 | + | of_node_put(db->phy_node); | |
| 1097 | 1099 | sunxi_sram_release(&pdev->dev); | |
| 1098 | 1100 | clk_disable_unprepare(db->clk); | |
| 1099 | 1101 | irq_dispose_mapping(ndev->irq); | |
modified drivers/net/ethernet/amd/pds_core/core.c
| @@ -810,8 +810,7 @@ void pdsc_host_mem_add(struct pdsc *pdsc) | |||
| 810 | 810 | if (count == 0) | |
| 811 | 811 | return; | |
| 812 | 812 | ||
| 813 | - | pdsc->host_mem_reqs = kzalloc_objs(*pdsc->host_mem_reqs, count, | |
| 814 | - | GFP_KERNEL); | |
| 813 | + | pdsc->host_mem_reqs = kzalloc_objs(*pdsc->host_mem_reqs, count); | |
| 815 | 814 | if (!pdsc->host_mem_reqs) { | |
| 816 | 815 | dev_err(pdsc->dev, "failed to alloc host_mem_reqs array\n"); | |
| 817 | 816 | return; | |
modified drivers/net/ethernet/amd/pds_core/fw.c
| @@ -171,8 +171,10 @@ pdsc_legacy_firmware_update(struct pdsc *pdsc, | |||
| 171 | 171 | ||
| 172 | 172 | dev_info(pdsc->dev, "Installing firmware\n"); | |
| 173 | 173 | ||
| 174 | - | if (!pdsc->cmd_regs) | |
| 174 | + | if (!pdsc->cmd_regs) { | |
| 175 | + | NL_SET_ERR_MSG_MOD(extack, "BARs not mapped"); | |
| 175 | 176 | return -ENXIO; | |
| 177 | + | } | |
| 176 | 178 | ||
| 177 | 179 | dl = priv_to_devlink(pdsc); | |
| 178 | 180 | devlink_flash_update_status_notify(dl, "Preparing to flash", | |
| @@ -198,6 +200,12 @@ pdsc_legacy_firmware_update(struct pdsc *pdsc, | |||
| 198 | 200 | ||
| 199 | 201 | copy_sz = min_t(unsigned int, buf_sz, fw->size - offset); | |
| 200 | 202 | mutex_lock(&pdsc->devcmd_lock); | |
| 203 | + | if (!pdsc->cmd_regs) { | |
| 204 | + | mutex_unlock(&pdsc->devcmd_lock); | |
| 205 | + | err = -ENXIO; | |
| 206 | + | NL_SET_ERR_MSG_MOD(extack, "Device reset during flash"); | |
| 207 | + | goto err_out; | |
| 208 | + | } | |
| 201 | 209 | memcpy_toio(&pdsc->cmd_regs->data, fw->data + offset, copy_sz); | |
| 202 | 210 | err = pdsc_devcmd_fw_download_locked(pdsc, data_addr, | |
| 203 | 211 | offset, copy_sz); | |
| @@ -382,7 +390,7 @@ static int pdsc_send_package_data(struct pldmfw *context, const u8 *data, | |||
| 382 | 390 | if (!length) | |
| 383 | 391 | return 0; | |
| 384 | 392 | ||
| 385 | - | deferred = kmalloc_obj(*deferred, GFP_KERNEL); | |
| 393 | + | deferred = kmalloc_obj(*deferred); | |
| 386 | 394 | if (!deferred) | |
| 387 | 395 | return -ENOMEM; | |
| 388 | 396 | ||
| @@ -505,7 +513,7 @@ static int pdsc_send_component_table(struct pldmfw *context, | |||
| 505 | 513 | component->version_string, component->index, | |
| 506 | 514 | component->component_size, transfer_flag); | |
| 507 | 515 | ||
| 508 | - | component_priv = kzalloc_obj(*component_priv, GFP_KERNEL); | |
| 516 | + | component_priv = kzalloc_obj(*component_priv); | |
| 509 | 517 | if (!component_priv) | |
| 510 | 518 | return -ENOMEM; | |
| 511 | 519 | ||
| @@ -710,7 +718,7 @@ static int pdsc_flash_component_chunk(struct pdsc *pdsc, struct device *dev, | |||
| 710 | 718 | u8 *component_data; | |
| 711 | 719 | int err; | |
| 712 | 720 | ||
| 713 | - | deferred = kmalloc_obj(*deferred, GFP_KERNEL); | |
| 721 | + | deferred = kmalloc_obj(*deferred); | |
| 714 | 722 | if (!deferred) | |
| 715 | 723 | return -ENOMEM; | |
| 716 | 724 | ||
modified drivers/net/ethernet/amd/pds_core/main.c
| @@ -513,8 +513,12 @@ static void pdsc_reset_prepare(struct pci_dev *pdev) | |||
| 513 | 513 | pdsc_auxbus_dev_del(pdsc, pdsc, &pdsc->padev); | |
| 514 | 514 | } | |
| 515 | 515 | ||
| 516 | - | pdsc_unmap_bars(pdsc); | |
| 517 | - | pci_release_regions(pdev); | |
| 516 | + | if (!pdev->is_virtfn) { | |
| 517 | + | mutex_lock(&pdsc->devcmd_lock); | |
| 518 | + | pdsc_unmap_bars(pdsc); | |
| 519 | + | mutex_unlock(&pdsc->devcmd_lock); | |
| 520 | + | pci_release_regions(pdev); | |
| 521 | + | } | |
| 518 | 522 | if (pci_is_enabled(pdev)) | |
| 519 | 523 | pci_disable_device(pdev); | |
| 520 | 524 | pdsc_deferred_dma_free(pdsc); | |
| @@ -543,7 +547,9 @@ static void pdsc_reset_done(struct pci_dev *pdev) | |||
| 543 | 547 | return; | |
| 544 | 548 | } | |
| 545 | 549 | ||
| 550 | + | mutex_lock(&pdsc->devcmd_lock); | |
| 546 | 551 | err = pdsc_map_bars(pdsc); | |
| 552 | + | mutex_unlock(&pdsc->devcmd_lock); | |
| 547 | 553 | if (err) | |
| 548 | 554 | return; | |
| 549 | 555 | } | |
modified drivers/net/ethernet/amd/xgbe/xgbe-dev.c
| @@ -3400,7 +3400,7 @@ static void xgbe_enable_rx(struct xgbe_prv_data *pdata) | |||
| 3400 | 3400 | XGMAC_IOWRITE(pdata, MAC_RQC0R, reg_val); | |
| 3401 | 3401 | ||
| 3402 | 3402 | /* Enable MAC Rx */ | |
| 3403 | - | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 1); | |
| 3403 | + | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 0); | |
| 3404 | 3404 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, CST, 1); | |
| 3405 | 3405 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ACS, 1); | |
| 3406 | 3406 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, RE, 1); | |
| @@ -3411,7 +3411,6 @@ static void xgbe_disable_rx(struct xgbe_prv_data *pdata) | |||
| 3411 | 3411 | unsigned int i; | |
| 3412 | 3412 | ||
| 3413 | 3413 | /* Disable MAC Rx */ | |
| 3414 | - | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 0); | |
| 3415 | 3414 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, CST, 0); | |
| 3416 | 3415 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ACS, 0); | |
| 3417 | 3416 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, RE, 0); | |
modified drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
| @@ -148,8 +148,9 @@ static int tx_spb_ring_full(struct bcmasp_intf *intf, int cnt) | |||
| 148 | 148 | int next_index, i; | |
| 149 | 149 | ||
| 150 | 150 | /* Check if we have enough room for cnt descriptors */ | |
| 151 | + | next_index = intf->tx_spb_index; | |
| 151 | 152 | for (i = 0; i < cnt; i++) { | |
| 152 | - | next_index = incr_ring(intf->tx_spb_index, DESC_RING_COUNT); | |
| 153 | + | next_index = incr_ring(next_index, DESC_RING_COUNT); | |
| 153 | 154 | if (next_index == intf->tx_spb_clean_index) | |
| 154 | 155 | return 1; | |
| 155 | 156 | } | |
| @@ -301,6 +302,7 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 301 | 302 | txcb->bytes_sent = total_bytes; | |
| 302 | 303 | dma_unmap_addr_set(txcb, dma_addr, mapping); | |
| 303 | 304 | dma_unmap_len_set(txcb, dma_len, size); | |
| 305 | + | txcb->last = false; | |
| 304 | 306 | if (!i) { | |
| 305 | 307 | desc->flags |= DESC_SOF; | |
| 306 | 308 | if (csum_hw) | |
modified drivers/net/ethernet/broadcom/bnxt/bnxt.c
| @@ -462,6 +462,16 @@ u16 bnxt_xmit_get_cfa_action(struct sk_buff *skb) | |||
| 462 | 462 | static void bnxt_txr_db_kick(struct bnxt *bp, struct bnxt_tx_ring_info *txr, | |
| 463 | 463 | u16 prod) | |
| 464 | 464 | { | |
| 465 | + | /* If the most recent BD has its completion suppressed, unset the bit | |
| 466 | + | * so that a completion is generated, otherwise nothing is left to | |
| 467 | + | * clean the ring and wake the queue. | |
| 468 | + | */ | |
| 469 | + | if (txr->kick_txbd0) { | |
| 470 | + | txr->kick_txbd0->tx_bd_len_flags_type &= | |
| 471 | + | cpu_to_le32(~TX_BD_FLAGS_NO_CMPL); | |
| 472 | + | txr->kick_txbd0 = NULL; | |
| 473 | + | } | |
| 474 | + | ||
| 465 | 475 | /* Sync BD data before updating doorbell */ | |
| 466 | 476 | wmb(); | |
| 467 | 477 | bnxt_db_write(bp, &txr->tx_db, prod); | |
| @@ -485,7 +495,6 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 485 | 495 | struct bnxt_sw_tx_bd *tx_buf; | |
| 486 | 496 | __le32 lflags = 0; | |
| 487 | 497 | skb_frag_t *frag; | |
| 488 | - | netdev_tx_t ret; | |
| 489 | 498 | ||
| 490 | 499 | i = skb_get_queue_mapping(skb); | |
| 491 | 500 | if (unlikely(i >= bp->tx_nr_rings)) { | |
| @@ -509,11 +518,22 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 509 | 518 | if (skb_is_gso(skb) && | |
| 510 | 519 | (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) && | |
| 511 | 520 | !(bp->flags & BNXT_FLAG_UDP_GSO_CAP)) { | |
| 512 | - | ret = bnxt_sw_udp_gso_xmit(bp, txr, txq, skb); | |
| 513 | - | if (txr->kick_pending) | |
| 521 | + | int rc = bnxt_sw_udp_gso_xmit(bp, txr, txq, skb); | |
| 522 | + | ||
| 523 | + | /* if SW USO queued a packet, the doorbell will be written | |
| 524 | + | * below and there is no reason to track the last BD with | |
| 525 | + | * suppressed completions | |
| 526 | + | */ | |
| 527 | + | if (rc > 0) | |
| 528 | + | txr->kick_txbd0 = NULL; | |
| 529 | + | ||
| 530 | + | /* if a packet was queued by SW USO or a doorbell was pending | |
| 531 | + | * from a previous xmit that was deferred, write the doorbell. | |
| 532 | + | */ | |
| 533 | + | if (rc > 0 || txr->kick_pending) | |
| 514 | 534 | bnxt_txr_db_kick(bp, txr, txr->tx_prod); | |
| 515 | 535 | ||
| 516 | - | return ret; | |
| 536 | + | return rc < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK; | |
| 517 | 537 | } | |
| 518 | 538 | ||
| 519 | 539 | free_size = bnxt_tx_avail(bp, txr); | |
| @@ -751,23 +771,23 @@ normal_tx: | |||
| 751 | 771 | prod = NEXT_TX(prod); | |
| 752 | 772 | WRITE_ONCE(txr->tx_prod, prod); | |
| 753 | 773 | ||
| 774 | + | txr->kick_txbd0 = NULL; | |
| 754 | 775 | if (!netdev_xmit_more() || netif_xmit_stopped(txq)) { | |
| 755 | 776 | bnxt_txr_db_kick(bp, txr, prod); | |
| 756 | 777 | } else { | |
| 757 | - | if (free_size >= bp->tx_wake_thresh) | |
| 778 | + | if (free_size >= bp->tx_wake_thresh) { | |
| 758 | 779 | txbd0->tx_bd_len_flags_type |= | |
| 759 | 780 | cpu_to_le32(TX_BD_FLAGS_NO_CMPL); | |
| 781 | + | txr->kick_txbd0 = txbd0; | |
| 782 | + | } | |
| 760 | 783 | txr->kick_pending = 1; | |
| 761 | 784 | } | |
| 762 | 785 | ||
| 763 | 786 | tx_done: | |
| 764 | 787 | ||
| 765 | 788 | if (unlikely(bnxt_tx_avail(bp, txr) <= MAX_SKB_FRAGS + 1)) { | |
| 766 | - | if (netdev_xmit_more() && !tx_buf->is_push) { | |
| 767 | - | txbd0->tx_bd_len_flags_type &= | |
| 768 | - | cpu_to_le32(~TX_BD_FLAGS_NO_CMPL); | |
| 789 | + | if (txr->kick_pending) | |
| 769 | 790 | bnxt_txr_db_kick(bp, txr, prod); | |
| 770 | - | } | |
| 771 | 791 | ||
| 772 | 792 | netif_txq_try_stop(txq, bnxt_tx_avail(bp, txr), | |
| 773 | 793 | bp->tx_wake_thresh); | |
| @@ -1514,14 +1534,16 @@ static int bnxt_discard_rx(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, | |||
| 1514 | 1534 | return 0; | |
| 1515 | 1535 | } | |
| 1516 | 1536 | ||
| 1517 | - | static u16 bnxt_alloc_agg_idx(struct bnxt_rx_ring_info *rxr, u16 agg_id) | |
| 1537 | + | static u16 bnxt_alloc_agg_idx(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, | |
| 1538 | + | u16 agg_id) | |
| 1518 | 1539 | { | |
| 1519 | 1540 | struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; | |
| 1520 | - | u16 idx = agg_id & MAX_TPA_P5_MASK; | |
| 1541 | + | u16 idx = agg_id & (bp->max_tpa_roundup_size - 1); | |
| 1521 | 1542 | ||
| 1522 | 1543 | if (test_bit(idx, map->agg_idx_bmap)) { | |
| 1523 | - | idx = find_first_zero_bit(map->agg_idx_bmap, MAX_TPA_P5); | |
| 1524 | - | if (idx >= MAX_TPA_P5) | |
| 1544 | + | idx = find_first_zero_bit(map->agg_idx_bmap, | |
| 1545 | + | bp->max_tpa_roundup_size); | |
| 1546 | + | if (idx >= bp->max_tpa_roundup_size) | |
| 1525 | 1547 | return INVALID_HW_RING_ID; | |
| 1526 | 1548 | } | |
| 1527 | 1549 | __set_bit(idx, map->agg_idx_bmap); | |
| @@ -1586,7 +1608,7 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, | |||
| 1586 | 1608 | ||
| 1587 | 1609 | if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { | |
| 1588 | 1610 | agg_id = TPA_START_AGG_ID_P5(tpa_start); | |
| 1589 | - | agg_id = bnxt_alloc_agg_idx(rxr, agg_id); | |
| 1611 | + | agg_id = bnxt_alloc_agg_idx(bp, rxr, agg_id); | |
| 1590 | 1612 | if (unlikely(agg_id == INVALID_HW_RING_ID)) { | |
| 1591 | 1613 | netdev_warn(bp->dev, "Unable to allocate agg ID for ring %d, agg 0x%x\n", | |
| 1592 | 1614 | rxr->bnapi->index, | |
| @@ -3584,7 +3606,7 @@ static void bnxt_free_one_tpa_info_data(struct bnxt *bp, | |||
| 3584 | 3606 | { | |
| 3585 | 3607 | int i; | |
| 3586 | 3608 | ||
| 3587 | - | for (i = 0; i < bp->max_tpa; i++) { | |
| 3609 | + | for (i = 0; i < bp->max_tpa_roundup_size; i++) { | |
| 3588 | 3610 | struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[i]; | |
| 3589 | 3611 | u8 *data = tpa_info->data; | |
| 3590 | 3612 | ||
| @@ -3781,7 +3803,7 @@ static void bnxt_free_one_tpa_info(struct bnxt *bp, | |||
| 3781 | 3803 | kfree(rxr->rx_tpa_idx_map); | |
| 3782 | 3804 | rxr->rx_tpa_idx_map = NULL; | |
| 3783 | 3805 | if (rxr->rx_tpa) { | |
| 3784 | - | for (i = 0; i < bp->max_tpa; i++) { | |
| 3806 | + | for (i = 0; i < bp->max_tpa_roundup_size; i++) { | |
| 3785 | 3807 | kfree(rxr->rx_tpa[i].agg_arr); | |
| 3786 | 3808 | rxr->rx_tpa[i].agg_arr = NULL; | |
| 3787 | 3809 | } | |
| @@ -3807,13 +3829,14 @@ static int bnxt_alloc_one_tpa_info(struct bnxt *bp, | |||
| 3807 | 3829 | struct rx_agg_cmp *agg; | |
| 3808 | 3830 | int i; | |
| 3809 | 3831 | ||
| 3810 | - | rxr->rx_tpa = kzalloc_objs(struct bnxt_tpa_info, bp->max_tpa); | |
| 3832 | + | rxr->rx_tpa = kzalloc_objs(struct bnxt_tpa_info, | |
| 3833 | + | bp->max_tpa_roundup_size); | |
| 3811 | 3834 | if (!rxr->rx_tpa) | |
| 3812 | 3835 | return -ENOMEM; | |
| 3813 | 3836 | ||
| 3814 | 3837 | if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) | |
| 3815 | 3838 | return 0; | |
| 3816 | - | for (i = 0; i < bp->max_tpa; i++) { | |
| 3839 | + | for (i = 0; i < bp->max_tpa_roundup_size; i++) { | |
| 3817 | 3840 | agg = kzalloc_objs(*agg, MAX_SKB_FRAGS); | |
| 3818 | 3841 | if (!agg) | |
| 3819 | 3842 | return -ENOMEM; | |
| @@ -3832,6 +3855,9 @@ static int bnxt_alloc_tpa_info(struct bnxt *bp) | |||
| 3832 | 3855 | ||
| 3833 | 3856 | bp->max_tpa = MAX_TPA; | |
| 3834 | 3857 | if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { | |
| 3858 | + | /* TPA is not supported at all, so there is nothing to | |
| 3859 | + | * allocate. | |
| 3860 | + | */ | |
| 3835 | 3861 | if (!bp->max_tpa_v2) | |
| 3836 | 3862 | return 0; | |
| 3837 | 3863 | bp->max_tpa = min_t(u16, bp->max_tpa_v2, MAX_TPA_P5); | |
| @@ -3839,6 +3865,7 @@ static int bnxt_alloc_tpa_info(struct bnxt *bp) | |||
| 3839 | 3865 | if (bp->max_tpa <= 32 && BNXT_CHIP_P5(bp) && !BNXT_NPAR(bp)) | |
| 3840 | 3866 | bp->max_tpa = MAX_TPA_P5; | |
| 3841 | 3867 | } | |
| 3868 | + | bp->max_tpa_roundup_size = roundup_pow_of_two(bp->max_tpa); | |
| 3842 | 3869 | ||
| 3843 | 3870 | for (i = 0; i < bp->rx_nr_rings; i++) { | |
| 3844 | 3871 | struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; | |
| @@ -4551,7 +4578,7 @@ static int bnxt_alloc_one_tpa_info_data(struct bnxt *bp, | |||
| 4551 | 4578 | u8 *data; | |
| 4552 | 4579 | int i; | |
| 4553 | 4580 | ||
| 4554 | - | for (i = 0; i < bp->max_tpa; i++) { | |
| 4581 | + | for (i = 0; i < bp->max_tpa_roundup_size; i++) { | |
| 4555 | 4582 | data = __bnxt_alloc_rx_frag(bp, &mapping, rxr, | |
| 4556 | 4583 | GFP_KERNEL); | |
| 4557 | 4584 | if (!data) | |
| @@ -5006,7 +5033,8 @@ void bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode) | |||
| 5006 | 5033 | bnxt_get_max_rings(bp, &rx, &tx, true); | |
| 5007 | 5034 | if (rx > 1) { | |
| 5008 | 5035 | bp->flags &= ~BNXT_FLAG_NO_AGG_RINGS; | |
| 5009 | - | bp->dev->hw_features |= NETIF_F_LRO; | |
| 5036 | + | if (BNXT_SUPPORTS_TPA(bp)) | |
| 5037 | + | bp->dev->hw_features |= NETIF_F_LRO; | |
| 5010 | 5038 | } | |
| 5011 | 5039 | } | |
| 5012 | 5040 | ||
| @@ -5427,6 +5455,8 @@ static void bnxt_clear_ring_indices(struct bnxt *bp) | |||
| 5427 | 5455 | txr->tx_prod = 0; | |
| 5428 | 5456 | txr->tx_cons = 0; | |
| 5429 | 5457 | txr->tx_hw_cons = 0; | |
| 5458 | + | txr->kick_pending = 0; | |
| 5459 | + | txr->kick_txbd0 = NULL; | |
| 5430 | 5460 | } | |
| 5431 | 5461 | ||
| 5432 | 5462 | rxr = bnapi->rx_ring; | |
| @@ -11340,8 +11370,13 @@ static int bnxt_shutdown_nic(struct bnxt *bp, bool irq_re_init) | |||
| 11340 | 11370 | ||
| 11341 | 11371 | static int bnxt_init_nic(struct bnxt *bp, bool irq_re_init) | |
| 11342 | 11372 | { | |
| 11373 | + | int rc; | |
| 11374 | + | ||
| 11343 | 11375 | bnxt_init_cp_rings(bp); | |
| 11344 | - | bnxt_init_rx_rings(bp); | |
| 11376 | + | rc = bnxt_init_rx_rings(bp); | |
| 11377 | + | if (rc) | |
| 11378 | + | return rc; | |
| 11379 | + | ||
| 11345 | 11380 | bnxt_init_tx_rings(bp); | |
| 11346 | 11381 | bnxt_init_ring_grps(bp, irq_re_init); | |
| 11347 | 11382 | bnxt_init_vnics(bp); | |
| @@ -11772,6 +11807,8 @@ static int bnxt_tx_queue_start(struct bnxt *bp, int idx) | |||
| 11772 | 11807 | txr->tx_prod = 0; | |
| 11773 | 11808 | txr->tx_cons = 0; | |
| 11774 | 11809 | txr->tx_hw_cons = 0; | |
| 11810 | + | txr->kick_pending = 0; | |
| 11811 | + | txr->kick_txbd0 = NULL; | |
| 11775 | 11812 | start_tx: | |
| 11776 | 11813 | WRITE_ONCE(txr->dev_state, 0); | |
| 11777 | 11814 | synchronize_net(); | |
| @@ -14603,7 +14640,14 @@ static void bnxt_rx_ring_reset(struct bnxt *bp) | |||
| 14603 | 14640 | rxr->rx_sw_agg_prod = 0; | |
| 14604 | 14641 | rxr->rx_next_cons = 0; | |
| 14605 | 14642 | rxr->bnapi->in_reset = false; | |
| 14606 | - | bnxt_alloc_one_rx_ring(bp, i); | |
| 14643 | + | rc = bnxt_alloc_one_rx_ring(bp, i); | |
| 14644 | + | if (rc) { | |
| 14645 | + | netdev_warn(bp->dev, "RX ring reset failed to allocate buffers, rc = %d, falling back to global reset\n", | |
| 14646 | + | rc); | |
| 14647 | + | bnxt_reset_task(bp, true); | |
| 14648 | + | bnxt_rtnl_unlock_sp(bp); | |
| 14649 | + | return; | |
| 14650 | + | } | |
| 14607 | 14651 | cpr = &rxr->bnapi->cp_ring; | |
| 14608 | 14652 | cpr->sw_stats->rx.rx_resets++; | |
| 14609 | 14653 | if (bp->flags & BNXT_FLAG_AGG_RINGS) | |
| @@ -16332,6 +16376,8 @@ static int bnxt_queue_mem_alloc(struct net_device *dev, | |||
| 16332 | 16376 | clone->need_head_pool = false; | |
| 16333 | 16377 | clone->rx_page_size = qcfg->rx_page_size; | |
| 16334 | 16378 | clone->rx_agg_bmap = NULL; | |
| 16379 | + | clone->rx_tpa = NULL; | |
| 16380 | + | clone->rx_tpa_idx_map = NULL; | |
| 16335 | 16381 | ||
| 16336 | 16382 | rc = bnxt_alloc_rx_page_pool(bp, clone, rxr->page_pool->p.nid); | |
| 16337 | 16383 | if (rc) | |
| @@ -16375,11 +16421,16 @@ static int bnxt_queue_mem_alloc(struct net_device *dev, | |||
| 16375 | 16421 | bnxt_alloc_one_rx_ring_skb(bp, clone, idx); | |
| 16376 | 16422 | if (bp->flags & BNXT_FLAG_AGG_RINGS) | |
| 16377 | 16423 | bnxt_alloc_one_rx_ring_netmem(bp, clone, idx); | |
| 16378 | - | if (bp->flags & BNXT_FLAG_TPA) | |
| 16379 | - | bnxt_alloc_one_tpa_info_data(bp, clone); | |
| 16424 | + | if (bp->flags & BNXT_FLAG_TPA) { | |
| 16425 | + | rc = bnxt_alloc_one_tpa_info_data(bp, clone); | |
| 16426 | + | if (rc) | |
| 16427 | + | goto err_free_rx_ring_skbs; | |
| 16428 | + | } | |
| 16380 | 16429 | ||
| 16381 | 16430 | return 0; | |
| 16382 | 16431 | ||
| 16432 | + | err_free_rx_ring_skbs: | |
| 16433 | + | bnxt_free_one_rx_ring_skbs(bp, clone); | |
| 16383 | 16434 | err_free_tpa_info: | |
| 16384 | 16435 | bnxt_free_one_tpa_info(bp, clone); | |
| 16385 | 16436 | err_free_rx_agg_ring: | |
modified drivers/net/ethernet/broadcom/bnxt/bnxt.h
| @@ -789,7 +789,6 @@ struct nqe_cn { | |||
| 789 | 789 | ||
| 790 | 790 | #define MAX_TPA 64 | |
| 791 | 791 | #define MAX_TPA_P5 256 | |
| 792 | - | #define MAX_TPA_P5_MASK (MAX_TPA_P5 - 1) | |
| 793 | 792 | #define MAX_TPA_SEGS_P5 0x3f | |
| 794 | 793 | ||
| 795 | 794 | #if (BNXT_PAGE_SHIFT == 16) | |
| @@ -993,6 +992,7 @@ struct bnxt_tx_ring_info { | |||
| 993 | 992 | u16 txq_index; | |
| 994 | 993 | u8 tx_napi_idx; | |
| 995 | 994 | u8 kick_pending; | |
| 995 | + | struct tx_bd *kick_txbd0; | |
| 996 | 996 | struct bnxt_db_info tx_db; | |
| 997 | 997 | ||
| 998 | 998 | struct tx_bd *tx_desc_ring[MAX_TX_PAGES]; | |
| @@ -2380,6 +2380,7 @@ struct bnxt { | |||
| 2380 | 2380 | ||
| 2381 | 2381 | u16 max_tpa_v2; | |
| 2382 | 2382 | u16 max_tpa; | |
| 2383 | + | u16 max_tpa_roundup_size; | |
| 2383 | 2384 | u32 rx_buf_size; | |
| 2384 | 2385 | u32 rx_buf_use_size; /* useable size */ | |
| 2385 | 2386 | u16 rx_offset; | |
modified drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c
| @@ -31,10 +31,14 @@ static u32 bnxt_sw_gso_lhint(unsigned int len) | |||
| 31 | 31 | return TX_BD_FLAGS_LHINT_2048_AND_LARGER; | |
| 32 | 32 | } | |
| 33 | 33 | ||
| 34 | - | netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp, | |
| 35 | - | struct bnxt_tx_ring_info *txr, | |
| 36 | - | struct netdev_queue *txq, | |
| 37 | - | struct sk_buff *skb) | |
| 34 | + | /* Transmit an skb requiring software UDP segmentation. | |
| 35 | + | * | |
| 36 | + | * Returns 1 if the skb was queued and new BDs were produced, 0 if the skb | |
| 37 | + | * was dropped, or -1 if the ring is full and the skb should be retried. | |
| 38 | + | * The caller owns the doorbell for all three cases. | |
| 39 | + | */ | |
| 40 | + | int bnxt_sw_udp_gso_xmit(struct bnxt *bp, struct bnxt_tx_ring_info *txr, | |
| 41 | + | struct netdev_queue *txq, struct sk_buff *skb) | |
| 38 | 42 | { | |
| 39 | 43 | unsigned int last_unmap_len __maybe_unused = 0; | |
| 40 | 44 | dma_addr_t last_unmap_addr __maybe_unused = 0; | |
| @@ -69,7 +73,7 @@ netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp, | |||
| 69 | 73 | if (unlikely(bnxt_tx_avail(bp, txr) < bds_needed)) { | |
| 70 | 74 | netif_txq_try_stop(txq, bnxt_tx_avail(bp, txr), | |
| 71 | 75 | bp->tx_wake_thresh); | |
| 72 | - | return NETDEV_TX_BUSY; | |
| 76 | + | return -1; | |
| 73 | 77 | } | |
| 74 | 78 | ||
| 75 | 79 | /* BD backpressure alone cannot prevent overwriting in-flight | |
| @@ -77,7 +81,7 @@ netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp, | |||
| 77 | 81 | */ | |
| 78 | 82 | if (!netif_txq_maybe_stop(txq, bnxt_inline_avail(txr), | |
| 79 | 83 | num_segs, num_segs)) | |
| 80 | - | return NETDEV_TX_BUSY; | |
| 84 | + | return -1; | |
| 81 | 85 | ||
| 82 | 86 | if (unlikely(tso_dma_map_init(&map, &pdev->dev, skb, hdr_len))) | |
| 83 | 87 | goto drop; | |
| @@ -223,16 +227,15 @@ netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp, | |||
| 223 | 227 | netdev_tx_sent_queue(txq, skb->len); | |
| 224 | 228 | ||
| 225 | 229 | WRITE_ONCE(txr->tx_prod, prod); | |
| 226 | - | txr->kick_pending = 1; | |
| 227 | 230 | ||
| 228 | 231 | if (unlikely(bnxt_tx_avail(bp, txr) <= bp->tx_wake_thresh)) | |
| 229 | 232 | netif_txq_try_stop(txq, bnxt_tx_avail(bp, txr), | |
| 230 | 233 | bp->tx_wake_thresh); | |
| 231 | 234 | ||
| 232 | - | return NETDEV_TX_OK; | |
| 235 | + | return 1; | |
| 233 | 236 | ||
| 234 | 237 | drop: | |
| 235 | 238 | dev_kfree_skb_any(skb); | |
| 236 | 239 | dev_core_stats_tx_dropped_inc(bp->dev); | |
| 237 | - | return NETDEV_TX_OK; | |
| 240 | + | return 0; | |
| 238 | 241 | } | |
modified drivers/net/ethernet/broadcom/bnxt/bnxt_gso.h
| @@ -38,9 +38,7 @@ static inline int bnxt_min_tx_desc_cnt(struct bnxt *bp, | |||
| 38 | 38 | return BNXT_MIN_TX_DESC_CNT; | |
| 39 | 39 | } | |
| 40 | 40 | ||
| 41 | - | netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp, | |
| 42 | - | struct bnxt_tx_ring_info *txr, | |
| 43 | - | struct netdev_queue *txq, | |
| 44 | - | struct sk_buff *skb); | |
| 41 | + | int bnxt_sw_udp_gso_xmit(struct bnxt *bp, struct bnxt_tx_ring_info *txr, | |
| 42 | + | struct netdev_queue *txq, struct sk_buff *skb); | |
| 45 | 43 | ||
| 46 | 44 | #endif | |
modified drivers/net/ethernet/cadence/macb.h
| @@ -968,6 +968,8 @@ struct macb_dma_desc_ptp { | |||
| 968 | 968 | * of the frame | |
| 969 | 969 | * @mapping: DMA address of the skb's fragment buffer | |
| 970 | 970 | * @size: size of the DMA mapped buffer | |
| 971 | + | * @fcs_len: FCS bytes appended in software, 0 or ETH_FCS_LEN, only | |
| 972 | + | * set for the last buffer of the frame | |
| 971 | 973 | * @mapped_as_page: true when buffer was mapped with skb_frag_dma_map(), | |
| 972 | 974 | * false when buffer was mapped with dma_map_single() | |
| 973 | 975 | */ | |
| @@ -975,6 +977,7 @@ struct macb_tx_skb { | |||
| 975 | 977 | struct sk_buff *skb; | |
| 976 | 978 | dma_addr_t mapping; | |
| 977 | 979 | size_t size; | |
| 980 | + | u8 fcs_len; | |
| 978 | 981 | bool mapped_as_page; | |
| 979 | 982 | }; | |
| 980 | 983 | ||
modified drivers/net/ethernet/cadence/macb_main.c
| @@ -1164,6 +1164,8 @@ static int macb_mii_init(struct macb *bp) | |||
| 1164 | 1164 | if (err) | |
| 1165 | 1165 | goto err_out_unregister_bus; | |
| 1166 | 1166 | ||
| 1167 | + | of_node_put(mdio_np); | |
| 1168 | + | ||
| 1167 | 1169 | return 0; | |
| 1168 | 1170 | ||
| 1169 | 1171 | err_out_unregister_bus: | |
| @@ -1322,8 +1324,8 @@ static void macb_tx_error_task(struct work_struct *work) | |||
| 1322 | 1324 | bp->netdev->stats.tx_packets++; | |
| 1323 | 1325 | queue->stats.tx_packets++; | |
| 1324 | 1326 | packets++; | |
| 1325 | - | bp->netdev->stats.tx_bytes += skb->len; | |
| 1326 | - | queue->stats.tx_bytes += skb->len; | |
| 1327 | + | bp->netdev->stats.tx_bytes += skb->len - tx_skb->fcs_len; | |
| 1328 | + | queue->stats.tx_bytes += skb->len - tx_skb->fcs_len; | |
| 1327 | 1329 | bytes += skb->len; | |
| 1328 | 1330 | } | |
| 1329 | 1331 | } else { | |
| @@ -1450,8 +1452,8 @@ static int macb_tx_complete(struct macb_queue *queue, int budget) | |||
| 1450 | 1452 | skb->data); | |
| 1451 | 1453 | bp->netdev->stats.tx_packets++; | |
| 1452 | 1454 | queue->stats.tx_packets++; | |
| 1453 | - | bp->netdev->stats.tx_bytes += skb->len; | |
| 1454 | - | queue->stats.tx_bytes += skb->len; | |
| 1455 | + | bp->netdev->stats.tx_bytes += skb->len - tx_skb->fcs_len; | |
| 1456 | + | queue->stats.tx_bytes += skb->len - tx_skb->fcs_len; | |
| 1455 | 1457 | packets++; | |
| 1456 | 1458 | bytes += skb->len; | |
| 1457 | 1459 | } | |
| @@ -2199,7 +2201,8 @@ static void macb_poll_controller(struct net_device *netdev) | |||
| 2199 | 2201 | static unsigned int macb_tx_map(struct macb *bp, | |
| 2200 | 2202 | struct macb_queue *queue, | |
| 2201 | 2203 | struct sk_buff *skb, | |
| 2202 | - | unsigned int hdrlen) | |
| 2204 | + | unsigned int hdrlen, | |
| 2205 | + | u8 fcs_len) | |
| 2203 | 2206 | { | |
| 2204 | 2207 | unsigned int f, nr_frags = skb_shinfo(skb)->nr_frags; | |
| 2205 | 2208 | unsigned int len, i, tx_head = queue->tx_head; | |
| @@ -2284,6 +2287,7 @@ static unsigned int macb_tx_map(struct macb *bp, | |||
| 2284 | 2287 | ||
| 2285 | 2288 | /* This is the last buffer of the frame: save socket buffer */ | |
| 2286 | 2289 | tx_skb->skb = skb; | |
| 2290 | + | tx_skb->fcs_len = fcs_len; | |
| 2287 | 2291 | ||
| 2288 | 2292 | /* Update TX ring: update buffer descriptors in reverse order | |
| 2289 | 2293 | * to avoid race condition | |
| @@ -2417,6 +2421,7 @@ static inline int macb_clear_csum(struct sk_buff *skb) | |||
| 2417 | 2421 | return 0; | |
| 2418 | 2422 | } | |
| 2419 | 2423 | ||
| 2424 | + | /* Returns a negative errno, or the FCS bytes appended (0 or ETH_FCS_LEN). */ | |
| 2420 | 2425 | static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *netdev) | |
| 2421 | 2426 | { | |
| 2422 | 2427 | bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb) || | |
| @@ -2465,7 +2470,7 @@ add_fcs: | |||
| 2465 | 2470 | skb_put_u8(*skb, (fcs >> 16) & 0xff); | |
| 2466 | 2471 | skb_put_u8(*skb, (fcs >> 24) & 0xff); | |
| 2467 | 2472 | ||
| 2468 | - | return 0; | |
| 2473 | + | return ETH_FCS_LEN; | |
| 2469 | 2474 | } | |
| 2470 | 2475 | ||
| 2471 | 2476 | static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |
| @@ -2478,6 +2483,7 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2478 | 2483 | netdev_tx_t ret = NETDEV_TX_OK; | |
| 2479 | 2484 | unsigned int hdrlen; | |
| 2480 | 2485 | unsigned long flags; | |
| 2486 | + | int fcs_len; | |
| 2481 | 2487 | bool is_lso; | |
| 2482 | 2488 | ||
| 2483 | 2489 | if (macb_clear_csum(skb)) { | |
| @@ -2485,7 +2491,8 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2485 | 2491 | return ret; | |
| 2486 | 2492 | } | |
| 2487 | 2493 | ||
| 2488 | - | if (macb_pad_and_fcs(&skb, netdev)) { | |
| 2494 | + | fcs_len = macb_pad_and_fcs(&skb, netdev); | |
| 2495 | + | if (fcs_len < 0) { | |
| 2489 | 2496 | dev_kfree_skb_any(skb); | |
| 2490 | 2497 | return ret; | |
| 2491 | 2498 | } | |
| @@ -2548,7 +2555,7 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2548 | 2555 | } | |
| 2549 | 2556 | ||
| 2550 | 2557 | /* Map socket buffer for DMA transfer */ | |
| 2551 | - | if (macb_tx_map(bp, queue, skb, hdrlen)) { | |
| 2558 | + | if (macb_tx_map(bp, queue, skb, hdrlen, fcs_len)) { | |
| 2552 | 2559 | dev_kfree_skb_any(skb); | |
| 2553 | 2560 | goto unlock; | |
| 2554 | 2561 | } | |
| @@ -4295,9 +4302,9 @@ static int macb_taprio_setup_replace(struct net_device *netdev, | |||
| 4295 | 4302 | u64 total_on_time = 0, start_time_sec = 0, start_time = conf->base_time; | |
| 4296 | 4303 | u32 configured_queues = 0, speed = 0, start_time_nsec; | |
| 4297 | 4304 | struct macb_queue_enst_config *enst_queue; | |
| 4298 | - | struct tc_taprio_sched_entry *entry; | |
| 4305 | + | struct ethtool_link_ksettings kset = {}; | |
| 4299 | 4306 | struct macb *bp = netdev_priv(netdev); | |
| 4300 | - | struct ethtool_link_ksettings kset; | |
| 4307 | + | struct tc_taprio_sched_entry *entry; | |
| 4301 | 4308 | struct macb_queue *queue; | |
| 4302 | 4309 | u32 queue_mask; | |
| 4303 | 4310 | u8 queue_id; | |
| @@ -4324,12 +4331,12 @@ static int macb_taprio_setup_replace(struct net_device *netdev, | |||
| 4324 | 4331 | } | |
| 4325 | 4332 | ||
| 4326 | 4333 | speed = kset.base.speed; | |
| 4327 | - | if (unlikely(speed <= 0)) { | |
| 4328 | - | netdev_err(netdev, "Invalid speed: %d\n", speed); | |
| 4334 | + | if (unlikely(speed == SPEED_UNKNOWN || !speed)) { | |
| 4335 | + | netdev_err(netdev, "Invalid speed %d, link-down?\n", speed); | |
| 4329 | 4336 | return -EINVAL; | |
| 4330 | 4337 | } | |
| 4331 | 4338 | ||
| 4332 | - | enst_queue = kcalloc(conf->num_entries, sizeof(*enst_queue), GFP_KERNEL); | |
| 4339 | + | enst_queue = kzalloc_objs(*enst_queue, conf->num_entries); | |
| 4333 | 4340 | if (unlikely(!enst_queue)) | |
| 4334 | 4341 | return -ENOMEM; | |
| 4335 | 4342 | ||
| @@ -5876,6 +5883,7 @@ static int macb_probe(struct platform_device *pdev) | |||
| 5876 | 5883 | } | |
| 5877 | 5884 | spin_lock_init(&bp->lock); | |
| 5878 | 5885 | spin_lock_init(&bp->stats_lock); | |
| 5886 | + | spin_lock_init(&bp->tsu_clk_lock); | |
| 5879 | 5887 | ||
| 5880 | 5888 | /* setup capabilities */ | |
| 5881 | 5889 | macb_configure_caps(bp, macb_config); | |
| @@ -5971,8 +5979,11 @@ err_out_free_tieoff: | |||
| 5971 | 5979 | macb_free_tieoff(bp); | |
| 5972 | 5980 | ||
| 5973 | 5981 | err_out_unregister_mdio: | |
| 5974 | - | mdiobus_unregister(bp->mii_bus); | |
| 5975 | - | mdiobus_free(bp->mii_bus); | |
| 5982 | + | if (bp->mii_bus) { | |
| 5983 | + | mdiobus_unregister(bp->mii_bus); | |
| 5984 | + | mdiobus_free(bp->mii_bus); | |
| 5985 | + | } | |
| 5986 | + | phylink_destroy(bp->phylink); | |
| 5976 | 5987 | ||
| 5977 | 5988 | err_out_phy_exit: | |
| 5978 | 5989 | phy_exit(bp->phy); | |
| @@ -6001,8 +6012,10 @@ static void macb_remove(struct platform_device *pdev) | |||
| 6001 | 6012 | unregister_netdev(netdev); | |
| 6002 | 6013 | macb_free_tieoff(bp); | |
| 6003 | 6014 | phy_exit(bp->phy); | |
| 6004 | - | mdiobus_unregister(bp->mii_bus); | |
| 6005 | - | mdiobus_free(bp->mii_bus); | |
| 6015 | + | if (bp->mii_bus) { | |
| 6016 | + | mdiobus_unregister(bp->mii_bus); | |
| 6017 | + | mdiobus_free(bp->mii_bus); | |
| 6018 | + | } | |
| 6006 | 6019 | ||
| 6007 | 6020 | device_set_wakeup_enable(&bp->pdev->dev, 0); | |
| 6008 | 6021 | cancel_delayed_work_sync(&bp->tx_lpi_work); | |
modified drivers/net/ethernet/cadence/macb_ptp.c
| @@ -334,6 +334,7 @@ void gem_ptp_init(struct net_device *netdev) | |||
| 334 | 334 | bp->tsu_rate = bp->ptp_info->get_tsu_rate(bp); | |
| 335 | 335 | bp->ptp_clock_info.max_adj = bp->ptp_info->get_ptp_max_adj(); | |
| 336 | 336 | gem_ptp_init_timer(bp); | |
| 337 | + | gem_ptp_init_tsu(bp); | |
| 337 | 338 | bp->ptp_clock = ptp_clock_register(&bp->ptp_clock_info, &netdev->dev); | |
| 338 | 339 | if (IS_ERR(bp->ptp_clock)) { | |
| 339 | 340 | pr_err("ptp clock register failed: %ld\n", | |
| @@ -345,10 +346,6 @@ void gem_ptp_init(struct net_device *netdev) | |||
| 345 | 346 | return; | |
| 346 | 347 | } | |
| 347 | 348 | ||
| 348 | - | spin_lock_init(&bp->tsu_clk_lock); | |
| 349 | - | ||
| 350 | - | gem_ptp_init_tsu(bp); | |
| 351 | - | ||
| 352 | 349 | dev_info(&bp->pdev->dev, "%s ptp clock registered.\n", | |
| 353 | 350 | GEM_PTP_TIMER_NAME); | |
| 354 | 351 | } | |
modified drivers/net/ethernet/cisco/enic/enic.h
| @@ -137,6 +137,12 @@ struct enic_port_profile { | |||
| 137 | 137 | u8 mac_addr[ETH_ALEN]; | |
| 138 | 138 | }; | |
| 139 | 139 | ||
| 140 | + | enum enic_vf_link_state { | |
| 141 | + | ENIC_VF_LINK_STATE_UNKNOWN, | |
| 142 | + | ENIC_VF_LINK_STATE_DOWN, | |
| 143 | + | ENIC_VF_LINK_STATE_UP, | |
| 144 | + | }; | |
| 145 | + | ||
| 140 | 146 | /* enic_rfs_fltr_node - rfs filter node in hash table | |
| 141 | 147 | * @@keys: IPv4 5 tuple | |
| 142 | 148 | * @flow_id: flow_id of clsf filter provided by kernel | |
| @@ -312,19 +318,25 @@ struct enic { | |||
| 312 | 318 | unsigned int admin_msg_count; /* current depth of admin_msg_list */ | |
| 313 | 319 | void (*admin_rq_handler)(struct enic *enic, void *buf, | |
| 314 | 320 | unsigned int len); | |
| 321 | + | /* The PF is authoritative for a V2 VF's carrier. Keep the last | |
| 322 | + | * notification across an ordinary netdev close/open and serialize it | |
| 323 | + | * against the open/stop carrier transition. | |
| 324 | + | */ | |
| 325 | + | spinlock_t vf_link_state_lock; | |
| 326 | + | enum enic_vf_link_state vf_link_state; | |
| 327 | + | bool vf_link_running; | |
| 315 | 328 | ||
| 316 | 329 | /* MBOX protocol state — mbox_lock serializes admin WQ sends */ | |
| 317 | 330 | struct mutex mbox_lock; | |
| 318 | 331 | u64 mbox_msg_num; | |
| 319 | - | /* MBOX request-reply state. mbox_expected_reply is written and | |
| 320 | - | * cleared by the process-context request helpers (capability/register/ | |
| 321 | - | * unregister) and only read by the admin_msg_work receive handlers, so | |
| 322 | - | * it is annotated with READ_ONCE()/WRITE_ONCE() rather than locked: | |
| 323 | - | * only one request is in flight at a time (requesters run under RTNL or | |
| 324 | - | * single-threaded probe/remove), so each request is serialized and its | |
| 325 | - | * reply completes mbox_comp before the next request is issued. | |
| 332 | + | /* MBOX request-reply state. Existing request callers allow only one | |
| 333 | + | * request in flight. The state lock arbitrates reply acceptance against | |
| 334 | + | * timeout invalidation, while mbox_comp publishes the accepted result to | |
| 335 | + | * the requester. | |
| 326 | 336 | */ | |
| 327 | 337 | struct completion mbox_comp; | |
| 338 | + | spinlock_t mbox_state_lock; /* protects expected reply state */ | |
| 339 | + | u64 mbox_expected_msg_num; | |
| 328 | 340 | u8 mbox_expected_reply; | |
| 329 | 341 | bool mbox_initialized; | |
| 330 | 342 | ||
modified drivers/net/ethernet/cisco/enic/enic_admin.c
| @@ -137,7 +137,7 @@ static void enic_admin_msg_enqueue(struct enic *enic, void *buf, | |||
| 137 | 137 | { | |
| 138 | 138 | struct enic_admin_msg *msg; | |
| 139 | 139 | ||
| 140 | - | msg = kmalloc(struct_size(msg, data, len), GFP_KERNEL); | |
| 140 | + | msg = kmalloc_flex(*msg, data, len); | |
| 141 | 141 | if (!msg) | |
| 142 | 142 | return; | |
| 143 | 143 | ||
modified drivers/net/ethernet/cisco/enic/enic_main.c
| @@ -1800,6 +1800,8 @@ static int enic_open(struct net_device *netdev) | |||
| 1800 | 1800 | ||
| 1801 | 1801 | enic_notify_timer_start(enic); | |
| 1802 | 1802 | enic_rfs_timer_start(enic); | |
| 1803 | + | if (enic_is_sriov_vf_v2(enic)) | |
| 1804 | + | enic_mbox_vf_link_state_set_running(enic, true); | |
| 1803 | 1805 | ||
| 1804 | 1806 | return 0; | |
| 1805 | 1807 | ||
| @@ -1853,7 +1855,10 @@ static int enic_stop(struct net_device *netdev) | |||
| 1853 | 1855 | for (i = 0; i < enic->rq_count; i++) | |
| 1854 | 1856 | napi_disable(&enic->napi[i]); | |
| 1855 | 1857 | ||
| 1856 | - | netif_carrier_off(netdev); | |
| 1858 | + | if (enic_is_sriov_vf_v2(enic)) | |
| 1859 | + | enic_mbox_vf_link_state_set_running(enic, false); | |
| 1860 | + | else | |
| 1861 | + | netif_carrier_off(netdev); | |
| 1857 | 1862 | if (vnic_dev_get_intr_mode(enic->vdev) == VNIC_DEV_INTR_MODE_MSIX) | |
| 1858 | 1863 | for (i = 0; i < enic->wq_count; i++) | |
| 1859 | 1864 | napi_disable(&enic->napi[enic_cq_wq(enic, i)]); | |
| @@ -2201,9 +2206,10 @@ static void enic_admin_chan_reopen(struct enic *enic) | |||
| 2201 | 2206 | { | |
| 2202 | 2207 | int err; | |
| 2203 | 2208 | ||
| 2204 | - | /* Install the MBOX receive handler and reset the sequence number | |
| 2205 | - | * before opening the channel, so the handler is in place before the | |
| 2206 | - | * admin interrupt is unmasked and no early completion is dropped. | |
| 2209 | + | /* Install the MBOX receive handler and clear pending reply state before | |
| 2210 | + | * opening the channel, so the handler is in place before the admin | |
| 2211 | + | * interrupt is unmasked and no early completion is dropped. Keep the | |
| 2212 | + | * sequence number monotonic across channel generations. | |
| 2207 | 2213 | */ | |
| 2208 | 2214 | enic_mbox_init(enic); | |
| 2209 | 2215 | ||
| @@ -2215,7 +2221,7 @@ static void enic_admin_chan_reopen(struct enic *enic) | |||
| 2215 | 2221 | * registration over a dead channel. | |
| 2216 | 2222 | */ | |
| 2217 | 2223 | if (enic_is_sriov_vf_v2(enic)) | |
| 2218 | - | enic->vf_registered = false; | |
| 2224 | + | WRITE_ONCE(enic->vf_registered, false); | |
| 2219 | 2225 | ||
| 2220 | 2226 | err = enic_admin_channel_open(enic); | |
| 2221 | 2227 | if (err) { | |
| @@ -2271,6 +2277,8 @@ static void enic_reset(struct work_struct *work) | |||
| 2271 | 2277 | enic_admin_channel_close(enic); | |
| 2272 | 2278 | ||
| 2273 | 2279 | enic_stop(enic->netdev); | |
| 2280 | + | if (enic_is_sriov_vf_v2(enic)) | |
| 2281 | + | enic_mbox_vf_link_state_reset(enic); | |
| 2274 | 2282 | ||
| 2275 | 2283 | enic_dev_soft_reset(enic); | |
| 2276 | 2284 | enic_reset_addr_lists(enic); | |
| @@ -2315,6 +2323,8 @@ static void enic_tx_hang_reset(struct work_struct *work) | |||
| 2315 | 2323 | ||
| 2316 | 2324 | enic_dev_hang_notify(enic); | |
| 2317 | 2325 | enic_stop(enic->netdev); | |
| 2326 | + | if (enic_is_sriov_vf_v2(enic)) | |
| 2327 | + | enic_mbox_vf_link_state_reset(enic); | |
| 2318 | 2328 | ||
| 2319 | 2329 | enic_dev_hang_reset(enic); | |
| 2320 | 2330 | enic_reset_addr_lists(enic); | |
| @@ -2858,7 +2868,7 @@ enic_sriov_v2_enable(struct enic *enic, int num_vfs) | |||
| 2858 | 2868 | return -EOPNOTSUPP; | |
| 2859 | 2869 | } | |
| 2860 | 2870 | ||
| 2861 | - | enic->vf_state = kcalloc(num_vfs, sizeof(*enic->vf_state), GFP_KERNEL); | |
| 2871 | + | enic->vf_state = kzalloc_objs(*enic->vf_state, num_vfs); | |
| 2862 | 2872 | if (!enic->vf_state) | |
| 2863 | 2873 | return -ENOMEM; | |
| 2864 | 2874 | ||
| @@ -2946,7 +2956,7 @@ enic_sriov_configure(struct pci_dev *pdev, int num_vfs) | |||
| 2946 | 2956 | if (enic->vf_type == ENIC_VF_TYPE_V2) | |
| 2947 | 2957 | return enic_sriov_v2_enable(enic, num_vfs); | |
| 2948 | 2958 | ||
| 2949 | - | pp = kcalloc(num_vfs, sizeof(*pp), GFP_KERNEL); | |
| 2959 | + | pp = kzalloc_objs(*pp, num_vfs); | |
| 2950 | 2960 | if (!pp) | |
| 2951 | 2961 | return -ENOMEM; | |
| 2952 | 2962 | ||
| @@ -2971,7 +2981,7 @@ enic_sriov_configure(struct pci_dev *pdev, int num_vfs) | |||
| 2971 | 2981 | return 0; | |
| 2972 | 2982 | } | |
| 2973 | 2983 | ||
| 2974 | - | pp = kzalloc_obj(*enic->pp, GFP_KERNEL); | |
| 2984 | + | pp = kzalloc_obj(*enic->pp); | |
| 2975 | 2985 | if (!pp) | |
| 2976 | 2986 | return -ENOMEM; | |
| 2977 | 2987 | ||
| @@ -3015,6 +3025,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 3015 | 3025 | enic = netdev_priv(netdev); | |
| 3016 | 3026 | enic->netdev = netdev; | |
| 3017 | 3027 | enic->pdev = pdev; | |
| 3028 | + | spin_lock_init(&enic->vf_link_state_lock); | |
| 3018 | 3029 | ||
| 3019 | 3030 | /* Setup PCI resources | |
| 3020 | 3031 | */ | |
| @@ -3339,7 +3350,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 3339 | 3350 | ||
| 3340 | 3351 | err_out_admin_close: | |
| 3341 | 3352 | if (enic_is_sriov_vf_v2(enic)) { | |
| 3342 | - | if (enic->vf_registered) { | |
| 3353 | + | if (READ_ONCE(enic->vf_registered)) { | |
| 3343 | 3354 | int unreg_err = enic_mbox_vf_unregister(enic); | |
| 3344 | 3355 | ||
| 3345 | 3356 | if (unreg_err) | |
| @@ -3392,7 +3403,7 @@ static void enic_remove(struct pci_dev *pdev) | |||
| 3392 | 3403 | * touching a netdev that is being torn down. | |
| 3393 | 3404 | */ | |
| 3394 | 3405 | if (enic_is_sriov_vf_v2(enic)) { | |
| 3395 | - | if (enic->vf_registered) { | |
| 3406 | + | if (READ_ONCE(enic->vf_registered)) { | |
| 3396 | 3407 | int unreg_err = enic_mbox_vf_unregister(enic); | |
| 3397 | 3408 | ||
| 3398 | 3409 | if (unreg_err) | |
modified drivers/net/ethernet/cisco/enic/enic_mbox.c
| @@ -18,22 +18,25 @@ | |||
| 18 | 18 | #define ENIC_MBOX_POLL_TIMEOUT_US 5000000 | |
| 19 | 19 | #define ENIC_MBOX_POLL_INTERVAL_US 100 | |
| 20 | 20 | ||
| 21 | - | static void enic_mbox_fill_hdr(struct enic *enic, struct enic_mbox_hdr *hdr, | |
| 22 | - | u8 msg_type, u16 dst_vnic_id, u16 msg_len) | |
| 21 | + | static void enic_mbox_fill_hdr(struct enic_mbox_hdr *hdr, u8 msg_type, | |
| 22 | + | u16 dst_vnic_id, u16 msg_len, u64 msg_num) | |
| 23 | 23 | { | |
| 24 | 24 | memset(hdr, 0, sizeof(*hdr)); | |
| 25 | 25 | hdr->dst_vnic_id = cpu_to_le16(dst_vnic_id); | |
| 26 | 26 | hdr->msg_type = msg_type; | |
| 27 | 27 | hdr->msg_len = cpu_to_le16(msg_len); | |
| 28 | - | hdr->msg_num = cpu_to_le64(++enic->mbox_msg_num); | |
| 28 | + | hdr->msg_num = cpu_to_le64(msg_num); | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | - | int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id, | |
| 32 | - | void *payload, u16 payload_len) | |
| 31 | + | static int enic_mbox_send_msg_id(struct enic *enic, u8 msg_type, | |
| 32 | + | u16 dst_vnic_id, void *payload, | |
| 33 | + | u16 payload_len, u64 msg_num, bool reuse_msg_num, | |
| 34 | + | u8 expected_reply) | |
| 33 | 35 | { | |
| 34 | 36 | size_t total_len = sizeof(struct enic_mbox_hdr) + payload_len; | |
| 35 | 37 | struct vnic_wq *wq = &enic->admin_wq; | |
| 36 | 38 | struct wq_enet_desc *desc; | |
| 39 | + | bool reply_expected = false; | |
| 37 | 40 | unsigned long timeout; | |
| 38 | 41 | dma_addr_t dma_addr; | |
| 39 | 42 | u16 vlan_tag; | |
| @@ -68,7 +71,21 @@ int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id, | |||
| 68 | 71 | goto unlock; | |
| 69 | 72 | } | |
| 70 | 73 | ||
| 71 | - | enic_mbox_fill_hdr(enic, buf, msg_type, dst_vnic_id, total_len); | |
| 74 | + | /* Replies reuse the initiating message number. Requests and | |
| 75 | + | * notifications allocate a new one. | |
| 76 | + | */ | |
| 77 | + | if (!reuse_msg_num) | |
| 78 | + | msg_num = ++enic->mbox_msg_num; | |
| 79 | + | if (expected_reply) { | |
| 80 | + | reinit_completion(&enic->mbox_comp); | |
| 81 | + | spin_lock_bh(&enic->mbox_state_lock); | |
| 82 | + | enic->mbox_expected_reply = expected_reply; | |
| 83 | + | enic->mbox_expected_msg_num = msg_num; | |
| 84 | + | spin_unlock_bh(&enic->mbox_state_lock); | |
| 85 | + | reply_expected = true; | |
| 86 | + | } | |
| 87 | + | ||
| 88 | + | enic_mbox_fill_hdr(buf, msg_type, dst_vnic_id, total_len, msg_num); | |
| 72 | 89 | if (payload_len) { | |
| 73 | 90 | void *dst = buf + sizeof(struct enic_mbox_hdr); | |
| 74 | 91 | ||
| @@ -139,18 +156,66 @@ int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id, | |||
| 139 | 156 | "MBOX send msg_type %u dst %u vlan %u err %d\n", | |
| 140 | 157 | msg_type, dst_vnic_id, vlan_tag, err); | |
| 141 | 158 | unlock: | |
| 159 | + | if (err && reply_expected) { | |
| 160 | + | spin_lock_bh(&enic->mbox_state_lock); | |
| 161 | + | if (enic->mbox_expected_reply == expected_reply && | |
| 162 | + | enic->mbox_expected_msg_num == msg_num) { | |
| 163 | + | enic->mbox_expected_reply = 0; | |
| 164 | + | enic->mbox_expected_msg_num = 0; | |
| 165 | + | } | |
| 166 | + | spin_unlock_bh(&enic->mbox_state_lock); | |
| 167 | + | } | |
| 142 | 168 | mutex_unlock(&enic->mbox_lock); | |
| 143 | 169 | return err; | |
| 144 | 170 | } | |
| 145 | 171 | ||
| 172 | + | int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id, | |
| 173 | + | void *payload, u16 payload_len) | |
| 174 | + | { | |
| 175 | + | return enic_mbox_send_msg_id(enic, msg_type, dst_vnic_id, payload, | |
| 176 | + | payload_len, 0, false, 0); | |
| 177 | + | } | |
| 178 | + | ||
| 179 | + | static int enic_mbox_send_reply(struct enic *enic, u8 msg_type, | |
| 180 | + | u16 dst_vnic_id, void *payload, u16 payload_len, | |
| 181 | + | u64 msg_num) | |
| 182 | + | { | |
| 183 | + | return enic_mbox_send_msg_id(enic, msg_type, dst_vnic_id, payload, | |
| 184 | + | payload_len, msg_num, true, 0); | |
| 185 | + | } | |
| 186 | + | ||
| 187 | + | static int enic_mbox_vf_send_request(struct enic *enic, u8 request_type, | |
| 188 | + | u8 expected_reply, void *payload, | |
| 189 | + | u16 payload_len) | |
| 190 | + | { | |
| 191 | + | return enic_mbox_send_msg_id(enic, request_type, ENIC_MBOX_DST_PF, | |
| 192 | + | payload, payload_len, 0, false, | |
| 193 | + | expected_reply); | |
| 194 | + | } | |
| 195 | + | ||
| 146 | 196 | static int enic_mbox_wait_reply(struct enic *enic, unsigned long timeout_ms) | |
| 147 | 197 | { | |
| 148 | 198 | unsigned long left; | |
| 199 | + | int err = 0; | |
| 149 | 200 | ||
| 150 | 201 | left = wait_for_completion_timeout(&enic->mbox_comp, | |
| 151 | 202 | msecs_to_jiffies(timeout_ms)); | |
| 203 | + | if (left) | |
| 204 | + | return 0; | |
| 205 | + | ||
| 206 | + | /* Invalidate a request that the handler has not already accepted. A | |
| 207 | + | * delayed reply cannot match a later request because message numbers are | |
| 208 | + | * monotonic across channel reopen. | |
| 209 | + | */ | |
| 210 | + | spin_lock_bh(&enic->mbox_state_lock); | |
| 211 | + | if (enic->mbox_expected_reply) { | |
| 212 | + | enic->mbox_expected_reply = 0; | |
| 213 | + | enic->mbox_expected_msg_num = 0; | |
| 214 | + | err = -ETIMEDOUT; | |
| 215 | + | } | |
| 216 | + | spin_unlock_bh(&enic->mbox_state_lock); | |
| 152 | 217 | ||
| 153 | - | return left ? 0 : -ETIMEDOUT; | |
| 218 | + | return err; | |
| 154 | 219 | } | |
| 155 | 220 | ||
| 156 | 221 | int enic_mbox_send_link_state(struct enic *enic, u16 vf_id, u32 link_state) | |
| @@ -178,8 +243,8 @@ static int enic_mbox_pf_handle_capability(struct enic *enic, void *msg, | |||
| 178 | 243 | reply.reply.ret_major = cpu_to_le16(0); | |
| 179 | 244 | reply.version = cpu_to_le32(ENIC_MBOX_CAP_VERSION_1); | |
| 180 | 245 | ||
| 181 | - | return enic_mbox_send_msg(enic, ENIC_MBOX_VF_CAPABILITY_REPLY, vf_id, | |
| 182 | - | &reply, sizeof(reply)); | |
| 246 | + | return enic_mbox_send_reply(enic, ENIC_MBOX_VF_CAPABILITY_REPLY, vf_id, | |
| 247 | + | &reply, sizeof(reply), msg_num); | |
| 183 | 248 | } | |
| 184 | 249 | ||
| 185 | 250 | static int enic_mbox_pf_handle_register(struct enic *enic, void *msg, | |
| @@ -208,8 +273,8 @@ static int enic_mbox_pf_handle_register(struct enic *enic, void *msg, | |||
| 208 | 273 | } | |
| 209 | 274 | ||
| 210 | 275 | reply.reply.ret_major = cpu_to_le16(0); | |
| 211 | - | err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_REGISTER_REPLY, vf_id, | |
| 212 | - | &reply, sizeof(reply)); | |
| 276 | + | err = enic_mbox_send_reply(enic, ENIC_MBOX_VF_REGISTER_REPLY, vf_id, | |
| 277 | + | &reply, sizeof(reply), msg_num); | |
| 213 | 278 | if (err) | |
| 214 | 279 | return err; | |
| 215 | 280 | ||
| @@ -253,8 +318,8 @@ static int enic_mbox_pf_handle_unregister(struct enic *enic, void *msg, | |||
| 253 | 318 | enic->vf_state[vf_id].registered = false; | |
| 254 | 319 | ||
| 255 | 320 | reply.reply.ret_major = cpu_to_le16(0); | |
| 256 | - | err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_UNREGISTER_REPLY, vf_id, | |
| 257 | - | &reply, sizeof(reply)); | |
| 321 | + | err = enic_mbox_send_reply(enic, ENIC_MBOX_VF_UNREGISTER_REPLY, vf_id, | |
| 322 | + | &reply, sizeof(reply), msg_num); | |
| 258 | 323 | ||
| 259 | 324 | if (net_ratelimit()) | |
| 260 | 325 | netdev_info(enic->netdev, | |
| @@ -324,105 +389,116 @@ static void enic_mbox_pf_process_msg(struct enic *enic, | |||
| 324 | 389 | hdr->msg_type, vf_id, err); | |
| 325 | 390 | } | |
| 326 | 391 | ||
| 327 | - | static void enic_mbox_vf_handle_capability_reply(struct enic *enic, | |
| 328 | - | void *payload) | |
| 392 | + | static void enic_mbox_vf_handle_reply(struct enic *enic, u8 reply_type, | |
| 393 | + | void *payload, u64 msg_num) | |
| 329 | 394 | { | |
| 330 | - | struct enic_mbox_vf_capability_reply_msg *reply = payload; | |
| 331 | - | ||
| 332 | - | if (READ_ONCE(enic->mbox_expected_reply) != ENIC_MBOX_VF_CAPABILITY_REPLY) { | |
| 395 | + | struct enic_mbox_generic_reply *reply = payload; | |
| 396 | + | u16 ret_major = le16_to_cpu(reply->ret_major); | |
| 397 | + | u64 expected_msg_num; | |
| 398 | + | u8 expected_type; | |
| 399 | + | ||
| 400 | + | spin_lock_bh(&enic->mbox_state_lock); | |
| 401 | + | expected_type = enic->mbox_expected_reply; | |
| 402 | + | expected_msg_num = enic->mbox_expected_msg_num; | |
| 403 | + | if (expected_type != reply_type || expected_msg_num != msg_num) { | |
| 404 | + | spin_unlock_bh(&enic->mbox_state_lock); | |
| 333 | 405 | netdev_warn(enic->netdev, | |
| 334 | - | "MBOX: stale capability reply (expected %u), drop\n", | |
| 335 | - | READ_ONCE(enic->mbox_expected_reply)); | |
| 406 | + | "MBOX: stale reply %u/%llu (expected %u/%llu), drop\n", | |
| 407 | + | reply_type, (unsigned long long)msg_num, | |
| 408 | + | expected_type, (unsigned long long)expected_msg_num); | |
| 336 | 409 | return; | |
| 337 | 410 | } | |
| 338 | 411 | ||
| 339 | - | if (le16_to_cpu(reply->reply.ret_major) == 0) | |
| 340 | - | enic->pf_cap_version = le32_to_cpu(reply->version); | |
| 341 | - | else | |
| 342 | - | netdev_warn(enic->netdev, | |
| 343 | - | "MBOX: PF rejected capability request: %u/%u\n", | |
| 344 | - | le16_to_cpu(reply->reply.ret_major), | |
| 345 | - | le16_to_cpu(reply->reply.ret_minor)); | |
| 346 | - | complete(&enic->mbox_comp); | |
| 347 | - | } | |
| 412 | + | if (!ret_major) { | |
| 413 | + | switch (reply_type) { | |
| 414 | + | case ENIC_MBOX_VF_CAPABILITY_REPLY: { | |
| 415 | + | struct enic_mbox_vf_capability_reply_msg *cap = payload; | |
| 348 | 416 | ||
| 349 | - | static void enic_mbox_vf_handle_register_reply(struct enic *enic, | |
| 350 | - | void *payload) | |
| 351 | - | { | |
| 352 | - | struct enic_mbox_vf_register_reply_msg *reply = payload; | |
| 353 | - | ||
| 354 | - | if (READ_ONCE(enic->mbox_expected_reply) != ENIC_MBOX_VF_REGISTER_REPLY) { | |
| 355 | - | netdev_warn(enic->netdev, | |
| 356 | - | "MBOX: stale register reply (expected %u), drop\n", | |
| 357 | - | READ_ONCE(enic->mbox_expected_reply)); | |
| 358 | - | return; | |
| 359 | - | } | |
| 360 | - | ||
| 361 | - | if (le16_to_cpu(reply->reply.ret_major)) { | |
| 362 | - | netdev_warn(enic->netdev, | |
| 363 | - | "MBOX: VF register rejected by PF: %u/%u\n", | |
| 364 | - | le16_to_cpu(reply->reply.ret_major), | |
| 365 | - | le16_to_cpu(reply->reply.ret_minor)); | |
| 366 | - | } else { | |
| 367 | - | enic->vf_registered = true; | |
| 417 | + | WRITE_ONCE(enic->pf_cap_version, | |
| 418 | + | le32_to_cpu(cap->version)); | |
| 419 | + | break; | |
| 420 | + | } | |
| 421 | + | case ENIC_MBOX_VF_REGISTER_REPLY: | |
| 422 | + | WRITE_ONCE(enic->vf_registered, true); | |
| 423 | + | break; | |
| 424 | + | case ENIC_MBOX_VF_UNREGISTER_REPLY: | |
| 425 | + | WRITE_ONCE(enic->vf_registered, false); | |
| 426 | + | break; | |
| 427 | + | } | |
| 368 | 428 | } | |
| 429 | + | enic->mbox_expected_reply = 0; | |
| 430 | + | enic->mbox_expected_msg_num = 0; | |
| 369 | 431 | complete(&enic->mbox_comp); | |
| 370 | - | } | |
| 432 | + | spin_unlock_bh(&enic->mbox_state_lock); | |
| 371 | 433 | ||
| 372 | - | static void enic_mbox_vf_handle_unregister_reply(struct enic *enic, | |
| 373 | - | void *payload) | |
| 374 | - | { | |
| 375 | - | struct enic_mbox_vf_register_reply_msg *reply = payload; | |
| 376 | - | ||
| 377 | - | if (READ_ONCE(enic->mbox_expected_reply) != ENIC_MBOX_VF_UNREGISTER_REPLY) { | |
| 434 | + | if (ret_major) | |
| 378 | 435 | netdev_warn(enic->netdev, | |
| 379 | - | "MBOX: stale unregister reply (expected %u), drop\n", | |
| 380 | - | READ_ONCE(enic->mbox_expected_reply)); | |
| 381 | - | return; | |
| 382 | - | } | |
| 383 | - | ||
| 384 | - | if (le16_to_cpu(reply->reply.ret_major)) { | |
| 385 | - | netdev_warn(enic->netdev, | |
| 386 | - | "MBOX: VF unregister rejected by PF: %u/%u\n", | |
| 387 | - | le16_to_cpu(reply->reply.ret_major), | |
| 388 | - | le16_to_cpu(reply->reply.ret_minor)); | |
| 389 | - | } else { | |
| 390 | - | enic->vf_registered = false; | |
| 391 | - | } | |
| 392 | - | complete(&enic->mbox_comp); | |
| 436 | + | "MBOX: PF rejected reply type %u: %u/%u\n", | |
| 437 | + | reply_type, ret_major, | |
| 438 | + | le16_to_cpu(reply->ret_minor)); | |
| 393 | 439 | } | |
| 394 | 440 | ||
| 395 | - | static void enic_mbox_vf_handle_link_state(struct enic *enic, void *payload) | |
| 441 | + | static void enic_mbox_vf_handle_link_state(struct enic *enic, void *payload, | |
| 442 | + | u64 msg_num) | |
| 396 | 443 | { | |
| 397 | 444 | struct enic_mbox_pf_link_state_notif_msg *notif = payload; | |
| 398 | 445 | struct enic_mbox_pf_link_state_ack_msg ack = {}; | |
| 446 | + | u32 link_state = le32_to_cpu(notif->link_state); | |
| 399 | 447 | int err; | |
| 400 | 448 | ||
| 401 | - | switch (le32_to_cpu(notif->link_state)) { | |
| 449 | + | spin_lock_bh(&enic->vf_link_state_lock); | |
| 450 | + | switch (link_state) { | |
| 402 | 451 | case ENIC_MBOX_LINK_STATE_ENABLE: | |
| 403 | - | if (!netif_carrier_ok(enic->netdev)) | |
| 452 | + | enic->vf_link_state = ENIC_VF_LINK_STATE_UP; | |
| 453 | + | if (enic->vf_link_running && | |
| 454 | + | !netif_carrier_ok(enic->netdev)) | |
| 404 | 455 | netif_carrier_on(enic->netdev); | |
| 405 | 456 | netdev_dbg(enic->netdev, "MBOX: link state -> UP\n"); | |
| 406 | 457 | break; | |
| 407 | 458 | case ENIC_MBOX_LINK_STATE_DISABLE: | |
| 408 | - | if (netif_carrier_ok(enic->netdev)) | |
| 459 | + | enic->vf_link_state = ENIC_VF_LINK_STATE_DOWN; | |
| 460 | + | if (enic->vf_link_running && | |
| 461 | + | netif_carrier_ok(enic->netdev)) | |
| 409 | 462 | netif_carrier_off(enic->netdev); | |
| 410 | 463 | netdev_dbg(enic->netdev, "MBOX: link state -> DOWN\n"); | |
| 411 | 464 | break; | |
| 412 | 465 | default: | |
| 413 | 466 | netdev_warn(enic->netdev, "MBOX: unknown link state %u\n", | |
| 414 | - | le32_to_cpu(notif->link_state)); | |
| 467 | + | link_state); | |
| 415 | 468 | ack.ack.ret_major = cpu_to_le16(ENIC_MBOX_ERR_GENERIC); | |
| 416 | 469 | break; | |
| 417 | 470 | } | |
| 471 | + | spin_unlock_bh(&enic->vf_link_state_lock); | |
| 418 | 472 | ||
| 419 | - | err = enic_mbox_send_msg(enic, ENIC_MBOX_PF_LINK_STATE_ACK, | |
| 420 | - | ENIC_MBOX_DST_PF, &ack, sizeof(ack)); | |
| 473 | + | err = enic_mbox_send_reply(enic, ENIC_MBOX_PF_LINK_STATE_ACK, | |
| 474 | + | ENIC_MBOX_DST_PF, &ack, sizeof(ack), msg_num); | |
| 421 | 475 | if (err && net_ratelimit()) | |
| 422 | 476 | netdev_warn(enic->netdev, | |
| 423 | 477 | "MBOX: failed to send link state ACK: %d\n", err); | |
| 424 | 478 | } | |
| 425 | 479 | ||
| 480 | + | void enic_mbox_vf_link_state_reset(struct enic *enic) | |
| 481 | + | { | |
| 482 | + | spin_lock_bh(&enic->vf_link_state_lock); | |
| 483 | + | enic->vf_link_state = ENIC_VF_LINK_STATE_UNKNOWN; | |
| 484 | + | if (enic->vf_link_running && netif_carrier_ok(enic->netdev)) | |
| 485 | + | netif_carrier_off(enic->netdev); | |
| 486 | + | spin_unlock_bh(&enic->vf_link_state_lock); | |
| 487 | + | } | |
| 488 | + | ||
| 489 | + | void enic_mbox_vf_link_state_set_running(struct enic *enic, bool running) | |
| 490 | + | { | |
| 491 | + | spin_lock_bh(&enic->vf_link_state_lock); | |
| 492 | + | enic->vf_link_running = running; | |
| 493 | + | if (running && enic->vf_link_state == ENIC_VF_LINK_STATE_UP) { | |
| 494 | + | if (!netif_carrier_ok(enic->netdev)) | |
| 495 | + | netif_carrier_on(enic->netdev); | |
| 496 | + | } else if (netif_carrier_ok(enic->netdev)) { | |
| 497 | + | netif_carrier_off(enic->netdev); | |
| 498 | + | } | |
| 499 | + | spin_unlock_bh(&enic->vf_link_state_lock); | |
| 500 | + | } | |
| 501 | + | ||
| 426 | 502 | static bool enic_mbox_vf_payload_ok(struct enic *enic, u8 msg_type, | |
| 427 | 503 | u16 payload_len, size_t min_len) | |
| 428 | 504 | { | |
| @@ -439,6 +515,8 @@ static void enic_mbox_vf_process_msg(struct enic *enic, | |||
| 439 | 515 | struct enic_mbox_hdr *hdr, void *payload, | |
| 440 | 516 | u16 payload_len) | |
| 441 | 517 | { | |
| 518 | + | u64 msg_num = le64_to_cpu(hdr->msg_num); | |
| 519 | + | ||
| 442 | 520 | switch (hdr->msg_type) { | |
| 443 | 521 | case ENIC_MBOX_VF_CAPABILITY_REPLY: { | |
| 444 | 522 | size_t exp = sizeof(struct enic_mbox_vf_capability_reply_msg); | |
| @@ -446,7 +524,7 @@ static void enic_mbox_vf_process_msg(struct enic *enic, | |||
| 446 | 524 | if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type, | |
| 447 | 525 | payload_len, exp)) | |
| 448 | 526 | return; | |
| 449 | - | enic_mbox_vf_handle_capability_reply(enic, payload); | |
| 527 | + | enic_mbox_vf_handle_reply(enic, hdr->msg_type, payload, msg_num); | |
| 450 | 528 | break; | |
| 451 | 529 | } | |
| 452 | 530 | case ENIC_MBOX_VF_REGISTER_REPLY: { | |
| @@ -455,7 +533,7 @@ static void enic_mbox_vf_process_msg(struct enic *enic, | |||
| 455 | 533 | if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type, | |
| 456 | 534 | payload_len, exp)) | |
| 457 | 535 | return; | |
| 458 | - | enic_mbox_vf_handle_register_reply(enic, payload); | |
| 536 | + | enic_mbox_vf_handle_reply(enic, hdr->msg_type, payload, msg_num); | |
| 459 | 537 | break; | |
| 460 | 538 | } | |
| 461 | 539 | case ENIC_MBOX_VF_UNREGISTER_REPLY: { | |
| @@ -464,7 +542,7 @@ static void enic_mbox_vf_process_msg(struct enic *enic, | |||
| 464 | 542 | if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type, | |
| 465 | 543 | payload_len, exp)) | |
| 466 | 544 | return; | |
| 467 | - | enic_mbox_vf_handle_unregister_reply(enic, payload); | |
| 545 | + | enic_mbox_vf_handle_reply(enic, hdr->msg_type, payload, msg_num); | |
| 468 | 546 | break; | |
| 469 | 547 | } | |
| 470 | 548 | case ENIC_MBOX_PF_LINK_STATE_NOTIF: { | |
| @@ -473,7 +551,7 @@ static void enic_mbox_vf_process_msg(struct enic *enic, | |||
| 473 | 551 | if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type, | |
| 474 | 552 | payload_len, exp)) | |
| 475 | 553 | return; | |
| 476 | - | enic_mbox_vf_handle_link_state(enic, payload); | |
| 554 | + | enic_mbox_vf_handle_link_state(enic, payload, msg_num); | |
| 477 | 555 | break; | |
| 478 | 556 | } | |
| 479 | 557 | default: | |
| @@ -542,32 +620,31 @@ static void enic_mbox_recv_handler(struct enic *enic, void *buf, | |||
| 542 | 620 | int enic_mbox_vf_capability_check(struct enic *enic) | |
| 543 | 621 | { | |
| 544 | 622 | struct enic_mbox_vf_capability_msg req = {}; | |
| 623 | + | u32 version; | |
| 545 | 624 | int err; | |
| 546 | 625 | ||
| 547 | - | enic->pf_cap_version = 0; | |
| 548 | - | reinit_completion(&enic->mbox_comp); | |
| 549 | - | WRITE_ONCE(enic->mbox_expected_reply, ENIC_MBOX_VF_CAPABILITY_REPLY); | |
| 626 | + | WRITE_ONCE(enic->pf_cap_version, 0); | |
| 550 | 627 | req.version = cpu_to_le32(ENIC_MBOX_CAP_VERSION_1); | |
| 551 | 628 | ||
| 552 | - | err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_CAPABILITY_REQUEST, | |
| 553 | - | ENIC_MBOX_DST_PF, &req, sizeof(req)); | |
| 554 | - | if (err) { | |
| 555 | - | WRITE_ONCE(enic->mbox_expected_reply, 0); | |
| 629 | + | err = enic_mbox_vf_send_request(enic, | |
| 630 | + | ENIC_MBOX_VF_CAPABILITY_REQUEST, | |
| 631 | + | ENIC_MBOX_VF_CAPABILITY_REPLY, | |
| 632 | + | &req, sizeof(req)); | |
| 633 | + | if (err) | |
| 556 | 634 | return err; | |
| 557 | - | } | |
| 558 | 635 | ||
| 559 | 636 | err = enic_mbox_wait_reply(enic, 3000); | |
| 560 | - | WRITE_ONCE(enic->mbox_expected_reply, 0); | |
| 637 | + | version = READ_ONCE(enic->pf_cap_version); | |
| 561 | 638 | if (err) { | |
| 562 | 639 | netdev_warn(enic->netdev, | |
| 563 | 640 | "MBOX: no capability reply from PF\n"); | |
| 564 | 641 | return err; | |
| 565 | 642 | } | |
| 566 | 643 | ||
| 567 | - | if (enic->pf_cap_version < ENIC_MBOX_CAP_VERSION_1) { | |
| 644 | + | if (version < ENIC_MBOX_CAP_VERSION_1) { | |
| 568 | 645 | netdev_warn(enic->netdev, | |
| 569 | 646 | "MBOX: PF rejected capability request or reported unsupported version %u\n", | |
| 570 | - | enic->pf_cap_version); | |
| 647 | + | version); | |
| 571 | 648 | return -EOPNOTSUPP; | |
| 572 | 649 | } | |
| 573 | 650 | ||
| @@ -576,28 +653,25 @@ int enic_mbox_vf_capability_check(struct enic *enic) | |||
| 576 | 653 | ||
| 577 | 654 | int enic_mbox_vf_register(struct enic *enic) | |
| 578 | 655 | { | |
| 656 | + | bool registered; | |
| 579 | 657 | int err; | |
| 580 | 658 | ||
| 581 | - | enic->vf_registered = false; | |
| 582 | - | reinit_completion(&enic->mbox_comp); | |
| 583 | - | WRITE_ONCE(enic->mbox_expected_reply, ENIC_MBOX_VF_REGISTER_REPLY); | |
| 659 | + | WRITE_ONCE(enic->vf_registered, false); | |
| 584 | 660 | ||
| 585 | - | err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_REGISTER_REQUEST, | |
| 586 | - | ENIC_MBOX_DST_PF, NULL, 0); | |
| 587 | - | if (err) { | |
| 588 | - | WRITE_ONCE(enic->mbox_expected_reply, 0); | |
| 661 | + | err = enic_mbox_vf_send_request(enic, ENIC_MBOX_VF_REGISTER_REQUEST, | |
| 662 | + | ENIC_MBOX_VF_REGISTER_REPLY, NULL, 0); | |
| 663 | + | if (err) | |
| 589 | 664 | return err; | |
| 590 | - | } | |
| 591 | 665 | ||
| 592 | 666 | err = enic_mbox_wait_reply(enic, 3000); | |
| 593 | - | WRITE_ONCE(enic->mbox_expected_reply, 0); | |
| 667 | + | registered = READ_ONCE(enic->vf_registered); | |
| 594 | 668 | if (err) { | |
| 595 | 669 | netdev_warn(enic->netdev, | |
| 596 | 670 | "MBOX: VF registration with PF timed out\n"); | |
| 597 | 671 | return err; | |
| 598 | 672 | } | |
| 599 | 673 | ||
| 600 | - | if (!enic->vf_registered) | |
| 674 | + | if (!registered) | |
| 601 | 675 | return -ENODEV; | |
| 602 | 676 | ||
| 603 | 677 | return 0; | |
| @@ -605,43 +679,48 @@ int enic_mbox_vf_register(struct enic *enic) | |||
| 605 | 679 | ||
| 606 | 680 | int enic_mbox_vf_unregister(struct enic *enic) | |
| 607 | 681 | { | |
| 682 | + | bool registered; | |
| 608 | 683 | int err; | |
| 609 | 684 | ||
| 610 | - | if (!enic->vf_registered) | |
| 685 | + | if (!READ_ONCE(enic->vf_registered)) | |
| 611 | 686 | return 0; | |
| 612 | 687 | ||
| 613 | - | reinit_completion(&enic->mbox_comp); | |
| 614 | - | WRITE_ONCE(enic->mbox_expected_reply, ENIC_MBOX_VF_UNREGISTER_REPLY); | |
| 615 | - | ||
| 616 | - | err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_UNREGISTER_REQUEST, | |
| 617 | - | ENIC_MBOX_DST_PF, NULL, 0); | |
| 618 | - | if (err) { | |
| 619 | - | WRITE_ONCE(enic->mbox_expected_reply, 0); | |
| 688 | + | err = enic_mbox_vf_send_request(enic, | |
| 689 | + | ENIC_MBOX_VF_UNREGISTER_REQUEST, | |
| 690 | + | ENIC_MBOX_VF_UNREGISTER_REPLY, | |
| 691 | + | NULL, 0); | |
| 692 | + | if (err) | |
| 620 | 693 | return err; | |
| 621 | - | } | |
| 622 | 694 | ||
| 623 | 695 | err = enic_mbox_wait_reply(enic, 3000); | |
| 624 | - | WRITE_ONCE(enic->mbox_expected_reply, 0); | |
| 696 | + | registered = READ_ONCE(enic->vf_registered); | |
| 625 | 697 | if (err) | |
| 626 | 698 | return err; | |
| 627 | - | if (enic->vf_registered) | |
| 699 | + | if (registered) | |
| 628 | 700 | return -EACCES; | |
| 629 | 701 | return 0; | |
| 630 | 702 | } | |
| 631 | 703 | ||
| 632 | 704 | void enic_mbox_init(struct enic *enic) | |
| 633 | 705 | { | |
| 634 | - | /* mbox_lock and mbox_comp must be initialized exactly once per | |
| 706 | + | bool reinit = enic->mbox_initialized; | |
| 707 | + | ||
| 708 | + | /* MBOX locks and mbox_comp must be initialized exactly once per | |
| 635 | 709 | * device lifetime; the PF sriov_configure path can re-enter this | |
| 636 | 710 | * on each enable cycle where these primitives are already set up. | |
| 637 | 711 | */ | |
| 638 | - | if (!enic->mbox_initialized) { | |
| 712 | + | if (!reinit) { | |
| 639 | 713 | mutex_init(&enic->mbox_lock); | |
| 640 | 714 | init_completion(&enic->mbox_comp); | |
| 715 | + | spin_lock_init(&enic->mbox_state_lock); | |
| 716 | + | enic->mbox_msg_num = 0; | |
| 641 | 717 | enic->mbox_initialized = true; | |
| 642 | 718 | } else { | |
| 643 | 719 | reinit_completion(&enic->mbox_comp); | |
| 644 | 720 | } | |
| 645 | - | enic->mbox_msg_num = 0; | |
| 721 | + | spin_lock_bh(&enic->mbox_state_lock); | |
| 722 | + | enic->mbox_expected_reply = 0; | |
| 723 | + | enic->mbox_expected_msg_num = 0; | |
| 724 | + | spin_unlock_bh(&enic->mbox_state_lock); | |
| 646 | 725 | enic->admin_rq_handler = enic_mbox_recv_handler; | |
| 647 | 726 | } | |
modified drivers/net/ethernet/cisco/enic/enic_mbox.h
| @@ -88,6 +88,8 @@ void enic_mbox_init(struct enic *enic); | |||
| 88 | 88 | int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id, | |
| 89 | 89 | void *payload, u16 payload_len); | |
| 90 | 90 | int enic_mbox_send_link_state(struct enic *enic, u16 vf_id, u32 link_state); | |
| 91 | + | void enic_mbox_vf_link_state_reset(struct enic *enic); | |
| 92 | + | void enic_mbox_vf_link_state_set_running(struct enic *enic, bool running); | |
| 91 | 93 | int enic_mbox_vf_capability_check(struct enic *enic); | |
| 92 | 94 | int enic_mbox_vf_register(struct enic *enic); | |
| 93 | 95 | int enic_mbox_vf_unregister(struct enic *enic); | |
modified drivers/net/ethernet/cortina/gemini.c
| @@ -124,6 +124,7 @@ struct gemini_ethernet_port { | |||
| 124 | 124 | unsigned int rx_coalesce_nsecs; | |
| 125 | 125 | struct sk_buff *rx_skb; | |
| 126 | 126 | unsigned int rx_frag_nr; | |
| 127 | + | bool rx_dropping; | |
| 127 | 128 | ||
| 128 | 129 | unsigned int freeq_refill; | |
| 129 | 130 | struct gmac_txq txq[TX_QUEUE_NUM]; | |
| @@ -1439,7 +1440,8 @@ update_exit: | |||
| 1439 | 1440 | return skb; | |
| 1440 | 1441 | } | |
| 1441 | 1442 | ||
| 1442 | - | static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) | |
| 1443 | + | static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget, | |
| 1444 | + | unsigned int *freeq_consumed) | |
| 1443 | 1445 | { | |
| 1444 | 1446 | struct gemini_ethernet_port *port = netdev_priv(netdev); | |
| 1445 | 1447 | unsigned short m = (1 << port->rxq_order) - 1; | |
| @@ -1447,9 +1449,12 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) | |||
| 1447 | 1449 | void __iomem *ptr_reg = port->rxq_rwptr; | |
| 1448 | 1450 | unsigned int frag_nr = port->rx_frag_nr; | |
| 1449 | 1451 | struct sk_buff *skb = port->rx_skb; | |
| 1452 | + | unsigned int consumed = 0; | |
| 1450 | 1453 | unsigned int frame_len, frag_len; | |
| 1451 | 1454 | struct gmac_rxdesc *rx = NULL; | |
| 1452 | 1455 | struct gmac_queue_page *gpage; | |
| 1456 | + | unsigned int received = 0; | |
| 1457 | + | bool dropping = port->rx_dropping; | |
| 1453 | 1458 | union gmac_rxdesc_0 word0; | |
| 1454 | 1459 | union gmac_rxdesc_1 word1; | |
| 1455 | 1460 | union gmac_rxdesc_3 word3; | |
| @@ -1471,6 +1476,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) | |||
| 1471 | 1476 | w = rw.bits.wptr; | |
| 1472 | 1477 | ||
| 1473 | 1478 | while (budget && w != r) { | |
| 1479 | + | page = NULL; | |
| 1474 | 1480 | rx = port->rxq_ring + r; | |
| 1475 | 1481 | word0 = rx->word0; | |
| 1476 | 1482 | word1 = rx->word1; | |
| @@ -1479,11 +1485,22 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) | |||
| 1479 | 1485 | ||
| 1480 | 1486 | r++; | |
| 1481 | 1487 | r &= m; | |
| 1488 | + | consumed++; | |
| 1482 | 1489 | ||
| 1483 | 1490 | frag_len = word0.bits.buffer_size; | |
| 1484 | 1491 | frame_len = word1.bits.byte_count; | |
| 1485 | 1492 | page_offs = mapping & ~PAGE_MASK; | |
| 1486 | 1493 | ||
| 1494 | + | if (word3.bits32 & SOF_BIT) { | |
| 1495 | + | if (skb) { | |
| 1496 | + | napi_free_frags(&port->napi); | |
| 1497 | + | port->stats.rx_dropped++; | |
| 1498 | + | skb = NULL; | |
| 1499 | + | frag_nr = 0; | |
| 1500 | + | } | |
| 1501 | + | dropping = false; | |
| 1502 | + | } | |
| 1503 | + | ||
| 1487 | 1504 | if (!mapping) { | |
| 1488 | 1505 | netdev_err(netdev, | |
| 1489 | 1506 | "rxq[%u]: HW BUG: zero DMA desc\n", r); | |
| @@ -1494,24 +1511,11 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) | |||
| 1494 | 1511 | gpage = gmac_get_queue_page(geth, port, mapping + PAGE_SIZE); | |
| 1495 | 1512 | if (!gpage) { | |
| 1496 | 1513 | dev_err(geth->dev, "could not find mapping\n"); | |
| 1497 | - | port->stats.rx_dropped++; | |
| 1498 | - | if (skb) { | |
| 1499 | - | napi_free_frags(&port->napi); | |
| 1500 | - | skb = NULL; | |
| 1501 | - | frag_nr = 0; | |
| 1502 | - | } | |
| 1503 | - | continue; | |
| 1514 | + | goto err_drop; | |
| 1504 | 1515 | } | |
| 1505 | 1516 | page = gpage->page; | |
| 1506 | 1517 | ||
| 1507 | 1518 | if (word3.bits32 & SOF_BIT) { | |
| 1508 | - | if (skb) { | |
| 1509 | - | napi_free_frags(&port->napi); | |
| 1510 | - | port->stats.rx_dropped++; | |
| 1511 | - | skb = NULL; | |
| 1512 | - | frag_nr = 0; | |
| 1513 | - | } | |
| 1514 | - | ||
| 1515 | 1519 | skb = gmac_skb_if_good_frame(port, word0, frame_len); | |
| 1516 | 1520 | if (!skb) | |
| 1517 | 1521 | goto err_drop; | |
| @@ -1521,8 +1525,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) | |||
| 1521 | 1525 | frag_nr = 0; | |
| 1522 | 1526 | ||
| 1523 | 1527 | } else if (!skb) { | |
| 1524 | - | put_page(page); | |
| 1525 | - | continue; | |
| 1528 | + | goto err_drop; | |
| 1526 | 1529 | } | |
| 1527 | 1530 | ||
| 1528 | 1531 | if (word3.bits32 & EOF_BIT) | |
| @@ -1545,9 +1548,8 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) | |||
| 1545 | 1548 | napi_gro_frags(&port->napi); | |
| 1546 | 1549 | skb = NULL; | |
| 1547 | 1550 | frag_nr = 0; | |
| 1548 | - | --budget; | |
| 1549 | 1551 | } | |
| 1550 | - | continue; | |
| 1552 | + | goto next_desc; | |
| 1551 | 1553 | ||
| 1552 | 1554 | err_drop: | |
| 1553 | 1555 | if (skb) { | |
| @@ -1556,16 +1558,29 @@ err_drop: | |||
| 1556 | 1558 | frag_nr = 0; | |
| 1557 | 1559 | } | |
| 1558 | 1560 | ||
| 1559 | - | if (mapping) | |
| 1561 | + | if (page) | |
| 1560 | 1562 | put_page(page); | |
| 1561 | 1563 | ||
| 1562 | - | port->stats.rx_dropped++; | |
| 1564 | + | if (!dropping) { | |
| 1565 | + | port->stats.rx_dropped++; | |
| 1566 | + | dropping = true; | |
| 1567 | + | } | |
| 1568 | + | ||
| 1569 | + | next_desc: | |
| 1570 | + | /* Final or single-descriptor fragment, advance things */ | |
| 1571 | + | if (word3.bits32 & EOF_BIT) { | |
| 1572 | + | budget--; | |
| 1573 | + | received++; | |
| 1574 | + | dropping = false; | |
| 1575 | + | } | |
| 1563 | 1576 | } | |
| 1564 | 1577 | ||
| 1565 | 1578 | port->rx_skb = skb; | |
| 1566 | 1579 | port->rx_frag_nr = frag_nr; | |
| 1580 | + | port->rx_dropping = dropping; | |
| 1581 | + | *freeq_consumed = consumed; | |
| 1567 | 1582 | writew(r, ptr_reg); | |
| 1568 | - | return budget; | |
| 1583 | + | return received; | |
| 1569 | 1584 | } | |
| 1570 | 1585 | ||
| 1571 | 1586 | static int gmac_napi_poll(struct napi_struct *napi, int budget) | |
| @@ -1573,26 +1588,27 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget) | |||
| 1573 | 1588 | struct gemini_ethernet_port *port = netdev_priv(napi->dev); | |
| 1574 | 1589 | struct gemini_ethernet *geth = port->geth; | |
| 1575 | 1590 | unsigned int freeq_threshold; | |
| 1591 | + | unsigned int freeq_consumed; | |
| 1576 | 1592 | unsigned int received; | |
| 1577 | 1593 | ||
| 1578 | 1594 | freeq_threshold = 1 << (geth->freeq_order - 1); | |
| 1579 | 1595 | u64_stats_update_begin(&port->rx_stats_syncp); | |
| 1580 | 1596 | ||
| 1581 | - | received = gmac_rx(napi->dev, budget); | |
| 1582 | - | if (received < budget) { | |
| 1583 | - | napi_gro_flush(napi, false); | |
| 1584 | - | napi_complete_done(napi, received); | |
| 1585 | - | gmac_enable_rx_irq(napi->dev, 1); | |
| 1597 | + | received = gmac_rx(napi->dev, budget, &freeq_consumed); | |
| 1598 | + | if (received < budget) | |
| 1586 | 1599 | ++port->rx_napi_exits; | |
| 1587 | - | } | |
| 1588 | 1600 | ||
| 1589 | - | port->freeq_refill += (budget - received); | |
| 1601 | + | u64_stats_update_end(&port->rx_stats_syncp); | |
| 1602 | + | ||
| 1603 | + | port->freeq_refill += freeq_consumed; | |
| 1590 | 1604 | if (port->freeq_refill > freeq_threshold) { | |
| 1591 | 1605 | port->freeq_refill -= freeq_threshold; | |
| 1592 | 1606 | geth_fill_freeq(geth, true); | |
| 1593 | 1607 | } | |
| 1594 | 1608 | ||
| 1595 | - | u64_stats_update_end(&port->rx_stats_syncp); | |
| 1609 | + | if (received < budget && napi_complete_done(napi, received)) | |
| 1610 | + | gmac_enable_rx_irq(napi->dev, 1); | |
| 1611 | + | ||
| 1596 | 1612 | return received; | |
| 1597 | 1613 | } | |
| 1598 | 1614 | ||
| @@ -1893,6 +1909,7 @@ static int gmac_stop(struct net_device *netdev) | |||
| 1893 | 1909 | napi_disable(&port->napi); | |
| 1894 | 1910 | port->rx_skb = NULL; | |
| 1895 | 1911 | port->rx_frag_nr = 0; | |
| 1912 | + | port->rx_dropping = false; | |
| 1896 | 1913 | ||
| 1897 | 1914 | gmac_enable_irq(netdev, 0); | |
| 1898 | 1915 | gmac_cleanup_rxq(netdev); | |
modified drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
| @@ -616,7 +616,7 @@ static int dpaa2_switch_lag_fdb_add(struct dpaa2_switch_lag *lag, | |||
| 616 | 616 | goto out; | |
| 617 | 617 | } | |
| 618 | 618 | ||
| 619 | - | a = kzalloc(sizeof(*a), GFP_KERNEL); | |
| 619 | + | a = kzalloc_obj(*a); | |
| 620 | 620 | if (!a) { | |
| 621 | 621 | err = -ENOMEM; | |
| 622 | 622 | goto out; | |
| @@ -4131,8 +4131,7 @@ static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev) | |||
| 4131 | 4131 | goto err_free_fdbs; | |
| 4132 | 4132 | } | |
| 4133 | 4133 | ||
| 4134 | - | ethsw->lags = kcalloc(ethsw->sw_attr.num_ifs, sizeof(*ethsw->lags), | |
| 4135 | - | GFP_KERNEL); | |
| 4134 | + | ethsw->lags = kzalloc_objs(*ethsw->lags, ethsw->sw_attr.num_ifs); | |
| 4136 | 4135 | if (!ethsw->lags) { | |
| 4137 | 4136 | err = -ENOMEM; | |
| 4138 | 4137 | goto err_free_filter; | |
modified drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c
| @@ -128,6 +128,7 @@ enum hinic_mbox_tx_status { | |||
| 128 | 128 | ||
| 129 | 129 | #define SEQ_ID_START_VAL 0 | |
| 130 | 130 | #define SEQ_ID_MAX_VAL 42 | |
| 131 | + | #define MBOX_LAST_SEG_MAX_LEN (MBOX_MAX_BUF_SZ - SEQ_ID_MAX_VAL * MBOX_SEG_LEN) | |
| 131 | 132 | ||
| 132 | 133 | #define NO_DMA_ATTRIBUTE_VAL 0 | |
| 133 | 134 | ||
| @@ -372,7 +373,8 @@ recv_pf_from_vf_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, | |||
| 372 | 373 | static bool check_mbox_seq_id_and_seg_len(struct hinic_recv_mbox *recv_mbox, | |
| 373 | 374 | u8 seq_id, u8 seg_len) | |
| 374 | 375 | { | |
| 375 | - | if (seq_id > SEQ_ID_MAX_VAL || seg_len > MBOX_SEG_LEN) | |
| 376 | + | if (seq_id > SEQ_ID_MAX_VAL || seg_len > MBOX_SEG_LEN || | |
| 377 | + | (seq_id == SEQ_ID_MAX_VAL && seg_len > MBOX_LAST_SEG_MAX_LEN)) | |
| 376 | 378 | return false; | |
| 377 | 379 | ||
| 378 | 380 | if (seq_id == 0) { | |
modified drivers/net/ethernet/intel/ice/ice_common.c
| @@ -1051,14 +1051,13 @@ int ice_init_hw(struct ice_hw *hw) | |||
| 1051 | 1051 | ||
| 1052 | 1052 | hw->evb_veb = true; | |
| 1053 | 1053 | ||
| 1054 | - | /* init xarray for identifying scheduling nodes uniquely */ | |
| 1055 | - | xa_init_flags(&hw->port_info->sched_node_ids, XA_FLAGS_ALLOC); | |
| 1054 | + | xa_init_flags(&hw->sched_node_ids, XA_FLAGS_ALLOC); | |
| 1056 | 1055 | ||
| 1057 | 1056 | /* Query the allocated resources for Tx scheduler */ | |
| 1058 | 1057 | status = ice_sched_query_res_alloc(hw); | |
| 1059 | 1058 | if (status) { | |
| 1060 | 1059 | ice_debug(hw, ICE_DBG_SCHED, "Failed to get scheduler allocated resources\n"); | |
| 1061 | - | goto err_unroll_alloc; | |
| 1060 | + | goto err_unroll_xarray; | |
| 1062 | 1061 | } | |
| 1063 | 1062 | ice_sched_get_psm_clk_freq(hw); | |
| 1064 | 1063 | ||
| @@ -1146,6 +1145,8 @@ err_unroll_fltr_mgmt_struct: | |||
| 1146 | 1145 | ice_cleanup_fltr_mgmt_struct(hw); | |
| 1147 | 1146 | err_unroll_sched: | |
| 1148 | 1147 | ice_sched_cleanup_all(hw); | |
| 1148 | + | err_unroll_xarray: | |
| 1149 | + | xa_destroy(&hw->sched_node_ids); | |
| 1149 | 1150 | err_unroll_alloc: | |
| 1150 | 1151 | devm_kfree(ice_hw_to_dev(hw), hw->port_info); | |
| 1151 | 1152 | err_unroll_cqinit: | |
| @@ -1186,6 +1187,8 @@ void ice_deinit_hw(struct ice_hw *hw) | |||
| 1186 | 1187 | ||
| 1187 | 1188 | /* Clear VSI contexts if not already cleared */ | |
| 1188 | 1189 | ice_clear_all_vsi_ctx(hw); | |
| 1190 | + | ||
| 1191 | + | xa_destroy(&hw->sched_node_ids); | |
| 1189 | 1192 | } | |
| 1190 | 1193 | ||
| 1191 | 1194 | /** | |
modified drivers/net/ethernet/intel/ice/ice_sched.c
| @@ -371,7 +371,7 @@ void ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node) | |||
| 371 | 371 | ||
| 372 | 372 | devm_kfree(ice_hw_to_dev(hw), node->children); | |
| 373 | 373 | kfree(node->name); | |
| 374 | - | xa_erase(&pi->sched_node_ids, node->id); | |
| 374 | + | xa_erase(&hw->sched_node_ids, node->id); | |
| 375 | 375 | devm_kfree(ice_hw_to_dev(hw), node); | |
| 376 | 376 | } | |
| 377 | 377 | ||
| @@ -977,7 +977,7 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, | |||
| 977 | 977 | if (!new_node->name) | |
| 978 | 978 | return -ENOMEM; | |
| 979 | 979 | ||
| 980 | - | status = xa_alloc(&pi->sched_node_ids, &new_node->id, NULL, XA_LIMIT(0, UINT_MAX), | |
| 980 | + | status = xa_alloc(&hw->sched_node_ids, &new_node->id, NULL, XA_LIMIT(0, UINT_MAX), | |
| 981 | 981 | GFP_KERNEL); | |
| 982 | 982 | if (status) { | |
| 983 | 983 | ice_debug(hw, ICE_DBG_SCHED, "xa_alloc failed for sched node status =%d\n", | |
modified drivers/net/ethernet/intel/ice/ice_trace.h
| @@ -63,23 +63,33 @@ | |||
| 63 | 63 | DECLARE_EVENT_CLASS(ice_rx_dim_template, | |
| 64 | 64 | TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim), | |
| 65 | 65 | TP_ARGS(q_vector, dim), | |
| 66 | - | TP_STRUCT__entry(__field(struct ice_q_vector *, q_vector) | |
| 67 | - | __field(struct dim *, dim) | |
| 66 | + | TP_STRUCT__entry(__field(u16, q_index) | |
| 67 | + | __field(u8, state) | |
| 68 | + | __field(u8, profile_ix) | |
| 69 | + | __field(u8, tune_state) | |
| 70 | + | __field(u8, steps_right) | |
| 71 | + | __field(u8, steps_left) | |
| 72 | + | __field(u8, tired) | |
| 68 | 73 | __string(devname, q_vector->rx.rx_ring->netdev->name)), | |
| 69 | 74 | ||
| 70 | - | TP_fast_assign(__entry->q_vector = q_vector; | |
| 71 | - | __entry->dim = dim; | |
| 75 | + | TP_fast_assign(__entry->q_index = q_vector->rx.rx_ring->q_index; | |
| 76 | + | __entry->state = dim->state; | |
| 77 | + | __entry->profile_ix = dim->profile_ix; | |
| 78 | + | __entry->tune_state = dim->tune_state; | |
| 79 | + | __entry->steps_right = dim->steps_right; | |
| 80 | + | __entry->steps_left = dim->steps_left; | |
| 81 | + | __entry->tired = dim->tired; | |
| 72 | 82 | __assign_str(devname);), | |
| 73 | 83 | ||
| 74 | 84 | TP_printk("netdev: %s Rx-Q: %d dim-state: %d dim-profile: %d dim-tune: %d dim-st-right: %d dim-st-left: %d dim-tired: %d", | |
| 75 | 85 | __get_str(devname), | |
| 76 | - | __entry->q_vector->rx.rx_ring->q_index, | |
| 77 | - | __entry->dim->state, | |
| 78 | - | __entry->dim->profile_ix, | |
| 79 | - | __entry->dim->tune_state, | |
| 80 | - | __entry->dim->steps_right, | |
| 81 | - | __entry->dim->steps_left, | |
| 82 | - | __entry->dim->tired) | |
| 86 | + | __entry->q_index, | |
| 87 | + | __entry->state, | |
| 88 | + | __entry->profile_ix, | |
| 89 | + | __entry->tune_state, | |
| 90 | + | __entry->steps_right, | |
| 91 | + | __entry->steps_left, | |
| 92 | + | __entry->tired) | |
| 83 | 93 | ); | |
| 84 | 94 | ||
| 85 | 95 | DEFINE_EVENT(ice_rx_dim_template, ice_rx_dim_work, | |
| @@ -90,23 +100,33 @@ DEFINE_EVENT(ice_rx_dim_template, ice_rx_dim_work, | |||
| 90 | 100 | DECLARE_EVENT_CLASS(ice_tx_dim_template, | |
| 91 | 101 | TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim), | |
| 92 | 102 | TP_ARGS(q_vector, dim), | |
| 93 | - | TP_STRUCT__entry(__field(struct ice_q_vector *, q_vector) | |
| 94 | - | __field(struct dim *, dim) | |
| 103 | + | TP_STRUCT__entry(__field(u16, q_index) | |
| 104 | + | __field(u8, state) | |
| 105 | + | __field(u8, profile_ix) | |
| 106 | + | __field(u8, tune_state) | |
| 107 | + | __field(u8, steps_right) | |
| 108 | + | __field(u8, steps_left) | |
| 109 | + | __field(u8, tired) | |
| 95 | 110 | __string(devname, q_vector->tx.tx_ring->netdev->name)), | |
| 96 | 111 | ||
| 97 | - | TP_fast_assign(__entry->q_vector = q_vector; | |
| 98 | - | __entry->dim = dim; | |
| 112 | + | TP_fast_assign(__entry->q_index = q_vector->tx.tx_ring->q_index; | |
| 113 | + | __entry->state = dim->state; | |
| 114 | + | __entry->profile_ix = dim->profile_ix; | |
| 115 | + | __entry->tune_state = dim->tune_state; | |
| 116 | + | __entry->steps_right = dim->steps_right; | |
| 117 | + | __entry->steps_left = dim->steps_left; | |
| 118 | + | __entry->tired = dim->tired; | |
| 99 | 119 | __assign_str(devname);), | |
| 100 | 120 | ||
| 101 | 121 | TP_printk("netdev: %s Tx-Q: %d dim-state: %d dim-profile: %d dim-tune: %d dim-st-right: %d dim-st-left: %d dim-tired: %d", | |
| 102 | 122 | __get_str(devname), | |
| 103 | - | __entry->q_vector->tx.tx_ring->q_index, | |
| 104 | - | __entry->dim->state, | |
| 105 | - | __entry->dim->profile_ix, | |
| 106 | - | __entry->dim->tune_state, | |
| 107 | - | __entry->dim->steps_right, | |
| 108 | - | __entry->dim->steps_left, | |
| 109 | - | __entry->dim->tired) | |
| 123 | + | __entry->q_index, | |
| 124 | + | __entry->state, | |
| 125 | + | __entry->profile_ix, | |
| 126 | + | __entry->tune_state, | |
| 127 | + | __entry->steps_right, | |
| 128 | + | __entry->steps_left, | |
| 129 | + | __entry->tired) | |
| 110 | 130 | ); | |
| 111 | 131 | ||
| 112 | 132 | DEFINE_EVENT(ice_tx_dim_template, ice_tx_dim_work, | |
modified drivers/net/ethernet/intel/ice/ice_type.h
| @@ -765,7 +765,6 @@ struct ice_port_info { | |||
| 765 | 765 | /* List contain profile ID(s) and other params per layer */ | |
| 766 | 766 | struct list_head rl_prof_list[ICE_AQC_TOPO_MAX_LEVEL_NUM]; | |
| 767 | 767 | struct ice_qos_cfg qos_cfg; | |
| 768 | - | struct xarray sched_node_ids; | |
| 769 | 768 | u8 is_vf:1; | |
| 770 | 769 | u8 is_custom_tx_enabled:1; | |
| 771 | 770 | }; | |
| @@ -930,6 +929,7 @@ struct ice_hw { | |||
| 930 | 929 | u8 sw_entry_point_layer; | |
| 931 | 930 | u16 max_children[ICE_AQC_TOPO_MAX_LEVEL_NUM]; | |
| 932 | 931 | struct list_head agg_list; /* lists all aggregator */ | |
| 932 | + | struct xarray sched_node_ids; | |
| 933 | 933 | ||
| 934 | 934 | struct ice_vsi_ctx *vsi_ctx[ICE_MAX_VSI]; | |
| 935 | 935 | u8 evb_veb; /* true for VEB, false for VEPA */ | |
modified drivers/net/ethernet/intel/idpf/idpf_main.c
| @@ -106,6 +106,11 @@ static int idpf_dev_init(struct idpf_adapter *adapter, | |||
| 106 | 106 | */ | |
| 107 | 107 | static void idpf_decfg_device(struct idpf_adapter *adapter) | |
| 108 | 108 | { | |
| 109 | + | struct pci_dev *pdev = adapter->pdev; | |
| 110 | + | ||
| 111 | + | if (pcie_ptm_enabled(pdev)) | |
| 112 | + | pci_disable_ptm(pdev); | |
| 113 | + | ||
| 109 | 114 | libie_pci_unmap_all_mmio_regions(&adapter->ctlq_ctx.mmio_info); | |
| 110 | 115 | } | |
| 111 | 116 | ||
modified drivers/net/ethernet/intel/idpf/idpf_txrx.c
| @@ -3299,6 +3299,7 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb, | |||
| 3299 | 3299 | struct libeth_rx_pt decoded) | |
| 3300 | 3300 | { | |
| 3301 | 3301 | u16 rsc_segments, rsc_seg_len; | |
| 3302 | + | u16 l3_start = 0; | |
| 3302 | 3303 | bool ipv4, ipv6; | |
| 3303 | 3304 | int len; | |
| 3304 | 3305 | ||
| @@ -3321,7 +3322,10 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb, | |||
| 3321 | 3322 | NAPI_GRO_CB(skb)->count = rsc_segments; | |
| 3322 | 3323 | skb_shinfo(skb)->gso_size = rsc_seg_len; | |
| 3323 | 3324 | ||
| 3324 | - | skb_reset_network_header(skb); | |
| 3325 | + | if (unlikely(eth_type_vlan(skb->protocol))) | |
| 3326 | + | l3_start = VLAN_HLEN; | |
| 3327 | + | ||
| 3328 | + | skb_set_network_header(skb, l3_start); | |
| 3325 | 3329 | ||
| 3326 | 3330 | if (ipv4) { | |
| 3327 | 3331 | struct iphdr *ipv4h = ip_hdr(skb); | |
| @@ -3329,7 +3333,7 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb, | |||
| 3329 | 3333 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; | |
| 3330 | 3334 | ||
| 3331 | 3335 | /* Reset and set transport header offset in skb */ | |
| 3332 | - | skb_set_transport_header(skb, sizeof(struct iphdr)); | |
| 3336 | + | skb_set_transport_header(skb, l3_start + sizeof(struct iphdr)); | |
| 3333 | 3337 | len = skb->len - skb_transport_offset(skb); | |
| 3334 | 3338 | ||
| 3335 | 3339 | /* Compute the TCP pseudo header checksum*/ | |
| @@ -3339,7 +3343,7 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb, | |||
| 3339 | 3343 | struct ipv6hdr *ipv6h = ipv6_hdr(skb); | |
| 3340 | 3344 | ||
| 3341 | 3345 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; | |
| 3342 | - | skb_set_transport_header(skb, sizeof(struct ipv6hdr)); | |
| 3346 | + | skb_set_transport_header(skb, l3_start + sizeof(struct ipv6hdr)); | |
| 3343 | 3347 | len = skb->len - skb_transport_offset(skb); | |
| 3344 | 3348 | tcp_hdr(skb)->check = | |
| 3345 | 3349 | ~tcp_v6_check(len, &ipv6h->saddr, &ipv6h->daddr, 0); | |
| @@ -4145,6 +4149,26 @@ static void idpf_vport_intr_ena_irq_all(struct idpf_vport *vport, | |||
| 4145 | 4149 | writel(rsrc->noirq_dyn_ctl_ena, rsrc->noirq_dyn_ctl); | |
| 4146 | 4150 | } | |
| 4147 | 4151 | ||
| 4152 | + | /** | |
| 4153 | + | * idpf_vport_intr_dis_dim_all - Disable DIM work for all q_vectors | |
| 4154 | + | * @rsrc: pointer to queue and vector resources | |
| 4155 | + | * | |
| 4156 | + | * The DIM works are embedded in the q_vector array that | |
| 4157 | + | * idpf_vport_intr_rel() frees, and the poll arms them after | |
| 4158 | + | * napi_complete_done() has already cleared NAPI_STATE_SCHED. Disable | |
| 4159 | + | * rather than just cancel, so that a poll tail still running past | |
| 4160 | + | * napi_disable() cannot queue them again behind the drain. | |
| 4161 | + | */ | |
| 4162 | + | static void idpf_vport_intr_dis_dim_all(struct idpf_q_vec_rsrc *rsrc) | |
| 4163 | + | { | |
| 4164 | + | for (u16 v_idx = 0; v_idx < rsrc->num_q_vectors; v_idx++) { | |
| 4165 | + | struct idpf_q_vector *q_vector = &rsrc->q_vectors[v_idx]; | |
| 4166 | + | ||
| 4167 | + | disable_work_sync(&q_vector->tx_dim.work); | |
| 4168 | + | disable_work_sync(&q_vector->rx_dim.work); | |
| 4169 | + | } | |
| 4170 | + | } | |
| 4171 | + | ||
| 4148 | 4172 | /** | |
| 4149 | 4173 | * idpf_vport_intr_deinit - Release all vector associations for the vport | |
| 4150 | 4174 | * @vport: main vport structure | |
| @@ -4155,6 +4179,7 @@ void idpf_vport_intr_deinit(struct idpf_vport *vport, | |||
| 4155 | 4179 | { | |
| 4156 | 4180 | idpf_vport_intr_dis_irq_all(rsrc); | |
| 4157 | 4181 | idpf_vport_intr_napi_dis_all(rsrc); | |
| 4182 | + | idpf_vport_intr_dis_dim_all(rsrc); | |
| 4158 | 4183 | idpf_vport_intr_napi_del_all(rsrc); | |
| 4159 | 4184 | idpf_vport_intr_rel_irq(vport, rsrc); | |
| 4160 | 4185 | } | |
| @@ -4235,7 +4260,6 @@ static void idpf_vport_intr_napi_ena_all(struct idpf_q_vec_rsrc *rsrc) | |||
| 4235 | 4260 | for (u16 q_idx = 0; q_idx < rsrc->num_q_vectors; q_idx++) { | |
| 4236 | 4261 | struct idpf_q_vector *q_vector = &rsrc->q_vectors[q_idx]; | |
| 4237 | 4262 | ||
| 4238 | - | idpf_init_dim(q_vector); | |
| 4239 | 4263 | napi_enable(&q_vector->napi); | |
| 4240 | 4264 | } | |
| 4241 | 4265 | } | |
| @@ -4578,6 +4602,8 @@ int idpf_vport_intr_alloc(struct idpf_vport *vport, | |||
| 4578 | 4602 | q_coal = &user_config->q_coalesce[v_idx]; | |
| 4579 | 4603 | q_vector->vport = vport; | |
| 4580 | 4604 | ||
| 4605 | + | idpf_init_dim(q_vector); | |
| 4606 | + | ||
| 4581 | 4607 | q_vector->tx_itr_value = q_coal->tx_coalesce_usecs; | |
| 4582 | 4608 | q_vector->tx_intr_mode = q_coal->tx_intr_mode; | |
| 4583 | 4609 | q_vector->tx_itr_idx = VIRTCHNL2_ITR_IDX_1; | |
modified drivers/net/ethernet/intel/libie/controlq.c
| @@ -157,8 +157,7 @@ static void libie_ctlq_free_tx_msgs(struct libie_ctlq_info *ctlq, | |||
| 157 | 157 | */ | |
| 158 | 158 | static int libie_ctlq_alloc_tx_msgs(struct libie_ctlq_info *ctlq) | |
| 159 | 159 | { | |
| 160 | - | ctlq->tx_msg = kvzalloc_objs(*ctlq->tx_msg, ctlq->ring_len, | |
| 161 | - | GFP_KERNEL); | |
| 160 | + | ctlq->tx_msg = kvzalloc_objs(*ctlq->tx_msg, ctlq->ring_len); | |
| 162 | 161 | if (!ctlq->tx_msg) | |
| 163 | 162 | return -ENOMEM; | |
| 164 | 163 | ||
modified drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
| @@ -3647,7 +3647,7 @@ static int npc_defrag_add_2_show_list(struct rvu *rvu, u16 old_midx, | |||
| 3647 | 3647 | { | |
| 3648 | 3648 | struct npc_defrag_show_node *node; | |
| 3649 | 3649 | ||
| 3650 | - | node = kcalloc(1, sizeof(*node), GFP_KERNEL); | |
| 3650 | + | node = kzalloc_objs(*node, 1); | |
| 3651 | 3651 | if (!node) | |
| 3652 | 3652 | return -ENOMEM; | |
| 3653 | 3653 | ||
| @@ -4082,7 +4082,7 @@ int npc_cn20k_defrag(struct rvu *rvu) | |||
| 4082 | 4082 | INIT_LIST_HEAD(&x4lh); | |
| 4083 | 4083 | INIT_LIST_HEAD(&x2lh); | |
| 4084 | 4084 | ||
| 4085 | - | node = kcalloc(npc_priv->num_subbanks, sizeof(*node), GFP_KERNEL); | |
| 4085 | + | node = kzalloc_objs(*node, npc_priv->num_subbanks); | |
| 4086 | 4086 | if (!node) | |
| 4087 | 4087 | return -ENOMEM; | |
| 4088 | 4088 | ||
| @@ -4711,7 +4711,7 @@ static int npc_priv_init(struct rvu *rvu) | |||
| 4711 | 4711 | return -EINVAL; | |
| 4712 | 4712 | } | |
| 4713 | 4713 | ||
| 4714 | - | npc_priv = kcalloc(1, sizeof(*npc_priv), GFP_KERNEL); | |
| 4714 | + | npc_priv = kzalloc_objs(*npc_priv, 1); | |
| 4715 | 4715 | if (!npc_priv) | |
| 4716 | 4716 | return -ENOMEM; | |
| 4717 | 4717 | ||
| @@ -4729,8 +4729,7 @@ static int npc_priv_init(struct rvu *rvu) | |||
| 4729 | 4729 | num_banks, bank_depth, num_subbanks, subbank_depth, | |
| 4730 | 4730 | npc_kw_name[npc_priv->kw]); | |
| 4731 | 4731 | ||
| 4732 | - | npc_priv->sb = kcalloc(num_subbanks, sizeof(struct npc_subbank), | |
| 4733 | - | GFP_KERNEL); | |
| 4732 | + | npc_priv->sb = kzalloc_objs(struct npc_subbank, num_subbanks); | |
| 4734 | 4733 | if (!npc_priv->sb) | |
| 4735 | 4734 | goto fail1; | |
| 4736 | 4735 | ||
| @@ -4757,9 +4756,7 @@ static int npc_priv_init(struct rvu *rvu) | |||
| 4757 | 4756 | ||
| 4758 | 4757 | /* Get number of pcifuncs in the system */ | |
| 4759 | 4758 | npc_priv->pf_cnt = npc_pcifunc_map_create(rvu); | |
| 4760 | - | npc_priv->xa_pf2idx_map = kcalloc(npc_priv->pf_cnt, | |
| 4761 | - | sizeof(struct xarray), | |
| 4762 | - | GFP_KERNEL); | |
| 4759 | + | npc_priv->xa_pf2idx_map = kzalloc_objs(struct xarray, npc_priv->pf_cnt); | |
| 4763 | 4760 | if (!npc_priv->xa_pf2idx_map) { | |
| 4764 | 4761 | ret = -ENOMEM; | |
| 4765 | 4762 | goto fail3; | |
modified drivers/net/ethernet/marvell/octeontx2/af/mcs.c
| @@ -1417,6 +1417,16 @@ static int mcs_x2p_calibration(struct mcs *mcs) | |||
| 1417 | 1417 | int i, err = 0; | |
| 1418 | 1418 | u64 val; | |
| 1419 | 1419 | ||
| 1420 | + | /* Clear any stale calibration state left by firmware/bootloader. | |
| 1421 | + | * Some firmware versions may leave MCSX_MIL_GLOBAL bit 5 set, | |
| 1422 | + | * preventing the hardware from detecting the rising edge needed to | |
| 1423 | + | * trigger X2P calibration. | |
| 1424 | + | */ | |
| 1425 | + | val = mcs_reg_read(mcs, MCSX_MIL_GLOBAL); | |
| 1426 | + | val &= ~BIT_ULL(5); | |
| 1427 | + | mcs_reg_write(mcs, MCSX_MIL_GLOBAL, val); | |
| 1428 | + | usleep_range(100, 200); | |
| 1429 | + | ||
| 1420 | 1430 | /* set X2P calibration */ | |
| 1421 | 1431 | val = mcs_reg_read(mcs, MCSX_MIL_GLOBAL); | |
| 1422 | 1432 | val |= BIT_ULL(5); | |
modified drivers/net/ethernet/marvell/octeontx2/af/rvu.c
| @@ -3468,6 +3468,8 @@ err: | |||
| 3468 | 3468 | return ret; | |
| 3469 | 3469 | } | |
| 3470 | 3470 | ||
| 3471 | + | #define PCI_DEVID_OCTEONTX2_RVU_AFVF 0xA0F8 | |
| 3472 | + | ||
| 3471 | 3473 | static int rvu_enable_sriov(struct rvu *rvu) | |
| 3472 | 3474 | { | |
| 3473 | 3475 | struct pci_dev *pdev = rvu->pdev; | |
| @@ -3486,24 +3488,27 @@ static int rvu_enable_sriov(struct rvu *rvu) | |||
| 3486 | 3488 | return 0; | |
| 3487 | 3489 | pci_read_config_word(pdev, pos + PCI_SRIOV_VF_DID, &rvu->vf_devid); | |
| 3488 | 3490 | ||
| 3489 | - | chans = rvu_get_num_lbk_chans(); | |
| 3490 | - | if (chans < 0) | |
| 3491 | - | return chans; | |
| 3492 | - | ||
| 3493 | 3491 | vfs = pci_sriov_get_totalvfs(pdev); | |
| 3494 | - | ||
| 3495 | - | /* Limit VFs in case we have more VFs than LBK channels available. */ | |
| 3496 | - | if (vfs > chans) | |
| 3497 | - | vfs = chans; | |
| 3498 | - | ||
| 3499 | 3492 | if (!vfs) | |
| 3500 | 3493 | return 0; | |
| 3501 | 3494 | ||
| 3502 | - | /* LBK channel number 63 is used for switching packets between | |
| 3503 | - | * CGX mapped VFs. Hence limit LBK pairs till 62 only. | |
| 3504 | - | */ | |
| 3505 | - | if (vfs > 62) | |
| 3506 | - | vfs = 62; | |
| 3495 | + | if (rvu->vf_devid == PCI_DEVID_OCTEONTX2_RVU_AFVF) { | |
| 3496 | + | chans = rvu_get_num_lbk_chans(); | |
| 3497 | + | if (chans < 0) | |
| 3498 | + | return chans; | |
| 3499 | + | ||
| 3500 | + | /* The last LBK channel is reserved for switching packets between | |
| 3501 | + | * CGX mapped VFs. Also, since LBK VFs work in pairs, limit VF | |
| 3502 | + | * count to available LBK channels minus 2. | |
| 3503 | + | */ | |
| 3504 | + | vfs = min(vfs, chans - 2); | |
| 3505 | + | ||
| 3506 | + | if (vfs <= 0) { | |
| 3507 | + | dev_warn(&pdev->dev, | |
| 3508 | + | "Skipping SRIOV enablement, not enough LBK channels available\n"); | |
| 3509 | + | return 0; | |
| 3510 | + | } | |
| 3511 | + | } | |
| 3507 | 3512 | ||
| 3508 | 3513 | /* Save VFs number for reference in VF interrupts handlers. | |
| 3509 | 3514 | * Since interrupts might start arriving during SRIOV enablement | |
modified drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
| @@ -829,19 +829,25 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused) | |||
| 829 | 829 | int pf, domain, blkid; | |
| 830 | 830 | u8 cgx_id, lmac_id; | |
| 831 | 831 | u16 pcifunc; | |
| 832 | + | u8 start; | |
| 832 | 833 | ||
| 833 | - | domain = 2; | |
| 834 | + | domain = pci_domain_nr(rvu->pdev->bus); | |
| 834 | 835 | mac_ops = get_mac_ops(rvu_first_cgx_pdata(rvu)); | |
| 835 | 836 | /* There can be no CGX devices at all */ | |
| 836 | 837 | if (!mac_ops) | |
| 837 | 838 | return 0; | |
| 838 | 839 | seq_printf(filp, "PCI dev\t\tRVU PF Func\tNIX block\t%s\tLMAC\tCHAN\n", | |
| 839 | 840 | mac_ops->name); | |
| 841 | + | ||
| 842 | + | /* All the PF devices are on contiguous PCI bus numbers, but the PF0(AF) | |
| 843 | + | * may not start from 1 always. Hence get domain and bus from PCI device. | |
| 844 | + | */ | |
| 845 | + | start = rvu->pdev->bus->number; | |
| 840 | 846 | for (pf = 0; pf < rvu->hw->total_pfs; pf++) { | |
| 841 | 847 | if (!is_pf_cgxmapped(rvu, pf)) | |
| 842 | 848 | continue; | |
| 843 | 849 | ||
| 844 | - | pdev = pci_get_domain_bus_and_slot(domain, pf + 1, 0); | |
| 850 | + | pdev = pci_get_domain_bus_and_slot(domain, pf + start, 0); | |
| 845 | 851 | if (!pdev) | |
| 846 | 852 | continue; | |
| 847 | 853 | ||
modified drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
| @@ -2957,10 +2957,9 @@ static void npc_mcam_free_all_entries(struct rvu *rvu, struct npc_mcam *mcam, | |||
| 2957 | 2957 | } | |
| 2958 | 2958 | } | |
| 2959 | 2959 | ||
| 2960 | - | /* Disable the entry */ | |
| 2961 | - | npc_enable_mcam_entry(rvu, mcam, blkaddr, index, false); | |
| 2962 | - | ||
| 2963 | 2960 | if (!cn20k_dft_rl) { | |
| 2961 | + | /* Disable the entry */ | |
| 2962 | + | npc_enable_mcam_entry(rvu, mcam, blkaddr, index, false); | |
| 2964 | 2963 | mcam->entry2pfvf_map[index] = NPC_MCAM_INVALID_MAP; | |
| 2965 | 2964 | /* Free the entry in bitmap */ | |
| 2966 | 2965 | npc_mcam_clear_bit(mcam, index); | |
modified drivers/net/ethernet/marvell/octeontx2/nic/qos.c
| @@ -235,13 +235,63 @@ static int otx2_qos_txschq_set_parent_topology(struct otx2_nic *pfvf, | |||
| 235 | 235 | return rc; | |
| 236 | 236 | } | |
| 237 | 237 | ||
| 238 | + | static int otx2_qos_reset_schq_topology(struct otx2_nic *pfvf, u16 lvl, | |
| 239 | + | u16 schq) | |
| 240 | + | { | |
| 241 | + | struct mbox *mbox = &pfvf->mbox; | |
| 242 | + | struct nix_txschq_config *cfg; | |
| 243 | + | int rc; | |
| 244 | + | ||
| 245 | + | if (lvl < NIX_TXSCH_LVL_TL4 || lvl >= NIX_TXSCH_LVL_TL1) | |
| 246 | + | return 0; | |
| 247 | + | ||
| 248 | + | mutex_lock(&mbox->lock); | |
| 249 | + | ||
| 250 | + | cfg = otx2_mbox_alloc_msg_nix_txschq_cfg(mbox); | |
| 251 | + | if (!cfg) { | |
| 252 | + | mutex_unlock(&mbox->lock); | |
| 253 | + | return -ENOMEM; | |
| 254 | + | } | |
| 255 | + | ||
| 256 | + | cfg->lvl = lvl; | |
| 257 | + | cfg->num_regs = 1; | |
| 258 | + | ||
| 259 | + | if (lvl == NIX_TXSCH_LVL_TL4) | |
| 260 | + | cfg->reg[0] = NIX_AF_TL4X_TOPOLOGY(schq); | |
| 261 | + | else if (lvl == NIX_TXSCH_LVL_TL3) | |
| 262 | + | cfg->reg[0] = NIX_AF_TL3X_TOPOLOGY(schq); | |
| 263 | + | else if (lvl == NIX_TXSCH_LVL_TL2) | |
| 264 | + | cfg->reg[0] = NIX_AF_TL2X_TOPOLOGY(schq); | |
| 265 | + | ||
| 266 | + | cfg->regval[0] = 0; | |
| 267 | + | ||
| 268 | + | rc = otx2_sync_mbox_msg(mbox); | |
| 269 | + | ||
| 270 | + | mutex_unlock(&mbox->lock); | |
| 271 | + | ||
| 272 | + | return rc; | |
| 273 | + | } | |
| 274 | + | ||
| 275 | + | static void otx2_qos_free_hw_schq(struct otx2_nic *pfvf, u16 lvl, u16 schq) | |
| 276 | + | { | |
| 277 | + | int err; | |
| 278 | + | ||
| 279 | + | err = otx2_qos_reset_schq_topology(pfvf, lvl, schq); | |
| 280 | + | if (err) | |
| 281 | + | netdev_warn(pfvf->netdev, | |
| 282 | + | "QoS: failed to reset topology for schq %u at level %u: %d\n", | |
| 283 | + | schq, lvl, err); | |
| 284 | + | ||
| 285 | + | otx2_txschq_free_one(pfvf, lvl, schq); | |
| 286 | + | } | |
| 287 | + | ||
| 238 | 288 | static void otx2_qos_free_hw_node_schq(struct otx2_nic *pfvf, | |
| 239 | 289 | struct otx2_qos_node *parent) | |
| 240 | 290 | { | |
| 241 | 291 | struct otx2_qos_node *node; | |
| 242 | 292 | ||
| 243 | 293 | list_for_each_entry_reverse(node, &parent->child_schq_list, list) | |
| 244 | - | otx2_txschq_free_one(pfvf, node->level, node->schq); | |
| 294 | + | otx2_qos_free_hw_schq(pfvf, node->level, node->schq); | |
| 245 | 295 | } | |
| 246 | 296 | ||
| 247 | 297 | static void otx2_qos_free_hw_node(struct otx2_nic *pfvf, | |
| @@ -252,7 +302,7 @@ static void otx2_qos_free_hw_node(struct otx2_nic *pfvf, | |||
| 252 | 302 | list_for_each_entry_safe(node, tmp, &parent->child_list, list) { | |
| 253 | 303 | otx2_qos_free_hw_node(pfvf, node); | |
| 254 | 304 | otx2_qos_free_hw_node_schq(pfvf, node); | |
| 255 | - | otx2_txschq_free_one(pfvf, node->level, node->schq); | |
| 305 | + | otx2_qos_free_hw_schq(pfvf, node->level, node->schq); | |
| 256 | 306 | } | |
| 257 | 307 | } | |
| 258 | 308 | ||
| @@ -266,7 +316,7 @@ static void otx2_qos_free_hw_cfg(struct otx2_nic *pfvf, | |||
| 266 | 316 | otx2_qos_free_hw_node_schq(pfvf, node); | |
| 267 | 317 | ||
| 268 | 318 | /* free node hw mappings */ | |
| 269 | - | otx2_txschq_free_one(pfvf, node->level, node->schq); | |
| 319 | + | otx2_qos_free_hw_schq(pfvf, node->level, node->schq); | |
| 270 | 320 | ||
| 271 | 321 | mutex_unlock(&pfvf->qos.qos_lock); | |
| 272 | 322 | } | |
| @@ -913,7 +963,7 @@ static void otx2_qos_free_cfg(struct otx2_nic *pfvf, struct otx2_qos_cfg *cfg) | |||
| 913 | 963 | for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) { | |
| 914 | 964 | for (idx = 0; idx < cfg->schq[lvl]; idx++) { | |
| 915 | 965 | schq = cfg->schq_list[lvl][idx]; | |
| 916 | - | otx2_txschq_free_one(pfvf, lvl, schq); | |
| 966 | + | otx2_qos_free_hw_schq(pfvf, lvl, schq); | |
| 917 | 967 | } | |
| 918 | 968 | } | |
| 919 | 969 | ||
| @@ -921,7 +971,7 @@ static void otx2_qos_free_cfg(struct otx2_nic *pfvf, struct otx2_qos_cfg *cfg) | |||
| 921 | 971 | for (idx = 0; idx < cfg->schq_contig[lvl]; idx++) { | |
| 922 | 972 | if (cfg->schq_index_used[lvl][idx]) { | |
| 923 | 973 | schq = cfg->schq_contig_list[lvl][idx]; | |
| 924 | - | otx2_txschq_free_one(pfvf, lvl, schq); | |
| 974 | + | otx2_qos_free_hw_schq(pfvf, lvl, schq); | |
| 925 | 975 | } | |
| 926 | 976 | } | |
| 927 | 977 | } | |
modified drivers/net/ethernet/mediatek/mtk_eth_soc.c
| @@ -4828,7 +4828,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) | |||
| 4828 | 4828 | phy_interface_t phy_mode; | |
| 4829 | 4829 | struct phylink *phylink; | |
| 4830 | 4830 | struct mtk_mac *mac; | |
| 4831 | - | int id, err; | |
| 4831 | + | int id, err, i; | |
| 4832 | 4832 | int txqs = 1; | |
| 4833 | 4833 | u32 val; | |
| 4834 | 4834 | ||
| @@ -4907,8 +4907,8 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) | |||
| 4907 | 4907 | mac->phylink_config.type = PHYLINK_NETDEV; | |
| 4908 | 4908 | mac->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | | |
| 4909 | 4909 | MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD; | |
| 4910 | - | mac->phylink_config.lpi_capabilities = MAC_100FD | MAC_1000FD | | |
| 4911 | - | MAC_2500FD; | |
| 4910 | + | /* LPI above 1 Gbps is not supported */ | |
| 4911 | + | mac->phylink_config.lpi_capabilities = MAC_100FD | MAC_1000FD; | |
| 4912 | 4912 | mac->phylink_config.lpi_timer_default = 1000; | |
| 4913 | 4913 | ||
| 4914 | 4914 | /* MT7623 gmac0 is now missing its speed-specific PLL configuration | |
| @@ -4966,6 +4966,18 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) | |||
| 4966 | 4966 | __set_bit(PHY_INTERFACE_MODE_INTERNAL, | |
| 4967 | 4967 | mac->phylink_config.supported_interfaces); | |
| 4968 | 4968 | ||
| 4969 | + | /* LPI wake-up timing is only verified on MTK_GMAC_EEE SoCs */ | |
| 4970 | + | if (MTK_HAS_CAPS(eth->soc->caps, MTK_GMAC_EEE)) { | |
| 4971 | + | phy_interface_copy(mac->phylink_config.lpi_interfaces, | |
| 4972 | + | mac->phylink_config.supported_interfaces); | |
| 4973 | + | __clear_bit(PHY_INTERFACE_MODE_2500BASEX, | |
| 4974 | + | mac->phylink_config.lpi_interfaces); | |
| 4975 | + | for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++) | |
| 4976 | + | if (mtk_interface_mode_is_xgmii(eth, i)) | |
| 4977 | + | __clear_bit(i, | |
| 4978 | + | mac->phylink_config.lpi_interfaces); | |
| 4979 | + | } | |
| 4980 | + | ||
| 4969 | 4981 | phylink = phylink_create(&mac->phylink_config, | |
| 4970 | 4982 | of_fwnode_handle(mac->of_node), | |
| 4971 | 4983 | phy_mode, mac_ops); | |
modified drivers/net/ethernet/mediatek/mtk_eth_soc.h
| @@ -994,6 +994,7 @@ enum mkt_eth_capabilities { | |||
| 994 | 994 | MTK_U3_COPHY_V2_BIT, | |
| 995 | 995 | MTK_SRAM_BIT, | |
| 996 | 996 | MTK_36BIT_DMA_BIT, | |
| 997 | + | MTK_GMAC_EEE_BIT, | |
| 997 | 998 | ||
| 998 | 999 | /* MUX BITS*/ | |
| 999 | 1000 | MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT, | |
| @@ -1034,6 +1035,7 @@ enum mkt_eth_capabilities { | |||
| 1034 | 1035 | #define MTK_U3_COPHY_V2 BIT_ULL(MTK_U3_COPHY_V2_BIT) | |
| 1035 | 1036 | #define MTK_SRAM BIT_ULL(MTK_SRAM_BIT) | |
| 1036 | 1037 | #define MTK_36BIT_DMA BIT_ULL(MTK_36BIT_DMA_BIT) | |
| 1038 | + | #define MTK_GMAC_EEE BIT_ULL(MTK_GMAC_EEE_BIT) | |
| 1037 | 1039 | ||
| 1038 | 1040 | #define MTK_ETH_MUX_GDM1_TO_GMAC1_ESW \ | |
| 1039 | 1041 | BIT_ULL(MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT) | |
| @@ -1117,7 +1119,7 @@ enum mkt_eth_capabilities { | |||
| 1117 | 1119 | #define MT7981_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | MTK_GMAC2_GEPHY | \ | |
| 1118 | 1120 | MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \ | |
| 1119 | 1121 | MTK_MUX_U3_GMAC2_TO_QPHY | MTK_U3_COPHY_V2 | \ | |
| 1120 | - | MTK_RSTCTRL_PPE1 | MTK_SRAM) | |
| 1122 | + | MTK_RSTCTRL_PPE1 | MTK_SRAM | MTK_GMAC_EEE) | |
| 1121 | 1123 | ||
| 1122 | 1124 | #define MT7986_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \ | |
| 1123 | 1125 | MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \ | |
modified drivers/net/ethernet/mellanox/mlx5/core/en/port.c
| @@ -557,6 +557,7 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy) | |||
| 557 | 557 | u32 in[MLX5_ST_SZ_DW(pplm_reg)] = {}; | |
| 558 | 558 | int sz = MLX5_ST_SZ_BYTES(pplm_reg); | |
| 559 | 559 | u16 fec_policy_auto = 0; | |
| 560 | + | bool fec_set = false; | |
| 560 | 561 | int err; | |
| 561 | 562 | int i; | |
| 562 | 563 | ||
| @@ -569,9 +570,6 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy) | |||
| 569 | 570 | if (fec_policy >= (1 << MLX5E_FEC_LLRS_272_257_1) && !fec_50g_per_lane) | |
| 570 | 571 | return -EOPNOTSUPP; | |
| 571 | 572 | ||
| 572 | - | if (fec_policy && !mlx5e_fec_in_caps(dev, fec_policy)) | |
| 573 | - | return -EOPNOTSUPP; | |
| 574 | - | ||
| 575 | 573 | MLX5_SET(pplm_reg, in, local_port, 1); | |
| 576 | 574 | err = mlx5_core_access_reg(dev, in, sz, out, sz, MLX5_REG_PPLM, 0, 0); | |
| 577 | 575 | if (err) | |
| @@ -591,12 +589,17 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy) | |||
| 591 | 589 | mlx5e_get_fec_cap_field(out, &fec_caps, i); | |
| 592 | 590 | ||
| 593 | 591 | /* policy supported for link speed */ | |
| 594 | - | if (fec_caps & conf_fec) | |
| 592 | + | if (fec_caps & conf_fec) { | |
| 595 | 593 | mlx5e_fec_admin_field(out, &conf_fec, 1, i); | |
| 596 | - | else | |
| 597 | - | /* set FEC to auto*/ | |
| 594 | + | fec_set = true; | |
| 595 | + | } else { | |
| 596 | + | /* set FEC to auto */ | |
| 598 | 597 | mlx5e_fec_admin_field(out, &fec_policy_auto, 1, i); | |
| 598 | + | } | |
| 599 | 599 | } | |
| 600 | 600 | ||
| 601 | + | if (fec_policy && !fec_set) | |
| 602 | + | return -EOPNOTSUPP; | |
| 603 | + | ||
| 601 | 604 | return mlx5_core_access_reg(dev, out, sz, out, sz, MLX5_REG_PPLM, 0, 1); | |
| 602 | 605 | } | |
modified drivers/net/ethernet/mellanox/mlx5/core/en/port.h
| @@ -66,4 +66,8 @@ enum { | |||
| 66 | 66 | MLX5E_FEC_LLRS_272_257_1 = 9, | |
| 67 | 67 | }; | |
| 68 | 68 | ||
| 69 | + | #define MLX5E_FEC_RS_MASK (BIT(MLX5E_FEC_RS_528_514) | \ | |
| 70 | + | BIT(MLX5E_FEC_RS_544_514_INTERLEAVED_QUAD) | \ | |
| 71 | + | BIT(MLX5E_FEC_RS_544_514)) | |
| 72 | + | ||
| 69 | 73 | #endif | |
modified drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c
| @@ -311,12 +311,15 @@ err_alloc: | |||
| 311 | 311 | static void | |
| 312 | 312 | sample_restore_put(struct mlx5e_tc_psample *tc_psample, struct mlx5e_sample_restore *restore) | |
| 313 | 313 | { | |
| 314 | + | bool last; | |
| 315 | + | ||
| 314 | 316 | mutex_lock(&tc_psample->restore_lock); | |
| 315 | - | if (--restore->count == 0) | |
| 317 | + | last = --restore->count == 0; | |
| 318 | + | if (last) | |
| 316 | 319 | hash_del(&restore->hlist); | |
| 317 | 320 | mutex_unlock(&tc_psample->restore_lock); | |
| 318 | 321 | ||
| 319 | - | if (!restore->count) { | |
| 322 | + | if (last) { | |
| 320 | 323 | mlx5_del_flow_rules(restore->rule); | |
| 321 | 324 | mlx5_modify_header_dealloc(tc_psample->esw->dev, restore->modify_hdr); | |
| 322 | 325 | kfree(restore); | |
modified drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | 4 | #include "rx.h" | |
| 5 | 5 | #include "en/xdp.h" | |
| 6 | + | #include <linux/bitmap.h> | |
| 6 | 7 | #include <net/xdp_sock_drv.h> | |
| 7 | 8 | #include <linux/filter.h> | |
| 8 | 9 | ||
| @@ -156,6 +157,7 @@ err_reuse_batch: | |||
| 156 | 157 | xsk_buff_free(xsk_buffs[batch]); | |
| 157 | 158 | ||
| 158 | 159 | err: | |
| 160 | + | bitmap_fill(wi->skip_release_bitmap, rq->mpwqe.pages_per_wqe); | |
| 159 | 161 | rq->stats->buff_alloc_err++; | |
| 160 | 162 | return -ENOMEM; | |
| 161 | 163 | } | |
modified drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
| @@ -148,7 +148,7 @@ static int mlx5e_dcbnl_ieee_getets(struct net_device *netdev, | |||
| 148 | 148 | if (err) | |
| 149 | 149 | return err; | |
| 150 | 150 | ||
| 151 | - | if (ets->tc_tx_bw[i] < MLX5E_MAX_BW_ALLOC && | |
| 151 | + | if (priv->dcbx.tc_tsa[i] == IEEE_8021QAZ_TSA_ETS && | |
| 152 | 152 | tc_group[i] == (MLX5E_LOWEST_PRIO_GROUP + 1)) | |
| 153 | 153 | is_zero_bw_ets_tc = true; | |
| 154 | 154 | ||
modified drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
| @@ -1002,9 +1002,9 @@ static u32 pplm2ethtool_fec(u_long fec_mode, unsigned long size) | |||
| 1002 | 1002 | return 0; | |
| 1003 | 1003 | } | |
| 1004 | 1004 | ||
| 1005 | - | #define MLX5E_ADVERTISE_SUPPORTED_FEC(mlx5_fec, ethtool_fec) \ | |
| 1005 | + | #define MLX5E_ADVERTISE_SUPPORTED_FEC(fec_mask, ethtool_fec) \ | |
| 1006 | 1006 | do { \ | |
| 1007 | - | if (mlx5e_fec_in_caps(dev, 1 << (mlx5_fec))) \ | |
| 1007 | + | if (mlx5e_fec_in_caps(dev, fec_mask)) \ | |
| 1008 | 1008 | __set_bit(ethtool_fec, \ | |
| 1009 | 1009 | link_ksettings->link_modes.supported);\ | |
| 1010 | 1010 | } while (0) | |
| @@ -1013,6 +1013,7 @@ static const u32 pplm_fec_2_ethtool_linkmodes[] = { | |||
| 1013 | 1013 | [MLX5E_FEC_NOFEC] = ETHTOOL_LINK_MODE_FEC_NONE_BIT, | |
| 1014 | 1014 | [MLX5E_FEC_FIRECODE] = ETHTOOL_LINK_MODE_FEC_BASER_BIT, | |
| 1015 | 1015 | [MLX5E_FEC_RS_528_514] = ETHTOOL_LINK_MODE_FEC_RS_BIT, | |
| 1016 | + | [MLX5E_FEC_RS_544_514_INTERLEAVED_QUAD] = ETHTOOL_LINK_MODE_FEC_RS_BIT, | |
| 1016 | 1017 | [MLX5E_FEC_RS_544_514] = ETHTOOL_LINK_MODE_FEC_RS_BIT, | |
| 1017 | 1018 | [MLX5E_FEC_LLRS_272_257_1] = ETHTOOL_LINK_MODE_FEC_LLRS_BIT, | |
| 1018 | 1019 | }; | |
| @@ -1029,13 +1030,13 @@ static int get_fec_supported_advertised(struct mlx5_core_dev *dev, | |||
| 1029 | 1030 | if (err) | |
| 1030 | 1031 | return (err == -EOPNOTSUPP) ? 0 : err; | |
| 1031 | 1032 | ||
| 1032 | - | MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_NOFEC, | |
| 1033 | + | MLX5E_ADVERTISE_SUPPORTED_FEC(BIT(MLX5E_FEC_NOFEC), | |
| 1033 | 1034 | ETHTOOL_LINK_MODE_FEC_NONE_BIT); | |
| 1034 | - | MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_FIRECODE, | |
| 1035 | + | MLX5E_ADVERTISE_SUPPORTED_FEC(BIT(MLX5E_FEC_FIRECODE), | |
| 1035 | 1036 | ETHTOOL_LINK_MODE_FEC_BASER_BIT); | |
| 1036 | - | MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_RS_528_514, | |
| 1037 | + | MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_RS_MASK, | |
| 1037 | 1038 | ETHTOOL_LINK_MODE_FEC_RS_BIT); | |
| 1038 | - | MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_LLRS_272_257_1, | |
| 1039 | + | MLX5E_ADVERTISE_SUPPORTED_FEC(BIT(MLX5E_FEC_LLRS_272_257_1), | |
| 1039 | 1040 | ETHTOOL_LINK_MODE_FEC_LLRS_BIT); | |
| 1040 | 1041 | ||
| 1041 | 1042 | active_fec_long = active_fec; | |
modified drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
| @@ -56,7 +56,6 @@ | |||
| 56 | 56 | #include "lib/vxlan.h" | |
| 57 | 57 | #define CREATE_TRACE_POINTS | |
| 58 | 58 | #include "diag/en_rep_tracepoint.h" | |
| 59 | - | #include "diag/reporter_vnic.h" | |
| 60 | 59 | #include "en_accel/ipsec.h" | |
| 61 | 60 | #include "en/tc/int_port.h" | |
| 62 | 61 | #include "en/ptp.h" | |
| @@ -1439,51 +1438,6 @@ static unsigned int mlx5e_ul_rep_stats_grps_num(struct mlx5e_priv *priv) | |||
| 1439 | 1438 | return ARRAY_SIZE(mlx5e_ul_rep_stats_grps); | |
| 1440 | 1439 | } | |
| 1441 | 1440 | ||
| 1442 | - | static int | |
| 1443 | - | mlx5e_rep_vnic_reporter_diagnose(struct devlink_health_reporter *reporter, | |
| 1444 | - | struct devlink_fmsg *fmsg, | |
| 1445 | - | struct netlink_ext_ack *extack) | |
| 1446 | - | { | |
| 1447 | - | struct mlx5e_rep_priv *rpriv = devlink_health_reporter_priv(reporter); | |
| 1448 | - | struct mlx5_eswitch_rep *rep = rpriv->rep; | |
| 1449 | - | ||
| 1450 | - | mlx5_reporter_vnic_diagnose_counters(rep->esw->dev, fmsg, rep->vport, | |
| 1451 | - | true); | |
| 1452 | - | return 0; | |
| 1453 | - | } | |
| 1454 | - | ||
| 1455 | - | static const struct devlink_health_reporter_ops mlx5_rep_vnic_reporter_ops = { | |
| 1456 | - | .name = "vnic", | |
| 1457 | - | .diagnose = mlx5e_rep_vnic_reporter_diagnose, | |
| 1458 | - | }; | |
| 1459 | - | ||
| 1460 | - | static void mlx5e_rep_vnic_reporter_create(struct mlx5e_priv *priv, | |
| 1461 | - | struct devlink_port *dl_port) | |
| 1462 | - | { | |
| 1463 | - | struct mlx5e_rep_priv *rpriv = priv->ppriv; | |
| 1464 | - | struct devlink_health_reporter *reporter; | |
| 1465 | - | ||
| 1466 | - | reporter = devl_port_health_reporter_create(dl_port, | |
| 1467 | - | &mlx5_rep_vnic_reporter_ops, | |
| 1468 | - | rpriv); | |
| 1469 | - | if (IS_ERR(reporter)) { | |
| 1470 | - | mlx5_core_err(priv->mdev, | |
| 1471 | - | "Failed to create representor vnic reporter, err = %pe\n", | |
| 1472 | - | reporter); | |
| 1473 | - | return; | |
| 1474 | - | } | |
| 1475 | - | ||
| 1476 | - | rpriv->rep_vnic_reporter = reporter; | |
| 1477 | - | } | |
| 1478 | - | ||
| 1479 | - | static void mlx5e_rep_vnic_reporter_destroy(struct mlx5e_priv *priv) | |
| 1480 | - | { | |
| 1481 | - | struct mlx5e_rep_priv *rpriv = priv->ppriv; | |
| 1482 | - | ||
| 1483 | - | if (!IS_ERR_OR_NULL(rpriv->rep_vnic_reporter)) | |
| 1484 | - | devl_health_reporter_destroy(rpriv->rep_vnic_reporter); | |
| 1485 | - | } | |
| 1486 | - | ||
| 1487 | 1441 | static const struct mlx5e_profile mlx5e_rep_profile = { | |
| 1488 | 1442 | .init = mlx5e_init_rep, | |
| 1489 | 1443 | .cleanup = mlx5e_cleanup_rep, | |
| @@ -1607,10 +1561,8 @@ mlx5e_vport_vf_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) | |||
| 1607 | 1561 | ||
| 1608 | 1562 | dl_port = mlx5_esw_offloads_devlink_port(dev->priv.eswitch, | |
| 1609 | 1563 | rpriv->rep->vport); | |
| 1610 | - | if (!IS_ERR(dl_port)) { | |
| 1564 | + | if (!IS_ERR(dl_port)) | |
| 1611 | 1565 | SET_NETDEV_DEVLINK_PORT(netdev, dl_port); | |
| 1612 | - | mlx5e_rep_vnic_reporter_create(priv, dl_port); | |
| 1613 | - | } | |
| 1614 | 1566 | ||
| 1615 | 1567 | err = register_netdev(netdev); | |
| 1616 | 1568 | if (err) { | |
| @@ -1623,7 +1575,6 @@ mlx5e_vport_vf_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) | |||
| 1623 | 1575 | return 0; | |
| 1624 | 1576 | ||
| 1625 | 1577 | err_detach_netdev: | |
| 1626 | - | mlx5e_rep_vnic_reporter_destroy(priv); | |
| 1627 | 1578 | mlx5e_detach_netdev(netdev_priv(netdev)); | |
| 1628 | 1579 | err_cleanup_profile: | |
| 1629 | 1580 | priv->profile->cleanup(priv); | |
| @@ -1681,7 +1632,6 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep) | |||
| 1681 | 1632 | } | |
| 1682 | 1633 | ||
| 1683 | 1634 | unregister_netdev(netdev); | |
| 1684 | - | mlx5e_rep_vnic_reporter_destroy(priv); | |
| 1685 | 1635 | mlx5e_detach_netdev(priv); | |
| 1686 | 1636 | priv->profile->cleanup(priv); | |
| 1687 | 1637 | mlx5e_destroy_netdev(netdev); | |
modified drivers/net/ethernet/mellanox/mlx5/core/en_rep.h
| @@ -118,7 +118,6 @@ struct mlx5e_rep_priv { | |||
| 118 | 118 | struct rtnl_link_stats64 prev_vf_vport_stats; | |
| 119 | 119 | struct mlx5_flow_handle *send_to_vport_meta_rule; | |
| 120 | 120 | struct rhashtable tc_ht; | |
| 121 | - | struct devlink_health_reporter *rep_vnic_reporter; | |
| 122 | 121 | }; | |
| 123 | 122 | ||
| 124 | 123 | static inline | |
modified drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
| @@ -410,8 +410,11 @@ static inline void mlx5e_free_rx_wqe(struct mlx5e_rq *rq, | |||
| 410 | 410 | ||
| 411 | 411 | static void mlx5e_xsk_free_rx_wqe(struct mlx5e_wqe_frag_info *wi) | |
| 412 | 412 | { | |
| 413 | - | if (!(wi->flags & BIT(MLX5E_WQE_FRAG_SKIP_RELEASE))) | |
| 414 | - | xsk_buff_free(*wi->xskp); | |
| 413 | + | if (wi->flags & BIT(MLX5E_WQE_FRAG_SKIP_RELEASE)) | |
| 414 | + | return; | |
| 415 | + | ||
| 416 | + | xsk_buff_free(*wi->xskp); | |
| 417 | + | wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE); | |
| 415 | 418 | } | |
| 416 | 419 | ||
| 417 | 420 | static void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix) | |
modified drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
| @@ -1199,50 +1199,39 @@ void mlx5e_stats_rmon_get(struct mlx5e_priv *priv, | |||
| 1199 | 1199 | void mlx5e_stats_ts_get(struct mlx5e_priv *priv, | |
| 1200 | 1200 | struct ethtool_ts_stats *ts_stats) | |
| 1201 | 1201 | { | |
| 1202 | - | int i, j; | |
| 1202 | + | u16 nch = mlx5e_stats_nch_read(priv); | |
| 1203 | + | int i, tc; | |
| 1203 | 1204 | ||
| 1204 | - | mutex_lock(&priv->state_lock); | |
| 1205 | + | ts_stats->pkts = 0; | |
| 1205 | 1206 | ||
| 1206 | - | if (priv->tx_ptp_opened) { | |
| 1207 | - | struct mlx5e_ptp *ptp = priv->channels.ptp; | |
| 1207 | + | for (i = 0; i < nch; i++) { | |
| 1208 | + | struct mlx5e_channel_stats *channel_stats = | |
| 1209 | + | priv->channel_stats[i]; | |
| 1208 | 1210 | ||
| 1209 | - | ts_stats->pkts = 0; | |
| 1211 | + | for (tc = 0; tc < priv->max_opened_tc; tc++) | |
| 1212 | + | ts_stats->pkts += channel_stats->sq[tc].timestamps; | |
| 1213 | + | } | |
| 1214 | + | ||
| 1215 | + | /* Accumulate DMA and port timestamp counters so values stay monotonic | |
| 1216 | + | * across channel teardown and mode switches. | |
| 1217 | + | */ | |
| 1218 | + | if (priv->tx_ptp_opened) { | |
| 1219 | + | /* Err and Lost stats are only relevant for port timestamping, | |
| 1220 | + | * as the DMA layer will always successfully timestamp packets. | |
| 1221 | + | */ | |
| 1210 | 1222 | ts_stats->err = 0; | |
| 1211 | 1223 | ts_stats->lost = 0; | |
| 1212 | 1224 | ||
| 1213 | - | if (!ptp) | |
| 1214 | - | goto out; | |
| 1215 | - | ||
| 1216 | - | /* Aggregate stats across all TCs */ | |
| 1217 | - | for (i = 0; i < ptp->num_tc; i++) { | |
| 1225 | + | for (tc = 0; tc < priv->max_opened_tc; tc++) { | |
| 1218 | 1226 | struct mlx5e_ptp_cq_stats *stats = | |
| 1219 | - | ptp->ptpsq[i].cq_stats; | |
| 1227 | + | &priv->ptp_stats.cq[tc]; | |
| 1220 | 1228 | ||
| 1221 | 1229 | ts_stats->pkts += stats->cqe; | |
| 1222 | 1230 | ts_stats->err += stats->abort + stats->err_cqe + | |
| 1223 | - | stats->late_cqe; | |
| 1231 | + | stats->late_cqe; | |
| 1224 | 1232 | ts_stats->lost += stats->lost_cqe; | |
| 1225 | 1233 | } | |
| 1226 | - | } else { | |
| 1227 | - | /* DMA layer will always successfully timestamp packets. Other | |
| 1228 | - | * counters do not make sense for this layer. | |
| 1229 | - | */ | |
| 1230 | - | ts_stats->pkts = 0; | |
| 1231 | - | ||
| 1232 | - | /* Aggregate stats across all SQs */ | |
| 1233 | - | for (j = 0; j < priv->channels.num; j++) { | |
| 1234 | - | struct mlx5e_channel *c = priv->channels.c[j]; | |
| 1235 | - | ||
| 1236 | - | for (i = 0; i < c->num_tc; i++) { | |
| 1237 | - | struct mlx5e_sq_stats *stats = c->sq[i].stats; | |
| 1238 | - | ||
| 1239 | - | ts_stats->pkts += stats->timestamps; | |
| 1240 | - | } | |
| 1241 | - | } | |
| 1242 | 1234 | } | |
| 1243 | - | ||
| 1244 | - | out: | |
| 1245 | - | mutex_unlock(&priv->state_lock); | |
| 1246 | 1235 | } | |
| 1247 | 1236 | ||
| 1248 | 1237 | #define PPORT_PHY_LAYER_OFF(c) \ | |
modified drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c
| @@ -4,6 +4,26 @@ | |||
| 4 | 4 | #include <linux/mlx5/driver.h> | |
| 5 | 5 | #include "eswitch.h" | |
| 6 | 6 | #include "devlink.h" | |
| 7 | + | #include "diag/reporter_vnic.h" | |
| 8 | + | ||
| 9 | + | static int | |
| 10 | + | mlx5_esw_rep_vnic_reporter_diagnose(struct devlink_health_reporter *reporter, | |
| 11 | + | struct devlink_fmsg *fmsg, | |
| 12 | + | struct netlink_ext_ack *extack) | |
| 13 | + | { | |
| 14 | + | struct mlx5_vport *vport = devlink_health_reporter_priv(reporter); | |
| 15 | + | ||
| 16 | + | mlx5_reporter_vnic_diagnose_counters(vport->dev, fmsg, vport->vport, | |
| 17 | + | true); | |
| 18 | + | ||
| 19 | + | return 0; | |
| 20 | + | } | |
| 21 | + | ||
| 22 | + | static const | |
| 23 | + | struct devlink_health_reporter_ops mlx5_esw_rep_vnic_reporter_ops = { | |
| 24 | + | .name = "vnic", | |
| 25 | + | .diagnose = mlx5_esw_rep_vnic_reporter_diagnose, | |
| 26 | + | }; | |
| 7 | 27 | ||
| 8 | 28 | static void | |
| 9 | 29 | mlx5_esw_get_port_parent_id(struct mlx5_core_dev *dev, struct netdev_phys_item_id *ppid) | |
| @@ -220,6 +240,7 @@ static void mlx5_esw_devlink_port_res_unregister(struct devlink_port *dl_port) | |||
| 220 | 240 | ||
| 221 | 241 | int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, struct mlx5_vport *vport) | |
| 222 | 242 | { | |
| 243 | + | struct devlink_health_reporter *reporter; | |
| 223 | 244 | struct mlx5_core_dev *dev = esw->dev; | |
| 224 | 245 | const struct devlink_port_ops *ops; | |
| 225 | 246 | struct mlx5_devlink_port *dl_port; | |
| @@ -255,6 +276,16 @@ int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, struct mlx | |||
| 255 | 276 | mlx5_core_dbg(dev, "Failed to register port resources: %d\n", | |
| 256 | 277 | err); | |
| 257 | 278 | ||
| 279 | + | reporter = devl_port_health_reporter_create( | |
| 280 | + | &dl_port->dl_port, &mlx5_esw_rep_vnic_reporter_ops, | |
| 281 | + | vport); | |
| 282 | + | if (IS_ERR(reporter)) | |
| 283 | + | mlx5_core_err(dev, | |
| 284 | + | "Failed to create vnic health reporter for vport %d: %pe\n", | |
| 285 | + | vport_num, reporter); | |
| 286 | + | else | |
| 287 | + | dl_port->vnic_reporter = reporter; | |
| 288 | + | ||
| 258 | 289 | return 0; | |
| 259 | 290 | ||
| 260 | 291 | rate_err: | |
| @@ -269,6 +300,12 @@ void mlx5_esw_offloads_devlink_port_unregister(struct mlx5_vport *vport) | |||
| 269 | 300 | if (!vport->dl_port) | |
| 270 | 301 | return; | |
| 271 | 302 | dl_port = vport->dl_port; | |
| 303 | + | ||
| 304 | + | if (dl_port->vnic_reporter) { | |
| 305 | + | devl_health_reporter_destroy(dl_port->vnic_reporter); | |
| 306 | + | dl_port->vnic_reporter = NULL; | |
| 307 | + | } | |
| 308 | + | ||
| 272 | 309 | mlx5_esw_devlink_port_res_unregister(&dl_port->dl_port); | |
| 273 | 310 | ||
| 274 | 311 | devl_rate_leaf_destroy(&dl_port->dl_port); | |
modified drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
| @@ -1040,13 +1040,19 @@ void mlx5_esw_vport_disable(struct mlx5_eswitch *esw, struct mlx5_vport *vport) | |||
| 1040 | 1040 | (vport->info.ipsec_crypto_enabled || vport->info.ipsec_packet_enabled)) | |
| 1041 | 1041 | esw->enabled_ipsec_vf_count--; | |
| 1042 | 1042 | ||
| 1043 | + | /* Clear rx-mode before esw_vport_change_handle_locked(): on | |
| 1044 | + | * MLX5_VPORT_PROMISC_CHANGE it calls esw_update_vport_mc_promisc() | |
| 1045 | + | * when vport->allmulti_rule is set, repopulating mc_list with FDB | |
| 1046 | + | * rules that dangle once the FDB is destroyed. NULL allmulti_rule | |
| 1047 | + | * here skips that path. | |
| 1048 | + | */ | |
| 1049 | + | esw_apply_vport_rx_mode(esw, vport, false, false); | |
| 1043 | 1050 | /* We don't assume VFs will cleanup after themselves. | |
| 1044 | 1051 | * Calling vport change handler while vport is disabled will cleanup | |
| 1045 | 1052 | * the vport resources. | |
| 1046 | 1053 | */ | |
| 1047 | 1054 | esw_vport_change_handle_locked(vport); | |
| 1048 | 1055 | vport->enabled_events = 0; | |
| 1049 | - | esw_apply_vport_rx_mode(esw, vport, false, false); | |
| 1050 | 1056 | esw_vport_cleanup(esw, vport); | |
| 1051 | 1057 | esw->enabled_vports--; | |
| 1052 | 1058 | ||
| @@ -2288,8 +2294,7 @@ static int mlx5_esw_spfs_init(struct mlx5_eswitch *esw) | |||
| 2288 | 2294 | if (!num_entries) | |
| 2289 | 2295 | goto out_free; | |
| 2290 | 2296 | ||
| 2291 | - | esw_funcs->spfs = kcalloc(num_entries, sizeof(*esw_funcs->spfs), | |
| 2292 | - | GFP_KERNEL); | |
| 2297 | + | esw_funcs->spfs = kzalloc_objs(*esw_funcs->spfs, num_entries); | |
| 2293 | 2298 | if (!esw_funcs->spfs) { | |
| 2294 | 2299 | err = -ENOMEM; | |
| 2295 | 2300 | goto out_free; | |
modified drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
| @@ -189,6 +189,7 @@ struct mlx5_vport; | |||
| 189 | 189 | struct mlx5_devlink_port { | |
| 190 | 190 | struct devlink_port dl_port; | |
| 191 | 191 | struct mlx5_vport *vport; | |
| 192 | + | struct devlink_health_reporter *vnic_reporter; | |
| 192 | 193 | }; | |
| 193 | 194 | ||
| 194 | 195 | static inline void mlx5_devlink_port_init(struct mlx5_devlink_port *dl_port, | |
modified drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
| @@ -1524,7 +1524,7 @@ struct mlx5_flow_handle * | |||
| 1524 | 1524 | mlx5_esw_lag_demux_rule_create(struct mlx5_eswitch *esw, u16 vport_num, | |
| 1525 | 1525 | struct mlx5_flow_table *lag_ft) | |
| 1526 | 1526 | { | |
| 1527 | - | struct mlx5_flow_spec *spec = kvzalloc(sizeof(*spec), GFP_KERNEL); | |
| 1527 | + | struct mlx5_flow_spec *spec = kvzalloc_obj(*spec); | |
| 1528 | 1528 | struct mlx5_flow_destination dest = {}; | |
| 1529 | 1529 | struct mlx5_flow_act flow_act = {}; | |
| 1530 | 1530 | struct mlx5_flow_handle *ret; | |
modified drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
| @@ -163,12 +163,15 @@ void | |||
| 163 | 163 | mlx5_eswitch_termtbl_put(struct mlx5_eswitch *esw, | |
| 164 | 164 | struct mlx5_termtbl_handle *tt) | |
| 165 | 165 | { | |
| 166 | + | bool last; | |
| 167 | + | ||
| 166 | 168 | mutex_lock(&esw->offloads.termtbl_mutex); | |
| 167 | - | if (--tt->ref_count == 0) | |
| 169 | + | last = (--tt->ref_count == 0); | |
| 170 | + | if (last) | |
| 168 | 171 | hash_del(&tt->termtbl_hlist); | |
| 169 | 172 | mutex_unlock(&esw->offloads.termtbl_mutex); | |
| 170 | 173 | ||
| 171 | - | if (!tt->ref_count) { | |
| 174 | + | if (last) { | |
| 172 | 175 | mlx5_del_flow_rules(tt->rule); | |
| 173 | 176 | mlx5_destroy_flow_table(tt->termtbl); | |
| 174 | 177 | kfree(tt); | |
modified drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
| @@ -63,14 +63,15 @@ static int get_port_sel_mode(enum mlx5_lag_mode mode, unsigned long flags) | |||
| 63 | 63 | return MLX5_LAG_PORT_SELECT_MODE_QUEUE_AFFINITY; | |
| 64 | 64 | } | |
| 65 | 65 | ||
| 66 | - | static u8 lag_active_port_bits(struct mlx5_lag *ldev) | |
| 66 | + | static u8 lag_active_port_bits(struct mlx5_lag *ldev, | |
| 67 | + | struct lag_tracker *tracker) | |
| 67 | 68 | { | |
| 68 | 69 | u8 enabled_ports[MLX5_MAX_PORTS] = {}; | |
| 69 | 70 | u8 active_port = 0; | |
| 70 | 71 | int num_enabled; | |
| 71 | 72 | int idx; | |
| 72 | 73 | ||
| 73 | - | mlx5_infer_tx_enabled(&ldev->tracker, ldev, enabled_ports, | |
| 74 | + | mlx5_infer_tx_enabled(tracker, ldev, enabled_ports, | |
| 74 | 75 | &num_enabled); | |
| 75 | 76 | for (idx = 0; idx < num_enabled; idx++) | |
| 76 | 77 | active_port |= BIT_MASK(enabled_ports[idx]); | |
| @@ -79,7 +80,8 @@ static u8 lag_active_port_bits(struct mlx5_lag *ldev) | |||
| 79 | 80 | } | |
| 80 | 81 | ||
| 81 | 82 | static int mlx5_cmd_create_lag(struct mlx5_core_dev *dev, struct mlx5_lag *ldev, | |
| 82 | - | int mode, unsigned long flags) | |
| 83 | + | struct lag_tracker *tracker, int mode, | |
| 84 | + | unsigned long flags) | |
| 83 | 85 | { | |
| 84 | 86 | bool fdb_sel_mode = test_bit(MLX5_LAG_MODE_FLAG_FDB_SEL_MODE_NATIVE, | |
| 85 | 87 | &flags); | |
| @@ -108,7 +110,7 @@ static int mlx5_cmd_create_lag(struct mlx5_core_dev *dev, struct mlx5_lag *ldev, | |||
| 108 | 110 | break; | |
| 109 | 111 | ||
| 110 | 112 | MLX5_SET(lagc, lag_ctx, active_port, | |
| 111 | - | lag_active_port_bits(mlx5_lag_dev(dev))); | |
| 113 | + | lag_active_port_bits(ldev, tracker)); | |
| 112 | 114 | break; | |
| 113 | 115 | default: | |
| 114 | 116 | break; | |
| @@ -787,7 +789,8 @@ static int mlx5_cmd_modify_active_port(struct mlx5_core_dev *dev, u8 ports) | |||
| 787 | 789 | return mlx5_cmd_exec_in(dev, modify_lag, in); | |
| 788 | 790 | } | |
| 789 | 791 | ||
| 790 | - | static int _mlx5_modify_lag(struct mlx5_lag *ldev, u8 *ports) | |
| 792 | + | static int _mlx5_modify_lag(struct mlx5_lag *ldev, | |
| 793 | + | struct lag_tracker *tracker, u8 *ports) | |
| 791 | 794 | { | |
| 792 | 795 | int idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1); | |
| 793 | 796 | struct mlx5_core_dev *dev0; | |
| @@ -804,7 +807,7 @@ static int _mlx5_modify_lag(struct mlx5_lag *ldev, u8 *ports) | |||
| 804 | 807 | !MLX5_CAP_PORT_SELECTION(dev0, port_select_flow_table_bypass)) | |
| 805 | 808 | return ret; | |
| 806 | 809 | ||
| 807 | - | active_ports = lag_active_port_bits(ldev); | |
| 810 | + | active_ports = lag_active_port_bits(ldev, tracker); | |
| 808 | 811 | ||
| 809 | 812 | return mlx5_cmd_modify_active_port(dev0, active_ports); | |
| 810 | 813 | } | |
| @@ -868,7 +871,7 @@ void mlx5_modify_lag(struct mlx5_lag *ldev, | |||
| 868 | 871 | idx = i * ldev->buckets + j; | |
| 869 | 872 | if (ports[idx] == ldev->v2p_map[idx]) | |
| 870 | 873 | continue; | |
| 871 | - | err = _mlx5_modify_lag(ldev, ports); | |
| 874 | + | err = _mlx5_modify_lag(ldev, tracker, ports); | |
| 872 | 875 | if (err) { | |
| 873 | 876 | mlx5_core_err(dev0, | |
| 874 | 877 | "Failed to modify LAG (%d)\n", | |
| @@ -976,7 +979,7 @@ static int mlx5_create_lag(struct mlx5_lag *ldev, | |||
| 976 | 979 | mlx5_core_info(dev0, "shared_fdb:%d mode:%s\n", | |
| 977 | 980 | shared_fdb, mlx5_get_str_port_sel_mode(mode, flags)); | |
| 978 | 981 | ||
| 979 | - | err = mlx5_cmd_create_lag(dev0, ldev, mode, flags); | |
| 982 | + | err = mlx5_cmd_create_lag(dev0, ldev, tracker, mode, flags); | |
| 980 | 983 | if (err) { | |
| 981 | 984 | mlx5_core_err(dev0, | |
| 982 | 985 | "Failed to create LAG (%d)\n", | |
modified drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c
| @@ -317,7 +317,7 @@ int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev) | |||
| 317 | 317 | ||
| 318 | 318 | num_spfs = mlx5_esw_get_num_spfs(dev); | |
| 319 | 319 | num_hwc = MLX5_SF_HWC_FIRST_SPF + num_spfs; | |
| 320 | - | table->hwc = kcalloc(num_hwc, sizeof(*table->hwc), GFP_KERNEL); | |
| 320 | + | table->hwc = kzalloc_objs(*table->hwc, num_hwc); | |
| 321 | 321 | if (!table->hwc) { | |
| 322 | 322 | err = -ENOMEM; | |
| 323 | 323 | goto hwc_alloc_err; | |
modified drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
| @@ -239,7 +239,7 @@ static int dr_icm_buddy_init_ste_cache(struct mlx5dr_icm_buddy_mem *buddy) | |||
| 239 | 239 | if (!buddy->hw_ste_arr) | |
| 240 | 240 | goto free_ste_arr; | |
| 241 | 241 | ||
| 242 | - | buddy->miss_list = kvmalloc_array(num_of_entries, sizeof(struct list_head), GFP_KERNEL); | |
| 242 | + | buddy->miss_list = kvmalloc_objs(struct list_head, num_of_entries); | |
| 243 | 243 | if (!buddy->miss_list) | |
| 244 | 244 | goto free_hw_ste_arr; | |
| 245 | 245 | ||
modified drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
| @@ -572,6 +572,38 @@ mlxsw_sp1_ptp_unmatched_remove(struct mlxsw_sp *mlxsw_sp, | |||
| 572 | 572 | mlxsw_sp1_ptp_unmatched_ht_params); | |
| 573 | 573 | } | |
| 574 | 574 | ||
| 575 | + | /* mlxsw_sp1_ptp_packet_finish() is reached both from the NAPI poll context | |
| 576 | + | * (mlxsw_sp1_ptp_got_packet(), mlxsw_sp1_ptp_got_piece() and | |
| 577 | + | * mlxsw_sp1_packet_timestamp()) and from process context, by way of the GC | |
| 578 | + | * workqueue (mlxsw_sp1_ptp_ht_gc_collect() -> | |
| 579 | + | * mlxsw_sp1_ptp_unmatched_finish()). | |
| 580 | + | * | |
| 581 | + | * mlxsw_sp_rx_listener_no_mark_func() ends in napi_gro_receive(), using the | |
| 582 | + | * NAPI pointer that was placed in the SKB control block when the trapped | |
| 583 | + | * packet was received in the NAPI context. That pointer may only be used | |
| 584 | + | * from its own poll context, which this call site cannot guarantee. | |
| 585 | + | * | |
| 586 | + | * netif_receive_skb(), unlike napi_gro_receive(), can be called from outside | |
| 587 | + | * of the NAPI instance's poll context. RX stats accounting and the skb->dev | |
| 588 | + | * assignment are still preserved; the only change is the delivery call. | |
| 589 | + | */ | |
| 590 | + | static void mlxsw_sp1_ptp_rx_finish(struct mlxsw_sp_port *mlxsw_sp_port, | |
| 591 | + | struct sk_buff *skb) | |
| 592 | + | { | |
| 593 | + | struct mlxsw_sp_port_pcpu_stats *pcpu_stats; | |
| 594 | + | ||
| 595 | + | skb->dev = mlxsw_sp_port->dev; | |
| 596 | + | ||
| 597 | + | pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats); | |
| 598 | + | u64_stats_update_begin(&pcpu_stats->syncp); | |
| 599 | + | pcpu_stats->rx_packets++; | |
| 600 | + | pcpu_stats->rx_bytes += skb->len; | |
| 601 | + | u64_stats_update_end(&pcpu_stats->syncp); | |
| 602 | + | ||
| 603 | + | skb->protocol = eth_type_trans(skb, skb->dev); | |
| 604 | + | netif_receive_skb(skb); | |
| 605 | + | } | |
| 606 | + | ||
| 575 | 607 | /* This function is called in the following scenarios: | |
| 576 | 608 | * | |
| 577 | 609 | * 1) When a packet is matched with its timestamp. | |
| @@ -600,7 +632,7 @@ static void mlxsw_sp1_ptp_packet_finish(struct mlxsw_sp *mlxsw_sp, | |||
| 600 | 632 | if (ingress) { | |
| 601 | 633 | if (hwtstamps) | |
| 602 | 634 | *skb_hwtstamps(skb) = *hwtstamps; | |
| 603 | - | mlxsw_sp_rx_listener_no_mark_func(skb, local_port, mlxsw_sp); | |
| 635 | + | mlxsw_sp1_ptp_rx_finish(mlxsw_sp_port, skb); | |
| 604 | 636 | } else { | |
| 605 | 637 | /* skb_tstamp_tx() allows hwtstamps to be NULL. */ | |
| 606 | 638 | skb_tstamp_tx(skb, hwtstamps); | |
modified drivers/net/ethernet/meta/fbnic/fbnic_irq.c
| @@ -282,7 +282,7 @@ enum fbnic_msix_self_test_codes fbnic_msix_test(struct fbnic_dev *fbd) | |||
| 282 | 282 | int i; | |
| 283 | 283 | ||
| 284 | 284 | /* Allocate bitmap and IRQ vector table */ | |
| 285 | - | test_data = kzalloc_obj(*test_data, GFP_KERNEL); | |
| 285 | + | test_data = kzalloc_obj(*test_data); | |
| 286 | 286 | ||
| 287 | 287 | /* memory allocation failure */ | |
| 288 | 288 | if (!test_data) | |
modified drivers/net/ethernet/micrel/ks8851_common.c
| @@ -143,9 +143,6 @@ static int ks8851_write_mac_addr(struct net_device *dev) | |||
| 143 | 143 | ks8851_wrreg16(ks, KS_MAR(i), val); | |
| 144 | 144 | } | |
| 145 | 145 | ||
| 146 | - | if (!netif_running(dev)) | |
| 147 | - | ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN); | |
| 148 | - | ||
| 149 | 146 | ks8851_unlock(ks); | |
| 150 | 147 | ||
| 151 | 148 | return 0; | |
| @@ -478,8 +475,7 @@ static int ks8851_net_open(struct net_device *dev) | |||
| 478 | 475 | * @dev: The device being closed. | |
| 479 | 476 | * | |
| 480 | 477 | * Called to close down a network device which has been active. Cancel any | |
| 481 | - | * work, shutdown the RX and TX process and then place the chip into a low | |
| 482 | - | * power state whilst it is not being used. | |
| 478 | + | * work and shutdown the RX and TX process. | |
| 483 | 479 | */ | |
| 484 | 480 | static int ks8851_net_stop(struct net_device *dev) | |
| 485 | 481 | { | |
| @@ -506,8 +502,6 @@ static int ks8851_net_stop(struct net_device *dev) | |||
| 506 | 502 | /* shutdown TX process */ | |
| 507 | 503 | ks8851_wrreg16(ks, KS_TXCR, 0x0000); | |
| 508 | 504 | ||
| 509 | - | /* set powermode to soft power down to save power */ | |
| 510 | - | ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN); | |
| 511 | 505 | ks8851_unlock(ks); | |
| 512 | 506 | ||
| 513 | 507 | /* ensure any queued tx buffers are dumped */ | |
modified drivers/net/ethernet/microsoft/mana/gdma_main.c
| @@ -429,11 +429,11 @@ int mana_gd_alloc_memory(struct gdma_context *gc, unsigned int length, | |||
| 429 | 429 | /* length is a power of 2 above PAGE_SIZE, so this divides exactly. */ | |
| 430 | 430 | npages = length / PAGE_SIZE; | |
| 431 | 431 | ||
| 432 | - | gmi->pages_va = kvcalloc(npages, sizeof(*gmi->pages_va), GFP_KERNEL); | |
| 432 | + | gmi->pages_va = kvzalloc_objs(*gmi->pages_va, npages); | |
| 433 | 433 | if (!gmi->pages_va) | |
| 434 | 434 | return -ENOMEM; | |
| 435 | 435 | ||
| 436 | - | gmi->pages_dma = kvcalloc(npages, sizeof(*gmi->pages_dma), GFP_KERNEL); | |
| 436 | + | gmi->pages_dma = kvzalloc_objs(*gmi->pages_dma, npages); | |
| 437 | 437 | if (!gmi->pages_dma) | |
| 438 | 438 | goto free_va; | |
| 439 | 439 | ||
| @@ -825,7 +825,7 @@ int mana_schedule_serv_work(struct gdma_context *gc, enum gdma_eqe_type type) | |||
| 825 | 825 | return -ENODEV; | |
| 826 | 826 | } | |
| 827 | 827 | ||
| 828 | - | mns_wk = kzalloc(sizeof(*mns_wk), GFP_ATOMIC); | |
| 828 | + | mns_wk = kzalloc_obj(*mns_wk, GFP_ATOMIC); | |
| 829 | 829 | if (!mns_wk) { | |
| 830 | 830 | module_put(THIS_MODULE); | |
| 831 | 831 | clear_bit(GC_IN_SERVICE, &gc->flags); | |
| @@ -1991,7 +1991,7 @@ struct gdma_irq_context *mana_gd_get_gic(struct gdma_context *gc, | |||
| 1991 | 1991 | *msi_requested = msi; | |
| 1992 | 1992 | } | |
| 1993 | 1993 | ||
| 1994 | - | gic = kzalloc(sizeof(*gic), GFP_KERNEL); | |
| 1994 | + | gic = kzalloc_obj(*gic); | |
| 1995 | 1995 | if (!gic) { | |
| 1996 | 1996 | gic = ERR_PTR(-ENOMEM); | |
| 1997 | 1997 | if (irq_map.virq) | |
modified drivers/net/ethernet/microsoft/mana/mana_bpf.c
| @@ -208,6 +208,7 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog, | |||
| 208 | 208 | if (err) { | |
| 209 | 209 | NL_SET_ERR_MSG_MOD(extack, | |
| 210 | 210 | "XDP: Insufficient memory for tx/rx re-config"); | |
| 211 | + | apc->bpf_prog = old_prog; | |
| 211 | 212 | return err; | |
| 212 | 213 | } | |
| 213 | 214 | ||
modified drivers/net/ethernet/microsoft/mana/mana_en.c
| @@ -2986,6 +2986,10 @@ static int mana_alloc_rx_wqe(struct mana_port_context *apc, | |||
| 2986 | 2986 | *cq_size += COMP_ENTRY_SIZE; | |
| 2987 | 2987 | } | |
| 2988 | 2988 | ||
| 2989 | + | /* Reserve an extra slot for Fence completion | |
| 2990 | + | * event (CQE_RX_OBJECT_FENCE) in case RX CQ is full. | |
| 2991 | + | */ | |
| 2992 | + | *cq_size += COMP_ENTRY_SIZE; | |
| 2989 | 2993 | return 0; | |
| 2990 | 2994 | } | |
| 2991 | 2995 | ||
| @@ -3080,7 +3084,7 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc, | |||
| 3080 | 3084 | goto out; | |
| 3081 | 3085 | ||
| 3082 | 3086 | rq_size = MANA_PAGE_ALIGN(rq_size); | |
| 3083 | - | cq_size = MANA_PAGE_ALIGN(cq_size); | |
| 3087 | + | cq_size = MANA_PAGE_ALIGN(roundup_pow_of_two(cq_size)); | |
| 3084 | 3088 | ||
| 3085 | 3089 | /* Create RQ */ | |
| 3086 | 3090 | memset(&spec, 0, sizeof(spec)); | |
| @@ -3983,7 +3987,8 @@ static void mana_rdma_service_handle(struct work_struct *work) | |||
| 3983 | 3987 | struct device *dev = gd->gdma_context->dev; | |
| 3984 | 3988 | int ret; | |
| 3985 | 3989 | ||
| 3986 | - | if (READ_ONCE(gd->rdma_teardown)) | |
| 3990 | + | /* Pairs with the smp_store_release() in mana_rdma_probe(). */ | |
| 3991 | + | if (smp_load_acquire(&gd->rdma_teardown)) | |
| 3987 | 3992 | goto out; | |
| 3988 | 3993 | ||
| 3989 | 3994 | switch (serv_work->event) { | |
| @@ -4279,6 +4284,21 @@ int mana_rdma_probe(struct gdma_dev *gd) | |||
| 4279 | 4284 | if (err) | |
| 4280 | 4285 | return err; | |
| 4281 | 4286 | ||
| 4287 | + | /* Clear the state left by a previous mana_rdma_remove() so servicing | |
| 4288 | + | * events are handled again after a reset cycle. | |
| 4289 | + | */ | |
| 4290 | + | gd->is_suspended = false; | |
| 4291 | + | ||
| 4292 | + | /* Publish is_suspended before re-opening the gate, so the handler | |
| 4293 | + | * cannot observe an open gate with a stale is_suspended. Pairs | |
| 4294 | + | * with the smp_load_acquire() in mana_rdma_service_handle(). This | |
| 4295 | + | * matters on the reset path, where mana_rdma_remove() closed the | |
| 4296 | + | * gate and drained the workqueue; on the initial probe path the | |
| 4297 | + | * gate was never closed and both flags are already clear. It does | |
| 4298 | + | * not order gd->adev, which add_adev() publishes below. | |
| 4299 | + | */ | |
| 4300 | + | smp_store_release(&gd->rdma_teardown, false); | |
| 4301 | + | ||
| 4282 | 4302 | err = add_adev(gd, "rdma"); | |
| 4283 | 4303 | if (err) | |
| 4284 | 4304 | mana_gd_deregister_device(gd); | |
modified drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
| @@ -1421,7 +1421,8 @@ static int nfp_net_get_fs_rule(struct nfp_net *nn, struct ethtool_rxnfc *cmd) | |||
| 1421 | 1421 | return -ENOENT; | |
| 1422 | 1422 | } | |
| 1423 | 1423 | ||
| 1424 | - | static int nfp_net_get_fs_loc(struct nfp_net *nn, u32 *rule_locs) | |
| 1424 | + | static int nfp_net_get_fs_loc(struct nfp_net *nn, struct ethtool_rxnfc *cmd, | |
| 1425 | + | u32 *rule_locs) | |
| 1425 | 1426 | { | |
| 1426 | 1427 | struct nfp_fs_entry *entry; | |
| 1427 | 1428 | u32 count = 0; | |
| @@ -1429,8 +1430,12 @@ static int nfp_net_get_fs_loc(struct nfp_net *nn, u32 *rule_locs) | |||
| 1429 | 1430 | if (!(nn->cap_w1 & NFP_NET_CFG_CTRL_FLOW_STEER)) | |
| 1430 | 1431 | return -EOPNOTSUPP; | |
| 1431 | 1432 | ||
| 1432 | - | list_for_each_entry(entry, &nn->fs.list, node) | |
| 1433 | + | list_for_each_entry(entry, &nn->fs.list, node) { | |
| 1434 | + | if (count == cmd->rule_cnt) | |
| 1435 | + | return -EMSGSIZE; | |
| 1433 | 1436 | rule_locs[count++] = entry->loc; | |
| 1437 | + | } | |
| 1438 | + | cmd->rule_cnt = count; | |
| 1434 | 1439 | ||
| 1435 | 1440 | return 0; | |
| 1436 | 1441 | } | |
| @@ -1455,7 +1460,7 @@ static int nfp_net_get_rxnfc(struct net_device *netdev, | |||
| 1455 | 1460 | return nfp_net_get_fs_rule(nn, cmd); | |
| 1456 | 1461 | case ETHTOOL_GRXCLSRLALL: | |
| 1457 | 1462 | cmd->data = NFP_FS_MAX_ENTRY; | |
| 1458 | - | return nfp_net_get_fs_loc(nn, rule_locs); | |
| 1463 | + | return nfp_net_get_fs_loc(nn, cmd, rule_locs); | |
| 1459 | 1464 | default: | |
| 1460 | 1465 | return -EOPNOTSUPP; | |
| 1461 | 1466 | } | |
| @@ -1698,8 +1703,14 @@ static int nfp_net_fs_add(struct nfp_net *nn, struct ethtool_rxnfc *cmd) | |||
| 1698 | 1703 | ||
| 1699 | 1704 | nn->fs.count--; | |
| 1700 | 1705 | err = nfp_net_fs_add_hw(nn, new); | |
| 1701 | - | if (err) | |
| 1706 | + | if (err) { | |
| 1707 | + | /* mbox broken, adding the old rule back will | |
| 1708 | + | * likely also fail. | |
| 1709 | + | */ | |
| 1710 | + | list_del(&entry->node); | |
| 1711 | + | kfree(entry); | |
| 1702 | 1712 | goto err; | |
| 1713 | + | } | |
| 1703 | 1714 | ||
| 1704 | 1715 | nn->fs.count++; | |
| 1705 | 1716 | list_replace(&entry->node, &new->node); | |
modified drivers/net/ethernet/oa_tc6.c
| @@ -83,7 +83,7 @@ struct oa_tc6 { | |||
| 83 | 83 | u16 spi_data_tx_buf_offset; | |
| 84 | 84 | u16 tx_credits; | |
| 85 | 85 | u8 rx_chunks_available; | |
| 86 | - | bool rx_buf_overflow; | |
| 86 | + | bool wait_until_start_valid; | |
| 87 | 87 | bool int_flag; | |
| 88 | 88 | bool disable_traffic; | |
| 89 | 89 | bool prot_ctrl; | |
| @@ -455,7 +455,7 @@ static int oa_tc6_mdiobus_read(struct mii_bus *bus, int addr, int regnum) | |||
| 455 | 455 | { | |
| 456 | 456 | struct oa_tc6 *tc6 = bus->priv; | |
| 457 | 457 | u32 regval; | |
| 458 | - | bool ret; | |
| 458 | + | int ret; | |
| 459 | 459 | ||
| 460 | 460 | ret = oa_tc6_read_register(tc6, OA_TC6_PHY_STD_REG_ADDR_BASE | | |
| 461 | 461 | (regnum & OA_TC6_PHY_STD_REG_ADDR_MASK), | |
| @@ -693,6 +693,26 @@ static int oa_tc6_enable_data_transfer(struct oa_tc6 *tc6) | |||
| 693 | 693 | return oa_tc6_write_register(tc6, OA_TC6_REG_CONFIG0, value); | |
| 694 | 694 | } | |
| 695 | 695 | ||
| 696 | + | /* Called when a frame that is meant to be transmitted, is dropped. */ | |
| 697 | + | static void oa_tc6_drop_tx_skb(struct oa_tc6 *tc6, struct sk_buff *skb) | |
| 698 | + | { | |
| 699 | + | if (skb) { | |
| 700 | + | tc6->netdev->stats.tx_dropped++; | |
| 701 | + | dev_kfree_skb_any(skb); | |
| 702 | + | } | |
| 703 | + | } | |
| 704 | + | ||
| 705 | + | static struct sk_buff *oa_tc6_detach_waiting_tx_skb(struct oa_tc6 *tc6) | |
| 706 | + | { | |
| 707 | + | struct sk_buff *skb; | |
| 708 | + | ||
| 709 | + | lockdep_assert_held(&tc6->tx_skb_lock); | |
| 710 | + | skb = tc6->waiting_tx_skb; | |
| 711 | + | tc6->waiting_tx_skb = NULL; | |
| 712 | + | ||
| 713 | + | return skb; | |
| 714 | + | } | |
| 715 | + | ||
| 696 | 716 | static void oa_tc6_cleanup_ongoing_rx_skb(struct oa_tc6 *tc6) | |
| 697 | 717 | { | |
| 698 | 718 | if (tc6->rx_skb) { | |
| @@ -704,29 +724,39 @@ static void oa_tc6_cleanup_ongoing_rx_skb(struct oa_tc6 *tc6) | |||
| 704 | 724 | ||
| 705 | 725 | static void oa_tc6_cleanup_ongoing_tx_skb(struct oa_tc6 *tc6) | |
| 706 | 726 | { | |
| 707 | - | if (tc6->ongoing_tx_skb) { | |
| 708 | - | tc6->netdev->stats.tx_dropped++; | |
| 709 | - | kfree_skb(tc6->ongoing_tx_skb); | |
| 710 | - | tc6->ongoing_tx_skb = NULL; | |
| 711 | - | } | |
| 727 | + | oa_tc6_drop_tx_skb(tc6, tc6->ongoing_tx_skb); | |
| 728 | + | tc6->ongoing_tx_skb = NULL; | |
| 712 | 729 | } | |
| 713 | 730 | ||
| 714 | 731 | static void oa_tc6_cleanup_waiting_tx_skb(struct oa_tc6 *tc6) | |
| 715 | 732 | { | |
| 716 | - | if (tc6->waiting_tx_skb) { | |
| 717 | - | tc6->netdev->stats.tx_dropped++; | |
| 718 | - | kfree_skb(tc6->waiting_tx_skb); | |
| 719 | - | tc6->waiting_tx_skb = NULL; | |
| 720 | - | } | |
| 733 | + | struct sk_buff *skb; | |
| 734 | + | ||
| 735 | + | spin_lock_bh(&tc6->tx_skb_lock); | |
| 736 | + | skb = oa_tc6_detach_waiting_tx_skb(tc6); | |
| 737 | + | spin_unlock_bh(&tc6->tx_skb_lock); | |
| 738 | + | ||
| 739 | + | oa_tc6_drop_tx_skb(tc6, skb); | |
| 721 | 740 | } | |
| 722 | 741 | ||
| 723 | - | static void oa_tc6_free_pending_skbs(struct oa_tc6 *tc6) | |
| 742 | + | static void oa_tc6_free_ongoing_skbs(struct oa_tc6 *tc6) | |
| 724 | 743 | { | |
| 725 | 744 | oa_tc6_cleanup_ongoing_tx_skb(tc6); | |
| 726 | 745 | oa_tc6_cleanup_ongoing_rx_skb(tc6); | |
| 746 | + | } | |
| 747 | + | ||
| 748 | + | static void oa_tc6_free_pending_skbs(struct oa_tc6 *tc6) | |
| 749 | + | { | |
| 750 | + | oa_tc6_free_ongoing_skbs(tc6); | |
| 727 | 751 | oa_tc6_cleanup_waiting_tx_skb(tc6); | |
| 728 | 752 | } | |
| 729 | 753 | ||
| 754 | + | static void oa_tc6_look_for_new_frame(struct oa_tc6 *tc6) | |
| 755 | + | { | |
| 756 | + | tc6->wait_until_start_valid = true; | |
| 757 | + | oa_tc6_cleanup_ongoing_rx_skb(tc6); | |
| 758 | + | } | |
| 759 | + | ||
| 730 | 760 | /* If the failure is at SPI interface level, masking and clearing | |
| 731 | 761 | * the interrupt of the device won't work. Since SPI interrupt is | |
| 732 | 762 | * disabled, it should stop the repeated interrupts. | |
| @@ -734,9 +764,19 @@ static void oa_tc6_free_pending_skbs(struct oa_tc6 *tc6) | |||
| 734 | 764 | static void oa_tc6_disable_traffic(struct oa_tc6 *tc6) | |
| 735 | 765 | { | |
| 736 | 766 | u32 regval = OA_TC6_INT_MASK0_ALL_INTERRUPTS; | |
| 767 | + | struct sk_buff *skb; | |
| 737 | 768 | ||
| 769 | + | spin_lock_bh(&tc6->tx_skb_lock); | |
| 738 | 770 | tc6->disable_traffic = true; | |
| 739 | - | oa_tc6_free_pending_skbs(tc6); | |
| 771 | + | skb = oa_tc6_detach_waiting_tx_skb(tc6); | |
| 772 | + | spin_unlock_bh(&tc6->tx_skb_lock); | |
| 773 | + | ||
| 774 | + | /* disable_traffic, when set, is a point of no return to | |
| 775 | + | * working state. Keeping the TX queues disabled. | |
| 776 | + | */ | |
| 777 | + | netif_tx_disable(tc6->netdev); | |
| 778 | + | oa_tc6_drop_tx_skb(tc6, skb); | |
| 779 | + | oa_tc6_free_ongoing_skbs(tc6); | |
| 740 | 780 | oa_tc6_write_register(tc6, OA_TC6_REG_INT_MASK0, regval); | |
| 741 | 781 | oa_tc6_read_register(tc6, OA_TC6_REG_STATUS0, ®val); | |
| 742 | 782 | oa_tc6_write_register(tc6, OA_TC6_REG_STATUS0, regval); | |
| @@ -755,6 +795,13 @@ static int oa_tc6_process_extended_status(struct oa_tc6 *tc6) | |||
| 755 | 795 | return ret; | |
| 756 | 796 | } | |
| 757 | 797 | ||
| 798 | + | /* This function is called for each chunk received in a given SPI | |
| 799 | + | * transaction. In case, extended status bit is set in more than | |
| 800 | + | * one chunk, skip the write, if status0 is already cleared. | |
| 801 | + | */ | |
| 802 | + | if (!value) | |
| 803 | + | return 0; | |
| 804 | + | ||
| 758 | 805 | /* Clear the error interrupts status */ | |
| 759 | 806 | ret = oa_tc6_write_register(tc6, OA_TC6_REG_STATUS0, value); | |
| 760 | 807 | if (ret) { | |
| @@ -764,8 +811,7 @@ static int oa_tc6_process_extended_status(struct oa_tc6 *tc6) | |||
| 764 | 811 | } | |
| 765 | 812 | ||
| 766 | 813 | if (FIELD_GET(OA_TC6_STATUS0_RX_BUFFER_OVERFLOW_ERROR, value)) { | |
| 767 | - | tc6->rx_buf_overflow = true; | |
| 768 | - | oa_tc6_cleanup_ongoing_rx_skb(tc6); | |
| 814 | + | oa_tc6_look_for_new_frame(tc6); | |
| 769 | 815 | net_err_ratelimited("%s: Receive buffer overflow error\n", | |
| 770 | 816 | tc6->netdev->name); | |
| 771 | 817 | return -EAGAIN; | |
| @@ -791,6 +837,8 @@ static int oa_tc6_process_extended_status(struct oa_tc6 *tc6) | |||
| 791 | 837 | ||
| 792 | 838 | static int oa_tc6_process_rx_chunk_footer(struct oa_tc6 *tc6, u32 footer) | |
| 793 | 839 | { | |
| 840 | + | int ret = 0; | |
| 841 | + | ||
| 794 | 842 | /* Process rx chunk footer for the following, | |
| 795 | 843 | * 1. tx credits | |
| 796 | 844 | * 2. errors if any from MAC-PHY | |
| @@ -801,9 +849,11 @@ static int oa_tc6_process_rx_chunk_footer(struct oa_tc6 *tc6, u32 footer) | |||
| 801 | 849 | footer); | |
| 802 | 850 | ||
| 803 | 851 | if (FIELD_GET(OA_TC6_DATA_FOOTER_EXTENDED_STS, footer)) { | |
| 804 | - | int ret = oa_tc6_process_extended_status(tc6); | |
| 805 | - | ||
| 806 | - | if (ret) | |
| 852 | + | ret = oa_tc6_process_extended_status(tc6); | |
| 853 | + | /* EAGAIN error is recoverable. Move on to check | |
| 854 | + | * HEADER and SYNC errors before returning. | |
| 855 | + | */ | |
| 856 | + | if (ret && ret != -EAGAIN) | |
| 807 | 857 | return ret; | |
| 808 | 858 | } | |
| 809 | 859 | ||
| @@ -821,7 +871,7 @@ static int oa_tc6_process_rx_chunk_footer(struct oa_tc6 *tc6, u32 footer) | |||
| 821 | 871 | return -ENODEV; | |
| 822 | 872 | } | |
| 823 | 873 | ||
| 824 | - | return 0; | |
| 874 | + | return ret; | |
| 825 | 875 | } | |
| 826 | 876 | ||
| 827 | 877 | static void oa_tc6_submit_rx_skb(struct oa_tc6 *tc6) | |
| @@ -846,13 +896,35 @@ static void oa_tc6_submit_rx_skb(struct oa_tc6 *tc6) | |||
| 846 | 896 | tc6->rx_skb = NULL; | |
| 847 | 897 | } | |
| 848 | 898 | ||
| 849 | - | static void oa_tc6_update_rx_skb(struct oa_tc6 *tc6, u8 *payload, u8 length) | |
| 899 | + | /* On oversubscribed traffic condition, particularly with overwhelming rx | |
| 900 | + | * buffer overflow errors, there could be data chunk loss. If tail + length | |
| 901 | + | * goes beyond end pointer, that is an indication that the data chunk with | |
| 902 | + | * end_valid bit is lost. Time to look for a data chunk with start_valid bit. | |
| 903 | + | * | |
| 904 | + | * If rx_skb is NULL, it is time to start looking for data chunk with | |
| 905 | + | * start_bit. | |
| 906 | + | */ | |
| 907 | + | static int oa_tc6_update_rx_skb(struct oa_tc6 *tc6, u8 *payload, u8 length) | |
| 850 | 908 | { | |
| 909 | + | if (!tc6->rx_skb || | |
| 910 | + | skb_tailroom(tc6->rx_skb) < length) { | |
| 911 | + | oa_tc6_look_for_new_frame(tc6); | |
| 912 | + | return -EAGAIN; | |
| 913 | + | } | |
| 914 | + | ||
| 851 | 915 | memcpy(skb_put(tc6->rx_skb, length), payload, length); | |
| 916 | + | return 0; | |
| 852 | 917 | } | |
| 853 | 918 | ||
| 919 | + | /* On overwhelming rx buffer overflow errors, due to data chunk loss, it is | |
| 920 | + | * possible that we get two data chunks with start_valid bit set, without | |
| 921 | + | * end_valid bit set in between. In this case, rx_skb would have a valid | |
| 922 | + | * buffer pointer. We should release, if a valid pointer is found before | |
| 923 | + | * allocating a new one. | |
| 924 | + | */ | |
| 854 | 925 | static int oa_tc6_allocate_rx_skb(struct oa_tc6 *tc6) | |
| 855 | 926 | { | |
| 927 | + | oa_tc6_cleanup_ongoing_rx_skb(tc6); | |
| 856 | 928 | tc6->rx_skb = netdev_alloc_skb_ip_align(tc6->netdev, tc6->netdev->mtu + | |
| 857 | 929 | ETH_HLEN + ETH_FCS_LEN); | |
| 858 | 930 | if (!tc6->rx_skb) { | |
| @@ -872,7 +944,9 @@ static int oa_tc6_prcs_complete_rx_frame(struct oa_tc6 *tc6, u8 *payload, | |||
| 872 | 944 | if (ret) | |
| 873 | 945 | return ret; | |
| 874 | 946 | ||
| 875 | - | oa_tc6_update_rx_skb(tc6, payload, size); | |
| 947 | + | ret = oa_tc6_update_rx_skb(tc6, payload, size); | |
| 948 | + | if (ret) | |
| 949 | + | return ret; | |
| 876 | 950 | ||
| 877 | 951 | oa_tc6_submit_rx_skb(tc6); | |
| 878 | 952 | ||
| @@ -887,22 +961,24 @@ static int oa_tc6_prcs_rx_frame_start(struct oa_tc6 *tc6, u8 *payload, u16 size) | |||
| 887 | 961 | if (ret) | |
| 888 | 962 | return ret; | |
| 889 | 963 | ||
| 890 | - | oa_tc6_update_rx_skb(tc6, payload, size); | |
| 891 | - | ||
| 892 | - | return 0; | |
| 964 | + | return oa_tc6_update_rx_skb(tc6, payload, size); | |
| 893 | 965 | } | |
| 894 | 966 | ||
| 895 | - | static void oa_tc6_prcs_rx_frame_end(struct oa_tc6 *tc6, u8 *payload, u16 size) | |
| 967 | + | static int oa_tc6_prcs_rx_frame_end(struct oa_tc6 *tc6, u8 *payload, u16 size) | |
| 896 | 968 | { | |
| 897 | - | oa_tc6_update_rx_skb(tc6, payload, size); | |
| 969 | + | int ret; | |
| 898 | 970 | ||
| 899 | - | oa_tc6_submit_rx_skb(tc6); | |
| 971 | + | ret = oa_tc6_update_rx_skb(tc6, payload, size); | |
| 972 | + | if (!ret) | |
| 973 | + | oa_tc6_submit_rx_skb(tc6); | |
| 974 | + | return ret; | |
| 900 | 975 | } | |
| 901 | 976 | ||
| 902 | - | static void oa_tc6_prcs_ongoing_rx_frame(struct oa_tc6 *tc6, u8 *payload, | |
| 903 | - | u32 footer) | |
| 977 | + | static int oa_tc6_prcs_ongoing_rx_frame(struct oa_tc6 *tc6, u8 *payload, | |
| 978 | + | u32 footer) | |
| 904 | 979 | { | |
| 905 | - | oa_tc6_update_rx_skb(tc6, payload, OA_TC6_CHUNK_PAYLOAD_SIZE); | |
| 980 | + | return oa_tc6_update_rx_skb(tc6, payload, | |
| 981 | + | OA_TC6_CHUNK_PAYLOAD_SIZE); | |
| 906 | 982 | } | |
| 907 | 983 | ||
| 908 | 984 | static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data, | |
| @@ -917,10 +993,10 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data, | |||
| 917 | 993 | u16 size; | |
| 918 | 994 | ||
| 919 | 995 | /* Restart the new rx frame after receiving rx buffer overflow error */ | |
| 920 | - | if (start_valid && tc6->rx_buf_overflow) | |
| 921 | - | tc6->rx_buf_overflow = false; | |
| 996 | + | if (start_valid && tc6->wait_until_start_valid) | |
| 997 | + | tc6->wait_until_start_valid = false; | |
| 922 | 998 | ||
| 923 | - | if (tc6->rx_buf_overflow) | |
| 999 | + | if (tc6->wait_until_start_valid) | |
| 924 | 1000 | return 0; | |
| 925 | 1001 | ||
| 926 | 1002 | /* Process the chunk with complete rx frame */ | |
| @@ -942,8 +1018,7 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data, | |||
| 942 | 1018 | /* Process the chunk with only rx frame end */ | |
| 943 | 1019 | if (end_valid && !start_valid) { | |
| 944 | 1020 | size = end_byte_offset + 1; | |
| 945 | - | oa_tc6_prcs_rx_frame_end(tc6, data, size); | |
| 946 | - | return 0; | |
| 1021 | + | return oa_tc6_prcs_rx_frame_end(tc6, data, size); | |
| 947 | 1022 | } | |
| 948 | 1023 | ||
| 949 | 1024 | /* Process the chunk with previous rx frame end and next rx frame | |
| @@ -957,6 +1032,15 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data, | |||
| 957 | 1032 | if (tc6->rx_skb) { | |
| 958 | 1033 | size = end_byte_offset + 1; | |
| 959 | 1034 | oa_tc6_prcs_rx_frame_end(tc6, data, size); | |
| 1035 | + | ||
| 1036 | + | /* Return value from oa_tc6_prcs_rx_frame_end is not | |
| 1037 | + | * checked. If it returned an error, it is to make | |
| 1038 | + | * the code to look for new frame. At this stage, | |
| 1039 | + | * code below is going to process a new frame. So, | |
| 1040 | + | * error condition is set to false, in case it is | |
| 1041 | + | * set before proceeding. | |
| 1042 | + | */ | |
| 1043 | + | tc6->wait_until_start_valid = false; | |
| 960 | 1044 | } | |
| 961 | 1045 | size = OA_TC6_CHUNK_PAYLOAD_SIZE - start_byte_offset; | |
| 962 | 1046 | return oa_tc6_prcs_rx_frame_start(tc6, | |
| @@ -965,9 +1049,7 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data, | |||
| 965 | 1049 | } | |
| 966 | 1050 | ||
| 967 | 1051 | /* Process the chunk with ongoing rx frame data */ | |
| 968 | - | oa_tc6_prcs_ongoing_rx_frame(tc6, data, footer); | |
| 969 | - | ||
| 970 | - | return 0; | |
| 1052 | + | return oa_tc6_prcs_ongoing_rx_frame(tc6, data, footer); | |
| 971 | 1053 | } | |
| 972 | 1054 | ||
| 973 | 1055 | static u32 oa_tc6_get_rx_chunk_footer(struct oa_tc6 *tc6, u16 footer_offset) | |
| @@ -983,8 +1065,9 @@ static u32 oa_tc6_get_rx_chunk_footer(struct oa_tc6 *tc6, u16 footer_offset) | |||
| 983 | 1065 | static int oa_tc6_process_spi_data_rx_buf(struct oa_tc6 *tc6, u16 length) | |
| 984 | 1066 | { | |
| 985 | 1067 | u16 no_of_rx_chunks = length / OA_TC6_CHUNK_SIZE; | |
| 1068 | + | bool retry = false; | |
| 1069 | + | int ret = 0; | |
| 986 | 1070 | u32 footer; | |
| 987 | - | int ret; | |
| 988 | 1071 | ||
| 989 | 1072 | /* All the rx chunks in the receive SPI data buffer are examined here */ | |
| 990 | 1073 | for (int i = 0; i < no_of_rx_chunks; i++) { | |
| @@ -993,8 +1076,11 @@ static int oa_tc6_process_spi_data_rx_buf(struct oa_tc6 *tc6, u16 length) | |||
| 993 | 1076 | OA_TC6_CHUNK_PAYLOAD_SIZE); | |
| 994 | 1077 | ||
| 995 | 1078 | ret = oa_tc6_process_rx_chunk_footer(tc6, footer); | |
| 996 | - | if (ret) | |
| 997 | - | return ret; | |
| 1079 | + | if (ret) { | |
| 1080 | + | if (ret != -EAGAIN) | |
| 1081 | + | return ret; | |
| 1082 | + | retry = true; | |
| 1083 | + | } | |
| 998 | 1084 | ||
| 999 | 1085 | /* If there is a data valid chunks then process it for the | |
| 1000 | 1086 | * information needed to determine the validity and the location | |
| @@ -1006,12 +1092,35 @@ static int oa_tc6_process_spi_data_rx_buf(struct oa_tc6 *tc6, u16 length) | |||
| 1006 | 1092 | ||
| 1007 | 1093 | ret = oa_tc6_prcs_rx_chunk_payload(tc6, payload, | |
| 1008 | 1094 | footer); | |
| 1009 | - | if (ret) | |
| 1010 | - | return ret; | |
| 1095 | + | if (ret) { | |
| 1096 | + | if (ret != -ENOMEM && ret != -EAGAIN) | |
| 1097 | + | return ret; | |
| 1098 | + | retry = true; | |
| 1099 | + | } | |
| 1011 | 1100 | } | |
| 1012 | 1101 | } | |
| 1013 | 1102 | ||
| 1014 | - | return 0; | |
| 1103 | + | /* Not bailing out on recoverable error codes, -EAGAIN and | |
| 1104 | + | * -ENOMEM. If subsequent loop iterations, if any, succeeds, | |
| 1105 | + | * error code would be overwritten. retry flag helps to | |
| 1106 | + | * make the caller to continue and retry. Since recovery | |
| 1107 | + | * action for -ENOMEM and -EAGAIN are same, we are returning | |
| 1108 | + | * one of the error codes, that is -EAGAIN. | |
| 1109 | + | * | |
| 1110 | + | * Successful recovery depends on how small the frames are, | |
| 1111 | + | * how many chunks, among the received chunks triggered the | |
| 1112 | + | * error, whether data is intact even with error conditions. | |
| 1113 | + | * As a result, there is no single, best method to recover | |
| 1114 | + | * most data when error conditions hit. We do our best by | |
| 1115 | + | * processing all the chunks with good "footer header" and | |
| 1116 | + | * "data valid" bit set. | |
| 1117 | + | */ | |
| 1118 | + | if (retry) { | |
| 1119 | + | ret = -EAGAIN; | |
| 1120 | + | oa_tc6_look_for_new_frame(tc6); | |
| 1121 | + | } | |
| 1122 | + | ||
| 1123 | + | return ret; | |
| 1015 | 1124 | } | |
| 1016 | 1125 | ||
| 1017 | 1126 | static __be32 oa_tc6_prepare_data_header(bool data_valid, bool start_valid, | |
| @@ -1173,12 +1282,9 @@ static int oa_tc6_try_spi_transfer(struct oa_tc6 *tc6) | |||
| 1173 | 1282 | } | |
| 1174 | 1283 | ||
| 1175 | 1284 | ret = oa_tc6_process_spi_data_rx_buf(tc6, spi_len); | |
| 1176 | - | if (ret) { | |
| 1177 | - | if (ret == -EAGAIN) | |
| 1178 | - | continue; | |
| 1179 | 1285 | ||
| 1180 | - | oa_tc6_cleanup_ongoing_tx_skb(tc6); | |
| 1181 | - | oa_tc6_cleanup_ongoing_rx_skb(tc6); | |
| 1286 | + | if (ret && ret != -EAGAIN) { | |
| 1287 | + | oa_tc6_free_ongoing_skbs(tc6); | |
| 1182 | 1288 | netdev_err(tc6->netdev, "Device error: %d\n", ret); | |
| 1183 | 1289 | return ret; | |
| 1184 | 1290 | } | |
| @@ -1200,15 +1306,20 @@ static irqreturn_t oa_tc6_macphy_threaded_irq(int irq, void *data) | |||
| 1200 | 1306 | * no need to attempt spi transfer, once it fails. Pending skbs | |
| 1201 | 1307 | * are already freed. | |
| 1202 | 1308 | */ | |
| 1203 | - | if (!tc6->disable_traffic) { | |
| 1204 | - | while (tc6->int_flag || | |
| 1205 | - | (tc6->waiting_tx_skb && tc6->tx_credits)) { | |
| 1206 | - | ret = oa_tc6_try_spi_transfer(tc6); | |
| 1207 | - | if (ret) { | |
| 1208 | - | disable_irq_nosync(tc6->spi->irq); | |
| 1209 | - | oa_tc6_disable_traffic(tc6); | |
| 1210 | - | break; | |
| 1211 | - | } | |
| 1309 | + | spin_lock_bh(&tc6->tx_skb_lock); | |
| 1310 | + | if (tc6->disable_traffic) { | |
| 1311 | + | spin_unlock_bh(&tc6->tx_skb_lock); | |
| 1312 | + | return IRQ_HANDLED; | |
| 1313 | + | } | |
| 1314 | + | spin_unlock_bh(&tc6->tx_skb_lock); | |
| 1315 | + | ||
| 1316 | + | while (tc6->int_flag || | |
| 1317 | + | (tc6->waiting_tx_skb && tc6->tx_credits)) { | |
| 1318 | + | ret = oa_tc6_try_spi_transfer(tc6); | |
| 1319 | + | if (ret) { | |
| 1320 | + | disable_irq_nosync(tc6->spi->irq); | |
| 1321 | + | oa_tc6_disable_traffic(tc6); | |
| 1322 | + | break; | |
| 1212 | 1323 | } | |
| 1213 | 1324 | } | |
| 1214 | 1325 | ||
| @@ -1287,23 +1398,30 @@ EXPORT_SYMBOL_GPL(oa_tc6_zero_align_receive_frame_enable); | |||
| 1287 | 1398 | * @tc6: oa_tc6 struct. | |
| 1288 | 1399 | * @skb: socket buffer in which the ethernet frame is stored. | |
| 1289 | 1400 | * | |
| 1290 | - | * Return: NETDEV_TX_OK if the transmit ethernet frame skb added in the tx_skb_q | |
| 1291 | - | * otherwise returns NETDEV_TX_BUSY. | |
| 1401 | + | * Return: NETDEV_TX_OK either on successful queueing of the packet for | |
| 1402 | + | * transmission, or on packet getting dropped. Packet can be dropped due to | |
| 1403 | + | * failure in linearizing the buffer or disable_traffic is set due to | |
| 1404 | + | * earlier fatal error. Returns NETDEV_TX_BUSY when there is no room | |
| 1405 | + | * to queue the packet. | |
| 1292 | 1406 | */ | |
| 1293 | 1407 | netdev_tx_t oa_tc6_start_xmit(struct oa_tc6 *tc6, struct sk_buff *skb) | |
| 1294 | 1408 | { | |
| 1295 | - | if (tc6->disable_traffic || tc6->waiting_tx_skb) { | |
| 1296 | - | netif_stop_queue(tc6->netdev); | |
| 1297 | - | return NETDEV_TX_BUSY; | |
| 1298 | - | } | |
| 1299 | - | ||
| 1300 | 1409 | if (skb_linearize(skb)) { | |
| 1301 | - | dev_kfree_skb_any(skb); | |
| 1302 | - | tc6->netdev->stats.tx_dropped++; | |
| 1410 | + | oa_tc6_drop_tx_skb(tc6, skb); | |
| 1303 | 1411 | return NETDEV_TX_OK; | |
| 1304 | 1412 | } | |
| 1305 | 1413 | ||
| 1306 | 1414 | spin_lock_bh(&tc6->tx_skb_lock); | |
| 1415 | + | if (tc6->waiting_tx_skb) { | |
| 1416 | + | netif_stop_queue(tc6->netdev); | |
| 1417 | + | spin_unlock_bh(&tc6->tx_skb_lock); | |
| 1418 | + | return NETDEV_TX_BUSY; | |
| 1419 | + | } | |
| 1420 | + | if (tc6->disable_traffic) { | |
| 1421 | + | spin_unlock_bh(&tc6->tx_skb_lock); | |
| 1422 | + | oa_tc6_drop_tx_skb(tc6, skb); | |
| 1423 | + | return NETDEV_TX_OK; | |
| 1424 | + | } | |
| 1307 | 1425 | tc6->waiting_tx_skb = skb; | |
| 1308 | 1426 | spin_unlock_bh(&tc6->tx_skb_lock); | |
| 1309 | 1427 | ||
| @@ -1462,8 +1580,10 @@ EXPORT_SYMBOL_GPL(oa_tc6_init); | |||
| 1462 | 1580 | */ | |
| 1463 | 1581 | void oa_tc6_exit(struct oa_tc6 *tc6) | |
| 1464 | 1582 | { | |
| 1465 | - | tc6->disable_traffic = true; | |
| 1466 | 1583 | disable_irq(tc6->spi->irq); | |
| 1584 | + | spin_lock_bh(&tc6->tx_skb_lock); | |
| 1585 | + | tc6->disable_traffic = true; | |
| 1586 | + | spin_unlock_bh(&tc6->tx_skb_lock); | |
| 1467 | 1587 | oa_tc6_phy_exit(tc6); | |
| 1468 | 1588 | oa_tc6_free_pending_skbs(tc6); | |
| 1469 | 1589 | } | |
modified drivers/net/ethernet/pensando/ionic/ionic_txrx.c
| @@ -1672,15 +1672,22 @@ static int ionic_tx(struct net_device *netdev, struct ionic_queue *q, | |||
| 1672 | 1672 | stats->pkts++; | |
| 1673 | 1673 | stats->bytes += skb->len; | |
| 1674 | 1674 | ||
| 1675 | + | ionic_txq_post(q, false); | |
| 1676 | + | ||
| 1675 | 1677 | if (likely(!ionic_txq_hwstamp_enabled(q))) { | |
| 1676 | 1678 | struct netdev_queue *ndq = q_to_ndq(netdev, q); | |
| 1677 | 1679 | ||
| 1678 | - | if (unlikely(!ionic_q_has_space(q, MAX_SKB_FRAGS + 1))) | |
| 1679 | - | netif_tx_stop_queue(ndq); | |
| 1680 | + | netif_txq_maybe_stop(ndq, ionic_q_space_avail(q), | |
| 1681 | + | MAX_SKB_FRAGS + 1, MAX_SKB_FRAGS + 1); | |
| 1680 | 1682 | ring_dbell = __netdev_tx_sent_queue(ndq, skb->len, | |
| 1681 | 1683 | netdev_xmit_more()); | |
| 1682 | 1684 | } | |
| 1683 | - | ionic_txq_post(q, ring_dbell); | |
| 1685 | + | ||
| 1686 | + | if (ring_dbell) { | |
| 1687 | + | ionic_dbell_ring(q->lif->kern_dbpage, q->hw_type, | |
| 1688 | + | q->dbval | q->head_idx); | |
| 1689 | + | q->dbell_jiffies = jiffies; | |
| 1690 | + | } | |
| 1684 | 1691 | ||
| 1685 | 1692 | return 0; | |
| 1686 | 1693 | } | |
modified drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
| @@ -3676,6 +3676,14 @@ static int stmmac_hw_setup(struct net_device *dev) | |||
| 3676 | 3676 | /* Initialize MTL*/ | |
| 3677 | 3677 | stmmac_mtl_configuration(priv); | |
| 3678 | 3678 | ||
| 3679 | + | /* Apply the RX packet parser table */ | |
| 3680 | + | if (priv->tc_entries) { | |
| 3681 | + | ret = stmmac_rxp_config(priv, priv->hw->pcsr, priv->tc_entries, | |
| 3682 | + | priv->tc_entries_max); | |
| 3683 | + | if (ret) | |
| 3684 | + | return ret; | |
| 3685 | + | } | |
| 3686 | + | ||
| 3679 | 3687 | /* Initialize Safety Features */ | |
| 3680 | 3688 | stmmac_safety_feat_configuration(priv); | |
| 3681 | 3689 | ||
| @@ -4319,6 +4327,7 @@ static bool stmmac_vlan_insert(struct stmmac_priv *priv, struct sk_buff *skb, | |||
| 4319 | 4327 | /** | |
| 4320 | 4328 | * stmmac_tso_allocator - close entry point of the driver | |
| 4321 | 4329 | * @priv: driver private structure | |
| 4330 | + | * @entry: TX queue buffer index | |
| 4322 | 4331 | * @des: buffer start address | |
| 4323 | 4332 | * @total_len: total length to fill in descriptors | |
| 4324 | 4333 | * @last_segment: condition for the last descriptor | |
| @@ -4327,8 +4336,9 @@ static bool stmmac_vlan_insert(struct stmmac_priv *priv, struct sk_buff *skb, | |||
| 4327 | 4336 | * This function fills descriptor and request new descriptors according to | |
| 4328 | 4337 | * buffer length to fill | |
| 4329 | 4338 | */ | |
| 4330 | - | static void stmmac_tso_allocator(struct stmmac_priv *priv, dma_addr_t des, | |
| 4331 | - | int total_len, bool last_segment, u32 queue) | |
| 4339 | + | static void stmmac_tso_allocator(struct stmmac_priv *priv, u32 *entry, | |
| 4340 | + | dma_addr_t des, int total_len, | |
| 4341 | + | bool last_segment, u32 queue) | |
| 4332 | 4342 | { | |
| 4333 | 4343 | struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue]; | |
| 4334 | 4344 | struct dma_desc *desc; | |
| @@ -4340,14 +4350,13 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, dma_addr_t des, | |||
| 4340 | 4350 | while (tmp_len > 0) { | |
| 4341 | 4351 | dma_addr_t curr_addr; | |
| 4342 | 4352 | ||
| 4343 | - | tx_q->cur_tx = STMMAC_NEXT_ENTRY(tx_q->cur_tx, | |
| 4344 | - | priv->dma_conf.dma_tx_size); | |
| 4345 | - | WARN_ON(tx_q->tx_skbuff[tx_q->cur_tx]); | |
| 4353 | + | *entry = STMMAC_NEXT_ENTRY(*entry, priv->dma_conf.dma_tx_size); | |
| 4354 | + | WARN_ON(tx_q->tx_skbuff[*entry]); | |
| 4346 | 4355 | ||
| 4347 | 4356 | if (tx_q->tbs & STMMAC_TBS_AVAIL) | |
| 4348 | - | desc = &tx_q->dma_entx[tx_q->cur_tx].basic; | |
| 4357 | + | desc = &tx_q->dma_entx[*entry].basic; | |
| 4349 | 4358 | else | |
| 4350 | - | desc = &tx_q->dma_tx[tx_q->cur_tx]; | |
| 4359 | + | desc = &tx_q->dma_tx[*entry]; | |
| 4351 | 4360 | ||
| 4352 | 4361 | curr_addr = des + (total_len - tmp_len); | |
| 4353 | 4362 | stmmac_set_desc_addr(priv, desc, curr_addr); | |
| @@ -4445,6 +4454,26 @@ static bool stmmac_tso_valid_packet(struct sk_buff *skb) | |||
| 4445 | 4454 | header_len + gso_size < 16383; | |
| 4446 | 4455 | } | |
| 4447 | 4456 | ||
| 4457 | + | static int stmmac_tso_get_num_desc(struct stmmac_tx_queue *tx_q, | |
| 4458 | + | struct sk_buff *skb, u32 pay_len) | |
| 4459 | + | { | |
| 4460 | + | int i, ndesc = 1; | |
| 4461 | + | ||
| 4462 | + | /* head payload */ | |
| 4463 | + | ndesc += DIV_ROUND_UP(pay_len, TSO_MAX_BUFF_SIZE); | |
| 4464 | + | /* frag payload */ | |
| 4465 | + | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | |
| 4466 | + | const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | |
| 4467 | + | ||
| 4468 | + | ndesc += DIV_ROUND_UP(skb_frag_size(frag), | |
| 4469 | + | TSO_MAX_BUFF_SIZE); | |
| 4470 | + | } | |
| 4471 | + | /* MSS update requires a new descriptor */ | |
| 4472 | + | ndesc += !!(skb_shinfo(skb)->gso_size != tx_q->mss); | |
| 4473 | + | ||
| 4474 | + | return ndesc; | |
| 4475 | + | } | |
| 4476 | + | ||
| 4448 | 4477 | /** | |
| 4449 | 4478 | * stmmac_tso_xmit - Tx entry point of the driver for oversized frames (TSO) | |
| 4450 | 4479 | * @skb : the socket buffer | |
| @@ -4486,12 +4515,12 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 4486 | 4515 | { | |
| 4487 | 4516 | struct dma_desc *desc, *first, *mss_desc = NULL; | |
| 4488 | 4517 | struct stmmac_priv *priv = netdev_priv(dev); | |
| 4489 | - | unsigned int first_entry, tx_packets; | |
| 4518 | + | unsigned int first_entry, entry, tx_packets; | |
| 4490 | 4519 | struct stmmac_txq_stats *txq_stats; | |
| 4520 | + | int i, first_tx, nfrags, ndesc; | |
| 4491 | 4521 | struct stmmac_tx_queue *tx_q; | |
| 4492 | 4522 | bool set_ic, is_last_segment; | |
| 4493 | 4523 | u32 pay_len, mss, queue; | |
| 4494 | - | int i, first_tx, nfrags; | |
| 4495 | 4524 | u8 proto_hdr_len, hdr; | |
| 4496 | 4525 | dma_addr_t des; | |
| 4497 | 4526 | ||
| @@ -4504,14 +4533,15 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 4504 | 4533 | ||
| 4505 | 4534 | /* Compute header lengths */ | |
| 4506 | 4535 | proto_hdr_len = stmmac_tso_header_size(skb); | |
| 4536 | + | pay_len = skb_headlen(skb) - proto_hdr_len; /* no frags */ | |
| 4537 | + | ||
| 4507 | 4538 | if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) | |
| 4508 | 4539 | hdr = sizeof(struct udphdr); | |
| 4509 | 4540 | else | |
| 4510 | 4541 | hdr = tcp_hdrlen(skb); | |
| 4511 | 4542 | ||
| 4512 | - | /* Desc availability based on threshold should be enough safe */ | |
| 4513 | - | if (unlikely(stmmac_tx_avail(priv, queue) < | |
| 4514 | - | (((skb->len - proto_hdr_len) / TSO_MAX_BUFF_SIZE + 1)))) { | |
| 4543 | + | ndesc = stmmac_tso_get_num_desc(tx_q, skb, pay_len); | |
| 4544 | + | if (unlikely(stmmac_tx_avail(priv, queue) < ndesc)) { | |
| 4515 | 4545 | if (!netif_tx_queue_stopped(netdev_get_tx_queue(dev, queue))) { | |
| 4516 | 4546 | netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, | |
| 4517 | 4547 | queue)); | |
| @@ -4523,8 +4553,6 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 4523 | 4553 | return NETDEV_TX_BUSY; | |
| 4524 | 4554 | } | |
| 4525 | 4555 | ||
| 4526 | - | pay_len = skb_headlen(skb) - proto_hdr_len; /* no frags */ | |
| 4527 | - | ||
| 4528 | 4556 | mss = skb_shinfo(skb)->gso_size; | |
| 4529 | 4557 | ||
| 4530 | 4558 | /* set new MSS value if needed */ | |
| @@ -4549,22 +4577,24 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 4549 | 4577 | } | |
| 4550 | 4578 | ||
| 4551 | 4579 | first_entry = tx_q->cur_tx; | |
| 4552 | - | WARN_ON(tx_q->tx_skbuff[first_entry]); | |
| 4580 | + | entry = first_entry; | |
| 4581 | + | ||
| 4582 | + | WARN_ON(tx_q->tx_skbuff[entry]); | |
| 4553 | 4583 | ||
| 4554 | 4584 | if (tx_q->tbs & STMMAC_TBS_AVAIL) | |
| 4555 | - | desc = &tx_q->dma_entx[first_entry].basic; | |
| 4585 | + | desc = &tx_q->dma_entx[entry].basic; | |
| 4556 | 4586 | else | |
| 4557 | - | desc = &tx_q->dma_tx[first_entry]; | |
| 4587 | + | desc = &tx_q->dma_tx[entry]; | |
| 4558 | 4588 | first = desc; | |
| 4559 | 4589 | ||
| 4560 | 4590 | /* first descriptor: fill Headers on Buf1 */ | |
| 4561 | 4591 | des = dma_map_single(priv->device, skb->data, skb_headlen(skb), | |
| 4562 | 4592 | DMA_TO_DEVICE); | |
| 4563 | 4593 | if (dma_mapping_error(priv->device, des)) | |
| 4564 | - | goto dma_map_err; | |
| 4594 | + | goto error; | |
| 4565 | 4595 | ||
| 4566 | 4596 | stmmac_set_desc_addr(priv, first, des); | |
| 4567 | - | stmmac_tso_allocator(priv, des + proto_hdr_len, pay_len, | |
| 4597 | + | stmmac_tso_allocator(priv, &entry, des + proto_hdr_len, pay_len, | |
| 4568 | 4598 | (nfrags == 0), queue); | |
| 4569 | 4599 | ||
| 4570 | 4600 | /* In case two or more DMA transmit descriptors are allocated for this | |
| @@ -4579,8 +4609,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 4579 | 4609 | * this DMA buffer right after the DMA engine completely finishes the | |
| 4580 | 4610 | * full buffer transmission. | |
| 4581 | 4611 | */ | |
| 4582 | - | stmmac_set_tx_skb_dma_entry(tx_q, tx_q->cur_tx, des, skb_headlen(skb), | |
| 4583 | - | false); | |
| 4612 | + | stmmac_set_tx_skb_dma_entry(tx_q, entry, des, skb_headlen(skb), false); | |
| 4584 | 4613 | ||
| 4585 | 4614 | /* Prepare fragments */ | |
| 4586 | 4615 | for (i = 0; i < nfrags; i++) { | |
| @@ -4590,14 +4619,15 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 4590 | 4619 | skb_frag_size(frag), | |
| 4591 | 4620 | DMA_TO_DEVICE); | |
| 4592 | 4621 | if (dma_mapping_error(priv->device, des)) | |
| 4593 | - | goto dma_map_err; | |
| 4622 | + | goto error_dma_unmap; | |
| 4594 | 4623 | ||
| 4595 | - | stmmac_tso_allocator(priv, des, skb_frag_size(frag), | |
| 4624 | + | stmmac_tso_allocator(priv, &entry, des, skb_frag_size(frag), | |
| 4596 | 4625 | (i == nfrags - 1), queue); | |
| 4597 | 4626 | ||
| 4598 | - | stmmac_set_tx_skb_dma_entry(tx_q, tx_q->cur_tx, des, | |
| 4627 | + | stmmac_set_tx_skb_dma_entry(tx_q, entry, des, | |
| 4599 | 4628 | skb_frag_size(frag), true); | |
| 4600 | 4629 | } | |
| 4630 | + | tx_q->cur_tx = entry; | |
| 4601 | 4631 | ||
| 4602 | 4632 | stmmac_set_tx_dma_last_segment(tx_q, tx_q->cur_tx); | |
| 4603 | 4633 | ||
| @@ -4702,7 +4732,19 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 4702 | 4732 | ||
| 4703 | 4733 | return NETDEV_TX_OK; | |
| 4704 | 4734 | ||
| 4705 | - | dma_map_err: | |
| 4735 | + | error_dma_unmap: | |
| 4736 | + | for (;;) { | |
| 4737 | + | desc = stmmac_get_tx_desc(priv, tx_q, first_entry); | |
| 4738 | + | stmmac_release_tx_desc(priv, desc, priv->descriptor_mode); | |
| 4739 | + | stmmac_free_tx_buffer(priv, &priv->dma_conf, queue, | |
| 4740 | + | first_entry); | |
| 4741 | + | if (first_entry == entry) | |
| 4742 | + | break; | |
| 4743 | + | ||
| 4744 | + | first_entry = STMMAC_NEXT_ENTRY(first_entry, | |
| 4745 | + | priv->dma_conf.dma_tx_size); | |
| 4746 | + | } | |
| 4747 | + | error: | |
| 4706 | 4748 | dev_err(priv->device, "Tx dma map failed\n"); | |
| 4707 | 4749 | dev_kfree_skb(skb); | |
| 4708 | 4750 | priv->xstats.tx_dropped++; | |
| @@ -8002,6 +8044,7 @@ static int __stmmac_dvr_probe(struct device *device, | |||
| 8002 | 8044 | stmmac_napi_add(ndev); | |
| 8003 | 8045 | ||
| 8004 | 8046 | mutex_init(&priv->lock); | |
| 8047 | + | rwlock_init(&priv->ptp_lock); | |
| 8005 | 8048 | ||
| 8006 | 8049 | stmmac_fpe_init(priv); | |
| 8007 | 8050 | ||
modified drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
| @@ -365,7 +365,6 @@ void stmmac_ptp_register(struct stmmac_priv *priv) | |||
| 365 | 365 | if (priv->plat->crosststamp) | |
| 366 | 366 | priv->ptp_clock_ops.getcrosststamp = stmmac_getcrosststamp; | |
| 367 | 367 | ||
| 368 | - | rwlock_init(&priv->ptp_lock); | |
| 369 | 368 | mutex_init(&priv->aux_ts_lock); | |
| 370 | 369 | ||
| 371 | 370 | priv->ptp_clock = ptp_clock_register(&priv->ptp_clock_ops, | |
modified drivers/net/gtp.c
| @@ -318,6 +318,11 @@ static int gtp_inner_proto(struct sk_buff *skb, unsigned int hdrlen, | |||
| 318 | 318 | static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff *skb, | |
| 319 | 319 | unsigned int hdrlen, unsigned int role, __u16 inner_proto) | |
| 320 | 320 | { | |
| 321 | + | if (skb_is_gso(skb)) { | |
| 322 | + | netdev_dbg(pctx->dev, "GSO is not supported in GTP\n"); | |
| 323 | + | goto err; | |
| 324 | + | } | |
| 325 | + | ||
| 321 | 326 | if (!gtp_check_ms(skb, pctx, hdrlen, role, inner_proto)) { | |
| 322 | 327 | netdev_dbg(pctx->dev, "No PDP ctx for this MS\n"); | |
| 323 | 328 | return 1; | |
modified drivers/net/ieee802154/cc2520.c
| @@ -1156,11 +1156,10 @@ static void cc2520_remove(struct spi_device *spi) | |||
| 1156 | 1156 | { | |
| 1157 | 1157 | struct cc2520_private *priv = spi_get_drvdata(spi); | |
| 1158 | 1158 | ||
| 1159 | - | mutex_destroy(&priv->buffer_mutex); | |
| 1160 | - | flush_work(&priv->fifop_irqwork); | |
| 1161 | - | ||
| 1159 | + | disable_work_sync(&priv->fifop_irqwork); | |
| 1162 | 1160 | ieee802154_unregister_hw(priv->hw); | |
| 1163 | 1161 | ieee802154_free_hw(priv->hw); | |
| 1162 | + | mutex_destroy(&priv->buffer_mutex); | |
| 1164 | 1163 | } | |
| 1165 | 1164 | ||
| 1166 | 1165 | static const struct spi_device_id cc2520_ids[] = { | |
modified drivers/net/ieee802154/mac802154_hwsim.c
| @@ -72,6 +72,8 @@ struct hwsim_phy { | |||
| 72 | 72 | struct ieee802154_hw *hw; | |
| 73 | 73 | u32 idx; | |
| 74 | 74 | ||
| 75 | + | /* Serializes phy->pib_updates. */ | |
| 76 | + | spinlock_t pib_lock; | |
| 75 | 77 | struct hwsim_pib __rcu *pib; | |
| 76 | 78 | ||
| 77 | 79 | bool suspended; | |
| @@ -102,8 +104,6 @@ static int hwsim_update_pib(struct ieee802154_hw *hw, u8 page, u8 channel, | |||
| 102 | 104 | if (!pib) | |
| 103 | 105 | return -ENOMEM; | |
| 104 | 106 | ||
| 105 | - | pib_old = rtnl_dereference(phy->pib); | |
| 106 | - | ||
| 107 | 107 | pib->page = page; | |
| 108 | 108 | pib->channel = channel; | |
| 109 | 109 | pib->filt.short_addr = filt->short_addr; | |
| @@ -112,7 +112,10 @@ static int hwsim_update_pib(struct ieee802154_hw *hw, u8 page, u8 channel, | |||
| 112 | 112 | pib->filt.pan_coord = filt->pan_coord; | |
| 113 | 113 | pib->filt_level = filt_level; | |
| 114 | 114 | ||
| 115 | - | rcu_assign_pointer(phy->pib, pib); | |
| 115 | + | spin_lock_bh(&phy->pib_lock); | |
| 116 | + | pib_old = rcu_replace_pointer(phy->pib, pib, | |
| 117 | + | lockdep_is_held(&phy->pib_lock)); | |
| 118 | + | spin_unlock_bh(&phy->pib_lock); | |
| 116 | 119 | kfree_rcu(pib_old, rcu); | |
| 117 | 120 | return 0; | |
| 118 | 121 | } | |
| @@ -952,6 +955,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev, | |||
| 952 | 955 | goto err_pib; | |
| 953 | 956 | } | |
| 954 | 957 | ||
| 958 | + | spin_lock_init(&phy->pib_lock); | |
| 955 | 959 | pib->channel = 13; | |
| 956 | 960 | pib->filt.short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST); | |
| 957 | 961 | pib->filt.pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST); | |
modified drivers/net/ipvlan/ipvlan_main.c
| @@ -848,7 +848,6 @@ static int ipvlan_device_event(struct notifier_block *unused, | |||
| 848 | 848 | __ipvlan_link_delete(net, ipvlan->dev, &lst_kill); | |
| 849 | 849 | } | |
| 850 | 850 | ||
| 851 | - | unregister_netdevice_many(&lst_kill); | |
| 852 | 851 | break; | |
| 853 | 852 | } | |
| 854 | 853 | case NETDEV_FEAT_CHANGE: | |
| @@ -899,6 +898,9 @@ static int ipvlan_device_event(struct notifier_block *unused, | |||
| 899 | 898 | ||
| 900 | 899 | mutex_unlock(&port->pnodes_lock); | |
| 901 | 900 | ||
| 901 | + | /* Avoid invoking nested netdevice notifiers under pnodes_lock. */ | |
| 902 | + | unregister_netdevice_many(&lst_kill); | |
| 903 | + | ||
| 902 | 904 | ipvlan_port_put(port); | |
| 903 | 905 | ||
| 904 | 906 | return ret; | |
modified drivers/net/mctp/mctp-i3c.c
| @@ -288,6 +288,7 @@ err: | |||
| 288 | 288 | static int mctp_i3c_probe(struct i3c_device *i3c) | |
| 289 | 289 | { | |
| 290 | 290 | struct mctp_i3c_bus *b = NULL, *mbus = NULL; | |
| 291 | + | int rc; | |
| 291 | 292 | ||
| 292 | 293 | /* Look for a known bus */ | |
| 293 | 294 | mutex_lock(&busdevs_lock); | |
| @@ -296,14 +297,16 @@ static int mctp_i3c_probe(struct i3c_device *i3c) | |||
| 296 | 297 | mbus = b; | |
| 297 | 298 | break; | |
| 298 | 299 | } | |
| 299 | - | mutex_unlock(&busdevs_lock); | |
| 300 | 300 | ||
| 301 | 301 | if (!mbus) { | |
| 302 | 302 | /* probably no "mctp-controller" property on the i3c bus */ | |
| 303 | - | return -ENODEV; | |
| 303 | + | rc = -ENODEV; | |
| 304 | + | } else { | |
| 305 | + | rc = mctp_i3c_add_device(mbus, i3c); | |
| 304 | 306 | } | |
| 307 | + | mutex_unlock(&busdevs_lock); | |
| 305 | 308 | ||
| 306 | - | return mctp_i3c_add_device(mbus, i3c); | |
| 309 | + | return rc; | |
| 307 | 310 | } | |
| 308 | 311 | ||
| 309 | 312 | static void mctp_i3c_remove_device(struct mctp_i3c_device *mi) | |
modified drivers/net/net_failover.c
| @@ -675,7 +675,7 @@ static int net_failover_slave_name_change(struct net_device *slave_dev, | |||
| 675 | 675 | /* We need to bring up the slave after the rename by udev in case | |
| 676 | 676 | * open failed with EBUSY when it was registered. | |
| 677 | 677 | */ | |
| 678 | - | dev_open(slave_dev, NULL); | |
| 678 | + | netif_open(slave_dev, NULL); | |
| 679 | 679 | ||
| 680 | 680 | return 0; | |
| 681 | 681 | } | |
modified drivers/net/ntb_netdev.c
| @@ -127,8 +127,10 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data, | |||
| 127 | 127 | { | |
| 128 | 128 | struct ntb_netdev_queue *q = qp_data; | |
| 129 | 129 | struct ntb_netdev *dev = q->ntdev; | |
| 130 | + | struct pcpu_sw_netstats *tstats; | |
| 130 | 131 | struct sk_buff *skb, *new_skb; | |
| 131 | 132 | struct net_device *ndev; | |
| 133 | + | unsigned long flags; | |
| 132 | 134 | int rc; | |
| 133 | 135 | ||
| 134 | 136 | ndev = dev->ndev; | |
| @@ -139,17 +141,20 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data, | |||
| 139 | 141 | netdev_dbg(ndev, "%s: %d byte payload received\n", __func__, len); | |
| 140 | 142 | ||
| 141 | 143 | if (len < 0) { | |
| 142 | - | ndev->stats.rx_errors++; | |
| 143 | - | ndev->stats.rx_length_errors++; | |
| 144 | + | DEV_STATS_INC(ndev, rx_errors); | |
| 145 | + | DEV_STATS_INC(ndev, rx_length_errors); | |
| 144 | 146 | goto enqueue_again; | |
| 145 | 147 | } | |
| 146 | 148 | ||
| 147 | - | ndev->stats.rx_packets++; | |
| 148 | - | ndev->stats.rx_bytes += len; | |
| 149 | + | tstats = this_cpu_ptr(ndev->tstats); | |
| 150 | + | flags = u64_stats_update_begin_irqsave(&tstats->syncp); | |
| 151 | + | u64_stats_inc(&tstats->rx_packets); | |
| 152 | + | u64_stats_add(&tstats->rx_bytes, len); | |
| 153 | + | u64_stats_update_end_irqrestore(&tstats->syncp, flags); | |
| 149 | 154 | ||
| 150 | 155 | new_skb = netdev_alloc_skb(ndev, ndev->mtu + ETH_HLEN); | |
| 151 | 156 | if (!new_skb) { | |
| 152 | - | ndev->stats.rx_dropped++; | |
| 157 | + | DEV_STATS_INC(ndev, rx_dropped); | |
| 153 | 158 | goto enqueue_again; | |
| 154 | 159 | } | |
| 155 | 160 | ||
| @@ -166,8 +171,8 @@ enqueue_again: | |||
| 166 | 171 | rc = ntb_transport_rx_enqueue(qp, skb, skb->data, ndev->mtu + ETH_HLEN); | |
| 167 | 172 | if (rc) { | |
| 168 | 173 | dev_kfree_skb_any(skb); | |
| 169 | - | ndev->stats.rx_errors++; | |
| 170 | - | ndev->stats.rx_fifo_errors++; | |
| 174 | + | DEV_STATS_INC(ndev, rx_errors); | |
| 175 | + | DEV_STATS_INC(ndev, rx_fifo_errors); | |
| 171 | 176 | } | |
| 172 | 177 | } | |
| 173 | 178 | ||
| @@ -210,25 +215,39 @@ static void ntb_netdev_tx_handler(struct ntb_transport_qp *qp, void *qp_data, | |||
| 210 | 215 | { | |
| 211 | 216 | struct ntb_netdev_queue *q = qp_data; | |
| 212 | 217 | struct ntb_netdev *dev = q->ntdev; | |
| 218 | + | struct pcpu_sw_netstats *tstats; | |
| 213 | 219 | struct net_device *ndev; | |
| 214 | 220 | struct sk_buff *skb; | |
| 221 | + | unsigned long flags; | |
| 222 | + | bool registered; | |
| 215 | 223 | ||
| 216 | 224 | ndev = dev->ndev; | |
| 217 | 225 | skb = data; | |
| 218 | 226 | if (!skb || !ndev) | |
| 219 | 227 | return; | |
| 220 | 228 | ||
| 229 | + | rcu_read_lock(); | |
| 230 | + | registered = READ_ONCE(ndev->reg_state) == NETREG_REGISTERED; | |
| 231 | + | if (!registered) | |
| 232 | + | goto free_skb; | |
| 233 | + | ||
| 221 | 234 | if (len > 0) { | |
| 222 | - | ndev->stats.tx_packets++; | |
| 223 | - | ndev->stats.tx_bytes += skb->len; | |
| 235 | + | /* The memcpy kthread can migrate, so pin the per-CPU update. */ | |
| 236 | + | tstats = get_cpu_ptr(ndev->tstats); | |
| 237 | + | flags = u64_stats_update_begin_irqsave(&tstats->syncp); | |
| 238 | + | u64_stats_inc(&tstats->tx_packets); | |
| 239 | + | u64_stats_add(&tstats->tx_bytes, skb->len); | |
| 240 | + | u64_stats_update_end_irqrestore(&tstats->syncp, flags); | |
| 241 | + | put_cpu_ptr(ndev->tstats); | |
| 224 | 242 | } else { | |
| 225 | - | ndev->stats.tx_errors++; | |
| 226 | - | ndev->stats.tx_aborted_errors++; | |
| 243 | + | DEV_STATS_INC(ndev, tx_errors); | |
| 244 | + | DEV_STATS_INC(ndev, tx_aborted_errors); | |
| 227 | 245 | } | |
| 228 | 246 | ||
| 247 | + | free_skb: | |
| 229 | 248 | dev_kfree_skb_any(skb); | |
| 230 | 249 | ||
| 231 | - | if (ntb_transport_tx_free_entry(qp) >= tx_start) { | |
| 250 | + | if (registered && ntb_transport_tx_free_entry(qp) >= tx_start) { | |
| 232 | 251 | /* Make sure anybody stopping the queue after this sees the new | |
| 233 | 252 | * value of ntb_transport_tx_free_entry() | |
| 234 | 253 | */ | |
| @@ -237,6 +256,7 @@ static void ntb_netdev_tx_handler(struct ntb_transport_qp *qp, void *qp_data, | |||
| 237 | 256 | ntb_transport_link_query(q->qp)) | |
| 238 | 257 | netif_wake_subqueue(ndev, q->qid); | |
| 239 | 258 | } | |
| 259 | + | rcu_read_unlock(); | |
| 240 | 260 | } | |
| 241 | 261 | ||
| 242 | 262 | static const struct ntb_queue_handlers ntb_netdev_handlers = { | |
| @@ -277,7 +297,7 @@ static netdev_tx_t ntb_netdev_start_xmit(struct sk_buff *skb, | |||
| 277 | 297 | ||
| 278 | 298 | drop: | |
| 279 | 299 | dev_kfree_skb_any(skb); | |
| 280 | - | ndev->stats.tx_dropped++; | |
| 300 | + | DEV_STATS_INC(ndev, tx_dropped); | |
| 281 | 301 | return NETDEV_TX_OK; | |
| 282 | 302 | } | |
| 283 | 303 | ||
| @@ -639,14 +659,14 @@ static int ntb_netdev_probe(struct device *client_dev) | |||
| 639 | 659 | dev->client_dev = client_dev; | |
| 640 | 660 | dev->num_queues = 0; | |
| 641 | 661 | ||
| 642 | - | dev->queues = kzalloc_objs(*dev->queues, NTB_NETDEV_MAX_QUEUES, | |
| 643 | - | GFP_KERNEL); | |
| 662 | + | dev->queues = kzalloc_objs(*dev->queues, NTB_NETDEV_MAX_QUEUES); | |
| 644 | 663 | if (!dev->queues) { | |
| 645 | 664 | rc = -ENOMEM; | |
| 646 | 665 | goto err_free_netdev; | |
| 647 | 666 | } | |
| 648 | 667 | ||
| 649 | 668 | ndev->features = NETIF_F_HIGHDMA; | |
| 669 | + | ndev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; | |
| 650 | 670 | ||
| 651 | 671 | ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; | |
| 652 | 672 | ||
modified drivers/net/phy/dp83867.c
| @@ -1150,6 +1150,9 @@ static int dp83867_led_polarity_set(struct phy_device *phydev, int index, | |||
| 1150 | 1150 | case PHY_LED_ACTIVE_LOW: | |
| 1151 | 1151 | polarity = 0; | |
| 1152 | 1152 | break; | |
| 1153 | + | case PHY_LED_ACTIVE_HIGH: | |
| 1154 | + | polarity = DP83867_LED_POLARITY(index); | |
| 1155 | + | break; | |
| 1153 | 1156 | default: | |
| 1154 | 1157 | return -EINVAL; | |
| 1155 | 1158 | } | |
modified drivers/net/phy/dp83td510.c
| @@ -439,6 +439,9 @@ static int dp83td510_led_polarity_set(struct phy_device *phydev, int index, | |||
| 439 | 439 | case PHY_LED_ACTIVE_LOW: | |
| 440 | 440 | polarity = 0; | |
| 441 | 441 | break; | |
| 442 | + | case PHY_LED_ACTIVE_HIGH: | |
| 443 | + | polarity = DP83TD510E_LED_POLARITY(index); | |
| 444 | + | break; | |
| 442 | 445 | default: | |
| 443 | 446 | return -EINVAL; | |
| 444 | 447 | } | |
modified drivers/net/phy/mediatek/mtk-ge.c
| @@ -62,10 +62,38 @@ static void mtk_gephy_config_init(struct phy_device *phydev) | |||
| 62 | 62 | FIELD_PREP(MTK_MCC_NEARECHO_OFFSET_MASK, 0x3)); | |
| 63 | 63 | } | |
| 64 | 64 | ||
| 65 | + | static int mt7530_phy_probe(struct phy_device *phydev) | |
| 66 | + | { | |
| 67 | + | /* The MT7530 internal GE PHY has broken EEE: with EEE advertised, | |
| 68 | + | * some link partners fail to establish a stable link (on a 2-pair | |
| 69 | + | * cable, 1000BASE-T training fails and the port loops instead of | |
| 70 | + | * falling back). MediaTek recommends disabling EEE on this PHY. | |
| 71 | + | * Clear the advertisement as early as possible, before anything | |
| 72 | + | * can negotiate EEE with the link partner. | |
| 73 | + | */ | |
| 74 | + | return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0); | |
| 75 | + | } | |
| 76 | + | ||
| 65 | 77 | static int mt7530_phy_config_init(struct phy_device *phydev) | |
| 66 | 78 | { | |
| 79 | + | int ret; | |
| 80 | + | ||
| 67 | 81 | mtk_gephy_config_init(phydev); | |
| 68 | 82 | ||
| 83 | + | /* The probe() clear alone is not durable: phy_init_hw() replays only | |
| 84 | + | * ->config_init after a PHY reset, with the register back at its | |
| 85 | + | * EEE-advertising hardware default, and phy_probe() zeroes | |
| 86 | + | * eee_disabled_modes (of_set_phy_eee_broken()) after ->probe already | |
| 87 | + | * ran. Clear the advertisement again and mark EEE disabled, so that | |
| 88 | + | * neither phylib nor userspace can re-enable it; dp83867 disables | |
| 89 | + | * broken EEE from config_init() the same way. | |
| 90 | + | */ | |
| 91 | + | ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0); | |
| 92 | + | if (ret) | |
| 93 | + | return ret; | |
| 94 | + | ||
| 95 | + | phy_disable_eee(phydev); | |
| 96 | + | ||
| 69 | 97 | /* Increase post_update_timer */ | |
| 70 | 98 | phy_write_paged(phydev, MTK_PHY_PAGE_EXTENDED_3, | |
| 71 | 99 | MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG11, 0x4b); | |
| @@ -100,6 +128,7 @@ static struct phy_driver mtk_gephy_driver[] = { | |||
| 100 | 128 | { | |
| 101 | 129 | PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7530), | |
| 102 | 130 | .name = "MediaTek MT7530 PHY", | |
| 131 | + | .probe = mt7530_phy_probe, | |
| 103 | 132 | .config_init = mt7530_phy_config_init, | |
| 104 | 133 | /* Interrupts are handled by the switch, not the PHY | |
| 105 | 134 | * itself. | |
modified drivers/net/phy/phylink.c
| @@ -1630,8 +1630,10 @@ static void phylink_resolve(struct work_struct *w) | |||
| 1630 | 1630 | ||
| 1631 | 1631 | if (pl->phylink_disable_state) { | |
| 1632 | 1632 | pl->link_failed = false; | |
| 1633 | + | link_state = pl->link_config; | |
| 1633 | 1634 | link_state.link = false; | |
| 1634 | 1635 | } else if (pl->link_failed) { | |
| 1636 | + | link_state = pl->link_config; | |
| 1635 | 1637 | link_state.link = false; | |
| 1636 | 1638 | retrigger = true; | |
| 1637 | 1639 | } else if (pl->act_link_an_mode == MLO_AN_FIXED) { | |
modified drivers/net/ppp/ppp_async.c
| @@ -63,8 +63,6 @@ struct asyncppp { | |||
| 63 | 63 | ||
| 64 | 64 | struct tasklet_struct tsk; | |
| 65 | 65 | ||
| 66 | - | refcount_t refcnt; | |
| 67 | - | struct completion dead; | |
| 68 | 66 | struct ppp_channel chan; /* interface to generic ppp layer */ | |
| 69 | 67 | unsigned char obuf[OBUFSIZE]; | |
| 70 | 68 | }; | |
| @@ -114,38 +112,6 @@ static const struct ppp_channel_ops async_ops = { | |||
| 114 | 112 | * Routines implementing the PPP line discipline. | |
| 115 | 113 | */ | |
| 116 | 114 | ||
| 117 | - | /* | |
| 118 | - | * We have a potential race on dereferencing tty->disc_data, | |
| 119 | - | * because the tty layer provides no locking at all - thus one | |
| 120 | - | * cpu could be running ppp_asynctty_receive while another | |
| 121 | - | * calls ppp_asynctty_close, which zeroes tty->disc_data and | |
| 122 | - | * frees the memory that ppp_asynctty_receive is using. The best | |
| 123 | - | * way to fix this is to use a rwlock in the tty struct, but for now | |
| 124 | - | * we use a single global rwlock for all ttys in ppp line discipline. | |
| 125 | - | * | |
| 126 | - | * FIXME: this is no longer true. The _close path for the ldisc is | |
| 127 | - | * now guaranteed to be sane. | |
| 128 | - | */ | |
| 129 | - | static DEFINE_RWLOCK(disc_data_lock); | |
| 130 | - | ||
| 131 | - | static struct asyncppp *ap_get(struct tty_struct *tty) | |
| 132 | - | { | |
| 133 | - | struct asyncppp *ap; | |
| 134 | - | ||
| 135 | - | read_lock(&disc_data_lock); | |
| 136 | - | ap = tty->disc_data; | |
| 137 | - | if (ap != NULL) | |
| 138 | - | refcount_inc(&ap->refcnt); | |
| 139 | - | read_unlock(&disc_data_lock); | |
| 140 | - | return ap; | |
| 141 | - | } | |
| 142 | - | ||
| 143 | - | static void ap_put(struct asyncppp *ap) | |
| 144 | - | { | |
| 145 | - | if (refcount_dec_and_test(&ap->refcnt)) | |
| 146 | - | complete(&ap->dead); | |
| 147 | - | } | |
| 148 | - | ||
| 149 | 115 | /* | |
| 150 | 116 | * Called when a tty is put into PPP line discipline. Called in process | |
| 151 | 117 | * context. | |
| @@ -180,9 +146,6 @@ ppp_asynctty_open(struct tty_struct *tty) | |||
| 180 | 146 | skb_queue_head_init(&ap->rqueue); | |
| 181 | 147 | tasklet_setup(&ap->tsk, ppp_async_process); | |
| 182 | 148 | ||
| 183 | - | refcount_set(&ap->refcnt, 1); | |
| 184 | - | init_completion(&ap->dead); | |
| 185 | - | ||
| 186 | 149 | ap->chan.private = ap; | |
| 187 | 150 | ap->chan.ops = &async_ops; | |
| 188 | 151 | ap->chan.mtu = PPP_MRU; | |
| @@ -203,34 +166,18 @@ ppp_asynctty_open(struct tty_struct *tty) | |||
| 203 | 166 | } | |
| 204 | 167 | ||
| 205 | 168 | /* | |
| 206 | - | * Called when the tty is put into another line discipline | |
| 207 | - | * or it hangs up. We have to wait for any cpu currently | |
| 208 | - | * executing in any of the other ppp_asynctty_* routines to | |
| 209 | - | * finish before we can call ppp_unregister_channel and free | |
| 210 | - | * the asyncppp struct. This routine must be called from | |
| 211 | - | * process context, not interrupt or softirq context. | |
| 169 | + | * Called when the tty is put into another line discipline or it hangs up. | |
| 170 | + | * This call is serialized against other ldisc functions. | |
| 212 | 171 | */ | |
| 213 | 172 | static void | |
| 214 | 173 | ppp_asynctty_close(struct tty_struct *tty) | |
| 215 | 174 | { | |
| 216 | - | struct asyncppp *ap; | |
| 175 | + | struct asyncppp *ap = tty->disc_data; | |
| 217 | 176 | ||
| 218 | - | write_lock_irq(&disc_data_lock); | |
| 219 | - | ap = tty->disc_data; | |
| 220 | - | tty->disc_data = NULL; | |
| 221 | - | write_unlock_irq(&disc_data_lock); | |
| 222 | 177 | if (!ap) | |
| 223 | 178 | return; | |
| 224 | 179 | ||
| 225 | - | /* | |
| 226 | - | * We have now ensured that nobody can start using ap from now | |
| 227 | - | * on, but we have to wait for all existing users to finish. | |
| 228 | - | * Note that ppp_unregister_channel ensures that no calls to | |
| 229 | - | * our channel ops (i.e. ppp_async_send/ioctl) are in progress | |
| 230 | - | * by the time it returns. | |
| 231 | - | */ | |
| 232 | - | if (!refcount_dec_and_test(&ap->refcnt)) | |
| 233 | - | wait_for_completion(&ap->dead); | |
| 180 | + | tty->disc_data = NULL; | |
| 234 | 181 | tasklet_kill(&ap->tsk); | |
| 235 | 182 | ||
| 236 | 183 | ppp_unregister_channel(&ap->chan); | |
| @@ -240,17 +187,6 @@ ppp_asynctty_close(struct tty_struct *tty) | |||
| 240 | 187 | kfree(ap); | |
| 241 | 188 | } | |
| 242 | 189 | ||
| 243 | - | /* | |
| 244 | - | * Called on tty hangup in process context. | |
| 245 | - | * | |
| 246 | - | * Wait for I/O to driver to complete and unregister PPP channel. | |
| 247 | - | * This is already done by the close routine, so just call that. | |
| 248 | - | */ | |
| 249 | - | static void ppp_asynctty_hangup(struct tty_struct *tty) | |
| 250 | - | { | |
| 251 | - | ppp_asynctty_close(tty); | |
| 252 | - | } | |
| 253 | - | ||
| 254 | 190 | /* | |
| 255 | 191 | * Read does nothing - no data is ever available this way. | |
| 256 | 192 | * Pppd reads and writes packets via /dev/ppp instead. | |
| @@ -281,7 +217,7 @@ ppp_asynctty_write(struct tty_struct *tty, struct file *file, const u8 *buf, | |||
| 281 | 217 | static int | |
| 282 | 218 | ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) | |
| 283 | 219 | { | |
| 284 | - | struct asyncppp *ap = ap_get(tty); | |
| 220 | + | struct asyncppp *ap = tty->disc_data; | |
| 285 | 221 | int err, val; | |
| 286 | 222 | int __user *p = (int __user *)arg; | |
| 287 | 223 | ||
| @@ -322,7 +258,6 @@ ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) | |||
| 322 | 258 | err = tty_mode_ioctl(tty, cmd, arg); | |
| 323 | 259 | } | |
| 324 | 260 | ||
| 325 | - | ap_put(ap); | |
| 326 | 261 | return err; | |
| 327 | 262 | } | |
| 328 | 263 | ||
| @@ -331,7 +266,7 @@ static void | |||
| 331 | 266 | ppp_asynctty_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags, | |
| 332 | 267 | size_t count) | |
| 333 | 268 | { | |
| 334 | - | struct asyncppp *ap = ap_get(tty); | |
| 269 | + | struct asyncppp *ap = tty->disc_data; | |
| 335 | 270 | unsigned long flags; | |
| 336 | 271 | ||
| 337 | 272 | if (!ap) | |
| @@ -341,21 +276,19 @@ ppp_asynctty_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags, | |||
| 341 | 276 | spin_unlock_irqrestore(&ap->recv_lock, flags); | |
| 342 | 277 | if (!skb_queue_empty(&ap->rqueue)) | |
| 343 | 278 | tasklet_schedule(&ap->tsk); | |
| 344 | - | ap_put(ap); | |
| 345 | 279 | tty_unthrottle(tty); | |
| 346 | 280 | } | |
| 347 | 281 | ||
| 348 | 282 | static void | |
| 349 | 283 | ppp_asynctty_wakeup(struct tty_struct *tty) | |
| 350 | 284 | { | |
| 351 | - | struct asyncppp *ap = ap_get(tty); | |
| 285 | + | struct asyncppp *ap = tty->disc_data; | |
| 352 | 286 | ||
| 353 | 287 | clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | |
| 354 | 288 | if (!ap) | |
| 355 | 289 | return; | |
| 356 | 290 | set_bit(XMIT_WAKEUP, &ap->xmit_flags); | |
| 357 | 291 | tasklet_schedule(&ap->tsk); | |
| 358 | - | ap_put(ap); | |
| 359 | 292 | } | |
| 360 | 293 | ||
| 361 | 294 | ||
| @@ -365,7 +298,6 @@ static struct tty_ldisc_ops ppp_ldisc = { | |||
| 365 | 298 | .name = "ppp", | |
| 366 | 299 | .open = ppp_asynctty_open, | |
| 367 | 300 | .close = ppp_asynctty_close, | |
| 368 | - | .hangup = ppp_asynctty_hangup, | |
| 369 | 301 | .read = ppp_asynctty_read, | |
| 370 | 302 | .write = ppp_asynctty_write, | |
| 371 | 303 | .ioctl = ppp_asynctty_ioctl, | |
| @@ -810,11 +742,8 @@ process_input_packet(struct asyncppp *ap) | |||
| 810 | 742 | err: | |
| 811 | 743 | /* frame had an error, remember that, reset SC_TOSS & SC_ESCAPE */ | |
| 812 | 744 | ap->state = SC_PREV_ERROR; | |
| 813 | - | if (skb) { | |
| 814 | - | /* make skb appear as freshly allocated */ | |
| 815 | - | skb_trim(skb, 0); | |
| 816 | - | skb_reserve(skb, - skb_headroom(skb)); | |
| 817 | - | } | |
| 745 | + | kfree_skb(skb); | |
| 746 | + | ap->rpkt = NULL; | |
| 818 | 747 | } | |
| 819 | 748 | ||
| 820 | 749 | /* Called when the tty driver has data for us. Runs parallel with the | |
modified drivers/net/ppp/ppp_synctty.c
| @@ -38,11 +38,9 @@ | |||
| 38 | 38 | #include <linux/ppp-ioctl.h> | |
| 39 | 39 | #include <linux/ppp_channel.h> | |
| 40 | 40 | #include <linux/spinlock.h> | |
| 41 | - | #include <linux/completion.h> | |
| 42 | 41 | #include <linux/init.h> | |
| 43 | 42 | #include <linux/interrupt.h> | |
| 44 | 43 | #include <linux/slab.h> | |
| 45 | - | #include <linux/refcount.h> | |
| 46 | 44 | #include <linux/unaligned.h> | |
| 47 | 45 | #include <linux/uaccess.h> | |
| 48 | 46 | ||
| @@ -67,8 +65,6 @@ struct syncppp { | |||
| 67 | 65 | ||
| 68 | 66 | struct tasklet_struct tsk; | |
| 69 | 67 | ||
| 70 | - | refcount_t refcnt; | |
| 71 | - | struct completion dead_cmp; | |
| 72 | 68 | struct ppp_channel chan; /* interface to generic ppp layer */ | |
| 73 | 69 | }; | |
| 74 | 70 | ||
| @@ -116,37 +112,6 @@ ppp_print_buffer (const char *name, const __u8 *buf, int count) | |||
| 116 | 112 | * Routines implementing the synchronous PPP line discipline. | |
| 117 | 113 | */ | |
| 118 | 114 | ||
| 119 | - | /* | |
| 120 | - | * We have a potential race on dereferencing tty->disc_data, | |
| 121 | - | * because the tty layer provides no locking at all - thus one | |
| 122 | - | * cpu could be running ppp_synctty_receive while another | |
| 123 | - | * calls ppp_synctty_close, which zeroes tty->disc_data and | |
| 124 | - | * frees the memory that ppp_synctty_receive is using. The best | |
| 125 | - | * way to fix this is to use a rwlock in the tty struct, but for now | |
| 126 | - | * we use a single global rwlock for all ttys in ppp line discipline. | |
| 127 | - | * | |
| 128 | - | * FIXME: Fixed in tty_io nowadays. | |
| 129 | - | */ | |
| 130 | - | static DEFINE_RWLOCK(disc_data_lock); | |
| 131 | - | ||
| 132 | - | static struct syncppp *sp_get(struct tty_struct *tty) | |
| 133 | - | { | |
| 134 | - | struct syncppp *ap; | |
| 135 | - | ||
| 136 | - | read_lock(&disc_data_lock); | |
| 137 | - | ap = tty->disc_data; | |
| 138 | - | if (ap != NULL) | |
| 139 | - | refcount_inc(&ap->refcnt); | |
| 140 | - | read_unlock(&disc_data_lock); | |
| 141 | - | return ap; | |
| 142 | - | } | |
| 143 | - | ||
| 144 | - | static void sp_put(struct syncppp *ap) | |
| 145 | - | { | |
| 146 | - | if (refcount_dec_and_test(&ap->refcnt)) | |
| 147 | - | complete(&ap->dead_cmp); | |
| 148 | - | } | |
| 149 | - | ||
| 150 | 115 | /* | |
| 151 | 116 | * Called when a tty is put into sync-PPP line discipline. | |
| 152 | 117 | */ | |
| @@ -177,9 +142,6 @@ ppp_sync_open(struct tty_struct *tty) | |||
| 177 | 142 | skb_queue_head_init(&ap->rqueue); | |
| 178 | 143 | tasklet_setup(&ap->tsk, ppp_sync_process); | |
| 179 | 144 | ||
| 180 | - | refcount_set(&ap->refcnt, 1); | |
| 181 | - | init_completion(&ap->dead_cmp); | |
| 182 | - | ||
| 183 | 145 | ap->chan.private = ap; | |
| 184 | 146 | ap->chan.ops = &sync_ops; | |
| 185 | 147 | ap->chan.mtu = PPP_MRU; | |
| @@ -201,34 +163,18 @@ ppp_sync_open(struct tty_struct *tty) | |||
| 201 | 163 | } | |
| 202 | 164 | ||
| 203 | 165 | /* | |
| 204 | - | * Called when the tty is put into another line discipline | |
| 205 | - | * or it hangs up. We have to wait for any cpu currently | |
| 206 | - | * executing in any of the other ppp_synctty_* routines to | |
| 207 | - | * finish before we can call ppp_unregister_channel and free | |
| 208 | - | * the syncppp struct. This routine must be called from | |
| 209 | - | * process context, not interrupt or softirq context. | |
| 166 | + | * Called when the tty is put into another line discipline or it hangs up. | |
| 167 | + | * This call is serialized against other ldisc functions. | |
| 210 | 168 | */ | |
| 211 | 169 | static void | |
| 212 | 170 | ppp_sync_close(struct tty_struct *tty) | |
| 213 | 171 | { | |
| 214 | - | struct syncppp *ap; | |
| 172 | + | struct syncppp *ap = tty->disc_data; | |
| 215 | 173 | ||
| 216 | - | write_lock_irq(&disc_data_lock); | |
| 217 | - | ap = tty->disc_data; | |
| 218 | - | tty->disc_data = NULL; | |
| 219 | - | write_unlock_irq(&disc_data_lock); | |
| 220 | 174 | if (!ap) | |
| 221 | 175 | return; | |
| 222 | 176 | ||
| 223 | - | /* | |
| 224 | - | * We have now ensured that nobody can start using ap from now | |
| 225 | - | * on, but we have to wait for all existing users to finish. | |
| 226 | - | * Note that ppp_unregister_channel ensures that no calls to | |
| 227 | - | * our channel ops (i.e. ppp_sync_send/ioctl) are in progress | |
| 228 | - | * by the time it returns. | |
| 229 | - | */ | |
| 230 | - | if (!refcount_dec_and_test(&ap->refcnt)) | |
| 231 | - | wait_for_completion(&ap->dead_cmp); | |
| 177 | + | tty->disc_data = NULL; | |
| 232 | 178 | tasklet_kill(&ap->tsk); | |
| 233 | 179 | ||
| 234 | 180 | ppp_unregister_channel(&ap->chan); | |
| @@ -237,17 +183,6 @@ ppp_sync_close(struct tty_struct *tty) | |||
| 237 | 183 | kfree(ap); | |
| 238 | 184 | } | |
| 239 | 185 | ||
| 240 | - | /* | |
| 241 | - | * Called on tty hangup in process context. | |
| 242 | - | * | |
| 243 | - | * Wait for I/O to driver to complete and unregister PPP channel. | |
| 244 | - | * This is already done by the close routine, so just call that. | |
| 245 | - | */ | |
| 246 | - | static void ppp_sync_hangup(struct tty_struct *tty) | |
| 247 | - | { | |
| 248 | - | ppp_sync_close(tty); | |
| 249 | - | } | |
| 250 | - | ||
| 251 | 186 | /* | |
| 252 | 187 | * Read does nothing - no data is ever available this way. | |
| 253 | 188 | * Pppd reads and writes packets via /dev/ppp instead. | |
| @@ -273,7 +208,7 @@ ppp_sync_write(struct tty_struct *tty, struct file *file, const u8 *buf, | |||
| 273 | 208 | static int | |
| 274 | 209 | ppp_synctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) | |
| 275 | 210 | { | |
| 276 | - | struct syncppp *ap = sp_get(tty); | |
| 211 | + | struct syncppp *ap = tty->disc_data; | |
| 277 | 212 | int __user *p = (int __user *)arg; | |
| 278 | 213 | int err, val; | |
| 279 | 214 | ||
| @@ -314,7 +249,6 @@ ppp_synctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) | |||
| 314 | 249 | break; | |
| 315 | 250 | } | |
| 316 | 251 | ||
| 317 | - | sp_put(ap); | |
| 318 | 252 | return err; | |
| 319 | 253 | } | |
| 320 | 254 | ||
| @@ -323,7 +257,7 @@ static void | |||
| 323 | 257 | ppp_sync_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags, | |
| 324 | 258 | size_t count) | |
| 325 | 259 | { | |
| 326 | - | struct syncppp *ap = sp_get(tty); | |
| 260 | + | struct syncppp *ap = tty->disc_data; | |
| 327 | 261 | unsigned long flags; | |
| 328 | 262 | ||
| 329 | 263 | if (!ap) | |
| @@ -333,21 +267,19 @@ ppp_sync_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags, | |||
| 333 | 267 | spin_unlock_irqrestore(&ap->recv_lock, flags); | |
| 334 | 268 | if (!skb_queue_empty(&ap->rqueue)) | |
| 335 | 269 | tasklet_schedule(&ap->tsk); | |
| 336 | - | sp_put(ap); | |
| 337 | 270 | tty_unthrottle(tty); | |
| 338 | 271 | } | |
| 339 | 272 | ||
| 340 | 273 | static void | |
| 341 | 274 | ppp_sync_wakeup(struct tty_struct *tty) | |
| 342 | 275 | { | |
| 343 | - | struct syncppp *ap = sp_get(tty); | |
| 276 | + | struct syncppp *ap = tty->disc_data; | |
| 344 | 277 | ||
| 345 | 278 | clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | |
| 346 | 279 | if (!ap) | |
| 347 | 280 | return; | |
| 348 | 281 | set_bit(XMIT_WAKEUP, &ap->xmit_flags); | |
| 349 | 282 | tasklet_schedule(&ap->tsk); | |
| 350 | - | sp_put(ap); | |
| 351 | 283 | } | |
| 352 | 284 | ||
| 353 | 285 | ||
| @@ -357,7 +289,6 @@ static struct tty_ldisc_ops ppp_sync_ldisc = { | |||
| 357 | 289 | .name = "pppsync", | |
| 358 | 290 | .open = ppp_sync_open, | |
| 359 | 291 | .close = ppp_sync_close, | |
| 360 | - | .hangup = ppp_sync_hangup, | |
| 361 | 292 | .read = ppp_sync_read, | |
| 362 | 293 | .write = ppp_sync_write, | |
| 363 | 294 | .ioctl = ppp_synctty_ioctl, | |
| @@ -524,17 +455,9 @@ ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb) | |||
| 524 | 455 | ||
| 525 | 456 | /* prepend address/control fields if necessary */ | |
| 526 | 457 | if ((ap->flags & SC_COMP_AC) == 0 || islcp) { | |
| 527 | - | if (skb_headroom(skb) < 2) { | |
| 528 | - | struct sk_buff *npkt = dev_alloc_skb(skb->len + 2); | |
| 529 | - | if (npkt == NULL) { | |
| 530 | - | kfree_skb(skb); | |
| 531 | - | return NULL; | |
| 532 | - | } | |
| 533 | - | skb_reserve(npkt,2); | |
| 534 | - | skb_copy_from_linear_data(skb, | |
| 535 | - | skb_put(npkt, skb->len), skb->len); | |
| 536 | - | consume_skb(skb); | |
| 537 | - | skb = npkt; | |
| 458 | + | if (skb_cow_head(skb, 2)) { | |
| 459 | + | kfree_skb(skb); | |
| 460 | + | return NULL; | |
| 538 | 461 | } | |
| 539 | 462 | skb_push(skb,2); | |
| 540 | 463 | skb->data[0] = PPP_ALLSTATIONS; | |
modified drivers/net/usb/cx82310_eth.c
| @@ -282,6 +282,7 @@ static int cx82310_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
| 282 | 282 | if (len == 0xffff) { | |
| 283 | 283 | netdev_info(dev->net, "router was rebooted, re-enabling ethernet mode"); | |
| 284 | 284 | schedule_work(&priv->reenable_work); | |
| 285 | + | return 0; | |
| 285 | 286 | } else if (len > CX82310_MTU) { | |
| 286 | 287 | netdev_err(dev->net, "RX packet too long: %d B\n", len); | |
| 287 | 288 | return 0; | |
modified drivers/net/usb/hso.c
| @@ -1547,10 +1547,10 @@ hso_wait_modem_status(struct hso_serial *serial, unsigned long arg) | |||
| 1547 | 1547 | spin_unlock_irq(&serial->serial_lock); | |
| 1548 | 1548 | add_wait_queue(&tiocmget->waitq, &wait); | |
| 1549 | 1549 | for (;;) { | |
| 1550 | + | set_current_state(TASK_INTERRUPTIBLE); | |
| 1550 | 1551 | spin_lock_irq(&serial->serial_lock); | |
| 1551 | 1552 | memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); | |
| 1552 | 1553 | spin_unlock_irq(&serial->serial_lock); | |
| 1553 | - | set_current_state(TASK_INTERRUPTIBLE); | |
| 1554 | 1554 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || | |
| 1555 | 1555 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || | |
| 1556 | 1556 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd))) { | |
modified drivers/net/usb/qmi_wwan.c
| @@ -1084,6 +1084,7 @@ static const struct usb_device_id products[] = { | |||
| 1084 | 1084 | }, | |
| 1085 | 1085 | {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0122)}, /* Quectel RG650V */ | |
| 1086 | 1086 | {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ | |
| 1087 | + | {QMI_MATCH_FF_FF_FF(0x2c7c, 0x013d)}, /* Quectel RG660QB */ | |
| 1087 | 1088 | {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */ | |
| 1088 | 1089 | {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */ | |
| 1089 | 1090 | {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0620)}, /* Quectel EM160R-GL */ | |
| @@ -1446,6 +1447,7 @@ static const struct usb_device_id products[] = { | |||
| 1446 | 1447 | {QMI_QUIRK_SET_DTR(0x2c7c, 0x0316, 3)}, /* Quectel RG255C */ | |
| 1447 | 1448 | {QMI_QUIRK_SET_DTR(0x2cb7, 0x0104, 4)}, /* Fibocom NL678 series */ | |
| 1448 | 1449 | {QMI_QUIRK_SET_DTR(0x2cb7, 0x0112, 0)}, /* Fibocom FG132 */ | |
| 1450 | + | {QMI_QUIRK_SET_DTR(0x04b7, 0x8217, 8)}, /* Compal EXM-G1x */ | |
| 1449 | 1451 | {QMI_FIXED_INTF(0x0489, 0xe0b4, 0)}, /* Foxconn T77W968 LTE */ | |
| 1450 | 1452 | {QMI_FIXED_INTF(0x0489, 0xe0b5, 0)}, /* Foxconn T77W968 LTE with eSIM support*/ | |
| 1451 | 1453 | {QMI_FIXED_INTF(0x2692, 0x9025, 4)}, /* Cellient MPL200 (rebranded Qualcomm 05c6:9025) */ | |
modified drivers/net/vxlan/vxlan_core.c
| @@ -996,6 +996,12 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan, | |||
| 996 | 996 | return -EOPNOTSUPP; | |
| 997 | 997 | } | |
| 998 | 998 | ||
| 999 | + | if (rcu_access_pointer(f->nh) && | |
| 1000 | + | !(state & (NUD_PERMANENT | NUD_NOARP))) { | |
| 1001 | + | NL_SET_ERR_MSG(extack, "Cannot make a nexthop fdb dynamic"); | |
| 1002 | + | return -EOPNOTSUPP; | |
| 1003 | + | } | |
| 1004 | + | ||
| 999 | 1005 | /* Do not allow an externally learned entry to take over an entry added | |
| 1000 | 1006 | * by the user. | |
| 1001 | 1007 | */ | |
| @@ -1257,6 +1263,11 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], | |||
| 1257 | 1263 | if (err) | |
| 1258 | 1264 | return err; | |
| 1259 | 1265 | ||
| 1266 | + | if (nhid && !(ndm->ndm_state & (NUD_PERMANENT | NUD_NOARP))) { | |
| 1267 | + | NL_SET_ERR_MSG(extack, "A nexthop fdb cannot be dynamic"); | |
| 1268 | + | return -EINVAL; | |
| 1269 | + | } | |
| 1270 | + | ||
| 1260 | 1271 | if (vxlan->default_dst.remote_ip.sa.sa_family != ip.sa.sa_family) | |
| 1261 | 1272 | return -EAFNOSUPPORT; | |
| 1262 | 1273 | ||
| @@ -2362,7 +2373,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, | |||
| 2362 | 2373 | struct ip_tunnel_key key; | |
| 2363 | 2374 | struct vxlan_dev *vxlan = netdev_priv(dev); | |
| 2364 | 2375 | const struct iphdr *old_iph; | |
| 2365 | - | struct vxlan_metadata _md; | |
| 2376 | + | struct vxlan_metadata _md = {}; | |
| 2366 | 2377 | struct vxlan_metadata *md = &_md; | |
| 2367 | 2378 | unsigned int pkt_len = skb->len; | |
| 2368 | 2379 | __be16 src_port = 0, dst_port; | |
modified drivers/net/vxlan/vxlan_mdb.c
| @@ -354,6 +354,10 @@ static bool vxlan_mdb_is_valid_source(const struct nlattr *attr, __be16 proto, | |||
| 354 | 354 | NL_SET_ERR_MSG_MOD(extack, "IPv4 multicast source address is not allowed"); | |
| 355 | 355 | return false; | |
| 356 | 356 | } | |
| 357 | + | if (ipv4_is_zeronet(nla_get_in_addr(attr))) { | |
| 358 | + | NL_SET_ERR_MSG_MOD(extack, "IPv4 all-zeros source address is not allowed"); | |
| 359 | + | return false; | |
| 360 | + | } | |
| 357 | 361 | break; | |
| 358 | 362 | #if IS_ENABLED(CONFIG_IPV6) | |
| 359 | 363 | case htons(ETH_P_IPV6): { | |
| @@ -368,6 +372,10 @@ static bool vxlan_mdb_is_valid_source(const struct nlattr *attr, __be16 proto, | |||
| 368 | 372 | NL_SET_ERR_MSG_MOD(extack, "IPv6 multicast source address is not allowed"); | |
| 369 | 373 | return false; | |
| 370 | 374 | } | |
| 375 | + | if (ipv6_addr_any(&src)) { | |
| 376 | + | NL_SET_ERR_MSG_MOD(extack, "IPv6 all-zeros source address is not allowed"); | |
| 377 | + | return false; | |
| 378 | + | } | |
| 371 | 379 | break; | |
| 372 | 380 | } | |
| 373 | 381 | #endif | |
modified drivers/net/wireless/ath/ath12k/ahb.c
| @@ -870,7 +870,7 @@ static struct ath12k_ahb_rproc_info *ath12k_ahb_rproc_info_alloc(struct ath12k_b | |||
| 870 | 870 | ||
| 871 | 871 | lockdep_assert_held(&ath12k_rproc_info_lock); | |
| 872 | 872 | ||
| 873 | - | rproc_info = kzalloc_obj(*rproc_info, GFP_KERNEL); | |
| 873 | + | rproc_info = kzalloc_obj(*rproc_info); | |
| 874 | 874 | if (!rproc_info) | |
| 875 | 875 | return NULL; | |
| 876 | 876 | ||
modified drivers/net/wireless/intel/iwlwifi/mld/regulatory.c
| @@ -514,8 +514,7 @@ void iwl_mld_init_ap_type_tables(struct iwl_mld *mld) | |||
| 514 | 514 | return; | |
| 515 | 515 | ||
| 516 | 516 | if (iwl_fw_lookup_cmd_ver(mld->fw, cmd.id, 1) == 1) { | |
| 517 | - | struct iwl_mcc_allowed_ap_type_cmd_v1 *cmd_v1 = | |
| 518 | - | kzalloc(sizeof(*cmd_v1), GFP_KERNEL); | |
| 517 | + | struct iwl_mcc_allowed_ap_type_cmd_v1 *cmd_v1 = kzalloc_obj(*cmd_v1); | |
| 519 | 518 | ||
| 520 | 519 | if (!cmd_v1) | |
| 521 | 520 | return; | |
modified drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
| @@ -477,18 +477,23 @@ static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name) | |||
| 477 | 477 | ||
| 478 | 478 | for (offset = 0; offset < len; offset += clc_len) { | |
| 479 | 479 | if (len - offset < sizeof(*clc)) { | |
| 480 | + | dev_err(mdev->dev, "Invalid CLC record\n"); | |
| 480 | 481 | ret = -EINVAL; | |
| 481 | 482 | goto out; | |
| 482 | 483 | } | |
| 483 | 484 | ||
| 484 | 485 | clc = (const struct mt7921_clc *)(clc_base + offset); | |
| 485 | 486 | clc_len = le32_to_cpu(clc->len); | |
| 486 | - | if (clc_len < sizeof(*clc) || clc_len > len - offset || | |
| 487 | - | clc->idx >= ARRAY_SIZE(phy->clc)) { | |
| 487 | + | if (clc_len < sizeof(*clc) || clc_len > len - offset) { | |
| 488 | + | dev_err(mdev->dev, "Invalid CLC record\n"); | |
| 488 | 489 | ret = -EINVAL; | |
| 489 | 490 | goto out; | |
| 490 | 491 | } | |
| 491 | 492 | ||
| 493 | + | /* Newer firmware may add records this driver does not use yet */ | |
| 494 | + | if (clc->idx >= ARRAY_SIZE(phy->clc)) | |
| 495 | + | continue; | |
| 496 | + | ||
| 492 | 497 | /* do not init buf again if chip reset triggered */ | |
| 493 | 498 | if (phy->clc[clc->idx]) | |
| 494 | 499 | continue; | |
modified drivers/net/wireless/mediatek/mt76/mt7921/regd.c
| @@ -289,7 +289,7 @@ int mt7921_regd_update(struct mt792x_phy *phy, char *alpha2) | |||
| 289 | 289 | goto err; | |
| 290 | 290 | } | |
| 291 | 291 | ||
| 292 | - | regd = kzalloc(struct_size(regd, reg_rules, num_of_rules), GFP_KERNEL); | |
| 292 | + | regd = kzalloc_flex(*regd, reg_rules, num_of_rules); | |
| 293 | 293 | if (!regd) { | |
| 294 | 294 | ret = -ENOMEM; | |
| 295 | 295 | goto err; | |
modified drivers/net/wireless/mediatek/mt76/mt7925/main.c
| @@ -1105,7 +1105,7 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif, | |||
| 1105 | 1105 | mlink = &msta->deflink; | |
| 1106 | 1106 | is_deflink = true; | |
| 1107 | 1107 | } else { | |
| 1108 | - | mlink = kzalloc(sizeof(*mlink), GFP_KERNEL); | |
| 1108 | + | mlink = kzalloc_obj(*mlink); | |
| 1109 | 1109 | if (!mlink) { | |
| 1110 | 1110 | err = -ENOMEM; | |
| 1111 | 1111 | break; | |
modified drivers/net/wireless/mediatek/mt76/mt7925/regd.c
| @@ -336,7 +336,7 @@ int mt7925_regd_update(struct mt792x_phy *phy, char *alpha2) | |||
| 336 | 336 | goto err; | |
| 337 | 337 | } | |
| 338 | 338 | ||
| 339 | - | regd = kzalloc(struct_size(regd, reg_rules, num_of_rules), GFP_KERNEL); | |
| 339 | + | regd = kzalloc_flex(*regd, reg_rules, num_of_rules); | |
| 340 | 340 | if (!regd) { | |
| 341 | 341 | ret = -ENOMEM; | |
| 342 | 342 | goto err; | |
modified drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
| @@ -323,7 +323,8 @@ int mt792x_init_acpi_sar_power(struct mt792x_phy *phy, bool set_default) | |||
| 323 | 323 | const struct cfg80211_sar_capa *capa = phy->mt76->hw->wiphy->sar_capa; | |
| 324 | 324 | int i; | |
| 325 | 325 | ||
| 326 | - | if (!phy->acpisar || !((struct mt792x_acpi_sar *)phy->acpisar)->dyn) | |
| 326 | + | if (!capa || !phy->acpisar || | |
| 327 | + | !((struct mt792x_acpi_sar *)phy->acpisar)->dyn) | |
| 327 | 328 | return 0; | |
| 328 | 329 | ||
| 329 | 330 | /* When ACPI SAR enabled in HW, we should apply rules for .frp | |
modified drivers/net/wireless/morsemicro/mm81x/mac.c
| @@ -706,8 +706,7 @@ static int mm81x_hw_scan_h_init_chan_list(struct mm81x_hw_scan_params *params, | |||
| 706 | 706 | ||
| 707 | 707 | params->num_chans = 0; | |
| 708 | 708 | params->allocated_chans = 0; | |
| 709 | - | params->channels = kcalloc(chans_to_allocate, sizeof(*params->channels), | |
| 710 | - | GFP_KERNEL); | |
| 709 | + | params->channels = kzalloc_objs(*params->channels, chans_to_allocate); | |
| 711 | 710 | if (!params->channels) | |
| 712 | 711 | return -ENOMEM; | |
| 713 | 712 | ||
| @@ -728,8 +727,8 @@ static int mm81x_hw_scan_h_init_chan_list(struct mm81x_hw_scan_params *params, | |||
| 728 | 727 | } | |
| 729 | 728 | } | |
| 730 | 729 | ||
| 731 | - | params->powers_qdbm = kmalloc_array( | |
| 732 | - | num_pwrs_coarse, sizeof(*params->powers_qdbm), GFP_KERNEL); | |
| 730 | + | params->powers_qdbm = kmalloc_objs(*params->powers_qdbm, | |
| 731 | + | num_pwrs_coarse); | |
| 733 | 732 | if (!params->powers_qdbm) | |
| 734 | 733 | return -ENOMEM; | |
| 735 | 734 | ||
| @@ -822,7 +821,7 @@ __mm81x_hw_scan_h_init_params(struct mm81x *mors) | |||
| 822 | 821 | struct mm81x_hw_scan_params *params = mors->hw_scan.params; | |
| 823 | 822 | ||
| 824 | 823 | if (!params) { | |
| 825 | - | params = kzalloc_obj(*params, GFP_KERNEL); | |
| 824 | + | params = kzalloc_obj(*params); | |
| 826 | 825 | if (params) | |
| 827 | 826 | mors->hw_scan.params = params; | |
| 828 | 827 | } else { | |
modified drivers/net/wireless/morsemicro/mm81x/yaps.c
| @@ -22,15 +22,13 @@ | |||
| 22 | 22 | ||
| 23 | 23 | static int mm81x_yaps_alloc_pkt_buffers(struct mm81x_yaps *yaps) | |
| 24 | 24 | { | |
| 25 | - | yaps->hw.to_chip_pkts = kcalloc(MAX_PKTS_PER_TX_TXN, | |
| 26 | - | sizeof(*yaps->hw.to_chip_pkts), | |
| 27 | - | GFP_KERNEL); | |
| 25 | + | yaps->hw.to_chip_pkts = kzalloc_objs(*yaps->hw.to_chip_pkts, | |
| 26 | + | MAX_PKTS_PER_TX_TXN); | |
| 28 | 27 | if (!yaps->hw.to_chip_pkts) | |
| 29 | 28 | return -ENOMEM; | |
| 30 | 29 | ||
| 31 | - | yaps->hw.from_chip_pkts = kcalloc(MAX_PKTS_PER_RX_TXN, | |
| 32 | - | sizeof(*yaps->hw.from_chip_pkts), | |
| 33 | - | GFP_KERNEL); | |
| 30 | + | yaps->hw.from_chip_pkts = kzalloc_objs(*yaps->hw.from_chip_pkts, | |
| 31 | + | MAX_PKTS_PER_RX_TXN); | |
| 34 | 32 | if (!yaps->hw.from_chip_pkts) { | |
| 35 | 33 | kfree(yaps->hw.to_chip_pkts); | |
| 36 | 34 | yaps->hw.to_chip_pkts = NULL; | |
modified drivers/net/wireless/nxp/nxpwifi/cfg80211.c
| @@ -641,7 +641,7 @@ nxpwifi_cfg80211_set_wiphy_params(struct wiphy *wiphy, int radio_idx, u32 change | |||
| 641 | 641 | ||
| 642 | 642 | switch (priv->bss_role) { | |
| 643 | 643 | case NXPWIFI_BSS_ROLE_UAP: | |
| 644 | - | bss_cfg = kzalloc_obj(*bss_cfg, GFP_KERNEL); | |
| 644 | + | bss_cfg = kzalloc_obj(*bss_cfg); | |
| 645 | 645 | if (!bss_cfg) { | |
| 646 | 646 | ret = -ENOMEM; | |
| 647 | 647 | break; | |
| @@ -1713,7 +1713,7 @@ static int nxpwifi_cfg80211_start_ap(struct wiphy *wiphy, | |||
| 1713 | 1713 | if (!nxpwifi_is_channel_setting_allowable(priv, params->chandef.chan)) | |
| 1714 | 1714 | return -EOPNOTSUPP; | |
| 1715 | 1715 | ||
| 1716 | - | bss_cfg = kzalloc_obj(*bss_cfg, GFP_KERNEL); | |
| 1716 | + | bss_cfg = kzalloc_obj(*bss_cfg); | |
| 1717 | 1717 | if (!bss_cfg) | |
| 1718 | 1718 | return -ENOMEM; | |
| 1719 | 1719 | ||
| @@ -1866,7 +1866,7 @@ nxpwifi_cfg80211_scan(struct wiphy *wiphy, | |||
| 1866 | 1866 | if (!nxpwifi_stop_bg_scan(priv)) | |
| 1867 | 1867 | cfg80211_sched_scan_stopped_locked(priv->wdev.wiphy, 0); | |
| 1868 | 1868 | ||
| 1869 | - | user_scan_cfg = kzalloc_obj(*user_scan_cfg, GFP_KERNEL); | |
| 1869 | + | user_scan_cfg = kzalloc_obj(*user_scan_cfg); | |
| 1870 | 1870 | if (!user_scan_cfg) | |
| 1871 | 1871 | return -ENOMEM; | |
| 1872 | 1872 | ||
| @@ -1973,7 +1973,7 @@ nxpwifi_cfg80211_sched_scan_start(struct wiphy *wiphy, | |||
| 1973 | 1973 | request->n_channels, request->scan_plans->interval, | |
| 1974 | 1974 | (int)request->ie_len); | |
| 1975 | 1975 | ||
| 1976 | - | bgscan_cfg = kzalloc_obj(*bgscan_cfg, GFP_KERNEL); | |
| 1976 | + | bgscan_cfg = kzalloc_obj(*bgscan_cfg); | |
| 1977 | 1977 | if (!bgscan_cfg) | |
| 1978 | 1978 | return -ENOMEM; | |
| 1979 | 1979 | ||
| @@ -2304,7 +2304,7 @@ nxpwifi_setup_he_caps(struct nxpwifi_private *priv, | |||
| 2304 | 2304 | if (!hw_he_cap_len) | |
| 2305 | 2305 | return; | |
| 2306 | 2306 | ||
| 2307 | - | iftype_data = kmalloc_obj(*iftype_data, GFP_KERNEL); | |
| 2307 | + | iftype_data = kmalloc_obj(*iftype_data); | |
| 2308 | 2308 | if (!iftype_data) | |
| 2309 | 2309 | return; | |
| 2310 | 2310 | memset(iftype_data, 0, sizeof(*iftype_data)); | |
| @@ -2759,7 +2759,7 @@ static int nxpwifi_set_mef_filter(struct nxpwifi_private *priv, | |||
| 2759 | 2759 | if (wowlan->n_patterns || wowlan->magic_pkt) | |
| 2760 | 2760 | num_entries++; | |
| 2761 | 2761 | ||
| 2762 | - | mef_entry = kzalloc_objs(*mef_entry, num_entries, GFP_KERNEL); | |
| 2762 | + | mef_entry = kzalloc_objs(*mef_entry, num_entries); | |
| 2763 | 2763 | if (!mef_entry) | |
| 2764 | 2764 | return -ENOMEM; | |
| 2765 | 2765 | ||
| @@ -3227,7 +3227,7 @@ static int nxpwifi_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev, | |||
| 3227 | 3227 | if (!tb[NXPWIFI_TM_ATTR_DATA]) | |
| 3228 | 3228 | return -EINVAL; | |
| 3229 | 3229 | ||
| 3230 | - | hostcmd = kzalloc_obj(*hostcmd, GFP_KERNEL); | |
| 3230 | + | hostcmd = kzalloc_obj(*hostcmd); | |
| 3231 | 3231 | if (!hostcmd) | |
| 3232 | 3232 | return -ENOMEM; | |
| 3233 | 3233 | ||
modified drivers/net/wireless/nxp/nxpwifi/cmdevt.c
| @@ -302,7 +302,7 @@ int nxpwifi_alloc_cmd_buffer(struct nxpwifi_adapter *adapter) | |||
| 302 | 302 | ||
| 303 | 303 | /* Allocate and initialize struct cmd_ctrl_node */ | |
| 304 | 304 | cmd_array = kzalloc_objs(struct cmd_ctrl_node, | |
| 305 | - | NXPWIFI_NUM_OF_CMD_BUFFER, GFP_KERNEL); | |
| 305 | + | NXPWIFI_NUM_OF_CMD_BUFFER); | |
| 306 | 306 | if (!cmd_array) | |
| 307 | 307 | return -ENOMEM; | |
| 308 | 308 | ||
modified drivers/net/wireless/nxp/nxpwifi/ie.c
| @@ -143,7 +143,7 @@ nxpwifi_update_uap_custom_ie(struct nxpwifi_private *priv, | |||
| 143 | 143 | u16 len; | |
| 144 | 144 | int ret; | |
| 145 | 145 | ||
| 146 | - | ap_custom_ie = kzalloc_obj(*ap_custom_ie, GFP_KERNEL); | |
| 146 | + | ap_custom_ie = kzalloc_obj(*ap_custom_ie); | |
| 147 | 147 | if (!ap_custom_ie) | |
| 148 | 148 | return -ENOMEM; | |
| 149 | 149 | ||
| @@ -209,7 +209,7 @@ static int nxpwifi_update_vs_ie(const u8 *ies, int ies_len, | |||
| 209 | 209 | vendor_ie = cfg80211_find_vendor_ie(oui, oui_type, ies, ies_len); | |
| 210 | 210 | if (vendor_ie) { | |
| 211 | 211 | if (!*ie_ptr) { | |
| 212 | - | *ie_ptr = kzalloc_obj(struct nxpwifi_ie, GFP_KERNEL); | |
| 212 | + | *ie_ptr = kzalloc_obj(struct nxpwifi_ie); | |
| 213 | 213 | if (!*ie_ptr) | |
| 214 | 214 | return -ENOMEM; | |
| 215 | 215 | ie = *ie_ptr; | |
| @@ -309,7 +309,7 @@ static int nxpwifi_uap_parse_tail_ies(struct nxpwifi_private *priv, | |||
| 309 | 309 | if (!info->tail || !info->tail_len) | |
| 310 | 310 | return 0; | |
| 311 | 311 | ||
| 312 | - | gen_ie = kzalloc_obj(*gen_ie, GFP_KERNEL); | |
| 312 | + | gen_ie = kzalloc_obj(*gen_ie); | |
| 313 | 313 | if (!gen_ie) | |
| 314 | 314 | return -ENOMEM; | |
| 315 | 315 | ||
| @@ -417,7 +417,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv) | |||
| 417 | 417 | int ret = 0; | |
| 418 | 418 | ||
| 419 | 419 | if (priv->gen_idx != NXPWIFI_AUTO_IDX_MASK) { | |
| 420 | - | gen_ie = kmalloc_obj(*gen_ie, GFP_KERNEL); | |
| 420 | + | gen_ie = kmalloc_obj(*gen_ie); | |
| 421 | 421 | if (!gen_ie) | |
| 422 | 422 | return -ENOMEM; | |
| 423 | 423 | ||
| @@ -434,7 +434,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv) | |||
| 434 | 434 | } | |
| 435 | 435 | ||
| 436 | 436 | if (priv->beacon_idx != NXPWIFI_AUTO_IDX_MASK) { | |
| 437 | - | beacon_ie = kmalloc_obj(*beacon_ie, GFP_KERNEL); | |
| 437 | + | beacon_ie = kmalloc_obj(*beacon_ie); | |
| 438 | 438 | if (!beacon_ie) { | |
| 439 | 439 | ret = -ENOMEM; | |
| 440 | 440 | goto done; | |
| @@ -444,7 +444,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv) | |||
| 444 | 444 | beacon_ie->ie_length = 0; | |
| 445 | 445 | } | |
| 446 | 446 | if (priv->proberesp_idx != NXPWIFI_AUTO_IDX_MASK) { | |
| 447 | - | pr_ie = kmalloc_obj(*pr_ie, GFP_KERNEL); | |
| 447 | + | pr_ie = kmalloc_obj(*pr_ie); | |
| 448 | 448 | if (!pr_ie) { | |
| 449 | 449 | ret = -ENOMEM; | |
| 450 | 450 | goto done; | |
| @@ -454,7 +454,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv) | |||
| 454 | 454 | pr_ie->ie_length = 0; | |
| 455 | 455 | } | |
| 456 | 456 | if (priv->assocresp_idx != NXPWIFI_AUTO_IDX_MASK) { | |
| 457 | - | ar_ie = kmalloc_obj(*ar_ie, GFP_KERNEL); | |
| 457 | + | ar_ie = kmalloc_obj(*ar_ie); | |
| 458 | 458 | if (!ar_ie) { | |
| 459 | 459 | ret = -ENOMEM; | |
| 460 | 460 | goto done; | |
modified drivers/net/wireless/nxp/nxpwifi/init.c
| @@ -20,7 +20,7 @@ static int nxpwifi_add_bss_prio_tbl(struct nxpwifi_private *priv) | |||
| 20 | 20 | struct nxpwifi_bss_prio_node *bss_prio; | |
| 21 | 21 | struct nxpwifi_bss_prio_tbl *tbl = adapter->bss_prio_tbl; | |
| 22 | 22 | ||
| 23 | - | bss_prio = kzalloc_obj(*bss_prio, GFP_KERNEL); | |
| 23 | + | bss_prio = kzalloc_obj(*bss_prio); | |
| 24 | 24 | if (!bss_prio) | |
| 25 | 25 | return -ENOMEM; | |
| 26 | 26 | ||
modified drivers/net/wireless/nxp/nxpwifi/main.c
| @@ -32,7 +32,7 @@ static struct nxpwifi_adapter *nxpwifi_register(void *card, struct device *dev, | |||
| 32 | 32 | int ret = 0; | |
| 33 | 33 | int i; | |
| 34 | 34 | ||
| 35 | - | adapter = kzalloc_obj(*adapter, GFP_KERNEL); | |
| 35 | + | adapter = kzalloc_obj(*adapter); | |
| 36 | 36 | if (!adapter) | |
| 37 | 37 | return ERR_PTR(-ENOMEM); | |
| 38 | 38 | ||
| @@ -55,7 +55,7 @@ static struct nxpwifi_adapter *nxpwifi_register(void *card, struct device *dev, | |||
| 55 | 55 | for (i = 0; i < NXPWIFI_MAX_BSS_NUM; i++) { | |
| 56 | 56 | /* Allocate memory for private structure */ | |
| 57 | 57 | adapter->priv[i] = | |
| 58 | - | kzalloc_obj(struct nxpwifi_private, GFP_KERNEL); | |
| 58 | + | kzalloc_obj(struct nxpwifi_private); | |
| 59 | 59 | if (!adapter->priv[i]) { | |
| 60 | 60 | ret = -ENOMEM; | |
| 61 | 61 | goto error; | |
| @@ -1106,7 +1106,7 @@ void nxpwifi_drv_info_dump(struct nxpwifi_adapter *adapter) | |||
| 1106 | 1106 | p += adapter->if_ops.reg_dump(adapter, p); | |
| 1107 | 1107 | } | |
| 1108 | 1108 | p += sprintf(p, "\n=== more debug information\n"); | |
| 1109 | - | debug_info = kzalloc_obj(*debug_info, GFP_KERNEL); | |
| 1109 | + | debug_info = kzalloc_obj(*debug_info); | |
| 1110 | 1110 | if (debug_info) { | |
| 1111 | 1111 | for (i = 0; i < adapter->priv_num; i++) { | |
| 1112 | 1112 | if (!adapter->priv[i]->netdev) | |
| @@ -1242,7 +1242,7 @@ void nxpwifi_init_priv_params(struct nxpwifi_private *priv, | |||
| 1242 | 1242 | ||
| 1243 | 1243 | if (GET_BSS_ROLE(priv) == NXPWIFI_BSS_ROLE_STA || | |
| 1244 | 1244 | GET_BSS_ROLE(priv) == NXPWIFI_BSS_ROLE_UAP) { | |
| 1245 | - | priv->hist_data = kmalloc_obj(*priv->hist_data, GFP_KERNEL); | |
| 1245 | + | priv->hist_data = kmalloc_obj(*priv->hist_data); | |
| 1246 | 1246 | if (priv->hist_data) | |
| 1247 | 1247 | nxpwifi_hist_data_reset(priv); | |
| 1248 | 1248 | } | |
modified drivers/net/wireless/nxp/nxpwifi/scan.c
| @@ -1341,15 +1341,14 @@ int nxpwifi_scan_networks(struct nxpwifi_private *priv, | |||
| 1341 | 1341 | adapter->scan_processing = true; | |
| 1342 | 1342 | spin_unlock_bh(&adapter->nxpwifi_cmd_lock); | |
| 1343 | 1343 | ||
| 1344 | - | scan_cfg_out = kzalloc_obj(union nxpwifi_scan_cmd_config_tlv, | |
| 1345 | - | GFP_KERNEL); | |
| 1344 | + | scan_cfg_out = kzalloc_obj(union nxpwifi_scan_cmd_config_tlv); | |
| 1346 | 1345 | if (!scan_cfg_out) { | |
| 1347 | 1346 | ret = -ENOMEM; | |
| 1348 | 1347 | goto done; | |
| 1349 | 1348 | } | |
| 1350 | 1349 | ||
| 1351 | 1350 | scan_chan_list = kzalloc_objs(struct nxpwifi_chan_scan_param_set, | |
| 1352 | - | NXPWIFI_USER_SCAN_CHAN_MAX, GFP_KERNEL); | |
| 1351 | + | NXPWIFI_USER_SCAN_CHAN_MAX); | |
| 1353 | 1352 | if (!scan_chan_list) { | |
| 1354 | 1353 | kfree(scan_cfg_out); | |
| 1355 | 1354 | ret = -ENOMEM; | |
| @@ -1471,7 +1470,7 @@ static int nxpwifi_save_hidden_ssid_channels(struct nxpwifi_private *priv, | |||
| 1471 | 1470 | int chid; | |
| 1472 | 1471 | ||
| 1473 | 1472 | /* Allocate and fill new bss descriptor */ | |
| 1474 | - | bss_desc = kzalloc_obj(*bss_desc, GFP_KERNEL); | |
| 1473 | + | bss_desc = kzalloc_obj(*bss_desc); | |
| 1475 | 1474 | if (!bss_desc) | |
| 1476 | 1475 | return -ENOMEM; | |
| 1477 | 1476 | ||
| @@ -1512,7 +1511,7 @@ static int nxpwifi_update_curr_bss_params(struct nxpwifi_private *priv, | |||
| 1512 | 1511 | int ret; | |
| 1513 | 1512 | ||
| 1514 | 1513 | /* Allocate and fill new bss descriptor */ | |
| 1515 | - | bss_desc = kzalloc_obj(*bss_desc, GFP_KERNEL); | |
| 1514 | + | bss_desc = kzalloc_obj(*bss_desc); | |
| 1516 | 1515 | if (!bss_desc) | |
| 1517 | 1516 | return -ENOMEM; | |
| 1518 | 1517 | ||
| @@ -1751,7 +1750,7 @@ nxpwifi_active_scan_req_for_passive_chan(struct nxpwifi_private *priv) | |||
| 1751 | 1750 | nxpwifi_dbg(adapter, INFO, "No BSS with hidden SSID found on DFS channels\n"); | |
| 1752 | 1751 | return 0; | |
| 1753 | 1752 | } | |
| 1754 | - | user_scan_cfg = kzalloc_obj(*user_scan_cfg, GFP_KERNEL); | |
| 1753 | + | user_scan_cfg = kzalloc_obj(*user_scan_cfg); | |
| 1755 | 1754 | ||
| 1756 | 1755 | if (!user_scan_cfg) | |
| 1757 | 1756 | return -ENOMEM; | |
| @@ -2258,7 +2257,7 @@ int nxpwifi_stop_bg_scan(struct nxpwifi_private *priv) | |||
| 2258 | 2257 | return 0; | |
| 2259 | 2258 | } | |
| 2260 | 2259 | ||
| 2261 | - | bgscan_cfg = kzalloc_obj(*bgscan_cfg, GFP_KERNEL); | |
| 2260 | + | bgscan_cfg = kzalloc_obj(*bgscan_cfg); | |
| 2262 | 2261 | if (!bgscan_cfg) | |
| 2263 | 2262 | return -ENOMEM; | |
| 2264 | 2263 | ||
modified drivers/net/wireless/nxp/nxpwifi/sta_cfg.c
| @@ -245,7 +245,7 @@ int nxpwifi_bss_start(struct nxpwifi_private *priv, struct cfg80211_bss *bss, | |||
| 245 | 245 | return -EINVAL; | |
| 246 | 246 | ||
| 247 | 247 | /* Allocate and fill new bss descriptor */ | |
| 248 | - | bss_desc = kzalloc_obj(*bss_desc, GFP_KERNEL); | |
| 248 | + | bss_desc = kzalloc_obj(*bss_desc); | |
| 249 | 249 | if (!bss_desc) | |
| 250 | 250 | return -ENOMEM; | |
| 251 | 251 | ||
modified drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
| @@ -2822,7 +2822,7 @@ nxpwifi_create_custom_regdomain(struct nxpwifi_private *priv, | |||
| 2822 | 2822 | if (WARN_ON_ONCE(num_chan > NL80211_MAX_SUPP_REG_RULES)) | |
| 2823 | 2823 | return ERR_PTR(-EINVAL); | |
| 2824 | 2824 | ||
| 2825 | - | regd = kzalloc_flex(*regd, reg_rules, num_chan, GFP_KERNEL); | |
| 2825 | + | regd = kzalloc_flex(*regd, reg_rules, num_chan); | |
| 2826 | 2826 | if (!regd) | |
| 2827 | 2827 | return ERR_PTR(-ENOMEM); | |
| 2828 | 2828 | ||
modified drivers/net/wireless/nxp/nxpwifi/uap_event.c
| @@ -88,7 +88,7 @@ nxpwifi_uap_event_sta_assoc(struct nxpwifi_private *priv) | |||
| 88 | 88 | struct nxpwifi_sta_node *node; | |
| 89 | 89 | int len, i; | |
| 90 | 90 | ||
| 91 | - | sinfo = kzalloc_obj(*sinfo, GFP_KERNEL); | |
| 91 | + | sinfo = kzalloc_obj(*sinfo); | |
| 92 | 92 | if (!sinfo) | |
| 93 | 93 | return -ENOMEM; | |
| 94 | 94 | ||
modified drivers/nvdimm/region_devs.c
| @@ -1002,8 +1002,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, | |||
| 1002 | 1002 | nd_region->num_lanes = ndr_desc->num_lanes; | |
| 1003 | 1003 | if (!nd_region->num_lanes) | |
| 1004 | 1004 | goto err_percpu; | |
| 1005 | - | nd_region->lane = kcalloc(nd_region->num_lanes, | |
| 1006 | - | sizeof(*nd_region->lane), GFP_KERNEL); | |
| 1005 | + | nd_region->lane = kzalloc_objs(*nd_region->lane, nd_region->num_lanes); | |
| 1007 | 1006 | if (!nd_region->lane) | |
| 1008 | 1007 | goto err_percpu; | |
| 1009 | 1008 | ||
modified drivers/nvme/host/core.c
| @@ -155,8 +155,6 @@ static const struct class nvme_ns_chr_class = { | |||
| 155 | 155 | }; | |
| 156 | 156 | ||
| 157 | 157 | static void nvme_put_subsystem(struct nvme_subsystem *subsys); | |
| 158 | - | static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl, | |
| 159 | - | unsigned nsid); | |
| 160 | 158 | static void nvme_update_keep_alive(struct nvme_ctrl *ctrl, | |
| 161 | 159 | struct nvme_command *cmd); | |
| 162 | 160 | static int nvme_get_log_lsi(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, | |
| @@ -1612,7 +1610,7 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl, | |||
| 1612 | 1610 | } | |
| 1613 | 1611 | ||
| 1614 | 1612 | if (nvme_multi_css(ctrl) && !csi_seen) { | |
| 1615 | - | dev_warn(ctrl->device, "Command set not reported for nsid:%d\n", | |
| 1613 | + | dev_warn(ctrl->device, "Command set not reported for nsid:%u\n", | |
| 1616 | 1614 | info->nsid); | |
| 1617 | 1615 | status = -EINVAL; | |
| 1618 | 1616 | } | |
| @@ -2341,14 +2339,6 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info) | |||
| 2341 | 2339 | size_t size; | |
| 2342 | 2340 | int i, ret; | |
| 2343 | 2341 | ||
| 2344 | - | /* | |
| 2345 | - | * The FDP configuration is static for the lifetime of the namespace, | |
| 2346 | - | * so return immediately if we've already registered this namespace's | |
| 2347 | - | * streams. | |
| 2348 | - | */ | |
| 2349 | - | if (head->nr_plids) | |
| 2350 | - | return 0; | |
| 2351 | - | ||
| 2352 | 2342 | ret = nvme_get_features(ctrl, NVME_FEAT_FDP, info->endgid, NULL, 0, | |
| 2353 | 2343 | &fdp); | |
| 2354 | 2344 | if (ret) { | |
| @@ -2382,8 +2372,7 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info) | |||
| 2382 | 2372 | if (!head->nr_plids) | |
| 2383 | 2373 | goto free; | |
| 2384 | 2374 | ||
| 2385 | - | head->plids = kcalloc(head->nr_plids, sizeof(*head->plids), | |
| 2386 | - | GFP_KERNEL); | |
| 2375 | + | head->plids = kzalloc_objs(*head->plids, head->nr_plids); | |
| 2387 | 2376 | if (!head->plids) { | |
| 2388 | 2377 | dev_warn(ctrl->device, | |
| 2389 | 2378 | "failed to allocate %u FDP placement IDs\n", | |
| @@ -2395,6 +2384,7 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info) | |||
| 2395 | 2384 | ||
| 2396 | 2385 | for (i = 0; i < head->nr_plids; i++) | |
| 2397 | 2386 | head->plids[i] = le16_to_cpu(ruhs->ruhsd[i].pid); | |
| 2387 | + | head->write_stream_granularity = min(info->runs, U32_MAX); | |
| 2398 | 2388 | free: | |
| 2399 | 2389 | kfree(ruhs); | |
| 2400 | 2390 | return ret; | |
| @@ -2442,12 +2432,6 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, | |||
| 2442 | 2432 | goto out; | |
| 2443 | 2433 | } | |
| 2444 | 2434 | ||
| 2445 | - | if (ns->ctrl->ctratt & NVME_CTRL_ATTR_FDPS) { | |
| 2446 | - | ret = nvme_query_fdp_info(ns, info); | |
| 2447 | - | if (ret < 0) | |
| 2448 | - | goto out; | |
| 2449 | - | } | |
| 2450 | - | ||
| 2451 | 2435 | if (nvme_invalid_lba_sz(le64_to_cpu(id->nsze), | |
| 2452 | 2436 | id->lbaf[lbaf].ds - SECTOR_SHIFT, &capacity)) { | |
| 2453 | 2437 | dev_warn_once(ns->ctrl->device, | |
| @@ -2468,9 +2452,26 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, | |||
| 2468 | 2452 | if (!nvme_update_disk_info(ns, id, nvm, &lim)) | |
| 2469 | 2453 | capacity = 0; | |
| 2470 | 2454 | ||
| 2455 | + | /* | |
| 2456 | + | * A failed zone info query leaves zi zero-initialized, so skip the | |
| 2457 | + | * zoned limits update instead of configuring the queue from it. | |
| 2458 | + | * During a revalidation that keeps the zone geometry the queue was | |
| 2459 | + | * last validated with; on a first scan the namespace is registered | |
| 2460 | + | * without zoned limits, so that it is still available as a handle | |
| 2461 | + | * for admin commands. | |
| 2462 | + | */ | |
| 2471 | 2463 | if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && | |
| 2472 | - | ns->head->ids.csi == NVME_CSI_ZNS) | |
| 2473 | - | nvme_update_zone_info(ns, &lim, &zi); | |
| 2464 | + | ns->head->ids.csi == NVME_CSI_ZNS) { | |
| 2465 | + | if (zi.zone_size) | |
| 2466 | + | nvme_update_zone_info(ns, &lim, &zi); | |
| 2467 | + | else | |
| 2468 | + | dev_warn(ns->ctrl->device, | |
| 2469 | + | "zone info query failed for nsid %u, %s\n", | |
| 2470 | + | ns->head->ns_id, | |
| 2471 | + | blk_queue_is_zoned(ns->disk->queue) ? | |
| 2472 | + | "keeping the previous zone limits" : | |
| 2473 | + | "not enabling zoned mode"); | |
| 2474 | + | } | |
| 2474 | 2475 | ||
| 2475 | 2476 | if ((ns->ctrl->vwc & NVME_CTRL_VWC_PRESENT) && !info->no_vwc) | |
| 2476 | 2477 | lim.features |= BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA; | |
| @@ -2490,10 +2491,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, | |||
| 2490 | 2491 | capacity = 0; | |
| 2491 | 2492 | ||
| 2492 | 2493 | lim.max_write_streams = ns->head->nr_plids; | |
| 2493 | - | if (lim.max_write_streams) | |
| 2494 | - | lim.write_stream_granularity = min(info->runs, U32_MAX); | |
| 2495 | - | else | |
| 2496 | - | lim.write_stream_granularity = 0; | |
| 2494 | + | lim.write_stream_granularity = ns->head->write_stream_granularity; | |
| 2497 | 2495 | ||
| 2498 | 2496 | /* | |
| 2499 | 2497 | * Only set the DEAC bit if the device guarantees that reads from | |
| @@ -4001,10 +3999,11 @@ static void nvme_add_ns_cdev(struct nvme_ns *ns) | |||
| 4001 | 3999 | set_bit(NVME_NS_CDEV_LIVE, &ns->flags); | |
| 4002 | 4000 | } | |
| 4003 | 4001 | ||
| 4004 | - | static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, | |
| 4002 | + | static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ns *ns, | |
| 4005 | 4003 | struct nvme_ns_info *info) | |
| 4006 | - | __must_hold(&ctrl->subsys->lock) | |
| 4004 | + | __must_hold(&ns->ctrl->subsys->lock) | |
| 4007 | 4005 | { | |
| 4006 | + | struct nvme_ctrl *ctrl = ns->ctrl; | |
| 4008 | 4007 | struct nvme_ns_head *head; | |
| 4009 | 4008 | size_t size = sizeof(*head); | |
| 4010 | 4009 | int ret = -ENOMEM; | |
| @@ -4032,6 +4031,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, | |||
| 4032 | 4031 | ratelimit_state_init(&head->rs_nuse, 5 * HZ, 1); | |
| 4033 | 4032 | ratelimit_set_flags(&head->rs_nuse, RATELIMIT_MSG_ON_RELEASE); | |
| 4034 | 4033 | kref_init(&head->ref); | |
| 4034 | + | ns->head = head; | |
| 4035 | 4035 | ||
| 4036 | 4036 | if (head->ids.csi) { | |
| 4037 | 4037 | ret = nvme_get_effects_log(ctrl, head->ids.csi, &head->effects); | |
| @@ -4040,21 +4040,30 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, | |||
| 4040 | 4040 | } else | |
| 4041 | 4041 | head->effects = ctrl->effects; | |
| 4042 | 4042 | ||
| 4043 | + | if (ctrl->ctratt & NVME_CTRL_ATTR_FDPS) { | |
| 4044 | + | ret = nvme_query_fdp_info(ns, info); | |
| 4045 | + | if (ret < 0) | |
| 4046 | + | goto out_cleanup_srcu; | |
| 4047 | + | } | |
| 4048 | + | ||
| 4043 | 4049 | ret = nvme_mpath_alloc_disk(ctrl, head); | |
| 4044 | 4050 | if (ret) | |
| 4045 | - | goto out_cleanup_srcu; | |
| 4051 | + | goto out_cleanup_fdp; | |
| 4046 | 4052 | ||
| 4047 | 4053 | list_add_tail(&head->entry, &ctrl->subsys->nsheads); | |
| 4048 | 4054 | ||
| 4049 | 4055 | kref_get(&ctrl->subsys->ref); | |
| 4050 | 4056 | ||
| 4051 | 4057 | return head; | |
| 4058 | + | out_cleanup_fdp: | |
| 4059 | + | kfree(head->plids); | |
| 4052 | 4060 | out_cleanup_srcu: | |
| 4053 | 4061 | cleanup_srcu_struct(&head->srcu); | |
| 4054 | 4062 | out_ida_remove: | |
| 4055 | 4063 | ida_free(&ctrl->subsys->ns_ida, head->instance); | |
| 4056 | 4064 | out_free_head: | |
| 4057 | 4065 | kfree(head); | |
| 4066 | + | ns->head = NULL; | |
| 4058 | 4067 | out: | |
| 4059 | 4068 | if (ret > 0) | |
| 4060 | 4069 | ret = blk_status_to_errno(nvme_error_status(ret)); | |
| @@ -4116,13 +4125,13 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info) | |||
| 4116 | 4125 | ((ns->ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) && | |
| 4117 | 4126 | info->is_shared)) { | |
| 4118 | 4127 | dev_err(ctrl->device, | |
| 4119 | - | "ignoring nsid %d because of duplicate IDs\n", | |
| 4128 | + | "ignoring nsid %u because of duplicate IDs\n", | |
| 4120 | 4129 | info->nsid); | |
| 4121 | 4130 | return ret; | |
| 4122 | 4131 | } | |
| 4123 | 4132 | ||
| 4124 | 4133 | dev_err(ctrl->device, | |
| 4125 | - | "clearing duplicate IDs for nsid %d\n", info->nsid); | |
| 4134 | + | "clearing duplicate IDs for nsid %u\n", info->nsid); | |
| 4126 | 4135 | dev_err(ctrl->device, | |
| 4127 | 4136 | "use of /dev/disk/by-id/ may cause data corruption\n"); | |
| 4128 | 4137 | memset(&info->ids.nguid, 0, sizeof(info->ids.nguid)); | |
| @@ -4137,11 +4146,11 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info) | |||
| 4137 | 4146 | ret = nvme_subsys_check_duplicate_ids(ctrl->subsys, &info->ids); | |
| 4138 | 4147 | if (ret) { | |
| 4139 | 4148 | dev_err(ctrl->device, | |
| 4140 | - | "duplicate IDs in subsystem for nsid %d\n", | |
| 4149 | + | "duplicate IDs in subsystem for nsid %u\n", | |
| 4141 | 4150 | info->nsid); | |
| 4142 | 4151 | goto out_unlock; | |
| 4143 | 4152 | } | |
| 4144 | - | head = nvme_alloc_ns_head(ctrl, info); | |
| 4153 | + | head = nvme_alloc_ns_head(ns, info); | |
| 4145 | 4154 | if (IS_ERR(head)) { | |
| 4146 | 4155 | ret = PTR_ERR(head); | |
| 4147 | 4156 | goto out_unlock; | |
| @@ -4151,20 +4160,20 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info) | |||
| 4151 | 4160 | if ((!info->is_shared || !head->shared) && | |
| 4152 | 4161 | !list_empty(&head->list)) { | |
| 4153 | 4162 | dev_err(ctrl->device, | |
| 4154 | - | "Duplicate unshared namespace %d\n", | |
| 4163 | + | "Duplicate unshared namespace %u\n", | |
| 4155 | 4164 | info->nsid); | |
| 4156 | 4165 | goto out_put_ns_head; | |
| 4157 | 4166 | } | |
| 4158 | 4167 | if (!nvme_ns_ids_equal(&head->ids, &info->ids)) { | |
| 4159 | 4168 | dev_err(ctrl->device, | |
| 4160 | - | "IDs don't match for shared namespace %d\n", | |
| 4169 | + | "IDs don't match for shared namespace %u\n", | |
| 4161 | 4170 | info->nsid); | |
| 4162 | 4171 | goto out_put_ns_head; | |
| 4163 | 4172 | } | |
| 4164 | 4173 | ||
| 4165 | 4174 | if (!multipath) { | |
| 4166 | 4175 | dev_warn(ctrl->device, | |
| 4167 | - | "Found shared namespace %d, but multipathing not supported.\n", | |
| 4176 | + | "Found shared namespace %u, but multipathing not supported.\n", | |
| 4168 | 4177 | info->nsid); | |
| 4169 | 4178 | dev_warn_once(ctrl->device, | |
| 4170 | 4179 | "Shared namespace support requires core_nvme.multipath=Y.\n"); | |
| @@ -4333,6 +4342,9 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info) | |||
| 4333 | 4342 | last_path = true; | |
| 4334 | 4343 | } | |
| 4335 | 4344 | mutex_unlock(&ctrl->subsys->lock); | |
| 4345 | + | ||
| 4346 | + | /* guarantee not available in head->list */ | |
| 4347 | + | synchronize_srcu(&ns->head->srcu); | |
| 4336 | 4348 | if (last_path) | |
| 4337 | 4349 | nvme_put_ns_head(ns->head); | |
| 4338 | 4350 | nvme_put_ns_head(ns->head); | |
| @@ -4410,7 +4422,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_info *info) | |||
| 4410 | 4422 | ||
| 4411 | 4423 | if (!nvme_ns_ids_equal(&ns->head->ids, &info->ids)) { | |
| 4412 | 4424 | dev_err(ns->ctrl->device, | |
| 4413 | - | "identifiers changed for nsid %d\n", ns->head->ns_id); | |
| 4425 | + | "identifiers changed for nsid %u\n", ns->head->ns_id); | |
| 4414 | 4426 | goto out; | |
| 4415 | 4427 | } | |
| 4416 | 4428 | ||
| @@ -4437,7 +4449,7 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid) | |||
| 4437 | 4449 | ||
| 4438 | 4450 | if (info.ids.csi != NVME_CSI_NVM && !nvme_multi_css(ctrl)) { | |
| 4439 | 4451 | dev_warn(ctrl->device, | |
| 4440 | - | "command set not reported for nsid: %d\n", nsid); | |
| 4452 | + | "command set not reported for nsid: %u\n", nsid); | |
| 4441 | 4453 | return; | |
| 4442 | 4454 | } | |
| 4443 | 4455 | ||
| @@ -4501,15 +4513,16 @@ static void nvme_scan_ns_async(void *data, async_cookie_t cookie) | |||
| 4501 | 4513 | nvme_scan_ns(scan_info->ctrl, nsid); | |
| 4502 | 4514 | } | |
| 4503 | 4515 | ||
| 4504 | - | static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl, | |
| 4505 | - | unsigned nsid) | |
| 4516 | + | static void nvme_remove_nsid_range(struct nvme_ctrl *ctrl, u32 start, u32 end) | |
| 4506 | 4517 | { | |
| 4507 | 4518 | struct nvme_ns *ns, *next; | |
| 4508 | 4519 | LIST_HEAD(rm_list); | |
| 4509 | 4520 | ||
| 4510 | 4521 | mutex_lock(&ctrl->namespaces_lock); | |
| 4511 | 4522 | list_for_each_entry_safe(ns, next, &ctrl->namespaces, list) { | |
| 4512 | - | if (ns->head->ns_id > nsid) { | |
| 4523 | + | if (ns->head->ns_id >= end) | |
| 4524 | + | break; | |
| 4525 | + | if (ns->head->ns_id > start) { | |
| 4513 | 4526 | list_del_rcu(&ns->list); | |
| 4514 | 4527 | synchronize_srcu(&ctrl->srcu); | |
| 4515 | 4528 | list_add_tail_rcu(&ns->list, &rm_list); | |
| @@ -4559,13 +4572,14 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl) | |||
| 4559 | 4572 | goto out; | |
| 4560 | 4573 | async_schedule_domain(nvme_scan_ns_async, &scan_info, | |
| 4561 | 4574 | &domain); | |
| 4562 | - | while (++prev < nsid) | |
| 4563 | - | nvme_ns_remove_by_nsid(ctrl, prev); | |
| 4575 | + | if (prev + 1 < nsid) | |
| 4576 | + | nvme_remove_nsid_range(ctrl, prev, nsid); | |
| 4577 | + | prev = max(prev + 1, nsid); | |
| 4564 | 4578 | } | |
| 4565 | 4579 | async_synchronize_full_domain(&domain); | |
| 4566 | 4580 | } | |
| 4567 | 4581 | out: | |
| 4568 | - | nvme_remove_invalid_namespaces(ctrl, prev); | |
| 4582 | + | nvme_remove_nsid_range(ctrl, prev, UINT_MAX); | |
| 4569 | 4583 | free: | |
| 4570 | 4584 | async_synchronize_full_domain(&domain); | |
| 4571 | 4585 | kfree(ns_list); | |
| @@ -4585,7 +4599,7 @@ static void nvme_scan_ns_sequential(struct nvme_ctrl *ctrl) | |||
| 4585 | 4599 | for (i = 1; i <= nn; i++) | |
| 4586 | 4600 | nvme_scan_ns(ctrl, i); | |
| 4587 | 4601 | ||
| 4588 | - | nvme_remove_invalid_namespaces(ctrl, nn); | |
| 4602 | + | nvme_remove_nsid_range(ctrl, nn, UINT_MAX); | |
| 4589 | 4603 | } | |
| 4590 | 4604 | ||
| 4591 | 4605 | static void nvme_clear_changed_ns_log(struct nvme_ctrl *ctrl) | |
modified drivers/nvme/host/fabrics.c
| @@ -1028,6 +1028,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, | |||
| 1028 | 1028 | } | |
| 1029 | 1029 | if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { | |
| 1030 | 1030 | pr_err("Invalid DH-CHAP secret %s\n", p); | |
| 1031 | + | kfree_sensitive(p); | |
| 1031 | 1032 | ret = -EINVAL; | |
| 1032 | 1033 | goto out; | |
| 1033 | 1034 | } | |
| @@ -1042,6 +1043,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, | |||
| 1042 | 1043 | } | |
| 1043 | 1044 | if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { | |
| 1044 | 1045 | pr_err("Invalid DH-CHAP secret %s\n", p); | |
| 1046 | + | kfree_sensitive(p); | |
| 1045 | 1047 | ret = -EINVAL; | |
| 1046 | 1048 | goto out; | |
| 1047 | 1049 | } | |
modified drivers/nvme/host/fault_inject.c
| @@ -42,9 +42,11 @@ void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj, | |||
| 42 | 42 | } | |
| 43 | 43 | fault_inj->parent = parent; | |
| 44 | 44 | ||
| 45 | - | /* create debugfs for status code and dont_retry */ | |
| 45 | + | /* create debugfs for opcode, status code, and dont_retry */ | |
| 46 | + | fault_inj->opcode = 0xffff; | |
| 46 | 47 | fault_inj->status = NVME_SC_INVALID_OPCODE; | |
| 47 | 48 | fault_inj->dont_retry = true; | |
| 49 | + | debugfs_create_x16("opcode", 0600, dir, &fault_inj->opcode); | |
| 48 | 50 | debugfs_create_x16("status", 0600, dir, &fault_inj->status); | |
| 49 | 51 | debugfs_create_bool("dont_retry", 0600, dir, &fault_inj->dont_retry); | |
| 50 | 52 | } | |
| @@ -59,6 +61,7 @@ void nvme_should_fail(struct request *req) | |||
| 59 | 61 | { | |
| 60 | 62 | struct gendisk *disk = req->q->disk; | |
| 61 | 63 | struct nvme_fault_inject *fault_inject = NULL; | |
| 64 | + | struct nvme_command *cmd = nvme_req(req)->cmd; | |
| 62 | 65 | u16 status; | |
| 63 | 66 | ||
| 64 | 67 | if (disk) { | |
| @@ -72,7 +75,14 @@ void nvme_should_fail(struct request *req) | |||
| 72 | 75 | fault_inject = &nvme_req(req)->ctrl->fault_inject; | |
| 73 | 76 | } | |
| 74 | 77 | ||
| 75 | - | if (fault_inject && should_fail(&fault_inject->attr, 1)) { | |
| 78 | + | if (!fault_inject) | |
| 79 | + | return; | |
| 80 | + | ||
| 81 | + | if (fault_inject->opcode <= 0xff && | |
| 82 | + | fault_inject->opcode != cmd->common.opcode) | |
| 83 | + | return; | |
| 84 | + | ||
| 85 | + | if (should_fail(&fault_inject->attr, 1)) { | |
| 76 | 86 | /* inject status code and DNR bit */ | |
| 77 | 87 | status = fault_inject->status; | |
| 78 | 88 | if (fault_inject->dont_retry) | |
modified drivers/nvme/host/fc.c
| @@ -2364,9 +2364,15 @@ nvme_fc_ctrl_free(struct kref *ref) | |||
| 2364 | 2364 | struct nvme_fc_ctrl *ctrl = | |
| 2365 | 2365 | container_of(ref, struct nvme_fc_ctrl, ref); | |
| 2366 | 2366 | unsigned long flags; | |
| 2367 | + | bool owns_opts; | |
| 2367 | 2368 | ||
| 2368 | - | /* remove from rport list */ | |
| 2369 | + | /* | |
| 2370 | + | * Presence on the rport list means nvme_fc_init_ctrl() completed, | |
| 2371 | + | * and with it ownership of the fabrics options passed to it. If it | |
| 2372 | + | * failed instead, the options still belong to nvmf_create_ctrl(). | |
| 2373 | + | */ | |
| 2369 | 2374 | spin_lock_irqsave(&ctrl->rport->lock, flags); | |
| 2375 | + | owns_opts = !list_empty(&ctrl->ctrl_list); | |
| 2370 | 2376 | list_del(&ctrl->ctrl_list); | |
| 2371 | 2377 | spin_unlock_irqrestore(&ctrl->rport->lock, flags); | |
| 2372 | 2378 | ||
| @@ -2376,7 +2382,7 @@ nvme_fc_ctrl_free(struct kref *ref) | |||
| 2376 | 2382 | nvme_fc_rport_put(ctrl->rport); | |
| 2377 | 2383 | ||
| 2378 | 2384 | ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); | |
| 2379 | - | if (ctrl->ctrl.opts) | |
| 2385 | + | if (owns_opts) | |
| 2380 | 2386 | nvmf_free_options(ctrl->ctrl.opts); | |
| 2381 | 2387 | kfree(ctrl); | |
| 2382 | 2388 | } | |
| @@ -3575,14 +3581,14 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, | |||
| 3575 | 3581 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { | |
| 3576 | 3582 | dev_err(ctrl->ctrl.device, | |
| 3577 | 3583 | "NVME-FC{%d}: failed to init ctrl state\n", ctrl->cnum); | |
| 3578 | - | goto fail_ctrl; | |
| 3584 | + | goto fail_unlist; | |
| 3579 | 3585 | } | |
| 3580 | 3586 | ||
| 3581 | 3587 | if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) { | |
| 3582 | 3588 | dev_err(ctrl->ctrl.device, | |
| 3583 | 3589 | "NVME-FC{%d}: failed to schedule initial connect\n", | |
| 3584 | 3590 | ctrl->cnum); | |
| 3585 | - | goto fail_ctrl; | |
| 3591 | + | goto fail_unlist; | |
| 3586 | 3592 | } | |
| 3587 | 3593 | ||
| 3588 | 3594 | flush_delayed_work(&ctrl->connect_work); | |
| @@ -3593,14 +3599,22 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, | |||
| 3593 | 3599 | ||
| 3594 | 3600 | return &ctrl->ctrl; | |
| 3595 | 3601 | ||
| 3602 | + | fail_unlist: | |
| 3603 | + | /* | |
| 3604 | + | * Leaving the list hands the options back to nvmf_create_ctrl(); | |
| 3605 | + | * see nvme_fc_ctrl_free(). Re-init so that list_empty() there | |
| 3606 | + | * reports the controller as unlisted. | |
| 3607 | + | */ | |
| 3608 | + | spin_lock_irqsave(&rport->lock, flags); | |
| 3609 | + | list_del_init(&ctrl->ctrl_list); | |
| 3610 | + | spin_unlock_irqrestore(&rport->lock, flags); | |
| 3611 | + | ||
| 3596 | 3612 | fail_ctrl: | |
| 3597 | 3613 | nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING); | |
| 3598 | 3614 | cancel_work_sync(&ctrl->ioerr_work); | |
| 3599 | 3615 | cancel_work_sync(&ctrl->ctrl.reset_work); | |
| 3600 | 3616 | cancel_delayed_work_sync(&ctrl->connect_work); | |
| 3601 | 3617 | ||
| 3602 | - | ctrl->ctrl.opts = NULL; | |
| 3603 | - | ||
| 3604 | 3618 | if (ctrl->ctrl.admin_tagset) | |
| 3605 | 3619 | nvme_remove_admin_tag_set(&ctrl->ctrl); | |
| 3606 | 3620 | /* initiate nvme ctrl ref counting teardown */ | |
modified drivers/nvme/host/nvme.h
| @@ -323,6 +323,7 @@ struct nvme_fault_inject { | |||
| 323 | 323 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS | |
| 324 | 324 | struct fault_attr attr; | |
| 325 | 325 | struct dentry *parent; | |
| 326 | + | u16 opcode; | |
| 326 | 327 | bool dont_retry; /* DNR, do not retry */ | |
| 327 | 328 | u16 status; /* status code */ | |
| 328 | 329 | #endif | |
| @@ -571,6 +572,7 @@ struct nvme_ns_head { | |||
| 571 | 572 | ||
| 572 | 573 | u16 nr_plids; | |
| 573 | 574 | u16 *plids; | |
| 575 | + | u32 write_stream_granularity; | |
| 574 | 576 | #ifdef CONFIG_NVME_MULTIPATH | |
| 575 | 577 | struct bio_list requeue_list | |
| 576 | 578 | __guarded_by(&requeue_lock); | |
modified drivers/nvme/host/pci.c
| @@ -201,7 +201,7 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp) | |||
| 201 | 201 | count++; | |
| 202 | 202 | } | |
| 203 | 203 | ||
| 204 | - | qlist = kcalloc(count, sizeof(*qlist), GFP_KERNEL); | |
| 204 | + | qlist = kzalloc_objs(*qlist, count); | |
| 205 | 205 | if (!qlist) { | |
| 206 | 206 | err = -ENOMEM; | |
| 207 | 207 | goto out_free_val; | |
modified drivers/nvme/host/rdma.c
| @@ -2036,7 +2036,7 @@ static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
| 2036 | 2036 | struct ib_device *dev; | |
| 2037 | 2037 | bool queue_ready = test_bit(NVME_RDMA_Q_LIVE, &queue->flags); | |
| 2038 | 2038 | blk_status_t ret; | |
| 2039 | - | int err; | |
| 2039 | + | int err = 0; | |
| 2040 | 2040 | ||
| 2041 | 2041 | WARN_ON_ONCE(rq->tag < 0); | |
| 2042 | 2042 | ||
| @@ -2092,16 +2092,18 @@ static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
| 2092 | 2092 | err_unmap: | |
| 2093 | 2093 | nvme_rdma_unmap_data(queue, rq); | |
| 2094 | 2094 | err: | |
| 2095 | - | if (err == -EIO) | |
| 2096 | - | ret = nvme_host_path_error(rq); | |
| 2097 | - | else if (err == -ENOMEM || err == -EAGAIN) | |
| 2098 | - | ret = BLK_STS_RESOURCE; | |
| 2099 | - | else | |
| 2100 | - | ret = BLK_STS_IOERR; | |
| 2101 | - | nvme_cleanup_cmd(rq); | |
| 2095 | + | if (err != -EIO) { | |
| 2096 | + | nvme_cleanup_cmd(rq); | |
| 2097 | + | if (err == -ENOMEM || err == -EAGAIN) | |
| 2098 | + | ret = BLK_STS_RESOURCE; | |
| 2099 | + | else | |
| 2100 | + | ret = BLK_STS_IOERR; | |
| 2101 | + | } | |
| 2102 | 2102 | unmap_qe: | |
| 2103 | 2103 | ib_dma_unmap_single(dev, req->sqe.dma, sizeof(struct nvme_command), | |
| 2104 | 2104 | DMA_TO_DEVICE); | |
| 2105 | + | if (err == -EIO) | |
| 2106 | + | return nvme_host_path_error(rq); | |
| 2105 | 2107 | return ret; | |
| 2106 | 2108 | } | |
| 2107 | 2109 | ||
modified drivers/nvme/host/sysfs.c
| @@ -166,7 +166,7 @@ static DEVICE_ATTR_RO(eui); | |||
| 166 | 166 | static ssize_t nsid_show(struct device *dev, struct device_attribute *attr, | |
| 167 | 167 | char *buf) | |
| 168 | 168 | { | |
| 169 | - | return sysfs_emit(buf, "%d\n", dev_to_ns_head(dev)->ns_id); | |
| 169 | + | return sysfs_emit(buf, "%u\n", dev_to_ns_head(dev)->ns_id); | |
| 170 | 170 | } | |
| 171 | 171 | static DEVICE_ATTR_RO(nsid); | |
| 172 | 172 | ||
modified drivers/nvme/host/tcp.c
| @@ -413,8 +413,13 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req, | |||
| 413 | 413 | * if we're the first on the send_list and we can try to send | |
| 414 | 414 | * directly, otherwise queue io_work. Also, only do that if we | |
| 415 | 415 | * are on the same cpu, so we don't introduce contention. | |
| 416 | + | * | |
| 417 | + | * TLS kTLS send takes ctx->tx_lock while blk_mq holds set->srcu. | |
| 418 | + | * lockdep reports circular locking via elevator_lock. Defer TLS | |
| 419 | + | * sends to the io workqueue instead of inline from this path. | |
| 416 | 420 | */ | |
| 417 | 421 | if (queue->io_cpu == raw_smp_processor_id() && | |
| 422 | + | !nvme_tcp_queue_tls(queue) && | |
| 418 | 423 | empty && mutex_trylock(&queue->send_mutex)) { | |
| 419 | 424 | nvme_tcp_send_all(queue); | |
| 420 | 425 | mutex_unlock(&queue->send_mutex); | |
| @@ -684,6 +689,13 @@ static int nvme_tcp_handle_c2h_data(struct nvme_tcp_queue *queue, | |||
| 684 | 689 | return -ENOENT; | |
| 685 | 690 | } | |
| 686 | 691 | ||
| 692 | + | if (rq_data_dir(rq) != READ) { | |
| 693 | + | dev_err(queue->ctrl->ctrl.device, | |
| 694 | + | "queue %d tag %#x unexpected data for a write\n", | |
| 695 | + | nvme_tcp_queue_id(queue), rq->tag); | |
| 696 | + | return -EPROTO; | |
| 697 | + | } | |
| 698 | + | ||
| 687 | 699 | req = blk_mq_rq_to_pdu(rq); | |
| 688 | 700 | if (!blk_rq_payload_bytes(rq) || !req->curr_bio || !req->data_len) { | |
| 689 | 701 | dev_err(queue->ctrl->ctrl.device, | |
modified drivers/nvme/host/zns.c
| @@ -48,12 +48,12 @@ int nvme_query_zone_info(struct nvme_ns *ns, unsigned lbaf, | |||
| 48 | 48 | NVME_CMD_EFFECTS_CSUPP)) { | |
| 49 | 49 | if (test_and_clear_bit(NVME_NS_FORCE_RO, &ns->flags)) | |
| 50 | 50 | dev_warn(ns->ctrl->device, | |
| 51 | - | "Zone Append supported for zoned namespace:%d. Remove read-only mode\n", | |
| 51 | + | "Zone Append supported for zoned namespace:%u. Remove read-only mode\n", | |
| 52 | 52 | ns->head->ns_id); | |
| 53 | 53 | } else { | |
| 54 | 54 | set_bit(NVME_NS_FORCE_RO, &ns->flags); | |
| 55 | 55 | dev_warn(ns->ctrl->device, | |
| 56 | - | "Zone Append not supported for zoned namespace:%d. Forcing to read-only mode\n", | |
| 56 | + | "Zone Append not supported for zoned namespace:%u. Forcing to read-only mode\n", | |
| 57 | 57 | ns->head->ns_id); | |
| 58 | 58 | } | |
| 59 | 59 | ||
modified drivers/nvme/target/auth.c
| @@ -238,6 +238,12 @@ void nvmet_auth_sq_free(struct nvmet_sq *sq) | |||
| 238 | 238 | sq->dhchap_skey = NULL; | |
| 239 | 239 | } | |
| 240 | 240 | ||
| 241 | + | void nvmet_auth_sq_destroy(struct nvmet_sq *sq) | |
| 242 | + | { | |
| 243 | + | cancel_delayed_work_sync(&sq->auth_expired_work); | |
| 244 | + | nvmet_auth_sq_free(sq); | |
| 245 | + | } | |
| 246 | + | ||
| 241 | 247 | void nvmet_destroy_auth(struct nvmet_ctrl *ctrl) | |
| 242 | 248 | { | |
| 243 | 249 | ctrl->shash_id = 0; | |
modified drivers/nvme/target/configfs.c
| @@ -814,7 +814,7 @@ static ssize_t nvmet_ns_resv_enable_store(struct config_item *item, | |||
| 814 | 814 | ||
| 815 | 815 | mutex_lock(&ns->subsys->lock); | |
| 816 | 816 | if (ns->enabled) { | |
| 817 | - | pr_err("the ns:%d is already enabled.\n", ns->nsid); | |
| 817 | + | pr_err("the ns:%u is already enabled.\n", ns->nsid); | |
| 818 | 818 | mutex_unlock(&ns->subsys->lock); | |
| 819 | 819 | return -EINVAL; | |
| 820 | 820 | } | |
| @@ -880,7 +880,7 @@ static struct config_group *nvmet_ns_make(struct config_group *group, | |||
| 880 | 880 | goto out; | |
| 881 | 881 | config_group_init_type_name(&ns->group, name, &nvmet_ns_type); | |
| 882 | 882 | ||
| 883 | - | pr_info("adding nsid %d to subsystem %s\n", nsid, subsys->subsysnqn); | |
| 883 | + | pr_info("adding nsid %u to subsystem %s\n", nsid, subsys->subsysnqn); | |
| 884 | 884 | ||
| 885 | 885 | return &ns->group; | |
| 886 | 886 | out: | |
modified drivers/nvme/target/core.c
| @@ -558,7 +558,7 @@ static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl, | |||
| 558 | 558 | if (ret < 0) | |
| 559 | 559 | pci_dev_put(p2p_dev); | |
| 560 | 560 | ||
| 561 | - | pr_info("using p2pmem on %s for nsid %d\n", pci_name(p2p_dev), | |
| 561 | + | pr_info("using p2pmem on %s for nsid %u\n", pci_name(p2p_dev), | |
| 562 | 562 | ns->nsid); | |
| 563 | 563 | } | |
| 564 | 564 | ||
| @@ -591,6 +591,11 @@ int nvmet_ns_enable(struct nvmet_ns *ns) | |||
| 591 | 591 | if (ns->enabled) | |
| 592 | 592 | goto out_unlock; | |
| 593 | 593 | ||
| 594 | + | if (!ns->device_path) { | |
| 595 | + | ret = -EINVAL; | |
| 596 | + | goto out_unlock; | |
| 597 | + | } | |
| 598 | + | ||
| 594 | 599 | ret = nvmet_bdev_ns_enable(ns); | |
| 595 | 600 | if (ret == -ENOTBLK) | |
| 596 | 601 | ret = nvmet_file_ns_enable(ns); | |
| @@ -980,7 +985,7 @@ void nvmet_sq_destroy(struct nvmet_sq *sq) | |||
| 980 | 985 | wait_for_completion(&sq->confirm_done); | |
| 981 | 986 | wait_for_completion(&sq->free_done); | |
| 982 | 987 | percpu_ref_exit(&sq->ref); | |
| 983 | - | nvmet_auth_sq_free(sq); | |
| 988 | + | nvmet_auth_sq_destroy(sq); | |
| 984 | 989 | nvmet_cq_put(sq->cq); | |
| 985 | 990 | ||
| 986 | 991 | /* | |
modified drivers/nvme/target/nvmet.h
| @@ -924,6 +924,7 @@ u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq, bool reset); | |||
| 924 | 924 | void nvmet_auth_sq_init(struct nvmet_sq *sq); | |
| 925 | 925 | void nvmet_destroy_auth(struct nvmet_ctrl *ctrl); | |
| 926 | 926 | void nvmet_auth_sq_free(struct nvmet_sq *sq); | |
| 927 | + | void nvmet_auth_sq_destroy(struct nvmet_sq *sq); | |
| 927 | 928 | int nvmet_setup_dhgroup(struct nvmet_ctrl *ctrl, u8 dhgroup_id); | |
| 928 | 929 | bool nvmet_check_auth_status(struct nvmet_req *req); | |
| 929 | 930 | int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response, | |
| @@ -950,6 +951,7 @@ static inline void nvmet_auth_sq_init(struct nvmet_sq *sq) | |||
| 950 | 951 | } | |
| 951 | 952 | static inline void nvmet_destroy_auth(struct nvmet_ctrl *ctrl) {}; | |
| 952 | 953 | static inline void nvmet_auth_sq_free(struct nvmet_sq *sq) {}; | |
| 954 | + | static inline void nvmet_auth_sq_destroy(struct nvmet_sq *sq) {}; | |
| 953 | 955 | static inline bool nvmet_check_auth_status(struct nvmet_req *req) | |
| 954 | 956 | { | |
| 955 | 957 | return true; | |
modified drivers/nvme/target/pr.c
| @@ -145,7 +145,7 @@ static void nvmet_pr_add_resv_log(struct nvmet_ctrl *ctrl, u8 log_type, | |||
| 145 | 145 | log.nsid = cpu_to_le32(nsid); | |
| 146 | 146 | ||
| 147 | 147 | if (!kfifo_put(&log_mgr->log_queue, log)) { | |
| 148 | - | pr_info("a reservation log lost, cntlid:%d, log_type:%d, nsid:%d\n", | |
| 148 | + | pr_info("a reservation log lost, cntlid:%d, log_type:%d, nsid:%u\n", | |
| 149 | 149 | ctrl->cntlid, log_type, nsid); | |
| 150 | 150 | log_mgr->lost_count++; | |
| 151 | 151 | } | |
modified drivers/nvme/target/rdma.c
| @@ -1631,19 +1631,13 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id, | |||
| 1631 | 1631 | mutex_unlock(&nvmet_rdma_queue_mutex); | |
| 1632 | 1632 | if (pending > NVMET_RDMA_BACKLOG) { | |
| 1633 | 1633 | ret = NVME_SC_CONNECT_CTRL_BUSY; | |
| 1634 | - | goto put_device; | |
| 1634 | + | goto free_queue; | |
| 1635 | 1635 | } | |
| 1636 | 1636 | } | |
| 1637 | 1637 | ||
| 1638 | 1638 | ret = nvmet_rdma_cm_accept(cm_id, queue, &event->param.conn); | |
| 1639 | - | if (ret) { | |
| 1640 | - | /* | |
| 1641 | - | * Don't destroy the cm_id in free path, as we implicitly | |
| 1642 | - | * destroy the cm_id here with non-zero ret code. | |
| 1643 | - | */ | |
| 1644 | - | queue->cm_id = NULL; | |
| 1639 | + | if (ret) | |
| 1645 | 1640 | goto free_queue; | |
| 1646 | - | } | |
| 1647 | 1641 | ||
| 1648 | 1642 | mutex_lock(&nvmet_rdma_queue_mutex); | |
| 1649 | 1643 | list_add_tail(&queue->queue_list, &nvmet_rdma_queue_list); | |
| @@ -1652,6 +1646,11 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id, | |||
| 1652 | 1646 | return 0; | |
| 1653 | 1647 | ||
| 1654 | 1648 | free_queue: | |
| 1649 | + | /* | |
| 1650 | + | * Don't destroy the cm_id in free path, as we implicitly | |
| 1651 | + | * destroy the cm_id here with non-zero ret code. | |
| 1652 | + | */ | |
| 1653 | + | queue->cm_id = NULL; | |
| 1655 | 1654 | nvmet_rdma_free_queue(queue); | |
| 1656 | 1655 | put_device: | |
| 1657 | 1656 | kref_put(&ndev->ref, nvmet_rdma_free_dev); | |
modified drivers/nvme/target/tcp.c
| @@ -103,6 +103,7 @@ enum nvmet_tcp_recv_state { | |||
| 103 | 103 | ||
| 104 | 104 | enum { | |
| 105 | 105 | NVMET_TCP_F_INIT_FAILED = (1 << 0), | |
| 106 | + | NVMET_TCP_F_R2T_SENT = (1 << 1), | |
| 106 | 107 | }; | |
| 107 | 108 | ||
| 108 | 109 | struct nvmet_tcp_cmd { | |
| @@ -776,6 +777,7 @@ static int nvmet_try_send_r2t(struct nvmet_tcp_cmd *cmd, bool last_in_batch) | |||
| 776 | 777 | return -EAGAIN; | |
| 777 | 778 | ||
| 778 | 779 | cmd->queue->snd_cmd = NULL; | |
| 780 | + | cmd->flags |= NVMET_TCP_F_R2T_SENT; | |
| 779 | 781 | return 1; | |
| 780 | 782 | } | |
| 781 | 783 | ||
| @@ -1009,6 +1011,12 @@ static int nvmet_tcp_handle_h2c_data_pdu(struct nvmet_tcp_queue *queue) | |||
| 1009 | 1011 | cmd = &queue->connect; | |
| 1010 | 1012 | } | |
| 1011 | 1013 | ||
| 1014 | + | if (unlikely(!(cmd->flags & NVMET_TCP_F_R2T_SENT))) { | |
| 1015 | + | pr_err("queue %d: unsolicited H2CData (ttag %u)\n", | |
| 1016 | + | queue->idx, data->ttag); | |
| 1017 | + | goto err_proto; | |
| 1018 | + | } | |
| 1019 | + | ||
| 1012 | 1020 | if (le32_to_cpu(data->data_offset) != cmd->rbytes_done) { | |
| 1013 | 1021 | pr_err("ttag %u unexpected data offset %u (expected %u)\n", | |
| 1014 | 1022 | data->ttag, le32_to_cpu(data->data_offset), | |
| @@ -1244,6 +1252,8 @@ recv: | |||
| 1244 | 1252 | } | |
| 1245 | 1253 | ||
| 1246 | 1254 | queue->left = hdr->hlen - queue->offset + hdgst; | |
| 1255 | + | if (queue->left > sizeof(queue->pdu) - queue->offset) | |
| 1256 | + | return -EPROTO; | |
| 1247 | 1257 | goto recv; | |
| 1248 | 1258 | } | |
| 1249 | 1259 | ||
modified drivers/opp/core.c
| @@ -348,7 +348,7 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) | |||
| 348 | 348 | ||
| 349 | 349 | count = opp_table->regulator_count; | |
| 350 | 350 | ||
| 351 | - | uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL); | |
| 351 | + | uV = kmalloc_objs(*uV, count); | |
| 352 | 352 | if (!uV) | |
| 353 | 353 | return 0; | |
| 354 | 354 | ||
| @@ -453,8 +453,8 @@ int dev_pm_opp_get_opp_count(struct device *dev) | |||
| 453 | 453 | _find_opp_table(dev); | |
| 454 | 454 | ||
| 455 | 455 | if (IS_ERR(opp_table)) { | |
| 456 | - | dev_dbg(dev, "%s: OPP table not found (%ld)\n", | |
| 457 | - | __func__, PTR_ERR(opp_table)); | |
| 456 | + | dev_dbg(dev, "%s: OPP table not found (%pe)\n", | |
| 457 | + | __func__, opp_table); | |
| 458 | 458 | return PTR_ERR(opp_table); | |
| 459 | 459 | } | |
| 460 | 460 | ||
| @@ -611,8 +611,8 @@ _find_key(struct device *dev, unsigned long *key, int index, bool available, | |||
| 611 | 611 | _find_opp_table(dev); | |
| 612 | 612 | ||
| 613 | 613 | if (IS_ERR(opp_table)) { | |
| 614 | - | dev_err(dev, "%s: OPP table not found (%ld)\n", __func__, | |
| 615 | - | PTR_ERR(opp_table)); | |
| 614 | + | dev_err(dev, "%s: OPP table not found (%pe)\n", __func__, | |
| 615 | + | opp_table); | |
| 616 | 616 | return ERR_CAST(opp_table); | |
| 617 | 617 | } | |
| 618 | 618 | ||
| @@ -722,8 +722,8 @@ struct dev_pm_opp *dev_pm_opp_find_key_exact(struct device *dev, | |||
| 722 | 722 | struct opp_table *opp_table __free(put_opp_table) = _find_opp_table(dev); | |
| 723 | 723 | ||
| 724 | 724 | if (IS_ERR(opp_table)) { | |
| 725 | - | dev_err(dev, "%s: OPP table not found (%ld)\n", __func__, | |
| 726 | - | PTR_ERR(opp_table)); | |
| 725 | + | dev_err(dev, "%s: OPP table not found (%pe)\n", __func__, | |
| 726 | + | opp_table); | |
| 727 | 727 | return ERR_CAST(opp_table); | |
| 728 | 728 | } | |
| 729 | 729 | ||
| @@ -1036,8 +1036,8 @@ static int _set_opp_voltage(struct device *dev, struct regulator *reg, | |||
| 1036 | 1036 | ||
| 1037 | 1037 | /* Regulator not available for device */ | |
| 1038 | 1038 | if (IS_ERR(reg)) { | |
| 1039 | - | dev_dbg(dev, "%s: regulator not available: %ld\n", __func__, | |
| 1040 | - | PTR_ERR(reg)); | |
| 1039 | + | dev_dbg(dev, "%s: regulator not available: %pe\n", __func__, | |
| 1040 | + | reg); | |
| 1041 | 1041 | return 0; | |
| 1042 | 1042 | } | |
| 1043 | 1043 | ||
| @@ -1448,8 +1448,8 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) | |||
| 1448 | 1448 | temp_freq = freq; | |
| 1449 | 1449 | opp = _find_freq_ceil(opp_table, &temp_freq); | |
| 1450 | 1450 | if (IS_ERR(opp)) { | |
| 1451 | - | dev_err(dev, "%s: failed to find OPP for freq %lu (%ld)\n", | |
| 1452 | - | __func__, freq, PTR_ERR(opp)); | |
| 1451 | + | dev_err(dev, "%s: failed to find OPP for freq %lu (%pe)\n", | |
| 1452 | + | __func__, freq, opp); | |
| 1453 | 1453 | return PTR_ERR(opp); | |
| 1454 | 1454 | } | |
| 1455 | 1455 | ||
| @@ -1505,7 +1505,7 @@ struct opp_device *_add_opp_dev(const struct device *dev, | |||
| 1505 | 1505 | { | |
| 1506 | 1506 | struct opp_device *opp_dev; | |
| 1507 | 1507 | ||
| 1508 | - | opp_dev = kzalloc(sizeof(*opp_dev), GFP_KERNEL); | |
| 1508 | + | opp_dev = kzalloc_obj(*opp_dev); | |
| 1509 | 1509 | if (!opp_dev) | |
| 1510 | 1510 | return NULL; | |
| 1511 | 1511 | ||
| @@ -1581,6 +1581,8 @@ static struct opp_table *_update_opp_table_clk(struct device *dev, | |||
| 1581 | 1581 | struct opp_table *opp_table, | |
| 1582 | 1582 | bool getclk) | |
| 1583 | 1583 | { | |
| 1584 | + | int ret; | |
| 1585 | + | ||
| 1584 | 1586 | /* | |
| 1585 | 1587 | * Return early if we don't need to get clk or we have already done it | |
| 1586 | 1588 | * earlier. | |
| @@ -1607,9 +1609,9 @@ static struct opp_table *_update_opp_table_clk(struct device *dev, | |||
| 1607 | 1609 | opp_table->clk = clk_get_optional(dev, NULL); | |
| 1608 | 1610 | ||
| 1609 | 1611 | if (IS_ERR(opp_table->clk)) { | |
| 1612 | + | ret = dev_err_probe(dev, PTR_ERR(opp_table->clk), "Couldn't find clock\n"); | |
| 1610 | 1613 | dev_pm_opp_put_opp_table(opp_table); | |
| 1611 | - | dev_err_probe(dev, PTR_ERR(opp_table->clk), "Couldn't find clock\n"); | |
| 1612 | - | return ERR_CAST(opp_table->clk); | |
| 1614 | + | return ERR_PTR(ret); | |
| 1613 | 1615 | } | |
| 1614 | 1616 | ||
| 1615 | 1617 | if (opp_table->clk) | |
| @@ -2869,8 +2871,8 @@ static int _opp_set_availability(struct device *dev, unsigned long freq, | |||
| 2869 | 2871 | struct dev_pm_opp *opp __free(put_opp) = ERR_PTR(-ENODEV), *tmp_opp; | |
| 2870 | 2872 | ||
| 2871 | 2873 | if (IS_ERR(opp_table)) { | |
| 2872 | - | dev_warn(dev, "%s: Device OPP not found (%ld)\n", __func__, | |
| 2873 | - | PTR_ERR(opp_table)); | |
| 2874 | + | dev_warn(dev, "%s: Device OPP not found (%pe)\n", __func__, | |
| 2875 | + | opp_table); | |
| 2874 | 2876 | return PTR_ERR(opp_table); | |
| 2875 | 2877 | } | |
| 2876 | 2878 | ||
modified drivers/opp/of.c
| @@ -1039,7 +1039,7 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) | |||
| 1039 | 1039 | ||
| 1040 | 1040 | val = prop->value; | |
| 1041 | 1041 | while (nr) { | |
| 1042 | - | unsigned long freq = be32_to_cpup(val++) * 1000; | |
| 1042 | + | unsigned long freq = (unsigned long)be32_to_cpup(val++) * 1000; | |
| 1043 | 1043 | unsigned long volt = be32_to_cpup(val++); | |
| 1044 | 1044 | struct dev_pm_opp_data data = { | |
| 1045 | 1045 | .freq = freq, | |
| @@ -1345,8 +1345,8 @@ int of_get_required_opp_performance_state(struct device_node *np, int index) | |||
| 1345 | 1345 | _find_table_of_opp_np(required_np); | |
| 1346 | 1346 | ||
| 1347 | 1347 | if (IS_ERR(opp_table)) { | |
| 1348 | - | pr_err("%s: Failed to find required OPP table %pOF: %ld\n", | |
| 1349 | - | __func__, np, PTR_ERR(opp_table)); | |
| 1348 | + | pr_err("%s: Failed to find required OPP table %pOF: %pe\n", | |
| 1349 | + | __func__, np, opp_table); | |
| 1350 | 1350 | return PTR_ERR(opp_table); | |
| 1351 | 1351 | } | |
| 1352 | 1352 | ||
modified drivers/pci/endpoint/pci-ep-msi.c
| @@ -57,7 +57,7 @@ static int pci_epf_alloc_doorbell_embedded(struct pci_epf *epf, u16 num_db) | |||
| 57 | 57 | return -ENODEV; | |
| 58 | 58 | ||
| 59 | 59 | struct pci_epc_aux_resource *res __free(kfree) = | |
| 60 | - | kcalloc(count, sizeof(*res), GFP_KERNEL); | |
| 60 | + | kzalloc_objs(*res, count); | |
| 61 | 61 | if (!res) | |
| 62 | 62 | return -ENOMEM; | |
| 63 | 63 | ||
| @@ -98,7 +98,7 @@ static int pci_epf_alloc_doorbell_embedded(struct pci_epf *epf, u16 num_db) | |||
| 98 | 98 | addr = iova_base + off; | |
| 99 | 99 | } | |
| 100 | 100 | ||
| 101 | - | msg = kcalloc(num_db, sizeof(*msg), GFP_KERNEL); | |
| 101 | + | msg = kzalloc_objs(*msg, num_db); | |
| 102 | 102 | if (!msg) { | |
| 103 | 103 | ret = -ENOMEM; | |
| 104 | 104 | goto err_unmap; | |
modified drivers/perf/riscv_pmu_legacy.c
| @@ -110,8 +110,9 @@ static void pmu_legacy_init(struct riscv_pmu *pmu) | |||
| 110 | 110 | { | |
| 111 | 111 | pr_info("Legacy PMU implementation is available\n"); | |
| 112 | 112 | ||
| 113 | - | pmu->cmask = BIT(RISCV_PMU_LEGACY_CYCLE) | | |
| 114 | - | BIT(RISCV_PMU_LEGACY_INSTRET); | |
| 113 | + | bitmap_zero(pmu->cmask, RISCV_MAX_COUNTERS); | |
| 114 | + | set_bit(RISCV_PMU_LEGACY_CYCLE, pmu->cmask); | |
| 115 | + | set_bit(RISCV_PMU_LEGACY_INSTRET, pmu->cmask); | |
| 115 | 116 | pmu->ctr_start = pmu_legacy_ctr_start; | |
| 116 | 117 | pmu->ctr_stop = NULL; | |
| 117 | 118 | pmu->event_map = pmu_legacy_event_map; | |
modified drivers/perf/riscv_pmu_sbi.c
| @@ -97,7 +97,7 @@ static unsigned int riscv_pmu_irq_mask; | |||
| 97 | 97 | static unsigned int riscv_pmu_irq; | |
| 98 | 98 | ||
| 99 | 99 | /* Cache the available counters in a bitmask */ | |
| 100 | - | static unsigned long cmask; | |
| 100 | + | static DECLARE_BITMAP(cmask, RISCV_MAX_COUNTERS); | |
| 101 | 101 | ||
| 102 | 102 | static int pmu_event_find_cache(u64 config); | |
| 103 | 103 | struct sbi_pmu_event_data { | |
| @@ -359,16 +359,38 @@ free_mem: | |||
| 359 | 359 | return result; | |
| 360 | 360 | } | |
| 361 | 361 | ||
| 362 | + | static struct sbiret pmu_sbi_ctr_cfg_match(unsigned long cbase, | |
| 363 | + | unsigned long ctr_mask, | |
| 364 | + | unsigned long cflags, | |
| 365 | + | unsigned long event_idx, | |
| 366 | + | u64 config) | |
| 367 | + | { | |
| 368 | + | #if defined(CONFIG_32BIT) | |
| 369 | + | return sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase, | |
| 370 | + | ctr_mask, cflags, event_idx, config, config >> 32); | |
| 371 | + | #else | |
| 372 | + | return sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase, | |
| 373 | + | ctr_mask, cflags, event_idx, config, 0); | |
| 374 | + | #endif | |
| 375 | + | } | |
| 376 | + | ||
| 362 | 377 | static void pmu_sbi_check_event(struct sbi_pmu_event_data *edata) | |
| 363 | 378 | { | |
| 364 | - | struct sbiret ret; | |
| 379 | + | struct sbiret ret = { .error = SBI_ERR_NOT_SUPPORTED }; | |
| 380 | + | int i; | |
| 365 | 381 | ||
| 366 | - | ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, | |
| 367 | - | 0, cmask, 0, edata->event_idx, 0, 0); | |
| 368 | - | if (!ret.error) { | |
| 369 | - | sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP, | |
| 370 | - | ret.value, 0x1, SBI_PMU_STOP_FLAG_RESET, 0, 0, 0); | |
| 371 | - | } else if (ret.error == SBI_ERR_NOT_SUPPORTED) { | |
| 382 | + | for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) { | |
| 383 | + | if (!cmask[i]) | |
| 384 | + | continue; | |
| 385 | + | ret = pmu_sbi_ctr_cfg_match(i * BITS_PER_LONG, cmask[i], 0, | |
| 386 | + | edata->event_idx, 0); | |
| 387 | + | if (!ret.error) { | |
| 388 | + | sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP, | |
| 389 | + | ret.value, 0x1, SBI_PMU_STOP_FLAG_RESET, 0, 0, 0); | |
| 390 | + | return; | |
| 391 | + | } | |
| 392 | + | } | |
| 393 | + | if (ret.error == SBI_ERR_NOT_SUPPORTED) { | |
| 372 | 394 | /* This event cannot be monitored by any counter */ | |
| 373 | 395 | edata->event_idx = -ENOENT; | |
| 374 | 396 | } | |
| @@ -488,10 +510,10 @@ int riscv_pmu_get_hpm_info(u32 *hw_ctr_width, u32 *num_hw_ctr) | |||
| 488 | 510 | union sbi_pmu_ctr_info *info; | |
| 489 | 511 | u32 hpm_width = 0, hpm_count = 0; | |
| 490 | 512 | ||
| 491 | - | if (!cmask) | |
| 513 | + | if (bitmap_empty(cmask, RISCV_MAX_COUNTERS)) | |
| 492 | 514 | return -EINVAL; | |
| 493 | 515 | ||
| 494 | - | for_each_set_bit(i, &cmask, RISCV_MAX_COUNTERS) { | |
| 516 | + | for_each_set_bit(i, cmask, RISCV_MAX_COUNTERS) { | |
| 495 | 517 | info = &pmu_ctr_list[i]; | |
| 496 | 518 | if (!info) | |
| 497 | 519 | continue; | |
| @@ -540,8 +562,8 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event) | |||
| 540 | 562 | struct riscv_pmu *rvpmu = to_riscv_pmu(event->pmu); | |
| 541 | 563 | struct cpu_hw_events *cpuc = this_cpu_ptr(rvpmu->hw_events); | |
| 542 | 564 | struct sbiret ret; | |
| 543 | - | int idx; | |
| 544 | - | uint64_t cbase = 0, cmask = rvpmu->cmask; | |
| 565 | + | int idx, i; | |
| 566 | + | u64 cbase = 0, cmask = 0; | |
| 545 | 567 | unsigned long cflags = 0; | |
| 546 | 568 | ||
| 547 | 569 | cflags = pmu_sbi_get_filter_flags(event); | |
| @@ -562,14 +584,21 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event) | |||
| 562 | 584 | } | |
| 563 | 585 | ||
| 564 | 586 | /* retrieve the available counter index */ | |
| 565 | - | #if defined(CONFIG_32BIT) | |
| 566 | - | ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase, | |
| 567 | - | cmask, cflags, hwc->event_base, hwc->config, | |
| 568 | - | hwc->config >> 32); | |
| 569 | - | #else | |
| 570 | - | ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase, | |
| 571 | - | cmask, cflags, hwc->event_base, hwc->config, 0); | |
| 572 | - | #endif | |
| 587 | + | if (cmask) { | |
| 588 | + | ret = pmu_sbi_ctr_cfg_match(cbase, cmask, cflags, hwc->event_base, | |
| 589 | + | hwc->config); | |
| 590 | + | } else { | |
| 591 | + | ret.error = SBI_ERR_NOT_SUPPORTED; | |
| 592 | + | for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) { | |
| 593 | + | if (!rvpmu->cmask[i]) | |
| 594 | + | continue; | |
| 595 | + | cbase = i * BITS_PER_LONG; | |
| 596 | + | ret = pmu_sbi_ctr_cfg_match(cbase, rvpmu->cmask[i], cflags, | |
| 597 | + | hwc->event_base, hwc->config); | |
| 598 | + | if (!ret.error) | |
| 599 | + | break; | |
| 600 | + | } | |
| 601 | + | } | |
| 573 | 602 | if (ret.error) { | |
| 574 | 603 | pr_debug("Not able to find a counter for event %lx config %llx\n", | |
| 575 | 604 | hwc->event_base, hwc->config); | |
| @@ -577,7 +606,7 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event) | |||
| 577 | 606 | } | |
| 578 | 607 | ||
| 579 | 608 | idx = ret.value; | |
| 580 | - | if (!test_bit(idx, &rvpmu->cmask) || !pmu_ctr_list[idx].value) | |
| 609 | + | if (!test_bit(idx, rvpmu->cmask) || !pmu_ctr_list[idx].value) | |
| 581 | 610 | return -ENOENT; | |
| 582 | 611 | ||
| 583 | 612 | /* Additional sanity check for the counter id */ | |
| @@ -881,7 +910,7 @@ static int pmu_sbi_get_ctrinfo(int nctr, unsigned long *mask) | |||
| 881 | 910 | /* The logical counter ids are not expected to be contiguous */ | |
| 882 | 911 | continue; | |
| 883 | 912 | ||
| 884 | - | *mask |= BIT(i); | |
| 913 | + | set_bit(i, mask); | |
| 885 | 914 | ||
| 886 | 915 | cinfo.value = ret.value; | |
| 887 | 916 | if (cinfo.type == SBI_PMU_CTR_TYPE_FW) | |
| @@ -898,12 +927,19 @@ static int pmu_sbi_get_ctrinfo(int nctr, unsigned long *mask) | |||
| 898 | 927 | ||
| 899 | 928 | static inline void pmu_sbi_stop_all(struct riscv_pmu *pmu) | |
| 900 | 929 | { | |
| 930 | + | int i; | |
| 931 | + | ||
| 901 | 932 | /* | |
| 902 | 933 | * No need to check the error because we are disabling all the counters | |
| 903 | 934 | * which may include counters that are not enabled yet. | |
| 904 | 935 | */ | |
| 905 | - | sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP, | |
| 906 | - | 0, pmu->cmask, SBI_PMU_STOP_FLAG_RESET, 0, 0, 0); | |
| 936 | + | for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) { | |
| 937 | + | if (!pmu->cmask[i]) | |
| 938 | + | continue; | |
| 939 | + | sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP, | |
| 940 | + | i * BITS_PER_LONG, pmu->cmask[i], | |
| 941 | + | SBI_PMU_STOP_FLAG_RESET, 0, 0, 0); | |
| 942 | + | } | |
| 907 | 943 | } | |
| 908 | 944 | ||
| 909 | 945 | static inline void pmu_sbi_stop_hw_ctrs(struct riscv_pmu *pmu) | |
| @@ -1002,7 +1038,7 @@ static inline void pmu_sbi_start_ovf_ctrs_snapshot(struct cpu_hw_events *cpu_hw_ | |||
| 1002 | 1038 | struct riscv_pmu_snapshot_data *sdata = cpu_hw_evt->snapshot_addr; | |
| 1003 | 1039 | ||
| 1004 | 1040 | for_each_set_bit(idx, cpu_hw_evt->used_hw_ctrs, RISCV_MAX_COUNTERS) { | |
| 1005 | - | if (ctr_ovf_mask & BIT(idx)) { | |
| 1041 | + | if (ctr_ovf_mask & BIT_ULL(idx)) { | |
| 1006 | 1042 | event = cpu_hw_evt->events[idx]; | |
| 1007 | 1043 | hwc = &event->hw; | |
| 1008 | 1044 | max_period = riscv_pmu_ctr_get_width_mask(event); | |
| @@ -1050,11 +1086,13 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev) | |||
| 1050 | 1086 | u64 overflowed_ctrs = 0; | |
| 1051 | 1087 | struct cpu_hw_events *cpu_hw_evt = dev; | |
| 1052 | 1088 | u64 start_clock = sched_clock(); | |
| 1053 | - | struct riscv_pmu_snapshot_data *sdata = cpu_hw_evt->snapshot_addr; | |
| 1089 | + | struct riscv_pmu_snapshot_data *sdata; | |
| 1054 | 1090 | ||
| 1055 | 1091 | if (WARN_ON_ONCE(!cpu_hw_evt)) | |
| 1056 | 1092 | return IRQ_NONE; | |
| 1057 | 1093 | ||
| 1094 | + | sdata = cpu_hw_evt->snapshot_addr; | |
| 1095 | + | ||
| 1058 | 1096 | /* Firmware counter don't support overflow yet */ | |
| 1059 | 1097 | fidx = find_first_bit(cpu_hw_evt->used_hw_ctrs, RISCV_MAX_COUNTERS); | |
| 1060 | 1098 | if (fidx == RISCV_MAX_COUNTERS) { | |
| @@ -1109,14 +1147,14 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev) | |||
| 1109 | 1147 | hidx = info->csr - CSR_CYCLE; | |
| 1110 | 1148 | ||
| 1111 | 1149 | /* check if the corresponding bit is set in scountovf or overflow mask in shmem */ | |
| 1112 | - | if (!(overflow & BIT(hidx))) | |
| 1150 | + | if (!(overflow & BIT_ULL(hidx))) | |
| 1113 | 1151 | continue; | |
| 1114 | 1152 | ||
| 1115 | 1153 | /* | |
| 1116 | 1154 | * Keep a track of overflowed counters so that they can be started | |
| 1117 | 1155 | * with updated initial value. | |
| 1118 | 1156 | */ | |
| 1119 | - | overflowed_ctrs |= BIT(lidx); | |
| 1157 | + | overflowed_ctrs |= BIT_ULL(lidx); | |
| 1120 | 1158 | hw_evt = &event->hw; | |
| 1121 | 1159 | /* Update the event states here so that we know the state while reading */ | |
| 1122 | 1160 | hw_evt->state |= PERF_HES_STOPPED; | |
| @@ -1451,7 +1489,7 @@ static int pmu_sbi_device_probe(struct platform_device *pdev) | |||
| 1451 | 1489 | } | |
| 1452 | 1490 | ||
| 1453 | 1491 | /* cache all the information about counters now */ | |
| 1454 | - | if (pmu_sbi_get_ctrinfo(num_counters, &cmask)) | |
| 1492 | + | if (pmu_sbi_get_ctrinfo(num_counters, cmask)) | |
| 1455 | 1493 | goto out_free; | |
| 1456 | 1494 | ||
| 1457 | 1495 | ret = pmu_sbi_setup_irqs(pmu, pdev); | |
| @@ -1464,7 +1502,7 @@ static int pmu_sbi_device_probe(struct platform_device *pdev) | |||
| 1464 | 1502 | ||
| 1465 | 1503 | pmu->pmu.attr_groups = riscv_pmu_attr_groups; | |
| 1466 | 1504 | pmu->pmu.parent = &pdev->dev; | |
| 1467 | - | pmu->cmask = cmask; | |
| 1505 | + | bitmap_copy(pmu->cmask, cmask, RISCV_MAX_COUNTERS); | |
| 1468 | 1506 | pmu->ctr_start = pmu_sbi_ctr_start; | |
| 1469 | 1507 | pmu->ctr_stop = pmu_sbi_ctr_stop; | |
| 1470 | 1508 | pmu->event_map = pmu_sbi_event_map; | |
modified drivers/platform/x86/amd/hsmp/acpi.c
| @@ -720,9 +720,8 @@ static int hsmp_acpi_probe(struct platform_device *pdev) | |||
| 720 | 720 | return -ENODEV; | |
| 721 | 721 | } | |
| 722 | 722 | ||
| 723 | - | hsmp_pdev->sock = kcalloc(hsmp_pdev->num_sockets, | |
| 724 | - | sizeof(*hsmp_pdev->sock), | |
| 725 | - | GFP_KERNEL); | |
| 723 | + | hsmp_pdev->sock = kzalloc_objs(*hsmp_pdev->sock, | |
| 724 | + | hsmp_pdev->num_sockets); | |
| 726 | 725 | if (!hsmp_pdev->sock) | |
| 727 | 726 | return -ENOMEM; | |
| 728 | 727 | ||
modified drivers/platform/x86/amd/pmf/spc.c
| @@ -17,7 +17,6 @@ | |||
| 17 | 17 | #include <linux/units.h> | |
| 18 | 18 | #include "pmf.h" | |
| 19 | 19 | ||
| 20 | - | #ifdef CONFIG_AMD_PMF_DEBUG | |
| 21 | 20 | u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index) | |
| 22 | 21 | { | |
| 23 | 22 | switch (index) { | |
| @@ -31,6 +30,7 @@ u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index) | |||
| 31 | 30 | } | |
| 32 | 31 | EXPORT_SYMBOL(amd_pmf_get_ta_custom_bios_inputs); | |
| 33 | 32 | ||
| 33 | + | #ifdef CONFIG_AMD_PMF_DEBUG | |
| 34 | 34 | void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) | |
| 35 | 35 | { | |
| 36 | 36 | int i; | |
modified drivers/platform/x86/asus-laptop.c
| @@ -1882,7 +1882,7 @@ static int asus_acpi_probe(struct platform_device *pdev) | |||
| 1882 | 1882 | if (result && result != -ENODEV) | |
| 1883 | 1883 | goto fail_pega_rfkill; | |
| 1884 | 1884 | ||
| 1885 | - | result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, | |
| 1885 | + | result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY, | |
| 1886 | 1886 | asus_acpi_notify, asus); | |
| 1887 | 1887 | if (result) | |
| 1888 | 1888 | goto fail_pega_rfkill; | |
| @@ -1912,7 +1912,7 @@ static void asus_acpi_remove(struct platform_device *pdev) | |||
| 1912 | 1912 | { | |
| 1913 | 1913 | struct asus_laptop *asus = platform_get_drvdata(pdev); | |
| 1914 | 1914 | ||
| 1915 | - | acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY, | |
| 1915 | + | acpi_dev_remove_notify_handler(asus->device, ACPI_ALL_NOTIFY, | |
| 1916 | 1916 | asus_acpi_notify); | |
| 1917 | 1917 | asus_backlight_exit(asus); | |
| 1918 | 1918 | asus_rfkill_exit(asus); | |
modified drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
| @@ -96,8 +96,8 @@ int hp_alloc_enumeration_data(void) | |||
| 96 | 96 | ||
| 97 | 97 | if (!bioscfg_drv.enumeration_instances_count) | |
| 98 | 98 | return -EINVAL; | |
| 99 | - | bioscfg_drv.enumeration_data = kvcalloc(bioscfg_drv.enumeration_instances_count, | |
| 100 | - | sizeof(*bioscfg_drv.enumeration_data), GFP_KERNEL); | |
| 99 | + | bioscfg_drv.enumeration_data = kvzalloc_objs(*bioscfg_drv.enumeration_data, | |
| 100 | + | bioscfg_drv.enumeration_instances_count); | |
| 101 | 101 | ||
| 102 | 102 | if (!bioscfg_drv.enumeration_data) { | |
| 103 | 103 | bioscfg_drv.enumeration_instances_count = 0; | |
modified drivers/platform/x86/hp/hp-wmi.c
| @@ -337,7 +337,7 @@ static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = { | |||
| 337 | 337 | }, | |
| 338 | 338 | { | |
| 339 | 339 | .matches = { DMI_MATCH(DMI_BOARD_NAME, "8DD6") }, | |
| 340 | - | .driver_data = (void *)&omen_v1_no_ec_thermal_params, | |
| 340 | + | .driver_data = (void *)&omen_v1_no_ec_board_params, | |
| 341 | 341 | }, | |
| 342 | 342 | { | |
| 343 | 343 | .matches = { DMI_MATCH(DMI_BOARD_NAME, "8E35") }, | |
modified drivers/platform/x86/intel/pmc/pwrm_telemetry.c
| @@ -93,8 +93,7 @@ acpi_disc_t pmc_parse_telem_dsd(union acpi_object *obj, | |||
| 93 | 93 | if (header->num_entries != num_regions) | |
| 94 | 94 | return ERR_PTR(-EINVAL); | |
| 95 | 95 | ||
| 96 | - | acpi_disc_t disc __free(kfree) = kmalloc_array(num_regions, sizeof(*disc), | |
| 97 | - | GFP_KERNEL); | |
| 96 | + | acpi_disc_t disc __free(kfree) = kmalloc_objs(*disc, num_regions); | |
| 98 | 97 | if (!disc) | |
| 99 | 98 | return ERR_PTR(-ENOMEM); | |
| 100 | 99 | ||
modified drivers/platform/x86/x86-android-tablets/core.c
| @@ -156,7 +156,6 @@ static struct platform_device **pdevs; | |||
| 156 | 156 | static struct serdev_device **serdevs; | |
| 157 | 157 | static const struct software_node **gpio_button_swnodes; | |
| 158 | 158 | static const struct software_node **swnode_group; | |
| 159 | - | static const struct software_node **gpiochip_node_group; | |
| 160 | 159 | static void (*exit_handler)(void); | |
| 161 | 160 | ||
| 162 | 161 | static __init struct i2c_adapter * | |
| @@ -362,11 +361,21 @@ static const struct software_node *cherryview_gpiochip_node_group[] = { | |||
| 362 | 361 | NULL | |
| 363 | 362 | }; | |
| 364 | 363 | ||
| 364 | + | const struct software_node crystalcove_gpiochip_node = { | |
| 365 | + | .name = "INT33FD:00", | |
| 366 | + | }; | |
| 367 | + | ||
| 368 | + | static const struct software_node *crystalcove_gpiochip_node_group[] = { | |
| 369 | + | &crystalcove_gpiochip_node, | |
| 370 | + | NULL | |
| 371 | + | }; | |
| 372 | + | ||
| 365 | 373 | static void gpio_secondary_unset(void *data) | |
| 366 | 374 | { | |
| 367 | 375 | struct device *dev = data; | |
| 368 | 376 | ||
| 369 | 377 | set_secondary_fwnode(dev, NULL); | |
| 378 | + | put_device(dev); | |
| 370 | 379 | } | |
| 371 | 380 | ||
| 372 | 381 | static void gpio_secondary_unregister_node_group(void *data) | |
| @@ -376,26 +385,28 @@ static void gpio_secondary_unregister_node_group(void *data) | |||
| 376 | 385 | software_node_unregister_node_group(nodes); | |
| 377 | 386 | } | |
| 378 | 387 | ||
| 379 | - | static int gpio_secondary_fwnode_init(struct device *parent) | |
| 388 | + | static int gpio_secondary_fwnode_init(struct device *parent, | |
| 389 | + | const struct software_node * const *node_group) | |
| 380 | 390 | { | |
| 381 | 391 | const struct software_node *const *swnode; | |
| 382 | 392 | struct fwnode_handle *fwnode; | |
| 393 | + | struct device *phys_dev; | |
| 383 | 394 | int ret; | |
| 384 | 395 | ||
| 385 | - | if (!gpiochip_node_group) | |
| 396 | + | if (!node_group) | |
| 386 | 397 | return 0; | |
| 387 | 398 | ||
| 388 | - | ret = software_node_register_node_group(gpiochip_node_group); | |
| 399 | + | ret = software_node_register_node_group(node_group); | |
| 389 | 400 | if (ret) | |
| 390 | 401 | return ret; | |
| 391 | 402 | ||
| 392 | 403 | ret = devm_add_action_or_reset(parent, | |
| 393 | 404 | gpio_secondary_unregister_node_group, | |
| 394 | - | gpiochip_node_group); | |
| 405 | + | (void *)node_group); | |
| 395 | 406 | if (ret) | |
| 396 | 407 | return ret; | |
| 397 | 408 | ||
| 398 | - | for (swnode = gpiochip_node_group; *swnode; swnode++) { | |
| 409 | + | for (swnode = node_group; *swnode; swnode++) { | |
| 399 | 410 | struct device *dev __free(put_device) = | |
| 400 | 411 | acpi_bus_find_device_by_name((*swnode)->name); | |
| 401 | 412 | if (!dev) | |
| @@ -407,9 +418,15 @@ static int gpio_secondary_fwnode_init(struct device *parent) | |||
| 407 | 418 | if (WARN_ON(!fwnode)) | |
| 408 | 419 | return -ENOENT; | |
| 409 | 420 | ||
| 410 | - | set_secondary_fwnode(dev, fwnode); | |
| 421 | + | phys_dev = acpi_get_first_physical_node(to_acpi_device(dev)); | |
| 422 | + | if (!phys_dev) | |
| 423 | + | return dev_err_probe(parent, -ENODEV, | |
| 424 | + | "No physical device for ACPI GPIO dev: %pfwP\n", | |
| 425 | + | fwnode); | |
| 426 | + | ||
| 427 | + | set_secondary_fwnode(phys_dev, fwnode); | |
| 411 | 428 | ||
| 412 | - | ret = devm_add_action_or_reset(parent, gpio_secondary_unset, dev); | |
| 429 | + | ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(phys_dev)); | |
| 413 | 430 | if (ret) | |
| 414 | 431 | return ret; | |
| 415 | 432 | } | |
| @@ -452,6 +469,7 @@ static void x86_android_tablet_remove(struct platform_device *pdev) | |||
| 452 | 469 | ||
| 453 | 470 | static __init int x86_android_tablet_probe(struct platform_device *pdev) | |
| 454 | 471 | { | |
| 472 | + | const struct software_node * const *gpiochip_node_group; | |
| 455 | 473 | const struct x86_dev_info *dev_info; | |
| 456 | 474 | const struct dmi_system_id *id; | |
| 457 | 475 | int i, ret = 0; | |
| @@ -483,12 +501,20 @@ static __init int x86_android_tablet_probe(struct platform_device *pdev) | |||
| 483 | 501 | break; | |
| 484 | 502 | } | |
| 485 | 503 | ||
| 486 | - | ret = gpio_secondary_fwnode_init(&pdev->dev); | |
| 504 | + | ret = gpio_secondary_fwnode_init(&pdev->dev, gpiochip_node_group); | |
| 487 | 505 | if (ret) { | |
| 488 | 506 | x86_android_tablet_remove(pdev); | |
| 489 | 507 | return ret; | |
| 490 | 508 | } | |
| 491 | 509 | ||
| 510 | + | if (dev_info->has_crystalcove) { | |
| 511 | + | ret = gpio_secondary_fwnode_init(&pdev->dev, crystalcove_gpiochip_node_group); | |
| 512 | + | if (ret) { | |
| 513 | + | x86_android_tablet_remove(pdev); | |
| 514 | + | return ret; | |
| 515 | + | } | |
| 516 | + | } | |
| 517 | + | ||
| 492 | 518 | ret = software_node_register_node_group(dev_info->swnode_group); | |
| 493 | 519 | if (ret) { | |
| 494 | 520 | x86_android_tablet_remove(pdev); | |
modified drivers/platform/x86/x86-android-tablets/lenovo.c
| @@ -61,13 +61,6 @@ static struct lp855x_platform_data lenovo_lp8557_reg_only_pdata = { | |||
| 61 | 61 | .initial_brightness = 128, | |
| 62 | 62 | }; | |
| 63 | 63 | ||
| 64 | - | static const struct software_node arizona_gpiochip_node = { | |
| 65 | - | .name = "arizona", | |
| 66 | - | }; | |
| 67 | - | ||
| 68 | - | static const struct software_node crystalcove_gpiochip_node = { | |
| 69 | - | .name = "gpio_crystalcove", | |
| 70 | - | }; | |
| 71 | 64 | ||
| 72 | 65 | /* Lenovo Yoga Book X90F / X90L's Android factory image has everything hardcoded */ | |
| 73 | 66 | ||
| @@ -416,15 +409,17 @@ static const struct platform_device_info lenovo_yoga_tab2_830_1050_pdevs[] __ini | |||
| 416 | 409 | ||
| 417 | 410 | #define LENOVO_YOGA_TAB2_830_1050_CODEC_NAME "spi-10WM5102:00" | |
| 418 | 411 | ||
| 412 | + | static const struct software_node lenovo_yoga_tab2_830_1050_wm5102; | |
| 413 | + | ||
| 419 | 414 | static const struct property_entry lenovo_yoga_tab2_830_1050_wm1502_props[] = { | |
| 420 | 415 | PROPERTY_ENTRY_GPIO("reset-gpios", | |
| 421 | 416 | &crystalcove_gpiochip_node, 3, GPIO_ACTIVE_HIGH), | |
| 422 | 417 | PROPERTY_ENTRY_GPIO("wlf,ldoena-gpios", | |
| 423 | 418 | &baytrail_gpiochip_nodes[1], 23, GPIO_ACTIVE_HIGH), | |
| 424 | 419 | PROPERTY_ENTRY_GPIO("wlf,spkvdd-ena-gpios", | |
| 425 | - | &arizona_gpiochip_node, 2, GPIO_ACTIVE_HIGH), | |
| 420 | + | &lenovo_yoga_tab2_830_1050_wm5102, 2, GPIO_ACTIVE_HIGH), | |
| 426 | 421 | PROPERTY_ENTRY_GPIO("wlf,micd-pol-gpios", | |
| 427 | - | &arizona_gpiochip_node, 4, GPIO_ACTIVE_LOW), | |
| 422 | + | &lenovo_yoga_tab2_830_1050_wm5102, 4, GPIO_ACTIVE_LOW), | |
| 428 | 423 | { } | |
| 429 | 424 | }; | |
| 430 | 425 | ||
| @@ -432,14 +427,6 @@ static const struct software_node lenovo_yoga_tab2_830_1050_wm5102 = { | |||
| 432 | 427 | .properties = lenovo_yoga_tab2_830_1050_wm1502_props, | |
| 433 | 428 | }; | |
| 434 | 429 | ||
| 435 | - | static const struct software_node *lenovo_yoga_tab2_830_1050_swnodes[] = { | |
| 436 | - | &crystalcove_gpiochip_node, | |
| 437 | - | &arizona_gpiochip_node, | |
| 438 | - | &lenovo_yoga_tab2_830_1050_wm5102, | |
| 439 | - | &generic_lipo_hv_4v35_battery_node, | |
| 440 | - | NULL | |
| 441 | - | }; | |
| 442 | - | ||
| 443 | 430 | static int __init lenovo_yoga_tab2_830_1050_init(struct device *dev); | |
| 444 | 431 | static void lenovo_yoga_tab2_830_1050_exit(void); | |
| 445 | 432 | ||
| @@ -455,8 +442,9 @@ const struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initconst = { | |||
| 455 | 442 | .pdev_info = lenovo_yoga_tab2_830_1050_pdevs, | |
| 456 | 443 | .pdev_count = ARRAY_SIZE(lenovo_yoga_tab2_830_1050_pdevs), | |
| 457 | 444 | .gpio_button_swnodes = lenovo_yoga_tab2_830_1050_lid_swnodes, | |
| 458 | - | .swnode_group = lenovo_yoga_tab2_830_1050_swnodes, | |
| 445 | + | .swnode_group = generic_lipo_hv_4v35_battery_swnodes, | |
| 459 | 446 | .modules = lenovo_yoga_tab2_modules, | |
| 447 | + | .has_crystalcove = true, | |
| 460 | 448 | .gpiochip_type = X86_GPIOCHIP_BAYTRAIL, | |
| 461 | 449 | .init = lenovo_yoga_tab2_830_1050_init, | |
| 462 | 450 | .exit = lenovo_yoga_tab2_830_1050_exit, | |
| @@ -800,8 +788,9 @@ const struct x86_dev_info lenovo_yoga_tab2_1380_info __initconst = { | |||
| 800 | 788 | .pdev_info = lenovo_yoga_tab2_1380_pdevs, | |
| 801 | 789 | .pdev_count = ARRAY_SIZE(lenovo_yoga_tab2_1380_pdevs), | |
| 802 | 790 | .gpio_button_swnodes = lenovo_yoga_tab2_830_1050_lid_swnodes, | |
| 803 | - | .swnode_group = lenovo_yoga_tab2_830_1050_swnodes, | |
| 791 | + | .swnode_group = generic_lipo_hv_4v35_battery_swnodes, | |
| 804 | 792 | .modules = lenovo_yoga_tab2_modules, | |
| 793 | + | .has_crystalcove = true, | |
| 805 | 794 | .gpiochip_type = X86_GPIOCHIP_BAYTRAIL, | |
| 806 | 795 | .init = lenovo_yoga_tab2_1380_init, | |
| 807 | 796 | .exit = lenovo_yoga_tab2_830_1050_exit, | |
| @@ -985,13 +974,15 @@ static struct arizona_pdata lenovo_yt3_wm5102_pdata = { | |||
| 985 | 974 | }, | |
| 986 | 975 | }; | |
| 987 | 976 | ||
| 977 | + | static const struct software_node lenovo_yt3_wm5102; | |
| 978 | + | ||
| 988 | 979 | static const struct property_entry lenovo_yt3_wm1502_props[] = { | |
| 989 | 980 | PROPERTY_ENTRY_GPIO("wlf,spkvdd-ena-gpios", | |
| 990 | 981 | &cherryview_gpiochip_nodes[0], 75, GPIO_ACTIVE_HIGH), | |
| 991 | 982 | PROPERTY_ENTRY_GPIO("wlf,ldoena-gpios", | |
| 992 | 983 | &cherryview_gpiochip_nodes[0], 81, GPIO_ACTIVE_HIGH), | |
| 993 | 984 | PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[0], 82, GPIO_ACTIVE_HIGH), | |
| 994 | - | PROPERTY_ENTRY_GPIO("wlf,micd-pol-gpios", &arizona_gpiochip_node, 2, GPIO_ACTIVE_HIGH), | |
| 985 | + | PROPERTY_ENTRY_GPIO("wlf,micd-pol-gpios", &lenovo_yt3_wm5102, 2, GPIO_ACTIVE_HIGH), | |
| 995 | 986 | { } | |
| 996 | 987 | }; | |
| 997 | 988 | ||
| @@ -1000,11 +991,6 @@ static const struct software_node lenovo_yt3_wm5102 = { | |||
| 1000 | 991 | .name = "wm5102", | |
| 1001 | 992 | }; | |
| 1002 | 993 | ||
| 1003 | - | static const struct software_node *lenovo_yt3_swnodes[] = { | |
| 1004 | - | &arizona_gpiochip_node, | |
| 1005 | - | &lenovo_yt3_wm5102, | |
| 1006 | - | NULL | |
| 1007 | - | }; | |
| 1008 | 994 | ||
| 1009 | 995 | static const struct x86_spi_dev_info lenovo_yt3_spi_devs[] __initconst = { | |
| 1010 | 996 | { | |
| @@ -1072,7 +1058,6 @@ const struct x86_dev_info lenovo_yt3_info __initconst = { | |||
| 1072 | 1058 | .i2c_client_count = ARRAY_SIZE(lenovo_yt3_i2c_clients), | |
| 1073 | 1059 | .spi_dev_info = lenovo_yt3_spi_devs, | |
| 1074 | 1060 | .spi_dev_count = ARRAY_SIZE(lenovo_yt3_spi_devs), | |
| 1075 | - | .swnode_group = lenovo_yt3_swnodes, | |
| 1076 | 1061 | .modules = lenovo_yt3_modules, | |
| 1077 | 1062 | .gpiochip_type = X86_GPIOCHIP_CHERRYVIEW, | |
| 1078 | 1063 | .init = lenovo_yt3_init, | |
modified drivers/platform/x86/x86-android-tablets/x86-android-tablets.h
| @@ -96,6 +96,7 @@ struct x86_dev_info { | |||
| 96 | 96 | int (*init)(struct device *dev); | |
| 97 | 97 | void (*exit)(void); | |
| 98 | 98 | bool use_pci; | |
| 99 | + | bool has_crystalcove; | |
| 99 | 100 | enum x86_gpiochip_type gpiochip_type; | |
| 100 | 101 | }; | |
| 101 | 102 | ||
| @@ -107,6 +108,7 @@ int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data); | |||
| 107 | 108 | /* Software nodes representing GPIO chips used by various tablets */ | |
| 108 | 109 | extern const struct software_node baytrail_gpiochip_nodes[]; | |
| 109 | 110 | extern const struct software_node cherryview_gpiochip_nodes[]; | |
| 111 | + | extern const struct software_node crystalcove_gpiochip_node; | |
| 110 | 112 | ||
| 111 | 113 | /* | |
| 112 | 114 | * Extern declarations of x86_dev_info structs so there can be a single | |
modified drivers/pmdomain/core.c
| @@ -2962,7 +2962,7 @@ int of_genpd_add_child_ids(struct device_node *np, | |||
| 2962 | 2962 | return -EINVAL; | |
| 2963 | 2963 | ||
| 2964 | 2964 | /* Allocate tracking array for error unwind (parent/child pairs) */ | |
| 2965 | - | pairs = kmalloc_array(count * 2, sizeof(*pairs), GFP_KERNEL); | |
| 2965 | + | pairs = kmalloc_objs(*pairs, count * 2); | |
| 2966 | 2966 | if (!pairs) | |
| 2967 | 2967 | return -ENOMEM; | |
| 2968 | 2968 | ||
modified drivers/pmdomain/mediatek/Kconfig
| @@ -43,9 +43,12 @@ config MTK_MFG_PM_DOMAIN | |||
| 43 | 43 | This driver is required for the Mali GPU to work at all on MT8196 and | |
| 44 | 44 | MT6991. | |
| 45 | 45 | ||
| 46 | + | endmenu | |
| 47 | + | ||
| 46 | 48 | config AIROHA_CPU_PM_DOMAIN | |
| 47 | 49 | tristate "Airoha CPU power domain" | |
| 48 | 50 | default ARCH_AIROHA | |
| 51 | + | depends on ARCH_AIROHA || COMPILE_TEST | |
| 49 | 52 | depends on HAVE_ARM_SMCCC | |
| 50 | 53 | depends on PM | |
| 51 | 54 | select PM_GENERIC_DOMAINS | |
| @@ -54,5 +57,3 @@ config AIROHA_CPU_PM_DOMAIN | |||
| 54 | 57 | ||
| 55 | 58 | CPU frequency and power is controlled by ATF with SMC command to | |
| 56 | 59 | set performance states. | |
| 57 | - | ||
| 58 | - | endmenu | |
modified drivers/pmdomain/qcom/rpmhpd.c
| @@ -241,13 +241,9 @@ static struct rpmhpd *eliza_rpmhpds[] = { | |||
| 241 | 241 | [RPMHPD_GFX] = &gfx, | |
| 242 | 242 | [RPMHPD_LCX] = &lcx, | |
| 243 | 243 | [RPMHPD_LMX] = &lmx, | |
| 244 | - | [RPMHPD_MMCX] = &mmcx, | |
| 245 | - | [RPMHPD_MMCX_AO] = &mmcx_ao, | |
| 246 | 244 | [RPMHPD_MSS] = &mss, | |
| 247 | 245 | [RPMHPD_MX] = &mx, | |
| 248 | 246 | [RPMHPD_MX_AO] = &mx_ao, | |
| 249 | - | [RPMHPD_MXC] = &mxc, | |
| 250 | - | [RPMHPD_MXC_AO] = &mxc_ao, | |
| 251 | 247 | [RPMHPD_NSP] = &nsp, | |
| 252 | 248 | }; | |
| 253 | 249 | ||
modified drivers/power/reset/reboot-mode.c
| @@ -122,14 +122,14 @@ static int reboot_mode_create_device(struct reboot_mode_driver *reboot) | |||
| 122 | 122 | struct mode_info *info; | |
| 123 | 123 | int ret; | |
| 124 | 124 | ||
| 125 | - | priv = kzalloc_obj(*priv, GFP_KERNEL); | |
| 125 | + | priv = kzalloc_obj(*priv); | |
| 126 | 126 | if (!priv) | |
| 127 | 127 | return -ENOMEM; | |
| 128 | 128 | ||
| 129 | 129 | INIT_LIST_HEAD(&priv->head); | |
| 130 | 130 | ||
| 131 | 131 | list_for_each_entry(info, &reboot->head, list) { | |
| 132 | - | sysfs_info = kzalloc_obj(*sysfs_info, GFP_KERNEL); | |
| 132 | + | sysfs_info = kzalloc_obj(*sysfs_info); | |
| 133 | 133 | if (!sysfs_info) { | |
| 134 | 134 | ret = -ENOMEM; | |
| 135 | 135 | goto error; | |
| @@ -188,7 +188,7 @@ int reboot_mode_register(struct reboot_mode_driver *reboot) | |||
| 188 | 188 | continue; | |
| 189 | 189 | } | |
| 190 | 190 | ||
| 191 | - | info = kzalloc_obj(*info, GFP_KERNEL); | |
| 191 | + | info = kzalloc_obj(*info); | |
| 192 | 192 | if (!info) { | |
| 193 | 193 | ret = -ENOMEM; | |
| 194 | 194 | goto error; | |
modified drivers/power/sequencing/core.c
| @@ -480,7 +480,7 @@ pwrseq_device_register(const struct pwrseq_config *config) | |||
| 480 | 480 | !config->targets[0]) | |
| 481 | 481 | return ERR_PTR(-EINVAL); | |
| 482 | 482 | ||
| 483 | - | pwrseq = kzalloc(sizeof(*pwrseq), GFP_KERNEL); | |
| 483 | + | pwrseq = kzalloc_obj(*pwrseq); | |
| 484 | 484 | if (!pwrseq) | |
| 485 | 485 | return ERR_PTR(-ENOMEM); | |
| 486 | 486 | ||
modified drivers/power/sequencing/pwrseq-pcie-m2.c
| @@ -291,7 +291,7 @@ static int pwrseq_pcie_m2_create_serdev_one(struct pwrseq_pcie_m2_ctx *ctx, | |||
| 291 | 291 | } | |
| 292 | 292 | } | |
| 293 | 293 | ||
| 294 | - | pci_dev = kzalloc(sizeof(*pci_dev), GFP_KERNEL); | |
| 294 | + | pci_dev = kzalloc_obj(*pci_dev); | |
| 295 | 295 | if (!pci_dev) { | |
| 296 | 296 | ret = -ENOMEM; | |
| 297 | 297 | goto err_put_ctrl; | |
modified drivers/power/supply/power_supply_core.c
| @@ -904,7 +904,7 @@ int power_supply_get_battery_info(struct power_supply *psy, | |||
| 904 | 904 | goto out_put_node; | |
| 905 | 905 | } | |
| 906 | 906 | ||
| 907 | - | u32 *propdata __free(kfree) = kcalloc(proplen, sizeof(*propdata), GFP_KERNEL); | |
| 907 | + | u32 *propdata __free(kfree) = kzalloc_objs(*propdata, proplen); | |
| 908 | 908 | if (!propdata) { | |
| 909 | 909 | power_supply_put_battery_info(psy, info); | |
| 910 | 910 | err = -EINVAL; | |
| @@ -944,7 +944,7 @@ int power_supply_get_battery_info(struct power_supply *psy, | |||
| 944 | 944 | goto out_put_node; | |
| 945 | 945 | } | |
| 946 | 946 | ||
| 947 | - | propdata = kcalloc(proplen, sizeof(*propdata), GFP_KERNEL); | |
| 947 | + | propdata = kzalloc_objs(*propdata, proplen); | |
| 948 | 948 | if (!propdata) { | |
| 949 | 949 | power_supply_put_battery_info(psy, info); | |
| 950 | 950 | err = -ENOMEM; | |
| @@ -1726,7 +1726,7 @@ __power_supply_register(struct device *parent, | |||
| 1726 | 1726 | pr_warn("%s: Expected proper parent device for '%s'\n", | |
| 1727 | 1727 | __func__, desc->name); | |
| 1728 | 1728 | ||
| 1729 | - | psy = kzalloc(sizeof(*psy), GFP_KERNEL); | |
| 1729 | + | psy = kzalloc_obj(*psy); | |
| 1730 | 1730 | if (!psy) | |
| 1731 | 1731 | return ERR_PTR(-ENOMEM); | |
| 1732 | 1732 | ||
modified drivers/ptp/ptp_chardev.c
| @@ -136,7 +136,7 @@ int ptp_open(struct posix_clock_context *pccontext, fmode_t fmode) | |||
| 136 | 136 | struct timestamp_event_queue *queue; | |
| 137 | 137 | char debugfsname[32]; | |
| 138 | 138 | ||
| 139 | - | queue = kzalloc(sizeof(*queue), GFP_KERNEL); | |
| 139 | + | queue = kzalloc_obj(*queue); | |
| 140 | 140 | if (!queue) | |
| 141 | 141 | return -EINVAL; | |
| 142 | 142 | queue->mask = bitmap_alloc(PTP_MAX_CHANNELS, GFP_KERNEL); | |
modified drivers/ras/amd/atl/core.c
| @@ -190,7 +190,6 @@ static const struct x86_cpu_id amd_atl_cpuids[] = { | |||
| 190 | 190 | X86_MATCH_FEATURE(X86_FEATURE_ZEN, NULL), | |
| 191 | 191 | { } | |
| 192 | 192 | }; | |
| 193 | - | MODULE_DEVICE_TABLE(x86cpu, amd_atl_cpuids); | |
| 194 | 193 | ||
| 195 | 194 | static int __init amd_atl_init(void) | |
| 196 | 195 | { | |
modified drivers/ras/amd/atl/map.c
| @@ -771,9 +771,5 @@ int get_address_map(struct addr_ctx *ctx) | |||
| 771 | 771 | ||
| 772 | 772 | dump_address_map(&ctx->map); | |
| 773 | 773 | ||
| 774 | - | ret = validate_address_map(ctx); | |
| 775 | - | if (ret) | |
| 776 | - | return ret; | |
| 777 | - | ||
| 778 | - | return ret; | |
| 774 | + | return validate_address_map(ctx); | |
| 779 | 775 | } | |
modified drivers/regulator/pf1550-regulator.c
| @@ -283,63 +283,61 @@ static struct pf1550_desc pf1550_regulators[] = { | |||
| 283 | 283 | PF_LDO1(PF1550, "ldo3", LDO3, 0x1f, pf1550_ldo13_volts), | |
| 284 | 284 | }; | |
| 285 | 285 | ||
| 286 | + | /* | |
| 287 | + | * The _LS interrupts indicate an over-current event. The _HS | |
| 288 | + | * interrupts, which are more accurate and can detect catastrophic | |
| 289 | + | * faults, issue an error event. The current limit FAULT interrupt is | |
| 290 | + | * similar to the _HS. | |
| 291 | + | */ | |
| 292 | + | static const struct pf1550_regulator_irq { | |
| 293 | + | unsigned int event; | |
| 294 | + | u8 id; | |
| 295 | + | } pf1550_regulator_irqs[] = { | |
| 296 | + | [PF1550_PMIC_IRQ_SW1_LS] = { REGULATOR_EVENT_OVER_CURRENT_WARN, PF1550_SW1 }, | |
| 297 | + | [PF1550_PMIC_IRQ_SW2_LS] = { REGULATOR_EVENT_OVER_CURRENT_WARN, PF1550_SW2 }, | |
| 298 | + | [PF1550_PMIC_IRQ_SW3_LS] = { REGULATOR_EVENT_OVER_CURRENT_WARN, PF1550_SW3 }, | |
| 299 | + | [PF1550_PMIC_IRQ_SW1_HS] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_SW1 }, | |
| 300 | + | [PF1550_PMIC_IRQ_SW2_HS] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_SW2 }, | |
| 301 | + | [PF1550_PMIC_IRQ_SW3_HS] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_SW3 }, | |
| 302 | + | [PF1550_PMIC_IRQ_LDO1_FAULT] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_LDO1 }, | |
| 303 | + | [PF1550_PMIC_IRQ_LDO2_FAULT] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_LDO2 }, | |
| 304 | + | [PF1550_PMIC_IRQ_LDO3_FAULT] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_LDO3 }, | |
| 305 | + | }; | |
| 306 | + | ||
| 286 | 307 | static irqreturn_t pf1550_regulator_irq_handler(int irq, void *data) | |
| 287 | 308 | { | |
| 309 | + | const struct pf1550_regulator_irq *map; | |
| 288 | 310 | struct pf1550_regulator_info *info = data; | |
| 289 | 311 | struct device *dev = info->dev; | |
| 290 | 312 | struct platform_device *pdev = to_platform_device(dev); | |
| 291 | 313 | int i, irq_type = -1; | |
| 292 | - | unsigned int event; | |
| 293 | 314 | ||
| 294 | 315 | for (i = 0; i < PF1550_REGULATOR_IRQ_NR; i++) | |
| 295 | 316 | if (irq == platform_get_irq(pdev, i)) | |
| 296 | 317 | irq_type = i; | |
| 297 | 318 | ||
| 298 | - | switch (irq_type) { | |
| 299 | - | /* The _LS interrupts indicate over-current event. The _HS interrupts | |
| 300 | - | * which are more accurate and can detect catastrophic faults, issue | |
| 301 | - | * an error event. The current limit FAULT interrupt is similar to the | |
| 302 | - | * _HS' | |
| 303 | - | */ | |
| 304 | - | case PF1550_PMIC_IRQ_SW1_LS: | |
| 305 | - | case PF1550_PMIC_IRQ_SW2_LS: | |
| 306 | - | case PF1550_PMIC_IRQ_SW3_LS: | |
| 307 | - | event = REGULATOR_EVENT_OVER_CURRENT_WARN; | |
| 308 | - | for (i = 0; i < PF1550_MAX_REGULATOR; i++) | |
| 309 | - | if (!strcmp(rdev_get_name(info->rdevs[i]), "SW3")) | |
| 310 | - | regulator_notifier_call_chain(info->rdevs[i], | |
| 311 | - | event, NULL); | |
| 312 | - | break; | |
| 313 | - | case PF1550_PMIC_IRQ_SW1_HS: | |
| 314 | - | case PF1550_PMIC_IRQ_SW2_HS: | |
| 315 | - | case PF1550_PMIC_IRQ_SW3_HS: | |
| 316 | - | event = REGULATOR_EVENT_OVER_CURRENT; | |
| 317 | - | for (i = 0; i < PF1550_MAX_REGULATOR; i++) | |
| 318 | - | if (!strcmp(rdev_get_name(info->rdevs[i]), "SW3")) | |
| 319 | - | regulator_notifier_call_chain(info->rdevs[i], | |
| 320 | - | event, NULL); | |
| 321 | - | break; | |
| 322 | - | case PF1550_PMIC_IRQ_LDO1_FAULT: | |
| 323 | - | case PF1550_PMIC_IRQ_LDO2_FAULT: | |
| 324 | - | case PF1550_PMIC_IRQ_LDO3_FAULT: | |
| 325 | - | event = REGULATOR_EVENT_OVER_CURRENT; | |
| 326 | - | for (i = 0; i < PF1550_MAX_REGULATOR; i++) | |
| 327 | - | if (!strcmp(rdev_get_name(info->rdevs[i]), "LDO3")) | |
| 328 | - | regulator_notifier_call_chain(info->rdevs[i], | |
| 329 | - | event, NULL); | |
| 330 | - | break; | |
| 331 | - | case PF1550_PMIC_IRQ_TEMP_110: | |
| 332 | - | case PF1550_PMIC_IRQ_TEMP_125: | |
| 333 | - | event = REGULATOR_EVENT_OVER_TEMP; | |
| 319 | + | /* The die temperature concerns every rail. */ | |
| 320 | + | if (irq_type == PF1550_PMIC_IRQ_TEMP_110 || | |
| 321 | + | irq_type == PF1550_PMIC_IRQ_TEMP_125) { | |
| 334 | 322 | for (i = 0; i < PF1550_MAX_REGULATOR; i++) | |
| 335 | 323 | regulator_notifier_call_chain(info->rdevs[i], | |
| 336 | - | event, NULL); | |
| 337 | - | break; | |
| 338 | - | default: | |
| 339 | - | dev_err(dev, "regulator interrupt: irq %d occurred\n", | |
| 340 | - | irq_type); | |
| 324 | + | REGULATOR_EVENT_OVER_TEMP, | |
| 325 | + | NULL); | |
| 326 | + | return IRQ_HANDLED; | |
| 327 | + | } | |
| 328 | + | ||
| 329 | + | if (irq_type < 0 || irq_type >= (int)ARRAY_SIZE(pf1550_regulator_irqs)) { | |
| 330 | + | dev_err(dev, "regulator interrupt: irq %d occurred\n", irq_type); | |
| 331 | + | return IRQ_HANDLED; | |
| 341 | 332 | } | |
| 342 | 333 | ||
| 334 | + | map = &pf1550_regulator_irqs[irq_type]; | |
| 335 | + | ||
| 336 | + | for (i = 0; i < PF1550_MAX_REGULATOR; i++) | |
| 337 | + | if (rdev_get_id(info->rdevs[i]) == map->id) | |
| 338 | + | regulator_notifier_call_chain(info->rdevs[i], | |
| 339 | + | map->event, NULL); | |
| 340 | + | ||
| 343 | 341 | return IRQ_HANDLED; | |
| 344 | 342 | } | |
| 345 | 343 | ||
modified drivers/s390/block/dasd.c
| @@ -87,7 +87,7 @@ struct dasd_device *dasd_alloc_device(void) | |||
| 87 | 87 | { | |
| 88 | 88 | struct dasd_device *device; | |
| 89 | 89 | ||
| 90 | - | device = kzalloc_obj(struct dasd_device, GFP_KERNEL); | |
| 90 | + | device = kzalloc_obj(struct dasd_device); | |
| 91 | 91 | if (!device) | |
| 92 | 92 | return ERR_PTR(-ENOMEM); | |
| 93 | 93 | ||
modified drivers/s390/crypto/zcrypt_cca_key.h
| @@ -219,6 +219,7 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p) | |||
| 219 | 219 | copy_from_user(key->key_parts + 2 * long_len + 2 * short_len, | |
| 220 | 220 | crt->u_mult_inv, long_len)) | |
| 221 | 221 | return -EFAULT; | |
| 222 | + | memset(key->key_parts + 3 * long_len + 2 * short_len, 0, pad_len); | |
| 222 | 223 | memset(key->key_parts + 3 * long_len + 2 * short_len + pad_len, | |
| 223 | 224 | 0xff, crt->inputdatalength); | |
| 224 | 225 | pub = (struct cca_public_sec *)(key->key_parts + key_len); | |
modified drivers/s390/crypto/zcrypt_ccamisc.c
| @@ -1158,8 +1158,21 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, | |||
| 1158 | 1158 | ||
| 1159 | 1159 | /* do not check the key here, it may be incomplete */ | |
| 1160 | 1160 | ||
| 1161 | - | /* copy the vlsc key token back */ | |
| 1161 | + | /* | |
| 1162 | + | * Copy the vlsc key token back. | |
| 1163 | + | * The available space in the destination (key_token) and the source | |
| 1164 | + | * (t) buffer is always larger as the valid range of prepparm->kb.len. | |
| 1165 | + | * Validate t->len by comparing it with the length information in the | |
| 1166 | + | * param block of the request (prepparm->kb.len) | |
| 1167 | + | * The value range of prepparm->kb.len has been checked above. | |
| 1168 | + | */ | |
| 1162 | 1169 | t = (struct cipherkeytoken *)prepparm->kb.tlv1.key_token; | |
| 1170 | + | if (t->len != prepparm->kb.len - 3 * sizeof(uint16_t)) { | |
| 1171 | + | ZCRYPT_DBF_ERR("%s reply with invalid key_token length %u\n", | |
| 1172 | + | __func__, t->len); | |
| 1173 | + | rc = -EIO; | |
| 1174 | + | goto out; | |
| 1175 | + | } | |
| 1163 | 1176 | memcpy(key_token, t, t->len); | |
| 1164 | 1177 | *key_token_size = t->len; | |
| 1165 | 1178 | ||
modified drivers/s390/net/ctcm_mpc.c
| @@ -826,7 +826,7 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg) | |||
| 826 | 826 | ||
| 827 | 827 | fsm_deltimer(&grp->timer); | |
| 828 | 828 | ||
| 829 | - | if (grp->saved_xid2->xid2_flag2 == 0x40) { | |
| 829 | + | if (priv->xid->xid2_flag2 == 0x40) { | |
| 830 | 830 | priv->xid->xid2_flag2 = 0x00; | |
| 831 | 831 | if (grp->estconnfunc) { | |
| 832 | 832 | grp->estconnfunc(grp->port_num, 1, | |
| @@ -1636,7 +1636,6 @@ done: | |||
| 1636 | 1636 | "The XID used in the MPC protocol is not valid, " | |
| 1637 | 1637 | "rc = %d\n", rc); | |
| 1638 | 1638 | priv->xid->xid2_flag2 = 0x40; | |
| 1639 | - | grp->saved_xid2->xid2_flag2 = 0x40; | |
| 1640 | 1639 | } | |
| 1641 | 1640 | ||
| 1642 | 1641 | return rc; | |
modified drivers/s390/net/ism_drv.c
| @@ -231,6 +231,7 @@ static void ism_free_dmb(struct ism_dev *ism, struct dibs_dmb *dmb) | |||
| 231 | 231 | dma_unmap_page(&ism->pdev->dev, dmb->dma_addr, dmb->dmb_len, | |
| 232 | 232 | DMA_FROM_DEVICE); | |
| 233 | 233 | folio_put(virt_to_folio(dmb->cpu_addr)); | |
| 234 | + | dmb->cpu_addr = NULL; | |
| 234 | 235 | } | |
| 235 | 236 | ||
| 236 | 237 | static int ism_alloc_dmb(struct ism_dev *ism, struct dibs_dmb *dmb) | |
| @@ -274,7 +275,8 @@ static int ism_alloc_dmb(struct ism_dev *ism, struct dibs_dmb *dmb) | |||
| 274 | 275 | return 0; | |
| 275 | 276 | ||
| 276 | 277 | out_free: | |
| 277 | - | kfree(dmb->cpu_addr); | |
| 278 | + | folio_put(folio); | |
| 279 | + | dmb->cpu_addr = NULL; | |
| 278 | 280 | out_bit: | |
| 279 | 281 | clear_bit(dmb->idx, ism->sba_bitmap); | |
| 280 | 282 | return rc; | |
modified drivers/s390/net/qeth_l2.h
| @@ -13,7 +13,8 @@ extern const struct attribute_group *qeth_l2_attr_groups[]; | |||
| 13 | 13 | ||
| 14 | 14 | int qeth_bridgeport_query_ports(struct qeth_card *card, | |
| 15 | 15 | enum qeth_sbp_roles *role, | |
| 16 | - | enum qeth_sbp_states *state); | |
| 16 | + | enum qeth_sbp_states *state, | |
| 17 | + | bool *os_mismatch); | |
| 17 | 18 | int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role); | |
| 18 | 19 | int qeth_bridgeport_an_set(struct qeth_card *card, int enable); | |
| 19 | 20 | ||
modified drivers/s390/net/qeth_l2_main.c
| @@ -1158,7 +1158,7 @@ static void qeth_l2_setup_bridgeport_attrs(struct qeth_card *card) | |||
| 1158 | 1158 | qeth_bridgeport_setrole(card, card->options.sbp.role); | |
| 1159 | 1159 | /* Let the callback function refresh the stored role value. */ | |
| 1160 | 1160 | qeth_bridgeport_query_ports(card, &card->options.sbp.role, | |
| 1161 | - | NULL); | |
| 1161 | + | NULL, NULL); | |
| 1162 | 1162 | } | |
| 1163 | 1163 | if (card->options.sbp.hostnotification) { | |
| 1164 | 1164 | if (qeth_bridgeport_an_set(card, 1)) | |
| @@ -1545,6 +1545,7 @@ struct _qeth_sbp_cbctl { | |||
| 1545 | 1545 | struct { | |
| 1546 | 1546 | enum qeth_sbp_roles *role; | |
| 1547 | 1547 | enum qeth_sbp_states *state; | |
| 1548 | + | bool *os_mismatch; | |
| 1548 | 1549 | } qports; | |
| 1549 | 1550 | } data; | |
| 1550 | 1551 | }; | |
| @@ -1721,10 +1722,19 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card, | |||
| 1721 | 1722 | struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; | |
| 1722 | 1723 | struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param; | |
| 1723 | 1724 | struct qeth_sbp_port_data *qports; | |
| 1725 | + | u16 sbp_rc; | |
| 1724 | 1726 | int rc; | |
| 1725 | 1727 | ||
| 1726 | 1728 | QETH_CARD_TEXT(card, 2, "brqprtcb"); | |
| 1727 | - | rc = qeth_bridgeport_makerc(card, cmd); | |
| 1729 | + | sbp_rc = cmd->data.sbp.hdr.return_code; | |
| 1730 | + | ||
| 1731 | + | /* on OS family mismatch, query still returns valid port data; | |
| 1732 | + | * treat as success | |
| 1733 | + | */ | |
| 1734 | + | if (sbp_rc == IPA_RC_SBP_IQD_OS_MISMATCH && !cmd->hdr.return_code) | |
| 1735 | + | rc = 0; | |
| 1736 | + | else | |
| 1737 | + | rc = qeth_bridgeport_makerc(card, cmd); | |
| 1728 | 1738 | if (rc) | |
| 1729 | 1739 | return rc; | |
| 1730 | 1740 | ||
| @@ -1740,6 +1750,9 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card, | |||
| 1740 | 1750 | if (cbctl->data.qports.state) | |
| 1741 | 1751 | *cbctl->data.qports.state = qports->entry[0].state; | |
| 1742 | 1752 | } | |
| 1753 | + | if (cbctl->data.qports.os_mismatch) | |
| 1754 | + | *cbctl->data.qports.os_mismatch = | |
| 1755 | + | (sbp_rc == IPA_RC_SBP_IQD_OS_MISMATCH); | |
| 1743 | 1756 | return 0; | |
| 1744 | 1757 | } | |
| 1745 | 1758 | ||
| @@ -1748,13 +1761,17 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card, | |||
| 1748 | 1761 | * @card: qeth_card structure pointer. | |
| 1749 | 1762 | * @role: Role of the port: 0-none, 1-primary, 2-secondary. | |
| 1750 | 1763 | * @state: State of the port: 0-inactive, 1-standby, 2-active. | |
| 1764 | + | * @os_mismatch: if non-NULL, set to true when firmware reports | |
| 1765 | + | * OS family mismatch. | |
| 1751 | 1766 | * | |
| 1752 | 1767 | * Returns negative errno-compatible error indication or 0 on success. | |
| 1753 | 1768 | * | |
| 1754 | - | * 'role' and 'state' are not updated in case of hardware operation failure. | |
| 1769 | + | * 'role', 'state' and 'os_mismatch' are not updated in case of | |
| 1770 | + | * hardware operation failure. | |
| 1755 | 1771 | */ | |
| 1756 | 1772 | int qeth_bridgeport_query_ports(struct qeth_card *card, | |
| 1757 | - | enum qeth_sbp_roles *role, enum qeth_sbp_states *state) | |
| 1773 | + | enum qeth_sbp_roles *role, enum qeth_sbp_states *state, | |
| 1774 | + | bool *os_mismatch) | |
| 1758 | 1775 | { | |
| 1759 | 1776 | struct qeth_cmd_buffer *iob; | |
| 1760 | 1777 | struct _qeth_sbp_cbctl cbctl = { | |
| @@ -1762,6 +1779,7 @@ int qeth_bridgeport_query_ports(struct qeth_card *card, | |||
| 1762 | 1779 | .qports = { | |
| 1763 | 1780 | .role = role, | |
| 1764 | 1781 | .state = state, | |
| 1782 | + | .os_mismatch = os_mismatch, | |
| 1765 | 1783 | }, | |
| 1766 | 1784 | }, | |
| 1767 | 1785 | }; | |
modified drivers/s390/net/qeth_l2_sys.c
| @@ -15,6 +15,7 @@ static ssize_t qeth_bridge_port_role_state_show(struct device *dev, | |||
| 15 | 15 | { | |
| 16 | 16 | struct qeth_card *card = dev_get_drvdata(dev); | |
| 17 | 17 | enum qeth_sbp_states state = QETH_SBP_STATE_INACTIVE; | |
| 18 | + | bool os_mismatch = false; | |
| 18 | 19 | int rc = 0; | |
| 19 | 20 | char *word; | |
| 20 | 21 | ||
| @@ -25,7 +26,7 @@ static ssize_t qeth_bridge_port_role_state_show(struct device *dev, | |||
| 25 | 26 | if (qeth_card_hw_is_reachable(card) && | |
| 26 | 27 | card->options.sbp.supported_funcs) | |
| 27 | 28 | rc = qeth_bridgeport_query_ports(card, | |
| 28 | - | &card->options.sbp.role, &state); | |
| 29 | + | &card->options.sbp.role, &state, &os_mismatch); | |
| 29 | 30 | if (!rc) { | |
| 30 | 31 | if (show_state) | |
| 31 | 32 | switch (state) { | |
| @@ -52,6 +53,10 @@ static ssize_t qeth_bridge_port_role_state_show(struct device *dev, | |||
| 52 | 53 | if (rc) | |
| 53 | 54 | QETH_CARD_TEXT_(card, 2, "SBP%02x:%02x", | |
| 54 | 55 | card->options.sbp.role, state); | |
| 56 | + | else if (!show_state && | |
| 57 | + | card->options.sbp.role == QETH_SBP_ROLE_NONE && | |
| 58 | + | os_mismatch) | |
| 59 | + | rc = sysfs_emit(buf, "%s (OS family mismatch)\n", word); | |
| 55 | 60 | else | |
| 56 | 61 | rc = sysfs_emit(buf, "%s\n", word); | |
| 57 | 62 | } | |
modified drivers/scsi/fnic/fnic_debugfs.c
| @@ -767,7 +767,7 @@ static int fnic_nvmef_debugfs_open(struct inode *inode, struct file *file) | |||
| 767 | 767 | struct fnic_nvmef_info *info; | |
| 768 | 768 | int buf_size = 2 * PAGE_SIZE; | |
| 769 | 769 | ||
| 770 | - | info = kzalloc_obj(struct fnic_nvmef_info, GFP_KERNEL); | |
| 770 | + | info = kzalloc_obj(struct fnic_nvmef_info); | |
| 771 | 771 | if (!info) | |
| 772 | 772 | return -ENOMEM; | |
| 773 | 773 | ||
modified drivers/scsi/fnic/fnic_nvme.c
| @@ -2216,7 +2216,7 @@ int nvfnic_add_tport(struct fnic *fnic, struct fnic_tport_s *tport, | |||
| 2216 | 2216 | ||
| 2217 | 2217 | int nvfnic_add_lport(struct fnic *fnic) | |
| 2218 | 2218 | { | |
| 2219 | - | struct nvme_fc_port_info pinfo; | |
| 2219 | + | struct nvme_fc_port_info pinfo = {}; | |
| 2220 | 2220 | struct fnic_iport_s *iport = &fnic->iport; | |
| 2221 | 2221 | int ret = 0; | |
| 2222 | 2222 | ||
modified drivers/scsi/ibmvscsi/ibmvfc-core.c
| @@ -1894,7 +1894,7 @@ static void ibmvfc_log_error(struct ibmvfc_event *evt) | |||
| 1894 | 1894 | } | |
| 1895 | 1895 | ||
| 1896 | 1896 | /** | |
| 1897 | - | * ibmvfc_relogin - Log back into the specified device | |
| 1897 | + | * ibmvfc_scsi_relogin - Log back into the specified device | |
| 1898 | 1898 | * @sdev: scsi device struct | |
| 1899 | 1899 | * | |
| 1900 | 1900 | **/ | |
| @@ -4987,6 +4987,7 @@ static void ibmvfc_tgt_query_target(struct ibmvfc_target *tgt) | |||
| 4987 | 4987 | * ibmvfc_alloc_target - Allocate and initialize an ibmvfc target | |
| 4988 | 4988 | * @vhost: ibmvfc host struct | |
| 4989 | 4989 | * @target: Holds SCSI ID to allocate target forand the WWPN | |
| 4990 | + | * @protocol: protocol of the target to allocate | |
| 4990 | 4991 | * | |
| 4991 | 4992 | * Returns: | |
| 4992 | 4993 | * 0 on success / other on failure | |
modified drivers/scsi/leapraid/leapraid_func.c
| @@ -2984,8 +2984,7 @@ static void leapraid_fw_evt_put(struct leapraid_fw_evt_work *fw_work) | |||
| 2984 | 2984 | ||
| 2985 | 2985 | static struct leapraid_fw_evt_work *leapraid_alloc_fw_evt_work(void) | |
| 2986 | 2986 | { | |
| 2987 | - | struct leapraid_fw_evt_work *fw_evt = | |
| 2988 | - | kzalloc(sizeof(*fw_evt), GFP_ATOMIC); | |
| 2987 | + | struct leapraid_fw_evt_work *fw_evt = kzalloc_obj(*fw_evt, GFP_ATOMIC); | |
| 2989 | 2988 | ||
| 2990 | 2989 | if (fw_evt) | |
| 2991 | 2990 | kref_init(&fw_evt->refcnt); | |
| @@ -3644,8 +3643,7 @@ static void leapraid_sas_host_add(struct leapraid_adapter *adapter, | |||
| 3644 | 3643 | return; | |
| 3645 | 3644 | ||
| 3646 | 3645 | adapter->dev_topo.card.card_phy = | |
| 3647 | - | kcalloc(phys_num, | |
| 3648 | - | sizeof(struct leapraid_card_phy), GFP_KERNEL); | |
| 3646 | + | kzalloc_objs(struct leapraid_card_phy, phys_num); | |
| 3649 | 3647 | if (!adapter->dev_topo.card.card_phy) | |
| 3650 | 3648 | return; | |
| 3651 | 3649 | ||
| @@ -3763,8 +3761,7 @@ static int leapraid_internal_exp_add(struct leapraid_adapter *adapter, | |||
| 3763 | 3761 | } | |
| 3764 | 3762 | ||
| 3765 | 3763 | topo_node_exp->card_phy = | |
| 3766 | - | kcalloc(topo_node_exp->phys_num, | |
| 3767 | - | sizeof(struct leapraid_card_phy), GFP_KERNEL); | |
| 3764 | + | kzalloc_objs(struct leapraid_card_phy, topo_node_exp->phys_num); | |
| 3768 | 3765 | if (!topo_node_exp->card_phy) { | |
| 3769 | 3766 | dev_err(&adapter->pdev->dev, | |
| 3770 | 3767 | "%s: Failed to alloc expander phy array, count=%u\n", | |
| @@ -4352,7 +4349,7 @@ static void leapraid_sas_volume_add( | |||
| 4352 | 4349 | return; | |
| 4353 | 4350 | } | |
| 4354 | 4351 | ||
| 4355 | - | raid_volume = kzalloc(sizeof(*raid_volume), GFP_KERNEL); | |
| 4352 | + | raid_volume = kzalloc_obj(*raid_volume); | |
| 4356 | 4353 | if (!raid_volume) | |
| 4357 | 4354 | return; | |
| 4358 | 4355 | ||
| @@ -6090,17 +6087,15 @@ static void leapraid_update_card_port_after_reset( | |||
| 6090 | 6087 | ||
| 6091 | 6088 | if (!adapter->dev_topo.card.card_phy) { | |
| 6092 | 6089 | adapter->dev_topo.card.card_phy = | |
| 6093 | - | kcalloc(nr_phys, sizeof(struct leapraid_card_phy), | |
| 6094 | - | GFP_KERNEL); | |
| 6090 | + | kzalloc_objs(struct leapraid_card_phy, nr_phys); | |
| 6095 | 6091 | if (!adapter->dev_topo.card.card_phy) | |
| 6096 | 6092 | return; | |
| 6097 | 6093 | } | |
| 6098 | 6094 | ||
| 6099 | 6095 | adapter->dev_topo.card.phys_num = nr_phys; | |
| 6100 | 6096 | ||
| 6101 | - | new_card_port_table = kcalloc(adapter->dev_topo.card.phys_num, | |
| 6102 | - | sizeof(struct leapraid_card_port), | |
| 6103 | - | GFP_KERNEL); | |
| 6097 | + | new_card_port_table = kzalloc_objs(struct leapraid_card_port, | |
| 6098 | + | adapter->dev_topo.card.phys_num); | |
| 6104 | 6099 | if (!new_card_port_table) | |
| 6105 | 6100 | return; | |
| 6106 | 6101 | ||
| @@ -7224,8 +7219,8 @@ static int leapraid_set_legacy_int(struct leapraid_adapter *adapter) | |||
| 7224 | 7219 | adapter->notification_desc.iopoll_qdex, | |
| 7225 | 7220 | adapter->notification_desc.iopoll_qcnt); | |
| 7226 | 7221 | adapter->notification_desc.int_rqs = | |
| 7227 | - | kcalloc(adapter->notification_desc.iopoll_qdex, | |
| 7228 | - | sizeof(struct leapraid_int_rq), GFP_KERNEL); | |
| 7222 | + | kzalloc_objs(struct leapraid_int_rq, | |
| 7223 | + | adapter->notification_desc.iopoll_qdex); | |
| 7229 | 7224 | if (!adapter->notification_desc.int_rqs) | |
| 7230 | 7225 | return -ENOMEM; | |
| 7231 | 7226 | ||
| @@ -7268,9 +7263,8 @@ static int leapraid_set_msix(struct leapraid_adapter *adapter) | |||
| 7268 | 7263 | } | |
| 7269 | 7264 | if (iopoll_qcnt) { | |
| 7270 | 7265 | adapter->notification_desc.blk_mq_poll_rqs = | |
| 7271 | - | kcalloc(iopoll_qcnt, | |
| 7272 | - | sizeof(struct leapraid_blk_mq_poll_rq), | |
| 7273 | - | GFP_KERNEL); | |
| 7266 | + | kzalloc_objs(struct leapraid_blk_mq_poll_rq, | |
| 7267 | + | iopoll_qcnt); | |
| 7274 | 7268 | if (!adapter->notification_desc.blk_mq_poll_rqs) | |
| 7275 | 7269 | return -ENOMEM; | |
| 7276 | 7270 | adapter->adapter_attr.rq_cnt = | |
| @@ -7289,8 +7283,8 @@ static int leapraid_set_msix(struct leapraid_adapter *adapter) | |||
| 7289 | 7283 | adapter->notification_desc.iopoll_qcnt); | |
| 7290 | 7284 | ||
| 7291 | 7285 | adapter->notification_desc.int_rqs = | |
| 7292 | - | kcalloc(adapter->notification_desc.iopoll_qdex, | |
| 7293 | - | sizeof(struct leapraid_int_rq), GFP_KERNEL); | |
| 7286 | + | kzalloc_objs(struct leapraid_int_rq, | |
| 7287 | + | adapter->notification_desc.iopoll_qdex); | |
| 7294 | 7288 | if (!adapter->notification_desc.int_rqs) | |
| 7295 | 7289 | return -ENOMEM; | |
| 7296 | 7290 | ||
| @@ -7365,9 +7359,8 @@ static int leapraid_set_msi(struct leapraid_adapter *adapter) | |||
| 7365 | 7359 | ||
| 7366 | 7360 | if (iopoll_qcnt) { | |
| 7367 | 7361 | adapter->notification_desc.blk_mq_poll_rqs = | |
| 7368 | - | kcalloc(iopoll_qcnt, | |
| 7369 | - | sizeof(struct leapraid_blk_mq_poll_rq), | |
| 7370 | - | GFP_KERNEL); | |
| 7362 | + | kzalloc_objs(struct leapraid_blk_mq_poll_rq, | |
| 7363 | + | iopoll_qcnt); | |
| 7371 | 7364 | if (!adapter->notification_desc.blk_mq_poll_rqs) | |
| 7372 | 7365 | return -ENOMEM; | |
| 7373 | 7366 | ||
| @@ -7404,9 +7397,8 @@ static int leapraid_set_msi(struct leapraid_adapter *adapter) | |||
| 7404 | 7397 | adapter->notification_desc.iopoll_qcnt); | |
| 7405 | 7398 | ||
| 7406 | 7399 | adapter->notification_desc.int_rqs = | |
| 7407 | - | kcalloc(adapter->notification_desc.iopoll_qdex, | |
| 7408 | - | sizeof(struct leapraid_int_rq), | |
| 7409 | - | GFP_KERNEL); | |
| 7400 | + | kzalloc_objs(struct leapraid_int_rq, | |
| 7401 | + | adapter->notification_desc.iopoll_qdex); | |
| 7410 | 7402 | if (!adapter->notification_desc.int_rqs) | |
| 7411 | 7403 | return -ENOMEM; | |
| 7412 | 7404 | ||
| @@ -7958,18 +7950,16 @@ try_again: | |||
| 7958 | 7950 | DIV_ROUND_UP(adapter->adapter_attr.rq_cnt, | |
| 7959 | 7951 | LEAPRAID_REP_DESC_CHUNK_SIZE); | |
| 7960 | 7952 | adapter->mem_desc.rep_desc_seg_maint = | |
| 7961 | - | kcalloc(adapter->adapter_attr.rep_desc_q_seg_cnt, | |
| 7962 | - | sizeof(struct leapraid_rep_desc_seg_maint), | |
| 7963 | - | GFP_KERNEL); | |
| 7953 | + | kzalloc_objs(struct leapraid_rep_desc_seg_maint, | |
| 7954 | + | adapter->adapter_attr.rep_desc_q_seg_cnt); | |
| 7964 | 7955 | if (!adapter->mem_desc.rep_desc_seg_maint) | |
| 7965 | 7956 | return -ENOMEM; | |
| 7966 | 7957 | ||
| 7967 | 7958 | rep_desc_q_cnt_allocated = 0; | |
| 7968 | 7959 | for (i = 0; i < adapter->adapter_attr.rep_desc_q_seg_cnt; i++) { | |
| 7969 | 7960 | adapter->mem_desc.rep_desc_seg_maint[i].rep_desc_maint = | |
| 7970 | - | kcalloc(LEAPRAID_REP_DESC_CHUNK_SIZE, | |
| 7971 | - | sizeof(struct leapraid_rep_desc_maint), | |
| 7972 | - | GFP_KERNEL); | |
| 7961 | + | kzalloc_objs(struct leapraid_rep_desc_maint, | |
| 7962 | + | LEAPRAID_REP_DESC_CHUNK_SIZE); | |
| 7973 | 7963 | if (!adapter->mem_desc.rep_desc_seg_maint[i].rep_desc_maint) | |
| 7974 | 7964 | return -ENOMEM; | |
| 7975 | 7965 | ||
modified drivers/scsi/megaraid/megaraid_sas_base.c
| @@ -1973,12 +1973,23 @@ megasas_set_nvme_device_properties(struct scsi_device *sdev, | |||
| 1973 | 1973 | { | |
| 1974 | 1974 | struct megasas_instance *instance; | |
| 1975 | 1975 | u32 mr_nvme_pg_size; | |
| 1976 | + | u64 max_prp_io; | |
| 1976 | 1977 | ||
| 1977 | 1978 | instance = (struct megasas_instance *)sdev->host->hostdata; | |
| 1978 | 1979 | mr_nvme_pg_size = max_t(u32, instance->nvme_page_size, | |
| 1979 | 1980 | MR_DEFAULT_NVME_PAGE_SIZE); | |
| 1980 | 1981 | ||
| 1981 | - | lim->max_hw_sectors = max_io_size / 512; | |
| 1982 | + | /* | |
| 1983 | + | * megasas_make_prp_nvme() builds the PRP list in cmd->sg_frame without | |
| 1984 | + | * bounding it against that buffer, and spends one entry per page of | |
| 1985 | + | * it on the chain pointer. Cap the transfer at what the buffer holds, | |
| 1986 | + | * less one page for lists that start off a page boundary. | |
| 1987 | + | */ | |
| 1988 | + | max_prp_io = (u64)((instance->max_chain_frame_sz / sizeof(u64)) - | |
| 1989 | + | (instance->max_chain_frame_sz / mr_nvme_pg_size) - 1) * | |
| 1990 | + | mr_nvme_pg_size; | |
| 1991 | + | ||
| 1992 | + | lim->max_hw_sectors = min_t(u64, max_io_size, max_prp_io) >> SECTOR_SHIFT; | |
| 1982 | 1993 | lim->virt_boundary_mask = mr_nvme_pg_size - 1; | |
| 1983 | 1994 | } | |
| 1984 | 1995 | ||
modified drivers/scsi/mpi3mr/mpi3mr_os.c
| @@ -1094,10 +1094,13 @@ static void mpi3mr_refresh_tgtdevs(struct mpi3mr_ioc *mrioc) | |||
| 1094 | 1094 | { | |
| 1095 | 1095 | struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next; | |
| 1096 | 1096 | struct mpi3mr_stgt_priv_data *tgt_priv; | |
| 1097 | + | struct scsi_target *starget; | |
| 1098 | + | unsigned long flags; | |
| 1097 | 1099 | ||
| 1098 | 1100 | dprint_reset(mrioc, "refresh target devices: check for removals\n"); | |
| 1099 | 1101 | list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list, | |
| 1100 | 1102 | list) { | |
| 1103 | + | spin_lock_irqsave(&mrioc->tgtdev_lock, flags); | |
| 1101 | 1104 | if (((tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) || | |
| 1102 | 1105 | tgtdev->is_hidden) && | |
| 1103 | 1106 | tgtdev->host_exposed && tgtdev->starget && | |
| @@ -1106,6 +1109,7 @@ static void mpi3mr_refresh_tgtdevs(struct mpi3mr_ioc *mrioc) | |||
| 1106 | 1109 | tgt_priv->dev_removed = 1; | |
| 1107 | 1110 | atomic_set(&tgt_priv->block_io, 0); | |
| 1108 | 1111 | } | |
| 1112 | + | spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags); | |
| 1109 | 1113 | } | |
| 1110 | 1114 | ||
| 1111 | 1115 | list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list, | |
| @@ -1127,15 +1131,25 @@ static void mpi3mr_refresh_tgtdevs(struct mpi3mr_ioc *mrioc) | |||
| 1127 | 1131 | tgtdev = NULL; | |
| 1128 | 1132 | list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) { | |
| 1129 | 1133 | if ((tgtdev->dev_handle != MPI3MR_INVALID_DEV_HANDLE) && | |
| 1130 | - | !tgtdev->is_hidden) { | |
| 1131 | - | if (!tgtdev->host_exposed) | |
| 1134 | + | !tgtdev->is_hidden) { | |
| 1135 | + | if (!tgtdev->host_exposed) { | |
| 1132 | 1136 | mpi3mr_report_tgtdev_to_host(mrioc, | |
| 1133 | - | tgtdev->perst_id); | |
| 1134 | - | else if (tgtdev->starget) | |
| 1135 | - | starget_for_each_device(tgtdev->starget, | |
| 1136 | - | (void *)tgtdev, mpi3mr_update_sdev); | |
| 1137 | - | } | |
| 1137 | + | tgtdev->perst_id); | |
| 1138 | + | continue; | |
| 1139 | + | } | |
| 1140 | + | spin_lock_irqsave(&mrioc->tgtdev_lock, flags); | |
| 1141 | + | starget = tgtdev->starget; | |
| 1142 | + | if (starget) | |
| 1143 | + | get_device(&starget->dev); | |
| 1144 | + | spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags); | |
| 1145 | + | if (starget) { | |
| 1146 | + | starget_for_each_device(starget, (void *)tgtdev, | |
| 1147 | + | mpi3mr_update_sdev); | |
| 1148 | + | put_device(&starget->dev); | |
| 1149 | + | } | |
| 1150 | + | } | |
| 1138 | 1151 | } | |
| 1152 | + | dprint_reset(mrioc, "refresh target devices: done\n"); | |
| 1139 | 1153 | } | |
| 1140 | 1154 | ||
| 1141 | 1155 | /** | |
| @@ -1515,6 +1529,8 @@ static void mpi3mr_devinfochg_evt_bh(struct mpi3mr_ioc *mrioc, | |||
| 1515 | 1529 | struct mpi3_device_page0 *dev_pg0) | |
| 1516 | 1530 | { | |
| 1517 | 1531 | struct mpi3mr_tgt_dev *tgtdev = NULL; | |
| 1532 | + | struct scsi_target *starget; | |
| 1533 | + | unsigned long flags; | |
| 1518 | 1534 | u16 dev_handle = 0, perst_id = 0; | |
| 1519 | 1535 | ||
| 1520 | 1536 | perst_id = le16_to_cpu(dev_pg0->persistent_id); | |
| @@ -1535,9 +1551,18 @@ static void mpi3mr_devinfochg_evt_bh(struct mpi3mr_ioc *mrioc, | |||
| 1535 | 1551 | mpi3mr_report_tgtdev_to_host(mrioc, perst_id); | |
| 1536 | 1552 | if (tgtdev->is_hidden && tgtdev->host_exposed) | |
| 1537 | 1553 | mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev); | |
| 1538 | - | if (!tgtdev->is_hidden && tgtdev->host_exposed && tgtdev->starget) | |
| 1539 | - | starget_for_each_device(tgtdev->starget, (void *)tgtdev, | |
| 1540 | - | mpi3mr_update_sdev); | |
| 1554 | + | if (!tgtdev->is_hidden && tgtdev->host_exposed) { | |
| 1555 | + | spin_lock_irqsave(&mrioc->tgtdev_lock, flags); | |
| 1556 | + | starget = tgtdev->starget; | |
| 1557 | + | if (starget) | |
| 1558 | + | get_device(&starget->dev); | |
| 1559 | + | spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags); | |
| 1560 | + | if (starget) { | |
| 1561 | + | starget_for_each_device(starget, (void *)tgtdev, | |
| 1562 | + | mpi3mr_update_sdev); | |
| 1563 | + | put_device(&starget->dev); | |
| 1564 | + | } | |
| 1565 | + | } | |
| 1541 | 1566 | out: | |
| 1542 | 1567 | if (tgtdev) | |
| 1543 | 1568 | mpi3mr_tgtdev_put(tgtdev); | |
modified drivers/scsi/mpi3mr/mpi3mr_transport.c
| @@ -1428,9 +1428,15 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc, | |||
| 1428 | 1428 | } | |
| 1429 | 1429 | ||
| 1430 | 1430 | port = sas_port_alloc_num(mr_sas_node->parent_dev); | |
| 1431 | + | if (!port) { | |
| 1432 | + | ioc_err(mrioc, "failure at %s:%d/%s()!\n", | |
| 1433 | + | __FILE__, __LINE__, __func__); | |
| 1434 | + | goto out_fail; | |
| 1435 | + | } | |
| 1431 | 1436 | if ((sas_port_add(port))) { | |
| 1432 | 1437 | ioc_err(mrioc, "failure at %s:%d/%s()!\n", | |
| 1433 | 1438 | __FILE__, __LINE__, __func__); | |
| 1439 | + | sas_port_free(port); | |
| 1434 | 1440 | goto out_fail; | |
| 1435 | 1441 | } | |
| 1436 | 1442 | ||
| @@ -1501,6 +1507,8 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc, | |||
| 1501 | 1507 | list_for_each_entry_safe(mr_sas_phy, next, &mr_sas_port->phy_list, | |
| 1502 | 1508 | port_siblings) | |
| 1503 | 1509 | list_del(&mr_sas_phy->port_siblings); | |
| 1510 | + | if (tgtdev) | |
| 1511 | + | mpi3mr_tgtdev_put(tgtdev); | |
| 1504 | 1512 | kfree(mr_sas_port); | |
| 1505 | 1513 | return NULL; | |
| 1506 | 1514 | } | |
modified drivers/scsi/mpt3sas/mpt3sas_base.c
| @@ -3238,7 +3238,10 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc) | |||
| 3238 | 3238 | * corresponding to high iops queues. | |
| 3239 | 3239 | */ | |
| 3240 | 3240 | if (ioc->high_iops_queues) { | |
| 3241 | - | mask = cpumask_of_node(dev_to_node(&ioc->pdev->dev)); | |
| 3241 | + | int node = dev_to_node(&ioc->pdev->dev); | |
| 3242 | + | ||
| 3243 | + | mask = (node == NUMA_NO_NODE) ? | |
| 3244 | + | cpu_online_mask : cpumask_of_node(node); | |
| 3242 | 3245 | for (index = 0; index < ioc->high_iops_queues; | |
| 3243 | 3246 | index++) { | |
| 3244 | 3247 | irq = pci_irq_vector(ioc->pdev, index); | |
modified drivers/scsi/pm8001/pm8001_init.c
| @@ -1029,8 +1029,8 @@ static u32 pm8001_request_msix(struct pm8001_hba_info *pm8001_ha) | |||
| 1029 | 1029 | &(pm8001_ha->irq_vector[i])); | |
| 1030 | 1030 | if (rc) { | |
| 1031 | 1031 | for (j = 0; j < i; j++) { | |
| 1032 | - | free_irq(pci_irq_vector(pm8001_ha->pdev, i), | |
| 1033 | - | &(pm8001_ha->irq_vector[i])); | |
| 1032 | + | free_irq(pci_irq_vector(pm8001_ha->pdev, j), | |
| 1033 | + | &pm8001_ha->irq_vector[j]); | |
| 1034 | 1034 | } | |
| 1035 | 1035 | pci_free_irq_vectors(pm8001_ha->pdev); | |
| 1036 | 1036 | break; | |
modified drivers/scsi/scsi_bsg.c
| @@ -18,6 +18,7 @@ struct scsi_bsg_uring_cmd_pdu { | |||
| 18 | 18 | struct bio *bio; /* mapped user buffer, unmap in task work */ | |
| 19 | 19 | struct request *req; /* block request, freed in task work */ | |
| 20 | 20 | u64 response_addr; /* user space response buffer address */ | |
| 21 | + | u32 max_response_len; /* user response buffer size */ | |
| 21 | 22 | }; | |
| 22 | 23 | static_assert(sizeof(struct scsi_bsg_uring_cmd_pdu) <= sizeof_field(struct io_uring_cmd, pdu)); | |
| 23 | 24 | ||
| @@ -45,8 +46,8 @@ static void scsi_bsg_uring_task_cb(struct io_tw_req tw_req, io_tw_token_t tw) | |||
| 45 | 46 | if (scsi_status_is_check_condition(scmd->result)) { | |
| 46 | 47 | driver_status = DRIVER_SENSE; | |
| 47 | 48 | if (pdu->response_addr) | |
| 48 | - | sense_len_wr = min_t(u8, scmd->sense_len, | |
| 49 | - | SCSI_SENSE_BUFFERSIZE); | |
| 49 | + | sense_len_wr = min_t(unsigned int, pdu->max_response_len, | |
| 50 | + | scmd->sense_len); | |
| 50 | 51 | } | |
| 51 | 52 | ||
| 52 | 53 | if (sense_len_wr) { | |
| @@ -76,12 +77,10 @@ static enum rq_end_io_ret scsi_bsg_uring_cmd_done(struct request *req, | |||
| 76 | 77 | ||
| 77 | 78 | static int scsi_bsg_map_user_buffer(struct request *req, | |
| 78 | 79 | struct io_uring_cmd *ioucmd, | |
| 79 | - | unsigned int issue_flags, gfp_t gfp_mask) | |
| 80 | + | unsigned int issue_flags, gfp_t gfp_mask, | |
| 81 | + | bool is_write, u64 buf_addr, | |
| 82 | + | unsigned long buf_len) | |
| 80 | 83 | { | |
| 81 | - | const struct bsg_uring_cmd *cmd = io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd); | |
| 82 | - | bool is_write = cmd->dout_xfer_len > 0; | |
| 83 | - | u64 buf_addr = is_write ? cmd->dout_xferp : cmd->din_xferp; | |
| 84 | - | unsigned long buf_len = is_write ? cmd->dout_xfer_len : cmd->din_xfer_len; | |
| 85 | 84 | struct iov_iter iter; | |
| 86 | 85 | int ret; | |
| 87 | 86 | ||
| @@ -104,21 +103,28 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc | |||
| 104 | 103 | unsigned int issue_flags, bool open_for_write) | |
| 105 | 104 | { | |
| 106 | 105 | struct scsi_bsg_uring_cmd_pdu *pdu = scsi_bsg_uring_cmd_pdu(ioucmd); | |
| 107 | - | const struct bsg_uring_cmd *cmd = io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd); | |
| 106 | + | const struct bsg_uring_cmd *cmd = | |
| 107 | + | io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd); | |
| 108 | 108 | struct scsi_cmnd *scmd; | |
| 109 | 109 | struct request *req; | |
| 110 | 110 | blk_mq_req_flags_t blk_flags = 0; | |
| 111 | 111 | gfp_t gfp_mask = GFP_KERNEL; | |
| 112 | + | u64 request = READ_ONCE(cmd->request); | |
| 113 | + | u32 request_len = READ_ONCE(cmd->request_len); | |
| 114 | + | u64 dout_xferp = READ_ONCE(cmd->dout_xferp); | |
| 115 | + | u32 dout_xfer_len = READ_ONCE(cmd->dout_xfer_len); | |
| 116 | + | u64 din_xferp = READ_ONCE(cmd->din_xferp); | |
| 117 | + | u32 din_xfer_len = READ_ONCE(cmd->din_xfer_len); | |
| 112 | 118 | int ret; | |
| 113 | 119 | ||
| 114 | 120 | if (cmd->protocol != BSG_PROTOCOL_SCSI || | |
| 115 | 121 | cmd->subprotocol != BSG_SUB_PROTOCOL_SCSI_CMD) | |
| 116 | 122 | return -EINVAL; | |
| 117 | 123 | ||
| 118 | - | if (!cmd->request || cmd->request_len == 0) | |
| 124 | + | if (!request || request_len == 0) | |
| 119 | 125 | return -EINVAL; | |
| 120 | 126 | ||
| 121 | - | if (cmd->dout_xfer_len && cmd->din_xfer_len) { | |
| 127 | + | if (dout_xfer_len && din_xfer_len) { | |
| 122 | 128 | pr_warn_once("BIDI support in bsg has been removed.\n"); | |
| 123 | 129 | return -EOPNOTSUPP; | |
| 124 | 130 | } | |
| @@ -131,20 +137,20 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc | |||
| 131 | 137 | gfp_mask = GFP_NOWAIT; | |
| 132 | 138 | } | |
| 133 | 139 | ||
| 134 | - | req = scsi_alloc_request(q, cmd->dout_xfer_len ? | |
| 140 | + | req = scsi_alloc_request(q, dout_xfer_len ? | |
| 135 | 141 | REQ_OP_DRV_OUT : REQ_OP_DRV_IN, blk_flags); | |
| 136 | 142 | if (IS_ERR(req)) | |
| 137 | 143 | return PTR_ERR(req); | |
| 138 | 144 | ||
| 139 | 145 | scmd = blk_mq_rq_to_pdu(req); | |
| 140 | - | if (cmd->request_len > sizeof(scmd->cmnd)) { | |
| 146 | + | if (request_len > sizeof(scmd->cmnd)) { | |
| 141 | 147 | ret = -EINVAL; | |
| 142 | 148 | goto out_free_req; | |
| 143 | 149 | } | |
| 144 | - | scmd->cmd_len = cmd->request_len; | |
| 150 | + | scmd->cmd_len = request_len; | |
| 145 | 151 | scmd->allowed = SG_DEFAULT_RETRIES; | |
| 146 | 152 | ||
| 147 | - | if (copy_from_user(scmd->cmnd, uptr64(cmd->request), cmd->request_len)) { | |
| 153 | + | if (copy_from_user(scmd->cmnd, uptr64(request), request_len)) { | |
| 148 | 154 | ret = -EFAULT; | |
| 149 | 155 | goto out_free_req; | |
| 150 | 156 | } | |
| @@ -155,11 +161,16 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc | |||
| 155 | 161 | } | |
| 156 | 162 | ||
| 157 | 163 | pdu->response_addr = cmd->response; | |
| 158 | - | scmd->sense_len = cmd->max_response_len ? | |
| 159 | - | min(cmd->max_response_len, SCSI_SENSE_BUFFERSIZE) : SCSI_SENSE_BUFFERSIZE; | |
| 164 | + | pdu->max_response_len = cmd->max_response_len; | |
| 160 | 165 | ||
| 161 | - | if (cmd->dout_xfer_len || cmd->din_xfer_len) { | |
| 162 | - | ret = scsi_bsg_map_user_buffer(req, ioucmd, issue_flags, gfp_mask); | |
| 166 | + | if (dout_xfer_len || din_xfer_len) { | |
| 167 | + | bool is_write = dout_xfer_len > 0; | |
| 168 | + | u64 buf_addr = is_write ? dout_xferp : din_xferp; | |
| 169 | + | unsigned long buf_len = is_write ? dout_xfer_len : din_xfer_len; | |
| 170 | + | ||
| 171 | + | ret = scsi_bsg_map_user_buffer(req, ioucmd, issue_flags, | |
| 172 | + | gfp_mask, is_write, buf_addr, | |
| 173 | + | buf_len); | |
| 163 | 174 | if (ret) | |
| 164 | 175 | goto out_free_req; | |
| 165 | 176 | pdu->bio = req->bio; | |
modified drivers/scsi/scsi_scan.c
| @@ -158,7 +158,7 @@ int scsi_complete_async_scans(void) | |||
| 158 | 158 | * sleep a little. Even if we never get memory, the async | |
| 159 | 159 | * scans will finish eventually. | |
| 160 | 160 | */ | |
| 161 | - | data = kmalloc(sizeof(*data), GFP_KERNEL); | |
| 161 | + | data = kmalloc_obj(*data); | |
| 162 | 162 | if (!data) | |
| 163 | 163 | msleep(1); | |
| 164 | 164 | } while (!data); | |
modified drivers/soc/bcm/brcmstb/common.c
| @@ -65,7 +65,7 @@ static int __init brcmstb_soc_device_init(void) | |||
| 65 | 65 | goto out_put_node; | |
| 66 | 66 | } | |
| 67 | 67 | ||
| 68 | - | soc_info = kzalloc(sizeof(*soc_info), GFP_KERNEL); | |
| 68 | + | soc_info = kzalloc_obj(*soc_info); | |
| 69 | 69 | if (!soc_info) { | |
| 70 | 70 | ret = -ENOMEM; | |
| 71 | 71 | goto out_unmap; | |
modified drivers/spi/spi-offload.c
| @@ -434,7 +434,7 @@ int devm_spi_offload_trigger_register(struct device *dev, | |||
| 434 | 434 | if (!info->fwnode || !info->ops || !info->ops->match) | |
| 435 | 435 | return -EINVAL; | |
| 436 | 436 | ||
| 437 | - | trigger = kzalloc(sizeof(*trigger), GFP_KERNEL); | |
| 437 | + | trigger = kzalloc_obj(*trigger); | |
| 438 | 438 | if (!trigger) | |
| 439 | 439 | return -ENOMEM; | |
| 440 | 440 | ||
modified drivers/staging/fbtft/fbtft-core.c
| @@ -298,14 +298,15 @@ static void fbtft_mkdirty(struct fb_info *info, int y, int height) | |||
| 298 | 298 | { | |
| 299 | 299 | struct fbtft_par *par = info->par; | |
| 300 | 300 | struct fb_deferred_io *fbdefio = info->fbdefio; | |
| 301 | + | unsigned long flags; | |
| 301 | 302 | ||
| 302 | 303 | /* Mark display lines/area as dirty */ | |
| 303 | - | spin_lock(&par->dirty_lock); | |
| 304 | + | spin_lock_irqsave(&par->dirty_lock, flags); | |
| 304 | 305 | if (y < par->dirty_lines_start) | |
| 305 | 306 | par->dirty_lines_start = y; | |
| 306 | 307 | if (y + height - 1 > par->dirty_lines_end) | |
| 307 | 308 | par->dirty_lines_end = y + height - 1; | |
| 308 | - | spin_unlock(&par->dirty_lock); | |
| 309 | + | spin_unlock_irqrestore(&par->dirty_lock, flags); | |
| 309 | 310 | ||
| 310 | 311 | /* Schedule deferred_io to update display (no-op if already on queue)*/ | |
| 311 | 312 | schedule_delayed_work(&info->deferred_work, fbdefio->delay); | |
| @@ -318,13 +319,13 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagereflis | |||
| 318 | 319 | struct fb_deferred_io_pageref *pageref; | |
| 319 | 320 | unsigned int y_low = 0, y_high = 0; | |
| 320 | 321 | ||
| 321 | - | spin_lock(&par->dirty_lock); | |
| 322 | + | spin_lock_irq(&par->dirty_lock); | |
| 322 | 323 | dirty_lines_start = par->dirty_lines_start; | |
| 323 | 324 | dirty_lines_end = par->dirty_lines_end; | |
| 324 | 325 | /* set display line markers as clean */ | |
| 325 | 326 | par->dirty_lines_start = par->info->var.yres - 1; | |
| 326 | 327 | par->dirty_lines_end = 0; | |
| 327 | - | spin_unlock(&par->dirty_lock); | |
| 328 | + | spin_unlock_irq(&par->dirty_lock); | |
| 328 | 329 | ||
| 329 | 330 | /* Mark display lines as dirty */ | |
| 330 | 331 | list_for_each_entry(pageref, pagereflist, list) { | |
modified drivers/staging/greybus/raw.c
| @@ -178,7 +178,7 @@ static int gb_raw_probe(struct gb_bundle *bundle, | |||
| 178 | 178 | if (minor < 0) | |
| 179 | 179 | return minor; | |
| 180 | 180 | ||
| 181 | - | raw = kzalloc_obj(*raw, GFP_KERNEL); | |
| 181 | + | raw = kzalloc_obj(*raw); | |
| 182 | 182 | if (!raw) { | |
| 183 | 183 | ida_free(&minors, minor); | |
| 184 | 184 | return -ENOMEM; | |
modified drivers/staging/media/atomisp/pci/sh_css.c
| @@ -5820,36 +5820,31 @@ static int ia_css_pipe_create_cas_scaler_desc_single_output( | |||
| 5820 | 5820 | } | |
| 5821 | 5821 | ||
| 5822 | 5822 | descr->in_info = kmalloc_objs(*descr->in_info, | |
| 5823 | - | descr->num_stage, | |
| 5824 | - | GFP_KERNEL); | |
| 5823 | + | descr->num_stage); | |
| 5825 | 5824 | if (!descr->in_info) { | |
| 5826 | 5825 | err = -ENOMEM; | |
| 5827 | 5826 | goto ERR; | |
| 5828 | 5827 | } | |
| 5829 | 5828 | descr->internal_out_info = kmalloc_objs(*descr->internal_out_info, | |
| 5830 | - | descr->num_stage, | |
| 5831 | - | GFP_KERNEL); | |
| 5829 | + | descr->num_stage); | |
| 5832 | 5830 | if (!descr->internal_out_info) { | |
| 5833 | 5831 | err = -ENOMEM; | |
| 5834 | 5832 | goto ERR; | |
| 5835 | 5833 | } | |
| 5836 | 5834 | descr->out_info = kmalloc_objs(*descr->out_info, | |
| 5837 | - | descr->num_stage, | |
| 5838 | - | GFP_KERNEL); | |
| 5835 | + | descr->num_stage); | |
| 5839 | 5836 | if (!descr->out_info) { | |
| 5840 | 5837 | err = -ENOMEM; | |
| 5841 | 5838 | goto ERR; | |
| 5842 | 5839 | } | |
| 5843 | 5840 | descr->vf_info = kmalloc_objs(*descr->vf_info, | |
| 5844 | - | descr->num_stage, | |
| 5845 | - | GFP_KERNEL); | |
| 5841 | + | descr->num_stage); | |
| 5846 | 5842 | if (!descr->vf_info) { | |
| 5847 | 5843 | err = -ENOMEM; | |
| 5848 | 5844 | goto ERR; | |
| 5849 | 5845 | } | |
| 5850 | 5846 | descr->is_output_stage = kmalloc_objs(*descr->is_output_stage, | |
| 5851 | - | descr->num_stage, | |
| 5852 | - | GFP_KERNEL); | |
| 5847 | + | descr->num_stage); | |
| 5853 | 5848 | if (!descr->is_output_stage) { | |
| 5854 | 5849 | err = -ENOMEM; | |
| 5855 | 5850 | goto ERR; | |
| @@ -5970,36 +5965,31 @@ ia_css_pipe_create_cas_scaler_desc(struct ia_css_pipe *pipe, | |||
| 5970 | 5965 | descr->num_stage = num_stages; | |
| 5971 | 5966 | ||
| 5972 | 5967 | descr->in_info = kmalloc_objs(*descr->in_info, | |
| 5973 | - | descr->num_stage, | |
| 5974 | - | GFP_KERNEL); | |
| 5968 | + | descr->num_stage); | |
| 5975 | 5969 | if (!descr->in_info) { | |
| 5976 | 5970 | err = -ENOMEM; | |
| 5977 | 5971 | goto ERR; | |
| 5978 | 5972 | } | |
| 5979 | 5973 | descr->internal_out_info = kmalloc_objs(*descr->internal_out_info, | |
| 5980 | - | descr->num_stage, | |
| 5981 | - | GFP_KERNEL); | |
| 5974 | + | descr->num_stage); | |
| 5982 | 5975 | if (!descr->internal_out_info) { | |
| 5983 | 5976 | err = -ENOMEM; | |
| 5984 | 5977 | goto ERR; | |
| 5985 | 5978 | } | |
| 5986 | 5979 | descr->out_info = kmalloc_objs(*descr->out_info, | |
| 5987 | - | descr->num_stage, | |
| 5988 | - | GFP_KERNEL); | |
| 5980 | + | descr->num_stage); | |
| 5989 | 5981 | if (!descr->out_info) { | |
| 5990 | 5982 | err = -ENOMEM; | |
| 5991 | 5983 | goto ERR; | |
| 5992 | 5984 | } | |
| 5993 | 5985 | descr->vf_info = kmalloc_objs(*descr->vf_info, | |
| 5994 | - | descr->num_stage, | |
| 5995 | - | GFP_KERNEL); | |
| 5986 | + | descr->num_stage); | |
| 5996 | 5987 | if (!descr->vf_info) { | |
| 5997 | 5988 | err = -ENOMEM; | |
| 5998 | 5989 | goto ERR; | |
| 5999 | 5990 | } | |
| 6000 | 5991 | descr->is_output_stage = kmalloc_objs(*descr->is_output_stage, | |
| 6001 | - | descr->num_stage, | |
| 6002 | - | GFP_KERNEL); | |
| 5992 | + | descr->num_stage); | |
| 6003 | 5993 | if (!descr->is_output_stage) { | |
| 6004 | 5994 | err = -ENOMEM; | |
| 6005 | 5995 | goto ERR; | |
modified drivers/staging/media/atomisp/pci/sh_css_firmware.c
| @@ -254,8 +254,8 @@ sh_css_load_firmware(struct device *dev, const char *fw_data, | |||
| 254 | 254 | /* Only allocate memory for ISP blob info */ | |
| 255 | 255 | if (sh_css_num_binaries > NUM_OF_SPS) { | |
| 256 | 256 | sh_css_blob_info = | |
| 257 | - | kmalloc_array(sh_css_num_binaries - NUM_OF_SPS, | |
| 258 | - | sizeof(*sh_css_blob_info), GFP_KERNEL); | |
| 257 | + | kmalloc_objs(*sh_css_blob_info, | |
| 258 | + | sh_css_num_binaries - NUM_OF_SPS); | |
| 259 | 259 | if (!sh_css_blob_info) | |
| 260 | 260 | return -ENOMEM; | |
| 261 | 261 | } else { | |
modified drivers/staging/rtl8723bs/core/rtw_ieee80211.c
| @@ -741,6 +741,10 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att | |||
| 741 | 741 | u16 attr_data_len = get_unaligned_be16(attr_ptr + 2); | |
| 742 | 742 | u16 attr_len = attr_data_len + 4; | |
| 743 | 743 | ||
| 744 | + | /* Reject attributes whose claimed length runs past the IE */ | |
| 745 | + | if (attr_ptr + attr_len > wps_ie + wps_ielen) | |
| 746 | + | break; | |
| 747 | + | ||
| 744 | 748 | if (attr_id == target_attr_id) { | |
| 745 | 749 | target_attr_ptr = attr_ptr; | |
| 746 | 750 | ||
| @@ -1149,6 +1153,9 @@ int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *act | |||
| 1149 | 1153 | u8 c; | |
| 1150 | 1154 | u8 a = ACT_PUBLIC_MAX; | |
| 1151 | 1155 | ||
| 1156 | + | if (frame_len < sizeof(struct ieee80211_hdr_3addr) + 2) | |
| 1157 | + | return false; | |
| 1158 | + | ||
| 1152 | 1159 | fc = le16_to_cpu(((struct ieee80211_hdr_3addr *)frame)->frame_control); | |
| 1153 | 1160 | ||
| 1154 | 1161 | if ((fc & (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) != | |
modified drivers/staging/rtl8723bs/core/rtw_mlme.c
| @@ -1975,6 +1975,9 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ | |||
| 1975 | 1975 | break; | |
| 1976 | 1976 | } | |
| 1977 | 1977 | ||
| 1978 | + | if (i + 1 >= in_len) | |
| 1979 | + | break; | |
| 1980 | + | ||
| 1978 | 1981 | i += (in_ie[i + 1] + 2); /* to the next IE element */ | |
| 1979 | 1982 | } | |
| 1980 | 1983 | ||
modified drivers/staging/sm750fb/sm750.c
| @@ -252,7 +252,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info, | |||
| 252 | 252 | spin_lock(&sm750_dev->slock); | |
| 253 | 253 | ||
| 254 | 254 | sm750_dev->accel.de_imageblit(&sm750_dev->accel, | |
| 255 | - | image->data, image->width >> 3, 0, | |
| 255 | + | image->data, 0, | |
| 256 | 256 | base, pitch, bpp, | |
| 257 | 257 | image->dx, image->dy, | |
| 258 | 258 | image->width, image->height, | |
modified drivers/staging/sm750fb/sm750.h
| @@ -64,7 +64,7 @@ struct lynx_accel { | |||
| 64 | 64 | u32 rop2); | |
| 65 | 65 | ||
| 66 | 66 | int (*de_imageblit)(struct lynx_accel *accel, const char *p_srcbuf, | |
| 67 | - | u32 src_delta, u32 start_bit, u32 d_base, u32 d_pitch, | |
| 67 | + | u32 start_bit, u32 d_base, u32 d_pitch, | |
| 68 | 68 | u32 byte_per_pixel, u32 dx, u32 dy, u32 width, | |
| 69 | 69 | u32 height, u32 f_color, u32 b_color, u32 rop2); | |
| 70 | 70 | ||
modified drivers/staging/sm750fb/sm750_accel.c
| @@ -288,8 +288,6 @@ static unsigned int de_get_transparency(struct lynx_accel *accel) | |||
| 288 | 288 | * sm750_hw_imageblit | |
| 289 | 289 | * @accel: Acceleration device data | |
| 290 | 290 | * @src_buf: pointer to start of source buffer in system memory | |
| 291 | - | * @src_delta: Pitch value (in bytes) of the source buffer, +ive means top down | |
| 292 | - | * and -ive mean button up | |
| 293 | 291 | * @start_bit: Mono data can start at any bit in a byte, this value should be | |
| 294 | 292 | * 0 to 7 | |
| 295 | 293 | * @dest_base: Address of destination: offset in frame buffer | |
| @@ -304,7 +302,7 @@ static unsigned int de_get_transparency(struct lynx_accel *accel) | |||
| 304 | 302 | * @rop2: ROP value | |
| 305 | 303 | */ | |
| 306 | 304 | int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf, | |
| 307 | - | u32 src_delta, u32 start_bit, u32 dest_base, u32 dest_pitch, | |
| 305 | + | u32 start_bit, u32 dest_base, u32 dest_pitch, | |
| 308 | 306 | u32 byte_per_pixel, u32 dx, u32 dy, u32 width, | |
| 309 | 307 | u32 height, u32 fg_color, u32 bg_color, u32 rop2) | |
| 310 | 308 | { | |
| @@ -395,7 +393,7 @@ int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf, | |||
| 395 | 393 | write_dp_port(accel, *(unsigned int *)remain); | |
| 396 | 394 | } | |
| 397 | 395 | ||
| 398 | - | src_buf += src_delta; | |
| 396 | + | src_buf += bytes_per_scan; | |
| 399 | 397 | } | |
| 400 | 398 | ||
| 401 | 399 | return 0; | |
modified drivers/staging/sm750fb/sm750_accel.h
| @@ -220,8 +220,6 @@ int sm750_hw_copyarea(struct lynx_accel *accel, | |||
| 220 | 220 | /** | |
| 221 | 221 | * sm750_hw_imageblit | |
| 222 | 222 | * @src_buf: pointer to start of source buffer in system memory | |
| 223 | - | * @src_delta: Pitch value (in bytes) of the source buffer, +ive means top down | |
| 224 | - | *>----- and -ive mean button up | |
| 225 | 223 | * @start_bit: Mono data can start at any bit in a byte, this value should be | |
| 226 | 224 | *>----- 0 to 7 | |
| 227 | 225 | * @dest_base: Address of destination: offset in frame buffer | |
| @@ -236,7 +234,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel, | |||
| 236 | 234 | * @rop2: ROP value | |
| 237 | 235 | */ | |
| 238 | 236 | int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf, | |
| 239 | - | u32 src_delta, u32 start_bit, u32 dest_base, u32 dest_pitch, | |
| 237 | + | u32 start_bit, u32 dest_base, u32 dest_pitch, | |
| 240 | 238 | u32 byte_per_pixel, u32 dx, u32 dy, u32 width, | |
| 241 | 239 | u32 height, u32 fg_color, u32 bg_color, u32 rop2); | |
| 242 | 240 | ||
modified drivers/target/iscsi/iscsi_target.c
| @@ -1533,8 +1533,10 @@ __iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf, | |||
| 1533 | 1533 | */ | |
| 1534 | 1534 | if (se_cmd->transport_state & CMD_T_ABORTED) { | |
| 1535 | 1535 | if (hdr->flags & ISCSI_FLAG_CMD_FINAL && | |
| 1536 | - | --cmd->outstanding_r2ts < 1) | |
| 1536 | + | --cmd->outstanding_r2ts < 1) { | |
| 1537 | 1537 | iscsit_stop_dataout_timer(cmd); | |
| 1538 | + | target_complete_cmd(se_cmd, SAM_STAT_TASK_ABORTED); | |
| 1539 | + | } | |
| 1538 | 1540 | ||
| 1539 | 1541 | return iscsit_dump_data_payload(conn, payload_length, 1); | |
| 1540 | 1542 | } | |
modified drivers/target/iscsi/iscsi_target_login.c
| @@ -47,7 +47,7 @@ static struct iscsi_login *iscsi_login_init_conn(struct iscsit_conn *conn) | |||
| 47 | 47 | login->conn = conn; | |
| 48 | 48 | login->first_request = 1; | |
| 49 | 49 | ||
| 50 | - | login->req_buf = kzalloc(MAX_KEY_VALUE_PAIRS, GFP_KERNEL); | |
| 50 | + | login->req_buf = kzalloc(MAX_KEY_VALUE_PAIRS + 1, GFP_KERNEL); | |
| 51 | 51 | if (!login->req_buf) { | |
| 52 | 52 | pr_err("Unable to allocate memory for response buffer.\n"); | |
| 53 | 53 | goto out_login; | |
modified drivers/tee/qcomtee/user_obj.c
| @@ -230,8 +230,7 @@ static int qcomtee_user_object_dispatch(struct qcomtee_object_invoke_ctx *oic, | |||
| 230 | 230 | struct qcomtee_context_data *ctxdata = uo->ctx->data; | |
| 231 | 231 | int errno; | |
| 232 | 232 | ||
| 233 | - | struct qcomtee_ureq *ureq __free(kfree) = kzalloc(sizeof(*ureq), | |
| 234 | - | GFP_KERNEL); | |
| 233 | + | struct qcomtee_ureq *ureq __free(kfree) = kzalloc_obj(*ureq); | |
| 235 | 234 | if (!ureq) | |
| 236 | 235 | return -ENOMEM; | |
| 237 | 236 | ||
modified drivers/thermal/thermal_sysfs.c
| @@ -400,8 +400,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz) | |||
| 400 | 400 | struct thermal_trip_attrs *trip_attrs = &td->trip_attrs; | |
| 401 | 401 | ||
| 402 | 402 | /* create trip type attribute */ | |
| 403 | - | snprintf(trip_attrs->type.name, THERMAL_NAME_LENGTH, | |
| 404 | - | "trip_point_%d_type", i); | |
| 403 | + | scnprintf(trip_attrs->type.name, sizeof(trip_attrs->type.name), | |
| 404 | + | "trip_point_%d_type", i); | |
| 405 | 405 | ||
| 406 | 406 | sysfs_attr_init(&trip_attrs->type.attr.attr); | |
| 407 | 407 | trip_attrs->type.attr.attr.name = trip_attrs->type.name; | |
| @@ -410,8 +410,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz) | |||
| 410 | 410 | attrs[i] = &trip_attrs->type.attr.attr; | |
| 411 | 411 | ||
| 412 | 412 | /* create trip temp attribute */ | |
| 413 | - | snprintf(trip_attrs->temp.name, THERMAL_NAME_LENGTH, | |
| 414 | - | "trip_point_%d_temp", i); | |
| 413 | + | scnprintf(trip_attrs->temp.name, sizeof(trip_attrs->temp.name), | |
| 414 | + | "trip_point_%d_temp", i); | |
| 415 | 415 | ||
| 416 | 416 | sysfs_attr_init(&trip_attrs->temp.attr.attr); | |
| 417 | 417 | trip_attrs->temp.attr.attr.name = trip_attrs->temp.name; | |
| @@ -423,8 +423,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz) | |||
| 423 | 423 | } | |
| 424 | 424 | attrs[i + tz->num_trips] = &trip_attrs->temp.attr.attr; | |
| 425 | 425 | ||
| 426 | - | snprintf(trip_attrs->hyst.name, THERMAL_NAME_LENGTH, | |
| 427 | - | "trip_point_%d_hyst", i); | |
| 426 | + | scnprintf(trip_attrs->hyst.name, sizeof(trip_attrs->hyst.name), | |
| 427 | + | "trip_point_%d_hyst", i); | |
| 428 | 428 | ||
| 429 | 429 | sysfs_attr_init(&trip_attrs->hyst.attr.attr); | |
| 430 | 430 | trip_attrs->hyst.attr.attr.name = trip_attrs->hyst.name; | |
modified drivers/thunderbolt/stream.c
| @@ -408,8 +408,7 @@ static int tbstream_dev_alloc_rx_buffers(struct tbstream_dev *sdev) | |||
| 408 | 408 | size_t ring_size = tb_ring_size(sdev->rx_ring.ring); | |
| 409 | 409 | int i; | |
| 410 | 410 | ||
| 411 | - | sdev->rx_ring.frames = kcalloc(ring_size, sizeof(struct tbstream_frame), | |
| 412 | - | GFP_KERNEL); | |
| 411 | + | sdev->rx_ring.frames = kzalloc_objs(struct tbstream_frame, ring_size); | |
| 413 | 412 | if (!sdev->rx_ring.frames) | |
| 414 | 413 | return -ENOMEM; | |
| 415 | 414 | ||
| @@ -463,8 +462,7 @@ static int tbstream_dev_alloc_tx_buffers(struct tbstream_dev *sdev) | |||
| 463 | 462 | size_t ring_size = tb_ring_size(sdev->tx_ring.ring); | |
| 464 | 463 | int i; | |
| 465 | 464 | ||
| 466 | - | sdev->tx_ring.frames = kcalloc(ring_size, sizeof(struct tbstream_frame), | |
| 467 | - | GFP_KERNEL); | |
| 465 | + | sdev->tx_ring.frames = kzalloc_objs(struct tbstream_frame, ring_size); | |
| 468 | 466 | if (!sdev->tx_ring.frames) | |
| 469 | 467 | return -ENOMEM; | |
| 470 | 468 | ||
| @@ -1498,7 +1496,7 @@ tbstream_dev_make_group(struct config_group *group, const char *name) | |||
| 1498 | 1496 | if (strlen(name) > TB_PROPERTY_KEY_SIZE) | |
| 1499 | 1497 | return ERR_PTR(-ENAMETOOLONG); | |
| 1500 | 1498 | ||
| 1501 | - | sdev = kzalloc_obj(*sdev, GFP_KERNEL); | |
| 1499 | + | sdev = kzalloc_obj(*sdev); | |
| 1502 | 1500 | if (!sdev) | |
| 1503 | 1501 | return ERR_PTR(-ENOMEM); | |
| 1504 | 1502 | ||
| @@ -1592,7 +1590,7 @@ tbstream_make_group(struct config_group *group, const char *name) | |||
| 1592 | 1590 | if (sscanf(name, "%u-%llx.%u", &domain, &route, &index) != 3) | |
| 1593 | 1591 | return ERR_PTR(-EINVAL); | |
| 1594 | 1592 | ||
| 1595 | - | sg = kzalloc_obj(*sg, GFP_KERNEL); | |
| 1593 | + | sg = kzalloc_obj(*sg); | |
| 1596 | 1594 | if (!sg) | |
| 1597 | 1595 | return ERR_PTR(-ENOMEM); | |
| 1598 | 1596 | ||
| @@ -1698,7 +1696,7 @@ static int tbstream_probe(struct tb_service *svc) | |||
| 1698 | 1696 | { | |
| 1699 | 1697 | struct tbstream *stream; | |
| 1700 | 1698 | ||
| 1701 | - | stream = kzalloc_obj(*stream, GFP_KERNEL); | |
| 1699 | + | stream = kzalloc_obj(*stream); | |
| 1702 | 1700 | if (!stream) | |
| 1703 | 1701 | return -ENOMEM; | |
| 1704 | 1702 | ||
modified drivers/tty/moxa.c
| @@ -954,8 +954,7 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev) | |||
| 954 | 954 | unsigned int i, first_idx; | |
| 955 | 955 | int ret; | |
| 956 | 956 | ||
| 957 | - | brd->ports = kcalloc(MAX_PORTS_PER_BOARD, sizeof(*brd->ports), | |
| 958 | - | GFP_KERNEL); | |
| 957 | + | brd->ports = kzalloc_objs(*brd->ports, MAX_PORTS_PER_BOARD); | |
| 959 | 958 | if (brd->ports == NULL) { | |
| 960 | 959 | printk(KERN_ERR "cannot allocate memory for ports\n"); | |
| 961 | 960 | ret = -ENOMEM; | |
modified drivers/tty/vt/consolemap.c
| @@ -776,7 +776,8 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, | |||
| 776 | 776 | struct uni_pagedict *dict; | |
| 777 | 777 | unsigned int d, r, g; | |
| 778 | 778 | ||
| 779 | - | struct unipair *unilist __free(kvfree) = kvmalloc_array(ct, sizeof(*unilist), GFP_KERNEL); | |
| 779 | + | struct unipair *unilist __free(kvfree) = kvmalloc_objs(*unilist, ct, | |
| 780 | + | GFP_KERNEL); | |
| 780 | 781 | if (!unilist) | |
| 781 | 782 | return -ENOMEM; | |
| 782 | 783 | ||
modified drivers/tty/vt/vt.c
| @@ -4986,8 +4986,8 @@ static int con_font_set(struct vc_data *vc, const struct console_font_op *op) | |||
| 4986 | 4986 | if (!vc->vc_sw->con_font_set) | |
| 4987 | 4987 | return -ENOSYS; | |
| 4988 | 4988 | ||
| 4989 | - | if (vc_is_sel(vc)) | |
| 4990 | - | clear_selection(); | |
| 4989 | + | /* hide selection and cursor prior font changes */ | |
| 4990 | + | hide_cursor(vc); | |
| 4991 | 4991 | ||
| 4992 | 4992 | return vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags); | |
| 4993 | 4993 | } | |
| @@ -5011,8 +5011,9 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op) | |||
| 5011 | 5011 | if (!vc->vc_sw->con_font_default) | |
| 5012 | 5012 | return -ENOSYS; | |
| 5013 | 5013 | ||
| 5014 | - | if (vc_is_sel(vc)) | |
| 5015 | - | clear_selection(); | |
| 5014 | + | /* hide selection and cursor prior font changes */ | |
| 5015 | + | hide_cursor(vc); | |
| 5016 | + | ||
| 5016 | 5017 | int ret = vc->vc_sw->con_font_default(vc, &font, s); | |
| 5017 | 5018 | if (ret) | |
| 5018 | 5019 | return ret; | |
modified drivers/ufs/core/ufs-txeq.c
| @@ -1073,7 +1073,7 @@ static int __ufshcd_tx_eqtr(struct ufs_hba *hba, | |||
| 1073 | 1073 | struct ufs_pa_layer_attr *pwr_mode) | |
| 1074 | 1074 | { | |
| 1075 | 1075 | struct ufshcd_tx_eqtr_data *eqtr_data __free(kfree) = | |
| 1076 | - | kzalloc(sizeof(*eqtr_data), GFP_KERNEL); | |
| 1076 | + | kzalloc_obj(*eqtr_data); | |
| 1077 | 1077 | struct tx_eqtr_iter h_iter = {}; | |
| 1078 | 1078 | struct tx_eqtr_iter d_iter = {}; | |
| 1079 | 1079 | u32 gear = pwr_mode->gear_tx; | |
modified drivers/ufs/host/ufs-qcom.c
| @@ -715,6 +715,7 @@ static void ufs_qcom_link_startup_post_change(struct ufs_hba *hba) | |||
| 715 | 715 | static int ufs_qcom_link_startup_notify(struct ufs_hba *hba, | |
| 716 | 716 | enum ufs_notify_change_status status) | |
| 717 | 717 | { | |
| 718 | + | struct ufs_qcom_host *host = ufshcd_get_variant(hba); | |
| 718 | 719 | int err = 0; | |
| 719 | 720 | ||
| 720 | 721 | switch (status) { | |
| @@ -737,6 +738,14 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba, | |||
| 737 | 738 | */ | |
| 738 | 739 | err = ufshcd_disable_host_tx_lcc(hba); | |
| 739 | 740 | ||
| 741 | + | /* | |
| 742 | + | * Restore HS/LS link startup mode set by bootloader | |
| 743 | + | * after UFS reset clears REG_UFS_DEBUG_SPARE_CFG. | |
| 744 | + | */ | |
| 745 | + | if (host->hw_ver.major > 0x6 || | |
| 746 | + | (host->hw_ver.major == 0x6 && host->hw_ver.minor >= 0x2)) | |
| 747 | + | ufshcd_writel(hba, host->boot_spare_cfg, | |
| 748 | + | REG_UFS_DEBUG_SPARE_CFG); | |
| 740 | 749 | break; | |
| 741 | 750 | case POST_CHANGE: | |
| 742 | 751 | ufs_qcom_link_startup_post_change(hba); | |
| @@ -1325,7 +1334,7 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba) | |||
| 1325 | 1334 | static void ufs_qcom_set_phy_gear(struct ufs_qcom_host *host) | |
| 1326 | 1335 | { | |
| 1327 | 1336 | struct ufs_host_params *host_params = &host->host_params; | |
| 1328 | - | u32 val, dev_major; | |
| 1337 | + | u32 dev_major; | |
| 1329 | 1338 | ||
| 1330 | 1339 | /* | |
| 1331 | 1340 | * Default to powering up the PHY to the max gear possible, which is | |
| @@ -1344,8 +1353,8 @@ static void ufs_qcom_set_phy_gear(struct ufs_qcom_host *host) | |||
| 1344 | 1353 | */ | |
| 1345 | 1354 | host->phy_gear = UFS_HS_G2; | |
| 1346 | 1355 | } else if (host->hw_ver.major >= 0x5) { | |
| 1347 | - | val = ufshcd_readl(host->hba, REG_UFS_DEBUG_SPARE_CFG); | |
| 1348 | - | dev_major = FIELD_GET(UFS_DEV_VER_MAJOR_MASK, val); | |
| 1356 | + | host->boot_spare_cfg = ufshcd_readl(host->hba, REG_UFS_DEBUG_SPARE_CFG); | |
| 1357 | + | dev_major = FIELD_GET(UFS_DEV_VER_MAJOR_MASK, host->boot_spare_cfg); | |
| 1349 | 1358 | ||
| 1350 | 1359 | /* | |
| 1351 | 1360 | * Since the UFS device version is populated, let's remove the | |
| @@ -2282,7 +2291,7 @@ static void ufs_qcom_config_scaling_param(struct ufs_hba *hba, | |||
| 2282 | 2291 | p->polling_ms = 60; | |
| 2283 | 2292 | p->timer = DEVFREQ_TIMER_DELAYED; | |
| 2284 | 2293 | d->upthreshold = 70; | |
| 2285 | - | d->downdifferential = 5; | |
| 2294 | + | d->downdifferential = 65; | |
| 2286 | 2295 | ||
| 2287 | 2296 | hba->clk_scaling.suspend_on_no_request = true; | |
| 2288 | 2297 | } | |
| @@ -2761,7 +2770,7 @@ static int ufs_qcom_get_rx_fom(struct ufs_hba *hba, | |||
| 2761 | 2770 | struct tx_eqtr_iter *d_iter) | |
| 2762 | 2771 | { | |
| 2763 | 2772 | struct ufshcd_tx_eq_params *params __free(kfree) = | |
| 2764 | - | kzalloc(sizeof(*params), GFP_KERNEL); | |
| 2773 | + | kzalloc_obj(*params); | |
| 2765 | 2774 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); | |
| 2766 | 2775 | struct ufs_pa_layer_attr old_pwr_info; | |
| 2767 | 2776 | u32 fom[PA_MAXDATALANES] = { 0 }; | |
modified drivers/ufs/host/ufs-qcom.h
| @@ -361,6 +361,7 @@ struct ufs_qcom_host { | |||
| 361 | 361 | bool esi_enabled; | |
| 362 | 362 | ||
| 363 | 363 | u32 saved_tx_eq_g1_setting; | |
| 364 | + | u32 boot_spare_cfg; | |
| 364 | 365 | }; | |
| 365 | 366 | ||
| 366 | 367 | struct ufs_qcom_drvdata { | |
modified drivers/ufs/host/ufshcd-pci.c
| @@ -181,6 +181,25 @@ static int ufs_intel_lkf_pwr_change_notify(struct ufs_hba *hba, | |||
| 181 | 181 | return err; | |
| 182 | 182 | } | |
| 183 | 183 | ||
| 184 | + | static int ufs_intel_nvl_pwr_change_notify(struct ufs_hba *hba, | |
| 185 | + | enum ufs_notify_change_status stage, | |
| 186 | + | struct ufs_pa_layer_attr *dev_req_params) | |
| 187 | + | { | |
| 188 | + | int adapt_val; | |
| 189 | + | ||
| 190 | + | if (stage != PRE_CHANGE || hba->ufs_version < ufshci_version(4, 0)) | |
| 191 | + | return 0; | |
| 192 | + | ||
| 193 | + | if (dev_req_params->pwr_tx == FAST_MODE || dev_req_params->pwr_tx == FASTAUTO_MODE) | |
| 194 | + | adapt_val = PA_INITIAL_ADAPT; | |
| 195 | + | else | |
| 196 | + | adapt_val = PA_NO_ADAPT; | |
| 197 | + | ||
| 198 | + | ufshcd_dme_configure_adapt(hba, dev_req_params->gear_tx, adapt_val); | |
| 199 | + | ||
| 200 | + | return 0; | |
| 201 | + | } | |
| 202 | + | ||
| 184 | 203 | static int ufs_intel_lkf_apply_dev_quirks(struct ufs_hba *hba) | |
| 185 | 204 | { | |
| 186 | 205 | u32 granularity, peer_granularity; | |
| @@ -441,6 +460,43 @@ static int ufs_intel_mtl_init(struct ufs_hba *hba) | |||
| 441 | 460 | return ufs_intel_common_init(hba); | |
| 442 | 461 | } | |
| 443 | 462 | ||
| 463 | + | static int ufs_intel_mcq_config_resource(struct ufs_hba *hba) | |
| 464 | + | { | |
| 465 | + | hba->mcq_base = hba->mmio_base + ufshcd_mcq_queue_cfg_addr(hba); | |
| 466 | + | ||
| 467 | + | return 0; | |
| 468 | + | } | |
| 469 | + | ||
| 470 | + | /* | |
| 471 | + | * This Intel UFS4.0 controller maps MCQ doorbell and interrupt-status | |
| 472 | + | * registers into the same PCI BAR as the legacy HCI space, at this | |
| 473 | + | * fixed offset/stride. | |
| 474 | + | */ | |
| 475 | + | #define UFS_INTEL_SQDAO0 0x2800 | |
| 476 | + | #define UFS_INTEL_SQISAO0 0x2814 | |
| 477 | + | #define UFS_INTEL_CQDAO0 0x281C | |
| 478 | + | #define UFS_INTEL_CQISAO0 0x2824 | |
| 479 | + | #define UFS_INTEL_MCQ_STRIDE 0x30 | |
| 480 | + | ||
| 481 | + | static int ufs_intel_op_runtime_config(struct ufs_hba *hba) | |
| 482 | + | { | |
| 483 | + | struct ufshcd_mcq_opr_info_t *opr; | |
| 484 | + | int i; | |
| 485 | + | ||
| 486 | + | hba->mcq_opr[OPR_SQD].offset = UFS_INTEL_SQDAO0; | |
| 487 | + | hba->mcq_opr[OPR_SQIS].offset = UFS_INTEL_SQISAO0; | |
| 488 | + | hba->mcq_opr[OPR_CQD].offset = UFS_INTEL_CQDAO0; | |
| 489 | + | hba->mcq_opr[OPR_CQIS].offset = UFS_INTEL_CQISAO0; | |
| 490 | + | ||
| 491 | + | for (i = 0; i < OPR_MAX; i++) { | |
| 492 | + | opr = &hba->mcq_opr[i]; | |
| 493 | + | opr->stride = UFS_INTEL_MCQ_STRIDE; | |
| 494 | + | opr->base = hba->mmio_base + opr->offset; | |
| 495 | + | } | |
| 496 | + | ||
| 497 | + | return 0; | |
| 498 | + | } | |
| 499 | + | ||
| 444 | 500 | static int ufs_qemu_get_hba_mac(struct ufs_hba *hba) | |
| 445 | 501 | { | |
| 446 | 502 | return MAX_SUPP_MAC; | |
| @@ -527,6 +583,9 @@ static struct ufs_hba_variant_ops ufs_intel_mtl_hba_vops = { | |||
| 527 | 583 | .exit = ufs_intel_common_exit, | |
| 528 | 584 | .hce_enable_notify = ufs_intel_hce_enable_notify, | |
| 529 | 585 | .link_startup_notify = ufs_intel_link_startup_notify, | |
| 586 | + | .pwr_change_notify = ufs_intel_nvl_pwr_change_notify, | |
| 587 | + | .mcq_config_resource = ufs_intel_mcq_config_resource, | |
| 588 | + | .op_runtime_config = ufs_intel_op_runtime_config, | |
| 530 | 589 | .resume = ufs_intel_resume, | |
| 531 | 590 | .device_reset = ufs_intel_device_reset, | |
| 532 | 591 | }; | |
modified drivers/usb/cdns3/cdnsp-gadget.c
| @@ -1338,7 +1338,6 @@ static int cdnsp_run(struct cdnsp_device *pdev, | |||
| 1338 | 1338 | ||
| 1339 | 1339 | cdnsp_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); | |
| 1340 | 1340 | ||
| 1341 | - | ||
| 1342 | 1341 | ret = cdnsp_start(pdev); | |
| 1343 | 1342 | if (ret) { | |
| 1344 | 1343 | ret = -ENODEV; | |
| @@ -1837,6 +1836,82 @@ static void cdnsp_get_rev_cap(struct cdnsp_device *pdev) | |||
| 1837 | 1836 | readl(&pdev->rev_cap->tx_buff_size)); | |
| 1838 | 1837 | } | |
| 1839 | 1838 | ||
| 1839 | + | static void cdnsp_set_event_deq(struct cdnsp_device *pdev) | |
| 1840 | + | { | |
| 1841 | + | dma_addr_t deq; | |
| 1842 | + | u64 temp; | |
| 1843 | + | ||
| 1844 | + | deq = cdnsp_trb_virt_to_dma(pdev->event_ring->deq_seg, | |
| 1845 | + | pdev->event_ring->dequeue); | |
| 1846 | + | ||
| 1847 | + | /* Update controller event ring dequeue pointer */ | |
| 1848 | + | temp = cdnsp_read_64(&pdev->ir_set->erst_dequeue); | |
| 1849 | + | temp &= ERST_PTR_MASK; | |
| 1850 | + | ||
| 1851 | + | /* | |
| 1852 | + | * Don't clear the EHB bit (which is RW1C) because | |
| 1853 | + | * there might be more events to service. | |
| 1854 | + | */ | |
| 1855 | + | temp &= ~ERST_EHB; | |
| 1856 | + | ||
| 1857 | + | cdnsp_write_64(((u64)deq & (u64)~ERST_PTR_MASK) | temp, | |
| 1858 | + | &pdev->ir_set->erst_dequeue); | |
| 1859 | + | } | |
| 1860 | + | ||
| 1861 | + | static void cdnsp_add_interrupter(struct cdnsp_device *pdev) | |
| 1862 | + | { | |
| 1863 | + | u64 erst_base; | |
| 1864 | + | u32 erst_size; | |
| 1865 | + | ||
| 1866 | + | /* Set ERST count with the number of entries in the segment table. */ | |
| 1867 | + | erst_size = readl(&pdev->ir_set->erst_size); | |
| 1868 | + | erst_size &= ERST_SIZE_MASK; | |
| 1869 | + | erst_size |= ERST_NUM_SEGS; | |
| 1870 | + | writel(erst_size, &pdev->ir_set->erst_size); | |
| 1871 | + | ||
| 1872 | + | /* Set the segment table base address. */ | |
| 1873 | + | erst_base = cdnsp_read_64(&pdev->ir_set->erst_base); | |
| 1874 | + | erst_base &= ERST_PTR_MASK; | |
| 1875 | + | erst_base |= (pdev->erst.erst_dma_addr & (u64)~ERST_PTR_MASK); | |
| 1876 | + | cdnsp_write_64(erst_base, &pdev->ir_set->erst_base); | |
| 1877 | + | ||
| 1878 | + | /* Set the event ring dequeue address. */ | |
| 1879 | + | cdnsp_set_event_deq(pdev); | |
| 1880 | + | } | |
| 1881 | + | ||
| 1882 | + | /* Set up basic CDNSP registers */ | |
| 1883 | + | static void cdnsp_init(struct cdnsp_device *pdev) | |
| 1884 | + | { | |
| 1885 | + | unsigned int val; | |
| 1886 | + | u64 val_64; | |
| 1887 | + | ||
| 1888 | + | val = readl(&pdev->op_regs->config_reg); | |
| 1889 | + | val |= ((val & ~MAX_DEVS) | CDNSP_DEV_MAX_SLOTS) | CONFIG_U3E; | |
| 1890 | + | writel(val, &pdev->op_regs->config_reg); | |
| 1891 | + | ||
| 1892 | + | /* Initialize the Command ring */ | |
| 1893 | + | cdnsp_ring_init(pdev, pdev->cmd_ring); | |
| 1894 | + | ||
| 1895 | + | /* Set the address in the Command Ring Control register */ | |
| 1896 | + | val_64 = cdnsp_read_64(&pdev->op_regs->cmd_ring); | |
| 1897 | + | val_64 = (val_64 & (u64)CMD_RING_RSVD_BITS) | | |
| 1898 | + | (pdev->cmd_ring->first_seg->dma & (u64)~CMD_RING_RSVD_BITS) | | |
| 1899 | + | pdev->cmd_ring->cycle_state; | |
| 1900 | + | cdnsp_write_64(val_64, &pdev->op_regs->cmd_ring); | |
| 1901 | + | ||
| 1902 | + | /* Set Device Context Base Address Array pointer */ | |
| 1903 | + | cdnsp_write_64(pdev->dcbaa->dma, &pdev->op_regs->dcbaa_ptr); | |
| 1904 | + | ||
| 1905 | + | /* Set Doorbell array pointer */ | |
| 1906 | + | val = readl(&pdev->cap_regs->db_off); | |
| 1907 | + | val &= DBOFF_MASK; | |
| 1908 | + | pdev->dba = (void __iomem *)pdev->cap_regs + val; | |
| 1909 | + | ||
| 1910 | + | /* Initialize the Primary interrupter */ | |
| 1911 | + | cdnsp_ring_init(pdev, pdev->event_ring); | |
| 1912 | + | cdnsp_add_interrupter(pdev); | |
| 1913 | + | } | |
| 1914 | + | ||
| 1840 | 1915 | static int cdnsp_gen_setup(struct cdnsp_device *pdev) | |
| 1841 | 1916 | { | |
| 1842 | 1917 | int ret; | |
| @@ -1902,6 +1977,8 @@ static int cdnsp_gen_setup(struct cdnsp_device *pdev) | |||
| 1902 | 1977 | if (ret) | |
| 1903 | 1978 | return ret; | |
| 1904 | 1979 | ||
| 1980 | + | cdnsp_init(pdev); | |
| 1981 | + | ||
| 1905 | 1982 | /* | |
| 1906 | 1983 | * Software workaround for U1: after transition | |
| 1907 | 1984 | * to U1 the controller starts gating clock, and in some cases, | |
| @@ -2031,9 +2108,6 @@ static int cdnsp_gadget_suspend(struct cdns *cdns, bool do_wakeup) | |||
| 2031 | 2108 | struct cdnsp_device *pdev = cdns->gadget_dev; | |
| 2032 | 2109 | unsigned long flags; | |
| 2033 | 2110 | ||
| 2034 | - | if (pdev->link_state == XDEV_U3) | |
| 2035 | - | return 0; | |
| 2036 | - | ||
| 2037 | 2111 | spin_lock_irqsave(&pdev->lock, flags); | |
| 2038 | 2112 | cdnsp_disconnect_gadget(pdev); | |
| 2039 | 2113 | cdnsp_stop(pdev); | |
| @@ -2047,12 +2121,38 @@ static int cdnsp_gadget_resume(struct cdns *cdns, bool lost_power) | |||
| 2047 | 2121 | struct cdnsp_device *pdev = cdns->gadget_dev; | |
| 2048 | 2122 | enum usb_device_speed max_speed; | |
| 2049 | 2123 | unsigned long flags; | |
| 2124 | + | bool context_lost; | |
| 2125 | + | u32 val; | |
| 2050 | 2126 | int ret; | |
| 2051 | 2127 | ||
| 2052 | 2128 | if (!pdev->gadget_driver) | |
| 2053 | 2129 | return 0; | |
| 2054 | 2130 | ||
| 2055 | 2131 | spin_lock_irqsave(&pdev->lock, flags); | |
| 2132 | + | val = readl(&pdev->port3x_regs->mode_2); | |
| 2133 | + | context_lost = !!(val & CFG_3XPORT_U1_PIPE_CLK_GATE_EN) || lost_power; | |
| 2134 | + | ||
| 2135 | + | if (context_lost) { | |
| 2136 | + | cdnsp_halt(pdev); | |
| 2137 | + | cdnsp_set_apb_timeout_value(pdev); | |
| 2138 | + | ||
| 2139 | + | /* Reset the internal controller memory state and registers. */ | |
| 2140 | + | ret = cdnsp_reset(pdev); | |
| 2141 | + | if (ret) | |
| 2142 | + | goto unlock; | |
| 2143 | + | ||
| 2144 | + | val = readl(&pdev->port3x_regs->mode_2); | |
| 2145 | + | val &= ~CFG_3XPORT_U1_PIPE_CLK_GATE_EN; | |
| 2146 | + | writel(val, &pdev->port3x_regs->mode_2); | |
| 2147 | + | ||
| 2148 | + | cdnsp_clear_cmd_ring(pdev); | |
| 2149 | + | ||
| 2150 | + | memset(pdev->event_ring->first_seg->trbs, 0, | |
| 2151 | + | sizeof(union cdnsp_trb) * (TRBS_PER_SEGMENT)); | |
| 2152 | + | ||
| 2153 | + | cdnsp_init(pdev); | |
| 2154 | + | } | |
| 2155 | + | ||
| 2056 | 2156 | max_speed = pdev->gadget_driver->max_speed; | |
| 2057 | 2157 | ||
| 2058 | 2158 | /* Limit speed if necessary. */ | |
| @@ -2060,9 +2160,10 @@ static int cdnsp_gadget_resume(struct cdns *cdns, bool lost_power) | |||
| 2060 | 2160 | ||
| 2061 | 2161 | ret = cdnsp_run(pdev, max_speed); | |
| 2062 | 2162 | ||
| 2063 | - | if (pdev->link_state == XDEV_U3) | |
| 2163 | + | if (!context_lost && pdev->link_state == XDEV_U3) | |
| 2064 | 2164 | __cdnsp_gadget_wakeup(pdev); | |
| 2065 | 2165 | ||
| 2166 | + | unlock: | |
| 2066 | 2167 | spin_unlock_irqrestore(&pdev->lock, flags); | |
| 2067 | 2168 | ||
| 2068 | 2169 | return ret; | |
modified drivers/usb/cdns3/cdnsp-gadget.h
| @@ -1510,6 +1510,7 @@ int cdnsp_endpoint_init(struct cdnsp_device *pdev, | |||
| 1510 | 1510 | int cdnsp_ring_expansion(struct cdnsp_device *pdev, | |
| 1511 | 1511 | struct cdnsp_ring *ring, | |
| 1512 | 1512 | unsigned int num_trbs, gfp_t flags); | |
| 1513 | + | void cdnsp_ring_init(struct cdnsp_device *pdev, struct cdnsp_ring *ring); | |
| 1513 | 1514 | struct cdnsp_ring *cdnsp_dma_to_transfer_ring(struct cdnsp_ep *ep, u64 address); | |
| 1514 | 1515 | int cdnsp_alloc_stream_info(struct cdnsp_device *pdev, | |
| 1515 | 1516 | struct cdnsp_ep *pep, | |
modified drivers/usb/cdns3/cdnsp-mem.c
| @@ -394,13 +394,6 @@ static struct cdnsp_ring *cdnsp_ring_alloc(struct cdnsp_device *pdev, | |||
| 394 | 394 | if (ret) | |
| 395 | 395 | goto fail; | |
| 396 | 396 | ||
| 397 | - | /* Only event ring does not use link TRB. */ | |
| 398 | - | if (type != TYPE_EVENT) | |
| 399 | - | ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |= | |
| 400 | - | cpu_to_le32(LINK_TOGGLE); | |
| 401 | - | ||
| 402 | - | cdnsp_initialize_ring_info(ring); | |
| 403 | - | trace_cdnsp_ring_alloc(ring); | |
| 404 | 397 | return ring; | |
| 405 | 398 | fail: | |
| 406 | 399 | kfree(ring); | |
| @@ -603,6 +596,7 @@ int cdnsp_alloc_stream_info(struct cdnsp_device *pdev, | |||
| 603 | 596 | if (!cur_ring) | |
| 604 | 597 | goto cleanup_rings; | |
| 605 | 598 | ||
| 599 | + | cdnsp_ring_init(pdev, cur_ring); | |
| 606 | 600 | cur_ring->stream_id = cur_stream; | |
| 607 | 601 | cur_ring->trb_address_map = &stream_info->trb_address_map; | |
| 608 | 602 | ||
| @@ -698,6 +692,8 @@ static int cdnsp_alloc_priv_device(struct cdnsp_device *pdev) | |||
| 698 | 692 | if (!pdev->eps[0].ring) | |
| 699 | 693 | goto fail; | |
| 700 | 694 | ||
| 695 | + | cdnsp_ring_init(pdev, pdev->eps[0].ring); | |
| 696 | + | ||
| 701 | 697 | /* Point to output device context in dcbaa. */ | |
| 702 | 698 | pdev->dcbaa->dev_context_ptrs[1] = cpu_to_le64(pdev->out_ctx.dma); | |
| 703 | 699 | pdev->cmd.in_ctx = &pdev->in_ctx; | |
| @@ -991,6 +987,8 @@ int cdnsp_endpoint_init(struct cdnsp_device *pdev, | |||
| 991 | 987 | if (!pep->ring) | |
| 992 | 988 | return -ENOMEM; | |
| 993 | 989 | ||
| 990 | + | cdnsp_ring_init(pdev, pep->ring); | |
| 991 | + | ||
| 994 | 992 | pep->skip = false; | |
| 995 | 993 | ||
| 996 | 994 | /* Fill the endpoint context */ | |
| @@ -1096,28 +1094,6 @@ void cdnsp_mem_cleanup(struct cdnsp_device *pdev) | |||
| 1096 | 1094 | pdev->active_port = NULL; | |
| 1097 | 1095 | } | |
| 1098 | 1096 | ||
| 1099 | - | static void cdnsp_set_event_deq(struct cdnsp_device *pdev) | |
| 1100 | - | { | |
| 1101 | - | dma_addr_t deq; | |
| 1102 | - | u64 temp; | |
| 1103 | - | ||
| 1104 | - | deq = cdnsp_trb_virt_to_dma(pdev->event_ring->deq_seg, | |
| 1105 | - | pdev->event_ring->dequeue); | |
| 1106 | - | ||
| 1107 | - | /* Update controller event ring dequeue pointer */ | |
| 1108 | - | temp = cdnsp_read_64(&pdev->ir_set->erst_dequeue); | |
| 1109 | - | temp &= ERST_PTR_MASK; | |
| 1110 | - | ||
| 1111 | - | /* | |
| 1112 | - | * Don't clear the EHB bit (which is RW1C) because | |
| 1113 | - | * there might be more events to service. | |
| 1114 | - | */ | |
| 1115 | - | temp &= ~ERST_EHB; | |
| 1116 | - | ||
| 1117 | - | cdnsp_write_64(((u64)deq & (u64)~ERST_PTR_MASK) | temp, | |
| 1118 | - | &pdev->ir_set->erst_dequeue); | |
| 1119 | - | } | |
| 1120 | - | ||
| 1121 | 1097 | static void cdnsp_add_in_port(struct cdnsp_device *pdev, | |
| 1122 | 1098 | struct cdnsp_port *port, | |
| 1123 | 1099 | __le32 __iomem *addr) | |
| @@ -1226,6 +1202,36 @@ static int cdnsp_setup_port_arrays(struct cdnsp_device *pdev) | |||
| 1226 | 1202 | return 0; | |
| 1227 | 1203 | } | |
| 1228 | 1204 | ||
| 1205 | + | static void cdnsp_initialize_ring_segments(struct cdnsp_device *pdev, struct cdnsp_ring *ring) | |
| 1206 | + | { | |
| 1207 | + | struct cdnsp_segment *seg; | |
| 1208 | + | ||
| 1209 | + | /* Only event ring does not use link TRB. */ | |
| 1210 | + | if (ring->type == TYPE_EVENT) | |
| 1211 | + | return; | |
| 1212 | + | ||
| 1213 | + | seg = ring->first_seg; | |
| 1214 | + | ||
| 1215 | + | while (seg) { | |
| 1216 | + | struct cdnsp_segment *next = seg->next; | |
| 1217 | + | ||
| 1218 | + | cdnsp_link_segments(pdev, seg, next, ring->type); | |
| 1219 | + | if (next == ring->first_seg) | |
| 1220 | + | break; | |
| 1221 | + | ||
| 1222 | + | seg = next; | |
| 1223 | + | } | |
| 1224 | + | ||
| 1225 | + | ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |= cpu_to_le32(LINK_TOGGLE); | |
| 1226 | + | } | |
| 1227 | + | ||
| 1228 | + | void cdnsp_ring_init(struct cdnsp_device *pdev, struct cdnsp_ring *ring) | |
| 1229 | + | { | |
| 1230 | + | cdnsp_initialize_ring_segments(pdev, ring); | |
| 1231 | + | cdnsp_initialize_ring_info(ring); | |
| 1232 | + | trace_cdnsp_ring_alloc(ring); | |
| 1233 | + | } | |
| 1234 | + | ||
| 1229 | 1235 | /* | |
| 1230 | 1236 | * Initialize memory for CDNSP (one-time init). | |
| 1231 | 1237 | * | |
| @@ -1237,10 +1243,8 @@ int cdnsp_mem_init(struct cdnsp_device *pdev) | |||
| 1237 | 1243 | { | |
| 1238 | 1244 | struct device *dev = pdev->dev; | |
| 1239 | 1245 | int ret = -ENOMEM; | |
| 1240 | - | unsigned int val; | |
| 1241 | 1246 | dma_addr_t dma; | |
| 1242 | 1247 | u32 page_size; | |
| 1243 | - | u64 val_64; | |
| 1244 | 1248 | ||
| 1245 | 1249 | /* | |
| 1246 | 1250 | * Use 4K pages, since that's common and the minimum the | |
| @@ -1248,10 +1252,6 @@ int cdnsp_mem_init(struct cdnsp_device *pdev) | |||
| 1248 | 1252 | */ | |
| 1249 | 1253 | page_size = 1 << 12; | |
| 1250 | 1254 | ||
| 1251 | - | val = readl(&pdev->op_regs->config_reg); | |
| 1252 | - | val |= ((val & ~MAX_DEVS) | CDNSP_DEV_MAX_SLOTS) | CONFIG_U3E; | |
| 1253 | - | writel(val, &pdev->op_regs->config_reg); | |
| 1254 | - | ||
| 1255 | 1255 | /* | |
| 1256 | 1256 | * Doorbell array must be physically contiguous | |
| 1257 | 1257 | * and 64-byte (cache line) aligned. | |
| @@ -1263,8 +1263,6 @@ int cdnsp_mem_init(struct cdnsp_device *pdev) | |||
| 1263 | 1263 | ||
| 1264 | 1264 | pdev->dcbaa->dma = dma; | |
| 1265 | 1265 | ||
| 1266 | - | cdnsp_write_64(dma, &pdev->op_regs->dcbaa_ptr); | |
| 1267 | - | ||
| 1268 | 1266 | /* | |
| 1269 | 1267 | * Initialize the ring segment pool. The ring must be a contiguous | |
| 1270 | 1268 | * structure comprised of TRBs. The TRBs must be 16 byte aligned, | |
| @@ -1290,17 +1288,6 @@ int cdnsp_mem_init(struct cdnsp_device *pdev) | |||
| 1290 | 1288 | if (!pdev->cmd_ring) | |
| 1291 | 1289 | goto destroy_device_pool; | |
| 1292 | 1290 | ||
| 1293 | - | /* Set the address in the Command Ring Control register */ | |
| 1294 | - | val_64 = cdnsp_read_64(&pdev->op_regs->cmd_ring); | |
| 1295 | - | val_64 = (val_64 & (u64)CMD_RING_RSVD_BITS) | | |
| 1296 | - | (pdev->cmd_ring->first_seg->dma & (u64)~CMD_RING_RSVD_BITS) | | |
| 1297 | - | pdev->cmd_ring->cycle_state; | |
| 1298 | - | cdnsp_write_64(val_64, &pdev->op_regs->cmd_ring); | |
| 1299 | - | ||
| 1300 | - | val = readl(&pdev->cap_regs->db_off); | |
| 1301 | - | val &= DBOFF_MASK; | |
| 1302 | - | pdev->dba = (void __iomem *)pdev->cap_regs + val; | |
| 1303 | - | ||
| 1304 | 1291 | /* Set ir_set to interrupt register set 0 */ | |
| 1305 | 1292 | pdev->ir_set = &pdev->run_regs->ir_set[0]; | |
| 1306 | 1293 | ||
| @@ -1317,21 +1304,6 @@ int cdnsp_mem_init(struct cdnsp_device *pdev) | |||
| 1317 | 1304 | if (ret) | |
| 1318 | 1305 | goto free_event_ring; | |
| 1319 | 1306 | ||
| 1320 | - | /* Set ERST count with the number of entries in the segment table. */ | |
| 1321 | - | val = readl(&pdev->ir_set->erst_size); | |
| 1322 | - | val &= ERST_SIZE_MASK; | |
| 1323 | - | val |= ERST_NUM_SEGS; | |
| 1324 | - | writel(val, &pdev->ir_set->erst_size); | |
| 1325 | - | ||
| 1326 | - | /* Set the segment table base address. */ | |
| 1327 | - | val_64 = cdnsp_read_64(&pdev->ir_set->erst_base); | |
| 1328 | - | val_64 &= ERST_PTR_MASK; | |
| 1329 | - | val_64 |= (pdev->erst.erst_dma_addr & (u64)~ERST_PTR_MASK); | |
| 1330 | - | cdnsp_write_64(val_64, &pdev->ir_set->erst_base); | |
| 1331 | - | ||
| 1332 | - | /* Set the event ring dequeue address. */ | |
| 1333 | - | cdnsp_set_event_deq(pdev); | |
| 1334 | - | ||
| 1335 | 1307 | ret = cdnsp_setup_port_arrays(pdev); | |
| 1336 | 1308 | if (ret) | |
| 1337 | 1309 | goto free_erst; | |
modified drivers/usb/dwc3/dwc3-google.c
| @@ -442,6 +442,7 @@ static int dwc3_google_probe(struct platform_device *pdev) | |||
| 442 | 442 | probe_data.dwc = &google->dwc; | |
| 443 | 443 | probe_data.res = res; | |
| 444 | 444 | probe_data.ignore_clocks_and_resets = true; | |
| 445 | + | probe_data.properties = DWC3_DEFAULT_PROPERTIES; | |
| 445 | 446 | ret = dwc3_core_probe(&probe_data); | |
| 446 | 447 | if (ret) { | |
| 447 | 448 | ret = dev_err_probe(dev, ret, "failed to register DWC3 Core\n"); | |
modified drivers/usb/dwc3/ep0.c
| @@ -304,7 +304,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) | |||
| 304 | 304 | ||
| 305 | 305 | dwc3_ep->flags &= ~DWC3_EP_DELAY_STOP; | |
| 306 | 306 | if (dwc->connected) | |
| 307 | - | dwc3_stop_active_transfer(dwc3_ep, true, true); | |
| 307 | + | dwc3_stop_active_transfer(dwc3_ep, false, true); | |
| 308 | 308 | else | |
| 309 | 309 | dwc3_remove_requests(dwc, dwc3_ep, -ESHUTDOWN); | |
| 310 | 310 | } | |
modified drivers/usb/dwc3/gadget.c
| @@ -1004,7 +1004,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action) | |||
| 1004 | 1004 | * controller to generate an ERDY to initiate the | |
| 1005 | 1005 | * stream. | |
| 1006 | 1006 | */ | |
| 1007 | - | dwc3_stop_active_transfer(dep, true, true); | |
| 1007 | + | dwc3_stop_active_transfer(dep, false, true); | |
| 1008 | 1008 | ||
| 1009 | 1009 | /* | |
| 1010 | 1010 | * All stream eps will reinitiate stream on NoStream | |
| @@ -1032,7 +1032,7 @@ void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep, int status) | |||
| 1032 | 1032 | { | |
| 1033 | 1033 | struct dwc3_request *req; | |
| 1034 | 1034 | ||
| 1035 | - | dwc3_stop_active_transfer(dep, true, false); | |
| 1035 | + | dwc3_stop_active_transfer(dep, false, false); | |
| 1036 | 1036 | ||
| 1037 | 1037 | /* If endxfer is delayed, avoid unmapping requests */ | |
| 1038 | 1038 | if (dep->flags & DWC3_EP_DELAY_STOP) | |
| @@ -1720,7 +1720,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep) | |||
| 1720 | 1720 | if (ret == -EAGAIN) | |
| 1721 | 1721 | return ret; | |
| 1722 | 1722 | ||
| 1723 | - | dwc3_stop_active_transfer(dep, true, true); | |
| 1723 | + | dwc3_stop_active_transfer(dep, false, true); | |
| 1724 | 1724 | ||
| 1725 | 1725 | list_for_each_entry_safe(req, tmp, &dep->started_list, list) | |
| 1726 | 1726 | dwc3_gadget_move_cancelled_request(req, DWC3_REQUEST_STATUS_DEQUEUED); | |
| @@ -1757,6 +1757,11 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc) | |||
| 1757 | 1757 | * the controller won't update the TRB progress on command | |
| 1758 | 1758 | * completion. It also won't clear the HWO bit in the TRB. | |
| 1759 | 1759 | * The command will also not complete immediately in that case. | |
| 1760 | + | * | |
| 1761 | + | * Older programming guide revisions recommended setting ForceRM to 1 | |
| 1762 | + | * when ending a transfer. Newer programming guide revisions now | |
| 1763 | + | * recommend keeping ForceRM cleared, and TRBs are properly updated | |
| 1764 | + | * on command completion. | |
| 1760 | 1765 | */ | |
| 1761 | 1766 | static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool interrupt) | |
| 1762 | 1767 | { | |
| @@ -1882,7 +1887,7 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep) | |||
| 1882 | 1887 | * to wait for the next XferNotReady to test the command again | |
| 1883 | 1888 | */ | |
| 1884 | 1889 | if (cmd_status == 0) { | |
| 1885 | - | dwc3_stop_active_transfer(dep, true, true); | |
| 1890 | + | dwc3_stop_active_transfer(dep, false, true); | |
| 1886 | 1891 | return 0; | |
| 1887 | 1892 | } | |
| 1888 | 1893 | } | |
| @@ -2165,7 +2170,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, | |||
| 2165 | 2170 | struct dwc3_request *t; | |
| 2166 | 2171 | ||
| 2167 | 2172 | /* wait until it is processed */ | |
| 2168 | - | dwc3_stop_active_transfer(dep, true, true); | |
| 2173 | + | dwc3_stop_active_transfer(dep, false, true); | |
| 2169 | 2174 | ||
| 2170 | 2175 | /* | |
| 2171 | 2176 | * Remove any started request if the transfer is | |
| @@ -2242,7 +2247,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) | |||
| 2242 | 2247 | return 0; | |
| 2243 | 2248 | } | |
| 2244 | 2249 | ||
| 2245 | - | dwc3_stop_active_transfer(dep, true, true); | |
| 2250 | + | dwc3_stop_active_transfer(dep, false, true); | |
| 2246 | 2251 | ||
| 2247 | 2252 | list_for_each_entry_safe(req, tmp, &dep->started_list, list) | |
| 2248 | 2253 | dwc3_gadget_move_cancelled_request(req, DWC3_REQUEST_STATUS_STALLED); | |
| @@ -3368,7 +3373,7 @@ static void dwc3_nostream_work(struct work_struct *work) | |||
| 3368 | 3373 | dwc3_send_gadget_generic_command(dwc, cmd, dep->number); | |
| 3369 | 3374 | } else { | |
| 3370 | 3375 | dep->flags |= DWC3_EP_DELAY_START; | |
| 3371 | - | dwc3_stop_active_transfer(dep, true, true); | |
| 3376 | + | dwc3_stop_active_transfer(dep, false, true); | |
| 3372 | 3377 | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 3373 | 3378 | return; | |
| 3374 | 3379 | } | |
| @@ -3726,7 +3731,7 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep, | |||
| 3726 | 3731 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && | |
| 3727 | 3732 | list_empty(&dep->started_list) && | |
| 3728 | 3733 | (list_empty(&dep->pending_list) || status == -EXDEV)) | |
| 3729 | - | dwc3_stop_active_transfer(dep, true, true); | |
| 3734 | + | dwc3_stop_active_transfer(dep, false, true); | |
| 3730 | 3735 | else if (dwc3_gadget_ep_should_continue(dep)) | |
| 3731 | 3736 | if (__dwc3_gadget_kick_transfer(dep) == 0) | |
| 3732 | 3737 | no_started_trb = false; | |
modified drivers/usb/gadget/function/f_mass_storage.c
| @@ -2747,6 +2747,9 @@ int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n) | |||
| 2747 | 2747 | struct fsg_buffhd *bh, *buffhds; | |
| 2748 | 2748 | int i; | |
| 2749 | 2749 | ||
| 2750 | + | if (n < 2) | |
| 2751 | + | return -EINVAL; | |
| 2752 | + | ||
| 2750 | 2753 | buffhds = kzalloc_objs(*buffhds, n); | |
| 2751 | 2754 | if (!buffhds) | |
| 2752 | 2755 | return -ENOMEM; | |
| @@ -2960,7 +2963,7 @@ EXPORT_SYMBOL_GPL(fsg_common_create_lun); | |||
| 2960 | 2963 | ||
| 2961 | 2964 | int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg) | |
| 2962 | 2965 | { | |
| 2963 | - | char buf[8]; /* enough for 100000000 different numbers, decimal */ | |
| 2966 | + | char buf[14]; | |
| 2964 | 2967 | int i, rc; | |
| 2965 | 2968 | ||
| 2966 | 2969 | fsg_common_remove_luns(common); | |
modified drivers/usb/gadget/function/f_midi.c
| @@ -879,7 +879,6 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f) | |||
| 879 | 879 | int status, n, jack = 1, i = 0, endpoint_descriptor_index = 0; | |
| 880 | 880 | ||
| 881 | 881 | midi->gadget = cdev->gadget; | |
| 882 | - | INIT_WORK(&midi->work, f_midi_in_work); | |
| 883 | 882 | status = f_midi_register_card(midi); | |
| 884 | 883 | if (status < 0) | |
| 885 | 884 | goto fail_register; | |
| @@ -1377,6 +1376,7 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi) | |||
| 1377 | 1376 | status = -ENOMEM; | |
| 1378 | 1377 | goto midi_free; | |
| 1379 | 1378 | } | |
| 1379 | + | INIT_WORK(&midi->work, f_midi_in_work); | |
| 1380 | 1380 | midi->out_ports = opts->out_ports; | |
| 1381 | 1381 | midi->index = opts->index; | |
| 1382 | 1382 | midi->buflen = opts->buflen; | |
modified drivers/usb/gadget/function/f_midi2.c
| @@ -1145,7 +1145,7 @@ static int f_midi2_alloc_ep_reqs(struct f_midi2_usb_ep *usb_ep) | |||
| 1145 | 1145 | if (!usb_ep->reqs) | |
| 1146 | 1146 | return -EINVAL; | |
| 1147 | 1147 | ||
| 1148 | - | for (i = 0; i < midi2->info.num_reqs; i++) { | |
| 1148 | + | for (i = 0; i < usb_ep->num_reqs; i++) { | |
| 1149 | 1149 | if (usb_ep->reqs[i].req) | |
| 1150 | 1150 | continue; | |
| 1151 | 1151 | usb_ep->reqs[i].req = alloc_ep_req(usb_ep->usb_ep, | |
| @@ -1160,10 +1160,9 @@ static int f_midi2_alloc_ep_reqs(struct f_midi2_usb_ep *usb_ep) | |||
| 1160 | 1160 | /* Free allocated requests */ | |
| 1161 | 1161 | static void f_midi2_free_ep_reqs(struct f_midi2_usb_ep *usb_ep) | |
| 1162 | 1162 | { | |
| 1163 | - | struct f_midi2 *midi2 = usb_ep->card; | |
| 1164 | 1163 | int i; | |
| 1165 | 1164 | ||
| 1166 | - | for (i = 0; i < midi2->info.num_reqs; i++) { | |
| 1165 | + | for (i = 0; i < usb_ep->num_reqs; i++) { | |
| 1167 | 1166 | if (!usb_ep->reqs[i].req) | |
| 1168 | 1167 | continue; | |
| 1169 | 1168 | free_ep_req(usb_ep->usb_ep, usb_ep->reqs[i].req); | |
| @@ -2178,13 +2177,13 @@ end: | |||
| 2178 | 2177 | ||
| 2179 | 2178 | /* generic show/store for string */ | |
| 2180 | 2179 | static ssize_t f_midi2_opts_str_show(struct f_midi2_opts *opts, | |
| 2181 | - | const char *str, char *page) | |
| 2180 | + | const char **strp, char *page) | |
| 2182 | 2181 | { | |
| 2183 | 2182 | int result = 0; | |
| 2184 | 2183 | ||
| 2185 | 2184 | mutex_lock(&opts->lock); | |
| 2186 | - | if (str) | |
| 2187 | - | result = scnprintf(page, PAGE_SIZE, "%s\n", str); | |
| 2185 | + | if (*strp) | |
| 2186 | + | result = scnprintf(page, PAGE_SIZE, "%s\n", *strp); | |
| 2188 | 2187 | mutex_unlock(&opts->lock); | |
| 2189 | 2188 | return result; | |
| 2190 | 2189 | } | |
| @@ -2278,7 +2277,7 @@ static ssize_t f_midi2_block_opts_name_show(struct config_item *item, | |||
| 2278 | 2277 | { | |
| 2279 | 2278 | struct f_midi2_block_opts *opts = to_f_midi2_block_opts(item); | |
| 2280 | 2279 | ||
| 2281 | - | return f_midi2_opts_str_show(opts->ep->opts, opts->info.name, page); | |
| 2280 | + | return f_midi2_opts_str_show(opts->ep->opts, &opts->info.name, page); | |
| 2282 | 2281 | } | |
| 2283 | 2282 | ||
| 2284 | 2283 | static ssize_t f_midi2_block_opts_name_store(struct config_item *item, | |
| @@ -2435,7 +2434,7 @@ static ssize_t f_midi2_ep_opts_##name##_show(struct config_item *item, \ | |||
| 2435 | 2434 | char *page) \ | |
| 2436 | 2435 | { \ | |
| 2437 | 2436 | struct f_midi2_ep_opts *opts = to_f_midi2_ep_opts(item); \ | |
| 2438 | - | return f_midi2_opts_str_show(opts->opts, opts->info.name, page);\ | |
| 2437 | + | return f_midi2_opts_str_show(opts->opts, &opts->info.name, page);\ | |
| 2439 | 2438 | } \ | |
| 2440 | 2439 | \ | |
| 2441 | 2440 | static ssize_t f_midi2_ep_opts_##name##_store(struct config_item *item, \ | |
| @@ -2590,7 +2589,7 @@ static ssize_t f_midi2_opts_iface_name_show(struct config_item *item, | |||
| 2590 | 2589 | { | |
| 2591 | 2590 | struct f_midi2_opts *opts = to_f_midi2_opts(item); | |
| 2592 | 2591 | ||
| 2593 | - | return f_midi2_opts_str_show(opts, opts->info.iface_name, page); | |
| 2592 | + | return f_midi2_opts_str_show(opts, &opts->info.iface_name, page); | |
| 2594 | 2593 | } | |
| 2595 | 2594 | ||
| 2596 | 2595 | static ssize_t f_midi2_opts_iface_name_store(struct config_item *item, | |
modified drivers/usb/gadget/function/f_ncm.c
| @@ -1766,7 +1766,7 @@ static struct usb_function *ncm_alloc(struct usb_function_instance *fi) | |||
| 1766 | 1766 | int status; | |
| 1767 | 1767 | ||
| 1768 | 1768 | /* allocate and initialize one new instance */ | |
| 1769 | - | ncm = kzalloc(sizeof(*ncm), GFP_KERNEL); | |
| 1769 | + | ncm = kzalloc_obj(*ncm); | |
| 1770 | 1770 | if (!ncm) | |
| 1771 | 1771 | return ERR_PTR(-ENOMEM); | |
| 1772 | 1772 | ||
modified drivers/usb/gadget/functions.c
| @@ -70,7 +70,7 @@ void usb_put_function_instance(struct usb_function_instance *fi) | |||
| 70 | 70 | { | |
| 71 | 71 | struct module *mod; | |
| 72 | 72 | ||
| 73 | - | if (!fi) | |
| 73 | + | if (!fi || !fi->fd) | |
| 74 | 74 | return; | |
| 75 | 75 | ||
| 76 | 76 | mod = fi->fd->mod; | |
modified drivers/usb/gadget/legacy/inode.c
| @@ -1260,10 +1260,11 @@ out: | |||
| 1260 | 1260 | static long gadget_dev_ioctl (struct file *fd, unsigned code, unsigned long value) | |
| 1261 | 1261 | { | |
| 1262 | 1262 | struct dev_data *dev = fd->private_data; | |
| 1263 | - | struct usb_gadget *gadget = dev->gadget; | |
| 1263 | + | struct usb_gadget *gadget; | |
| 1264 | 1264 | long ret = -ENOTTY; | |
| 1265 | 1265 | ||
| 1266 | 1266 | spin_lock_irq(&dev->lock); | |
| 1267 | + | gadget = dev->gadget; | |
| 1267 | 1268 | if (dev->state == STATE_DEV_OPENED || | |
| 1268 | 1269 | dev->state == STATE_DEV_UNBOUND) { | |
| 1269 | 1270 | /* Not bound to a UDC */ | |
modified drivers/usb/host/xhci-mem.c
No content changes.
This diff is too large to show in full - only the first part is shown.