Compare
8157cd417d72137ba0bd4c8c8355a67223f1ad95..4db45fc1da3d62d0fa6e8f1e457ae92e8741ed07
ASoC: nau8822: Fix the 128x oversampling switch bits
The DAC and ADC 128x Oversampling Switches use bit 5 of R10 and R14.
The NAU8822 datasheet register map puts DACOS and ADCOS at bit 3 of
those registers.
In R14, bit 5 is inside HPF[6:4], which the High Pass Cut Off control
owns. So turning on ADC oversampling changes the high pass cut-off, and
the oversampling bit cannot be set. In R10, bit 5 is reserved, so the
DAC switch has no effect.
Use bit 3 for both.
Fixes: 1e3cb6c321be ("ASoC: nau8822: new codec driver")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
Link: https://patch.msgid.link/20261008130953.2446692-7-sammiee5311@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
HyeongJun An <sammiee5311@gmail.com> · 2026-10-08 13:09 UTC · committed by Mark Brown
662 files changed,
+8021
−4079
- .mailmap
- Documentation/admin-guide/ext4.rst
- Documentation/arch/arm64/silicon-errata.rst
- Documentation/devicetree/bindings/iio/adc/rockchip-saradc.yaml
- Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
- Documentation/filesystems/netfs_library.rst
- Documentation/filesystems/propagate_umount.txt
- Documentation/filesystems/sharedsubtree.rst
- Documentation/networking/strparser.rst
- MAINTAINERS
- Makefile
- arch/arc/Kconfig
- arch/arc/include/asm/atomic64-arcv2.h
- arch/arc/include/asm/cmpxchg.h
- arch/arc/kernel/setup.c
- arch/arc/kernel/smp.c
- arch/arm64/Kconfig
- arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi
- arch/arm64/boot/dts/freescale/imx8mp-var-dart-sonata.dts
- arch/arm64/boot/dts/qcom/x1-microsoft-denali.dtsi
- arch/arm64/include/asm/el2_setup.h
- arch/arm64/kernel/Makefile
- arch/arm64/kernel/cpu_errata.c
- arch/arm64/kernel/cpufeature.c
- arch/arm64/kernel/signal.c
- arch/arm64/kernel/topology.c
- arch/arm64/kernel/vdso/Makefile
- arch/arm64/kvm/emulate-nested.c
- arch/arm64/kvm/hyp/include/nvhe/pkvm.h
- arch/arm64/kvm/hyp/nvhe/hyp-main.c
- arch/arm64/kvm/hyp/nvhe/pkvm.c
- arch/arm64/kvm/mmu.c
- arch/arm64/kvm/vgic/vgic-init.c
- arch/arm64/kvm/vgic/vgic-its.c
- arch/arm64/kvm/vgic/vgic-v2.c
- arch/arm64/kvm/vgic/vgic-v3.c
- arch/arm64/kvm/vgic/vgic.c
- arch/arm64/mm/mmu.c
- arch/arm64/net/bpf_jit_comp.c
- arch/arm64/tools/cpucaps
- arch/loongarch/net/bpf_jit.c
- arch/loongarch/vdso/Makefile
- arch/powerpc/kernel/vdso/Makefile
- arch/powerpc/kvm/book3s_hv.c
- arch/powerpc/net/bpf_jit_comp.c
- arch/powerpc/perf/imc-pmu.c
- arch/riscv/Kconfig
- arch/riscv/Kconfig.errata
- arch/riscv/Kconfig.socs
- arch/riscv/errata/sifive/errata.c
- arch/riscv/include/asm/cpufeature.h
- arch/riscv/include/asm/errata_list_vendors.h
- arch/riscv/include/asm/futex.h
- arch/riscv/include/asm/insn-def.h
- arch/riscv/include/asm/scs.h
- arch/riscv/include/asm/vector.h
- arch/riscv/include/uapi/asm/vendor/mips.h
- arch/riscv/kernel/cpufeature.c
- arch/riscv/kernel/entry.S
- arch/riscv/kernel/patch.c
- arch/riscv/kernel/ptrace.c
- arch/riscv/kernel/setup.c
- arch/riscv/kernel/smpboot.c
- arch/riscv/kernel/suspend.c
- arch/riscv/kernel/vdso/Makefile
- arch/riscv/kvm/aia_device.c
- arch/riscv/lib/strnlen.S
- arch/riscv/mm/extable.c
- arch/riscv/net/bpf_jit_comp64.c
- arch/s390/kernel/vdso/Makefile
- arch/s390/kvm/s390/s390.c
- arch/s390/net/bpf_jit_comp.c
- arch/um/drivers/vector_transports.c
- arch/x86/crypto/aesni-intel_glue.c
- arch/x86/entry/vdso/vdso64/Makefile
- arch/x86/include/asm/cpufeatures.h
- arch/x86/include/asm/tlb.h
- arch/x86/include/uapi/asm/ptrace-abi.h
- arch/x86/kernel/cpu/amd.c
- arch/x86/kernel/sys_x86_64.c
- arch/x86/kvm/mmu/mmu.c
- arch/x86/kvm/svm/sev.c
- arch/x86/kvm/svm/svm.c
- arch/x86/kvm/svm/svm.h
- arch/x86/kvm/vmx/nested.c
- arch/x86/kvm/vmx/tdx.c
- arch/x86/mm/pgtable.c
- arch/x86/net/bpf_jit_comp.c
- arch/x86/um/asm/ptrace.h
- arch/x86/um/ptrace_32.c
- block/blk-cgroup.c
- block/blk-mq.c
- block/fops.c
- block/mq-deadline.c
- crypto/aes.c
- drivers/accessibility/braille/braille_console.c
- drivers/android/binder.c
- drivers/android/binder/node.rs
- drivers/android/binder/node/wrapper.rs
- drivers/android/binder/rust_binderfs.c
- drivers/android/binder/thread.rs
- drivers/android/binderfs.c
- drivers/ata/libata-scsi.c
- drivers/block/drbd/drbd_nl_gen.c
- drivers/block/virtio_blk.c
- drivers/block/zloop.c
- drivers/bluetooth/btintel.c
- drivers/bluetooth/btintel_pcie.c
- drivers/char/mem.c
- drivers/char/tpm/tpm-interface.c
- drivers/char/tpm/tpm2-cmd.c
- drivers/char/tpm/tpm2-sessions.c
- drivers/clk/qcom/gcc-eliza.c
- drivers/clk/qcom/gcc-hawi.c
- drivers/clk/qcom/gcc-kaanapali.c
- drivers/clk/qcom/gpucc-glymur.c
- drivers/clk/qcom/gpucc-kaanapali.c
- drivers/clk/spacemit/ccu-k3.c
- drivers/clk/ti/composite.c
- drivers/cpufreq/cpufreq.c
- drivers/cpufreq/intel_pstate.c
- drivers/edac/altera_edac.c
- drivers/edac/amd64_edac.c
- drivers/edac/versalnet_edac.c
- drivers/gpio/gpio-exar.c
- drivers/gpio/gpio-mpsse.c
- drivers/gpio/gpio-xilinx.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
- drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
- drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c
- drivers/gpu/drm/amd/amdgpu/vi.c
- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
- drivers/gpu/drm/amd/amdkfd/kfd_priv.h
- drivers/gpu/drm/amd/amdkfd/kfd_svm.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
- drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
- drivers/gpu/drm/amd/display/dc/dc.h
- drivers/gpu/drm/amd/display/dc/dml/Makefile
- drivers/gpu/drm/amd/display/dc/dml2_0/Makefile
- drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
- drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c
- drivers/gpu/drm/amd/display/modules/power/power.c
- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
- drivers/gpu/drm/bridge/th1520-dw-hdmi.c
- drivers/gpu/drm/display/drm_dp_helper.c
- drivers/gpu/drm/drm_bridge.c
- drivers/gpu/drm/drm_fb_helper.c
- drivers/gpu/drm/gud/gud_pipe.c
- drivers/gpu/drm/i915/display/intel_display_params.c
- drivers/gpu/drm/i915/display/intel_display_params.h
- drivers/gpu/drm/i915/display/intel_vrr.c
- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
- drivers/gpu/drm/i915/gt/intel_rps.c
- drivers/gpu/drm/imagination/pvr_mmu.c
- drivers/gpu/drm/imagination/pvr_vm.c
- drivers/gpu/drm/mediatek/mtk_drm_drv.c
- drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c
- drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h
- drivers/gpu/drm/nouveau/nouveau_abi16.c
- drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
- drivers/gpu/drm/panthor/panthor_sched.c
- drivers/gpu/drm/radeon/radeon_bios.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_irq.c
- drivers/gpu/drm/vc4/vc4_v3d.c
- drivers/gpu/drm/vc4/vc4_validate.c
- drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
- drivers/gpu/drm/xe/display/xe_fb_pin.c
- drivers/gpu/drm/xe/xe_bo.c
- drivers/gpu/drm/xe/xe_bo.h
- drivers/gpu/drm/xe/xe_i2c.c
- drivers/gpu/drm/xe/xe_lrc.c
- drivers/gpu/drm/xe/xe_mmio.c
- drivers/gpu/drm/xe/xe_pci_sriov.c
- drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
- drivers/hid/bpf/hid_bpf_dispatch.c
- drivers/hid/hid-ids.h
- drivers/hid/hid-logitech-dj.c
- drivers/hid/hid-logitech-hidpp.c
- drivers/hid/hid-multitouch.c
- drivers/hid/hid-universal-pidff.c
- drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
- drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
- drivers/i2c/busses/i2c-at91-master.c
- drivers/i2c/busses/i2c-qcom-geni.c
- drivers/i2c/busses/i2c-xiic.c
- drivers/iio/accel/kionix-kx022a.c
- drivers/iio/accel/kxcjk-1013.c
- drivers/iio/accel/sca3000.c
- drivers/iio/adc/ad4030.c
- drivers/iio/adc/ad7173.c
- drivers/iio/adc/ad_sigma_delta.c
- drivers/iio/adc/ade9000.c
- drivers/iio/adc/adi-axi-adc.c
- drivers/iio/adc/aspeed_adc.c
- drivers/iio/adc/axp288_adc.c
- drivers/iio/adc/max1363.c
- drivers/iio/adc/pac1934.c
- drivers/iio/adc/rohm-bd79124.c
- drivers/iio/adc/stm32-adc.c
- drivers/iio/adc/sun4i-gpadc-iio.c
- drivers/iio/adc/xilinx-xadc-core.c
- drivers/iio/buffer/industrialio-buffer-dmaengine.c
- drivers/iio/cdc/ad7150.c
- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
- drivers/iio/dac/mcp47a1.c
- drivers/iio/dac/rohm-bd79703.c
- drivers/iio/frequency/adf4377.c
- drivers/iio/frequency/admv1013.c
- drivers/iio/gyro/adis16136.c
- drivers/iio/health/max30102.c
- drivers/iio/imu/adis16400.c
- drivers/iio/imu/adis16480.c
- drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
- drivers/iio/industrialio-buffer.c
- drivers/iio/industrialio-trigger.c
- drivers/iio/light/gp2ap020a00f.c
- drivers/iio/light/rohm-bu27034.c
- drivers/iio/pressure/bmp280-core.c
- drivers/iio/pressure/rohm-bm1390.c
- drivers/iio/proximity/aw96103.c
- drivers/iio/proximity/isl29501.c
- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
- drivers/iio/proximity/sx9324.c
- drivers/iio/proximity/vcnl3020.c
- drivers/iio/proximity/vl53l0x-i2c.c
- drivers/input/joystick/xpad.c
- drivers/input/keyboard/atkbd.c
- drivers/input/misc/ati_remote2.c
- drivers/input/mouse/synaptics.c
- drivers/input/serio/i8042-acpipnpio.h
- drivers/input/touchscreen/s6sy761.c
- drivers/interconnect/qcom/x1e80100.c
- drivers/iommu/dma-iommu.c
- drivers/md/dm-crypt.c
- drivers/md/dm-integrity.c
- drivers/md/dm-ioctl.c
- drivers/md/dm-snap.c
- drivers/media/usb/em28xx/em28xx-video.c
- drivers/memstick/core/memstick.c
- drivers/memstick/host/rtsx_usb_ms.c
- drivers/mmc/host/cavium-octeon.c
- drivers/mmc/host/cavium-thunderx.c
- drivers/mmc/host/mtk-sd.c
- drivers/mmc/host/sdhci-sprd.c
- drivers/mtd/chips/cfi_cmdset_0001.c
- drivers/mtd/devices/block2mtd.c
- drivers/mtd/devices/mtd_intel_dg.c
- drivers/mtd/mtdcore.c
- drivers/mtd/nand/ecc.c
- drivers/mtd/nand/raw/cadence-nand-controller.c
- drivers/mtd/nand/raw/vf610_nfc.c
- drivers/mtd/nand/spi/core.c
- drivers/mtd/spi-nor/core.c
- drivers/net/amt.c
- drivers/net/bareudp.c
- drivers/net/bonding/bond_main.c
- drivers/net/can/dev/skb.c
- drivers/net/can/usb/f81604.c
- drivers/net/can/vxcan.c
- drivers/net/dsa/microchip/ksz_common.h
- drivers/net/ethernet/airoha/airoha_eth.c
- drivers/net/ethernet/airoha/airoha_eth.h
- drivers/net/ethernet/allwinner/sun4i-emac.c
- drivers/net/ethernet/broadcom/bcmsysport.c
- drivers/net/ethernet/broadcom/bnxt/bnxt.c
- drivers/net/ethernet/broadcom/bnxt/bnxt.h
- drivers/net/ethernet/broadcom/genet/bcmgenet.c
- drivers/net/ethernet/broadcom/genet/bcmgenet.h
- drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
- drivers/net/ethernet/cadence/macb_main.c
- drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
- drivers/net/ethernet/google/gve/gve_main.c
- drivers/net/ethernet/google/gve/gve_rx_dqo.c
- drivers/net/ethernet/google/gve/gve_tx_dqo.c
- drivers/net/ethernet/ibm/ibmveth.c
- drivers/net/ethernet/intel/e1000e/netdev.c
- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
- drivers/net/ethernet/intel/iavf/iavf.h
- drivers/net/ethernet/intel/iavf/iavf_main.c
- drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
- drivers/net/ethernet/intel/ice/devlink/port.c
- drivers/net/ethernet/intel/ice/ice_eswitch.c
- drivers/net/ethernet/intel/ice/ice_sriov.c
- drivers/net/ethernet/intel/ice/ice_txrx.c
- drivers/net/ethernet/marvell/mvneta.c
- drivers/net/ethernet/marvell/octeontx2/af/mcs.c
- drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c
- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
- drivers/net/ethernet/mediatek/mtk_eth_soc.c
- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
- drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c
- drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
- drivers/net/ethernet/mellanox/mlx5/core/vport.c
- drivers/net/ethernet/mellanox/mlxsw/spectrum.h
- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
- drivers/net/ethernet/microchip/sparx5/sparx5_main.c
- drivers/net/ethernet/microchip/sparx5/sparx5_main.h
- drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
- drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
- drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
- drivers/net/ethernet/microchip/vcap/vcap_api.c
- drivers/net/ethernet/microsoft/mana/mana_bpf.c
- drivers/net/ethernet/microsoft/mana/mana_en.c
- drivers/net/ethernet/microsoft/mana/mana_ethtool.c
- drivers/net/ethernet/realtek/r8169_main.c
- drivers/net/ethernet/stmicro/stmmac/hwif.h
- drivers/net/ethernet/stmicro/stmmac/stmmac.h
- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
- drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
- drivers/net/ethernet/xilinx/xilinx_axienet.h
- drivers/net/ethernet/xilinx/xilinx_axienet_main.c
- drivers/net/pcs/pcs-rzn1-miic.c
- drivers/net/pfcp.c
- drivers/net/phy/aquantia/aquantia_main.c
- drivers/net/phy/qcom/at803x.c
- drivers/net/team/team_core.c
- drivers/net/team/team_mode_broadcast.c
- drivers/net/tun.c
- drivers/net/usb/ax88179_178a.c
- drivers/net/usb/qmi_wwan.c
- drivers/net/veth.c
- drivers/net/virtio_net.c
- drivers/net/wireguard/noise.c
- drivers/net/wireguard/queueing.h
- drivers/net/wireless/ath/ath11k/mac.c
- drivers/net/wireless/ath/ath12k/core.c
- drivers/net/wireless/ath/ath12k/core.h
- drivers/net/wireless/ath/ath12k/hif.h
- drivers/net/wireless/ath/ath12k/pci.c
- drivers/net/wireless/ath/ath9k/hif_usb.c
- drivers/net/wireless/ath/ath9k/htc.h
- drivers/net/wireless/ath/ath9k/htc_drv_init.c
- drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
- drivers/net/wireless/ath/ath9k/wmi.c
- drivers/net/wireless/ath/ath9k/wmi.h
- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
- drivers/net/wireless/intel/iwlegacy/3945-mac.c
- drivers/net/wireless/intersil/p54/fwio.c
- drivers/net/wireless/marvell/libertas/tx.c
- drivers/net/wireless/mediatek/mt76/mt76.h
- drivers/net/wireless/mediatek/mt76/mt7603/init.c
- drivers/net/wireless/mediatek/mt76/mt7915/init.c
- drivers/net/wireless/mediatek/mt76/mt7915/main.c
- drivers/net/wireless/mediatek/mt76/mt7925/mac.c
- drivers/net/wireless/mediatek/mt76/mt7925/main.c
- drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
- drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.h
- drivers/net/wireless/mediatek/mt76/mt7996/init.c
- drivers/net/wireless/mediatek/mt76/mt7996/main.c
- drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
- drivers/net/wireless/mediatek/mt76/tx.c
- drivers/net/wireless/nxp/nxpwifi/11n.c
- drivers/net/wireless/nxp/nxpwifi/11n_aggr.c
- drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c
- drivers/net/wireless/nxp/nxpwifi/cfg80211.c
- drivers/net/wireless/nxp/nxpwifi/init.c
- drivers/net/wireless/nxp/nxpwifi/main.c
- drivers/net/wireless/nxp/nxpwifi/uap_event.c
- drivers/net/wireless/nxp/nxpwifi/util.c
- drivers/net/wireless/silabs/wfx/hif_tx.c
- drivers/net/wireless/st/cw1200/bh.c
- drivers/net/wireless/st/cw1200/txrx.c
- drivers/net/wireless/ti/wlcore/main.c
- drivers/net/xen-netfront.c
- drivers/nvme/host/core.c
- drivers/nvme/host/fc.c
- drivers/nvme/host/multipath.c
- drivers/nvme/host/nvme.h
- drivers/nvme/host/pci.c
- drivers/nvme/host/sysfs.c
- drivers/nvme/host/tcp.c
- drivers/nvme/target/configfs.c
- drivers/nvme/target/core.c
- drivers/nvme/target/fabrics-cmd-auth.c
- drivers/nvme/target/nvmet.h
- drivers/nvme/target/pci-epf.c
- drivers/nvme/target/pr.c
- drivers/of/base.c
- drivers/of/irq.c
- drivers/of/overlay.c
- drivers/pci/pci.c
- drivers/pci/pcie/aer.c
- drivers/pinctrl/qcom/pinctrl-hawi.c
- drivers/pinctrl/qcom/pinctrl-ipq5018.c
- drivers/pinctrl/qcom/pinctrl-maili.c
- drivers/pinctrl/qcom/pinctrl-nord.c
- drivers/pinctrl/qcom/pinctrl-qcs8300.c
- drivers/pmdomain/imx/imx8m-blk-ctrl.c
- drivers/pmdomain/rockchip/pm-domains.c
- drivers/power/sequencing/pwrseq-pcie-m2.c
- drivers/ptp/ptp_ocp.c
- drivers/regulator/ltc3676.c
- drivers/regulator/of_regulator.c
- drivers/regulator/tps6594-regulator.c
- drivers/rtc/dev.c
- drivers/rtc/rtc-ac100.c
- drivers/rtc/rtc-efi.c
- drivers/rtc/rtc-mpfs.c
- drivers/rtc/rtc-spear.c
- drivers/scsi/ch.c
- drivers/scsi/qedi/qedi_main.c
- drivers/spi/spi-cadence-quadspi.c
- drivers/spi/spi-cs42l43.c
- drivers/spi/spi-nxp-fspi.c
- drivers/spi/spi-sg2044-nor.c
- drivers/staging/greybus/uart.c
- drivers/tee/optee/ffa_abi.c
- drivers/tee/optee/optee_msg.h
- drivers/tee/optee/smc_abi.c
- drivers/tee/qcomtee/async.c
- drivers/tee/qcomtee/qcomtee_msg.h
- drivers/tee/qcomtee/qcomtee_object.h
- drivers/tee/tee_shm.c
- drivers/thunderbolt/ctl.c
- drivers/thunderbolt/domain.c
- drivers/thunderbolt/nhi.c
- drivers/thunderbolt/nhi.h
- drivers/thunderbolt/nhi_regs.h
- drivers/thunderbolt/pci.c
- drivers/thunderbolt/quirks.c
- drivers/thunderbolt/stream.c
- drivers/thunderbolt/switch.c
- drivers/thunderbolt/tb.c
- drivers/thunderbolt/test.c
- drivers/thunderbolt/tunnel.c
- drivers/thunderbolt/tunnel.h
- drivers/thunderbolt/xdomain.c
- drivers/tty/amiserial.c
- drivers/tty/n_gsm.c
- drivers/tty/serial/8250/8250_bcm7271.c
- drivers/tty/serial/8250/8250_omap.c
- drivers/tty/serial/8250/8250_port.c
- drivers/tty/serial/amba-pl011.c
- drivers/tty/serial/imx.c
- drivers/tty/serial/kgdboc.c
- drivers/tty/serial/ma35d1_serial.c
- drivers/tty/serial/max3100.c
- drivers/tty/serial/mpc52xx_uart.c
- drivers/tty/serial/qcom_geni_serial.c
- drivers/tty/serial/sc16is7xx.c
- drivers/tty/serial/serial-tegra.c
- drivers/tty/serial/serial_core.c
- drivers/tty/serial/sifive.c
- drivers/tty/serial/vt8500_serial.c
- drivers/tty/tty_io.c
- drivers/tty/tty_port.c
- drivers/tty/vcc.c
- drivers/tty/vt/selection.c
- drivers/tty/vt/vc_screen.c
- drivers/tty/vt/vt.c
- drivers/ufs/core/ufs-mcq.c
- drivers/ufs/core/ufshcd.c
- drivers/ufs/host/ufs-mediatek.c
- drivers/usb/cdns3/cdns3-gadget.c
- drivers/usb/cdns3/cdns3-pci-wrap.c
- drivers/usb/chipidea/ci_hdrc_tegra.c
- drivers/usb/class/cdc-acm.c
- drivers/usb/class/cdc-acm.h
- drivers/usb/core/hub.c
- drivers/usb/core/message.c
- drivers/usb/dwc2/hcd.c
- drivers/usb/dwc3/core.h
- drivers/usb/dwc3/dwc3-am62.c
- drivers/usb/dwc3/ep0.c
- drivers/usb/dwc3/gadget.c
- drivers/usb/gadget/function/f_fs.c
- drivers/usb/gadget/function/f_midi2.c
- drivers/usb/gadget/function/f_uac1_legacy.c
- drivers/usb/gadget/udc/aspeed-vhub/core.c
- drivers/usb/gadget/udc/aspeed-vhub/dev.c
- drivers/usb/gadget/udc/aspeed-vhub/hub.c
- drivers/usb/gadget/udc/aspeed-vhub/vhub.h
- drivers/usb/gadget/udc/dummy_hcd.c
- drivers/usb/host/octeon-hcd.c
- drivers/usb/host/ohci-da8xx.c
- drivers/usb/host/ohci-s3c2410.c
- drivers/usb/host/ohci-spear.c
- drivers/usb/host/ohci-st.c
- drivers/usb/mtu3/mtu3_trace.h
- drivers/usb/serial/bus.c
- drivers/usb/serial/cp210x.c
- drivers/usb/serial/generic.c
- drivers/usb/serial/option.c
- drivers/usb/serial/quatech2.c
- drivers/usb/serial/ssu100.c
- drivers/usb/serial/usb-serial.c
- drivers/usb/serial/xr_serial.c
- drivers/usb/storage/sierra_ms.c
- drivers/usb/typec/anx7411.c
- drivers/usb/typec/port-mapper.c
- drivers/usb/typec/tcpm/tcpm.c
- drivers/usb/typec/tipd/core.c
- drivers/usb/typec/ucsi/displayport.c
- drivers/usb/typec/ucsi/ucsi.c
- drivers/usb/typec/ucsi/ucsi_acpi.c
- drivers/usb/typec/ucsi/ucsi_glink.c
- drivers/virt/nitro_enclaves/ne_misc_dev.c
- drivers/virt/vmgenid.c
- fs/btrfs/inode.c
- fs/btrfs/ioctl.c
- fs/btrfs/scrub.c
- fs/btrfs/transaction.c
- fs/btrfs/xattr.c
- fs/dcache.c
- fs/ext4/super.c
- fs/fcntl.c
- fs/fhandle.c
- fs/file_table.c
- fs/fs_context.c
- fs/mount.h
- fs/namei.c
- fs/namespace.c
- fs/netfs/buffered_read.c
- fs/netfs/buffered_write.c
- fs/netfs/direct_write.c
- fs/netfs/internal.h
- fs/netfs/misc.c
- fs/netfs/read_collect.c
- fs/notify/mark.c
- fs/nullfs.c
- fs/pnode.c
- fs/readdir.c
- fs/smb/client/cifsfs.c
- fs/smb/client/cifsfs.h
- fs/smb/client/cifsglob.h
- fs/smb/client/file.c
- fs/smb/client/inode.c
- fs/smb/client/smb2ops.c
- fs/smb/client/smb2pdu.c
- fs/verity/fsverity_private.h
- fs/verity/open.c
- fs/xfs/libxfs/xfs_exchmaps.c
- fs/xfs/libxfs/xfs_log_format.h
- fs/xfs/xfs_bmap_util.c
- fs/xfs/xfs_exchrange.c
- include/linux/bpf.h
- include/linux/can/core.h
- include/linux/can/skb.h
- include/linux/console.h
- include/linux/cpufreq.h
- include/linux/fs.h
- include/linux/hrtimer_rearm.h
- include/linux/io_uring_types.h
- include/linux/kvm_host.h
- include/linux/mount.h
- include/linux/mtd/nand.h
- include/linux/netdevice.h
- include/linux/netfilter_netdev.h
- include/linux/netfs.h
- include/linux/nsproxy.h
- include/linux/nvme.h
- include/linux/perf_event.h
- include/linux/rtnetlink.h
- include/linux/sched/ext.h
- include/linux/siphash.h
- include/linux/skbuff.h
- include/linux/soc/qcom/geni-se.h
- include/linux/thunderbolt.h
- include/linux/tty.h
- include/linux/tty_driver.h
- include/linux/tty_port.h
- include/linux/usb/serial.h
- include/linux/virtio_net.h
- include/net/amt.h
- include/net/bluetooth/hci_core.h
- include/net/bluetooth/rfcomm.h
- include/net/can.h
- include/net/gso.h
- include/net/ip.h
- include/net/mana/mana.h
- include/net/netfilter/nf_flow_table.h
- include/net/sch_generic.h
- include/net/strparser.h
- include/net/xdp.h
- include/sound/core.h
- include/sound/cs35l56.h
- include/uapi/linux/alloc_tag.h
- include/uapi/linux/random.h
- include/vdso/getrandom.h
- init/Kconfig
- io_uring/bpf_filter.c
- io_uring/cancel.c
- io_uring/cmd_net.c
- io_uring/io_uring.c
- io_uring/kbuf.c
- io_uring/loop.c
- io_uring/memmap.c
- io_uring/memmap.h
- io_uring/net.c
- io_uring/register.c
- io_uring/tw.c
- io_uring/zcrx.c
- kernel/audit_tree.c
- kernel/bpf/core.c
- kernel/bpf/hashtab.c
- kernel/bpf/memalloc.c
- kernel/bpf/syscall.c
- kernel/bpf/trampoline.c
- kernel/bpf/verifier.c
- kernel/cgroup/cpuset.c
- kernel/dma/swiotlb.c
- kernel/events/core.c
- kernel/events/ring_buffer.c
- kernel/fork.c
- kernel/futex/core.c
- kernel/irq/Kconfig
- kernel/irq/Makefile
- kernel/kprobes.c
- kernel/module/main.c
- kernel/nsproxy.c
- kernel/printk/nbcon.c
- kernel/rcu/srcutree.c
- kernel/sched/ext/ext.c
- kernel/sched/ext/inlines.h
- kernel/sched/ext/internal.h
- kernel/sched/ext/sub.c
- kernel/sched/sched.h
- kernel/sysctl.c
- kernel/time/jiffies.c
- kernel/trace/fprobe.c
- kernel/workqueue.c
- lib/Kconfig.debug
- lib/dim/Makefile
- lib/dim/dim.c
- lib/dim/dim_kunit.c
- mm/damon/core.c
- mm/kasan/common.c
- mm/mremap.c
- mm/pgtable-generic.c
- mm/shmem.c
- mm/slub.c
- mm/vma.c
- mm/vma.h
modified .mailmap
| @@ -101,6 +101,7 @@ Andy Chiu <andybnac@gmail.com> <andy.chiu@sifive.com> | |||
| 101 | 101 | Andy Chiu <andybnac@gmail.com> <taochiu@synology.com> | |
| 102 | 102 | Andy Shevchenko <andy@kernel.org> <andy@smile.org.ua> | |
| 103 | 103 | Andy Shevchenko <andy@kernel.org> <ext-andriy.shevchenko@nokia.com> | |
| 104 | + | Andy Yan <andyshrk@163.com> <andy.yan@rock-chips.com> | |
| 104 | 105 | Anilkumar Kolli <quic_akolli@quicinc.com> <akolli@codeaurora.org> | |
| 105 | 106 | Anirudh Ghayal <quic_aghayal@quicinc.com> <aghayal@codeaurora.org> | |
| 106 | 107 | Antoine Tenart <atenart@kernel.org> <antoine.tenart@bootlin.com> | |
| @@ -286,6 +287,8 @@ Ed L. Cashin <ecashin@coraid.com> | |||
| 286 | 287 | Elliot Berman <quic_eberman@quicinc.com> <eberman@codeaurora.org> | |
| 287 | 288 | Enric Balletbo i Serra <eballetbo@kernel.org> <enric.balletbo@collabora.com> | |
| 288 | 289 | Enric Balletbo i Serra <eballetbo@kernel.org> <eballetbo@iseebcn.com> | |
| 290 | + | Eric Dumazet <edumazet@kernel.org> <edumazet@google.com> | |
| 291 | + | Eric Dumazet <edumazet@kernel.org> <eric.dumazet@gmail.com> | |
| 289 | 292 | Erik Kaneda <erik.kaneda@intel.com> <erik.schmauss@intel.com> | |
| 290 | 293 | Ethan Carter Edwards <ethan@ethancedwards.com> Ethan Edwards <ethancarteredwards@gmail.com> | |
| 291 | 294 | Eugen Hristev <ehristev@kernel.org> <eugen.hristev@microchip.com> | |
| @@ -459,7 +462,8 @@ Johan Hovold <johan@kernel.org> <jhovold@gmail.com> | |||
| 459 | 462 | Johan Hovold <johan@kernel.org> <johan@hovoldconsulting.com> | |
| 460 | 463 | John Crispin <john@phrozen.org> <blogic@openwrt.org> | |
| 461 | 464 | John Fastabend <john.fastabend@gmail.com> <john.r.fastabend@intel.com> | |
| 462 | - | John Garry <john.g.garry@oracle.com> <john.garry@huawei.com> | |
| 465 | + | John Garry <john.garry@linux.dev> <john.garry@huawei.com> | |
| 466 | + | John Garry <john.garry@linux.dev> <john.g.garry@oracle.com> | |
| 463 | 467 | John Keeping <john@keeping.me.uk> <john@metanate.com> | |
| 464 | 468 | John Moon <john@jmoon.dev> <quic_johmoo@quicinc.com> | |
| 465 | 469 | John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> | |
| @@ -484,6 +488,7 @@ Juha Yrjola <juha.yrjola@nokia.com> | |||
| 484 | 488 | Juha Yrjola <juha.yrjola@solidboot.com> | |
| 485 | 489 | Julien Thierry <julien.thierry.kdev@gmail.com> <julien.thierry@arm.com> | |
| 486 | 490 | Justin Iurman <justin.iurman@gmail.com> <justin.iurman@uliege.be> | |
| 491 | + | Imre Kaloz <kaloz@kernel.org> <kaloz@openwrt.org> | |
| 487 | 492 | Ira Weiny <iweiny@kernel.org> <ira.weiny@intel.com> | |
| 488 | 493 | Iskren Chernev <me@iskren.info> <iskren.chernev@gmail.com> | |
| 489 | 494 | Kalle Valo <kvalo@kernel.org> <kvalo@codeaurora.org> | |
modified Documentation/admin-guide/ext4.rst
| @@ -172,7 +172,8 @@ When mounting an ext4 filesystem, the following option are accepted: | |||
| 172 | 172 | data=journal | |
| 173 | 173 | All data are committed into the journal prior to being written into the | |
| 174 | 174 | main file system. Enabling this mode will disable delayed allocation | |
| 175 | - | and O_DIRECT support. | |
| 175 | + | and O_DIRECT support. This feature is deprecated and support | |
| 176 | + | will be removed in January 2028. | |
| 176 | 177 | ||
| 177 | 178 | data=ordered (*) | |
| 178 | 179 | All data are forced directly out to the main file system prior to its | |
| @@ -418,7 +419,8 @@ There are 3 different data modes: | |||
| 418 | 419 | consistent state. This mode is the slowest except when data needs to be read | |
| 419 | 420 | from and written to disk at the same time where it outperforms all others | |
| 420 | 421 | modes. Enabling this mode will disable delayed allocation and O_DIRECT | |
| 421 | - | support. | |
| 422 | + | support. The data=journal feature is deprecated and support will be | |
| 423 | + | removed in January 2028. | |
| 422 | 424 | ||
| 423 | 425 | /proc entries | |
| 424 | 426 | ============= | |
modified Documentation/arch/arm64/silicon-errata.rst
| @@ -174,6 +174,8 @@ stable kernels. | |||
| 174 | 174 | +----------------+-----------------+-----------------+-----------------------------+ | |
| 175 | 175 | | ARM | Cortex-A725 | #3456106 | ARM64_ERRATUM_3194386 | | |
| 176 | 176 | +----------------+-----------------+-----------------+-----------------------------+ | |
| 177 | + | | ARM | Cortex-A725 | #3821522 | ARM64_ERRATUM_3821522 | | |
| 178 | + | +----------------+-----------------+-----------------+-----------------------------+ | |
| 177 | 179 | | ARM | Cortex-X1 | #1502854 | N/A | | |
| 178 | 180 | +----------------+-----------------+-----------------+-----------------------------+ | |
| 179 | 181 | | ARM | Cortex-X1 | #3324344 | ARM64_ERRATUM_3194386 | | |
modified Documentation/devicetree/bindings/iio/adc/rockchip-saradc.yaml
| @@ -12,19 +12,19 @@ maintainers: | |||
| 12 | 12 | properties: | |
| 13 | 13 | compatible: | |
| 14 | 14 | oneOf: | |
| 15 | - | - const: rockchip,saradc | |
| 16 | - | - const: rockchip,rk3066-tsadc | |
| 17 | - | - const: rockchip,rk3399-saradc | |
| 18 | - | - const: rockchip,rk3528-saradc | |
| 15 | + | - enum: | |
| 16 | + | - rockchip,saradc | |
| 17 | + | - rockchip,rk3066-tsadc | |
| 18 | + | - rockchip,rk3399-saradc | |
| 19 | + | - rockchip,rk3528-saradc | |
| 20 | + | - rockchip,rk3562-saradc | |
| 21 | + | - rockchip,rk3588-saradc | |
| 22 | + | - rockchip,rv1106-saradc | |
| 19 | 23 | - items: | |
| 20 | 24 | - const: rockchip,rk3506-saradc | |
| 21 | 25 | - const: rockchip,rk3528-saradc | |
| 22 | - | - const: rockchip,rk3562-saradc | |
| 23 | - | - const: rockchip,rk3588-saradc | |
| 24 | 26 | - items: | |
| 25 | - | - enum: | |
| 26 | - | - rockchip,rk3576-saradc | |
| 27 | - | - rockchip,rv1106-saradc | |
| 27 | + | - const: rockchip,rk3576-saradc | |
| 28 | 28 | - const: rockchip,rk3588-saradc | |
| 29 | 29 | - items: | |
| 30 | 30 | - enum: | |
modified Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
| @@ -77,6 +77,7 @@ properties: | |||
| 77 | 77 | - mscc,ocelot-spi | |
| 78 | 78 | - mscc,jaguar2-spi | |
| 79 | 79 | - sophgo,sg2042-spi | |
| 80 | + | - syna,sl2610-spi | |
| 80 | 81 | - thead,th1520-spi | |
| 81 | 82 | - ultrarisc,dp1000-spi | |
| 82 | 83 | - const: snps,dw-apb-ssi | |
modified Documentation/filesystems/netfs_library.rst
| @@ -451,6 +451,32 @@ one. | |||
| 451 | 451 | The inode should be marked ``NETFS_ICTX_SINGLE_NO_UPLOAD`` if this API is to be | |
| 452 | 452 | used. The writeback function requires the buffer to be of ITER_FOLIOQ type. | |
| 453 | 453 | ||
| 454 | + | Clearing Stale Post-EOF Pagecache | |
| 455 | + | --------------------------------- | |
| 456 | + | ||
| 457 | + | When a file is extended, data left in the pagecache past the old EOF by a write | |
| 458 | + | through an mmap must not be exposed as file content. Netfslib clears this on | |
| 459 | + | its own write paths, and exports a helper so a filesystem can do the same from | |
| 460 | + | a resize path (truncate, setattr, fallocate and the like) that holds the | |
| 461 | + | inode's ``i_rwsem`` exclusively across the whole resize:: | |
| 462 | + | ||
| 463 | + | void netfs_clear_stale_post_isize(struct inode *inode, uoff_t from, | |
| 464 | + | uoff_t to); | |
| 465 | + | ||
| 466 | + | This zeroes any such data within the ``[from, to)`` hole to be made, where | |
| 467 | + | @from is the old EOF and @to is the new one, and the caller must have already | |
| 468 | + | updated ``i_size`` to @to before calling it. Only the folio straddling @from | |
| 469 | + | can hold data written past the EOF through an mmap, as pages wholly beyond the | |
| 470 | + | EOF can't be faulted in, so the zeroing is limited to that folio. The folio is | |
| 471 | + | zeroed rather than dropped so that a concurrent extending write can't lose | |
| 472 | + | data. | |
| 473 | + | ||
| 474 | + | This overlaps with ``pagecache_isize_extended()`` but can't reuse it: that | |
| 475 | + | helper is keyed on a sub-page block size and is a no-op when the block size is | |
| 476 | + | ``>= PAGE_SIZE`` (as on network filesystems), and it doesn't wait for | |
| 477 | + | writeback. As both address the same problem, a change to one should probably | |
| 478 | + | be reflected in the other to keep them in sync. | |
| 479 | + | ||
| 454 | 480 | High-Level VM API | |
| 455 | 481 | ================== | |
| 456 | 482 | ||
modified Documentation/filesystems/propagate_umount.txt
| @@ -32,12 +32,12 @@ of set. They can be reparented to the place where the bottom of | |||
| 32 | 32 | stack is attached to a mount that will survive. NOTE: doing that | |
| 33 | 33 | will violate a constraint on having no more than one mount with | |
| 34 | 34 | the same parent/mountpoint pair; however, the caller (umount_tree()) | |
| 35 | - | will immediately remedy that - it may keep unmounted element attached | |
| 36 | - | to parent, but only if the parent itself is unmounted. Since all | |
| 37 | - | conflicts created by reparenting have common parent *not* in the | |
| 38 | - | set and one side of the conflict (bottom of the stack of overmounts) | |
| 39 | - | is in the set, it will be resolved. However, we rely upon umount_tree() | |
| 40 | - | doing that pretty much immediately after the call of propagate_umount(). | |
| 35 | + | will immediately remedy that - it detaches every element of the set | |
| 36 | + | from its parent. Since all conflicts created by reparenting have | |
| 37 | + | common parent *not* in the set and one side of the conflict (bottom | |
| 38 | + | of the stack of overmounts) is in the set, it will be resolved. | |
| 39 | + | However, we rely upon umount_tree() doing that pretty much immediately | |
| 40 | + | after the call of propagate_umount(). | |
| 41 | 41 | ||
| 42 | 42 | Algorithm is based on two statements: | |
| 43 | 43 | 1) for any set S, there is a maximal non-shifting subset of S | |
modified Documentation/networking/strparser.rst
| @@ -77,7 +77,7 @@ Functions | |||
| 77 | 77 | ||
| 78 | 78 | strp_done is called to release any resources held by the stream | |
| 79 | 79 | parser instance. This must be called after the stream processor | |
| 80 | - | has been stopped. | |
| 80 | + | has been stopped. The socket lock must not be held. | |
| 81 | 81 | ||
| 82 | 82 | :: | |
| 83 | 83 | ||
modified MAINTAINERS
| @@ -3012,7 +3012,7 @@ F: arch/arm/boot/dts/ti/omap/omap3-igep* | |||
| 3012 | 3012 | ||
| 3013 | 3013 | ARM/INTEL IXP4XX ARM ARCHITECTURE | |
| 3014 | 3014 | M: Linus Walleij <linusw@kernel.org> | |
| 3015 | - | M: Imre Kaloz <kaloz@openwrt.org> | |
| 3015 | + | M: Imre Kaloz <kaloz@kernel.org> | |
| 3016 | 3016 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | |
| 3017 | 3017 | S: Maintained | |
| 3018 | 3018 | F: Documentation/devicetree/bindings/arm/intel-ixp4xx.yaml | |
| @@ -5143,6 +5143,7 @@ L: netdev@vger.kernel.org | |||
| 5143 | 5143 | L: openwrt-devel@lists.openwrt.org (subscribers-only) | |
| 5144 | 5144 | S: Supported | |
| 5145 | 5145 | F: Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml | |
| 5146 | + | F: Documentation/networking/dsa/b53.rst | |
| 5146 | 5147 | F: drivers/net/dsa/b53/* | |
| 5147 | 5148 | F: drivers/net/dsa/bcm_sf2* | |
| 5148 | 5149 | F: include/linux/dsa/brcm.h | |
| @@ -9860,7 +9861,7 @@ L: linux-ext4@vger.kernel.org | |||
| 9860 | 9861 | S: Maintained | |
| 9861 | 9862 | W: http://ext4.wiki.kernel.org | |
| 9862 | 9863 | Q: http://patchwork.ozlabs.org/project/linux-ext4/list/ | |
| 9863 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git | |
| 9864 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev | |
| 9864 | 9865 | F: Documentation/filesystems/ext4/ | |
| 9865 | 9866 | F: fs/ext4/ | |
| 9866 | 9867 | F: include/trace/events/ext4.h | |
| @@ -17209,31 +17210,6 @@ F: include/trace/events/ksm.h | |||
| 17209 | 17210 | F: mm/ksm.c | |
| 17210 | 17211 | F: mm/mm_slot.h | |
| 17211 | 17212 | ||
| 17212 | - | MEMORY MANAGEMENT - MEMORY POLICY AND MIGRATION | |
| 17213 | - | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17214 | - | M: David Hildenbrand <david@kernel.org> | |
| 17215 | - | R: Zi Yan <ziy@nvidia.com> | |
| 17216 | - | R: Matthew Brost <matthew.brost@intel.com> | |
| 17217 | - | R: Joshua Hahn <joshua.hahnjy@gmail.com> | |
| 17218 | - | R: Rakie Kim <rakie.kim@sk.com> | |
| 17219 | - | R: Byungchul Park <byungchul@sk.com> | |
| 17220 | - | R: Gregory Price <gourry@gourry.net> | |
| 17221 | - | R: Ying Huang <ying.huang@linux.alibaba.com> | |
| 17222 | - | R: Alistair Popple <apopple@nvidia.com> | |
| 17223 | - | L: linux-mm@kvack.org | |
| 17224 | - | S: Maintained | |
| 17225 | - | W: http://www.linux-mm.org | |
| 17226 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm | |
| 17227 | - | F: Documentation/ABI/testing/sysfs-kernel-mm-mempolicy | |
| 17228 | - | F: Documentation/ABI/testing/sysfs-kernel-mm-mempolicy-weighted-interleave | |
| 17229 | - | F: include/linux/mempolicy.h | |
| 17230 | - | F: include/uapi/linux/mempolicy.h | |
| 17231 | - | F: include/linux/migrate.h | |
| 17232 | - | F: include/linux/migrate_mode.h | |
| 17233 | - | F: mm/mempolicy.c | |
| 17234 | - | F: mm/migrate.c | |
| 17235 | - | F: mm/migrate_device.c | |
| 17236 | - | ||
| 17237 | 17213 | MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU) | |
| 17238 | 17214 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17239 | 17215 | R: Kairui Song <kasong@tencent.com> | |
| @@ -17256,6 +17232,25 @@ F: include/linux/mmzone.h | |||
| 17256 | 17232 | F: mm/vmscan.c | |
| 17257 | 17233 | F: mm/workingset.c | |
| 17258 | 17234 | ||
| 17235 | + | MEMORY MANAGEMENT - MIGRATION | |
| 17236 | + | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17237 | + | M: David Hildenbrand <david@kernel.org> | |
| 17238 | + | R: Zi Yan <ziy@nvidia.com> | |
| 17239 | + | R: Matthew Brost <matthew.brost@intel.com> | |
| 17240 | + | R: Joshua Hahn <joshua.hahnjy@gmail.com> | |
| 17241 | + | R: Byungchul Park <byungchul@sk.com> | |
| 17242 | + | R: Gregory Price <gourry@gourry.net> | |
| 17243 | + | R: Ying Huang <ying.huang@linux.alibaba.com> | |
| 17244 | + | R: Alistair Popple <apopple@nvidia.com> | |
| 17245 | + | L: linux-mm@kvack.org | |
| 17246 | + | S: Maintained | |
| 17247 | + | W: http://www.linux-mm.org | |
| 17248 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm | |
| 17249 | + | F: include/linux/migrate.h | |
| 17250 | + | F: include/linux/migrate_mode.h | |
| 17251 | + | F: mm/migrate.c | |
| 17252 | + | F: mm/migrate_device.c | |
| 17253 | + | ||
| 17259 | 17254 | MEMORY MANAGEMENT - MISC | |
| 17260 | 17255 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17261 | 17256 | M: David Hildenbrand <david@kernel.org> | |
| @@ -17271,7 +17266,6 @@ W: http://www.linux-mm.org | |||
| 17271 | 17266 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm | |
| 17272 | 17267 | F: Documentation/ABI/testing/sysfs-kernel-mm | |
| 17273 | 17268 | F: Documentation/ABI/testing/sysfs-kernel-mm-cma | |
| 17274 | - | F: Documentation/ABI/testing/sysfs-kernel-mm-memory-tiers | |
| 17275 | 17269 | F: Documentation/ABI/testing/sysfs-kernel-mm-numa | |
| 17276 | 17270 | F: Documentation/admin-guide/mm/ | |
| 17277 | 17271 | F: Documentation/mm/ | |
| @@ -17279,7 +17273,6 @@ F: drivers/char/mem.c | |||
| 17279 | 17273 | F: include/linux/cma.h | |
| 17280 | 17274 | F: include/linux/dmapool.h | |
| 17281 | 17275 | F: include/linux/ioremap.h | |
| 17282 | - | F: include/linux/memory-tiers.h | |
| 17283 | 17276 | F: include/linux/page_idle.h | |
| 17284 | 17277 | F: mm/backing-dev.c | |
| 17285 | 17278 | F: mm/cma.c | |
| @@ -17291,7 +17284,6 @@ F: mm/early_ioremap.c | |||
| 17291 | 17284 | F: mm/fadvise.c | |
| 17292 | 17285 | F: mm/ioremap.c | |
| 17293 | 17286 | F: mm/mapping_dirty_helpers.c | |
| 17294 | - | F: mm/memory-tiers.c | |
| 17295 | 17287 | F: mm/page_idle.c | |
| 17296 | 17288 | F: mm/pgalloc-track.h | |
| 17297 | 17289 | F: mm/process_vm_access.c | |
| @@ -17308,6 +17300,27 @@ F: mm/numa.c | |||
| 17308 | 17300 | F: mm/numa_emulation.c | |
| 17309 | 17301 | F: mm/numa_memblks.c | |
| 17310 | 17302 | ||
| 17303 | + | MEMORY MANAGEMENT - NUMA PLACEMENT | |
| 17304 | + | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17305 | + | M: David Hildenbrand <david@kernel.org> | |
| 17306 | + | M: Gregory Price <gourry@gourry.net> | |
| 17307 | + | R: Zi Yan <ziy@nvidia.com> | |
| 17308 | + | R: Joshua Hahn <joshua.hahnjy@gmail.com> | |
| 17309 | + | R: Rakie Kim <rakie.kim@sk.com> | |
| 17310 | + | R: Ying Huang <ying.huang@linux.alibaba.com> | |
| 17311 | + | L: linux-mm@kvack.org | |
| 17312 | + | S: Maintained | |
| 17313 | + | W: http://www.linux-mm.org | |
| 17314 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm | |
| 17315 | + | F: Documentation/ABI/testing/sysfs-kernel-mm-memory-tiers | |
| 17316 | + | F: Documentation/ABI/testing/sysfs-kernel-mm-mempolicy | |
| 17317 | + | F: Documentation/ABI/testing/sysfs-kernel-mm-mempolicy-weighted-interleave | |
| 17318 | + | F: include/linux/memory-tiers.h | |
| 17319 | + | F: include/linux/mempolicy.h | |
| 17320 | + | F: include/uapi/linux/mempolicy.h | |
| 17321 | + | F: mm/memory-tiers.c | |
| 17322 | + | F: mm/mempolicy.c | |
| 17323 | + | ||
| 17311 | 17324 | MEMORY MANAGEMENT - OOM KILLER | |
| 17312 | 17325 | M: Michal Hocko <mhocko@suse.com> | |
| 17313 | 17326 | R: David Rientjes <rientjes@google.com> | |
| @@ -18885,7 +18898,7 @@ F: net/core/drop_monitor.c | |||
| 18885 | 18898 | NETWORKING DRIVERS | |
| 18886 | 18899 | M: Andrew Lunn <andrew+netdev@lunn.ch> | |
| 18887 | 18900 | M: "David S. Miller" <davem@davemloft.net> | |
| 18888 | - | M: Eric Dumazet <edumazet@google.com> | |
| 18901 | + | M: Eric Dumazet <edumazet@kernel.org> | |
| 18889 | 18902 | M: Jakub Kicinski <kuba@kernel.org> | |
| 18890 | 18903 | M: Paolo Abeni <pabeni@redhat.com> | |
| 18891 | 18904 | L: netdev@vger.kernel.org | |
| @@ -19002,7 +19015,7 @@ K: struct\s+phy_port|phy_port_ | |||
| 19002 | 19015 | ||
| 19003 | 19016 | NETWORKING [GENERAL] | |
| 19004 | 19017 | M: "David S. Miller" <davem@davemloft.net> | |
| 19005 | - | M: Eric Dumazet <edumazet@google.com> | |
| 19018 | + | M: Eric Dumazet <edumazet@kernel.org> | |
| 19006 | 19019 | M: Jakub Kicinski <kuba@kernel.org> | |
| 19007 | 19020 | M: Paolo Abeni <pabeni@redhat.com> | |
| 19008 | 19021 | R: Simon Horman <horms@kernel.org> | |
| @@ -19228,7 +19241,7 @@ F: net/ipv6/seg6* | |||
| 19228 | 19241 | F: tools/testing/selftests/net/srv6* | |
| 19229 | 19242 | ||
| 19230 | 19243 | NETWORKING [TCP] | |
| 19231 | - | M: Eric Dumazet <edumazet@google.com> | |
| 19244 | + | M: Eric Dumazet <edumazet@kernel.org> | |
| 19232 | 19245 | M: Neal Cardwell <ncardwell@google.com> | |
| 19233 | 19246 | R: Kuniyuki Iwashima <kuniyu@google.com> | |
| 19234 | 19247 | L: netdev@vger.kernel.org | |
| @@ -19261,7 +19274,7 @@ F: net/tls/ | |||
| 19261 | 19274 | F: tools/testing/selftests/net/tls.c | |
| 19262 | 19275 | ||
| 19263 | 19276 | NETWORKING [SOCKETS] | |
| 19264 | - | M: Eric Dumazet <edumazet@google.com> | |
| 19277 | + | M: Eric Dumazet <edumazet@kernel.org> | |
| 19265 | 19278 | M: Kuniyuki Iwashima <kuniyu@google.com> | |
| 19266 | 19279 | M: Paolo Abeni <pabeni@redhat.com> | |
| 19267 | 19280 | M: Willem de Bruijn <willemb@google.com> | |
| @@ -20557,6 +20570,7 @@ ORACLE CLUSTER FILESYSTEM 2 (OCFS2) | |||
| 20557 | 20570 | M: Mark Fasheh <mark@fasheh.com> | |
| 20558 | 20571 | M: Joel Becker <jlbec@evilplan.org> | |
| 20559 | 20572 | M: Joseph Qi <joseph.qi@linux.alibaba.com> | |
| 20573 | + | R: Heming Zhao <heming.zhao@suse.com> | |
| 20560 | 20574 | L: ocfs2-devel@lists.linux.dev | |
| 20561 | 20575 | S: Supported | |
| 20562 | 20576 | W: http://ocfs2.wiki.kernel.org | |
| @@ -24475,6 +24489,11 @@ R: Marc Murphy <marc.murphy@sancloud.com> | |||
| 24475 | 24489 | S: Supported | |
| 24476 | 24490 | F: arch/arm/boot/dts/ti/omap/am335x-sancloud* | |
| 24477 | 24491 | ||
| 24492 | + | SB1250-DUART BROADCOM SOC SERIAL DRIVER | |
| 24493 | + | M: "Maciej W. Rozycki" <macro@orcam.me.uk> | |
| 24494 | + | S: Maintained | |
| 24495 | + | F: drivers/tty/serial/sb1250-duart.c | |
| 24496 | + | ||
| 24478 | 24497 | SBOM | |
| 24479 | 24498 | M: Luis Augenstein <luis.augenstein@tngtech.com> | |
| 24480 | 24499 | M: Maximilian Huber <maximilian.huber@tngtech.com> | |
| @@ -25185,7 +25204,7 @@ R: David Rientjes <rientjes@google.com> | |||
| 25185 | 25204 | R: Roman Gushchin <roman.gushchin@linux.dev> | |
| 25186 | 25205 | L: linux-mm@kvack.org | |
| 25187 | 25206 | S: Maintained | |
| 25188 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git | |
| 25207 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mm/slab.git | |
| 25189 | 25208 | F: Documentation/admin-guide/mm/slab.rst | |
| 25190 | 25209 | F: Documentation/mm/slab.rst | |
| 25191 | 25210 | F: include/linux/mempool.h | |
modified Makefile
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | VERSION = 7 | |
| 3 | 3 | PATCHLEVEL = 3 | |
| 4 | 4 | SUBLEVEL = 0 | |
| 5 | - | EXTRAVERSION = -rc5 | |
| 5 | + | EXTRAVERSION = -rc7 | |
| 6 | 6 | NAME = Baby Opossum Posse | |
| 7 | 7 | ||
| 8 | 8 | # *DOCUMENTATION* | |
modified arch/arc/Kconfig
| @@ -331,13 +331,9 @@ config ARC_FPU_SAVE_RESTORE | |||
| 331 | 331 | for floating point exceptions and rounding modes. These are | |
| 332 | 332 | preserved across task context switch when enabled. | |
| 333 | 333 | ||
| 334 | - | config ARC_CANT_LLSC | |
| 335 | - | def_bool n | |
| 336 | - | ||
| 337 | 334 | config ARC_HAS_LLSC | |
| 338 | 335 | bool "Insn: LLOCK/SCOND (efficient atomic ops)" | |
| 339 | 336 | default y | |
| 340 | - | depends on !ARC_CANT_LLSC | |
| 341 | 337 | ||
| 342 | 338 | if ISA_ARCV2 | |
| 343 | 339 | ||
modified arch/arc/include/asm/atomic64-arcv2.h
| @@ -156,6 +156,12 @@ static inline u64 __arch_cmpxchg64_relaxed(volatile void *ptr, u64 old, u64 new) | |||
| 156 | 156 | } | |
| 157 | 157 | #define arch_cmpxchg64_relaxed __arch_cmpxchg64_relaxed | |
| 158 | 158 | ||
| 159 | + | static inline s64 arch_atomic64_cmpxchg_relaxed(atomic64_t *v, s64 old, s64 new) | |
| 160 | + | { | |
| 161 | + | return arch_cmpxchg64_relaxed(&v->counter, old, new); | |
| 162 | + | } | |
| 163 | + | #define arch_atomic64_cmpxchg_relaxed arch_atomic64_cmpxchg_relaxed | |
| 164 | + | ||
| 159 | 165 | static inline s64 arch_atomic64_xchg(atomic64_t *ptr, s64 new) | |
| 160 | 166 | { | |
| 161 | 167 | s64 prev; | |
modified arch/arc/include/asm/cmpxchg.h
| @@ -46,7 +46,7 @@ | |||
| 46 | 46 | __typeof__(*(ptr)) _n_ = (new); \ | |
| 47 | 47 | __typeof__(*(ptr)) _prev_; \ | |
| 48 | 48 | \ | |
| 49 | - | switch(sizeof((_p_))) { \ | |
| 49 | + | switch (sizeof(*(_p_))) { \ | |
| 50 | 50 | case 1: \ | |
| 51 | 51 | _prev_ = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *__force)_p_, (uintptr_t)_o_, (uintptr_t)_n_); \ | |
| 52 | 52 | break; \ | |
| @@ -102,7 +102,7 @@ | |||
| 102 | 102 | __typeof__(ptr) _p_ = (ptr); \ | |
| 103 | 103 | __typeof__(*(ptr)) _val_ = (val); \ | |
| 104 | 104 | \ | |
| 105 | - | switch(sizeof(*(_p_))) { \ | |
| 105 | + | switch (sizeof(*(_p_))) { \ | |
| 106 | 106 | case 4: \ | |
| 107 | 107 | _val_ = __arch_xchg(_p_, _val_); \ | |
| 108 | 108 | break; \ | |
modified arch/arc/kernel/setup.c
| @@ -593,6 +593,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
| 593 | 593 | cpu_id); | |
| 594 | 594 | } else { | |
| 595 | 595 | freq = clk_get_rate(cpu_clk); | |
| 596 | + | clk_put(cpu_clk); | |
| 596 | 597 | } | |
| 597 | 598 | if (freq) | |
| 598 | 599 | seq_printf(m, "CPU speed\t: %lu.%02lu Mhz\n", | |
modified arch/arc/kernel/smp.c
| @@ -12,7 +12,6 @@ | |||
| 12 | 12 | #include <linux/spinlock.h> | |
| 13 | 13 | #include <linux/sched/mm.h> | |
| 14 | 14 | #include <linux/interrupt.h> | |
| 15 | - | #include <linux/profile.h> | |
| 16 | 15 | #include <linux/mm.h> | |
| 17 | 16 | #include <linux/cpu.h> | |
| 18 | 17 | #include <linux/irq.h> | |
modified arch/arm64/Kconfig
| @@ -1040,9 +1040,17 @@ config ARM64_ERRATUM_1902691 | |||
| 1040 | 1040 | ||
| 1041 | 1041 | If unsure, say Y. | |
| 1042 | 1042 | ||
| 1043 | + | config ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 1044 | + | bool | |
| 1045 | + | # Targeting errata affecting AMEVCNTR01, the AMU constant counter. | |
| 1046 | + | # On affected CPUs the counter may not increment at the expected rate, | |
| 1047 | + | # making it unreliable. As a result, AMU users should treat it as | |
| 1048 | + | # unavailable rather than relying on misleading counter values. | |
| 1049 | + | ||
| 1043 | 1050 | config ARM64_ERRATUM_2457168 | |
| 1044 | 1051 | bool "Cortex-A510: 2457168: workaround for AMEVCNTR01 incrementing incorrectly" | |
| 1045 | 1052 | depends on ARM64_AMU_EXTN | |
| 1053 | + | select ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 1046 | 1054 | default y | |
| 1047 | 1055 | help | |
| 1048 | 1056 | This option adds the workaround for ARM Cortex-A510 erratum 2457168. | |
| @@ -1073,6 +1081,28 @@ config ARM64_ERRATUM_2645198 | |||
| 1073 | 1081 | ||
| 1074 | 1082 | If unsure, say Y. | |
| 1075 | 1083 | ||
| 1084 | + | config ARM64_ERRATUM_3821522 | |
| 1085 | + | bool "Cortex-A725: 3821522: workaround for possible CNT_CYCLES increment error due to WFE/WFI" | |
| 1086 | + | depends on ARM64_AMU_EXTN | |
| 1087 | + | select ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 1088 | + | default y | |
| 1089 | + | help | |
| 1090 | + | This option adds the workaround for ARM Cortex-A725 erratum 3821522. | |
| 1091 | + | ||
| 1092 | + | On affected A725 cores, the CNT_CYCLES event may incur a significant | |
| 1093 | + | increment error when entering and subsequently exiting WFx. | |
| 1094 | + | As a result, the CNT_CYCLES may diverge from the system counter | |
| 1095 | + | frequency at which it is expected to increment. | |
| 1096 | + | This renders the AMU counter AMEVCNTR01, that implements CNT_CYCLES, | |
| 1097 | + | being unreliable and unsuitable for use. | |
| 1098 | + | ||
| 1099 | + | Since there is no hardware workaround, reads of the affected CNT_CYCLES | |
| 1100 | + | counter return 0 in the relevant paths. This causes users of the counter | |
| 1101 | + | to treat it as unavailable and is functionally equivalent to firmware | |
| 1102 | + | disabling the affected counter. | |
| 1103 | + | ||
| 1104 | + | If unsure, say Y. | |
| 1105 | + | ||
| 1076 | 1106 | config ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD | |
| 1077 | 1107 | bool | |
| 1078 | 1108 | ||
modified arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi
| @@ -1602,7 +1602,7 @@ | |||
| 1602 | 1602 | }; | |
| 1603 | 1603 | ||
| 1604 | 1604 | dspi2_miso_mosi_pins: iic5-spi3-pins { | |
| 1605 | - | pinctrl-single,bits = <0x3 (0x2 << 9) (0x7 << 9)>; | |
| 1605 | + | pinctrl-single,bits = <0x0 (0x3 << 9) (0x7 << 9)>; | |
| 1606 | 1606 | }; | |
| 1607 | 1607 | ||
| 1608 | 1608 | i2c5_pins: iic6-i2c-pins { | |
| @@ -1622,7 +1622,7 @@ | |||
| 1622 | 1622 | }; | |
| 1623 | 1623 | ||
| 1624 | 1624 | gpio1_31_28_pins: xspi1-data74-gpio-pins { | |
| 1625 | - | pinctrl-single,bits = <0x0 0x1 (0x7 << 15)>; | |
| 1625 | + | pinctrl-single,bits = <0x0 (0x1 << 15) (0x7 << 15)>; | |
| 1626 | 1626 | }; | |
| 1627 | 1627 | ||
| 1628 | 1628 | fspi_data30_pins: xspi1-data30-pins { | |
| @@ -1630,7 +1630,7 @@ | |||
| 1630 | 1630 | }; | |
| 1631 | 1631 | ||
| 1632 | 1632 | gpio1_27_24_pins: xspi1-data30-gpio-pins { | |
| 1633 | - | pinctrl-single,bits = <0x0 0x1 (0x7 << 18)>; | |
| 1633 | + | pinctrl-single,bits = <0x0 (0x1 << 18) (0x7 << 18)>; | |
| 1634 | 1634 | }; | |
| 1635 | 1635 | ||
| 1636 | 1636 | fspi_dqs_sck_cs10_pins: xspi1-base-pins { | |
| @@ -1638,7 +1638,7 @@ | |||
| 1638 | 1638 | }; | |
| 1639 | 1639 | ||
| 1640 | 1640 | gpio1_23_20_pins: xspi1-base-gpio-pins { | |
| 1641 | - | pinctrl-single,bits = <0x0 0x1 (0x7 << 21)>; | |
| 1641 | + | pinctrl-single,bits = <0x0 (0x1 << 21) (0x7 << 21)>; | |
| 1642 | 1642 | }; | |
| 1643 | 1643 | ||
| 1644 | 1644 | esdhc0_cmd_data30_clk_vsel_pins: sdhc1-base-sdhc-vsel-pins { | |
| @@ -1687,12 +1687,19 @@ | |||
| 1687 | 1687 | }; | |
| 1688 | 1688 | ||
| 1689 | 1689 | /* RCWSR14 */ | |
| 1690 | + | /* | |
| 1691 | + | * IIC1_PMUX is a single bit at RCWSR14[10], but bit-per-mux | |
| 1692 | + | * uses the mask for the field to clear before applying the | |
| 1693 | + | * value. | |
| 1694 | + | * So bits 11 and 12, which are reserved, are written as 0 | |
| 1695 | + | * on every mux switch, it is harmless. | |
| 1696 | + | */ | |
| 1690 | 1697 | i2c0_pins: iic1-i2c-pins { | |
| 1691 | - | pinctrl-single,bits = <0x8 0x0 (0x1 << 10)>; | |
| 1698 | + | pinctrl-single,bits = <0x8 0x0 (0x7 << 10)>; | |
| 1692 | 1699 | }; | |
| 1693 | 1700 | ||
| 1694 | 1701 | gpio0_3_2_pins: iic1-gpio-pins { | |
| 1695 | - | pinctrl-single,bits = <0x8 (0x1 << 10) (0x1 << 10)>; | |
| 1702 | + | pinctrl-single,bits = <0x8 (0x1 << 10) (0x7 << 10)>; | |
| 1696 | 1703 | }; | |
| 1697 | 1704 | }; | |
| 1698 | 1705 | ||
modified arch/arm64/boot/dts/freescale/imx8mp-var-dart-sonata.dts
| @@ -511,6 +511,7 @@ | |||
| 511 | 511 | pinctrl-2 = <&pinctrl_usdhc2_200mhz>, <&pinctrl_usdhc2_gpio>; | |
| 512 | 512 | cd-gpios = <&gpio2 12 GPIO_ACTIVE_LOW>; | |
| 513 | 513 | vmmc-supply = <®_usdhc2_vmmc>; | |
| 514 | + | vqmmc-supply = <&ldo5>; | |
| 514 | 515 | bus-width = <4>; | |
| 515 | 516 | status = "okay"; | |
| 516 | 517 | }; | |
modified arch/arm64/boot/dts/qcom/x1-microsoft-denali.dtsi
| @@ -863,11 +863,11 @@ | |||
| 863 | 863 | }; | |
| 864 | 864 | ||
| 865 | 865 | &lpass_vamacro { | |
| 866 | - | pinctrl-0 = <&dmic01_default>, <&dmic23_default>; | |
| 866 | + | pinctrl-0 = <&dmic01_default>; | |
| 867 | 867 | pinctrl-names = "default"; | |
| 868 | 868 | ||
| 869 | 869 | vdd-micb-supply = <&vreg_l1b_1p8>; | |
| 870 | - | qcom,dmic-sample-rate = <4800000>; | |
| 870 | + | qcom,dmic-sample-rate = <2400000>; | |
| 871 | 871 | }; | |
| 872 | 872 | ||
| 873 | 873 | &mdss { | |
modified arch/arm64/include/asm/el2_setup.h
| @@ -421,8 +421,9 @@ | |||
| 421 | 421 | mov x2, xzr | |
| 422 | 422 | mrs x1, id_aa64dfr0_el1 | |
| 423 | 423 | ubfx x1, x1, #ID_AA64DFR0_EL1_PMUVer_SHIFT, #4 | |
| 424 | - | cmp x1, #ID_AA64DFR0_EL1_PMUVer_V3P9 | |
| 425 | - | b.lt .Lskip_pmuv3p9_\@ | |
| 424 | + | cmp x1, #ID_AA64DFR0_EL1_PMUVer_IMP_DEF | |
| 425 | + | ccmp x1, #ID_AA64DFR0_EL1_PMUVer_V3P9, #8, ne | |
| 426 | + | b.lt .Lskip_pmuv3p9_\@ // Skip if < PMUv3p9 or IMP_DEF | |
| 426 | 427 | ||
| 427 | 428 | orr x0, x0, #HDFGRTR2_EL2_nPMICNTR_EL0 | |
| 428 | 429 | orr x0, x0, #HDFGRTR2_EL2_nPMICFILTR_EL0 | |
modified arch/arm64/kernel/Makefile
| @@ -25,6 +25,9 @@ KASAN_SANITIZE_stacktrace.o := n | |||
| 25 | 25 | KCOV_INSTRUMENT_entry-common.o := n | |
| 26 | 26 | KCOV_INSTRUMENT_idle.o := n | |
| 27 | 27 | ||
| 28 | + | # Softirq stack switching can run outside interrupt context. | |
| 29 | + | KCOV_INSTRUMENT_irq.o := n | |
| 30 | + | ||
| 28 | 31 | # Object file lists. | |
| 29 | 32 | obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ | |
| 30 | 33 | entry-common.o process.o ptrace.o \ | |
modified arch/arm64/kernel/cpu_errata.c
| @@ -384,6 +384,20 @@ static const struct arm64_cpu_capabilities arm64_repeat_tlbi_list[] = { | |||
| 384 | 384 | }; | |
| 385 | 385 | #endif | |
| 386 | 386 | ||
| 387 | + | #ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 388 | + | static const struct midr_range workaround_amu_constcnt_list[] = { | |
| 389 | + | #ifdef CONFIG_ARM64_ERRATUM_2457168 | |
| 390 | + | /* Cortex-A510 r0p0-r1p1 */ | |
| 391 | + | MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1), | |
| 392 | + | #endif | |
| 393 | + | #ifdef CONFIG_ARM64_ERRATUM_3821522 | |
| 394 | + | /* Cortex-A725 r0p0 - r0p2 */ | |
| 395 | + | MIDR_RANGE(MIDR_CORTEX_A725, 0, 0, 0, 2), | |
| 396 | + | #endif | |
| 397 | + | {} | |
| 398 | + | }; | |
| 399 | + | #endif /* CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT */ | |
| 400 | + | ||
| 387 | 401 | #ifdef CONFIG_CAVIUM_ERRATUM_23154 | |
| 388 | 402 | static const struct midr_range cavium_erratum_23154_cpus[] = { | |
| 389 | 403 | MIDR_ALL_VERSIONS(MIDR_THUNDERX), | |
| @@ -919,14 +933,12 @@ const struct arm64_cpu_capabilities arm64_errata[] = { | |||
| 919 | 933 | ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) | |
| 920 | 934 | }, | |
| 921 | 935 | #endif | |
| 922 | - | #ifdef CONFIG_ARM64_ERRATUM_2457168 | |
| 936 | + | #ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 923 | 937 | { | |
| 924 | - | .desc = "ARM erratum 2457168", | |
| 925 | - | .capability = ARM64_WORKAROUND_2457168, | |
| 938 | + | .desc = "Broken AMU AMEVCNTR01 (const counter)", | |
| 939 | + | .capability = ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT, | |
| 926 | 940 | .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, | |
| 927 | - | ||
| 928 | - | /* Cortex-A510 r0p0-r1p1 */ | |
| 929 | - | CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1) | |
| 941 | + | CAP_MIDR_RANGE_LIST(workaround_amu_constcnt_list) | |
| 930 | 942 | }, | |
| 931 | 943 | #endif | |
| 932 | 944 | #ifdef CONFIG_ARM64_ERRATUM_2038923 | |
modified arch/arm64/kernel/cpufeature.c
| @@ -2089,7 +2089,7 @@ static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap) | |||
| 2089 | 2089 | cpumask_set_cpu(smp_processor_id(), &amu_cpus); | |
| 2090 | 2090 | ||
| 2091 | 2091 | /* 0 reference values signal broken/disabled counters */ | |
| 2092 | - | if (!this_cpu_has_cap(ARM64_WORKAROUND_2457168)) | |
| 2092 | + | if (!this_cpu_has_cap(ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT)) | |
| 2093 | 2093 | update_freq_counters_refs(); | |
| 2094 | 2094 | } | |
| 2095 | 2095 | } | |
modified arch/arm64/kernel/signal.c
| @@ -433,6 +433,7 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user) | |||
| 433 | 433 | unsigned int vl, vq; | |
| 434 | 434 | struct user_fpsimd_state fpsimd; | |
| 435 | 435 | u16 user_vl, flags; | |
| 436 | + | bool fpsimd_only; | |
| 436 | 437 | bool sm; | |
| 437 | 438 | ||
| 438 | 439 | if (user->sve_size < sizeof(*user->sve)) | |
| @@ -443,19 +444,33 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user) | |||
| 443 | 444 | if (err) | |
| 444 | 445 | return err; | |
| 445 | 446 | ||
| 447 | + | fpsimd_only = (user->sve_size == sizeof(*user->sve)); | |
| 446 | 448 | sm = flags & SVE_SIG_FLAG_SM; | |
| 449 | + | ||
| 447 | 450 | if (sm) { | |
| 448 | 451 | if (!system_supports_sme()) | |
| 449 | 452 | return -EINVAL; | |
| 450 | 453 | ||
| 454 | + | /* | |
| 455 | + | * Streaming SVE state is always preserved with an SVE payload. | |
| 456 | + | * Only accept streaming state which has an SVE payload. | |
| 457 | + | */ | |
| 458 | + | if (fpsimd_only) | |
| 459 | + | return -EINVAL; | |
| 460 | + | ||
| 451 | 461 | vl = task_get_sme_vl(current); | |
| 452 | 462 | } else { | |
| 453 | 463 | /* | |
| 454 | - | * A SME only system use SVE for streaming mode so can | |
| 455 | - | * have a SVE formatted context with a zero VL and no | |
| 456 | - | * payload data. | |
| 464 | + | * Non-streaming SVE state may be preserved without an SVE | |
| 465 | + | * payload, in which case all state is saved in the FPSIMD | |
| 466 | + | * context. | |
| 467 | + | * | |
| 468 | + | * On SME-only systems, non-streaming (FPSIMD-only) state is | |
| 469 | + | * always preserved without an SVE payload, and with VL==0. On | |
| 470 | + | * such systems, only accept non-streaming state without an SVE | |
| 471 | + | * payload. | |
| 457 | 472 | */ | |
| 458 | - | if (!system_supports_sve() && !system_supports_sme()) | |
| 473 | + | if (!system_supports_sve() && !fpsimd_only) | |
| 459 | 474 | return -EINVAL; | |
| 460 | 475 | ||
| 461 | 476 | vl = task_get_sve_vl(current); | |
| @@ -464,16 +479,7 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user) | |||
| 464 | 479 | if (user_vl != vl) | |
| 465 | 480 | return -EINVAL; | |
| 466 | 481 | ||
| 467 | - | /* | |
| 468 | - | * Non-streaming SVE state may be preserved without an SVE payload, in | |
| 469 | - | * which case the SVE context only has a header with VL==0, and all | |
| 470 | - | * state can be restored from the FPSIMD context. | |
| 471 | - | * | |
| 472 | - | * Streaming SVE state is always preserved with an SVE payload. For | |
| 473 | - | * consistency and robustness, reject restoring streaming SVE state | |
| 474 | - | * without an SVE payload. | |
| 475 | - | */ | |
| 476 | - | if (!sm && user->sve_size == sizeof(*user->sve)) | |
| 482 | + | if (fpsimd_only) | |
| 477 | 483 | return restore_fpsimd_context(user); | |
| 478 | 484 | ||
| 479 | 485 | vq = sve_vq_from_vl(vl); | |
modified arch/arm64/kernel/topology.c
| @@ -186,7 +186,6 @@ int arch_freq_get_on_cpu(int cpu) | |||
| 186 | 186 | struct amu_cntr_sample *amu_sample; | |
| 187 | 187 | unsigned int start_cpu = cpu; | |
| 188 | 188 | unsigned long last_update; | |
| 189 | - | unsigned int freq = 0; | |
| 190 | 189 | u64 scale; | |
| 191 | 190 | ||
| 192 | 191 | if (!amu_fie_cpu_supported(cpu) || !arch_scale_freq_ref(cpu)) | |
| @@ -245,9 +244,8 @@ int arch_freq_get_on_cpu(int cpu) | |||
| 245 | 244 | * (see amu_scale_freq_tick for details) | |
| 246 | 245 | */ | |
| 247 | 246 | scale = arch_scale_freq_capacity(cpu); | |
| 248 | - | freq = scale * arch_scale_freq_ref(cpu); | |
| 249 | - | freq >>= SCHED_CAPACITY_SHIFT; | |
| 250 | - | return freq; | |
| 247 | + | ||
| 248 | + | return (scale * arch_scale_freq_ref(cpu)) >> SCHED_CAPACITY_SHIFT; | |
| 251 | 249 | } | |
| 252 | 250 | ||
| 253 | 251 | static void amu_fie_setup(const struct cpumask *cpus) | |
| @@ -397,12 +395,13 @@ static void cpu_read_corecnt(void *val) | |||
| 397 | 395 | static void cpu_read_constcnt(void *val) | |
| 398 | 396 | { | |
| 399 | 397 | /* | |
| 400 | - | * Return 0 if the current CPU is affected by erratum 2457168. A value | |
| 401 | - | * of 0 is also returned if the current CPU does not support AMUs or if | |
| 402 | - | * the counter is disabled. A return value of 0 at counter read is | |
| 403 | - | * properly handled as an error case by the users of the counter. | |
| 398 | + | * Return 0 if the current CPU is affected by a HW erratum. | |
| 399 | + | * A value of 0 is also returned if the current CPU does not | |
| 400 | + | * support AMUs or if the counter is disabled. A return | |
| 401 | + | * value of 0 at counter read is properly handled as an error | |
| 402 | + | * case by the users of the counter. | |
| 404 | 403 | */ | |
| 405 | - | *(u64 *)val = this_cpu_has_cap(ARM64_WORKAROUND_2457168) ? | |
| 404 | + | *(u64 *)val = this_cpu_has_cap(ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT) ? | |
| 406 | 405 | 0UL : read_constcnt(); | |
| 407 | 406 | } | |
| 408 | 407 | ||
| @@ -463,8 +462,9 @@ static void amu_read_core_const_ctrs(void *val) | |||
| 463 | 462 | ||
| 464 | 463 | /* | |
| 465 | 464 | * cpu_read_constcnt() incurs slight latency due to the | |
| 466 | - | * ARM64_WORKAROUND_2457168 check. Read it first to minimize | |
| 467 | - | * the sampling skew between the const and core counters. | |
| 465 | + | * ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT check. | |
| 466 | + | * Read it first to minimize the sampling skew between the const | |
| 467 | + | * and core counters. | |
| 468 | 468 | */ | |
| 469 | 469 | cpu_read_constcnt(&ctrs->constcnt); | |
| 470 | 470 | cpu_read_corecnt(&ctrs->corecnt); | |
modified arch/arm64/kernel/vdso/Makefile
| @@ -41,7 +41,7 @@ CC_FLAGS_REMOVE_VDSO := $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \ | |||
| 41 | 41 | $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \ | |
| 42 | 42 | -Wmissing-prototypes -Wmissing-declarations | |
| 43 | 43 | ||
| 44 | - | CC_FLAGS_ADD_VDSO := -O2 -mcmodel=tiny -fasynchronous-unwind-tables | |
| 44 | + | CC_FLAGS_ADD_VDSO := -O2 -mcmodel=tiny -fasynchronous-unwind-tables $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 45 | 45 | ||
| 46 | 46 | CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_REMOVE_VDSO) | |
| 47 | 47 | CFLAGS_REMOVE_vgetrandom.o = $(CC_FLAGS_REMOVE_VDSO) | |
modified arch/arm64/kvm/emulate-nested.c
| @@ -2386,9 +2386,6 @@ int __init populate_nv_trap_config(void) | |||
| 2386 | 2386 | print_nv_trap_error(fgt, "FGT bit is reserved", ret); | |
| 2387 | 2387 | } | |
| 2388 | 2388 | ||
| 2389 | - | if (!cpus_have_final_cap(ARM64_HAS_FGT)) | |
| 2390 | - | continue; | |
| 2391 | - | ||
| 2392 | 2389 | prev = xa_store(&sr_forward_xa, enc, | |
| 2393 | 2390 | xa_mk_value(tc.val), GFP_KERNEL); | |
| 2394 | 2391 | ||
modified arch/arm64/kvm/hyp/include/nvhe/pkvm.h
| @@ -12,6 +12,15 @@ | |||
| 12 | 12 | #include <nvhe/gfp.h> | |
| 13 | 13 | #include <nvhe/spinlock.h> | |
| 14 | 14 | ||
| 15 | + | /* | |
| 16 | + | * HCR_EL2 bits EL2 takes from the host on each entry, per VM type. The rest | |
| 17 | + | * are EL2's own and nothing the host sets there reaches the guest. | |
| 18 | + | */ | |
| 19 | + | #define PKVM_HCR_EL2_HOST_PVM (HCR_EL2_TWI | HCR_EL2_TWE | HCR_EL2_VSE) | |
| 20 | + | #define PKVM_HCR_EL2_HOST_NPVM (PKVM_HCR_EL2_HOST_PVM | HCR_EL2_VI | HCR_EL2_VF | \ | |
| 21 | + | HCR_EL2_TVM | HCR_EL2_TID2 | HCR_EL2_TID4 | \ | |
| 22 | + | HCR_EL2_TID5 | HCR_EL2_TTLBOS) | |
| 23 | + | ||
| 15 | 24 | /* | |
| 16 | 25 | * Holds the relevant data for maintaining the vcpu state completely at hyp. | |
| 17 | 26 | */ | |
modified arch/arm64/kvm/hyp/nvhe/hyp-main.c
| @@ -216,6 +216,7 @@ static void sync_debug_state(struct pkvm_hyp_vcpu *hyp_vcpu) | |||
| 216 | 216 | static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu) | |
| 217 | 217 | { | |
| 218 | 218 | struct kvm_vcpu *host_vcpu = hyp_vcpu->host_vcpu; | |
| 219 | + | u64 host_hcr_mask = PKVM_HCR_EL2_HOST_PVM; | |
| 219 | 220 | ||
| 220 | 221 | fpsimd_sve_flush(); | |
| 221 | 222 | flush_debug_state(hyp_vcpu); | |
| @@ -228,6 +229,7 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu) | |||
| 228 | 229 | if (!pkvm_hyp_vcpu_is_protected(hyp_vcpu)) { | |
| 229 | 230 | if (vcpu_get_flag(host_vcpu, PKVM_HOST_STATE_DIRTY)) | |
| 230 | 231 | flush_hyp_vcpu_state(hyp_vcpu); | |
| 232 | + | host_hcr_mask = PKVM_HCR_EL2_HOST_NPVM; | |
| 231 | 233 | } else { | |
| 232 | 234 | hyp_vcpu->vcpu.arch.ctxt = host_vcpu->arch.ctxt; | |
| 233 | 235 | } | |
| @@ -241,9 +243,8 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu) | |||
| 241 | 243 | * trap-control bit, so it must flow to the hyp vCPU alongside TWI/TWE | |
| 242 | 244 | * for the vSError to be delivered. sync_hyp_vcpu() reflects it back. | |
| 243 | 245 | */ | |
| 244 | - | hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE | HCR_VSE); | |
| 245 | - | hyp_vcpu->vcpu.arch.hcr_el2 |= READ_ONCE(host_vcpu->arch.hcr_el2) & | |
| 246 | - | (HCR_TWI | HCR_TWE | HCR_VSE); | |
| 246 | + | hyp_vcpu->vcpu.arch.hcr_el2 &= ~host_hcr_mask; | |
| 247 | + | hyp_vcpu->vcpu.arch.hcr_el2 |= READ_ONCE(host_vcpu->arch.hcr_el2) & host_hcr_mask; | |
| 247 | 248 | ||
| 248 | 249 | hyp_vcpu->vcpu.arch.iflags = host_vcpu->arch.iflags; | |
| 249 | 250 | ||
modified arch/arm64/kvm/hyp/nvhe/pkvm.c
| @@ -30,6 +30,7 @@ unsigned int kvm_host_sve_max_vl; | |||
| 30 | 30 | */ | |
| 31 | 31 | static DEFINE_PER_CPU(struct pkvm_hyp_vcpu *, loaded_hyp_vcpu); | |
| 32 | 32 | ||
| 33 | + | /* The PKVM_HCR_EL2_HOST_{PVM,NPVM} bits of this value come from the host on each entry. */ | |
| 33 | 34 | static void pkvm_vcpu_reset_hcr(struct kvm_vcpu *vcpu) | |
| 34 | 35 | { | |
| 35 | 36 | vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS; | |
| @@ -47,18 +48,17 @@ static void pkvm_vcpu_reset_hcr(struct kvm_vcpu *vcpu) | |||
| 47 | 48 | if (cpus_have_final_cap(ARM64_HAS_STAGE2_FWB)) | |
| 48 | 49 | vcpu->arch.hcr_el2 |= HCR_FWB; | |
| 49 | 50 | ||
| 50 | - | if (cpus_have_final_cap(ARM64_HAS_EVT) && | |
| 51 | - | !cpus_have_final_cap(ARM64_MISMATCHED_CACHE_TYPE) && | |
| 52 | - | kvm_read_vm_id_reg(vcpu->kvm, SYS_CTR_EL0) == read_cpuid(CTR_EL0)) | |
| 53 | - | vcpu->arch.hcr_el2 |= HCR_TID4; | |
| 54 | - | else | |
| 55 | - | vcpu->arch.hcr_el2 |= HCR_TID2; | |
| 51 | + | /* | |
| 52 | + | * Without AArch32 EL1, leave RW set and let the entry fail with an | |
| 53 | + | * illegal exception return: the *32_EL2 registers EL2 would otherwise | |
| 54 | + | * switch are UNDEFINED there. | |
| 55 | + | */ | |
| 56 | + | if (vcpu_has_feature(vcpu, KVM_ARM_VCPU_EL1_32BIT) && | |
| 57 | + | cpus_have_final_cap(ARM64_HAS_32BIT_EL1)) | |
| 58 | + | vcpu->arch.hcr_el2 &= ~HCR_EL2_RW; | |
| 56 | 59 | ||
| 57 | 60 | if (vcpu_has_ptrauth(vcpu)) | |
| 58 | 61 | vcpu->arch.hcr_el2 |= (HCR_API | HCR_APK); | |
| 59 | - | ||
| 60 | - | if (kvm_has_mte(vcpu->kvm)) | |
| 61 | - | vcpu->arch.hcr_el2 |= HCR_ATA; | |
| 62 | 62 | } | |
| 63 | 63 | ||
| 64 | 64 | static void pvm_init_traps_hcr(struct kvm_vcpu *vcpu) | |
| @@ -76,6 +76,13 @@ static void pvm_init_traps_hcr(struct kvm_vcpu *vcpu) | |||
| 76 | 76 | */ | |
| 77 | 77 | val |= HCR_TACR | HCR_TIDCP | HCR_TID3 | HCR_TID1; | |
| 78 | 78 | ||
| 79 | + | if (cpus_have_final_cap(ARM64_HAS_EVT) && | |
| 80 | + | !cpus_have_final_cap(ARM64_MISMATCHED_CACHE_TYPE) && | |
| 81 | + | kvm_read_vm_id_reg(kvm, SYS_CTR_EL0) == read_cpuid(CTR_EL0)) | |
| 82 | + | val |= HCR_EL2_TID4; | |
| 83 | + | else | |
| 84 | + | val |= HCR_EL2_TID2; | |
| 85 | + | ||
| 79 | 86 | if (!kvm_has_feat(kvm, ID_AA64PFR0_EL1, RAS, IMP)) { | |
| 80 | 87 | val |= HCR_TERR | HCR_TEA; | |
| 81 | 88 | val &= ~(HCR_FIEN); | |
modified arch/arm64/kvm/mmu.c
| @@ -1468,32 +1468,11 @@ transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot, | |||
| 1468 | 1468 | return PAGE_SIZE; | |
| 1469 | 1469 | } | |
| 1470 | 1470 | ||
| 1471 | - | static int get_vma_page_shift(struct vm_area_struct *vma, unsigned long hva) | |
| 1471 | + | static int get_vma_page_shift(struct vm_area_struct *vma) | |
| 1472 | 1472 | { | |
| 1473 | - | unsigned long pa; | |
| 1474 | - | ||
| 1475 | - | if (is_vm_hugetlb_page(vma) && !(vma->vm_flags & VM_PFNMAP)) | |
| 1473 | + | if (is_vm_hugetlb_page(vma)) | |
| 1476 | 1474 | return huge_page_shift(hstate_vma(vma)); | |
| 1477 | 1475 | ||
| 1478 | - | if (!(vma->vm_flags & VM_PFNMAP)) | |
| 1479 | - | return PAGE_SHIFT; | |
| 1480 | - | ||
| 1481 | - | VM_BUG_ON(is_vm_hugetlb_page(vma)); | |
| 1482 | - | ||
| 1483 | - | pa = (vma->vm_pgoff << PAGE_SHIFT) + (hva - vma->vm_start); | |
| 1484 | - | ||
| 1485 | - | #ifndef __PAGETABLE_PMD_FOLDED | |
| 1486 | - | if ((hva & (PUD_SIZE - 1)) == (pa & (PUD_SIZE - 1)) && | |
| 1487 | - | ALIGN_DOWN(hva, PUD_SIZE) >= vma->vm_start && | |
| 1488 | - | ALIGN(hva, PUD_SIZE) <= vma->vm_end) | |
| 1489 | - | return PUD_SHIFT; | |
| 1490 | - | #endif | |
| 1491 | - | ||
| 1492 | - | if ((hva & (PMD_SIZE - 1)) == (pa & (PMD_SIZE - 1)) && | |
| 1493 | - | ALIGN_DOWN(hva, PMD_SIZE) >= vma->vm_start && | |
| 1494 | - | ALIGN(hva, PMD_SIZE) <= vma->vm_end) | |
| 1495 | - | return PMD_SHIFT; | |
| 1496 | - | ||
| 1497 | 1476 | return PAGE_SHIFT; | |
| 1498 | 1477 | } | |
| 1499 | 1478 | ||
| @@ -1794,7 +1773,7 @@ static short kvm_s2_resolve_vma_size(const struct kvm_s2_fault_desc *s2fd, | |||
| 1794 | 1773 | vma_shift = PAGE_SHIFT; | |
| 1795 | 1774 | } else { | |
| 1796 | 1775 | s2vi->max_map_size = PUD_SIZE; | |
| 1797 | - | vma_shift = get_vma_page_shift(vma, s2fd->hva); | |
| 1776 | + | vma_shift = get_vma_page_shift(vma); | |
| 1798 | 1777 | } | |
| 1799 | 1778 | ||
| 1800 | 1779 | switch (vma_shift) { | |
| @@ -1952,16 +1931,6 @@ static int kvm_s2_fault_pin_pfn(const struct kvm_s2_fault_desc *s2fd, | |||
| 1952 | 1931 | return -EFAULT; | |
| 1953 | 1932 | } | |
| 1954 | 1933 | } else { | |
| 1955 | - | /* | |
| 1956 | - | * If the page was identified as device early by looking at | |
| 1957 | - | * the VMA flags, vma_pagesize is already representing the | |
| 1958 | - | * largest quantity we can map. If instead it was mapped | |
| 1959 | - | * via __kvm_faultin_pfn(), vma_pagesize is set to PAGE_SIZE | |
| 1960 | - | * and must not be upgraded. | |
| 1961 | - | * | |
| 1962 | - | * In both cases, we don't let transparent_hugepage_adjust() | |
| 1963 | - | * change things at the last minute. | |
| 1964 | - | */ | |
| 1965 | 1934 | s2vi->map_non_cacheable = true; | |
| 1966 | 1935 | } | |
| 1967 | 1936 | ||
| @@ -2051,10 +2020,10 @@ static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd, | |||
| 2051 | 2020 | ||
| 2052 | 2021 | /* | |
| 2053 | 2022 | * If we are not forced to use page mapping, check if we are | |
| 2054 | - | * backed by a THP and thus use block mapping if possible. | |
| 2023 | + | * backed by a huge stage-1 mapping and thus use block mapping if | |
| 2024 | + | * possible. | |
| 2055 | 2025 | */ | |
| 2056 | - | if (mapping_size == PAGE_SIZE && | |
| 2057 | - | !(s2vi->max_map_size == PAGE_SIZE || s2vi->map_non_cacheable)) { | |
| 2026 | + | if (mapping_size == PAGE_SIZE && s2vi->max_map_size != PAGE_SIZE) { | |
| 2058 | 2027 | if (perm_fault_granule > PAGE_SIZE) { | |
| 2059 | 2028 | mapping_size = perm_fault_granule; | |
| 2060 | 2029 | } else { | |
| @@ -2135,10 +2104,6 @@ static int user_mem_abort(const struct kvm_s2_fault_desc *s2fd) | |||
| 2135 | 2104 | return ret; | |
| 2136 | 2105 | } | |
| 2137 | 2106 | ||
| 2138 | - | /* | |
| 2139 | - | * Let's check if we will get back a huge page backed by hugetlbfs, or | |
| 2140 | - | * get block mapping for device MMIO region. | |
| 2141 | - | */ | |
| 2142 | 2107 | ret = kvm_s2_fault_pin_pfn(s2fd, &s2vi); | |
| 2143 | 2108 | if (ret != 1) | |
| 2144 | 2109 | return ret; | |
modified arch/arm64/kvm/vgic/vgic-init.c
| @@ -97,6 +97,9 @@ int kvm_vgic_create(struct kvm *kvm, u32 type) | |||
| 97 | 97 | /* | |
| 98 | 98 | * - Acquiring the vCPU mutex for every *online* vCPU to prevent | |
| 99 | 99 | * concurrent vCPU ioctls for vCPUs already visible to userspace. | |
| 100 | + | * This also ensures KVM isn't in the middle of creating a vCPU, | |
| 101 | + | * i.e. that there are no vCPUs that have been created but aren't | |
| 102 | + | * yet fully online. | |
| 100 | 103 | */ | |
| 101 | 104 | ret = -EBUSY; | |
| 102 | 105 | if (kvm_trylock_all_vcpus(kvm)) | |
| @@ -105,18 +108,11 @@ int kvm_vgic_create(struct kvm *kvm, u32 type) | |||
| 105 | 108 | /* | |
| 106 | 109 | * - Taking the config_lock which protects VGIC data structures such | |
| 107 | 110 | * as the per-vCPU arrays of private IRQs (SGIs, PPIs). | |
| 108 | - | */ | |
| 109 | - | mutex_lock(&kvm->arch.config_lock); | |
| 110 | - | ||
| 111 | - | /* | |
| 112 | - | * - Bailing on the entire thing if a vCPU is in the middle of creation, | |
| 113 | - | * dropped the kvm->lock, but hasn't reached kvm_arch_vcpu_create(). | |
| 114 | 111 | * | |
| 115 | 112 | * The whole combination of this guarantees that no vCPU can get into | |
| 116 | 113 | * KVM with a VGIC configuration inconsistent with the VM's VGIC. | |
| 117 | 114 | */ | |
| 118 | - | if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus)) | |
| 119 | - | goto out_unlock; | |
| 115 | + | mutex_lock(&kvm->arch.config_lock); | |
| 120 | 116 | ||
| 121 | 117 | if (irqchip_in_kernel(kvm)) { | |
| 122 | 118 | ret = -EEXIST; | |
modified arch/arm64/kvm/vgic/vgic-its.c
| @@ -319,12 +319,16 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq, | |||
| 319 | 319 | return ret; | |
| 320 | 320 | } | |
| 321 | 321 | ||
| 322 | - | static int update_affinity(struct vgic_irq *irq, struct kvm_vcpu *vcpu) | |
| 322 | + | static int update_affinity(struct vgic_irq *irq, | |
| 323 | + | struct kvm_vcpu *from_vcpu, struct kvm_vcpu *vcpu) | |
| 323 | 324 | { | |
| 324 | 325 | struct its_vlpi_map map; | |
| 325 | 326 | int ret; | |
| 326 | 327 | ||
| 327 | 328 | guard(raw_spinlock_irqsave)(&irq->irq_lock); | |
| 329 | + | if (from_vcpu && irq->target_vcpu != from_vcpu) | |
| 330 | + | return 0; | |
| 331 | + | ||
| 328 | 332 | irq->target_vcpu = vcpu; | |
| 329 | 333 | ||
| 330 | 334 | if (!irq->hw) | |
| @@ -362,7 +366,7 @@ static void update_affinity_ite(struct kvm *kvm, struct its_ite *ite) | |||
| 362 | 366 | return; | |
| 363 | 367 | ||
| 364 | 368 | vcpu = collection_to_vcpu(kvm, ite->collection); | |
| 365 | - | update_affinity(ite->irq, vcpu); | |
| 369 | + | update_affinity(ite->irq, NULL, vcpu); | |
| 366 | 370 | } | |
| 367 | 371 | ||
| 368 | 372 | /* | |
| @@ -856,7 +860,7 @@ static int vgic_its_cmd_handle_movi(struct kvm *kvm, struct vgic_its *its, | |||
| 856 | 860 | ||
| 857 | 861 | vgic_its_invalidate_cache(its); | |
| 858 | 862 | ||
| 859 | - | return update_affinity(ite->irq, vcpu); | |
| 863 | + | return update_affinity(ite->irq, NULL, vcpu); | |
| 860 | 864 | } | |
| 861 | 865 | ||
| 862 | 866 | static bool __is_visible_gfn_locked(struct vgic_its *its, gpa_t gpa) | |
| @@ -1383,7 +1387,7 @@ static int vgic_its_cmd_handle_movall(struct kvm *kvm, struct vgic_its *its, | |||
| 1383 | 1387 | if (!irq) | |
| 1384 | 1388 | continue; | |
| 1385 | 1389 | ||
| 1386 | - | update_affinity(irq, vcpu2); | |
| 1390 | + | update_affinity(irq, vcpu1, vcpu2); | |
| 1387 | 1391 | ||
| 1388 | 1392 | vgic_put_irq(kvm, irq); | |
| 1389 | 1393 | } | |
modified arch/arm64/kvm/vgic/vgic-v2.c
| @@ -122,6 +122,10 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) | |||
| 122 | 122 | for (int lr = 0; lr < vgic_cpu->vgic_v2.used_lrs; lr++) | |
| 123 | 123 | vgic_v2_fold_lr(vcpu, cpuif->vgic_lr[lr]); | |
| 124 | 124 | ||
| 125 | + | cpuif->used_lrs = 0; | |
| 126 | + | if (!irq) | |
| 127 | + | return; | |
| 128 | + | ||
| 125 | 129 | /* See the GICv3 equivalent for the EOIcount handling rationale */ | |
| 126 | 130 | list_for_each_entry_continue(irq, &vgic_cpu->ap_list_head, ap_list) { | |
| 127 | 131 | u32 lr; | |
| @@ -144,8 +148,6 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) | |||
| 144 | 148 | vgic_v2_fold_lr(vcpu, lr); | |
| 145 | 149 | eoicount--; | |
| 146 | 150 | } | |
| 147 | - | ||
| 148 | - | cpuif->used_lrs = 0; | |
| 149 | 151 | } | |
| 150 | 152 | ||
| 151 | 153 | void vgic_v2_deactivate(struct kvm_vcpu *vcpu, u32 val) | |
modified arch/arm64/kvm/vgic/vgic-v3.c
| @@ -155,6 +155,10 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) | |||
| 155 | 155 | for (int lr = 0; lr < cpuif->used_lrs; lr++) | |
| 156 | 156 | vgic_v3_fold_lr(vcpu, cpuif->vgic_lr[lr]); | |
| 157 | 157 | ||
| 158 | + | cpuif->used_lrs = 0; | |
| 159 | + | if (!irq) | |
| 160 | + | return; | |
| 161 | + | ||
| 158 | 162 | /* | |
| 159 | 163 | * EOIMode=0: use EOIcount to emulate deactivation. We are | |
| 160 | 164 | * guaranteed to deactivate in reverse order of the activation, so | |
| @@ -188,8 +192,6 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) | |||
| 188 | 192 | vgic_v3_fold_lr(vcpu, lr); | |
| 189 | 193 | eoicount--; | |
| 190 | 194 | } | |
| 191 | - | ||
| 192 | - | cpuif->used_lrs = 0; | |
| 193 | 195 | } | |
| 194 | 196 | ||
| 195 | 197 | void vgic_v3_deactivate(struct kvm_vcpu *vcpu, u64 val) | |
modified arch/arm64/kvm/vgic/vgic.c
| @@ -853,6 +853,17 @@ retry: | |||
| 853 | 853 | goto retry; | |
| 854 | 854 | } | |
| 855 | 855 | ||
| 856 | + | /* | |
| 857 | + | * Fix the last_lr_irq refcount which was obtained while | |
| 858 | + | * populating the LRs. This can also result in the LPI being | |
| 859 | + | * deleted. | |
| 860 | + | */ | |
| 861 | + | irq = *host_data_ptr(last_lr_irq); | |
| 862 | + | if (irq) { | |
| 863 | + | deleted_lpis |= vgic_put_irq_norelease(vcpu->kvm, irq); | |
| 864 | + | *host_data_ptr(last_lr_irq) = NULL; | |
| 865 | + | } | |
| 866 | + | ||
| 856 | 867 | raw_spin_unlock(&vgic_cpu->ap_list_lock); | |
| 857 | 868 | ||
| 858 | 869 | if (unlikely(deleted_lpis)) | |
| @@ -866,9 +877,6 @@ static void vgic_fold_state(struct kvm_vcpu *vcpu) | |||
| 866 | 877 | return; | |
| 867 | 878 | } | |
| 868 | 879 | ||
| 869 | - | if (!*host_data_ptr(last_lr_irq)) | |
| 870 | - | return; | |
| 871 | - | ||
| 872 | 880 | if (kvm_vgic_global_state.type == VGIC_V2) | |
| 873 | 881 | vgic_v2_fold_lr_state(vcpu); | |
| 874 | 882 | else | |
| @@ -1021,11 +1029,14 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu) | |||
| 1021 | 1029 | scoped_guard(raw_spinlock, &irq->irq_lock) { | |
| 1022 | 1030 | if (likely(vgic_target_oracle(irq) == vcpu)) { | |
| 1023 | 1031 | vgic_populate_lr(vcpu, irq, count++); | |
| 1024 | - | *host_data_ptr(last_lr_irq) = irq; | |
| 1032 | + | if (count == kvm_vgic_global_state.nr_lr) { | |
| 1033 | + | vgic_get_irq_ref(irq); | |
| 1034 | + | *host_data_ptr(last_lr_irq) = irq; | |
| 1035 | + | } | |
| 1025 | 1036 | } | |
| 1026 | 1037 | } | |
| 1027 | 1038 | ||
| 1028 | - | if (count == kvm_vgic_global_state.nr_lr) | |
| 1039 | + | if (*host_data_ptr(last_lr_irq)) | |
| 1029 | 1040 | break; | |
| 1030 | 1041 | } | |
| 1031 | 1042 | ||
modified arch/arm64/mm/mmu.c
| @@ -2295,7 +2295,7 @@ pte_t modify_prot_start_ptes(struct vm_area_struct *vma, unsigned long addr, | |||
| 2295 | 2295 | * in cases where cpu is affected with errata #2645198. | |
| 2296 | 2296 | */ | |
| 2297 | 2297 | if (pte_accessible(vma->vm_mm, pte) && pte_user_exec(pte)) | |
| 2298 | - | __flush_tlb_range(vma, addr, nr * PAGE_SIZE, | |
| 2298 | + | __flush_tlb_range(vma, addr, addr + nr * PAGE_SIZE, | |
| 2299 | 2299 | PAGE_SIZE, 3, TLBF_NOWALKCACHE); | |
| 2300 | 2300 | } | |
| 2301 | 2301 | ||
modified arch/arm64/net/bpf_jit_comp.c
| @@ -2418,10 +2418,11 @@ bool bpf_jit_supports_subprog_tailcalls(void) | |||
| 2418 | 2418 | return true; | |
| 2419 | 2419 | } | |
| 2420 | 2420 | ||
| 2421 | - | static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *node, | |
| 2422 | - | int bargs_off, int retval_off, int run_ctx_off, | |
| 2423 | - | bool save_ret) | |
| 2421 | + | static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |
| 2422 | + | struct bpf_tramp_node *node, int bargs_off, | |
| 2423 | + | int retval_off, int run_ctx_off, bool save_ret) | |
| 2424 | 2424 | { | |
| 2425 | + | void *skip; | |
| 2425 | 2426 | __le32 *branch; | |
| 2426 | 2427 | u64 enter_prog; | |
| 2427 | 2428 | u64 exit_prog; | |
| @@ -2431,6 +2432,10 @@ static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *node, | |||
| 2431 | 2432 | enter_prog = (u64)bpf_trampoline_enter(p); | |
| 2432 | 2433 | exit_prog = (u64)bpf_trampoline_exit(p); | |
| 2433 | 2434 | ||
| 2435 | + | /* nop, patched to skip this prog when it is detached */ | |
| 2436 | + | skip = ctx->ro_image + ctx->idx; | |
| 2437 | + | emit(A64_NOP, ctx); | |
| 2438 | + | ||
| 2434 | 2439 | if (node->cookie == 0) { | |
| 2435 | 2440 | /* if cookie is zero, one instruction is enough to store it */ | |
| 2436 | 2441 | emit(A64_STR64I(A64_ZR, A64_SP, run_ctx_off + cookie_off), ctx); | |
| @@ -2483,11 +2488,13 @@ static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *node, | |||
| 2483 | 2488 | emit(A64_ADD_I(1, A64_R(2), A64_SP, run_ctx_off), ctx); | |
| 2484 | 2489 | ||
| 2485 | 2490 | emit_call(exit_prog, ctx); | |
| 2491 | + | ||
| 2492 | + | bpf_tramp_image_add_skip(im, p, skip, ctx->ro_image + ctx->idx); | |
| 2486 | 2493 | } | |
| 2487 | 2494 | ||
| 2488 | - | static void invoke_bpf_mod_ret(struct jit_ctx *ctx, struct bpf_tramp_nodes *tn, | |
| 2489 | - | int bargs_off, int retval_off, int run_ctx_off, | |
| 2490 | - | __le32 **branches) | |
| 2495 | + | static void invoke_bpf_mod_ret(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |
| 2496 | + | struct bpf_tramp_nodes *tn, int bargs_off, | |
| 2497 | + | int retval_off, int run_ctx_off, __le32 **branches) | |
| 2491 | 2498 | { | |
| 2492 | 2499 | int i; | |
| 2493 | 2500 | ||
| @@ -2496,7 +2503,7 @@ static void invoke_bpf_mod_ret(struct jit_ctx *ctx, struct bpf_tramp_nodes *tn, | |||
| 2496 | 2503 | */ | |
| 2497 | 2504 | emit(A64_STR64I(A64_ZR, A64_SP, retval_off), ctx); | |
| 2498 | 2505 | for (i = 0; i < tn->nr_nodes; i++) { | |
| 2499 | - | invoke_bpf_prog(ctx, tn->nodes[i], bargs_off, retval_off, | |
| 2506 | + | invoke_bpf_prog(ctx, im, tn->nodes[i], bargs_off, retval_off, | |
| 2500 | 2507 | run_ctx_off, true); | |
| 2501 | 2508 | /* if (*(u64 *)(sp + retval_off) != 0) | |
| 2502 | 2509 | * goto do_fexit; | |
| @@ -2882,7 +2889,7 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |||
| 2882 | 2889 | store_func_meta(ctx, meta, func_meta_off); | |
| 2883 | 2890 | cookie_bargs_off--; | |
| 2884 | 2891 | } | |
| 2885 | - | invoke_bpf_prog(ctx, fentry->nodes[i], bargs_off, | |
| 2892 | + | invoke_bpf_prog(ctx, im, fentry->nodes[i], bargs_off, | |
| 2886 | 2893 | retval_off, run_ctx_off, | |
| 2887 | 2894 | flags & BPF_TRAMP_F_RET_FENTRY_RET); | |
| 2888 | 2895 | } | |
| @@ -2893,7 +2900,7 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |||
| 2893 | 2900 | if (!branches) | |
| 2894 | 2901 | return -ENOMEM; | |
| 2895 | 2902 | ||
| 2896 | - | invoke_bpf_mod_ret(ctx, fmod_ret, bargs_off, retval_off, | |
| 2903 | + | invoke_bpf_mod_ret(ctx, im, fmod_ret, bargs_off, retval_off, | |
| 2897 | 2904 | run_ctx_off, branches); | |
| 2898 | 2905 | } | |
| 2899 | 2906 | ||
| @@ -2906,9 +2913,6 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |||
| 2906 | 2913 | emit(A64_RET(A64_R(10)), ctx); | |
| 2907 | 2914 | /* store return value */ | |
| 2908 | 2915 | emit(A64_STR64I(A64_R(0), A64_SP, retval_off), ctx); | |
| 2909 | - | /* reserve a nop for bpf_tramp_image_put */ | |
| 2910 | - | im->ip_after_call = ctx->ro_image + ctx->idx; | |
| 2911 | - | emit(A64_NOP, ctx); | |
| 2912 | 2916 | } | |
| 2913 | 2917 | ||
| 2914 | 2918 | /* update the branches saved in invoke_bpf_mod_ret with cbnz */ | |
| @@ -2930,12 +2934,11 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |||
| 2930 | 2934 | store_func_meta(ctx, meta, func_meta_off); | |
| 2931 | 2935 | cookie_bargs_off--; | |
| 2932 | 2936 | } | |
| 2933 | - | invoke_bpf_prog(ctx, fexit->nodes[i], bargs_off, retval_off, | |
| 2937 | + | invoke_bpf_prog(ctx, im, fexit->nodes[i], bargs_off, retval_off, | |
| 2934 | 2938 | run_ctx_off, false); | |
| 2935 | 2939 | } | |
| 2936 | 2940 | ||
| 2937 | 2941 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 2938 | - | im->ip_epilogue = ctx->ro_image + ctx->idx; | |
| 2939 | 2942 | /* for the first pass, assume the worst case */ | |
| 2940 | 2943 | if (!ctx->image) | |
| 2941 | 2944 | ctx->idx += 4; | |
| @@ -2994,7 +2997,7 @@ int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |||
| 2994 | 2997 | .image = NULL, | |
| 2995 | 2998 | .idx = 0, | |
| 2996 | 2999 | }; | |
| 2997 | - | struct bpf_tramp_image im; | |
| 3000 | + | struct bpf_tramp_image im = {}; | |
| 2998 | 3001 | struct arg_aux aaux; | |
| 2999 | 3002 | int ret; | |
| 3000 | 3003 | ||
| @@ -3281,6 +3284,10 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t, | |||
| 3281 | 3284 | * longer reachable, since bpf_tramp_image_put() function already | |
| 3282 | 3285 | * uses percpu_ref and task-based rcu to do the sync, no need to call | |
| 3283 | 3286 | * the sync version here, see bpf_tramp_image_put() for details. | |
| 3287 | + | * | |
| 3288 | + | * 3. when a detached prog is patched out of a trampoline, a CPU that | |
| 3289 | + | * still executes the old nop calls the prog before it went through | |
| 3290 | + | * a quiescent state, and the prog is freed after grace periods. | |
| 3284 | 3291 | */ | |
| 3285 | 3292 | ret = aarch64_insn_patch_text_nosync(ip, new_insn); | |
| 3286 | 3293 | out: | |
modified arch/arm64/tools/cpucaps
| @@ -105,7 +105,6 @@ WORKAROUND_1902691 | |||
| 105 | 105 | WORKAROUND_2038923 | |
| 106 | 106 | WORKAROUND_2064142 | |
| 107 | 107 | WORKAROUND_2077057 | |
| 108 | - | WORKAROUND_2457168 | |
| 109 | 108 | WORKAROUND_2645198 | |
| 110 | 109 | WORKAROUND_2658417 | |
| 111 | 110 | WORKAROUND_4193714 | |
| @@ -132,3 +131,4 @@ WORKAROUND_REPEAT_TLBI_SYNC | |||
| 132 | 131 | WORKAROUND_SPECULATIVE_AT | |
| 133 | 132 | WORKAROUND_SPECULATIVE_SSBS | |
| 134 | 133 | WORKAROUND_SPECULATIVE_UNPRIV_LOAD | |
| 134 | + | WORKAROUND_BROKEN_AMU_CONSTCNT | |
modified arch/loongarch/net/bpf_jit.c
| @@ -1578,6 +1578,24 @@ void *bpf_arch_text_copy(void *dst, void *src, size_t len) | |||
| 1578 | 1578 | return ret ? ERR_PTR(-EINVAL) : dst; | |
| 1579 | 1579 | } | |
| 1580 | 1580 | ||
| 1581 | + | int arch_bpf_trampoline_skip(void *nop, void *target) | |
| 1582 | + | { | |
| 1583 | + | u32 old_insn = INSN_NOP; | |
| 1584 | + | u32 new_insn = larch_insn_gen_b((unsigned long)nop, (unsigned long)target); | |
| 1585 | + | int ret; | |
| 1586 | + | ||
| 1587 | + | if (memcmp(nop, &old_insn, LOONGARCH_INSN_SIZE)) | |
| 1588 | + | return -EFAULT; | |
| 1589 | + | ||
| 1590 | + | cpus_read_lock(); | |
| 1591 | + | mutex_lock(&text_mutex); | |
| 1592 | + | ret = larch_insn_text_copy(nop, &new_insn, LOONGARCH_INSN_SIZE); | |
| 1593 | + | mutex_unlock(&text_mutex); | |
| 1594 | + | cpus_read_unlock(); | |
| 1595 | + | ||
| 1596 | + | return ret; | |
| 1597 | + | } | |
| 1598 | + | ||
| 1581 | 1599 | int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t, | |
| 1582 | 1600 | enum bpf_text_poke_type new_t, void *old_addr, | |
| 1583 | 1601 | void *new_addr) | |
| @@ -1696,13 +1714,18 @@ static void restore_stk_args(struct jit_ctx *ctx, int nr_stk_args, int args_off, | |||
| 1696 | 1714 | } | |
| 1697 | 1715 | } | |
| 1698 | 1716 | ||
| 1699 | - | static int invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *n, | |
| 1700 | - | int args_off, int retval_off, int run_ctx_off, bool save_ret) | |
| 1717 | + | static int invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |
| 1718 | + | struct bpf_tramp_node *n, int args_off, int retval_off, | |
| 1719 | + | int run_ctx_off, bool save_ret) | |
| 1701 | 1720 | { | |
| 1702 | 1721 | int ret; | |
| 1703 | 1722 | u32 *branch; | |
| 1704 | 1723 | struct bpf_prog *p = n->link->prog; | |
| 1705 | 1724 | int cookie_off = offsetof(struct bpf_tramp_run_ctx, bpf_cookie); | |
| 1725 | + | void *skip = ctx->ro_image + ctx->idx; | |
| 1726 | + | ||
| 1727 | + | /* nop, patched to a b over this prog when it is detached */ | |
| 1728 | + | emit_insn(ctx, nop); | |
| 1706 | 1729 | ||
| 1707 | 1730 | if (n->cookie) | |
| 1708 | 1731 | emit_store_stack_imm64(ctx, LOONGARCH_GPR_T1, | |
| @@ -1755,13 +1778,17 @@ static int invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *n, | |||
| 1755 | 1778 | /* arg3: &run_ctx */ | |
| 1756 | 1779 | emit_insn(ctx, addid, LOONGARCH_GPR_A2, LOONGARCH_GPR_FP, -run_ctx_off); | |
| 1757 | 1780 | ret = emit_call(ctx, (const u64)bpf_trampoline_exit(p)); | |
| 1781 | + | if (ret) | |
| 1782 | + | return ret; | |
| 1758 | 1783 | ||
| 1759 | - | return ret; | |
| 1784 | + | bpf_tramp_image_add_skip(im, p, skip, ctx->ro_image + ctx->idx); | |
| 1785 | + | return 0; | |
| 1760 | 1786 | } | |
| 1761 | 1787 | ||
| 1762 | - | static int invoke_bpf(struct jit_ctx *ctx, struct bpf_tramp_nodes *tn, | |
| 1763 | - | int args_off, int retval_off, int run_ctx_off, | |
| 1764 | - | int func_meta_off, bool save_ret, u64 func_meta, int cookie_off) | |
| 1788 | + | static int invoke_bpf(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |
| 1789 | + | struct bpf_tramp_nodes *tn, int args_off, int retval_off, | |
| 1790 | + | int run_ctx_off, int func_meta_off, bool save_ret, | |
| 1791 | + | u64 func_meta, int cookie_off) | |
| 1765 | 1792 | { | |
| 1766 | 1793 | int i, cur_cookie = (cookie_off - args_off) / 8; | |
| 1767 | 1794 | ||
| @@ -1774,7 +1801,8 @@ static int invoke_bpf(struct jit_ctx *ctx, struct bpf_tramp_nodes *tn, | |||
| 1774 | 1801 | emit_store_stack_imm64(ctx, LOONGARCH_GPR_T1, -func_meta_off, meta); | |
| 1775 | 1802 | cur_cookie--; | |
| 1776 | 1803 | } | |
| 1777 | - | err = invoke_bpf_prog(ctx, tn->nodes[i], args_off, retval_off, run_ctx_off, save_ret); | |
| 1804 | + | err = invoke_bpf_prog(ctx, im, tn->nodes[i], args_off, retval_off, | |
| 1805 | + | run_ctx_off, save_ret); | |
| 1778 | 1806 | if (err) | |
| 1779 | 1807 | return err; | |
| 1780 | 1808 | } | |
| @@ -2017,7 +2045,7 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i | |||
| 2017 | 2045 | } | |
| 2018 | 2046 | ||
| 2019 | 2047 | if (fentry->nr_nodes) { | |
| 2020 | - | ret = invoke_bpf(ctx, fentry, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 2048 | + | ret = invoke_bpf(ctx, im, fentry, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 2021 | 2049 | flags & BPF_TRAMP_F_RET_FENTRY_RET, func_meta, cookie_off); | |
| 2022 | 2050 | if (ret) | |
| 2023 | 2051 | return ret; | |
| @@ -2029,7 +2057,7 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i | |||
| 2029 | 2057 | ||
| 2030 | 2058 | emit_insn(ctx, std, LOONGARCH_GPR_ZERO, LOONGARCH_GPR_FP, -retval_off); | |
| 2031 | 2059 | for (i = 0; i < fmod_ret->nr_nodes; i++) { | |
| 2032 | - | ret = invoke_bpf_prog(ctx, fmod_ret->nodes[i], | |
| 2060 | + | ret = invoke_bpf_prog(ctx, im, fmod_ret->nodes[i], | |
| 2033 | 2061 | args_off, retval_off, run_ctx_off, true); | |
| 2034 | 2062 | if (ret) | |
| 2035 | 2063 | goto out; | |
| @@ -2051,10 +2079,6 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i | |||
| 2051 | 2079 | goto out; | |
| 2052 | 2080 | emit_insn(ctx, std, LOONGARCH_GPR_A0, LOONGARCH_GPR_FP, -retval_off); | |
| 2053 | 2081 | emit_insn(ctx, std, regmap[BPF_REG_0], LOONGARCH_GPR_FP, -(retval_off - 8)); | |
| 2054 | - | im->ip_after_call = ctx->ro_image + ctx->idx; | |
| 2055 | - | /* Reserve space for the move_imm + jirl instruction */ | |
| 2056 | - | for (i = 0; i < LOONGARCH_LONG_JUMP_NINSNS; i++) | |
| 2057 | - | emit_insn(ctx, nop); | |
| 2058 | 2082 | } | |
| 2059 | 2083 | ||
| 2060 | 2084 | for (i = 0; ctx->image && i < fmod_ret->nr_nodes; i++) { | |
| @@ -2068,14 +2092,13 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i | |||
| 2068 | 2092 | emit_store_stack_imm64(ctx, LOONGARCH_GPR_T1, -func_meta_off, func_meta); | |
| 2069 | 2093 | ||
| 2070 | 2094 | if (fexit->nr_nodes) { | |
| 2071 | - | ret = invoke_bpf(ctx, fexit, args_off, retval_off, run_ctx_off, | |
| 2095 | + | ret = invoke_bpf(ctx, im, fexit, args_off, retval_off, run_ctx_off, | |
| 2072 | 2096 | func_meta_off, false, func_meta, cookie_off); | |
| 2073 | 2097 | if (ret) | |
| 2074 | 2098 | goto out; | |
| 2075 | 2099 | } | |
| 2076 | 2100 | ||
| 2077 | 2101 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 2078 | - | im->ip_epilogue = ctx->ro_image + ctx->idx; | |
| 2079 | 2102 | move_addr(ctx, LOONGARCH_GPR_A0, (const u64)im); | |
| 2080 | 2103 | ret = emit_call(ctx, (const u64)__bpf_tramp_exit); | |
| 2081 | 2104 | if (ret) | |
| @@ -2177,11 +2200,8 @@ int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |||
| 2177 | 2200 | struct bpf_tramp_nodes *tnodes, void *func_addr) | |
| 2178 | 2201 | { | |
| 2179 | 2202 | int ret; | |
| 2180 | - | struct jit_ctx ctx; | |
| 2181 | - | struct bpf_tramp_image im; | |
| 2182 | - | ||
| 2183 | - | ctx.image = NULL; | |
| 2184 | - | ctx.idx = 0; | |
| 2203 | + | struct jit_ctx ctx = {}; | |
| 2204 | + | struct bpf_tramp_image im = {}; | |
| 2185 | 2205 | ||
| 2186 | 2206 | ret = __arch_prepare_bpf_trampoline(&ctx, &im, m, tnodes, func_addr, flags); | |
| 2187 | 2207 | ||
modified arch/loongarch/vdso/Makefile
| @@ -16,6 +16,7 @@ ccflags-vdso := \ | |||
| 16 | 16 | $(filter -m64,$(KBUILD_CFLAGS)) \ | |
| 17 | 17 | $(filter -march=%,$(KBUILD_CFLAGS)) \ | |
| 18 | 18 | $(filter -m%-float,$(KBUILD_CFLAGS)) \ | |
| 19 | + | $(CONFIG_CC_OPT_INLINE_MEMSET) \ | |
| 19 | 20 | $(CLANG_FLAGS) \ | |
| 20 | 21 | -D__VDSO__ | |
| 21 | 22 | ||
modified arch/powerpc/kernel/vdso/Makefile
| @@ -43,6 +43,7 @@ ccflags-y := -fno-common -fno-builtin -DBUILD_VDSO | |||
| 43 | 43 | ccflags-y += $(DISABLE_LATENT_ENTROPY_PLUGIN) | |
| 44 | 44 | ccflags-y += $(call cc-option, -fno-stack-protector) | |
| 45 | 45 | ccflags-y += -DDISABLE_BRANCH_PROFILING | |
| 46 | + | ccflags-y += $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 46 | 47 | ccflags-y += -ffreestanding -fasynchronous-unwind-tables | |
| 47 | 48 | ccflags-remove-y := $(CC_FLAGS_FTRACE) | |
| 48 | 49 | ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS) | |
modified arch/powerpc/kvm/book3s_hv.c
| @@ -3058,7 +3058,6 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu) | |||
| 3058 | 3058 | ||
| 3059 | 3059 | init_waitqueue_head(&vcpu->arch.cpu_run); | |
| 3060 | 3060 | ||
| 3061 | - | mutex_lock(&kvm->lock); | |
| 3062 | 3061 | vcore = NULL; | |
| 3063 | 3062 | err = -EINVAL; | |
| 3064 | 3063 | if (cpu_has_feature(CPU_FTR_ARCH_300)) { | |
| @@ -3091,7 +3090,6 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu) | |||
| 3091 | 3090 | mutex_unlock(&kvm->arch.mmu_setup_lock); | |
| 3092 | 3091 | } | |
| 3093 | 3092 | } | |
| 3094 | - | mutex_unlock(&kvm->lock); | |
| 3095 | 3093 | ||
| 3096 | 3094 | if (!vcore) | |
| 3097 | 3095 | return err; | |
modified arch/powerpc/net/bpf_jit_comp.c
| @@ -602,14 +602,18 @@ int arch_protect_bpf_trampoline(void *image, unsigned int size) | |||
| 602 | 602 | } | |
| 603 | 603 | ||
| 604 | 604 | static int invoke_bpf_prog(u32 *image, u32 *ro_image, struct codegen_context *ctx, | |
| 605 | - | struct bpf_tramp_node *n, int regs_off, int retval_off, | |
| 606 | - | int run_ctx_off, bool save_ret) | |
| 605 | + | struct bpf_tramp_image *im, struct bpf_tramp_node *n, | |
| 606 | + | int regs_off, int retval_off, int run_ctx_off, bool save_ret) | |
| 607 | 607 | { | |
| 608 | 608 | struct bpf_prog *p = n->link->prog; | |
| 609 | 609 | ppc_inst_t branch_insn; | |
| 610 | - | u32 jmp_idx; | |
| 610 | + | u32 jmp_idx, skip_idx; | |
| 611 | 611 | int ret = 0; | |
| 612 | 612 | ||
| 613 | + | /* nop, patched to skip this prog when it is detached */ | |
| 614 | + | skip_idx = ctx->idx; | |
| 615 | + | EMIT(PPC_RAW_NOP()); | |
| 616 | + | ||
| 613 | 617 | /* Save cookie */ | |
| 614 | 618 | if (IS_ENABLED(CONFIG_PPC64)) { | |
| 615 | 619 | PPC_LI64(_R3, n->cookie); | |
| @@ -679,13 +683,17 @@ static int invoke_bpf_prog(u32 *image, u32 *ro_image, struct codegen_context *ct | |||
| 679 | 683 | EMIT(PPC_RAW_ADDI(_R5, _R1, run_ctx_off)); | |
| 680 | 684 | ret = bpf_jit_emit_func_call_rel(image, ro_image, ctx, | |
| 681 | 685 | (unsigned long)bpf_trampoline_exit(p)); | |
| 686 | + | if (ret) | |
| 687 | + | return ret; | |
| 682 | 688 | ||
| 683 | - | return ret; | |
| 689 | + | if (ro_image) /* image is NULL for dummy pass */ | |
| 690 | + | bpf_tramp_image_add_skip(im, p, &ro_image[skip_idx], &ro_image[ctx->idx]); | |
| 691 | + | return 0; | |
| 684 | 692 | } | |
| 685 | 693 | ||
| 686 | 694 | static int invoke_bpf_mod_ret(u32 *image, u32 *ro_image, struct codegen_context *ctx, | |
| 687 | - | struct bpf_tramp_nodes *tn, int regs_off, int retval_off, | |
| 688 | - | int run_ctx_off, u32 *branches) | |
| 695 | + | struct bpf_tramp_image *im, struct bpf_tramp_nodes *tn, | |
| 696 | + | int regs_off, int retval_off, int run_ctx_off, u32 *branches) | |
| 689 | 697 | { | |
| 690 | 698 | int i; | |
| 691 | 699 | ||
| @@ -696,8 +704,8 @@ static int invoke_bpf_mod_ret(u32 *image, u32 *ro_image, struct codegen_context | |||
| 696 | 704 | EMIT(PPC_RAW_LI(_R3, 0)); | |
| 697 | 705 | EMIT(PPC_RAW_STL(_R3, _R1, retval_off)); | |
| 698 | 706 | for (i = 0; i < tn->nr_nodes; i++) { | |
| 699 | - | if (invoke_bpf_prog(image, ro_image, ctx, tn->nodes[i], regs_off, retval_off, | |
| 700 | - | run_ctx_off, true)) | |
| 707 | + | if (invoke_bpf_prog(image, ro_image, ctx, im, tn->nodes[i], regs_off, | |
| 708 | + | retval_off, run_ctx_off, true)) | |
| 701 | 709 | return -EINVAL; | |
| 702 | 710 | ||
| 703 | 711 | /* | |
| @@ -1043,8 +1051,8 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 1043 | 1051 | cookie_ctx_off--; | |
| 1044 | 1052 | } | |
| 1045 | 1053 | ||
| 1046 | - | if (invoke_bpf_prog(image, ro_image, ctx, fentry->nodes[i], regs_off, retval_off, | |
| 1047 | - | run_ctx_off, flags & BPF_TRAMP_F_RET_FENTRY_RET)) | |
| 1054 | + | if (invoke_bpf_prog(image, ro_image, ctx, im, fentry->nodes[i], regs_off, | |
| 1055 | + | retval_off, run_ctx_off, flags & BPF_TRAMP_F_RET_FENTRY_RET)) | |
| 1048 | 1056 | return -EINVAL; | |
| 1049 | 1057 | } | |
| 1050 | 1058 | ||
| @@ -1053,7 +1061,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 1053 | 1061 | if (!branches) | |
| 1054 | 1062 | return -ENOMEM; | |
| 1055 | 1063 | ||
| 1056 | - | if (invoke_bpf_mod_ret(image, ro_image, ctx, fmod_ret, regs_off, retval_off, | |
| 1064 | + | if (invoke_bpf_mod_ret(image, ro_image, ctx, im, fmod_ret, regs_off, retval_off, | |
| 1057 | 1065 | run_ctx_off, branches)) { | |
| 1058 | 1066 | ret = -EINVAL; | |
| 1059 | 1067 | goto cleanup; | |
| @@ -1090,11 +1098,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 1090 | 1098 | /* Restore updated tail_call_cnt */ | |
| 1091 | 1099 | if (flags & BPF_TRAMP_F_TAIL_CALL_CTX) | |
| 1092 | 1100 | bpf_trampoline_restore_tail_call_cnt(image, ctx, bpf_frame_size, r4_off); | |
| 1093 | - | ||
| 1094 | - | /* Reserve space to patch branch instruction to skip fexit progs */ | |
| 1095 | - | if (ro_image) /* image is NULL for dummy pass */ | |
| 1096 | - | im->ip_after_call = &((u32 *)ro_image)[ctx->idx]; | |
| 1097 | - | EMIT(PPC_RAW_NOP()); | |
| 1098 | 1101 | } | |
| 1099 | 1102 | ||
| 1100 | 1103 | /* Update branches saved in invoke_bpf_mod_ret with address of do_fexit */ | |
| @@ -1123,16 +1126,14 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 1123 | 1126 | cookie_ctx_off--; | |
| 1124 | 1127 | } | |
| 1125 | 1128 | ||
| 1126 | - | if (invoke_bpf_prog(image, ro_image, ctx, fexit->nodes[i], regs_off, retval_off, | |
| 1127 | - | run_ctx_off, false)) { | |
| 1129 | + | if (invoke_bpf_prog(image, ro_image, ctx, im, fexit->nodes[i], regs_off, | |
| 1130 | + | retval_off, run_ctx_off, false)) { | |
| 1128 | 1131 | ret = -EINVAL; | |
| 1129 | 1132 | goto cleanup; | |
| 1130 | 1133 | } | |
| 1131 | 1134 | } | |
| 1132 | 1135 | ||
| 1133 | 1136 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 1134 | - | if (ro_image) /* image is NULL for dummy pass */ | |
| 1135 | - | im->ip_epilogue = &((u32 *)ro_image)[ctx->idx]; | |
| 1136 | 1137 | PPC_LI_ADDR(_R3, im); | |
| 1137 | 1138 | ret = bpf_jit_emit_func_call_rel(image, ro_image, ctx, | |
| 1138 | 1139 | (unsigned long)__bpf_tramp_exit); | |
| @@ -1192,7 +1193,7 @@ cleanup: | |||
| 1192 | 1193 | int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |
| 1193 | 1194 | struct bpf_tramp_nodes *tnodes, void *func_addr) | |
| 1194 | 1195 | { | |
| 1195 | - | struct bpf_tramp_image im; | |
| 1196 | + | struct bpf_tramp_image im = {}; | |
| 1196 | 1197 | int ret; | |
| 1197 | 1198 | ||
| 1198 | 1199 | ret = __arch_prepare_bpf_trampoline(&im, NULL, NULL, NULL, m, flags, tnodes, func_addr); | |
| @@ -1320,7 +1321,7 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t, | |||
| 1320 | 1321 | ||
| 1321 | 1322 | /* | |
| 1322 | 1323 | * If we are not poking at bpf prog entry, then we are simply patching in/out | |
| 1323 | - | * an unconditional branch instruction at im->ip_after_call | |
| 1324 | + | * an unconditional branch instruction in a trampoline image | |
| 1324 | 1325 | */ | |
| 1325 | 1326 | if (offset) { | |
| 1326 | 1327 | if (old_t == BPF_MOD_CALL || new_t == BPF_MOD_CALL) { | |
modified arch/powerpc/perf/imc-pmu.c
| @@ -1275,6 +1275,8 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem, | |||
| 1275 | 1275 | struct perf_event_header *header, | |
| 1276 | 1276 | struct perf_event *event) | |
| 1277 | 1277 | { | |
| 1278 | + | u16 misc = 0; | |
| 1279 | + | ||
| 1278 | 1280 | /* Sanity checks for a valid record */ | |
| 1279 | 1281 | if (be64_to_cpu(READ_ONCE(mem->tb1)) > *prev_tb) | |
| 1280 | 1282 | *prev_tb = be64_to_cpu(READ_ONCE(mem->tb1)); | |
| @@ -1289,23 +1291,19 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem, | |||
| 1289 | 1291 | data->ip = be64_to_cpu(READ_ONCE(mem->ip)); | |
| 1290 | 1292 | data->period = event->hw.last_period; | |
| 1291 | 1293 | ||
| 1292 | - | header->type = PERF_RECORD_SAMPLE; | |
| 1293 | - | header->size = sizeof(*header) + event->header_size; | |
| 1294 | - | header->misc = 0; | |
| 1295 | - | ||
| 1296 | 1294 | if (cpu_has_feature(CPU_FTR_ARCH_31)) { | |
| 1297 | 1295 | switch (IMC_TRACE_RECORD_VAL_HVPR(be64_to_cpu(READ_ONCE(mem->val)))) { | |
| 1298 | 1296 | case 0:/* when MSR HV and PR not set in the trace-record */ | |
| 1299 | - | header->misc |= PERF_RECORD_MISC_GUEST_KERNEL; | |
| 1297 | + | misc |= PERF_RECORD_MISC_GUEST_KERNEL; | |
| 1300 | 1298 | break; | |
| 1301 | 1299 | case 1: /* MSR HV is 0 and PR is 1 */ | |
| 1302 | - | header->misc |= PERF_RECORD_MISC_GUEST_USER; | |
| 1300 | + | misc |= PERF_RECORD_MISC_GUEST_USER; | |
| 1303 | 1301 | break; | |
| 1304 | 1302 | case 2: /* MSR HV is 1 and PR is 0 */ | |
| 1305 | - | header->misc |= PERF_RECORD_MISC_KERNEL; | |
| 1303 | + | misc |= PERF_RECORD_MISC_KERNEL; | |
| 1306 | 1304 | break; | |
| 1307 | 1305 | case 3: /* MSR HV is 1 and PR is 1 */ | |
| 1308 | - | header->misc |= PERF_RECORD_MISC_USER; | |
| 1306 | + | misc |= PERF_RECORD_MISC_USER; | |
| 1309 | 1307 | break; | |
| 1310 | 1308 | default: | |
| 1311 | 1309 | pr_info("IMC: Unable to set the flag based on MSR bits\n"); | |
| @@ -1313,11 +1311,14 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem, | |||
| 1313 | 1311 | } | |
| 1314 | 1312 | } else { | |
| 1315 | 1313 | if (is_kernel_addr(data->ip)) | |
| 1316 | - | header->misc |= PERF_RECORD_MISC_KERNEL; | |
| 1314 | + | misc |= PERF_RECORD_MISC_KERNEL; | |
| 1317 | 1315 | else | |
| 1318 | - | header->misc |= PERF_RECORD_MISC_USER; | |
| 1316 | + | misc |= PERF_RECORD_MISC_USER; | |
| 1319 | 1317 | } | |
| 1320 | - | perf_event_header__init_id(header, data, event); | |
| 1318 | + | perf_event_header__init(header, data, | |
| 1319 | + | PERF_RECORD_SAMPLE, misc, | |
| 1320 | + | sizeof(*header) + event->header_size, | |
| 1321 | + | event); | |
| 1321 | 1322 | ||
| 1322 | 1323 | return 0; | |
| 1323 | 1324 | } | |
modified arch/riscv/Kconfig
| @@ -453,9 +453,10 @@ config SMP | |||
| 453 | 453 | config NR_CPUS | |
| 454 | 454 | int "Maximum number of CPUs (2-512)" | |
| 455 | 455 | depends on SMP | |
| 456 | - | range 2 512 if !RISCV_SBI_V01 | |
| 457 | - | range 2 32 if RISCV_SBI_V01 && 32BIT | |
| 456 | + | range 2 512 if !RISCV_SBI_V01 && 64BIT | |
| 457 | + | range 2 128 if !RISCV_SBI_V01 && 32BIT | |
| 458 | 458 | range 2 64 if RISCV_SBI_V01 && 64BIT | |
| 459 | + | range 2 32 if RISCV_SBI_V01 && 32BIT | |
| 459 | 460 | default "32" if 32BIT | |
| 460 | 461 | default "64" if RISCV_SBI_V01 && 64BIT | |
| 461 | 462 | default "256" if !RISCV_SBI_V01 && 64BIT | |
modified arch/riscv/Kconfig.errata
| @@ -46,7 +46,7 @@ config ERRATA_MIPS_P8700_PAUSE_OPCODE | |||
| 46 | 46 | ||
| 47 | 47 | config ERRATA_SIFIVE | |
| 48 | 48 | bool "SiFive errata" | |
| 49 | - | depends on RISCV_ALTERNATIVE | |
| 49 | + | depends on RISCV_ALTERNATIVE && 64BIT | |
| 50 | 50 | help | |
| 51 | 51 | All SiFive errata Kconfig depend on this Kconfig. Disabling | |
| 52 | 52 | this Kconfig will disable all SiFive errata. Please say "Y" | |
| @@ -96,6 +96,20 @@ config ERRATA_STARFIVE_JH7100 | |||
| 96 | 96 | Say "Y" if you want to support the BeagleV Starlight and/or | |
| 97 | 97 | StarFive VisionFive V1 boards. | |
| 98 | 98 | ||
| 99 | + | config ERRATA_SIFIVE_MAL_9092 | |
| 100 | + | bool "Apply SiFive HLV/HLVX/HSV fence errata" | |
| 101 | + | depends on ERRATA_SIFIVE && 64BIT | |
| 102 | + | default y | |
| 103 | + | help | |
| 104 | + | This will apply the SiFive MAL-9092 errata to add fence.rw | |
| 105 | + | instructions around all HLV/HLVX/HSV instructions. | |
| 106 | + | ||
| 107 | + | Note: HSTATUS.HU is cleared during KVM initialization. If future | |
| 108 | + | changes enable HSTATUS.HU to allow hypervisor instructions in | |
| 109 | + | U-mode, additional errata handling may be required. | |
| 110 | + | ||
| 111 | + | If you don't know what to do here, say "Y". | |
| 112 | + | ||
| 99 | 113 | config ERRATA_THEAD | |
| 100 | 114 | bool "T-HEAD errata" | |
| 101 | 115 | depends on RISCV_ALTERNATIVE | |
| @@ -146,6 +160,7 @@ config ERRATA_THEAD_PMU | |||
| 146 | 160 | config ERRATA_THEAD_GHOSTWRITE | |
| 147 | 161 | bool "Apply T-Head Ghostwrite errata" | |
| 148 | 162 | depends on ERRATA_THEAD && RISCV_ISA_XTHEADVECTOR | |
| 163 | + | select RISCV_ALTERNATIVE_EARLY | |
| 149 | 164 | default y | |
| 150 | 165 | help | |
| 151 | 166 | The T-Head C9xx cores have a vulnerability in the xtheadvector | |
modified arch/riscv/Kconfig.socs
| @@ -34,6 +34,7 @@ config ARCH_RENESAS | |||
| 34 | 34 | config ARCH_SIFIVE | |
| 35 | 35 | bool "SiFive SoCs" | |
| 36 | 36 | select ERRATA_SIFIVE | |
| 37 | + | depends on 64BIT | |
| 37 | 38 | help | |
| 38 | 39 | This enables support for SiFive SoC platform hardware. | |
| 39 | 40 | ||
modified arch/riscv/errata/sifive/errata.c
| @@ -51,6 +51,22 @@ static bool errata_cip_1200_check_func(unsigned long arch_id, unsigned long imp | |||
| 51 | 51 | return true; | |
| 52 | 52 | } | |
| 53 | 53 | ||
| 54 | + | static bool errata_mal_9092_check_func(unsigned long arch_id, unsigned long impid) | |
| 55 | + | { | |
| 56 | + | /* | |
| 57 | + | * Affected cores: | |
| 58 | + | * Architecture ID: 0x8000000000000109 | |
| 59 | + | * Implementation ID: 0x19251031, 0x19251217, 0x19260320 | |
| 60 | + | */ | |
| 61 | + | ||
| 62 | + | if (arch_id != 0x8000000000000109) | |
| 63 | + | return false; | |
| 64 | + | if (impid != 0x19251031 && impid != 0x19251217 && impid != 0x19260320) | |
| 65 | + | return false; | |
| 66 | + | ||
| 67 | + | return true; | |
| 68 | + | } | |
| 69 | + | ||
| 54 | 70 | static struct errata_info_t errata_list[ERRATA_SIFIVE_NUMBER] = { | |
| 55 | 71 | { | |
| 56 | 72 | .name = "cip-453", | |
| @@ -60,6 +76,10 @@ static struct errata_info_t errata_list[ERRATA_SIFIVE_NUMBER] = { | |||
| 60 | 76 | .name = "cip-1200", | |
| 61 | 77 | .check_func = errata_cip_1200_check_func | |
| 62 | 78 | }, | |
| 79 | + | { | |
| 80 | + | .name = "mal-9092", | |
| 81 | + | .check_func = errata_mal_9092_check_func | |
| 82 | + | }, | |
| 63 | 83 | }; | |
| 64 | 84 | ||
| 65 | 85 | static u32 __init_or_module sifive_errata_probe(unsigned long archid, | |
modified arch/riscv/include/asm/cpufeature.h
| @@ -40,6 +40,8 @@ extern u32 thead_vlenb_of; | |||
| 40 | 40 | ||
| 41 | 41 | void __init riscv_user_isa_enable(void); | |
| 42 | 42 | ||
| 43 | + | void riscv_clear_hypervisor_csr(void); | |
| 44 | + | ||
| 43 | 45 | #define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size, _validate) { \ | |
| 44 | 46 | .name = #_name, \ | |
| 45 | 47 | .property = #_name, \ | |
modified arch/riscv/include/asm/errata_list_vendors.h
| @@ -11,7 +11,8 @@ | |||
| 11 | 11 | #ifdef CONFIG_ERRATA_SIFIVE | |
| 12 | 12 | #define ERRATA_SIFIVE_CIP_453 0 | |
| 13 | 13 | #define ERRATA_SIFIVE_CIP_1200 1 | |
| 14 | - | #define ERRATA_SIFIVE_NUMBER 2 | |
| 14 | + | #define ERRATA_SIFIVE_MAL_9092 2 | |
| 15 | + | #define ERRATA_SIFIVE_NUMBER 3 | |
| 15 | 16 | #endif | |
| 16 | 17 | ||
| 17 | 18 | #ifdef CONFIG_ERRATA_THEAD | |
modified arch/riscv/include/asm/futex.h
| @@ -40,6 +40,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) | |||
| 40 | 40 | ||
| 41 | 41 | if (!access_ok(uaddr, sizeof(u32))) | |
| 42 | 42 | return -EFAULT; | |
| 43 | + | uaddr = untagged_addr(uaddr); | |
| 43 | 44 | ||
| 44 | 45 | switch (op) { | |
| 45 | 46 | case FUTEX_OP_SET: | |
| @@ -82,6 +83,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, | |||
| 82 | 83 | ||
| 83 | 84 | if (!access_ok(uaddr, sizeof(u32))) | |
| 84 | 85 | return -EFAULT; | |
| 86 | + | uaddr = untagged_addr(uaddr); | |
| 85 | 87 | ||
| 86 | 88 | __enable_user_access(); | |
| 87 | 89 | __asm__ __volatile__ ( | |
modified arch/riscv/include/asm/insn-def.h
| @@ -192,18 +192,28 @@ | |||
| 192 | 192 | INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(49), \ | |
| 193 | 193 | __RD(0), RS1(gaddr), RS2(vmid)) | |
| 194 | 194 | ||
| 195 | + | #define ALT_SIFIVE_MAL_9092_FENCE \ | |
| 196 | + | ALTERNATIVE("nop", "fence rw, rw", SIFIVE_VENDOR_ID, \ | |
| 197 | + | ERRATA_SIFIVE_MAL_9092, CONFIG_ERRATA_SIFIVE_MAL_9092) | |
| 198 | + | ||
| 195 | 199 | #define HLVX_HU(dest, addr) \ | |
| 200 | + | ALT_SIFIVE_MAL_9092_FENCE "\n" \ | |
| 196 | 201 | INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(50), \ | |
| 197 | - | RD(dest), RS1(addr), __RS2(3)) | |
| 202 | + | RD(dest), RS1(addr), __RS2(3)) "\n" \ | |
| 203 | + | ALT_SIFIVE_MAL_9092_FENCE | |
| 198 | 204 | ||
| 199 | 205 | #define HLV_W(dest, addr) \ | |
| 206 | + | ALT_SIFIVE_MAL_9092_FENCE "\n" \ | |
| 200 | 207 | INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(52), \ | |
| 201 | - | RD(dest), RS1(addr), __RS2(0)) | |
| 208 | + | RD(dest), RS1(addr), __RS2(0)) "\n" \ | |
| 209 | + | ALT_SIFIVE_MAL_9092_FENCE | |
| 202 | 210 | ||
| 203 | 211 | #ifdef CONFIG_64BIT | |
| 204 | 212 | #define HLV_D(dest, addr) \ | |
| 213 | + | ALT_SIFIVE_MAL_9092_FENCE "\n" \ | |
| 205 | 214 | INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(54), \ | |
| 206 | - | RD(dest), RS1(addr), __RS2(0)) | |
| 215 | + | RD(dest), RS1(addr), __RS2(0)) "\n" \ | |
| 216 | + | ALT_SIFIVE_MAL_9092_FENCE | |
| 207 | 217 | #else | |
| 208 | 218 | #define HLV_D(dest, addr) \ | |
| 209 | 219 | __ASM_STR(.error "hlv.d requires 64-bit support") | |
modified arch/riscv/include/asm/scs.h
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | #ifdef __ASSEMBLER__ | |
| 6 | 6 | #include <asm/asm-offsets.h> | |
| 7 | + | #include <asm/csr.h> | |
| 7 | 8 | ||
| 8 | 9 | #ifdef CONFIG_SHADOW_CALL_STACK | |
| 9 | 10 | ||
| @@ -22,9 +23,17 @@ | |||
| 22 | 23 | REG_L gp, TASK_TI_SCS_SP(tp) | |
| 23 | 24 | .endm | |
| 24 | 25 | ||
| 25 | - | /* Load task_scs_sp(current) to gp, but only if tp has changed. */ | |
| 26 | - | .macro scs_load_current_if_task_changed prev | |
| 27 | - | beq \prev, tp, _skip_scs | |
| 26 | + | /* | |
| 27 | + | * Load task_scs_sp(current) to gp, but only when the trap came from U-mode. | |
| 28 | + | * The source privilege level is taken from the saved sstatus.SPP bit (written | |
| 29 | + | * by hardware on trap entry), not by comparing tp. tp is a user-writable | |
| 30 | + | * register, so gating the shadow call stack reload on it let a user task that | |
| 31 | + | * set tp == ¤t skip the reload and run the kernel with an attacker | |
| 32 | + | * controlled gp (the shadow call stack pointer). | |
| 33 | + | */ | |
| 34 | + | .macro scs_load_current_if_from_user status, tmp | |
| 35 | + | andi \tmp, \status, SR_SPP | |
| 36 | + | bnez \tmp, _skip_scs | |
| 28 | 37 | scs_load_current | |
| 29 | 38 | _skip_scs: | |
| 30 | 39 | .endm | |
| @@ -42,7 +51,7 @@ _skip_scs: | |||
| 42 | 51 | .endm | |
| 43 | 52 | .macro scs_load_current | |
| 44 | 53 | .endm | |
| 45 | - | .macro scs_load_current_if_task_changed prev | |
| 54 | + | .macro scs_load_current_if_from_user status, tmp | |
| 46 | 55 | .endm | |
| 47 | 56 | .macro scs_save_current | |
| 48 | 57 | .endm | |
modified arch/riscv/include/asm/vector.h
| @@ -137,8 +137,8 @@ static __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest) | |||
| 137 | 137 | "csrr %0, " __stringify(CSR_VSTART) "\n\t" | |
| 138 | 138 | "csrr %1, " __stringify(CSR_VTYPE) "\n\t" | |
| 139 | 139 | "csrr %2, " __stringify(CSR_VL) "\n\t" | |
| 140 | - | : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl), | |
| 141 | - | "=r" (dest->vcsr) : :); | |
| 140 | + | : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl) | |
| 141 | + | : :); | |
| 142 | 142 | ||
| 143 | 143 | if (has_xtheadvector()) { | |
| 144 | 144 | unsigned long status; | |
| @@ -230,7 +230,7 @@ static inline void __riscv_v_vstate_save(struct __riscv_v_ext_state *save_to, | |||
| 230 | 230 | "add %1, %1, %0\n\t" | |
| 231 | 231 | "vse8.v v24, (%1)\n\t" | |
| 232 | 232 | ".option pop\n\t" | |
| 233 | - | : "=&r" (vl) : "r" (datap) : "memory"); | |
| 233 | + | : "=&r" (vl), "+r" (datap) : : "memory"); | |
| 234 | 234 | } | |
| 235 | 235 | riscv_v_disable(); | |
| 236 | 236 | } | |
| @@ -266,7 +266,7 @@ static inline void __riscv_v_vstate_restore(struct __riscv_v_ext_state *restore_ | |||
| 266 | 266 | "add %1, %1, %0\n\t" | |
| 267 | 267 | "vle8.v v24, (%1)\n\t" | |
| 268 | 268 | ".option pop\n\t" | |
| 269 | - | : "=&r" (vl) : "r" (datap) : "memory"); | |
| 269 | + | : "=&r" (vl), "+r" (datap) : : "memory"); | |
| 270 | 270 | } | |
| 271 | 271 | __vstate_csr_restore(restore_from); | |
| 272 | 272 | riscv_v_disable(); | |
modified arch/riscv/include/uapi/asm/vendor/mips.h
| @@ -1,3 +1,5 @@ | |||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
| 2 | 2 | ||
| 3 | - | #define RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL BIT(0) | |
| 3 | + | #include <linux/const.h> | |
| 4 | + | ||
| 5 | + | #define RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL _BITULL(0) | |
modified arch/riscv/kernel/cpufeature.c
| @@ -1233,6 +1233,18 @@ void __init riscv_user_isa_enable(void) | |||
| 1233 | 1233 | pr_warn("Zicbop disabled as it is unavailable on some harts\n"); | |
| 1234 | 1234 | } | |
| 1235 | 1235 | ||
| 1236 | + | void riscv_clear_hypervisor_csr(void) | |
| 1237 | + | { | |
| 1238 | + | if (!riscv_has_extension_unlikely(RISCV_ISA_EXT_H)) | |
| 1239 | + | return; | |
| 1240 | + | ||
| 1241 | + | /* | |
| 1242 | + | * Clear HSTATUS.HU to restrict hypervisor instructions to HS-mode. | |
| 1243 | + | * This prevents user-mode from executing HLV/HSV instructions. | |
| 1244 | + | */ | |
| 1245 | + | csr_clear(CSR_HSTATUS, HSTATUS_HU); | |
| 1246 | + | } | |
| 1247 | + | ||
| 1236 | 1248 | #ifdef CONFIG_RISCV_ALTERNATIVE | |
| 1237 | 1249 | /* | |
| 1238 | 1250 | * Alternative patch sites consider 48 bits when determining when to patch | |
modified arch/riscv/kernel/entry.S
| @@ -208,7 +208,7 @@ SYM_CODE_START(handle_exception) | |||
| 208 | 208 | load_global_pointer | |
| 209 | 209 | ||
| 210 | 210 | /* Load the kernel shadow call stack pointer if coming from userspace */ | |
| 211 | - | scs_load_current_if_task_changed s5 | |
| 211 | + | scs_load_current_if_from_user s1, s5 | |
| 212 | 212 | ||
| 213 | 213 | #ifdef CONFIG_RISCV_ISA_V_PREEMPTIVE | |
| 214 | 214 | move a0, sp | |
modified arch/riscv/kernel/patch.c
| @@ -48,7 +48,7 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap) | |||
| 48 | 48 | if (!IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)) | |
| 49 | 49 | return addr; | |
| 50 | 50 | phys = __pa_symbol(addr); | |
| 51 | - | } else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) { | |
| 51 | + | } else if (IS_ENABLED(CONFIG_EXECMEM)) { | |
| 52 | 52 | struct page *page = vmalloc_to_page(addr); | |
| 53 | 53 | ||
| 54 | 54 | BUG_ON(!page); | |
modified arch/riscv/kernel/ptrace.c
| @@ -230,6 +230,7 @@ static int riscv_vr_set(struct task_struct *target, | |||
| 230 | 230 | return -ENODATA; | |
| 231 | 231 | ||
| 232 | 232 | /* Copy rest of the vstate except datap */ | |
| 233 | + | memset(&ptrace_vstate, 0, sizeof(ptrace_vstate)); | |
| 233 | 234 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ptrace_vstate, 0, | |
| 234 | 235 | sizeof(struct __riscv_v_regset_state)); | |
| 235 | 236 | if (unlikely(ret)) | |
| @@ -299,6 +300,9 @@ static int riscv_cfi_get(struct task_struct *target, | |||
| 299 | 300 | struct user_cfi_state user_cfi; | |
| 300 | 301 | struct pt_regs *regs; | |
| 301 | 302 | ||
| 303 | + | if (!is_user_lpad_enabled() && !is_user_shstk_enabled()) | |
| 304 | + | return -EINVAL; | |
| 305 | + | ||
| 302 | 306 | memset(&user_cfi, 0, sizeof(user_cfi)); | |
| 303 | 307 | regs = task_pt_regs(target); | |
| 304 | 308 | ||
| @@ -337,8 +341,12 @@ static int riscv_cfi_set(struct task_struct *target, | |||
| 337 | 341 | struct user_cfi_state user_cfi; | |
| 338 | 342 | struct pt_regs *regs; | |
| 339 | 343 | ||
| 344 | + | if (!is_user_lpad_enabled() && !is_user_shstk_enabled()) | |
| 345 | + | return -EINVAL; | |
| 346 | + | ||
| 340 | 347 | regs = task_pt_regs(target); | |
| 341 | 348 | ||
| 349 | + | memset(&user_cfi, 0, sizeof(user_cfi)); | |
| 342 | 350 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &user_cfi, 0, -1); | |
| 343 | 351 | if (ret) | |
| 344 | 352 | return ret; | |
modified arch/riscv/kernel/setup.c
| @@ -366,6 +366,8 @@ void __init setup_arch(char **cmdline_p) | |||
| 366 | 366 | ||
| 367 | 367 | if (!IS_ENABLED(CONFIG_RISCV_ISA_ZBB) || !riscv_isa_extension_available(NULL, ZBB)) | |
| 368 | 368 | static_branch_disable(&efficient_ffs_key); | |
| 369 | + | ||
| 370 | + | riscv_clear_hypervisor_csr(); | |
| 369 | 371 | } | |
| 370 | 372 | ||
| 371 | 373 | bool arch_cpu_is_hotpluggable(int cpu) | |
modified arch/riscv/kernel/smpboot.c
| @@ -244,6 +244,8 @@ asmlinkage __visible void smp_callin(void) | |||
| 244 | 244 | ||
| 245 | 245 | numa_add_cpu(curr_cpuid); | |
| 246 | 246 | ||
| 247 | + | riscv_clear_hypervisor_csr(); | |
| 248 | + | ||
| 247 | 249 | pr_debug("CPU%u: Booted secondary hartid %lu\n", curr_cpuid, | |
| 248 | 250 | cpuid_to_hartid_map(curr_cpuid)); | |
| 249 | 251 | ||
modified arch/riscv/kernel/suspend.c
| @@ -43,6 +43,8 @@ void suspend_save_csrs(struct suspend_context *context) | |||
| 43 | 43 | ||
| 44 | 44 | void suspend_restore_csrs(struct suspend_context *context) | |
| 45 | 45 | { | |
| 46 | + | riscv_clear_hypervisor_csr(); | |
| 47 | + | ||
| 46 | 48 | csr_write(CSR_SCRATCH, 0); | |
| 47 | 49 | if (riscv_has_extension_unlikely(RISCV_ISA_EXT_XLINUXENVCFG)) | |
| 48 | 50 | csr_write(CSR_ENVCFG, context->envcfg); | |
modified arch/riscv/kernel/vdso/Makefile
| @@ -36,6 +36,7 @@ endif | |||
| 36 | 36 | ccflags-y := -fno-stack-protector | |
| 37 | 37 | ccflags-y += -DDISABLE_BRANCH_PROFILING | |
| 38 | 38 | ccflags-y += -fno-builtin | |
| 39 | + | ccflags-y += $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 39 | 40 | ccflags-y += $(KBUILD_BASE_ISA)$(CFI_MARCH) | |
| 40 | 41 | ccflags-y += $(CFI_FULL) | |
| 41 | 42 | asflags-y += $(KBUILD_BASE_ISA)$(CFI_MARCH) | |
modified arch/riscv/kvm/aia_device.c
| @@ -237,7 +237,7 @@ static int aia_init(struct kvm *kvm) | |||
| 237 | 237 | return -EBUSY; | |
| 238 | 238 | ||
| 239 | 239 | /* We might be in the middle of creating a VCPU? */ | |
| 240 | - | if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus)) | |
| 240 | + | if (kvm_is_vcpu_creation_in_progress(kvm)) | |
| 241 | 241 | return -EBUSY; | |
| 242 | 242 | ||
| 243 | 243 | /* Number of sources should be less than or equals number of IDs */ | |
modified arch/riscv/lib/strnlen.S
| @@ -87,9 +87,25 @@ strnlen_zbb: | |||
| 87 | 87 | * Aligned boundary. Use the address of the last valid byte | |
| 88 | 88 | * (s + count - 1) to avoid loading a word past the count | |
| 89 | 89 | * boundary in the loop below. count == 0 is handled above. | |
| 90 | + | * | |
| 91 | + | * Saturate the boundary when s + count would wrap around (very | |
| 92 | + | * large counts, e.g. SIZE_MAX passed by FORTIFY strcat/strlcat | |
| 93 | + | * with a destination whose size is unknown at compile time). | |
| 94 | + | * Without this, the wrapped boundary lands before s and the | |
| 95 | + | * pre-loop guard below always exits, returning a truncated | |
| 96 | + | * length. | |
| 97 | + | * | |
| 98 | + | * Clamping the increment to ~s (== SIZE_MAX - s) keeps the | |
| 99 | + | * computation branchless and wrap-free: | |
| 100 | + | * | |
| 101 | + | * s + min(count - 1, ~s) == saturating_add(s, count - 1) | |
| 102 | + | * | |
| 103 | + | * Saturating makes the scan equivalent to strlen(). | |
| 90 | 104 | */ | |
| 91 | - | add t4, a0, a1 | |
| 92 | - | addi t4, t4, -1 | |
| 105 | + | addi t4, a1, -1 /* count - 1 */ | |
| 106 | + | not t1, a0 /* SIZE_MAX - s */ | |
| 107 | + | minu t4, t4, t1 /* clamp, so s + t4 can never wrap */ | |
| 108 | + | add t4, a0, t4 /* saturated s + count - 1 */ | |
| 93 | 109 | andi t4, t4, -SZREG | |
| 94 | 110 | ||
| 95 | 111 | /* Get the first word. */ | |
modified arch/riscv/mm/extable.c
| @@ -68,8 +68,8 @@ ex_handler_load_unaligned_zeropad(const struct exception_table_entry *ex, | |||
| 68 | 68 | ||
| 69 | 69 | addr = regs_get_gpr(regs, reg_addr * sizeof(unsigned long)); | |
| 70 | 70 | ||
| 71 | - | offset = addr & 0x7UL; | |
| 72 | - | addr &= ~0x7UL; | |
| 71 | + | offset = addr & (sizeof(data) - 1); | |
| 72 | + | addr &= ~(sizeof(data) - 1); | |
| 73 | 73 | ||
| 74 | 74 | data = *(unsigned long *)addr >> (offset * 8); | |
| 75 | 75 | ||
modified arch/riscv/net/bpf_jit_comp64.c
| @@ -822,6 +822,24 @@ static int gen_jump_or_nops(void *target, void *ip, u32 *insns, bool is_call) | |||
| 822 | 822 | return emit_jump_and_link(is_call ? RV_REG_T0 : RV_REG_ZERO, rvoff, false, &ctx); | |
| 823 | 823 | } | |
| 824 | 824 | ||
| 825 | + | int arch_bpf_trampoline_skip(void *nop, void *target) | |
| 826 | + | { | |
| 827 | + | u32 old_insn = rv_nop(); | |
| 828 | + | u32 new_insn = rv_jal(RV_REG_ZERO, (target - nop) >> 1); | |
| 829 | + | int ret; | |
| 830 | + | ||
| 831 | + | if (memcmp(nop, &old_insn, sizeof(old_insn))) | |
| 832 | + | return -EFAULT; | |
| 833 | + | ||
| 834 | + | cpus_read_lock(); | |
| 835 | + | mutex_lock(&text_mutex); | |
| 836 | + | ret = patch_text(nop, &new_insn, sizeof(new_insn)); | |
| 837 | + | mutex_unlock(&text_mutex); | |
| 838 | + | cpus_read_unlock(); | |
| 839 | + | ||
| 840 | + | return ret; | |
| 841 | + | } | |
| 842 | + | ||
| 825 | 843 | int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t, | |
| 826 | 844 | enum bpf_text_poke_type new_t, void *old_addr, | |
| 827 | 845 | void *new_addr) | |
| @@ -904,12 +922,17 @@ static void emit_store_stack_imm64(u8 reg, int stack_off, u64 imm64, | |||
| 904 | 922 | emit_sd(RV_REG_FP, stack_off, reg, ctx); | |
| 905 | 923 | } | |
| 906 | 924 | ||
| 907 | - | static int invoke_bpf_prog(struct bpf_tramp_node *node, int args_off, int retval_off, | |
| 908 | - | int run_ctx_off, bool save_ret, struct rv_jit_context *ctx) | |
| 925 | + | static int invoke_bpf_prog(struct bpf_tramp_image *im, struct bpf_tramp_node *node, | |
| 926 | + | int args_off, int retval_off, int run_ctx_off, bool save_ret, | |
| 927 | + | struct rv_jit_context *ctx) | |
| 909 | 928 | { | |
| 910 | 929 | int ret, branch_off; | |
| 911 | 930 | struct bpf_prog *p = node->link->prog; | |
| 912 | 931 | int cookie_off = offsetof(struct bpf_tramp_run_ctx, bpf_cookie); | |
| 932 | + | void *skip = ctx->ro_insns + ctx->ninsns; | |
| 933 | + | ||
| 934 | + | /* nop, patched to a jal over this prog when it is detached */ | |
| 935 | + | emit(rv_nop(), ctx); | |
| 913 | 936 | ||
| 914 | 937 | if (node->cookie) | |
| 915 | 938 | emit_store_stack_imm64(RV_REG_T1, -run_ctx_off + cookie_off, node->cookie, ctx); | |
| @@ -962,13 +985,17 @@ static int invoke_bpf_prog(struct bpf_tramp_node *node, int args_off, int retval | |||
| 962 | 985 | /* arg3: &run_ctx */ | |
| 963 | 986 | emit_addi(RV_REG_A2, RV_REG_FP, -run_ctx_off, ctx); | |
| 964 | 987 | ret = emit_call((const u64)bpf_trampoline_exit(p), true, ctx); | |
| 988 | + | if (ret) | |
| 989 | + | return ret; | |
| 965 | 990 | ||
| 966 | - | return ret; | |
| 991 | + | bpf_tramp_image_add_skip(im, p, skip, ctx->ro_insns + ctx->ninsns); | |
| 992 | + | return 0; | |
| 967 | 993 | } | |
| 968 | 994 | ||
| 969 | - | static int invoke_bpf(struct bpf_tramp_nodes *tn, int args_off, int retval_off, | |
| 970 | - | int run_ctx_off, int func_meta_off, bool save_ret, u64 func_meta, | |
| 971 | - | int cookie_off, struct rv_jit_context *ctx) | |
| 995 | + | static int invoke_bpf(struct bpf_tramp_image *im, struct bpf_tramp_nodes *tn, | |
| 996 | + | int args_off, int retval_off, int run_ctx_off, int func_meta_off, | |
| 997 | + | bool save_ret, u64 func_meta, int cookie_off, | |
| 998 | + | struct rv_jit_context *ctx) | |
| 972 | 999 | { | |
| 973 | 1000 | int i, cur_cookie = (cookie_off - args_off) / 8; | |
| 974 | 1001 | ||
| @@ -981,8 +1008,8 @@ static int invoke_bpf(struct bpf_tramp_nodes *tn, int args_off, int retval_off, | |||
| 981 | 1008 | emit_store_stack_imm64(RV_REG_T1, -func_meta_off, meta, ctx); | |
| 982 | 1009 | cur_cookie--; | |
| 983 | 1010 | } | |
| 984 | - | err = invoke_bpf_prog(tn->nodes[i], args_off, retval_off, run_ctx_off, | |
| 985 | - | save_ret, ctx); | |
| 1011 | + | err = invoke_bpf_prog(im, tn->nodes[i], args_off, retval_off, | |
| 1012 | + | run_ctx_off, save_ret, ctx); | |
| 986 | 1013 | if (err) | |
| 987 | 1014 | return err; | |
| 988 | 1015 | } | |
| @@ -1170,7 +1197,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 1170 | 1197 | } | |
| 1171 | 1198 | ||
| 1172 | 1199 | if (fentry->nr_nodes) { | |
| 1173 | - | ret = invoke_bpf(fentry, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 1200 | + | ret = invoke_bpf(im, fentry, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 1174 | 1201 | flags & BPF_TRAMP_F_RET_FENTRY_RET, func_meta, cookie_off, ctx); | |
| 1175 | 1202 | if (ret) | |
| 1176 | 1203 | return ret; | |
| @@ -1184,7 +1211,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 1184 | 1211 | /* cleanup to avoid garbage return value confusion */ | |
| 1185 | 1212 | emit_sd(RV_REG_FP, -retval_off, RV_REG_ZERO, ctx); | |
| 1186 | 1213 | for (i = 0; i < fmod_ret->nr_nodes; i++) { | |
| 1187 | - | ret = invoke_bpf_prog(fmod_ret->nodes[i], args_off, retval_off, | |
| 1214 | + | ret = invoke_bpf_prog(im, fmod_ret->nodes[i], args_off, retval_off, | |
| 1188 | 1215 | run_ctx_off, true, ctx); | |
| 1189 | 1216 | if (ret) | |
| 1190 | 1217 | goto out; | |
| @@ -1211,10 +1238,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 1211 | 1238 | emit_sd(RV_REG_FP, -tcc_off, RV_REG_TCC, ctx); | |
| 1212 | 1239 | emit_sd(RV_REG_FP, -retval_off, RV_REG_A0, ctx); | |
| 1213 | 1240 | emit_sd(RV_REG_FP, -(retval_off - 8), regmap[BPF_REG_0], ctx); | |
| 1214 | - | im->ip_after_call = ctx->ro_insns + ctx->ninsns; | |
| 1215 | - | /* 2 nops reserved for auipc+jalr pair */ | |
| 1216 | - | emit(rv_nop(), ctx); | |
| 1217 | - | emit(rv_nop(), ctx); | |
| 1218 | 1241 | } | |
| 1219 | 1242 | ||
| 1220 | 1243 | /* update branches saved in invoke_bpf_mod_ret with bnez */ | |
| @@ -1230,14 +1253,13 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 1230 | 1253 | emit_store_stack_imm64(RV_REG_T1, -func_meta_off, func_meta, ctx); | |
| 1231 | 1254 | ||
| 1232 | 1255 | if (fexit->nr_nodes) { | |
| 1233 | - | ret = invoke_bpf(fexit, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 1256 | + | ret = invoke_bpf(im, fexit, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 1234 | 1257 | false, func_meta, cookie_off, ctx); | |
| 1235 | 1258 | if (ret) | |
| 1236 | 1259 | goto out; | |
| 1237 | 1260 | } | |
| 1238 | 1261 | ||
| 1239 | 1262 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 1240 | - | im->ip_epilogue = ctx->ro_insns + ctx->ninsns; | |
| 1241 | 1263 | emit_imm(RV_REG_A0, ctx->insns ? (const s64)im : RV_MAX_COUNT_IMM, ctx); | |
| 1242 | 1264 | ret = emit_call((const u64)__bpf_tramp_exit, true, ctx); | |
| 1243 | 1265 | if (ret) | |
| @@ -1299,7 +1321,7 @@ out: | |||
| 1299 | 1321 | int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |
| 1300 | 1322 | struct bpf_tramp_nodes *tnodes, void *func_addr) | |
| 1301 | 1323 | { | |
| 1302 | - | struct bpf_tramp_image im; | |
| 1324 | + | struct bpf_tramp_image im = {}; | |
| 1303 | 1325 | struct rv_jit_context ctx; | |
| 1304 | 1326 | int ret; | |
| 1305 | 1327 | ||
modified arch/s390/kernel/vdso/Makefile
| @@ -29,6 +29,7 @@ KBUILD_CFLAGS_VDSO := $(filter-out -munaligned-symbols,$(KBUILD_CFLAGS_VDSO)) | |||
| 29 | 29 | KBUILD_CFLAGS_VDSO := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_VDSO)) | |
| 30 | 30 | KBUILD_CFLAGS_VDSO += -fPIC -fno-common -fno-builtin -fasynchronous-unwind-tables | |
| 31 | 31 | KBUILD_CFLAGS_VDSO += -fno-stack-protector $(DISABLE_KSTACK_ERASE) | |
| 32 | + | KBUILD_CFLAGS_VDSO += $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 32 | 33 | ldflags-y := -shared -soname=linux-vdso.so.1 \ | |
| 33 | 34 | --hash-style=both --build-id=sha1 \ | |
| 34 | 35 | $(call ld-option, --eh-frame-hdr) -T | |
modified arch/s390/kvm/s390/s390.c
| @@ -3579,12 +3579,11 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) | |||
| 3579 | 3579 | ||
| 3580 | 3580 | void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) | |
| 3581 | 3581 | { | |
| 3582 | - | mutex_lock(&vcpu->kvm->lock); | |
| 3583 | 3582 | preempt_disable(); | |
| 3584 | 3583 | vcpu->arch.sie_block->epoch = vcpu->kvm->arch.epoch; | |
| 3585 | 3584 | vcpu->arch.sie_block->epdx = vcpu->kvm->arch.epdx; | |
| 3586 | 3585 | preempt_enable(); | |
| 3587 | - | mutex_unlock(&vcpu->kvm->lock); | |
| 3586 | + | ||
| 3588 | 3587 | if (!kvm_is_ucontrol(vcpu->kvm)) { | |
| 3589 | 3588 | vcpu->arch.gmap = vcpu->kvm->arch.gmap; | |
| 3590 | 3589 | sca_add_vcpu(vcpu); | |
| @@ -3757,13 +3756,11 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) | |||
| 3757 | 3756 | ||
| 3758 | 3757 | kvm_s390_vcpu_pci_setup(vcpu); | |
| 3759 | 3758 | ||
| 3760 | - | mutex_lock(&vcpu->kvm->lock); | |
| 3761 | 3759 | if (kvm_s390_pv_is_protected(vcpu->kvm)) { | |
| 3762 | 3760 | rc = kvm_s390_pv_create_cpu(vcpu, &uvrc, &uvrrc); | |
| 3763 | 3761 | if (rc) | |
| 3764 | 3762 | kvm_s390_vcpu_unsetup_cmma(vcpu); | |
| 3765 | 3763 | } | |
| 3766 | - | mutex_unlock(&vcpu->kvm->lock); | |
| 3767 | 3764 | ||
| 3768 | 3765 | return rc; | |
| 3769 | 3766 | } | |
modified arch/s390/net/bpf_jit_comp.c
| @@ -2566,6 +2566,8 @@ struct bpf_tramp_jit { | |||
| 2566 | 2566 | int r14_off; /* Offset of saved %r14, has to be at the | |
| 2567 | 2567 | * bottom */ | |
| 2568 | 2568 | int do_fexit; /* do_fexit: label */ | |
| 2569 | + | int skip[BPF_MAX_TRAMP_LINKS]; /* skip: labels after each prog */ | |
| 2570 | + | int nr_progs; | |
| 2569 | 2571 | }; | |
| 2570 | 2572 | ||
| 2571 | 2573 | static void load_imm64(struct bpf_jit *jit, int dst_reg, u64 val) | |
| @@ -2584,6 +2586,7 @@ static void emit_store_stack_imm64(struct bpf_jit *jit, int tmp_reg, int stack_o | |||
| 2584 | 2586 | } | |
| 2585 | 2587 | ||
| 2586 | 2588 | static int invoke_bpf_prog(struct bpf_tramp_jit *tjit, | |
| 2589 | + | struct bpf_tramp_image *im, | |
| 2587 | 2590 | const struct btf_func_model *m, | |
| 2588 | 2591 | struct bpf_tramp_node *node, bool save_ret) | |
| 2589 | 2592 | { | |
| @@ -2591,8 +2594,20 @@ static int invoke_bpf_prog(struct bpf_tramp_jit *tjit, | |||
| 2591 | 2594 | int cookie_off = tjit->run_ctx_off + | |
| 2592 | 2595 | offsetof(struct bpf_tramp_run_ctx, bpf_cookie); | |
| 2593 | 2596 | struct bpf_prog *p = node->link->prog; | |
| 2597 | + | void *skip = jit->prg_buf + jit->prg; | |
| 2598 | + | int idx = tjit->nr_progs++; | |
| 2594 | 2599 | int patch; | |
| 2595 | 2600 | ||
| 2601 | + | if (idx >= ARRAY_SIZE(tjit->skip)) | |
| 2602 | + | return -E2BIG; | |
| 2603 | + | ||
| 2604 | + | /* | |
| 2605 | + | * nop, patched to skip this prog when it is detached | |
| 2606 | + | */ | |
| 2607 | + | ||
| 2608 | + | /* brcl 0,skip */ | |
| 2609 | + | EMIT6_PCREL_RILC(0xc0040000, 0, tjit->skip[idx]); | |
| 2610 | + | ||
| 2596 | 2611 | /* | |
| 2597 | 2612 | * run_ctx.cookie = node->cookie; | |
| 2598 | 2613 | */ | |
| @@ -2652,10 +2667,15 @@ static int invoke_bpf_prog(struct bpf_tramp_jit *tjit, | |||
| 2652 | 2667 | /* brasl %r14,__bpf_prog_exit */ | |
| 2653 | 2668 | EMIT6_PCREL_RILB_PTR(0xc0050000, REG_14, bpf_trampoline_exit(p)); | |
| 2654 | 2669 | ||
| 2670 | + | /* skip: */ | |
| 2671 | + | tjit->skip[idx] = jit->prg; | |
| 2672 | + | bpf_tramp_image_add_skip(im, p, skip, jit->prg_buf + jit->prg); | |
| 2673 | + | ||
| 2655 | 2674 | return 0; | |
| 2656 | 2675 | } | |
| 2657 | 2676 | ||
| 2658 | 2677 | static int invoke_bpf(struct bpf_tramp_jit *tjit, | |
| 2678 | + | struct bpf_tramp_image *im, | |
| 2659 | 2679 | const struct btf_func_model *m, | |
| 2660 | 2680 | struct bpf_tramp_nodes *tn, bool save_ret, | |
| 2661 | 2681 | u64 func_meta, int cookie_off) | |
| @@ -2670,7 +2690,7 @@ static int invoke_bpf(struct bpf_tramp_jit *tjit, | |||
| 2670 | 2690 | emit_store_stack_imm64(jit, REG_0, tjit->func_meta_off, meta); | |
| 2671 | 2691 | cur_cookie--; | |
| 2672 | 2692 | } | |
| 2673 | - | if (invoke_bpf_prog(tjit, m, tn->nodes[i], save_ret)) | |
| 2693 | + | if (invoke_bpf_prog(tjit, im, m, tn->nodes[i], save_ret)) | |
| 2674 | 2694 | return -EINVAL; | |
| 2675 | 2695 | } | |
| 2676 | 2696 | ||
| @@ -2712,6 +2732,11 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2712 | 2732 | u64 func_meta; | |
| 2713 | 2733 | int i, j; | |
| 2714 | 2734 | ||
| 2735 | + | /* The skip labels are taken from the previous pass. */ | |
| 2736 | + | tjit->nr_progs = 0; | |
| 2737 | + | if (im) | |
| 2738 | + | im->nr_skips = 0; | |
| 2739 | + | ||
| 2715 | 2740 | /* Support as many stack arguments as "mvc" instruction can handle. */ | |
| 2716 | 2741 | nr_reg_args = min_t(int, m->nr_args, MAX_NR_REG_ARGS); | |
| 2717 | 2742 | nr_stack_args = m->nr_args - nr_reg_args; | |
| @@ -2875,7 +2900,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2875 | 2900 | emit_store_stack_imm64(jit, REG_0, tjit->retval_off, 0); | |
| 2876 | 2901 | } | |
| 2877 | 2902 | ||
| 2878 | - | if (invoke_bpf(tjit, m, fentry, flags & BPF_TRAMP_F_RET_FENTRY_RET, | |
| 2903 | + | if (invoke_bpf(tjit, im, m, fentry, flags & BPF_TRAMP_F_RET_FENTRY_RET, | |
| 2879 | 2904 | func_meta, cookie_off)) | |
| 2880 | 2905 | return -EINVAL; | |
| 2881 | 2906 | ||
| @@ -2889,7 +2914,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2889 | 2914 | 0xf000 | tjit->retval_off); | |
| 2890 | 2915 | ||
| 2891 | 2916 | for (i = 0; i < fmod_ret->nr_nodes; i++) { | |
| 2892 | - | if (invoke_bpf_prog(tjit, m, fmod_ret->nodes[i], true)) | |
| 2917 | + | if (invoke_bpf_prog(tjit, im, m, fmod_ret->nodes[i], true)) | |
| 2893 | 2918 | return -EINVAL; | |
| 2894 | 2919 | ||
| 2895 | 2920 | /* | |
| @@ -2943,15 +2968,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2943 | 2968 | /* mvc tccnt_off(%r15),tail_call_cnt(4,%r15) */ | |
| 2944 | 2969 | _EMIT6(0xd203f000 | tjit->tccnt_off, | |
| 2945 | 2970 | 0xf000 | offsetof(struct prog_frame, tail_call_cnt)); | |
| 2946 | - | ||
| 2947 | - | im->ip_after_call = jit->prg_buf + jit->prg; | |
| 2948 | - | ||
| 2949 | - | /* | |
| 2950 | - | * The following nop will be patched by bpf_tramp_image_put(). | |
| 2951 | - | */ | |
| 2952 | - | ||
| 2953 | - | /* brcl 0,im->ip_epilogue */ | |
| 2954 | - | EMIT6_PCREL_RILC(0xc0040000, 0, (u64)im->ip_epilogue); | |
| 2955 | 2971 | } | |
| 2956 | 2972 | ||
| 2957 | 2973 | /* Set the "is_return" flag for fsession. */ | |
| @@ -2962,12 +2978,10 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2962 | 2978 | ||
| 2963 | 2979 | /* do_fexit: */ | |
| 2964 | 2980 | tjit->do_fexit = jit->prg; | |
| 2965 | - | if (invoke_bpf(tjit, m, fexit, false, func_meta, cookie_off)) | |
| 2981 | + | if (invoke_bpf(tjit, im, m, fexit, false, func_meta, cookie_off)) | |
| 2966 | 2982 | return -EINVAL; | |
| 2967 | 2983 | ||
| 2968 | 2984 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 2969 | - | im->ip_epilogue = jit->prg_buf + jit->prg; | |
| 2970 | - | ||
| 2971 | 2985 | /* | |
| 2972 | 2986 | * __bpf_tramp_exit(im); | |
| 2973 | 2987 | */ | |
| @@ -3016,7 +3030,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 3016 | 3030 | int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |
| 3017 | 3031 | struct bpf_tramp_nodes *tnodes, void *orig_call) | |
| 3018 | 3032 | { | |
| 3019 | - | struct bpf_tramp_image im; | |
| 3033 | + | struct bpf_tramp_image im = {}; | |
| 3020 | 3034 | struct bpf_tramp_jit tjit; | |
| 3021 | 3035 | int ret; | |
| 3022 | 3036 | ||
modified arch/um/drivers/vector_transports.c
| @@ -209,6 +209,7 @@ static int raw_verify_header( | |||
| 209 | 209 | if ((vheader->flags & VIRTIO_NET_HDR_F_DATA_VALID) > 0) | |
| 210 | 210 | return 1; | |
| 211 | 211 | ||
| 212 | + | skb_set_network_header(skb, ETH_HLEN); | |
| 212 | 213 | virtio_net_hdr_to_skb(skb, vheader, virtio_legacy_is_little_endian()); | |
| 213 | 214 | return 0; | |
| 214 | 215 | } | |
modified arch/x86/crypto/aesni-intel_glue.c
| @@ -1293,6 +1293,7 @@ static void gcm_process_assoc(const struct aes_gcm_key *key, u8 ghash_acc[16], | |||
| 1293 | 1293 | unsigned int len; | |
| 1294 | 1294 | const u8 *src = walk.addr; | |
| 1295 | 1295 | ||
| 1296 | + | assoclen -= orig_len_this_step; | |
| 1296 | 1297 | if (unlikely(pos)) { | |
| 1297 | 1298 | len = min(len_this_step, 16 - pos); | |
| 1298 | 1299 | memcpy(&buf[pos], src, len); | |
| @@ -1320,7 +1321,6 @@ next: | |||
| 1320 | 1321 | kernel_fpu_end(); | |
| 1321 | 1322 | kernel_fpu_begin(); | |
| 1322 | 1323 | } | |
| 1323 | - | assoclen -= orig_len_this_step; | |
| 1324 | 1324 | } | |
| 1325 | 1325 | if (unlikely(pos)) | |
| 1326 | 1326 | aes_gcm_aad_update(key, ghash_acc, buf, pos, flags); | |
modified arch/x86/entry/vdso/vdso64/Makefile
| @@ -14,7 +14,7 @@ vobjs-$(CONFIG_X86_SGX) += vsgx.o | |||
| 14 | 14 | vobjs-$(CONFIG_FUTEX_ROBUST_UNLOCK) += vfutex.o | |
| 15 | 15 | ||
| 16 | 16 | # Compilation flags | |
| 17 | - | flags-y := -DBUILD_VDSO64 -m64 -mcmodel=small | |
| 17 | + | flags-y := -DBUILD_VDSO64 -m64 -mcmodel=small $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 18 | 18 | ||
| 19 | 19 | # The location of this include matters! | |
| 20 | 20 | include $(src)/../common/Makefile.include | |
modified arch/x86/include/asm/cpufeatures.h
| @@ -477,6 +477,8 @@ | |||
| 477 | 477 | #define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* No Nested Data Breakpoints */ | |
| 478 | 478 | #define X86_FEATURE_WRMSR_XX_BASE_NS (20*32+ 1) /* WRMSR to {FS,GS,KERNEL_GS}_BASE is non-serializing */ | |
| 479 | 479 | #define X86_FEATURE_LFENCE_RDTSC (20*32+ 2) /* LFENCE always serializing / synchronizes RDTSC */ | |
| 480 | + | ||
| 481 | + | #define X86_FEATURE_TLBSYNC_SFW_NO (20*32+ 4) /* TLBI Erratum #1718 fixed in microcode */ | |
| 480 | 482 | #define X86_FEATURE_VERW_CLEAR (20*32+ 5) /* The memory form of VERW mitigates TSA */ | |
| 481 | 483 | #define X86_FEATURE_NULL_SEL_CLR_BASE (20*32+ 6) /* Null Selector Clears Base */ | |
| 482 | 484 | ||
| @@ -587,4 +589,5 @@ | |||
| 587 | 589 | #define X86_BUG_TSA X86_BUG( 1*32+ 9) /* "tsa" CPU is affected by Transient Scheduler Attacks */ | |
| 588 | 590 | #define X86_BUG_VMSCAPE X86_BUG( 1*32+10) /* "vmscape" CPU is affected by VMSCAPE attacks from guests */ | |
| 589 | 591 | #define X86_BUG_SEAMRET_INVD_VMCS X86_BUG( 1*32+11) /* "seamret_invd_vmcs" SEAMRET from P-SEAMLDR clears the current VMCS */ | |
| 592 | + | #define X86_BUG_TLBI X86_BUG( 1*32+12) /* "tlbi" AMD TLBI Erratum #1718 */ | |
| 590 | 593 | #endif /* _ASM_X86_CPUFEATURES_H */ | |
modified arch/x86/include/asm/tlb.h
| @@ -110,6 +110,12 @@ static inline void __tlbsync(void) | |||
| 110 | 110 | ||
| 111 | 111 | /* TLBSYNC: supported in binutils >= 0.36. */ | |
| 112 | 112 | asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory"); | |
| 113 | + | ||
| 114 | + | if (!static_cpu_has_bug(X86_BUG_TLBI)) | |
| 115 | + | return; | |
| 116 | + | ||
| 117 | + | /* TLBSYNC: supported in binutils >= 0.36. */ | |
| 118 | + | asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory"); | |
| 113 | 119 | } | |
| 114 | 120 | #else | |
| 115 | 121 | /* Some compilers (I'm looking at you clang!) simply can't do DCE */ | |
modified arch/x86/include/uapi/asm/ptrace-abi.h
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | #ifndef _ASM_X86_PTRACE_ABI_H | |
| 3 | 3 | #define _ASM_X86_PTRACE_ABI_H | |
| 4 | 4 | ||
| 5 | + | #if defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS) | |
| 5 | 6 | #ifdef __i386__ | |
| 6 | 7 | ||
| 7 | 8 | #define EBX 0 | |
| @@ -25,7 +26,6 @@ | |||
| 25 | 26 | ||
| 26 | 27 | #else /* __i386__ */ | |
| 27 | 28 | ||
| 28 | - | #if defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS) | |
| 29 | 29 | /* | |
| 30 | 30 | * C ABI says these regs are callee-preserved. They aren't saved on kernel entry | |
| 31 | 31 | * unless syscall needs a complete, fully filled "struct pt_regs". | |
| @@ -57,12 +57,12 @@ | |||
| 57 | 57 | #define EFLAGS 144 | |
| 58 | 58 | #define RSP 152 | |
| 59 | 59 | #define SS 160 | |
| 60 | - | #endif /* __ASSEMBLER__ */ | |
| 61 | 60 | ||
| 62 | 61 | /* top of stack page */ | |
| 63 | 62 | #define FRAME_SIZE 168 | |
| 64 | 63 | ||
| 65 | 64 | #endif /* !__i386__ */ | |
| 65 | + | #endif /* defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS) */ | |
| 66 | 66 | ||
| 67 | 67 | /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ | |
| 68 | 68 | #define PTRACE_GETREGS 12 | |
modified arch/x86/kernel/cpu/amd.c
| @@ -1049,6 +1049,10 @@ static void init_amd_zen5(struct cpuinfo_x86 *c) | |||
| 1049 | 1049 | msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18); | |
| 1050 | 1050 | pr_emerg_once("RDSEED32 is broken. Disabling the corresponding CPUID bit.\n"); | |
| 1051 | 1051 | } | |
| 1052 | + | ||
| 1053 | + | if (cpu_has(c, X86_FEATURE_INVLPGB) && | |
| 1054 | + | !cpu_has(c, X86_FEATURE_TLBSYNC_SFW_NO)) | |
| 1055 | + | set_cpu_bug(c, X86_BUG_TLBI); | |
| 1052 | 1056 | } | |
| 1053 | 1057 | ||
| 1054 | 1058 | static void init_amd(struct cpuinfo_x86 *c) | |
modified arch/x86/kernel/sys_x86_64.c
| @@ -50,9 +50,16 @@ static unsigned long get_align_mask(struct file *filp) | |||
| 50 | 50 | * value before calling vm_unmapped_area() or ORed directly to the | |
| 51 | 51 | * address. | |
| 52 | 52 | */ | |
| 53 | - | static unsigned long get_align_bits(void) | |
| 53 | + | static unsigned long get_align_bits(struct file *filp) | |
| 54 | 54 | { | |
| 55 | - | return va_align.bits & get_align_mask(NULL); | |
| 55 | + | /* | |
| 56 | + | * va_align.bits is smaller than the huge page size and will | |
| 57 | + | * lead to misaligned huge pages. Ignore it for huge mappings. | |
| 58 | + | */ | |
| 59 | + | if (is_file_hugepages(filp)) | |
| 60 | + | return 0; | |
| 61 | + | ||
| 62 | + | return va_align.bits & get_align_mask(filp); | |
| 56 | 63 | } | |
| 57 | 64 | ||
| 58 | 65 | static int __init control_va_addr_alignment(char *str) | |
| @@ -157,7 +164,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, | |||
| 157 | 164 | } | |
| 158 | 165 | if (filp) { | |
| 159 | 166 | info.align_mask = get_align_mask(filp); | |
| 160 | - | info.align_offset += get_align_bits(); | |
| 167 | + | info.align_offset += get_align_bits(filp); | |
| 161 | 168 | } | |
| 162 | 169 | ||
| 163 | 170 | return vm_unmapped_area(&info); | |
| @@ -222,7 +229,7 @@ get_unmapped_area: | |||
| 222 | 229 | ||
| 223 | 230 | if (filp) { | |
| 224 | 231 | info.align_mask = get_align_mask(filp); | |
| 225 | - | info.align_offset += get_align_bits(); | |
| 232 | + | info.align_offset += get_align_bits(filp); | |
| 226 | 233 | } | |
| 227 | 234 | addr = vm_unmapped_area(&info); | |
| 228 | 235 | if (!(addr & ~PAGE_MASK)) | |
modified arch/x86/kvm/mmu/mmu.c
| @@ -2512,6 +2512,12 @@ static void shadow_walk_init_using_root(struct kvm_shadow_walk_iterator *iterato | |||
| 2512 | 2512 | ||
| 2513 | 2513 | iterator->addr = addr; | |
| 2514 | 2514 | iterator->shadow_addr = root; | |
| 2515 | + | ||
| 2516 | + | if (WARN_ON_ONCE(!VALID_PAGE(root)) || kvm_mmu_is_dummy_root(root)) { | |
| 2517 | + | iterator->level = 0; | |
| 2518 | + | return; | |
| 2519 | + | } | |
| 2520 | + | ||
| 2515 | 2521 | iterator->level = vcpu->arch.mmu->root_role.level; | |
| 2516 | 2522 | ||
| 2517 | 2523 | if (iterator->level >= PT64_ROOT_4LEVEL && | |
modified arch/x86/kvm/svm/sev.c
| @@ -488,6 +488,20 @@ static void snp_guest_req_cleanup(struct kvm *kvm) | |||
| 488 | 488 | sev->guest_resp_buf = NULL; | |
| 489 | 489 | } | |
| 490 | 490 | ||
| 491 | + | static int sev_alloc_have_run_cpus(struct kvm_sev_info *sev) | |
| 492 | + | { | |
| 493 | + | if (!zalloc_cpumask_var(&sev->have_run_cpus, GFP_KERNEL_ACCOUNT)) | |
| 494 | + | return -ENOMEM; | |
| 495 | + | ||
| 496 | + | return 0; | |
| 497 | + | } | |
| 498 | + | ||
| 499 | + | static void sev_free_have_run_cpus(struct kvm_sev_info *sev) | |
| 500 | + | { | |
| 501 | + | free_cpumask_var(sev->have_run_cpus); | |
| 502 | + | memset(&sev->have_run_cpus, 0, sizeof(sev->have_run_cpus)); | |
| 503 | + | } | |
| 504 | + | ||
| 491 | 505 | static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp, | |
| 492 | 506 | struct kvm_sev_init *data, | |
| 493 | 507 | unsigned long vm_type) | |
| @@ -545,10 +559,9 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp, | |||
| 545 | 559 | if (ret) | |
| 546 | 560 | goto e_free_asid; | |
| 547 | 561 | ||
| 548 | - | if (!zalloc_cpumask_var(&sev->have_run_cpus, GFP_KERNEL_ACCOUNT)) { | |
| 549 | - | ret = -ENOMEM; | |
| 562 | + | ret = sev_alloc_have_run_cpus(sev); | |
| 563 | + | if (ret) | |
| 550 | 564 | goto e_free_asid; | |
| 551 | - | } | |
| 552 | 565 | ||
| 553 | 566 | /* This needs to happen after SEV/SNP firmware initialization. */ | |
| 554 | 567 | if (snp_active) { | |
| @@ -566,7 +579,7 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp, | |||
| 566 | 579 | return 0; | |
| 567 | 580 | ||
| 568 | 581 | e_free: | |
| 569 | - | free_cpumask_var(sev->have_run_cpus); | |
| 582 | + | sev_free_have_run_cpus(sev); | |
| 570 | 583 | e_free_asid: | |
| 571 | 584 | argp->error = init_args.error; | |
| 572 | 585 | sev_asid_free(sev); | |
| @@ -1125,9 +1138,6 @@ static int sev_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp) | |||
| 1125 | 1138 | if (!sev_es_guest(kvm)) | |
| 1126 | 1139 | return -ENOTTY; | |
| 1127 | 1140 | ||
| 1128 | - | if (kvm_is_vcpu_creation_in_progress(kvm)) | |
| 1129 | - | return -EBUSY; | |
| 1130 | - | ||
| 1131 | 1141 | ret = kvm_lock_all_vcpus(kvm); | |
| 1132 | 1142 | if (ret) | |
| 1133 | 1143 | return ret; | |
| @@ -2035,6 +2045,13 @@ static void sev_migrate_from(struct kvm *dst_kvm, struct kvm *src_kvm) | |||
| 2035 | 2045 | struct kvm_sev_info *mirror; | |
| 2036 | 2046 | unsigned long i; | |
| 2037 | 2047 | ||
| 2048 | + | /* | |
| 2049 | + | * Do cache maintenance on the source VM *before* clearing "SEV active", | |
| 2050 | + | * as memory reclaim flows won't trigger cache maintenance on the VM | |
| 2051 | + | * once it's no longer an SEV VM. | |
| 2052 | + | */ | |
| 2053 | + | sev_writeback_caches(src_kvm); | |
| 2054 | + | ||
| 2038 | 2055 | dst->active = true; | |
| 2039 | 2056 | dst->asid = src->asid; | |
| 2040 | 2057 | dst->handle = src->handle; | |
| @@ -2048,12 +2065,6 @@ static void sev_migrate_from(struct kvm *dst_kvm, struct kvm *src_kvm) | |||
| 2048 | 2065 | src->pages_locked = 0; | |
| 2049 | 2066 | src->es_active = false; | |
| 2050 | 2067 | ||
| 2051 | - | /* | |
| 2052 | - | * Do cache maintenance on the source VM as it is no longer an SEV VM, | |
| 2053 | - | * i.e. memory reclaim flows won't trigger cache maintenance on the VM. | |
| 2054 | - | */ | |
| 2055 | - | sev_writeback_caches(src_kvm); | |
| 2056 | - | ||
| 2057 | 2068 | list_cut_before(&dst->regions_list, &src->regions_list, &src->regions_list); | |
| 2058 | 2069 | ||
| 2059 | 2070 | mutex_lock(&sev_mirror_lock); | |
| @@ -2121,10 +2132,6 @@ static int sev_check_source_vcpus(struct kvm *dst, struct kvm *src) | |||
| 2121 | 2132 | struct kvm_vcpu *src_vcpu; | |
| 2122 | 2133 | unsigned long i; | |
| 2123 | 2134 | ||
| 2124 | - | if (kvm_is_vcpu_creation_in_progress(src) || | |
| 2125 | - | kvm_is_vcpu_creation_in_progress(dst)) | |
| 2126 | - | return -EBUSY; | |
| 2127 | - | ||
| 2128 | 2135 | if (!sev_es_guest(src)) | |
| 2129 | 2136 | return 0; | |
| 2130 | 2137 | ||
| @@ -2198,10 +2205,9 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd) | |||
| 2198 | 2205 | * does not, i.e. KVM could skip flushes if memory is reclaimed from | |
| 2199 | 2206 | * the old VM but not the new VM. | |
| 2200 | 2207 | */ | |
| 2201 | - | if (!zalloc_cpumask_var(&dst_sev->have_run_cpus, GFP_KERNEL_ACCOUNT)) { | |
| 2202 | - | ret = -ENOMEM; | |
| 2208 | + | ret = sev_alloc_have_run_cpus(dst_sev); | |
| 2209 | + | if (ret) | |
| 2203 | 2210 | goto out_source_vcpu; | |
| 2204 | - | } | |
| 2205 | 2211 | ||
| 2206 | 2212 | sev_migrate_from(kvm, source_kvm); | |
| 2207 | 2213 | kvm_vm_dead(source_kvm); | |
| @@ -2520,9 +2526,6 @@ static int snp_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp) | |||
| 2520 | 2526 | unsigned long i; | |
| 2521 | 2527 | int ret; | |
| 2522 | 2528 | ||
| 2523 | - | if (kvm_is_vcpu_creation_in_progress(kvm)) | |
| 2524 | - | return -EBUSY; | |
| 2525 | - | ||
| 2526 | 2529 | ret = kvm_lock_all_vcpus(kvm); | |
| 2527 | 2530 | if (ret) | |
| 2528 | 2531 | return ret; | |
| @@ -2898,10 +2901,9 @@ int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd) | |||
| 2898 | 2901 | } | |
| 2899 | 2902 | ||
| 2900 | 2903 | mirror_sev = to_kvm_sev_info(kvm); | |
| 2901 | - | if (!zalloc_cpumask_var(&mirror_sev->have_run_cpus, GFP_KERNEL_ACCOUNT)) { | |
| 2902 | - | ret = -ENOMEM; | |
| 2904 | + | ret = sev_alloc_have_run_cpus(mirror_sev); | |
| 2905 | + | if (ret) | |
| 2903 | 2906 | goto e_unlock; | |
| 2904 | - | } | |
| 2905 | 2907 | ||
| 2906 | 2908 | /* | |
| 2907 | 2909 | * The mirror kvm holds an enc_context_owner ref so its asid can't | |
| @@ -2994,7 +2996,7 @@ void sev_vm_destroy(struct kvm *kvm) | |||
| 2994 | 2996 | * Free the mask even if the VM is not *currently* an SEV VM, as it may | |
| 2995 | 2997 | * have been an SEV VM prior to intra-host migration. | |
| 2996 | 2998 | */ | |
| 2997 | - | free_cpumask_var(sev->have_run_cpus); | |
| 2999 | + | sev_free_have_run_cpus(sev); | |
| 2998 | 3000 | ||
| 2999 | 3001 | if (!sev_guest(kvm)) | |
| 3000 | 3002 | return; | |
| @@ -3630,7 +3632,6 @@ int pre_sev_run(struct vcpu_svm *svm, int cpu) | |||
| 3630 | 3632 | ||
| 3631 | 3633 | sd->sev_vmcbs[asid] = svm->vmcb; | |
| 3632 | 3634 | svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ASID; | |
| 3633 | - | vmcb_mark_dirty(svm->vmcb, VMCB_ASID); | |
| 3634 | 3635 | return 0; | |
| 3635 | 3636 | } | |
| 3636 | 3637 | ||
modified arch/x86/kvm/svm/svm.c
| @@ -673,16 +673,7 @@ static void clr_dr_intercepts(struct vcpu_svm *svm) | |||
| 673 | 673 | ||
| 674 | 674 | static bool msr_write_intercepted(struct vcpu_svm *svm, u32 msr) | |
| 675 | 675 | { | |
| 676 | - | /* | |
| 677 | - | * For non-nested case: | |
| 678 | - | * If the L01 MSR bitmap does not intercept the MSR, then we need to | |
| 679 | - | * save it. | |
| 680 | - | * | |
| 681 | - | * For nested case: | |
| 682 | - | * If the L02 MSR bitmap does not intercept the MSR, then we need to | |
| 683 | - | * save it. | |
| 684 | - | */ | |
| 685 | - | void *msrpm = is_guest_mode(&svm->vcpu) ? svm->nested.msrpm : svm->msrpm; | |
| 676 | + | void *msrpm = __va(__sme_clr(svm->vmcb->control.msrpm_base_pa)); | |
| 686 | 677 | ||
| 687 | 678 | return svm_test_msr_bitmap_write(msrpm, msr); | |
| 688 | 679 | } | |
| @@ -1902,8 +1893,7 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd) | |||
| 1902 | 1893 | if (sd->next_asid > sd->max_asid) { | |
| 1903 | 1894 | ++sd->asid_generation; | |
| 1904 | 1895 | sd->next_asid = sd->min_asid; | |
| 1905 | - | svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID; | |
| 1906 | - | vmcb_mark_dirty(svm->vmcb, VMCB_ASID); | |
| 1896 | + | sd->flush_all_asids = true; | |
| 1907 | 1897 | } | |
| 1908 | 1898 | ||
| 1909 | 1899 | svm->current_vmcb->asid_generation = sd->asid_generation; | |
| @@ -4528,6 +4518,9 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags) | |||
| 4528 | 4518 | svm->vmcb->control.asid = svm->asid; | |
| 4529 | 4519 | vmcb_mark_dirty(svm->vmcb, VMCB_ASID); | |
| 4530 | 4520 | } | |
| 4521 | + | if (this_cpu_ptr(&svm_data)->flush_all_asids) | |
| 4522 | + | svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID; | |
| 4523 | + | ||
| 4531 | 4524 | svm->vmcb->save.cr2 = vcpu->arch.cr2; | |
| 4532 | 4525 | ||
| 4533 | 4526 | if (guest_cpu_cap_has(vcpu, X86_FEATURE_ERAPS) && | |
| @@ -4618,16 +4611,23 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags) | |||
| 4618 | 4611 | vcpu->arch.nested_run_pending = 0; | |
| 4619 | 4612 | } | |
| 4620 | 4613 | ||
| 4621 | - | svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING; | |
| 4614 | + | if (!svm_is_vmrun_failure(svm->vmcb->control.exit_code)) { | |
| 4615 | + | this_cpu_ptr(&svm_data)->flush_all_asids = false; | |
| 4616 | + | svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING; | |
| 4622 | 4617 | ||
| 4623 | - | /* | |
| 4624 | - | * Unconditionally mask off the CLEAR_RAP bit, the AND is just as cheap | |
| 4625 | - | * as the TEST+Jcc to avoid it. | |
| 4626 | - | */ | |
| 4627 | - | if (cpu_feature_enabled(X86_FEATURE_ERAPS)) | |
| 4628 | - | svm->vmcb->control.erap_ctl &= ~ERAP_CONTROL_CLEAR_RAP; | |
| 4618 | + | /* | |
| 4619 | + | * Unconditionally mask off the CLEAR_RAP bit, the AND is just | |
| 4620 | + | * as cheap as the TEST+Jcc to avoid it. | |
| 4621 | + | */ | |
| 4622 | + | if (cpu_feature_enabled(X86_FEATURE_ERAPS)) | |
| 4623 | + | svm->vmcb->control.erap_ctl &= ~ERAP_CONTROL_CLEAR_RAP; | |
| 4629 | 4624 | ||
| 4630 | - | vmcb_mark_all_clean(svm->vmcb); | |
| 4625 | + | vmcb_mark_all_clean(svm->vmcb); | |
| 4626 | + | ||
| 4627 | + | if (!msr_write_intercepted(svm, MSR_AMD64_PERF_CNTR_GLOBAL_CTL)) | |
| 4628 | + | rdmsrq(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, | |
| 4629 | + | vcpu_to_pmu(vcpu)->global_ctrl); | |
| 4630 | + | } | |
| 4631 | 4631 | ||
| 4632 | 4632 | /* if exit due to PF check for async PF */ | |
| 4633 | 4633 | if (svm->vmcb->control.exit_code == SVM_EXIT_EXCP_BASE + PF_VECTOR) | |
| @@ -4636,9 +4636,6 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags) | |||
| 4636 | 4636 | ||
| 4637 | 4637 | kvm_clear_available_registers(vcpu, SVM_REGS_LAZY_LOAD_SET); | |
| 4638 | 4638 | ||
| 4639 | - | if (!msr_write_intercepted(svm, MSR_AMD64_PERF_CNTR_GLOBAL_CTL)) | |
| 4640 | - | rdmsrq(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, vcpu_to_pmu(vcpu)->global_ctrl); | |
| 4641 | - | ||
| 4642 | 4639 | trace_kvm_exit(vcpu, KVM_ISA_SVM); | |
| 4643 | 4640 | ||
| 4644 | 4641 | svm_complete_interrupts(vcpu); | |
modified arch/x86/kvm/svm/svm.h
| @@ -376,6 +376,7 @@ struct svm_cpu_data { | |||
| 376 | 376 | u32 next_asid; | |
| 377 | 377 | u32 min_asid; | |
| 378 | 378 | ||
| 379 | + | bool flush_all_asids; | |
| 379 | 380 | bool bp_spec_reduce_set; | |
| 380 | 381 | ||
| 381 | 382 | struct vmcb *save_area; | |
modified arch/x86/kvm/vmx/nested.c
| @@ -1754,6 +1754,9 @@ static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx) | |||
| 1754 | 1754 | static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx, u32 hv_clean_fields) | |
| 1755 | 1755 | { | |
| 1756 | 1756 | #ifdef CONFIG_KVM_HYPERV | |
| 1757 | + | const u64 runtime_controls = HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 | | |
| 1758 | + | HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 | | |
| 1759 | + | HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC; | |
| 1757 | 1760 | struct vmcs12 *vmcs12 = vmx->nested.cached_vmcs12; | |
| 1758 | 1761 | struct hv_enlightened_vmcs *evmcs = nested_vmx_evmcs(vmx); | |
| 1759 | 1762 | struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(&vmx->vcpu); | |
| @@ -1762,6 +1765,9 @@ static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx, u32 hv_clean_fields | |||
| 1762 | 1765 | vmcs12->tpr_threshold = evmcs->tpr_threshold; | |
| 1763 | 1766 | vmcs12->guest_rip = evmcs->guest_rip; | |
| 1764 | 1767 | ||
| 1768 | + | if ((hv_clean_fields & runtime_controls) != runtime_controls) | |
| 1769 | + | vmx->nested.force_msr_bitmap_recalc = true; | |
| 1770 | + | ||
| 1765 | 1771 | if (unlikely(!(hv_clean_fields & | |
| 1766 | 1772 | HV_VMX_ENLIGHTENED_CLEAN_FIELD_ENLIGHTENMENTSCONTROL))) { | |
| 1767 | 1773 | hv_vcpu->nested.pa_page_gpa = evmcs->partition_assist_page; | |
modified arch/x86/kvm/vmx/tdx.c
| @@ -2728,11 +2728,6 @@ static tdx_vm_state_guard_t tdx_acquire_vm_state_locks(struct kvm *kvm) | |||
| 2728 | 2728 | ||
| 2729 | 2729 | mutex_lock(&kvm->lock); | |
| 2730 | 2730 | ||
| 2731 | - | if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus)) { | |
| 2732 | - | r = -EBUSY; | |
| 2733 | - | goto out_err; | |
| 2734 | - | } | |
| 2735 | - | ||
| 2736 | 2731 | r = kvm_lock_all_vcpus(kvm); | |
| 2737 | 2732 | if (r) | |
| 2738 | 2733 | goto out_err; | |
modified arch/x86/mm/pgtable.c
| @@ -705,47 +705,37 @@ int pmd_clear_huge(pmd_t *pmd) | |||
| 705 | 705 | } | |
| 706 | 706 | ||
| 707 | 707 | #ifdef CONFIG_X86_64 | |
| 708 | - | /** | |
| 709 | - | * pud_free_pmd_page - Clear PUD entry and free PMD page | |
| 710 | - | * @pud: Pointer to a PUD | |
| 711 | - | * @addr: Virtual address associated with PUD | |
| 712 | - | * | |
| 713 | - | * Context: The PUD range has been unmapped and TLB purged. | |
| 714 | - | * Return: 1 if clearing the entry succeeded. 0 otherwise. | |
| 715 | - | * | |
| 716 | - | * NOTE: Callers must allow a single page allocation. | |
| 708 | + | /* | |
| 709 | + | * Given a PUD poitner, detach and free the pointed-to | |
| 710 | + | * PMD page and any PTE page children. The entire range | |
| 711 | + | * under the PUD must not have any valid translations | |
| 712 | + | * and the TLB must have already been flushed. | |
| 717 | 713 | */ | |
| 718 | 714 | int pud_free_pmd_page(pud_t *pud, unsigned long addr) | |
| 719 | 715 | { | |
| 720 | - | pmd_t *pmd, *pmd_sv; | |
| 721 | 716 | struct ptdesc *pt; | |
| 717 | + | pmd_t *pmd; | |
| 722 | 718 | int i; | |
| 723 | 719 | ||
| 724 | 720 | pmd = pud_pgtable(*pud); | |
| 725 | - | pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL); | |
| 726 | - | if (!pmd_sv) | |
| 727 | - | return 0; | |
| 728 | - | ||
| 729 | - | for (i = 0; i < PTRS_PER_PMD; i++) { | |
| 730 | - | pmd_sv[i] = pmd[i]; | |
| 731 | - | if (!pmd_none(pmd[i])) | |
| 732 | - | pmd_clear(&pmd[i]); | |
| 733 | - | } | |
| 734 | 721 | ||
| 722 | + | /* Detach the PMD page: */ | |
| 735 | 723 | pud_clear(pud); | |
| 736 | 724 | ||
| 737 | - | /* INVLPG to clear all paging-structure caches */ | |
| 725 | + | /* | |
| 726 | + | * PMD and all its descendents are unreachable | |
| 727 | + | * via normal page walks. Make them unreachable | |
| 728 | + | * in cached mid-level walks too: | |
| 729 | + | */ | |
| 738 | 730 | flush_tlb_kernel_range(addr, addr + PAGE_SIZE-1); | |
| 739 | 731 | ||
| 740 | 732 | for (i = 0; i < PTRS_PER_PMD; i++) { | |
| 741 | - | if (!pmd_none(pmd_sv[i])) { | |
| 742 | - | pt = page_ptdesc(pmd_page(pmd_sv[i])); | |
| 733 | + | if (!pmd_none(pmd[i])) { | |
| 734 | + | pt = page_ptdesc(pmd_page(pmd[i])); | |
| 743 | 735 | pagetable_dtor_free(pt); | |
| 744 | 736 | } | |
| 745 | 737 | } | |
| 746 | 738 | ||
| 747 | - | free_page((unsigned long)pmd_sv); | |
| 748 | - | ||
| 749 | 739 | pmd_free(&init_mm, pmd); | |
| 750 | 740 | ||
| 751 | 741 | return 1; | |
modified arch/x86/net/bpf_jit_comp.c
| @@ -3217,16 +3217,21 @@ static void restore_regs(const struct btf_func_model *m, u8 **prog, | |||
| 3217 | 3217 | } | |
| 3218 | 3218 | ||
| 3219 | 3219 | static int invoke_bpf_prog(const struct btf_func_model *m, u8 **pprog, | |
| 3220 | + | struct bpf_tramp_image *im, | |
| 3220 | 3221 | struct bpf_tramp_node *node, int stack_size, | |
| 3221 | 3222 | int run_ctx_off, bool save_ret, | |
| 3222 | 3223 | void *image, void *rw_image) | |
| 3223 | 3224 | { | |
| 3224 | 3225 | u8 *prog = *pprog; | |
| 3225 | - | u8 *jmp_insn; | |
| 3226 | + | u8 *jmp_insn, *skip; | |
| 3226 | 3227 | int ctx_cookie_off = offsetof(struct bpf_tramp_run_ctx, bpf_cookie); | |
| 3227 | 3228 | struct bpf_prog *p = node->link->prog; | |
| 3228 | 3229 | u64 cookie = node->cookie; | |
| 3229 | 3230 | ||
| 3231 | + | /* nop, patched to skip this prog when it is detached */ | |
| 3232 | + | skip = image + (prog - (u8 *)rw_image); | |
| 3233 | + | emit_nops(&prog, X86_PATCH_SIZE); | |
| 3234 | + | ||
| 3230 | 3235 | /* mov rdi, cookie */ | |
| 3231 | 3236 | emit_mov_imm64(&prog, BPF_REG_1, (long) cookie >> 32, (u32) (long) cookie); | |
| 3232 | 3237 | ||
| @@ -3301,6 +3306,8 @@ static int invoke_bpf_prog(const struct btf_func_model *m, u8 **pprog, | |||
| 3301 | 3306 | if (emit_rsb_call(&prog, bpf_trampoline_exit(p), image + (prog - (u8 *)rw_image))) | |
| 3302 | 3307 | return -EINVAL; | |
| 3303 | 3308 | ||
| 3309 | + | bpf_tramp_image_add_skip(im, p, skip, image + (prog - (u8 *)rw_image)); | |
| 3310 | + | ||
| 3304 | 3311 | *pprog = prog; | |
| 3305 | 3312 | return 0; | |
| 3306 | 3313 | } | |
| @@ -3332,6 +3339,7 @@ static int emit_cond_near_jump(u8 **pprog, void *func, void *ip, u8 jmp_cond) | |||
| 3332 | 3339 | } | |
| 3333 | 3340 | ||
| 3334 | 3341 | static int invoke_bpf(const struct btf_func_model *m, u8 **pprog, | |
| 3342 | + | struct bpf_tramp_image *im, | |
| 3335 | 3343 | struct bpf_tramp_nodes *tl, int stack_size, | |
| 3336 | 3344 | int run_ctx_off, int func_meta_off, bool save_ret, | |
| 3337 | 3345 | void *image, void *rw_image, u64 func_meta, | |
| @@ -3346,7 +3354,7 @@ static int invoke_bpf(const struct btf_func_model *m, u8 **pprog, | |||
| 3346 | 3354 | func_meta | (cur_cookie << BPF_TRAMP_COOKIE_INDEX_SHIFT)); | |
| 3347 | 3355 | cur_cookie--; | |
| 3348 | 3356 | } | |
| 3349 | - | if (invoke_bpf_prog(m, &prog, tl->nodes[i], stack_size, | |
| 3357 | + | if (invoke_bpf_prog(m, &prog, im, tl->nodes[i], stack_size, | |
| 3350 | 3358 | run_ctx_off, save_ret, image, rw_image)) | |
| 3351 | 3359 | return -EINVAL; | |
| 3352 | 3360 | } | |
| @@ -3355,6 +3363,7 @@ static int invoke_bpf(const struct btf_func_model *m, u8 **pprog, | |||
| 3355 | 3363 | } | |
| 3356 | 3364 | ||
| 3357 | 3365 | static int invoke_bpf_mod_ret(const struct btf_func_model *m, u8 **pprog, | |
| 3366 | + | struct bpf_tramp_image *im, | |
| 3358 | 3367 | struct bpf_tramp_nodes *tl, int stack_size, | |
| 3359 | 3368 | int run_ctx_off, u8 **branches, | |
| 3360 | 3369 | void *image, void *rw_image) | |
| @@ -3368,7 +3377,7 @@ static int invoke_bpf_mod_ret(const struct btf_func_model *m, u8 **pprog, | |||
| 3368 | 3377 | emit_mov_imm32(&prog, false, BPF_REG_0, 0); | |
| 3369 | 3378 | emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -8); | |
| 3370 | 3379 | for (i = 0; i < tl->nr_nodes; i++) { | |
| 3371 | - | if (invoke_bpf_prog(m, &prog, tl->nodes[i], stack_size, run_ctx_off, true, | |
| 3380 | + | if (invoke_bpf_prog(m, &prog, im, tl->nodes[i], stack_size, run_ctx_off, true, | |
| 3372 | 3381 | image, rw_image)) | |
| 3373 | 3382 | return -EINVAL; | |
| 3374 | 3383 | ||
| @@ -3640,7 +3649,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3640 | 3649 | } | |
| 3641 | 3650 | ||
| 3642 | 3651 | if (fentry->nr_nodes) { | |
| 3643 | - | if (invoke_bpf(m, &prog, fentry, regs_off, run_ctx_off, func_meta_off, | |
| 3652 | + | if (invoke_bpf(m, &prog, im, fentry, regs_off, run_ctx_off, func_meta_off, | |
| 3644 | 3653 | flags & BPF_TRAMP_F_RET_FENTRY_RET, image, rw_image, | |
| 3645 | 3654 | func_meta, cookie_off)) | |
| 3646 | 3655 | return -EINVAL; | |
| @@ -3652,7 +3661,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3652 | 3661 | if (!branches) | |
| 3653 | 3662 | return -ENOMEM; | |
| 3654 | 3663 | ||
| 3655 | - | if (invoke_bpf_mod_ret(m, &prog, fmod_ret, regs_off, | |
| 3664 | + | if (invoke_bpf_mod_ret(m, &prog, im, fmod_ret, regs_off, | |
| 3656 | 3665 | run_ctx_off, branches, image, rw_image)) { | |
| 3657 | 3666 | ret = -EINVAL; | |
| 3658 | 3667 | goto cleanup; | |
| @@ -3682,8 +3691,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3682 | 3691 | } | |
| 3683 | 3692 | /* remember return value in a stack for bpf prog to access */ | |
| 3684 | 3693 | emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -8); | |
| 3685 | - | im->ip_after_call = image + (prog - (u8 *)rw_image); | |
| 3686 | - | emit_nops(&prog, X86_PATCH_SIZE); | |
| 3687 | 3694 | } | |
| 3688 | 3695 | ||
| 3689 | 3696 | if (fmod_ret->nr_nodes) { | |
| @@ -3708,7 +3715,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3708 | 3715 | emit_store_stack_imm64(&prog, BPF_REG_0, -func_meta_off, func_meta); | |
| 3709 | 3716 | ||
| 3710 | 3717 | if (fexit->nr_nodes) { | |
| 3711 | - | if (invoke_bpf(m, &prog, fexit, regs_off, run_ctx_off, func_meta_off, | |
| 3718 | + | if (invoke_bpf(m, &prog, im, fexit, regs_off, run_ctx_off, func_meta_off, | |
| 3712 | 3719 | false, image, rw_image, func_meta, cookie_off)) { | |
| 3713 | 3720 | ret = -EINVAL; | |
| 3714 | 3721 | goto cleanup; | |
| @@ -3723,7 +3730,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3723 | 3730 | * restored to R0. | |
| 3724 | 3731 | */ | |
| 3725 | 3732 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 3726 | - | im->ip_epilogue = image + (prog - (u8 *)rw_image); | |
| 3727 | 3733 | /* arg1: mov rdi, im */ | |
| 3728 | 3734 | emit_mov_imm64(&prog, BPF_REG_1, (long) im >> 32, (u32) (long) im); | |
| 3729 | 3735 | if (emit_rsb_call(&prog, __bpf_tramp_exit, image + (prog - (u8 *)rw_image))) { | |
| @@ -3811,7 +3817,7 @@ out: | |||
| 3811 | 3817 | int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |
| 3812 | 3818 | struct bpf_tramp_nodes *tnodes, void *func_addr) | |
| 3813 | 3819 | { | |
| 3814 | - | struct bpf_tramp_image im; | |
| 3820 | + | struct bpf_tramp_image im = {}; | |
| 3815 | 3821 | void *image; | |
| 3816 | 3822 | int ret; | |
| 3817 | 3823 | ||
modified arch/x86/um/asm/ptrace.h
| @@ -13,9 +13,7 @@ enum { | |||
| 13 | 13 | }; | |
| 14 | 14 | ||
| 15 | 15 | #include <linux/compiler.h> | |
| 16 | - | #ifndef CONFIG_X86_32 | |
| 17 | - | #define __FRAME_OFFSETS /* Needed to get the R* macros */ | |
| 18 | - | #endif | |
| 16 | + | #define __FRAME_OFFSETS /* Needed to get the register macros */ | |
| 19 | 17 | #include <asm/ptrace-generic.h> | |
| 20 | 18 | ||
| 21 | 19 | #define user_mode(r) UPT_IS_USER(&(r)->regs) | |
modified arch/x86/um/ptrace_32.c
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | #include <linux/sched.h> | |
| 8 | 8 | #include <linux/uaccess.h> | |
| 9 | 9 | #include <linux/regset.h> | |
| 10 | + | #define __FRAME_OFFSETS | |
| 10 | 11 | #include <asm/ptrace-abi.h> | |
| 11 | 12 | #include <registers.h> | |
| 12 | 13 | #include <skas.h> | |
modified block/blk-cgroup.c
| @@ -2091,6 +2091,7 @@ static inline struct blkcg_gq *blkg_tryget_closest(struct bio *bio, | |||
| 2091 | 2091 | struct request_queue *q = bio->bi_bdev->bd_queue; | |
| 2092 | 2092 | struct blkcg *blkcg = css_to_blkcg(css); | |
| 2093 | 2093 | struct blkcg_gq *blkg; | |
| 2094 | + | unsigned long flags; | |
| 2094 | 2095 | ||
| 2095 | 2096 | rcu_read_lock(); | |
| 2096 | 2097 | blkg = blkg_lookup(blkcg, q); | |
| @@ -2105,11 +2106,11 @@ static inline struct blkcg_gq *blkg_tryget_closest(struct bio *bio, | |||
| 2105 | 2106 | * Fast path failed, we're probably issuing IO in this cgroup the first | |
| 2106 | 2107 | * time, hold lock to create new blkg. | |
| 2107 | 2108 | */ | |
| 2108 | - | spin_lock_irq(&q->queue_lock); | |
| 2109 | + | spin_lock_irqsave(&q->queue_lock, flags); | |
| 2109 | 2110 | blkg = blkg_lookup_create(blkcg, bio->bi_bdev->bd_disk); | |
| 2110 | 2111 | if (blkg) | |
| 2111 | 2112 | blkg = blkg_lookup_tryget(blkg); | |
| 2112 | - | spin_unlock_irq(&q->queue_lock); | |
| 2113 | + | spin_unlock_irqrestore(&q->queue_lock, flags); | |
| 2113 | 2114 | ||
| 2114 | 2115 | return blkg; | |
| 2115 | 2116 | } | |
modified block/blk-mq.c
| @@ -447,16 +447,6 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, | |||
| 447 | 447 | WRITE_ONCE(rq->deadline, 0); | |
| 448 | 448 | req_ref_set(rq, 1); | |
| 449 | 449 | ||
| 450 | - | if (rq->rq_flags & RQF_USE_SCHED) { | |
| 451 | - | struct elevator_queue *e = data->q->elevator; | |
| 452 | - | ||
| 453 | - | INIT_HLIST_NODE(&rq->hash); | |
| 454 | - | RB_CLEAR_NODE(&rq->rb_node); | |
| 455 | - | ||
| 456 | - | if (e->type->ops.prepare_request) | |
| 457 | - | e->type->ops.prepare_request(rq); | |
| 458 | - | } | |
| 459 | - | ||
| 460 | 450 | return rq; | |
| 461 | 451 | } | |
| 462 | 452 | ||
| @@ -498,6 +488,12 @@ __blk_mq_alloc_requests_batch(struct blk_mq_alloc_data *data) | |||
| 498 | 488 | return rq_list_pop(data->cached_rqs); | |
| 499 | 489 | } | |
| 500 | 490 | ||
| 491 | + | static bool blk_op_bypass_sched(blk_opf_t opf) | |
| 492 | + | { | |
| 493 | + | return (opf & REQ_OP_MASK) == REQ_OP_FLUSH || | |
| 494 | + | blk_op_is_passthrough(opf); | |
| 495 | + | } | |
| 496 | + | ||
| 501 | 497 | static void blk_mq_limit_depth(struct blk_mq_alloc_data *data) | |
| 502 | 498 | { | |
| 503 | 499 | struct elevator_mq_ops *ops; | |
| @@ -518,12 +514,10 @@ static void blk_mq_limit_depth(struct blk_mq_alloc_data *data) | |||
| 518 | 514 | * Flush/passthrough requests are special and go directly to the | |
| 519 | 515 | * dispatch list, they are not subject to the async_depth limit. | |
| 520 | 516 | */ | |
| 521 | - | if ((data->cmd_flags & REQ_OP_MASK) == REQ_OP_FLUSH || | |
| 522 | - | blk_op_is_passthrough(data->cmd_flags)) | |
| 517 | + | if (blk_op_bypass_sched(data->cmd_flags)) | |
| 523 | 518 | return; | |
| 524 | 519 | ||
| 525 | 520 | WARN_ON_ONCE(data->flags & BLK_MQ_REQ_RESERVED); | |
| 526 | - | data->rq_flags |= RQF_USE_SCHED; | |
| 527 | 521 | ||
| 528 | 522 | /* | |
| 529 | 523 | * By default, sync requests have no limit, and async requests are | |
| @@ -534,6 +528,29 @@ static void blk_mq_limit_depth(struct blk_mq_alloc_data *data) | |||
| 534 | 528 | ops->limit_depth(data->cmd_flags, data); | |
| 535 | 529 | } | |
| 536 | 530 | ||
| 531 | + | /* | |
| 532 | + | * Finish initializing a request once it has been claimed for an operation. | |
| 533 | + | * Cached requests are allocated before that operation is known. | |
| 534 | + | */ | |
| 535 | + | static void blk_mq_rq_late_init(struct request *rq, u64 alloc_time_ns) | |
| 536 | + | { | |
| 537 | + | struct elevator_queue *e; | |
| 538 | + | ||
| 539 | + | blk_mq_rq_time_init(rq, alloc_time_ns); | |
| 540 | + | ||
| 541 | + | if (!(rq->rq_flags & RQF_SCHED_TAGS) || (rq->rq_flags & RQF_RESV) || | |
| 542 | + | blk_op_bypass_sched(rq->cmd_flags)) | |
| 543 | + | return; | |
| 544 | + | ||
| 545 | + | rq->rq_flags |= RQF_USE_SCHED; | |
| 546 | + | INIT_HLIST_NODE(&rq->hash); | |
| 547 | + | RB_CLEAR_NODE(&rq->rb_node); | |
| 548 | + | ||
| 549 | + | e = rq->q->elevator; | |
| 550 | + | if (e->type->ops.prepare_request) | |
| 551 | + | e->type->ops.prepare_request(rq); | |
| 552 | + | } | |
| 553 | + | ||
| 537 | 554 | static struct request *__blk_mq_alloc_requests(struct blk_mq_alloc_data *data) | |
| 538 | 555 | { | |
| 539 | 556 | struct request_queue *q = data->q; | |
| @@ -562,7 +579,7 @@ retry: | |||
| 562 | 579 | if (data->nr_tags > 1) { | |
| 563 | 580 | rq = __blk_mq_alloc_requests_batch(data); | |
| 564 | 581 | if (rq) { | |
| 565 | - | blk_mq_rq_time_init(rq, alloc_time_ns); | |
| 582 | + | blk_mq_rq_late_init(rq, alloc_time_ns); | |
| 566 | 583 | return rq; | |
| 567 | 584 | } | |
| 568 | 585 | data->nr_tags = 1; | |
| @@ -590,7 +607,7 @@ retry: | |||
| 590 | 607 | if (!(data->rq_flags & RQF_SCHED_TAGS)) | |
| 591 | 608 | blk_mq_inc_active_requests(data->hctx); | |
| 592 | 609 | rq = blk_mq_rq_ctx_init(data, blk_mq_tags_from_data(data), tag); | |
| 593 | - | blk_mq_rq_time_init(rq, alloc_time_ns); | |
| 610 | + | blk_mq_rq_late_init(rq, alloc_time_ns); | |
| 594 | 611 | return rq; | |
| 595 | 612 | } | |
| 596 | 613 | ||
| @@ -637,8 +654,6 @@ static struct request *blk_mq_alloc_cached_request(struct request_queue *q, | |||
| 637 | 654 | if (plug->nr_ios == 1) | |
| 638 | 655 | return NULL; | |
| 639 | 656 | rq = blk_mq_rq_cache_fill(q, plug, opf, flags); | |
| 640 | - | if (!rq) | |
| 641 | - | return NULL; | |
| 642 | 657 | } else { | |
| 643 | 658 | rq = rq_list_peek(&plug->cached_rqs); | |
| 644 | 659 | if (!rq || rq->q != q) | |
| @@ -646,15 +661,13 @@ static struct request *blk_mq_alloc_cached_request(struct request_queue *q, | |||
| 646 | 661 | ||
| 647 | 662 | if (blk_mq_get_hctx_type(opf) != rq->mq_hctx->type) | |
| 648 | 663 | return NULL; | |
| 649 | - | if (op_is_flush(rq->cmd_flags) != op_is_flush(opf)) | |
| 650 | - | return NULL; | |
| 651 | 664 | ||
| 652 | 665 | rq_list_pop(&plug->cached_rqs); | |
| 653 | - | blk_mq_rq_time_init(rq, blk_time_get_ns()); | |
| 666 | + | rq->cmd_flags = opf; | |
| 667 | + | INIT_LIST_HEAD(&rq->queuelist); | |
| 668 | + | blk_mq_rq_late_init(rq, blk_time_get_ns()); | |
| 654 | 669 | } | |
| 655 | 670 | ||
| 656 | - | rq->cmd_flags = opf; | |
| 657 | - | INIT_LIST_HEAD(&rq->queuelist); | |
| 658 | 671 | return rq; | |
| 659 | 672 | } | |
| 660 | 673 | ||
| @@ -766,7 +779,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, | |||
| 766 | 779 | if (!(data.rq_flags & RQF_SCHED_TAGS)) | |
| 767 | 780 | blk_mq_inc_active_requests(data.hctx); | |
| 768 | 781 | rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag); | |
| 769 | - | blk_mq_rq_time_init(rq, alloc_time_ns); | |
| 782 | + | blk_mq_rq_late_init(rq, alloc_time_ns); | |
| 770 | 783 | rq->__data_len = 0; | |
| 771 | 784 | rq->phys_gap_bit = 0; | |
| 772 | 785 | rq->__sector = (sector_t) -1; | |
| @@ -3060,8 +3073,6 @@ static struct request *blk_mq_get_cached_request(struct blk_plug *plug, | |||
| 3060 | 3073 | if (type != rq->mq_hctx->type && | |
| 3061 | 3074 | (type != HCTX_TYPE_READ || rq->mq_hctx->type != HCTX_TYPE_DEFAULT)) | |
| 3062 | 3075 | return NULL; | |
| 3063 | - | if (op_is_flush(rq->cmd_flags) != op_is_flush(opf)) | |
| 3064 | - | return NULL; | |
| 3065 | 3076 | rq_list_pop(&plug->cached_rqs); | |
| 3066 | 3077 | return rq; | |
| 3067 | 3078 | } | |
| @@ -3163,9 +3174,9 @@ void blk_mq_submit_bio(struct bio *bio) | |||
| 3163 | 3174 | new_request: | |
| 3164 | 3175 | if (rq) { | |
| 3165 | 3176 | rq_qos_throttle(rq->q, bio); | |
| 3166 | - | blk_mq_rq_time_init(rq, blk_time_get_ns()); | |
| 3167 | 3177 | rq->cmd_flags = bio->bi_opf; | |
| 3168 | 3178 | INIT_LIST_HEAD(&rq->queuelist); | |
| 3179 | + | blk_mq_rq_late_init(rq, blk_time_get_ns()); | |
| 3169 | 3180 | } else { | |
| 3170 | 3181 | rq = blk_mq_get_new_requests(q, plug, bio); | |
| 3171 | 3182 | if (unlikely(!rq)) { | |
modified block/fops.c
| @@ -402,6 +402,11 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) | |||
| 402 | 402 | if (blkdev_dio_invalid(bdev, iocb, iter)) | |
| 403 | 403 | return -EINVAL; | |
| 404 | 404 | ||
| 405 | + | /* HIPRI needs private as bio; HAS_METADATA keeps it as uio_meta */ | |
| 406 | + | if ((iocb->ki_flags & IOCB_HIPRI) && | |
| 407 | + | (iocb->ki_flags & IOCB_HAS_METADATA)) | |
| 408 | + | return -EOPNOTSUPP; | |
| 409 | + | ||
| 405 | 410 | if (iov_iter_rw(iter) == WRITE) { | |
| 406 | 411 | u16 max_write_streams = bdev_max_write_streams(bdev); | |
| 407 | 412 | ||
modified block/mq-deadline.c
| @@ -685,7 +685,7 @@ static void dd_insert_requests(struct blk_mq_hw_ctx *hctx, | |||
| 685 | 685 | blk_mq_free_requests(&free); | |
| 686 | 686 | } | |
| 687 | 687 | ||
| 688 | - | /* Callback from inside blk_mq_rq_ctx_init(). */ | |
| 688 | + | /* Callback from inside blk_mq_rq_late_init(). */ | |
| 689 | 689 | static void dd_prepare_request(struct request *rq) | |
| 690 | 690 | { | |
| 691 | 691 | rq->elv.priv[0] = NULL; | |
modified crypto/aes.c
| @@ -637,7 +637,18 @@ static struct skcipher_alg skcipher_algs[] = { | |||
| 637 | 637 | .decrypt = crypto_aes_cbc_decrypt, | |
| 638 | 638 | }, | |
| 639 | 639 | #endif | |
| 640 | - | #if IS_ENABLED(CONFIG_CRYPTO_CTS) | |
| 640 | + | /* | |
| 641 | + | * Don't register library-based "cts(cbc(aes))" on architectures where | |
| 642 | + | * it might block a "better" implementation from being instantiated via | |
| 643 | + | * the "cts" template. These exclusions are temporary and will go away | |
| 644 | + | * as the arch-optimized AES code is migrated into the library. | |
| 645 | + | */ | |
| 646 | + | #if IS_ENABLED(CONFIG_CRYPTO_CTS) && \ | |
| 647 | + | !(IS_ENABLED(CONFIG_ARM) || \ | |
| 648 | + | IS_ENABLED(CONFIG_ARM64) || \ | |
| 649 | + | IS_ENABLED(CONFIG_PPC) || \ | |
| 650 | + | IS_ENABLED(CONFIG_S390) || \ | |
| 651 | + | IS_ENABLED(CONFIG_SPARC)) | |
| 641 | 652 | { | |
| 642 | 653 | .base.cra_name = "cts(cbc(aes))", | |
| 643 | 654 | .base.cra_driver_name = "cts-cbc-aes-lib", | |
| @@ -687,7 +698,13 @@ static struct skcipher_alg skcipher_algs[] = { | |||
| 687 | 698 | .decrypt = crypto_aes_xctr_crypt, | |
| 688 | 699 | }, | |
| 689 | 700 | #endif | |
| 690 | - | #if IS_ENABLED(CONFIG_CRYPTO_XTS) | |
| 701 | + | /* | |
| 702 | + | * Don't register library-based "xts(aes)" on architectures where it | |
| 703 | + | * might block a "better" implementation from being instantiated via the | |
| 704 | + | * "xts" template. This exclusion is temporary and will go away when | |
| 705 | + | * the library AES-XTS is optimized for SPARC. | |
| 706 | + | */ | |
| 707 | + | #if IS_ENABLED(CONFIG_CRYPTO_XTS) && !IS_ENABLED(CONFIG_SPARC) | |
| 691 | 708 | { | |
| 692 | 709 | .base.cra_name = "xts(aes)", | |
| 693 | 710 | .base.cra_driver_name = "xts-aes-lib", | |
| @@ -980,7 +997,20 @@ static __maybe_unused int crypto_aes_ccm_decrypt(struct aead_request *req) | |||
| 980 | 997 | } | |
| 981 | 998 | ||
| 982 | 999 | static struct aead_alg aead_algs[] = { | |
| 983 | - | #if IS_ENABLED(CONFIG_CRYPTO_GCM) | |
| 1000 | + | /* | |
| 1001 | + | * Don't register library-based "gcm(aes)" and "rfc4106(gcm(aes))" on | |
| 1002 | + | * architectures where they might block a "better" implementation from | |
| 1003 | + | * being instantiated via the "gcm" and "rfc4106" templates. These | |
| 1004 | + | * exclusions are temporary and will go away as the arch-optimized AES | |
| 1005 | + | * code is migrated into the library. | |
| 1006 | + | */ | |
| 1007 | + | #if IS_ENABLED(CONFIG_CRYPTO_GCM) && \ | |
| 1008 | + | !(IS_ENABLED(CONFIG_ARM) || \ | |
| 1009 | + | IS_ENABLED(CONFIG_ARM64) || \ | |
| 1010 | + | IS_ENABLED(CONFIG_PPC) || \ | |
| 1011 | + | IS_ENABLED(CONFIG_RISCV) || \ | |
| 1012 | + | IS_ENABLED(CONFIG_S390) || \ | |
| 1013 | + | IS_ENABLED(CONFIG_SPARC)) | |
| 984 | 1014 | { | |
| 985 | 1015 | .base.cra_name = "gcm(aes)", | |
| 986 | 1016 | .base.cra_driver_name = "gcm-aes-lib", | |
| @@ -1012,7 +1042,20 @@ static struct aead_alg aead_algs[] = { | |||
| 1012 | 1042 | .chunksize = AES_BLOCK_SIZE, | |
| 1013 | 1043 | }, | |
| 1014 | 1044 | #endif /* CONFIG_CRYPTO_GCM */ | |
| 1015 | - | #if IS_ENABLED(CONFIG_CRYPTO_CCM) | |
| 1045 | + | /* | |
| 1046 | + | * Don't register library-based "ccm(aes)" on architectures where it | |
| 1047 | + | * might block a "better" implementation from being instantiated via the | |
| 1048 | + | * "ccm" template. These exclusions are temporary and will go away as | |
| 1049 | + | * the arch-optimized AES code is migrated into the library. | |
| 1050 | + | */ | |
| 1051 | + | #if IS_ENABLED(CONFIG_CRYPTO_CCM) && \ | |
| 1052 | + | !(IS_ENABLED(CONFIG_ARM) || \ | |
| 1053 | + | IS_ENABLED(CONFIG_ARM64) || \ | |
| 1054 | + | IS_ENABLED(CONFIG_PPC) || \ | |
| 1055 | + | IS_ENABLED(CONFIG_RISCV) || \ | |
| 1056 | + | IS_ENABLED(CONFIG_S390) || \ | |
| 1057 | + | IS_ENABLED(CONFIG_SPARC) || \ | |
| 1058 | + | IS_ENABLED(CONFIG_X86)) | |
| 1016 | 1059 | { | |
| 1017 | 1060 | .base.cra_name = "ccm(aes)", | |
| 1018 | 1061 | .base.cra_driver_name = "ccm-aes-lib", | |
modified drivers/accessibility/braille/braille_console.c
| @@ -62,14 +62,50 @@ static void braille_write(u16 *buf) | |||
| 62 | 62 | { | |
| 63 | 63 | static u16 lastwrite[WIDTH]; | |
| 64 | 64 | unsigned char data[1 + 1 + 2*WIDTH + 2 + 1], csum = 0, *c; | |
| 65 | + | struct nbcon_write_context wctxt = { }; | |
| 66 | + | unsigned long flags; | |
| 65 | 67 | u16 out; | |
| 66 | 68 | int i; | |
| 67 | 69 | ||
| 68 | 70 | if (!braille_co) | |
| 69 | 71 | return; | |
| 70 | 72 | ||
| 73 | + | /* | |
| 74 | + | * Braille console is not registered in console_list. Instead, it | |
| 75 | + | * is integrated with VT and shows what appears on the graphical | |
| 76 | + | * console under console_lock(). From this POV it is a legacy | |
| 77 | + | * console. But it calls serial console driver which might be | |
| 78 | + | * converted to the NBCON API. It is similar to | |
| 79 | + | * nbcon_legacy_emit_next_record() except that we should try | |
| 80 | + | * harder to get the lock. Otherwise, the Braille device won't show | |
| 81 | + | * everything what is displayed on the terminal. | |
| 82 | + | * | |
| 83 | + | * In short, simulate the original locking using NBCON API. | |
| 84 | + | */ | |
| 85 | + | if (braille_co->flags & CON_NBCON) { | |
| 86 | + | if (panic_on_this_cpu()) { | |
| 87 | + | /* | |
| 88 | + | * This should be good enough in practice. Most/all | |
| 89 | + | * serial console drivers have the atomic callback. | |
| 90 | + | */ | |
| 91 | + | if (!braille_co->write_atomic) | |
| 92 | + | return; | |
| 93 | + | ||
| 94 | + | local_irq_save(flags); | |
| 95 | + | /* NBCON API strictly requires the ownership. */ | |
| 96 | + | if (!nbcon_braille_try_acquire(braille_co, &wctxt)) { | |
| 97 | + | local_irq_restore(flags); | |
| 98 | + | return; | |
| 99 | + | } | |
| 100 | + | } else { | |
| 101 | + | braille_co->device_lock(braille_co, &flags); | |
| 102 | + | while (!nbcon_braille_try_acquire(braille_co, &wctxt)) | |
| 103 | + | cpu_relax(); | |
| 104 | + | } | |
| 105 | + | } | |
| 106 | + | ||
| 71 | 107 | if (!memcmp(lastwrite, buf, WIDTH * sizeof(*buf))) | |
| 72 | - | return; | |
| 108 | + | goto unlock_nbcon; | |
| 73 | 109 | memcpy(lastwrite, buf, WIDTH * sizeof(*buf)); | |
| 74 | 110 | ||
| 75 | 111 | #define SOH 1 | |
| @@ -102,7 +138,24 @@ static void braille_write(u16 *buf) | |||
| 102 | 138 | *c++ = csum; | |
| 103 | 139 | *c++ = ETX; | |
| 104 | 140 | ||
| 105 | - | braille_co->write(braille_co, data, c - data); | |
| 141 | + | if (braille_co->flags & CON_NBCON) { | |
| 142 | + | nbcon_write_context_set_buf(&wctxt, (char *)data, c - data); | |
| 143 | + | if (panic_on_this_cpu()) | |
| 144 | + | braille_co->write_atomic(braille_co, &wctxt); | |
| 145 | + | else | |
| 146 | + | braille_co->write_thread(braille_co, &wctxt); | |
| 147 | + | } else { | |
| 148 | + | braille_co->write(braille_co, data, c - data); | |
| 149 | + | } | |
| 150 | + | ||
| 151 | + | unlock_nbcon: | |
| 152 | + | if (braille_co->flags & CON_NBCON) { | |
| 153 | + | nbcon_braille_release(&wctxt); | |
| 154 | + | if (panic_on_this_cpu()) | |
| 155 | + | local_irq_restore(flags); | |
| 156 | + | else | |
| 157 | + | braille_co->device_unlock(braille_co, flags); | |
| 158 | + | } | |
| 106 | 159 | } | |
| 107 | 160 | ||
| 108 | 161 | /* Follow the VC cursor*/ | |
modified drivers/android/binder.c
| @@ -2930,8 +2930,9 @@ static int binder_proc_transaction(struct binder_transaction *t, | |||
| 2930 | 2930 | t_outdated->buffer = NULL; | |
| 2931 | 2931 | buffer->transaction = NULL; | |
| 2932 | 2932 | trace_binder_transaction_update_buffer_release(buffer); | |
| 2933 | - | binder_release_entire_buffer(proc, NULL, buffer, false); | |
| 2933 | + | binder_release_entire_buffer(proc, NULL, buffer, true); | |
| 2934 | 2934 | binder_alloc_free_buf(&proc->alloc, buffer); | |
| 2935 | + | binder_free_txn_fixups(t_outdated); | |
| 2935 | 2936 | kfree(t_outdated); | |
| 2936 | 2937 | binder_stats_deleted(BINDER_STAT_TRANSACTION); | |
| 2937 | 2938 | } | |
modified drivers/android/binder/node.rs
| @@ -51,9 +51,9 @@ pub(crate) struct CouldNotDeliverCriticalIncrement; | |||
| 51 | 51 | /// about to drop the weak reference, then the strong increment could be processed after the | |
| 52 | 52 | /// other thread has already exited, which would be too late. | |
| 53 | 53 | /// | |
| 54 | - | /// Note that trying to create a `ListArc` to the node can succeed even if `has_normal_push` is | |
| 54 | + | /// Note that trying to create a `ListArc` to the node can succeed even if `has_pushed_node` is | |
| 55 | 55 | /// set. This is because another thread might just have popped the node from a todo list, but not | |
| 56 | - | /// yet called `do_work`. However, if `has_normal_push` is false, then creating a `ListArc` should | |
| 56 | + | /// yet called `do_work`. However, if `has_pushed_node` is false, then creating a `ListArc` should | |
| 57 | 57 | /// always succeed. | |
| 58 | 58 | /// | |
| 59 | 59 | /// Like the other fields in `NodeInner`, the delivery state is protected by the process lock. | |
| @@ -738,7 +738,21 @@ impl DeliverToRead for Node { | |||
| 738 | 738 | self.do_work_locked(writer, owner_inner) | |
| 739 | 739 | } | |
| 740 | 740 | ||
| 741 | - | fn cancel(self: DArc<Self>) {} | |
| 741 | + | fn cancel(self: DArc<Self>) { | |
| 742 | + | let _drop_outside_lock; | |
| 743 | + | let mut owner_inner = self.owner.inner.lock(); | |
| 744 | + | ||
| 745 | + | // We only do something on BINDER_THREAD_EXIT, not process exit. | |
| 746 | + | if owner_inner.is_dead { | |
| 747 | + | return; | |
| 748 | + | } | |
| 749 | + | ||
| 750 | + | // If BINDER_THREAD_EXIT is invoked on a thread with a pending node refcount update, we | |
| 751 | + | // should move ourselves to ensure the refcount update is still delivered. | |
| 752 | + | if let Some(node) = ListArc::try_from_arc_borrow(self.as_arc_borrow()) { | |
| 753 | + | _drop_outside_lock = owner_inner.push_work(&self.owner, node); | |
| 754 | + | } | |
| 755 | + | } | |
| 742 | 756 | ||
| 743 | 757 | fn should_sync_wakeup(&self) -> bool { | |
| 744 | 758 | false | |
modified drivers/android/binder/node/wrapper.rs
| @@ -57,7 +57,39 @@ impl DeliverToRead for NodeWrapper { | |||
| 57 | 57 | node.do_work_locked(writer, owner_inner) | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | - | fn cancel(self: DArc<Self>) {} | |
| 60 | + | fn cancel(self: DArc<Self>) { | |
| 61 | + | let _drop_outside_lock; | |
| 62 | + | let node = &self.node; | |
| 63 | + | let mut owner_inner = node.owner.inner.lock(); | |
| 64 | + | ||
| 65 | + | // We only do something on BINDER_THREAD_EXIT, not process exit. | |
| 66 | + | if owner_inner.is_dead { | |
| 67 | + | return; | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | // We transfer the responsibility of the node refcount update to the scheduled Node because | |
| 71 | + | // NodeWrapper has no way to re-create the ListArc. | |
| 72 | + | let inner = node.inner.access_mut(&mut owner_inner); | |
| 73 | + | ||
| 74 | + | let ds = &mut inner.delivery_state; | |
| 75 | + | assert!(ds.has_pushed_wrapper); | |
| 76 | + | assert!(ds.has_strong_zero2one); | |
| 77 | + | ds.has_pushed_wrapper = false; | |
| 78 | + | ||
| 79 | + | // We are changing the state to one where the Node is the strong zero2one update instead of | |
| 80 | + | // the wrapper. | |
| 81 | + | ds.has_weak_zero2one = false; | |
| 82 | + | ||
| 83 | + | if !ds.has_pushed_node { | |
| 84 | + | if let Some(node2) = ListArc::try_from_arc_borrow(node.as_arc_borrow()) { | |
| 85 | + | ds.has_pushed_node = true; | |
| 86 | + | _drop_outside_lock = owner_inner.push_work(&node.owner, node2); | |
| 87 | + | } else { | |
| 88 | + | // This can't actually happen. | |
| 89 | + | ds.has_strong_zero2one = false; | |
| 90 | + | } | |
| 91 | + | } | |
| 92 | + | } | |
| 61 | 93 | ||
| 62 | 94 | fn should_sync_wakeup(&self) -> bool { | |
| 63 | 95 | false | |
modified drivers/android/binder/rust_binderfs.c
| @@ -72,6 +72,7 @@ struct binder_features { | |||
| 72 | 72 | bool oneway_spam_detection; | |
| 73 | 73 | bool extended_error; | |
| 74 | 74 | bool freeze_notification; | |
| 75 | + | bool transaction_report; | |
| 75 | 76 | }; | |
| 76 | 77 | ||
| 77 | 78 | static const struct constant_table binderfs_param_stats[] = { | |
| @@ -89,6 +90,7 @@ static struct binder_features binder_features = { | |||
| 89 | 90 | .oneway_spam_detection = true, | |
| 90 | 91 | .extended_error = true, | |
| 91 | 92 | .freeze_notification = true, | |
| 93 | + | .transaction_report = true, | |
| 92 | 94 | }; | |
| 93 | 95 | ||
| 94 | 96 | static inline struct binderfs_info *BINDERFS_SB(const struct super_block *sb) | |
| @@ -566,6 +568,12 @@ static int init_binder_features(struct super_block *sb) | |||
| 566 | 568 | if (IS_ERR(dentry)) | |
| 567 | 569 | return PTR_ERR(dentry); | |
| 568 | 570 | ||
| 571 | + | dentry = rust_binderfs_create_file(dir, "transaction_report", | |
| 572 | + | &binder_features_fops, | |
| 573 | + | &binder_features.transaction_report); | |
| 574 | + | if (IS_ERR(dentry)) | |
| 575 | + | return PTR_ERR(dentry); | |
| 576 | + | ||
| 569 | 577 | return 0; | |
| 570 | 578 | } | |
| 571 | 579 | ||
modified drivers/android/binder/thread.rs
| @@ -686,6 +686,12 @@ impl Thread { | |||
| 686 | 686 | self.inner.lock().push_return_work(reply); | |
| 687 | 687 | } | |
| 688 | 688 | ||
| 689 | + | pub(crate) fn pop_work_even_if_deferred(&self) -> Option<DLArc<dyn DeliverToRead>> { | |
| 690 | + | let mut thread_inner = self.inner.lock(); | |
| 691 | + | thread_inner.process_work_list = true; | |
| 692 | + | thread_inner.pop_work() | |
| 693 | + | } | |
| 694 | + | ||
| 689 | 695 | fn translate_object( | |
| 690 | 696 | &self, | |
| 691 | 697 | obj_index: usize, | |
| @@ -1678,7 +1684,7 @@ impl Thread { | |||
| 1678 | 1684 | self.unwind_transaction_stack(); | |
| 1679 | 1685 | ||
| 1680 | 1686 | // Cancel all pending work items. | |
| 1681 | - | while let Ok(Some(work)) = self.get_work_local(false) { | |
| 1687 | + | while let Some(work) = self.pop_work_even_if_deferred() { | |
| 1682 | 1688 | work.into_arc().cancel(); | |
| 1683 | 1689 | } | |
| 1684 | 1690 | } | |
modified drivers/android/binderfs.c
| @@ -189,12 +189,11 @@ static int binderfs_binder_device_create(struct inode *ref_inode, | |||
| 189 | 189 | goto err; | |
| 190 | 190 | } | |
| 191 | 191 | inode->i_private = device; | |
| 192 | + | binder_add_device(device); | |
| 192 | 193 | d_make_persistent(dentry, inode); | |
| 193 | 194 | fsnotify_create(root->d_inode, dentry); | |
| 194 | 195 | simple_done_creating(dentry); | |
| 195 | 196 | ||
| 196 | - | binder_add_device(device); | |
| 197 | - | ||
| 198 | 197 | return 0; | |
| 199 | 198 | ||
| 200 | 199 | err: | |
modified drivers/ata/libata-scsi.c
| @@ -3059,10 +3059,15 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) | |||
| 3059 | 3059 | if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) | |
| 3060 | 3060 | qc->dev->sdev->locked = 0; | |
| 3061 | 3061 | ||
| 3062 | - | if (cmd->result) | |
| 3063 | - | ata_scsi_qc_done(qc, false, 0); | |
| 3064 | - | else | |
| 3065 | - | ata_scsi_qc_done(qc, true, SAM_STAT_CHECK_CONDITION); | |
| 3062 | + | /* | |
| 3063 | + | * Report CHECK CONDITION unless the command was terminated | |
| 3064 | + | * with a host byte set. Only set the status byte, so that the | |
| 3065 | + | * SCSI midlayer internal byte, which scsi_check_sense() may | |
| 3066 | + | * have set from the sense data, is preserved. | |
| 3067 | + | */ | |
| 3068 | + | if (get_host_byte(cmd) == DID_OK) | |
| 3069 | + | set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); | |
| 3070 | + | ata_scsi_qc_done(qc, false, 0); | |
| 3066 | 3071 | goto schedule_deferred; | |
| 3067 | 3072 | } | |
| 3068 | 3073 | ||
modified drivers/block/drbd/drbd_nl_gen.c
| @@ -638,10 +638,6 @@ const struct genl_split_ops drbd_nl_ops[32] = { | |||
| 638 | 638 | }, | |
| 639 | 639 | }; | |
| 640 | 640 | ||
| 641 | - | static const struct genl_multicast_group drbd_nl_mcgrps[] = { | |
| 642 | - | [DRBD_NLGRP_EVENTS] = { "events", }, | |
| 643 | - | }; | |
| 644 | - | ||
| 645 | 641 | static int __drbd_cfg_context_from_attrs(struct drbd_cfg_context *s, | |
| 646 | 642 | struct nlattr ***ret_nested_attribute_table, | |
| 647 | 643 | struct genl_info *info) | |
modified drivers/block/virtio_blk.c
| @@ -743,6 +743,7 @@ static int virtblk_read_zoned_limits(struct virtio_blk *vblk, | |||
| 743 | 743 | dev_warn(&vdev->dev, "zero write granularity reported\n"); | |
| 744 | 744 | return -ENODEV; | |
| 745 | 745 | } | |
| 746 | + | lim->zone_write_granularity = wg; | |
| 746 | 747 | lim->physical_block_size = wg; | |
| 747 | 748 | lim->io_min = wg; | |
| 748 | 749 | ||
modified drivers/block/zloop.c
| @@ -800,6 +800,27 @@ static void zloop_cmd_workfn(struct work_struct *work) | |||
| 800 | 800 | current->flags = orig_flags; | |
| 801 | 801 | } | |
| 802 | 802 | ||
| 803 | + | static void zloop_fill_zero_rq(struct request *rq, unsigned int zero_from) | |
| 804 | + | { | |
| 805 | + | struct req_iterator iter; | |
| 806 | + | struct bio_vec bv; | |
| 807 | + | unsigned int pos = 0; | |
| 808 | + | unsigned int end, off; | |
| 809 | + | ||
| 810 | + | rq_for_each_segment(bv, rq, iter) { | |
| 811 | + | end = pos + bv.bv_len; | |
| 812 | + | if (end > zero_from) { | |
| 813 | + | if (pos < zero_from) | |
| 814 | + | off = zero_from - pos; | |
| 815 | + | else | |
| 816 | + | off = 0; | |
| 817 | + | memzero_page(bv.bv_page, bv.bv_offset + off, | |
| 818 | + | bv.bv_len - off); | |
| 819 | + | } | |
| 820 | + | pos = end; | |
| 821 | + | } | |
| 822 | + | } | |
| 823 | + | ||
| 803 | 824 | static void zloop_complete_rq(struct request *rq) | |
| 804 | 825 | { | |
| 805 | 826 | struct zloop_cmd *cmd = blk_mq_rq_to_pdu(rq); | |
| @@ -814,13 +835,9 @@ static void zloop_complete_rq(struct request *rq) | |||
| 814 | 835 | pr_err("Zone %u: failed read sector %llu, %llu sectors\n", | |
| 815 | 836 | zone_no, cmd->sector, cmd->nr_sectors); | |
| 816 | 837 | ||
| 817 | - | if (cmd->ret >= 0 && cmd->ret != blk_rq_bytes(rq)) { | |
| 818 | - | /* short read */ | |
| 819 | - | struct bio *bio; | |
| 820 | - | ||
| 821 | - | __rq_for_each_bio(bio, rq) | |
| 822 | - | zero_fill_bio(bio); | |
| 823 | - | } | |
| 838 | + | /* Short read. Zero out the unread tail beyond cmd->ret. */ | |
| 839 | + | if (cmd->ret >= 0 && cmd->ret != blk_rq_bytes(rq)) | |
| 840 | + | zloop_fill_zero_rq(rq, cmd->ret); | |
| 824 | 841 | break; | |
| 825 | 842 | case REQ_OP_WRITE: | |
| 826 | 843 | case REQ_OP_ZONE_APPEND: | |
modified drivers/bluetooth/btintel.c
| @@ -289,7 +289,8 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code) | |||
| 289 | 289 | goto unlock; | |
| 290 | 290 | } | |
| 291 | 291 | ||
| 292 | - | bt_dev_err(hdev, "Exception info %s", (char *)(skb->data + 1)); | |
| 292 | + | bt_dev_err(hdev, "Exception info %.*s", (int)(skb->len - 1), | |
| 293 | + | (char *)(skb->data + 1)); | |
| 293 | 294 | ||
| 294 | 295 | kfree_skb(skb); | |
| 295 | 296 | ||
| @@ -408,8 +409,16 @@ int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name) | |||
| 408 | 409 | /* DDC file contains one or more DDC structure which has | |
| 409 | 410 | * Length (1 byte), DDC ID (2 bytes), and DDC value (Length - 2). | |
| 410 | 411 | */ | |
| 411 | - | while (fw->size > fw_ptr - fw->data) { | |
| 412 | - | u8 cmd_plen = fw_ptr[0] + sizeof(u8); | |
| 412 | + | while (fw->size > (size_t)(fw_ptr - fw->data)) { | |
| 413 | + | size_t remaining = fw->size - (fw_ptr - fw->data); | |
| 414 | + | unsigned int cmd_plen = fw_ptr[0] + 1U; | |
| 415 | + | ||
| 416 | + | if (cmd_plen < 3 || cmd_plen > U8_MAX || cmd_plen > remaining) { | |
| 417 | + | bt_dev_err(hdev, "Malformed DDC record (plen=%u, remaining=%zu)", | |
| 418 | + | cmd_plen, remaining); | |
| 419 | + | release_firmware(fw); | |
| 420 | + | return -EINVAL; | |
| 421 | + | } | |
| 413 | 422 | ||
| 414 | 423 | skb = __hci_cmd_sync(hdev, 0xfc8b, cmd_plen, fw_ptr, | |
| 415 | 424 | HCI_INIT_TIMEOUT); | |
modified drivers/bluetooth/btintel_pcie.c
| @@ -401,7 +401,7 @@ static int btintel_pcie_send_sync(struct btintel_pcie_data *data, | |||
| 401 | 401 | ||
| 402 | 402 | tfd_index = data->ia.tr_hia[BTINTEL_PCIE_TXQ_NUM]; | |
| 403 | 403 | ||
| 404 | - | if (tfd_index > txq->count) | |
| 404 | + | if (tfd_index >= txq->count) | |
| 405 | 405 | return -ERANGE; | |
| 406 | 406 | ||
| 407 | 407 | if (skb->len > BTINTEL_PCIE_BUFFER_SIZE - BTINTEL_PCIE_HCI_TYPE_LEN) { | |
| @@ -1197,7 +1197,7 @@ static int btintel_pcie_recv_frame(struct btintel_pcie_data *data, | |||
| 1197 | 1197 | { | |
| 1198 | 1198 | int ret; | |
| 1199 | 1199 | u8 pkt_type; | |
| 1200 | - | u16 plen; | |
| 1200 | + | u32 plen; | |
| 1201 | 1201 | u32 pcie_pkt_type; | |
| 1202 | 1202 | void *pdata; | |
| 1203 | 1203 | struct hci_dev *hdev = data->hdev; | |
| @@ -1777,7 +1777,7 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id) | |||
| 1777 | 1777 | static int btintel_pcie_setup_irq(struct btintel_pcie_data *data) | |
| 1778 | 1778 | { | |
| 1779 | 1779 | int err; | |
| 1780 | - | int num_irqs, i; | |
| 1780 | + | int num_irqs, i, j; | |
| 1781 | 1781 | ||
| 1782 | 1782 | for (i = 0; i < BTINTEL_PCIE_MSIX_VEC_MAX; i++) | |
| 1783 | 1783 | data->msix_entries[i].entry = i; | |
| @@ -1806,6 +1806,10 @@ static int btintel_pcie_setup_irq(struct btintel_pcie_data *data) | |||
| 1806 | 1806 | KBUILD_MODNAME, | |
| 1807 | 1807 | msix_entry); | |
| 1808 | 1808 | if (err) { | |
| 1809 | + | for (j = 0; j < i; j++) | |
| 1810 | + | devm_free_irq(&data->pdev->dev, | |
| 1811 | + | data->msix_entries[j].vector, | |
| 1812 | + | &data->msix_entries[j]); | |
| 1809 | 1813 | pci_free_irq_vectors(data->pdev); | |
| 1810 | 1814 | data->alloc_vecs = 0; | |
| 1811 | 1815 | return err; | |
| @@ -1877,6 +1881,13 @@ static int btintel_pcie_config_pcie(struct pci_dev *pdev, | |||
| 1877 | 1881 | if (IS_ERR(data->base_addr)) | |
| 1878 | 1882 | return PTR_ERR(data->base_addr); | |
| 1879 | 1883 | ||
| 1884 | + | /* Do shared hardware reset to ensure a clean start before | |
| 1885 | + | * configuring interrupts. | |
| 1886 | + | */ | |
| 1887 | + | err = btintel_pcie_reset_bt(data); | |
| 1888 | + | if (err) | |
| 1889 | + | return err; | |
| 1890 | + | ||
| 1880 | 1891 | err = btintel_pcie_setup_irq(data); | |
| 1881 | 1892 | if (err) | |
| 1882 | 1893 | return err; | |
| @@ -2219,6 +2230,16 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev, | |||
| 2219 | 2230 | if (test_bit(BTINTEL_PCIE_RECOVERY_IN_PROGRESS, &data->flags)) | |
| 2220 | 2231 | return -ENODEV; | |
| 2221 | 2232 | ||
| 2233 | + | /* Account for the 4-byte PCIe type header prepended before the | |
| 2234 | + | * DMA copy. Written as a subtraction to avoid wrap-around on | |
| 2235 | + | * attacker-controlled skb->len. | |
| 2236 | + | */ | |
| 2237 | + | if (skb->len > BTINTEL_PCIE_BUFFER_SIZE - BTINTEL_PCIE_HCI_TYPE_LEN) { | |
| 2238 | + | bt_dev_err(hdev, "Packet too large: %u > %u", skb->len, | |
| 2239 | + | BTINTEL_PCIE_BUFFER_SIZE - BTINTEL_PCIE_HCI_TYPE_LEN); | |
| 2240 | + | return -EMSGSIZE; | |
| 2241 | + | } | |
| 2242 | + | ||
| 2222 | 2243 | /* Due to the fw limitation, the type header of the packet should be | |
| 2223 | 2244 | * 4 bytes unlike 1 byte for UART. In UART, the firmware can read | |
| 2224 | 2245 | * the first byte to get the packet type and redirect the rest of data | |
| @@ -3128,7 +3149,7 @@ static void btintel_pcie_remove(struct pci_dev *pdev) | |||
| 3128 | 3149 | struct msix_entry *msix_entry; | |
| 3129 | 3150 | ||
| 3130 | 3151 | msix_entry = &data->msix_entries[i]; | |
| 3131 | - | free_irq(msix_entry->vector, msix_entry); | |
| 3152 | + | devm_free_irq(&pdev->dev, msix_entry->vector, msix_entry); | |
| 3132 | 3153 | } | |
| 3133 | 3154 | ||
| 3134 | 3155 | pci_free_irq_vectors(pdev); | |
modified drivers/char/mem.c
| @@ -503,7 +503,7 @@ static int mmap_zero_prepare(struct vm_area_desc *desc) | |||
| 503 | 503 | #ifndef CONFIG_MMU | |
| 504 | 504 | return -ENOSYS; | |
| 505 | 505 | #endif | |
| 506 | - | if (vma_desc_test(desc, VMA_SHARED_BIT)) | |
| 506 | + | if (vma_desc_test(desc, VMA_MAYSHARE_BIT)) | |
| 507 | 507 | return shmem_zero_setup_desc(desc); | |
| 508 | 508 | ||
| 509 | 509 | /* | |
modified drivers/char/tpm/tpm-interface.c
| @@ -268,7 +268,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf, | |||
| 268 | 268 | int err; | |
| 269 | 269 | ssize_t len; | |
| 270 | 270 | ||
| 271 | - | len = tpm_transmit(chip, buf->data, PAGE_SIZE); | |
| 271 | + | len = tpm_transmit(chip, buf->data, buf->capacity); | |
| 272 | 272 | if (len < 0) | |
| 273 | 273 | return len; | |
| 274 | 274 | ||
modified drivers/char/tpm/tpm2-cmd.c
| @@ -281,8 +281,10 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max) | |||
| 281 | 281 | } | |
| 282 | 282 | tpm_buf_append_u16(buf, num_bytes); | |
| 283 | 283 | err = tpm_buf_fill_hmac_session(chip, buf); | |
| 284 | - | if (err) | |
| 284 | + | if (err) { | |
| 285 | + | tpm2_end_auth_session(chip); | |
| 285 | 286 | return err; | |
| 287 | + | } | |
| 286 | 288 | ||
| 287 | 289 | err = tpm_transmit_cmd(chip, buf, | |
| 288 | 290 | offsetof(struct tpm2_get_random_out, | |
| @@ -305,7 +307,7 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max) | |||
| 305 | 307 | out = (struct tpm2_get_random_out *)&buf->data[offset]; | |
| 306 | 308 | recd = min_t(u32, be16_to_cpu(out->size), num_bytes); | |
| 307 | 309 | if (tpm_buf_length(buf) < | |
| 308 | - | TPM_HEADER_SIZE + | |
| 310 | + | offset + | |
| 309 | 311 | offsetof(struct tpm2_get_random_out, buffer) + | |
| 310 | 312 | recd) { | |
| 311 | 313 | tpm2_end_auth_session(chip); | |
modified drivers/char/tpm/tpm2-sessions.c
| @@ -975,6 +975,7 @@ static int tpm2_load_null(struct tpm_chip *chip, u32 *null_key) | |||
| 975 | 975 | /* Deduce from the name change TPM interference: */ | |
| 976 | 976 | dev_err(&chip->dev, "null key integrity check failed\n"); | |
| 977 | 977 | tpm2_flush_context(chip, tmp_null_key); | |
| 978 | + | rc = -ENODEV; | |
| 978 | 979 | ||
| 979 | 980 | err: | |
| 980 | 981 | if (rc) { | |
modified drivers/clk/qcom/gcc-eliza.c
| @@ -3010,8 +3010,6 @@ static const u32 gcc_eliza_critical_cbcrs[] = { | |||
| 3010 | 3010 | 0x26034, /* GCC_CAMERA_XO_CLK */ | |
| 3011 | 3011 | 0x27004, /* GCC_DISP_AHB_CLK */ | |
| 3012 | 3012 | 0x71004, /* GCC_GPU_CFG_AHB_CLK */ | |
| 3013 | - | 0x52010, /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3014 | - | 0x52010, /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3015 | 3013 | 0x32004, /* GCC_VIDEO_AHB_CLK */ | |
| 3016 | 3014 | 0x32038, /* GCC_VIDEO_XO_CLK */ | |
| 3017 | 3015 | }; | |
| @@ -3045,6 +3043,10 @@ static const struct regmap_config gcc_eliza_regmap_config = { | |||
| 3045 | 3043 | ||
| 3046 | 3044 | static void clk_eliza_regs_configure(struct device *dev, struct regmap *regmap) | |
| 3047 | 3045 | { | |
| 3046 | + | /* Keep clocks always enabled */ | |
| 3047 | + | regmap_update_bits(regmap, 0x52010, BIT(20), BIT(20)); /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3048 | + | regmap_update_bits(regmap, 0x52010, BIT(21), BIT(21)); /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3049 | + | ||
| 3048 | 3050 | /* FORCE_MEM_CORE_ON for ufs phy ice core and gcc ufs phy axi clocks */ | |
| 3049 | 3051 | qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_ice_core_clk, true); | |
| 3050 | 3052 | qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_axi_clk, true); | |
modified drivers/clk/qcom/gcc-hawi.c
| @@ -3692,8 +3692,6 @@ static const u32 gcc_hawi_critical_cbcrs[] = { | |||
| 3692 | 3692 | 0x67084, /* GCC_PCIE_1_RSC_CORE_CLK */ | |
| 3693 | 3693 | 0x43014, /* GCC_PCIE_LINK_XO_CLK */ | |
| 3694 | 3694 | 0x6b088, /* GCC_PCIE_RSC_CORE_CLK */ | |
| 3695 | - | 0x52010, /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3696 | - | 0x52010, /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3697 | 3695 | 0x32004, /* GCC_VIDEO_AHB_CLK */ | |
| 3698 | 3696 | 0x32028, /* GCC_VIDEO_XO_CLK */ | |
| 3699 | 3697 | }; | |
| @@ -3763,6 +3761,10 @@ static const struct regmap_config gcc_hawi_regmap_config = { | |||
| 3763 | 3761 | ||
| 3764 | 3762 | static void clk_hawi_regs_configure(struct device *dev, struct regmap *regmap) | |
| 3765 | 3763 | { | |
| 3764 | + | /* Keep clocks always enabled */ | |
| 3765 | + | regmap_update_bits(regmap, 0x52010, BIT(20), BIT(20)); /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3766 | + | regmap_update_bits(regmap, 0x52010, BIT(21), BIT(21)); /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3767 | + | ||
| 3766 | 3768 | /* FORCE_MEM_CORE_ON for ufs phy ice core clocks */ | |
| 3767 | 3769 | qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_ice_core_clk, true); | |
| 3768 | 3770 | } | |
modified drivers/clk/qcom/gcc-kaanapali.c
| @@ -3464,8 +3464,6 @@ static const u32 gcc_kaanapali_critical_cbcrs[] = { | |||
| 3464 | 3464 | 0x9f004, /* GCC_EVA_AHB_CLK */ | |
| 3465 | 3465 | 0x9f024, /* GCC_EVA_XO_CLK */ | |
| 3466 | 3466 | 0x71004, /* GCC_GPU_CFG_AHB_CLK */ | |
| 3467 | - | 0x52010, /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3468 | - | 0x52010, /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3469 | 3467 | 0x32004, /* GCC_VIDEO_AHB_CLK */ | |
| 3470 | 3468 | 0x32040, /* GCC_VIDEO_XO_CLK */ | |
| 3471 | 3469 | }; | |
| @@ -3480,6 +3478,10 @@ static const struct regmap_config gcc_kaanapali_regmap_config = { | |||
| 3480 | 3478 | ||
| 3481 | 3479 | static void clk_kaanapali_regs_configure(struct device *dev, struct regmap *regmap) | |
| 3482 | 3480 | { | |
| 3481 | + | /* Keep clocks always enabled */ | |
| 3482 | + | regmap_update_bits(regmap, 0x52010, BIT(20), BIT(20)); /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3483 | + | regmap_update_bits(regmap, 0x52010, BIT(21), BIT(21)); /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3484 | + | ||
| 3483 | 3485 | /* FORCE_MEM_CORE_ON for ufs phy ice core clocks */ | |
| 3484 | 3486 | qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_ice_core_clk, true); | |
| 3485 | 3487 | } | |
modified drivers/clk/qcom/gpucc-glymur.c
| @@ -510,7 +510,7 @@ static struct gdsc gpu_cc_cx_gdsc = { | |||
| 510 | 510 | .name = "gpu_cc_cx_gdsc", | |
| 511 | 511 | }, | |
| 512 | 512 | .pwrsts = PWRSTS_OFF_ON, | |
| 513 | - | .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE, | |
| 513 | + | .flags = RETAIN_FF_ENABLE | VOTABLE, | |
| 514 | 514 | }; | |
| 515 | 515 | ||
| 516 | 516 | static struct clk_regmap *gpu_cc_glymur_clocks[] = { | |
modified drivers/clk/qcom/gpucc-kaanapali.c
| @@ -380,7 +380,7 @@ static struct gdsc gpu_cc_cx_gdsc = { | |||
| 380 | 380 | .name = "gpu_cc_cx_gdsc", | |
| 381 | 381 | }, | |
| 382 | 382 | .pwrsts = PWRSTS_OFF_ON, | |
| 383 | - | .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE, | |
| 383 | + | .flags = RETAIN_FF_ENABLE | VOTABLE, | |
| 384 | 384 | }; | |
| 385 | 385 | ||
| 386 | 386 | static struct clk_regmap *gpu_cc_kaanapali_clocks[] = { | |
modified drivers/clk/spacemit/ccu-k3.c
| @@ -30,14 +30,87 @@ static const struct ccu_pll_rate_tbl pll2_rate_tbl[] = { | |||
| 30 | 30 | }; | |
| 31 | 31 | ||
| 32 | 32 | static const struct ccu_pll_rate_tbl pll3_rate_tbl[] = { | |
| 33 | + | CCU_PLLA_RATE(1050000000UL, 0x0b2b3000, 0x00000000, 0xa0458080), | |
| 34 | + | CCU_PLLA_RATE(1100000000UL, 0x0b2d3555, 0x00005500, 0xa0458181), | |
| 35 | + | CCU_PLLA_RATE(1150000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0458181), | |
| 36 | + | CCU_PLLA_RATE(1200000000UL, 0x0b320000, 0x00000000, 0xa0458181), | |
| 37 | + | CCU_PLLA_RATE(1250000000UL, 0x0b340555, 0x00005500, 0xa0458181), | |
| 38 | + | CCU_PLLA_RATE(1300000000UL, 0x0b360aaa, 0x0000ab00, 0xa0458282), | |
| 39 | + | CCU_PLLA_RATE(1350000000UL, 0x0b381000, 0x00000000, 0xa0458282), | |
| 40 | + | CCU_PLLA_RATE(1400000000UL, 0x0b3a1555, 0x00005500, 0xa0458282), | |
| 41 | + | CCU_PLLA_RATE(1450000000UL, 0x0b3c1aaa, 0x0000ab00, 0xa0458383), | |
| 42 | + | CCU_PLLA_RATE(1500000000UL, 0x0b3e2000, 0x00000000, 0xa0458383), | |
| 43 | + | CCU_PLLA_RATE(1550000000UL, 0x0b402555, 0x00005500, 0xa0458383), | |
| 44 | + | CCU_PLLA_RATE(1600000000UL, 0x0b422aaa, 0x0000ab00, 0xa0458484), | |
| 45 | + | CCU_PLLA_RATE(1650000000UL, 0x0b443000, 0x00000000, 0xa0458484), | |
| 46 | + | CCU_PLLA_RATE(1700000000UL, 0x0b463555, 0x00005500, 0xa0458484), | |
| 47 | + | CCU_PLLA_RATE(1750000000UL, 0x0b483aaa, 0x0000ab00, 0xa0458585), | |
| 48 | + | CCU_PLLA_RATE(1800000000UL, 0x0b4b0000, 0x00000000, 0xa0458585), | |
| 49 | + | CCU_PLLA_RATE(1850000000UL, 0x0b4d0555, 0x00005500, 0xa0458585), | |
| 50 | + | CCU_PLLA_RATE(1900000000UL, 0x0b4f0aaa, 0x0000ab00, 0xa0458686), | |
| 51 | + | CCU_PLLA_RATE(1950000000UL, 0x0b511000, 0x00000000, 0xa0458686), | |
| 52 | + | CCU_PLLA_RATE(2000000000UL, 0x0b292aaa, 0x0000ab00, 0xa0558686), | |
| 53 | + | CCU_PLLA_RATE(2050000000UL, 0x0b2a2d55, 0x00005500, 0xa0558686), | |
| 54 | + | CCU_PLLA_RATE(2100000000UL, 0x0b2b3000, 0x00000000, 0xa0558787), | |
| 55 | + | CCU_PLLA_RATE(2150000000UL, 0x0b2c32aa, 0x0000ab00, 0xa0558787), | |
| 33 | 56 | CCU_PLLA_RATE(2200000000UL, 0x0b2d3555, 0x00005500, 0xa0558787), | |
| 57 | + | CCU_PLLA_RATE(2250000000UL, 0x0b2e3800, 0x00000000, 0xa0558888), | |
| 58 | + | CCU_PLLA_RATE(2300000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0558888), | |
| 59 | + | CCU_PLLA_RATE(2350000000UL, 0x0b303d55, 0x00005500, 0xa0558888), | |
| 60 | + | CCU_PLLA_RATE(2400000000UL, 0x0b320000, 0x00000000, 0xa0558989), | |
| 34 | 61 | }; | |
| 35 | 62 | ||
| 36 | 63 | static const struct ccu_pll_rate_tbl pll4_rate_tbl[] = { | |
| 64 | + | CCU_PLLA_RATE(1050000000UL, 0x0b2b3000, 0x00000000, 0xa0458080), | |
| 65 | + | CCU_PLLA_RATE(1100000000UL, 0x0b2d3555, 0x00005500, 0xa0458181), | |
| 66 | + | CCU_PLLA_RATE(1150000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0458181), | |
| 67 | + | CCU_PLLA_RATE(1200000000UL, 0x0b320000, 0x00000000, 0xa0458181), | |
| 68 | + | CCU_PLLA_RATE(1250000000UL, 0x0b340555, 0x00005500, 0xa0458181), | |
| 69 | + | CCU_PLLA_RATE(1300000000UL, 0x0b360aaa, 0x0000ab00, 0xa0458282), | |
| 70 | + | CCU_PLLA_RATE(1350000000UL, 0x0b381000, 0x00000000, 0xa0458282), | |
| 71 | + | CCU_PLLA_RATE(1400000000UL, 0x0b3a1555, 0x00005500, 0xa0458282), | |
| 72 | + | CCU_PLLA_RATE(1450000000UL, 0x0b3c1aaa, 0x0000ab00, 0xa0458383), | |
| 73 | + | CCU_PLLA_RATE(1500000000UL, 0x0b3e2000, 0x00000000, 0xa0458383), | |
| 74 | + | CCU_PLLA_RATE(1550000000UL, 0x0b402555, 0x00005500, 0xa0458383), | |
| 75 | + | CCU_PLLA_RATE(1600000000UL, 0x0b422aaa, 0x0000ab00, 0xa0458484), | |
| 76 | + | CCU_PLLA_RATE(1650000000UL, 0x0b443000, 0x00000000, 0xa0458484), | |
| 77 | + | CCU_PLLA_RATE(1700000000UL, 0x0b463555, 0x00005500, 0xa0458484), | |
| 78 | + | CCU_PLLA_RATE(1750000000UL, 0x0b483aaa, 0x0000ab00, 0xa0458585), | |
| 79 | + | CCU_PLLA_RATE(1800000000UL, 0x0b4b0000, 0x00000000, 0xa0458585), | |
| 80 | + | CCU_PLLA_RATE(1850000000UL, 0x0b4d0555, 0x00005500, 0xa0458585), | |
| 81 | + | CCU_PLLA_RATE(1900000000UL, 0x0b4f0aaa, 0x0000ab00, 0xa0458686), | |
| 82 | + | CCU_PLLA_RATE(1950000000UL, 0x0b511000, 0x00000000, 0xa0458686), | |
| 83 | + | CCU_PLLA_RATE(2000000000UL, 0x0b292aaa, 0x0000ab00, 0xa0558686), | |
| 84 | + | CCU_PLLA_RATE(2050000000UL, 0x0b2a2d55, 0x00005500, 0xa0558686), | |
| 85 | + | CCU_PLLA_RATE(2100000000UL, 0x0b2b3000, 0x00000000, 0xa0558787), | |
| 86 | + | CCU_PLLA_RATE(2150000000UL, 0x0b2c32aa, 0x0000ab00, 0xa0558787), | |
| 37 | 87 | CCU_PLLA_RATE(2200000000UL, 0x0b2d3555, 0x00005500, 0xa0558787), | |
| 88 | + | CCU_PLLA_RATE(2250000000UL, 0x0b2e3800, 0x00000000, 0xa0558888), | |
| 89 | + | CCU_PLLA_RATE(2300000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0558888), | |
| 90 | + | CCU_PLLA_RATE(2350000000UL, 0x0b303d55, 0x00005500, 0xa0558888), | |
| 91 | + | CCU_PLLA_RATE(2400000000UL, 0x0b320000, 0x00000000, 0xa0558989), | |
| 38 | 92 | }; | |
| 39 | 93 | ||
| 40 | 94 | static const struct ccu_pll_rate_tbl pll5_rate_tbl[] = { | |
| 95 | + | CCU_PLLA_RATE(1050000000UL, 0x0b2b3000, 0x00000000, 0xa0458080), | |
| 96 | + | CCU_PLLA_RATE(1100000000UL, 0x0b2d3555, 0x00005500, 0xa0458181), | |
| 97 | + | CCU_PLLA_RATE(1150000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0458181), | |
| 98 | + | CCU_PLLA_RATE(1200000000UL, 0x0b320000, 0x00000000, 0xa0458181), | |
| 99 | + | CCU_PLLA_RATE(1250000000UL, 0x0b340555, 0x00005500, 0xa0458181), | |
| 100 | + | CCU_PLLA_RATE(1300000000UL, 0x0b360aaa, 0x0000ab00, 0xa0458282), | |
| 101 | + | CCU_PLLA_RATE(1350000000UL, 0x0b381000, 0x00000000, 0xa0458282), | |
| 102 | + | CCU_PLLA_RATE(1400000000UL, 0x0b3a1555, 0x00005500, 0xa0458282), | |
| 103 | + | CCU_PLLA_RATE(1450000000UL, 0x0b3c1aaa, 0x0000ab00, 0xa0458383), | |
| 104 | + | CCU_PLLA_RATE(1500000000UL, 0x0b3e2000, 0x00000000, 0xa0458383), | |
| 105 | + | CCU_PLLA_RATE(1550000000UL, 0x0b402555, 0x00005500, 0xa0458383), | |
| 106 | + | CCU_PLLA_RATE(1600000000UL, 0x0b422aaa, 0x0000ab00, 0xa0458484), | |
| 107 | + | CCU_PLLA_RATE(1650000000UL, 0x0b443000, 0x00000000, 0xa0458484), | |
| 108 | + | CCU_PLLA_RATE(1700000000UL, 0x0b463555, 0x00005500, 0xa0458484), | |
| 109 | + | CCU_PLLA_RATE(1750000000UL, 0x0b483aaa, 0x0000ab00, 0xa0458585), | |
| 110 | + | CCU_PLLA_RATE(1800000000UL, 0x0b4b0000, 0x00000000, 0xa0458585), | |
| 111 | + | CCU_PLLA_RATE(1850000000UL, 0x0b4d0555, 0x00005500, 0xa0458585), | |
| 112 | + | CCU_PLLA_RATE(1900000000UL, 0x0b4f0aaa, 0x0000ab00, 0xa0458686), | |
| 113 | + | CCU_PLLA_RATE(1950000000UL, 0x0b511000, 0x00000000, 0xa0458686), | |
| 41 | 114 | CCU_PLLA_RATE(2000000000UL, 0x0b292aaa, 0x0000ab00, 0xa0558686), | |
| 42 | 115 | }; | |
| 43 | 116 | ||
| @@ -50,6 +123,25 @@ static const struct ccu_pll_rate_tbl pll7_rate_tbl[] = { | |||
| 50 | 123 | }; | |
| 51 | 124 | ||
| 52 | 125 | static const struct ccu_pll_rate_tbl pll8_rate_tbl[] = { | |
| 126 | + | CCU_PLLA_RATE(1050000000UL, 0x0b2b3000, 0x00000000, 0xa0458080), | |
| 127 | + | CCU_PLLA_RATE(1100000000UL, 0x0b2d3555, 0x00005500, 0xa0458181), | |
| 128 | + | CCU_PLLA_RATE(1150000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0458181), | |
| 129 | + | CCU_PLLA_RATE(1200000000UL, 0x0b320000, 0x00000000, 0xa0458181), | |
| 130 | + | CCU_PLLA_RATE(1250000000UL, 0x0b340555, 0x00005500, 0xa0458181), | |
| 131 | + | CCU_PLLA_RATE(1300000000UL, 0x0b360aaa, 0x0000ab00, 0xa0458282), | |
| 132 | + | CCU_PLLA_RATE(1350000000UL, 0x0b381000, 0x00000000, 0xa0458282), | |
| 133 | + | CCU_PLLA_RATE(1400000000UL, 0x0b3a1555, 0x00005500, 0xa0458282), | |
| 134 | + | CCU_PLLA_RATE(1450000000UL, 0x0b3c1aaa, 0x0000ab00, 0xa0458383), | |
| 135 | + | CCU_PLLA_RATE(1500000000UL, 0x0b3e2000, 0x00000000, 0xa0458383), | |
| 136 | + | CCU_PLLA_RATE(1550000000UL, 0x0b402555, 0x00005500, 0xa0458383), | |
| 137 | + | CCU_PLLA_RATE(1600000000UL, 0x0b422aaa, 0x0000ab00, 0xa0458484), | |
| 138 | + | CCU_PLLA_RATE(1650000000UL, 0x0b443000, 0x00000000, 0xa0458484), | |
| 139 | + | CCU_PLLA_RATE(1700000000UL, 0x0b463555, 0x00005500, 0xa0458484), | |
| 140 | + | CCU_PLLA_RATE(1750000000UL, 0x0b483aaa, 0x0000ab00, 0xa0458585), | |
| 141 | + | CCU_PLLA_RATE(1800000000UL, 0x0b4b0000, 0x00000000, 0xa0458585), | |
| 142 | + | CCU_PLLA_RATE(1850000000UL, 0x0b4d0555, 0x00005500, 0xa0458585), | |
| 143 | + | CCU_PLLA_RATE(1900000000UL, 0x0b4f0aaa, 0x0000ab00, 0xa0458686), | |
| 144 | + | CCU_PLLA_RATE(1950000000UL, 0x0b511000, 0x00000000, 0xa0458686), | |
| 53 | 145 | CCU_PLLA_RATE(2000000000UL, 0x0b292aaa, 0x0000ab00, 0xa0558686), | |
| 54 | 146 | }; | |
| 55 | 147 | ||
modified drivers/clk/ti/composite.c
| @@ -52,7 +52,7 @@ static const struct clk_ops ti_composite_gate_ops = { | |||
| 52 | 52 | ||
| 53 | 53 | struct component_clk { | |
| 54 | 54 | int num_parents; | |
| 55 | - | struct clk_parent_data *parent_data; | |
| 55 | + | const char **parent_names; | |
| 56 | 56 | struct device_node *node; | |
| 57 | 57 | int type; | |
| 58 | 58 | struct clk_hw *hw; | |
| @@ -116,7 +116,7 @@ static void __init _register_composite(void *user, | |||
| 116 | 116 | struct clk_hw_omap_comp *cclk = to_clk_hw_comp(hw); | |
| 117 | 117 | struct component_clk *comp; | |
| 118 | 118 | int num_parents = 0; | |
| 119 | - | struct clk_parent_data *parent_data = NULL; | |
| 119 | + | const char **parent_names = NULL; | |
| 120 | 120 | const char *name; | |
| 121 | 121 | int i; | |
| 122 | 122 | int ret; | |
| @@ -155,7 +155,7 @@ static void __init _register_composite(void *user, | |||
| 155 | 155 | continue; | |
| 156 | 156 | if (comp->num_parents) { | |
| 157 | 157 | num_parents = comp->num_parents; | |
| 158 | - | parent_data = comp->parent_data; | |
| 158 | + | parent_names = comp->parent_names; | |
| 159 | 159 | break; | |
| 160 | 160 | } | |
| 161 | 161 | } | |
| @@ -166,8 +166,8 @@ static void __init _register_composite(void *user, | |||
| 166 | 166 | } | |
| 167 | 167 | ||
| 168 | 168 | name = ti_dt_clk_name(node); | |
| 169 | - | clk = clk_register_composite_pdata(NULL, name, | |
| 170 | - | parent_data, num_parents, | |
| 169 | + | clk = clk_register_composite(NULL, name, | |
| 170 | + | parent_names, num_parents, | |
| 171 | 171 | _get_hw(cclk, CLK_COMPONENT_TYPE_MUX), | |
| 172 | 172 | &ti_clk_mux_ops, | |
| 173 | 173 | _get_hw(cclk, CLK_COMPONENT_TYPE_DIVIDER), | |
| @@ -190,7 +190,7 @@ cleanup: | |||
| 190 | 190 | if (!cclk->comp_clks[i]) | |
| 191 | 191 | continue; | |
| 192 | 192 | list_del(&cclk->comp_clks[i]->link); | |
| 193 | - | kfree(cclk->comp_clks[i]->parent_data); | |
| 193 | + | kfree(cclk->comp_clks[i]->parent_names); | |
| 194 | 194 | kfree(cclk->comp_clks[i]); | |
| 195 | 195 | } | |
| 196 | 196 | ||
| @@ -237,9 +237,8 @@ int __init ti_clk_add_component(struct device_node *node, struct clk_hw *hw, | |||
| 237 | 237 | int type) | |
| 238 | 238 | { | |
| 239 | 239 | unsigned int num_parents; | |
| 240 | - | struct clk_parent_data *parent_data; | |
| 240 | + | const char **parent_names; | |
| 241 | 241 | struct component_clk *clk; | |
| 242 | - | unsigned int i; | |
| 243 | 242 | ||
| 244 | 243 | num_parents = of_clk_get_parent_count(node); | |
| 245 | 244 | ||
| @@ -248,21 +247,20 @@ int __init ti_clk_add_component(struct device_node *node, struct clk_hw *hw, | |||
| 248 | 247 | return -EINVAL; | |
| 249 | 248 | } | |
| 250 | 249 | ||
| 251 | - | parent_data = kzalloc_objs(*parent_data, num_parents); | |
| 252 | - | if (!parent_data) | |
| 250 | + | parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL); | |
| 251 | + | if (!parent_names) | |
| 253 | 252 | return -ENOMEM; | |
| 254 | 253 | ||
| 255 | - | for (i = 0; i < num_parents; i++) | |
| 256 | - | parent_data[i].index = i; | |
| 254 | + | of_clk_parent_fill(node, parent_names, num_parents); | |
| 257 | 255 | ||
| 258 | 256 | clk = kzalloc_obj(*clk); | |
| 259 | 257 | if (!clk) { | |
| 260 | - | kfree(parent_data); | |
| 258 | + | kfree(parent_names); | |
| 261 | 259 | return -ENOMEM; | |
| 262 | 260 | } | |
| 263 | 261 | ||
| 264 | 262 | clk->num_parents = num_parents; | |
| 265 | - | clk->parent_data = parent_data; | |
| 263 | + | clk->parent_names = parent_names; | |
| 266 | 264 | clk->hw = hw; | |
| 267 | 265 | clk->node = node; | |
| 268 | 266 | clk->type = type; | |
modified drivers/cpufreq/cpufreq.c
| @@ -2590,8 +2590,8 @@ static void cpufreq_update_pressure(struct cpufreq_policy *policy) | |||
| 2590 | 2590 | ||
| 2591 | 2591 | cpu = cpumask_first(policy->related_cpus); | |
| 2592 | 2592 | max_freq = arch_scale_freq_ref(cpu); | |
| 2593 | - | if (!max_freq) | |
| 2594 | - | max_freq = policy->cpuinfo.max_freq; | |
| 2593 | + | if (!max_freq && cpufreq_driver->scale_freq_ref) | |
| 2594 | + | max_freq = cpufreq_driver->scale_freq_ref(policy); | |
| 2595 | 2595 | ||
| 2596 | 2596 | capped_freq = policy->max; | |
| 2597 | 2597 | ||
modified drivers/cpufreq/intel_pstate.c
| @@ -1135,6 +1135,14 @@ static bool hybrid_clear_max_perf_cpu(void) | |||
| 1135 | 1135 | return ret; | |
| 1136 | 1136 | } | |
| 1137 | 1137 | ||
| 1138 | + | static unsigned int intel_pstate_scale_freq_ref(struct cpufreq_policy *policy) | |
| 1139 | + | { | |
| 1140 | + | if (READ_ONCE(all_cpu_data[policy->cpu]->capacity_perf)) | |
| 1141 | + | return policy->cpuinfo.max_freq; | |
| 1142 | + | ||
| 1143 | + | return 0; | |
| 1144 | + | } | |
| 1145 | + | ||
| 1138 | 1146 | static void intel_pstate_update_freq_limits(struct cpudata *cpu) | |
| 1139 | 1147 | { | |
| 1140 | 1148 | int scaling = cpu->pstate.scaling; | |
| @@ -3088,6 +3096,7 @@ static struct cpufreq_driver intel_pstate = { | |||
| 3088 | 3096 | .offline = intel_pstate_cpu_offline, | |
| 3089 | 3097 | .online = intel_pstate_cpu_online, | |
| 3090 | 3098 | .update_limits = intel_pstate_update_limits, | |
| 3099 | + | .scale_freq_ref = intel_pstate_scale_freq_ref, | |
| 3091 | 3100 | .name = "intel_pstate", | |
| 3092 | 3101 | }; | |
| 3093 | 3102 | ||
| @@ -3411,6 +3420,7 @@ static struct cpufreq_driver intel_cpufreq = { | |||
| 3411 | 3420 | .suspend = intel_cpufreq_suspend, | |
| 3412 | 3421 | .resume = intel_pstate_resume, | |
| 3413 | 3422 | .update_limits = intel_pstate_update_limits, | |
| 3423 | + | .scale_freq_ref = intel_pstate_scale_freq_ref, | |
| 3414 | 3424 | .name = "intel_cpufreq", | |
| 3415 | 3425 | }; | |
| 3416 | 3426 | ||
modified drivers/edac/altera_edac.c
| @@ -453,15 +453,6 @@ free: | |||
| 453 | 453 | return res; | |
| 454 | 454 | } | |
| 455 | 455 | ||
| 456 | - | static void altr_sdram_remove(struct platform_device *pdev) | |
| 457 | - | { | |
| 458 | - | struct mem_ctl_info *mci = platform_get_drvdata(pdev); | |
| 459 | - | ||
| 460 | - | edac_mc_del_mc(&pdev->dev); | |
| 461 | - | edac_mc_free(mci); | |
| 462 | - | platform_set_drvdata(pdev, NULL); | |
| 463 | - | } | |
| 464 | - | ||
| 465 | 456 | /* | |
| 466 | 457 | * If you want to suspend, need to disable EDAC by removing it | |
| 467 | 458 | * from the device tree or defconfig. | |
| @@ -481,13 +472,13 @@ static const struct dev_pm_ops altr_sdram_pm_ops = { | |||
| 481 | 472 | ||
| 482 | 473 | static struct platform_driver altr_sdram_edac_driver = { | |
| 483 | 474 | .probe = altr_sdram_probe, | |
| 484 | - | .remove = altr_sdram_remove, | |
| 485 | 475 | .driver = { | |
| 486 | 476 | .name = "altr_sdram_edac", | |
| 487 | 477 | #ifdef CONFIG_PM | |
| 488 | 478 | .pm = &altr_sdram_pm_ops, | |
| 489 | 479 | #endif | |
| 490 | 480 | .of_match_table = altr_sdram_ctrl_of_match, | |
| 481 | + | .suppress_bind_attrs = true, | |
| 491 | 482 | }, | |
| 492 | 483 | }; | |
| 493 | 484 | ||
| @@ -517,6 +508,7 @@ static struct platform_driver altr_edac_driver = { | |||
| 517 | 508 | .driver = { | |
| 518 | 509 | .name = "socfpga_ecc_manager", | |
| 519 | 510 | .of_match_table = altr_edac_of_match, | |
| 511 | + | .suppress_bind_attrs = true, | |
| 520 | 512 | }, | |
| 521 | 513 | }; | |
| 522 | 514 | module_platform_driver(altr_edac_driver); | |
| @@ -803,22 +795,12 @@ fail: | |||
| 803 | 795 | return res; | |
| 804 | 796 | } | |
| 805 | 797 | ||
| 806 | - | static void altr_edac_device_remove(struct platform_device *pdev) | |
| 807 | - | { | |
| 808 | - | struct edac_device_ctl_info *dci = platform_get_drvdata(pdev); | |
| 809 | - | struct altr_edac_device_dev *drvdata = dci->pvt_info; | |
| 810 | - | ||
| 811 | - | debugfs_remove_recursive(drvdata->debugfs_dir); | |
| 812 | - | edac_device_del_device(&pdev->dev); | |
| 813 | - | edac_device_free_ctl_info(dci); | |
| 814 | - | } | |
| 815 | - | ||
| 816 | 798 | static struct platform_driver altr_edac_device_driver = { | |
| 817 | 799 | .probe = altr_edac_device_probe, | |
| 818 | - | .remove = altr_edac_device_remove, | |
| 819 | 800 | .driver = { | |
| 820 | 801 | .name = "altr_edac_device", | |
| 821 | 802 | .of_match_table = altr_edac_device_of_match, | |
| 803 | + | .suppress_bind_attrs = true, | |
| 822 | 804 | }, | |
| 823 | 805 | }; | |
| 824 | 806 | module_platform_driver(altr_edac_device_driver); | |
| @@ -944,7 +926,7 @@ static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) | |||
| 944 | 926 | return ret; | |
| 945 | 927 | } | |
| 946 | 928 | ||
| 947 | - | static __init int __maybe_unused | |
| 929 | + | static int __maybe_unused | |
| 948 | 930 | altr_init_a10_ecc_block(struct device_node *np, u32 irq_mask, | |
| 949 | 931 | u32 ecc_ctrl_en_mask, bool dual_port) | |
| 950 | 932 | { | |
| @@ -1019,7 +1001,7 @@ out: | |||
| 1019 | 1001 | ||
| 1020 | 1002 | static int validate_parent_available(struct device_node *np); | |
| 1021 | 1003 | static const struct of_device_id altr_edac_a10_device_of_match[]; | |
| 1022 | - | static int __init __maybe_unused altr_init_a10_ecc_device_type(char *compat) | |
| 1004 | + | static int __maybe_unused altr_init_a10_ecc_device_type(char *compat) | |
| 1023 | 1005 | { | |
| 1024 | 1006 | int irq; | |
| 1025 | 1007 | struct device_node *child, *np; | |
| @@ -1348,7 +1330,7 @@ static const struct edac_device_prv_data a10_l2ecc_data = { | |||
| 1348 | 1330 | ||
| 1349 | 1331 | #ifdef CONFIG_EDAC_ALTERA_ETHERNET | |
| 1350 | 1332 | ||
| 1351 | - | static int __init socfpga_init_ethernet_ecc(struct altr_edac_device_dev *dev) | |
| 1333 | + | static int socfpga_init_ethernet_ecc(struct altr_edac_device_dev *dev) | |
| 1352 | 1334 | { | |
| 1353 | 1335 | int ret; | |
| 1354 | 1336 | ||
| @@ -1378,7 +1360,7 @@ static const struct edac_device_prv_data a10_enetecc_data = { | |||
| 1378 | 1360 | ||
| 1379 | 1361 | #ifdef CONFIG_EDAC_ALTERA_NAND | |
| 1380 | 1362 | ||
| 1381 | - | static int __init socfpga_init_nand_ecc(struct altr_edac_device_dev *device) | |
| 1363 | + | static int socfpga_init_nand_ecc(struct altr_edac_device_dev *device) | |
| 1382 | 1364 | { | |
| 1383 | 1365 | int ret; | |
| 1384 | 1366 | ||
| @@ -1408,7 +1390,7 @@ static const struct edac_device_prv_data a10_nandecc_data = { | |||
| 1408 | 1390 | ||
| 1409 | 1391 | #ifdef CONFIG_EDAC_ALTERA_DMA | |
| 1410 | 1392 | ||
| 1411 | - | static int __init socfpga_init_dma_ecc(struct altr_edac_device_dev *device) | |
| 1393 | + | static int socfpga_init_dma_ecc(struct altr_edac_device_dev *device) | |
| 1412 | 1394 | { | |
| 1413 | 1395 | int ret; | |
| 1414 | 1396 | ||
| @@ -1438,7 +1420,7 @@ static const struct edac_device_prv_data a10_dmaecc_data = { | |||
| 1438 | 1420 | ||
| 1439 | 1421 | #ifdef CONFIG_EDAC_ALTERA_USB | |
| 1440 | 1422 | ||
| 1441 | - | static int __init socfpga_init_usb_ecc(struct altr_edac_device_dev *device) | |
| 1423 | + | static int socfpga_init_usb_ecc(struct altr_edac_device_dev *device) | |
| 1442 | 1424 | { | |
| 1443 | 1425 | int ret; | |
| 1444 | 1426 | ||
| @@ -1468,7 +1450,7 @@ static const struct edac_device_prv_data a10_usbecc_data = { | |||
| 1468 | 1450 | ||
| 1469 | 1451 | #ifdef CONFIG_EDAC_ALTERA_QSPI | |
| 1470 | 1452 | ||
| 1471 | - | static int __init socfpga_init_qspi_ecc(struct altr_edac_device_dev *device) | |
| 1453 | + | static int socfpga_init_qspi_ecc(struct altr_edac_device_dev *device) | |
| 1472 | 1454 | { | |
| 1473 | 1455 | int ret; | |
| 1474 | 1456 | ||
| @@ -1524,6 +1506,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1524 | 1506 | dci = edac_device_alloc_ctl_info(sizeof(*altdev), ecc_name, 1, | |
| 1525 | 1507 | ecc_name, 1, 0, edac_idx); | |
| 1526 | 1508 | if (!dci) { | |
| 1509 | + | of_node_put(np); | |
| 1527 | 1510 | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 1528 | 1511 | "%s: Unable to allocate PortB EDAC device\n", | |
| 1529 | 1512 | ecc_name); | |
| @@ -1534,8 +1517,11 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1534 | 1517 | altdev = dci->pvt_info; | |
| 1535 | 1518 | *altdev = *device; | |
| 1536 | 1519 | ||
| 1537 | - | if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL)) | |
| 1520 | + | if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL)) { | |
| 1521 | + | edac_device_free_ctl_info(dci); | |
| 1522 | + | of_node_put(np); | |
| 1538 | 1523 | return -ENOMEM; | |
| 1524 | + | } | |
| 1539 | 1525 | ||
| 1540 | 1526 | /* Update PortB specific values */ | |
| 1541 | 1527 | altdev->edac_dev_name = ecc_name; | |
| @@ -1600,6 +1586,8 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1600 | 1586 | rc = -ENOMEM; | |
| 1601 | 1587 | goto err_release_group_1; | |
| 1602 | 1588 | } | |
| 1589 | + | of_node_put(np); | |
| 1590 | + | ||
| 1603 | 1591 | altr_create_edacdev_dbgfs(dci, prv); | |
| 1604 | 1592 | ||
| 1605 | 1593 | list_add(&altdev->next, &altdev->edac->a10_ecc_devices); | |
| @@ -1609,14 +1597,20 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1609 | 1597 | return 0; | |
| 1610 | 1598 | ||
| 1611 | 1599 | err_release_group_1: | |
| 1612 | - | edac_device_free_ctl_info(dci); | |
| 1600 | + | /* | |
| 1601 | + | * Release the devres group first so the managed IRQs are | |
| 1602 | + | * unregistered before dci (which contains the IRQ handler's | |
| 1603 | + | * data via dci->pvt_info) is freed, avoiding a use-after-free. | |
| 1604 | + | */ | |
| 1613 | 1605 | devres_release_group(device->edac->dev, altr_portb_setup); | |
| 1606 | + | edac_device_free_ctl_info(dci); | |
| 1607 | + | of_node_put(np); | |
| 1614 | 1608 | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 1615 | 1609 | "%s:Error setting up EDAC device: %d\n", ecc_name, rc); | |
| 1616 | 1610 | return rc; | |
| 1617 | 1611 | } | |
| 1618 | 1612 | ||
| 1619 | - | static int __init socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device) | |
| 1613 | + | static int socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device) | |
| 1620 | 1614 | { | |
| 1621 | 1615 | int rc = -ENODEV; | |
| 1622 | 1616 | struct device_node *child; | |
| @@ -1638,7 +1632,7 @@ static int __init socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device) | |||
| 1638 | 1632 | goto exit; | |
| 1639 | 1633 | ||
| 1640 | 1634 | /* Setup portB */ | |
| 1641 | - | return altr_portb_setup(device); | |
| 1635 | + | rc = altr_portb_setup(device); | |
| 1642 | 1636 | ||
| 1643 | 1637 | exit: | |
| 1644 | 1638 | of_node_put(child); | |
| @@ -2013,9 +2007,17 @@ static int altr_edac_a10_device_add(struct altr_arria10_edac *edac, | |||
| 2013 | 2007 | return 0; | |
| 2014 | 2008 | ||
| 2015 | 2009 | err_release_group1: | |
| 2010 | + | /* | |
| 2011 | + | * Release the devres group first so the managed IRQs are | |
| 2012 | + | * unregistered before dci (which contains the IRQ handler's | |
| 2013 | + | * data via dci->pvt_info) is freed, avoiding a use-after-free. | |
| 2014 | + | */ | |
| 2015 | + | devres_release_group(edac->dev, NULL); | |
| 2016 | 2016 | edac_device_free_ctl_info(dci); | |
| 2017 | + | goto err_print; | |
| 2017 | 2018 | err_release_group: | |
| 2018 | 2019 | devres_release_group(edac->dev, NULL); | |
| 2020 | + | err_print: | |
| 2019 | 2021 | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 2020 | 2022 | "%s:Error setting up EDAC device: %d\n", ecc_name, rc); | |
| 2021 | 2023 | ||
| @@ -2214,6 +2216,7 @@ static struct platform_driver altr_edac_a10_driver = { | |||
| 2214 | 2216 | .driver = { | |
| 2215 | 2217 | .name = "socfpga_a10_ecc_manager", | |
| 2216 | 2218 | .of_match_table = altr_edac_a10_of_match, | |
| 2219 | + | .suppress_bind_attrs = true, | |
| 2217 | 2220 | }, | |
| 2218 | 2221 | }; | |
| 2219 | 2222 | module_platform_driver(altr_edac_a10_driver); | |
modified drivers/edac/amd64_edac.c
| @@ -2796,13 +2796,13 @@ static inline void decode_bus_error(int node_id, struct mce *m) | |||
| 2796 | 2796 | * the instance_id. For example, instance_id=0xYXXXXX where Y is the channel | |
| 2797 | 2797 | * number. | |
| 2798 | 2798 | * | |
| 2799 | - | * For DRAM ECC errors, the Chip Select number is given in bits [2:0] of | |
| 2799 | + | * For DRAM ECC errors, the Chip Select number is given in bits [1:0] of | |
| 2800 | 2800 | * the MCA_SYND[ErrorInformation] field. | |
| 2801 | 2801 | */ | |
| 2802 | 2802 | static void umc_get_err_info(struct mce *m, struct err_info *err) | |
| 2803 | 2803 | { | |
| 2804 | 2804 | err->channel = (m->ipid & GENMASK(31, 0)) >> 20; | |
| 2805 | - | err->csrow = m->synd & 0x7; | |
| 2805 | + | err->csrow = m->synd & 0x3; | |
| 2806 | 2806 | } | |
| 2807 | 2807 | ||
| 2808 | 2808 | static void decode_umc_error(int node_id, struct mce *m) | |
modified drivers/edac/versalnet_edac.c
| @@ -953,6 +953,7 @@ static void mc_remove(struct platform_device *pdev) | |||
| 953 | 953 | remove_versalnet(priv); | |
| 954 | 954 | rproc_shutdown(priv->mcdi->r5_rproc); | |
| 955 | 955 | cdx_mcdi_finish(priv->mcdi); | |
| 956 | + | rproc_put(priv->mcdi->r5_rproc); | |
| 956 | 957 | kfree(priv->mcdi); | |
| 957 | 958 | } | |
| 958 | 959 | ||
modified drivers/gpio/gpio-exar.c
| @@ -199,6 +199,7 @@ static int gpio_exar_probe(struct platform_device *pdev) | |||
| 199 | 199 | index = ida_alloc(&ida_index, GFP_KERNEL); | |
| 200 | 200 | if (index < 0) | |
| 201 | 201 | return index; | |
| 202 | + | exar_gpio->index = index; | |
| 202 | 203 | ||
| 203 | 204 | ret = devm_add_action_or_reset(dev, exar_devm_ida_free, exar_gpio); | |
| 204 | 205 | if (ret) | |
| @@ -214,7 +215,6 @@ static int gpio_exar_probe(struct platform_device *pdev) | |||
| 214 | 215 | exar_gpio->gpio_chip.set = exar_set_value; | |
| 215 | 216 | exar_gpio->gpio_chip.base = -1; | |
| 216 | 217 | exar_gpio->gpio_chip.ngpio = ngpios; | |
| 217 | - | exar_gpio->index = index; | |
| 218 | 218 | exar_gpio->first_pin = first_pin; | |
| 219 | 219 | ||
| 220 | 220 | ret = devm_gpiochip_add_data(dev, &exar_gpio->gpio_chip, exar_gpio); | |
modified drivers/gpio/gpio-mpsse.c
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | #include <linux/cleanup.h> | |
| 11 | 11 | #include <linux/gpio/driver.h> | |
| 12 | 12 | #include <linux/mutex.h> | |
| 13 | + | #include <linux/rcupdate.h> | |
| 13 | 14 | #include <linux/spinlock.h> | |
| 14 | 15 | #include <linux/usb.h> | |
| 15 | 16 | ||
| @@ -24,6 +25,7 @@ struct mpsse_priv { | |||
| 24 | 25 | raw_spinlock_t irq_spin; /* protects worker list */ | |
| 25 | 26 | atomic_t irq_type[16]; /* pin -> edge detection type */ | |
| 26 | 27 | atomic_t irq_enabled; | |
| 28 | + | atomic_t dying; /* no new workers after disconnect */ | |
| 27 | 29 | int id; | |
| 28 | 30 | ||
| 29 | 31 | u8 gpio_outputs[2]; /* Output states for GPIOs [L, H] */ | |
| @@ -46,6 +48,7 @@ struct mpsse_worker { | |||
| 46 | 48 | atomic_t cancelled; | |
| 47 | 49 | struct list_head list; /* linked list */ | |
| 48 | 50 | struct list_head destroy; /* teardown linked list */ | |
| 51 | + | struct rcu_head rcu; /* deferred free for dying path */ | |
| 49 | 52 | }; | |
| 50 | 53 | ||
| 51 | 54 | struct bulk_desc { | |
| @@ -525,10 +528,24 @@ static void gpio_mpsse_irq_enable(struct irq_data *irqd) | |||
| 525 | 528 | worker->priv = priv; | |
| 526 | 529 | INIT_LIST_HEAD(&worker->list); | |
| 527 | 530 | INIT_WORK(&worker->work, gpio_mpsse_poll); | |
| 528 | - | schedule_work(&worker->work); | |
| 529 | 531 | ||
| 530 | - | scoped_guard(raw_spinlock_irqsave, &priv->irq_spin) | |
| 532 | + | scoped_guard(raw_spinlock_irqsave, &priv->irq_spin) { | |
| 533 | + | if (atomic_read(&priv->dying)) { | |
| 534 | + | /* | |
| 535 | + | * Cannot kfree() here: this callback | |
| 536 | + | * runs with the IRQ descriptor's raw | |
| 537 | + | * spinlock held and kfree() may sleep | |
| 538 | + | * on PREEMPT_RT. The worker is not | |
| 539 | + | * yet published, so the deferred free | |
| 540 | + | * is unobservable. | |
| 541 | + | */ | |
| 542 | + | kfree_rcu(worker, rcu); | |
| 543 | + | return; | |
| 544 | + | } | |
| 545 | + | ||
| 531 | 546 | list_add(&worker->list, &priv->workers); | |
| 547 | + | schedule_work(&worker->work); | |
| 548 | + | } | |
| 532 | 549 | } | |
| 533 | 550 | } | |
| 534 | 551 | ||
| @@ -704,6 +721,9 @@ static void gpio_mpsse_disconnect(struct usb_interface *intf) | |||
| 704 | 721 | { | |
| 705 | 722 | struct mpsse_priv *priv = usb_get_intfdata(intf); | |
| 706 | 723 | ||
| 724 | + | scoped_guard(raw_spinlock_irqsave, &priv->irq_spin) | |
| 725 | + | atomic_set(&priv->dying, 1); | |
| 726 | + | ||
| 707 | 727 | /* | |
| 708 | 728 | * Lock prevents double-free of worker from here and the teardown | |
| 709 | 729 | * step at the beginning of gpio_mpsse_poll | |
modified drivers/gpio/gpio-xilinx.c
| @@ -271,14 +271,7 @@ static void xgpio_save_regs(struct xgpio_instance *chip) | |||
| 271 | 271 | ||
| 272 | 272 | static int xgpio_request(struct gpio_chip *chip, unsigned int offset) | |
| 273 | 273 | { | |
| 274 | - | int ret; | |
| 275 | - | ||
| 276 | - | ret = pm_runtime_get_sync(chip->parent); | |
| 277 | - | /* | |
| 278 | - | * If the device is already active pm_runtime_get() will return 1 on | |
| 279 | - | * success, but gpio_request still needs to return 0. | |
| 280 | - | */ | |
| 281 | - | return ret < 0 ? ret : 0; | |
| 274 | + | return pm_runtime_resume_and_get(chip->parent); | |
| 282 | 275 | } | |
| 283 | 276 | ||
| 284 | 277 | static void xgpio_free(struct gpio_chip *chip, unsigned int offset) | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
| @@ -318,7 +318,7 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 318 | 318 | r = device_for_each_child(adev->acp.parent, &adev->acp.acp_genpd->gpd, | |
| 319 | 319 | acp_genpd_add_device); | |
| 320 | 320 | if (r) | |
| 321 | - | goto failure; | |
| 321 | + | goto failure_remove_mfd; | |
| 322 | 322 | break; | |
| 323 | 323 | } | |
| 324 | 324 | default: | |
| @@ -443,7 +443,7 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 443 | 443 | r = device_for_each_child(adev->acp.parent, &adev->acp.acp_genpd->gpd, | |
| 444 | 444 | acp_genpd_add_device); | |
| 445 | 445 | if (r) | |
| 446 | - | goto failure; | |
| 446 | + | goto failure_remove_mfd; | |
| 447 | 447 | } | |
| 448 | 448 | ||
| 449 | 449 | /* Assert Soft reset of ACP */ | |
| @@ -461,7 +461,7 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 461 | 461 | if (--count == 0) { | |
| 462 | 462 | dev_err(&adev->pdev->dev, "Failed to reset ACP\n"); | |
| 463 | 463 | r = -ETIMEDOUT; | |
| 464 | - | goto failure; | |
| 464 | + | goto failure_remove_mfd; | |
| 465 | 465 | } | |
| 466 | 466 | udelay(100); | |
| 467 | 467 | } | |
| @@ -479,7 +479,7 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 479 | 479 | if (--count == 0) { | |
| 480 | 480 | dev_err(&adev->pdev->dev, "Failed to reset ACP\n"); | |
| 481 | 481 | r = -ETIMEDOUT; | |
| 482 | - | goto failure; | |
| 482 | + | goto failure_remove_mfd; | |
| 483 | 483 | } | |
| 484 | 484 | udelay(100); | |
| 485 | 485 | } | |
| @@ -489,6 +489,11 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 489 | 489 | cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val); | |
| 490 | 490 | return 0; | |
| 491 | 491 | ||
| 492 | + | failure_remove_mfd: | |
| 493 | + | device_for_each_child(adev->acp.parent, NULL, | |
| 494 | + | acp_genpd_remove_device); | |
| 495 | + | mfd_remove_devices(adev->acp.parent); | |
| 496 | + | ||
| 492 | 497 | failure: | |
| 493 | 498 | kfree(adev->acp.i2s_pdata); | |
| 494 | 499 | kfree(adev->acp.acp_res); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
| @@ -598,14 +598,18 @@ int amdgpu_amdkfd_get_dmabuf_info(struct amdgpu_device *adev, int dma_buf_fd, | |||
| 598 | 598 | /* first get metadata_size by buffer = NULL */ | |
| 599 | 599 | r = amdgpu_bo_get_metadata(bo, NULL, 0, | |
| 600 | 600 | metadata_size, NULL); | |
| 601 | + | if (r) | |
| 602 | + | goto out_put; | |
| 601 | 603 | ||
| 602 | 604 | /* user buf_size is bigger than bo metadata_size | |
| 603 | 605 | * allocate a buf at kernel space and copy */ | |
| 604 | 606 | if (*metadata_size <= buffer_size) { | |
| 605 | 607 | *metadata_buffer = kzalloc(*metadata_size, GFP_KERNEL); | |
| 606 | 608 | ||
| 607 | - | if (!*metadata_buffer) | |
| 608 | - | return -ENOMEM; | |
| 609 | + | if (!*metadata_buffer) { | |
| 610 | + | r = -ENOMEM; | |
| 611 | + | goto out_put; | |
| 612 | + | } | |
| 609 | 613 | ||
| 610 | 614 | r = amdgpu_bo_get_metadata(bo, *metadata_buffer, *metadata_size, | |
| 611 | 615 | NULL, &metadata_flags); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
| @@ -121,6 +121,20 @@ static int amdgpu_debugfs_process_reg_op(bool read, struct file *f, | |||
| 121 | 121 | ||
| 122 | 122 | *pos &= (1UL << 22) - 1; | |
| 123 | 123 | ||
| 124 | + | if (size > PAGE_SIZE) | |
| 125 | + | return -EINVAL; | |
| 126 | + | ||
| 127 | + | /* | |
| 128 | + | * Access the user buffer only while none of the locks below are held: | |
| 129 | + | * a fault takes mmap_lock, and grbm_idx_mutex and srbm_mutex nest | |
| 130 | + | * inside it. | |
| 131 | + | */ | |
| 132 | + | u32 *data __free(kfree) = kmalloc(size, GFP_KERNEL); | |
| 133 | + | if (!data) | |
| 134 | + | return -ENOMEM; | |
| 135 | + | if (!read && copy_from_user(data, buf, size)) | |
| 136 | + | return -EFAULT; | |
| 137 | + | ||
| 124 | 138 | r = pm_runtime_get_sync(adev_to_drm(adev)->dev); | |
| 125 | 139 | if (r < 0) { | |
| 126 | 140 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| @@ -152,28 +166,16 @@ static int amdgpu_debugfs_process_reg_op(bool read, struct file *f, | |||
| 152 | 166 | mutex_lock(&adev->pm.mutex); | |
| 153 | 167 | ||
| 154 | 168 | while (size) { | |
| 155 | - | uint32_t value; | |
| 156 | - | ||
| 157 | - | if (read) { | |
| 158 | - | value = RREG32(*pos >> 2); | |
| 159 | - | r = put_user(value, (uint32_t *)buf); | |
| 160 | - | } else { | |
| 161 | - | r = get_user(value, (uint32_t *)buf); | |
| 162 | - | if (!r) | |
| 163 | - | amdgpu_mm_wreg_mmio_rlc(adev, *pos >> 2, value, 0); | |
| 164 | - | } | |
| 165 | - | if (r) { | |
| 166 | - | result = r; | |
| 167 | - | goto end; | |
| 168 | - | } | |
| 169 | + | if (read) | |
| 170 | + | data[result >> 2] = RREG32(*pos >> 2); | |
| 171 | + | else | |
| 172 | + | amdgpu_mm_wreg_mmio_rlc(adev, *pos >> 2, data[result >> 2], 0); | |
| 169 | 173 | ||
| 170 | 174 | result += 4; | |
| 171 | - | buf += 4; | |
| 172 | 175 | *pos += 4; | |
| 173 | 176 | size -= 4; | |
| 174 | 177 | } | |
| 175 | 178 | ||
| 176 | - | end: | |
| 177 | 179 | if (use_bank) { | |
| 178 | 180 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff, 0); | |
| 179 | 181 | mutex_unlock(&adev->grbm_idx_mutex); | |
| @@ -188,6 +190,10 @@ end: | |||
| 188 | 190 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| 189 | 191 | ||
| 190 | 192 | amdgpu_virt_disable_access_debugfs(adev); | |
| 193 | + | ||
| 194 | + | if (read && copy_to_user(buf, data, result)) | |
| 195 | + | return -EFAULT; | |
| 196 | + | ||
| 191 | 197 | return result; | |
| 192 | 198 | } | |
| 193 | 199 | ||
| @@ -238,11 +244,24 @@ static ssize_t amdgpu_debugfs_regs2_op(struct file *f, char __user *buf, u32 off | |||
| 238 | 244 | struct amdgpu_device *adev = rd->adev; | |
| 239 | 245 | ssize_t result = 0; | |
| 240 | 246 | int r; | |
| 241 | - | uint32_t value; | |
| 242 | 247 | ||
| 243 | 248 | if (size & 0x3 || offset & 0x3) | |
| 244 | 249 | return -EINVAL; | |
| 245 | 250 | ||
| 251 | + | if (size > PAGE_SIZE) | |
| 252 | + | return -EINVAL; | |
| 253 | + | ||
| 254 | + | /* | |
| 255 | + | * Access the user buffer only while none of the locks below are held: | |
| 256 | + | * a fault takes mmap_lock, and grbm_idx_mutex and srbm_mutex nest | |
| 257 | + | * inside it. | |
| 258 | + | */ | |
| 259 | + | u32 *data __free(kfree) = kmalloc(size, GFP_KERNEL); | |
| 260 | + | if (!data) | |
| 261 | + | return -ENOMEM; | |
| 262 | + | if (write_en && copy_from_user(data, buf, size)) | |
| 263 | + | return -EFAULT; | |
| 264 | + | ||
| 246 | 265 | r = pm_runtime_get_sync(adev_to_drm(adev)->dev); | |
| 247 | 266 | if (r < 0) { | |
| 248 | 267 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| @@ -281,24 +300,16 @@ static ssize_t amdgpu_debugfs_regs2_op(struct file *f, char __user *buf, u32 off | |||
| 281 | 300 | mutex_lock(&adev->pm.mutex); | |
| 282 | 301 | ||
| 283 | 302 | while (size) { | |
| 284 | - | if (!write_en) { | |
| 285 | - | value = RREG32(offset >> 2); | |
| 286 | - | r = put_user(value, (uint32_t *)buf); | |
| 287 | - | } else { | |
| 288 | - | r = get_user(value, (uint32_t *)buf); | |
| 289 | - | if (!r) | |
| 290 | - | amdgpu_mm_wreg_mmio_rlc(adev, offset >> 2, value, rd->id.xcc_id); | |
| 291 | - | } | |
| 292 | - | if (r) { | |
| 293 | - | result = r; | |
| 294 | - | goto end; | |
| 295 | - | } | |
| 303 | + | if (!write_en) | |
| 304 | + | data[result >> 2] = RREG32(offset >> 2); | |
| 305 | + | else | |
| 306 | + | amdgpu_mm_wreg_mmio_rlc(adev, offset >> 2, data[result >> 2], | |
| 307 | + | rd->id.xcc_id); | |
| 296 | 308 | offset += 4; | |
| 297 | 309 | size -= 4; | |
| 298 | 310 | result += 4; | |
| 299 | - | buf += 4; | |
| 300 | 311 | } | |
| 301 | - | end: | |
| 312 | + | ||
| 302 | 313 | if (rd->id.use_grbm) { | |
| 303 | 314 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff, rd->id.xcc_id); | |
| 304 | 315 | mutex_unlock(&adev->grbm_idx_mutex); | |
| @@ -317,6 +328,10 @@ end: | |||
| 317 | 328 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| 318 | 329 | ||
| 319 | 330 | amdgpu_virt_disable_access_debugfs(adev); | |
| 331 | + | ||
| 332 | + | if (!write_en && copy_to_user(buf, data, result)) | |
| 333 | + | return -EFAULT; | |
| 334 | + | ||
| 320 | 335 | return result; | |
| 321 | 336 | } | |
| 322 | 337 | ||
modified drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
| @@ -1325,6 +1325,8 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev, | |||
| 1325 | 1325 | ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset; | |
| 1326 | 1326 | res = kobject_add(&ip_hw_instance->kobj, NULL, | |
| 1327 | 1327 | "%d", ip_hw_instance->num_instance); | |
| 1328 | + | if (res) | |
| 1329 | + | kobject_put(&ip_hw_instance->kobj); | |
| 1328 | 1330 | next_ip: | |
| 1329 | 1331 | if (reg_base_64) | |
| 1330 | 1332 | ip_offset += struct_size(ip, base_address_64, | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
| @@ -2664,6 +2664,14 @@ static int amdgpu_pmops_suspend_noirq(struct device *dev) | |||
| 2664 | 2664 | struct amdgpu_device *adev = drm_to_adev(drm_dev); | |
| 2665 | 2665 | int r; | |
| 2666 | 2666 | ||
| 2667 | + | /* | |
| 2668 | + | * A GPU parked by vga_switcheroo has no power and no PCIe link, so the | |
| 2669 | + | * ASIC reset below would fail and abort the whole noirq suspend phase. | |
| 2670 | + | * Bail out like amdgpu_device_prepare/suspend/resume() already do. | |
| 2671 | + | */ | |
| 2672 | + | if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) | |
| 2673 | + | return 0; | |
| 2674 | + | ||
| 2667 | 2675 | if (amdgpu_acpi_should_gpu_reset(adev)) { | |
| 2668 | 2676 | amdgpu_device_lock_reset_domain(adev->reset_domain); | |
| 2669 | 2677 | r = amdgpu_asic_reset(adev); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
| @@ -724,8 +724,14 @@ void amdgpu_ring_set_fence_errors_and_reemit(struct amdgpu_ring *ring, | |||
| 724 | 724 | bool is_guilty_fence; | |
| 725 | 725 | bool is_guilty_context; | |
| 726 | 726 | ||
| 727 | - | last_seq = amdgpu_fence_read(ring) & ring->fence_drv.num_fences_mask; | |
| 728 | - | seq = ring->fence_drv.sync_seq & ring->fence_drv.num_fences_mask; | |
| 727 | + | last_seq = amdgpu_fence_read(ring); | |
| 728 | + | seq = ring->fence_drv.sync_seq; | |
| 729 | + | ||
| 730 | + | /* Hardware completion can precede the interrupt which signals fences. */ | |
| 731 | + | if (last_seq == seq) { | |
| 732 | + | amdgpu_fence_process(ring); | |
| 733 | + | return; | |
| 734 | + | } | |
| 729 | 735 | ||
| 730 | 736 | /* If there is nothing to reemit, return early and set an error on the fence | |
| 731 | 737 | * if applicable. If all of the fences are siganlled, this will be a nop. | |
| @@ -733,7 +739,9 @@ void amdgpu_ring_set_fence_errors_and_reemit(struct amdgpu_ring *ring, | |||
| 733 | 739 | * we are skipping it on purpose. | |
| 734 | 740 | */ | |
| 735 | 741 | if (!ring->ring_backup_entries_to_copy) { | |
| 736 | - | amdgpu_fence_driver_force_completion(ring, &guilty_fence->base); | |
| 742 | + | if (guilty_fence) | |
| 743 | + | amdgpu_fence_driver_force_completion(ring, | |
| 744 | + | &guilty_fence->base); | |
| 737 | 745 | return; | |
| 738 | 746 | } | |
| 739 | 747 | ring->reemit = true; | |
| @@ -741,9 +749,8 @@ void amdgpu_ring_set_fence_errors_and_reemit(struct amdgpu_ring *ring, | |||
| 741 | 749 | spin_lock_irqsave(&ring->fence_drv.lock, flags); | |
| 742 | 750 | do { | |
| 743 | 751 | last_seq++; | |
| 744 | - | last_seq &= ring->fence_drv.num_fences_mask; | |
| 745 | 752 | ||
| 746 | - | ptr = &ring->fence_drv.fences[last_seq]; | |
| 753 | + | ptr = &ring->fence_drv.fences[last_seq & ring->fence_drv.num_fences_mask]; | |
| 747 | 754 | rcu_read_lock(); | |
| 748 | 755 | unprocessed = rcu_dereference(*ptr); | |
| 749 | 756 | ||
| @@ -800,26 +807,24 @@ void amdgpu_ring_backup_unprocessed_commands(struct amdgpu_ring *ring, | |||
| 800 | 807 | struct amdgpu_fence *fence; | |
| 801 | 808 | u32 seq, last_seq; | |
| 802 | 809 | ||
| 803 | - | last_seq = amdgpu_fence_read(ring) & ring->fence_drv.num_fences_mask; | |
| 804 | - | seq = ring->fence_drv.sync_seq & ring->fence_drv.num_fences_mask; | |
| 810 | + | last_seq = amdgpu_fence_read(ring); | |
| 811 | + | seq = ring->fence_drv.sync_seq; | |
| 805 | 812 | ring->ring_backup_entries_to_copy = 0; | |
| 806 | 813 | ||
| 807 | - | /* if we've already seen this fence, return early. | |
| 808 | - | * ring->ring_backup_entries_to_copy is set to 0 so | |
| 809 | - | * the reemit helper will return early as well to | |
| 810 | - | * avoid getting stuck in a reemit loop. | |
| 814 | + | /* | |
| 815 | + | * Avoid replay loops for a repeated guilty fence. NULL identifies a | |
| 816 | + | * collateral ring, whose pending commands still need backup. | |
| 811 | 817 | */ | |
| 812 | - | if (ring->guilty_fence == guilty_fence) { | |
| 818 | + | if (guilty_fence && ring->guilty_fence == guilty_fence) { | |
| 813 | 819 | ring->guilty_fence = NULL; | |
| 814 | 820 | return; | |
| 815 | 821 | } | |
| 816 | 822 | ring->guilty_fence = guilty_fence; | |
| 817 | 823 | ||
| 818 | - | do { | |
| 824 | + | while (last_seq != seq) { | |
| 819 | 825 | last_seq++; | |
| 820 | - | last_seq &= ring->fence_drv.num_fences_mask; | |
| 821 | 826 | ||
| 822 | - | ptr = &ring->fence_drv.fences[last_seq]; | |
| 827 | + | ptr = &ring->fence_drv.fences[last_seq & ring->fence_drv.num_fences_mask]; | |
| 823 | 828 | rcu_read_lock(); | |
| 824 | 829 | unprocessed = rcu_dereference(*ptr); | |
| 825 | 830 | ||
| @@ -829,7 +834,7 @@ void amdgpu_ring_backup_unprocessed_commands(struct amdgpu_ring *ring, | |||
| 829 | 834 | amdgpu_ring_backup_unprocessed_command(ring, fence); | |
| 830 | 835 | } | |
| 831 | 836 | rcu_read_unlock(); | |
| 832 | - | } while (last_seq != seq); | |
| 837 | + | } | |
| 833 | 838 | } | |
| 834 | 839 | ||
| 835 | 840 | struct amdgpu_fence * | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
| @@ -1080,20 +1080,17 @@ void amdgpu_gmc_init_vga_resv_regions(struct amdgpu_device *adev) | |||
| 1080 | 1080 | case CHIP_RENOIR: | |
| 1081 | 1081 | adev->mman.keep_stolen_vga_memory = true; | |
| 1082 | 1082 | break; | |
| 1083 | - | case CHIP_POLARIS10: | |
| 1084 | - | case CHIP_POLARIS11: | |
| 1085 | - | case CHIP_POLARIS12: | |
| 1086 | - | /* MacBookPros with switchable graphics put VRAM at 0 when | |
| 1087 | - | * the iGPU is enabled which results in cursor issues if | |
| 1088 | - | * the cursor ends up at 0. Reserve vram at 0 in that case. | |
| 1089 | - | */ | |
| 1090 | - | if (adev->gmc.vram_start == 0) | |
| 1091 | - | adev->mman.keep_stolen_vga_memory = true; | |
| 1092 | - | break; | |
| 1093 | 1083 | default: | |
| 1094 | 1084 | adev->mman.keep_stolen_vga_memory = false; | |
| 1095 | 1085 | break; | |
| 1096 | 1086 | } | |
| 1087 | + | /* MacBookPros with switchable graphics put VRAM at 0 when | |
| 1088 | + | * the iGPU is enabled which results in cursor issues if | |
| 1089 | + | * the cursor ends up at 0. Reserve vram at 0 in that case. | |
| 1090 | + | */ | |
| 1091 | + | if ((adev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) && | |
| 1092 | + | (adev->gmc.vram_start == 0)) | |
| 1093 | + | adev->mman.keep_stolen_vga_memory = true; | |
| 1097 | 1094 | ||
| 1098 | 1095 | if (amdgpu_sriov_vf(adev) || | |
| 1099 | 1096 | !amdgpu_device_has_display_hardware(adev)) { | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
| @@ -30,6 +30,7 @@ | |||
| 30 | 30 | #include <drm/amdgpu_drm.h> | |
| 31 | 31 | #include <drm/drm_drv.h> | |
| 32 | 32 | #include <drm/drm_fb_helper.h> | |
| 33 | + | #include <drm/drm_vblank.h> | |
| 33 | 34 | #include "amdgpu_uvd.h" | |
| 34 | 35 | #include "amdgpu_vce.h" | |
| 35 | 36 | #include "atom.h" | |
| @@ -1660,6 +1661,9 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_crtc *crtc) | |||
| 1660 | 1661 | DRM_ERROR("Invalid crtc %u\n", pipe); | |
| 1661 | 1662 | return -EINVAL; | |
| 1662 | 1663 | } | |
| 1664 | + | if (!down_read_trylock(&adev->reset_domain->sem)) | |
| 1665 | + | return drm_crtc_vblank_count(crtc); | |
| 1666 | + | ||
| 1663 | 1667 | ||
| 1664 | 1668 | /* The hw increments its frame counter at start of vsync, not at start | |
| 1665 | 1669 | * of vblank, as is required by DRM core vblank counter handling. | |
| @@ -1705,6 +1709,7 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_crtc *crtc) | |||
| 1705 | 1709 | DRM_DEBUG_VBL("NULL mode info! Returned count may be wrong.\n"); | |
| 1706 | 1710 | } | |
| 1707 | 1711 | ||
| 1712 | + | up_read(&adev->reset_domain->sem); | |
| 1708 | 1713 | return count; | |
| 1709 | 1714 | } | |
| 1710 | 1715 | ||
modified drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
| @@ -2342,7 +2342,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) | |||
| 2342 | 2342 | void amdgpu_ttm_enable_buffer_funcs(struct amdgpu_device *adev) | |
| 2343 | 2343 | { | |
| 2344 | 2344 | struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); | |
| 2345 | - | u32 num_clear_entities, num_move_entities; | |
| 2345 | + | u32 num_clear_entities, num_move_entities, sdma_ip_version; | |
| 2346 | 2346 | int r, i, j; | |
| 2347 | 2347 | ||
| 2348 | 2348 | if (!adev->mman.initialized || amdgpu_in_reset(adev) || | |
| @@ -2367,6 +2367,12 @@ void amdgpu_ttm_enable_buffer_funcs(struct amdgpu_device *adev) | |||
| 2367 | 2367 | ||
| 2368 | 2368 | num_clear_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES); | |
| 2369 | 2369 | num_move_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES); | |
| 2370 | + | /* TODO: workaround for DCC corruption when moving BOs from multiple queues at | |
| 2371 | + | * the same time: use a single queue until the root cause is identified and fixed. | |
| 2372 | + | */ | |
| 2373 | + | sdma_ip_version = amdgpu_ip_version(adev, SDMA0_HWIP, 0); | |
| 2374 | + | if (sdma_ip_version == IP_VERSION(7, 0, 0) || sdma_ip_version == IP_VERSION(7, 0, 1)) | |
| 2375 | + | num_move_entities = 1; | |
| 2370 | 2376 | ||
| 2371 | 2377 | adev->mman.clear_entities = kzalloc_objs(struct amdgpu_ttm_buffer_entity, | |
| 2372 | 2378 | num_clear_entities); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
| @@ -472,6 +472,7 @@ amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr, | |||
| 472 | 472 | u64 doorbell_index; | |
| 473 | 473 | struct drm_gem_object *gobj; | |
| 474 | 474 | struct amdgpu_userq_obj *db_obj = db_info->db_obj; | |
| 475 | + | struct amdgpu_bo *abo; | |
| 475 | 476 | int r, db_size; | |
| 476 | 477 | ||
| 477 | 478 | gobj = drm_gem_object_lookup(filp, db_info->doorbell_handle); | |
| @@ -480,7 +481,17 @@ amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr, | |||
| 480 | 481 | return -EINVAL; | |
| 481 | 482 | } | |
| 482 | 483 | ||
| 483 | - | db_obj->obj = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj)); | |
| 484 | + | /* | |
| 485 | + | * Pinning a regular BO into the doorbell domain would discard its | |
| 486 | + | * contents, possibly those of a buffer shared by another client. | |
| 487 | + | */ | |
| 488 | + | abo = gem_to_amdgpu_bo(gobj); | |
| 489 | + | if (!(abo->preferred_domains & AMDGPU_GEM_DOMAIN_DOORBELL)) { | |
| 490 | + | drm_gem_object_put(gobj); | |
| 491 | + | return -EINVAL; | |
| 492 | + | } | |
| 493 | + | ||
| 494 | + | db_obj->obj = amdgpu_bo_ref(abo); | |
| 484 | 495 | drm_gem_object_put(gobj); | |
| 485 | 496 | ||
| 486 | 497 | r = amdgpu_bo_reserve(db_obj->obj, true); | |
modified drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
| @@ -3808,6 +3808,7 @@ static int gfx_v11_0_cp_gfx_resume(struct amdgpu_device *adev) | |||
| 3808 | 3808 | rb_bufsz = order_base_2(ring->ring_size / 8); | |
| 3809 | 3809 | tmp = REG_SET_FIELD(0, CP_RB0_CNTL, RB_BUFSZ, rb_bufsz); | |
| 3810 | 3810 | tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, RB_BLKSZ, rb_bufsz - 2); | |
| 3811 | + | tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, KMD_QUEUE, 1); | |
| 3811 | 3812 | WREG32_SOC15(GC, 0, regCP_RB0_CNTL, tmp); | |
| 3812 | 3813 | ||
| 3813 | 3814 | /* Initialize the ring buffer's write pointers */ | |
| @@ -4216,6 +4217,7 @@ static int gfx_v11_0_gfx_mqd_init(struct amdgpu_device *adev, void *m, | |||
| 4216 | 4217 | tmp = regCP_GFX_HQD_CNTL_DEFAULT; | |
| 4217 | 4218 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_BUFSZ, rb_bufsz); | |
| 4218 | 4219 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_BLKSZ, rb_bufsz - 2); | |
| 4220 | + | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, KMD_QUEUE, prop->kernel_queue); | |
| 4219 | 4221 | #ifdef __BIG_ENDIAN | |
| 4220 | 4222 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, BUF_SWAP, 1); | |
| 4221 | 4223 | #endif | |
modified drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
| @@ -2767,6 +2767,7 @@ static int gfx_v12_0_cp_gfx_resume(struct amdgpu_device *adev) | |||
| 2767 | 2767 | rb_bufsz = order_base_2(ring->ring_size / 8); | |
| 2768 | 2768 | tmp = REG_SET_FIELD(0, CP_RB0_CNTL, RB_BUFSZ, rb_bufsz); | |
| 2769 | 2769 | tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, RB_BLKSZ, rb_bufsz - 2); | |
| 2770 | + | tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, KMD_QUEUE, 1); | |
| 2770 | 2771 | WREG32_SOC15(GC, 0, regCP_RB0_CNTL, tmp); | |
| 2771 | 2772 | ||
| 2772 | 2773 | /* Initialize the ring buffer's write pointers */ | |
| @@ -3059,6 +3060,7 @@ static int gfx_v12_0_gfx_mqd_init(struct amdgpu_device *adev, void *m, | |||
| 3059 | 3060 | tmp = regCP_GFX_HQD_CNTL_DEFAULT; | |
| 3060 | 3061 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_BUFSZ, rb_bufsz); | |
| 3061 | 3062 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_BLKSZ, rb_bufsz - 2); | |
| 3063 | + | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, KMD_QUEUE, prop->kernel_queue); | |
| 3062 | 3064 | #ifdef __BIG_ENDIAN | |
| 3063 | 3065 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, BUF_SWAP, 1); | |
| 3064 | 3066 | #endif | |
modified drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
| @@ -322,6 +322,14 @@ static const u32 verde_rlc_save_restore_register_list[] = | |||
| 322 | 322 | 0x00000000 | |
| 323 | 323 | }; | |
| 324 | 324 | ||
| 325 | + | static void gfx_v6_0_free_microcode(struct amdgpu_device *adev) | |
| 326 | + | { | |
| 327 | + | amdgpu_ucode_release(&adev->gfx.pfp_fw); | |
| 328 | + | amdgpu_ucode_release(&adev->gfx.me_fw); | |
| 329 | + | amdgpu_ucode_release(&adev->gfx.ce_fw); | |
| 330 | + | amdgpu_ucode_release(&adev->gfx.rlc_fw); | |
| 331 | + | } | |
| 332 | + | ||
| 325 | 333 | static int gfx_v6_0_init_microcode(struct amdgpu_device *adev) | |
| 326 | 334 | { | |
| 327 | 335 | const char *chip_name; | |
| @@ -3249,6 +3257,7 @@ static int gfx_v6_0_sw_fini(struct amdgpu_ip_block *ip_block) | |||
| 3249 | 3257 | amdgpu_ring_fini(&adev->gfx.compute_ring[i]); | |
| 3250 | 3258 | ||
| 3251 | 3259 | amdgpu_gfx_rlc_fini(adev); | |
| 3260 | + | gfx_v6_0_free_microcode(adev); | |
| 3252 | 3261 | ||
| 3253 | 3262 | return 0; | |
| 3254 | 3263 | } | |
modified drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
| @@ -327,7 +327,7 @@ static void gmc_v12_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, | |||
| 327 | 327 | return; | |
| 328 | 328 | } | |
| 329 | 329 | ||
| 330 | - | gmc_v12_0_flush_vm_hub(adev, vmid, vmhub, 0); | |
| 330 | + | gmc_v12_0_flush_vm_hub(adev, vmid, vmhub, flush_type); | |
| 331 | 331 | return; | |
| 332 | 332 | } | |
| 333 | 333 | ||
modified drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
| @@ -389,7 +389,7 @@ static void gmc_v12_1_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, | |||
| 389 | 389 | return; | |
| 390 | 390 | } | |
| 391 | 391 | ||
| 392 | - | gmc_v12_1_flush_vm_hub(adev, vmid, vmhub, 0); | |
| 392 | + | gmc_v12_1_flush_vm_hub(adev, vmid, vmhub, flush_type); | |
| 393 | 393 | return; | |
| 394 | 394 | } | |
| 395 | 395 | ||
modified drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
| @@ -361,8 +361,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, | |||
| 361 | 361 | ||
| 362 | 362 | compute_mqd = memdup_user(u64_to_user_ptr(mqd_user->mqd), mqd_user->mqd_size); | |
| 363 | 363 | if (IS_ERR(compute_mqd)) { | |
| 364 | - | DRM_ERROR("Failed to read user MQD\n"); | |
| 365 | - | r = -ENOMEM; | |
| 364 | + | r = PTR_ERR(compute_mqd); | |
| 366 | 365 | goto free_mqd; | |
| 367 | 366 | } | |
| 368 | 367 | ||
| @@ -406,8 +405,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, | |||
| 406 | 405 | ||
| 407 | 406 | mqd_gfx_v11 = memdup_user(u64_to_user_ptr(mqd_user->mqd), mqd_user->mqd_size); | |
| 408 | 407 | if (IS_ERR(mqd_gfx_v11)) { | |
| 409 | - | DRM_ERROR("Failed to read user MQD\n"); | |
| 410 | - | r = -ENOMEM; | |
| 408 | + | r = PTR_ERR(mqd_gfx_v11); | |
| 411 | 409 | goto free_mqd; | |
| 412 | 410 | } | |
| 413 | 411 | ||
| @@ -451,8 +449,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, | |||
| 451 | 449 | ||
| 452 | 450 | mqd_sdma_v11 = memdup_user(u64_to_user_ptr(mqd_user->mqd), mqd_user->mqd_size); | |
| 453 | 451 | if (IS_ERR(mqd_sdma_v11)) { | |
| 454 | - | DRM_ERROR("Failed to read sdma user MQD\n"); | |
| 455 | - | r = -ENOMEM; | |
| 452 | + | r = PTR_ERR(mqd_sdma_v11); | |
| 456 | 453 | goto free_mqd; | |
| 457 | 454 | } | |
| 458 | 455 | ||
modified drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c
| @@ -1339,10 +1339,6 @@ static int sdma_v7_1_sw_init(struct amdgpu_ip_block *ip_block) | |||
| 1339 | 1339 | else | |
| 1340 | 1340 | DRM_ERROR("Failed to allocated memory for SDMA IP Dump\n"); | |
| 1341 | 1341 | ||
| 1342 | - | #ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ | |
| 1343 | - | adev->userq_funcs[AMDGPU_HW_IP_DMA] = &userq_mes_funcs; | |
| 1344 | - | #endif | |
| 1345 | - | ||
| 1346 | 1342 | return r; | |
| 1347 | 1343 | } | |
| 1348 | 1344 | ||
modified drivers/gpu/drm/amd/amdgpu/vi.c
| @@ -1397,6 +1397,7 @@ struct vi_reset_quirk { | |||
| 1397 | 1397 | static const struct vi_reset_quirk vi_reset_quirks[] = { | |
| 1398 | 1398 | { 0x67ef, PCI_VENDOR_ID_APPLE, 0x0190, 0xe3 }, /* Radeon Pro 555X */ | |
| 1399 | 1399 | { 0x67ef, PCI_VENDOR_ID_APPLE, 0x018f, 0xc2 }, /* Radeon Pro 560X */ | |
| 1400 | + | { 0x67ef, PCI_VENDOR_ID_APPLE, 0x017a, 0xc7 }, /* Radeon Pro 555 */ | |
| 1400 | 1401 | }; | |
| 1401 | 1402 | ||
| 1402 | 1403 | static bool vi_need_reset_on_init(struct amdgpu_device *adev) | |
modified drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
| @@ -572,12 +572,32 @@ static int allocate_doorbell(struct qcm_process_device *qpd, | |||
| 572 | 572 | * we need the physical sdma engine id in order to get the | |
| 573 | 573 | * correct doorbell offset. | |
| 574 | 574 | */ | |
| 575 | - | uint32_t valid_id = idx_offset[qpd->dqm->dev->node_id * | |
| 576 | - | get_num_all_sdma_engines(qpd->dqm) + | |
| 577 | - | q->properties.sdma_engine_id] | |
| 578 | - | + (q->properties.sdma_queue_id & 1) | |
| 579 | - | * KFD_QUEUE_DOORBELL_MIRROR_OFFSET | |
| 580 | - | + (q->properties.sdma_queue_id >> 1); | |
| 575 | + | u32 engine_base = idx_offset[dev->node_id * | |
| 576 | + | get_num_all_sdma_engines(qpd->dqm) + | |
| 577 | + | q->properties.sdma_engine_id]; | |
| 578 | + | u32 valid_id; | |
| 579 | + | ||
| 580 | + | /* | |
| 581 | + | * With the aqua_vanjaram doorbell layout, a shader doorbell | |
| 582 | + | * write whose 32-byte block starts in the previous engine's | |
| 583 | + | * range rings that engine instead. Engine ranges are 10 | |
| 584 | + | * indices apart (sdma_doorbell_range = 20 dwords, halved for | |
| 585 | + | * 8-byte doorbells, in aqua_vanjaram_doorbell_index_init()), | |
| 586 | + | * which puts odd engines 2 indices into a shared block. | |
| 587 | + | * Aligning costs at most 2 indices, and 8 queues per engine use | |
| 588 | + | * only 4 of the 10, so the aligned base stays in range. The | |
| 589 | + | * 512-index mirror offset keeps the alignment. | |
| 590 | + | */ | |
| 591 | + | if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 3) || | |
| 592 | + | KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 4) || | |
| 593 | + | KFD_GC_VERSION(dev) == IP_VERSION(9, 5, 0)) | |
| 594 | + | engine_base = ALIGN(engine_base, | |
| 595 | + | KFD_SDMA_SHADER_DOORBELL_GRANULARITY); | |
| 596 | + | ||
| 597 | + | valid_id = engine_base + | |
| 598 | + | (q->properties.sdma_queue_id & 1) * | |
| 599 | + | KFD_QUEUE_DOORBELL_MIRROR_OFFSET + | |
| 600 | + | (q->properties.sdma_queue_id >> 1); | |
| 581 | 601 | ||
| 582 | 602 | if (restore_id && *restore_id != valid_id) | |
| 583 | 603 | return -EINVAL; | |
modified drivers/gpu/drm/amd/amdkfd/kfd_priv.h
| @@ -133,6 +133,13 @@ | |||
| 133 | 133 | */ | |
| 134 | 134 | #define KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512 | |
| 135 | 135 | ||
| 136 | + | /* | |
| 137 | + | * On GC 9.4.3, 9.4.4 and 9.5.0, doorbell writes issued from shaders are | |
| 138 | + | * routed to an SDMA engine at 32-byte granularity, i.e. 4 indices with the | |
| 139 | + | * 8-byte SDMA doorbells used on SOC15. | |
| 140 | + | */ | |
| 141 | + | #define KFD_SDMA_SHADER_DOORBELL_GRANULARITY 4 | |
| 142 | + | ||
| 136 | 143 | /** | |
| 137 | 144 | * enum kfd_ioctl_flags - KFD ioctl flags | |
| 138 | 145 | * Various flags that can be set in &amdkfd_ioctl_desc.flags to control how | |
modified drivers/gpu/drm/amd/amdkfd/kfd_svm.c
| @@ -1752,12 +1752,15 @@ static int svm_range_validate_and_map(struct mm_struct *mm, | |||
| 1752 | 1752 | } | |
| 1753 | 1753 | ||
| 1754 | 1754 | /* | |
| 1755 | - | * If prange with always mapped flag, update mapping on GPUs with | |
| 1756 | - | * ACCESS attribute | |
| 1755 | + | * If prange with always mapped flag is not mapped or migrated | |
| 1756 | + | * yet, update mapping on GPUs with ACCESS attribute. Don't add | |
| 1757 | + | * them otherwise, ACCESS GPUs may be on different XGMI hives, | |
| 1758 | + | * that would force hmm_range_fault to migrate VRAM back to ram. | |
| 1757 | 1759 | */ | |
| 1758 | - | if (prange->flags & KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED) | |
| 1759 | - | bitmap_or(ctx->bitmap, ctx->bitmap, prange->bitmap_access, | |
| 1760 | - | MAX_GPU_INSTANCE); | |
| 1760 | + | if (bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE) && | |
| 1761 | + | prange->flags & KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED) | |
| 1762 | + | bitmap_copy(ctx->bitmap, prange->bitmap_access, | |
| 1763 | + | MAX_GPU_INSTANCE); | |
| 1761 | 1764 | } else { | |
| 1762 | 1765 | bitmap_or(ctx->bitmap, prange->bitmap_access, | |
| 1763 | 1766 | prange->bitmap_aip, MAX_GPU_INSTANCE); | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
| @@ -426,6 +426,8 @@ static int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm) | |||
| 426 | 426 | init_data[i].use_custom_backlight_caps = false; | |
| 427 | 427 | init_data[i].custom_backlight_caps_config_no = 0; | |
| 428 | 428 | init_data[i].use_linear_backlight_curve = false; | |
| 429 | + | if (amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE) | |
| 430 | + | init_data[i].use_linear_backlight_curve = true; | |
| 429 | 431 | init_data[i].def_varibright_enable = 0; | |
| 430 | 432 | init_data[i].varibright_level = 0; | |
| 431 | 433 | /* | |
| @@ -1582,9 +1584,14 @@ static int dm_suspend(struct amdgpu_ip_block *ip_block) | |||
| 1582 | 1584 | dc_allow_idle_optimizations(adev->dm.dc, false); | |
| 1583 | 1585 | ||
| 1584 | 1586 | dm->cached_dc_state = dc_state_create_copy(dm->dc->current_state); | |
| 1587 | + | if (!dm->cached_dc_state) { | |
| 1588 | + | drm_err(adev_to_drm(adev), | |
| 1589 | + | "Failed to allocate cached DC state during suspend\n"); | |
| 1590 | + | mutex_unlock(&dm->dc_lock); | |
| 1591 | + | return -ENOMEM; | |
| 1592 | + | } | |
| 1585 | 1593 | ||
| 1586 | - | if (dm->cached_dc_state) | |
| 1587 | - | dm_gpureset_toggle_interrupts(adev, dm->cached_dc_state, false); | |
| 1594 | + | dm_gpureset_toggle_interrupts(adev, dm->cached_dc_state, false); | |
| 1588 | 1595 | ||
| 1589 | 1596 | res = amdgpu_dm_commit_zero_streams(dm->dc); | |
| 1590 | 1597 | if (res != DC_OK) { | |
| @@ -3701,6 +3708,13 @@ static void amdgpu_dm_enable_self_refresh(struct amdgpu_display_manager *dm, | |||
| 3701 | 3708 | struct amdgpu_dm_connector *aconn = | |
| 3702 | 3709 | (struct amdgpu_dm_connector *)acrtc_state->stream->dm_stream_context; | |
| 3703 | 3710 | ||
| 3711 | + | if (!acrtc_state->base.async_flip) { | |
| 3712 | + | amdgpu_dm_psr_set_event(dm, acrtc_state->stream, false, | |
| 3713 | + | psr_event_immediate_flip, false); | |
| 3714 | + | amdgpu_dm_replay_set_event(dm, acrtc_state->stream, false, | |
| 3715 | + | replay_event_immediate_flip, false); | |
| 3716 | + | } | |
| 3717 | + | ||
| 3704 | 3718 | /* Decrement skip count when SR is enabled and we're doing fast updates. */ | |
| 3705 | 3719 | if (acrtc_state->update_type == UPDATE_TYPE_FAST && | |
| 3706 | 3720 | (psr->psr_feature_enabled || pr->replay_feature_enabled)) { | |
| @@ -4111,6 +4125,18 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state, | |||
| 4111 | 4125 | spin_unlock_irqrestore(&pcrtc->dev->event_lock, flags); | |
| 4112 | 4126 | } | |
| 4113 | 4127 | mutex_lock(&dm->dc_lock); | |
| 4128 | + | /* | |
| 4129 | + | * Tearing (immediate) flips cannot work with panel self-refresh | |
| 4130 | + | * features. The event is cleared by | |
| 4131 | + | * amdgpu_dm_enable_self_refresh() once async flips stop. | |
| 4132 | + | */ | |
| 4133 | + | if (immediate_flip) { | |
| 4134 | + | dc_exit_ips_for_hw_access(dm->dc); | |
| 4135 | + | amdgpu_dm_psr_set_event(dm, acrtc_state->stream, true, | |
| 4136 | + | psr_event_immediate_flip, true); | |
| 4137 | + | amdgpu_dm_replay_set_event(dm, acrtc_state->stream, true, | |
| 4138 | + | replay_event_immediate_flip, true); | |
| 4139 | + | } | |
| 4114 | 4140 | update_planes_and_stream_adapter(dm->dc, | |
| 4115 | 4141 | acrtc_state->update_type, | |
| 4116 | 4142 | planes_count, | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
| @@ -39,6 +39,7 @@ | |||
| 39 | 39 | #include "modules/inc/mod_power.h" | |
| 40 | 40 | ||
| 41 | 41 | #include <linux/backlight.h> | |
| 42 | + | #include <linux/minmax.h> | |
| 42 | 43 | #include <linux/power_supply.h> | |
| 43 | 44 | #include <drm/drm_edid.h> | |
| 44 | 45 | #include <drm/drm_utils.h> | |
| @@ -118,6 +119,68 @@ static inline u32 scale_fw_to_input(int min, int max, u64 input) | |||
| 118 | 119 | return min + DIV_ROUND_CLOSEST_ULL(input * (max - min), AMDGPU_MAX_BL_LEVEL); | |
| 119 | 120 | } | |
| 120 | 121 | ||
| 122 | + | static u32 backlight_signal_to_luminance(const struct amdgpu_dm_backlight_caps *caps, | |
| 123 | + | u32 signal) | |
| 124 | + | { | |
| 125 | + | u32 lower_signal, upper_signal; | |
| 126 | + | u32 lower_lum, upper_lum; | |
| 127 | + | int i; | |
| 128 | + | ||
| 129 | + | if (!caps->data_points) | |
| 130 | + | return DIV_ROUND_CLOSEST(signal * 100, AMDGPU_MAX_BL_LEVEL); | |
| 131 | + | ||
| 132 | + | if (signal < caps->luminance_data[0].input_signal) { | |
| 133 | + | lower_signal = 0; | |
| 134 | + | lower_lum = 0; | |
| 135 | + | upper_signal = caps->luminance_data[0].input_signal; | |
| 136 | + | upper_lum = caps->luminance_data[0].luminance; | |
| 137 | + | } else if (signal >= | |
| 138 | + | caps->luminance_data[caps->data_points - 1].input_signal) { | |
| 139 | + | lower_signal = caps->luminance_data[caps->data_points - 1].input_signal; | |
| 140 | + | lower_lum = caps->luminance_data[caps->data_points - 1].luminance; | |
| 141 | + | upper_signal = caps->max_input_signal; | |
| 142 | + | upper_lum = 100; | |
| 143 | + | } else { | |
| 144 | + | for (i = 1; | |
| 145 | + | i < caps->data_points && | |
| 146 | + | signal > caps->luminance_data[i].input_signal; | |
| 147 | + | i++) | |
| 148 | + | ; | |
| 149 | + | ||
| 150 | + | lower_signal = caps->luminance_data[i - 1].input_signal; | |
| 151 | + | upper_signal = caps->luminance_data[i].input_signal; | |
| 152 | + | lower_lum = caps->luminance_data[i - 1].luminance; | |
| 153 | + | upper_lum = caps->luminance_data[i].luminance; | |
| 154 | + | } | |
| 155 | + | ||
| 156 | + | if (upper_signal == lower_signal) | |
| 157 | + | return upper_lum; | |
| 158 | + | ||
| 159 | + | return lower_lum + DIV_ROUND_CLOSEST((upper_lum - lower_lum) * | |
| 160 | + | (signal - lower_signal), | |
| 161 | + | upper_signal - lower_signal); | |
| 162 | + | } | |
| 163 | + | ||
| 164 | + | static u32 convert_brightness_to_millipercent(const struct amdgpu_dm_backlight_caps *caps, | |
| 165 | + | u32 user_brightness) | |
| 166 | + | { | |
| 167 | + | unsigned int min, max; | |
| 168 | + | u32 signal, luminance; | |
| 169 | + | ||
| 170 | + | if (!get_brightness_range(caps, &min, &max)) | |
| 171 | + | return DIV_ROUND_CLOSEST_ULL((u64)user_brightness * 100000, | |
| 172 | + | MAX_BACKLIGHT_LEVEL); | |
| 173 | + | ||
| 174 | + | user_brightness = clamp(user_brightness, min, max); | |
| 175 | + | if (amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE) | |
| 176 | + | return DIV_ROUND_CLOSEST_ULL((u64)user_brightness * 100000, max); | |
| 177 | + | ||
| 178 | + | signal = scale_input_to_fw(max, user_brightness); | |
| 179 | + | luminance = backlight_signal_to_luminance(caps, signal); | |
| 180 | + | ||
| 181 | + | return min_t(u32, luminance * 1000, 100000); | |
| 182 | + | } | |
| 183 | + | ||
| 121 | 184 | STATIC_IFN_KUNIT | |
| 122 | 185 | void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps, | |
| 123 | 186 | unsigned int min, unsigned int max, | |
| @@ -260,10 +323,10 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, | |||
| 260 | 323 | struct amdgpu_dm_backlight_caps *caps; | |
| 261 | 324 | struct dc_link *link; | |
| 262 | 325 | u32 brightness = 0; | |
| 326 | + | u32 millipercent = 0; | |
| 263 | 327 | bool rc = false, reallow_idle = false; | |
| 264 | 328 | struct drm_connector *connector; | |
| 265 | 329 | struct dc_stream_state *stream; | |
| 266 | - | unsigned int min, max; | |
| 267 | 330 | ||
| 268 | 331 | list_for_each_entry(connector, &dm->ddev->mode_config.connector_list, head) { | |
| 269 | 332 | struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); | |
| @@ -286,12 +349,21 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, | |||
| 286 | 349 | /* update scratch register */ | |
| 287 | 350 | if (bl_idx == 0) | |
| 288 | 351 | amdgpu_atombios_scratch_regs_set_backlight_level(dm->adev, dm->brightness[bl_idx]); | |
| 289 | - | brightness = convert_brightness_from_user(caps, dm->brightness[bl_idx]); | |
| 352 | + | ||
| 290 | 353 | link = (struct dc_link *)dm->backlight_link[bl_idx]; | |
| 354 | + | stream = dm_find_stream_with_link(dm, link); | |
| 355 | + | if (!stream) | |
| 356 | + | return; | |
| 291 | 357 | ||
| 292 | - | /* Apply brightness quirk */ | |
| 293 | - | if (caps->brightness_mask) | |
| 294 | - | brightness |= caps->brightness_mask; | |
| 358 | + | if (caps->aux_support) { | |
| 359 | + | brightness = convert_brightness_from_user(caps, dm->brightness[bl_idx]); | |
| 360 | + | /* Apply brightness quirk */ | |
| 361 | + | if (caps->brightness_mask) | |
| 362 | + | brightness |= caps->brightness_mask; | |
| 363 | + | } else { | |
| 364 | + | millipercent = convert_brightness_to_millipercent(caps, | |
| 365 | + | user_brightness); | |
| 366 | + | } | |
| 295 | 367 | ||
| 296 | 368 | if (trace_amdgpu_dm_brightness_enabled()) { | |
| 297 | 369 | trace_amdgpu_dm_brightness(__builtin_return_address(0), | |
| @@ -301,10 +373,6 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, | |||
| 301 | 373 | power_supply_is_system_supplied() > 0); | |
| 302 | 374 | } | |
| 303 | 375 | ||
| 304 | - | stream = dm_find_stream_with_link(dm, link); | |
| 305 | - | if (!stream) | |
| 306 | - | return; | |
| 307 | - | ||
| 308 | 376 | mutex_lock(&dm->dc_lock); | |
| 309 | 377 | if (dm->dc->caps.ips_support && dm->dc->ctx->dmub_srv->idle_allowed) { | |
| 310 | 378 | dc_allow_idle_optimizations(dm->dc, false); | |
| @@ -316,10 +384,8 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, | |||
| 316 | 384 | AUX_BL_DEFAULT_TRANSITION_TIME_MS, false, true); | |
| 317 | 385 | } else { | |
| 318 | 386 | /* power module uses millipercent */ | |
| 319 | - | get_brightness_range(caps, &min, &max); | |
| 320 | - | brightness = DIV_ROUND_CLOSEST(brightness * 100, (max - min)) * 1000; | |
| 321 | 387 | rc = mod_power_set_backlight_percent(dm->power_module, stream, | |
| 322 | - | brightness, 0, false); | |
| 388 | + | millipercent, 0, false); | |
| 323 | 389 | } | |
| 324 | 390 | ||
| 325 | 391 | /* | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
| @@ -732,6 +732,24 @@ get_aspect_ratio(const struct drm_display_mode *mode_in) | |||
| 732 | 732 | } | |
| 733 | 733 | EXPORT_IF_KUNIT(get_aspect_ratio); | |
| 734 | 734 | ||
| 735 | + | /* | |
| 736 | + | * CTA-861 5.1: RGB video formats default to limited range except 640x480 (VIC 1). | |
| 737 | + | * With Broadcast RGB left at Automatic follow that default, as i915 does. | |
| 738 | + | */ | |
| 739 | + | static bool rgb_output_is_limited_range(const struct dc_crtc_timing *dc_crtc_timing, | |
| 740 | + | const struct drm_connector_state *connector_state) | |
| 741 | + | { | |
| 742 | + | switch (connector_state->hdmi.broadcast_rgb) { | |
| 743 | + | case DRM_HDMI_BROADCAST_RGB_FULL: | |
| 744 | + | return false; | |
| 745 | + | case DRM_HDMI_BROADCAST_RGB_LIMITED: | |
| 746 | + | return true; | |
| 747 | + | default: | |
| 748 | + | return connector_state->connector->display_info.is_hdmi && | |
| 749 | + | dc_crtc_timing->vic > 1; | |
| 750 | + | } | |
| 751 | + | } | |
| 752 | + | ||
| 735 | 753 | enum dc_color_space | |
| 736 | 754 | amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing, | |
| 737 | 755 | const struct drm_connector_state *connector_state) | |
| @@ -757,7 +775,7 @@ amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing, | |||
| 757 | 775 | case DRM_MODE_COLORIMETRY_BT2020_RGB: | |
| 758 | 776 | case DRM_MODE_COLORIMETRY_BT2020_YCC: | |
| 759 | 777 | if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) { | |
| 760 | - | if (connector_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED) | |
| 778 | + | if (rgb_output_is_limited_range(dc_crtc_timing, connector_state)) | |
| 761 | 779 | color_space = COLOR_SPACE_2020_RGB_LIMITEDRANGE; | |
| 762 | 780 | else | |
| 763 | 781 | color_space = COLOR_SPACE_2020_RGB_FULLRANGE; | |
| @@ -769,7 +787,7 @@ amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing, | |||
| 769 | 787 | default: | |
| 770 | 788 | if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) { | |
| 771 | 789 | color_space = COLOR_SPACE_SRGB; | |
| 772 | - | if (connector_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED) | |
| 790 | + | if (rgb_output_is_limited_range(dc_crtc_timing, connector_state)) | |
| 773 | 791 | color_space = COLOR_SPACE_SRGB_LIMITED; | |
| 774 | 792 | /* | |
| 775 | 793 | * 27030khz is the separation point between HDTV and SDTV | |
| @@ -994,10 +1012,15 @@ decide_crtc_timing_for_drm_display_mode(struct drm_display_mode *drm_mode, | |||
| 994 | 1012 | const struct drm_display_mode *native_mode, | |
| 995 | 1013 | bool scale_enabled) | |
| 996 | 1014 | { | |
| 1015 | + | /* Inserted modes copy the native sync; a sink mode with equal totals may not */ | |
| 997 | 1016 | if (scale_enabled || ( | |
| 998 | 1017 | native_mode->clock == drm_mode->clock && | |
| 999 | 1018 | native_mode->htotal == drm_mode->htotal && | |
| 1000 | - | native_mode->vtotal == drm_mode->vtotal)) { | |
| 1019 | + | native_mode->vtotal == drm_mode->vtotal && | |
| 1020 | + | native_mode->hsync_start == drm_mode->hsync_start && | |
| 1021 | + | native_mode->hsync_end == drm_mode->hsync_end && | |
| 1022 | + | native_mode->vsync_start == drm_mode->vsync_start && | |
| 1023 | + | native_mode->vsync_end == drm_mode->vsync_end)) { | |
| 1001 | 1024 | if (native_mode->crtc_clock) | |
| 1002 | 1025 | copy_crtc_timing_for_drm_display_mode(native_mode, drm_mode); | |
| 1003 | 1026 | } else { | |
| @@ -2256,8 +2279,8 @@ amdgpu_dm_create_validate_stream_for_sink(struct drm_connector *connector, | |||
| 2256 | 2279 | * below gate which of these entries are actually attempted. | |
| 2257 | 2280 | */ | |
| 2258 | 2281 | static const enum dc_pixel_encoding encoding_order[] = { | |
| 2259 | - | PIXEL_ENCODING_YCBCR444, | |
| 2260 | 2282 | PIXEL_ENCODING_RGB, | |
| 2283 | + | PIXEL_ENCODING_YCBCR444, | |
| 2261 | 2284 | PIXEL_ENCODING_YCBCR422, | |
| 2262 | 2285 | PIXEL_ENCODING_YCBCR420, | |
| 2263 | 2286 | }; | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
| @@ -1231,7 +1231,8 @@ static bool get_conv_frl_bw(struct amdgpu_dm_connector *aconnector, | |||
| 1231 | 1231 | unsigned int max_sink_bw_in_kbps = 0; | |
| 1232 | 1232 | unsigned int dsc_max_sink_bw_in_kbps = 0; | |
| 1233 | 1233 | ||
| 1234 | - | if (aconnector->dc_link->dc->caps.dp_hdmi21_pcon_support && | |
| 1234 | + | if (aconnector->dc_sink && | |
| 1235 | + | aconnector->dc_link->dc->caps.dp_hdmi21_pcon_support && | |
| 1235 | 1236 | aconnector->mst_downstream_port_caps.bytes.byte0.bits.DWN_STRM_PORTX_TYPE == DOWN_STREAM_DETAILED_HDMI) { | |
| 1236 | 1237 | max_conv_bw_in_kbps = dc_link_bw_kbps_from_raw_frl_link_rate_data( | |
| 1237 | 1238 | aconnector->dc_link->dc, | |
| @@ -1996,6 +1997,9 @@ enum dc_status dm_dp_mst_is_port_support_mode( | |||
| 1996 | 1997 | struct dc_dsc_config_options dsc_options = {0}; | |
| 1997 | 1998 | uint32_t stream_kbps; | |
| 1998 | 1999 | ||
| 2000 | + | if (!aconnector->dc_sink) | |
| 2001 | + | return DC_FAIL_BANDWIDTH_VALIDATE; | |
| 2002 | + | ||
| 1999 | 2003 | /* DSC unnecessary case | |
| 2000 | 2004 | * Check if timing could be supported within end-to-end BW | |
| 2001 | 2005 | */ | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
| @@ -112,25 +112,7 @@ void amdgpu_dm_plane_fill_blending_from_plane_state(const struct drm_plane_state | |||
| 112 | 112 | ||
| 113 | 113 | if (plane_state->pixel_blend_mode == DRM_MODE_BLEND_PREMULTI || | |
| 114 | 114 | plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) { | |
| 115 | - | static const uint32_t alpha_formats[] = { | |
| 116 | - | DRM_FORMAT_ARGB8888, | |
| 117 | - | DRM_FORMAT_RGBA8888, | |
| 118 | - | DRM_FORMAT_ABGR8888, | |
| 119 | - | DRM_FORMAT_ARGB2101010, | |
| 120 | - | DRM_FORMAT_ABGR2101010, | |
| 121 | - | DRM_FORMAT_ARGB16161616, | |
| 122 | - | DRM_FORMAT_ABGR16161616, | |
| 123 | - | DRM_FORMAT_ARGB16161616F, | |
| 124 | - | }; | |
| 125 | - | uint32_t format = plane_state->fb->format->format; | |
| 126 | - | unsigned int i; | |
| 127 | - | ||
| 128 | - | for (i = 0; i < ARRAY_SIZE(alpha_formats); ++i) { | |
| 129 | - | if (format == alpha_formats[i]) { | |
| 130 | - | *per_pixel_alpha = true; | |
| 131 | - | break; | |
| 132 | - | } | |
| 133 | - | } | |
| 115 | + | *per_pixel_alpha = plane_state->fb->format->has_alpha; | |
| 134 | 116 | ||
| 135 | 117 | if (*per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) | |
| 136 | 118 | *pre_multiplied_alpha = false; | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
| @@ -409,7 +409,9 @@ static void dm_test_output_color_space_default_rgb_full(struct kunit *test) | |||
| 409 | 409 | { | |
| 410 | 410 | struct dc_crtc_timing timing = {}; | |
| 411 | 411 | struct drm_connector_state state = {}; | |
| 412 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 412 | 413 | ||
| 414 | + | state.connector = connector; | |
| 413 | 415 | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 414 | 416 | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 415 | 417 | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| @@ -559,7 +561,9 @@ static void dm_test_output_color_space_bt2020_rgb(struct kunit *test) | |||
| 559 | 561 | { | |
| 560 | 562 | struct dc_crtc_timing timing = {}; | |
| 561 | 563 | struct drm_connector_state state = {}; | |
| 564 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 562 | 565 | ||
| 566 | + | state.connector = connector; | |
| 563 | 567 | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 564 | 568 | state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB; | |
| 565 | 569 | ||
| @@ -584,6 +588,110 @@ static void dm_test_output_color_space_bt2020_rgb_limited(struct kunit *test) | |||
| 584 | 588 | (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE); | |
| 585 | 589 | } | |
| 586 | 590 | ||
| 591 | + | /** | |
| 592 | + | * dm_test_output_color_space_default_rgb_auto_hdmi_cta - Automatic follows the CTA-861 default | |
| 593 | + | * @test: The KUnit test context | |
| 594 | + | */ | |
| 595 | + | static void dm_test_output_color_space_default_rgb_auto_hdmi_cta(struct kunit *test) | |
| 596 | + | { | |
| 597 | + | struct dc_crtc_timing timing = {}; | |
| 598 | + | struct drm_connector_state state = {}; | |
| 599 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 600 | + | ||
| 601 | + | connector->display_info.is_hdmi = true; | |
| 602 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 603 | + | timing.vic = 32; | |
| 604 | + | state.connector = connector; | |
| 605 | + | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 606 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| 607 | + | ||
| 608 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 609 | + | (int)COLOR_SPACE_SRGB_LIMITED); | |
| 610 | + | } | |
| 611 | + | ||
| 612 | + | /** | |
| 613 | + | * dm_test_output_color_space_default_rgb_auto_hdmi_vga - 640x480 (VIC 1) stays full range | |
| 614 | + | * @test: The KUnit test context | |
| 615 | + | */ | |
| 616 | + | static void dm_test_output_color_space_default_rgb_auto_hdmi_vga(struct kunit *test) | |
| 617 | + | { | |
| 618 | + | struct dc_crtc_timing timing = {}; | |
| 619 | + | struct drm_connector_state state = {}; | |
| 620 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 621 | + | ||
| 622 | + | connector->display_info.is_hdmi = true; | |
| 623 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 624 | + | timing.vic = 1; | |
| 625 | + | state.connector = connector; | |
| 626 | + | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 627 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| 628 | + | ||
| 629 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 630 | + | (int)COLOR_SPACE_SRGB); | |
| 631 | + | } | |
| 632 | + | ||
| 633 | + | /** | |
| 634 | + | * dm_test_output_color_space_default_rgb_auto_dp_cta - Automatic on a non-HDMI sink is full range | |
| 635 | + | * @test: The KUnit test context | |
| 636 | + | */ | |
| 637 | + | static void dm_test_output_color_space_default_rgb_auto_dp_cta(struct kunit *test) | |
| 638 | + | { | |
| 639 | + | struct dc_crtc_timing timing = {}; | |
| 640 | + | struct drm_connector_state state = {}; | |
| 641 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 642 | + | ||
| 643 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 644 | + | timing.vic = 32; | |
| 645 | + | state.connector = connector; | |
| 646 | + | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 647 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| 648 | + | ||
| 649 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 650 | + | (int)COLOR_SPACE_SRGB); | |
| 651 | + | } | |
| 652 | + | ||
| 653 | + | /** | |
| 654 | + | * dm_test_output_color_space_default_rgb_full_hdmi_cta - Full overrides the CTA-861 default | |
| 655 | + | * @test: The KUnit test context | |
| 656 | + | */ | |
| 657 | + | static void dm_test_output_color_space_default_rgb_full_hdmi_cta(struct kunit *test) | |
| 658 | + | { | |
| 659 | + | struct dc_crtc_timing timing = {}; | |
| 660 | + | struct drm_connector_state state = {}; | |
| 661 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 662 | + | ||
| 663 | + | connector->display_info.is_hdmi = true; | |
| 664 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 665 | + | timing.vic = 32; | |
| 666 | + | state.connector = connector; | |
| 667 | + | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 668 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_FULL; | |
| 669 | + | ||
| 670 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 671 | + | (int)COLOR_SPACE_SRGB); | |
| 672 | + | } | |
| 673 | + | ||
| 674 | + | /** | |
| 675 | + | * dm_test_output_color_space_bt2020_rgb_auto_hdmi_cta - BT.2020 RGB follows the same default | |
| 676 | + | * @test: The KUnit test context | |
| 677 | + | */ | |
| 678 | + | static void dm_test_output_color_space_bt2020_rgb_auto_hdmi_cta(struct kunit *test) | |
| 679 | + | { | |
| 680 | + | struct dc_crtc_timing timing = {}; | |
| 681 | + | struct drm_connector_state state = {}; | |
| 682 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 683 | + | ||
| 684 | + | connector->display_info.is_hdmi = true; | |
| 685 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 686 | + | timing.vic = 32; | |
| 687 | + | state.connector = connector; | |
| 688 | + | state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB; | |
| 689 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| 690 | + | ||
| 691 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 692 | + | (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE); | |
| 693 | + | } | |
| 694 | + | ||
| 587 | 695 | /** | |
| 588 | 696 | * dm_test_output_color_space_bt2020_ycc - Test Output color space bt2020 ycc | |
| 589 | 697 | * @test: The KUnit test context | |
| @@ -647,7 +755,9 @@ static void dm_test_output_color_space_bt2020_ycc_rgb_encoding(struct kunit *tes | |||
| 647 | 755 | { | |
| 648 | 756 | struct dc_crtc_timing timing = {}; | |
| 649 | 757 | struct drm_connector_state state = {}; | |
| 758 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 650 | 759 | ||
| 760 | + | state.connector = connector; | |
| 651 | 761 | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 652 | 762 | state.colorspace = DRM_MODE_COLORIMETRY_BT2020_YCC; | |
| 653 | 763 | ||
| @@ -1462,6 +1572,46 @@ static void dm_test_decide_crtc_timing_no_crtc_clock(struct kunit *test) | |||
| 1462 | 1572 | KUNIT_EXPECT_EQ(test, drm_mode.crtc_hdisplay, 0); | |
| 1463 | 1573 | } | |
| 1464 | 1574 | ||
| 1575 | + | static void dm_test_decide_crtc_timing_sink_mode_same_totals(struct kunit *test) | |
| 1576 | + | { | |
| 1577 | + | struct drm_display_mode native_mode = { | |
| 1578 | + | DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016, 4104, | |
| 1579 | + | 4400, 0, 2160, 2168, 2178, 2250, 0, | |
| 1580 | + | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }; | |
| 1581 | + | struct drm_display_mode drm_mode = { | |
| 1582 | + | DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 4184, 4272, | |
| 1583 | + | 4400, 0, 2160, 2168, 2178, 2250, 0, | |
| 1584 | + | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }; | |
| 1585 | + | ||
| 1586 | + | drm_mode_set_crtcinfo(&native_mode, 0); | |
| 1587 | + | drm_mode_set_crtcinfo(&drm_mode, 0); | |
| 1588 | + | ||
| 1589 | + | decide_crtc_timing_for_drm_display_mode(&drm_mode, &native_mode, false); | |
| 1590 | + | ||
| 1591 | + | KUNIT_EXPECT_EQ(test, drm_mode.crtc_hdisplay, 4096); | |
| 1592 | + | KUNIT_EXPECT_EQ(test, drm_mode.crtc_hsync_start, 4184); | |
| 1593 | + | } | |
| 1594 | + | ||
| 1595 | + | static void dm_test_decide_crtc_timing_inserted_mode(struct kunit *test) | |
| 1596 | + | { | |
| 1597 | + | struct drm_display_mode native_mode = { | |
| 1598 | + | DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016, 4104, | |
| 1599 | + | 4400, 0, 2160, 2168, 2178, 2250, 0, | |
| 1600 | + | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }; | |
| 1601 | + | struct drm_display_mode drm_mode; | |
| 1602 | + | ||
| 1603 | + | drm_mode_set_crtcinfo(&native_mode, 0); | |
| 1604 | + | drm_mode = native_mode; | |
| 1605 | + | drm_mode.hdisplay = 1920; | |
| 1606 | + | drm_mode.vdisplay = 1080; | |
| 1607 | + | drm_mode_set_crtcinfo(&drm_mode, 0); | |
| 1608 | + | ||
| 1609 | + | decide_crtc_timing_for_drm_display_mode(&drm_mode, &native_mode, false); | |
| 1610 | + | ||
| 1611 | + | KUNIT_EXPECT_EQ(test, drm_mode.crtc_hdisplay, 3840); | |
| 1612 | + | KUNIT_EXPECT_EQ(test, drm_mode.crtc_vdisplay, 2160); | |
| 1613 | + | } | |
| 1614 | + | ||
| 1465 | 1615 | /* Tests for amdgpu_dm_connector_funcs_reset() */ | |
| 1466 | 1616 | ||
| 1467 | 1617 | static const struct drm_connector_funcs dm_test_connector_funcs = { | |
| @@ -3425,6 +3575,7 @@ static struct dm_test_fill_ctx *dm_test_fill_ctx_alloc(struct kunit *test) | |||
| 3425 | 3575 | ||
| 3426 | 3576 | ctx->conn_state = drmm_kzalloc(ctx->drm, sizeof(*ctx->conn_state), GFP_KERNEL); | |
| 3427 | 3577 | KUNIT_ASSERT_NOT_NULL(test, ctx->conn_state); | |
| 3578 | + | ctx->conn_state->connector = &ctx->aconnector->base; | |
| 3428 | 3579 | ctx->stream = kunit_kzalloc(test, sizeof(*ctx->stream), GFP_KERNEL); | |
| 3429 | 3580 | KUNIT_ASSERT_NOT_NULL(test, ctx->stream); | |
| 3430 | 3581 | ctx->mode = kunit_kzalloc(test, sizeof(*ctx->mode), GFP_KERNEL); | |
| @@ -3818,6 +3969,7 @@ static struct dm_test_stream_ctx *dm_test_stream_ctx_alloc(struct kunit *test) | |||
| 3818 | 3969 | ||
| 3819 | 3970 | ctx->dm_state = kunit_kzalloc(test, sizeof(*ctx->dm_state), GFP_KERNEL); | |
| 3820 | 3971 | KUNIT_ASSERT_NOT_NULL(test, ctx->dm_state); | |
| 3972 | + | ctx->dm_state->base.connector = &ctx->aconnector->base; | |
| 3821 | 3973 | ctx->dm_state->scaling = RMX_OFF; | |
| 3822 | 3974 | ||
| 3823 | 3975 | ctx->mode = kunit_kzalloc(test, sizeof(*ctx->mode), GFP_KERNEL); | |
| @@ -5458,6 +5610,11 @@ static struct kunit_case amdgpu_dm_connector_tests[] = { | |||
| 5458 | 5610 | KUNIT_CASE(dm_test_output_color_space_oprgb), | |
| 5459 | 5611 | KUNIT_CASE(dm_test_output_color_space_bt2020_rgb), | |
| 5460 | 5612 | KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_limited), | |
| 5613 | + | KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_hdmi_cta), | |
| 5614 | + | KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_hdmi_vga), | |
| 5615 | + | KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_dp_cta), | |
| 5616 | + | KUNIT_CASE(dm_test_output_color_space_default_rgb_full_hdmi_cta), | |
| 5617 | + | KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_auto_hdmi_cta), | |
| 5461 | 5618 | KUNIT_CASE(dm_test_output_color_space_bt2020_ycc), | |
| 5462 | 5619 | KUNIT_CASE(dm_test_output_color_space_default_ycbcr709_y_only), | |
| 5463 | 5620 | KUNIT_CASE(dm_test_output_color_space_default_ycbcr601), | |
| @@ -5518,6 +5675,8 @@ static struct kunit_case amdgpu_dm_connector_tests[] = { | |||
| 5518 | 5675 | KUNIT_CASE(dm_test_decide_crtc_timing_matching_mode), | |
| 5519 | 5676 | KUNIT_CASE(dm_test_decide_crtc_timing_no_copy), | |
| 5520 | 5677 | KUNIT_CASE(dm_test_decide_crtc_timing_no_crtc_clock), | |
| 5678 | + | KUNIT_CASE(dm_test_decide_crtc_timing_sink_mode_same_totals), | |
| 5679 | + | KUNIT_CASE(dm_test_decide_crtc_timing_inserted_mode), | |
| 5521 | 5680 | /* amdgpu_dm_connector_funcs_reset */ | |
| 5522 | 5681 | KUNIT_CASE(dm_test_funcs_reset_sets_defaults), | |
| 5523 | 5682 | KUNIT_CASE(dm_test_funcs_reset_edp_abm_level), | |
modified drivers/gpu/drm/amd/display/dc/dc.h
| @@ -1905,6 +1905,7 @@ struct dc_scratch_space { | |||
| 1905 | 1905 | struct ddc_service *ddc; | |
| 1906 | 1906 | ||
| 1907 | 1907 | enum dp_panel_mode panel_mode; | |
| 1908 | + | bool panel_mode_initialized; | |
| 1908 | 1909 | bool aux_mode; | |
| 1909 | 1910 | ||
| 1910 | 1911 | /* Private to DC core */ | |
modified drivers/gpu/drm/amd/display/dc/dml/Makefile
| @@ -29,7 +29,7 @@ dml_ccflags := $(CC_FLAGS_FPU) | |||
| 29 | 29 | dml_rcflags := $(CC_FLAGS_NO_FPU) | |
| 30 | 30 | ||
| 31 | 31 | ifneq ($(CONFIG_FRAME_WARN),0) | |
| 32 | - | ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)$(CONFIG_UBSAN)),y) | |
| 32 | + | ifneq ($(filter y,$(CONFIG_KASAN) $(CONFIG_KCSAN) $(CONFIG_UBSAN)),) | |
| 33 | 33 | ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_COMPILE_TEST),yy) | |
| 34 | 34 | frame_warn_limit := 4096 | |
| 35 | 35 | else | |
modified drivers/gpu/drm/amd/display/dc/dml2_0/Makefile
| @@ -28,7 +28,7 @@ dml2_ccflags := $(CC_FLAGS_FPU) | |||
| 28 | 28 | dml2_rcflags := $(CC_FLAGS_NO_FPU) | |
| 29 | 29 | ||
| 30 | 30 | ifneq ($(CONFIG_FRAME_WARN),0) | |
| 31 | - | ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)$(CONFIG_UBSAN)),y) | |
| 31 | + | ifneq ($(filter y,$(CONFIG_KASAN) $(CONFIG_KCSAN) $(CONFIG_UBSAN)),) | |
| 32 | 32 | ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_COMPILE_TEST),yy) | |
| 33 | 33 | frame_warn_limit := 4096 | |
| 34 | 34 | else | |
modified drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
| @@ -93,6 +93,7 @@ void dp_set_panel_mode(struct dc_link *link, enum dp_panel_mode panel_mode) | |||
| 93 | 93 | } | |
| 94 | 94 | ||
| 95 | 95 | link->panel_mode = panel_mode; | |
| 96 | + | link->panel_mode_initialized = true; | |
| 96 | 97 | DC_LOG_DETECTION_DP_CAPS("%d eDP panel mode supported: %d, enabled: %d\n", | |
| 97 | 98 | link->link_index, | |
| 98 | 99 | link->dpcd_caps.panel_mode_edp, | |
| @@ -1297,7 +1298,8 @@ void edp_set_panel_assr(struct dc_link *link, struct pipe_ctx *pipe_ctx, | |||
| 1297 | 1298 | ||
| 1298 | 1299 | result = cp_psp->funcs.enable_assr(cp_psp->handle, link); | |
| 1299 | 1300 | ||
| 1300 | - | if (!result && link->panel_mode != DP_PANEL_MODE_EDP) | |
| 1301 | + | if (!result && link->panel_mode_initialized && | |
| 1302 | + | link->panel_mode != DP_PANEL_MODE_EDP) | |
| 1301 | 1303 | *panel_mode = DP_PANEL_MODE_DEFAULT; | |
| 1302 | 1304 | } | |
| 1303 | 1305 | } | |
modified drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c
| @@ -448,6 +448,12 @@ static const struct dce_abm_mask abm_mask = { | |||
| 448 | 448 | ABM_MASK_SH_LIST_DCE110(_MASK) | |
| 449 | 449 | }; | |
| 450 | 450 | ||
| 451 | + | static const struct dc_debug_options debug_defaults = { 0 }; | |
| 452 | + | ||
| 453 | + | static const struct dc_check_config config_defaults = { | |
| 454 | + | .enable_legacy_fast_update = true, | |
| 455 | + | }; | |
| 456 | + | ||
| 451 | 457 | #define CTX ctx | |
| 452 | 458 | #define REG(reg) mm ## reg | |
| 453 | 459 | ||
| @@ -937,6 +943,8 @@ static bool dce60_construct( | |||
| 937 | 943 | dc->caps.max_cursor_size = 64; | |
| 938 | 944 | dc->caps.dual_link_dvi = true; | |
| 939 | 945 | dc->caps.extended_aux_timeout_support = false; | |
| 946 | + | dc->debug = debug_defaults; | |
| 947 | + | dc->check_config = config_defaults; | |
| 940 | 948 | ||
| 941 | 949 | /************************************************* | |
| 942 | 950 | * Create resources * | |
| @@ -1134,6 +1142,8 @@ static bool dce61_construct( | |||
| 1134 | 1142 | dc->caps.i2c_speed_in_khz = 40; | |
| 1135 | 1143 | dc->caps.max_cursor_size = 64; | |
| 1136 | 1144 | dc->caps.is_apu = true; | |
| 1145 | + | dc->debug = debug_defaults; | |
| 1146 | + | dc->check_config = config_defaults; | |
| 1137 | 1147 | ||
| 1138 | 1148 | /************************************************* | |
| 1139 | 1149 | * Create resources * | |
| @@ -1331,7 +1341,8 @@ static bool dce64_construct( | |||
| 1331 | 1341 | dc->caps.max_downscale_ratio = 200; | |
| 1332 | 1342 | dc->caps.i2c_speed_in_khz = 40; | |
| 1333 | 1343 | dc->caps.max_cursor_size = 64; | |
| 1334 | - | dc->caps.is_apu = true; | |
| 1344 | + | dc->debug = debug_defaults; | |
| 1345 | + | dc->check_config = config_defaults; | |
| 1335 | 1346 | ||
| 1336 | 1347 | /************************************************* | |
| 1337 | 1348 | * Create resources * | |
modified drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c
| @@ -1148,6 +1148,8 @@ static bool dce81_construct( | |||
| 1148 | 1148 | dc->caps.max_cursor_size = 128; | |
| 1149 | 1149 | dc->caps.min_horizontal_blanking_period = 80; | |
| 1150 | 1150 | dc->caps.is_apu = true; | |
| 1151 | + | dc->debug = debug_defaults; | |
| 1152 | + | dc->check_config = config_defaults; | |
| 1151 | 1153 | ||
| 1152 | 1154 | /************************************************* | |
| 1153 | 1155 | * Create resources * | |
modified drivers/gpu/drm/amd/display/modules/power/power.c
| @@ -328,6 +328,7 @@ bool mod_power_add_stream(struct mod_power *mod_power, | |||
| 328 | 328 | core_power->map[core_power->num_entities].psr_enabled = 0; | |
| 329 | 329 | core_power->map[core_power->num_entities].psr_events = psr_event_vsync; | |
| 330 | 330 | core_power->map[core_power->num_entities].psr_power_opt = 0; | |
| 331 | + | core_power->map[core_power->num_entities].replay_events = replay_event_vsync; | |
| 331 | 332 | core_power->num_entities++; | |
| 332 | 333 | return true; | |
| 333 | 334 | } | |
| @@ -387,6 +388,7 @@ bool mod_power_remove_stream(struct mod_power *mod_power, | |||
| 387 | 388 | core_power->map[i].psr_enabled = core_power->map[i + 1].psr_enabled; | |
| 388 | 389 | core_power->map[i].psr_events = core_power->map[i + 1].psr_events; | |
| 389 | 390 | core_power->map[i].psr_power_opt = core_power->map[i + 1].psr_power_opt; | |
| 391 | + | core_power->map[i].replay_events = core_power->map[i + 1].replay_events; | |
| 390 | 392 | ||
| 391 | 393 | memcpy(core_power->map[i].psr_context, core_power->map[i + 1].psr_context, sizeof(struct mod_power_psr_context)); | |
| 392 | 394 | memset(core_power->map[i + 1].psr_context, 0, sizeof(struct mod_power_psr_context)); | |
modified drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
| @@ -5263,7 +5263,8 @@ static int si_init_smc_table(struct amdgpu_device *adev) | |||
| 5263 | 5263 | break; | |
| 5264 | 5264 | } | |
| 5265 | 5265 | ||
| 5266 | - | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC) | |
| 5266 | + | if ((adev->flags & AMD_IS_MOBILITY) && | |
| 5267 | + | (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)) | |
| 5267 | 5268 | table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC; | |
| 5268 | 5269 | ||
| 5269 | 5270 | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT) { | |
| @@ -7237,6 +7238,19 @@ static void si_parse_pplib_non_clock_info(struct amdgpu_device *adev, | |||
| 7237 | 7238 | adev->pm.dpm.uvd_ps = rps; | |
| 7238 | 7239 | } | |
| 7239 | 7240 | ||
| 7241 | + | static void si_update_limits(struct amdgpu_clock_and_voltage_limits *limits, | |
| 7242 | + | struct rv7xx_pl *pl) | |
| 7243 | + | { | |
| 7244 | + | if (pl->sclk > limits->sclk) | |
| 7245 | + | limits->sclk = pl->sclk; | |
| 7246 | + | if (pl->mclk > limits->mclk) | |
| 7247 | + | limits->mclk = pl->mclk; | |
| 7248 | + | if (pl->vddc > limits->vddc) | |
| 7249 | + | limits->vddc = pl->vddc; | |
| 7250 | + | if (pl->vddci > limits->vddci) | |
| 7251 | + | limits->vddci = pl->vddci; | |
| 7252 | + | } | |
| 7253 | + | ||
| 7240 | 7254 | static void si_parse_pplib_clock_info(struct amdgpu_device *adev, | |
| 7241 | 7255 | struct amdgpu_ps *rps, int index, | |
| 7242 | 7256 | union pplib_clock_info *clock_info) | |
| @@ -7245,7 +7259,6 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev, | |||
| 7245 | 7259 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | |
| 7246 | 7260 | struct si_power_info *si_pi = si_get_pi(adev); | |
| 7247 | 7261 | struct si_ps *ps = si_get_ps(rps); | |
| 7248 | - | struct amdgpu_clock_and_voltage_limits *limits; | |
| 7249 | 7262 | u16 leakage_voltage; | |
| 7250 | 7263 | struct rv7xx_pl *pl = &ps->performance_levels[index]; | |
| 7251 | 7264 | int ret; | |
| @@ -7310,26 +7323,14 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev, | |||
| 7310 | 7323 | * VBIOS can contain conflicting values between: | |
| 7311 | 7324 | * - the maximum allowed clocks and voltages on AC or DC | |
| 7312 | 7325 | * - the clocks and voltages in power states on AC or DC | |
| 7326 | + | * | |
| 7327 | + | * Assume that the AC limits are the maximum of all power states, | |
| 7328 | + | * and the DC limits are the maximum of battery power states. | |
| 7313 | 7329 | */ | |
| 7330 | + | si_update_limits(&adev->pm.dpm.dyn_state.max_clock_voltage_on_ac, pl); | |
| 7314 | 7331 | if ((rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) == | |
| 7315 | - | ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE) | |
| 7316 | - | limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | |
| 7317 | - | else if ((rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) == | |
| 7318 | 7332 | ATOM_PPLIB_CLASSIFICATION_UI_BATTERY) | |
| 7319 | - | limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; | |
| 7320 | - | else | |
| 7321 | - | limits = NULL; | |
| 7322 | - | ||
| 7323 | - | if (limits) { | |
| 7324 | - | if (pl->sclk > limits->sclk) | |
| 7325 | - | limits->sclk = pl->sclk; | |
| 7326 | - | if (pl->mclk > limits->mclk) | |
| 7327 | - | limits->mclk = pl->mclk; | |
| 7328 | - | if (pl->vddc > limits->vddc) | |
| 7329 | - | limits->vddc = pl->vddc; | |
| 7330 | - | if (pl->vddci > limits->vddci) | |
| 7331 | - | limits->vddci = pl->vddci; | |
| 7332 | - | } | |
| 7333 | + | si_update_limits(&adev->pm.dpm.dyn_state.max_clock_voltage_on_dc, pl); | |
| 7333 | 7334 | } | |
| 7334 | 7335 | ||
| 7335 | 7336 | union pplib_power_state { | |
modified drivers/gpu/drm/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/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/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_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_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/gud/gud_pipe.c
| @@ -507,6 +507,7 @@ int gud_plane_atomic_check(struct drm_plane *plane, | |||
| 507 | 507 | for_each_new_connector_in_state(state, connector, connector_state, i) { | |
| 508 | 508 | if (connector_state->crtc) | |
| 509 | 509 | break; | |
| 510 | + | connector_state = NULL; | |
| 510 | 511 | } | |
| 511 | 512 | ||
| 512 | 513 | /* | |
modified drivers/gpu/drm/i915/display/intel_display_params.c
| @@ -120,6 +120,10 @@ intel_display_param_named_unsafe(enable_psr, int, 0400, | |||
| 120 | 120 | "(0=disabled, 1=enable up to PSR1, 2=enable up to PSR2) " | |
| 121 | 121 | "Default: -1 (use per-chip default)"); | |
| 122 | 122 | ||
| 123 | + | intel_display_param_named_unsafe(enable_dc_balance, bool, 0400, | |
| 124 | + | "Enable VRR DC balance (0=disabled, 1=enabled). " | |
| 125 | + | "Default: 0 (disabled)"); | |
| 126 | + | ||
| 123 | 127 | intel_display_param_named_unsafe(enable_panel_replay, int, 0400, | |
| 124 | 128 | "Enable Panel Replay (0=disabled, 1=enabled). Default: -1 (use per-chip default)"); | |
| 125 | 129 | ||
modified drivers/gpu/drm/i915/display/intel_display_params.h
| @@ -46,6 +46,7 @@ struct drm_printer; | |||
| 46 | 46 | param(bool, enable_dp_mst, true, 0600) \ | |
| 47 | 47 | param(int, enable_fbc, -1, 0600) \ | |
| 48 | 48 | param(int, enable_psr, -1, 0600) \ | |
| 49 | + | param(bool, enable_dc_balance, false, 0600) \ | |
| 49 | 50 | param(int, enable_panel_replay, -1, 0600) \ | |
| 50 | 51 | param(bool, psr_safest_params, false, 0400) \ | |
| 51 | 52 | param(bool, enable_psr2_sel_fetch, true, 0400) \ | |
modified drivers/gpu/drm/i915/display/intel_vrr.c
| @@ -386,10 +386,12 @@ static bool intel_vrr_dc_balance_possible(const struct intel_crtc_state *crtc_st | |||
| 386 | 386 | static void | |
| 387 | 387 | intel_vrr_dc_balance_compute_config(struct intel_crtc_state *crtc_state) | |
| 388 | 388 | { | |
| 389 | + | struct intel_display *display = to_intel_display(crtc_state); | |
| 389 | 390 | int guardband_usec, adjustment_usec; | |
| 390 | 391 | struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; | |
| 391 | 392 | ||
| 392 | - | if (!intel_vrr_dc_balance_possible(crtc_state) || !crtc_state->vrr.enable) | |
| 393 | + | if (!intel_vrr_dc_balance_possible(crtc_state) || | |
| 394 | + | !crtc_state->vrr.enable || !display->params.enable_dc_balance) | |
| 393 | 395 | return; | |
| 394 | 396 | ||
| 395 | 397 | crtc_state->vrr.dc_balance.vmax = crtc_state->vrr.vmax; | |
modified drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
| @@ -1766,6 +1766,7 @@ static int eb_reinit_userptr(struct i915_execbuffer *eb) | |||
| 1766 | 1766 | ||
| 1767 | 1767 | static noinline int eb_relocate_parse_slow(struct i915_execbuffer *eb) | |
| 1768 | 1768 | { | |
| 1769 | + | const unsigned int count = eb->buffer_count; | |
| 1769 | 1770 | bool have_copy = false; | |
| 1770 | 1771 | struct eb_vma *ev; | |
| 1771 | 1772 | int err = 0; | |
| @@ -1868,7 +1869,6 @@ err: | |||
| 1868 | 1869 | ||
| 1869 | 1870 | out: | |
| 1870 | 1871 | if (have_copy) { | |
| 1871 | - | const unsigned int count = eb->buffer_count; | |
| 1872 | 1872 | unsigned int i; | |
| 1873 | 1873 | ||
| 1874 | 1874 | for (i = 0; i < count; i++) { | |
modified drivers/gpu/drm/i915/gt/intel_rps.c
| @@ -1904,7 +1904,8 @@ static void rps_work(struct work_struct *work) | |||
| 1904 | 1904 | ||
| 1905 | 1905 | out: | |
| 1906 | 1906 | spin_lock_irq(gt->irq_lock); | |
| 1907 | - | gen6_gt_pm_unmask_irq(gt, rps->pm_events); | |
| 1907 | + | if (intel_rps_is_active(rps)) | |
| 1908 | + | gen6_gt_pm_unmask_irq(gt, rps->pm_events); | |
| 1908 | 1909 | spin_unlock_irq(gt->irq_lock); | |
| 1909 | 1910 | } | |
| 1910 | 1911 | ||
modified drivers/gpu/drm/imagination/pvr_mmu.c
| @@ -2337,7 +2337,7 @@ void pvr_mmu_op_context_destroy(struct pvr_mmu_op_context *op_ctx) | |||
| 2337 | 2337 | * @ctx: MMU context associated with owning VM context. | |
| 2338 | 2338 | * @sgt: Scatter gather table containing pages pinned for use by this context. | |
| 2339 | 2339 | * @device_addr: Virtual device address at the start of the requested mapping. | |
| 2340 | - | * @sgt_offset: Start offset of the requested device-virtual memory mapping. | |
| 2340 | + | * @sgt_offset: Offset into @sgt of the start of the requested mapping. | |
| 2341 | 2341 | * @size: Size in bytes of the requested device-virtual memory mapping. For an | |
| 2342 | 2342 | * unmapping, this should be zero so that no page tables are allocated. | |
| 2343 | 2343 | * | |
| @@ -2350,7 +2350,6 @@ struct pvr_mmu_op_context * | |||
| 2350 | 2350 | pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, struct sg_table *sgt, | |
| 2351 | 2351 | u64 device_addr, u64 sgt_offset, u64 size) | |
| 2352 | 2352 | { | |
| 2353 | - | u64 start_addr = device_addr + sgt_offset; | |
| 2354 | 2353 | int err; | |
| 2355 | 2354 | ||
| 2356 | 2355 | struct pvr_mmu_op_context *op_ctx = kzalloc_obj(*op_ctx); | |
| @@ -2365,18 +2364,18 @@ pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, struct sg_table *sgt, | |||
| 2365 | 2364 | ||
| 2366 | 2365 | if (size) { | |
| 2367 | 2366 | /* | |
| 2368 | - | * The number of page table objects we need to prealloc is | |
| 2369 | - | * indicated by the mapping size, start address and the sizes | |
| 2370 | - | * of the areas mapped per PT or PD. The range calculation is | |
| 2371 | - | * identical to that for the index into a table for a device | |
| 2372 | - | * 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. | |
| 2373 | 2371 | */ | |
| 2374 | - | const u32 l1_start_idx = pvr_page_table_l2_idx(start_addr); | |
| 2375 | - | const u32 l1_end_idx = pvr_page_table_l2_idx(start_addr + size); | |
| 2376 | - | const u32 l1_count = l1_end_idx - l1_start_idx + 1; | |
| 2377 | - | const u32 l0_start_idx = pvr_page_table_l1_idx(start_addr); | |
| 2378 | - | const u32 l0_end_idx = pvr_page_table_l1_idx(start_addr + size); | |
| 2379 | - | 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; | |
| 2380 | 2379 | ||
| 2381 | 2380 | /* | |
| 2382 | 2381 | * Alloc and push page table entries until we have enough of | |
modified drivers/gpu/drm/imagination/pvr_vm.c
| @@ -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/mediatek/mtk_drm_drv.c
| @@ -638,8 +638,10 @@ static int mtk_drm_bind(struct device *dev) | |||
| 638 | 638 | private->mtk_drm_bound = true; | |
| 639 | 639 | private->dev = dev; | |
| 640 | 640 | ||
| 641 | - | if (!mtk_drm_get_all_drm_priv(dev)) | |
| 641 | + | if (!mtk_drm_get_all_drm_priv(dev)) { | |
| 642 | + | put_device(private->mutex_dev); | |
| 642 | 643 | return 0; | |
| 644 | + | } | |
| 643 | 645 | ||
| 644 | 646 | drm = drm_dev_alloc(&mtk_drm_driver, dev); | |
| 645 | 647 | if (IS_ERR(drm)) { | |
| @@ -1060,7 +1062,7 @@ static int mtk_drm_probe(struct platform_device *pdev) | |||
| 1060 | 1062 | struct mtk_mmsys_driver_data *mtk_drm_data; | |
| 1061 | 1063 | struct device_node *node; | |
| 1062 | 1064 | struct component_match *match = NULL; | |
| 1063 | - | struct platform_device *ovl_adaptor; | |
| 1065 | + | struct platform_device *ovl_adaptor = NULL; | |
| 1064 | 1066 | int ret; | |
| 1065 | 1067 | int i; | |
| 1066 | 1068 | ||
| @@ -1112,6 +1114,9 @@ static int mtk_drm_probe(struct platform_device *pdev) | |||
| 1112 | 1114 | PLATFORM_DEVID_AUTO, | |
| 1113 | 1115 | (void *)private->mmsys_dev, | |
| 1114 | 1116 | sizeof(*private->mmsys_dev)); | |
| 1117 | + | if (IS_ERR(ovl_adaptor)) | |
| 1118 | + | return PTR_ERR(ovl_adaptor); | |
| 1119 | + | ||
| 1115 | 1120 | private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR].dev = &ovl_adaptor->dev; | |
| 1116 | 1121 | mtk_ddp_comp_init(dev, NULL, &private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR], | |
| 1117 | 1122 | DDP_COMPONENT_DRM_OVL_ADAPTOR); | |
| @@ -1205,6 +1210,8 @@ static int mtk_drm_probe(struct platform_device *pdev) | |||
| 1205 | 1210 | err_pm: | |
| 1206 | 1211 | pm_runtime_disable(dev); | |
| 1207 | 1212 | err_node: | |
| 1213 | + | if (ovl_adaptor) | |
| 1214 | + | platform_device_unregister(ovl_adaptor); | |
| 1208 | 1215 | of_node_put(private->mutex_node); | |
| 1209 | 1216 | for (i = 0; i < DDP_COMPONENT_DRM_ID_MAX; i++) | |
| 1210 | 1217 | of_node_put(private->comp_node[i]); | |
| @@ -1214,9 +1221,15 @@ err_node: | |||
| 1214 | 1221 | static void mtk_drm_remove(struct platform_device *pdev) | |
| 1215 | 1222 | { | |
| 1216 | 1223 | struct mtk_drm_private *private = platform_get_drvdata(pdev); | |
| 1224 | + | struct device *ovl_adaptor_dev; | |
| 1217 | 1225 | int i; | |
| 1218 | 1226 | ||
| 1227 | + | ovl_adaptor_dev = | |
| 1228 | + | private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR].dev; | |
| 1229 | + | ||
| 1219 | 1230 | component_master_del(&pdev->dev, &mtk_drm_ops); | |
| 1231 | + | if (ovl_adaptor_dev) | |
| 1232 | + | platform_device_unregister(to_platform_device(ovl_adaptor_dev)); | |
| 1220 | 1233 | pm_runtime_disable(&pdev->dev); | |
| 1221 | 1234 | of_node_put(private->mutex_node); | |
| 1222 | 1235 | for (i = 0; i < DDP_COMPONENT_DRM_ID_MAX; i++) | |
modified drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c
| @@ -376,8 +376,10 @@ static int mtk_hdmi_ddc_v2_probe(struct platform_device *pdev) | |||
| 376 | 376 | pm_runtime_get_sync(dev); | |
| 377 | 377 | ||
| 378 | 378 | ret = devm_i2c_add_adapter(dev, &ddc->adap); | |
| 379 | - | if (ret < 0) | |
| 379 | + | if (ret < 0) { | |
| 380 | + | pm_runtime_put_noidle(dev); | |
| 380 | 381 | return dev_err_probe(dev, ret, "Cannot add DDC I2C adapter\n"); | |
| 382 | + | } | |
| 381 | 383 | ||
| 382 | 384 | platform_set_drvdata(pdev, ddc); | |
| 383 | 385 | return 0; | |
modified drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h
| @@ -173,7 +173,7 @@ | |||
| 173 | 173 | #define TPI_AUDIO_LOOKUP_EN BIT(2) | |
| 174 | 174 | ||
| 175 | 175 | /* Video downsampling configuration */ | |
| 176 | - | #define VID_DOWNSAMPLE_CONFIG 0x8d0 | |
| 176 | + | #define VID_DOWNSAMPLE_CONFIG 0x8f0 | |
| 177 | 177 | #define C444_C422_CONFIG_ENABLE BIT(0) | |
| 178 | 178 | #define C422_C420_CONFIG_ENABLE BIT(4) | |
| 179 | 179 | #define C422_C420_CONFIG_BYPASS BIT(5) | |
modified drivers/gpu/drm/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/nvkm/engine/device/user.c
| @@ -201,7 +201,7 @@ nvkm_udevice_gcx_ready(struct nvkm_udevice *udev, void *data, u32 size) | |||
| 201 | 201 | } *args = data; | |
| 202 | 202 | int ret = -ENOSYS; | |
| 203 | 203 | ||
| 204 | - | if (!gsp) { | |
| 204 | + | if (!gsp || !gsp->rm) { | |
| 205 | 205 | args->v0.ready = NV_DEVICE_GC6_READY | NV_DEVICE_GCOFF_READY; | |
| 206 | 206 | return 0; | |
| 207 | 207 | } | |
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/radeon/radeon_bios.c
| @@ -49,6 +49,7 @@ | |||
| 49 | 49 | static bool igp_read_bios_from_vram(struct radeon_device *rdev) | |
| 50 | 50 | { | |
| 51 | 51 | uint8_t __iomem *bios; | |
| 52 | + | uint8_t val1, val2; | |
| 52 | 53 | resource_size_t vram_base; | |
| 53 | 54 | resource_size_t size = 256 * 1024; /* ??? */ | |
| 54 | 55 | ||
| @@ -63,7 +64,10 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) | |||
| 63 | 64 | return false; | |
| 64 | 65 | } | |
| 65 | 66 | ||
| 66 | - | if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { | |
| 67 | + | val1 = readb(&bios[0]); | |
| 68 | + | val2 = readb(&bios[1]); | |
| 69 | + | ||
| 70 | + | if (size == 0 || val1 != 0x55 || val2 != 0xaa) { | |
| 67 | 71 | iounmap(bios); | |
| 68 | 72 | return false; | |
| 69 | 73 | } | |
modified drivers/gpu/drm/vc4/vc4_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_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_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/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/display/xe_fb_pin.c
| @@ -356,7 +356,7 @@ static struct i915_vma *__xe_pin_fb_vma(struct drm_gem_object *obj, bool is_dpt, | |||
| 356 | 356 | drm_exec_retry_on_contention(&exec); | |
| 357 | 357 | xe_validation_retry_on_oom(&ctx, &ret); | |
| 358 | 358 | if (!ret) | |
| 359 | - | ttm_bo_pin(&bo->ttm); | |
| 359 | + | xe_bo_pin_account(bo); | |
| 360 | 360 | } | |
| 361 | 361 | if (ret) | |
| 362 | 362 | goto err; | |
| @@ -373,7 +373,7 @@ static struct i915_vma *__xe_pin_fb_vma(struct drm_gem_object *obj, bool is_dpt, | |||
| 373 | 373 | ||
| 374 | 374 | err_unpin: | |
| 375 | 375 | ttm_bo_reserve(&bo->ttm, false, false, NULL); | |
| 376 | - | ttm_bo_unpin(&bo->ttm); | |
| 376 | + | xe_bo_unpin_account(bo); | |
| 377 | 377 | ttm_bo_unreserve(&bo->ttm); | |
| 378 | 378 | err: | |
| 379 | 379 | kfree(vma); | |
| @@ -393,7 +393,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma) | |||
| 393 | 393 | xe_ggtt_node_remove(vma->node, false); | |
| 394 | 394 | ||
| 395 | 395 | ttm_bo_reserve(&vma->bo->ttm, false, false, NULL); | |
| 396 | - | ttm_bo_unpin(&vma->bo->ttm); | |
| 396 | + | xe_bo_unpin_account(vma->bo); | |
| 397 | 397 | ttm_bo_unreserve(&vma->bo->ttm); | |
| 398 | 398 | kfree(vma); | |
| 399 | 399 | } | |
modified drivers/gpu/drm/xe/xe_bo.c
| @@ -455,6 +455,100 @@ static void xe_ttm_tt_account_subtract(struct xe_device *xe, struct ttm_tt *tt) | |||
| 455 | 455 | xe_shrinker_mod_pages(xe->mem.shrinker, -(long)tt->num_pages, 0); | |
| 456 | 456 | } | |
| 457 | 457 | ||
| 458 | + | static bool xe_ttm_bo_is_imported(struct ttm_buffer_object *tbo) | |
| 459 | + | { | |
| 460 | + | dma_resv_assert_held(tbo->base.resv); | |
| 461 | + | ||
| 462 | + | return tbo->ttm && | |
| 463 | + | (tbo->ttm->page_flags & (TTM_TT_FLAG_EXTERNAL | TTM_TT_FLAG_EXTERNAL_MAPPABLE)) == | |
| 464 | + | TTM_TT_FLAG_EXTERNAL; | |
| 465 | + | } | |
| 466 | + | ||
| 467 | + | /* | |
| 468 | + | * Account @bo's pages as pinned for the shrinker. Removes @bo's pages | |
| 469 | + | * from the shrinker's shrinkable / purgeable counts on the transition | |
| 470 | + | * from unpinned to pinned. Must be called with @bo's dma-resv held, | |
| 471 | + | * after &ttm_buffer_object.pin_count has been incremented by | |
| 472 | + | * ttm_bo_pin(). Safe to call unconditionally regardless of which pin | |
| 473 | + | * path (kernel, external, framebuffer, backup object, ...) is pinning | |
| 474 | + | * @bo, since it only acts on the true 0->1 pin_count transition. | |
| 475 | + | * | |
| 476 | + | * Imported bos (xe_ttm_bo_is_imported()) are excluded: for those, | |
| 477 | + | * xe_ttm_tt_populate() never actually populates the tt or calls | |
| 478 | + | * xe_ttm_tt_account_add(), but TTM core's ttm_tt_populate() still | |
| 479 | + | * unconditionally marks the tt as populated on driver-hook success. | |
| 480 | + | * Relying on ttm_tt_is_populated() for these would subtract pages that | |
| 481 | + | * were never added, underflowing the shrinker's counts. | |
| 482 | + | */ | |
| 483 | + | static void xe_bo_account_pin(struct xe_bo *bo) | |
| 484 | + | { | |
| 485 | + | struct xe_device *xe = xe_bo_device(bo); | |
| 486 | + | ||
| 487 | + | if (bo->ttm.pin_count == 1 && bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm) && | |
| 488 | + | !xe_ttm_bo_is_imported(&bo->ttm)) | |
| 489 | + | xe_ttm_tt_account_subtract(xe, bo->ttm.ttm); | |
| 490 | + | } | |
| 491 | + | ||
| 492 | + | /* | |
| 493 | + | * Counterpart to xe_bo_account_pin(). Must be called with @bo's dma-resv | |
| 494 | + | * held, before &ttm_buffer_object.pin_count is decremented by | |
| 495 | + | * ttm_bo_unpin(), so that the check against the true 1->0 transition sees | |
| 496 | + | * the pin count that is about to be released. See xe_bo_account_pin() for | |
| 497 | + | * why imported bos are excluded. | |
| 498 | + | * | |
| 499 | + | * On the true last unpin, also removes @bo from whichever pinned-bo list | |
| 500 | + | * (external or kernel_bo_present) it may currently be linked on, since a | |
| 501 | + | * bo's final unpin can happen through a pin path (e.g. framebuffer, | |
| 502 | + | * backup object) that has no notion of, or ownership over, that list. | |
| 503 | + | * This is safe and list-agnostic: list_del_init() only needs the node | |
| 504 | + | * itself, not knowledge of which list it is threaded through, and is a | |
| 505 | + | * no-op if @bo is not linked. | |
| 506 | + | */ | |
| 507 | + | static void xe_bo_account_unpin(struct xe_bo *bo) | |
| 508 | + | { | |
| 509 | + | struct xe_device *xe = xe_bo_device(bo); | |
| 510 | + | bool last_unpin = bo->ttm.pin_count == 1; | |
| 511 | + | ||
| 512 | + | if (last_unpin && !list_empty(&bo->pinned_link)) { | |
| 513 | + | spin_lock(&xe->pinned.lock); | |
| 514 | + | list_del_init(&bo->pinned_link); | |
| 515 | + | spin_unlock(&xe->pinned.lock); | |
| 516 | + | } | |
| 517 | + | ||
| 518 | + | if (last_unpin && bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm) && | |
| 519 | + | !xe_ttm_bo_is_imported(&bo->ttm)) | |
| 520 | + | xe_ttm_tt_account_add(xe, bo->ttm.ttm); | |
| 521 | + | } | |
| 522 | + | ||
| 523 | + | /** | |
| 524 | + | * xe_bo_pin_account() - Pin a bo and account its pages for the shrinker | |
| 525 | + | * @bo: The buffer object to pin. | |
| 526 | + | * | |
| 527 | + | * Pins @bo via ttm_bo_pin() and updates the shrinker's shrinkable / | |
| 528 | + | * purgeable page accounting to match. Must be called with @bo's dma-resv | |
| 529 | + | * held. Safe to call regardless of which pin path (kernel, external, | |
| 530 | + | * framebuffer, backup object, ...) is pinning @bo. | |
| 531 | + | */ | |
| 532 | + | void xe_bo_pin_account(struct xe_bo *bo) | |
| 533 | + | { | |
| 534 | + | ttm_bo_pin(&bo->ttm); | |
| 535 | + | xe_bo_account_pin(bo); | |
| 536 | + | } | |
| 537 | + | ||
| 538 | + | /** | |
| 539 | + | * xe_bo_unpin_account() - Unpin a bo and account its pages for the shrinker | |
| 540 | + | * @bo: The buffer object to unpin. | |
| 541 | + | * | |
| 542 | + | * Counterpart to xe_bo_pin_account(). Updates the shrinker's shrinkable / | |
| 543 | + | * purgeable page accounting to match, then unpins @bo via ttm_bo_unpin(). | |
| 544 | + | * Must be called with @bo's dma-resv held. | |
| 545 | + | */ | |
| 546 | + | void xe_bo_unpin_account(struct xe_bo *bo) | |
| 547 | + | { | |
| 548 | + | xe_bo_account_unpin(bo); | |
| 549 | + | ttm_bo_unpin(&bo->ttm); | |
| 550 | + | } | |
| 551 | + | ||
| 458 | 552 | static void update_global_total_pages(struct ttm_device *ttm_dev, | |
| 459 | 553 | long num_pages) | |
| 460 | 554 | { | |
| @@ -1389,7 +1483,8 @@ int xe_bo_notifier_prepare_pinned(struct xe_bo *bo) | |||
| 1389 | 1483 | } | |
| 1390 | 1484 | ||
| 1391 | 1485 | backup->parent_obj = xe_bo_get(bo); /* Released by bo_destroy */ | |
| 1392 | - | ttm_bo_pin(&backup->ttm); | |
| 1486 | + | /* Note: XE_BO_FLAG_SYSTEM resolves to XE_PL_TT so already populated. */ | |
| 1487 | + | xe_bo_pin_account(backup); | |
| 1393 | 1488 | bo->backup_obj = backup; | |
| 1394 | 1489 | } | |
| 1395 | 1490 | ||
| @@ -1409,7 +1504,7 @@ int xe_bo_notifier_unprepare_pinned(struct xe_bo *bo) | |||
| 1409 | 1504 | { | |
| 1410 | 1505 | xe_bo_lock(bo, false); | |
| 1411 | 1506 | if (bo->backup_obj) { | |
| 1412 | - | ttm_bo_unpin(&bo->backup_obj->ttm); | |
| 1507 | + | xe_bo_unpin_account(bo->backup_obj); | |
| 1413 | 1508 | xe_bo_put(bo->backup_obj); | |
| 1414 | 1509 | bo->backup_obj = NULL; | |
| 1415 | 1510 | } | |
| @@ -1620,7 +1715,7 @@ out_backup: | |||
| 1620 | 1715 | xe_bo_vunmap(backup); | |
| 1621 | 1716 | if (!bo->backup_obj) { | |
| 1622 | 1717 | if (xe_bo_is_pinned(backup)) | |
| 1623 | - | ttm_bo_unpin(&backup->ttm); | |
| 1718 | + | xe_bo_unpin_account(backup); | |
| 1624 | 1719 | xe_bo_put(backup); | |
| 1625 | 1720 | } | |
| 1626 | 1721 | out_unlock_bo: | |
| @@ -2012,15 +2107,6 @@ static vm_fault_t xe_err_to_fault_t(int err) | |||
| 2012 | 2107 | return VM_FAULT_SIGBUS; | |
| 2013 | 2108 | } | |
| 2014 | 2109 | ||
| 2015 | - | static bool xe_ttm_bo_is_imported(struct ttm_buffer_object *tbo) | |
| 2016 | - | { | |
| 2017 | - | dma_resv_assert_held(tbo->base.resv); | |
| 2018 | - | ||
| 2019 | - | return tbo->ttm && | |
| 2020 | - | (tbo->ttm->page_flags & (TTM_TT_FLAG_EXTERNAL | TTM_TT_FLAG_EXTERNAL_MAPPABLE)) == | |
| 2021 | - | TTM_TT_FLAG_EXTERNAL; | |
| 2022 | - | } | |
| 2023 | - | ||
| 2024 | 2110 | static vm_fault_t xe_bo_cpu_fault_fastpath(struct vm_fault *vmf, struct xe_device *xe, | |
| 2025 | 2111 | struct xe_bo *bo, bool needs_rpm) | |
| 2026 | 2112 | { | |
| @@ -3141,12 +3227,13 @@ uint64_t vram_region_gpu_offset(struct ttm_resource *res) | |||
| 3141 | 3227 | int xe_bo_pin_external(struct xe_bo *bo, bool in_place, struct drm_exec *exec) | |
| 3142 | 3228 | { | |
| 3143 | 3229 | struct xe_device *xe = xe_bo_device(bo); | |
| 3230 | + | bool first_pin = !xe_bo_is_pinned(bo); | |
| 3144 | 3231 | int err; | |
| 3145 | 3232 | ||
| 3146 | 3233 | xe_assert(xe, !bo->vm); | |
| 3147 | 3234 | xe_assert(xe, xe_bo_is_user(bo)); | |
| 3148 | 3235 | ||
| 3149 | - | if (!xe_bo_is_pinned(bo)) { | |
| 3236 | + | if (first_pin) { | |
| 3150 | 3237 | if (!in_place) { | |
| 3151 | 3238 | err = xe_bo_validate(bo, NULL, false, exec); | |
| 3152 | 3239 | if (err) | |
| @@ -3158,9 +3245,7 @@ int xe_bo_pin_external(struct xe_bo *bo, bool in_place, struct drm_exec *exec) | |||
| 3158 | 3245 | spin_unlock(&xe->pinned.lock); | |
| 3159 | 3246 | } | |
| 3160 | 3247 | ||
| 3161 | - | ttm_bo_pin(&bo->ttm); | |
| 3162 | - | if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm)) | |
| 3163 | - | xe_ttm_tt_account_subtract(xe, bo->ttm.ttm); | |
| 3248 | + | xe_bo_pin_account(bo); | |
| 3164 | 3249 | ||
| 3165 | 3250 | /* | |
| 3166 | 3251 | * FIXME: If we always use the reserve / unreserve functions for locking | |
| @@ -3216,9 +3301,7 @@ int xe_bo_pin(struct xe_bo *bo, struct drm_exec *exec) | |||
| 3216 | 3301 | spin_unlock(&xe->pinned.lock); | |
| 3217 | 3302 | } | |
| 3218 | 3303 | ||
| 3219 | - | ttm_bo_pin(&bo->ttm); | |
| 3220 | - | if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm)) | |
| 3221 | - | xe_ttm_tt_account_subtract(xe, bo->ttm.ttm); | |
| 3304 | + | xe_bo_pin_account(bo); | |
| 3222 | 3305 | ||
| 3223 | 3306 | /* | |
| 3224 | 3307 | * FIXME: If we always use the reserve / unreserve functions for locking | |
| @@ -3247,14 +3330,7 @@ void xe_bo_unpin_external(struct xe_bo *bo) | |||
| 3247 | 3330 | xe_assert(xe, xe_bo_is_pinned(bo)); | |
| 3248 | 3331 | xe_assert(xe, xe_bo_is_user(bo)); | |
| 3249 | 3332 | ||
| 3250 | - | spin_lock(&xe->pinned.lock); | |
| 3251 | - | if (bo->ttm.pin_count == 1 && !list_empty(&bo->pinned_link)) | |
| 3252 | - | list_del_init(&bo->pinned_link); | |
| 3253 | - | spin_unlock(&xe->pinned.lock); | |
| 3254 | - | ||
| 3255 | - | ttm_bo_unpin(&bo->ttm); | |
| 3256 | - | if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm)) | |
| 3257 | - | xe_ttm_tt_account_add(xe, bo->ttm.ttm); | |
| 3333 | + | xe_bo_unpin_account(bo); | |
| 3258 | 3334 | ||
| 3259 | 3335 | /* | |
| 3260 | 3336 | * FIXME: If we always use the reserve / unreserve functions for locking | |
| @@ -3272,21 +3348,16 @@ void xe_bo_unpin(struct xe_bo *bo) | |||
| 3272 | 3348 | xe_assert(xe, xe_bo_is_pinned(bo)); | |
| 3273 | 3349 | ||
| 3274 | 3350 | if (mem_type_is_vram(place->mem_type) || bo->flags & XE_BO_FLAG_GGTT) { | |
| 3275 | - | spin_lock(&xe->pinned.lock); | |
| 3276 | 3351 | xe_assert(xe, !list_empty(&bo->pinned_link)); | |
| 3277 | - | list_del_init(&bo->pinned_link); | |
| 3278 | - | spin_unlock(&xe->pinned.lock); | |
| 3279 | 3352 | ||
| 3280 | 3353 | if (bo->backup_obj) { | |
| 3281 | 3354 | if (xe_bo_is_pinned(bo->backup_obj)) | |
| 3282 | - | ttm_bo_unpin(&bo->backup_obj->ttm); | |
| 3355 | + | xe_bo_unpin_account(bo->backup_obj); | |
| 3283 | 3356 | xe_bo_put(bo->backup_obj); | |
| 3284 | 3357 | bo->backup_obj = NULL; | |
| 3285 | 3358 | } | |
| 3286 | 3359 | } | |
| 3287 | - | ttm_bo_unpin(&bo->ttm); | |
| 3288 | - | if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm)) | |
| 3289 | - | xe_ttm_tt_account_add(xe, bo->ttm.ttm); | |
| 3360 | + | xe_bo_unpin_account(bo); | |
| 3290 | 3361 | } | |
| 3291 | 3362 | ||
| 3292 | 3363 | /** | |
modified drivers/gpu/drm/xe/xe_bo.h
| @@ -229,6 +229,8 @@ int xe_bo_pin_external(struct xe_bo *bo, bool in_place, struct drm_exec *exec); | |||
| 229 | 229 | int xe_bo_pin(struct xe_bo *bo, struct drm_exec *exec); | |
| 230 | 230 | void xe_bo_unpin_external(struct xe_bo *bo); | |
| 231 | 231 | void xe_bo_unpin(struct xe_bo *bo); | |
| 232 | + | void xe_bo_pin_account(struct xe_bo *bo); | |
| 233 | + | void xe_bo_unpin_account(struct xe_bo *bo); | |
| 232 | 234 | int xe_bo_validate(struct xe_bo *bo, struct xe_vm *vm, bool allow_res_evict, | |
| 233 | 235 | struct drm_exec *exec); | |
| 234 | 236 | ||
modified drivers/gpu/drm/xe/xe_i2c.c
| @@ -324,12 +324,15 @@ static void xe_i2c_remove(void *data) | |||
| 324 | 324 | xe_i2c_irq_reset(xe); | |
| 325 | 325 | xe_amc_exit(i2c); | |
| 326 | 326 | ||
| 327 | + | /* Stop the notifier from arming the client work before teardown. */ | |
| 328 | + | bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier); | |
| 329 | + | cancel_work_sync(&i2c->work); | |
| 330 | + | ||
| 327 | 331 | for (i = 0; i < XE_I2C_MAX_CLIENTS; i++) { | |
| 328 | 332 | i2c_unregister_device(i2c->client[i]); | |
| 329 | 333 | i2c->client[i] = NULL; | |
| 330 | 334 | } | |
| 331 | 335 | ||
| 332 | - | bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier); | |
| 333 | 336 | xe_i2c_unregister_adapter(i2c); | |
| 334 | 337 | xe->i2c = NULL; | |
| 335 | 338 | } | |
modified drivers/gpu/drm/xe/xe_lrc.c
| @@ -1099,8 +1099,7 @@ static void xe_lrc_finish(struct xe_lrc *lrc) | |||
| 1099 | 1099 | #define CONTEXT_ACTIVE XE_LRC_CTX_TIMESTAMP_ACTIVE | |
| 1100 | 1100 | static ssize_t setup_utilization_wa(struct xe_lrc *lrc, | |
| 1101 | 1101 | struct xe_hw_engine *hwe, | |
| 1102 | - | u32 *batch, | |
| 1103 | - | size_t max_len) | |
| 1102 | + | u32 *batch, size_t max_len, bool indirect) | |
| 1104 | 1103 | { | |
| 1105 | 1104 | u32 *cmd = batch; | |
| 1106 | 1105 | ||
| @@ -1131,19 +1130,25 @@ static ssize_t setup_utilization_wa(struct xe_lrc *lrc, | |||
| 1131 | 1130 | } | |
| 1132 | 1131 | ||
| 1133 | 1132 | static ssize_t setup_timestamp_wa(struct xe_lrc *lrc, struct xe_hw_engine *hwe, | |
| 1134 | - | u32 *batch, size_t max_len) | |
| 1133 | + | u32 *batch, size_t max_len, bool indirect) | |
| 1135 | 1134 | { | |
| 1136 | 1135 | const u32 ts_addr = __xe_lrc_ctx_timestamp_ggtt_addr(lrc); | |
| 1137 | 1136 | u32 *cmd = batch; | |
| 1138 | 1137 | ||
| 1139 | - | if (!XE_GT_WA(lrc->gt, 16010904313) || | |
| 1140 | - | !(hwe->class == XE_ENGINE_CLASS_RENDER || | |
| 1141 | - | hwe->class == XE_ENGINE_CLASS_COMPUTE || | |
| 1142 | - | hwe->class == XE_ENGINE_CLASS_COPY || | |
| 1138 | + | if (!XE_GT_WA(lrc->gt, 16010904313)) | |
| 1139 | + | return 0; | |
| 1140 | + | ||
| 1141 | + | if (!indirect && | |
| 1142 | + | !(hwe->class == XE_ENGINE_CLASS_COPY || | |
| 1143 | 1143 | hwe->class == XE_ENGINE_CLASS_VIDEO_DECODE || | |
| 1144 | 1144 | hwe->class == XE_ENGINE_CLASS_VIDEO_ENHANCE)) | |
| 1145 | 1145 | return 0; | |
| 1146 | 1146 | ||
| 1147 | + | if (indirect && | |
| 1148 | + | !(hwe->class == XE_ENGINE_CLASS_RENDER || | |
| 1149 | + | hwe->class == XE_ENGINE_CLASS_COMPUTE)) | |
| 1150 | + | return 0; | |
| 1151 | + | ||
| 1147 | 1152 | if (xe_gt_WARN_ON(lrc->gt, max_len < 12)) | |
| 1148 | 1153 | return -ENOSPC; | |
| 1149 | 1154 | ||
| @@ -1169,7 +1174,8 @@ static ssize_t setup_timestamp_wa(struct xe_lrc *lrc, struct xe_hw_engine *hwe, | |||
| 1169 | 1174 | ||
| 1170 | 1175 | static ssize_t setup_configfs_post_ctx_restore_bb(struct xe_lrc *lrc, | |
| 1171 | 1176 | struct xe_hw_engine *hwe, | |
| 1172 | - | u32 *batch, size_t max_len) | |
| 1177 | + | u32 *batch, size_t max_len, | |
| 1178 | + | bool indirect) | |
| 1173 | 1179 | { | |
| 1174 | 1180 | struct xe_device *xe = gt_to_xe(lrc->gt); | |
| 1175 | 1181 | const u32 *user_batch; | |
| @@ -1198,7 +1204,8 @@ static ssize_t setup_configfs_post_ctx_restore_bb(struct xe_lrc *lrc, | |||
| 1198 | 1204 | ||
| 1199 | 1205 | static ssize_t setup_configfs_mid_ctx_restore_bb(struct xe_lrc *lrc, | |
| 1200 | 1206 | struct xe_hw_engine *hwe, | |
| 1201 | - | u32 *batch, size_t max_len) | |
| 1207 | + | u32 *batch, size_t max_len, | |
| 1208 | + | bool indirect) | |
| 1202 | 1209 | { | |
| 1203 | 1210 | struct xe_device *xe = gt_to_xe(lrc->gt); | |
| 1204 | 1211 | const u32 *user_batch; | |
| @@ -1227,7 +1234,8 @@ static ssize_t setup_configfs_mid_ctx_restore_bb(struct xe_lrc *lrc, | |||
| 1227 | 1234 | ||
| 1228 | 1235 | static ssize_t setup_invalidate_state_cache_wa(struct xe_lrc *lrc, | |
| 1229 | 1236 | struct xe_hw_engine *hwe, | |
| 1230 | - | u32 *batch, size_t max_len) | |
| 1237 | + | u32 *batch, size_t max_len, | |
| 1238 | + | bool indirect) | |
| 1231 | 1239 | { | |
| 1232 | 1240 | u32 *cmd = batch; | |
| 1233 | 1241 | ||
| @@ -1247,7 +1255,8 @@ static ssize_t setup_invalidate_state_cache_wa(struct xe_lrc *lrc, | |||
| 1247 | 1255 | ||
| 1248 | 1256 | static ssize_t setup_invalidate_auxccs_wa(struct xe_lrc *lrc, | |
| 1249 | 1257 | struct xe_hw_engine *hwe, | |
| 1250 | - | u32 *batch, size_t max_len) | |
| 1258 | + | u32 *batch, size_t max_len, | |
| 1259 | + | bool indirect) | |
| 1251 | 1260 | { | |
| 1252 | 1261 | struct xe_gt *gt = lrc->gt; | |
| 1253 | 1262 | u32 *(*emit)(struct xe_gt *gt, u32 *cmd) = | |
| @@ -1264,7 +1273,7 @@ static ssize_t setup_invalidate_auxccs_wa(struct xe_lrc *lrc, | |||
| 1264 | 1273 | ||
| 1265 | 1274 | struct bo_setup { | |
| 1266 | 1275 | ssize_t (*setup)(struct xe_lrc *lrc, struct xe_hw_engine *hwe, | |
| 1267 | - | u32 *batch, size_t max_size); | |
| 1276 | + | u32 *batch, size_t max_size, bool indirect); | |
| 1268 | 1277 | }; | |
| 1269 | 1278 | ||
| 1270 | 1279 | struct bo_setup_state { | |
| @@ -1273,6 +1282,7 @@ struct bo_setup_state { | |||
| 1273 | 1282 | struct xe_hw_engine *hwe; | |
| 1274 | 1283 | size_t max_size; | |
| 1275 | 1284 | size_t reserve_dw; | |
| 1285 | + | bool indirect; | |
| 1276 | 1286 | unsigned int offset; | |
| 1277 | 1287 | const struct bo_setup *funcs; | |
| 1278 | 1288 | unsigned int num_funcs; | |
| @@ -1298,7 +1308,8 @@ static int setup_bo(struct bo_setup_state *state) | |||
| 1298 | 1308 | ||
| 1299 | 1309 | for (size_t i = 0; i < state->num_funcs; i++) { | |
| 1300 | 1310 | ssize_t len = state->funcs[i].setup(state->lrc, state->hwe, | |
| 1301 | - | state->ptr, remain); | |
| 1311 | + | state->ptr, remain, | |
| 1312 | + | state->indirect); | |
| 1302 | 1313 | ||
| 1303 | 1314 | remain -= len; | |
| 1304 | 1315 | ||
| @@ -1404,6 +1415,7 @@ setup_indirect_ctx(struct xe_lrc *lrc, struct xe_hw_engine *hwe) | |||
| 1404 | 1415 | struct bo_setup_state state = { | |
| 1405 | 1416 | .lrc = lrc, | |
| 1406 | 1417 | .hwe = hwe, | |
| 1418 | + | .indirect = true, | |
| 1407 | 1419 | .max_size = (63 * 64) /* max 63 cachelines */, | |
| 1408 | 1420 | .buffer = NULL, | |
| 1409 | 1421 | .offset = __xe_lrc_indirect_ctx_offset(lrc), | |
modified drivers/gpu/drm/xe/xe_mmio.c
| @@ -320,6 +320,7 @@ u64 xe_mmio_read64_2x32(struct xe_mmio *mmio, struct xe_reg reg) | |||
| 320 | 320 | return (u64)udw << 32 | ldw; | |
| 321 | 321 | } | |
| 322 | 322 | ||
| 323 | + | #define __XE_MMIO_WAIT_MAX_BACKOFF_100MS (100 * USEC_PER_MSEC) | |
| 323 | 324 | static int __xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u32 val, | |
| 324 | 325 | u32 timeout_us, u32 *out_val, bool atomic, bool expect_match) | |
| 325 | 326 | { | |
| @@ -350,10 +351,10 @@ static int __xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u | |||
| 350 | 351 | wait = ktime_us_delta(end, cur); | |
| 351 | 352 | ||
| 352 | 353 | if (atomic) | |
| 353 | - | udelay(wait); | |
| 354 | + | udelay(min_t(s64, wait, (MAX_UDELAY_MS * 1000))); | |
| 354 | 355 | else | |
| 355 | 356 | usleep_range(wait, wait << 1); | |
| 356 | - | wait <<= 1; | |
| 357 | + | wait = min_t(s64, wait << 1, __XE_MMIO_WAIT_MAX_BACKOFF_100MS); | |
| 357 | 358 | } | |
| 358 | 359 | ||
| 359 | 360 | if (ret != 0) { | |
modified drivers/gpu/drm/xe/xe_pci_sriov.c
| @@ -82,16 +82,33 @@ static void pf_engine_activity_stats(struct xe_device *xe, unsigned int num_vfs, | |||
| 82 | 82 | } | |
| 83 | 83 | } | |
| 84 | 84 | ||
| 85 | - | static int resize_vf_vram_bar(struct xe_device *xe, int num_vfs) | |
| 85 | + | static int pf_resize_vf_vram_bar(struct xe_device *xe, int num_vfs) | |
| 86 | 86 | { | |
| 87 | 87 | struct pci_dev *pdev = to_pci_dev(xe->drm.dev); | |
| 88 | + | char buf[10]; | |
| 88 | 89 | u32 sizes; | |
| 90 | + | int size; | |
| 91 | + | int err; | |
| 92 | + | ||
| 93 | + | if (!IS_DGFX(xe)) | |
| 94 | + | return 0; | |
| 89 | 95 | ||
| 90 | 96 | sizes = pci_iov_vf_bar_get_sizes(pdev, VF_LMEM_BAR, num_vfs); | |
| 91 | 97 | if (!sizes) | |
| 92 | 98 | return 0; | |
| 93 | 99 | ||
| 94 | - | return pci_iov_vf_bar_set_size(pdev, VF_LMEM_BAR, __fls(sizes)); | |
| 100 | + | size = __fls(sizes); | |
| 101 | + | string_get_size(pci_rebar_size_to_bytes(size), 1, STRING_UNITS_2, buf, sizeof(buf)); | |
| 102 | + | ||
| 103 | + | err = pci_iov_vf_bar_set_size(pdev, VF_LMEM_BAR, size); | |
| 104 | + | if (err) { | |
| 105 | + | xe_sriov_notice(xe, "Failed to resize VF BAR %u to %s (%pe)\n", | |
| 106 | + | VF_LMEM_BAR, buf, ERR_PTR(err)); | |
| 107 | + | return err; | |
| 108 | + | } | |
| 109 | + | ||
| 110 | + | xe_sriov_dbg(xe, "VF LMEM BAR resized to %s\n", buf); | |
| 111 | + | return 0; | |
| 95 | 112 | } | |
| 96 | 113 | ||
| 97 | 114 | static int pf_prepare_vfs_enabling(struct xe_device *xe) | |
| @@ -142,11 +159,7 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs) | |||
| 142 | 159 | if (err < 0) | |
| 143 | 160 | goto failed; | |
| 144 | 161 | ||
| 145 | - | if (IS_DGFX(xe)) { | |
| 146 | - | err = resize_vf_vram_bar(xe, num_vfs); | |
| 147 | - | if (err) | |
| 148 | - | xe_sriov_info(xe, "Failed to set VF LMEM BAR size: %d\n", err); | |
| 149 | - | } | |
| 162 | + | pf_resize_vf_vram_bar(xe, num_vfs); | |
| 150 | 163 | ||
| 151 | 164 | err = pci_enable_sriov(pdev, num_vfs); | |
| 152 | 165 | if (err < 0) | |
| @@ -164,6 +177,7 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs) | |||
| 164 | 177 | return num_vfs; | |
| 165 | 178 | ||
| 166 | 179 | failed: | |
| 180 | + | pf_resize_vf_vram_bar(xe, xe->sriov.pf.device_total_vfs); | |
| 167 | 181 | xe_sriov_pf_unprovision_vfs(xe, num_vfs); | |
| 168 | 182 | xe_pm_runtime_put(xe); | |
| 169 | 183 | pf_finish_vfs_enabling(xe); | |
| @@ -191,6 +205,8 @@ static int pf_disable_vfs(struct xe_device *xe) | |||
| 191 | 205 | ||
| 192 | 206 | pci_disable_sriov(pdev); | |
| 193 | 207 | ||
| 208 | + | pf_resize_vf_vram_bar(xe, xe->sriov.pf.device_total_vfs); | |
| 209 | + | ||
| 194 | 210 | xe_sriov_pf_reprovision_default(xe); | |
| 195 | 211 | ||
| 196 | 212 | pf_reset_vfs(xe, num_vfs); | |
modified drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
| @@ -19,20 +19,20 @@ | |||
| 19 | 19 | #include "xe_sysctrl_mailbox_types.h" | |
| 20 | 20 | ||
| 21 | 21 | struct xe_sysctrl_mailbox_msg_hdr { | |
| 22 | - | __le32 data; | |
| 23 | - | } __packed; | |
| 22 | + | u32 data; | |
| 23 | + | }; | |
| 24 | 24 | ||
| 25 | 25 | #define XE_SYSCTRL_HDR_GROUP_ID(hdr) \ | |
| 26 | - | FIELD_GET(SYSCTRL_HDR_GROUP_ID_MASK, le32_to_cpu((hdr)->data)) | |
| 26 | + | FIELD_GET(SYSCTRL_HDR_GROUP_ID_MASK, (hdr)->data) | |
| 27 | 27 | ||
| 28 | 28 | #define XE_SYSCTRL_HDR_COMMAND(hdr) \ | |
| 29 | - | FIELD_GET(SYSCTRL_HDR_COMMAND_MASK, le32_to_cpu((hdr)->data)) | |
| 29 | + | FIELD_GET(SYSCTRL_HDR_COMMAND_MASK, (hdr)->data) | |
| 30 | 30 | ||
| 31 | 31 | #define XE_SYSCTRL_HDR_IS_RESPONSE(hdr) \ | |
| 32 | - | FIELD_GET(SYSCTRL_HDR_IS_RESPONSE, le32_to_cpu((hdr)->data)) | |
| 32 | + | FIELD_GET(SYSCTRL_HDR_IS_RESPONSE, (hdr)->data) | |
| 33 | 33 | ||
| 34 | 34 | #define XE_SYSCTRL_HDR_RESULT(hdr) \ | |
| 35 | - | FIELD_GET(SYSCTRL_HDR_RESULT_MASK, le32_to_cpu((hdr)->data)) | |
| 35 | + | FIELD_GET(SYSCTRL_HDR_RESULT_MASK, (hdr)->data) | |
| 36 | 36 | ||
| 37 | 37 | static bool sysctrl_wait_bit_clear(struct xe_sysctrl *sc, u32 bit_mask, | |
| 38 | 38 | unsigned int timeout_ms) | |
| @@ -126,8 +126,8 @@ static int sysctrl_prepare_command(struct xe_device *xe, | |||
| 126 | 126 | return -ENOMEM; | |
| 127 | 127 | ||
| 128 | 128 | hdr = (struct xe_sysctrl_mailbox_msg_hdr *)buffer; | |
| 129 | - | hdr->data = cpu_to_le32(FIELD_PREP(SYSCTRL_HDR_GROUP_ID_MASK, group_id) | | |
| 130 | - | FIELD_PREP(SYSCTRL_HDR_COMMAND_MASK, command)); | |
| 129 | + | hdr->data = FIELD_PREP(SYSCTRL_HDR_GROUP_ID_MASK, group_id) | | |
| 130 | + | FIELD_PREP(SYSCTRL_HDR_COMMAND_MASK, command); | |
| 131 | 131 | ||
| 132 | 132 | if (data_in && data_in_len) | |
| 133 | 133 | memcpy(buffer + sizeof(*hdr), data_in, data_in_len); | |
modified drivers/hid/bpf/hid_bpf_dispatch.c
| @@ -453,7 +453,7 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz, | |||
| 453 | 453 | (u64)(long)ctx, | |
| 454 | 454 | true); /* prevent infinite recursions */ | |
| 455 | 455 | ||
| 456 | - | if (ret > size) | |
| 456 | + | if (ret > (ssize_t)size) | |
| 457 | 457 | ret = size; | |
| 458 | 458 | if (ret > 0) | |
| 459 | 459 | memcpy(buf, dma_data, ret); | |
modified drivers/hid/hid-ids.h
| @@ -1510,6 +1510,9 @@ | |||
| 1510 | 1510 | #define USB_DEVICE_ID_ASUS_MD_5110 0x5110 | |
| 1511 | 1511 | #define USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART 0x7100 | |
| 1512 | 1512 | ||
| 1513 | + | #define USB_VENDOR_ID_TURTLE_BEACH 0x10f5 | |
| 1514 | + | #define USB_DEVICE_ID_TB_VELOCITYONE_RACE 0x7077 | |
| 1515 | + | ||
| 1513 | 1516 | #define USB_VENDOR_ID_TWINHAN 0x6253 | |
| 1514 | 1517 | #define USB_DEVICE_ID_TWINHAN_IR_REMOTE 0x0100 | |
| 1515 | 1518 | ||
modified drivers/hid/hid-logitech-dj.c
| @@ -121,7 +121,6 @@ enum recvr_type { | |||
| 121 | 121 | recvr_type_27mhz, | |
| 122 | 122 | recvr_type_bluetooth, | |
| 123 | 123 | recvr_type_dinovo, | |
| 124 | - | recvr_type_bolt, | |
| 125 | 124 | }; | |
| 126 | 125 | ||
| 127 | 126 | struct dj_report { | |
| @@ -1157,10 +1156,6 @@ static void logi_hidpp_recv_queue_notif(struct hid_device *hdev, | |||
| 1157 | 1156 | logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem); | |
| 1158 | 1157 | workitem.reports_supported |= STD_KEYBOARD; | |
| 1159 | 1158 | break; | |
| 1160 | - | case 0x10: | |
| 1161 | - | device_type = "Bolt"; | |
| 1162 | - | logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem); | |
| 1163 | - | break; | |
| 1164 | 1159 | } | |
| 1165 | 1160 | ||
| 1166 | 1161 | /* custom receiver device (eg. powerplay) */ | |
| @@ -1750,24 +1745,6 @@ static int logi_dj_hidpp_event(struct hid_device *hdev, | |||
| 1750 | 1745 | ||
| 1751 | 1746 | dj_dev = djrcv_dev->paired_dj_devices[device_index]; | |
| 1752 | 1747 | ||
| 1753 | - | /* | |
| 1754 | - | * Bolt receivers send explicit unpair notifications as HID++ events; | |
| 1755 | - | * queue device removal when we receive one. | |
| 1756 | - | */ | |
| 1757 | - | if (djrcv_dev->type == recvr_type_bolt && | |
| 1758 | - | hidpp_report->report_id == REPORT_ID_HIDPP_SHORT && | |
| 1759 | - | hidpp_report->sub_id == REPORT_TYPE_NOTIF_DEVICE_UNPAIRED) { | |
| 1760 | - | struct dj_workitem workitem = { | |
| 1761 | - | .device_index = device_index, | |
| 1762 | - | .type = WORKITEM_TYPE_UNPAIRED, | |
| 1763 | - | }; | |
| 1764 | - | ||
| 1765 | - | kfifo_in(&djrcv_dev->notif_fifo, &workitem, sizeof(workitem)); | |
| 1766 | - | schedule_work(&djrcv_dev->work); | |
| 1767 | - | spin_unlock_irqrestore(&djrcv_dev->lock, flags); | |
| 1768 | - | return false; | |
| 1769 | - | } | |
| 1770 | - | ||
| 1771 | 1748 | /* | |
| 1772 | 1749 | * With 27 MHz receivers, we do not get an explicit unpair event, | |
| 1773 | 1750 | * remove the old device if the user has paired a *different* device. | |
| @@ -1907,9 +1884,6 @@ static int logi_dj_probe(struct hid_device *hdev, | |||
| 1907 | 1884 | * treat these as logitech-dj interfaces then this causes input events | |
| 1908 | 1885 | * reported through this extra interface to not be reported correctly. | |
| 1909 | 1886 | * To avoid this, we treat these as generic-hid devices. | |
| 1910 | - | * | |
| 1911 | - | * Bolt receivers only use LOGITECH_DJ_INTERFACE_NUMBER for receiver | |
| 1912 | - | * reporting. Treat all other Bolt interfaces as generic-hid devices. | |
| 1913 | 1887 | */ | |
| 1914 | 1888 | switch (id->driver_data) { | |
| 1915 | 1889 | case recvr_type_dj: no_dj_interfaces = 3; break; | |
| @@ -1923,20 +1897,10 @@ static int logi_dj_probe(struct hid_device *hdev, | |||
| 1923 | 1897 | } | |
| 1924 | 1898 | if (hid_is_usb(hdev)) { | |
| 1925 | 1899 | intf = to_usb_interface(hdev->dev.parent); | |
| 1926 | - | if (intf) { | |
| 1927 | - | bool generic_hid_interface; | |
| 1928 | - | ||
| 1929 | - | if (id->driver_data == recvr_type_bolt) | |
| 1930 | - | generic_hid_interface = | |
| 1931 | - | intf->altsetting->desc.bInterfaceNumber != | |
| 1932 | - | LOGITECH_DJ_INTERFACE_NUMBER; | |
| 1933 | - | else | |
| 1934 | - | generic_hid_interface = | |
| 1935 | - | intf->altsetting->desc.bInterfaceNumber >= no_dj_interfaces; | |
| 1936 | - | if (generic_hid_interface) { | |
| 1937 | - | hdev->quirks |= HID_QUIRK_INPUT_PER_APP; | |
| 1938 | - | return hid_hw_start(hdev, HID_CONNECT_DEFAULT); | |
| 1939 | - | } | |
| 1900 | + | if (intf && intf->altsetting->desc.bInterfaceNumber >= | |
| 1901 | + | no_dj_interfaces) { | |
| 1902 | + | hdev->quirks |= HID_QUIRK_INPUT_PER_APP; | |
| 1903 | + | return hid_hw_start(hdev, HID_CONNECT_DEFAULT); | |
| 1940 | 1904 | } | |
| 1941 | 1905 | } | |
| 1942 | 1906 | ||
| @@ -2139,10 +2103,6 @@ static const struct hid_device_id logi_dj_receivers[] = { | |||
| 2139 | 2103 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, | |
| 2140 | 2104 | USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_3), | |
| 2141 | 2105 | .driver_data = recvr_type_gaming_hidpp_ls_1_3}, | |
| 2142 | - | { /* Logitech Bolt receiver (0xc548) */ | |
| 2143 | - | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, | |
| 2144 | - | USB_DEVICE_ID_LOGITECH_BOLT_RECEIVER), | |
| 2145 | - | .driver_data = recvr_type_bolt}, | |
| 2146 | 2106 | { /* Logitech lightspeed receiver (0xc54d) */ | |
| 2147 | 2107 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, | |
| 2148 | 2108 | USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_4), | |
modified drivers/hid/hid-logitech-hidpp.c
| @@ -988,8 +988,7 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) | |||
| 988 | 988 | } | |
| 989 | 989 | ||
| 990 | 990 | /* the device might not be connected */ | |
| 991 | - | if (ret == HIDPP_ERROR_CONNECT_FAIL || | |
| 992 | - | ret == HIDPP_ERROR_RESOURCE_ERROR || | |
| 991 | + | if (ret == HIDPP_ERROR_RESOURCE_ERROR || | |
| 993 | 992 | ret == HIDPP_ERROR_UNKNOWN_DEVICE) | |
| 994 | 993 | return -EIO; | |
| 995 | 994 | ||
| @@ -4405,50 +4404,8 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp) | |||
| 4405 | 4404 | return ret; | |
| 4406 | 4405 | } | |
| 4407 | 4406 | ||
| 4408 | - | static bool hidpp_is_bolt_child(struct hid_device *hdev) | |
| 4409 | - | { | |
| 4410 | - | struct device *parent = hdev->dev.parent; | |
| 4411 | - | struct hid_device *receiver_hdev; | |
| 4412 | - | ||
| 4413 | - | if (!parent) | |
| 4414 | - | return false; | |
| 4415 | - | ||
| 4416 | - | receiver_hdev = to_hid_device(parent); | |
| 4417 | - | return receiver_hdev->vendor == USB_VENDOR_ID_LOGITECH && | |
| 4418 | - | receiver_hdev->product == USB_DEVICE_ID_LOGITECH_BOLT_RECEIVER; | |
| 4419 | - | } | |
| 4420 | - | ||
| 4421 | - | static int hidpp_bolt_init(struct hidpp_device *hidpp) | |
| 4422 | - | { | |
| 4423 | - | struct hid_device *hdev = hidpp->hid_dev; | |
| 4424 | - | char *name; | |
| 4425 | - | int ret; | |
| 4426 | - | ||
| 4427 | - | ret = hidpp_serial_init(hidpp); | |
| 4428 | - | if (ret) | |
| 4429 | - | return ret; | |
| 4430 | - | ||
| 4431 | - | name = hidpp_get_device_name(hidpp); | |
| 4432 | - | if (!name) | |
| 4433 | - | return -EIO; | |
| 4434 | - | ||
| 4435 | - | snprintf(hdev->name, sizeof(hdev->name), "%s", name); | |
| 4436 | - | dbg_hid("HID++ Bolt: Got name: %s\n", name); | |
| 4437 | - | ||
| 4438 | - | kfree(name); | |
| 4439 | - | return 0; | |
| 4440 | - | } | |
| 4441 | - | ||
| 4442 | - | static int hidpp_receiver_init(struct hidpp_device *hidpp) | |
| 4443 | - | { | |
| 4444 | - | if (hidpp_is_bolt_child(hidpp->hid_dev)) | |
| 4445 | - | return hidpp_bolt_init(hidpp); | |
| 4446 | - | ||
| 4447 | - | return hidpp_unifying_init(hidpp); | |
| 4448 | - | } | |
| 4449 | - | ||
| 4450 | 4407 | /* Get name + serial for USB and Bluetooth HID++ devices */ | |
| 4451 | - | static void hidpp_non_receiver_init(struct hidpp_device *hidpp) | |
| 4408 | + | static void hidpp_non_unifying_init(struct hidpp_device *hidpp) | |
| 4452 | 4409 | { | |
| 4453 | 4410 | struct hid_device *hdev = hidpp->hid_dev; | |
| 4454 | 4411 | char *name; | |
| @@ -4800,9 +4757,9 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 4800 | 4757 | ||
| 4801 | 4758 | /* Get name + serial, store in hdev->name + hdev->uniq */ | |
| 4802 | 4759 | if (id->group == HID_GROUP_LOGITECH_DJ_DEVICE) | |
| 4803 | - | hidpp_receiver_init(hidpp); | |
| 4760 | + | hidpp_unifying_init(hidpp); | |
| 4804 | 4761 | else | |
| 4805 | - | hidpp_non_receiver_init(hidpp); | |
| 4762 | + | hidpp_non_unifying_init(hidpp); | |
| 4806 | 4763 | ||
| 4807 | 4764 | if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) | |
| 4808 | 4765 | connect_mask &= ~HID_CONNECT_HIDINPUT; | |
modified drivers/hid/hid-multitouch.c
| @@ -2249,7 +2249,7 @@ static void mt_remove(struct hid_device *hdev) | |||
| 2249 | 2249 | { | |
| 2250 | 2250 | struct mt_device *td = hid_get_drvdata(hdev); | |
| 2251 | 2251 | ||
| 2252 | - | timer_delete_sync(&td->release_timer); | |
| 2252 | + | timer_shutdown_sync(&td->release_timer); | |
| 2253 | 2253 | ||
| 2254 | 2254 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); | |
| 2255 | 2255 | hid_hw_stop(hdev); | |
modified drivers/hid/hid-universal-pidff.c
| @@ -187,6 +187,7 @@ static const struct hid_device_id universal_pidff_devices[] = { | |||
| 187 | 187 | { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_FORTE) }, | |
| 188 | 188 | { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_LA_PRIMA) }, | |
| 189 | 189 | { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_TONY_KANAAN) }, | |
| 190 | + | { HID_USB_DEVICE(USB_VENDOR_ID_TURTLE_BEACH, USB_DEVICE_ID_TB_VELOCITYONE_RACE)}, | |
| 190 | 191 | {} | |
| 191 | 192 | }; | |
| 192 | 193 | MODULE_DEVICE_TABLE(hid, universal_pidff_devices); | |
modified drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
| @@ -606,7 +606,8 @@ static int quicki2c_alloc_report_buf(struct quicki2c_device *qcdev) | |||
| 606 | 606 | */ | |
| 607 | 607 | max_report_len = max(le16_to_cpu(qcdev->dev_desc.max_input_len), SZ_4K); | |
| 608 | 608 | ||
| 609 | - | qcdev->input_buf = devm_kzalloc(qcdev->dev, max_report_len, GFP_KERNEL); | |
| 609 | + | qcdev->input_buf = devm_kzalloc(qcdev->dev, | |
| 610 | + | HIDI2C_PACKET_LEN(max_report_len), GFP_KERNEL); | |
| 610 | 611 | if (!qcdev->input_buf) | |
| 611 | 612 | return -ENOMEM; | |
| 612 | 613 | ||
| @@ -616,7 +617,8 @@ static int quicki2c_alloc_report_buf(struct quicki2c_device *qcdev) | |||
| 616 | 617 | max_report_len = max(le16_to_cpu(qcdev->dev_desc.max_output_len), | |
| 617 | 618 | max_report_len); | |
| 618 | 619 | ||
| 619 | - | qcdev->report_buf = devm_kzalloc(qcdev->dev, max_report_len, GFP_KERNEL); | |
| 620 | + | qcdev->report_buf = devm_kzalloc(qcdev->dev, | |
| 621 | + | HIDI2C_PACKET_LEN(max_report_len), GFP_KERNEL); | |
| 620 | 622 | if (!qcdev->report_buf) | |
| 621 | 623 | return -ENOMEM; | |
| 622 | 624 | ||
modified drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
| @@ -552,7 +552,8 @@ static int quickspi_alloc_report_buf(struct quickspi_device *qsdev) | |||
| 552 | 552 | max_input_len = max(le16_to_cpu(qsdev->dev_desc.rep_desc_len), | |
| 553 | 553 | le16_to_cpu(qsdev->dev_desc.max_input_len)); | |
| 554 | 554 | ||
| 555 | - | qsdev->input_buf = devm_kzalloc(qsdev->dev, max_input_len, GFP_KERNEL); | |
| 555 | + | qsdev->input_buf = devm_kzalloc(qsdev->dev, | |
| 556 | + | HIDSPI_INPUT_BODY_SIZE(max_input_len), GFP_KERNEL); | |
| 556 | 557 | if (!qsdev->input_buf) | |
| 557 | 558 | return -ENOMEM; | |
| 558 | 559 | ||
modified drivers/i2c/busses/i2c-at91-master.c
| @@ -921,8 +921,14 @@ int at91_twi_probe_master(struct platform_device *pdev, | |||
| 921 | 921 | at91_calc_twi_clock(dev); | |
| 922 | 922 | ||
| 923 | 923 | rc = at91_init_twi_recovery_info(pdev, dev); | |
| 924 | - | if (rc == -EPROBE_DEFER) | |
| 924 | + | if (rc == -EPROBE_DEFER) { | |
| 925 | + | /* | |
| 926 | + | * The DMA channels were already set up above, release them | |
| 927 | + | * before deferring the probe so they are not leaked. | |
| 928 | + | */ | |
| 929 | + | at91_twi_dma_release(dev); | |
| 925 | 930 | return rc; | |
| 931 | + | } | |
| 926 | 932 | ||
| 927 | 933 | dev->adapter.algo = &at91_twi_algorithm; | |
| 928 | 934 | dev->adapter.quirks = &at91_twi_quirks; | |
modified drivers/i2c/busses/i2c-qcom-geni.c
| @@ -1003,13 +1003,14 @@ static int geni_i2c_xfer(struct i2c_adapter *adap, | |||
| 1003 | 1003 | ||
| 1004 | 1004 | ret = gi2c->dev_data->set_rate(&gi2c->se, gi2c->clk_freq_out); | |
| 1005 | 1005 | if (ret) | |
| 1006 | - | return ret; | |
| 1006 | + | goto out_pm; | |
| 1007 | 1007 | ||
| 1008 | 1008 | if (gi2c->gpi_mode) | |
| 1009 | 1009 | ret = geni_i2c_gpi_xfer(gi2c, msgs, num); | |
| 1010 | 1010 | else | |
| 1011 | 1011 | ret = geni_i2c_fifo_xfer(gi2c, msgs, num); | |
| 1012 | 1012 | ||
| 1013 | + | out_pm: | |
| 1013 | 1014 | pm_runtime_put_autosuspend(gi2c->se.dev); | |
| 1014 | 1015 | gi2c->cur = NULL; | |
| 1015 | 1016 | gi2c->err = 0; | |
modified drivers/i2c/busses/i2c-xiic.c
| @@ -73,6 +73,9 @@ enum i2c_scl_freq { | |||
| 73 | 73 | * @prev_msg_tx: Previous message is Tx | |
| 74 | 74 | * @quirks: To hold platform specific bug info | |
| 75 | 75 | * @smbus_block_read: Flag to handle block read | |
| 76 | + | * @smbus_actual_len: Valid byte count (length + payload + optional PEC) of a | |
| 77 | + | * padded SMBus block read. msg->len is trimmed to this on completion. | |
| 78 | + | * Zero when no trimming is needed. | |
| 76 | 79 | * @input_clk: Input clock to I2C controller | |
| 77 | 80 | * @i2c_clk: I2C SCL frequency | |
| 78 | 81 | * @atomic: Mode of transfer | |
| @@ -98,6 +101,7 @@ struct xiic_i2c { | |||
| 98 | 101 | bool prev_msg_tx; | |
| 99 | 102 | u32 quirks; | |
| 100 | 103 | bool smbus_block_read; | |
| 104 | + | unsigned int smbus_actual_len; | |
| 101 | 105 | unsigned long input_clk; | |
| 102 | 106 | unsigned int i2c_clk; | |
| 103 | 107 | bool atomic; | |
| @@ -539,30 +543,38 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c *i2c) | |||
| 539 | 543 | ||
| 540 | 544 | /* Check if received length is valid */ | |
| 541 | 545 | if (rxmsg_len <= I2C_SMBUS_BLOCK_MAX) { | |
| 546 | + | unsigned int pec_len = i2c->rx_msg->len - 1; | |
| 547 | + | ||
| 542 | 548 | /* Set Receive fifo depth */ | |
| 543 | - | if (rxmsg_len > IIC_RX_FIFO_DEPTH) { | |
| 549 | + | if (rxmsg_len + pec_len > IIC_RX_FIFO_DEPTH) { | |
| 544 | 550 | /* | |
| 545 | - | * When Rx msg len greater than or equal to Rx fifo capacity | |
| 546 | - | * Receive fifo depth should set to Rx fifo capacity minus 1 | |
| 551 | + | * Trailing bytes (payload plus any PEC) exceed Rx FIFO | |
| 552 | + | * capacity, so drain in chunks. This also keeps the | |
| 553 | + | * else branch below from pushing rfd_set past the | |
| 554 | + | * 4-bit XIIC_RFD_REG_OFFSET field. | |
| 547 | 555 | */ | |
| 548 | 556 | rfd_set = IIC_RX_FIFO_DEPTH - 1; | |
| 549 | - | i2c->rx_msg->len = rxmsg_len + 1; | |
| 550 | - | } else if ((rxmsg_len == 1) || | |
| 551 | - | (rxmsg_len == 0)) { | |
| 557 | + | i2c->rx_msg->len = rxmsg_len + 1 + pec_len; | |
| 558 | + | } else if (1 + rxmsg_len + pec_len < SMBUS_BLOCK_READ_MIN_LEN) { | |
| 552 | 559 | /* | |
| 553 | - | * Minimum of 3 bytes required to exit cleanly. 1 byte | |
| 554 | - | * already received, Second byte is being received. Have | |
| 555 | - | * to set NACK in read_rx before receiving the last byte | |
| 560 | + | * The HW needs SMBUS_BLOCK_READ_MIN_LEN bytes on the | |
| 561 | + | * bus to exit cleanly: by the time the ISR reads the | |
| 562 | + | * length byte the second byte is already being clocked | |
| 563 | + | * in, too late to NACK. Pad the drain target and record | |
| 564 | + | * the real length, trimmed back on completion so the | |
| 565 | + | * PEC check sees the right byte. | |
| 556 | 566 | */ | |
| 557 | 567 | rfd_set = 0; | |
| 558 | 568 | i2c->rx_msg->len = SMBUS_BLOCK_READ_MIN_LEN; | |
| 569 | + | i2c->smbus_actual_len = 1 + rxmsg_len + pec_len; | |
| 559 | 570 | } else { | |
| 560 | 571 | /* | |
| 561 | - | * When Rx msg len less than Rx fifo capacity | |
| 562 | - | * Receive fifo depth should set to Rx msg len minus 2 | |
| 572 | + | * All trailing bytes fit in the Rx FIFO. Defer RX_FULL | |
| 573 | + | * until every one of them is buffered, so the drain | |
| 574 | + | * takes xiic_read_rx()'s bytes_rem == 0 path. | |
| 563 | 575 | */ | |
| 564 | - | rfd_set = rxmsg_len - 2; | |
| 565 | - | i2c->rx_msg->len = rxmsg_len + 1; | |
| 576 | + | rfd_set = rxmsg_len + pec_len - 1; | |
| 577 | + | i2c->rx_msg->len = rxmsg_len + 1 + pec_len; | |
| 566 | 578 | } | |
| 567 | 579 | xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set); | |
| 568 | 580 | ||
| @@ -575,6 +587,16 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c *i2c) | |||
| 575 | 587 | dev_err(i2c->adap.dev.parent, "smbus_block_read Invalid msg length\n"); | |
| 576 | 588 | } | |
| 577 | 589 | ||
| 590 | + | /* | |
| 591 | + | * Undo the setup-time padding of a short SMBus block read before rx_msg is | |
| 592 | + | * cleared, so the PEC check sees the right byte. | |
| 593 | + | */ | |
| 594 | + | static void xiic_smbus_trim_len(struct xiic_i2c *i2c) | |
| 595 | + | { | |
| 596 | + | if (i2c->rx_msg && i2c->smbus_actual_len) | |
| 597 | + | i2c->rx_msg->len = i2c->smbus_actual_len; | |
| 598 | + | } | |
| 599 | + | ||
| 578 | 600 | static void xiic_read_rx(struct xiic_i2c *i2c) | |
| 579 | 601 | { | |
| 580 | 602 | u8 bytes_in_fifo, cr = 0, bytes_to_read = 0; | |
| @@ -797,6 +819,8 @@ static irqreturn_t xiic_process(int irq, void *dev_id) | |||
| 797 | 819 | ||
| 798 | 820 | xiic_read_rx(i2c); | |
| 799 | 821 | if (xiic_rx_space(i2c) == 0) { | |
| 822 | + | xiic_smbus_trim_len(i2c); | |
| 823 | + | ||
| 800 | 824 | /* this is the last part of the message */ | |
| 801 | 825 | i2c->rx_msg = NULL; | |
| 802 | 826 | ||
| @@ -865,8 +889,11 @@ static irqreturn_t xiic_process(int irq, void *dev_id) | |||
| 865 | 889 | ||
| 866 | 890 | if (i2c->tx_msg && i2c->smbus_block_read) { | |
| 867 | 891 | i2c->smbus_block_read = false; | |
| 868 | - | /* Set requested message len=1 to indicate STATE_DONE */ | |
| 869 | - | i2c->tx_msg->len = 1; | |
| 892 | + | /* | |
| 893 | + | * Drive xiic_tx_space() to 0 to signal STATE_DONE | |
| 894 | + | * without truncating the rx_msg length. | |
| 895 | + | */ | |
| 896 | + | i2c->tx_pos = i2c->tx_msg->len; | |
| 870 | 897 | } | |
| 871 | 898 | ||
| 872 | 899 | if (!i2c->tx_msg) | |
| @@ -938,6 +965,7 @@ static void xiic_recv_atomic(struct xiic_i2c *i2c) | |||
| 938 | 965 | return; | |
| 939 | 966 | } | |
| 940 | 967 | ||
| 968 | + | xiic_smbus_trim_len(i2c); | |
| 941 | 969 | i2c->rx_msg = NULL; | |
| 942 | 970 | xiic_irq_clr_en(i2c, XIIC_INTR_TX_ERROR_MASK); | |
| 943 | 971 | ||
| @@ -955,6 +983,9 @@ static void xiic_start_recv(struct xiic_i2c *i2c) | |||
| 955 | 983 | u8 cr = 0, rfd_set = 0; | |
| 956 | 984 | struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; | |
| 957 | 985 | ||
| 986 | + | /* A stale value from an aborted block read would truncate this msg. */ | |
| 987 | + | i2c->smbus_actual_len = 0; | |
| 988 | + | ||
| 958 | 989 | if (!i2c->atomic) | |
| 959 | 990 | dev_dbg(i2c->adap.dev.parent, "%s entry, ISR: 0x%x, CR: 0x%x\n", | |
| 960 | 991 | __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), | |
modified drivers/iio/accel/kionix-kx022a.c
| @@ -649,7 +649,7 @@ static int kx022a_read_raw(struct iio_dev *idev, | |||
| 649 | 649 | if (ret) | |
| 650 | 650 | return ret; | |
| 651 | 651 | ||
| 652 | - | if ((regval & KX022A_MASK_ODR) > | |
| 652 | + | if ((regval & KX022A_MASK_ODR) >= | |
| 653 | 653 | ARRAY_SIZE(kx022a_accel_samp_freq_table)) { | |
| 654 | 654 | dev_err(data->dev, "Invalid ODR\n"); | |
| 655 | 655 | return -EINVAL; | |
| @@ -980,26 +980,44 @@ static int kx022a_fifo_enable(struct kx022a_data *data) | |||
| 980 | 980 | guard(mutex)(&data->mutex); | |
| 981 | 981 | ret = __kx022a_turn_on_off(data, false); | |
| 982 | 982 | if (ret) | |
| 983 | - | return ret; | |
| 983 | + | goto err_free_out; | |
| 984 | 984 | ||
| 985 | 985 | /* Update watermark to HW */ | |
| 986 | 986 | ret = kx022a_fifo_set_wmi(data); | |
| 987 | 987 | if (ret) | |
| 988 | - | return ret; | |
| 988 | + | goto err_turn_on_out; | |
| 989 | 989 | ||
| 990 | 990 | /* Enable buffer */ | |
| 991 | 991 | ret = regmap_set_bits(data->regmap, data->chip_info->buf_cntl2, | |
| 992 | 992 | KX022A_MASK_BUF_EN); | |
| 993 | 993 | if (ret) | |
| 994 | - | return ret; | |
| 994 | + | goto err_turn_on_out; | |
| 995 | 995 | ||
| 996 | 996 | data->state |= KX022A_STATE_FIFO; | |
| 997 | 997 | ret = regmap_set_bits(data->regmap, data->ien_reg, | |
| 998 | 998 | KX022A_MASK_WMI); | |
| 999 | 999 | if (ret) | |
| 1000 | - | return ret; | |
| 1000 | + | goto err_buf_disable_out; | |
| 1001 | 1001 | ||
| 1002 | - | return __kx022a_turn_on_off(data, true); | |
| 1002 | + | ret = __kx022a_turn_on_off(data, true); | |
| 1003 | + | if (ret) | |
| 1004 | + | goto err_wmi_clear_out; | |
| 1005 | + | ||
| 1006 | + | return ret; | |
| 1007 | + | ||
| 1008 | + | err_wmi_clear_out: | |
| 1009 | + | regmap_clear_bits(data->regmap, data->ien_reg, | |
| 1010 | + | KX022A_MASK_WMI); | |
| 1011 | + | err_buf_disable_out: | |
| 1012 | + | regmap_clear_bits(data->regmap, data->chip_info->buf_cntl2, | |
| 1013 | + | KX022A_MASK_BUF_EN); | |
| 1014 | + | data->state &= ~KX022A_STATE_FIFO; | |
| 1015 | + | err_turn_on_out: | |
| 1016 | + | __kx022a_turn_on_off(data, true); | |
| 1017 | + | err_free_out: | |
| 1018 | + | kfree(data->fifo_buffer); | |
| 1019 | + | ||
| 1020 | + | return ret; | |
| 1003 | 1021 | } | |
| 1004 | 1022 | ||
| 1005 | 1023 | static int kx022a_buffer_postenable(struct iio_dev *idev) | |
modified drivers/iio/accel/kxcjk-1013.c
| @@ -1030,7 +1030,7 @@ static int kxcjk1013_write_event_config(struct iio_dev *indio_dev, | |||
| 1030 | 1030 | struct kxcjk1013_data *data = iio_priv(indio_dev); | |
| 1031 | 1031 | int ret; | |
| 1032 | 1032 | ||
| 1033 | - | if (state && data->ev_enable_state) | |
| 1033 | + | if (state == data->ev_enable_state) | |
| 1034 | 1034 | return 0; | |
| 1035 | 1035 | ||
| 1036 | 1036 | mutex_lock(&data->mutex); | |
modified drivers/iio/accel/sca3000.c
| @@ -638,7 +638,7 @@ static int sca3000_write_raw_samp_freq(struct sca3000_state *st, int val) | |||
| 638 | 638 | ||
| 639 | 639 | if (val == base_freq / 2) | |
| 640 | 640 | ctrlval |= SCA3000_REG_OUT_CTRL_BUF_DIV_2; | |
| 641 | - | if (val == base_freq / 4) | |
| 641 | + | else if (val == base_freq / 4) | |
| 642 | 642 | ctrlval |= SCA3000_REG_OUT_CTRL_BUF_DIV_4; | |
| 643 | 643 | else if (val != base_freq) | |
| 644 | 644 | return -EINVAL; | |
modified drivers/iio/adc/ad4030.c
| @@ -746,14 +746,21 @@ static int ad4030_set_chan_calibbias(struct iio_dev *indio_dev, | |||
| 746 | 746 | static int ad4030_set_avg_frame_len(struct iio_dev *dev, int avg_val) | |
| 747 | 747 | { | |
| 748 | 748 | struct ad4030_state *st = iio_priv(dev); | |
| 749 | - | unsigned int avg_log2 = ilog2(avg_val); | |
| 750 | 749 | unsigned int last_avg_idx = ARRAY_SIZE(ad4030_average_modes) - 1; | |
| 750 | + | unsigned int avg_log2; | |
| 751 | 751 | int freq_hz; | |
| 752 | 752 | int ret; | |
| 753 | 753 | ||
| 754 | - | if (avg_val < 0 || avg_val > ad4030_average_modes[last_avg_idx]) | |
| 754 | + | /* Reject unsupported modes */ | |
| 755 | + | if (avg_val > ad4030_average_modes[last_avg_idx]) | |
| 756 | + | return -EINVAL; | |
| 757 | + | ||
| 758 | + | /* Avoid invalid values for logarithm since it's undefined */ | |
| 759 | + | if (avg_val < 1) | |
| 755 | 760 | return -EINVAL; | |
| 756 | 761 | ||
| 762 | + | avg_log2 = ilog2(avg_val); | |
| 763 | + | ||
| 757 | 764 | if (st->offload_trigger) { | |
| 758 | 765 | /* | |
| 759 | 766 | * The sample averaging and sampling frequency configurations | |
modified drivers/iio/adc/ad7173.c
| @@ -775,9 +775,9 @@ static int ad7173_load_config(struct ad7173_state *st, | |||
| 775 | 775 | ||
| 776 | 776 | return ad_sd_write_reg(&st->sd, AD7173_REG_FILTER(free_cfg_slot), 2, | |
| 777 | 777 | FIELD_PREP(AD7173_FILTER_SINC3_MAP, 0) | | |
| 778 | - | FIELD_PREP(AD7173_FILTER_ENHFILT_MASK, | |
| 779 | - | post_filter_enable) | | |
| 780 | 778 | FIELD_PREP(AD7173_FILTER_ENHFILTEN, | |
| 779 | + | post_filter_enable) | | |
| 780 | + | FIELD_PREP(AD7173_FILTER_ENHFILT_MASK, | |
| 781 | 781 | post_filter_select) | | |
| 782 | 782 | FIELD_PREP(AD7173_FILTER_ORDER, 0) | | |
| 783 | 783 | FIELD_PREP(AD7173_FILTER_ODR_MASK, | |
modified drivers/iio/adc/ad_sigma_delta.c
| @@ -498,7 +498,6 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev) | |||
| 498 | 498 | const struct iio_scan_type *scan_type = &indio_dev->channels[0].scan_type; | |
| 499 | 499 | struct spi_transfer *xfer = sigma_delta->sample_xfer; | |
| 500 | 500 | unsigned int i, slot, channel; | |
| 501 | - | u8 *samples_buf; | |
| 502 | 501 | int ret; | |
| 503 | 502 | ||
| 504 | 503 | if (sigma_delta->num_slots == 1) { | |
| @@ -530,7 +529,7 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev) | |||
| 530 | 529 | xfer[1].bits_per_word = scan_type->realbits; | |
| 531 | 530 | xfer[1].len = spi_bpw_to_bytes(scan_type->realbits); | |
| 532 | 531 | } else { | |
| 533 | - | unsigned int samples_buf_size, scan_size; | |
| 532 | + | unsigned int scan_size; | |
| 534 | 533 | ||
| 535 | 534 | if (sigma_delta->active_slots > 1) { | |
| 536 | 535 | ret = ad_sigma_delta_append_status(sigma_delta, true); | |
| @@ -538,17 +537,6 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev) | |||
| 538 | 537 | return ret; | |
| 539 | 538 | } | |
| 540 | 539 | ||
| 541 | - | samples_buf_size = | |
| 542 | - | ALIGN(slot * BITS_TO_BYTES(scan_type->storagebits), | |
| 543 | - | sizeof(s64)); | |
| 544 | - | samples_buf_size += sizeof(s64); | |
| 545 | - | samples_buf = devm_krealloc(&sigma_delta->spi->dev, | |
| 546 | - | sigma_delta->samples_buf, | |
| 547 | - | samples_buf_size, GFP_KERNEL); | |
| 548 | - | if (!samples_buf) | |
| 549 | - | return -ENOMEM; | |
| 550 | - | ||
| 551 | - | sigma_delta->samples_buf = samples_buf; | |
| 552 | 540 | scan_size = BITS_TO_BYTES(scan_type->realbits + scan_type->shift); | |
| 553 | 541 | /* For 24-bit data, there is an extra byte of padding. */ | |
| 554 | 542 | xfer[1].rx_buf = &sigma_delta->rx_buf[scan_size == 3 ? 1 : 0]; | |
| @@ -855,6 +843,23 @@ int devm_ad_sd_setup_buffer_and_trigger(struct device *dev, struct iio_dev *indi | |||
| 855 | 843 | ||
| 856 | 844 | indio_dev->setup_ops = &ad_sd_buffer_setup_ops; | |
| 857 | 845 | } else { | |
| 846 | + | const struct iio_scan_type *scan_type = | |
| 847 | + | &indio_dev->channels[0].scan_type; | |
| 848 | + | unsigned int samples_buf_size; | |
| 849 | + | ||
| 850 | + | /* | |
| 851 | + | * Worst-case size: all sequencer slots can be active, capped | |
| 852 | + | * at num_slots by ad_sd_validate_scan_mask(). | |
| 853 | + | */ | |
| 854 | + | samples_buf_size = | |
| 855 | + | ALIGN(sigma_delta->num_slots * | |
| 856 | + | BITS_TO_BYTES(scan_type->storagebits), | |
| 857 | + | sizeof(s64)); | |
| 858 | + | samples_buf_size += sizeof(s64); | |
| 859 | + | sigma_delta->samples_buf = devm_kzalloc(dev, samples_buf_size, GFP_KERNEL); | |
| 860 | + | if (!sigma_delta->samples_buf) | |
| 861 | + | return -ENOMEM; | |
| 862 | + | ||
| 858 | 863 | ret = devm_iio_triggered_buffer_setup(dev, indio_dev, | |
| 859 | 864 | &iio_pollfunc_store_time, | |
| 860 | 865 | &ad_sd_trigger_handler, | |
modified drivers/iio/adc/ade9000.c
| @@ -219,7 +219,7 @@ | |||
| 219 | 219 | #define ADE9000_ST1_ERROR2_BIT BIT(30) | |
| 220 | 220 | #define ADE9000_ST1_ERROR3_BIT BIT(31) | |
| 221 | 221 | #define ADE9000_ST1_CROSSING_FIRST 6 | |
| 222 | - | #define ADE9000_ST1_CROSSING_DEPTH 25 | |
| 222 | + | #define ADE9000_ST1_CROSSING_DEPTH 26 | |
| 223 | 223 | ||
| 224 | 224 | #define ADE9000_WFB_TRG_DIP_BIT BIT(0) | |
| 225 | 225 | #define ADE9000_WFB_TRG_SWELL_BIT BIT(1) | |
| @@ -444,7 +444,7 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = { | |||
| 444 | 444 | BIT(IIO_CHAN_INFO_CALIBSCALE), \ | |
| 445 | 445 | .event_spec = ade9000_current_events, \ | |
| 446 | 446 | .num_event_specs = ARRAY_SIZE(ade9000_current_events), \ | |
| 447 | - | .scan_index = num, \ | |
| 447 | + | .scan_index = num * 2, \ | |
| 448 | 448 | .indexed = 1, \ | |
| 449 | 449 | .scan_type = { \ | |
| 450 | 450 | .sign = 's', \ | |
| @@ -464,7 +464,7 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = { | |||
| 464 | 464 | BIT(IIO_CHAN_INFO_FREQUENCY), \ | |
| 465 | 465 | .event_spec = ade9000_voltage_events, \ | |
| 466 | 466 | .num_event_specs = ARRAY_SIZE(ade9000_voltage_events), \ | |
| 467 | - | .scan_index = num + 1, /* interleave with current channels */ \ | |
| 467 | + | .scan_index = num * 2 + 1, /* interleave with current channels */ \ | |
| 468 | 468 | .indexed = 1, \ | |
| 469 | 469 | .scan_type = { \ | |
| 470 | 470 | .sign = 's', \ | |
| @@ -1647,8 +1647,9 @@ static int ade9000_setup_clkout(struct device *dev, struct ade9000_state *st) | |||
| 1647 | 1647 | return 0; | |
| 1648 | 1648 | ||
| 1649 | 1649 | /* CLKOUT passes through CLKIN with divider of 1 */ | |
| 1650 | - | clkout_hw = devm_clk_hw_register_divider(dev, "clkout", __clk_get_name(st->clkin), | |
| 1651 | - | CLK_SET_RATE_PARENT, NULL, 0, 1, 0, NULL); | |
| 1650 | + | clkout_hw = devm_clk_hw_register_fixed_factor(dev, "clkout", | |
| 1651 | + | __clk_get_name(st->clkin), | |
| 1652 | + | CLK_SET_RATE_PARENT, 1, 1); | |
| 1652 | 1653 | if (IS_ERR(clkout_hw)) | |
| 1653 | 1654 | return dev_err_probe(dev, PTR_ERR(clkout_hw), "Failed to register clkout"); | |
| 1654 | 1655 | ||
| @@ -1705,18 +1706,6 @@ static int ade9000_probe(struct spi_device *spi) | |||
| 1705 | 1706 | if (ret) | |
| 1706 | 1707 | return ret; | |
| 1707 | 1708 | ||
| 1708 | - | ret = ade9000_request_irq(dev, "irq0", ade9000_irq0_thread, indio_dev); | |
| 1709 | - | if (ret) | |
| 1710 | - | return ret; | |
| 1711 | - | ||
| 1712 | - | ret = ade9000_request_irq(dev, "irq1", ade9000_irq1_thread, indio_dev); | |
| 1713 | - | if (ret) | |
| 1714 | - | return ret; | |
| 1715 | - | ||
| 1716 | - | ret = ade9000_request_irq(dev, "dready", ade9000_dready_thread, indio_dev); | |
| 1717 | - | if (ret) | |
| 1718 | - | return ret; | |
| 1719 | - | ||
| 1720 | 1709 | /* External CMOS clock input (optional - crystal can be used instead) */ | |
| 1721 | 1710 | st->clkin = devm_clk_get_optional_enabled(dev, NULL); | |
| 1722 | 1711 | if (IS_ERR(st->clkin)) | |
| @@ -1736,6 +1725,19 @@ static int ade9000_probe(struct spi_device *spi) | |||
| 1736 | 1725 | return dev_err_probe(&spi->dev, ret, | |
| 1737 | 1726 | "Failed to get and enable vdd regulator\n"); | |
| 1738 | 1727 | ||
| 1728 | + | /* Request IRQs only after powering the chip; the handlers do SPI access. */ | |
| 1729 | + | ret = ade9000_request_irq(dev, "irq0", ade9000_irq0_thread, indio_dev); | |
| 1730 | + | if (ret) | |
| 1731 | + | return ret; | |
| 1732 | + | ||
| 1733 | + | ret = ade9000_request_irq(dev, "irq1", ade9000_irq1_thread, indio_dev); | |
| 1734 | + | if (ret) | |
| 1735 | + | return ret; | |
| 1736 | + | ||
| 1737 | + | ret = ade9000_request_irq(dev, "dready", ade9000_dready_thread, indio_dev); | |
| 1738 | + | if (ret) | |
| 1739 | + | return ret; | |
| 1740 | + | ||
| 1739 | 1741 | indio_dev->channels = ade9000_channels; | |
| 1740 | 1742 | indio_dev->num_channels = ARRAY_SIZE(ade9000_channels); | |
| 1741 | 1743 | ||
modified drivers/iio/adc/adi-axi-adc.c
| @@ -714,6 +714,10 @@ static int adi_axi_adc_probe(struct platform_device *pdev) | |||
| 714 | 714 | if (!st) | |
| 715 | 715 | return -ENOMEM; | |
| 716 | 716 | ||
| 717 | + | ret = devm_mutex_init(dev, &st->lock); | |
| 718 | + | if (ret) | |
| 719 | + | return ret; | |
| 720 | + | ||
| 717 | 721 | base = devm_platform_ioremap_resource(pdev, 0); | |
| 718 | 722 | if (IS_ERR(base)) | |
| 719 | 723 | return PTR_ERR(base); | |
modified drivers/iio/adc/aspeed_adc.c
| @@ -585,7 +585,9 @@ static int aspeed_adc_probe(struct platform_device *pdev) | |||
| 585 | 585 | return dev_err_probe(dev, PTR_ERR(data->rst), | |
| 586 | 586 | "invalid or missing reset controller device tree entry"); | |
| 587 | 587 | ||
| 588 | - | reset_control_deassert(data->rst); | |
| 588 | + | ret = reset_control_deassert(data->rst); | |
| 589 | + | if (ret) | |
| 590 | + | return ret; | |
| 589 | 591 | ||
| 590 | 592 | ret = devm_add_action_or_reset(dev, aspeed_adc_reset_assert, data->rst); | |
| 591 | 593 | if (ret) | |
modified drivers/iio/adc/axp288_adc.c
| @@ -207,6 +207,14 @@ static const struct dmi_system_id axp288_adc_ts_bias_override[] = { | |||
| 207 | 207 | }, | |
| 208 | 208 | .driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA, | |
| 209 | 209 | }, | |
| 210 | + | { | |
| 211 | + | /* Haier HV103H */ | |
| 212 | + | .matches = { | |
| 213 | + | DMI_MATCH(DMI_SYS_VENDOR, "Haier"), | |
| 214 | + | DMI_MATCH(DMI_PRODUCT_NAME, "HV103H"), | |
| 215 | + | }, | |
| 216 | + | .driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA, | |
| 217 | + | }, | |
| 210 | 218 | { } | |
| 211 | 219 | }; | |
| 212 | 220 | ||
modified drivers/iio/adc/max1363.c
| @@ -404,6 +404,14 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev, | |||
| 404 | 404 | ||
| 405 | 405 | data = rxbuf[0]; | |
| 406 | 406 | } | |
| 407 | + | ||
| 408 | + | /* | |
| 409 | + | * Differential channels are bipolar and the device returns the sample | |
| 410 | + | * in two's complement, so sign-extend it from the resolution bit. | |
| 411 | + | */ | |
| 412 | + | if (chan->differential) | |
| 413 | + | data = sign_extend32(data, st->chip_info->bits - 1); | |
| 414 | + | ||
| 407 | 415 | *val = data; | |
| 408 | 416 | ||
| 409 | 417 | return 0; | |
modified drivers/iio/adc/pac1934.c
| @@ -1108,6 +1108,10 @@ static int pac1934_acpi_parse_channel_config(struct i2c_client *client, | |||
| 1108 | 1108 | devm_kmemdup(dev, rez->package.elements[i].string.pointer, | |
| 1109 | 1109 | (size_t)rez->package.elements[i].string.length + 1, | |
| 1110 | 1110 | GFP_KERNEL); | |
| 1111 | + | if (!info->labels[idx]) { | |
| 1112 | + | ACPI_FREE(rez); | |
| 1113 | + | return -ENOMEM; | |
| 1114 | + | } | |
| 1111 | 1115 | info->labels[idx][rez->package.elements[i].string.length] = '\0'; | |
| 1112 | 1116 | info->shunts[idx] = rez->package.elements[i + 1].integer.value * 1000; | |
| 1113 | 1117 | info->active_channels[idx] = (info->shunts[idx] != 0); | |
modified drivers/iio/adc/rohm-bd79124.c
| @@ -200,7 +200,7 @@ static int bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask, | |||
| 200 | 200 | if (ret) | |
| 201 | 201 | return ret; | |
| 202 | 202 | ||
| 203 | - | if (all_gpos ^ *mask) { | |
| 203 | + | if (*mask & ~all_gpos) { | |
| 204 | 204 | dev_dbg(data->dev, "Invalid mux config. Can't set value.\n"); | |
| 205 | 205 | ||
| 206 | 206 | return -EINVAL; | |
| @@ -381,6 +381,9 @@ static int bd79124_start_measurement(struct bd79124_data *data, int chan) | |||
| 381 | 381 | ||
| 382 | 382 | /* See if already started */ | |
| 383 | 383 | ret = regmap_read(data->map, BD79124_REG_AUTO_CHANNELS, &val); | |
| 384 | + | if (ret) | |
| 385 | + | return ret; | |
| 386 | + | ||
| 384 | 387 | if (val & BIT(chan)) | |
| 385 | 388 | return 0; | |
| 386 | 389 | ||
| @@ -420,11 +423,16 @@ static int bd79124_stop_measurement(struct bd79124_data *data, int chan) | |||
| 420 | 423 | ||
| 421 | 424 | /* See if already stopped */ | |
| 422 | 425 | ret = regmap_read(data->map, BD79124_REG_AUTO_CHANNELS, &enabled_chans); | |
| 426 | + | if (ret) | |
| 427 | + | return ret; | |
| 428 | + | ||
| 423 | 429 | if (!(enabled_chans & BIT(chan))) | |
| 424 | 430 | return 0; | |
| 425 | 431 | ||
| 426 | 432 | ret = regmap_clear_bits(data->map, BD79124_REG_SEQ_CFG, | |
| 427 | 433 | BD79124_MSK_SEQ_START); | |
| 434 | + | if (ret) | |
| 435 | + | return ret; | |
| 428 | 436 | ||
| 429 | 437 | /* Clear the channel from the measured channels */ | |
| 430 | 438 | enabled_chans &= ~BIT(chan); | |
| @@ -524,7 +532,7 @@ static int bd79124_enable_event(struct bd79124_data *data, | |||
| 524 | 532 | return ret; | |
| 525 | 533 | ||
| 526 | 534 | if (dir == IIO_EV_DIR_RISING) { | |
| 527 | - | limit = &data->alarm_f_limit[channel]; | |
| 535 | + | limit = &data->alarm_r_limit[channel]; | |
| 528 | 536 | reg = BD79124_GET_HIGH_LIMIT_REG(channel); | |
| 529 | 537 | } else { | |
| 530 | 538 | limit = &data->alarm_f_limit[channel]; | |
| @@ -919,13 +927,13 @@ static int bd79124_chan_init(struct bd79124_data *data, int channel) | |||
| 919 | 927 | { | |
| 920 | 928 | int ret; | |
| 921 | 929 | ||
| 922 | - | ret = regmap_write(data->map, BD79124_GET_HIGH_LIMIT_REG(channel), | |
| 923 | - | BD79124_HIGH_LIMIT_MAX); | |
| 930 | + | ret = bd79124_write_int_to_reg(data, BD79124_GET_HIGH_LIMIT_REG(channel), | |
| 931 | + | BD79124_HIGH_LIMIT_MAX); | |
| 924 | 932 | if (ret) | |
| 925 | 933 | return ret; | |
| 926 | 934 | ||
| 927 | - | return regmap_write(data->map, BD79124_GET_LOW_LIMIT_REG(channel), | |
| 928 | - | BD79124_LOW_LIMIT_MIN); | |
| 935 | + | return bd79124_write_int_to_reg(data, BD79124_GET_LOW_LIMIT_REG(channel), | |
| 936 | + | BD79124_LOW_LIMIT_MIN); | |
| 929 | 937 | } | |
| 930 | 938 | ||
| 931 | 939 | static int bd79124_get_gpio_pins(const struct iio_chan_spec *cs, int num_channels) | |
modified drivers/iio/adc/stm32-adc.c
| @@ -1608,11 +1608,16 @@ static int stm32_adc_read_raw(struct iio_dev *indio_dev, | |||
| 1608 | 1608 | ret = stm32_adc_single_conv(indio_dev, chan, val); | |
| 1609 | 1609 | else | |
| 1610 | 1610 | ret = -EINVAL; | |
| 1611 | + | iio_device_release_direct(indio_dev); | |
| 1612 | + | if (ret < 0) | |
| 1613 | + | return ret; | |
| 1611 | 1614 | ||
| 1612 | - | if (mask == IIO_CHAN_INFO_PROCESSED) | |
| 1615 | + | if (mask == IIO_CHAN_INFO_PROCESSED) { | |
| 1616 | + | if (*val == 0) | |
| 1617 | + | return -EINVAL; | |
| 1613 | 1618 | *val = STM32_ADC_VREFINT_VOLTAGE * adc->vrefint.vrefint_cal / *val; | |
| 1619 | + | } | |
| 1614 | 1620 | ||
| 1615 | - | iio_device_release_direct(indio_dev); | |
| 1616 | 1621 | return ret; | |
| 1617 | 1622 | ||
| 1618 | 1623 | case IIO_CHAN_INFO_SCALE: | |
| @@ -2263,33 +2268,37 @@ static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_n | |||
| 2263 | 2268 | ||
| 2264 | 2269 | for (i = 0; i < STM32_ADC_INT_CH_NB; i++) { | |
| 2265 | 2270 | if (!strncmp(stm32_adc_ic[i].name, ch_name, STM32_ADC_CH_SZ)) { | |
| 2271 | + | bool na; | |
| 2272 | + | ||
| 2266 | 2273 | /* Check internal channel availability */ | |
| 2267 | 2274 | switch (i) { | |
| 2268 | 2275 | case STM32_ADC_INT_CH_VDDCORE: | |
| 2269 | - | if (!adc->cfg->regs->or_vddcore.reg) | |
| 2270 | - | dev_warn(&indio_dev->dev, | |
| 2271 | - | "%s channel not available\n", ch_name); | |
| 2276 | + | na = !adc->cfg->regs->or_vddcore.reg; | |
| 2272 | 2277 | break; | |
| 2273 | 2278 | case STM32_ADC_INT_CH_VDDCPU: | |
| 2274 | - | if (!adc->cfg->regs->or_vddcpu.reg) | |
| 2275 | - | dev_warn(&indio_dev->dev, | |
| 2276 | - | "%s channel not available\n", ch_name); | |
| 2279 | + | na = !adc->cfg->regs->or_vddcpu.reg; | |
| 2277 | 2280 | break; | |
| 2278 | 2281 | case STM32_ADC_INT_CH_VDDQ_DDR: | |
| 2279 | - | if (!adc->cfg->regs->or_vddq_ddr.reg) | |
| 2280 | - | dev_warn(&indio_dev->dev, | |
| 2281 | - | "%s channel not available\n", ch_name); | |
| 2282 | + | na = !adc->cfg->regs->or_vddq_ddr.reg; | |
| 2282 | 2283 | break; | |
| 2283 | 2284 | case STM32_ADC_INT_CH_VREFINT: | |
| 2284 | - | if (!adc->cfg->regs->ccr_vref.reg) | |
| 2285 | - | dev_warn(&indio_dev->dev, | |
| 2286 | - | "%s channel not available\n", ch_name); | |
| 2285 | + | na = !adc->cfg->regs->ccr_vref.reg; | |
| 2287 | 2286 | break; | |
| 2288 | 2287 | case STM32_ADC_INT_CH_VBAT: | |
| 2289 | - | if (!adc->cfg->regs->ccr_vbat.reg) | |
| 2290 | - | dev_warn(&indio_dev->dev, | |
| 2291 | - | "%s channel not available\n", ch_name); | |
| 2288 | + | na = !adc->cfg->regs->ccr_vbat.reg; | |
| 2292 | 2289 | break; | |
| 2290 | + | default: | |
| 2291 | + | return -EINVAL; | |
| 2292 | + | } | |
| 2293 | + | ||
| 2294 | + | if (na) { | |
| 2295 | + | /* | |
| 2296 | + | * Channel label matches an internal STM32 ADC channel. | |
| 2297 | + | * Warn about it, as there's normally no restriction on the | |
| 2298 | + | * name but that's not among available internal channels. | |
| 2299 | + | */ | |
| 2300 | + | dev_warn(&indio_dev->dev, "no %s internal channel\n", ch_name); | |
| 2301 | + | return 0; | |
| 2293 | 2302 | } | |
| 2294 | 2303 | ||
| 2295 | 2304 | if (stm32_adc_ic[i].idx != STM32_ADC_INT_CH_VREFINT) { | |
modified drivers/iio/adc/sun4i-gpadc-iio.c
| @@ -638,10 +638,10 @@ static int sun4i_gpadc_probe(struct platform_device *pdev) | |||
| 638 | 638 | * thermal because no thermal DT node is found. | |
| 639 | 639 | */ | |
| 640 | 640 | if (IS_ERR(info->tzd) && PTR_ERR(info->tzd) != -ENODEV) { | |
| 641 | - | dev_err(&pdev->dev, | |
| 642 | - | "could not register thermal sensor: %ld\n", | |
| 643 | - | PTR_ERR(info->tzd)); | |
| 644 | - | return PTR_ERR(info->tzd); | |
| 641 | + | ret = dev_err_probe(&pdev->dev, | |
| 642 | + | PTR_ERR(info->tzd), | |
| 643 | + | "could not register thermal sensor\n"); | |
| 644 | + | goto err_map; | |
| 645 | 645 | } | |
| 646 | 646 | } | |
| 647 | 647 | ||
| @@ -657,7 +657,6 @@ err_map: | |||
| 657 | 657 | if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF)) | |
| 658 | 658 | iio_map_array_unregister(indio_dev); | |
| 659 | 659 | ||
| 660 | - | pm_runtime_put(&pdev->dev); | |
| 661 | 660 | pm_runtime_disable(&pdev->dev); | |
| 662 | 661 | ||
| 663 | 662 | return ret; | |
| @@ -668,7 +667,6 @@ static void sun4i_gpadc_remove(struct platform_device *pdev) | |||
| 668 | 667 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | |
| 669 | 668 | struct sun4i_gpadc_iio *info = iio_priv(indio_dev); | |
| 670 | 669 | ||
| 671 | - | pm_runtime_put(&pdev->dev); | |
| 672 | 670 | pm_runtime_disable(&pdev->dev); | |
| 673 | 671 | ||
| 674 | 672 | if (!IS_ENABLED(CONFIG_THERMAL_OF)) | |
modified drivers/iio/adc/xilinx-xadc-core.c
| @@ -1401,13 +1401,14 @@ static int xadc_probe(struct platform_device *pdev) | |||
| 1401 | 1401 | } | |
| 1402 | 1402 | ||
| 1403 | 1403 | if (irq > 0) { | |
| 1404 | - | ret = devm_request_irq(dev, irq, xadc->ops->interrupt_handler, | |
| 1405 | - | 0, dev_name(dev), indio_dev); | |
| 1404 | + | /* Clear out any work queued by the interrupt */ | |
| 1405 | + | ret = devm_add_action_or_reset(dev, xadc_cancel_delayed_work, | |
| 1406 | + | &xadc->zynq_unmask_work); | |
| 1406 | 1407 | if (ret) | |
| 1407 | 1408 | return ret; | |
| 1408 | 1409 | ||
| 1409 | - | ret = devm_add_action_or_reset(dev, xadc_cancel_delayed_work, | |
| 1410 | - | &xadc->zynq_unmask_work); | |
| 1410 | + | ret = devm_request_irq(dev, irq, xadc->ops->interrupt_handler, | |
| 1411 | + | 0, dev_name(dev), indio_dev); | |
| 1411 | 1412 | if (ret) | |
| 1412 | 1413 | return ret; | |
| 1413 | 1414 | } | |
modified drivers/iio/buffer/industrialio-buffer-dmaengine.c
| @@ -104,10 +104,13 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, | |||
| 104 | 104 | if (block->sg_table) { | |
| 105 | 105 | unsigned long flags; | |
| 106 | 106 | ||
| 107 | - | sgl = block->sg_table->sgl; | |
| 108 | - | nents = sg_nents_for_len(sgl, block->bytes_used); | |
| 109 | - | if (nents < 0) | |
| 110 | - | return nents; | |
| 107 | + | /* | |
| 108 | + | * Only the first sgt->nents entries carry a valid | |
| 109 | + | * sg_dma_address()/sg_dma_len() pair as mapping the table may | |
| 110 | + | * have coalesced entries, in which case nents is smaller than | |
| 111 | + | * orig_nents. | |
| 112 | + | */ | |
| 113 | + | nents = block->sg_table->nents; | |
| 111 | 114 | ||
| 112 | 115 | vecs = kmalloc_objs(*vecs, nents, GFP_ATOMIC); | |
| 113 | 116 | if (!vecs) | |
| @@ -115,7 +118,8 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, | |||
| 115 | 118 | ||
| 116 | 119 | len_total = block->bytes_used; | |
| 117 | 120 | ||
| 118 | - | for (i = 0; i < nents; i++) { | |
| 121 | + | sgl = block->sg_table->sgl; | |
| 122 | + | for (i = 0; i < nents && len_total; i++) { | |
| 119 | 123 | vecs[i].addr = sg_dma_address(sgl); | |
| 120 | 124 | vecs[i].len = min(sg_dma_len(sgl), len_total); | |
| 121 | 125 | len_total -= vecs[i].len; | |
| @@ -123,6 +127,8 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, | |||
| 123 | 127 | sgl = sg_next(sgl); | |
| 124 | 128 | } | |
| 125 | 129 | ||
| 130 | + | nents = i; | |
| 131 | + | ||
| 126 | 132 | if (block->cyclic) | |
| 127 | 133 | flags = DMA_PREP_REPEAT; | |
| 128 | 134 | else | |
modified drivers/iio/cdc/ad7150.c
| @@ -636,11 +636,13 @@ static const struct i2c_device_id ad7150_id[] = { | |||
| 636 | 636 | MODULE_DEVICE_TABLE(i2c, ad7150_id); | |
| 637 | 637 | ||
| 638 | 638 | static const struct of_device_id ad7150_of_match[] = { | |
| 639 | - | { "adi,ad7150" }, | |
| 640 | - | { "adi,ad7151" }, | |
| 641 | - | { "adi,ad7156" }, | |
| 639 | + | { .compatible = "adi,ad7150" }, | |
| 640 | + | { .compatible = "adi,ad7151" }, | |
| 641 | + | { .compatible = "adi,ad7156" }, | |
| 642 | 642 | { } | |
| 643 | 643 | }; | |
| 644 | + | MODULE_DEVICE_TABLE(of, ad7150_of_match); | |
| 645 | + | ||
| 644 | 646 | static struct i2c_driver ad7150_driver = { | |
| 645 | 647 | .driver = { | |
| 646 | 648 | .name = "ad7150", | |
modified drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
| @@ -167,11 +167,16 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts, | |||
| 167 | 167 | valid = inv_validate_period(ts, period); | |
| 168 | 168 | } | |
| 169 | 169 | ||
| 170 | - | /* if interrupt interval is valid, sync with interrupt timestamp */ | |
| 170 | + | /* | |
| 171 | + | * If interrupt interval is valid, sync with interrupt timestamp. | |
| 172 | + | * Otherwise, use estimated value while ensuring interrupt timestamp | |
| 173 | + | * remains the maximum possible value. | |
| 174 | + | */ | |
| 175 | + | period = inv_align_timestamp_it(ts, sample_nb); | |
| 171 | 176 | if (valid) | |
| 172 | - | ts->period = inv_align_timestamp_it(ts, sample_nb); | |
| 177 | + | ts->period = period; | |
| 173 | 178 | else | |
| 174 | - | ts->period = ts->mult * ts->chip_period.val; | |
| 179 | + | ts->period = min(ts->mult * ts->chip_period.val, period); | |
| 175 | 180 | } | |
| 176 | 181 | EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_interrupt, "IIO_INV_SENSORS_TIMESTAMP"); | |
| 177 | 182 | ||
modified drivers/iio/dac/mcp47a1.c
| @@ -26,7 +26,7 @@ struct mcp47a1_data { | |||
| 26 | 26 | int vref_mV; | |
| 27 | 27 | }; | |
| 28 | 28 | ||
| 29 | - | static const int mcp47a1_raw_avail[] = { 0, 1, MCP47A1_MAX_STEPS - 1 }; | |
| 29 | + | static const int mcp47a1_raw_avail[] = { 0, 1, MCP47A1_MAX_STEPS }; | |
| 30 | 30 | ||
| 31 | 31 | static const struct iio_chan_spec mcp47a1_channel = { | |
| 32 | 32 | .type = IIO_VOLTAGE, | |
| @@ -46,7 +46,7 @@ static int mcp47a1_write(struct iio_dev *indio_dev, | |||
| 46 | 46 | ||
| 47 | 47 | switch (mask) { | |
| 48 | 48 | case IIO_CHAN_INFO_RAW: | |
| 49 | - | if (!in_range(val, 0, MCP47A1_MAX_STEPS)) | |
| 49 | + | if (!in_range(val, 0, MCP47A1_MAX_STEPS + 1)) | |
| 50 | 50 | return -EINVAL; | |
| 51 | 51 | ||
| 52 | 52 | return i2c_smbus_write_byte_data(data->client, MCP47A1_CMD_CODE, | |
modified drivers/iio/dac/rohm-bd79703.c
| @@ -73,6 +73,9 @@ static int bd79703_write_raw(struct iio_dev *idev, | |||
| 73 | 73 | { | |
| 74 | 74 | struct bd79703_data *data = iio_priv(idev); | |
| 75 | 75 | ||
| 76 | + | if (mask != IIO_CHAN_INFO_RAW) | |
| 77 | + | return -EINVAL; | |
| 78 | + | ||
| 76 | 79 | if (val < 0 || val >= 1 << BD79703_DAC_BITS) | |
| 77 | 80 | return -EINVAL; | |
| 78 | 81 | ||
modified drivers/iio/frequency/adf4377.c
| @@ -988,10 +988,10 @@ static const struct clk_ops adf4377_clk_ops = { | |||
| 988 | 988 | ||
| 989 | 989 | static int adf4377_clk_register(struct adf4377_state *st) | |
| 990 | 990 | { | |
| 991 | + | struct clk_parent_data parent_data = { }; | |
| 991 | 992 | struct spi_device *spi = st->spi; | |
| 992 | 993 | struct device *dev = &spi->dev; | |
| 993 | - | struct clk_init_data init; | |
| 994 | - | struct clk_parent_data parent_data; | |
| 994 | + | struct clk_init_data init = { }; | |
| 995 | 995 | int ret; | |
| 996 | 996 | ||
| 997 | 997 | if (!device_property_present(dev, "#clock-cells")) | |
modified drivers/iio/frequency/admv1013.c
| @@ -195,7 +195,7 @@ static int admv1013_read_raw(struct iio_dev *indio_dev, | |||
| 195 | 195 | ||
| 196 | 196 | switch (info) { | |
| 197 | 197 | case IIO_CHAN_INFO_CALIBBIAS: | |
| 198 | - | switch (chan->channel) { | |
| 198 | + | switch (chan->channel2) { | |
| 199 | 199 | case IIO_MOD_I: | |
| 200 | 200 | addr = ADMV1013_REG_OFFSET_ADJUST_I; | |
| 201 | 201 | break; | |
| @@ -601,11 +601,14 @@ static int admv1013_probe(struct spi_device *spi) | |||
| 601 | 601 | "failed to get the LO input clock\n"); | |
| 602 | 602 | ||
| 603 | 603 | st->nb.notifier_call = admv1013_freq_change; | |
| 604 | - | ret = devm_clk_notifier_register(dev, st->clkin, &st->nb); | |
| 604 | + | ||
| 605 | + | ret = devm_mutex_init(dev, &st->lock); | |
| 605 | 606 | if (ret) | |
| 606 | 607 | return ret; | |
| 607 | 608 | ||
| 608 | - | mutex_init(&st->lock); | |
| 609 | + | ret = devm_clk_notifier_register(dev, st->clkin, &st->nb); | |
| 610 | + | if (ret) | |
| 611 | + | return ret; | |
| 609 | 612 | ||
| 610 | 613 | ret = admv1013_init(st, vcm_uv); | |
| 611 | 614 | if (ret) | |
modified drivers/iio/gyro/adis16136.c
| @@ -145,7 +145,7 @@ static int adis16136_debugfs_init(struct iio_dev *indio_dev) | |||
| 145 | 145 | struct adis16136 *adis16136 = iio_priv(indio_dev); | |
| 146 | 146 | struct dentry *d = iio_get_debugfs_dentry(indio_dev); | |
| 147 | 147 | ||
| 148 | - | debugfs_create_file_unsafe("serial_number", 0400, | |
| 148 | + | debugfs_create_file("serial_number", 0400, | |
| 149 | 149 | d, adis16136, &adis16136_serial_fops); | |
| 150 | 150 | debugfs_create_file_unsafe("product_id", 0400, | |
| 151 | 151 | d, adis16136, &adis16136_product_id_fops); | |
modified drivers/iio/health/max30102.c
| @@ -290,9 +290,15 @@ static irqreturn_t max30102_interrupt_handler(int irq, void *private) | |||
| 290 | 290 | { | |
| 291 | 291 | struct iio_dev *indio_dev = private; | |
| 292 | 292 | struct max30102_data *data = iio_priv(indio_dev); | |
| 293 | - | unsigned int measurements = bitmap_weight(indio_dev->active_scan_mask, | |
| 294 | - | iio_get_masklength(indio_dev)); | |
| 295 | - | int ret, cnt = 0; | |
| 293 | + | unsigned int measurements; | |
| 294 | + | int ret, cnt; | |
| 295 | + | ||
| 296 | + | cnt = max30102_fifo_count(data); | |
| 297 | + | if (cnt <= 0) | |
| 298 | + | return IRQ_HANDLED; | |
| 299 | + | ||
| 300 | + | measurements = bitmap_weight(indio_dev->active_scan_mask, | |
| 301 | + | iio_get_masklength(indio_dev)); | |
| 296 | 302 | ||
| 297 | 303 | mutex_lock(&data->lock); | |
| 298 | 304 | ||
modified drivers/iio/imu/adis16400.c
| @@ -280,7 +280,7 @@ static void adis16400_debugfs_init(struct iio_dev *indio_dev) | |||
| 280 | 280 | return; | |
| 281 | 281 | ||
| 282 | 282 | if (st->variant->flags & ADIS16400_HAS_SERIAL_NUMBER) | |
| 283 | - | debugfs_create_file_unsafe("serial_number", 0400, | |
| 283 | + | debugfs_create_file("serial_number", 0400, | |
| 284 | 284 | d, st, &adis16400_serial_number_fops); | |
| 285 | 285 | if (st->variant->flags & ADIS16400_HAS_PROD_ID) | |
| 286 | 286 | debugfs_create_file_unsafe("product_id", 0400, | |
modified drivers/iio/imu/adis16480.c
| @@ -309,9 +309,9 @@ static void adis16480_debugfs_init(struct iio_dev *indio_dev) | |||
| 309 | 309 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) | |
| 310 | 310 | return; | |
| 311 | 311 | ||
| 312 | - | debugfs_create_file_unsafe("firmware_revision", 0400, | |
| 312 | + | debugfs_create_file("firmware_revision", 0400, | |
| 313 | 313 | d, adis16480, &adis16480_firmware_revision_fops); | |
| 314 | - | debugfs_create_file_unsafe("firmware_date", 0400, | |
| 314 | + | debugfs_create_file("firmware_date", 0400, | |
| 315 | 315 | d, adis16480, &adis16480_firmware_date_fops); | |
| 316 | 316 | debugfs_create_file_unsafe("serial_number", 0400, | |
| 317 | 317 | d, adis16480, &adis16480_serial_number_fops); | |
modified drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
| @@ -537,9 +537,8 @@ static int inv_icm42607_enable_vddio_reg(struct inv_icm42607_state *st) | |||
| 537 | 537 | return 0; | |
| 538 | 538 | } | |
| 539 | 539 | ||
| 540 | - | static void inv_icm42607_sensors_off(void *_data) | |
| 540 | + | static int inv_icm42607_sensors_off(struct inv_icm42607_state *st) | |
| 541 | 541 | { | |
| 542 | - | struct inv_icm42607_state *st = _data; | |
| 543 | 542 | const struct device *dev = regmap_get_device(st->map); | |
| 544 | 543 | int ret; | |
| 545 | 544 | ||
| @@ -552,6 +551,13 @@ static void inv_icm42607_sensors_off(void *_data) | |||
| 552 | 551 | st->conf.accel.mode); | |
| 553 | 552 | if (ret) | |
| 554 | 553 | dev_err(dev, "Unable to turn off sensors\n"); | |
| 554 | + | ||
| 555 | + | return ret; | |
| 556 | + | } | |
| 557 | + | ||
| 558 | + | static void inv_icm42607_sensors_off_action(void *data) | |
| 559 | + | { | |
| 560 | + | inv_icm42607_sensors_off(data); | |
| 555 | 561 | } | |
| 556 | 562 | ||
| 557 | 563 | static void inv_icm42607_disable_vddio_reg(void *_data) | |
| @@ -619,7 +625,7 @@ int inv_icm42607_core_probe(struct regmap *regmap, | |||
| 619 | 625 | * Ensure if sensors get turned on at some point, they're turned off | |
| 620 | 626 | * as part of teardown. | |
| 621 | 627 | */ | |
| 622 | - | ret = devm_add_action_or_reset(dev, inv_icm42607_sensors_off, st); | |
| 628 | + | ret = devm_add_action_or_reset(dev, inv_icm42607_sensors_off_action, st); | |
| 623 | 629 | if (ret) | |
| 624 | 630 | return ret; | |
| 625 | 631 | ||
| @@ -658,9 +664,8 @@ static int inv_icm42607_suspend(struct device *dev) | |||
| 658 | 664 | return 0; | |
| 659 | 665 | } | |
| 660 | 666 | ||
| 661 | - | static int inv_icm42607_resume(struct device *dev) | |
| 667 | + | static int inv_icm42607_resume_core(struct inv_icm42607_state *st) | |
| 662 | 668 | { | |
| 663 | - | struct inv_icm42607_state *st = dev_get_drvdata(dev); | |
| 664 | 669 | int ret; | |
| 665 | 670 | ||
| 666 | 671 | ret = inv_icm42607_enable_vddio_reg(st); | |
| @@ -669,9 +674,25 @@ static int inv_icm42607_resume(struct device *dev) | |||
| 669 | 674 | ||
| 670 | 675 | /* Sync the regcache again after regulator shutdown. */ | |
| 671 | 676 | regcache_mark_dirty(st->map); | |
| 672 | - | ret = regcache_sync(st->map); | |
| 673 | - | if (ret) | |
| 677 | + | ||
| 678 | + | return regcache_sync(st->map); | |
| 679 | + | } | |
| 680 | + | ||
| 681 | + | static int inv_icm42607_resume(struct device *dev) | |
| 682 | + | { | |
| 683 | + | struct inv_icm42607_state *st = dev_get_drvdata(dev); | |
| 684 | + | int ret; | |
| 685 | + | ||
| 686 | + | ret = inv_icm42607_resume_core(st); | |
| 687 | + | if (ret) { | |
| 688 | + | int rc; | |
| 689 | + | ||
| 690 | + | rc = pm_runtime_force_resume(dev); | |
| 691 | + | if (rc) | |
| 692 | + | dev_warn(dev, "Failed to restore runtime PM state: %d\n", rc); | |
| 693 | + | ||
| 674 | 694 | return ret; | |
| 695 | + | } | |
| 675 | 696 | ||
| 676 | 697 | return pm_runtime_force_resume(dev); | |
| 677 | 698 | } | |
| @@ -688,8 +709,7 @@ static int inv_icm42607_runtime_suspend(struct device *dev) | |||
| 688 | 709 | * however the tradeoff is that an unused sensor won't be | |
| 689 | 710 | * turned off until the entire chip is no longer in use. | |
| 690 | 711 | */ | |
| 691 | - | inv_icm42607_sensors_off(st); | |
| 692 | - | return 0; | |
| 712 | + | return inv_icm42607_sensors_off(st); | |
| 693 | 713 | } | |
| 694 | 714 | ||
| 695 | 715 | EXPORT_NS_GPL_DEV_PM_OPS(inv_icm42607_pm_ops, IIO_ICM42607) = { | |
modified drivers/iio/industrialio-buffer.c
| @@ -1377,6 +1377,10 @@ EXPORT_SYMBOL_GPL(iio_update_buffers); | |||
| 1377 | 1377 | ||
| 1378 | 1378 | void iio_disable_all_buffers(struct iio_dev *indio_dev) | |
| 1379 | 1379 | { | |
| 1380 | + | struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); | |
| 1381 | + | ||
| 1382 | + | guard(mutex)(&iio_dev_opaque->mlock); | |
| 1383 | + | ||
| 1380 | 1384 | iio_disable_buffers(indio_dev); | |
| 1381 | 1385 | iio_buffer_deactivate_all(indio_dev); | |
| 1382 | 1386 | } | |
| @@ -2462,7 +2466,8 @@ int iio_push_to_buffers_with_ts_unaligned(struct iio_dev *indio_dev, | |||
| 2462 | 2466 | ||
| 2463 | 2467 | bb = devm_krealloc(&indio_dev->dev, | |
| 2464 | 2468 | iio_dev_opaque->bounce_buffer, | |
| 2465 | - | indio_dev->scan_bytes, GFP_KERNEL); | |
| 2469 | + | indio_dev->scan_bytes, | |
| 2470 | + | GFP_KERNEL | __GFP_ZERO); | |
| 2466 | 2471 | if (!bb) | |
| 2467 | 2472 | return -ENOMEM; | |
| 2468 | 2473 | iio_dev_opaque->bounce_buffer = bb; | |
modified drivers/iio/industrialio-trigger.c
| @@ -509,6 +509,8 @@ static void iio_trig_release(struct device *device) | |||
| 509 | 509 | struct iio_trigger *trig = to_iio_trigger(device); | |
| 510 | 510 | int i; | |
| 511 | 511 | ||
| 512 | + | cancel_work_sync(&trig->reenable_work); | |
| 513 | + | ||
| 512 | 514 | if (trig->subirq_base) { | |
| 513 | 515 | for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) { | |
| 514 | 516 | irq_modify_status(trig->subirq_base + i, | |
modified drivers/iio/light/gp2ap020a00f.c
| @@ -1497,6 +1497,7 @@ error_trigger_unregister: | |||
| 1497 | 1497 | iio_trigger_unregister(data->trig); | |
| 1498 | 1498 | error_free_irq: | |
| 1499 | 1499 | free_irq(client->irq, indio_dev); | |
| 1500 | + | irq_work_sync(&data->work); | |
| 1500 | 1501 | error_uninit_buffer: | |
| 1501 | 1502 | iio_triggered_buffer_cleanup(indio_dev); | |
| 1502 | 1503 | error_regulator_disable: | |
| @@ -1519,6 +1520,7 @@ static void gp2ap020a00f_remove(struct i2c_client *client) | |||
| 1519 | 1520 | iio_device_unregister(indio_dev); | |
| 1520 | 1521 | iio_trigger_unregister(data->trig); | |
| 1521 | 1522 | free_irq(client->irq, indio_dev); | |
| 1523 | + | irq_work_sync(&data->work); | |
| 1522 | 1524 | iio_triggered_buffer_cleanup(indio_dev); | |
| 1523 | 1525 | regulator_disable(data->vled_reg); | |
| 1524 | 1526 | } | |
modified drivers/iio/light/rohm-bu27034.c
| @@ -137,6 +137,7 @@ static const struct iio_gain_sel_pair bu27034_gains[] = { | |||
| 137 | 137 | #define BU27034_MEAS_MODE_200MS 2 | |
| 138 | 138 | #define BU27034_MEAS_MODE_400MS 4 | |
| 139 | 139 | ||
| 140 | + | #define BU27034_INT_TIME_US_MIN (55 * USEC_PER_MSEC) | |
| 140 | 141 | static const struct iio_itime_sel_mul bu27034_itimes[] = { | |
| 141 | 142 | GAIN_SCALE_ITIME_US(400000, BU27034_MEAS_MODE_400MS, 8), | |
| 142 | 143 | GAIN_SCALE_ITIME_US(200000, BU27034_MEAS_MODE_200MS, 4), | |
| @@ -296,7 +297,7 @@ static int bu27034_get_gain(struct bu27034_data *data, int chan, int *gain) | |||
| 296 | 297 | return 0; | |
| 297 | 298 | } | |
| 298 | 299 | ||
| 299 | - | static int bu27034_get_int_time(struct bu27034_data *data) | |
| 300 | + | static int bu27034_get_int_time(struct bu27034_data *data, int *itime) | |
| 300 | 301 | { | |
| 301 | 302 | int ret, sel; | |
| 302 | 303 | ||
| @@ -304,24 +305,30 @@ static int bu27034_get_int_time(struct bu27034_data *data) | |||
| 304 | 305 | if (ret) | |
| 305 | 306 | return ret; | |
| 306 | 307 | ||
| 307 | - | return iio_gts_find_int_time_by_sel(&data->gts, | |
| 308 | - | sel & BU27034_MASK_MEAS_MODE); | |
| 308 | + | ret = iio_gts_find_int_time_by_sel(&data->gts, | |
| 309 | + | sel & BU27034_MASK_MEAS_MODE); | |
| 310 | + | if (ret < 0) | |
| 311 | + | return ret; | |
| 312 | + | ||
| 313 | + | *itime = ret; | |
| 314 | + | ||
| 315 | + | return 0; | |
| 309 | 316 | } | |
| 310 | 317 | ||
| 311 | 318 | static int _bu27034_get_scale(struct bu27034_data *data, int channel, int *val, | |
| 312 | 319 | int *val2) | |
| 313 | 320 | { | |
| 314 | - | int gain, ret; | |
| 321 | + | int gain, itime, ret; | |
| 315 | 322 | ||
| 316 | 323 | ret = bu27034_get_gain(data, channel, &gain); | |
| 317 | 324 | if (ret) | |
| 318 | 325 | return ret; | |
| 319 | 326 | ||
| 320 | - | ret = bu27034_get_int_time(data); | |
| 321 | - | if (ret < 0) | |
| 327 | + | ret = bu27034_get_int_time(data, &itime); | |
| 328 | + | if (ret) | |
| 322 | 329 | return ret; | |
| 323 | 330 | ||
| 324 | - | return iio_gts_get_scale(&data->gts, gain, ret, val, val2); | |
| 331 | + | return iio_gts_get_scale(&data->gts, gain, itime, val, val2); | |
| 325 | 332 | } | |
| 326 | 333 | ||
| 327 | 334 | static int bu27034_get_scale(struct bu27034_data *data, int channel, int *val, | |
| @@ -397,12 +404,10 @@ static int bu27034_try_set_int_time(struct bu27034_data *data, int time_us) | |||
| 397 | 404 | int ret, int_time_old, i; | |
| 398 | 405 | ||
| 399 | 406 | guard(mutex)(&data->mutex); | |
| 400 | - | ret = bu27034_get_int_time(data); | |
| 401 | - | if (ret < 0) | |
| 407 | + | ret = bu27034_get_int_time(data, &int_time_old); | |
| 408 | + | if (ret) | |
| 402 | 409 | return ret; | |
| 403 | 410 | ||
| 404 | - | int_time_old = ret; | |
| 405 | - | ||
| 406 | 411 | if (!iio_gts_valid_time(&data->gts, time_us)) { | |
| 407 | 412 | dev_err(data->dev, "Unsupported integration time %u\n", | |
| 408 | 413 | time_us); | |
| @@ -415,7 +420,7 @@ static int bu27034_try_set_int_time(struct bu27034_data *data, int time_us) | |||
| 415 | 420 | for (i = 0; i < numg; i++) { | |
| 416 | 421 | ret = bu27034_get_gain(data, gains[i].chan, &gains[i].old_gain); | |
| 417 | 422 | if (ret) | |
| 418 | - | return 0; | |
| 423 | + | return ret; | |
| 419 | 424 | ||
| 420 | 425 | ret = iio_gts_find_new_gain_by_old_gain_time(&data->gts, | |
| 421 | 426 | gains[i].old_gain, | |
| @@ -841,7 +846,7 @@ static int bu27034_meas_set(struct bu27034_data *data, bool en) | |||
| 841 | 846 | static int bu27034_get_single_result(struct bu27034_data *data, int chan, | |
| 842 | 847 | int *val) | |
| 843 | 848 | { | |
| 844 | - | int ret; | |
| 849 | + | int ret, itime; | |
| 845 | 850 | ||
| 846 | 851 | if (chan < BU27034_CHAN_DATA0 || chan > BU27034_CHAN_DATA1) | |
| 847 | 852 | return -EINVAL; | |
| @@ -850,11 +855,11 @@ static int bu27034_get_single_result(struct bu27034_data *data, int chan, | |||
| 850 | 855 | if (ret) | |
| 851 | 856 | return ret; | |
| 852 | 857 | ||
| 853 | - | ret = bu27034_get_int_time(data); | |
| 854 | - | if (ret < 0) | |
| 858 | + | ret = bu27034_get_int_time(data, &itime); | |
| 859 | + | if (ret) | |
| 855 | 860 | return ret; | |
| 856 | 861 | ||
| 857 | - | msleep(ret / 1000); | |
| 862 | + | msleep(itime / 1000); | |
| 858 | 863 | ||
| 859 | 864 | return bu27034_read_result(data, chan, val); | |
| 860 | 865 | } | |
| @@ -904,12 +909,10 @@ static int bu27034_calc_mlux(struct bu27034_data *data, __le16 *res, int *val) | |||
| 904 | 909 | if (ret) | |
| 905 | 910 | return ret; | |
| 906 | 911 | ||
| 907 | - | ret = bu27034_get_int_time(data); | |
| 908 | - | if (ret < 0) | |
| 912 | + | ret = bu27034_get_int_time(data, &meastime); | |
| 913 | + | if (ret) | |
| 909 | 914 | return ret; | |
| 910 | 915 | ||
| 911 | - | meastime = ret; | |
| 912 | - | ||
| 913 | 916 | d1_d0_ratio_scaled = (unsigned int)ch1 * (unsigned int)gain0 * 100; | |
| 914 | 917 | helper64 = (u64)ch1 * (u64)gain0 * 100LLU; | |
| 915 | 918 | ||
| @@ -970,9 +973,9 @@ static int bu27034_read_raw(struct iio_dev *idev, | |||
| 970 | 973 | switch (mask) { | |
| 971 | 974 | case IIO_CHAN_INFO_INT_TIME: | |
| 972 | 975 | *val = 0; | |
| 973 | - | *val2 = bu27034_get_int_time(data); | |
| 974 | - | if (*val2 < 0) | |
| 975 | - | return *val2; | |
| 976 | + | ret = bu27034_get_int_time(data, val2); | |
| 977 | + | if (ret) | |
| 978 | + | return ret; | |
| 976 | 979 | ||
| 977 | 980 | return IIO_VAL_INT_PLUS_MICRO; | |
| 978 | 981 | ||
| @@ -1157,11 +1160,20 @@ static int bu27034_buffer_thread(void *arg) | |||
| 1157 | 1160 | { | |
| 1158 | 1161 | struct iio_dev *idev = arg; | |
| 1159 | 1162 | struct bu27034_data *data; | |
| 1160 | - | int wait_ms; | |
| 1163 | + | int wait_ms, ret; | |
| 1161 | 1164 | ||
| 1162 | 1165 | data = iio_priv(idev); | |
| 1163 | 1166 | ||
| 1164 | - | wait_ms = bu27034_get_int_time(data); | |
| 1167 | + | /* | |
| 1168 | + | * If reading the integration time fails, default to the minimum so we | |
| 1169 | + | * don't lose samples. This may waste CPU cycles, but as a hardening | |
| 1170 | + | * against theoretical, once-in-a-blue-moon error, this should be Ok. | |
| 1171 | + | */ | |
| 1172 | + | wait_ms = BU27034_INT_TIME_US_MIN; | |
| 1173 | + | ret = bu27034_get_int_time(data, &wait_ms); | |
| 1174 | + | if (ret) | |
| 1175 | + | dev_warn(data->dev, "Failed to get integration time\n"); | |
| 1176 | + | ||
| 1165 | 1177 | wait_ms /= 1000; | |
| 1166 | 1178 | ||
| 1167 | 1179 | wait_ms -= BU27034_MEAS_WAIT_PREMATURE_MS; | |
modified drivers/iio/pressure/bmp280-core.c
| @@ -839,7 +839,7 @@ static int bmp280_write_sampling_frequency(struct bmp280_data *data, | |||
| 839 | 839 | int val, int val2) | |
| 840 | 840 | { | |
| 841 | 841 | const int (*avail)[2] = data->chip_info->sampling_freq_avail; | |
| 842 | - | const int n = data->chip_info->num_sampling_freq_avail; | |
| 842 | + | const int n = data->chip_info->num_sampling_freq_avail / 2; | |
| 843 | 843 | int ret, prev; | |
| 844 | 844 | int i; | |
| 845 | 845 | ||
modified drivers/iio/pressure/rohm-bm1390.c
| @@ -289,7 +289,7 @@ static int bm1390_read_data(struct bm1390_data *data, | |||
| 289 | 289 | if (warn) | |
| 290 | 290 | dev_warn(data->dev, "Failed to stop measurement (%d)\n", warn); | |
| 291 | 291 | ||
| 292 | - | return 0; | |
| 292 | + | return ret; | |
| 293 | 293 | } | |
| 294 | 294 | ||
| 295 | 295 | static int bm1390_read_raw(struct iio_dev *idev, | |
modified drivers/iio/proximity/aw96103.c
| @@ -24,6 +24,7 @@ | |||
| 24 | 24 | #define AW96103_BIN_VALID_DATA_OFFSET 64 | |
| 25 | 25 | #define AW96103_BIN_DATA_LEN_OFFSET 16 | |
| 26 | 26 | #define AW96103_BIN_DATA_REG_NUM_SIZE 4 | |
| 27 | + | #define AW96103_BIN_REG_SIZE 6 | |
| 27 | 28 | #define AW96103_BIN_CHIP_TYPE_SIZE 8 | |
| 28 | 29 | #define AW96103_BIN_CHIP_TYPE_OFFSET 24 | |
| 29 | 30 | ||
| @@ -229,14 +230,27 @@ static const struct aw_chip_info aw_chip_info_tbl[] = { | |||
| 229 | 230 | }, | |
| 230 | 231 | }; | |
| 231 | 232 | ||
| 232 | - | static void aw96103_parsing_bin_file(struct aw_bin *bin) | |
| 233 | + | static int aw96103_parsing_bin_file(struct aw_bin *bin) | |
| 233 | 234 | { | |
| 235 | + | u32 data_len; | |
| 236 | + | ||
| 237 | + | if (bin->len < AW96103_BIN_VALID_DATA_OFFSET) | |
| 238 | + | return -EINVAL; | |
| 239 | + | ||
| 240 | + | data_len = get_unaligned_le32(bin->data + AW96103_BIN_DATA_LEN_OFFSET); | |
| 241 | + | if (data_len < AW96103_BIN_DATA_REG_NUM_SIZE) | |
| 242 | + | return -EINVAL; | |
| 243 | + | ||
| 244 | + | bin->valid_data_len = data_len - AW96103_BIN_DATA_REG_NUM_SIZE; | |
| 245 | + | if (bin->valid_data_len > bin->len - AW96103_BIN_VALID_DATA_OFFSET || | |
| 246 | + | bin->valid_data_len % AW96103_BIN_REG_SIZE) | |
| 247 | + | return -EINVAL; | |
| 248 | + | ||
| 234 | 249 | bin->valid_data_addr = AW96103_BIN_VALID_DATA_OFFSET; | |
| 235 | - | bin->valid_data_len = | |
| 236 | - | *(unsigned int *)(bin->data + AW96103_BIN_DATA_LEN_OFFSET) - | |
| 237 | - | AW96103_BIN_DATA_REG_NUM_SIZE; | |
| 238 | 250 | memcpy(bin->chip_type, bin->data + AW96103_BIN_CHIP_TYPE_OFFSET, | |
| 239 | 251 | AW96103_BIN_CHIP_TYPE_SIZE); | |
| 252 | + | ||
| 253 | + | return 0; | |
| 240 | 254 | } | |
| 241 | 255 | ||
| 242 | 256 | static const struct regmap_config aw96103_regmap_confg = { | |
| @@ -500,7 +514,7 @@ static int aw96103_bin_valid_loaded(struct aw96103 *aw96103, | |||
| 500 | 514 | int ret; | |
| 501 | 515 | ||
| 502 | 516 | for (i = 0; i < aw_bin_data_s->valid_data_len; | |
| 503 | - | i += 6, start_addr += 6) { | |
| 517 | + | i += AW96103_BIN_REG_SIZE, start_addr += AW96103_BIN_REG_SIZE) { | |
| 504 | 518 | reg_addr = get_unaligned_le16(aw_bin_data_s->data + start_addr); | |
| 505 | 519 | reg_data = get_unaligned_le32(aw_bin_data_s->data + | |
| 506 | 520 | start_addr + 2); | |
| @@ -550,6 +564,8 @@ static int aw96103_para_loaded(struct aw96103 *aw96103) | |||
| 550 | 564 | static int aw96103_cfg_all_loaded(const struct firmware *cont, | |
| 551 | 565 | struct aw96103 *aw96103) | |
| 552 | 566 | { | |
| 567 | + | int ret; | |
| 568 | + | ||
| 553 | 569 | if (!cont) | |
| 554 | 570 | return -EINVAL; | |
| 555 | 571 | ||
| @@ -561,7 +577,9 @@ static int aw96103_cfg_all_loaded(const struct firmware *cont, | |||
| 561 | 577 | aw_bin->len = cont->size; | |
| 562 | 578 | memcpy(aw_bin->data, cont->data, cont->size); | |
| 563 | 579 | release_firmware(cont); | |
| 564 | - | aw96103_parsing_bin_file(aw_bin); | |
| 580 | + | ret = aw96103_parsing_bin_file(aw_bin); | |
| 581 | + | if (ret) | |
| 582 | + | return ret; | |
| 565 | 583 | ||
| 566 | 584 | return aw96103_bin_valid_loaded(aw96103, aw_bin); | |
| 567 | 585 | } | |
modified drivers/iio/proximity/isl29501.c
| @@ -226,7 +226,7 @@ err: | |||
| 226 | 226 | return ret; | |
| 227 | 227 | } | |
| 228 | 228 | ||
| 229 | - | static u32 isl29501_register_write(struct isl29501_private *isl29501, | |
| 229 | + | static int isl29501_register_write(struct isl29501_private *isl29501, | |
| 230 | 230 | enum isl29501_register_name name, | |
| 231 | 231 | u32 value) | |
| 232 | 232 | { | |
modified drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
| @@ -294,12 +294,14 @@ static int lidar_probe(struct i2c_client *client) | |||
| 294 | 294 | ||
| 295 | 295 | ret = pm_runtime_set_active(&client->dev); | |
| 296 | 296 | if (ret) | |
| 297 | - | goto error_unreg_buffer; | |
| 297 | + | goto error_unreg_dev; | |
| 298 | 298 | pm_runtime_enable(&client->dev); | |
| 299 | 299 | pm_runtime_idle(&client->dev); | |
| 300 | 300 | ||
| 301 | 301 | return 0; | |
| 302 | 302 | ||
| 303 | + | error_unreg_dev: | |
| 304 | + | iio_device_unregister(indio_dev); | |
| 303 | 305 | error_unreg_buffer: | |
| 304 | 306 | iio_triggered_buffer_cleanup(indio_dev); | |
| 305 | 307 | ||
modified drivers/iio/proximity/sx9324.c
| @@ -222,7 +222,7 @@ static const struct iio_chan_spec_ext_info sx9324_channel_ext_info[] = { | |||
| 222 | 222 | .scan_index = idx, \ | |
| 223 | 223 | .scan_type = { \ | |
| 224 | 224 | .sign = 's', \ | |
| 225 | - | .realbits = 12, \ | |
| 225 | + | .realbits = 16, \ | |
| 226 | 226 | .storagebits = 16, \ | |
| 227 | 227 | .endianness = IIO_BE, \ | |
| 228 | 228 | }, \ | |
modified drivers/iio/proximity/vcnl3020.c
| @@ -584,16 +584,26 @@ static irqreturn_t vcnl3020_handle_irq_thread(int irq, void *p) | |||
| 584 | 584 | return IRQ_HANDLED; | |
| 585 | 585 | } | |
| 586 | 586 | ||
| 587 | - | if (!(isr & VCNL_ICR_THRES_EN)) | |
| 587 | + | if (!(isr & (VCNL_INT_TH_HI | VCNL_INT_TH_LOW))) | |
| 588 | 588 | return IRQ_NONE; | |
| 589 | 589 | ||
| 590 | - | iio_push_event(indio_dev, | |
| 591 | - | IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 1, | |
| 592 | - | IIO_EV_TYPE_THRESH, | |
| 593 | - | IIO_EV_DIR_RISING), | |
| 594 | - | iio_get_time_ns(indio_dev)); | |
| 590 | + | if (isr & VCNL_INT_TH_HI) { | |
| 591 | + | iio_push_event(indio_dev, | |
| 592 | + | IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0, | |
| 593 | + | IIO_EV_TYPE_THRESH, | |
| 594 | + | IIO_EV_DIR_RISING), | |
| 595 | + | iio_get_time_ns(indio_dev)); | |
| 596 | + | } | |
| 597 | + | ||
| 598 | + | if (isr & VCNL_INT_TH_LOW) { | |
| 599 | + | iio_push_event(indio_dev, | |
| 600 | + | IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0, | |
| 601 | + | IIO_EV_TYPE_THRESH, | |
| 602 | + | IIO_EV_DIR_FALLING), | |
| 603 | + | iio_get_time_ns(indio_dev)); | |
| 604 | + | } | |
| 595 | 605 | ||
| 596 | - | rc = regmap_write(data->regmap, VCNL_ISR, isr & VCNL_ICR_THRES_EN); | |
| 606 | + | rc = regmap_write(data->regmap, VCNL_ISR, isr & (VCNL_INT_TH_HI | VCNL_INT_TH_LOW)); | |
| 597 | 607 | if (rc) | |
| 598 | 608 | dev_err(data->dev, "Error (%d) writing in reg (0x%x)\n", | |
| 599 | 609 | rc, VCNL_ISR); | |
modified drivers/iio/proximity/vl53l0x-i2c.c
| @@ -219,7 +219,10 @@ static int vl53l0x_read_raw(struct iio_dev *indio_dev, | |||
| 219 | 219 | ||
| 220 | 220 | switch (mask) { | |
| 221 | 221 | case IIO_CHAN_INFO_RAW: | |
| 222 | + | if (!iio_device_claim_direct(indio_dev)) | |
| 223 | + | return -EBUSY; | |
| 222 | 224 | ret = vl53l0x_read_proximity(data, chan, val); | |
| 225 | + | iio_device_release_direct(indio_dev); | |
| 223 | 226 | if (ret < 0) | |
| 224 | 227 | return ret; | |
| 225 | 228 | ||
modified drivers/input/joystick/xpad.c
| @@ -302,6 +302,8 @@ static const struct xpad_device { | |||
| 302 | 302 | { 0x17ef, 0x6182, "Lenovo Legion Controller for Windows", 0, XTYPE_XBOX360 }, | |
| 303 | 303 | { 0x1949, 0x041a, "Amazon Game Controller", 0, XTYPE_XBOX360 }, | |
| 304 | 304 | { 0x1a86, 0xe310, "Legion Go S", 0, XTYPE_XBOX360 }, | |
| 305 | + | { 0x1b1c, 0x2b1f, "Corsair Novablade Pro (Wired)", 0, XTYPE_XBOX360 }, | |
| 306 | + | { 0x1b1c, 0x2b2b, "Corsair Novablade Pro (2.4 GHz Receiver)", 0, XTYPE_XBOX360 }, | |
| 305 | 307 | { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 }, | |
| 306 | 308 | { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, | |
| 307 | 309 | { 0x1bad, 0x0130, "Ion Drum Rocker", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, | |
| @@ -379,6 +381,7 @@ static const struct xpad_device { | |||
| 379 | 381 | { 0x2993, 0x2001, "TECNO Pocket Go", 0, XTYPE_XBOX360 }, | |
| 380 | 382 | { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE }, | |
| 381 | 383 | { 0x2dc8, 0x200f, "8BitDo Ultimate 3-mode Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, | |
| 384 | + | { 0x2dc8, 0x201e, "8BitDo Pro 2 Wired Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, | |
| 382 | 385 | { 0x2dc8, 0x3106, "8BitDo Ultimate Wireless / Pro 2 Wired Controller", 0, XTYPE_XBOX360 }, | |
| 383 | 386 | { 0x2dc8, 0x3109, "8BitDo Ultimate Wireless Bluetooth", 0, XTYPE_XBOX360 }, | |
| 384 | 387 | { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 }, | |
| @@ -545,6 +548,7 @@ static const struct usb_device_id xpad_table[] = { | |||
| 545 | 548 | XPAD_XBOX360_VENDOR(0x17ef), /* Lenovo */ | |
| 546 | 549 | XPAD_XBOX360_VENDOR(0x1949), /* Amazon controllers */ | |
| 547 | 550 | XPAD_XBOX360_VENDOR(0x1a86), /* Nanjing Qinheng Microelectronics (WCH) */ | |
| 551 | + | XPAD_XBOX360_VENDOR(0x1b1c), /* Corsair controllers */ | |
| 548 | 552 | XPAD_XBOX360_VENDOR(0x1bad), /* Harmonix Rock Band guitar and drums */ | |
| 549 | 553 | XPAD_XBOX360_VENDOR(0x1ee9), /* ZOTAC Technology Limited */ | |
| 550 | 554 | XPAD_XBOX360_VENDOR(0x20bc), /* BETOP wireless dongles */ | |
modified drivers/input/keyboard/atkbd.c
| @@ -1938,6 +1938,14 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = { | |||
| 1938 | 1938 | }, | |
| 1939 | 1939 | .callback = atkbd_deactivate_fixup, | |
| 1940 | 1940 | }, | |
| 1941 | + | { | |
| 1942 | + | /* Lenovo IdeaPad Slim 3 15IWC11 (83RR) */ | |
| 1943 | + | .matches = { | |
| 1944 | + | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | |
| 1945 | + | DMI_MATCH(DMI_PRODUCT_NAME, "83RR"), | |
| 1946 | + | }, | |
| 1947 | + | .callback = atkbd_deactivate_fixup, | |
| 1948 | + | }, | |
| 1941 | 1949 | { | |
| 1942 | 1950 | /* Xiaomi Book Pro 14 (TM2424) */ | |
| 1943 | 1951 | .matches = { | |
modified drivers/input/misc/ati_remote2.c
| @@ -672,8 +672,7 @@ static ssize_t ati_remote2_show_channel_mask(struct device *dev, | |||
| 672 | 672 | struct device_attribute *attr, | |
| 673 | 673 | char *buf) | |
| 674 | 674 | { | |
| 675 | - | struct usb_device *udev = to_usb_device(dev); | |
| 676 | - | struct usb_interface *intf = usb_ifnum_to_if(udev, 0); | |
| 675 | + | struct usb_interface *intf = to_usb_interface(dev); | |
| 677 | 676 | struct ati_remote2 *ar2 = usb_get_intfdata(intf); | |
| 678 | 677 | ||
| 679 | 678 | return sprintf(buf, "0x%04x\n", ar2->channel_mask); | |
| @@ -683,8 +682,7 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev, | |||
| 683 | 682 | struct device_attribute *attr, | |
| 684 | 683 | const char *buf, size_t count) | |
| 685 | 684 | { | |
| 686 | - | struct usb_device *udev = to_usb_device(dev); | |
| 687 | - | struct usb_interface *intf = usb_ifnum_to_if(udev, 0); | |
| 685 | + | struct usb_interface *intf = to_usb_interface(dev); | |
| 688 | 686 | struct ati_remote2 *ar2 = usb_get_intfdata(intf); | |
| 689 | 687 | unsigned int mask; | |
| 690 | 688 | int r; | |
| @@ -720,8 +718,7 @@ static ssize_t ati_remote2_show_mode_mask(struct device *dev, | |||
| 720 | 718 | struct device_attribute *attr, | |
| 721 | 719 | char *buf) | |
| 722 | 720 | { | |
| 723 | - | struct usb_device *udev = to_usb_device(dev); | |
| 724 | - | struct usb_interface *intf = usb_ifnum_to_if(udev, 0); | |
| 721 | + | struct usb_interface *intf = to_usb_interface(dev); | |
| 725 | 722 | struct ati_remote2 *ar2 = usb_get_intfdata(intf); | |
| 726 | 723 | ||
| 727 | 724 | return sprintf(buf, "0x%02x\n", ar2->mode_mask); | |
| @@ -731,8 +728,7 @@ static ssize_t ati_remote2_store_mode_mask(struct device *dev, | |||
| 731 | 728 | struct device_attribute *attr, | |
| 732 | 729 | const char *buf, size_t count) | |
| 733 | 730 | { | |
| 734 | - | struct usb_device *udev = to_usb_device(dev); | |
| 735 | - | struct usb_interface *intf = usb_ifnum_to_if(udev, 0); | |
| 731 | + | struct usb_interface *intf = to_usb_interface(dev); | |
| 736 | 732 | struct ati_remote2 *ar2 = usb_get_intfdata(intf); | |
| 737 | 733 | unsigned int mask; | |
| 738 | 734 | int err; | |
modified drivers/input/mouse/synaptics.c
| @@ -192,6 +192,7 @@ static const char * const smbus_pnp_ids[] = { | |||
| 192 | 192 | "LEN2054", /* E480 */ | |
| 193 | 193 | "LEN2055", /* E580 */ | |
| 194 | 194 | "LEN2058", /* E490 */ | |
| 195 | + | "LEN205b", /* T490 */ | |
| 195 | 196 | "LEN2068", /* T14 Gen 1 */ | |
| 196 | 197 | "SYN1221", /* TUXEDO InfinityBook Pro 14 v5 */ | |
| 197 | 198 | "SYN3003", /* HP EliteBook 850 G1 */ | |
| @@ -1839,8 +1840,10 @@ static int synaptics_setup_intertouch(struct psmouse *psmouse, | |||
| 1839 | 1840 | return -ENXIO; | |
| 1840 | 1841 | } | |
| 1841 | 1842 | ||
| 1842 | - | /* Disable intertouch on known-broken board revisions */ | |
| 1843 | - | if (info->board_id == 2722) { | |
| 1843 | + | /* Disable intertouch on known-broken T440p board revisions */ | |
| 1844 | + | if (info->board_id == 2722 && | |
| 1845 | + | psmouse_matches_pnp_id(psmouse, | |
| 1846 | + | (const char * const []){"LEN0036", NULL})) { | |
| 1844 | 1847 | psmouse_info(psmouse, | |
| 1845 | 1848 | "Disabling intertouch for board id %u\n", | |
| 1846 | 1849 | info->board_id); | |
modified drivers/input/serio/i8042-acpipnpio.h
| @@ -671,6 +671,15 @@ static const struct dmi_system_id i8042_dmi_quirk_table[] __initconst = { | |||
| 671 | 671 | }, | |
| 672 | 672 | .driver_data = (void *)(SERIO_QUIRK_NOAUX) | |
| 673 | 673 | }, | |
| 674 | + | { | |
| 675 | + | /* Fujitsu LIFEBOOK U7410 */ | |
| 676 | + | /* Mux mode also disturbs the EC keyboard, causing spurious ACKs */ | |
| 677 | + | .matches = { | |
| 678 | + | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU CLIENT COMPUTING LIMITED"), | |
| 679 | + | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U7410"), | |
| 680 | + | }, | |
| 681 | + | .driver_data = (void *)(SERIO_QUIRK_NOMUX) | |
| 682 | + | }, | |
| 674 | 683 | { | |
| 675 | 684 | /* Gigabyte M912 */ | |
| 676 | 685 | .matches = { | |
modified drivers/input/touchscreen/s6sy761.c
| @@ -500,10 +500,22 @@ static int s6sy761_suspend(struct device *dev) | |||
| 500 | 500 | static int s6sy761_resume(struct device *dev) | |
| 501 | 501 | { | |
| 502 | 502 | struct s6sy761_data *sdata = dev_get_drvdata(dev); | |
| 503 | + | int err; | |
| 504 | + | ||
| 505 | + | err = s6sy761_power_on(sdata); | |
| 506 | + | if (err) | |
| 507 | + | return err; | |
| 503 | 508 | ||
| 504 | 509 | enable_irq(sdata->client->irq); | |
| 505 | 510 | ||
| 506 | - | return s6sy761_power_on(sdata); | |
| 511 | + | guard(mutex)(&sdata->input->mutex); | |
| 512 | + | ||
| 513 | + | if (!input_device_enabled(sdata->input)) | |
| 514 | + | return 0; | |
| 515 | + | ||
| 516 | + | err = i2c_smbus_write_byte(sdata->client, S6SY761_SENSE_ON); | |
| 517 | + | ||
| 518 | + | return err; | |
| 507 | 519 | } | |
| 508 | 520 | ||
| 509 | 521 | static const struct dev_pm_ops s6sy761_pm_ops = { | |
modified drivers/interconnect/qcom/x1e80100.c
| @@ -173,13 +173,6 @@ static struct qcom_icc_node qhm_qspi = { | |||
| 173 | 173 | .name = "qhm_qspi", | |
| 174 | 174 | .channels = 1, | |
| 175 | 175 | .buswidth = 4, | |
| 176 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 177 | - | .num_ports = 1, | |
| 178 | - | .port_offsets = { 0xb000 }, | |
| 179 | - | .prio = 2, | |
| 180 | - | .urg_fwd = 0, | |
| 181 | - | .prio_fwd_disable = 1, | |
| 182 | - | }, | |
| 183 | 176 | .num_links = 1, | |
| 184 | 177 | .link_nodes = { &qns_a1noc_snoc }, | |
| 185 | 178 | }; | |
| @@ -188,13 +181,6 @@ static struct qcom_icc_node qhm_qup1 = { | |||
| 188 | 181 | .name = "qhm_qup1", | |
| 189 | 182 | .channels = 1, | |
| 190 | 183 | .buswidth = 4, | |
| 191 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 192 | - | .num_ports = 1, | |
| 193 | - | .port_offsets = { 0xc000 }, | |
| 194 | - | .prio = 2, | |
| 195 | - | .urg_fwd = 0, | |
| 196 | - | .prio_fwd_disable = 1, | |
| 197 | - | }, | |
| 198 | 184 | .num_links = 1, | |
| 199 | 185 | .link_nodes = { &qns_a1noc_snoc }, | |
| 200 | 186 | }; | |
| @@ -203,13 +189,6 @@ static struct qcom_icc_node xm_sdc4 = { | |||
| 203 | 189 | .name = "xm_sdc4", | |
| 204 | 190 | .channels = 1, | |
| 205 | 191 | .buswidth = 8, | |
| 206 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 207 | - | .num_ports = 1, | |
| 208 | - | .port_offsets = { 0xd000 }, | |
| 209 | - | .prio = 2, | |
| 210 | - | .urg_fwd = 0, | |
| 211 | - | .prio_fwd_disable = 1, | |
| 212 | - | }, | |
| 213 | 192 | .num_links = 1, | |
| 214 | 193 | .link_nodes = { &qns_a1noc_snoc }, | |
| 215 | 194 | }; | |
| @@ -218,13 +197,6 @@ static struct qcom_icc_node xm_ufs_mem = { | |||
| 218 | 197 | .name = "xm_ufs_mem", | |
| 219 | 198 | .channels = 1, | |
| 220 | 199 | .buswidth = 16, | |
| 221 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 222 | - | .num_ports = 1, | |
| 223 | - | .port_offsets = { 0xe000 }, | |
| 224 | - | .prio = 2, | |
| 225 | - | .urg_fwd = 0, | |
| 226 | - | .prio_fwd_disable = 1, | |
| 227 | - | }, | |
| 228 | 200 | .num_links = 1, | |
| 229 | 201 | .link_nodes = { &qns_a1noc_snoc }, | |
| 230 | 202 | }; | |
| @@ -233,13 +205,6 @@ static struct qcom_icc_node qhm_qup0 = { | |||
| 233 | 205 | .name = "qhm_qup0", | |
| 234 | 206 | .channels = 1, | |
| 235 | 207 | .buswidth = 4, | |
| 236 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 237 | - | .num_ports = 1, | |
| 238 | - | .port_offsets = { 0x16000 }, | |
| 239 | - | .prio = 2, | |
| 240 | - | .urg_fwd = 0, | |
| 241 | - | .prio_fwd_disable = 1, | |
| 242 | - | }, | |
| 243 | 208 | .num_links = 1, | |
| 244 | 209 | .link_nodes = { &qns_a2noc_snoc }, | |
| 245 | 210 | }; | |
| @@ -248,13 +213,6 @@ static struct qcom_icc_node qhm_qup2 = { | |||
| 248 | 213 | .name = "qhm_qup2", | |
| 249 | 214 | .channels = 1, | |
| 250 | 215 | .buswidth = 4, | |
| 251 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 252 | - | .num_ports = 1, | |
| 253 | - | .port_offsets = { 0x11000 }, | |
| 254 | - | .prio = 2, | |
| 255 | - | .urg_fwd = 0, | |
| 256 | - | .prio_fwd_disable = 1, | |
| 257 | - | }, | |
| 258 | 216 | .num_links = 1, | |
| 259 | 217 | .link_nodes = { &qns_a2noc_snoc }, | |
| 260 | 218 | }; | |
| @@ -263,13 +221,6 @@ static struct qcom_icc_node qxm_crypto = { | |||
| 263 | 221 | .name = "qxm_crypto", | |
| 264 | 222 | .channels = 1, | |
| 265 | 223 | .buswidth = 8, | |
| 266 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 267 | - | .num_ports = 1, | |
| 268 | - | .port_offsets = { 0x12000 }, | |
| 269 | - | .prio = 2, | |
| 270 | - | .urg_fwd = 0, | |
| 271 | - | .prio_fwd_disable = 1, | |
| 272 | - | }, | |
| 273 | 224 | .num_links = 1, | |
| 274 | 225 | .link_nodes = { &qns_a2noc_snoc }, | |
| 275 | 226 | }; | |
| @@ -286,13 +237,6 @@ static struct qcom_icc_node xm_qdss_etr_0 = { | |||
| 286 | 237 | .name = "xm_qdss_etr_0", | |
| 287 | 238 | .channels = 1, | |
| 288 | 239 | .buswidth = 8, | |
| 289 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 290 | - | .num_ports = 1, | |
| 291 | - | .port_offsets = { 0x13000 }, | |
| 292 | - | .prio = 2, | |
| 293 | - | .urg_fwd = 0, | |
| 294 | - | .prio_fwd_disable = 1, | |
| 295 | - | }, | |
| 296 | 240 | .num_links = 1, | |
| 297 | 241 | .link_nodes = { &qns_a2noc_snoc }, | |
| 298 | 242 | }; | |
| @@ -301,13 +245,6 @@ static struct qcom_icc_node xm_qdss_etr_1 = { | |||
| 301 | 245 | .name = "xm_qdss_etr_1", | |
| 302 | 246 | .channels = 1, | |
| 303 | 247 | .buswidth = 8, | |
| 304 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 305 | - | .num_ports = 1, | |
| 306 | - | .port_offsets = { 0x14000 }, | |
| 307 | - | .prio = 2, | |
| 308 | - | .urg_fwd = 0, | |
| 309 | - | .prio_fwd_disable = 1, | |
| 310 | - | }, | |
| 311 | 248 | .num_links = 1, | |
| 312 | 249 | .link_nodes = { &qns_a2noc_snoc }, | |
| 313 | 250 | }; | |
| @@ -316,13 +253,6 @@ static struct qcom_icc_node xm_sdc2 = { | |||
| 316 | 253 | .name = "xm_sdc2", | |
| 317 | 254 | .channels = 1, | |
| 318 | 255 | .buswidth = 8, | |
| 319 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 320 | - | .num_ports = 1, | |
| 321 | - | .port_offsets = { 0x15000 }, | |
| 322 | - | .prio = 2, | |
| 323 | - | .urg_fwd = 0, | |
| 324 | - | .prio_fwd_disable = 1, | |
| 325 | - | }, | |
| 326 | 256 | .num_links = 1, | |
| 327 | 257 | .link_nodes = { &qns_a2noc_snoc }, | |
| 328 | 258 | }; | |
| @@ -407,13 +337,6 @@ static struct qcom_icc_node alm_gpu_tcu = { | |||
| 407 | 337 | .name = "alm_gpu_tcu", | |
| 408 | 338 | .channels = 1, | |
| 409 | 339 | .buswidth = 8, | |
| 410 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 411 | - | .num_ports = 1, | |
| 412 | - | .port_offsets = { 0x271000 }, | |
| 413 | - | .prio = 1, | |
| 414 | - | .urg_fwd = 0, | |
| 415 | - | .prio_fwd_disable = 1, | |
| 416 | - | }, | |
| 417 | 340 | .num_links = 2, | |
| 418 | 341 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 419 | 342 | }; | |
| @@ -422,13 +345,6 @@ static struct qcom_icc_node alm_pcie_tcu = { | |||
| 422 | 345 | .name = "alm_pcie_tcu", | |
| 423 | 346 | .channels = 1, | |
| 424 | 347 | .buswidth = 8, | |
| 425 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 426 | - | .num_ports = 1, | |
| 427 | - | .port_offsets = { 0x27d000 }, | |
| 428 | - | .prio = 3, | |
| 429 | - | .urg_fwd = 0, | |
| 430 | - | .prio_fwd_disable = 1, | |
| 431 | - | }, | |
| 432 | 348 | .num_links = 2, | |
| 433 | 349 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 434 | 350 | }; | |
| @@ -437,13 +353,6 @@ static struct qcom_icc_node alm_sys_tcu = { | |||
| 437 | 353 | .name = "alm_sys_tcu", | |
| 438 | 354 | .channels = 1, | |
| 439 | 355 | .buswidth = 8, | |
| 440 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 441 | - | .num_ports = 1, | |
| 442 | - | .port_offsets = { 0x273000 }, | |
| 443 | - | .prio = 6, | |
| 444 | - | .urg_fwd = 0, | |
| 445 | - | .prio_fwd_disable = 1, | |
| 446 | - | }, | |
| 447 | 356 | .num_links = 2, | |
| 448 | 357 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 449 | 358 | }; | |
| @@ -461,13 +370,6 @@ static struct qcom_icc_node qnm_gpu = { | |||
| 461 | 370 | .name = "qnm_gpu", | |
| 462 | 371 | .channels = 4, | |
| 463 | 372 | .buswidth = 32, | |
| 464 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 465 | - | .num_ports = 4, | |
| 466 | - | .port_offsets = { 0x51000, 0x58000, 0xd1000, 0xd8000 }, | |
| 467 | - | .prio = 0, | |
| 468 | - | .urg_fwd = 0, | |
| 469 | - | .prio_fwd_disable = 1, | |
| 470 | - | }, | |
| 471 | 373 | .num_links = 2, | |
| 472 | 374 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 473 | 375 | }; | |
| @@ -476,13 +378,6 @@ static struct qcom_icc_node qnm_lpass = { | |||
| 476 | 378 | .name = "qnm_lpass", | |
| 477 | 379 | .channels = 1, | |
| 478 | 380 | .buswidth = 16, | |
| 479 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 480 | - | .num_ports = 1, | |
| 481 | - | .port_offsets = { 0x275000 }, | |
| 482 | - | .prio = 0, | |
| 483 | - | .urg_fwd = 1, | |
| 484 | - | .prio_fwd_disable = 0, | |
| 485 | - | }, | |
| 486 | 381 | .num_links = 3, | |
| 487 | 382 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc, | |
| 488 | 383 | &qns_pcie }, | |
| @@ -492,13 +387,6 @@ static struct qcom_icc_node qnm_mnoc_hf = { | |||
| 492 | 387 | .name = "qnm_mnoc_hf", | |
| 493 | 388 | .channels = 2, | |
| 494 | 389 | .buswidth = 32, | |
| 495 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 496 | - | .num_ports = 2, | |
| 497 | - | .port_offsets = { 0x53000, 0xd3000 }, | |
| 498 | - | .prio = 0, | |
| 499 | - | .urg_fwd = 1, | |
| 500 | - | .prio_fwd_disable = 0, | |
| 501 | - | }, | |
| 502 | 390 | .num_links = 2, | |
| 503 | 391 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 504 | 392 | }; | |
| @@ -507,13 +395,6 @@ static struct qcom_icc_node qnm_mnoc_sf = { | |||
| 507 | 395 | .name = "qnm_mnoc_sf", | |
| 508 | 396 | .channels = 2, | |
| 509 | 397 | .buswidth = 32, | |
| 510 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 511 | - | .num_ports = 2, | |
| 512 | - | .port_offsets = { 0x55000, 0xd5000 }, | |
| 513 | - | .prio = 0, | |
| 514 | - | .urg_fwd = 1, | |
| 515 | - | .prio_fwd_disable = 0, | |
| 516 | - | }, | |
| 517 | 398 | .num_links = 2, | |
| 518 | 399 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 519 | 400 | }; | |
| @@ -522,13 +403,6 @@ static struct qcom_icc_node qnm_nsp_noc = { | |||
| 522 | 403 | .name = "qnm_nsp_noc", | |
| 523 | 404 | .channels = 2, | |
| 524 | 405 | .buswidth = 32, | |
| 525 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 526 | - | .num_ports = 2, | |
| 527 | - | .port_offsets = { 0x57000, 0xd7000 }, | |
| 528 | - | .prio = 0, | |
| 529 | - | .urg_fwd = 0, | |
| 530 | - | .prio_fwd_disable = 1, | |
| 531 | - | }, | |
| 532 | 406 | .num_links = 3, | |
| 533 | 407 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc, | |
| 534 | 408 | &qns_pcie }, | |
| @@ -538,13 +412,6 @@ static struct qcom_icc_node qnm_pcie = { | |||
| 538 | 412 | .name = "qnm_pcie", | |
| 539 | 413 | .channels = 1, | |
| 540 | 414 | .buswidth = 64, | |
| 541 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 542 | - | .num_ports = 1, | |
| 543 | - | .port_offsets = { 0x277000 }, | |
| 544 | - | .prio = 0, | |
| 545 | - | .urg_fwd = 1, | |
| 546 | - | .prio_fwd_disable = 0, | |
| 547 | - | }, | |
| 548 | 415 | .num_links = 2, | |
| 549 | 416 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 550 | 417 | }; | |
| @@ -553,13 +420,6 @@ static struct qcom_icc_node qnm_snoc_sf = { | |||
| 553 | 420 | .name = "qnm_snoc_sf", | |
| 554 | 421 | .channels = 1, | |
| 555 | 422 | .buswidth = 64, | |
| 556 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 557 | - | .num_ports = 1, | |
| 558 | - | .port_offsets = { 0x27b000 }, | |
| 559 | - | .prio = 2, | |
| 560 | - | .urg_fwd = 1, | |
| 561 | - | .prio_fwd_disable = 0, | |
| 562 | - | }, | |
| 563 | 423 | .num_links = 3, | |
| 564 | 424 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc, | |
| 565 | 425 | &qns_pcie }, | |
| @@ -569,13 +429,6 @@ static struct qcom_icc_node xm_gic = { | |||
| 569 | 429 | .name = "xm_gic", | |
| 570 | 430 | .channels = 1, | |
| 571 | 431 | .buswidth = 8, | |
| 572 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 573 | - | .num_ports = 1, | |
| 574 | - | .port_offsets = { 0x27f000 }, | |
| 575 | - | .prio = 2, | |
| 576 | - | .urg_fwd = 0, | |
| 577 | - | .prio_fwd_disable = 1, | |
| 578 | - | }, | |
| 579 | 432 | .num_links = 1, | |
| 580 | 433 | .link_nodes = { &qns_llcc }, | |
| 581 | 434 | }; | |
| @@ -616,13 +469,6 @@ static struct qcom_icc_node qnm_av1_enc = { | |||
| 616 | 469 | .name = "qnm_av1_enc", | |
| 617 | 470 | .channels = 1, | |
| 618 | 471 | .buswidth = 32, | |
| 619 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 620 | - | .num_ports = 1, | |
| 621 | - | .port_offsets = { 0x2f000 }, | |
| 622 | - | .prio = 4, | |
| 623 | - | .urg_fwd = 0, | |
| 624 | - | .prio_fwd_disable = 1, | |
| 625 | - | }, | |
| 626 | 472 | .num_links = 1, | |
| 627 | 473 | .link_nodes = { &qns_mem_noc_sf }, | |
| 628 | 474 | }; | |
| @@ -631,13 +477,6 @@ static struct qcom_icc_node qnm_camnoc_hf = { | |||
| 631 | 477 | .name = "qnm_camnoc_hf", | |
| 632 | 478 | .channels = 2, | |
| 633 | 479 | .buswidth = 32, | |
| 634 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 635 | - | .num_ports = 2, | |
| 636 | - | .port_offsets = { 0x28000, 0x29000 }, | |
| 637 | - | .prio = 0, | |
| 638 | - | .urg_fwd = 1, | |
| 639 | - | .prio_fwd_disable = 0, | |
| 640 | - | }, | |
| 641 | 480 | .num_links = 1, | |
| 642 | 481 | .link_nodes = { &qns_mem_noc_hf }, | |
| 643 | 482 | }; | |
| @@ -646,13 +485,6 @@ static struct qcom_icc_node qnm_camnoc_icp = { | |||
| 646 | 485 | .name = "qnm_camnoc_icp", | |
| 647 | 486 | .channels = 1, | |
| 648 | 487 | .buswidth = 8, | |
| 649 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 650 | - | .num_ports = 1, | |
| 651 | - | .port_offsets = { 0x2a000 }, | |
| 652 | - | .prio = 4, | |
| 653 | - | .urg_fwd = 0, | |
| 654 | - | .prio_fwd_disable = 1, | |
| 655 | - | }, | |
| 656 | 488 | .num_links = 1, | |
| 657 | 489 | .link_nodes = { &qns_mem_noc_sf }, | |
| 658 | 490 | }; | |
| @@ -661,13 +493,6 @@ static struct qcom_icc_node qnm_camnoc_sf = { | |||
| 661 | 493 | .name = "qnm_camnoc_sf", | |
| 662 | 494 | .channels = 2, | |
| 663 | 495 | .buswidth = 32, | |
| 664 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 665 | - | .num_ports = 2, | |
| 666 | - | .port_offsets = { 0x2b000, 0x2c000 }, | |
| 667 | - | .prio = 0, | |
| 668 | - | .urg_fwd = 1, | |
| 669 | - | .prio_fwd_disable = 0, | |
| 670 | - | }, | |
| 671 | 496 | .num_links = 1, | |
| 672 | 497 | .link_nodes = { &qns_mem_noc_sf }, | |
| 673 | 498 | }; | |
| @@ -676,13 +501,6 @@ static struct qcom_icc_node qnm_eva = { | |||
| 676 | 501 | .name = "qnm_eva", | |
| 677 | 502 | .channels = 1, | |
| 678 | 503 | .buswidth = 32, | |
| 679 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 680 | - | .num_ports = 1, | |
| 681 | - | .port_offsets = { 0x33000 }, | |
| 682 | - | .prio = 0, | |
| 683 | - | .urg_fwd = 1, | |
| 684 | - | .prio_fwd_disable = 0, | |
| 685 | - | }, | |
| 686 | 504 | .num_links = 1, | |
| 687 | 505 | .link_nodes = { &qns_mem_noc_sf }, | |
| 688 | 506 | }; | |
| @@ -691,13 +509,6 @@ static struct qcom_icc_node qnm_mdp = { | |||
| 691 | 509 | .name = "qnm_mdp", | |
| 692 | 510 | .channels = 2, | |
| 693 | 511 | .buswidth = 32, | |
| 694 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 695 | - | .num_ports = 2, | |
| 696 | - | .port_offsets = { 0x2d000, 0x2e000 }, | |
| 697 | - | .prio = 0, | |
| 698 | - | .urg_fwd = 1, | |
| 699 | - | .prio_fwd_disable = 0, | |
| 700 | - | }, | |
| 701 | 512 | .num_links = 1, | |
| 702 | 513 | .link_nodes = { &qns_mem_noc_hf }, | |
| 703 | 514 | }; | |
| @@ -706,13 +517,6 @@ static struct qcom_icc_node qnm_video = { | |||
| 706 | 517 | .name = "qnm_video", | |
| 707 | 518 | .channels = 2, | |
| 708 | 519 | .buswidth = 32, | |
| 709 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 710 | - | .num_ports = 2, | |
| 711 | - | .port_offsets = { 0x30000, 0x31000 }, | |
| 712 | - | .prio = 0, | |
| 713 | - | .urg_fwd = 1, | |
| 714 | - | .prio_fwd_disable = 0, | |
| 715 | - | }, | |
| 716 | 520 | .num_links = 1, | |
| 717 | 521 | .link_nodes = { &qns_mem_noc_sf }, | |
| 718 | 522 | }; | |
| @@ -721,13 +525,6 @@ static struct qcom_icc_node qnm_video_cv_cpu = { | |||
| 721 | 525 | .name = "qnm_video_cv_cpu", | |
| 722 | 526 | .channels = 1, | |
| 723 | 527 | .buswidth = 8, | |
| 724 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 725 | - | .num_ports = 1, | |
| 726 | - | .port_offsets = { 0x32000 }, | |
| 727 | - | .prio = 4, | |
| 728 | - | .urg_fwd = 0, | |
| 729 | - | .prio_fwd_disable = 1, | |
| 730 | - | }, | |
| 731 | 528 | .num_links = 1, | |
| 732 | 529 | .link_nodes = { &qns_mem_noc_sf }, | |
| 733 | 530 | }; | |
| @@ -736,13 +533,6 @@ static struct qcom_icc_node qnm_video_v_cpu = { | |||
| 736 | 533 | .name = "qnm_video_v_cpu", | |
| 737 | 534 | .channels = 1, | |
| 738 | 535 | .buswidth = 8, | |
| 739 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 740 | - | .num_ports = 1, | |
| 741 | - | .port_offsets = { 0x34000 }, | |
| 742 | - | .prio = 4, | |
| 743 | - | .urg_fwd = 0, | |
| 744 | - | .prio_fwd_disable = 1, | |
| 745 | - | }, | |
| 746 | 536 | .num_links = 1, | |
| 747 | 537 | .link_nodes = { &qns_mem_noc_sf }, | |
| 748 | 538 | }; | |
| @@ -783,13 +573,6 @@ static struct qcom_icc_node xm_pcie_3 = { | |||
| 783 | 573 | .name = "xm_pcie_3", | |
| 784 | 574 | .channels = 1, | |
| 785 | 575 | .buswidth = 64, | |
| 786 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 787 | - | .num_ports = 1, | |
| 788 | - | .port_offsets = { 0x7000 }, | |
| 789 | - | .prio = 2, | |
| 790 | - | .urg_fwd = 0, | |
| 791 | - | .prio_fwd_disable = 1, | |
| 792 | - | }, | |
| 793 | 576 | .num_links = 1, | |
| 794 | 577 | .link_nodes = { &qns_pcie_north_gem_noc }, | |
| 795 | 578 | }; | |
| @@ -798,13 +581,6 @@ static struct qcom_icc_node xm_pcie_4 = { | |||
| 798 | 581 | .name = "xm_pcie_4", | |
| 799 | 582 | .channels = 1, | |
| 800 | 583 | .buswidth = 8, | |
| 801 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 802 | - | .num_ports = 1, | |
| 803 | - | .port_offsets = { 0x8000 }, | |
| 804 | - | .prio = 2, | |
| 805 | - | .urg_fwd = 0, | |
| 806 | - | .prio_fwd_disable = 1, | |
| 807 | - | }, | |
| 808 | 584 | .num_links = 1, | |
| 809 | 585 | .link_nodes = { &qns_pcie_north_gem_noc }, | |
| 810 | 586 | }; | |
| @@ -813,13 +589,6 @@ static struct qcom_icc_node xm_pcie_5 = { | |||
| 813 | 589 | .name = "xm_pcie_5", | |
| 814 | 590 | .channels = 1, | |
| 815 | 591 | .buswidth = 8, | |
| 816 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 817 | - | .num_ports = 1, | |
| 818 | - | .port_offsets = { 0x9000 }, | |
| 819 | - | .prio = 3, | |
| 820 | - | .urg_fwd = 0, | |
| 821 | - | .prio_fwd_disable = 1, | |
| 822 | - | }, | |
| 823 | 592 | .num_links = 1, | |
| 824 | 593 | .link_nodes = { &qns_pcie_north_gem_noc }, | |
| 825 | 594 | }; | |
| @@ -828,13 +597,6 @@ static struct qcom_icc_node xm_pcie_0 = { | |||
| 828 | 597 | .name = "xm_pcie_0", | |
| 829 | 598 | .channels = 1, | |
| 830 | 599 | .buswidth = 16, | |
| 831 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 832 | - | .num_ports = 1, | |
| 833 | - | .port_offsets = { 0x9000 }, | |
| 834 | - | .prio = 2, | |
| 835 | - | .urg_fwd = 0, | |
| 836 | - | .prio_fwd_disable = 1, | |
| 837 | - | }, | |
| 838 | 600 | .num_links = 1, | |
| 839 | 601 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 840 | 602 | }; | |
| @@ -843,13 +605,6 @@ static struct qcom_icc_node xm_pcie_1 = { | |||
| 843 | 605 | .name = "xm_pcie_1", | |
| 844 | 606 | .channels = 1, | |
| 845 | 607 | .buswidth = 16, | |
| 846 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 847 | - | .num_ports = 1, | |
| 848 | - | .port_offsets = { 0xa000 }, | |
| 849 | - | .prio = 2, | |
| 850 | - | .urg_fwd = 0, | |
| 851 | - | .prio_fwd_disable = 1, | |
| 852 | - | }, | |
| 853 | 608 | .num_links = 1, | |
| 854 | 609 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 855 | 610 | }; | |
| @@ -858,13 +613,6 @@ static struct qcom_icc_node xm_pcie_2 = { | |||
| 858 | 613 | .name = "xm_pcie_2", | |
| 859 | 614 | .channels = 1, | |
| 860 | 615 | .buswidth = 16, | |
| 861 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 862 | - | .num_ports = 1, | |
| 863 | - | .port_offsets = { 0xb000 }, | |
| 864 | - | .prio = 2, | |
| 865 | - | .urg_fwd = 0, | |
| 866 | - | .prio_fwd_disable = 1, | |
| 867 | - | }, | |
| 868 | 616 | .num_links = 1, | |
| 869 | 617 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 870 | 618 | }; | |
| @@ -873,13 +621,6 @@ static struct qcom_icc_node xm_pcie_6a = { | |||
| 873 | 621 | .name = "xm_pcie_6a", | |
| 874 | 622 | .channels = 1, | |
| 875 | 623 | .buswidth = 32, | |
| 876 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 877 | - | .num_ports = 1, | |
| 878 | - | .port_offsets = { 0xc000 }, | |
| 879 | - | .prio = 2, | |
| 880 | - | .urg_fwd = 0, | |
| 881 | - | .prio_fwd_disable = 1, | |
| 882 | - | }, | |
| 883 | 624 | .num_links = 1, | |
| 884 | 625 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 885 | 626 | }; | |
| @@ -888,13 +629,6 @@ static struct qcom_icc_node xm_pcie_6b = { | |||
| 888 | 629 | .name = "xm_pcie_6b", | |
| 889 | 630 | .channels = 1, | |
| 890 | 631 | .buswidth = 16, | |
| 891 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 892 | - | .num_ports = 1, | |
| 893 | - | .port_offsets = { 0xd000 }, | |
| 894 | - | .prio = 2, | |
| 895 | - | .urg_fwd = 0, | |
| 896 | - | .prio_fwd_disable = 1, | |
| 897 | - | }, | |
| 898 | 632 | .num_links = 1, | |
| 899 | 633 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 900 | 634 | }; | |
| @@ -919,13 +653,6 @@ static struct qcom_icc_node qnm_gic = { | |||
| 919 | 653 | .name = "qnm_gic", | |
| 920 | 654 | .channels = 1, | |
| 921 | 655 | .buswidth = 8, | |
| 922 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 923 | - | .num_ports = 1, | |
| 924 | - | .port_offsets = { 0x1c000 }, | |
| 925 | - | .prio = 2, | |
| 926 | - | .urg_fwd = 0, | |
| 927 | - | .prio_fwd_disable = 1, | |
| 928 | - | }, | |
| 929 | 656 | .num_links = 1, | |
| 930 | 657 | .link_nodes = { &qns_gemnoc_sf }, | |
| 931 | 658 | }; | |
| @@ -958,13 +685,6 @@ static struct qcom_icc_node xm_usb2_0 = { | |||
| 958 | 685 | .name = "xm_usb2_0", | |
| 959 | 686 | .channels = 1, | |
| 960 | 687 | .buswidth = 8, | |
| 961 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 962 | - | .num_ports = 1, | |
| 963 | - | .port_offsets = { 0x6000 }, | |
| 964 | - | .prio = 2, | |
| 965 | - | .urg_fwd = 0, | |
| 966 | - | .prio_fwd_disable = 1, | |
| 967 | - | }, | |
| 968 | 688 | .num_links = 1, | |
| 969 | 689 | .link_nodes = { &qns_aggre_usb_north_snoc }, | |
| 970 | 690 | }; | |
| @@ -973,13 +693,6 @@ static struct qcom_icc_node xm_usb3_mp = { | |||
| 973 | 693 | .name = "xm_usb3_mp", | |
| 974 | 694 | .channels = 1, | |
| 975 | 695 | .buswidth = 16, | |
| 976 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 977 | - | .num_ports = 1, | |
| 978 | - | .port_offsets = { 0x7000 }, | |
| 979 | - | .prio = 2, | |
| 980 | - | .urg_fwd = 0, | |
| 981 | - | .prio_fwd_disable = 1, | |
| 982 | - | }, | |
| 983 | 696 | .num_links = 1, | |
| 984 | 697 | .link_nodes = { &qns_aggre_usb_north_snoc }, | |
| 985 | 698 | }; | |
| @@ -988,13 +701,6 @@ static struct qcom_icc_node xm_usb3_0 = { | |||
| 988 | 701 | .name = "xm_usb3_0", | |
| 989 | 702 | .channels = 1, | |
| 990 | 703 | .buswidth = 8, | |
| 991 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 992 | - | .num_ports = 1, | |
| 993 | - | .port_offsets = { 0xa000 }, | |
| 994 | - | .prio = 2, | |
| 995 | - | .urg_fwd = 0, | |
| 996 | - | .prio_fwd_disable = 1, | |
| 997 | - | }, | |
| 998 | 704 | .num_links = 1, | |
| 999 | 705 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1000 | 706 | }; | |
| @@ -1003,13 +709,6 @@ static struct qcom_icc_node xm_usb3_1 = { | |||
| 1003 | 709 | .name = "xm_usb3_1", | |
| 1004 | 710 | .channels = 1, | |
| 1005 | 711 | .buswidth = 8, | |
| 1006 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1007 | - | .num_ports = 1, | |
| 1008 | - | .port_offsets = { 0xb000 }, | |
| 1009 | - | .prio = 2, | |
| 1010 | - | .urg_fwd = 0, | |
| 1011 | - | .prio_fwd_disable = 1, | |
| 1012 | - | }, | |
| 1013 | 712 | .num_links = 1, | |
| 1014 | 713 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1015 | 714 | }; | |
| @@ -1018,13 +717,6 @@ static struct qcom_icc_node xm_usb3_2 = { | |||
| 1018 | 717 | .name = "xm_usb3_2", | |
| 1019 | 718 | .channels = 1, | |
| 1020 | 719 | .buswidth = 8, | |
| 1021 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1022 | - | .num_ports = 1, | |
| 1023 | - | .port_offsets = { 0xc000 }, | |
| 1024 | - | .prio = 2, | |
| 1025 | - | .urg_fwd = 0, | |
| 1026 | - | .prio_fwd_disable = 1, | |
| 1027 | - | }, | |
| 1028 | 720 | .num_links = 1, | |
| 1029 | 721 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1030 | 722 | }; | |
| @@ -1033,13 +725,6 @@ static struct qcom_icc_node xm_usb4_0 = { | |||
| 1033 | 725 | .name = "xm_usb4_0", | |
| 1034 | 726 | .channels = 1, | |
| 1035 | 727 | .buswidth = 16, | |
| 1036 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1037 | - | .num_ports = 1, | |
| 1038 | - | .port_offsets = { 0xd000 }, | |
| 1039 | - | .prio = 2, | |
| 1040 | - | .urg_fwd = 0, | |
| 1041 | - | .prio_fwd_disable = 1, | |
| 1042 | - | }, | |
| 1043 | 728 | .num_links = 1, | |
| 1044 | 729 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1045 | 730 | }; | |
| @@ -1048,13 +733,6 @@ static struct qcom_icc_node xm_usb4_1 = { | |||
| 1048 | 733 | .name = "xm_usb4_1", | |
| 1049 | 734 | .channels = 1, | |
| 1050 | 735 | .buswidth = 16, | |
| 1051 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1052 | - | .num_ports = 1, | |
| 1053 | - | .port_offsets = { 0xe000 }, | |
| 1054 | - | .prio = 2, | |
| 1055 | - | .urg_fwd = 0, | |
| 1056 | - | .prio_fwd_disable = 1, | |
| 1057 | - | }, | |
| 1058 | 736 | .num_links = 1, | |
| 1059 | 737 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1060 | 738 | }; | |
| @@ -1063,13 +741,6 @@ static struct qcom_icc_node xm_usb4_2 = { | |||
| 1063 | 741 | .name = "xm_usb4_2", | |
| 1064 | 742 | .channels = 1, | |
| 1065 | 743 | .buswidth = 16, | |
| 1066 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1067 | - | .num_ports = 1, | |
| 1068 | - | .port_offsets = { 0xf000 }, | |
| 1069 | - | .prio = 2, | |
| 1070 | - | .urg_fwd = 0, | |
| 1071 | - | .prio_fwd_disable = 1, | |
| 1072 | - | }, | |
| 1073 | 744 | .num_links = 1, | |
| 1074 | 745 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1075 | 746 | }; | |
| @@ -1795,21 +1466,11 @@ static struct qcom_icc_node * const aggre1_noc_nodes[] = { | |||
| 1795 | 1466 | [SLAVE_A1NOC_SNOC] = &qns_a1noc_snoc, | |
| 1796 | 1467 | }; | |
| 1797 | 1468 | ||
| 1798 | - | static const struct regmap_config x1e80100_aggre1_noc_regmap_config = { | |
| 1799 | - | .reg_bits = 32, | |
| 1800 | - | .reg_stride = 4, | |
| 1801 | - | .val_bits = 32, | |
| 1802 | - | .max_register = 0x14400, | |
| 1803 | - | .fast_io = true, | |
| 1804 | - | }; | |
| 1805 | - | ||
| 1806 | 1469 | static const struct qcom_icc_desc x1e80100_aggre1_noc = { | |
| 1807 | - | .config = &x1e80100_aggre1_noc_regmap_config, | |
| 1808 | 1470 | .nodes = aggre1_noc_nodes, | |
| 1809 | 1471 | .num_nodes = ARRAY_SIZE(aggre1_noc_nodes), | |
| 1810 | 1472 | .bcms = aggre1_noc_bcms, | |
| 1811 | 1473 | .num_bcms = ARRAY_SIZE(aggre1_noc_bcms), | |
| 1812 | - | .qos_requires_clocks = true, | |
| 1813 | 1474 | }; | |
| 1814 | 1475 | ||
| 1815 | 1476 | static struct qcom_icc_bcm * const aggre2_noc_bcms[] = { | |
| @@ -1827,16 +1488,7 @@ static struct qcom_icc_node * const aggre2_noc_nodes[] = { | |||
| 1827 | 1488 | [SLAVE_A2NOC_SNOC] = &qns_a2noc_snoc, | |
| 1828 | 1489 | }; | |
| 1829 | 1490 | ||
| 1830 | - | static const struct regmap_config x1e80100_aggre2_noc_regmap_config = { | |
| 1831 | - | .reg_bits = 32, | |
| 1832 | - | .reg_stride = 4, | |
| 1833 | - | .val_bits = 32, | |
| 1834 | - | .max_register = 0x1c400, | |
| 1835 | - | .fast_io = true, | |
| 1836 | - | }; | |
| 1837 | - | ||
| 1838 | 1491 | static const struct qcom_icc_desc x1e80100_aggre2_noc = { | |
| 1839 | - | .config = &x1e80100_aggre2_noc_regmap_config, | |
| 1840 | 1492 | .nodes = aggre2_noc_nodes, | |
| 1841 | 1493 | .num_nodes = ARRAY_SIZE(aggre2_noc_nodes), | |
| 1842 | 1494 | .bcms = aggre2_noc_bcms, | |
| @@ -1921,16 +1573,7 @@ static struct qcom_icc_node * const cnoc_cfg_nodes[] = { | |||
| 1921 | 1573 | [SLAVE_TCU] = &xs_sys_tcu_cfg, | |
| 1922 | 1574 | }; | |
| 1923 | 1575 | ||
| 1924 | - | static const struct regmap_config x1e80100_cnoc_cfg_regmap_config = { | |
| 1925 | - | .reg_bits = 32, | |
| 1926 | - | .reg_stride = 4, | |
| 1927 | - | .val_bits = 32, | |
| 1928 | - | .max_register = 0x6600, | |
| 1929 | - | .fast_io = true, | |
| 1930 | - | }; | |
| 1931 | - | ||
| 1932 | 1576 | static const struct qcom_icc_desc x1e80100_cnoc_cfg = { | |
| 1933 | - | .config = &x1e80100_cnoc_cfg_regmap_config, | |
| 1934 | 1577 | .nodes = cnoc_cfg_nodes, | |
| 1935 | 1578 | .num_nodes = ARRAY_SIZE(cnoc_cfg_nodes), | |
| 1936 | 1579 | .bcms = cnoc_cfg_bcms, | |
| @@ -1960,16 +1603,7 @@ static struct qcom_icc_node * const cnoc_main_nodes[] = { | |||
| 1960 | 1603 | [SLAVE_PCIE_6B] = &xs_pcie_6b, | |
| 1961 | 1604 | }; | |
| 1962 | 1605 | ||
| 1963 | - | static const struct regmap_config x1e80100_cnoc_main_regmap_config = { | |
| 1964 | - | .reg_bits = 32, | |
| 1965 | - | .reg_stride = 4, | |
| 1966 | - | .val_bits = 32, | |
| 1967 | - | .max_register = 0x14400, | |
| 1968 | - | .fast_io = true, | |
| 1969 | - | }; | |
| 1970 | - | ||
| 1971 | 1606 | static const struct qcom_icc_desc x1e80100_cnoc_main = { | |
| 1972 | - | .config = &x1e80100_cnoc_main_regmap_config, | |
| 1973 | 1607 | .nodes = cnoc_main_nodes, | |
| 1974 | 1608 | .num_nodes = ARRAY_SIZE(cnoc_main_nodes), | |
| 1975 | 1609 | .bcms = cnoc_main_bcms, | |
| @@ -1999,16 +1633,7 @@ static struct qcom_icc_node * const gem_noc_nodes[] = { | |||
| 1999 | 1633 | [SLAVE_MEM_NOC_PCIE_SNOC] = &qns_pcie, | |
| 2000 | 1634 | }; | |
| 2001 | 1635 | ||
| 2002 | - | static const struct regmap_config x1e80100_gem_noc_regmap_config = { | |
| 2003 | - | .reg_bits = 32, | |
| 2004 | - | .reg_stride = 4, | |
| 2005 | - | .val_bits = 32, | |
| 2006 | - | .max_register = 0x311200, | |
| 2007 | - | .fast_io = true, | |
| 2008 | - | }; | |
| 2009 | - | ||
| 2010 | 1636 | static const struct qcom_icc_desc x1e80100_gem_noc = { | |
| 2011 | - | .config = &x1e80100_gem_noc_regmap_config, | |
| 2012 | 1637 | .nodes = gem_noc_nodes, | |
| 2013 | 1638 | .num_nodes = ARRAY_SIZE(gem_noc_nodes), | |
| 2014 | 1639 | .bcms = gem_noc_bcms, | |
| @@ -2023,16 +1648,7 @@ static struct qcom_icc_node * const lpass_ag_noc_nodes[] = { | |||
| 2023 | 1648 | [SLAVE_LPASS_GEM_NOC] = &qns_lpass_ag_noc_gemnoc, | |
| 2024 | 1649 | }; | |
| 2025 | 1650 | ||
| 2026 | - | static const struct regmap_config x1e80100_lpass_ag_noc_regmap_config = { | |
| 2027 | - | .reg_bits = 32, | |
| 2028 | - | .reg_stride = 4, | |
| 2029 | - | .val_bits = 32, | |
| 2030 | - | .max_register = 0xe080, | |
| 2031 | - | .fast_io = true, | |
| 2032 | - | }; | |
| 2033 | - | ||
| 2034 | 1651 | static const struct qcom_icc_desc x1e80100_lpass_ag_noc = { | |
| 2035 | - | .config = &x1e80100_lpass_ag_noc_regmap_config, | |
| 2036 | 1652 | .nodes = lpass_ag_noc_nodes, | |
| 2037 | 1653 | .num_nodes = ARRAY_SIZE(lpass_ag_noc_nodes), | |
| 2038 | 1654 | .bcms = lpass_ag_noc_bcms, | |
| @@ -2048,16 +1664,7 @@ static struct qcom_icc_node * const lpass_lpiaon_noc_nodes[] = { | |||
| 2048 | 1664 | [SLAVE_LPIAON_NOC_LPASS_AG_NOC] = &qns_lpass_aggnoc, | |
| 2049 | 1665 | }; | |
| 2050 | 1666 | ||
| 2051 | - | static const struct regmap_config x1e80100_lpass_lpiaon_noc_regmap_config = { | |
| 2052 | - | .reg_bits = 32, | |
| 2053 | - | .reg_stride = 4, | |
| 2054 | - | .val_bits = 32, | |
| 2055 | - | .max_register = 0x19080, | |
| 2056 | - | .fast_io = true, | |
| 2057 | - | }; | |
| 2058 | - | ||
| 2059 | 1667 | static const struct qcom_icc_desc x1e80100_lpass_lpiaon_noc = { | |
| 2060 | - | .config = &x1e80100_lpass_lpiaon_noc_regmap_config, | |
| 2061 | 1668 | .nodes = lpass_lpiaon_noc_nodes, | |
| 2062 | 1669 | .num_nodes = ARRAY_SIZE(lpass_lpiaon_noc_nodes), | |
| 2063 | 1670 | .bcms = lpass_lpiaon_noc_bcms, | |
| @@ -2072,16 +1679,7 @@ static struct qcom_icc_node * const lpass_lpicx_noc_nodes[] = { | |||
| 2072 | 1679 | [SLAVE_LPICX_NOC_LPIAON_NOC] = &qns_lpi_aon_noc, | |
| 2073 | 1680 | }; | |
| 2074 | 1681 | ||
| 2075 | - | static const struct regmap_config x1e80100_lpass_lpicx_noc_regmap_config = { | |
| 2076 | - | .reg_bits = 32, | |
| 2077 | - | .reg_stride = 4, | |
| 2078 | - | .val_bits = 32, | |
| 2079 | - | .max_register = 0x3a200, | |
| 2080 | - | .fast_io = true, | |
| 2081 | - | }; | |
| 2082 | - | ||
| 2083 | 1682 | static const struct qcom_icc_desc x1e80100_lpass_lpicx_noc = { | |
| 2084 | - | .config = &x1e80100_lpass_lpicx_noc_regmap_config, | |
| 2085 | 1683 | .nodes = lpass_lpicx_noc_nodes, | |
| 2086 | 1684 | .num_nodes = ARRAY_SIZE(lpass_lpicx_noc_nodes), | |
| 2087 | 1685 | .bcms = lpass_lpicx_noc_bcms, | |
| @@ -2126,16 +1724,7 @@ static struct qcom_icc_node * const mmss_noc_nodes[] = { | |||
| 2126 | 1724 | [SLAVE_SERVICE_MNOC] = &srvc_mnoc, | |
| 2127 | 1725 | }; | |
| 2128 | 1726 | ||
| 2129 | - | static const struct regmap_config x1e80100_mmss_noc_regmap_config = { | |
| 2130 | - | .reg_bits = 32, | |
| 2131 | - | .reg_stride = 4, | |
| 2132 | - | .val_bits = 32, | |
| 2133 | - | .max_register = 0x5b800, | |
| 2134 | - | .fast_io = true, | |
| 2135 | - | }; | |
| 2136 | - | ||
| 2137 | 1727 | static const struct qcom_icc_desc x1e80100_mmss_noc = { | |
| 2138 | - | .config = &x1e80100_mmss_noc_regmap_config, | |
| 2139 | 1728 | .nodes = mmss_noc_nodes, | |
| 2140 | 1729 | .num_nodes = ARRAY_SIZE(mmss_noc_nodes), | |
| 2141 | 1730 | .bcms = mmss_noc_bcms, | |
| @@ -2151,16 +1740,7 @@ static struct qcom_icc_node * const nsp_noc_nodes[] = { | |||
| 2151 | 1740 | [SLAVE_CDSP_MEM_NOC] = &qns_nsp_gemnoc, | |
| 2152 | 1741 | }; | |
| 2153 | 1742 | ||
| 2154 | - | static const struct regmap_config x1e80100_nsp_noc_regmap_config = { | |
| 2155 | - | .reg_bits = 32, | |
| 2156 | - | .reg_stride = 4, | |
| 2157 | - | .val_bits = 32, | |
| 2158 | - | .max_register = 0xe080, | |
| 2159 | - | .fast_io = true, | |
| 2160 | - | }; | |
| 2161 | - | ||
| 2162 | 1743 | static const struct qcom_icc_desc x1e80100_nsp_noc = { | |
| 2163 | - | .config = &x1e80100_nsp_noc_regmap_config, | |
| 2164 | 1744 | .nodes = nsp_noc_nodes, | |
| 2165 | 1745 | .num_nodes = ARRAY_SIZE(nsp_noc_nodes), | |
| 2166 | 1746 | .bcms = nsp_noc_bcms, | |
| @@ -2177,16 +1757,7 @@ static struct qcom_icc_node * const pcie_center_anoc_nodes[] = { | |||
| 2177 | 1757 | [SLAVE_ANOC_PCIE_GEM_NOC] = &qns_pcie_mem_noc, | |
| 2178 | 1758 | }; | |
| 2179 | 1759 | ||
| 2180 | - | static const struct regmap_config x1e80100_pcie_center_anoc_regmap_config = { | |
| 2181 | - | .reg_bits = 32, | |
| 2182 | - | .reg_stride = 4, | |
| 2183 | - | .val_bits = 32, | |
| 2184 | - | .max_register = 0x7000, | |
| 2185 | - | .fast_io = true, | |
| 2186 | - | }; | |
| 2187 | - | ||
| 2188 | 1760 | static const struct qcom_icc_desc x1e80100_pcie_center_anoc = { | |
| 2189 | - | .config = &x1e80100_pcie_center_anoc_regmap_config, | |
| 2190 | 1761 | .nodes = pcie_center_anoc_nodes, | |
| 2191 | 1762 | .num_nodes = ARRAY_SIZE(pcie_center_anoc_nodes), | |
| 2192 | 1763 | .bcms = pcie_center_anoc_bcms, | |
| @@ -2203,16 +1774,7 @@ static struct qcom_icc_node * const pcie_north_anoc_nodes[] = { | |||
| 2203 | 1774 | [SLAVE_PCIE_NORTH] = &qns_pcie_north_gem_noc, | |
| 2204 | 1775 | }; | |
| 2205 | 1776 | ||
| 2206 | - | static const struct regmap_config x1e80100_pcie_north_anoc_regmap_config = { | |
| 2207 | - | .reg_bits = 32, | |
| 2208 | - | .reg_stride = 4, | |
| 2209 | - | .val_bits = 32, | |
| 2210 | - | .max_register = 0x9080, | |
| 2211 | - | .fast_io = true, | |
| 2212 | - | }; | |
| 2213 | - | ||
| 2214 | 1777 | static const struct qcom_icc_desc x1e80100_pcie_north_anoc = { | |
| 2215 | - | .config = &x1e80100_pcie_north_anoc_regmap_config, | |
| 2216 | 1778 | .nodes = pcie_north_anoc_nodes, | |
| 2217 | 1779 | .num_nodes = ARRAY_SIZE(pcie_north_anoc_nodes), | |
| 2218 | 1780 | .bcms = pcie_north_anoc_bcms, | |
| @@ -2231,16 +1793,7 @@ static struct qcom_icc_node * const pcie_south_anoc_nodes[] = { | |||
| 2231 | 1793 | [SLAVE_PCIE_SOUTH] = &qns_pcie_south_gem_noc, | |
| 2232 | 1794 | }; | |
| 2233 | 1795 | ||
| 2234 | - | static const struct regmap_config x1e80100_pcie_south_anoc_regmap_config = { | |
| 2235 | - | .reg_bits = 32, | |
| 2236 | - | .reg_stride = 4, | |
| 2237 | - | .val_bits = 32, | |
| 2238 | - | .max_register = 0xd080, | |
| 2239 | - | .fast_io = true, | |
| 2240 | - | }; | |
| 2241 | - | ||
| 2242 | 1796 | static const struct qcom_icc_desc x1e80100_pcie_south_anoc = { | |
| 2243 | - | .config = &x1e80100_pcie_south_anoc_regmap_config, | |
| 2244 | 1797 | .nodes = pcie_south_anoc_nodes, | |
| 2245 | 1798 | .num_nodes = ARRAY_SIZE(pcie_south_anoc_nodes), | |
| 2246 | 1799 | .bcms = pcie_south_anoc_bcms, | |
| @@ -2262,16 +1815,7 @@ static struct qcom_icc_node * const system_noc_nodes[] = { | |||
| 2262 | 1815 | [SLAVE_SNOC_GEM_NOC_SF] = &qns_gemnoc_sf, | |
| 2263 | 1816 | }; | |
| 2264 | 1817 | ||
| 2265 | - | static const struct regmap_config x1e80100_system_noc_regmap_config = { | |
| 2266 | - | .reg_bits = 32, | |
| 2267 | - | .reg_stride = 4, | |
| 2268 | - | .val_bits = 32, | |
| 2269 | - | .max_register = 0x1c080, | |
| 2270 | - | .fast_io = true, | |
| 2271 | - | }; | |
| 2272 | - | ||
| 2273 | 1818 | static const struct qcom_icc_desc x1e80100_system_noc = { | |
| 2274 | - | .config = &x1e80100_system_noc_regmap_config, | |
| 2275 | 1819 | .nodes = system_noc_nodes, | |
| 2276 | 1820 | .num_nodes = ARRAY_SIZE(system_noc_nodes), | |
| 2277 | 1821 | .bcms = system_noc_bcms, | |
| @@ -2287,16 +1831,7 @@ static struct qcom_icc_node * const usb_center_anoc_nodes[] = { | |||
| 2287 | 1831 | [SLAVE_USB_NOC_SNOC] = &qns_aggre_usb_snoc, | |
| 2288 | 1832 | }; | |
| 2289 | 1833 | ||
| 2290 | - | static const struct regmap_config x1e80100_usb_center_anoc_regmap_config = { | |
| 2291 | - | .reg_bits = 32, | |
| 2292 | - | .reg_stride = 4, | |
| 2293 | - | .val_bits = 32, | |
| 2294 | - | .max_register = 0x8800, | |
| 2295 | - | .fast_io = true, | |
| 2296 | - | }; | |
| 2297 | - | ||
| 2298 | 1834 | static const struct qcom_icc_desc x1e80100_usb_center_anoc = { | |
| 2299 | - | .config = &x1e80100_usb_center_anoc_regmap_config, | |
| 2300 | 1835 | .nodes = usb_center_anoc_nodes, | |
| 2301 | 1836 | .num_nodes = ARRAY_SIZE(usb_center_anoc_nodes), | |
| 2302 | 1837 | .bcms = usb_center_anoc_bcms, | |
| @@ -2312,21 +1847,11 @@ static struct qcom_icc_node * const usb_north_anoc_nodes[] = { | |||
| 2312 | 1847 | [SLAVE_AGGRE_USB_NORTH] = &qns_aggre_usb_north_snoc, | |
| 2313 | 1848 | }; | |
| 2314 | 1849 | ||
| 2315 | - | static const struct regmap_config x1e80100_usb_north_anoc_regmap_config = { | |
| 2316 | - | .reg_bits = 32, | |
| 2317 | - | .reg_stride = 4, | |
| 2318 | - | .val_bits = 32, | |
| 2319 | - | .max_register = 0x7080, | |
| 2320 | - | .fast_io = true, | |
| 2321 | - | }; | |
| 2322 | - | ||
| 2323 | 1850 | static const struct qcom_icc_desc x1e80100_usb_north_anoc = { | |
| 2324 | - | .config = &x1e80100_usb_north_anoc_regmap_config, | |
| 2325 | 1851 | .nodes = usb_north_anoc_nodes, | |
| 2326 | 1852 | .num_nodes = ARRAY_SIZE(usb_north_anoc_nodes), | |
| 2327 | 1853 | .bcms = usb_north_anoc_bcms, | |
| 2328 | 1854 | .num_bcms = ARRAY_SIZE(usb_north_anoc_bcms), | |
| 2329 | - | .qos_requires_clocks = true, | |
| 2330 | 1855 | }; | |
| 2331 | 1856 | ||
| 2332 | 1857 | static struct qcom_icc_bcm * const usb_south_anoc_bcms[] = { | |
| @@ -2342,21 +1867,11 @@ static struct qcom_icc_node * const usb_south_anoc_nodes[] = { | |||
| 2342 | 1867 | [SLAVE_AGGRE_USB_SOUTH] = &qns_aggre_usb_south_snoc, | |
| 2343 | 1868 | }; | |
| 2344 | 1869 | ||
| 2345 | - | static const struct regmap_config x1e80100_usb_south_anoc_regmap_config = { | |
| 2346 | - | .reg_bits = 32, | |
| 2347 | - | .reg_stride = 4, | |
| 2348 | - | .val_bits = 32, | |
| 2349 | - | .max_register = 0xf080, | |
| 2350 | - | .fast_io = true, | |
| 2351 | - | }; | |
| 2352 | - | ||
| 2353 | 1870 | static const struct qcom_icc_desc x1e80100_usb_south_anoc = { | |
| 2354 | - | .config = &x1e80100_usb_south_anoc_regmap_config, | |
| 2355 | 1871 | .nodes = usb_south_anoc_nodes, | |
| 2356 | 1872 | .num_nodes = ARRAY_SIZE(usb_south_anoc_nodes), | |
| 2357 | 1873 | .bcms = usb_south_anoc_bcms, | |
| 2358 | 1874 | .num_bcms = ARRAY_SIZE(usb_south_anoc_bcms), | |
| 2359 | - | .qos_requires_clocks = true, | |
| 2360 | 1875 | }; | |
| 2361 | 1876 | ||
| 2362 | 1877 | static const struct of_device_id qnoc_of_match[] = { | |
modified drivers/iommu/dma-iommu.c
| @@ -1228,9 +1228,9 @@ dma_addr_t iommu_dma_map_phys(struct device *dev, phys_addr_t phys, size_t size, | |||
| 1228 | 1228 | * If both the physical buffer start address and size are page aligned, | |
| 1229 | 1229 | * we don't need to use a bounce page. | |
| 1230 | 1230 | */ | |
| 1231 | - | if (dev_use_swiotlb(dev, size, dir) && | |
| 1231 | + | if (!(attrs & DMA_ATTR_MMIO) && dev_use_swiotlb(dev, size, dir) && | |
| 1232 | 1232 | iova_unaligned(iovad, phys, size)) { | |
| 1233 | - | if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT)) | |
| 1233 | + | if (attrs & DMA_ATTR_REQUIRE_COHERENT) | |
| 1234 | 1234 | return DMA_MAPPING_ERROR; | |
| 1235 | 1235 | ||
| 1236 | 1236 | phys = iommu_dma_map_swiotlb(dev, phys, size, dir, attrs); | |
modified drivers/md/dm-crypt.c
| @@ -2894,8 +2894,13 @@ static int crypt_ctr_cipher_new(struct dm_target *ti, char *cipher_in, char *key | |||
| 2894 | 2894 | } | |
| 2895 | 2895 | } | |
| 2896 | 2896 | ||
| 2897 | - | if (*ivmode && !strcmp(*ivmode, "lmk")) | |
| 2897 | + | if (*ivmode && !strcmp(*ivmode, "lmk")) { | |
| 2898 | + | if (crypt_integrity_aead(cc)) { | |
| 2899 | + | ti->error = "AEAD transforms not supported for LMK"; | |
| 2900 | + | return -EINVAL; | |
| 2901 | + | } | |
| 2898 | 2902 | cc->tfms_count = 64; | |
| 2903 | + | } | |
| 2899 | 2904 | ||
| 2900 | 2905 | if (*ivmode && !strcmp(*ivmode, "essiv")) { | |
| 2901 | 2906 | if (!*ivopts) { | |
modified drivers/md/dm-integrity.c
| @@ -180,6 +180,7 @@ struct dm_integrity_c { | |||
| 180 | 180 | struct dm_bufio_client *bufio; | |
| 181 | 181 | struct workqueue_struct *metadata_wq; | |
| 182 | 182 | struct superblock *sb; | |
| 183 | + | struct superblock *sb_copy; | |
| 183 | 184 | unsigned int journal_pages; | |
| 184 | 185 | unsigned int n_bitmap_blocks; | |
| 185 | 186 | ||
| @@ -2721,7 +2722,7 @@ static void dm_integrity_inline_recheck(struct work_struct *w) | |||
| 2721 | 2722 | outgoing_data = dio->integrity_payload + PAGE_SIZE; | |
| 2722 | 2723 | ||
| 2723 | 2724 | while (dio->bio_details.bi_iter.bi_size) { | |
| 2724 | - | char digest[HASH_MAX_DIGESTSIZE]; | |
| 2725 | + | char digest[MAX_T(size_t, HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)]; | |
| 2725 | 2726 | int r; | |
| 2726 | 2727 | struct bio_integrity_payload *bip; | |
| 2727 | 2728 | struct bio_vec bv; | |
| @@ -2788,7 +2789,7 @@ static inline bool dm_integrity_check(struct dm_integrity_c *ic, struct dm_integ | |||
| 2788 | 2789 | unsigned pos = 0; | |
| 2789 | 2790 | ||
| 2790 | 2791 | while (dio->bio_details.bi_iter.bi_size) { | |
| 2791 | - | char digest[HASH_MAX_DIGESTSIZE]; | |
| 2792 | + | char digest[MAX_T(size_t, HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)]; | |
| 2792 | 2793 | struct bio_vec bv = bio_iter_iovec(bio, dio->bio_details.bi_iter); | |
| 2793 | 2794 | char *mem = integrity_kmap(ic, bv.bv_page); | |
| 2794 | 2795 | integrity_sector_checksum(ic, &dio->ahash_req, dio->bio_details.bi_iter.bi_sector, mem, bv.bv_offset, digest); | |
| @@ -3858,6 +3859,35 @@ static void dm_integrity_postsuspend(struct dm_target *ti) | |||
| 3858 | 3859 | ic->journal_uptodate = true; | |
| 3859 | 3860 | } | |
| 3860 | 3861 | ||
| 3862 | + | /* | |
| 3863 | + | * The superblock is re-read from the device on every resume, so that we pick | |
| 3864 | + | * up the flags and the recalculate position. The geometry described by the | |
| 3865 | + | * superblock must not change though - the in-memory structures (and the | |
| 3866 | + | * journal in particular) were sized according to the superblock that was | |
| 3867 | + | * validated in the constructor. Reject a superblock that was modified behind | |
| 3868 | + | * our back. | |
| 3869 | + | * | |
| 3870 | + | * Only the fields that the driver never rewrites may be tested here. In | |
| 3871 | + | * particular, "version" is recalculated by sb_set_version on every superblock | |
| 3872 | + | * write and it depends on SB_FLAG_RECALCULATING and SB_FLAG_DIRTY_BITMAP, and | |
| 3873 | + | * SB_FLAG_DISCARD_KEYED may be set by dm_integrity_resume itself. | |
| 3874 | + | */ | |
| 3875 | + | static bool superblock_changed(struct dm_integrity_c *ic) | |
| 3876 | + | { | |
| 3877 | + | const __le32 immutable_flags = cpu_to_le32(SB_FLAG_HAVE_JOURNAL_MAC | | |
| 3878 | + | SB_FLAG_FIXED_PADDING | | |
| 3879 | + | SB_FLAG_FIXED_HMAC | | |
| 3880 | + | SB_FLAG_INLINE); | |
| 3881 | + | ||
| 3882 | + | return memcmp(ic->sb->magic, ic->sb_copy->magic, sizeof(ic->sb->magic)) != 0 || | |
| 3883 | + | ic->sb->log2_interleave_sectors != ic->sb_copy->log2_interleave_sectors || | |
| 3884 | + | ic->sb->integrity_tag_size != ic->sb_copy->integrity_tag_size || | |
| 3885 | + | ic->sb->journal_sections != ic->sb_copy->journal_sections || | |
| 3886 | + | ic->sb->log2_sectors_per_block != ic->sb_copy->log2_sectors_per_block || | |
| 3887 | + | ((ic->sb->flags ^ ic->sb_copy->flags) & immutable_flags) != 0 || | |
| 3888 | + | memcmp(ic->sb->salt, ic->sb_copy->salt, SALT_SIZE) != 0; | |
| 3889 | + | } | |
| 3890 | + | ||
| 3861 | 3891 | static void dm_integrity_resume(struct dm_target *ti) | |
| 3862 | 3892 | { | |
| 3863 | 3893 | struct dm_integrity_c *ic = ti->private; | |
| @@ -3876,6 +3906,18 @@ static void dm_integrity_resume(struct dm_target *ti) | |||
| 3876 | 3906 | if (r) | |
| 3877 | 3907 | dm_integrity_io_error(ic, "reading superblock", r); | |
| 3878 | 3908 | ||
| 3909 | + | if (unlikely(superblock_changed(ic))) { | |
| 3910 | + | /* | |
| 3911 | + | * Restore the superblock that we validated in the constructor, | |
| 3912 | + | * so that the rest of the driver doesn't operate on values | |
| 3913 | + | * that don't match the in-memory structures. | |
| 3914 | + | */ | |
| 3915 | + | memcpy(ic->sb, ic->sb_copy, sizeof(struct superblock)); | |
| 3916 | + | DMERR("The superblock was changed while the device was suspended"); | |
| 3917 | + | dm_integrity_io_error(ic, "superblock check", -EINVAL); | |
| 3918 | + | goto skip_writes; | |
| 3919 | + | } | |
| 3920 | + | ||
| 3879 | 3921 | if (ic->mode == 'R') | |
| 3880 | 3922 | goto skip_writes; | |
| 3881 | 3923 | ||
| @@ -5427,6 +5469,13 @@ try_smaller_buffer: | |||
| 5427 | 5469 | ic->just_formatted = true; | |
| 5428 | 5470 | } | |
| 5429 | 5471 | ||
| 5472 | + | ic->sb_copy = kmemdup(ic->sb, sizeof(struct superblock), GFP_KERNEL); | |
| 5473 | + | if (!ic->sb_copy) { | |
| 5474 | + | ti->error = "Cannot allocate superblock copy"; | |
| 5475 | + | r = -ENOMEM; | |
| 5476 | + | goto bad; | |
| 5477 | + | } | |
| 5478 | + | ||
| 5430 | 5479 | if (!ic->meta_dev && ic->mode != 'I') { | |
| 5431 | 5480 | r = dm_set_target_max_io_len(ti, 1U << ic->sb->log2_interleave_sectors); | |
| 5432 | 5481 | if (r) | |
| @@ -5525,6 +5574,7 @@ static void dm_integrity_dtr(struct dm_target *ti) | |||
| 5525 | 5574 | kvfree(ic->journal_tree); | |
| 5526 | 5575 | if (ic->sb) | |
| 5527 | 5576 | free_pages_exact(ic->sb, SB_SECTORS << SECTOR_SHIFT); | |
| 5577 | + | kfree(ic->sb_copy); | |
| 5528 | 5578 | ||
| 5529 | 5579 | if (ic->internal_shash) | |
| 5530 | 5580 | crypto_free_shash(ic->internal_shash); | |
modified drivers/md/dm-ioctl.c
| @@ -656,10 +656,16 @@ static void *get_result_buffer(struct dm_ioctl *param, size_t param_size, | |||
| 656 | 656 | { | |
| 657 | 657 | param->data_start = align_ptr(param + 1) - (void *) param; | |
| 658 | 658 | ||
| 659 | - | if (param->data_start < param_size) | |
| 659 | + | if (param->data_start < param_size) { | |
| 660 | 660 | *len = param_size - param->data_start; | |
| 661 | - | else | |
| 661 | + | } else { | |
| 662 | + | /* | |
| 663 | + | * The buffer can be as small as offsetof(*param, data), which | |
| 664 | + | * is less than sizeof(*param), so don't run off the end of it. | |
| 665 | + | */ | |
| 662 | 666 | *len = 0; | |
| 667 | + | param->data_start = param_size; | |
| 668 | + | } | |
| 663 | 669 | ||
| 664 | 670 | return ((void *) param) + param->data_start; | |
| 665 | 671 | } | |
| @@ -1267,6 +1273,7 @@ static int do_resume(struct dm_ioctl *param) | |||
| 1267 | 1273 | /* Do we need to load a new map ? */ | |
| 1268 | 1274 | if (new_map) { | |
| 1269 | 1275 | sector_t old_size, new_size; | |
| 1276 | + | blk_mode_t new_map_mode; | |
| 1270 | 1277 | ||
| 1271 | 1278 | dm_ima_context_table_op(md, ima_context, DM_IMA_TABLE_SAVE); | |
| 1272 | 1279 | /* Suspend if it isn't already suspended */ | |
| @@ -1299,6 +1306,7 @@ static int do_resume(struct dm_ioctl *param) | |||
| 1299 | 1306 | } | |
| 1300 | 1307 | } | |
| 1301 | 1308 | ||
| 1309 | + | new_map_mode = dm_table_get_mode(new_map); | |
| 1302 | 1310 | old_size = dm_get_size(md); | |
| 1303 | 1311 | old_map = dm_swap_table(md, new_map); | |
| 1304 | 1312 | if (IS_ERR(old_map)) { | |
| @@ -1314,7 +1322,7 @@ static int do_resume(struct dm_ioctl *param) | |||
| 1314 | 1322 | if (old_size && new_size && old_size != new_size) | |
| 1315 | 1323 | need_resize_uevent = true; | |
| 1316 | 1324 | ||
| 1317 | - | if (dm_table_get_mode(new_map) & BLK_OPEN_WRITE) | |
| 1325 | + | if (new_map_mode & BLK_OPEN_WRITE) | |
| 1318 | 1326 | set_disk_ro(dm_disk(md), 0); | |
| 1319 | 1327 | else | |
| 1320 | 1328 | set_disk_ro(dm_disk(md), 1); | |
modified drivers/md/dm-snap.c
| @@ -1292,6 +1292,20 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 1292 | 1292 | goto bad_store; | |
| 1293 | 1293 | } | |
| 1294 | 1294 | ||
| 1295 | + | /* | |
| 1296 | + | * snapshot-merge requires the optional prepare_merge/commit_merge | |
| 1297 | + | * callbacks; the transient exception store does not implement them. | |
| 1298 | + | * The handover path checks this in __validate_exception_handover(), | |
| 1299 | + | * but a directly constructed snapshot-merge never goes through it. | |
| 1300 | + | */ | |
| 1301 | + | if (dm_target_is_snapshot_merge(ti) && | |
| 1302 | + | (!s->store->type->prepare_merge || | |
| 1303 | + | !s->store->type->commit_merge)) { | |
| 1304 | + | ti->error = "Snapshot exception store does not support snapshot-merge."; | |
| 1305 | + | r = -EINVAL; | |
| 1306 | + | goto bad_hash_tables; | |
| 1307 | + | } | |
| 1308 | + | ||
| 1295 | 1309 | argv += args_used; | |
| 1296 | 1310 | argc -= args_used; | |
| 1297 | 1311 | ||
modified drivers/media/usb/em28xx/em28xx-video.c
| @@ -2416,7 +2416,7 @@ static int em28xx_v4l2_fini(struct em28xx *dev) | |||
| 2416 | 2416 | if (video_is_registered(&v4l2->radio_dev)) { | |
| 2417 | 2417 | dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", | |
| 2418 | 2418 | video_device_node_name(&v4l2->radio_dev)); | |
| 2419 | - | vb2_video_unregister_device(&v4l2->radio_dev); | |
| 2419 | + | video_unregister_device(&v4l2->radio_dev); | |
| 2420 | 2420 | } | |
| 2421 | 2421 | if (video_is_registered(&v4l2->vbi_dev)) { | |
| 2422 | 2422 | dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", | |
| @@ -3082,7 +3082,7 @@ unregister_dev: | |||
| 3082 | 3082 | dev_info(&dev->intf->dev, | |
| 3083 | 3083 | "V4L2 device %s deregistered\n", | |
| 3084 | 3084 | video_device_node_name(&v4l2->radio_dev)); | |
| 3085 | - | vb2_video_unregister_device(&v4l2->radio_dev); | |
| 3085 | + | video_unregister_device(&v4l2->radio_dev); | |
| 3086 | 3086 | } | |
| 3087 | 3087 | if (video_is_registered(&v4l2->vbi_dev)) { | |
| 3088 | 3088 | dev_info(&dev->intf->dev, | |
modified drivers/memstick/core/memstick.c
| @@ -370,9 +370,7 @@ int memstick_set_rw_addr(struct memstick_dev *card) | |||
| 370 | 370 | { | |
| 371 | 371 | card->next_request = h_memstick_set_rw_addr; | |
| 372 | 372 | memstick_new_req(card->host); | |
| 373 | - | if (!wait_for_completion_timeout(&card->mrq_complete, | |
| 374 | - | msecs_to_jiffies(500))) | |
| 375 | - | card->current_mrq.error = -ETIMEDOUT; | |
| 373 | + | wait_for_completion(&card->mrq_complete); | |
| 376 | 374 | ||
| 377 | 375 | return card->current_mrq.error; | |
| 378 | 376 | } | |
| @@ -405,9 +403,7 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host) | |||
| 405 | 403 | ||
| 406 | 404 | card->next_request = h_memstick_read_dev_id; | |
| 407 | 405 | memstick_new_req(host); | |
| 408 | - | if (!wait_for_completion_timeout(&card->mrq_complete, | |
| 409 | - | msecs_to_jiffies(500))) | |
| 410 | - | card->current_mrq.error = -ETIMEDOUT; | |
| 406 | + | wait_for_completion(&card->mrq_complete); | |
| 411 | 407 | ||
| 412 | 408 | if (card->current_mrq.error) | |
| 413 | 409 | goto err_out; | |
modified drivers/memstick/host/rtsx_usb_ms.c
| @@ -27,7 +27,6 @@ struct rtsx_usb_ms { | |||
| 27 | 27 | struct memstick_host *msh; | |
| 28 | 28 | struct memstick_request *req; | |
| 29 | 29 | ||
| 30 | - | struct mutex host_mutex; | |
| 31 | 30 | struct work_struct handle_req; | |
| 32 | 31 | struct delayed_work poll_card; | |
| 33 | 32 | ||
| @@ -514,6 +513,13 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work) | |||
| 514 | 513 | struct memstick_host *msh = host->msh; | |
| 515 | 514 | int rc; | |
| 516 | 515 | ||
| 516 | + | /* Fail requests after eject so their waiters are released. */ | |
| 517 | + | if (host->eject) { | |
| 518 | + | while (!memstick_next_req(msh, &host->req)) | |
| 519 | + | host->req->error = -ENOMEDIUM; | |
| 520 | + | return; | |
| 521 | + | } | |
| 522 | + | ||
| 517 | 523 | if (!host->req) { | |
| 518 | 524 | pm_runtime_get_sync(ms_dev(host)); | |
| 519 | 525 | do { | |
| @@ -547,8 +553,7 @@ static void rtsx_usb_ms_request(struct memstick_host *msh) | |||
| 547 | 553 | ||
| 548 | 554 | dev_dbg(ms_dev(host), "--> %s\n", __func__); | |
| 549 | 555 | ||
| 550 | - | if (!host->eject) | |
| 551 | - | schedule_work(&host->handle_req); | |
| 556 | + | schedule_work(&host->handle_req); | |
| 552 | 557 | } | |
| 553 | 558 | ||
| 554 | 559 | static int rtsx_usb_ms_set_param(struct memstick_host *msh, | |
| @@ -781,7 +786,6 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev) | |||
| 781 | 786 | host->power_mode = MEMSTICK_POWER_OFF; | |
| 782 | 787 | platform_set_drvdata(pdev, host); | |
| 783 | 788 | ||
| 784 | - | mutex_init(&host->host_mutex); | |
| 785 | 789 | INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req); | |
| 786 | 790 | ||
| 787 | 791 | INIT_DELAYED_WORK(&host->poll_card, rtsx_usb_ms_poll_card); | |
| @@ -812,27 +816,12 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev) | |||
| 812 | 816 | { | |
| 813 | 817 | struct rtsx_usb_ms *host = platform_get_drvdata(pdev); | |
| 814 | 818 | struct memstick_host *msh = host->msh; | |
| 815 | - | int err; | |
| 816 | 819 | ||
| 817 | 820 | host->eject = true; | |
| 818 | 821 | msh->removing = true; | |
| 819 | - | cancel_work_sync(&host->handle_req); | |
| 822 | + | flush_work(&host->handle_req); | |
| 820 | 823 | cancel_delayed_work_sync(&host->poll_card); | |
| 821 | 824 | ||
| 822 | - | mutex_lock(&host->host_mutex); | |
| 823 | - | if (host->req) { | |
| 824 | - | dev_dbg(ms_dev(host), | |
| 825 | - | "%s: Controller removed during transfer\n", | |
| 826 | - | dev_name(&msh->dev)); | |
| 827 | - | host->req->error = -ENOMEDIUM; | |
| 828 | - | do { | |
| 829 | - | err = memstick_next_req(msh, &host->req); | |
| 830 | - | if (!err) | |
| 831 | - | host->req->error = -ENOMEDIUM; | |
| 832 | - | } while (!err); | |
| 833 | - | } | |
| 834 | - | mutex_unlock(&host->host_mutex); | |
| 835 | - | ||
| 836 | 825 | /* Balance possible unbalanced usage count | |
| 837 | 826 | * e.g. unconditional module removal | |
| 838 | 827 | */ | |
| @@ -841,6 +830,8 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev) | |||
| 841 | 830 | ||
| 842 | 831 | pm_runtime_disable(ms_dev(host)); | |
| 843 | 832 | memstick_remove_host(msh); | |
| 833 | + | /* No card, no new requests; wait for the last failed one to finish. */ | |
| 834 | + | cancel_work_sync(&host->handle_req); | |
| 844 | 835 | dev_dbg(ms_dev(host), | |
| 845 | 836 | ": Realtek USB Memstick controller has been removed\n"); | |
| 846 | 837 | memstick_free_host(msh); | |
modified drivers/mmc/host/cavium-octeon.c
| @@ -295,9 +295,12 @@ static void octeon_mmc_remove(struct platform_device *pdev) | |||
| 295 | 295 | u64 dma_cfg; | |
| 296 | 296 | int i; | |
| 297 | 297 | ||
| 298 | - | for (i = 0; i < CAVIUM_MAX_MMC; i++) | |
| 298 | + | for (i = 0; i < CAVIUM_MAX_MMC; i++) { | |
| 299 | 299 | if (host->slot[i]) | |
| 300 | 300 | cvm_mmc_of_slot_remove(host->slot[i]); | |
| 301 | + | if (host->slot_pdev[i]) | |
| 302 | + | of_platform_device_destroy(&host->slot_pdev[i]->dev, NULL); | |
| 303 | + | } | |
| 301 | 304 | ||
| 302 | 305 | dma_cfg = readq(host->dma_base + MIO_EMM_DMA_CFG(host)); | |
| 303 | 306 | dma_cfg &= ~MIO_EMM_DMA_CFG_EN; | |
modified drivers/mmc/host/cavium-thunderx.c
| @@ -173,9 +173,12 @@ static void thunder_mmc_remove(struct pci_dev *pdev) | |||
| 173 | 173 | u64 dma_cfg; | |
| 174 | 174 | int i; | |
| 175 | 175 | ||
| 176 | - | for (i = 0; i < CAVIUM_MAX_MMC; i++) | |
| 176 | + | for (i = 0; i < CAVIUM_MAX_MMC; i++) { | |
| 177 | 177 | if (host->slot[i]) | |
| 178 | 178 | cvm_mmc_of_slot_remove(host->slot[i]); | |
| 179 | + | if (host->slot_pdev[i]) | |
| 180 | + | of_platform_device_destroy(&host->slot_pdev[i]->dev, NULL); | |
| 181 | + | } | |
| 179 | 182 | ||
| 180 | 183 | dma_cfg = readq(host->dma_base + MIO_EMM_DMA_CFG(host)); | |
| 181 | 184 | dma_cfg &= ~MIO_EMM_DMA_CFG_EN; | |
modified drivers/mmc/host/mtk-sd.c
| @@ -3216,6 +3216,7 @@ static void msdc_drv_remove(struct platform_device *pdev) | |||
| 3216 | 3216 | ||
| 3217 | 3217 | platform_set_drvdata(pdev, NULL); | |
| 3218 | 3218 | mmc_remove_host(mmc); | |
| 3219 | + | cancel_delayed_work_sync(&host->req_timeout); | |
| 3219 | 3220 | msdc_deinit_hw(host); | |
| 3220 | 3221 | msdc_gate_clock(host); | |
| 3221 | 3222 | ||
modified drivers/mmc/host/sdhci-sprd.c
| @@ -890,6 +890,10 @@ static void sdhci_sprd_remove(struct platform_device *pdev) | |||
| 890 | 890 | struct sdhci_host *host = platform_get_drvdata(pdev); | |
| 891 | 891 | struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); | |
| 892 | 892 | ||
| 893 | + | pm_runtime_get_sync(&pdev->dev); | |
| 894 | + | pm_runtime_disable(&pdev->dev); | |
| 895 | + | pm_runtime_put_noidle(&pdev->dev); | |
| 896 | + | ||
| 893 | 897 | sdhci_remove_host(host, 0); | |
| 894 | 898 | ||
| 895 | 899 | clk_disable_unprepare(sprd_host->clk_sdio); | |
modified drivers/mtd/chips/cfi_cmdset_0001.c
| @@ -1716,12 +1716,24 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le | |||
| 1716 | 1716 | } | |
| 1717 | 1717 | ||
| 1718 | 1718 | ||
| 1719 | + | /* | |
| 1720 | + | * Keep noinline: inlined, the map_word temporaries put do_write_buffer() over | |
| 1721 | + | * the frame-size limit with MTD_MAP_BANK_WIDTH_32 and KASAN_STACK. | |
| 1722 | + | */ | |
| 1723 | + | static noinline void __xipram cfi_write_cmd(struct map_info *map, | |
| 1724 | + | unsigned long cmd, unsigned long adr) | |
| 1725 | + | { | |
| 1726 | + | struct cfi_private *cfi = map->fldrv_priv; | |
| 1727 | + | ||
| 1728 | + | map_write(map, CMD(cmd), adr); | |
| 1729 | + | } | |
| 1730 | + | ||
| 1719 | 1731 | static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |
| 1720 | 1732 | unsigned long adr, const struct kvec **pvec, | |
| 1721 | 1733 | unsigned long *pvec_seek, int len) | |
| 1722 | 1734 | { | |
| 1723 | 1735 | struct cfi_private *cfi = map->fldrv_priv; | |
| 1724 | - | map_word status, write_cmd, datum; | |
| 1736 | + | map_word status, datum; | |
| 1725 | 1737 | unsigned long cmd_adr; | |
| 1726 | 1738 | int ret, wbufsize, word_gap, words; | |
| 1727 | 1739 | const struct kvec *vec; | |
| @@ -1740,9 +1752,6 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1740 | 1752 | if (is_LH28F640BF(cfi)) | |
| 1741 | 1753 | cmd_adr = adr; | |
| 1742 | 1754 | ||
| 1743 | - | /* Let's determine this according to the interleave only once */ | |
| 1744 | - | write_cmd = (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? CMD(0xe8) : CMD(0xe9); | |
| 1745 | - | ||
| 1746 | 1755 | mutex_lock(&chip->mutex); | |
| 1747 | 1756 | ret = get_chip(map, chip, cmd_adr, FL_WRITING); | |
| 1748 | 1757 | if (ret) { | |
| @@ -1759,7 +1768,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1759 | 1768 | So we must check here and reset those bits if they're set. Otherwise | |
| 1760 | 1769 | we're just pissing in the wind */ | |
| 1761 | 1770 | if (chip->state != FL_STATUS) { | |
| 1762 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1771 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1763 | 1772 | chip->state = FL_STATUS; | |
| 1764 | 1773 | } | |
| 1765 | 1774 | status = map_read(map, cmd_adr); | |
| @@ -1767,21 +1776,22 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1767 | 1776 | xip_enable(map, chip, cmd_adr); | |
| 1768 | 1777 | printk(KERN_WARNING "SR.4 or SR.5 bits set in buffer write (status %lx). Clearing.\n", status.x[0]); | |
| 1769 | 1778 | xip_disable(map, chip, cmd_adr); | |
| 1770 | - | map_write(map, CMD(0x50), cmd_adr); | |
| 1771 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1779 | + | cfi_write_cmd(map, 0x50, cmd_adr); | |
| 1780 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1772 | 1781 | } | |
| 1773 | 1782 | ||
| 1774 | 1783 | chip->state = FL_WRITING_TO_BUFFER; | |
| 1775 | - | map_write(map, write_cmd, cmd_adr); | |
| 1784 | + | cfi_write_cmd(map, (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? 0xe8 : 0xe9, | |
| 1785 | + | cmd_adr); | |
| 1776 | 1786 | ret = WAIT_TIMEOUT(map, chip, cmd_adr, 0, 0); | |
| 1777 | 1787 | if (ret) { | |
| 1778 | 1788 | /* Argh. Not ready for write to buffer */ | |
| 1779 | 1789 | map_word Xstatus = map_read(map, cmd_adr); | |
| 1780 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1790 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1781 | 1791 | chip->state = FL_STATUS; | |
| 1782 | 1792 | status = map_read(map, cmd_adr); | |
| 1783 | - | map_write(map, CMD(0x50), cmd_adr); | |
| 1784 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1793 | + | cfi_write_cmd(map, 0x50, cmd_adr); | |
| 1794 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1785 | 1795 | xip_enable(map, chip, cmd_adr); | |
| 1786 | 1796 | printk(KERN_ERR "%s: Chip not ready for buffer write. Xstatus = %lx, status = %lx\n", | |
| 1787 | 1797 | map->name, Xstatus.x[0], status.x[0]); | |
| @@ -1800,7 +1810,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1800 | 1810 | } | |
| 1801 | 1811 | ||
| 1802 | 1812 | /* Write length of data to come */ | |
| 1803 | - | map_write(map, CMD(words), cmd_adr ); | |
| 1813 | + | cfi_write_cmd(map, words, cmd_adr); | |
| 1804 | 1814 | ||
| 1805 | 1815 | /* Write data */ | |
| 1806 | 1816 | vec = *pvec; | |
| @@ -1837,7 +1847,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1837 | 1847 | *pvec_seek = vec_seek; | |
| 1838 | 1848 | ||
| 1839 | 1849 | /* GO GO GO */ | |
| 1840 | - | map_write(map, CMD(0xd0), cmd_adr); | |
| 1850 | + | cfi_write_cmd(map, 0xd0, cmd_adr); | |
| 1841 | 1851 | chip->state = FL_WRITING; | |
| 1842 | 1852 | ||
| 1843 | 1853 | ret = INVAL_CACHE_AND_WAIT(map, chip, cmd_adr, | |
| @@ -1845,7 +1855,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1845 | 1855 | chip->buffer_write_time, | |
| 1846 | 1856 | chip->buffer_write_time_max); | |
| 1847 | 1857 | if (ret) { | |
| 1848 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1858 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1849 | 1859 | chip->state = FL_STATUS; | |
| 1850 | 1860 | xip_enable(map, chip, cmd_adr); | |
| 1851 | 1861 | printk(KERN_ERR "%s: buffer write error (status timeout)\n", map->name); | |
| @@ -1858,8 +1868,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1858 | 1868 | unsigned long chipstatus = MERGESTATUS(status); | |
| 1859 | 1869 | ||
| 1860 | 1870 | /* reset status */ | |
| 1861 | - | map_write(map, CMD(0x50), cmd_adr); | |
| 1862 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1871 | + | cfi_write_cmd(map, 0x50, cmd_adr); | |
| 1872 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1863 | 1873 | xip_enable(map, chip, cmd_adr); | |
| 1864 | 1874 | ||
| 1865 | 1875 | if (chipstatus & 0x02) { | |
modified drivers/mtd/devices/block2mtd.c
| @@ -293,7 +293,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, | |||
| 293 | 293 | } | |
| 294 | 294 | ||
| 295 | 295 | size = bdev_nr_bytes(bdev); | |
| 296 | - | if ((long)size % erase_size) { | |
| 296 | + | if (!erase_size || (long)size % erase_size) { | |
| 297 | 297 | pr_err("erasesize must be a divisor of device size\n"); | |
| 298 | 298 | goto err_free_block2mtd; | |
| 299 | 299 | } | |
modified drivers/mtd/devices/mtd_intel_dg.c
| @@ -387,7 +387,7 @@ idg_erase(struct intel_dg_nvm *nvm, u8 region, loff_t from, u64 len, u64 *fail_a | |||
| 387 | 387 | void __iomem *base2 = nvm->base2; | |
| 388 | 388 | void __iomem *base = nvm->base; | |
| 389 | 389 | const u32 block = 0x10; | |
| 390 | - | u32 iter = 0; | |
| 390 | + | u32 iter; | |
| 391 | 391 | u32 reg; | |
| 392 | 392 | u64 i; | |
| 393 | 393 | ||
| @@ -396,6 +396,7 @@ idg_erase(struct intel_dg_nvm *nvm, u8 region, loff_t from, u64 len, u64 *fail_a | |||
| 396 | 396 | iowrite32(region << 24 | block, base + NVM_ERASE_REG); | |
| 397 | 397 | if (nvm->non_posted_erase) { | |
| 398 | 398 | /* Wait for Erase Done */ | |
| 399 | + | iter = 0; | |
| 399 | 400 | reg = ioread32(base2 + NVM_DEBUG_REG); | |
| 400 | 401 | while (!(reg & NVM_NON_POSTED_ERASE_DONE) && | |
| 401 | 402 | ++iter < NVM_NON_POSTED_ERASE_DONE_ITER) { | |
modified drivers/mtd/mtdcore.c
| @@ -1083,6 +1083,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd) | |||
| 1083 | 1083 | ||
| 1084 | 1084 | err: | |
| 1085 | 1085 | nvmem_unregister(mtd->otp_user_nvmem); | |
| 1086 | + | mtd->otp_user_nvmem = NULL; | |
| 1086 | 1087 | /* Don't report error if OTP is not supported. */ | |
| 1087 | 1088 | if (err == -EOPNOTSUPP) | |
| 1088 | 1089 | return 0; | |
| @@ -1332,7 +1333,7 @@ int __get_mtd_device(struct mtd_info *mtd) | |||
| 1332 | 1333 | int err; | |
| 1333 | 1334 | ||
| 1334 | 1335 | if (master->_get_device) { | |
| 1335 | - | err = master->_get_device(mtd); | |
| 1336 | + | err = master->_get_device(master); | |
| 1336 | 1337 | if (err) | |
| 1337 | 1338 | return err; | |
| 1338 | 1339 | } | |
modified drivers/mtd/nand/ecc.c
| @@ -159,6 +159,13 @@ int nand_ecc_finish_io_req(struct nand_device *nand, | |||
| 159 | 159 | } | |
| 160 | 160 | EXPORT_SYMBOL(nand_ecc_finish_io_req); | |
| 161 | 161 | ||
| 162 | + | bool nand_ecc_is_pipelined(const struct nand_device *nand) | |
| 163 | + | { | |
| 164 | + | return nand->ecc.engine && | |
| 165 | + | nand->ecc.engine->integration == NAND_ECC_ENGINE_INTEGRATION_PIPELINED; | |
| 166 | + | } | |
| 167 | + | EXPORT_SYMBOL(nand_ecc_is_pipelined); | |
| 168 | + | ||
| 162 | 169 | /* Define default OOB placement schemes for large and small page devices */ | |
| 163 | 170 | static int nand_ooblayout_ecc_sp(struct mtd_info *mtd, int section, | |
| 164 | 171 | struct mtd_oob_region *oobregion) | |
modified drivers/mtd/nand/raw/cadence-nand-controller.c
| @@ -3143,6 +3143,9 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl) | |||
| 3143 | 3143 | goto free_buf_desc; | |
| 3144 | 3144 | } | |
| 3145 | 3145 | ||
| 3146 | + | spin_lock_init(&cdns_ctrl->irq_lock); | |
| 3147 | + | init_completion(&cdns_ctrl->complete); | |
| 3148 | + | ||
| 3146 | 3149 | if (devm_request_irq(cdns_ctrl->dev, cdns_ctrl->irq, cadence_nand_isr, | |
| 3147 | 3150 | IRQF_SHARED, "cadence-nand-controller", | |
| 3148 | 3151 | cdns_ctrl)) { | |
| @@ -3151,9 +3154,6 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl) | |||
| 3151 | 3154 | goto free_buf; | |
| 3152 | 3155 | } | |
| 3153 | 3156 | ||
| 3154 | - | spin_lock_init(&cdns_ctrl->irq_lock); | |
| 3155 | - | init_completion(&cdns_ctrl->complete); | |
| 3156 | - | ||
| 3157 | 3157 | ret = cadence_nand_hw_init(cdns_ctrl); | |
| 3158 | 3158 | if (ret) | |
| 3159 | 3159 | goto disable_irq; | |
modified drivers/mtd/nand/raw/vf610_nfc.c
| @@ -505,6 +505,11 @@ static int vf610_nfc_exec_op(struct nand_chip *chip, | |||
| 505 | 505 | check_only); | |
| 506 | 506 | } | |
| 507 | 507 | ||
| 508 | + | static unsigned int vf610_nfc_spare_size(struct mtd_info *mtd) | |
| 509 | + | { | |
| 510 | + | return min_t(unsigned int, mtd->oobsize, 64); | |
| 511 | + | } | |
| 512 | + | ||
| 508 | 513 | static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat, | |
| 509 | 514 | uint8_t *oob, int page) | |
| 510 | 515 | { | |
| @@ -514,6 +519,7 @@ static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat, | |||
| 514 | 519 | u8 ecc_status; | |
| 515 | 520 | u8 ecc_count; | |
| 516 | 521 | int flips_threshold = nfc->chip.ecc.strength / 2; | |
| 522 | + | int ret; | |
| 517 | 523 | ||
| 518 | 524 | ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff; | |
| 519 | 525 | ecc_count = ecc_status & ECC_STATUS_ERR_COUNT; | |
| @@ -521,16 +527,22 @@ static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat, | |||
| 521 | 527 | if (!(ecc_status & ECC_STATUS_MASK)) | |
| 522 | 528 | return ecc_count; | |
| 523 | 529 | ||
| 530 | + | /* The failed decode leaves a bogus correction in SRAM; re-read without ECC */ | |
| 524 | 531 | nfc->data_access = true; | |
| 525 | - | nand_read_oob_op(&nfc->chip, page, 0, oob, mtd->oobsize); | |
| 532 | + | ret = nand_read_page_op(&nfc->chip, page, 0, dat, mtd->writesize); | |
| 533 | + | if (!ret) | |
| 534 | + | ret = nand_read_oob_op(&nfc->chip, page, 0, oob, | |
| 535 | + | vf610_nfc_spare_size(mtd)); | |
| 526 | 536 | nfc->data_access = false; | |
| 537 | + | if (ret) | |
| 538 | + | return ret; | |
| 527 | 539 | ||
| 528 | 540 | /* | |
| 529 | - | * On an erased page, bit count (including OOB) should be zero or | |
| 530 | - | * at least less then half of the ECC strength. | |
| 541 | + | * Run the erased-page check with the driver's historic threshold | |
| 542 | + | * of half the ECC strength. | |
| 531 | 543 | */ | |
| 532 | - | return nand_check_erased_ecc_chunk(dat, nfc->chip.ecc.size, oob, | |
| 533 | - | mtd->oobsize, NULL, 0, | |
| 544 | + | return nand_check_erased_ecc_chunk(dat, mtd->writesize, oob, | |
| 545 | + | vf610_nfc_spare_size(mtd), NULL, 0, | |
| 534 | 546 | flips_threshold); | |
| 535 | 547 | } | |
| 536 | 548 | ||
| @@ -551,7 +563,7 @@ static int vf610_nfc_read_page(struct nand_chip *chip, uint8_t *buf, | |||
| 551 | 563 | { | |
| 552 | 564 | struct vf610_nfc *nfc = chip_to_nfc(chip); | |
| 553 | 565 | struct mtd_info *mtd = nand_to_mtd(chip); | |
| 554 | - | int trfr_sz = mtd->writesize + mtd->oobsize; | |
| 566 | + | int trfr_sz = mtd->writesize + vf610_nfc_spare_size(mtd); | |
| 555 | 567 | u32 row = 0, cmd1 = 0, cmd2 = 0, code = 0; | |
| 556 | 568 | int stat; | |
| 557 | 569 | ||
| @@ -577,11 +589,16 @@ static int vf610_nfc_read_page(struct nand_chip *chip, uint8_t *buf, | |||
| 577 | 589 | */ | |
| 578 | 590 | vf610_nfc_rd_from_sram(buf, nfc->regs + NFC_MAIN_AREA(0), | |
| 579 | 591 | mtd->writesize, false); | |
| 580 | - | if (oob_required) | |
| 592 | + | if (oob_required) { | |
| 593 | + | unsigned int spare = vf610_nfc_spare_size(mtd); | |
| 594 | + | ||
| 581 | 595 | vf610_nfc_rd_from_sram(chip->oob_poi, | |
| 582 | 596 | nfc->regs + NFC_MAIN_AREA(0) + | |
| 583 | 597 | mtd->writesize, | |
| 584 | - | mtd->oobsize, false); | |
| 598 | + | spare, false); | |
| 599 | + | /* Not transferred, and never written: reads back erased */ | |
| 600 | + | memset(chip->oob_poi + spare, 0xff, mtd->oobsize - spare); | |
| 601 | + | } | |
| 585 | 602 | ||
| 586 | 603 | stat = vf610_nfc_correct_data(chip, buf, chip->oob_poi, page); | |
| 587 | 604 | ||
| @@ -599,7 +616,7 @@ static int vf610_nfc_write_page(struct nand_chip *chip, const uint8_t *buf, | |||
| 599 | 616 | { | |
| 600 | 617 | struct vf610_nfc *nfc = chip_to_nfc(chip); | |
| 601 | 618 | struct mtd_info *mtd = nand_to_mtd(chip); | |
| 602 | - | int trfr_sz = mtd->writesize + mtd->oobsize; | |
| 619 | + | int trfr_sz = mtd->writesize + vf610_nfc_spare_size(mtd); | |
| 603 | 620 | u32 row = 0, cmd1 = 0, cmd2 = 0, code = 0; | |
| 604 | 621 | u8 status; | |
| 605 | 622 | int ret; | |
| @@ -740,6 +757,49 @@ static void vf610_nfc_init_controller(struct vf610_nfc *nfc) | |||
| 740 | 757 | } | |
| 741 | 758 | } | |
| 742 | 759 | ||
| 760 | + | /* | |
| 761 | + | * With 64 byte OOB chips the core's large page layout matches what | |
| 762 | + | * U-Boot uses, and on chips with more, U-Boot and older kernels clamped | |
| 763 | + | * mtd->oobsize to 64. Modifying the OOB size is no longer possible, the | |
| 764 | + | * actual chip geometry must be respected, so to avoid breaking those | |
| 765 | + | * existing setups use our own layout: the core's large page one, | |
| 766 | + | * computed over the first 64 spare bytes only. | |
| 767 | + | */ | |
| 768 | + | static int vf610_nfc_ooblayout_ecc(struct mtd_info *mtd, int section, | |
| 769 | + | struct mtd_oob_region *oobregion) | |
| 770 | + | { | |
| 771 | + | struct nand_device *nand = mtd_to_nanddev(mtd); | |
| 772 | + | unsigned int total_ecc_bytes = nand->ecc.ctx.total; | |
| 773 | + | ||
| 774 | + | if (section || !total_ecc_bytes) | |
| 775 | + | return -ERANGE; | |
| 776 | + | ||
| 777 | + | oobregion->length = total_ecc_bytes; | |
| 778 | + | oobregion->offset = vf610_nfc_spare_size(mtd) - oobregion->length; | |
| 779 | + | ||
| 780 | + | return 0; | |
| 781 | + | } | |
| 782 | + | ||
| 783 | + | static int vf610_nfc_ooblayout_free(struct mtd_info *mtd, int section, | |
| 784 | + | struct mtd_oob_region *oobregion) | |
| 785 | + | { | |
| 786 | + | struct nand_device *nand = mtd_to_nanddev(mtd); | |
| 787 | + | unsigned int total_ecc_bytes = nand->ecc.ctx.total; | |
| 788 | + | ||
| 789 | + | if (section) | |
| 790 | + | return -ERANGE; | |
| 791 | + | ||
| 792 | + | oobregion->length = vf610_nfc_spare_size(mtd) - total_ecc_bytes - 2; | |
| 793 | + | oobregion->offset = 2; | |
| 794 | + | ||
| 795 | + | return 0; | |
| 796 | + | } | |
| 797 | + | ||
| 798 | + | static const struct mtd_ooblayout_ops vf610_nfc_ooblayout_ops = { | |
| 799 | + | .ecc = vf610_nfc_ooblayout_ecc, | |
| 800 | + | .free = vf610_nfc_ooblayout_free, | |
| 801 | + | }; | |
| 802 | + | ||
| 743 | 803 | static int vf610_nfc_attach_chip(struct nand_chip *chip) | |
| 744 | 804 | { | |
| 745 | 805 | struct mtd_info *mtd = nand_to_mtd(chip); | |
| @@ -770,12 +830,7 @@ static int vf610_nfc_attach_chip(struct nand_chip *chip) | |||
| 770 | 830 | return -ENXIO; | |
| 771 | 831 | } | |
| 772 | 832 | ||
| 773 | - | /* Only 64 byte ECC layouts known */ | |
| 774 | - | if (mtd->oobsize > 64) | |
| 775 | - | mtd->oobsize = 64; | |
| 776 | - | ||
| 777 | - | /* Use default large page ECC layout defined in NAND core */ | |
| 778 | - | mtd_set_ooblayout(mtd, nand_get_large_page_ooblayout()); | |
| 833 | + | mtd_set_ooblayout(mtd, &vf610_nfc_ooblayout_ops); | |
| 779 | 834 | if (chip->ecc.strength == 32) { | |
| 780 | 835 | nfc->ecc_mode = ECC_60_BYTE; | |
| 781 | 836 | chip->ecc.bytes = 60; | |
modified drivers/mtd/nand/spi/core.c
| @@ -281,8 +281,26 @@ static int spinand_init_cfg_cache(struct spinand_device *spinand) | |||
| 281 | 281 | static int spinand_init_quad_enable(struct spinand_device *spinand, | |
| 282 | 282 | bool enable) | |
| 283 | 283 | { | |
| 284 | - | return spinand_upd_cfg(spinand, CFG_QUAD_ENABLE, | |
| 285 | - | enable ? CFG_QUAD_ENABLE : 0); | |
| 284 | + | struct nand_device *nand = spinand_to_nand(spinand); | |
| 285 | + | unsigned int target; | |
| 286 | + | int ret; | |
| 287 | + | ||
| 288 | + | /* | |
| 289 | + | * QE is a per-die setting on some devices. Program each target | |
| 290 | + | * individually when enabling or disabling quad I/O mode. | |
| 291 | + | */ | |
| 292 | + | for (target = 0; target < nand->memorg.ntargets; target++) { | |
| 293 | + | ret = spinand_select_target(spinand, target); | |
| 294 | + | if (ret) | |
| 295 | + | return ret; | |
| 296 | + | ||
| 297 | + | ret = spinand_upd_cfg(spinand, CFG_QUAD_ENABLE, | |
| 298 | + | enable ? CFG_QUAD_ENABLE : 0); | |
| 299 | + | if (ret) | |
| 300 | + | return ret; | |
| 301 | + | } | |
| 302 | + | ||
| 303 | + | return 0; | |
| 286 | 304 | } | |
| 287 | 305 | ||
| 288 | 306 | static int spinand_ecc_enable(struct spinand_device *spinand, | |
| @@ -508,8 +526,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, | |||
| 508 | 526 | else | |
| 509 | 527 | rdesc->info.op_tmpl = &rdesc->info.primary_op_tmpl; | |
| 510 | 528 | ||
| 511 | - | if (nand->ecc.engine->integration == NAND_ECC_ENGINE_INTEGRATION_PIPELINED && | |
| 512 | - | req->mode != MTD_OPS_RAW) | |
| 529 | + | if (nand_ecc_is_pipelined(nand) && req->mode != MTD_OPS_RAW) | |
| 513 | 530 | rdesc->info.op_tmpl->data.ecc = true; | |
| 514 | 531 | else | |
| 515 | 532 | rdesc->info.op_tmpl->data.ecc = false; | |
| @@ -603,8 +620,7 @@ static int spinand_write_to_cache_op(struct spinand_device *spinand, | |||
| 603 | 620 | ||
| 604 | 621 | wdesc = spinand->dirmaps[req->pos.plane].wdesc; | |
| 605 | 622 | ||
| 606 | - | if (nand->ecc.engine->integration == NAND_ECC_ENGINE_INTEGRATION_PIPELINED && | |
| 607 | - | req->mode != MTD_OPS_RAW) | |
| 623 | + | if (nand_ecc_is_pipelined(nand) && req->mode != MTD_OPS_RAW) | |
| 608 | 624 | wdesc->info.op_tmpl->data.ecc = true; | |
| 609 | 625 | else | |
| 610 | 626 | wdesc->info.op_tmpl->data.ecc = false; | |
| @@ -1261,7 +1277,7 @@ static int spinand_create_dirmap(struct spinand_device *spinand, | |||
| 1261 | 1277 | struct spi_mem_dirmap_desc *desc; | |
| 1262 | 1278 | bool enable_ecc = false, secondary_op = false; | |
| 1263 | 1279 | ||
| 1264 | - | if (nand->ecc.engine->integration == NAND_ECC_ENGINE_INTEGRATION_PIPELINED) | |
| 1280 | + | if (nand_ecc_is_pipelined(nand)) | |
| 1265 | 1281 | enable_ecc = true; | |
| 1266 | 1282 | ||
| 1267 | 1283 | if (spinand->cont_read_possible && spinand->op_templates->cont_read_cache) | |
| @@ -1797,11 +1813,11 @@ try_ssdr: | |||
| 1797 | 1813 | spinand->ssdr_op_templates.write_cache->data.buswidth == 4 || | |
| 1798 | 1814 | spinand->ssdr_op_templates.update_cache->data.buswidth == 4) | |
| 1799 | 1815 | quad_enable = true; | |
| 1800 | - | } | |
| 1801 | 1816 | ||
| 1802 | - | ret = spinand_init_quad_enable(spinand, quad_enable); | |
| 1803 | - | if (ret) | |
| 1804 | - | return ret; | |
| 1817 | + | ret = spinand_init_quad_enable(spinand, quad_enable); | |
| 1818 | + | if (ret) | |
| 1819 | + | return ret; | |
| 1820 | + | } | |
| 1805 | 1821 | ||
| 1806 | 1822 | if (spinand->configure_chip) { | |
| 1807 | 1823 | ret = spinand->configure_chip(spinand, SSDR); | |
| @@ -1809,7 +1825,7 @@ try_ssdr: | |||
| 1809 | 1825 | return ret; | |
| 1810 | 1826 | } | |
| 1811 | 1827 | ||
| 1812 | - | return ret; | |
| 1828 | + | return 0; | |
| 1813 | 1829 | } | |
| 1814 | 1830 | ||
| 1815 | 1831 | static int spinand_init_flash(struct spinand_device *spinand) | |
| @@ -1980,12 +1996,17 @@ static int spinand_init(struct spinand_device *spinand) | |||
| 1980 | 1996 | goto err_cleanup_ecc_engine; | |
| 1981 | 1997 | } | |
| 1982 | 1998 | ||
| 1983 | - | if (nand->ecc.engine) { | |
| 1984 | - | ret = mtd_ooblayout_count_freebytes(mtd); | |
| 1985 | - | if (ret < 0) | |
| 1986 | - | goto err_cleanup_ecc_engine; | |
| 1999 | + | if (!nand->ecc.engine) { | |
| 2000 | + | if (spinand->eccinfo.ooblayout) | |
| 2001 | + | mtd_set_ooblayout(mtd, spinand->eccinfo.ooblayout); | |
| 2002 | + | else | |
| 2003 | + | mtd_set_ooblayout(mtd, &spinand_noecc_ooblayout); | |
| 1987 | 2004 | } | |
| 1988 | 2005 | ||
| 2006 | + | ret = mtd_ooblayout_count_freebytes(mtd); | |
| 2007 | + | if (ret < 0) | |
| 2008 | + | goto err_cleanup_ecc_engine; | |
| 2009 | + | ||
| 1989 | 2010 | mtd->oobavail = ret; | |
| 1990 | 2011 | ||
| 1991 | 2012 | /* Propagate ECC information to mtd_info */ | |
modified drivers/mtd/spi-nor/core.c
| @@ -1310,7 +1310,7 @@ static bool spi_nor_rww_start_exclusive(struct spi_nor *nor) | |||
| 1310 | 1310 | { | |
| 1311 | 1311 | struct spi_nor_rww *rww = &nor->rww; | |
| 1312 | 1312 | ||
| 1313 | - | mutex_lock(&nor->lock); | |
| 1313 | + | guard(mutex)(&nor->lock); | |
| 1314 | 1314 | ||
| 1315 | 1315 | if (rww->ongoing_io || rww->ongoing_rd || rww->ongoing_pe) | |
| 1316 | 1316 | return false; | |
modified drivers/net/amt.c
| @@ -80,15 +80,6 @@ static struct in6_addr mld2_all_node = MLD2_ALL_NODE_INIT; | |||
| 80 | 80 | static struct mld2_grec mldv2_zero_grec; | |
| 81 | 81 | #endif | |
| 82 | 82 | ||
| 83 | - | static struct amt_skb_cb *amt_skb_cb(struct sk_buff *skb) | |
| 84 | - | { | |
| 85 | - | BUILD_BUG_ON(sizeof(struct amt_skb_cb) + sizeof(struct tc_skb_cb) > | |
| 86 | - | sizeof_field(struct sk_buff, cb)); | |
| 87 | - | ||
| 88 | - | return (struct amt_skb_cb *)((void *)skb->cb + | |
| 89 | - | sizeof(struct tc_skb_cb)); | |
| 90 | - | } | |
| 91 | - | ||
| 92 | 83 | static void __amt_source_gc_work(void) | |
| 93 | 84 | { | |
| 94 | 85 | struct amt_source_node *snode; | |
| @@ -791,6 +782,11 @@ out: | |||
| 791 | 782 | rcu_read_unlock(); | |
| 792 | 783 | } | |
| 793 | 784 | ||
| 785 | + | static bool amt_send_membership_query(struct amt_dev *amt, | |
| 786 | + | struct sk_buff *skb, | |
| 787 | + | struct amt_tunnel_list *tunnel, | |
| 788 | + | bool v6); | |
| 789 | + | ||
| 794 | 790 | static void amt_send_igmp_gq(struct amt_dev *amt, | |
| 795 | 791 | struct amt_tunnel_list *tunnel) | |
| 796 | 792 | { | |
| @@ -800,8 +796,11 @@ static void amt_send_igmp_gq(struct amt_dev *amt, | |||
| 800 | 796 | if (!skb) | |
| 801 | 797 | return; | |
| 802 | 798 | ||
| 803 | - | amt_skb_cb(skb)->tunnel = tunnel; | |
| 804 | - | dev_queue_xmit(skb); | |
| 799 | + | skb_pull(skb, sizeof(struct ethhdr)); | |
| 800 | + | if (amt_send_membership_query(amt, skb, tunnel, false)) { | |
| 801 | + | amt->dev->stats.tx_dropped++; | |
| 802 | + | kfree_skb(skb); | |
| 803 | + | } | |
| 805 | 804 | } | |
| 806 | 805 | ||
| 807 | 806 | #if IS_ENABLED(CONFIG_IPV6) | |
| @@ -885,8 +884,11 @@ static void amt_send_mld_gq(struct amt_dev *amt, struct amt_tunnel_list *tunnel) | |||
| 885 | 884 | if (!skb) | |
| 886 | 885 | return; | |
| 887 | 886 | ||
| 888 | - | amt_skb_cb(skb)->tunnel = tunnel; | |
| 889 | - | dev_queue_xmit(skb); | |
| 887 | + | skb_pull(skb, sizeof(struct ethhdr)); | |
| 888 | + | if (amt_send_membership_query(amt, skb, tunnel, true)) { | |
| 889 | + | amt->dev->stats.tx_dropped++; | |
| 890 | + | kfree_skb(skb); | |
| 891 | + | } | |
| 890 | 892 | } | |
| 891 | 893 | #else | |
| 892 | 894 | static void amt_send_mld_gq(struct amt_dev *amt, struct amt_tunnel_list *tunnel) | |
| @@ -1186,7 +1188,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1186 | 1188 | #endif | |
| 1187 | 1189 | bool report = false; | |
| 1188 | 1190 | struct igmphdr *ih; | |
| 1189 | - | bool query = false; | |
| 1190 | 1191 | struct iphdr *iph; | |
| 1191 | 1192 | bool data = false; | |
| 1192 | 1193 | bool v6 = false; | |
| @@ -1204,9 +1205,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1204 | 1205 | case IGMP_HOST_MEMBERSHIP_REPORT: | |
| 1205 | 1206 | report = true; | |
| 1206 | 1207 | break; | |
| 1207 | - | case IGMP_HOST_MEMBERSHIP_QUERY: | |
| 1208 | - | query = true; | |
| 1209 | - | break; | |
| 1210 | 1208 | default: | |
| 1211 | 1209 | goto free; | |
| 1212 | 1210 | } | |
| @@ -1228,9 +1226,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1228 | 1226 | case ICMPV6_MLD2_REPORT: | |
| 1229 | 1227 | report = true; | |
| 1230 | 1228 | break; | |
| 1231 | - | case ICMPV6_MGM_QUERY: | |
| 1232 | - | query = true; | |
| 1233 | - | break; | |
| 1234 | 1229 | default: | |
| 1235 | 1230 | goto free; | |
| 1236 | 1231 | } | |
| @@ -1261,19 +1256,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1261 | 1256 | goto free; | |
| 1262 | 1257 | goto unlock; | |
| 1263 | 1258 | } else if (amt->mode == AMT_MODE_RELAY) { | |
| 1264 | - | if (query) { | |
| 1265 | - | tunnel = amt_skb_cb(skb)->tunnel; | |
| 1266 | - | if (!tunnel) { | |
| 1267 | - | WARN_ON(1); | |
| 1268 | - | goto free; | |
| 1269 | - | } | |
| 1270 | - | ||
| 1271 | - | /* Do not forward unexpected query */ | |
| 1272 | - | if (amt_send_membership_query(amt, skb, tunnel, v6)) | |
| 1273 | - | goto free; | |
| 1274 | - | goto unlock; | |
| 1275 | - | } | |
| 1276 | - | ||
| 1277 | 1259 | if (!data) | |
| 1278 | 1260 | goto free; | |
| 1279 | 1261 | list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) { | |
modified drivers/net/bareudp.c
| @@ -356,7 +356,7 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
| 356 | 356 | if (err) | |
| 357 | 357 | goto free_dst; | |
| 358 | 358 | ||
| 359 | - | skb_set_inner_protocol(skb, bareudp->ethertype); | |
| 359 | + | skb_set_inner_protocol(skb, skb->protocol); | |
| 360 | 360 | udp_tunnel_xmit_skb(rt, sk, skb, saddr, info->key.u.ipv4.dst, | |
| 361 | 361 | tos, ttl, df, sport, bareudp->port, | |
| 362 | 362 | !net_eq(bareudp->net, dev_net(bareudp->dev)), | |
| @@ -424,6 +424,7 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
| 424 | 424 | if (err) | |
| 425 | 425 | goto free_dst; | |
| 426 | 426 | ||
| 427 | + | skb_set_inner_protocol(skb, skb->protocol); | |
| 427 | 428 | daddr = info->key.u.ipv6.dst; | |
| 428 | 429 | udp_tunnel6_xmit_skb(dst, sk, skb, dev, | |
| 429 | 430 | &saddr, &daddr, prio, ttl, | |
modified drivers/net/bonding/bond_main.c
| @@ -5732,12 +5732,12 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog, | |||
| 5732 | 5732 | bpf_prog_inc(prog); | |
| 5733 | 5733 | } | |
| 5734 | 5734 | ||
| 5735 | - | if (prog) { | |
| 5735 | + | if (prog && !old_prog) | |
| 5736 | 5736 | static_branch_inc(&bpf_master_redirect_enabled_key); | |
| 5737 | - | } else if (old_prog) { | |
| 5738 | - | bpf_prog_put(old_prog); | |
| 5737 | + | else if (!prog && old_prog) | |
| 5739 | 5738 | static_branch_dec(&bpf_master_redirect_enabled_key); | |
| 5740 | - | } | |
| 5739 | + | if (old_prog) | |
| 5740 | + | bpf_prog_put(old_prog); | |
| 5741 | 5741 | ||
| 5742 | 5742 | return 0; | |
| 5743 | 5743 | ||
modified drivers/net/can/dev/skb.c
| @@ -210,6 +210,10 @@ static void init_can_skb(struct sk_buff *skb) | |||
| 210 | 210 | { | |
| 211 | 211 | skb->pkt_type = PACKET_BROADCAST; | |
| 212 | 212 | skb->ip_summed = CHECKSUM_UNNECESSARY; | |
| 213 | + | ||
| 214 | + | skb_reset_mac_header(skb); | |
| 215 | + | skb_reset_network_header(skb); | |
| 216 | + | skb_reset_transport_header(skb); | |
| 213 | 217 | } | |
| 214 | 218 | ||
| 215 | 219 | struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf) | |
modified drivers/net/can/usb/f81604.c
| @@ -169,7 +169,7 @@ struct f81604_int_data { | |||
| 169 | 169 | u8 rxerr; | |
| 170 | 170 | u8 txerr; | |
| 171 | 171 | u8 val; | |
| 172 | - | } __packed __aligned(4); | |
| 172 | + | } __packed; | |
| 173 | 173 | ||
| 174 | 174 | struct f81604_sff { | |
| 175 | 175 | __be16 id; | |
modified drivers/net/can/vxcan.c
| @@ -79,6 +79,9 @@ static netdev_tx_t vxcan_xmit(struct sk_buff *oskb, struct net_device *dev) | |||
| 79 | 79 | ||
| 80 | 80 | /* reset CAN GW hop counter */ | |
| 81 | 81 | csx->can_gw_hops = 0; | |
| 82 | + | /* start with new CAN skb UID in the other namespace */ | |
| 83 | + | csx->can_skb_uid = 0; | |
| 84 | + | ||
| 82 | 85 | skb->pkt_type = PACKET_BROADCAST; | |
| 83 | 86 | skb->dev = peer; | |
| 84 | 87 | skb->ip_summed = CHECKSUM_UNNECESSARY; | |
modified drivers/net/dsa/microchip/ksz_common.h
| @@ -853,7 +853,7 @@ static inline bool ksz_is_sgmii_port(struct ksz_device *dev, int port) | |||
| 853 | 853 | #define KSZ88_FAMILY_ID 0x88 | |
| 854 | 854 | #define KSZ8895_FAMILY_ID 0x95 | |
| 855 | 855 | ||
| 856 | - | #define KSZ8_PORT_STATUS_0 0x08 | |
| 856 | + | #define KSZ8_PORT_STATUS_0 0x18 | |
| 857 | 857 | #define KSZ8_PORT_FIBER_MODE BIT(7) | |
| 858 | 858 | ||
| 859 | 859 | #define SW_CHIP_ID_M GENMASK(7, 4) | |
modified drivers/net/ethernet/airoha/airoha_eth.c
| @@ -2800,14 +2800,34 @@ static int airoha_qdma_set_trtcm_param(struct airoha_qdma *qdma, int channel, | |||
| 2800 | 2800 | FIELD_PREP(TRTCM_METER_GROUP_MASK, group) | | |
| 2801 | 2801 | FIELD_PREP(TRTCM_PARAM_INDEX_MASK, idx) | | |
| 2802 | 2802 | FIELD_PREP(TRTCM_PARAM_RATE_TYPE_MASK, mode); | |
| 2803 | + | int i; | |
| 2803 | 2804 | ||
| 2804 | - | airoha_qdma_wr(qdma, REG_TRTCM_DATA_LOW(addr), val); | |
| 2805 | - | airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config); | |
| 2805 | + | /* | |
| 2806 | + | * HW might be in the middle of bucket handling and might | |
| 2807 | + | * require an additional try to actually apply the new TRTCM | |
| 2808 | + | * config. | |
| 2809 | + | */ | |
| 2810 | + | for (i = 0; i < TRTCM_CONFIG_RETRY_MAX; i++) { | |
| 2811 | + | u32 data = 0; | |
| 2806 | 2812 | ||
| 2807 | - | return read_poll_timeout(airoha_qdma_rr, val, | |
| 2808 | - | val & TRTCM_PARAM_RW_DONE_MASK, | |
| 2809 | - | USEC_PER_MSEC, 10 * USEC_PER_MSEC, true, | |
| 2810 | - | qdma, REG_TRTCM_CFG_PARAM(addr)); | |
| 2813 | + | airoha_qdma_wr(qdma, REG_TRTCM_DATA_LOW(addr), val); | |
| 2814 | + | airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config); | |
| 2815 | + | ||
| 2816 | + | if (read_poll_timeout(airoha_qdma_rr, data, | |
| 2817 | + | data & TRTCM_PARAM_RW_DONE_MASK, | |
| 2818 | + | USEC_PER_MSEC, 10 * USEC_PER_MSEC, | |
| 2819 | + | true, qdma, REG_TRTCM_CFG_PARAM(addr))) | |
| 2820 | + | continue; | |
| 2821 | + | ||
| 2822 | + | if (airoha_qdma_get_trtcm_param(qdma, channel, addr, param, | |
| 2823 | + | mode, &data, NULL)) | |
| 2824 | + | continue; | |
| 2825 | + | ||
| 2826 | + | if (data == val) | |
| 2827 | + | return 0; | |
| 2828 | + | } | |
| 2829 | + | ||
| 2830 | + | return -EBUSY; | |
| 2811 | 2831 | } | |
| 2812 | 2832 | ||
| 2813 | 2833 | static int airoha_qdma_set_trtcm_config(struct airoha_qdma *qdma, int channel, | |
modified drivers/net/ethernet/airoha/airoha_eth.h
| @@ -171,6 +171,8 @@ enum trtcm_param { | |||
| 171 | 171 | #define TRTCM_TOKEN_RATE_MASK GENMASK(23, 6) | |
| 172 | 172 | #define TRTCM_TOKEN_RATE_FRACTION_MASK GENMASK(5, 0) | |
| 173 | 173 | ||
| 174 | + | #define TRTCM_CONFIG_RETRY_MAX 2 | |
| 175 | + | ||
| 174 | 176 | enum airoha_dma_map_type { | |
| 175 | 177 | AIROHA_DMA_UNMAPPED, | |
| 176 | 178 | AIROHA_DMA_MAP_SINGLE, | |
modified drivers/net/ethernet/allwinner/sun4i-emac.c
| @@ -300,7 +300,7 @@ static int emac_dma_inblk_32bit(struct emac_board_info *db, | |||
| 300 | 300 | if (!req) { | |
| 301 | 301 | dev_err(db->dev, "alloc emac dma req error.\n"); | |
| 302 | 302 | ret = -ENOMEM; | |
| 303 | - | goto alloc_req_err; | |
| 303 | + | goto prepare_err; | |
| 304 | 304 | } | |
| 305 | 305 | ||
| 306 | 306 | desc->callback_param = req; | |
| @@ -319,9 +319,6 @@ static int emac_dma_inblk_32bit(struct emac_board_info *db, | |||
| 319 | 319 | submit_err: | |
| 320 | 320 | emac_free_dma_req(req); | |
| 321 | 321 | ||
| 322 | - | alloc_req_err: | |
| 323 | - | dmaengine_desc_free(desc); | |
| 324 | - | ||
| 325 | 322 | prepare_err: | |
| 326 | 323 | dma_unmap_single(db->dev, rxbuf, count, DMA_FROM_DEVICE); | |
| 327 | 324 | return ret; | |
modified drivers/net/ethernet/broadcom/bcmsysport.c
| @@ -391,8 +391,10 @@ static void bcm_sysport_update_mib_counters(struct bcm_sysport_priv *priv) | |||
| 391 | 391 | if (priv->is_lite) | |
| 392 | 392 | continue; | |
| 393 | 393 | ||
| 394 | - | if (s->type != BCM_SYSPORT_STAT_MIB_RX) | |
| 394 | + | if (s->type == BCM_SYSPORT_STAT_MIB_TX) | |
| 395 | 395 | offset = UMAC_MIB_STAT_OFFSET; | |
| 396 | + | else if (s->type == BCM_SYSPORT_STAT_RUNT) | |
| 397 | + | offset = 2 * UMAC_MIB_STAT_OFFSET; | |
| 396 | 398 | val = umac_readl(priv, UMAC_MIB_START + j + offset); | |
| 397 | 399 | break; | |
| 398 | 400 | case BCM_SYSPORT_STAT_RXCHK: | |
| @@ -482,10 +484,10 @@ static void bcm_sysport_get_stats(struct net_device *dev, | |||
| 482 | 484 | s->type == BCM_SYSPORT_STAT_NETDEV64) { | |
| 483 | 485 | do { | |
| 484 | 486 | start = u64_stats_fetch_begin(syncp); | |
| 485 | - | data[i] = *(u64 *)p; | |
| 487 | + | data[j] = *(u64 *)p; | |
| 486 | 488 | } while (u64_stats_fetch_retry(syncp, start)); | |
| 487 | 489 | } else | |
| 488 | - | data[i] = *(u32 *)p; | |
| 490 | + | data[j] = *(u32 *)p; | |
| 489 | 491 | j++; | |
| 490 | 492 | } | |
| 491 | 493 | ||
modified drivers/net/ethernet/broadcom/bnxt/bnxt.c
| @@ -486,7 +486,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 486 | 486 | struct netdev_queue *txq; | |
| 487 | 487 | int i; | |
| 488 | 488 | dma_addr_t mapping; | |
| 489 | - | unsigned int length, pad = 0; | |
| 489 | + | unsigned int length; | |
| 490 | 490 | u32 len, free_size, vlan_tag_flags, cfa_action, flags; | |
| 491 | 491 | struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; | |
| 492 | 492 | struct pci_dev *pdev = bp->pdev; | |
| @@ -536,6 +536,16 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 536 | 536 | return rc < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK; | |
| 537 | 537 | } | |
| 538 | 538 | ||
| 539 | + | /* Pad after the SW USO branch: bnxt_sw_udp_gso_xmit() would | |
| 540 | + | * otherwise account the padding as UDP payload. | |
| 541 | + | * Must be done before skb_shinfo(skb)->nr_frags is sampled, | |
| 542 | + | * because skb_put_padto() might linearize the skb. | |
| 543 | + | */ | |
| 544 | + | if (skb_put_padto(skb, BNXT_MIN_PKT_SIZE)) { | |
| 545 | + | /* SKB already freed. */ | |
| 546 | + | goto tx_kick_pending; | |
| 547 | + | } | |
| 548 | + | ||
| 539 | 549 | free_size = bnxt_tx_avail(bp, txr); | |
| 540 | 550 | if (unlikely(free_size < skb_shinfo(skb)->nr_frags + 2)) { | |
| 541 | 551 | /* We must have raced with NAPI cleanup */ | |
| @@ -672,14 +682,6 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 672 | 682 | } | |
| 673 | 683 | ||
| 674 | 684 | normal_tx: | |
| 675 | - | if (length < BNXT_MIN_PKT_SIZE) { | |
| 676 | - | pad = BNXT_MIN_PKT_SIZE - length; | |
| 677 | - | if (skb_pad(skb, pad)) | |
| 678 | - | /* SKB already freed. */ | |
| 679 | - | goto tx_kick_pending; | |
| 680 | - | length = BNXT_MIN_PKT_SIZE; | |
| 681 | - | } | |
| 682 | - | ||
| 683 | 685 | mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE); | |
| 684 | 686 | ||
| 685 | 687 | if (unlikely(dma_mapping_error(&pdev->dev, mapping))) | |
| @@ -759,10 +761,7 @@ normal_tx: | |||
| 759 | 761 | txbd->tx_bd_len_flags_type = cpu_to_le32(flags); | |
| 760 | 762 | } | |
| 761 | 763 | ||
| 762 | - | flags &= ~TX_BD_LEN; | |
| 763 | - | txbd->tx_bd_len_flags_type = | |
| 764 | - | cpu_to_le32(((len + pad) << TX_BD_LEN_SHIFT) | flags | | |
| 765 | - | TX_BD_FLAGS_PACKET_END); | |
| 764 | + | txbd->tx_bd_len_flags_type |= cpu_to_le32(TX_BD_FLAGS_PACKET_END); | |
| 766 | 765 | ||
| 767 | 766 | netdev_tx_sent_queue(txq, skb->len); | |
| 768 | 767 | ||
| @@ -15547,7 +15546,7 @@ static void bnxt_fw_reset_task(struct work_struct *work) | |||
| 15547 | 15546 | if (test_and_clear_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state) && | |
| 15548 | 15547 | !test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) | |
| 15549 | 15548 | bnxt_dl_remote_reload(bp); | |
| 15550 | - | if (pci_enable_device(bp->pdev)) { | |
| 15549 | + | if (!pci_is_enabled(bp->pdev) && pci_enable_device(bp->pdev)) { | |
| 15551 | 15550 | netdev_err(bp->dev, "Cannot re-enable PCI device\n"); | |
| 15552 | 15551 | rc = -ENODEV; | |
| 15553 | 15552 | goto fw_reset_abort; | |
| @@ -17111,6 +17110,51 @@ void bnxt_print_device_info(struct bnxt *bp) | |||
| 17111 | 17110 | pcie_print_link_status(bp->pdev); | |
| 17112 | 17111 | } | |
| 17113 | 17112 | ||
| 17113 | + | static void bnxt_clear_bars(struct pci_dev *pdev) | |
| 17114 | + | { | |
| 17115 | + | int off; | |
| 17116 | + | ||
| 17117 | + | for (off = PCI_BASE_ADDRESS_0; off <= PCI_BASE_ADDRESS_5; off += 4) | |
| 17118 | + | pci_write_config_dword(pdev, off, 0); | |
| 17119 | + | } | |
| 17120 | + | ||
| 17121 | + | /* Clear any pending DMA transactions from crash kernel while loading driver in | |
| 17122 | + | * capture kernel. | |
| 17123 | + | */ | |
| 17124 | + | static int bnxt_kdump_reset(struct pci_dev *pdev) | |
| 17125 | + | { | |
| 17126 | + | int rc, i; | |
| 17127 | + | u16 cmd; | |
| 17128 | + | ||
| 17129 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17130 | + | cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); | |
| 17131 | + | pci_write_config_word(pdev, PCI_COMMAND, cmd); | |
| 17132 | + | ||
| 17133 | + | if (pci_save_state(pdev)) | |
| 17134 | + | dev_warn(&pdev->dev, "Failed to save PCI state, PCI restore may be incomplete\n"); | |
| 17135 | + | ||
| 17136 | + | rc = pcie_flr(pdev); | |
| 17137 | + | if (rc) | |
| 17138 | + | dev_warn(&pdev->dev, "pcie_flr() failed (rc: %d), trying to continue\n", | |
| 17139 | + | rc); | |
| 17140 | + | ||
| 17141 | + | /* In case device is not returning CRS, wait 5 seconds longer */ | |
| 17142 | + | for (i = 0; i < 50; i++) { | |
| 17143 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17144 | + | if (!PCI_POSSIBLE_ERROR(cmd)) | |
| 17145 | + | break; | |
| 17146 | + | msleep(100); | |
| 17147 | + | } | |
| 17148 | + | if (PCI_POSSIBLE_ERROR(cmd)) { | |
| 17149 | + | dev_err(&pdev->dev, "PCI config space inaccessible after FLR, aborting\n"); | |
| 17150 | + | return -ENODEV; | |
| 17151 | + | } | |
| 17152 | + | ||
| 17153 | + | bnxt_clear_bars(pdev); | |
| 17154 | + | pci_restore_state(pdev); | |
| 17155 | + | return 0; | |
| 17156 | + | } | |
| 17157 | + | ||
| 17114 | 17158 | static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |
| 17115 | 17159 | { | |
| 17116 | 17160 | struct bnxt_hw_resc *hw_resc; | |
| @@ -17126,12 +17170,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 17126 | 17170 | return -ENODEV; | |
| 17127 | 17171 | } | |
| 17128 | 17172 | ||
| 17129 | - | /* Clear any pending DMA transactions from crash kernel | |
| 17130 | - | * while loading driver in capture kernel. | |
| 17131 | - | */ | |
| 17132 | 17173 | if (is_kdump_kernel()) { | |
| 17133 | - | pci_clear_master(pdev); | |
| 17134 | - | pcie_flr(pdev); | |
| 17174 | + | rc = bnxt_kdump_reset(pdev); | |
| 17175 | + | if (rc) | |
| 17176 | + | return rc; | |
| 17135 | 17177 | } | |
| 17136 | 17178 | ||
| 17137 | 17179 | max_irqs = bnxt_get_max_irq(pdev); | |
| @@ -17565,10 +17607,8 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev, | |||
| 17565 | 17607 | * so we disable bus master to prevent any potential bad DMAs before | |
| 17566 | 17608 | * freeing kernel memory. | |
| 17567 | 17609 | */ | |
| 17568 | - | if (state == pci_channel_io_frozen) { | |
| 17569 | - | set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); | |
| 17610 | + | if (state == pci_channel_io_frozen) | |
| 17570 | 17611 | bnxt_fw_fatal_close(bp); | |
| 17571 | - | } | |
| 17572 | 17612 | ||
| 17573 | 17613 | if (netif_running(netdev)) | |
| 17574 | 17614 | __bnxt_close_nic(bp, true, true); | |
| @@ -17598,69 +17638,80 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev) | |||
| 17598 | 17638 | struct bnxt *bp = netdev_priv(netdev); | |
| 17599 | 17639 | int retry = 0; | |
| 17600 | 17640 | int err = 0; | |
| 17601 | - | int off; | |
| 17641 | + | u16 cmd; | |
| 17602 | 17642 | ||
| 17603 | 17643 | netdev_info(bp->dev, "PCI Slot Reset\n"); | |
| 17604 | 17644 | ||
| 17605 | - | if (test_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state)) { | |
| 17606 | - | /* After DPC, the chip should return CRS when the vendor ID | |
| 17607 | - | * config register is read until it is ready. On all chips, | |
| 17608 | - | * this is not happening reliably so add a 5-second delay as a | |
| 17609 | - | * workaround. | |
| 17610 | - | */ | |
| 17611 | - | msleep(5000); | |
| 17612 | - | } | |
| 17645 | + | /* After a PCIe hot reset, the chip should return CRS when the | |
| 17646 | + | * vendor ID config register is read until it is ready. On all | |
| 17647 | + | * chips, this is not happening reliably so add a 5-second delay | |
| 17648 | + | * as a workaround. | |
| 17649 | + | */ | |
| 17650 | + | msleep(5000); | |
| 17613 | 17651 | ||
| 17614 | 17652 | netdev_lock(netdev); | |
| 17615 | 17653 | ||
| 17616 | - | if (pci_enable_device(pdev)) { | |
| 17654 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17655 | + | if (PCI_POSSIBLE_ERROR(cmd)) { | |
| 17617 | 17656 | dev_err(&pdev->dev, | |
| 17618 | - | "Cannot re-enable PCI device after reset.\n"); | |
| 17619 | - | } else { | |
| 17620 | - | pci_set_master(pdev); | |
| 17621 | - | /* Upon fatal error, our device internal logic that latches to | |
| 17622 | - | * BAR value is getting reset and will restore only upon | |
| 17623 | - | * rewriting the BARs. | |
| 17624 | - | * | |
| 17625 | - | * As pci_restore_state() does not re-write the BARs if the | |
| 17626 | - | * value is same as saved value earlier, driver needs to | |
| 17627 | - | * write the BARs to 0 to force restore, in case of fatal error. | |
| 17628 | - | */ | |
| 17629 | - | if (test_and_clear_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, | |
| 17630 | - | &bp->state)) { | |
| 17631 | - | for (off = PCI_BASE_ADDRESS_0; | |
| 17632 | - | off <= PCI_BASE_ADDRESS_5; off += 4) | |
| 17633 | - | pci_write_config_dword(bp->pdev, off, 0); | |
| 17634 | - | } | |
| 17635 | - | pci_restore_state(pdev); | |
| 17657 | + | "PCI config space inaccessible after reset\n"); | |
| 17658 | + | goto reset_exit; | |
| 17659 | + | } | |
| 17636 | 17660 | ||
| 17637 | - | bnxt_inv_fw_health_reg(bp); | |
| 17638 | - | bnxt_try_map_fw_health_reg(bp); | |
| 17661 | + | /* Upon PCIe error, our device internal logic that latches to | |
| 17662 | + | * BAR value is getting reset and will restore only upon | |
| 17663 | + | * rewriting the BARs. | |
| 17664 | + | * | |
| 17665 | + | * As pci_restore_state() does not re-write the BARs if the | |
| 17666 | + | * value is same as saved value earlier, driver needs to | |
| 17667 | + | * write the BARs to 0 to force restore. | |
| 17668 | + | */ | |
| 17669 | + | pci_clear_master(pdev); | |
| 17670 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17671 | + | cmd &= ~PCI_COMMAND_MEMORY; | |
| 17672 | + | pci_write_config_word(pdev, PCI_COMMAND, cmd); | |
| 17639 | 17673 | ||
| 17640 | - | /* In some PCIe AER scenarios, firmware may take up to | |
| 17641 | - | * 10 seconds to become ready in the worst case. | |
| 17642 | - | */ | |
| 17643 | - | do { | |
| 17644 | - | err = bnxt_try_recover_fw(bp); | |
| 17645 | - | if (!err) | |
| 17646 | - | break; | |
| 17647 | - | retry++; | |
| 17648 | - | } while (retry < BNXT_FW_SLOT_RESET_RETRY); | |
| 17674 | + | bnxt_clear_bars(pdev); | |
| 17675 | + | pci_restore_state(pdev); | |
| 17649 | 17676 | ||
| 17650 | - | if (err) { | |
| 17651 | - | dev_err(&pdev->dev, "Firmware not ready\n"); | |
| 17652 | - | goto reset_exit; | |
| 17677 | + | if (!pci_is_enabled(pdev) && pci_enable_device(pdev)) { | |
| 17678 | + | dev_err(&pdev->dev, | |
| 17679 | + | "Cannot re-enable PCI device after reset.\n"); | |
| 17680 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17681 | + | if (!PCI_POSSIBLE_ERROR(cmd)) { | |
| 17682 | + | cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); | |
| 17683 | + | pci_write_config_word(pdev, PCI_COMMAND, cmd); | |
| 17653 | 17684 | } | |
| 17685 | + | goto reset_exit; | |
| 17686 | + | } | |
| 17687 | + | pci_set_master(pdev); | |
| 17654 | 17688 | ||
| 17655 | - | err = bnxt_hwrm_func_reset(bp); | |
| 17689 | + | bnxt_inv_fw_health_reg(bp); | |
| 17690 | + | bnxt_try_map_fw_health_reg(bp); | |
| 17691 | + | ||
| 17692 | + | /* In some PCIe AER scenarios, firmware may take up to | |
| 17693 | + | * 10 seconds to become ready in the worst case. | |
| 17694 | + | */ | |
| 17695 | + | do { | |
| 17696 | + | err = bnxt_try_recover_fw(bp); | |
| 17656 | 17697 | if (!err) | |
| 17657 | - | result = PCI_ERS_RESULT_RECOVERED; | |
| 17698 | + | break; | |
| 17699 | + | retry++; | |
| 17700 | + | } while (retry < BNXT_FW_SLOT_RESET_RETRY); | |
| 17658 | 17701 | ||
| 17659 | - | /* IRQ will be initialized later in bnxt_io_resume */ | |
| 17660 | - | bnxt_ulp_irq_stop(bp); | |
| 17661 | - | bnxt_clear_int_mode(bp); | |
| 17702 | + | if (err) { | |
| 17703 | + | dev_err(&pdev->dev, "Firmware not ready\n"); | |
| 17704 | + | goto reset_exit; | |
| 17662 | 17705 | } | |
| 17663 | 17706 | ||
| 17707 | + | err = bnxt_hwrm_func_reset(bp); | |
| 17708 | + | if (!err) | |
| 17709 | + | result = PCI_ERS_RESULT_RECOVERED; | |
| 17710 | + | ||
| 17711 | + | /* IRQ will be initialized later in bnxt_io_resume */ | |
| 17712 | + | bnxt_ulp_irq_stop(bp); | |
| 17713 | + | bnxt_clear_int_mode(bp); | |
| 17714 | + | ||
| 17664 | 17715 | reset_exit: | |
| 17665 | 17716 | clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); | |
| 17666 | 17717 | bnxt_clear_reservations(bp, true); | |
modified drivers/net/ethernet/broadcom/bnxt/bnxt.h
| @@ -2468,7 +2468,6 @@ struct bnxt { | |||
| 2468 | 2468 | #define BNXT_STATE_ABORT_ERR 5 | |
| 2469 | 2469 | #define BNXT_STATE_FW_FATAL_COND 6 | |
| 2470 | 2470 | #define BNXT_STATE_DRV_REGISTERED 7 | |
| 2471 | - | #define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8 | |
| 2472 | 2471 | #define BNXT_STATE_NAPI_DISABLED 9 | |
| 2473 | 2472 | #define BNXT_STATE_FW_ACTIVATE 11 | |
| 2474 | 2473 | #define BNXT_STATE_RECOVER 12 | |
modified drivers/net/ethernet/broadcom/genet/bcmgenet.c
| @@ -57,6 +57,9 @@ | |||
| 57 | 57 | */ | |
| 58 | 58 | #define GENET_RSB_PAD (sizeof(struct status_64) + 2) | |
| 59 | 59 | ||
| 60 | + | /* RX buffer plus the skb_shared_info napi_build_skb() places behind it */ | |
| 61 | + | #define GENET_RX_BUF_SIZE SKB_HEAD_ALIGN(RX_BUF_LENGTH) | |
| 62 | + | ||
| 60 | 63 | /* Tx/Rx DMA register offset, skip 256 descriptors */ | |
| 61 | 64 | #define WORDS_PER_BD(p) (p->hw_params->words_per_bd) | |
| 62 | 65 | #define DMA_DESC_SIZE (WORDS_PER_BD(priv) * sizeof(u32)) | |
| @@ -2254,11 +2257,12 @@ static int bcmgenet_rx_refill(struct bcmgenet_rx_ring *ring, | |||
| 2254 | 2257 | struct enet_cb *cb) | |
| 2255 | 2258 | { | |
| 2256 | 2259 | struct bcmgenet_priv *priv = ring->priv; | |
| 2260 | + | unsigned int size = GENET_RX_BUF_SIZE; | |
| 2261 | + | unsigned int offset; | |
| 2257 | 2262 | dma_addr_t mapping; | |
| 2258 | 2263 | struct page *page; | |
| 2259 | 2264 | ||
| 2260 | - | page = page_pool_alloc_pages(ring->page_pool, | |
| 2261 | - | GFP_ATOMIC); | |
| 2265 | + | page = page_pool_dev_alloc(ring->page_pool, &offset, &size); | |
| 2262 | 2266 | if (!page) { | |
| 2263 | 2267 | priv->mib.alloc_rx_buff_failed++; | |
| 2264 | 2268 | netif_err(priv, rx_err, priv->dev, | |
| @@ -2267,9 +2271,13 @@ static int bcmgenet_rx_refill(struct bcmgenet_rx_ring *ring, | |||
| 2267 | 2271 | } | |
| 2268 | 2272 | ||
| 2269 | 2273 | /* page_pool handles DMA mapping via PP_FLAG_DMA_MAP */ | |
| 2270 | - | mapping = page_pool_get_dma_addr(page); | |
| 2274 | + | mapping = page_pool_get_dma_addr(page) + offset; | |
| 2275 | + | dma_sync_single_for_device(&priv->pdev->dev, mapping, RX_BUF_LENGTH, | |
| 2276 | + | DMA_FROM_DEVICE); | |
| 2271 | 2277 | ||
| 2272 | 2278 | cb->rx_page = page; | |
| 2279 | + | cb->rx_offset = offset; | |
| 2280 | + | cb->rx_size = size; | |
| 2273 | 2281 | dmadesc_set_addr(priv, cb->bd_addr, mapping); | |
| 2274 | 2282 | ||
| 2275 | 2283 | return 0; | |
| @@ -2323,6 +2331,7 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, | |||
| 2323 | 2331 | ||
| 2324 | 2332 | while ((rxpktprocessed < rxpkttoprocess) && | |
| 2325 | 2333 | (rxpktprocessed < budget)) { | |
| 2334 | + | unsigned int rx_offset, rx_size; | |
| 2326 | 2335 | struct status_64 *status; | |
| 2327 | 2336 | struct page *rx_page; | |
| 2328 | 2337 | void *hard_start; | |
| @@ -2332,6 +2341,8 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, | |||
| 2332 | 2341 | ||
| 2333 | 2342 | /* Save the received page before refilling */ | |
| 2334 | 2343 | rx_page = cb->rx_page; | |
| 2344 | + | rx_offset = cb->rx_offset; | |
| 2345 | + | rx_size = cb->rx_size; | |
| 2335 | 2346 | ||
| 2336 | 2347 | if (bcmgenet_rx_refill(ring, cb)) { | |
| 2337 | 2348 | BCMGENET_STATS64_INC(stats, dropped); | |
| @@ -2341,10 +2352,10 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, | |||
| 2341 | 2352 | /* Sync the full buffer; the HW may have written anywhere | |
| 2342 | 2353 | * up to RX_BUF_LENGTH. | |
| 2343 | 2354 | */ | |
| 2344 | - | page_pool_dma_sync_for_cpu(ring->page_pool, rx_page, 0, | |
| 2355 | + | page_pool_dma_sync_for_cpu(ring->page_pool, rx_page, rx_offset, | |
| 2345 | 2356 | RX_BUF_LENGTH); | |
| 2346 | 2357 | ||
| 2347 | - | hard_start = page_address(rx_page); | |
| 2358 | + | hard_start = page_address(rx_page) + rx_offset; | |
| 2348 | 2359 | status = (struct status_64 *)hard_start; | |
| 2349 | 2360 | dma_length_status = status->length_status; | |
| 2350 | 2361 | ||
| @@ -2410,7 +2421,7 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, | |||
| 2410 | 2421 | /* Build SKB from the page - data starts at hard_start, | |
| 2411 | 2422 | * frame begins after RSB(64) + pad(2) = 66 bytes. | |
| 2412 | 2423 | */ | |
| 2413 | - | skb = napi_build_skb(hard_start, PAGE_SIZE); | |
| 2424 | + | skb = napi_build_skb(hard_start, rx_size); | |
| 2414 | 2425 | if (unlikely(!skb)) { | |
| 2415 | 2426 | BCMGENET_STATS64_INC(stats, dropped); | |
| 2416 | 2427 | page_pool_put_full_page(ring->page_pool, rx_page, | |
| @@ -2762,14 +2773,16 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_priv *priv, | |||
| 2762 | 2773 | static int bcmgenet_rx_ring_create_pool(struct bcmgenet_priv *priv, | |
| 2763 | 2774 | struct bcmgenet_rx_ring *ring) | |
| 2764 | 2775 | { | |
| 2776 | + | /* Buffers share a page. bcmgenet_rx_refill() syncs each one for the | |
| 2777 | + | * device, PP_FLAG_DMA_SYNC_DEV would sync the whole page. | |
| 2778 | + | */ | |
| 2765 | 2779 | struct page_pool_params pp_params = { | |
| 2766 | 2780 | .order = 0, | |
| 2767 | - | .flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV, | |
| 2781 | + | .flags = PP_FLAG_DMA_MAP, | |
| 2768 | 2782 | .pool_size = ring->size, | |
| 2769 | 2783 | .nid = NUMA_NO_NODE, | |
| 2770 | 2784 | .dev = &priv->pdev->dev, | |
| 2771 | 2785 | .dma_dir = DMA_FROM_DEVICE, | |
| 2772 | - | .max_len = RX_BUF_LENGTH, | |
| 2773 | 2786 | }; | |
| 2774 | 2787 | int err; | |
| 2775 | 2788 | ||
| @@ -4138,8 +4151,11 @@ static int bcmgenet_probe(struct platform_device *pdev) | |||
| 4138 | 4151 | netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1); | |
| 4139 | 4152 | ||
| 4140 | 4153 | /* Set default coalescing parameters */ | |
| 4141 | - | for (i = 0; i <= priv->hw_params->rx_queues; i++) | |
| 4154 | + | for (i = 0; i <= priv->hw_params->rx_queues; i++) { | |
| 4155 | + | priv->rx_rings[i].priv = priv; | |
| 4156 | + | priv->rx_rings[i].index = i; | |
| 4142 | 4157 | priv->rx_rings[i].rx_max_coalesced_frames = 1; | |
| 4158 | + | } | |
| 4143 | 4159 | ||
| 4144 | 4160 | /* Initialize u64 stats seq counter for 32bit machines */ | |
| 4145 | 4161 | for (i = 0; i <= GENET_MAX_MQ_CNT; i++) { | |
modified drivers/net/ethernet/broadcom/genet/bcmgenet.h
| @@ -470,6 +470,8 @@ struct bcmgenet_rx_stats64 { | |||
| 470 | 470 | struct enet_cb { | |
| 471 | 471 | struct sk_buff *skb; | |
| 472 | 472 | struct page *rx_page; | |
| 473 | + | unsigned int rx_offset; | |
| 474 | + | unsigned int rx_size; | |
| 473 | 475 | void __iomem *bd_addr; | |
| 474 | 476 | DEFINE_DMA_UNMAP_ADDR(dma_addr); | |
| 475 | 477 | DEFINE_DMA_UNMAP_LEN(dma_len); | |
modified drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
| @@ -253,6 +253,17 @@ int bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv, | |||
| 253 | 253 | reg = bcmgenet_umac_readl(priv, UMAC_CMD); | |
| 254 | 254 | reg &= ~CMD_CRC_FWD; | |
| 255 | 255 | bcmgenet_umac_writel(priv, reg, UMAC_CMD); | |
| 256 | + | ||
| 257 | + | /* | |
| 258 | + | * Mirror wol_power_down_cfg(). If only UMAC_RX | |
| 259 | + | * is enabled, then we must place the UMAC back | |
| 260 | + | * into SW_RESET. | |
| 261 | + | */ | |
| 262 | + | reg = bcmgenet_umac_readl(priv, UMAC_CMD); | |
| 263 | + | if ((reg & CMD_RX_EN) && !(reg & CMD_TX_EN)) { | |
| 264 | + | reg |= CMD_SW_RESET; | |
| 265 | + | bcmgenet_umac_writel(priv, reg, UMAC_CMD); | |
| 266 | + | } | |
| 256 | 267 | spin_unlock_bh(&priv->reg_lock); | |
| 257 | 268 | ||
| 258 | 269 | /* Resume link status tracking */ | |
modified drivers/net/ethernet/cadence/macb_main.c
| @@ -2421,34 +2421,40 @@ static inline int macb_clear_csum(struct sk_buff *skb) | |||
| 2421 | 2421 | return 0; | |
| 2422 | 2422 | } | |
| 2423 | 2423 | ||
| 2424 | + | static bool macb_needs_sw_fcs(struct sk_buff *skb, struct net_device *netdev) | |
| 2425 | + | { | |
| 2426 | + | return netdev->features & NETIF_F_HW_CSUM && | |
| 2427 | + | skb->ip_summed != CHECKSUM_PARTIAL && | |
| 2428 | + | !skb_shinfo(skb)->gso_size && !ptp_one_step_sync(skb); | |
| 2429 | + | } | |
| 2430 | + | ||
| 2424 | 2431 | /* Returns a negative errno, or the FCS bytes appended (0 or ETH_FCS_LEN). */ | |
| 2425 | - | static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *netdev) | |
| 2432 | + | static int macb_pad_and_fcs(struct sk_buff **skb, bool add_fcs) | |
| 2426 | 2433 | { | |
| 2427 | 2434 | bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb) || | |
| 2428 | 2435 | skb_is_nonlinear(*skb); | |
| 2429 | 2436 | int padlen = ETH_ZLEN - (*skb)->len; | |
| 2430 | 2437 | int tailroom = skb_tailroom(*skb); | |
| 2438 | + | bool shared = skb_shared(*skb); | |
| 2431 | 2439 | struct sk_buff *nskb; | |
| 2432 | 2440 | u32 fcs; | |
| 2433 | 2441 | ||
| 2434 | - | if (!(netdev->features & NETIF_F_HW_CSUM) || | |
| 2435 | - | !((*skb)->ip_summed != CHECKSUM_PARTIAL) || | |
| 2436 | - | skb_shinfo(*skb)->gso_size || ptp_one_step_sync(*skb)) | |
| 2442 | + | if (!add_fcs) | |
| 2437 | 2443 | return 0; | |
| 2438 | 2444 | ||
| 2439 | 2445 | if (padlen <= 0) { | |
| 2440 | - | /* FCS could be appeded to tailroom. */ | |
| 2441 | - | if (tailroom >= ETH_FCS_LEN) | |
| 2446 | + | /* FCS could be appended to tailroom. */ | |
| 2447 | + | if (!shared && !skb_is_nonlinear(*skb) && | |
| 2448 | + | tailroom >= ETH_FCS_LEN) | |
| 2442 | 2449 | goto add_fcs; | |
| 2443 | - | /* No room for FCS, need to reallocate skb. */ | |
| 2444 | - | else | |
| 2445 | - | padlen = ETH_FCS_LEN; | |
| 2450 | + | /* Reallocate with room for the FCS. */ | |
| 2451 | + | padlen = ETH_FCS_LEN; | |
| 2446 | 2452 | } else { | |
| 2447 | 2453 | /* Add room for FCS. */ | |
| 2448 | 2454 | padlen += ETH_FCS_LEN; | |
| 2449 | 2455 | } | |
| 2450 | 2456 | ||
| 2451 | - | if (cloned || tailroom < padlen) { | |
| 2457 | + | if (shared || cloned || tailroom < padlen) { | |
| 2452 | 2458 | nskb = skb_copy_expand(*skb, 0, padlen, GFP_ATOMIC); | |
| 2453 | 2459 | if (!nskb) | |
| 2454 | 2460 | return -ENOMEM; | |
| @@ -2481,27 +2487,15 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2481 | 2487 | unsigned int desc_cnt, nr_frags, frag_size, f; | |
| 2482 | 2488 | struct macb_queue *queue = &bp->queues[q]; | |
| 2483 | 2489 | netdev_tx_t ret = NETDEV_TX_OK; | |
| 2484 | - | unsigned int hdrlen; | |
| 2490 | + | unsigned int hdrlen, tx_len; | |
| 2491 | + | bool add_fcs, is_lso; | |
| 2485 | 2492 | unsigned long flags; | |
| 2486 | 2493 | int fcs_len; | |
| 2487 | - | bool is_lso; | |
| 2488 | - | ||
| 2489 | - | if (macb_clear_csum(skb)) { | |
| 2490 | - | dev_kfree_skb_any(skb); | |
| 2491 | - | return ret; | |
| 2492 | - | } | |
| 2493 | - | ||
| 2494 | - | fcs_len = macb_pad_and_fcs(&skb, netdev); | |
| 2495 | - | if (fcs_len < 0) { | |
| 2496 | - | dev_kfree_skb_any(skb); | |
| 2497 | - | return ret; | |
| 2498 | - | } | |
| 2499 | - | ||
| 2500 | - | if (macb_dma_ptp(bp) && | |
| 2501 | - | (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) | |
| 2502 | - | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; | |
| 2503 | 2494 | ||
| 2495 | + | add_fcs = macb_needs_sw_fcs(skb, netdev); | |
| 2504 | 2496 | is_lso = (skb_shinfo(skb)->gso_size != 0); | |
| 2497 | + | tx_len = add_fcs ? max_t(unsigned int, skb->len, ETH_ZLEN) + | |
| 2498 | + | ETH_FCS_LEN : skb->len; | |
| 2505 | 2499 | ||
| 2506 | 2500 | if (is_lso) { | |
| 2507 | 2501 | /* length of headers */ | |
| @@ -2515,8 +2509,11 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2515 | 2509 | /* if this is required, would need to copy to single buffer */ | |
| 2516 | 2510 | return NETDEV_TX_BUSY; | |
| 2517 | 2511 | } | |
| 2518 | - | } else | |
| 2512 | + | } else if (add_fcs) { | |
| 2513 | + | hdrlen = umin(tx_len, bp->max_tx_length); | |
| 2514 | + | } else { | |
| 2519 | 2515 | hdrlen = umin(skb_headlen(skb), bp->max_tx_length); | |
| 2516 | + | } | |
| 2520 | 2517 | ||
| 2521 | 2518 | #if defined(DEBUG) && defined(VERBOSE_DEBUG) | |
| 2522 | 2519 | netdev_vdbg(bp->netdev, | |
| @@ -2531,12 +2528,18 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2531 | 2528 | * socket buffer: skb fragments of jumbo frames may need to be | |
| 2532 | 2529 | * split into many buffer descriptors. | |
| 2533 | 2530 | */ | |
| 2534 | - | if (is_lso && (skb_headlen(skb) > hdrlen)) | |
| 2531 | + | if (add_fcs) { | |
| 2532 | + | /* macb_pad_and_fcs() linearizes the skb before adding the FCS. */ | |
| 2533 | + | desc_cnt = DIV_ROUND_UP(tx_len, bp->max_tx_length); | |
| 2534 | + | nr_frags = 0; | |
| 2535 | + | } else if (is_lso && (skb_headlen(skb) > hdrlen)) { | |
| 2535 | 2536 | /* extra header descriptor if also payload in first buffer */ | |
| 2536 | 2537 | desc_cnt = DIV_ROUND_UP((skb_headlen(skb) - hdrlen), bp->max_tx_length) + 1; | |
| 2537 | - | else | |
| 2538 | + | nr_frags = skb_shinfo(skb)->nr_frags; | |
| 2539 | + | } else { | |
| 2538 | 2540 | desc_cnt = DIV_ROUND_UP(skb_headlen(skb), bp->max_tx_length); | |
| 2539 | - | nr_frags = skb_shinfo(skb)->nr_frags; | |
| 2541 | + | nr_frags = skb_shinfo(skb)->nr_frags; | |
| 2542 | + | } | |
| 2540 | 2543 | for (f = 0; f < nr_frags; f++) { | |
| 2541 | 2544 | frag_size = skb_frag_size(&skb_shinfo(skb)->frags[f]); | |
| 2542 | 2545 | desc_cnt += DIV_ROUND_UP(frag_size, bp->max_tx_length); | |
| @@ -2554,6 +2557,21 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2554 | 2557 | goto unlock; | |
| 2555 | 2558 | } | |
| 2556 | 2559 | ||
| 2560 | + | if (macb_clear_csum(skb)) { | |
| 2561 | + | dev_kfree_skb_any(skb); | |
| 2562 | + | goto unlock; | |
| 2563 | + | } | |
| 2564 | + | ||
| 2565 | + | fcs_len = macb_pad_and_fcs(&skb, add_fcs); | |
| 2566 | + | if (fcs_len < 0) { | |
| 2567 | + | dev_kfree_skb_any(skb); | |
| 2568 | + | goto unlock; | |
| 2569 | + | } | |
| 2570 | + | ||
| 2571 | + | if (macb_dma_ptp(bp) && | |
| 2572 | + | (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) | |
| 2573 | + | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; | |
| 2574 | + | ||
| 2557 | 2575 | /* Map socket buffer for DMA transfer */ | |
| 2558 | 2576 | if (macb_tx_map(bp, queue, skb, hdrlen, fcs_len)) { | |
| 2559 | 2577 | dev_kfree_skb_any(skb); | |
modified drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
| @@ -389,7 +389,7 @@ static void chcr_ktls_dev_del(struct net_device *netdev, | |||
| 389 | 389 | cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan, | |
| 390 | 390 | tx_info->tid, tx_info->ip_family); | |
| 391 | 391 | ||
| 392 | - | xa_erase(&u_ctx->tid_list, tx_info->tid); | |
| 392 | + | xa_erase_bh(&u_ctx->tid_list, tx_info->tid); | |
| 393 | 393 | } | |
| 394 | 394 | ||
| 395 | 395 | port_stats = &tx_info->adap->ch_ktls_stats.ktls_port[tx_info->port_id]; | |
| @@ -577,7 +577,7 @@ free_tid: | |||
| 577 | 577 | cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan, | |
| 578 | 578 | tx_info->tid, tx_info->ip_family); | |
| 579 | 579 | ||
| 580 | - | xa_erase(&u_ctx->tid_list, tx_info->tid); | |
| 580 | + | xa_erase_bh(&u_ctx->tid_list, tx_info->tid); | |
| 581 | 581 | ||
| 582 | 582 | put_module: | |
| 583 | 583 | /* release module refcount */ | |
modified drivers/net/ethernet/google/gve/gve_main.c
| @@ -1708,17 +1708,17 @@ static int gve_xsk_pool_disable(struct net_device *dev, | |||
| 1708 | 1708 | } | |
| 1709 | 1709 | ||
| 1710 | 1710 | napi_rx = &priv->ntfy_blocks[priv->rx[qid].ntfy_id].napi; | |
| 1711 | - | napi_disable(napi_rx); /* make sure current rx poll is done */ | |
| 1711 | + | napi_disable_locked(napi_rx); /* make sure current rx poll is done */ | |
| 1712 | 1712 | ||
| 1713 | 1713 | tx_qid = gve_xdp_tx_queue_id(priv, qid); | |
| 1714 | 1714 | napi_tx = &priv->ntfy_blocks[priv->tx[tx_qid].ntfy_id].napi; | |
| 1715 | - | napi_disable(napi_tx); /* make sure current tx poll is done */ | |
| 1715 | + | napi_disable_locked(napi_tx); /* make sure current tx poll is done */ | |
| 1716 | 1716 | ||
| 1717 | 1717 | gve_unreg_xsk_pool(priv, qid); | |
| 1718 | 1718 | smp_mb(); /* Make sure it is visible to the workers on datapath */ | |
| 1719 | 1719 | ||
| 1720 | - | napi_enable(napi_rx); | |
| 1721 | - | napi_enable(napi_tx); | |
| 1720 | + | napi_enable_locked(napi_rx); | |
| 1721 | + | napi_enable_locked(napi_tx); | |
| 1722 | 1722 | if (gve_is_gqi(priv)) { | |
| 1723 | 1723 | if (gve_rx_work_pending(&priv->rx[qid])) | |
| 1724 | 1724 | napi_schedule(napi_rx); | |
modified drivers/net/ethernet/google/gve/gve_rx_dqo.c
| @@ -113,6 +113,12 @@ static void gve_rx_reset_ring_dqo(struct gve_priv *priv, int idx) | |||
| 113 | 113 | gve_free_to_page_pool(rx, bs, false); | |
| 114 | 114 | else | |
| 115 | 115 | gve_free_qpl_page_dqo(bs); | |
| 116 | + | ||
| 117 | + | if (gve_buf_state_is_allocated(rx, bs) && | |
| 118 | + | bs->xsk_buff) { | |
| 119 | + | xsk_buff_free(bs->xsk_buff); | |
| 120 | + | bs->xsk_buff = NULL; | |
| 121 | + | } | |
| 116 | 122 | } | |
| 117 | 123 | } | |
| 118 | 124 | ||
| @@ -836,7 +842,12 @@ static int gve_rx_dqo(struct napi_struct *napi, struct gve_rx_ring *rx, | |||
| 836 | 842 | } | |
| 837 | 843 | ||
| 838 | 844 | if (unlikely(compl_desc->rx_error)) { | |
| 839 | - | gve_free_buffer(rx, buf_state); | |
| 845 | + | if (buf_state->xsk_buff) { | |
| 846 | + | xsk_buff_free(buf_state->xsk_buff); | |
| 847 | + | gve_free_buf_state(rx, buf_state); | |
| 848 | + | } else { | |
| 849 | + | gve_free_buffer(rx, buf_state); | |
| 850 | + | } | |
| 840 | 851 | return -EINVAL; | |
| 841 | 852 | } | |
| 842 | 853 | ||
modified drivers/net/ethernet/google/gve/gve_tx_dqo.c
| @@ -595,25 +595,25 @@ static int gve_prep_tso(struct sk_buff *skb) | |||
| 595 | 595 | err = skb_cow_head(skb, 0); | |
| 596 | 596 | if (err < 0) | |
| 597 | 597 | return err; | |
| 598 | + | shinfo = skb_shinfo(skb); | |
| 598 | 599 | ||
| 599 | 600 | l4_start = skb_transport_offset(skb); | |
| 600 | 601 | paylen = skb->len - l4_start; | |
| 601 | 602 | ||
| 602 | - | switch (shinfo->gso_type) { | |
| 603 | - | case SKB_GSO_TCPV4: | |
| 604 | - | case SKB_GSO_TCPV6: | |
| 603 | + | /* gso_type is a bitmask: SKB_GSO_DODGY, SKB_GSO_TCP_ECN and | |
| 604 | + | * SKB_GSO_TCP_FIXEDID may be set alongside the protocol bit. | |
| 605 | + | */ | |
| 606 | + | if (shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { | |
| 605 | 607 | tcp = tcp_hdr(skb); | |
| 606 | 608 | csum_replace_by_diff(&tcp->check, | |
| 607 | 609 | (__force __wsum)htonl(paylen)); | |
| 608 | 610 | header_len = skb_tcp_all_headers(skb); | |
| 609 | - | break; | |
| 610 | - | case SKB_GSO_UDP_L4: | |
| 611 | + | } else if (shinfo->gso_type & SKB_GSO_UDP_L4) { | |
| 611 | 612 | udp = udp_hdr(skb); | |
| 612 | 613 | csum_replace_by_diff(&udp->check, | |
| 613 | 614 | (__force __wsum)htonl(paylen)); | |
| 614 | 615 | header_len = sizeof(struct udphdr) + l4_start; | |
| 615 | - | break; | |
| 616 | - | default: | |
| 616 | + | } else { | |
| 617 | 617 | return -EINVAL; | |
| 618 | 618 | } | |
| 619 | 619 | ||
modified drivers/net/ethernet/ibm/ibmveth.c
| @@ -553,10 +553,15 @@ static int ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter, | |||
| 553 | 553 | ||
| 554 | 554 | static void ibmveth_free_tx_ltb(struct ibmveth_adapter *adapter, int idx) | |
| 555 | 555 | { | |
| 556 | + | void *ptr = adapter->tx_ltb_ptr[idx]; | |
| 557 | + | ||
| 558 | + | if (!ptr) | |
| 559 | + | return; | |
| 560 | + | ||
| 561 | + | adapter->tx_ltb_ptr[idx] = NULL; | |
| 556 | 562 | dma_unmap_single(&adapter->vdev->dev, adapter->tx_ltb_dma[idx], | |
| 557 | 563 | adapter->tx_ltb_size, DMA_TO_DEVICE); | |
| 558 | - | kfree(adapter->tx_ltb_ptr[idx]); | |
| 559 | - | adapter->tx_ltb_ptr[idx] = NULL; | |
| 564 | + | kfree(ptr); | |
| 560 | 565 | } | |
| 561 | 566 | ||
| 562 | 567 | static int ibmveth_allocate_tx_ltb(struct ibmveth_adapter *adapter, int idx) | |
| @@ -667,7 +672,7 @@ static int ibmveth_open(struct net_device *netdev) | |||
| 667 | 672 | ||
| 668 | 673 | for (i = 0; i < netdev->real_num_tx_queues; i++) { | |
| 669 | 674 | if (ibmveth_allocate_tx_ltb(adapter, i)) | |
| 670 | - | goto out_free_tx_ltb; | |
| 675 | + | goto out_unmap_filter_list; | |
| 671 | 676 | } | |
| 672 | 677 | ||
| 673 | 678 | adapter->rx_queue.index = 0; | |
| @@ -718,10 +723,6 @@ static int ibmveth_open(struct net_device *netdev) | |||
| 718 | 723 | if (rc != 0) { | |
| 719 | 724 | netdev_err(netdev, "unable to request irq 0x%x, rc %d\n", | |
| 720 | 725 | netdev->irq, rc); | |
| 721 | - | do { | |
| 722 | - | lpar_rc = h_free_logical_lan(adapter->vdev->unit_address); | |
| 723 | - | } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY)); | |
| 724 | - | ||
| 725 | 726 | goto out_free_buffer_pools; | |
| 726 | 727 | } | |
| 727 | 728 | ||
| @@ -737,6 +738,9 @@ static int ibmveth_open(struct net_device *netdev) | |||
| 737 | 738 | return 0; | |
| 738 | 739 | ||
| 739 | 740 | out_free_buffer_pools: | |
| 741 | + | do { | |
| 742 | + | lpar_rc = h_free_logical_lan(adapter->vdev->unit_address); | |
| 743 | + | } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY)); | |
| 740 | 744 | while (--i >= 0) { | |
| 741 | 745 | if (adapter->rx_buff_pool[i].active) | |
| 742 | 746 | ibmveth_free_buffer_pool(adapter, | |
| @@ -746,10 +750,8 @@ out_unmap_filter_list: | |||
| 746 | 750 | dma_unmap_single(dev, adapter->filter_list_dma, 4096, | |
| 747 | 751 | DMA_BIDIRECTIONAL); | |
| 748 | 752 | ||
| 749 | - | out_free_tx_ltb: | |
| 750 | - | while (--i >= 0) { | |
| 753 | + | for (i = netdev->real_num_tx_queues - 1; i >= 0; i--) | |
| 751 | 754 | ibmveth_free_tx_ltb(adapter, i); | |
| 752 | - | } | |
| 753 | 755 | ||
| 754 | 756 | out_unmap_buffer_list: | |
| 755 | 757 | dma_unmap_single(dev, adapter->buffer_list_dma, 4096, | |
modified drivers/net/ethernet/intel/e1000e/netdev.c
| @@ -67,6 +67,13 @@ static const struct dmi_system_id disable_k1_list[] = { | |||
| 67 | 67 | DMI_MATCH(DMI_PRODUCT_NAME, "Dell Pro 16 Plus PB16250"), | |
| 68 | 68 | }, | |
| 69 | 69 | }, | |
| 70 | + | { | |
| 71 | + | .ident = "Lenovo ThinkPad P14s Gen 5", | |
| 72 | + | .matches = { | |
| 73 | + | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | |
| 74 | + | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad P14s Gen 5"), | |
| 75 | + | }, | |
| 76 | + | }, | |
| 70 | 77 | {} | |
| 71 | 78 | }; | |
| 72 | 79 | ||
modified drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
| @@ -4943,6 +4943,20 @@ out: | |||
| 4943 | 4943 | return ret; | |
| 4944 | 4944 | } | |
| 4945 | 4945 | ||
| 4946 | + | /** | |
| 4947 | + | * i40e_setup_vf_trust - Enable/disable VF trust mode without reset | |
| 4948 | + | * @vf: VF to configure | |
| 4949 | + | * @setting: trust setting | |
| 4950 | + | * | |
| 4951 | + | * Update VF flags when changing trust without performing a VF reset. | |
| 4952 | + | * This is only called when it's safe to skip the reset (VF has no advanced | |
| 4953 | + | * features configured that need cleanup). | |
| 4954 | + | */ | |
| 4955 | + | static void i40e_setup_vf_trust(struct i40e_vf *vf, bool setting) | |
| 4956 | + | { | |
| 4957 | + | assign_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps, setting); | |
| 4958 | + | } | |
| 4959 | + | ||
| 4946 | 4960 | /** | |
| 4947 | 4961 | * i40e_ndo_set_vf_trust | |
| 4948 | 4962 | * @netdev: network interface device structure of the pf | |
| @@ -4987,19 +5001,20 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting) | |||
| 4987 | 5001 | set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state); | |
| 4988 | 5002 | pf->vsi[vf->lan_vsi_idx]->flags |= I40E_VSI_FLAG_FILTER_CHANGED; | |
| 4989 | 5003 | ||
| 4990 | - | i40e_vc_reset_vf(vf, true); | |
| 5004 | + | /* Reset only if revoking trust and VF has advanced features configured */ | |
| 5005 | + | if (!setting && | |
| 5006 | + | (vf->adq_enabled || vf->num_cloud_filters > 0 || | |
| 5007 | + | test_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states) || | |
| 5008 | + | test_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states))) { | |
| 5009 | + | i40e_vc_reset_vf(vf, true); | |
| 5010 | + | i40e_del_all_cloud_filters(vf); | |
| 5011 | + | } else { | |
| 5012 | + | i40e_setup_vf_trust(vf, setting); | |
| 5013 | + | } | |
| 5014 | + | ||
| 4991 | 5015 | dev_info(&pf->pdev->dev, "VF %u is now %strusted\n", | |
| 4992 | 5016 | vf_id, setting ? "" : "un"); | |
| 4993 | 5017 | ||
| 4994 | - | if (vf->adq_enabled) { | |
| 4995 | - | if (!vf->trusted) { | |
| 4996 | - | dev_info(&pf->pdev->dev, | |
| 4997 | - | "VF %u no longer Trusted, deleting all cloud filters\n", | |
| 4998 | - | vf_id); | |
| 4999 | - | i40e_del_all_cloud_filters(vf); | |
| 5000 | - | } | |
| 5001 | - | } | |
| 5002 | - | ||
| 5003 | 5018 | out: | |
| 5004 | 5019 | clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); | |
| 5005 | 5020 | return ret; | |
modified drivers/net/ethernet/intel/iavf/iavf.h
| @@ -259,7 +259,6 @@ struct iavf_adapter { | |||
| 259 | 259 | struct work_struct adminq_task; | |
| 260 | 260 | struct work_struct finish_config; | |
| 261 | 261 | wait_queue_head_t down_waitqueue; | |
| 262 | - | wait_queue_head_t vc_waitqueue; | |
| 263 | 262 | struct iavf_q_vector *q_vectors; | |
| 264 | 263 | struct list_head vlan_filter_list; | |
| 265 | 264 | int num_vlan_filters; | |
| @@ -588,8 +587,9 @@ void iavf_configure_queues(struct iavf_adapter *adapter); | |||
| 588 | 587 | void iavf_enable_queues(struct iavf_adapter *adapter); | |
| 589 | 588 | void iavf_disable_queues(struct iavf_adapter *adapter); | |
| 590 | 589 | void iavf_map_queues(struct iavf_adapter *adapter); | |
| 591 | - | void iavf_add_ether_addrs(struct iavf_adapter *adapter); | |
| 590 | + | int iavf_add_ether_addrs(struct iavf_adapter *adapter); | |
| 592 | 591 | void iavf_del_ether_addrs(struct iavf_adapter *adapter); | |
| 592 | + | void iavf_mac_add_reject(struct iavf_adapter *adapter); | |
| 593 | 593 | void iavf_add_vlans(struct iavf_adapter *adapter); | |
| 594 | 594 | void iavf_del_vlans(struct iavf_adapter *adapter); | |
| 595 | 595 | void iavf_set_promiscuous(struct iavf_adapter *adapter); | |
| @@ -606,6 +606,13 @@ void iavf_disable_vlan_stripping(struct iavf_adapter *adapter); | |||
| 606 | 606 | void iavf_virtchnl_completion(struct iavf_adapter *adapter, | |
| 607 | 607 | enum virtchnl_ops v_opcode, | |
| 608 | 608 | enum iavf_status v_retval, u8 *msg, u16 msglen); | |
| 609 | + | int iavf_poll_virtchnl_response(struct iavf_adapter *adapter, | |
| 610 | + | struct iavf_arq_event_info *event, | |
| 611 | + | bool (*condition)(struct iavf_adapter *adapter, | |
| 612 | + | const void *data, | |
| 613 | + | enum virtchnl_ops v_op), | |
| 614 | + | const void *cond_data, | |
| 615 | + | unsigned int timeout_ms); | |
| 609 | 616 | int iavf_config_rss(struct iavf_adapter *adapter); | |
| 610 | 617 | void iavf_cfg_queues_bw(struct iavf_adapter *adapter); | |
| 611 | 618 | void iavf_cfg_queues_quanta_size(struct iavf_adapter *adapter); | |
modified drivers/net/ethernet/intel/iavf/iavf_main.c
| @@ -1029,6 +1029,60 @@ static bool iavf_is_mac_set_handled(struct net_device *netdev, | |||
| 1029 | 1029 | return ret; | |
| 1030 | 1030 | } | |
| 1031 | 1031 | ||
| 1032 | + | /** | |
| 1033 | + | * iavf_mac_change_done - Check if MAC change completed | |
| 1034 | + | * @adapter: board private structure | |
| 1035 | + | * @data: MAC address being checked (as const void *) | |
| 1036 | + | * @v_op: virtchnl opcode from processed message | |
| 1037 | + | * | |
| 1038 | + | * Callback for iavf_poll_virtchnl_response() to check if MAC change completed. | |
| 1039 | + | * | |
| 1040 | + | * Return: true if MAC change completed, false otherwise | |
| 1041 | + | */ | |
| 1042 | + | static bool iavf_mac_change_done(struct iavf_adapter *adapter, | |
| 1043 | + | const void *data, enum virtchnl_ops v_op) | |
| 1044 | + | { | |
| 1045 | + | const u8 *addr = data; | |
| 1046 | + | ||
| 1047 | + | return iavf_is_mac_set_handled(adapter->netdev, addr); | |
| 1048 | + | } | |
| 1049 | + | ||
| 1050 | + | /** | |
| 1051 | + | * iavf_set_mac_sync - Synchronously change MAC address | |
| 1052 | + | * @adapter: board private structure | |
| 1053 | + | * @addr: MAC address to set | |
| 1054 | + | * | |
| 1055 | + | * Send MAC change request to PF and poll admin queue for response. | |
| 1056 | + | * Caller must hold netdev_lock. This can sleep for up to 2.5 seconds. | |
| 1057 | + | * Event buffer is allocated before sending to avoid state mismatch if | |
| 1058 | + | * allocation fails after message is sent to PF. | |
| 1059 | + | * | |
| 1060 | + | * Return: 0 on success, negative on failure | |
| 1061 | + | */ | |
| 1062 | + | static int iavf_set_mac_sync(struct iavf_adapter *adapter, const u8 *addr) | |
| 1063 | + | { | |
| 1064 | + | struct iavf_arq_event_info event; | |
| 1065 | + | int ret; | |
| 1066 | + | ||
| 1067 | + | netdev_assert_locked(adapter->netdev); | |
| 1068 | + | ||
| 1069 | + | event.buf_len = IAVF_MAX_AQ_BUF_SIZE; | |
| 1070 | + | event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL); | |
| 1071 | + | if (!event.msg_buf) | |
| 1072 | + | return -ENOMEM; | |
| 1073 | + | ||
| 1074 | + | ret = iavf_add_ether_addrs(adapter); | |
| 1075 | + | if (ret) | |
| 1076 | + | goto out; | |
| 1077 | + | ||
| 1078 | + | ret = iavf_poll_virtchnl_response(adapter, &event, | |
| 1079 | + | iavf_mac_change_done, addr, 2500); | |
| 1080 | + | ||
| 1081 | + | out: | |
| 1082 | + | kfree(event.msg_buf); | |
| 1083 | + | return ret; | |
| 1084 | + | } | |
| 1085 | + | ||
| 1032 | 1086 | /** | |
| 1033 | 1087 | * iavf_set_mac - NDO callback to set port MAC address | |
| 1034 | 1088 | * @netdev: network interface device structure | |
| @@ -1046,25 +1100,23 @@ static int iavf_set_mac(struct net_device *netdev, void *p) | |||
| 1046 | 1100 | return -EADDRNOTAVAIL; | |
| 1047 | 1101 | ||
| 1048 | 1102 | ret = iavf_replace_primary_mac(adapter, addr->sa_data); | |
| 1049 | - | ||
| 1050 | 1103 | if (ret) | |
| 1051 | 1104 | return ret; | |
| 1052 | 1105 | ||
| 1053 | - | ret = wait_event_interruptible_timeout(adapter->vc_waitqueue, | |
| 1054 | - | iavf_is_mac_set_handled(netdev, addr->sa_data), | |
| 1055 | - | msecs_to_jiffies(2500)); | |
| 1056 | - | ||
| 1057 | - | /* If ret < 0 then it means wait was interrupted. | |
| 1058 | - | * If ret == 0 then it means we got a timeout. | |
| 1059 | - | * else it means we got response for set MAC from PF, | |
| 1060 | - | * check if netdev MAC was updated to requested MAC, | |
| 1061 | - | * if yes then set MAC succeeded otherwise it failed return -EACCES | |
| 1062 | - | */ | |
| 1063 | - | if (ret < 0) | |
| 1106 | + | ret = iavf_set_mac_sync(adapter, addr->sa_data); | |
| 1107 | + | if (ret) { | |
| 1108 | + | /* Rollback only if send failed (message never reached PF). | |
| 1109 | + | * Don't rollback on timeout (-EAGAIN) because the message was | |
| 1110 | + | * sent and PF will eventually respond. When the response arrives, | |
| 1111 | + | * iavf_virtchnl_completion() will handle rollback (on PF error) | |
| 1112 | + | * or acceptance (on PF success) automatically. | |
| 1113 | + | */ | |
| 1114 | + | if (ret != -EAGAIN) { | |
| 1115 | + | iavf_mac_add_reject(adapter); | |
| 1116 | + | ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr); | |
| 1117 | + | } | |
| 1064 | 1118 | return ret; | |
| 1065 | - | ||
| 1066 | - | if (!ret) | |
| 1067 | - | return -EAGAIN; | |
| 1119 | + | } | |
| 1068 | 1120 | ||
| 1069 | 1121 | if (!ether_addr_equal(netdev->dev_addr, addr->sa_data)) | |
| 1070 | 1122 | return -EACCES; | |
| @@ -5394,9 +5446,6 @@ static int iavf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 5394 | 5446 | /* Setup the wait queue for indicating transition to down status */ | |
| 5395 | 5447 | init_waitqueue_head(&adapter->down_waitqueue); | |
| 5396 | 5448 | ||
| 5397 | - | /* Setup the wait queue for indicating virtchannel events */ | |
| 5398 | - | init_waitqueue_head(&adapter->vc_waitqueue); | |
| 5399 | - | ||
| 5400 | 5449 | INIT_LIST_HEAD(&adapter->ptp.aq_cmds); | |
| 5401 | 5450 | init_waitqueue_head(&adapter->ptp.phc_time_waitqueue); | |
| 5402 | 5451 | mutex_init(&adapter->ptp.aq_cmd_lock); | |
modified drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | /* Copyright(c) 2013 - 2018 Intel Corporation. */ | |
| 3 | 3 | ||
| 4 | 4 | #include <linux/net/intel/libie/rx.h> | |
| 5 | + | #include <net/netdev_lock.h> | |
| 5 | 6 | ||
| 6 | 7 | #include "iavf.h" | |
| 7 | 8 | #include "iavf_ptp.h" | |
| @@ -555,20 +556,23 @@ iavf_set_mac_addr_type(struct virtchnl_ether_addr *virtchnl_ether_addr, | |||
| 555 | 556 | * @adapter: adapter structure | |
| 556 | 557 | * | |
| 557 | 558 | * Request that the PF add one or more addresses to our filters. | |
| 558 | - | **/ | |
| 559 | - | void iavf_add_ether_addrs(struct iavf_adapter *adapter) | |
| 559 | + | * | |
| 560 | + | * Return: 0 on success, negative on failure | |
| 561 | + | */ | |
| 562 | + | int iavf_add_ether_addrs(struct iavf_adapter *adapter) | |
| 560 | 563 | { | |
| 561 | 564 | struct virtchnl_ether_addr_list *veal; | |
| 562 | 565 | struct iavf_mac_filter *f; | |
| 563 | 566 | int i = 0, count = 0; | |
| 564 | 567 | bool more = false; | |
| 565 | 568 | size_t len; | |
| 569 | + | int ret; | |
| 566 | 570 | ||
| 567 | 571 | if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) { | |
| 568 | 572 | /* bail because we already have a command pending */ | |
| 569 | 573 | dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n", | |
| 570 | 574 | adapter->current_op); | |
| 571 | - | return; | |
| 575 | + | return -EBUSY; | |
| 572 | 576 | } | |
| 573 | 577 | ||
| 574 | 578 | spin_lock_bh(&adapter->mac_vlan_list_lock); | |
| @@ -580,7 +584,7 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter) | |||
| 580 | 584 | if (!count) { | |
| 581 | 585 | adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER; | |
| 582 | 586 | spin_unlock_bh(&adapter->mac_vlan_list_lock); | |
| 583 | - | return; | |
| 587 | + | return 0; | |
| 584 | 588 | } | |
| 585 | 589 | adapter->current_op = VIRTCHNL_OP_ADD_ETH_ADDR; | |
| 586 | 590 | ||
| @@ -594,8 +598,9 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter) | |||
| 594 | 598 | ||
| 595 | 599 | veal = kzalloc(len, GFP_ATOMIC); | |
| 596 | 600 | if (!veal) { | |
| 601 | + | adapter->current_op = VIRTCHNL_OP_UNKNOWN; | |
| 597 | 602 | spin_unlock_bh(&adapter->mac_vlan_list_lock); | |
| 598 | - | return; | |
| 603 | + | return -ENOMEM; | |
| 599 | 604 | } | |
| 600 | 605 | ||
| 601 | 606 | veal->vsi_id = adapter->vsi_res->vsi_id; | |
| @@ -615,8 +620,15 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter) | |||
| 615 | 620 | ||
| 616 | 621 | spin_unlock_bh(&adapter->mac_vlan_list_lock); | |
| 617 | 622 | ||
| 618 | - | iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len); | |
| 623 | + | ret = iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len); | |
| 619 | 624 | kfree(veal); | |
| 625 | + | if (ret) { | |
| 626 | + | dev_err(&adapter->pdev->dev, | |
| 627 | + | "Unable to send ADD_ETH_ADDR message to PF, error %d\n", ret); | |
| 628 | + | adapter->current_op = VIRTCHNL_OP_UNKNOWN; | |
| 629 | + | } | |
| 630 | + | ||
| 631 | + | return ret; | |
| 620 | 632 | } | |
| 621 | 633 | ||
| 622 | 634 | /** | |
| @@ -712,8 +724,8 @@ static void iavf_mac_add_ok(struct iavf_adapter *adapter) | |||
| 712 | 724 | * @adapter: adapter structure | |
| 713 | 725 | * | |
| 714 | 726 | * Remove filters from list based on PF response. | |
| 715 | - | **/ | |
| 716 | - | static void iavf_mac_add_reject(struct iavf_adapter *adapter) | |
| 727 | + | */ | |
| 728 | + | void iavf_mac_add_reject(struct iavf_adapter *adapter) | |
| 717 | 729 | { | |
| 718 | 730 | struct net_device *netdev = adapter->netdev; | |
| 719 | 731 | struct iavf_mac_filter *f, *ftmp; | |
| @@ -2364,7 +2376,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, | |||
| 2364 | 2376 | iavf_mac_add_reject(adapter); | |
| 2365 | 2377 | /* restore administratively set MAC address */ | |
| 2366 | 2378 | ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr); | |
| 2367 | - | wake_up(&adapter->vc_waitqueue); | |
| 2368 | 2379 | break; | |
| 2369 | 2380 | case VIRTCHNL_OP_DEL_ETH_ADDR: | |
| 2370 | 2381 | dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n", | |
| @@ -2555,7 +2566,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, | |||
| 2555 | 2566 | eth_hw_addr_set(netdev, adapter->hw.mac.addr); | |
| 2556 | 2567 | netif_addr_unlock_bh(netdev); | |
| 2557 | 2568 | } | |
| 2558 | - | wake_up(&adapter->vc_waitqueue); | |
| 2559 | 2569 | break; | |
| 2560 | 2570 | case VIRTCHNL_OP_GET_STATS: { | |
| 2561 | 2571 | struct iavf_eth_stats *stats = | |
| @@ -2950,3 +2960,72 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, | |||
| 2950 | 2960 | } /* switch v_opcode */ | |
| 2951 | 2961 | adapter->current_op = VIRTCHNL_OP_UNKNOWN; | |
| 2952 | 2962 | } | |
| 2963 | + | ||
| 2964 | + | /** | |
| 2965 | + | * iavf_poll_virtchnl_response - Poll admin queue for virtchnl response | |
| 2966 | + | * @adapter: adapter structure | |
| 2967 | + | * @event: pre-allocated event buffer to use for polling | |
| 2968 | + | * @condition: callback to check if desired response received | |
| 2969 | + | * @cond_data: context data passed to condition callback | |
| 2970 | + | * @timeout_ms: maximum time to wait in milliseconds | |
| 2971 | + | * | |
| 2972 | + | * Polls the admin queue and processes all incoming virtchnl messages. | |
| 2973 | + | * After processing each valid message, calls the condition callback to check | |
| 2974 | + | * if the expected response has been received. The callback receives the opcode | |
| 2975 | + | * of the processed message to identify which response was received. Continues | |
| 2976 | + | * polling until the callback returns true or timeout expires. | |
| 2977 | + | * | |
| 2978 | + | * Caller must allocate event buffer before sending any messages to PF to avoid | |
| 2979 | + | * state mismatch if allocation fails after message is sent. | |
| 2980 | + | * | |
| 2981 | + | * Caller must hold netdev_lock. This can sleep for up to timeout_ms while | |
| 2982 | + | * polling hardware. | |
| 2983 | + | * | |
| 2984 | + | * Return: 0 on success (condition met), -EAGAIN on timeout, or error code | |
| 2985 | + | */ | |
| 2986 | + | int iavf_poll_virtchnl_response(struct iavf_adapter *adapter, | |
| 2987 | + | struct iavf_arq_event_info *event, | |
| 2988 | + | bool (*condition)(struct iavf_adapter *adapter, | |
| 2989 | + | const void *data, | |
| 2990 | + | enum virtchnl_ops v_op), | |
| 2991 | + | const void *cond_data, | |
| 2992 | + | unsigned int timeout_ms) | |
| 2993 | + | { | |
| 2994 | + | struct iavf_hw *hw = &adapter->hw; | |
| 2995 | + | enum virtchnl_ops received_op; | |
| 2996 | + | unsigned long timeout; | |
| 2997 | + | int ret = -EAGAIN; | |
| 2998 | + | u16 pending = 0; | |
| 2999 | + | u32 v_retval; | |
| 3000 | + | ||
| 3001 | + | netdev_assert_locked(adapter->netdev); | |
| 3002 | + | ||
| 3003 | + | timeout = jiffies + msecs_to_jiffies(timeout_ms); | |
| 3004 | + | do { | |
| 3005 | + | if (!pending) | |
| 3006 | + | usleep_range(50, 75); | |
| 3007 | + | ||
| 3008 | + | if (iavf_clean_arq_element(hw, event, &pending) == IAVF_SUCCESS) { | |
| 3009 | + | received_op = (enum virtchnl_ops)le32_to_cpu(event->desc.cookie_high); | |
| 3010 | + | if (received_op != VIRTCHNL_OP_UNKNOWN) { | |
| 3011 | + | v_retval = le32_to_cpu(event->desc.cookie_low); | |
| 3012 | + | ||
| 3013 | + | iavf_virtchnl_completion(adapter, received_op, | |
| 3014 | + | (enum iavf_status)v_retval, | |
| 3015 | + | event->msg_buf, event->msg_len); | |
| 3016 | + | ||
| 3017 | + | if (condition(adapter, cond_data, received_op)) { | |
| 3018 | + | ret = 0; | |
| 3019 | + | break; | |
| 3020 | + | } | |
| 3021 | + | } | |
| 3022 | + | ||
| 3023 | + | memset(event->msg_buf, 0, IAVF_MAX_AQ_BUF_SIZE); | |
| 3024 | + | ||
| 3025 | + | if (pending) | |
| 3026 | + | continue; | |
| 3027 | + | } | |
| 3028 | + | } while (time_before(jiffies, timeout)); | |
| 3029 | + | ||
| 3030 | + | return ret; | |
| 3031 | + | } | |
modified drivers/net/ethernet/intel/ice/devlink/port.c
| @@ -590,8 +590,8 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port) | |||
| 590 | 590 | ||
| 591 | 591 | xa_erase(&pf->sf_nums, devlink_port->attrs.pci_sf.sf); | |
| 592 | 592 | ice_eswitch_detach_sf(pf, dyn_port); | |
| 593 | - | ice_vsi_free(dyn_port->vsi); | |
| 594 | 593 | xa_erase(&pf->dyn_ports, dyn_port->vsi->idx); | |
| 594 | + | ice_vsi_free(dyn_port->vsi); | |
| 595 | 595 | kfree(dyn_port); | |
| 596 | 596 | } | |
| 597 | 597 | ||
modified drivers/net/ethernet/intel/ice/ice_eswitch.c
| @@ -95,7 +95,7 @@ ice_eswitch_release_repr(struct ice_pf *pf, struct ice_repr *repr) | |||
| 95 | 95 | return; | |
| 96 | 96 | ||
| 97 | 97 | ice_vsi_update_security(vsi, ice_vsi_ctx_set_antispoof); | |
| 98 | - | metadata_dst_free(repr->dst); | |
| 98 | + | dst_release(&repr->dst->dst); | |
| 99 | 99 | repr->dst = NULL; | |
| 100 | 100 | ice_fltr_add_mac_and_broadcast(vsi, repr->parent_mac, | |
| 101 | 101 | ICE_FWD_TO_VSI); | |
modified drivers/net/ethernet/intel/ice/ice_sriov.c
| @@ -1366,6 +1366,20 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) | |||
| 1366 | 1366 | return __ice_set_vf_mac(ice_netdev_to_pf(netdev), vf_id, mac); | |
| 1367 | 1367 | } | |
| 1368 | 1368 | ||
| 1369 | + | /** | |
| 1370 | + | * ice_setup_vf_trust - Enable/disable VF trust mode without reset | |
| 1371 | + | * @vf: VF to configure | |
| 1372 | + | * @setting: trust setting | |
| 1373 | + | * | |
| 1374 | + | * Update VF flags when changing trust without performing a VF reset. | |
| 1375 | + | * This is only called when it's safe to skip the reset (VF has no advanced | |
| 1376 | + | * features configured that need cleanup). | |
| 1377 | + | */ | |
| 1378 | + | static void ice_setup_vf_trust(struct ice_vf *vf, bool setting) | |
| 1379 | + | { | |
| 1380 | + | assign_bit(ICE_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps, setting); | |
| 1381 | + | } | |
| 1382 | + | ||
| 1369 | 1383 | /** | |
| 1370 | 1384 | * ice_set_vf_trust | |
| 1371 | 1385 | * @netdev: network interface device structure | |
| @@ -1401,11 +1415,19 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted) | |||
| 1401 | 1415 | ||
| 1402 | 1416 | mutex_lock(&vf->cfg_lock); | |
| 1403 | 1417 | ||
| 1404 | - | while (!trusted && vf->num_mac_lldp) | |
| 1405 | - | ice_vf_update_mac_lldp_num(vf, ice_get_vf_vsi(vf), false); | |
| 1406 | - | ||
| 1407 | - | vf->trusted = trusted; | |
| 1408 | - | ice_reset_vf(vf, ICE_VF_RESET_NOTIFY); | |
| 1418 | + | /* Reset only if revoking trust and VF has advanced features configured */ | |
| 1419 | + | if (!trusted && | |
| 1420 | + | (vf->num_mac_lldp > 0 || | |
| 1421 | + | test_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states) || | |
| 1422 | + | test_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))) { | |
| 1423 | + | while (vf->num_mac_lldp) | |
| 1424 | + | ice_vf_update_mac_lldp_num(vf, ice_get_vf_vsi(vf), false); | |
| 1425 | + | vf->trusted = trusted; | |
| 1426 | + | ice_reset_vf(vf, ICE_VF_RESET_NOTIFY); | |
| 1427 | + | } else { | |
| 1428 | + | vf->trusted = trusted; | |
| 1429 | + | ice_setup_vf_trust(vf, trusted); | |
| 1430 | + | } | |
| 1409 | 1431 | dev_info(ice_pf_to_dev(pf), "VF %u is now %strusted\n", | |
| 1410 | 1432 | vf_id, trusted ? "" : "un"); | |
| 1411 | 1433 | ||
modified drivers/net/ethernet/intel/ice/ice_txrx.c
| @@ -1561,10 +1561,10 @@ ice_tx_map(struct ice_tx_ring *tx_ring, struct ice_tx_buf *first, | |||
| 1561 | 1561 | } | |
| 1562 | 1562 | } | |
| 1563 | 1563 | tstamp_ring->next_to_use = j; | |
| 1564 | - | writel_relaxed(j, tstamp_ring->tail); | |
| 1564 | + | writel(j, tstamp_ring->tail); | |
| 1565 | 1565 | } else { | |
| 1566 | 1566 | ring_kick: | |
| 1567 | - | writel_relaxed(i, tx_ring->tail); | |
| 1567 | + | writel(i, tx_ring->tail); | |
| 1568 | 1568 | } | |
| 1569 | 1569 | return; | |
| 1570 | 1570 | ||
modified drivers/net/ethernet/marvell/mvneta.c
| @@ -2340,7 +2340,7 @@ mvneta_swbm_rx_frame(struct mvneta_port *pp, | |||
| 2340 | 2340 | ||
| 2341 | 2341 | /* Prefetch header */ | |
| 2342 | 2342 | prefetch(data); | |
| 2343 | - | xdp_buff_clear_frags_flag(xdp); | |
| 2343 | + | xdp_reinit_buff(xdp); | |
| 2344 | 2344 | xdp_prepare_buff(xdp, data, pp->rx_offset_correction + MVNETA_MH_SIZE, | |
| 2345 | 2345 | data_len, true); | |
| 2346 | 2346 | } | |
modified drivers/net/ethernet/marvell/octeontx2/af/mcs.c
| @@ -314,7 +314,7 @@ int mcs_clear_all_stats(struct mcs *mcs, u16 pcifunc, int dir) | |||
| 314 | 314 | } | |
| 315 | 315 | ||
| 316 | 316 | /* Clear SC stats */ | |
| 317 | - | for (id = 0; id < map->secy.max; id++) { | |
| 317 | + | for (id = 0; id < map->sc.max; id++) { | |
| 318 | 318 | if (map->sc2pf_map[id] != pcifunc) | |
| 319 | 319 | continue; | |
| 320 | 320 | mcs_clear_stats(mcs, MCS_SC_STATS, id, dir); | |
| @@ -738,7 +738,7 @@ int mcs_free_all_rsrc(struct mcs *mcs, int dir, u16 pcifunc) | |||
| 738 | 738 | } | |
| 739 | 739 | ||
| 740 | 740 | /* free sc entries */ | |
| 741 | - | for (id = 0; id < map->secy.max; id++) { | |
| 741 | + | for (id = 0; id < map->sc.max; id++) { | |
| 742 | 742 | if (map->sc2pf_map[id] != pcifunc) | |
| 743 | 743 | continue; | |
| 744 | 744 | mcs_free_rsrc(&map->sc, map->sc2pf_map, id, pcifunc); | |
modified drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c
| @@ -242,15 +242,6 @@ int cn20k_register_pfvf_mbox_intr(struct otx2_nic *pf, int numvfs) | |||
| 242 | 242 | ||
| 243 | 243 | #define RQ_BP_LVL_AURA (255 - ((85 * 256) / 100)) /* BP when 85% is full */ | |
| 244 | 244 | ||
| 245 | - | static u8 cn20k_aura_bpid_idx(struct otx2_nic *pfvf, int aura_id) | |
| 246 | - | { | |
| 247 | - | #ifdef CONFIG_DCB | |
| 248 | - | return pfvf->queue_to_pfc_map[aura_id]; | |
| 249 | - | #else | |
| 250 | - | return 0; | |
| 251 | - | #endif | |
| 252 | - | } | |
| 253 | - | ||
| 254 | 245 | static int cn20k_tc_get_entry_index(struct otx2_flow_config *flow_cfg, | |
| 255 | 246 | struct otx2_tc_flow *node) | |
| 256 | 247 | { | |
| @@ -580,7 +571,7 @@ static int cn20k_aura_aq_init(struct otx2_nic *pfvf, int aura_id, | |||
| 580 | 571 | if (pfvf->nix_blkaddr == BLKADDR_NIX1) | |
| 581 | 572 | aq->aura.bp_ena = 1; | |
| 582 | 573 | ||
| 583 | - | bpid_idx = cn20k_aura_bpid_idx(pfvf, aura_id); | |
| 574 | + | bpid_idx = otx2_get_bpid_idx(pfvf, aura_id); | |
| 584 | 575 | aq->aura.bpid = pfvf->bpid[bpid_idx]; | |
| 585 | 576 | ||
| 586 | 577 | /* Set backpressure level for RQ's Aura */ | |
modified drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
| @@ -394,7 +394,7 @@ int otx2_rss_init(struct otx2_nic *pfvf) | |||
| 394 | 394 | struct otx2_rss_info *rss = &pfvf->hw.rss_info; | |
| 395 | 395 | int idx, ret = 0; | |
| 396 | 396 | ||
| 397 | - | rss->rss_size = sizeof(*rss->ind_tbl); | |
| 397 | + | rss->rss_size = ARRAY_SIZE(rss->ind_tbl); | |
| 398 | 398 | ||
| 399 | 399 | /* Init RSS key if it is not setup already */ | |
| 400 | 400 | if (!rss->enable) | |
| @@ -1055,6 +1055,7 @@ int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx) | |||
| 1055 | 1055 | struct nix_aq_enq_req *aq; | |
| 1056 | 1056 | struct otx2_cq_queue *cq; | |
| 1057 | 1057 | struct otx2_pool *pool; | |
| 1058 | + | u8 bpid_idx; | |
| 1058 | 1059 | ||
| 1059 | 1060 | cq = &qset->cq[qidx]; | |
| 1060 | 1061 | cq->cq_idx = qidx; | |
| @@ -1132,11 +1133,8 @@ int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx) | |||
| 1132 | 1133 | if (!is_otx2_lbkvf(pfvf->pdev)) { | |
| 1133 | 1134 | /* Enable receive CQ backpressure */ | |
| 1134 | 1135 | aq->cq.bp_ena = 1; | |
| 1135 | - | #ifdef CONFIG_DCB | |
| 1136 | - | aq->cq.bpid = pfvf->bpid[pfvf->queue_to_pfc_map[qidx]]; | |
| 1137 | - | #else | |
| 1138 | - | aq->cq.bpid = pfvf->bpid[0]; | |
| 1139 | - | #endif | |
| 1136 | + | bpid_idx = otx2_get_bpid_idx(pfvf, qidx); | |
| 1137 | + | aq->cq.bpid = pfvf->bpid[bpid_idx]; | |
| 1140 | 1138 | ||
| 1141 | 1139 | /* Set backpressure level is same as cq pass level */ | |
| 1142 | 1140 | aq->cq.bp = RQ_PASS_LVL_CQ(pfvf->hw.rq_skid, qset->rqe_cnt); | |
| @@ -1378,6 +1376,7 @@ int otx2_aura_aq_init(struct otx2_nic *pfvf, int aura_id, | |||
| 1378 | 1376 | { | |
| 1379 | 1377 | struct npa_aq_enq_req *aq; | |
| 1380 | 1378 | struct otx2_pool *pool; | |
| 1379 | + | u8 bpid_idx; | |
| 1381 | 1380 | int err; | |
| 1382 | 1381 | ||
| 1383 | 1382 | pool = &pfvf->qset.pool[pool_id]; | |
| @@ -1433,11 +1432,8 @@ int otx2_aura_aq_init(struct otx2_nic *pfvf, int aura_id, | |||
| 1433 | 1432 | */ | |
| 1434 | 1433 | if (pfvf->nix_blkaddr == BLKADDR_NIX1) | |
| 1435 | 1434 | aq->aura.bp_ena = 1; | |
| 1436 | - | #ifdef CONFIG_DCB | |
| 1437 | - | aq->aura.nix0_bpid = pfvf->bpid[pfvf->queue_to_pfc_map[aura_id]]; | |
| 1438 | - | #else | |
| 1439 | - | aq->aura.nix0_bpid = pfvf->bpid[0]; | |
| 1440 | - | #endif | |
| 1435 | + | bpid_idx = otx2_get_bpid_idx(pfvf, aura_id); | |
| 1436 | + | aq->aura.nix0_bpid = pfvf->bpid[bpid_idx]; | |
| 1441 | 1437 | ||
| 1442 | 1438 | /* Set backpressure level for RQ's Aura */ | |
| 1443 | 1439 | aq->aura.bp = RQ_BP_LVL_AURA; | |
modified drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
| @@ -1029,6 +1029,15 @@ static inline int otx2_tc_flower_rule_cnt(struct otx2_nic *pfvf) | |||
| 1029 | 1029 | return pfvf->flow_cfg->nr_flows; | |
| 1030 | 1030 | } | |
| 1031 | 1031 | ||
| 1032 | + | static inline u8 otx2_get_bpid_idx(struct otx2_nic *pfvf, int qidx) | |
| 1033 | + | { | |
| 1034 | + | #ifdef CONFIG_DCB | |
| 1035 | + | if (pfvf->queue_to_pfc_map) | |
| 1036 | + | return pfvf->queue_to_pfc_map[qidx]; | |
| 1037 | + | #endif | |
| 1038 | + | return 0; | |
| 1039 | + | } | |
| 1040 | + | ||
| 1032 | 1041 | /* MSI-X APIs */ | |
| 1033 | 1042 | void otx2_free_cints(struct otx2_nic *pfvf, int n); | |
| 1034 | 1043 | void otx2_set_cints_affinity(struct otx2_nic *pfvf); | |
modified drivers/net/ethernet/mediatek/mtk_eth_soc.c
| @@ -5341,6 +5341,22 @@ static int mtk_probe(struct platform_device *pdev) | |||
| 5341 | 5341 | } | |
| 5342 | 5342 | } | |
| 5343 | 5343 | ||
| 5344 | + | /* we run 2 devices on the same DMA ring so we need a dummy device | |
| 5345 | + | * for NAPI to work. Allocate it before registering the netdevs so a | |
| 5346 | + | * concurrent ndo_open (e.g. netifd bringing the first netdev up the | |
| 5347 | + | * instant it is registered) never observes eth->dummy_dev == NULL in | |
| 5348 | + | * mtk_dma_init() -> mtk_rx_alloc() -> __xdp_rxq_info_reg() (net/core/xdp.c | |
| 5349 | + | * "Missing net_device from driver") and fails the first open. | |
| 5350 | + | */ | |
| 5351 | + | eth->dummy_dev = alloc_netdev_dummy(0); | |
| 5352 | + | if (!eth->dummy_dev) { | |
| 5353 | + | err = -ENOMEM; | |
| 5354 | + | dev_err(eth->dev, "failed to allocated dummy device\n"); | |
| 5355 | + | goto err_unreg_netdev; | |
| 5356 | + | } | |
| 5357 | + | netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx); | |
| 5358 | + | netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx); | |
| 5359 | + | ||
| 5344 | 5360 | for (i = 0; i < MTK_MAX_DEVS; i++) { | |
| 5345 | 5361 | if (!eth->netdev[i]) | |
| 5346 | 5362 | continue; | |
| @@ -5355,18 +5371,6 @@ static int mtk_probe(struct platform_device *pdev) | |||
| 5355 | 5371 | eth->netdev[i]->base_addr, eth->irq[MTK_FE_IRQ_SHARED]); | |
| 5356 | 5372 | } | |
| 5357 | 5373 | ||
| 5358 | - | /* we run 2 devices on the same DMA ring so we need a dummy device | |
| 5359 | - | * for NAPI to work | |
| 5360 | - | */ | |
| 5361 | - | eth->dummy_dev = alloc_netdev_dummy(0); | |
| 5362 | - | if (!eth->dummy_dev) { | |
| 5363 | - | err = -ENOMEM; | |
| 5364 | - | dev_err(eth->dev, "failed to allocated dummy device\n"); | |
| 5365 | - | goto err_unreg_netdev; | |
| 5366 | - | } | |
| 5367 | - | netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx); | |
| 5368 | - | netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx); | |
| 5369 | - | ||
| 5370 | 5374 | platform_set_drvdata(pdev, eth); | |
| 5371 | 5375 | schedule_delayed_work(ð->reset.monitor_work, | |
| 5372 | 5376 | MTK_DMA_MONITOR_TIMEOUT); | |
| @@ -5376,6 +5380,16 @@ static int mtk_probe(struct platform_device *pdev) | |||
| 5376 | 5380 | err_unreg_netdev: | |
| 5377 | 5381 | mtk_unreg_dev(eth); | |
| 5378 | 5382 | err_deinit_ppe: | |
| 5383 | + | /* A netdev opened while probe was still registering can have queued | |
| 5384 | + | * the frame-engine reset worker, which takes rtnl and drives the | |
| 5385 | + | * hardware; cancel it before anything below is torn down. | |
| 5386 | + | */ | |
| 5387 | + | cancel_work_sync(ð->pending_work); | |
| 5388 | + | if (eth->dummy_dev) { | |
| 5389 | + | netif_napi_del(ð->tx_napi); | |
| 5390 | + | netif_napi_del(ð->rx_napi); | |
| 5391 | + | free_netdev(eth->dummy_dev); | |
| 5392 | + | } | |
| 5379 | 5393 | mtk_ppe_deinit(eth); | |
| 5380 | 5394 | mtk_mdio_cleanup(eth); | |
| 5381 | 5395 | err_free_dev: | |
modified drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
| @@ -293,6 +293,9 @@ static u64 mlx5e_xsk_fill_timestamp(void *_priv) | |||
| 293 | 293 | struct mlx5e_xsk_tx_complete *priv = _priv; | |
| 294 | 294 | u64 ts; | |
| 295 | 295 | ||
| 296 | + | if (!priv->cqe) | |
| 297 | + | return 0; | |
| 298 | + | ||
| 296 | 299 | ts = get_cqe_ts(priv->cqe); | |
| 297 | 300 | ||
| 298 | 301 | if (mlx5_is_real_time_rq(priv->cq->mdev) || mlx5_is_real_time_sq(priv->cq->mdev)) | |
modified drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
| @@ -908,10 +908,12 @@ int mlx5e_poll_ico_cq(struct mlx5e_cq *cq) | |||
| 908 | 908 | } while (!last_wqe); | |
| 909 | 909 | } while ((++i < MLX5E_TX_CQ_POLL_BUDGET) && (cqe = mlx5_cqwq_get_cqe(&cq->wq))); | |
| 910 | 910 | ||
| 911 | - | sq->cc = sqcc; | |
| 912 | - | ||
| 913 | 911 | mlx5_cqwq_update_db_record(&cq->wq); | |
| 914 | 912 | ||
| 913 | + | /* ensure cq space is freed before enabling more cqes */ | |
| 914 | + | dma_wmb(); | |
| 915 | + | ||
| 916 | + | sq->cc = sqcc; | |
| 915 | 917 | return i; | |
| 916 | 918 | } | |
| 917 | 919 | ||
modified drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c
| @@ -11,26 +11,6 @@ int mlx5_esw_adj_vport_modify(struct mlx5_core_dev *dev, u16 vport, | |||
| 11 | 11 | ||
| 12 | 12 | lockdep_assert_held(&dev->priv.eswitch->state_lock); | |
| 13 | 13 | ||
| 14 | - | if (MLX5_CAP_ESW(dev, esw_vport_state_max_tx_speed)) { | |
| 15 | - | u8 op_mod = MLX5_VPORT_STATE_OP_MOD_ESW_VPORT; | |
| 16 | - | struct mlx5_vport *esw_vport; | |
| 17 | - | u32 speed = 0; | |
| 18 | - | int err; | |
| 19 | - | ||
| 20 | - | err = mlx5_query_vport_max_tx_speed(dev, op_mod, vport, | |
| 21 | - | true, &speed, NULL); | |
| 22 | - | if (err) { | |
| 23 | - | esw_vport = mlx5_eswitch_get_vport(dev->priv.eswitch, | |
| 24 | - | vport); | |
| 25 | - | speed = IS_ERR(esw_vport) ? 0 : | |
| 26 | - | esw_vport->agg_max_tx_speed; | |
| 27 | - | mlx5_core_dbg(dev, | |
| 28 | - | "Failed to query vport %d max tx speed, err=%d, using cached %u\n", | |
| 29 | - | vport, err, speed); | |
| 30 | - | } | |
| 31 | - | MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed); | |
| 32 | - | } | |
| 33 | - | ||
| 34 | 14 | MLX5_SET(modify_vport_state_in, in, opcode, | |
| 35 | 15 | MLX5_CMD_OP_MODIFY_VPORT_STATE); | |
| 36 | 16 | MLX5_SET(modify_vport_state_in, in, op_mod, | |
modified drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
| @@ -1432,30 +1432,40 @@ static bool mlx5_lag_should_disable_lag(struct mlx5_lag *ldev, bool do_bond) | |||
| 1432 | 1432 | } | |
| 1433 | 1433 | ||
| 1434 | 1434 | #ifdef CONFIG_MLX5_ESWITCH | |
| 1435 | - | static int | |
| 1436 | - | mlx5_lag_sum_devices_speed(struct mlx5_lag *ldev, u32 *sum_speed, | |
| 1437 | - | int (*get_speed)(struct mlx5_core_dev *, u32 *)) | |
| 1435 | + | static int mlx5_lag_get_devices_oper_speed(struct mlx5_lag *ldev, | |
| 1436 | + | u32 *sum_speed) | |
| 1438 | 1437 | { | |
| 1439 | - | struct mlx5_core_dev *pf_mdev; | |
| 1440 | - | struct lag_func *pf; | |
| 1441 | 1438 | int pf_idx; | |
| 1442 | - | u32 speed; | |
| 1443 | - | int ret; | |
| 1444 | 1439 | ||
| 1445 | 1440 | *sum_speed = 0; | |
| 1446 | 1441 | mlx5_ldev_for_each(pf_idx, 0, ldev) { | |
| 1442 | + | u8 opmod = MLX5_VPORT_STATE_OP_MOD_VNIC_VPORT; | |
| 1443 | + | struct mlx5_core_dev *pf_mdev; | |
| 1444 | + | struct lag_func *pf; | |
| 1445 | + | u32 speed; | |
| 1446 | + | u8 state; | |
| 1447 | + | int ret; | |
| 1448 | + | ||
| 1447 | 1449 | pf = mlx5_lag_pf(ldev, pf_idx); | |
| 1448 | 1450 | if (!pf) | |
| 1449 | 1451 | continue; | |
| 1450 | 1452 | pf_mdev = pf->dev; | |
| 1451 | 1453 | if (!pf_mdev) | |
| 1452 | 1454 | continue; | |
| 1455 | + | ret = mlx5_query_vport_max_tx_speed(pf_mdev, opmod, 0, 0, | |
| 1456 | + | &speed, &state); | |
| 1457 | + | if (ret) { | |
| 1458 | + | mlx5_core_dbg(pf_mdev, "State query failed (err=%d)\n", | |
| 1459 | + | ret); | |
| 1460 | + | return ret; | |
| 1461 | + | } | |
| 1462 | + | if (state != VPORT_STATE_UP) | |
| 1463 | + | continue; | |
| 1453 | 1464 | ||
| 1454 | - | ret = get_speed(pf_mdev, &speed); | |
| 1465 | + | ret = mlx5_port_oper_linkspeed(pf_mdev, &speed); | |
| 1455 | 1466 | if (ret) { | |
| 1456 | 1467 | mlx5_core_dbg(pf_mdev, | |
| 1457 | - | "Failed to get device speed using %ps. Device %s speed is not available (err=%d)\n", | |
| 1458 | - | get_speed, dev_name(pf_mdev->device), | |
| 1468 | + | "Failed to get oper speed (err=%d)\n", | |
| 1459 | 1469 | ret); | |
| 1460 | 1470 | return ret; | |
| 1461 | 1471 | } | |
| @@ -1466,17 +1476,42 @@ mlx5_lag_sum_devices_speed(struct mlx5_lag *ldev, u32 *sum_speed, | |||
| 1466 | 1476 | return 0; | |
| 1467 | 1477 | } | |
| 1468 | 1478 | ||
| 1469 | - | static int mlx5_lag_sum_devices_max_speed(struct mlx5_lag *ldev, u32 *max_speed) | |
| 1479 | + | static int mlx5_lag_get_devices_max_speed(struct mlx5_lag *ldev, u32 *max_speed) | |
| 1470 | 1480 | { | |
| 1471 | - | return mlx5_lag_sum_devices_speed(ldev, max_speed, | |
| 1472 | - | mlx5_port_max_linkspeed); | |
| 1473 | - | } | |
| 1481 | + | bool take_max; | |
| 1482 | + | int pf_idx; | |
| 1474 | 1483 | ||
| 1475 | - | static int mlx5_lag_sum_devices_oper_speed(struct mlx5_lag *ldev, | |
| 1476 | - | u32 *oper_speed) | |
| 1477 | - | { | |
| 1478 | - | return mlx5_lag_sum_devices_speed(ldev, oper_speed, | |
| 1479 | - | mlx5_port_oper_linkspeed); | |
| 1484 | + | take_max = ldev->tracker.tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP; | |
| 1485 | + | if (ldev->mode == MLX5_LAG_MODE_MPESW) | |
| 1486 | + | take_max = false; | |
| 1487 | + | ||
| 1488 | + | *max_speed = 0; | |
| 1489 | + | mlx5_ldev_for_each(pf_idx, 0, ldev) { | |
| 1490 | + | struct mlx5_core_dev *pf_mdev; | |
| 1491 | + | struct lag_func *pf; | |
| 1492 | + | u32 speed; | |
| 1493 | + | int ret; | |
| 1494 | + | ||
| 1495 | + | pf = mlx5_lag_pf(ldev, pf_idx); | |
| 1496 | + | if (!pf) | |
| 1497 | + | continue; | |
| 1498 | + | pf_mdev = pf->dev; | |
| 1499 | + | if (!pf_mdev) | |
| 1500 | + | continue; | |
| 1501 | + | ||
| 1502 | + | ret = mlx5_port_max_linkspeed(pf_mdev, &speed); | |
| 1503 | + | if (ret) { | |
| 1504 | + | mlx5_core_dbg(pf_mdev, | |
| 1505 | + | "Failed to get max speed (err=%d)\n", | |
| 1506 | + | ret); | |
| 1507 | + | return ret; | |
| 1508 | + | } | |
| 1509 | + | ||
| 1510 | + | *max_speed = take_max ? | |
| 1511 | + | max(*max_speed, speed) : *max_speed + speed; | |
| 1512 | + | } | |
| 1513 | + | ||
| 1514 | + | return 0; | |
| 1480 | 1515 | } | |
| 1481 | 1516 | ||
| 1482 | 1517 | static void mlx5_lag_modify_device_vports_speed(struct mlx5_core_dev *mdev, | |
| @@ -1525,7 +1560,7 @@ void mlx5_lag_set_vports_agg_speed(struct mlx5_lag *ldev) | |||
| 1525 | 1560 | int pf_idx; | |
| 1526 | 1561 | ||
| 1527 | 1562 | if (ldev->mode == MLX5_LAG_MODE_MPESW) { | |
| 1528 | - | if (mlx5_lag_sum_devices_oper_speed(ldev, &speed)) | |
| 1563 | + | if (mlx5_lag_get_devices_oper_speed(ldev, &speed)) | |
| 1529 | 1564 | return; | |
| 1530 | 1565 | } else { | |
| 1531 | 1566 | speed = ldev->tracker.bond_speed_mbps; | |
| @@ -1533,8 +1568,8 @@ void mlx5_lag_set_vports_agg_speed(struct mlx5_lag *ldev) | |||
| 1533 | 1568 | return; | |
| 1534 | 1569 | } | |
| 1535 | 1570 | ||
| 1536 | - | /* If speed is not set, use the sum of max speeds of all PFs */ | |
| 1537 | - | if (!speed && mlx5_lag_sum_devices_max_speed(ldev, &speed)) | |
| 1571 | + | /* If speed is not set, fall back to the max achievable speed */ | |
| 1572 | + | if (!speed && mlx5_lag_get_devices_max_speed(ldev, &speed)) | |
| 1538 | 1573 | return; | |
| 1539 | 1574 | ||
| 1540 | 1575 | speed = speed / MLX5_MAX_TX_SPEED_UNIT; | |
| @@ -1943,9 +1978,11 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev, | |||
| 1943 | 1978 | } | |
| 1944 | 1979 | } | |
| 1945 | 1980 | if (i < MLX5_MAX_PORTS) { | |
| 1946 | - | slave = bond_slave_get_rcu(ndev_tmp); | |
| 1947 | - | if (slave) | |
| 1948 | - | has_inactive |= bond_is_slave_inactive(slave); | |
| 1981 | + | if (netif_is_bond_master(upper)) { | |
| 1982 | + | slave = bond_slave_get_rcu(ndev_tmp); | |
| 1983 | + | if (slave) | |
| 1984 | + | has_inactive |= bond_is_slave_inactive(slave); | |
| 1985 | + | } | |
| 1949 | 1986 | bond_status |= (1 << idx); | |
| 1950 | 1987 | } | |
| 1951 | 1988 | ||
| @@ -2029,7 +2066,7 @@ static int mlx5_handle_changeinfodata_event(struct mlx5_lag *ldev, | |||
| 2029 | 2066 | bool has_inactive = 0; | |
| 2030 | 2067 | int idx; | |
| 2031 | 2068 | ||
| 2032 | - | if (!netif_is_lag_master(ndev)) | |
| 2069 | + | if (!netif_is_bond_master(ndev)) | |
| 2033 | 2070 | return 0; | |
| 2034 | 2071 | ||
| 2035 | 2072 | rcu_read_lock(); | |
modified drivers/net/ethernet/mellanox/mlx5/core/vport.c
| @@ -93,30 +93,6 @@ int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod, | |||
| 93 | 93 | lockdep_assert_held(&mdev->priv.eswitch->state_lock); | |
| 94 | 94 | #endif | |
| 95 | 95 | ||
| 96 | - | if (MLX5_CAP_ESW(mdev, esw_vport_state_max_tx_speed) && | |
| 97 | - | opmod == MLX5_VPORT_STATE_OP_MOD_ESW_VPORT && | |
| 98 | - | vport != MLX5_VPORT_UPLINK) { | |
| 99 | - | u32 speed = 0; | |
| 100 | - | int err; | |
| 101 | - | ||
| 102 | - | err = mlx5_query_vport_max_tx_speed(mdev, opmod, vport, | |
| 103 | - | other_vport, &speed, NULL); | |
| 104 | - | if (err) { | |
| 105 | - | #ifdef CONFIG_MLX5_ESWITCH | |
| 106 | - | struct mlx5_vport *esw_vport; | |
| 107 | - | ||
| 108 | - | esw_vport = mlx5_eswitch_get_vport(mdev->priv.eswitch, | |
| 109 | - | vport); | |
| 110 | - | speed = IS_ERR(esw_vport) ? 0 : | |
| 111 | - | esw_vport->agg_max_tx_speed; | |
| 112 | - | #endif | |
| 113 | - | mlx5_core_dbg(mdev, | |
| 114 | - | "Failed to query vport %d max tx speed, err=%d, using cached %u\n", | |
| 115 | - | vport, err, speed); | |
| 116 | - | } | |
| 117 | - | MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed); | |
| 118 | - | } | |
| 119 | - | ||
| 120 | 96 | MLX5_SET(modify_vport_state_in, in, opcode, | |
| 121 | 97 | MLX5_CMD_OP_MODIFY_VPORT_STATE); | |
| 122 | 98 | MLX5_SET(modify_vport_state_in, in, op_mod, opmod); | |
modified drivers/net/ethernet/mellanox/mlxsw/spectrum.h
| @@ -989,6 +989,8 @@ void mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset, | |||
| 989 | 989 | struct mlxsw_sp_acl_rule_info * | |
| 990 | 990 | mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl, | |
| 991 | 991 | struct mlxsw_afa_block *afa_block); | |
| 992 | + | void mlxsw_sp_acl_rulei_free(struct mlxsw_sp *mlxsw_sp, | |
| 993 | + | const struct mlxsw_sp_acl_rule_info *rulei); | |
| 992 | 994 | void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp, | |
| 993 | 995 | struct mlxsw_sp_acl_rule_info *rulei); | |
| 994 | 996 | int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); | |
modified drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
| @@ -340,8 +340,8 @@ err_afa_block_create: | |||
| 340 | 340 | return ERR_PTR(err); | |
| 341 | 341 | } | |
| 342 | 342 | ||
| 343 | - | void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp, | |
| 344 | - | struct mlxsw_sp_acl_rule_info *rulei) | |
| 343 | + | void mlxsw_sp_acl_rulei_free(struct mlxsw_sp *mlxsw_sp, | |
| 344 | + | const struct mlxsw_sp_acl_rule_info *rulei) | |
| 345 | 345 | { | |
| 346 | 346 | if (rulei->action_created) | |
| 347 | 347 | mlxsw_afa_block_destroy(rulei->act_block); | |
| @@ -351,6 +351,12 @@ void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp, | |||
| 351 | 351 | if (rulei->dst_port_range_reg_valid) | |
| 352 | 352 | mlxsw_sp_port_range_reg_put(mlxsw_sp, | |
| 353 | 353 | rulei->dst_port_range_reg_index); | |
| 354 | + | } | |
| 355 | + | ||
| 356 | + | void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp, | |
| 357 | + | struct mlxsw_sp_acl_rule_info *rulei) | |
| 358 | + | { | |
| 359 | + | mlxsw_sp_acl_rulei_free(mlxsw_sp, rulei); | |
| 354 | 360 | kfree(rulei); | |
| 355 | 361 | } | |
| 356 | 362 | ||
modified drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
| @@ -862,14 +862,19 @@ int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp, | |||
| 862 | 862 | memset(&rulei, 0, sizeof(rulei)); | |
| 863 | 863 | err = mlxsw_sp_flower_parse(mlxsw_sp, block, &rulei, f); | |
| 864 | 864 | if (err) | |
| 865 | - | return err; | |
| 865 | + | goto out; | |
| 866 | + | ||
| 866 | 867 | ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, block, | |
| 867 | 868 | f->common.chain_index, | |
| 868 | 869 | MLXSW_SP_ACL_PROFILE_FLOWER, | |
| 869 | 870 | &rulei.values.elusage); | |
| 871 | + | err = PTR_ERR_OR_ZERO(ruleset); | |
| 872 | + | ||
| 873 | + | out: | |
| 874 | + | mlxsw_sp_acl_rulei_free(mlxsw_sp, &rulei); | |
| 870 | 875 | ||
| 871 | 876 | /* keep the reference to the ruleset */ | |
| 872 | - | return PTR_ERR_OR_ZERO(ruleset); | |
| 877 | + | return err; | |
| 873 | 878 | } | |
| 874 | 879 | ||
| 875 | 880 | void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp, | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_main.c
| @@ -898,6 +898,7 @@ static int mchp_sparx5_probe(struct platform_device *pdev) | |||
| 898 | 898 | dev_info(sparx5->dev, "MAC addr was not set, use random MAC\n"); | |
| 899 | 899 | eth_random_addr(sparx5->base_mac); | |
| 900 | 900 | sparx5->base_mac[5] = 0; | |
| 901 | + | sparx5->base_mac_assign_type = NET_ADDR_RANDOM; | |
| 901 | 902 | } | |
| 902 | 903 | ||
| 903 | 904 | sparx5->fdma_irq = platform_get_irq_byname(sparx5->pdev, "fdma"); | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_main.h
| @@ -392,6 +392,7 @@ struct sparx5 { | |||
| 392 | 392 | struct notifier_block switchdev_blocking_nb; | |
| 393 | 393 | /* Switch state */ | |
| 394 | 394 | u8 base_mac[ETH_ALEN]; | |
| 395 | + | u8 base_mac_assign_type; | |
| 395 | 396 | /* Associated bridge device (when bridged) */ | |
| 396 | 397 | struct net_device *hw_bridge_dev; | |
| 397 | 398 | /* Bridged interfaces */ | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
| @@ -294,6 +294,7 @@ struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno) | |||
| 294 | 294 | ndev->ethtool_ops = &sparx5_ethtool_ops; | |
| 295 | 295 | ||
| 296 | 296 | eth_hw_addr_gen(ndev, sparx5->base_mac, portno + 1); | |
| 297 | + | ndev->addr_assign_type = sparx5->base_mac_assign_type; | |
| 297 | 298 | ||
| 298 | 299 | return ndev; | |
| 299 | 300 | } | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
| @@ -622,18 +622,9 @@ int sparx5_ptp_init(struct sparx5 *sparx5) | |||
| 622 | 622 | sparx5->ptp = 1; | |
| 623 | 623 | } | |
| 624 | 624 | ||
| 625 | - | if (!sparx5->ptp) | |
| 626 | - | return 0; | |
| 627 | - | ||
| 628 | - | for (i = 0; i < SPARX5_PHC_COUNT; ++i) { | |
| 629 | - | err = sparx5_ptp_phc_init(sparx5, i, &sparx5_ptp_clock_info); | |
| 630 | - | if (err) | |
| 631 | - | return err; | |
| 632 | - | } | |
| 633 | - | ||
| 634 | - | spin_lock_init(&sparx5->ptp_clock_lock); | |
| 635 | - | spin_lock_init(&sparx5->ptp_ts_id_lock); | |
| 636 | - | mutex_init(&sparx5->ptp_lock); | |
| 625 | + | /* The base, non-PTP-capable lan969x variants need the | |
| 626 | + | * first TOD counter running to forward frames. | |
| 627 | + | */ | |
| 637 | 628 | ||
| 638 | 629 | /* Disable master counters */ | |
| 639 | 630 | spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0), sparx5, PTP_PTP_DOM_CFG); | |
| @@ -657,6 +648,19 @@ int sparx5_ptp_init(struct sparx5 *sparx5) | |||
| 657 | 648 | /* Enable master counters */ | |
| 658 | 649 | spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0x7), sparx5, PTP_PTP_DOM_CFG); | |
| 659 | 650 | ||
| 651 | + | if (!sparx5->ptp) | |
| 652 | + | return 0; | |
| 653 | + | ||
| 654 | + | for (i = 0; i < SPARX5_PHC_COUNT; ++i) { | |
| 655 | + | err = sparx5_ptp_phc_init(sparx5, i, &sparx5_ptp_clock_info); | |
| 656 | + | if (err) | |
| 657 | + | return err; | |
| 658 | + | } | |
| 659 | + | ||
| 660 | + | spin_lock_init(&sparx5->ptp_clock_lock); | |
| 661 | + | spin_lock_init(&sparx5->ptp_ts_id_lock); | |
| 662 | + | mutex_init(&sparx5->ptp_lock); | |
| 663 | + | ||
| 660 | 664 | for (i = 0; i < sparx5->data->consts->n_ports; i++) { | |
| 661 | 665 | port = sparx5->ports[i]; | |
| 662 | 666 | if (!port) | |
| @@ -673,6 +677,9 @@ void sparx5_ptp_deinit(struct sparx5 *sparx5) | |||
| 673 | 677 | struct sparx5_port *port; | |
| 674 | 678 | int i; | |
| 675 | 679 | ||
| 680 | + | if (!sparx5->ptp) | |
| 681 | + | return; | |
| 682 | + | ||
| 676 | 683 | if (sparx5->ptp_irq >= 0) { | |
| 677 | 684 | disable_irq(sparx5->ptp_irq); | |
| 678 | 685 | sparx5->ptp_irq = -ENXIO; | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
| @@ -160,6 +160,7 @@ static int sparx5_tc_matchall_destroy(struct net_device *ndev, | |||
| 160 | 160 | } | |
| 161 | 161 | ||
| 162 | 162 | list_del(&entry->list); | |
| 163 | + | kfree(entry); | |
| 163 | 164 | ||
| 164 | 165 | return err; | |
| 165 | 166 | } | |
modified drivers/net/ethernet/microchip/vcap/vcap_api.c
| @@ -3527,8 +3527,8 @@ int vcap_filter_rule_keys(struct vcap_rule *rule, | |||
| 3527 | 3527 | if (key == keylist[idx]) { | |
| 3528 | 3528 | list_del(&ckf->ctrl.list); | |
| 3529 | 3529 | kfree(ckf); | |
| 3530 | - | idx++; | |
| 3531 | 3530 | err = 0; | |
| 3531 | + | break; | |
| 3532 | 3532 | } | |
| 3533 | 3533 | } | |
| 3534 | 3534 | } | |
modified drivers/net/ethernet/microsoft/mana/mana_bpf.c
| @@ -91,7 +91,7 @@ u32 mana_run_xdp(struct net_device *ndev, struct mana_rxq *rxq, | |||
| 91 | 91 | goto out; | |
| 92 | 92 | ||
| 93 | 93 | xdp_init_buff(xdp, PAGE_SIZE, &rxq->xdp_rxq); | |
| 94 | - | xdp_prepare_buff(xdp, buf_va, XDP_PACKET_HEADROOM, pkt_len, true); | |
| 94 | + | xdp_prepare_buff(xdp, buf_va, rxq->headroom, pkt_len, true); | |
| 95 | 95 | ||
| 96 | 96 | act = bpf_prog_run_xdp(prog, xdp); | |
| 97 | 97 | ||
| @@ -183,9 +183,9 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog, | |||
| 183 | 183 | if (!old_prog && !prog) | |
| 184 | 184 | return 0; | |
| 185 | 185 | ||
| 186 | - | if (prog && ndev->mtu > MANA_XDP_MTU_MAX) { | |
| 186 | + | if (prog && ndev->mtu > MANA_XDP_MTU_MAX(ndev)) { | |
| 187 | 187 | netdev_err(ndev, "XDP: mtu:%u too large, mtu_max:%lu\n", | |
| 188 | - | ndev->mtu, MANA_XDP_MTU_MAX); | |
| 188 | + | ndev->mtu, MANA_XDP_MTU_MAX(ndev)); | |
| 189 | 189 | NL_SET_ERR_MSG_MOD(extack, "XDP: mtu too large"); | |
| 190 | 190 | ||
| 191 | 191 | return -EOPNOTSUPP; | |
| @@ -238,7 +238,7 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog, | |||
| 238 | 238 | bpf_prog_put(old_prog); | |
| 239 | 239 | ||
| 240 | 240 | if (prog) | |
| 241 | - | ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX, | |
| 241 | + | ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX(ndev), | |
| 242 | 242 | gc->adapter_mtu - ETH_HLEN); | |
| 243 | 243 | else | |
| 244 | 244 | ndev->max_mtu = gc->adapter_mtu - ETH_HLEN; | |
modified drivers/net/ethernet/microsoft/mana/mana_en.c
| @@ -758,6 +758,44 @@ static void *mana_get_rxbuf_pre(struct mana_rxq *rxq, dma_addr_t *da) | |||
| 758 | 758 | return va; | |
| 759 | 759 | } | |
| 760 | 760 | ||
| 761 | + | /* Reserve enough headroom to satisfy the skb_cow() in ip_forward() and avoid | |
| 762 | + | * reallocation: the TX path keeps the SGE DMA mappings in struct mana_skb_head | |
| 763 | + | * at skb->head, so the port advertises ndev->needed_headroom = MANA_HEADROOM. | |
| 764 | + | */ | |
| 765 | + | static u32 mana_get_rxbuf_headroom(struct mana_port_context *apc) | |
| 766 | + | { | |
| 767 | + | if (mana_xdp_get(apc)) | |
| 768 | + | return mana_xdp_headroom(apc->ndev); | |
| 769 | + | ||
| 770 | + | return LL_RESERVED_SPACE(apc->ndev); | |
| 771 | + | } | |
| 772 | + | ||
| 773 | + | static u32 mana_get_rxbuf_size(struct mana_port_context *apc, u32 mtu) | |
| 774 | + | { | |
| 775 | + | u32 len = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + | |
| 776 | + | mana_get_rxbuf_headroom(apc)); | |
| 777 | + | ||
| 778 | + | return ALIGN(len, MANA_RX_FRAG_ALIGNMENT); | |
| 779 | + | } | |
| 780 | + | ||
| 781 | + | /* Returns true when one RX buffer per page is already required by XDP or by | |
| 782 | + | * the buffer size implied by the MTU, i.e. regardless of the | |
| 783 | + | * MANA_PRIV_FLAG_USE_FULL_PAGE_RXBUF private flag. | |
| 784 | + | */ | |
| 785 | + | bool mana_single_rxbuf_per_page_forced(struct mana_port_context *apc, u32 mtu) | |
| 786 | + | { | |
| 787 | + | /* For xdp make sure only one packet fits per page. */ | |
| 788 | + | if (mana_xdp_get(apc)) | |
| 789 | + | return true; | |
| 790 | + | ||
| 791 | + | /* Only use the page_pool fragment path when at least two buffers, | |
| 792 | + | * including the headroom each of them has to reserve, actually fit | |
| 793 | + | * into one page. Otherwise the fragment path degenerates into one | |
| 794 | + | * buffer per page while still paying the fragment accounting cost. | |
| 795 | + | */ | |
| 796 | + | return PAGE_SIZE / mana_get_rxbuf_size(apc, mtu) < 2; | |
| 797 | + | } | |
| 798 | + | ||
| 761 | 799 | static bool | |
| 762 | 800 | mana_use_single_rxbuf_per_page(struct mana_port_context *apc, u32 mtu) | |
| 763 | 801 | { | |
| @@ -770,32 +808,27 @@ mana_use_single_rxbuf_per_page(struct mana_port_context *apc, u32 mtu) | |||
| 770 | 808 | if (apc->priv_flags & BIT(MANA_PRIV_FLAG_USE_FULL_PAGE_RXBUF)) | |
| 771 | 809 | return true; | |
| 772 | 810 | ||
| 773 | - | /* For xdp and jumbo frames make sure only one packet fits per page. */ | |
| 774 | - | if (mtu + MANA_RXBUF_PAD > PAGE_SIZE / 2 || mana_xdp_get(apc)) | |
| 775 | - | return true; | |
| 776 | - | ||
| 777 | - | return false; | |
| 811 | + | return mana_single_rxbuf_per_page_forced(apc, mtu); | |
| 778 | 812 | } | |
| 779 | 813 | ||
| 780 | - | /* Get RX buffer's data size, alloc size, XDP headroom based on MTU */ | |
| 814 | + | /* Get RX buffer's data size, alloc size, headroom and frag count based on MTU */ | |
| 781 | 815 | static void mana_get_rxbuf_cfg(struct mana_port_context *apc, | |
| 782 | 816 | int mtu, u32 *datasize, u32 *alloc_size, | |
| 783 | 817 | u32 *headroom, u32 *frag_count) | |
| 784 | 818 | { | |
| 785 | - | u32 len, buf_size; | |
| 819 | + | u32 buf_size; | |
| 786 | 820 | ||
| 787 | 821 | /* Calculate datasize first (consistent across all cases) */ | |
| 788 | 822 | *datasize = mtu + ETH_HLEN; | |
| 789 | 823 | ||
| 824 | + | *headroom = mana_get_rxbuf_headroom(apc); | |
| 825 | + | ||
| 790 | 826 | if (mana_use_single_rxbuf_per_page(apc, mtu)) { | |
| 791 | - | if (mana_xdp_get(apc)) { | |
| 792 | - | *headroom = XDP_PACKET_HEADROOM; | |
| 827 | + | if (mana_xdp_get(apc)) | |
| 793 | 828 | *alloc_size = PAGE_SIZE; | |
| 794 | - | } else { | |
| 795 | - | *headroom = 0; /* no support for XDP */ | |
| 829 | + | else | |
| 796 | 830 | *alloc_size = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + | |
| 797 | 831 | *headroom); | |
| 798 | - | } | |
| 799 | 832 | ||
| 800 | 833 | *frag_count = 1; | |
| 801 | 834 | ||
| @@ -809,11 +842,7 @@ static void mana_get_rxbuf_cfg(struct mana_port_context *apc, | |||
| 809 | 842 | } | |
| 810 | 843 | ||
| 811 | 844 | /* Standard MTU case - optimize for multiple packets per page */ | |
| 812 | - | *headroom = 0; | |
| 813 | - | ||
| 814 | - | /* Calculate base buffer size needed */ | |
| 815 | - | len = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + *headroom); | |
| 816 | - | buf_size = ALIGN(len, MANA_RX_FRAG_ALIGNMENT); | |
| 845 | + | buf_size = mana_get_rxbuf_size(apc, mtu); | |
| 817 | 846 | ||
| 818 | 847 | /* Calculate how many packets can fit in a page */ | |
| 819 | 848 | *frag_count = PAGE_SIZE / buf_size; | |
modified drivers/net/ethernet/microsoft/mana/mana_ethtool.c
| @@ -815,12 +815,12 @@ static int mana_set_priv_flags(struct net_device *ndev, u32 priv_flags) | |||
| 815 | 815 | if (!apc->port_is_up) | |
| 816 | 816 | return 0; | |
| 817 | 817 | ||
| 818 | - | /* If XDP is attached or MTU is jumbo, single-buffer-per-page | |
| 819 | - | * is already forced regardless of this flag. Skip the | |
| 820 | - | * expensive detach/attach cycle since nothing changes. | |
| 818 | + | /* If XDP is attached or the MTU already forces one buffer per | |
| 819 | + | * page, single-buffer-per-page is used regardless of this | |
| 820 | + | * flag. Skip the expensive detach/attach cycle since nothing | |
| 821 | + | * changes. | |
| 821 | 822 | */ | |
| 822 | - | if (ndev->mtu + MANA_RXBUF_PAD > PAGE_SIZE / 2 || | |
| 823 | - | mana_xdp_get(apc)) | |
| 823 | + | if (mana_single_rxbuf_per_page_forced(apc, ndev->mtu)) | |
| 824 | 824 | return 0; | |
| 825 | 825 | ||
| 826 | 826 | /* Block RDMA from grabbing the vport during detach/attach */ | |
modified drivers/net/ethernet/realtek/r8169_main.c
| @@ -5484,6 +5484,12 @@ static int r8169_mdio_register(struct rtl8169_private *tp) | |||
| 5484 | 5484 | phy_disable_eee_mode(tp->phydev, | |
| 5485 | 5485 | ETHTOOL_LINK_MODE_2500baseT_Full_BIT); | |
| 5486 | 5486 | ||
| 5487 | + | /* Keep EEE off but the version stays EEE-capable so that link-up | |
| 5488 | + | * still clears the MAC TX-LPI bits. | |
| 5489 | + | */ | |
| 5490 | + | if (tp->mac_version == RTL_GIGA_MAC_VER_46) | |
| 5491 | + | phy_disable_eee(tp->phydev); | |
| 5492 | + | ||
| 5487 | 5493 | /* PHY will be woken up in rtl_open() */ | |
| 5488 | 5494 | phy_suspend(tp->phydev); | |
| 5489 | 5495 | ||
modified drivers/net/ethernet/stmicro/stmmac/hwif.h
| @@ -633,7 +633,7 @@ struct stmmac_est_ops { | |||
| 633 | 633 | struct stmmac_vlan_ops { | |
| 634 | 634 | /* VLAN */ | |
| 635 | 635 | void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash, | |
| 636 | - | u16 perfect_match, bool is_double); | |
| 636 | + | bool is_svlan); | |
| 637 | 637 | void (*enable_vlan)(struct mac_device_info *hw, u32 type); | |
| 638 | 638 | void (*rx_hw_vlan)(struct mac_device_info *hw, struct dma_desc *rx_desc, | |
| 639 | 639 | struct sk_buff *skb); | |
modified drivers/net/ethernet/stmicro/stmmac/stmmac.h
| @@ -344,7 +344,7 @@ struct stmmac_priv { | |||
| 344 | 344 | void __iomem *ptpaddr; | |
| 345 | 345 | void __iomem *estaddr; | |
| 346 | 346 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; | |
| 347 | - | unsigned int num_double_vlans; | |
| 347 | + | unsigned int num_svlans; | |
| 348 | 348 | int sfty_irq; | |
| 349 | 349 | struct stmmac_msi *msi; | |
| 350 | 350 | ||
modified drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
| @@ -1629,6 +1629,16 @@ static void stmmac_clear_descriptors(struct stmmac_priv *priv, | |||
| 1629 | 1629 | stmmac_clear_tx_descriptors(priv, dma_conf, queue); | |
| 1630 | 1630 | } | |
| 1631 | 1631 | ||
| 1632 | + | static bool stmmac_rx_check_buf2_cap(struct stmmac_priv *priv) | |
| 1633 | + | { | |
| 1634 | + | /* Only cores that can program an independent secondary RX buffer | |
| 1635 | + | * (used for scatter-gather overflow or split-header payload) back | |
| 1636 | + | * buffer2. Legacy cores have no set_sec_addr op, so buffer2 is | |
| 1637 | + | * never handed to the hardware there. | |
| 1638 | + | */ | |
| 1639 | + | return priv->hw->desc && priv->hw->desc->set_sec_addr; | |
| 1640 | + | } | |
| 1641 | + | ||
| 1632 | 1642 | /** | |
| 1633 | 1643 | * stmmac_init_rx_buffers - init the RX descriptor buffer. | |
| 1634 | 1644 | * @priv: driver private structure | |
| @@ -1659,16 +1669,13 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, | |||
| 1659 | 1669 | buf->page_offset = stmmac_rx_offset(priv); | |
| 1660 | 1670 | } | |
| 1661 | 1671 | ||
| 1662 | - | if (priv->sph_active && !buf->sec_page) { | |
| 1672 | + | if (stmmac_rx_check_buf2_cap(priv) && !buf->sec_page) { | |
| 1663 | 1673 | buf->sec_page = page_pool_alloc_pages(rx_q->page_pool, gfp); | |
| 1664 | 1674 | if (!buf->sec_page) | |
| 1665 | 1675 | return -ENOMEM; | |
| 1666 | 1676 | ||
| 1667 | 1677 | buf->sec_addr = page_pool_get_dma_addr(buf->sec_page); | |
| 1668 | 1678 | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true); | |
| 1669 | - | } else { | |
| 1670 | - | buf->sec_page = NULL; | |
| 1671 | - | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false); | |
| 1672 | 1679 | } | |
| 1673 | 1680 | ||
| 1674 | 1681 | buf->addr = page_pool_get_dma_addr(buf->page) + buf->page_offset; | |
| @@ -2256,13 +2263,8 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, | |||
| 2256 | 2263 | pp_params.nid = dev_to_node(priv->device); | |
| 2257 | 2264 | pp_params.dev = priv->device; | |
| 2258 | 2265 | pp_params.dma_dir = xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE; | |
| 2259 | - | pp_params.offset = stmmac_rx_offset(priv); | |
| 2260 | - | pp_params.max_len = dma_conf->dma_buf_sz; | |
| 2261 | - | ||
| 2262 | - | if (priv->sph_active) { | |
| 2263 | - | pp_params.offset = 0; | |
| 2264 | - | pp_params.max_len += stmmac_rx_offset(priv); | |
| 2265 | - | } | |
| 2266 | + | pp_params.offset = 0; | |
| 2267 | + | pp_params.max_len = dma_conf->dma_buf_sz + stmmac_rx_offset(priv); | |
| 2266 | 2268 | ||
| 2267 | 2269 | rx_q->page_pool = page_pool_create(&pp_params); | |
| 2268 | 2270 | if (IS_ERR(rx_q->page_pool)) { | |
| @@ -5099,7 +5101,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue) | |||
| 5099 | 5101 | break; | |
| 5100 | 5102 | } | |
| 5101 | 5103 | ||
| 5102 | - | if (priv->sph_active && !buf->sec_page) { | |
| 5104 | + | if (stmmac_rx_check_buf2_cap(priv) && !buf->sec_page) { | |
| 5103 | 5105 | buf->sec_page = page_pool_alloc_pages(rx_q->page_pool, gfp); | |
| 5104 | 5106 | if (!buf->sec_page) | |
| 5105 | 5107 | break; | |
| @@ -5110,10 +5112,8 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue) | |||
| 5110 | 5112 | buf->addr = page_pool_get_dma_addr(buf->page) + buf->page_offset; | |
| 5111 | 5113 | ||
| 5112 | 5114 | stmmac_set_desc_addr(priv, p, buf->addr); | |
| 5113 | - | if (priv->sph_active) | |
| 5114 | - | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true); | |
| 5115 | - | else | |
| 5116 | - | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false); | |
| 5115 | + | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, | |
| 5116 | + | stmmac_rx_check_buf2_cap(priv)); | |
| 5117 | 5117 | stmmac_refill_desc3(priv, rx_q, p); | |
| 5118 | 5118 | ||
| 5119 | 5119 | rx_q->rx_count_frames++; | |
| @@ -5144,7 +5144,9 @@ static unsigned int stmmac_rx_buf1_len(struct stmmac_priv *priv, | |||
| 5144 | 5144 | unsigned int plen = 0, hlen = 0; | |
| 5145 | 5145 | int coe = priv->hw->rx_csum; | |
| 5146 | 5146 | ||
| 5147 | - | /* Not first descriptor, buffer is always zero */ | |
| 5147 | + | /* Not first descriptor, SPH enabled: buffer1 only carries the | |
| 5148 | + | * split header of the first descriptor, so it is zero here. | |
| 5149 | + | */ | |
| 5148 | 5150 | if (priv->sph_active && len) | |
| 5149 | 5151 | return 0; | |
| 5150 | 5152 | ||
| @@ -5155,14 +5157,16 @@ static unsigned int stmmac_rx_buf1_len(struct stmmac_priv *priv, | |||
| 5155 | 5157 | return hlen; | |
| 5156 | 5158 | } | |
| 5157 | 5159 | ||
| 5158 | - | /* First descriptor, not last descriptor and not split header */ | |
| 5160 | + | /* Not last descriptor and not split header: buffer1 is fully filled */ | |
| 5159 | 5161 | if (status & rx_not_ls) | |
| 5160 | 5162 | return priv->dma_conf.dma_buf_sz; | |
| 5161 | 5163 | ||
| 5162 | 5164 | plen = stmmac_get_rx_frame_len(priv, p, coe); | |
| 5163 | 5165 | ||
| 5164 | - | /* First descriptor and last descriptor and not split header */ | |
| 5165 | - | return min_t(unsigned int, priv->dma_conf.dma_buf_sz, plen); | |
| 5166 | + | /* Last descriptor and not split header: buffer1 holds the remaining | |
| 5167 | + | * bytes of the frame, up to dma_buf_sz | |
| 5168 | + | */ | |
| 5169 | + | return min_t(unsigned int, priv->dma_conf.dma_buf_sz, plen - len); | |
| 5166 | 5170 | } | |
| 5167 | 5171 | ||
| 5168 | 5172 | static unsigned int stmmac_rx_buf2_len(struct stmmac_priv *priv, | |
| @@ -5172,8 +5176,7 @@ static unsigned int stmmac_rx_buf2_len(struct stmmac_priv *priv, | |||
| 5172 | 5176 | int coe = priv->hw->rx_csum; | |
| 5173 | 5177 | unsigned int plen = 0; | |
| 5174 | 5178 | ||
| 5175 | - | /* Not split header, buffer is not available */ | |
| 5176 | - | if (!priv->sph_active) | |
| 5179 | + | if (!stmmac_rx_check_buf2_cap(priv)) | |
| 5177 | 5180 | return 0; | |
| 5178 | 5181 | ||
| 5179 | 5182 | /* For GMAC4, when split header is enabled, in some rare cases, the | |
| @@ -5190,14 +5193,15 @@ static unsigned int stmmac_rx_buf2_len(struct stmmac_priv *priv, | |||
| 5190 | 5193 | * Thus 'plen - len' always gives the correct length of buf2. | |
| 5191 | 5194 | */ | |
| 5192 | 5195 | ||
| 5193 | - | /* Not GMAC4 and not last descriptor */ | |
| 5194 | - | if (priv->plat->core_type != DWMAC_CORE_GMAC4 && (status & rx_not_ls)) | |
| 5196 | + | /* Not GMAC4, or non-SPH and not last descriptor */ | |
| 5197 | + | if ((priv->plat->core_type != DWMAC_CORE_GMAC4 || !priv->sph_active) && | |
| 5198 | + | (status & rx_not_ls)) | |
| 5195 | 5199 | return priv->dma_conf.dma_buf_sz; | |
| 5196 | 5200 | ||
| 5197 | 5201 | /* GMAC4 or last descriptor */ | |
| 5198 | 5202 | plen = stmmac_get_rx_frame_len(priv, p, coe); | |
| 5199 | 5203 | ||
| 5200 | - | return plen - len; | |
| 5204 | + | return plen > len ? plen - len : 0; | |
| 5201 | 5205 | } | |
| 5202 | 5206 | ||
| 5203 | 5207 | static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue, | |
| @@ -5720,6 +5724,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) | |||
| 5720 | 5724 | unsigned int desc_size; | |
| 5721 | 5725 | struct sk_buff *skb = NULL; | |
| 5722 | 5726 | struct stmmac_xdp_buff ctx; | |
| 5727 | + | bool fcs_stripped = false; | |
| 5723 | 5728 | int xdp_status = 0; | |
| 5724 | 5729 | int bufsz; | |
| 5725 | 5730 | ||
| @@ -5809,24 +5814,25 @@ read_again: | |||
| 5809 | 5814 | len += buf2_len; | |
| 5810 | 5815 | ||
| 5811 | 5816 | /* ACS is disabled; strip manually. */ | |
| 5812 | - | if (likely(!(status & rx_not_ls))) { | |
| 5813 | - | if (buf2_len) { | |
| 5814 | - | buf2_len -= ETH_FCS_LEN; | |
| 5815 | - | len -= ETH_FCS_LEN; | |
| 5816 | - | } else if (buf1_len) { | |
| 5817 | - | buf1_len -= ETH_FCS_LEN; | |
| 5818 | - | len -= ETH_FCS_LEN; | |
| 5819 | - | } | |
| 5820 | - | } | |
| 5817 | + | if (likely(!(status & rx_not_ls))) | |
| 5818 | + | len -= ETH_FCS_LEN; | |
| 5821 | 5819 | ||
| 5822 | 5820 | if (!skb) { | |
| 5823 | 5821 | unsigned int pre_len, sync_len; | |
| 5824 | 5822 | ||
| 5823 | + | /* Each frame starts here: reset the FCS handling */ | |
| 5824 | + | fcs_stripped = false; | |
| 5825 | + | ||
| 5825 | 5826 | dma_sync_single_for_cpu(priv->device, buf->addr, | |
| 5826 | 5827 | buf1_len, dma_dir); | |
| 5827 | 5828 | net_prefetch(page_address(buf->page) + | |
| 5828 | 5829 | buf->page_offset); | |
| 5829 | 5830 | ||
| 5831 | + | if (stmmac_xdp_is_enabled(priv) && !buf2_len) { | |
| 5832 | + | buf1_len -= ETH_FCS_LEN; | |
| 5833 | + | fcs_stripped = true; | |
| 5834 | + | } | |
| 5835 | + | ||
| 5830 | 5836 | xdp_init_buff(&ctx.xdp, bufsz, &rx_q->xdp_rxq); | |
| 5831 | 5837 | xdp_prepare_buff(&ctx.xdp, page_address(buf->page), | |
| 5832 | 5838 | buf->page_offset, buf1_len, true); | |
| @@ -5927,6 +5933,15 @@ drain_data: | |||
| 5927 | 5933 | ||
| 5928 | 5934 | /* Got entire packet into SKB. Finish it. */ | |
| 5929 | 5935 | ||
| 5936 | + | /* Remove FCS if needed */ | |
| 5937 | + | if (!fcs_stripped && pskb_trim(skb, len)) { | |
| 5938 | + | dev_kfree_skb_any(skb); | |
| 5939 | + | skb = NULL; | |
| 5940 | + | rx_dropped++; | |
| 5941 | + | count++; | |
| 5942 | + | continue; | |
| 5943 | + | } | |
| 5944 | + | ||
| 5930 | 5945 | stmmac_get_rx_hwtstamp(priv, p, np, skb); | |
| 5931 | 5946 | ||
| 5932 | 5947 | if (priv->hw->hw_vlan_en) | |
| @@ -6211,6 +6226,13 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, | |||
| 6211 | 6226 | if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN)) | |
| 6212 | 6227 | features &= ~NETIF_F_CSUM_MASK; | |
| 6213 | 6228 | ||
| 6229 | + | if (priv->plat->core_type == DWMAC_CORE_XGMAC) { | |
| 6230 | + | if (features & NETIF_F_HW_VLAN_CTAG_RX) | |
| 6231 | + | features |= NETIF_F_HW_VLAN_STAG_RX; | |
| 6232 | + | else | |
| 6233 | + | features &= ~NETIF_F_HW_VLAN_STAG_RX; | |
| 6234 | + | } | |
| 6235 | + | ||
| 6214 | 6236 | return features; | |
| 6215 | 6237 | } | |
| 6216 | 6238 | ||
| @@ -6835,32 +6857,21 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le) | |||
| 6835 | 6857 | return crc; | |
| 6836 | 6858 | } | |
| 6837 | 6859 | ||
| 6838 | - | static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double) | |
| 6860 | + | static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_svlan) | |
| 6839 | 6861 | { | |
| 6840 | 6862 | u32 crc, hash = 0; | |
| 6841 | - | u16 pmatch = 0; | |
| 6842 | - | int count = 0; | |
| 6843 | 6863 | u16 vid = 0; | |
| 6844 | 6864 | ||
| 6845 | 6865 | for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) { | |
| 6846 | 6866 | __le16 vid_le = cpu_to_le16(vid); | |
| 6847 | 6867 | crc = bitrev32(~stmmac_vid_crc32_le(vid_le)) >> 28; | |
| 6848 | 6868 | hash |= (1 << crc); | |
| 6849 | - | count++; | |
| 6850 | - | } | |
| 6851 | - | ||
| 6852 | - | if (!priv->dma_cap.vlhash) { | |
| 6853 | - | if (count > 2) /* VID = 0 always passes filter */ | |
| 6854 | - | return -EOPNOTSUPP; | |
| 6855 | - | ||
| 6856 | - | pmatch = vid; | |
| 6857 | - | hash = 0; | |
| 6858 | 6869 | } | |
| 6859 | 6870 | ||
| 6860 | 6871 | if (!netif_running(priv->dev)) | |
| 6861 | 6872 | return 0; | |
| 6862 | 6873 | ||
| 6863 | - | return stmmac_update_vlan_hash(priv, priv->hw, hash, pmatch, is_double); | |
| 6874 | + | return stmmac_update_vlan_hash(priv, priv->hw, hash, is_svlan); | |
| 6864 | 6875 | } | |
| 6865 | 6876 | ||
| 6866 | 6877 | /* FIXME: This may need RXC to be running, but it may be called with BH | |
| @@ -6869,8 +6880,8 @@ static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double) | |||
| 6869 | 6880 | static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid) | |
| 6870 | 6881 | { | |
| 6871 | 6882 | struct stmmac_priv *priv = netdev_priv(ndev); | |
| 6872 | - | unsigned int num_double_vlans; | |
| 6873 | - | bool is_double = false; | |
| 6883 | + | unsigned int num_svlans; | |
| 6884 | + | bool is_svlan = false; | |
| 6874 | 6885 | int ret; | |
| 6875 | 6886 | ||
| 6876 | 6887 | ret = pm_runtime_resume_and_get(priv->device); | |
| @@ -6878,11 +6889,11 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid | |||
| 6878 | 6889 | return ret; | |
| 6879 | 6890 | ||
| 6880 | 6891 | if (be16_to_cpu(proto) == ETH_P_8021AD) | |
| 6881 | - | is_double = true; | |
| 6892 | + | is_svlan = true; | |
| 6882 | 6893 | ||
| 6883 | 6894 | set_bit(vid, priv->active_vlans); | |
| 6884 | - | num_double_vlans = priv->num_double_vlans + is_double; | |
| 6885 | - | ret = stmmac_vlan_update(priv, num_double_vlans); | |
| 6895 | + | num_svlans = priv->num_svlans + is_svlan; | |
| 6896 | + | ret = stmmac_vlan_update(priv, num_svlans); | |
| 6886 | 6897 | if (ret) { | |
| 6887 | 6898 | clear_bit(vid, priv->active_vlans); | |
| 6888 | 6899 | goto err_pm_put; | |
| @@ -6892,12 +6903,12 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid | |||
| 6892 | 6903 | ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); | |
| 6893 | 6904 | if (ret) { | |
| 6894 | 6905 | clear_bit(vid, priv->active_vlans); | |
| 6895 | - | stmmac_vlan_update(priv, priv->num_double_vlans); | |
| 6906 | + | stmmac_vlan_update(priv, priv->num_svlans); | |
| 6896 | 6907 | goto err_pm_put; | |
| 6897 | 6908 | } | |
| 6898 | 6909 | } | |
| 6899 | 6910 | ||
| 6900 | - | priv->num_double_vlans = num_double_vlans; | |
| 6911 | + | priv->num_svlans = num_svlans; | |
| 6901 | 6912 | ||
| 6902 | 6913 | err_pm_put: | |
| 6903 | 6914 | pm_runtime_put(priv->device); | |
| @@ -6911,8 +6922,8 @@ err_pm_put: | |||
| 6911 | 6922 | static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid) | |
| 6912 | 6923 | { | |
| 6913 | 6924 | struct stmmac_priv *priv = netdev_priv(ndev); | |
| 6914 | - | unsigned int num_double_vlans; | |
| 6915 | - | bool is_double = false; | |
| 6925 | + | unsigned int num_svlans; | |
| 6926 | + | bool is_svlan = false; | |
| 6916 | 6927 | int ret; | |
| 6917 | 6928 | ||
| 6918 | 6929 | ret = pm_runtime_resume_and_get(priv->device); | |
| @@ -6920,11 +6931,11 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi | |||
| 6920 | 6931 | return ret; | |
| 6921 | 6932 | ||
| 6922 | 6933 | if (be16_to_cpu(proto) == ETH_P_8021AD) | |
| 6923 | - | is_double = true; | |
| 6934 | + | is_svlan = true; | |
| 6924 | 6935 | ||
| 6925 | 6936 | clear_bit(vid, priv->active_vlans); | |
| 6926 | - | num_double_vlans = priv->num_double_vlans - is_double; | |
| 6927 | - | ret = stmmac_vlan_update(priv, num_double_vlans); | |
| 6937 | + | num_svlans = priv->num_svlans - is_svlan; | |
| 6938 | + | ret = stmmac_vlan_update(priv, num_svlans); | |
| 6928 | 6939 | if (ret) { | |
| 6929 | 6940 | set_bit(vid, priv->active_vlans); | |
| 6930 | 6941 | goto del_vlan_error; | |
| @@ -6934,12 +6945,12 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi | |||
| 6934 | 6945 | ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); | |
| 6935 | 6946 | if (ret) { | |
| 6936 | 6947 | set_bit(vid, priv->active_vlans); | |
| 6937 | - | stmmac_vlan_update(priv, priv->num_double_vlans); | |
| 6948 | + | stmmac_vlan_update(priv, priv->num_svlans); | |
| 6938 | 6949 | goto del_vlan_error; | |
| 6939 | 6950 | } | |
| 6940 | 6951 | } | |
| 6941 | 6952 | ||
| 6942 | - | priv->num_double_vlans = num_double_vlans; | |
| 6953 | + | priv->num_svlans = num_svlans; | |
| 6943 | 6954 | ||
| 6944 | 6955 | del_vlan_error: | |
| 6945 | 6956 | pm_runtime_put(priv->device); | |
| @@ -6955,7 +6966,7 @@ static void stmmac_vlan_restore(struct stmmac_priv *priv) | |||
| 6955 | 6966 | if (priv->hw->num_vlan) | |
| 6956 | 6967 | stmmac_restore_hw_vlan_rx_fltr(priv, priv->dev, priv->hw); | |
| 6957 | 6968 | ||
| 6958 | - | stmmac_vlan_update(priv, priv->num_double_vlans); | |
| 6969 | + | stmmac_vlan_update(priv, priv->num_svlans); | |
| 6959 | 6970 | } | |
| 6960 | 6971 | ||
| 6961 | 6972 | static int stmmac_bpf(struct net_device *dev, struct netdev_bpf *bpf) | |
| @@ -7994,14 +8005,18 @@ static int __stmmac_dvr_probe(struct device *device, | |||
| 7994 | 8005 | ndev->watchdog_timeo = msecs_to_jiffies(watchdog); | |
| 7995 | 8006 | #ifdef STMMAC_VLAN_TAG_USED | |
| 7996 | 8007 | /* Both mac100 and gmac support receive VLAN tag detection */ | |
| 7997 | - | ndev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX; | |
| 8008 | + | ndev->features |= NETIF_F_HW_VLAN_CTAG_RX; | |
| 8009 | + | if (priv->plat->core_type == DWMAC_CORE_XGMAC) | |
| 8010 | + | ndev->features |= NETIF_F_HW_VLAN_STAG_RX; | |
| 8011 | + | ||
| 7998 | 8012 | if (dwmac_is_xmac(priv->plat->core_type)) { | |
| 7999 | 8013 | ndev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX; | |
| 8000 | 8014 | priv->hw->hw_vlan_en = true; | |
| 8001 | 8015 | } | |
| 8002 | 8016 | if (priv->dma_cap.vlhash) { | |
| 8003 | 8017 | ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; | |
| 8004 | - | ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER; | |
| 8018 | + | if (priv->plat->core_type == DWMAC_CORE_XGMAC) | |
| 8019 | + | ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER; | |
| 8005 | 8020 | } | |
| 8006 | 8021 | if (priv->dma_cap.vlins) | |
| 8007 | 8022 | ndev->features |= NETIF_F_HW_VLAN_CTAG_TX; | |
modified drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
| @@ -243,7 +243,7 @@ struct stmmac_test_priv { | |||
| 243 | 243 | int (*func)(struct sk_buff *skb, struct net_device *ndev, | |
| 244 | 244 | struct packet_type *pt, struct net_device *orig_ndev); | |
| 245 | 245 | bool capture_all; | |
| 246 | - | int double_vlan; | |
| 246 | + | int svlan; | |
| 247 | 247 | int vlan_id; | |
| 248 | 248 | int ok; | |
| 249 | 249 | }; | |
| @@ -285,7 +285,7 @@ static int stmmac_test_loopback_validate(struct sk_buff *skb, | |||
| 285 | 285 | } | |
| 286 | 286 | ||
| 287 | 287 | ihdr = ip_hdr(skb); | |
| 288 | - | if (tpriv->double_vlan) | |
| 288 | + | if (tpriv->svlan) | |
| 289 | 289 | ihdr = (struct iphdr *)(skb_network_header(skb) + 4); | |
| 290 | 290 | ||
| 291 | 291 | if (tpriv->packet->tcp) { | |
| @@ -936,7 +936,7 @@ static int stmmac_test_vlan_validate(struct sk_buff *skb, | |||
| 936 | 936 | struct iphdr *ihdr; | |
| 937 | 937 | u16 proto; | |
| 938 | 938 | ||
| 939 | - | proto = tpriv->double_vlan ? ETH_P_8021AD : ETH_P_8021Q; | |
| 939 | + | proto = tpriv->svlan ? ETH_P_8021AD : ETH_P_8021Q; | |
| 940 | 940 | ||
| 941 | 941 | skb = skb_unshare(skb, GFP_ATOMIC); | |
| 942 | 942 | if (!skb) | |
| @@ -963,7 +963,7 @@ static int stmmac_test_vlan_validate(struct sk_buff *skb, | |||
| 963 | 963 | } | |
| 964 | 964 | ||
| 965 | 965 | ihdr = ip_hdr(skb); | |
| 966 | - | if (tpriv->double_vlan) | |
| 966 | + | if (tpriv->svlan) | |
| 967 | 967 | ihdr = (struct iphdr *)(skb_network_header(skb) + 4); | |
| 968 | 968 | if (ihdr->protocol != IPPROTO_UDP) | |
| 969 | 969 | goto out; | |
| @@ -1080,7 +1080,7 @@ static int stmmac_test_vlanfilt_perfect(struct stmmac_priv *priv) | |||
| 1080 | 1080 | return ret; | |
| 1081 | 1081 | } | |
| 1082 | 1082 | ||
| 1083 | - | static int __stmmac_test_dvlanfilt(struct stmmac_priv *priv) | |
| 1083 | + | static int __stmmac_test_svlanfilt(struct stmmac_priv *priv) | |
| 1084 | 1084 | { | |
| 1085 | 1085 | struct stmmac_packet_attrs attr = { }; | |
| 1086 | 1086 | struct stmmac_test_priv *tpriv; | |
| @@ -1092,7 +1092,7 @@ static int __stmmac_test_dvlanfilt(struct stmmac_priv *priv) | |||
| 1092 | 1092 | return -ENOMEM; | |
| 1093 | 1093 | ||
| 1094 | 1094 | tpriv->ok = false; | |
| 1095 | - | tpriv->double_vlan = true; | |
| 1095 | + | tpriv->svlan = true; | |
| 1096 | 1096 | init_completion(&tpriv->comp); | |
| 1097 | 1097 | ||
| 1098 | 1098 | tpriv->pt.type = htons(ETH_P_8021Q); | |
| @@ -1155,15 +1155,15 @@ cleanup: | |||
| 1155 | 1155 | return ret; | |
| 1156 | 1156 | } | |
| 1157 | 1157 | ||
| 1158 | - | static int stmmac_test_dvlanfilt(struct stmmac_priv *priv) | |
| 1158 | + | static int stmmac_test_svlanfilt(struct stmmac_priv *priv) | |
| 1159 | 1159 | { | |
| 1160 | 1160 | if (!priv->dma_cap.vlhash) | |
| 1161 | 1161 | return -EOPNOTSUPP; | |
| 1162 | 1162 | ||
| 1163 | - | return __stmmac_test_dvlanfilt(priv); | |
| 1163 | + | return __stmmac_test_svlanfilt(priv); | |
| 1164 | 1164 | } | |
| 1165 | 1165 | ||
| 1166 | - | static int stmmac_test_dvlanfilt_perfect(struct stmmac_priv *priv) | |
| 1166 | + | static int stmmac_test_svlanfilt_perfect(struct stmmac_priv *priv) | |
| 1167 | 1167 | { | |
| 1168 | 1168 | int ret, prev_cap = priv->dma_cap.vlhash; | |
| 1169 | 1169 | ||
| @@ -1171,7 +1171,7 @@ static int stmmac_test_dvlanfilt_perfect(struct stmmac_priv *priv) | |||
| 1171 | 1171 | return -EOPNOTSUPP; | |
| 1172 | 1172 | ||
| 1173 | 1173 | priv->dma_cap.vlhash = 0; | |
| 1174 | - | ret = __stmmac_test_dvlanfilt(priv); | |
| 1174 | + | ret = __stmmac_test_svlanfilt(priv); | |
| 1175 | 1175 | priv->dma_cap.vlhash = prev_cap; | |
| 1176 | 1176 | ||
| 1177 | 1177 | return ret; | |
| @@ -1372,7 +1372,7 @@ static int stmmac_test_vlanoff_common(struct stmmac_priv *priv, bool svlan) | |||
| 1372 | 1372 | proto = svlan ? ETH_P_8021AD : ETH_P_8021Q; | |
| 1373 | 1373 | ||
| 1374 | 1374 | tpriv->ok = false; | |
| 1375 | - | tpriv->double_vlan = svlan; | |
| 1375 | + | tpriv->svlan = svlan; | |
| 1376 | 1376 | init_completion(&tpriv->comp); | |
| 1377 | 1377 | ||
| 1378 | 1378 | tpriv->pt.type = svlan ? htons(ETH_P_8021Q) : htons(ETH_P_IP); | |
| @@ -1960,11 +1960,11 @@ static const struct stmmac_test { | |||
| 1960 | 1960 | .name = "VLAN Filtering (perf) ", | |
| 1961 | 1961 | .fn = stmmac_test_vlanfilt_perfect, | |
| 1962 | 1962 | }, { | |
| 1963 | - | .name = "Double VLAN Filter ", | |
| 1964 | - | .fn = stmmac_test_dvlanfilt, | |
| 1963 | + | .name = "SVLAN Filtering ", | |
| 1964 | + | .fn = stmmac_test_svlanfilt, | |
| 1965 | 1965 | }, { | |
| 1966 | - | .name = "Double VLAN Filter (perf) ", | |
| 1967 | - | .fn = stmmac_test_dvlanfilt_perfect, | |
| 1966 | + | .name = "SVLAN Filtering (perf) ", | |
| 1967 | + | .fn = stmmac_test_svlanfilt_perfect, | |
| 1968 | 1968 | }, { | |
| 1969 | 1969 | .name = "Flexible RX Parser ", | |
| 1970 | 1970 | .fn = stmmac_test_rxp, | |
modified drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
| @@ -162,7 +162,7 @@ static void vlan_restore_hw_rx_fltr(struct net_device *dev, | |||
| 162 | 162 | } | |
| 163 | 163 | ||
| 164 | 164 | static void vlan_update_hash(struct mac_device_info *hw, u32 hash, | |
| 165 | - | u16 perfect_match, bool is_double) | |
| 165 | + | bool is_svlan) | |
| 166 | 166 | { | |
| 167 | 167 | void __iomem *ioaddr = hw->pcsr; | |
| 168 | 168 | u32 value; | |
| @@ -173,34 +173,17 @@ static void vlan_update_hash(struct mac_device_info *hw, u32 hash, | |||
| 173 | 173 | ||
| 174 | 174 | if (hash) { | |
| 175 | 175 | value |= VLAN_VTHM | VLAN_ETV; | |
| 176 | - | if (is_double) { | |
| 177 | - | value |= VLAN_EDVLP; | |
| 176 | + | if (is_svlan) { | |
| 178 | 177 | value |= VLAN_ESVL; | |
| 179 | 178 | value |= VLAN_DOVLTC; | |
| 180 | 179 | } else { | |
| 181 | - | value &= ~VLAN_EDVLP; | |
| 182 | 180 | value &= ~VLAN_ESVL; | |
| 183 | 181 | value &= ~VLAN_DOVLTC; | |
| 184 | 182 | } | |
| 185 | 183 | ||
| 186 | 184 | writel(value, ioaddr + VLAN_TAG); | |
| 187 | - | } else if (perfect_match) { | |
| 188 | - | u32 value = VLAN_ETV; | |
| 189 | - | ||
| 190 | - | if (is_double) { | |
| 191 | - | value |= VLAN_EDVLP; | |
| 192 | - | value |= VLAN_ESVL; | |
| 193 | - | value |= VLAN_DOVLTC; | |
| 194 | - | } else { | |
| 195 | - | value &= ~VLAN_EDVLP; | |
| 196 | - | value &= ~VLAN_ESVL; | |
| 197 | - | value &= ~VLAN_DOVLTC; | |
| 198 | - | } | |
| 199 | - | ||
| 200 | - | writel(value | perfect_match, ioaddr + VLAN_TAG); | |
| 201 | 185 | } else { | |
| 202 | - | value &= ~(VLAN_VTHM | VLAN_ETV); | |
| 203 | - | value &= ~(VLAN_EDVLP | VLAN_ESVL); | |
| 186 | + | value &= ~(VLAN_VTHM | VLAN_ETV | VLAN_ESVL); | |
| 204 | 187 | value &= ~VLAN_DOVLTC; | |
| 205 | 188 | value &= ~VLAN_VID; | |
| 206 | 189 | ||
| @@ -236,6 +219,7 @@ static void vlan_set_hw_mode(struct mac_device_info *hw) | |||
| 236 | 219 | void __iomem *ioaddr = hw->pcsr; | |
| 237 | 220 | u32 value = readl(ioaddr + VLAN_TAG); | |
| 238 | 221 | ||
| 222 | + | value |= VLAN_EDVLP; | |
| 239 | 223 | value &= ~VLAN_TAG_CTRL_EVLS_MASK; | |
| 240 | 224 | ||
| 241 | 225 | if (hw->hw_vlan_en) | |
| @@ -251,7 +235,7 @@ static void vlan_set_hw_mode(struct mac_device_info *hw) | |||
| 251 | 235 | } | |
| 252 | 236 | ||
| 253 | 237 | static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash, | |
| 254 | - | u16 perfect_match, bool is_double) | |
| 238 | + | bool is_svlan) | |
| 255 | 239 | { | |
| 256 | 240 | void __iomem *ioaddr = hw->pcsr; | |
| 257 | 241 | ||
| @@ -267,41 +251,16 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash, | |||
| 267 | 251 | value = readl(ioaddr + VLAN_TAG); | |
| 268 | 252 | ||
| 269 | 253 | value |= VLAN_VTHM | VLAN_ETV; | |
| 270 | - | if (is_double) { | |
| 271 | - | value |= VLAN_EDVLP; | |
| 254 | + | if (is_svlan) { | |
| 272 | 255 | value |= VLAN_ESVL; | |
| 273 | 256 | value |= VLAN_DOVLTC; | |
| 274 | 257 | } else { | |
| 275 | - | value &= ~VLAN_EDVLP; | |
| 276 | 258 | value &= ~VLAN_ESVL; | |
| 277 | 259 | value &= ~VLAN_DOVLTC; | |
| 278 | 260 | } | |
| 279 | 261 | ||
| 280 | 262 | value &= ~VLAN_VID; | |
| 281 | 263 | writel(value, ioaddr + VLAN_TAG); | |
| 282 | - | } else if (perfect_match) { | |
| 283 | - | u32 value = readl(ioaddr + XGMAC_PACKET_FILTER); | |
| 284 | - | ||
| 285 | - | value |= XGMAC_FILTER_VTFE; | |
| 286 | - | ||
| 287 | - | writel(value, ioaddr + XGMAC_PACKET_FILTER); | |
| 288 | - | ||
| 289 | - | value = readl(ioaddr + VLAN_TAG); | |
| 290 | - | ||
| 291 | - | value &= ~VLAN_VTHM; | |
| 292 | - | value |= VLAN_ETV; | |
| 293 | - | if (is_double) { | |
| 294 | - | value |= VLAN_EDVLP; | |
| 295 | - | value |= VLAN_ESVL; | |
| 296 | - | value |= VLAN_DOVLTC; | |
| 297 | - | } else { | |
| 298 | - | value &= ~VLAN_EDVLP; | |
| 299 | - | value &= ~VLAN_ESVL; | |
| 300 | - | value &= ~VLAN_DOVLTC; | |
| 301 | - | } | |
| 302 | - | ||
| 303 | - | value &= ~VLAN_VID; | |
| 304 | - | writel(value | perfect_match, ioaddr + VLAN_TAG); | |
| 305 | 264 | } else { | |
| 306 | 265 | u32 value = readl(ioaddr + XGMAC_PACKET_FILTER); | |
| 307 | 266 | ||
| @@ -311,8 +270,7 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash, | |||
| 311 | 270 | ||
| 312 | 271 | value = readl(ioaddr + VLAN_TAG); | |
| 313 | 272 | ||
| 314 | - | value &= ~(VLAN_VTHM | VLAN_ETV); | |
| 315 | - | value &= ~(VLAN_EDVLP | VLAN_ESVL); | |
| 273 | + | value &= ~(VLAN_VTHM | VLAN_ETV | VLAN_ESVL); | |
| 316 | 274 | value &= ~VLAN_DOVLTC; | |
| 317 | 275 | value &= ~VLAN_VID; | |
| 318 | 276 | ||
| @@ -320,6 +278,14 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash, | |||
| 320 | 278 | } | |
| 321 | 279 | } | |
| 322 | 280 | ||
| 281 | + | static void dwxlgmac2_set_hw_vlan_mode(struct mac_device_info *hw) | |
| 282 | + | { | |
| 283 | + | void __iomem *ioaddr = hw->pcsr; | |
| 284 | + | u32 value = readl(ioaddr + VLAN_TAG); | |
| 285 | + | ||
| 286 | + | writel(value | VLAN_EDVLP, ioaddr + VLAN_TAG); | |
| 287 | + | } | |
| 288 | + | ||
| 323 | 289 | const struct stmmac_vlan_ops dwmac_vlan_ops = { | |
| 324 | 290 | .update_vlan_hash = vlan_update_hash, | |
| 325 | 291 | .enable_vlan = vlan_enable, | |
| @@ -333,6 +299,7 @@ const struct stmmac_vlan_ops dwmac_vlan_ops = { | |||
| 333 | 299 | const struct stmmac_vlan_ops dwxlgmac2_vlan_ops = { | |
| 334 | 300 | .update_vlan_hash = dwxgmac2_update_vlan_hash, | |
| 335 | 301 | .enable_vlan = vlan_enable, | |
| 302 | + | .set_hw_vlan_mode = dwxlgmac2_set_hw_vlan_mode, | |
| 336 | 303 | }; | |
| 337 | 304 | ||
| 338 | 305 | const struct stmmac_vlan_ops dwxgmac210_vlan_ops = { | |
modified drivers/net/ethernet/xilinx/xilinx_axienet.h
| @@ -523,8 +523,9 @@ struct skbuf_dma_descriptor { | |||
| 523 | 523 | * @stats_work: Work for reading the hardware statistics counters often enough | |
| 524 | 524 | * to catch overflows. | |
| 525 | 525 | * @dma_err_task: Work structure to process Axi DMA errors | |
| 526 | - | * @stopping: Set when @dma_err_task shouldn't do anything because we are | |
| 527 | - | * about to stop the device. | |
| 526 | + | * @stopping: Set when we are about to stop the device: makes @dma_err_task | |
| 527 | + | * a no-op (legacy DMA path) and fences RX descriptor | |
| 528 | + | * resubmission in axienet_dma_rx_cb() (dmaengine path). | |
| 528 | 529 | * @tx_irq: Axidma TX IRQ number | |
| 529 | 530 | * @rx_irq: Axidma RX IRQ number | |
| 530 | 531 | * @eth_irq: Ethernet core IRQ number | |
| @@ -545,6 +546,7 @@ struct skbuf_dma_descriptor { | |||
| 545 | 546 | * @tx_ring_tail: TX skb ring buffer tail index. | |
| 546 | 547 | * @rx_ring_head: RX skb ring buffer head index. | |
| 547 | 548 | * @rx_ring_tail: RX skb ring buffer tail index. | |
| 549 | + | * @rx_submit_lock: Protects RX ring resubmission vs teardown in dmaengine path. | |
| 548 | 550 | */ | |
| 549 | 551 | struct axienet_local { | |
| 550 | 552 | struct net_device *ndev; | |
| @@ -626,6 +628,7 @@ struct axienet_local { | |||
| 626 | 628 | int tx_ring_tail; | |
| 627 | 629 | int rx_ring_head; | |
| 628 | 630 | int rx_ring_tail; | |
| 631 | + | spinlock_t rx_submit_lock; | |
| 629 | 632 | }; | |
| 630 | 633 | ||
| 631 | 634 | /** | |
modified drivers/net/ethernet/xilinx/xilinx_axienet_main.c
| @@ -881,6 +881,7 @@ static void axienet_dma_tx_cb(void *data, const struct dmaengine_result *result) | |||
| 881 | 881 | u64_stats_update_end(&lp->tx_stat_sync); | |
| 882 | 882 | dma_unmap_sg(lp->dev, skbuf_dma->sgl, skbuf_dma->sg_len, DMA_TO_DEVICE); | |
| 883 | 883 | dev_consume_skb_any(skbuf_dma->skb); | |
| 884 | + | skbuf_dma->skb = NULL; | |
| 884 | 885 | netif_txq_completed_wake(txq, 1, len, | |
| 885 | 886 | CIRC_SPACE(lp->tx_ring_head, lp->tx_ring_tail, TX_BD_NUM_MAX), | |
| 886 | 887 | 2); | |
| @@ -1171,6 +1172,7 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result) | |||
| 1171 | 1172 | &meta_max_len); | |
| 1172 | 1173 | dma_unmap_single(lp->dev, skbuf_dma->dma_address, lp->max_frm_size, | |
| 1173 | 1174 | DMA_FROM_DEVICE); | |
| 1175 | + | skbuf_dma->skb = NULL; | |
| 1174 | 1176 | ||
| 1175 | 1177 | if (IS_ERR(app_metadata)) { | |
| 1176 | 1178 | if (net_ratelimit()) | |
| @@ -1193,10 +1195,17 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result) | |||
| 1193 | 1195 | u64_stats_update_end(&lp->rx_stat_sync); | |
| 1194 | 1196 | ||
| 1195 | 1197 | rx_submit: | |
| 1198 | + | spin_lock(&lp->rx_submit_lock); | |
| 1199 | + | if (lp->stopping) { | |
| 1200 | + | spin_unlock(&lp->rx_submit_lock); | |
| 1201 | + | return; | |
| 1202 | + | } | |
| 1203 | + | ||
| 1196 | 1204 | for (i = 0; i < CIRC_SPACE(lp->rx_ring_head, lp->rx_ring_tail, | |
| 1197 | 1205 | RX_BUF_NUM_DEFAULT); i++) | |
| 1198 | 1206 | axienet_rx_submit_desc(lp->ndev); | |
| 1199 | 1207 | dma_async_issue_pending(lp->rx_chan); | |
| 1208 | + | spin_unlock(&lp->rx_submit_lock); | |
| 1200 | 1209 | } | |
| 1201 | 1210 | ||
| 1202 | 1211 | /** | |
| @@ -1541,6 +1550,7 @@ static int axienet_init_dmaengine(struct net_device *ndev) | |||
| 1541 | 1550 | lp->tx_ring_head = 0; | |
| 1542 | 1551 | lp->rx_ring_tail = 0; | |
| 1543 | 1552 | lp->rx_ring_head = 0; | |
| 1553 | + | lp->stopping = false; | |
| 1544 | 1554 | lp->tx_skb_ring = kzalloc_objs(*lp->tx_skb_ring, TX_BD_NUM_MAX); | |
| 1545 | 1555 | if (!lp->tx_skb_ring) { | |
| 1546 | 1556 | ret = -ENOMEM; | |
| @@ -1752,20 +1762,42 @@ static int axienet_stop(struct net_device *ndev) | |||
| 1752 | 1762 | free_irq(lp->rx_irq, ndev); | |
| 1753 | 1763 | axienet_dma_bd_release(ndev); | |
| 1754 | 1764 | } else { | |
| 1765 | + | struct skbuf_dma_descriptor *skbuf_dma; | |
| 1766 | + | ||
| 1767 | + | spin_lock_bh(&lp->rx_submit_lock); | |
| 1768 | + | lp->stopping = true; | |
| 1769 | + | spin_unlock_bh(&lp->rx_submit_lock); | |
| 1770 | + | ||
| 1755 | 1771 | dmaengine_terminate_sync(lp->tx_chan); | |
| 1756 | - | dmaengine_synchronize(lp->tx_chan); | |
| 1757 | 1772 | dmaengine_terminate_sync(lp->rx_chan); | |
| 1758 | - | dmaengine_synchronize(lp->rx_chan); | |
| 1759 | - | ||
| 1760 | - | for (i = 0; i < TX_BD_NUM_MAX; i++) | |
| 1761 | - | kfree(lp->tx_skb_ring[i]); | |
| 1762 | - | kfree(lp->tx_skb_ring); | |
| 1763 | - | for (i = 0; i < RX_BUF_NUM_DEFAULT; i++) | |
| 1764 | - | kfree(lp->rx_skb_ring[i]); | |
| 1765 | - | kfree(lp->rx_skb_ring); | |
| 1766 | 1773 | ||
| 1767 | 1774 | dma_release_channel(lp->rx_chan); | |
| 1768 | 1775 | dma_release_channel(lp->tx_chan); | |
| 1776 | + | ||
| 1777 | + | /* Unmap and free any buffer the terminate did not reclaim, so it | |
| 1778 | + | * is not leaked; a non-NULL skb marks such a slot. | |
| 1779 | + | */ | |
| 1780 | + | for (i = 0; i < TX_BD_NUM_MAX; i++) { | |
| 1781 | + | skbuf_dma = lp->tx_skb_ring[i]; | |
| 1782 | + | if (skbuf_dma && skbuf_dma->skb) { | |
| 1783 | + | dma_unmap_sg(lp->dev, skbuf_dma->sgl, | |
| 1784 | + | skbuf_dma->sg_len, DMA_TO_DEVICE); | |
| 1785 | + | dev_kfree_skb_any(skbuf_dma->skb); | |
| 1786 | + | } | |
| 1787 | + | kfree(skbuf_dma); | |
| 1788 | + | } | |
| 1789 | + | kfree(lp->tx_skb_ring); | |
| 1790 | + | ||
| 1791 | + | for (i = 0; i < RX_BUF_NUM_DEFAULT; i++) { | |
| 1792 | + | skbuf_dma = lp->rx_skb_ring[i]; | |
| 1793 | + | if (skbuf_dma && skbuf_dma->skb) { | |
| 1794 | + | dma_unmap_single(lp->dev, skbuf_dma->dma_address, | |
| 1795 | + | lp->max_frm_size, DMA_FROM_DEVICE); | |
| 1796 | + | dev_kfree_skb_any(skbuf_dma->skb); | |
| 1797 | + | } | |
| 1798 | + | kfree(skbuf_dma); | |
| 1799 | + | } | |
| 1800 | + | kfree(lp->rx_skb_ring); | |
| 1769 | 1801 | } | |
| 1770 | 1802 | ||
| 1771 | 1803 | netdev_reset_queue(ndev); | |
| @@ -3065,6 +3097,7 @@ static int axienet_probe(struct platform_device *pdev) | |||
| 3065 | 3097 | ||
| 3066 | 3098 | spin_lock_init(&lp->rx_cr_lock); | |
| 3067 | 3099 | spin_lock_init(&lp->tx_cr_lock); | |
| 3100 | + | spin_lock_init(&lp->rx_submit_lock); | |
| 3068 | 3101 | INIT_WORK(&lp->rx_dim.work, axienet_rx_dim_work); | |
| 3069 | 3102 | lp->rx_dim_enabled = true; | |
| 3070 | 3103 | lp->rx_dim.profile_ix = 1; | |
modified drivers/net/pcs/pcs-rzn1-miic.c
| @@ -270,6 +270,9 @@ static struct miic_port *phylink_pcs_to_miic_port(struct phylink_pcs *pcs) | |||
| 270 | 270 | ||
| 271 | 271 | static void miic_unlock_regs(struct miic *miic) | |
| 272 | 272 | { | |
| 273 | + | /* Clear protection state */ | |
| 274 | + | writel(0x0000, miic->base + MIIC_PRCMD); | |
| 275 | + | ||
| 273 | 276 | /* Unprotect register writes */ | |
| 274 | 277 | writel(0x00A5, miic->base + MIIC_PRCMD); | |
| 275 | 278 | writel(0x0001, miic->base + MIIC_PRCMD); | |
modified drivers/net/pfcp.c
| @@ -65,6 +65,13 @@ static int pfcp_encap_recv(struct sock *sk, struct sk_buff *skb) | |||
| 65 | 65 | goto drop; | |
| 66 | 66 | ||
| 67 | 67 | unparsed = pfcp_hdr(skb); | |
| 68 | + | if (unparsed->flags & PFCP_SEID_FLAG) { | |
| 69 | + | if (unlikely(!pskb_may_pull(skb, PFCP_HLEN + | |
| 70 | + | offsetofend(struct pfcphdr_session, | |
| 71 | + | seid)))) | |
| 72 | + | goto drop; | |
| 73 | + | unparsed = pfcp_hdr(skb); | |
| 74 | + | } | |
| 68 | 75 | ||
| 69 | 76 | ip_tunnel_flags_zero(flags); | |
| 70 | 77 | tun_dst = udp_tun_rx_dst(skb, sk->sk_family, flags, 0, | |
| @@ -105,6 +112,9 @@ drop: | |||
| 105 | 112 | ||
| 106 | 113 | static void pfcp_del_sock(struct pfcp_dev *pfcp) | |
| 107 | 114 | { | |
| 115 | + | if (!pfcp->sk) | |
| 116 | + | return; | |
| 117 | + | ||
| 108 | 118 | udp_tunnel_sock_release(pfcp->sk); | |
| 109 | 119 | pfcp->sk = NULL; | |
| 110 | 120 | } | |
modified drivers/net/phy/aquantia/aquantia_main.c
| @@ -544,7 +544,7 @@ static int aqr_gen1_read_status(struct phy_device *phydev) | |||
| 544 | 544 | if (ret) | |
| 545 | 545 | return ret; | |
| 546 | 546 | ||
| 547 | - | if (!phydev->link || phydev->autoneg == AUTONEG_DISABLE) | |
| 547 | + | if (!phydev->link) | |
| 548 | 548 | return 0; | |
| 549 | 549 | ||
| 550 | 550 | /* The status register is not immediately correct on line side link up. | |
| @@ -594,6 +594,9 @@ static int aqr_gen1_read_status(struct phy_device *phydev) | |||
| 594 | 594 | ||
| 595 | 595 | phydev->interface = aqr_translate_interface(phydev, interface); | |
| 596 | 596 | ||
| 597 | + | if (phydev->autoneg == AUTONEG_DISABLE) | |
| 598 | + | return 0; | |
| 599 | + | ||
| 597 | 600 | /* Read rate from vendor register */ | |
| 598 | 601 | return aqr_gen1_read_rate(phydev); | |
| 599 | 602 | } | |
modified drivers/net/phy/qcom/at803x.c
| @@ -1051,11 +1051,15 @@ static int ipq5018_config_init(struct phy_device *phydev) | |||
| 1051 | 1051 | if (priv->set_short_cable_dac) { | |
| 1052 | 1052 | /* setting MDAC (Multi-level Digital-to-Analog Converter) in MMD1 */ | |
| 1053 | 1053 | phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, IPQ5018_PHY_MMD1_MDAC, | |
| 1054 | - | IPQ5018_PHY_DAC_MASK, IPQ5018_PHY_MMD1_MDAC_VAL); | |
| 1054 | + | IPQ5018_PHY_DAC_MASK, | |
| 1055 | + | FIELD_PREP(IPQ5018_PHY_DAC_MASK, | |
| 1056 | + | IPQ5018_PHY_MMD1_MDAC_VAL)); | |
| 1055 | 1057 | ||
| 1056 | 1058 | /* setting EDAC (Error-detection and Correction) in debug register */ | |
| 1057 | 1059 | at803x_debug_reg_mask(phydev, IPQ5018_PHY_DEBUG_EDAC, | |
| 1058 | - | IPQ5018_PHY_DAC_MASK, IPQ5018_PHY_DEBUG_EDAC_VAL); | |
| 1060 | + | IPQ5018_PHY_DAC_MASK, | |
| 1061 | + | FIELD_PREP(IPQ5018_PHY_DAC_MASK, | |
| 1062 | + | IPQ5018_PHY_DEBUG_EDAC_VAL)); | |
| 1059 | 1063 | } | |
| 1060 | 1064 | ||
| 1061 | 1065 | return 0; | |
modified drivers/net/team/team_core.c
| @@ -820,7 +820,8 @@ static struct list_head *__team_get_qom_list(struct team *team, u16 queue_id) | |||
| 820 | 820 | /* | |
| 821 | 821 | * note: already called with rcu_read_lock | |
| 822 | 822 | */ | |
| 823 | - | static bool team_queue_override_transmit(struct team *team, struct sk_buff *skb) | |
| 823 | + | static bool team_queue_override_transmit(struct team *team, struct sk_buff *skb, | |
| 824 | + | bool *tx_success) | |
| 824 | 825 | { | |
| 825 | 826 | struct list_head *qom_list; | |
| 826 | 827 | struct team_port *port; | |
| @@ -828,11 +829,11 @@ static bool team_queue_override_transmit(struct team *team, struct sk_buff *skb) | |||
| 828 | 829 | if (!team->queue_override_enabled || !skb->queue_mapping) | |
| 829 | 830 | return false; | |
| 830 | 831 | qom_list = __team_get_qom_list(team, skb->queue_mapping); | |
| 831 | - | list_for_each_entry_rcu(port, qom_list, qom_list) { | |
| 832 | - | if (!team_dev_queue_xmit(team, port, skb)) | |
| 833 | - | return true; | |
| 834 | - | } | |
| 835 | - | return false; | |
| 832 | + | port = list_first_or_null_rcu(qom_list, struct team_port, qom_list); | |
| 833 | + | if (!port) | |
| 834 | + | return false; | |
| 835 | + | *tx_success = !team_dev_queue_xmit(team, port, skb); | |
| 836 | + | return true; | |
| 836 | 837 | } | |
| 837 | 838 | ||
| 838 | 839 | static void __team_queue_override_port_del(struct team *team, | |
| @@ -1864,8 +1865,7 @@ static netdev_tx_t team_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1864 | 1865 | bool tx_success; | |
| 1865 | 1866 | unsigned int len = skb->len; | |
| 1866 | 1867 | ||
| 1867 | - | tx_success = team_queue_override_transmit(team, skb); | |
| 1868 | - | if (!tx_success) | |
| 1868 | + | if (!team_queue_override_transmit(team, skb, &tx_success)) | |
| 1869 | 1869 | tx_success = READ_ONCE(team->ops.transmit)(team, skb); | |
| 1870 | 1870 | if (tx_success) { | |
| 1871 | 1871 | struct team_pcpu_stats *pcpu_stats; | |
modified drivers/net/team/team_mode_broadcast.c
| @@ -37,6 +37,8 @@ static bool bc_transmit(struct team *team, struct sk_buff *skb) | |||
| 37 | 37 | ret = !team_dev_queue_xmit(team, last, skb); | |
| 38 | 38 | if (!sum_ret) | |
| 39 | 39 | sum_ret = ret; | |
| 40 | + | } else { | |
| 41 | + | dev_kfree_skb_any(skb); | |
| 40 | 42 | } | |
| 41 | 43 | return sum_ret; | |
| 42 | 44 | } | |
modified drivers/net/tun.c
| @@ -1897,12 +1897,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1897 | 1897 | } | |
| 1898 | 1898 | } | |
| 1899 | 1899 | ||
| 1900 | - | if (tun_vnet_hdr_tnl_to_skb(tun->flags, features, skb, &hdr)) { | |
| 1901 | - | atomic_long_inc(&tun->rx_frame_errors); | |
| 1902 | - | err = -EINVAL; | |
| 1903 | - | goto free_skb; | |
| 1904 | - | } | |
| 1905 | - | ||
| 1900 | + | skb->dev = tun->dev; | |
| 1906 | 1901 | switch (tun->flags & TUN_TYPE_MASK) { | |
| 1907 | 1902 | case IFF_TUN: | |
| 1908 | 1903 | if (tun->flags & IFF_NO_PI) { | |
| @@ -1927,9 +1922,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1927 | 1922 | } | |
| 1928 | 1923 | } | |
| 1929 | 1924 | ||
| 1930 | - | skb_reset_mac_header(skb); | |
| 1925 | + | skb_reset_network_header(skb); | |
| 1931 | 1926 | skb->protocol = pi.proto; | |
| 1932 | - | skb->dev = tun->dev; | |
| 1933 | 1927 | break; | |
| 1934 | 1928 | case IFF_TAP: | |
| 1935 | 1929 | if (!pskb_may_pull(skb, ETH_HLEN)) { | |
| @@ -1937,10 +1931,19 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1937 | 1931 | drop_reason = SKB_DROP_REASON_HDR_TRUNC; | |
| 1938 | 1932 | goto drop; | |
| 1939 | 1933 | } | |
| 1940 | - | skb->protocol = eth_type_trans(skb, tun->dev); | |
| 1934 | + | skb_set_network_header(skb, ETH_HLEN); | |
| 1941 | 1935 | break; | |
| 1942 | 1936 | } | |
| 1943 | 1937 | ||
| 1938 | + | if (tun_vnet_hdr_tnl_to_skb(tun->flags, features, skb, &hdr)) { | |
| 1939 | + | atomic_long_inc(&tun->rx_frame_errors); | |
| 1940 | + | err = -EINVAL; | |
| 1941 | + | goto free_skb; | |
| 1942 | + | } | |
| 1943 | + | ||
| 1944 | + | if ((tun->flags & TUN_TYPE_MASK) == IFF_TAP) | |
| 1945 | + | skb->protocol = eth_type_trans(skb, tun->dev); | |
| 1946 | + | ||
| 1944 | 1947 | /* copy skb_ubuf_info for callback when skb has no error */ | |
| 1945 | 1948 | if (zerocopy) { | |
| 1946 | 1949 | skb_zcopy_init(skb, msg_control); | |
| @@ -2600,6 +2603,8 @@ build: | |||
| 2600 | 2603 | ||
| 2601 | 2604 | features = tun_vnet_hdr_guest_features(READ_ONCE(tun->vnet_hdr_sz)); | |
| 2602 | 2605 | tnl_hdr = (struct virtio_net_hdr_v1_hash_tunnel *)gso; | |
| 2606 | + | skb->dev = tun->dev; | |
| 2607 | + | skb_set_network_header(skb, ETH_HLEN); | |
| 2603 | 2608 | if (tun_vnet_hdr_tnl_to_skb(tun->flags, features, skb, tnl_hdr)) { | |
| 2604 | 2609 | atomic_long_inc(&tun->rx_frame_errors); | |
| 2605 | 2610 | kfree_skb(skb); | |
modified drivers/net/usb/ax88179_178a.c
| @@ -1457,11 +1457,11 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
| 1457 | 1457 | return 1; | |
| 1458 | 1458 | } | |
| 1459 | 1459 | ||
| 1460 | - | ax_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len); | |
| 1460 | + | ax_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len - 2); | |
| 1461 | 1461 | if (!ax_skb) | |
| 1462 | 1462 | return 0; | |
| 1463 | - | skb_put(ax_skb, pkt_len); | |
| 1464 | - | memcpy(ax_skb->data, skb->data + 2, pkt_len); | |
| 1463 | + | skb_put(ax_skb, pkt_len - 2); | |
| 1464 | + | memcpy(ax_skb->data, skb->data + 2, pkt_len - 2); | |
| 1465 | 1465 | ||
| 1466 | 1466 | ax88179_rx_checksum(ax_skb, pkt_hdr); | |
| 1467 | 1467 | usbnet_skb_return(dev, ax_skb); | |
modified drivers/net/usb/qmi_wwan.c
| @@ -1455,6 +1455,7 @@ static const struct usb_device_id products[] = { | |||
| 1455 | 1455 | {QMI_QUIRK_SET_DTR(0x1546, 0x1312, 4)}, /* u-blox LARA-R6 01B */ | |
| 1456 | 1456 | {QMI_QUIRK_SET_DTR(0x1546, 0x1342, 4)}, /* u-blox LARA-L6 */ | |
| 1457 | 1457 | {QMI_QUIRK_SET_DTR(0x33f8, 0x0104, 4)}, /* Rolling RW101 RMNET */ | |
| 1458 | + | {QMI_QUIRK_SET_DTR(0x33f8, 0x9300, 8)}, /* Rolling RN947R RMNET */ | |
| 1458 | 1459 | {QMI_FIXED_INTF(0x2dee, 0x4d22, 5)}, /* MeiG Smart SRM825L */ | |
| 1459 | 1460 | {QMI_QUIRK_SET_DTR(0x2dee, 0x4d63, 0)}, /* MeiG SRM813Q w/ Modem(PPP) */ | |
| 1460 | 1461 | {QMI_QUIRK_SET_DTR(0x2dee, 0x4d64, 0)}, /* MeiG SRM813Q w/ NMEA */ | |
modified drivers/net/veth.c
| @@ -1415,6 +1415,7 @@ static int veth_open(struct net_device *dev) | |||
| 1415 | 1415 | } | |
| 1416 | 1416 | ||
| 1417 | 1417 | veth_set_xdp_features(dev); | |
| 1418 | + | veth_set_xdp_features(peer); | |
| 1418 | 1419 | ||
| 1419 | 1420 | return 0; | |
| 1420 | 1421 | } | |
modified drivers/net/virtio_net.c
| @@ -2515,6 +2515,8 @@ static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * | |||
| 2515 | 2515 | goto frame_err; | |
| 2516 | 2516 | } | |
| 2517 | 2517 | ||
| 2518 | + | skb->dev = dev; | |
| 2519 | + | skb_set_network_header(skb, ETH_HLEN); | |
| 2518 | 2520 | if (virtio_net_hdr_tnl_to_skb(skb, &hdr->tnl_hdr, vi->rx_tnl, | |
| 2519 | 2521 | vi->rx_tnl_csum, | |
| 2520 | 2522 | virtio_is_little_endian(vi->vdev))) { | |
modified drivers/net/wireguard/noise.c
| @@ -784,10 +784,11 @@ wg_noise_handshake_consume_response(struct message_handshake_response *src, | |||
| 784 | 784 | ||
| 785 | 785 | /* Success! Copy everything to peer */ | |
| 786 | 786 | down_write(&handshake->lock); | |
| 787 | - | /* It's important to check that the state is still the same, while we | |
| 788 | - | * have an exclusive lock. | |
| 787 | + | /* Check that the state is the same and that this is still the | |
| 788 | + | * initiation we started with, while we have an exclusive lock. | |
| 789 | 789 | */ | |
| 790 | - | if (handshake->state != state) { | |
| 790 | + | if (handshake->state != state || | |
| 791 | + | crypto_memneq(handshake->ephemeral_private, ephemeral_private, NOISE_PUBLIC_KEY_LEN)) { | |
| 791 | 792 | up_write(&handshake->lock); | |
| 792 | 793 | goto fail; | |
| 793 | 794 | } | |
modified drivers/net/wireguard/queueing.h
| @@ -78,12 +78,14 @@ static inline void wg_reset_packet(struct sk_buff *skb, bool encapsulating) | |||
| 78 | 78 | u8 l4_hash = skb->l4_hash; | |
| 79 | 79 | u8 sw_hash = skb->sw_hash; | |
| 80 | 80 | u32 hash = skb->hash; | |
| 81 | + | u8 tstamp_type = skb->tstamp_type; | |
| 81 | 82 | skb_scrub_packet(skb, true); | |
| 82 | 83 | memset(&skb->headers, 0, sizeof(skb->headers)); | |
| 83 | 84 | if (encapsulating) { | |
| 84 | 85 | skb->l4_hash = l4_hash; | |
| 85 | 86 | skb->sw_hash = sw_hash; | |
| 86 | 87 | skb->hash = hash; | |
| 88 | + | skb->tstamp_type = tstamp_type; | |
| 87 | 89 | } | |
| 88 | 90 | skb->queue_mapping = 0; | |
| 89 | 91 | skb->nohdr = 0; | |
modified drivers/net/wireless/ath/ath11k/mac.c
| @@ -6716,6 +6716,7 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw) | |||
| 6716 | 6716 | ar->num_started_vdevs = 0; | |
| 6717 | 6717 | ar->num_created_vdevs = 0; | |
| 6718 | 6718 | ar->num_peers = 0; | |
| 6719 | + | ar->num_stations = 0; | |
| 6719 | 6720 | ar->allocated_vdev_map = 0; | |
| 6720 | 6721 | ||
| 6721 | 6722 | /* Configure monitor status ring with default rx_filter to get rx status | |
modified drivers/net/wireless/ath/ath12k/core.c
| @@ -1776,29 +1776,6 @@ int ath12k_core_pre_init(struct ath12k_base *ab) | |||
| 1776 | 1776 | return 0; | |
| 1777 | 1777 | } | |
| 1778 | 1778 | ||
| 1779 | - | static int ath12k_core_panic_handler(struct notifier_block *nb, | |
| 1780 | - | unsigned long action, void *data) | |
| 1781 | - | { | |
| 1782 | - | struct ath12k_base *ab = container_of(nb, struct ath12k_base, | |
| 1783 | - | panic_nb); | |
| 1784 | - | ||
| 1785 | - | return ath12k_hif_panic_handler(ab); | |
| 1786 | - | } | |
| 1787 | - | ||
| 1788 | - | static int ath12k_core_panic_notifier_register(struct ath12k_base *ab) | |
| 1789 | - | { | |
| 1790 | - | ab->panic_nb.notifier_call = ath12k_core_panic_handler; | |
| 1791 | - | ||
| 1792 | - | return atomic_notifier_chain_register(&panic_notifier_list, | |
| 1793 | - | &ab->panic_nb); | |
| 1794 | - | } | |
| 1795 | - | ||
| 1796 | - | static void ath12k_core_panic_notifier_unregister(struct ath12k_base *ab) | |
| 1797 | - | { | |
| 1798 | - | atomic_notifier_chain_unregister(&panic_notifier_list, | |
| 1799 | - | &ab->panic_nb); | |
| 1800 | - | } | |
| 1801 | - | ||
| 1802 | 1779 | static inline | |
| 1803 | 1780 | bool ath12k_core_hw_group_create_ready(struct ath12k_hw_group *ag) | |
| 1804 | 1781 | { | |
| @@ -2214,18 +2191,13 @@ int ath12k_core_init(struct ath12k_base *ab) | |||
| 2214 | 2191 | struct ath12k_hw_group *ag; | |
| 2215 | 2192 | int ret; | |
| 2216 | 2193 | ||
| 2217 | - | ret = ath12k_core_panic_notifier_register(ab); | |
| 2218 | - | if (ret) | |
| 2219 | - | ath12k_warn(ab, "failed to register panic handler: %d\n", ret); | |
| 2220 | - | ||
| 2221 | 2194 | mutex_lock(&ath12k_hw_group_mutex); | |
| 2222 | 2195 | ||
| 2223 | 2196 | ag = ath12k_core_hw_group_assign(ab); | |
| 2224 | 2197 | if (!ag) { | |
| 2225 | 2198 | mutex_unlock(&ath12k_hw_group_mutex); | |
| 2226 | 2199 | ath12k_warn(ab, "unable to get hw group\n"); | |
| 2227 | - | ret = -ENODEV; | |
| 2228 | - | goto err_unregister_notifier; | |
| 2200 | + | return -ENODEV; | |
| 2229 | 2201 | } | |
| 2230 | 2202 | ||
| 2231 | 2203 | mutex_unlock(&ath12k_hw_group_mutex); | |
| @@ -2250,8 +2222,6 @@ int ath12k_core_init(struct ath12k_base *ab) | |||
| 2250 | 2222 | ||
| 2251 | 2223 | err_unassign_hw_group: | |
| 2252 | 2224 | ath12k_core_hw_group_unassign(ab); | |
| 2253 | - | err_unregister_notifier: | |
| 2254 | - | ath12k_core_panic_notifier_unregister(ab); | |
| 2255 | 2225 | ||
| 2256 | 2226 | return ret; | |
| 2257 | 2227 | } | |
| @@ -2260,7 +2230,6 @@ void ath12k_core_deinit(struct ath12k_base *ab) | |||
| 2260 | 2230 | { | |
| 2261 | 2231 | ath12k_core_hw_group_destroy(ab->ag); | |
| 2262 | 2232 | ath12k_core_hw_group_unassign(ab); | |
| 2263 | - | ath12k_core_panic_notifier_unregister(ab); | |
| 2264 | 2233 | } | |
| 2265 | 2234 | ||
| 2266 | 2235 | void ath12k_core_free(struct ath12k_base *ab) | |
modified drivers/net/wireless/ath/ath12k/core.h
| @@ -15,7 +15,6 @@ | |||
| 15 | 15 | #include <linux/ctype.h> | |
| 16 | 16 | #include <linux/firmware.h> | |
| 17 | 17 | #include <linux/of_reserved_mem.h> | |
| 18 | - | #include <linux/panic_notifier.h> | |
| 19 | 18 | #include <linux/average.h> | |
| 20 | 19 | #include <linux/of.h> | |
| 21 | 20 | #include <linux/rhashtable.h> | |
| @@ -1139,8 +1138,6 @@ struct ath12k_base { | |||
| 1139 | 1138 | ||
| 1140 | 1139 | #endif /* CONFIG_ACPI */ | |
| 1141 | 1140 | ||
| 1142 | - | struct notifier_block panic_nb; | |
| 1143 | - | ||
| 1144 | 1141 | struct ath12k_hw_group *ag; | |
| 1145 | 1142 | struct ath12k_wsi_info wsi_info; | |
| 1146 | 1143 | enum ath12k_qmi_firmware_mode fw_mode; | |
modified drivers/net/wireless/ath/ath12k/hif.h
| @@ -30,7 +30,6 @@ struct ath12k_hif_ops { | |||
| 30 | 30 | void (*ce_irq_enable)(struct ath12k_base *ab); | |
| 31 | 31 | void (*ce_irq_disable)(struct ath12k_base *ab); | |
| 32 | 32 | void (*get_ce_msi_idx)(struct ath12k_base *ab, u32 ce_id, u32 *msi_idx); | |
| 33 | - | int (*panic_handler)(struct ath12k_base *ab); | |
| 34 | 33 | void (*coredump_download)(struct ath12k_base *ab); | |
| 35 | 34 | }; | |
| 36 | 35 | ||
| @@ -149,14 +148,6 @@ static inline void ath12k_hif_power_down(struct ath12k_base *ab, bool is_suspend | |||
| 149 | 148 | ab->hif.ops->power_down(ab, is_suspend); | |
| 150 | 149 | } | |
| 151 | 150 | ||
| 152 | - | static inline int ath12k_hif_panic_handler(struct ath12k_base *ab) | |
| 153 | - | { | |
| 154 | - | if (!ab->hif.ops->panic_handler) | |
| 155 | - | return NOTIFY_DONE; | |
| 156 | - | ||
| 157 | - | return ab->hif.ops->panic_handler(ab); | |
| 158 | - | } | |
| 159 | - | ||
| 160 | 151 | static inline void ath12k_hif_coredump_download(struct ath12k_base *ab) | |
| 161 | 152 | { | |
| 162 | 153 | if (ab->hif.ops->coredump_download) | |
modified drivers/net/wireless/ath/ath12k/pci.c
| @@ -1484,13 +1484,6 @@ void ath12k_pci_power_down(struct ath12k_base *ab, bool is_suspend) | |||
| 1484 | 1484 | ath12k_pci_sw_reset(ab_pci->ab, false); | |
| 1485 | 1485 | } | |
| 1486 | 1486 | ||
| 1487 | - | static int ath12k_pci_panic_handler(struct ath12k_base *ab) | |
| 1488 | - | { | |
| 1489 | - | ath12k_pci_sw_reset(ab, false); | |
| 1490 | - | ||
| 1491 | - | return NOTIFY_OK; | |
| 1492 | - | } | |
| 1493 | - | ||
| 1494 | 1487 | static const struct ath12k_hif_ops ath12k_pci_hif_ops = { | |
| 1495 | 1488 | .start = ath12k_pci_start, | |
| 1496 | 1489 | .stop = ath12k_pci_stop, | |
| @@ -1508,7 +1501,6 @@ static const struct ath12k_hif_ops ath12k_pci_hif_ops = { | |||
| 1508 | 1501 | .ce_irq_enable = ath12k_pci_hif_ce_irq_enable, | |
| 1509 | 1502 | .ce_irq_disable = ath12k_pci_hif_ce_irq_disable, | |
| 1510 | 1503 | .get_ce_msi_idx = ath12k_pci_get_ce_msi_idx, | |
| 1511 | - | .panic_handler = ath12k_pci_panic_handler, | |
| 1512 | 1504 | #ifdef CONFIG_ATH12K_COREDUMP | |
| 1513 | 1505 | .coredump_download = ath12k_pci_coredump_download, | |
| 1514 | 1506 | #endif | |
modified drivers/net/wireless/ath/ath9k/hif_usb.c
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 15 | 15 | */ | |
| 16 | 16 | ||
| 17 | + | #include <linux/math.h> | |
| 17 | 18 | #include <linux/unaligned.h> | |
| 18 | 19 | #include "htc.h" | |
| 19 | 20 | ||
| @@ -328,11 +329,14 @@ static int __hif_usb_tx(struct hif_device_usb *hif_dev) | |||
| 328 | 329 | tx_skb_cnt = min_t(u16, hif_dev->tx.tx_skb_cnt, MAX_TX_AGGR_NUM); | |
| 329 | 330 | ||
| 330 | 331 | for (i = 0; i < tx_skb_cnt; i++) { | |
| 331 | - | nskb = __skb_dequeue(&hif_dev->tx.tx_skb_queue); | |
| 332 | + | nskb = skb_peek(&hif_dev->tx.tx_skb_queue); | |
| 333 | + | if (!nskb) | |
| 334 | + | break; | |
| 332 | 335 | ||
| 333 | - | /* Should never be NULL */ | |
| 334 | - | BUG_ON(!nskb); | |
| 336 | + | if (tx_buf->offset + nskb->len + 4 > MAX_TX_BUF_SIZE) | |
| 337 | + | break; | |
| 335 | 338 | ||
| 339 | + | nskb = __skb_dequeue(&hif_dev->tx.tx_skb_queue); | |
| 336 | 340 | hif_dev->tx.tx_skb_cnt--; | |
| 337 | 341 | ||
| 338 | 342 | buf = tx_buf->buf; | |
| @@ -342,13 +346,8 @@ static int __hif_usb_tx(struct hif_device_usb *hif_dev) | |||
| 342 | 346 | *hdr++ = cpu_to_le16(ATH_USB_TX_STREAM_MODE_TAG); | |
| 343 | 347 | buf += 4; | |
| 344 | 348 | memcpy(buf, nskb->data, nskb->len); | |
| 345 | - | tx_buf->len = nskb->len + 4; | |
| 346 | - | ||
| 347 | - | if (i < (tx_skb_cnt - 1)) | |
| 348 | - | tx_buf->offset += (((tx_buf->len - 1) / 4) + 1) * 4; | |
| 349 | - | ||
| 350 | - | if (i == (tx_skb_cnt - 1)) | |
| 351 | - | tx_buf->len += tx_buf->offset; | |
| 349 | + | tx_buf->len = tx_buf->offset + nskb->len + 4; | |
| 350 | + | tx_buf->offset += round_up(nskb->len + 4, 4); | |
| 352 | 351 | ||
| 353 | 352 | __skb_queue_tail(&tx_buf->skb_queue, nskb); | |
| 354 | 353 | TX_STAT_INC(hif_dev, skb_queued); | |
modified drivers/net/wireless/ath/ath9k/htc.h
| @@ -281,7 +281,6 @@ struct ath9k_htc_rxbuf { | |||
| 281 | 281 | struct ath9k_htc_rx { | |
| 282 | 282 | struct list_head rxbuf; | |
| 283 | 283 | spinlock_t rxbuflock; | |
| 284 | - | bool initialized; | |
| 285 | 284 | }; | |
| 286 | 285 | ||
| 287 | 286 | #define ATH9K_HTC_TX_CLEANUP_INTERVAL 50 /* ms */ | |
modified drivers/net/wireless/ath/ath9k/htc_drv_init.c
| @@ -910,6 +910,9 @@ static int ath9k_init_device(struct ath9k_htc_priv *priv, | |||
| 910 | 910 | ath9k_init_leds(priv); | |
| 911 | 911 | ath9k_start_rfkill_poll(priv); | |
| 912 | 912 | ||
| 913 | + | /* signal completion to ath9k_htc_rxep() and ath9k_wmi_event_tasklet() */ | |
| 914 | + | smp_store_release(&priv->initialized, true); | |
| 915 | + | ||
| 913 | 916 | return 0; | |
| 914 | 917 | ||
| 915 | 918 | err_world: | |
| @@ -966,10 +969,6 @@ int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev, | |||
| 966 | 969 | ||
| 967 | 970 | htc_handle->drv_priv = priv; | |
| 968 | 971 | ||
| 969 | - | /* Allow ath9k_wmi_event_tasklet() to operate. */ | |
| 970 | - | smp_wmb(); | |
| 971 | - | priv->initialized = true; | |
| 972 | - | ||
| 973 | 972 | return 0; | |
| 974 | 973 | ||
| 975 | 974 | err_init: | |
modified drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
| @@ -1141,8 +1141,8 @@ void ath9k_htc_rxep(void *drv_priv, struct sk_buff *skb, | |||
| 1141 | 1141 | struct ath9k_htc_rxbuf *rxbuf = NULL, *tmp_buf = NULL; | |
| 1142 | 1142 | unsigned long flags; | |
| 1143 | 1143 | ||
| 1144 | - | /* Check if ath9k_rx_init() completed. */ | |
| 1145 | - | if (!data_race(priv->rx.initialized)) | |
| 1144 | + | /* Check if ath9k_init_device() completed. */ | |
| 1145 | + | if (!smp_load_acquire(&priv->initialized)) | |
| 1146 | 1146 | goto err; | |
| 1147 | 1147 | ||
| 1148 | 1148 | spin_lock_irqsave(&priv->rx.rxbuflock, flags); | |
| @@ -1200,10 +1200,6 @@ int ath9k_rx_init(struct ath9k_htc_priv *priv) | |||
| 1200 | 1200 | list_add_tail(&rxbuf->list, &priv->rx.rxbuf); | |
| 1201 | 1201 | } | |
| 1202 | 1202 | ||
| 1203 | - | /* Allow ath9k_htc_rxep() to operate. */ | |
| 1204 | - | smp_wmb(); | |
| 1205 | - | priv->rx.initialized = true; | |
| 1206 | - | ||
| 1207 | 1203 | return 0; | |
| 1208 | 1204 | ||
| 1209 | 1205 | err: | |
modified drivers/net/wireless/ath/ath9k/wmi.c
| @@ -146,6 +146,12 @@ void ath9k_wmi_event_tasklet(struct tasklet_struct *t) | |||
| 146 | 146 | unsigned long flags; | |
| 147 | 147 | u16 cmd_id; | |
| 148 | 148 | ||
| 149 | + | /* Check if ath9k_init_device() completed. */ | |
| 150 | + | if (!smp_load_acquire(&priv->initialized)) { | |
| 151 | + | tasklet_schedule(t); | |
| 152 | + | return; | |
| 153 | + | } | |
| 154 | + | ||
| 149 | 155 | do { | |
| 150 | 156 | spin_lock_irqsave(&wmi->wmi_lock, flags); | |
| 151 | 157 | skb = __skb_dequeue(&wmi->wmi_event_queue); | |
| @@ -155,12 +161,6 @@ void ath9k_wmi_event_tasklet(struct tasklet_struct *t) | |||
| 155 | 161 | } | |
| 156 | 162 | spin_unlock_irqrestore(&wmi->wmi_lock, flags); | |
| 157 | 163 | ||
| 158 | - | /* Check if ath9k_htc_probe_device() completed. */ | |
| 159 | - | if (!data_race(priv->initialized)) { | |
| 160 | - | kfree_skb(skb); | |
| 161 | - | continue; | |
| 162 | - | } | |
| 163 | - | ||
| 164 | 164 | hdr = (struct wmi_cmd_hdr *) skb->data; | |
| 165 | 165 | cmd_id = be16_to_cpu(hdr->command_id); | |
| 166 | 166 | wmi_event = skb_pull(skb, sizeof(struct wmi_cmd_hdr)); | |
| @@ -206,9 +206,16 @@ static void ath9k_wmi_rsp_callback(struct wmi *wmi, struct sk_buff *skb) | |||
| 206 | 206 | { | |
| 207 | 207 | skb_pull(skb, sizeof(struct wmi_cmd_hdr)); | |
| 208 | 208 | ||
| 209 | - | if (wmi->cmd_rsp_buf != NULL && wmi->cmd_rsp_len != 0) | |
| 209 | + | if (wmi->cmd_rsp_buf && wmi->cmd_rsp_len) { | |
| 210 | + | if (skb->len < wmi->cmd_rsp_len) { | |
| 211 | + | wmi->cmd_rsp_status = -EMSGSIZE; | |
| 212 | + | goto complete; | |
| 213 | + | } | |
| 210 | 214 | memcpy(wmi->cmd_rsp_buf, skb->data, wmi->cmd_rsp_len); | |
| 215 | + | } | |
| 216 | + | wmi->cmd_rsp_status = 0; | |
| 211 | 217 | ||
| 218 | + | complete: | |
| 212 | 219 | complete(&wmi->cmd_wait); | |
| 213 | 220 | } | |
| 214 | 221 | ||
| @@ -300,6 +307,7 @@ static int ath9k_wmi_cmd_issue(struct wmi *wmi, | |||
| 300 | 307 | /* record the rsp buffer and length */ | |
| 301 | 308 | wmi->cmd_rsp_buf = rsp_buf; | |
| 302 | 309 | wmi->cmd_rsp_len = rsp_len; | |
| 310 | + | wmi->cmd_rsp_status = 0; | |
| 303 | 311 | ||
| 304 | 312 | wmi->last_seq_id = wmi->tx_seq_id; | |
| 305 | 313 | spin_unlock_irqrestore(&wmi->wmi_lock, flags); | |
| @@ -356,9 +364,13 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id, | |||
| 356 | 364 | return -ETIMEDOUT; | |
| 357 | 365 | } | |
| 358 | 366 | ||
| 367 | + | spin_lock_irqsave(&wmi->wmi_lock, flags); | |
| 368 | + | ret = wmi->cmd_rsp_status; | |
| 369 | + | spin_unlock_irqrestore(&wmi->wmi_lock, flags); | |
| 370 | + | ||
| 359 | 371 | mutex_unlock(&wmi->op_mutex); | |
| 360 | 372 | ||
| 361 | - | return 0; | |
| 373 | + | return ret; | |
| 362 | 374 | ||
| 363 | 375 | out: | |
| 364 | 376 | ath_dbg(common, WMI, "WMI failure for: %s\n", wmi_cmd_to_name(cmd_id)); | |
modified drivers/net/wireless/ath/ath9k/wmi.h
| @@ -157,6 +157,7 @@ struct wmi { | |||
| 157 | 157 | u16 tx_seq_id; | |
| 158 | 158 | u8 *cmd_rsp_buf; | |
| 159 | 159 | u32 cmd_rsp_len; | |
| 160 | + | int cmd_rsp_status; | |
| 160 | 161 | bool stopped; | |
| 161 | 162 | ||
| 162 | 163 | struct list_head pending_tx_events; | |
modified drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
| @@ -1489,8 +1489,31 @@ void brcmf_detach(struct device *dev) | |||
| 1489 | 1489 | brcmf_bus_change_state(bus_if, BRCMF_BUS_DOWN); | |
| 1490 | 1490 | /* make sure primary interface removed last */ | |
| 1491 | 1491 | for (i = BRCMF_MAX_IFS - 1; i > -1; i--) { | |
| 1492 | - | if (drvr->iflist[i]) | |
| 1493 | - | brcmf_remove_interface(drvr->iflist[i], false); | |
| 1492 | + | struct brcmf_if *ifp = drvr->iflist[i]; | |
| 1493 | + | ||
| 1494 | + | if (!ifp) | |
| 1495 | + | continue; | |
| 1496 | + | ||
| 1497 | + | if (ifp->ndev) { | |
| 1498 | + | brcmf_remove_interface(ifp, false); | |
| 1499 | + | continue; | |
| 1500 | + | } | |
| 1501 | + | ||
| 1502 | + | /* The P2P device interface has no netdev. Its removal can | |
| 1503 | + | * race with NL80211_CMD_DEL_INTERFACE issued by a user space | |
| 1504 | + | * process that is exiting (e.g. wpa_supplicant), which ends | |
| 1505 | + | * in brcmf_p2p_del_vif() under RTNL and the wiphy mutex. If | |
| 1506 | + | * both paths remove the interface, the wdev is unregistered | |
| 1507 | + | * twice and the vif is used after being freed. Take the same | |
| 1508 | + | * locks and re-read iflist, so only one path removes it. | |
| 1509 | + | */ | |
| 1510 | + | rtnl_lock(); | |
| 1511 | + | wiphy_lock(drvr->wiphy); | |
| 1512 | + | ifp = drvr->iflist[i]; | |
| 1513 | + | if (ifp) | |
| 1514 | + | brcmf_remove_interface(ifp, true); | |
| 1515 | + | wiphy_unlock(drvr->wiphy); | |
| 1516 | + | rtnl_unlock(); | |
| 1494 | 1517 | } | |
| 1495 | 1518 | brcmf_bus_stop(drvr->bus_if); | |
| 1496 | 1519 | ||
modified drivers/net/wireless/intel/iwlegacy/3945-mac.c
| @@ -3807,6 +3807,7 @@ il3945_pci_remove(struct pci_dev *pdev) | |||
| 3807 | 3807 | ||
| 3808 | 3808 | il_free_channel_map(il); | |
| 3809 | 3809 | il_free_geos(il); | |
| 3810 | + | il_eeprom_free(il); | |
| 3810 | 3811 | kfree(il->scan_cmd); | |
| 3811 | 3812 | dev_kfree_skb(il->beacon_skb); | |
| 3812 | 3813 | ieee80211_free_hw(il->hw); | |
modified drivers/net/wireless/intersil/p54/fwio.c
| @@ -52,6 +52,13 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw) | |||
| 52 | 52 | u32 code = le32_to_cpu(bootrec->code); | |
| 53 | 53 | switch (code) { | |
| 54 | 54 | case BR_CODE_COMPONENT_ID: | |
| 55 | + | if (len < sizeof(struct bootrec_comp_id) / | |
| 56 | + | sizeof(*bootrec->data)) { | |
| 57 | + | wiphy_err(priv->hw->wiphy, | |
| 58 | + | "firmware component ID is too short\n"); | |
| 59 | + | return -EINVAL; | |
| 60 | + | } | |
| 61 | + | ||
| 55 | 62 | priv->fw_interface = be32_to_cpup((__be32 *) | |
| 56 | 63 | bootrec->data); | |
| 57 | 64 | switch (priv->fw_interface) { | |
| @@ -72,16 +79,41 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw) | |||
| 72 | 79 | } | |
| 73 | 80 | break; | |
| 74 | 81 | case BR_CODE_COMPONENT_VERSION: | |
| 82 | + | if (len < DIV_ROUND_UP(sizeof(struct bootrec_comp_ver), | |
| 83 | + | sizeof(*bootrec->data))) { | |
| 84 | + | wiphy_err(priv->hw->wiphy, | |
| 85 | + | "firmware component version is too short\n"); | |
| 86 | + | return -EINVAL; | |
| 87 | + | } | |
| 88 | + | ||
| 75 | 89 | /* 24 bytes should be enough for all firmwares */ | |
| 76 | - | if (strnlen((unsigned char *) bootrec->data, 24) < 24) | |
| 77 | - | fw_version = (unsigned char *) bootrec->data; | |
| 90 | + | if (strnlen((unsigned char *)bootrec->data, | |
| 91 | + | sizeof(struct bootrec_comp_ver)) < | |
| 92 | + | sizeof(struct bootrec_comp_ver)) | |
| 93 | + | fw_version = (unsigned char *)bootrec->data; | |
| 78 | 94 | break; | |
| 79 | 95 | case BR_CODE_DESCR: { | |
| 80 | 96 | struct bootrec_desc *desc = | |
| 81 | 97 | (struct bootrec_desc *)bootrec->data; | |
| 82 | - | priv->rx_start = le32_to_cpu(desc->rx_start); | |
| 83 | - | /* FIXME add sanity checking */ | |
| 84 | - | priv->rx_end = le32_to_cpu(desc->rx_end) - 0x3500; | |
| 98 | + | u32 rx_start, rx_end; | |
| 99 | + | ||
| 100 | + | /* 0xa is the shortest descriptor in supported firmware. */ | |
| 101 | + | if (len < 0xa) { | |
| 102 | + | wiphy_err(priv->hw->wiphy, | |
| 103 | + | "firmware descriptor is too short\n"); | |
| 104 | + | return -EINVAL; | |
| 105 | + | } | |
| 106 | + | ||
| 107 | + | rx_start = le32_to_cpu(desc->rx_start); | |
| 108 | + | rx_end = le32_to_cpu(desc->rx_end); | |
| 109 | + | if (rx_end < 0x3500 || rx_end - 0x3500 <= rx_start) { | |
| 110 | + | wiphy_err(priv->hw->wiphy, | |
| 111 | + | "firmware descriptor has invalid RX range\n"); | |
| 112 | + | return -EINVAL; | |
| 113 | + | } | |
| 114 | + | ||
| 115 | + | priv->rx_start = rx_start; | |
| 116 | + | priv->rx_end = rx_end - 0x3500; | |
| 85 | 117 | priv->headroom = desc->headroom; | |
| 86 | 118 | priv->tailroom = desc->tailroom; | |
| 87 | 119 | priv->privacy_caps = desc->privacy_caps; | |
modified drivers/net/wireless/marvell/libertas/tx.c
| @@ -117,13 +117,6 @@ netdev_tx_t lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 117 | 117 | if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) { | |
| 118 | 118 | struct tx_radiotap_hdr *rtap_hdr = (void *)skb->data; | |
| 119 | 119 | ||
| 120 | - | if (skb->len < sizeof(*rtap_hdr) + 4 + ETH_ALEN) { | |
| 121 | - | lbs_deb_tx("tx err: short monitor frame %u\n", skb->len); | |
| 122 | - | dev->stats.tx_dropped++; | |
| 123 | - | dev->stats.tx_errors++; | |
| 124 | - | goto free; | |
| 125 | - | } | |
| 126 | - | ||
| 127 | 120 | /* set txpd fields from the radiotap header */ | |
| 128 | 121 | txpd->tx_control = cpu_to_le32(convert_radiotap_rate_to_mv(rtap_hdr->rate)); | |
| 129 | 122 | ||
modified drivers/net/wireless/mediatek/mt76/mt76.h
| @@ -1426,6 +1426,13 @@ mtxq_to_txq(struct mt76_txq *mtxq) | |||
| 1426 | 1426 | return container_of(ptr, struct ieee80211_txq, drv_priv); | |
| 1427 | 1427 | } | |
| 1428 | 1428 | ||
| 1429 | + | /* peer-wide state uses the wcid of the primary link */ | |
| 1430 | + | static inline struct mt76_wcid * | |
| 1431 | + | mt76_wcid_primary(struct mt76_wcid *wcid) | |
| 1432 | + | { | |
| 1433 | + | return wcid->def_wcid ? wcid->def_wcid : wcid; | |
| 1434 | + | } | |
| 1435 | + | ||
| 1429 | 1436 | static inline struct ieee80211_sta * | |
| 1430 | 1437 | wcid_to_sta(struct mt76_wcid *wcid) | |
| 1431 | 1438 | { | |
modified drivers/net/wireless/mediatek/mt76/mt7603/init.c
| @@ -230,6 +230,7 @@ mt7603_mac_init(struct mt7603_dev *dev) | |||
| 230 | 230 | ||
| 231 | 231 | eth_broadcast_addr(bc_addr); | |
| 232 | 232 | mt7603_wtbl_init(dev, MT7603_WTBL_RESERVED, -1, bc_addr); | |
| 233 | + | mt76_wcid_init(&dev->global_sta.wcid, 0); | |
| 233 | 234 | dev->global_sta.wcid.idx = MT7603_WTBL_RESERVED; | |
| 234 | 235 | rcu_assign_pointer(dev->mt76.wcid[MT7603_WTBL_RESERVED], | |
| 235 | 236 | &dev->global_sta.wcid); | |
modified drivers/net/wireless/mediatek/mt76/mt7915/init.c
| @@ -1238,6 +1238,12 @@ static void mt7915_unregister_ext_phy(struct mt7915_dev *dev) | |||
| 1238 | 1238 | ||
| 1239 | 1239 | static void mt7915_stop_hardware(struct mt7915_dev *dev) | |
| 1240 | 1240 | { | |
| 1241 | + | int i; | |
| 1242 | + | ||
| 1243 | + | mt76_for_each_q_rx(&dev->mt76, i) { | |
| 1244 | + | if (!mt76_queue_is_wed_rro(&dev->mt76.q_rx[i])) | |
| 1245 | + | napi_disable(&dev->mt76.napi[i]); | |
| 1246 | + | } | |
| 1241 | 1247 | mt7915_mcu_exit(dev); | |
| 1242 | 1248 | mt76_connac2_tx_token_put(&dev->mt76); | |
| 1243 | 1249 | mt7915_dma_cleanup(dev); | |
modified drivers/net/wireless/mediatek/mt76/mt7915/main.c
| @@ -805,6 +805,7 @@ __mt7915_drop_sta(void *ptr, u8 *mac, struct ieee80211_vif *vif) | |||
| 805 | 805 | ||
| 806 | 806 | msta = (struct mt7915_sta *)sta->drv_priv; | |
| 807 | 807 | mt7915_mcu_add_sta(data->dev, vif, sta, CONN_STATE_DISCONNECT, false); | |
| 808 | + | msta->wcid.tx_info &= ~MT_WCID_TX_INFO_SET; | |
| 808 | 809 | msta->wcid.sta_disabled = 1; | |
| 809 | 810 | msta->wcid.sta = 0; | |
| 810 | 811 | } | |
| @@ -871,6 +872,7 @@ int mt7915_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif, | |||
| 871 | 872 | mutex_unlock(&dev->mt76.mutex); | |
| 872 | 873 | ||
| 873 | 874 | mt7915_mcu_add_sta(dev, vif, sta, CONN_STATE_DISCONNECT, false); | |
| 875 | + | msta->wcid.tx_info &= ~MT_WCID_TX_INFO_SET; | |
| 874 | 876 | msta->wcid.sta_disabled = 1; | |
| 875 | 877 | msta->wcid.sta = 0; | |
| 876 | 878 | return 0; | |
modified drivers/net/wireless/mediatek/mt76/mt7925/mac.c
| @@ -798,7 +798,8 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, | |||
| 798 | 798 | val = FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) | | |
| 799 | 799 | FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx); | |
| 800 | 800 | ||
| 801 | - | if (band_idx) | |
| 801 | + | /* 0xff means BAND_AUTO to the firmware, and TGID cannot encode it */ | |
| 802 | + | if (band_idx && band_idx != 0xff) | |
| 802 | 803 | val |= FIELD_PREP(MT_TXD1_TGID, band_idx); | |
| 803 | 804 | ||
| 804 | 805 | txwi[1] = cpu_to_le32(val); | |
modified drivers/net/wireless/mediatek/mt76/mt7925/main.c
| @@ -2294,6 +2294,18 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |||
| 2294 | 2294 | ||
| 2295 | 2295 | mvif->valid_links = new_links; | |
| 2296 | 2296 | ||
| 2297 | + | /* Restore the legacy BSS after disabling MLO */ | |
| 2298 | + | if (old_links && !new_links) { | |
| 2299 | + | mt792x_mac_link_bss_remove(dev, &mvif->bss_conf, | |
| 2300 | + | &mvif->sta.deflink); | |
| 2301 | + | err = mt7925_mac_link_bss_add(dev, &vif->bss_conf, | |
| 2302 | + | &mvif->sta.deflink); | |
| 2303 | + | if (err < 0) { | |
| 2304 | + | mt792x_mutex_release(dev); | |
| 2305 | + | return err; | |
| 2306 | + | } | |
| 2307 | + | } | |
| 2308 | + | ||
| 2297 | 2309 | mt792x_mutex_release(dev); | |
| 2298 | 2310 | ||
| 2299 | 2311 | return 0; | |
modified drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
| @@ -108,68 +108,98 @@ mt792x_asar_acpi_read_mtcl(struct mt792x_dev *dev, u8 **table, u8 *version) | |||
| 108 | 108 | return ret; | |
| 109 | 109 | } | |
| 110 | 110 | ||
| 111 | + | /* A table's layout is decided by the version byte in MTCL, but some firmware | |
| 112 | + | * labels a version 2 table as version 1. Accept whichever layout the table | |
| 113 | + | * actually has: for every accepted entry count the two do not overlap, since | |
| 114 | + | * one is 6 + 5n bytes and the other 7 + 7n. | |
| 115 | + | */ | |
| 116 | + | static bool | |
| 117 | + | mt792x_asar_fits(u8 *table, int len, int prelen, int sarlen, int nr_off, | |
| 118 | + | int min, int max) | |
| 119 | + | { | |
| 120 | + | int tblcnt; | |
| 121 | + | ||
| 122 | + | if (len < prelen || (len - prelen) % sarlen) | |
| 123 | + | return false; | |
| 124 | + | ||
| 125 | + | tblcnt = (len - prelen) / sarlen; | |
| 126 | + | if (tblcnt < min || tblcnt > max) | |
| 127 | + | return false; | |
| 128 | + | ||
| 129 | + | return tblcnt == table[nr_off]; | |
| 130 | + | } | |
| 131 | + | ||
| 111 | 132 | /* MTDS : Dynamic SAR Power Table */ | |
| 112 | 133 | static int | |
| 113 | - | mt792x_asar_acpi_read_mtds(struct mt792x_dev *dev, u8 **table, u8 version) | |
| 134 | + | mt792x_asar_acpi_read_mtds(struct mt792x_dev *dev, u8 **table, u8 version, | |
| 135 | + | u8 *used) | |
| 114 | 136 | { | |
| 115 | - | int len, ret, sarlen, prelen, tblcnt; | |
| 116 | - | bool enable; | |
| 137 | + | int len, ret; | |
| 138 | + | u8 *t; | |
| 117 | 139 | ||
| 118 | 140 | ret = mt792x_acpi_read(dev, MT792x_ACPI_MTDS, table, &len); | |
| 119 | 141 | if (ret) | |
| 120 | 142 | return ret; | |
| 121 | 143 | ||
| 144 | + | t = *table; | |
| 145 | + | ||
| 122 | 146 | /* Table content validation */ | |
| 123 | - | switch (version) { | |
| 124 | - | case 1: | |
| 125 | - | enable = ((struct mt792x_asar_dyn *)*table)->enable; | |
| 126 | - | sarlen = sizeof(struct mt792x_asar_dyn_limit); | |
| 127 | - | prelen = sizeof(struct mt792x_asar_dyn); | |
| 128 | - | break; | |
| 129 | - | case 2: | |
| 130 | - | enable = ((struct mt792x_asar_dyn_v2 *)*table)->enable; | |
| 131 | - | sarlen = sizeof(struct mt792x_asar_dyn_limit_v2); | |
| 132 | - | prelen = sizeof(struct mt792x_asar_dyn_v2); | |
| 133 | - | break; | |
| 134 | - | default: | |
| 147 | + | if (mt792x_asar_fits(t, len, sizeof(struct mt792x_asar_dyn), | |
| 148 | + | sizeof(struct mt792x_asar_dyn_limit), | |
| 149 | + | offsetof(struct mt792x_asar_dyn, nr_tbl), | |
| 150 | + | MT792x_ASAR_MIN_DYN, MT792x_ASAR_MAX_DYN)) | |
| 151 | + | *used = 1; | |
| 152 | + | else if (mt792x_asar_fits(t, len, sizeof(struct mt792x_asar_dyn_v2), | |
| 153 | + | sizeof(struct mt792x_asar_dyn_limit_v2), | |
| 154 | + | offsetof(struct mt792x_asar_dyn_v2, nr_tbl), | |
| 155 | + | MT792x_ASAR_MIN_DYN, MT792x_ASAR_MAX_DYN)) | |
| 156 | + | *used = 2; | |
| 157 | + | else | |
| 135 | 158 | return -EINVAL; | |
| 136 | - | } | |
| 137 | 159 | ||
| 138 | - | tblcnt = (len - prelen) / sarlen; | |
| 139 | - | if (!enable || | |
| 140 | - | tblcnt > MT792x_ASAR_MAX_DYN || tblcnt < MT792x_ASAR_MIN_DYN) | |
| 160 | + | if (!t[offsetof(struct mt792x_asar_dyn, enable)]) | |
| 141 | 161 | return -EINVAL; | |
| 142 | 162 | ||
| 163 | + | if (version && *used != version) | |
| 164 | + | dev_info(dev->mt76.dev, | |
| 165 | + | "MTDS is v%u, MTCL says v%u; using v%u\n", | |
| 166 | + | *used, version, *used); | |
| 167 | + | ||
| 143 | 168 | return 0; | |
| 144 | 169 | } | |
| 145 | 170 | ||
| 146 | 171 | /* MTGS : Geo SAR Power Table */ | |
| 147 | 172 | static int | |
| 148 | - | mt792x_asar_acpi_read_mtgs(struct mt792x_dev *dev, u8 **table, u8 version) | |
| 173 | + | mt792x_asar_acpi_read_mtgs(struct mt792x_dev *dev, u8 **table, u8 version, | |
| 174 | + | u8 *used) | |
| 149 | 175 | { | |
| 150 | - | int len, ret, sarlen, prelen, tblcnt; | |
| 176 | + | int len, ret; | |
| 177 | + | u8 *t; | |
| 151 | 178 | ||
| 152 | 179 | ret = mt792x_acpi_read(dev, MT792x_ACPI_MTGS, table, &len); | |
| 153 | 180 | if (ret) | |
| 154 | 181 | return ret; | |
| 155 | 182 | ||
| 183 | + | t = *table; | |
| 184 | + | ||
| 156 | 185 | /* Table content validation */ | |
| 157 | - | switch (version) { | |
| 158 | - | case 1: | |
| 159 | - | sarlen = sizeof(struct mt792x_asar_geo_limit); | |
| 160 | - | prelen = sizeof(struct mt792x_asar_geo); | |
| 161 | - | break; | |
| 162 | - | case 2: | |
| 163 | - | sarlen = sizeof(struct mt792x_asar_geo_limit_v2); | |
| 164 | - | prelen = sizeof(struct mt792x_asar_geo_v2); | |
| 165 | - | break; | |
| 166 | - | default: | |
| 186 | + | if (mt792x_asar_fits(t, len, sizeof(struct mt792x_asar_geo), | |
| 187 | + | sizeof(struct mt792x_asar_geo_limit), | |
| 188 | + | offsetof(struct mt792x_asar_geo, nr_tbl), | |
| 189 | + | MT792x_ASAR_MIN_GEO, MT792x_ASAR_MAX_GEO)) | |
| 190 | + | *used = 1; | |
| 191 | + | else if (mt792x_asar_fits(t, len, sizeof(struct mt792x_asar_geo_v2), | |
| 192 | + | sizeof(struct mt792x_asar_geo_limit_v2), | |
| 193 | + | offsetof(struct mt792x_asar_geo_v2, nr_tbl), | |
| 194 | + | MT792x_ASAR_MIN_GEO, MT792x_ASAR_MAX_GEO)) | |
| 195 | + | *used = 2; | |
| 196 | + | else | |
| 167 | 197 | return -EINVAL; | |
| 168 | - | } | |
| 169 | 198 | ||
| 170 | - | tblcnt = (len - prelen) / sarlen; | |
| 171 | - | if (tblcnt > MT792x_ASAR_MAX_GEO || tblcnt < MT792x_ASAR_MIN_GEO) | |
| 172 | - | return -EINVAL; | |
| 199 | + | if (version && *used != version) | |
| 200 | + | dev_info(dev->mt76.dev, | |
| 201 | + | "MTGS is v%u, MTCL says v%u; using v%u\n", | |
| 202 | + | *used, version, *used); | |
| 173 | 203 | ||
| 174 | 204 | return 0; | |
| 175 | 205 | } | |
| @@ -205,14 +235,16 @@ int mt792x_init_acpi_sar(struct mt792x_dev *dev) | |||
| 205 | 235 | asar->countrylist = NULL; | |
| 206 | 236 | } | |
| 207 | 237 | ||
| 208 | - | ret = mt792x_asar_acpi_read_mtds(dev, (u8 **)&asar->dyn, asar->ver); | |
| 238 | + | ret = mt792x_asar_acpi_read_mtds(dev, (u8 **)&asar->dyn, asar->ver, | |
| 239 | + | &asar->dyn_ver); | |
| 209 | 240 | if (ret) { | |
| 210 | 241 | devm_kfree(dev->mt76.dev, asar->dyn); | |
| 211 | 242 | asar->dyn = NULL; | |
| 212 | 243 | } | |
| 213 | 244 | ||
| 214 | 245 | /* MTGS is optional */ | |
| 215 | - | ret = mt792x_asar_acpi_read_mtgs(dev, (u8 **)&asar->geo, asar->ver); | |
| 246 | + | ret = mt792x_asar_acpi_read_mtgs(dev, (u8 **)&asar->geo, asar->ver, | |
| 247 | + | &asar->geo_ver); | |
| 216 | 248 | if (ret) { | |
| 217 | 249 | devm_kfree(dev->mt76.dev, asar->geo); | |
| 218 | 250 | asar->geo = NULL; | |
| @@ -254,7 +286,7 @@ mt792x_asar_get_geo_pwr(struct mt792x_phy *phy, | |||
| 254 | 286 | break; | |
| 255 | 287 | } | |
| 256 | 288 | ||
| 257 | - | if (asar->ver == 1) { | |
| 289 | + | if (asar->geo_ver == 1) { | |
| 258 | 290 | band_pwr = &asar->geo->tbl[idx].band[0]; | |
| 259 | 291 | max = ARRAY_SIZE(asar->geo->tbl[idx].band); | |
| 260 | 292 | } else { | |
| @@ -279,10 +311,18 @@ mt792x_asar_get_geo_pwr(struct mt792x_phy *phy, | |||
| 279 | 311 | if (idx >= max) | |
| 280 | 312 | return dyn_power; | |
| 281 | 313 | ||
| 282 | - | geo_power = (band_pwr + idx)->pwr; | |
| 283 | - | dyn_power += (band_pwr + idx)->offset; | |
| 314 | + | band_pwr += idx; | |
| 315 | + | ||
| 316 | + | /* Some OEM tables carry 0xff here; narrowed to s8 that is -1 and | |
| 317 | + | * wins the min() below. Take it as no limit. | |
| 318 | + | */ | |
| 319 | + | if (band_pwr->pwr == 0xff) | |
| 320 | + | return dyn_power; | |
| 321 | + | ||
| 322 | + | geo_power = band_pwr->pwr; | |
| 284 | 323 | ||
| 285 | - | return min(geo_power, dyn_power); | |
| 324 | + | return min_t(int, geo_power, | |
| 325 | + | min_t(int, dyn_power + band_pwr->offset, 127)); | |
| 286 | 326 | } | |
| 287 | 327 | ||
| 288 | 328 | static s8 | |
| @@ -297,7 +337,7 @@ mt792x_asar_range_pwr(struct mt792x_phy *phy, | |||
| 297 | 337 | if (!capa) | |
| 298 | 338 | return 127; | |
| 299 | 339 | ||
| 300 | - | if (asar->ver == 1) { | |
| 340 | + | if (asar->dyn_ver == 1) { | |
| 301 | 341 | limit = &asar->dyn->tbl[0].frp[0]; | |
| 302 | 342 | max = ARRAY_SIZE(asar->dyn->tbl[0].frp); | |
| 303 | 343 | } else { | |
| @@ -315,7 +355,9 @@ mt792x_asar_range_pwr(struct mt792x_phy *phy, | |||
| 315 | 355 | else | |
| 316 | 356 | band = NL80211_BAND_2GHZ; | |
| 317 | 357 | ||
| 318 | - | return mt792x_asar_get_geo_pwr(phy, band, limit[idx]); | |
| 358 | + | /* 0xff: no dynamic limit, see mt792x_asar_get_geo_pwr() */ | |
| 359 | + | return mt792x_asar_get_geo_pwr(phy, band, | |
| 360 | + | limit[idx] == 0xff ? 127 : limit[idx]); | |
| 319 | 361 | } | |
| 320 | 362 | ||
| 321 | 363 | int mt792x_init_acpi_sar_power(struct mt792x_phy *phy, bool set_default) | |
modified drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.h
| @@ -105,6 +105,8 @@ struct mt792x_asar_fg { | |||
| 105 | 105 | ||
| 106 | 106 | struct mt792x_acpi_sar { | |
| 107 | 107 | u8 ver; | |
| 108 | + | u8 dyn_ver; | |
| 109 | + | u8 geo_ver; | |
| 108 | 110 | union { | |
| 109 | 111 | struct mt792x_asar_dyn *dyn; | |
| 110 | 112 | struct mt792x_asar_dyn_v2 *dyn_v2; | |
modified drivers/net/wireless/mediatek/mt76/mt7996/init.c
| @@ -540,6 +540,7 @@ mt7996_init_wiphy(struct ieee80211_hw *hw, struct mtk_wed_device *wed) | |||
| 540 | 540 | ieee80211_hw_set(hw, NO_VIRTUAL_MONITOR); | |
| 541 | 541 | ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID); | |
| 542 | 542 | ieee80211_hw_set(hw, CHANCTX_STA_CSA); | |
| 543 | + | ieee80211_hw_set(hw, CONNECTION_MONITOR); | |
| 543 | 544 | ||
| 544 | 545 | hw->max_tx_fragments = 4; | |
| 545 | 546 | wiphy->txq_memory_limit = 32 << 20; /* 32 MiB */ | |
| @@ -1247,7 +1248,7 @@ static int mt7996_variant_fem_init(struct mt7996_dev *dev) | |||
| 1247 | 1248 | adie_ver = u32_get_bits(regval, MT_ADIE_VERSION_MASK); | |
| 1248 | 1249 | idx = MT7976C_EFUSE_OFFSET % MT7996_EEPROM_BLOCK_SIZE; | |
| 1249 | 1250 | is_7976c = adie_ver == 0x8a10 || adie_ver == 0x8b00 || | |
| 1250 | - | adie_ver == 0x8c10 || buf[idx] == 0xc; | |
| 1251 | + | adie_ver == 0x8c10 || (!ret && buf[idx] == 0xc); | |
| 1251 | 1252 | ||
| 1252 | 1253 | adie_id = u32_get_bits(regval, MT_ADIE_CHIP_ID_MASK); | |
| 1253 | 1254 | if (adie_id == 0x7975 || adie_id == 0x7979 || | |
modified drivers/net/wireless/mediatek/mt76/mt7996/main.c
| @@ -310,7 +310,14 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif, | |||
| 310 | 310 | if (vif->type == NL80211_IFTYPE_AP) | |
| 311 | 311 | return mt7996_mcu_mld_link_oper(dev, link_conf, link, | |
| 312 | 312 | true); | |
| 313 | - | return 0; | |
| 313 | + | ||
| 314 | + | /* update the link address */ | |
| 315 | + | ret = mt7996_mcu_add_dev_info(phy, vif, link_conf, mlink, true); | |
| 316 | + | if (ret) | |
| 317 | + | return ret; | |
| 318 | + | ||
| 319 | + | return mt7996_mcu_add_bss_info(phy, vif, link_conf, mlink, | |
| 320 | + | msta_link, true); | |
| 314 | 321 | } | |
| 315 | 322 | ||
| 316 | 323 | mlink->idx = __ffs64(~dev->mt76.vif_mask); | |
| @@ -1426,6 +1433,7 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif, | |||
| 1426 | 1433 | else if (sta->mlo && links == BIT(link_id)) /* last link */ | |
| 1427 | 1434 | mt7996_mcu_teardown_mld_sta(dev, link, | |
| 1428 | 1435 | msta_link); | |
| 1436 | + | msta_link->wcid.tx_info &= ~MT_WCID_TX_INFO_SET; | |
| 1429 | 1437 | msta_link->wcid.sta_disabled = 1; | |
| 1430 | 1438 | msta_link->wcid.sta = 0; | |
| 1431 | 1439 | links = links & ~BIT(link_id); | |
modified drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
| @@ -284,6 +284,9 @@ struct mt7996_mcu_wed_rro_ba_delete_event { | |||
| 284 | 284 | __le16 len; | |
| 285 | 285 | ||
| 286 | 286 | __le16 session_id; | |
| 287 | + | __le16 wlan_id; | |
| 288 | + | u8 tid; | |
| 289 | + | u8 __rsv1; | |
| 287 | 290 | u8 __rsv2[2]; | |
| 288 | 291 | } __packed; | |
| 289 | 292 | ||
modified drivers/net/wireless/mediatek/mt76/tx.c
| @@ -234,6 +234,8 @@ mt76_tx_check_non_aql(struct mt76_dev *dev, struct mt76_wcid *wcid, | |||
| 234 | 234 | if (!wcid || info->tx_time_est) | |
| 235 | 235 | return; | |
| 236 | 236 | ||
| 237 | + | wcid = mt76_wcid_primary(wcid); | |
| 238 | + | ||
| 237 | 239 | pending = atomic_dec_return(&wcid->non_aql_packets); | |
| 238 | 240 | if (pending < 0) | |
| 239 | 241 | atomic_cmpxchg(&wcid->non_aql_packets, pending, 0); | |
| @@ -344,7 +346,8 @@ __mt76_tx_queue_skb(struct mt76_phy *phy, int qid, struct sk_buff *skb, | |||
| 344 | 346 | if (!non_aql) | |
| 345 | 347 | return idx; | |
| 346 | 348 | ||
| 347 | - | pending = atomic_inc_return(&wcid->non_aql_packets); | |
| 349 | + | /* the hardware can report the completion on a different link */ | |
| 350 | + | pending = atomic_inc_return(&mt76_wcid_primary(wcid)->non_aql_packets); | |
| 348 | 351 | if (stop && pending >= MT_MAX_NON_AQL_PKT) | |
| 349 | 352 | *stop = true; | |
| 350 | 353 | ||
| @@ -506,7 +509,8 @@ mt76_txq_send_burst(struct mt76_phy *phy, struct mt76_queue *q, | |||
| 506 | 509 | return 0; | |
| 507 | 510 | } | |
| 508 | 511 | ||
| 509 | - | if (atomic_read(&wcid->non_aql_packets) >= MT_MAX_NON_AQL_PKT) | |
| 512 | + | if (atomic_read(&mt76_wcid_primary(wcid)->non_aql_packets) >= | |
| 513 | + | MT_MAX_NON_AQL_PKT) | |
| 510 | 514 | return 0; | |
| 511 | 515 | ||
| 512 | 516 | skb = mt76_txq_dequeue(phy, mtxq); | |
| @@ -603,7 +607,8 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid) | |||
| 603 | 607 | continue; | |
| 604 | 608 | } | |
| 605 | 609 | ||
| 606 | - | if (atomic_read(&wcid->non_aql_packets) >= MT_MAX_NON_AQL_PKT) | |
| 610 | + | if (atomic_read(&mt76_wcid_primary(wcid)->non_aql_packets) >= | |
| 611 | + | MT_MAX_NON_AQL_PKT) | |
| 607 | 612 | continue; | |
| 608 | 613 | if (dev->queue_ops->tx_cleanup && | |
| 609 | 614 | q->queued + 2 * MT_TXQ_FREE_THR >= q->ndesc) { | |
| @@ -675,7 +680,8 @@ mt76_txq_schedule_pending_wcid(struct mt76_phy *phy, struct mt76_wcid *wcid, | |||
| 675 | 680 | if ((dev->drv->drv_flags & MT_DRV_HW_MGMT_TXQ) && | |
| 676 | 681 | !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && | |
| 677 | 682 | !ieee80211_is_data_present(hdr->frame_control) && | |
| 678 | - | (!ieee80211_is_bufferable_mmpdu(skb) || | |
| 683 | + | (!(wcid->tx_info & MT_WCID_TX_INFO_SET) || | |
| 684 | + | !ieee80211_is_bufferable_mmpdu(skb) || | |
| 679 | 685 | ieee80211_is_deauth(hdr->frame_control) || | |
| 680 | 686 | ieee80211_is_disassoc(hdr->frame_control) || | |
| 681 | 687 | head == &wcid->tx_offchannel)) | |
modified drivers/net/wireless/nxp/nxpwifi/11n.c
| @@ -451,7 +451,7 @@ void | |||
| 451 | 451 | nxpwifi_11n_delete_tx_ba_stream_tbl_entry(struct nxpwifi_private *priv, | |
| 452 | 452 | struct nxpwifi_tx_ba_stream_tbl *tbl) | |
| 453 | 453 | { | |
| 454 | - | if (!tbl || nxpwifi_is_tx_ba_stream_ptr_valid(priv, tbl)) | |
| 454 | + | if (!tbl || !nxpwifi_is_tx_ba_stream_ptr_valid(priv, tbl)) | |
| 455 | 455 | return; | |
| 456 | 456 | ||
| 457 | 457 | nxpwifi_dbg(priv->adapter, INFO, | |
modified drivers/net/wireless/nxp/nxpwifi/11n_aggr.c
| @@ -168,6 +168,7 @@ nxpwifi_11n_aggregate_pkt(struct nxpwifi_private *priv, | |||
| 168 | 168 | ||
| 169 | 169 | if (!nxpwifi_is_ralist_valid(priv, pra_list, ptrindex)) { | |
| 170 | 170 | spin_unlock_bh(&priv->wmm.ra_list_spinlock); | |
| 171 | + | nxpwifi_write_data_complete(adapter, skb_aggr, 1, -1); | |
| 171 | 172 | return -ENOENT; | |
| 172 | 173 | } | |
| 173 | 174 | ||
modified drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c
| @@ -205,11 +205,12 @@ void nxpwifi_11n_del_rx_reorder_tbl_by_ta(struct nxpwifi_private *priv, u8 *ta) | |||
| 205 | 205 | return; | |
| 206 | 206 | ||
| 207 | 207 | for (i = 0; i < MAX_NUM_TID; i++) { | |
| 208 | - | guard(rcu)(); | |
| 209 | - | list_for_each_entry_rcu(tbl, &priv->rx_reorder_tbl_ptr[i], list) { | |
| 210 | - | if (!memcmp(tbl->ta, ta, ETH_ALEN)) { | |
| 211 | - | INIT_LIST_HEAD(&tbl->tmp_list); | |
| 212 | - | list_add_tail(&tbl->tmp_list, &to_delete); | |
| 208 | + | scoped_guard(rcu) { | |
| 209 | + | list_for_each_entry_rcu(tbl, &priv->rx_reorder_tbl_ptr[i], list) { | |
| 210 | + | if (!memcmp(tbl->ta, ta, ETH_ALEN)) { | |
| 211 | + | INIT_LIST_HEAD(&tbl->tmp_list); | |
| 212 | + | list_add_tail(&tbl->tmp_list, &to_delete); | |
| 213 | + | } | |
| 213 | 214 | } | |
| 214 | 215 | } | |
| 215 | 216 | ||
modified drivers/net/wireless/nxp/nxpwifi/cfg80211.c
| @@ -1539,9 +1539,11 @@ nxpwifi_cfg80211_del_station(struct wiphy *wiphy, struct wireless_dev *wdev, | |||
| 1539 | 1539 | ||
| 1540 | 1540 | eth_zero_addr(deauth_mac); | |
| 1541 | 1541 | ||
| 1542 | + | rcu_read_lock(); | |
| 1542 | 1543 | sta_node = nxpwifi_get_sta_entry(priv, params->mac); | |
| 1543 | 1544 | if (sta_node) | |
| 1544 | 1545 | ether_addr_copy(deauth_mac, params->mac); | |
| 1546 | + | rcu_read_unlock(); | |
| 1545 | 1547 | ||
| 1546 | 1548 | if (is_valid_ether_addr(deauth_mac)) { | |
| 1547 | 1549 | ret = nxpwifi_uap_sta_deauth(priv, deauth_mac); | |
| @@ -3323,6 +3325,7 @@ nxpwifi_cfg80211_authenticate(struct wiphy *wiphy, | |||
| 3323 | 3325 | struct nxpwifi_adapter *adapter = priv->adapter; | |
| 3324 | 3326 | struct sk_buff *skb; | |
| 3325 | 3327 | u16 pkt_len, auth_alg; | |
| 3328 | + | size_t frame_len; | |
| 3326 | 3329 | int ret; | |
| 3327 | 3330 | struct ieee80211_mgmt *mgmt; | |
| 3328 | 3331 | struct nxpwifi_txinfo *tx_info; | |
| @@ -3396,13 +3399,25 @@ nxpwifi_cfg80211_authenticate(struct wiphy *wiphy, | |||
| 3396 | 3399 | ||
| 3397 | 3400 | nxpwifi_cancel_scan(adapter); | |
| 3398 | 3401 | ||
| 3399 | - | pkt_len = (u16)req->ie_len + req->auth_data_len + | |
| 3400 | - | NXPWIFI_MGMT_HEADER_LEN + NXPWIFI_AUTH_BODY_LEN; | |
| 3402 | + | frame_len = req->ie_len + req->auth_data_len + | |
| 3403 | + | sizeof(struct ieee80211_hdr_3addr) + NXPWIFI_AUTH_BODY_LEN; | |
| 3401 | 3404 | ||
| 3402 | 3405 | if (req->auth_data_len >= 4) | |
| 3403 | - | pkt_len -= 4; | |
| 3406 | + | frame_len -= 4; | |
| 3407 | + | ||
| 3408 | + | /* nxpwifi_form_mgmt_frame() inserts address4, so the frame handed to | |
| 3409 | + | * the firmware is ETH_ALEN longer than the one built here. | |
| 3410 | + | */ | |
| 3411 | + | if (frame_len > U16_MAX - ETH_ALEN) { | |
| 3412 | + | nxpwifi_dbg(adapter, ERROR, | |
| 3413 | + | "auth frame too long: %zu bytes\n", frame_len); | |
| 3414 | + | return -EINVAL; | |
| 3415 | + | } | |
| 3416 | + | pkt_len = frame_len + ETH_ALEN; | |
| 3404 | 3417 | ||
| 3405 | - | mgmt = kzalloc(pkt_len, GFP_KERNEL); | |
| 3418 | + | mgmt = kzalloc(frame_len, GFP_KERNEL); | |
| 3419 | + | if (!mgmt) | |
| 3420 | + | return -ENOMEM; | |
| 3406 | 3421 | ||
| 3407 | 3422 | skb = dev_alloc_skb(NXPWIFI_MIN_DATA_HEADER_LEN + | |
| 3408 | 3423 | NXPWIFI_MGMT_FRAME_HEADER_SIZE + | |
| @@ -3410,6 +3425,7 @@ nxpwifi_cfg80211_authenticate(struct wiphy *wiphy, | |||
| 3410 | 3425 | if (!skb) { | |
| 3411 | 3426 | nxpwifi_dbg(adapter, ERROR, | |
| 3412 | 3427 | "allocate skb failed for management frame\n"); | |
| 3428 | + | kfree(mgmt); | |
| 3413 | 3429 | return -ENOMEM; | |
| 3414 | 3430 | } | |
| 3415 | 3431 | ||
| @@ -3448,7 +3464,7 @@ nxpwifi_cfg80211_authenticate(struct wiphy *wiphy, | |||
| 3448 | 3464 | memcpy((u8 *)varptr, req->ie, req->ie_len); | |
| 3449 | 3465 | } | |
| 3450 | 3466 | ||
| 3451 | - | nxpwifi_form_mgmt_frame(skb, (const u8 *)mgmt, pkt_len); | |
| 3467 | + | nxpwifi_form_mgmt_frame(skb, (const u8 *)mgmt, frame_len); | |
| 3452 | 3468 | kfree(mgmt); | |
| 3453 | 3469 | priv->auth_flag = HOST_MLME_AUTH_PENDING; | |
| 3454 | 3470 | priv->auth_alg = auth_alg; | |
| @@ -3729,8 +3745,9 @@ int nxpwifi_init_channel_scan_gap(struct nxpwifi_adapter *adapter) | |||
| 3729 | 3745 | * additional active scan request for hidden SSIDs on passive channels. | |
| 3730 | 3746 | */ | |
| 3731 | 3747 | adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a); | |
| 3732 | - | adapter->chan_stats = vmalloc(array_size(sizeof(*adapter->chan_stats), | |
| 3733 | - | adapter->num_in_chan_stats)); | |
| 3748 | + | adapter->chan_stats = kcalloc(adapter->num_in_chan_stats, | |
| 3749 | + | sizeof(*adapter->chan_stats), | |
| 3750 | + | GFP_KERNEL); | |
| 3734 | 3751 | ||
| 3735 | 3752 | if (!adapter->chan_stats) | |
| 3736 | 3753 | return -ENOMEM; | |
modified drivers/net/wireless/nxp/nxpwifi/init.c
| @@ -328,7 +328,7 @@ static void nxpwifi_invalidate_lists(struct nxpwifi_adapter *adapter) | |||
| 328 | 328 | static void | |
| 329 | 329 | nxpwifi_adapter_cleanup(struct nxpwifi_adapter *adapter) | |
| 330 | 330 | { | |
| 331 | - | timer_delete(&adapter->wakeup_timer); | |
| 331 | + | timer_delete_sync(&adapter->wakeup_timer); | |
| 332 | 332 | nxpwifi_cancel_all_pending_cmd(adapter); | |
| 333 | 333 | wake_up_interruptible(&adapter->cmd_wait_q.wait); | |
| 334 | 334 | wake_up_interruptible(&adapter->hs_activate_wait_q); | |
modified drivers/net/wireless/nxp/nxpwifi/main.c
| @@ -644,7 +644,7 @@ static int _nxpwifi_fw_dpc(const struct firmware *firmware, void *context) | |||
| 644 | 644 | goto done; | |
| 645 | 645 | ||
| 646 | 646 | err_add_intf: | |
| 647 | - | vfree(adapter->chan_stats); | |
| 647 | + | kfree(adapter->chan_stats); | |
| 648 | 648 | err_init_chan_scan: | |
| 649 | 649 | wiphy_unregister(adapter->wiphy); | |
| 650 | 650 | wiphy_free(adapter->wiphy); | |
| @@ -1384,7 +1384,7 @@ static void nxpwifi_uninit_sw(struct nxpwifi_adapter *adapter) | |||
| 1384 | 1384 | wiphy_free(adapter->wiphy); | |
| 1385 | 1385 | adapter->wiphy = NULL; | |
| 1386 | 1386 | ||
| 1387 | - | vfree(adapter->chan_stats); | |
| 1387 | + | kfree(adapter->chan_stats); | |
| 1388 | 1388 | nxpwifi_free_cmd_buffers(adapter); | |
| 1389 | 1389 | } | |
| 1390 | 1390 | ||
modified drivers/net/wireless/nxp/nxpwifi/uap_event.c
| @@ -75,6 +75,7 @@ nxpwifi_uap_event_sta_deauth(struct nxpwifi_private *priv) | |||
| 75 | 75 | nxpwifi_del_tx_ba_stream_tbl_by_ra(priv, deauth_mac); | |
| 76 | 76 | } | |
| 77 | 77 | nxpwifi_wmm_del_peer_ra_list(priv, deauth_mac); | |
| 78 | + | nxpwifi_del_sta_entry(priv, deauth_mac); | |
| 78 | 79 | ||
| 79 | 80 | return 0; | |
| 80 | 81 | } | |
modified drivers/net/wireless/nxp/nxpwifi/util.c
| @@ -1041,19 +1041,23 @@ nxpwifi_set_sta_ht_cap(struct nxpwifi_private *priv, const u8 *ies, | |||
| 1041 | 1041 | } | |
| 1042 | 1042 | } | |
| 1043 | 1043 | ||
| 1044 | - | /* Delete a station from list; called under cfg80211 mutex. */ | |
| 1044 | + | /* Delete a station from list. */ | |
| 1045 | 1045 | ||
| 1046 | 1046 | void nxpwifi_del_sta_entry(struct nxpwifi_private *priv, const u8 *mac) | |
| 1047 | 1047 | { | |
| 1048 | 1048 | struct nxpwifi_sta_node *node; | |
| 1049 | 1049 | ||
| 1050 | - | list_for_each_entry_rcu(node, &priv->sta_list, list) { | |
| 1050 | + | spin_lock_bh(&priv->sta_list_spinlock); | |
| 1051 | + | ||
| 1052 | + | list_for_each_entry(node, &priv->sta_list, list) { | |
| 1051 | 1053 | if (!memcmp(node->mac_addr, mac, ETH_ALEN)) { | |
| 1052 | 1054 | list_del_rcu(&node->list); | |
| 1053 | 1055 | kfree_rcu(node, rcu); | |
| 1054 | 1056 | break; | |
| 1055 | 1057 | } | |
| 1056 | 1058 | } | |
| 1059 | + | ||
| 1060 | + | spin_unlock_bh(&priv->sta_list_spinlock); | |
| 1057 | 1061 | } | |
| 1058 | 1062 | ||
| 1059 | 1063 | /* Delete all stations from list. */ | |
modified drivers/net/wireless/silabs/wfx/hif_tx.c
| @@ -207,9 +207,11 @@ int wfx_hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, si | |||
| 207 | 207 | dev_warn(wdev->dev, "%s: confirmation mismatch request\n", __func__); | |
| 208 | 208 | ret = -EIO; | |
| 209 | 209 | } | |
| 210 | - | if (ret == -ENOMEM) | |
| 210 | + | if (!ret && le16_to_cpu(reply->length) > val_len) { | |
| 211 | 211 | dev_err(wdev->dev, "buffer is too small to receive %s (%zu < %d)\n", | |
| 212 | 212 | wfx_get_mib_name(mib_id), val_len, le16_to_cpu(reply->length)); | |
| 213 | + | ret = -EIO; | |
| 214 | + | } | |
| 213 | 215 | if (!ret) | |
| 214 | 216 | memcpy(val, &reply->mib_data, le16_to_cpu(reply->length)); | |
| 215 | 217 | else | |
modified drivers/net/wireless/st/cw1200/bh.c
| @@ -344,6 +344,7 @@ static int cw1200_bh_tx_helper(struct cw1200_common *priv, | |||
| 344 | 344 | int *tx_burst) | |
| 345 | 345 | { | |
| 346 | 346 | size_t tx_len; | |
| 347 | + | size_t aligned_len; | |
| 347 | 348 | u8 *data; | |
| 348 | 349 | int ret; | |
| 349 | 350 | struct wsm_hdr *wsm; | |
| @@ -376,9 +377,14 @@ static int cw1200_bh_tx_helper(struct cw1200_common *priv, | |||
| 376 | 377 | ||
| 377 | 378 | atomic_inc(&priv->bh_tx); | |
| 378 | 379 | ||
| 379 | - | tx_len = priv->hwbus_ops->align_size( | |
| 380 | + | aligned_len = priv->hwbus_ops->align_size( | |
| 380 | 381 | priv->hwbus_priv, tx_len); | |
| 381 | 382 | ||
| 383 | + | /* Zero the bus alignment padding so no stale data is sent. */ | |
| 384 | + | if (aligned_len > tx_len) | |
| 385 | + | memset(data + tx_len, 0, aligned_len - tx_len); | |
| 386 | + | tx_len = aligned_len; | |
| 387 | + | ||
| 382 | 388 | /* Check if not exceeding CW1200 capabilities */ | |
| 383 | 389 | if (WARN_ON_ONCE(tx_len > EFFECTIVE_BUF_SIZE)) | |
| 384 | 390 | pr_debug("Write aligned len: %zu\n", tx_len); | |
modified drivers/net/wireless/st/cw1200/txrx.c
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | #include "wsm.h" | |
| 15 | 15 | #include "bh.h" | |
| 16 | 16 | #include "sta.h" | |
| 17 | + | #include "hwbus.h" | |
| 17 | 18 | #include "debug.h" | |
| 18 | 19 | ||
| 19 | 20 | #define CW1200_INVALID_RATE_ID (0xFF) | |
| @@ -716,6 +717,7 @@ void cw1200_tx(struct ieee80211_hw *dev, | |||
| 716 | 717 | struct ieee80211_sta *sta; | |
| 717 | 718 | struct wsm_tx *wsm; | |
| 718 | 719 | bool tid_update = false; | |
| 720 | + | size_t pad_len; | |
| 719 | 721 | u8 flags = 0; | |
| 720 | 722 | int ret; | |
| 721 | 723 | ||
| @@ -764,6 +766,18 @@ void cw1200_tx(struct ieee80211_hw *dev, | |||
| 764 | 766 | ||
| 765 | 767 | sta = t.sta; | |
| 766 | 768 | ||
| 769 | + | /* | |
| 770 | + | * The bus transfer is padded up to the bus alignment and the | |
| 771 | + | * padding is transferred from the frame buffer. Make sure the | |
| 772 | + | * buffer has room for the padding so the device never receives | |
| 773 | + | * data past the end of the frame. | |
| 774 | + | */ | |
| 775 | + | pad_len = priv->hwbus_ops->align_size(priv->hwbus_priv, skb->len) - | |
| 776 | + | skb->len; | |
| 777 | + | if (skb_tailroom(skb) < pad_len && | |
| 778 | + | pskb_expand_head(skb, 0, pad_len, GFP_ATOMIC)) | |
| 779 | + | goto drop; | |
| 780 | + | ||
| 767 | 781 | spin_lock_bh(&priv->ps_state_lock); | |
| 768 | 782 | { | |
| 769 | 783 | tid_update = cw1200_tx_h_pm_state(priv, &t); | |
modified drivers/net/wireless/ti/wlcore/main.c
| @@ -6809,8 +6809,10 @@ void wlcore_remove(struct platform_device *pdev) | |||
| 6809 | 6809 | ||
| 6810 | 6810 | if (pdev_data->family && pdev_data->family->nvs_name) | |
| 6811 | 6811 | wait_for_completion(&wl->nvs_loading_complete); | |
| 6812 | - | if (!wl->initialized) | |
| 6812 | + | if (!wl->initialized) { | |
| 6813 | + | pm_runtime_put_noidle(wl->dev); | |
| 6813 | 6814 | return; | |
| 6815 | + | } | |
| 6814 | 6816 | ||
| 6815 | 6817 | if (wl->wakeirq >= 0) { | |
| 6816 | 6818 | dev_pm_clear_wake_irq(wl->dev); | |
modified drivers/net/xen-netfront.c
| @@ -1234,8 +1234,16 @@ static int handle_incoming_queue(struct netfront_queue *queue, | |||
| 1234 | 1234 | while ((skb = __skb_dequeue(rxq)) != NULL) { | |
| 1235 | 1235 | int pull_to = NETFRONT_SKB_CB(skb)->pull_to; | |
| 1236 | 1236 | ||
| 1237 | - | if (pull_to > skb_headlen(skb)) | |
| 1238 | - | __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); | |
| 1237 | + | /* pull_to comes from the first slot's length, which the | |
| 1238 | + | * backend controls. Make sure the head holds at least an | |
| 1239 | + | * Ethernet header for eth_type_trans(). | |
| 1240 | + | */ | |
| 1241 | + | if (!pskb_may_pull(skb, max(pull_to, ETH_HLEN))) { | |
| 1242 | + | kfree_skb(skb); | |
| 1243 | + | packets_dropped++; | |
| 1244 | + | queue->info->netdev->stats.rx_errors++; | |
| 1245 | + | continue; | |
| 1246 | + | } | |
| 1239 | 1247 | ||
| 1240 | 1248 | /* Ethernet work: Delayed to here as it peeks the header. */ | |
| 1241 | 1249 | skb->protocol = eth_type_trans(skb, queue->info->netdev); | |
| @@ -1338,8 +1346,10 @@ err: | |||
| 1338 | 1346 | skb->data_len = rx->status; | |
| 1339 | 1347 | skb->len += rx->status; | |
| 1340 | 1348 | ||
| 1341 | - | if (unlikely(xennet_fill_frags(queue, skb, &tmpq))) | |
| 1349 | + | if (unlikely(xennet_fill_frags(queue, skb, &tmpq))) { | |
| 1350 | + | __skb_queue_head(&tmpq, skb); | |
| 1342 | 1351 | goto err; | |
| 1352 | + | } | |
| 1343 | 1353 | ||
| 1344 | 1354 | if (rx->flags & XEN_NETRXF_csum_blank) | |
| 1345 | 1355 | skb->ip_summed = CHECKSUM_PARTIAL; | |
modified drivers/nvme/host/core.c
| @@ -2617,10 +2617,19 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info) | |||
| 2617 | 2617 | set_capacity_and_notify(ns->head->disk, get_capacity(ns->disk)); | |
| 2618 | 2618 | set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info)); | |
| 2619 | 2619 | nvme_mpath_revalidate_paths(ns->head); | |
| 2620 | - | ret = nvme_mpath_revalidate_zones(ns->head); | |
| 2621 | 2620 | ||
| 2622 | 2621 | unfreeze_head_queue: | |
| 2623 | 2622 | blk_mq_unfreeze_queue(ns->head->disk->queue, memflags); | |
| 2623 | + | ||
| 2624 | + | /* | |
| 2625 | + | * Wait until the head queue is unfrozen before revalidating | |
| 2626 | + | * its zones. blk_revalidate_disk_zones() takes the queue limits | |
| 2627 | + | * lock and then freezes the queue on its own, so it must not be | |
| 2628 | + | * called with the queue already frozen. This is also what | |
| 2629 | + | * nvme_update_ns_info_block() does for ns->disk. | |
| 2630 | + | */ | |
| 2631 | + | if (!ret) | |
| 2632 | + | ret = nvme_mpath_revalidate_zones(ns->head); | |
| 2624 | 2633 | } | |
| 2625 | 2634 | ||
| 2626 | 2635 | return ret; | |
| @@ -3195,9 +3204,16 @@ static void nvme_release_subsystem(struct device *dev) | |||
| 3195 | 3204 | { | |
| 3196 | 3205 | struct nvme_subsystem *subsys = | |
| 3197 | 3206 | container_of(dev, struct nvme_subsystem, dev); | |
| 3207 | + | struct nvme_effects_log *cel; | |
| 3208 | + | unsigned long i; | |
| 3198 | 3209 | ||
| 3199 | 3210 | if (subsys->instance >= 0) | |
| 3200 | 3211 | ida_free(&nvme_instance_ida, subsys->instance); | |
| 3212 | + | xa_for_each(&subsys->cels, i, cel) { | |
| 3213 | + | xa_erase(&subsys->cels, i); | |
| 3214 | + | kfree(cel); | |
| 3215 | + | } | |
| 3216 | + | xa_destroy(&subsys->cels); | |
| 3201 | 3217 | kfree(subsys); | |
| 3202 | 3218 | } | |
| 3203 | 3219 | ||
| @@ -3311,6 +3327,7 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) | |||
| 3311 | 3327 | kref_init(&subsys->ref); | |
| 3312 | 3328 | INIT_LIST_HEAD(&subsys->ctrls); | |
| 3313 | 3329 | INIT_LIST_HEAD(&subsys->nsheads); | |
| 3330 | + | xa_init(&subsys->cels); | |
| 3314 | 3331 | nvme_init_subnqn(subsys, ctrl, id); | |
| 3315 | 3332 | memcpy(subsys->serial, id->sn, sizeof(subsys->serial)); | |
| 3316 | 3333 | memcpy(subsys->model, id->mn, sizeof(subsys->model)); | |
| @@ -3413,7 +3430,7 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi, | |||
| 3413 | 3430 | static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, | |
| 3414 | 3431 | struct nvme_effects_log **log) | |
| 3415 | 3432 | { | |
| 3416 | - | struct nvme_effects_log *old, *cel = xa_load(&ctrl->cels, csi); | |
| 3433 | + | struct nvme_effects_log *old, *cel = xa_load(&ctrl->subsys->cels, csi); | |
| 3417 | 3434 | int ret; | |
| 3418 | 3435 | ||
| 3419 | 3436 | if (cel) | |
| @@ -3430,7 +3447,7 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, | |||
| 3430 | 3447 | return ret; | |
| 3431 | 3448 | } | |
| 3432 | 3449 | ||
| 3433 | - | old = xa_store(&ctrl->cels, csi, cel, GFP_KERNEL); | |
| 3450 | + | old = xa_store(&ctrl->subsys->cels, csi, cel, GFP_KERNEL); | |
| 3434 | 3451 | if (xa_is_err(old)) { | |
| 3435 | 3452 | kfree(cel); | |
| 3436 | 3453 | return xa_err(old); | |
| @@ -3505,7 +3522,7 @@ static int nvme_init_effects_log(struct nvme_ctrl *ctrl, | |||
| 3505 | 3522 | if (!effects) | |
| 3506 | 3523 | return -ENOMEM; | |
| 3507 | 3524 | ||
| 3508 | - | old = xa_store(&ctrl->cels, csi, effects, GFP_KERNEL); | |
| 3525 | + | old = xa_store(&ctrl->subsys->cels, csi, effects, GFP_KERNEL); | |
| 3509 | 3526 | if (xa_is_err(old)) { | |
| 3510 | 3527 | kfree(effects); | |
| 3511 | 3528 | return xa_err(old); | |
| @@ -3551,23 +3568,27 @@ static int nvme_init_effects(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) | |||
| 3551 | 3568 | { | |
| 3552 | 3569 | int ret = 0; | |
| 3553 | 3570 | ||
| 3571 | + | mutex_lock(&ctrl->subsys->lock); | |
| 3572 | + | ctrl->effects = xa_load(&ctrl->subsys->cels, NVME_CSI_NVM); | |
| 3554 | 3573 | if (ctrl->effects) | |
| 3555 | - | return 0; | |
| 3574 | + | goto out_unlock; | |
| 3556 | 3575 | ||
| 3557 | 3576 | if (id->lpa & NVME_CTRL_LPA_CMD_EFFECTS_LOG) { | |
| 3558 | 3577 | ret = nvme_get_effects_log(ctrl, NVME_CSI_NVM, &ctrl->effects); | |
| 3559 | 3578 | if (ret < 0) | |
| 3560 | - | return ret; | |
| 3579 | + | goto out_unlock; | |
| 3561 | 3580 | } | |
| 3562 | 3581 | ||
| 3563 | 3582 | if (!ctrl->effects) { | |
| 3564 | 3583 | ret = nvme_init_effects_log(ctrl, NVME_CSI_NVM, &ctrl->effects); | |
| 3565 | 3584 | if (ret < 0) | |
| 3566 | - | return ret; | |
| 3585 | + | goto out_unlock; | |
| 3567 | 3586 | } | |
| 3568 | 3587 | ||
| 3569 | 3588 | nvme_init_known_nvm_effects(ctrl); | |
| 3570 | - | return 0; | |
| 3589 | + | out_unlock: | |
| 3590 | + | mutex_unlock(&ctrl->subsys->lock); | |
| 3591 | + | return ret; | |
| 3571 | 3592 | } | |
| 3572 | 3593 | ||
| 3573 | 3594 | static int nvme_check_ctrl_fabric_info(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) | |
| @@ -3931,9 +3952,9 @@ void nvme_cdev_del(struct cdev *cdev, struct device *cdev_device) | |||
| 3931 | 3952 | put_device(cdev_device); | |
| 3932 | 3953 | } | |
| 3933 | 3954 | ||
| 3934 | - | int nvme_cdev_add(const char *name, struct cdev *cdev, | |
| 3935 | - | struct device *cdev_device, | |
| 3936 | - | const struct file_operations *fops, struct module *owner) | |
| 3955 | + | int nvme_cdev_add(struct cdev *cdev, struct device *cdev_device, | |
| 3956 | + | const struct file_operations *fops, struct module *owner, | |
| 3957 | + | int ctrl, int head) | |
| 3937 | 3958 | { | |
| 3938 | 3959 | int minor, ret; | |
| 3939 | 3960 | ||
| @@ -3941,7 +3962,7 @@ int nvme_cdev_add(const char *name, struct cdev *cdev, | |||
| 3941 | 3962 | if (minor < 0) | |
| 3942 | 3963 | return minor; | |
| 3943 | 3964 | ||
| 3944 | - | ret = dev_set_name(cdev_device, name); | |
| 3965 | + | ret = dev_set_name(cdev_device, "ng%dn%d", ctrl, head); | |
| 3945 | 3966 | if (ret) { | |
| 3946 | 3967 | ida_free(&nvme_ns_chr_minor_ida, minor); | |
| 3947 | 3968 | return ret; | |
| @@ -3982,17 +4003,14 @@ static const struct file_operations nvme_ns_chr_fops = { | |||
| 3982 | 4003 | ||
| 3983 | 4004 | static void nvme_add_ns_cdev(struct nvme_ns *ns) | |
| 3984 | 4005 | { | |
| 3985 | - | char name[32]; | |
| 3986 | - | ||
| 3987 | 4006 | ns->cdev_device.parent = ns->ctrl->device; | |
| 3988 | - | snprintf(name, sizeof(name), "ng%dn%d", ns->ctrl->instance, | |
| 3989 | - | ns->head->instance); | |
| 3990 | 4007 | ||
| 3991 | 4008 | nvme_get_ns(ns); /* Undone in nvme_cdev_rel() */ | |
| 3992 | - | if (nvme_cdev_add(name, &ns->cdev, &ns->cdev_device, | |
| 3993 | - | &nvme_ns_chr_fops, ns->ctrl->ops->module)) { | |
| 3994 | - | dev_err(ns->ctrl->device, "Unable to create the %s device\n", | |
| 3995 | - | name); | |
| 4009 | + | if (nvme_cdev_add(&ns->cdev, &ns->cdev_device, | |
| 4010 | + | &nvme_ns_chr_fops, ns->ctrl->ops->module, | |
| 4011 | + | ns->ctrl->instance, ns->head->instance)) { | |
| 4012 | + | dev_err(ns->ctrl->device, "Unable to create the ng%dn%d device\n", | |
| 4013 | + | ns->ctrl->instance, ns->head->instance); | |
| 3996 | 4014 | nvme_put_ns(ns); | |
| 3997 | 4015 | return; | |
| 3998 | 4016 | } | |
| @@ -5155,19 +5173,6 @@ void nvme_uninit_ctrl(struct nvme_ctrl *ctrl) | |||
| 5155 | 5173 | } | |
| 5156 | 5174 | EXPORT_SYMBOL_GPL(nvme_uninit_ctrl); | |
| 5157 | 5175 | ||
| 5158 | - | static void nvme_free_cels(struct nvme_ctrl *ctrl) | |
| 5159 | - | { | |
| 5160 | - | struct nvme_effects_log *cel; | |
| 5161 | - | unsigned long i; | |
| 5162 | - | ||
| 5163 | - | xa_for_each(&ctrl->cels, i, cel) { | |
| 5164 | - | xa_erase(&ctrl->cels, i); | |
| 5165 | - | kfree(cel); | |
| 5166 | - | } | |
| 5167 | - | ||
| 5168 | - | xa_destroy(&ctrl->cels); | |
| 5169 | - | } | |
| 5170 | - | ||
| 5171 | 5176 | static void nvme_free_ctrl(struct device *dev) | |
| 5172 | 5177 | { | |
| 5173 | 5178 | struct nvme_ctrl *ctrl = | |
| @@ -5180,7 +5185,6 @@ static void nvme_free_ctrl(struct device *dev) | |||
| 5180 | 5185 | blk_put_queue(ctrl->fabrics_q); | |
| 5181 | 5186 | if (!subsys || ctrl->instance != subsys->instance) | |
| 5182 | 5187 | ida_free(&nvme_instance_ida, ctrl->instance); | |
| 5183 | - | nvme_free_cels(ctrl); | |
| 5184 | 5188 | nvme_mpath_uninit(ctrl); | |
| 5185 | 5189 | cleanup_srcu_struct(&ctrl->srcu); | |
| 5186 | 5190 | nvme_auth_stop(ctrl); | |
| @@ -5226,7 +5230,6 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, | |||
| 5226 | 5230 | ||
| 5227 | 5231 | mutex_init(&ctrl->scan_lock); | |
| 5228 | 5232 | INIT_LIST_HEAD(&ctrl->namespaces); | |
| 5229 | - | xa_init(&ctrl->cels); | |
| 5230 | 5233 | ctrl->dev = dev; | |
| 5231 | 5234 | ctrl->ops = ops; | |
| 5232 | 5235 | ctrl->quirks = quirks; | |
modified drivers/nvme/host/fc.c
| @@ -3338,7 +3338,7 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) | |||
| 3338 | 3338 | ctrl->cnum, min_t(int, portptr->dev_loss_tmo, | |
| 3339 | 3339 | (ctrl->ctrl.opts->max_reconnects * | |
| 3340 | 3340 | ctrl->ctrl.opts->reconnect_delay))); | |
| 3341 | - | WARN_ON(nvme_delete_ctrl(&ctrl->ctrl)); | |
| 3341 | + | nvme_delete_ctrl(&ctrl->ctrl); | |
| 3342 | 3342 | } | |
| 3343 | 3343 | } | |
| 3344 | 3344 | ||
modified drivers/nvme/host/multipath.c
| @@ -646,17 +646,15 @@ static const struct file_operations nvme_ns_head_chr_fops = { | |||
| 646 | 646 | ||
| 647 | 647 | static void nvme_add_ns_head_cdev(struct nvme_ns_head *head) | |
| 648 | 648 | { | |
| 649 | - | char name[32]; | |
| 650 | - | ||
| 651 | 649 | head->cdev_device.parent = &head->subsys->dev; | |
| 652 | - | snprintf(name, sizeof(name), "ng%dn%d", head->subsys->instance, | |
| 653 | - | head->instance); | |
| 654 | 650 | ||
| 655 | 651 | nvme_get_ns_head(head); /* Undone in nvme_cdev_rel() */ | |
| 656 | - | if (nvme_cdev_add(name, &head->cdev, &head->cdev_device, | |
| 657 | - | &nvme_ns_head_chr_fops, THIS_MODULE)) { | |
| 652 | + | if (nvme_cdev_add(&head->cdev, &head->cdev_device, | |
| 653 | + | &nvme_ns_head_chr_fops, THIS_MODULE, | |
| 654 | + | head->subsys->instance, head->instance)) { | |
| 658 | 655 | dev_err(disk_to_dev(head->disk), | |
| 659 | - | "Unable to create the %s device\n", name); | |
| 656 | + | "Unable to create the ng%dn%d device\n", | |
| 657 | + | head->subsys->instance, head->instance); | |
| 660 | 658 | nvme_put_ns_head(head); | |
| 661 | 659 | return; | |
| 662 | 660 | } | |
| @@ -763,8 +761,6 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) | |||
| 763 | 761 | lim.dma_alignment = 3; | |
| 764 | 762 | lim.features |= BLK_FEAT_IO_STAT | BLK_FEAT_NOWAIT | | |
| 765 | 763 | BLK_FEAT_POLL | BLK_FEAT_ATOMIC_WRITES | BLK_FEAT_PCI_P2PDMA; | |
| 766 | - | if (head->ids.csi == NVME_CSI_ZNS) | |
| 767 | - | lim.features |= BLK_FEAT_ZONED; | |
| 768 | 764 | ||
| 769 | 765 | head->disk = blk_alloc_disk(&lim, ctrl->numa_node); | |
| 770 | 766 | if (IS_ERR(head->disk)) | |
| @@ -845,7 +841,8 @@ static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data, | |||
| 845 | 841 | u32 nr_nsids; | |
| 846 | 842 | size_t nsid_buf_size; | |
| 847 | 843 | ||
| 848 | - | if (WARN_ON_ONCE(offset > ctrl->ana_log_size - sizeof(*desc))) | |
| 844 | + | if (WARN_ON_ONCE(offset > ctrl->ana_log_size || | |
| 845 | + | sizeof(*desc) > ctrl->ana_log_size - offset)) | |
| 849 | 846 | return -EINVAL; | |
| 850 | 847 | ||
| 851 | 848 | nr_nsids = le32_to_cpu(desc->nnsids); | |
| @@ -861,7 +858,7 @@ static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data, | |||
| 861 | 858 | return -EINVAL; | |
| 862 | 859 | ||
| 863 | 860 | offset += sizeof(*desc); | |
| 864 | - | if (WARN_ON_ONCE(offset > ctrl->ana_log_size - nsid_buf_size)) | |
| 861 | + | if (WARN_ON_ONCE(nsid_buf_size > ctrl->ana_log_size - offset)) | |
| 865 | 862 | return -EINVAL; | |
| 866 | 863 | ||
| 867 | 864 | error = cb(ctrl, desc, data); | |
modified drivers/nvme/host/nvme.h
| @@ -415,7 +415,6 @@ struct nvme_ctrl { | |||
| 415 | 415 | unsigned long quirks; | |
| 416 | 416 | struct nvme_id_power_state psd[32]; | |
| 417 | 417 | struct nvme_effects_log *effects; | |
| 418 | - | struct xarray cels; | |
| 419 | 418 | struct work_struct scan_work; | |
| 420 | 419 | struct work_struct async_event_work; | |
| 421 | 420 | struct delayed_work ka_work; | |
| @@ -509,6 +508,8 @@ struct nvme_subsystem { | |||
| 509 | 508 | __guarded_by(&nvme_subsystems_lock); | |
| 510 | 509 | struct list_head nsheads | |
| 511 | 510 | __guarded_by(&lock); | |
| 511 | + | /* Command effects logs, indexed by CSI and protected by lock. */ | |
| 512 | + | struct xarray cels; | |
| 512 | 513 | char subnqn[NVMF_NQN_SIZE]; | |
| 513 | 514 | char serial[20]; | |
| 514 | 515 | char model[40]; | |
| @@ -1013,9 +1014,9 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi, | |||
| 1013 | 1014 | void nvme_get_ns_head(struct nvme_ns_head *head); | |
| 1014 | 1015 | bool nvme_tryget_ns_head(struct nvme_ns_head *head); | |
| 1015 | 1016 | void nvme_put_ns_head(struct nvme_ns_head *head); | |
| 1016 | - | int nvme_cdev_add(const char *name, struct cdev *cdev, | |
| 1017 | - | struct device *cdev_device, | |
| 1018 | - | const struct file_operations *fops, struct module *owner); | |
| 1017 | + | int nvme_cdev_add(struct cdev *cdev, struct device *cdev_device, | |
| 1018 | + | const struct file_operations *fops, struct module *owner, | |
| 1019 | + | int ctrl, int head); | |
| 1019 | 1020 | void nvme_cdev_del(struct cdev *cdev, struct device *cdev_device); | |
| 1020 | 1021 | int nvme_ioctl(struct block_device *bdev, blk_mode_t mode, | |
| 1021 | 1022 | unsigned int cmd, unsigned long arg); | |
modified drivers/nvme/host/pci.c
| @@ -4196,6 +4196,8 @@ static const struct pci_device_id nvme_id_table[] = { | |||
| 4196 | 4196 | .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN }, | |
| 4197 | 4197 | { PCI_DEVICE(0x1344, 0x6001), /* Micron Nitro NVMe */ | |
| 4198 | 4198 | .driver_data = NVME_QUIRK_BOGUS_NID, }, | |
| 4199 | + | { PCI_DEVICE(0x1344, 0x6004), /* Micron 4100AT */ | |
| 4200 | + | .driver_data = NVME_QUIRK_DMAPOOL_ALIGN_512, }, | |
| 4199 | 4201 | { PCI_DEVICE(0x1c5c, 0x1504), /* SK Hynix PC400 */ | |
| 4200 | 4202 | .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, | |
| 4201 | 4203 | { PCI_DEVICE(0x1c5c, 0x174a), /* SK Hynix P31 SSD */ | |
modified drivers/nvme/host/sysfs.c
| @@ -679,7 +679,7 @@ static ssize_t cntrltype_show(struct device *dev, | |||
| 679 | 679 | if (ctrl->cntrltype > NVME_CTRL_ADMIN || !type[ctrl->cntrltype]) | |
| 680 | 680 | return sysfs_emit(buf, "reserved\n"); | |
| 681 | 681 | ||
| 682 | - | return sysfs_emit(buf, type[ctrl->cntrltype]); | |
| 682 | + | return sysfs_emit(buf, "%s", type[ctrl->cntrltype]); | |
| 683 | 683 | } | |
| 684 | 684 | static DEVICE_ATTR_RO(cntrltype); | |
| 685 | 685 | ||
| @@ -696,7 +696,7 @@ static ssize_t dctype_show(struct device *dev, | |||
| 696 | 696 | if (ctrl->dctype > NVME_DCTYPE_CDC || !type[ctrl->dctype]) | |
| 697 | 697 | return sysfs_emit(buf, "reserved\n"); | |
| 698 | 698 | ||
| 699 | - | return sysfs_emit(buf, type[ctrl->dctype]); | |
| 699 | + | return sysfs_emit(buf, "%s", type[ctrl->dctype]); | |
| 700 | 700 | } | |
| 701 | 701 | static DEVICE_ATTR_RO(dctype); | |
| 702 | 702 | ||
modified drivers/nvme/host/tcp.c
| @@ -144,11 +144,6 @@ struct nvme_tcp_queue { | |||
| 144 | 144 | void (*state_change)(struct sock *); | |
| 145 | 145 | void (*data_ready)(struct sock *); | |
| 146 | 146 | void (*write_space)(struct sock *); | |
| 147 | - | ||
| 148 | - | #ifdef CONFIG_DEBUG_LOCK_ALLOC | |
| 149 | - | struct lock_class_key nvme_tcp_sk_key; | |
| 150 | - | struct lock_class_key nvme_tcp_slock_key; | |
| 151 | - | #endif | |
| 152 | 147 | }; | |
| 153 | 148 | ||
| 154 | 149 | static DEFINE_MUTEX(nvme_tcp_ctrl_mutex); | |
| @@ -185,9 +180,12 @@ static int nvme_tcp_try_send(struct nvme_tcp_queue *queue); | |||
| 185 | 180 | * a separate class prevents lockdep from conflating nvme-tcp socket use with | |
| 186 | 181 | * user-space socket API use. | |
| 187 | 182 | */ | |
| 188 | - | static void nvme_tcp_reclassify_socket(struct nvme_tcp_queue *queue) | |
| 183 | + | static struct lock_class_key nvme_tcp_sk_key[2]; | |
| 184 | + | static struct lock_class_key nvme_tcp_slock_key[2]; | |
| 185 | + | ||
| 186 | + | static void nvme_tcp_reclassify_socket(struct socket *sock) | |
| 189 | 187 | { | |
| 190 | - | struct sock *sk = queue->sock->sk; | |
| 188 | + | struct sock *sk = sock->sk; | |
| 191 | 189 | ||
| 192 | 190 | if (WARN_ON_ONCE(!sock_allow_reclassification(sk))) | |
| 193 | 191 | return; | |
| @@ -195,20 +193,22 @@ static void nvme_tcp_reclassify_socket(struct nvme_tcp_queue *queue) | |||
| 195 | 193 | switch (sk->sk_family) { | |
| 196 | 194 | case AF_INET: | |
| 197 | 195 | sock_lock_init_class_and_name(sk, "slock-AF_INET-NVME", | |
| 198 | - | &queue->nvme_tcp_slock_key, | |
| 196 | + | &nvme_tcp_slock_key[0], | |
| 199 | 197 | "sk_lock-AF_INET-NVME", | |
| 200 | - | &queue->nvme_tcp_sk_key); | |
| 198 | + | &nvme_tcp_sk_key[0]); | |
| 201 | 199 | break; | |
| 202 | 200 | case AF_INET6: | |
| 203 | 201 | sock_lock_init_class_and_name(sk, "slock-AF_INET6-NVME", | |
| 204 | - | &queue->nvme_tcp_slock_key, | |
| 202 | + | &nvme_tcp_slock_key[1], | |
| 205 | 203 | "sk_lock-AF_INET6-NVME", | |
| 206 | - | &queue->nvme_tcp_sk_key); | |
| 204 | + | &nvme_tcp_sk_key[1]); | |
| 207 | 205 | break; | |
| 208 | 206 | default: | |
| 209 | 207 | WARN_ON_ONCE(1); | |
| 210 | 208 | } | |
| 211 | 209 | } | |
| 210 | + | #else | |
| 211 | + | static void nvme_tcp_reclassify_socket(struct socket *sock) { } | |
| 212 | 212 | #endif | |
| 213 | 213 | ||
| 214 | 214 | static inline struct nvme_tcp_ctrl *to_tcp_ctrl(struct nvme_ctrl *ctrl) | |
| @@ -1523,11 +1523,6 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid) | |||
| 1523 | 1523 | mutex_destroy(&queue->send_mutex); | |
| 1524 | 1524 | mutex_destroy(&queue->queue_lock); | |
| 1525 | 1525 | mutex_destroy(&queue->pf_cache_lock); | |
| 1526 | - | ||
| 1527 | - | #ifdef CONFIG_DEBUG_LOCK_ALLOC | |
| 1528 | - | lockdep_unregister_key(&queue->nvme_tcp_sk_key); | |
| 1529 | - | lockdep_unregister_key(&queue->nvme_tcp_slock_key); | |
| 1530 | - | #endif | |
| 1531 | 1526 | } | |
| 1532 | 1527 | ||
| 1533 | 1528 | static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue) | |
| @@ -1875,12 +1870,6 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid, | |||
| 1875 | 1870 | ||
| 1876 | 1871 | sk_net_refcnt_upgrade(queue->sock->sk); | |
| 1877 | 1872 | ||
| 1878 | - | #ifdef CONFIG_DEBUG_LOCK_ALLOC | |
| 1879 | - | lockdep_register_key(&queue->nvme_tcp_sk_key); | |
| 1880 | - | lockdep_register_key(&queue->nvme_tcp_slock_key); | |
| 1881 | - | nvme_tcp_reclassify_socket(queue); | |
| 1882 | - | #endif | |
| 1883 | - | ||
| 1884 | 1873 | /* Single syn retry */ | |
| 1885 | 1874 | tcp_sock_set_syncnt(queue->sock->sk, 1); | |
| 1886 | 1875 | ||
| @@ -1968,6 +1957,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid, | |||
| 1968 | 1957 | goto err_init_connect; | |
| 1969 | 1958 | } | |
| 1970 | 1959 | ||
| 1960 | + | nvme_tcp_reclassify_socket(queue->sock); | |
| 1961 | + | ||
| 1971 | 1962 | ret = nvme_tcp_init_connection(queue); | |
| 1972 | 1963 | if (ret) | |
| 1973 | 1964 | goto err_init_connect; | |
| @@ -1984,10 +1975,6 @@ err_sock: | |||
| 1984 | 1975 | /* Use sync variant - see nvme_tcp_free_queue() for explanation */ | |
| 1985 | 1976 | __fput_sync(queue->sock->file); | |
| 1986 | 1977 | queue->sock = NULL; | |
| 1987 | - | #ifdef CONFIG_DEBUG_LOCK_ALLOC | |
| 1988 | - | lockdep_unregister_key(&queue->nvme_tcp_sk_key); | |
| 1989 | - | lockdep_unregister_key(&queue->nvme_tcp_slock_key); | |
| 1990 | - | #endif | |
| 1991 | 1978 | err_destroy_mutex: | |
| 1992 | 1979 | mutex_destroy(&queue->send_mutex); | |
| 1993 | 1980 | mutex_destroy(&queue->queue_lock); | |
modified drivers/nvme/target/configfs.c
| @@ -534,6 +534,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item, | |||
| 534 | 534 | struct nvmet_subsys *subsys = ns->subsys; | |
| 535 | 535 | size_t len; | |
| 536 | 536 | int ret; | |
| 537 | + | char *new_path = NULL; | |
| 537 | 538 | ||
| 538 | 539 | mutex_lock(&subsys->lock); | |
| 539 | 540 | ret = -EBUSY; | |
| @@ -545,12 +546,14 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item, | |||
| 545 | 546 | if (!len) | |
| 546 | 547 | goto out_unlock; | |
| 547 | 548 | ||
| 548 | - | kfree(ns->device_path); | |
| 549 | 549 | ret = -ENOMEM; | |
| 550 | - | ns->device_path = kmemdup_nul(page, len, GFP_KERNEL); | |
| 551 | - | if (!ns->device_path) | |
| 550 | + | new_path = kmemdup_nul(page, len, GFP_KERNEL); | |
| 551 | + | if (!new_path) | |
| 552 | 552 | goto out_unlock; | |
| 553 | 553 | ||
| 554 | + | kfree(ns->device_path); | |
| 555 | + | ns->device_path = new_path; | |
| 556 | + | ||
| 554 | 557 | mutex_unlock(&subsys->lock); | |
| 555 | 558 | return count; | |
| 556 | 559 | ||
modified drivers/nvme/target/core.c
| @@ -446,20 +446,27 @@ u16 nvmet_req_find_ns(struct nvmet_req *req) | |||
| 446 | 446 | { | |
| 447 | 447 | u32 nsid = le32_to_cpu(req->cmd->common.nsid); | |
| 448 | 448 | struct nvmet_subsys *subsys = nvmet_req_subsys(req); | |
| 449 | + | u16 status = NVME_SC_SUCCESS; | |
| 449 | 450 | ||
| 451 | + | rcu_read_lock(); | |
| 450 | 452 | req->ns = xa_load(&subsys->namespaces, nsid); | |
| 451 | - | if (unlikely(!req->ns || !req->ns->enabled)) { | |
| 453 | + | if (unlikely(!req->ns) || | |
| 454 | + | !test_bit(NVMET_NS_IO_LIVE, &req->ns->flags) || | |
| 455 | + | !percpu_ref_tryget_live_rcu(&req->ns->ref)) { | |
| 452 | 456 | req->error_loc = offsetof(struct nvme_common_command, nsid); | |
| 453 | - | if (!req->ns) /* ns doesn't exist! */ | |
| 454 | - | return NVME_SC_INVALID_NS | NVME_STATUS_DNR; | |
| 457 | + | if (!req->ns) { /* ns doesn't exist! */ | |
| 458 | + | status = NVME_SC_INVALID_NS | NVME_STATUS_DNR; | |
| 459 | + | goto unlock; | |
| 460 | + | } | |
| 455 | 461 | ||
| 456 | 462 | /* ns exists but it's disabled */ | |
| 457 | 463 | req->ns = NULL; | |
| 458 | - | return NVME_SC_INTERNAL_PATH_ERROR; | |
| 464 | + | status = NVME_SC_INTERNAL_PATH_ERROR; | |
| 459 | 465 | } | |
| 466 | + | unlock: | |
| 467 | + | rcu_read_unlock(); | |
| 460 | 468 | ||
| 461 | - | percpu_ref_get(&req->ns->ref); | |
| 462 | - | return NVME_SC_SUCCESS; | |
| 469 | + | return status; | |
| 463 | 470 | } | |
| 464 | 471 | ||
| 465 | 472 | static void nvmet_destroy_namespace(struct percpu_ref *ref) | |
| @@ -623,6 +630,7 @@ int nvmet_ns_enable(struct nvmet_ns *ns) | |||
| 623 | 630 | ns->enabled = true; | |
| 624 | 631 | xa_set_mark(&subsys->namespaces, ns->nsid, NVMET_NS_ENABLED); | |
| 625 | 632 | nvmet_debugfs_ns_setup(ns); | |
| 633 | + | set_bit(NVMET_NS_IO_LIVE, &ns->flags); | |
| 626 | 634 | ret = 0; | |
| 627 | 635 | out_unlock: | |
| 628 | 636 | mutex_unlock(&subsys->lock); | |
| @@ -643,11 +651,11 @@ void nvmet_ns_disable(struct nvmet_ns *ns) | |||
| 643 | 651 | struct nvmet_subsys *subsys = ns->subsys; | |
| 644 | 652 | struct nvmet_ctrl *ctrl; | |
| 645 | 653 | ||
| 654 | + | if (!test_and_clear_bit(NVMET_NS_IO_LIVE, &ns->flags)) | |
| 655 | + | return; | |
| 656 | + | ||
| 646 | 657 | mutex_lock(&subsys->lock); | |
| 647 | - | if (!ns->enabled) | |
| 648 | - | goto out_unlock; | |
| 649 | 658 | ||
| 650 | - | ns->enabled = false; | |
| 651 | 659 | xa_clear_mark(&subsys->namespaces, ns->nsid, NVMET_NS_ENABLED); | |
| 652 | 660 | nvmet_debugfs_ns_free(ns); | |
| 653 | 661 | ||
| @@ -675,7 +683,7 @@ void nvmet_ns_disable(struct nvmet_ns *ns) | |||
| 675 | 683 | mutex_lock(&subsys->lock); | |
| 676 | 684 | nvmet_ns_changed(subsys, ns->nsid); | |
| 677 | 685 | nvmet_ns_dev_disable(ns); | |
| 678 | - | out_unlock: | |
| 686 | + | ns->enabled = false; | |
| 679 | 687 | mutex_unlock(&subsys->lock); | |
| 680 | 688 | } | |
| 681 | 689 | ||
| @@ -1317,7 +1325,7 @@ static int nvmet_req_alloc_p2pmem_sgls(struct pci_dev *p2p_dev, | |||
| 1317 | 1325 | ||
| 1318 | 1326 | return 0; | |
| 1319 | 1327 | out_free_sg: | |
| 1320 | - | pci_p2pmem_free_sgl(req->p2p_dev, req->sg); | |
| 1328 | + | pci_p2pmem_free_sgl(p2p_dev, req->sg); | |
| 1321 | 1329 | out_err: | |
| 1322 | 1330 | return -ENOMEM; | |
| 1323 | 1331 | } | |
| @@ -1648,6 +1656,8 @@ struct nvmet_ctrl *nvmet_alloc_ctrl(struct nvmet_alloc_ctrl_args *args) | |||
| 1648 | 1656 | INIT_DELAYED_WORK(&ctrl->ka_work, nvmet_keep_alive_timer); | |
| 1649 | 1657 | ||
| 1650 | 1658 | memcpy(ctrl->hostnqn, args->hostnqn, NVMF_NQN_SIZE); | |
| 1659 | + | if (args->hostid) | |
| 1660 | + | uuid_copy(&ctrl->hostid, args->hostid); | |
| 1651 | 1661 | ||
| 1652 | 1662 | kref_init(&ctrl->ref); | |
| 1653 | 1663 | ctrl->subsys = subsys; | |
| @@ -1706,9 +1716,6 @@ struct nvmet_ctrl *nvmet_alloc_ctrl(struct nvmet_alloc_ctrl_args *args) | |||
| 1706 | 1716 | ||
| 1707 | 1717 | nvmet_start_keep_alive_timer(ctrl); | |
| 1708 | 1718 | ||
| 1709 | - | if (args->hostid) | |
| 1710 | - | uuid_copy(&ctrl->hostid, args->hostid); | |
| 1711 | - | ||
| 1712 | 1719 | dhchap_status = nvmet_setup_auth(ctrl, args->sq, false); | |
| 1713 | 1720 | if (dhchap_status) { | |
| 1714 | 1721 | pr_err("Failed to setup authentication, dhchap status %u\n", | |
modified drivers/nvme/target/fabrics-cmd-auth.c
| @@ -427,7 +427,7 @@ static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al) | |||
| 427 | 427 | struct nvmet_ctrl *ctrl = req->sq->ctrl; | |
| 428 | 428 | int ret = 0; | |
| 429 | 429 | int hash_len = nvme_auth_hmac_hash_len(ctrl->shash_id); | |
| 430 | - | int data_size = sizeof(*d) + hash_len; | |
| 430 | + | int data_size = sizeof(*data) + hash_len; | |
| 431 | 431 | ||
| 432 | 432 | if (ctrl->dh_tfm) | |
| 433 | 433 | data_size += ctrl->dh_keysize; | |
modified drivers/nvme/target/nvmet.h
| @@ -112,6 +112,8 @@ struct nvmet_ns { | |||
| 112 | 112 | ||
| 113 | 113 | bool buffered_io; | |
| 114 | 114 | bool enabled; | |
| 115 | + | #define NVMET_NS_IO_LIVE 0 | |
| 116 | + | unsigned long flags; | |
| 115 | 117 | struct nvmet_subsys *subsys; | |
| 116 | 118 | const char *device_path; | |
| 117 | 119 | ||
modified drivers/nvme/target/pci-epf.c
| @@ -978,6 +978,9 @@ nvmet_pci_epf_get_sgl_segment(struct nvmet_pci_epf_ctrl *ctrl, | |||
| 978 | 978 | int nr_descs, ret; | |
| 979 | 979 | void *buf; | |
| 980 | 980 | ||
| 981 | + | if (length < sizeof(struct nvme_sgl_desc)) | |
| 982 | + | return NULL; | |
| 983 | + | ||
| 981 | 984 | buf = kmalloc(length, GFP_KERNEL); | |
| 982 | 985 | if (!buf) | |
| 983 | 986 | return NULL; | |
modified drivers/nvme/target/pr.c
| @@ -51,6 +51,8 @@ u16 nvmet_set_feat_resv_notif_mask(struct nvmet_req *req, u32 mask) | |||
| 51 | 51 | ||
| 52 | 52 | if (nsid != U32_MAX) { | |
| 53 | 53 | status = nvmet_req_find_ns(req); | |
| 54 | + | if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR)) | |
| 55 | + | return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR; | |
| 54 | 56 | if (status) | |
| 55 | 57 | return status; | |
| 56 | 58 | if (!req->ns->pr.enable) | |
| @@ -75,6 +77,8 @@ u16 nvmet_get_feat_resv_notif_mask(struct nvmet_req *req) | |||
| 75 | 77 | u16 status; | |
| 76 | 78 | ||
| 77 | 79 | status = nvmet_req_find_ns(req); | |
| 80 | + | if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR)) | |
| 81 | + | return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR; | |
| 78 | 82 | if (status) | |
| 79 | 83 | return status; | |
| 80 | 84 | ||
modified drivers/of/base.c
| @@ -96,9 +96,17 @@ static bool __of_node_is_type(const struct device_node *np, const char *type) | |||
| 96 | 96 | return !strcmp(match, type); | |
| 97 | 97 | } | |
| 98 | 98 | ||
| 99 | + | static bool of_coreboot_present(void) | |
| 100 | + | { | |
| 101 | + | struct device_node *np __free(device_node) = | |
| 102 | + | of_find_compatible_node(NULL, NULL, "coreboot"); | |
| 103 | + | ||
| 104 | + | return np; | |
| 105 | + | } | |
| 106 | + | ||
| 99 | 107 | #define EXCLUDED_DEFAULT_CELLS_PLATFORMS ( \ | |
| 100 | 108 | IS_ENABLED(CONFIG_SPARC) || \ | |
| 101 | - | of_find_compatible_node(NULL, NULL, "coreboot") \ | |
| 109 | + | of_coreboot_present() \ | |
| 102 | 110 | ) | |
| 103 | 111 | ||
| 104 | 112 | int of_bus_n_addr_cells(struct device_node *np) | |
modified drivers/of/irq.c
| @@ -754,6 +754,8 @@ void __init of_irq_init(const struct of_device_id *matches) | |||
| 754 | 754 | ||
| 755 | 755 | list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) { | |
| 756 | 756 | list_del(&desc->list); | |
| 757 | + | of_node_put(desc->interrupt_parent); | |
| 758 | + | of_node_put(desc->dev); | |
| 757 | 759 | kfree(desc); | |
| 758 | 760 | } | |
| 759 | 761 | err: | |
modified drivers/of/overlay.c
| @@ -256,6 +256,9 @@ static struct property *dup_and_fixup_symbol_prop( | |||
| 256 | 256 | if (!target_path) | |
| 257 | 257 | return NULL; | |
| 258 | 258 | target_path_len = strlen(target_path); | |
| 259 | + | /* a root target renders as "/"; drop it to avoid "//" results */ | |
| 260 | + | if (target_path_len == 1 && target_path[0] == '/' && path_tail_len) | |
| 261 | + | target_path_len = 0; | |
| 259 | 262 | ||
| 260 | 263 | new_prop = kzalloc_obj(*new_prop); | |
| 261 | 264 | if (!new_prop) | |
| @@ -358,12 +361,13 @@ static int add_changeset_property(struct overlay_changeset *ovcs, | |||
| 358 | 361 | return -ENOMEM; | |
| 359 | 362 | ||
| 360 | 363 | if (!prop) { | |
| 361 | - | if (!target->in_livetree) { | |
| 364 | + | ret = of_changeset_add_property(&ovcs->cset, target->np, | |
| 365 | + | new_prop); | |
| 366 | + | /* the detached node owns the property until the apply */ | |
| 367 | + | if (!ret && !target->in_livetree) { | |
| 362 | 368 | new_prop->next = target->np->deadprops; | |
| 363 | 369 | target->np->deadprops = new_prop; | |
| 364 | 370 | } | |
| 365 | - | ret = of_changeset_add_property(&ovcs->cset, target->np, | |
| 366 | - | new_prop); | |
| 367 | 371 | } else { | |
| 368 | 372 | ret = of_changeset_update_property(&ovcs->cset, target->np, | |
| 369 | 373 | new_prop); | |
| @@ -853,6 +857,10 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs, | |||
| 853 | 857 | err_out: | |
| 854 | 858 | pr_err("%s() failed, ret = %d\n", __func__, ret); | |
| 855 | 859 | ||
| 860 | + | /* let free_overlay_changeset() put the fragments set up so far */ | |
| 861 | + | if (ovcs->fragments) | |
| 862 | + | ovcs->count = cnt; | |
| 863 | + | ||
| 856 | 864 | return ret; | |
| 857 | 865 | } | |
| 858 | 866 | ||
| @@ -863,7 +871,8 @@ static void free_overlay_changeset(struct overlay_changeset *ovcs) | |||
| 863 | 871 | if (ovcs->cset.entries.next) | |
| 864 | 872 | of_changeset_destroy(&ovcs->cset); | |
| 865 | 873 | ||
| 866 | - | if (ovcs->id) { | |
| 874 | + | /* a failed idr_alloc() leaves its negative error in ovcs->id */ | |
| 875 | + | if (ovcs->id > 0) { | |
| 867 | 876 | idr_remove(&ovcs_idr, ovcs->id); | |
| 868 | 877 | list_del(&ovcs->ovcs_list); | |
| 869 | 878 | ovcs->id = 0; | |
modified drivers/pci/pci.c
| @@ -3769,8 +3769,21 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask) | |||
| 3769 | 3769 | } | |
| 3770 | 3770 | ||
| 3771 | 3771 | root = pcie_find_root_port(dev); | |
| 3772 | - | if (!root) | |
| 3772 | + | if (!root) { | |
| 3773 | + | ||
| 3774 | + | /* | |
| 3775 | + | * A hypervisor may expose a topology with the root port | |
| 3776 | + | * not visible to the guest. If the hypervisor has already | |
| 3777 | + | * set AtomicOp Requester Enable in the endpoint, we assume | |
| 3778 | + | * it has verified support in the root port, so it is safe | |
| 3779 | + | * for the driver to use AtomicOps. | |
| 3780 | + | */ | |
| 3781 | + | pcie_capability_read_dword(dev, PCI_EXP_DEVCTL2, &ctl2); | |
| 3782 | + | if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ) | |
| 3783 | + | return 0; | |
| 3784 | + | ||
| 3773 | 3785 | return -EINVAL; | |
| 3786 | + | } | |
| 3774 | 3787 | ||
| 3775 | 3788 | pcie_capability_read_dword(root, PCI_EXP_DEVCAP2, &cap); | |
| 3776 | 3789 | if ((cap & cap_mask) != cap_mask) | |
modified drivers/pci/pcie/aer.c
| @@ -1360,8 +1360,10 @@ static DEFINE_KFIFO(aer_recover_ring, struct aer_recover_entry, | |||
| 1360 | 1360 | ||
| 1361 | 1361 | static void aer_recover_work_func(struct work_struct *work) | |
| 1362 | 1362 | { | |
| 1363 | + | struct aer_capability_regs *regs; | |
| 1363 | 1364 | struct aer_recover_entry entry; | |
| 1364 | 1365 | struct pci_dev *pdev; | |
| 1366 | + | u32 err; | |
| 1365 | 1367 | ||
| 1366 | 1368 | while (kfifo_get(&aer_recover_ring, &entry)) { | |
| 1367 | 1369 | pdev = pci_get_domain_bus_and_slot(entry.domain, entry.bus, | |
| @@ -1375,6 +1377,12 @@ static void aer_recover_work_func(struct work_struct *work) | |||
| 1375 | 1377 | } | |
| 1376 | 1378 | pci_print_aer(pdev, entry.severity, entry.regs); | |
| 1377 | 1379 | ||
| 1380 | + | regs = entry.regs; | |
| 1381 | + | if (entry.severity == AER_CORRECTABLE) | |
| 1382 | + | err = regs->cor_status & ~regs->cor_mask; | |
| 1383 | + | else | |
| 1384 | + | err = regs->uncor_status & ~regs->uncor_mask; | |
| 1385 | + | ||
| 1378 | 1386 | /* | |
| 1379 | 1387 | * Memory for aer_capability_regs(entry.regs) is being | |
| 1380 | 1388 | * allocated from the ghes_estatus_pool to protect it from | |
| @@ -1385,12 +1393,14 @@ static void aer_recover_work_func(struct work_struct *work) | |||
| 1385 | 1393 | ghes_estatus_pool_region_free((unsigned long)entry.regs, | |
| 1386 | 1394 | sizeof(struct aer_capability_regs)); | |
| 1387 | 1395 | ||
| 1388 | - | if (entry.severity == AER_NONFATAL) | |
| 1389 | - | pcie_do_recovery(pdev, pci_channel_io_normal, | |
| 1390 | - | aer_root_reset); | |
| 1391 | - | else if (entry.severity == AER_FATAL) | |
| 1392 | - | pcie_do_recovery(pdev, pci_channel_io_frozen, | |
| 1393 | - | aer_root_reset); | |
| 1396 | + | if (err) { | |
| 1397 | + | if (entry.severity == AER_NONFATAL) | |
| 1398 | + | pcie_do_recovery(pdev, pci_channel_io_normal, | |
| 1399 | + | aer_root_reset); | |
| 1400 | + | else if (entry.severity == AER_FATAL) | |
| 1401 | + | pcie_do_recovery(pdev, pci_channel_io_frozen, | |
| 1402 | + | aer_root_reset); | |
| 1403 | + | } | |
| 1394 | 1404 | pci_dev_put(pdev); | |
| 1395 | 1405 | } | |
| 1396 | 1406 | } | |
modified drivers/pinctrl/qcom/pinctrl-hawi.c
| @@ -47,7 +47,6 @@ | |||
| 47 | 47 | .intr_wakeup_present_bit = 6, \ | |
| 48 | 48 | .intr_wakeup_enable_bit = 7, \ | |
| 49 | 49 | .intr_target_bit = 8, \ | |
| 50 | - | .intr_target_width = 4, \ | |
| 51 | 50 | .intr_target_kpss_val = 3, \ | |
| 52 | 51 | .intr_raw_status_bit = 4, \ | |
| 53 | 52 | .intr_polarity_bit = 1, \ | |
modified drivers/pinctrl/qcom/pinctrl-ipq5018.c
| @@ -563,7 +563,7 @@ static const char * const qdss_cti_trig_out_b1_groups[] = { | |||
| 563 | 563 | }; | |
| 564 | 564 | ||
| 565 | 565 | static const char * const pwm3_groups[] = { | |
| 566 | - | "gpio45", "gpio13", | |
| 566 | + | "gpio45", | |
| 567 | 567 | }; | |
| 568 | 568 | ||
| 569 | 569 | static const char * const qdss_cti_trig_in_b1_groups[] = { | |
| @@ -689,7 +689,7 @@ static const struct msm_pingroup ipq5018_groups[] = { | |||
| 689 | 689 | PINGROUP(10, blsp0_spi, blsp1_uart0, led0, gcc_plltest, qdss_tracedata_a, _, _, _, _), | |
| 690 | 690 | PINGROUP(11, blsp0_spi, blsp1_uart0, _, gcc_tlmm, qdss_tracedata_a, _, _, _, _), | |
| 691 | 691 | PINGROUP(12, blsp0_spi, blsp0_i2c, blsp1_uart0, _, gcc_plltest, qdss_tracedata_a, _, _, _), | |
| 692 | - | PINGROUP(13, blsp0_spi, blsp0_i2c, blsp1_uart0, pwm3, qdss_tracedata_a, _, _, _, _), | |
| 692 | + | PINGROUP(13, blsp0_spi, blsp0_i2c, blsp1_uart0, _, qdss_tracedata_a, _, _, _, _), | |
| 693 | 693 | PINGROUP(14, pcie0_clk, _, _, cri_trng0, qdss_tracedata_a, _, _, _, _), | |
| 694 | 694 | PINGROUP(15, _, _, cri_trng1, qdss_tracedata_a, _, _, _, _, _), | |
| 695 | 695 | PINGROUP(16, pcie0_wake, _, _, cri_trng, qdss_tracedata_a, _, _, _, _), | |
modified drivers/pinctrl/qcom/pinctrl-maili.c
| @@ -47,7 +47,6 @@ | |||
| 47 | 47 | .intr_wakeup_present_bit = 6, \ | |
| 48 | 48 | .intr_wakeup_enable_bit = 7, \ | |
| 49 | 49 | .intr_target_bit = 8, \ | |
| 50 | - | .intr_target_width = 4, \ | |
| 51 | 50 | .intr_target_kpss_val = 3, \ | |
| 52 | 51 | .intr_raw_status_bit = 4, \ | |
| 53 | 52 | .intr_polarity_bit = 1, \ | |
modified drivers/pinctrl/qcom/pinctrl-nord.c
| @@ -32,7 +32,6 @@ | |||
| 32 | 32 | .intr_wakeup_present_bit = 6, \ | |
| 33 | 33 | .intr_wakeup_enable_bit = 7, \ | |
| 34 | 34 | .intr_target_bit = 8, \ | |
| 35 | - | .intr_target_width = 4, \ | |
| 36 | 35 | .intr_target_kpss_val = 3, \ | |
| 37 | 36 | .intr_raw_status_bit = 4, \ | |
| 38 | 37 | .intr_polarity_bit = 1, \ | |
modified drivers/pinctrl/qcom/pinctrl-qcs8300.c
| @@ -45,7 +45,6 @@ | |||
| 45 | 45 | .intr_enable_bit = 0, \ | |
| 46 | 46 | .intr_status_bit = 0, \ | |
| 47 | 47 | .intr_target_bit = 5, \ | |
| 48 | - | .intr_target_width = 4, \ | |
| 49 | 48 | .intr_target_kpss_val = 3, \ | |
| 50 | 49 | .intr_raw_status_bit = 4, \ | |
| 51 | 50 | .intr_polarity_bit = 1, \ | |
modified drivers/pmdomain/imx/imx8m-blk-ctrl.c
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | #include <linux/pm_runtime.h> | |
| 16 | 16 | #include <linux/regmap.h> | |
| 17 | 17 | #include <linux/clk.h> | |
| 18 | + | #include <linux/mutex.h> | |
| 18 | 19 | ||
| 19 | 20 | #include <dt-bindings/power/imx8mm-power.h> | |
| 20 | 21 | #include <dt-bindings/power/imx8mn-power.h> | |
| @@ -34,6 +35,12 @@ struct imx8m_blk_ctrl { | |||
| 34 | 35 | struct regmap *regmap; | |
| 35 | 36 | struct imx8m_blk_ctrl_domain *domains; | |
| 36 | 37 | struct genpd_onecell_data onecell_data; | |
| 38 | + | /* | |
| 39 | + | * Serializes the blk-ctrl reset/clock sequence across sibling domains; | |
| 40 | + | * their transitions interact through the shared VPUMIX bus domain, | |
| 41 | + | * VPU_NOC and the not-ack-verified ADB400 handshake (ERR050531). | |
| 42 | + | */ | |
| 43 | + | struct mutex power_lock; | |
| 37 | 44 | }; | |
| 38 | 45 | ||
| 39 | 46 | struct imx8m_blk_ctrl_domain_data { | |
| @@ -98,6 +105,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd) | |||
| 98 | 105 | struct imx8m_blk_ctrl *bc = domain->bc; | |
| 99 | 106 | int ret; | |
| 100 | 107 | ||
| 108 | + | guard(mutex)(&bc->power_lock); | |
| 109 | + | ||
| 101 | 110 | /* make sure bus domain is awake */ | |
| 102 | 111 | ret = pm_runtime_get_sync(bc->bus_power_dev); | |
| 103 | 112 | if (ret < 0) { | |
| @@ -164,6 +173,8 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) | |||
| 164 | 173 | const struct imx8m_blk_ctrl_domain_data *data = domain->data; | |
| 165 | 174 | struct imx8m_blk_ctrl *bc = domain->bc; | |
| 166 | 175 | ||
| 176 | + | guard(mutex)(&bc->power_lock); | |
| 177 | + | ||
| 167 | 178 | /* put devices into reset and disable clocks */ | |
| 168 | 179 | if (data->mipi_phy_rst_mask) | |
| 169 | 180 | regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask); | |
| @@ -202,6 +213,10 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) | |||
| 202 | 213 | ||
| 203 | 214 | bc->dev = dev; | |
| 204 | 215 | ||
| 216 | + | ret = devm_mutex_init(dev, &bc->power_lock); | |
| 217 | + | if (ret) | |
| 218 | + | return ret; | |
| 219 | + | ||
| 205 | 220 | bc_data = of_device_get_match_data(dev); | |
| 206 | 221 | ||
| 207 | 222 | base = devm_platform_ioremap_resource(pdev, 0); | |
modified drivers/pmdomain/rockchip/pm-domains.c
| @@ -759,7 +759,19 @@ static int rockchip_pd_attach_dev(struct generic_pm_domain *genpd, | |||
| 759 | 759 | } | |
| 760 | 760 | ||
| 761 | 761 | i = 0; | |
| 762 | - | while ((clk = of_clk_get(dev->of_node, i++)) && !IS_ERR(clk)) { | |
| 762 | + | while (1) { | |
| 763 | + | clk = of_clk_get(dev->of_node, i++); | |
| 764 | + | if (IS_ERR(clk)) { | |
| 765 | + | error = PTR_ERR(clk); | |
| 766 | + | if (error == -ENOENT) | |
| 767 | + | break; | |
| 768 | + | ||
| 769 | + | dev_err(dev, "failed to get clock %d: %d\n", i - 1, | |
| 770 | + | error); | |
| 771 | + | pm_clk_destroy(dev); | |
| 772 | + | return error; | |
| 773 | + | } | |
| 774 | + | ||
| 763 | 775 | dev_dbg(dev, "adding clock '%pC' to list of PM clocks\n", clk); | |
| 764 | 776 | error = pm_clk_add_clk(dev, clk); | |
| 765 | 777 | if (error) { | |
| @@ -842,7 +854,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, | |||
| 842 | 854 | dev_err(pmu->dev, | |
| 843 | 855 | "%pOFn: failed to get clk at index %d: %d\n", | |
| 844 | 856 | node, i, error); | |
| 845 | - | return error; | |
| 857 | + | goto err_put_clocks; | |
| 846 | 858 | } | |
| 847 | 859 | } | |
| 848 | 860 | ||
| @@ -1018,7 +1030,9 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, | |||
| 1018 | 1030 | parent_domain->name, child_domain->name); | |
| 1019 | 1031 | } | |
| 1020 | 1032 | ||
| 1021 | - | rockchip_pm_add_subdomain(pmu, np); | |
| 1033 | + | error = rockchip_pm_add_subdomain(pmu, np); | |
| 1034 | + | if (error) | |
| 1035 | + | return error; | |
| 1022 | 1036 | } | |
| 1023 | 1037 | ||
| 1024 | 1038 | return 0; | |
modified drivers/power/sequencing/pwrseq-pcie-m2.c
| @@ -197,6 +197,8 @@ static const struct pci_device_id pwrseq_m2_pci_ids[] = { | |||
| 197 | 197 | .driver_data = (kernel_ulong_t)"qcom,wcn6855-bt" }, | |
| 198 | 198 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x1107, PCI_VENDOR_ID_QCOM, 0x337c), | |
| 199 | 199 | .driver_data = (kernel_ulong_t)"qcom,wcn7850-bt" }, | |
| 200 | + | { PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x1107, PCI_VENDOR_ID_LENOVO, 0xe0e9), | |
| 201 | + | .driver_data = (kernel_ulong_t)"qcom,wcn7850-bt" }, | |
| 200 | 202 | { } /* Sentinel */ | |
| 201 | 203 | }; | |
| 202 | 204 | ||
| @@ -570,6 +572,7 @@ err_destroy_mutex: | |||
| 570 | 572 | mutex_destroy(&ctx->list_lock); | |
| 571 | 573 | err_free_regulators: | |
| 572 | 574 | regulator_bulk_free(ctx->num_vregs, ctx->regs); | |
| 575 | + | kfree(ctx->regs); | |
| 573 | 576 | ||
| 574 | 577 | return ret; | |
| 575 | 578 | } | |
| @@ -583,6 +586,7 @@ static void pwrseq_pcie_m2_remove(struct platform_device *pdev) | |||
| 583 | 586 | mutex_destroy(&ctx->list_lock); | |
| 584 | 587 | ||
| 585 | 588 | regulator_bulk_free(ctx->num_vregs, ctx->regs); | |
| 589 | + | kfree(ctx->regs); | |
| 586 | 590 | } | |
| 587 | 591 | ||
| 588 | 592 | static const struct of_device_id pwrseq_pcie_m2_of_match[] = { | |
modified drivers/ptp/ptp_ocp.c
| @@ -1825,7 +1825,7 @@ ptp_ocp_watchdog(struct timer_list *t) | |||
| 1825 | 1825 | static void | |
| 1826 | 1826 | ptp_ocp_estimate_pci_timing(struct ptp_ocp *bp) | |
| 1827 | 1827 | { | |
| 1828 | - | ktime_t start, end, delay = U64_MAX; | |
| 1828 | + | ktime_t start, end, delay = KTIME_MAX; | |
| 1829 | 1829 | u32 ctrl; | |
| 1830 | 1830 | int i; | |
| 1831 | 1831 | ||
modified drivers/regulator/ltc3676.c
| @@ -232,7 +232,7 @@ static const struct regulator_desc ltc3676_regulators[LTC3676_NUM_REGULATORS] = | |||
| 232 | 232 | LTC3676_FIXED_REG(LDO4, ldo4, LDOB, 2), | |
| 233 | 233 | }; | |
| 234 | 234 | ||
| 235 | - | static bool ltc3676_readable_writeable_reg(struct device *dev, unsigned int reg) | |
| 235 | + | static bool ltc3676_writeable_reg(struct device *dev, unsigned int reg) | |
| 236 | 236 | { | |
| 237 | 237 | switch (reg) { | |
| 238 | 238 | case LTC3676_BUCK1 ... LTC3676_IRQSTAT: | |
| @@ -243,6 +243,15 @@ static bool ltc3676_readable_writeable_reg(struct device *dev, unsigned int reg) | |||
| 243 | 243 | return false; | |
| 244 | 244 | } | |
| 245 | 245 | ||
| 246 | + | static bool ltc3676_readable_reg(struct device *dev, unsigned int reg) | |
| 247 | + | { | |
| 248 | + | switch (reg) { | |
| 249 | + | case LTC3676_BUCK1 ... LTC3676_IRQSTAT: | |
| 250 | + | return true; | |
| 251 | + | } | |
| 252 | + | return false; | |
| 253 | + | } | |
| 254 | + | ||
| 246 | 255 | static bool ltc3676_volatile_reg(struct device *dev, unsigned int reg) | |
| 247 | 256 | { | |
| 248 | 257 | switch (reg) { | |
| @@ -255,8 +264,8 @@ static bool ltc3676_volatile_reg(struct device *dev, unsigned int reg) | |||
| 255 | 264 | static const struct regmap_config ltc3676_regmap_config = { | |
| 256 | 265 | .reg_bits = 8, | |
| 257 | 266 | .val_bits = 8, | |
| 258 | - | .writeable_reg = ltc3676_readable_writeable_reg, | |
| 259 | - | .readable_reg = ltc3676_readable_writeable_reg, | |
| 267 | + | .writeable_reg = ltc3676_writeable_reg, | |
| 268 | + | .readable_reg = ltc3676_readable_reg, | |
| 260 | 269 | .volatile_reg = ltc3676_volatile_reg, | |
| 261 | 270 | .max_register = LTC3676_CLIRQ, | |
| 262 | 271 | .use_single_read = true, | |
modified drivers/regulator/of_regulator.c
| @@ -929,21 +929,26 @@ static int is_supply_name(const char *name) | |||
| 929 | 929 | * before returning to the caller, and @consumers will not be | |
| 930 | 930 | * changed. | |
| 931 | 931 | * | |
| 932 | + | * On success the array is allocated here and handed to the caller, which | |
| 933 | + | * owns it from then on: release the regulators with regulator_bulk_free() | |
| 934 | + | * and free the array itself with kfree(). The supply names live in the | |
| 935 | + | * same allocation, so they are gone once the array is freed. | |
| 936 | + | * | |
| 932 | 937 | * Return: Number of regulators on success, or a negative error number | |
| 933 | 938 | * on failure. | |
| 934 | 939 | */ | |
| 935 | 940 | int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, | |
| 936 | 941 | struct regulator_bulk_data **consumers) | |
| 937 | 942 | { | |
| 938 | - | int num_consumers = 0; | |
| 943 | + | int num_consumers = 0, names_len = 0; | |
| 939 | 944 | struct regulator *tmp; | |
| 940 | 945 | struct regulator_bulk_data *_consumers = NULL; | |
| 941 | 946 | struct property *prop; | |
| 947 | + | char *names; | |
| 942 | 948 | int i, n = 0, ret; | |
| 943 | - | char name[64]; | |
| 944 | 949 | ||
| 945 | 950 | /* | |
| 946 | - | * first pass: get numbers of xxx-supply | |
| 951 | + | * first pass: get numbers of xxx-supply and the room their names take | |
| 947 | 952 | * second pass: fill consumers | |
| 948 | 953 | */ | |
| 949 | 954 | restart: | |
| @@ -953,16 +958,19 @@ restart: | |||
| 953 | 958 | continue; | |
| 954 | 959 | if (!_consumers) { | |
| 955 | 960 | num_consumers++; | |
| 961 | + | names_len += i + 1; | |
| 956 | 962 | continue; | |
| 957 | 963 | } else { | |
| 958 | - | memcpy(name, prop->name, i); | |
| 959 | - | name[i] = '\0'; | |
| 960 | - | tmp = regulator_get(dev, name); | |
| 964 | + | memcpy(names, prop->name, i); | |
| 965 | + | names[i] = '\0'; | |
| 966 | + | tmp = regulator_get(dev, names); | |
| 961 | 967 | if (IS_ERR(tmp)) { | |
| 962 | 968 | ret = PTR_ERR(tmp); | |
| 963 | 969 | goto error; | |
| 964 | 970 | } | |
| 971 | + | _consumers[n].supply = names; | |
| 965 | 972 | _consumers[n].consumer = tmp; | |
| 973 | + | names += i + 1; | |
| 966 | 974 | n++; | |
| 967 | 975 | continue; | |
| 968 | 976 | } | |
| @@ -973,9 +981,16 @@ restart: | |||
| 973 | 981 | } | |
| 974 | 982 | if (num_consumers == 0) | |
| 975 | 983 | return 0; | |
| 976 | - | _consumers = kmalloc_objs(struct regulator_bulk_data, num_consumers); | |
| 984 | + | /* | |
| 985 | + | * The supply names are kept in the same allocation as the array, so | |
| 986 | + | * that they share its lifetime and the caller has nothing extra to | |
| 987 | + | * free. | |
| 988 | + | */ | |
| 989 | + | _consumers = kzalloc(size_add(size_mul(num_consumers, sizeof(*_consumers)), | |
| 990 | + | names_len), GFP_KERNEL); | |
| 977 | 991 | if (!_consumers) | |
| 978 | 992 | return -ENOMEM; | |
| 993 | + | names = (char *)(_consumers + num_consumers); | |
| 979 | 994 | goto restart; | |
| 980 | 995 | ||
| 981 | 996 | error: | |
modified drivers/regulator/tps6594-regulator.c
| @@ -241,21 +241,21 @@ static const struct regulator_desc tps65224_buck_regs[] = { | |||
| 241 | 241 | TPS65224_MASK_BUCKS_VSET, | |
| 242 | 242 | TPS6594_REG_BUCKX_CTRL(1), | |
| 243 | 243 | TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_2_3_4_ranges, | |
| 244 | - | 4, 0, 0, NULL, 0, 0), | |
| 244 | + | ARRAY_SIZE(tps65224_bucks_2_3_4_ranges), 0, 0, NULL, 0, 0), | |
| 245 | 245 | TPS6594_REGULATOR("BUCK3", "buck3", TPS6594_BUCK_3, | |
| 246 | 246 | REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS65224_MASK_BUCKS_VSET, | |
| 247 | 247 | TPS6594_REG_BUCKX_VOUT_1(2), | |
| 248 | 248 | TPS65224_MASK_BUCKS_VSET, | |
| 249 | 249 | TPS6594_REG_BUCKX_CTRL(2), | |
| 250 | 250 | TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_2_3_4_ranges, | |
| 251 | - | 4, 0, 0, NULL, 0, 0), | |
| 251 | + | ARRAY_SIZE(tps65224_bucks_2_3_4_ranges), 0, 0, NULL, 0, 0), | |
| 252 | 252 | TPS6594_REGULATOR("BUCK4", "buck4", TPS6594_BUCK_4, | |
| 253 | 253 | REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS65224_MASK_BUCKS_VSET, | |
| 254 | 254 | TPS6594_REG_BUCKX_VOUT_1(3), | |
| 255 | 255 | TPS65224_MASK_BUCKS_VSET, | |
| 256 | 256 | TPS6594_REG_BUCKX_CTRL(3), | |
| 257 | 257 | TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_2_3_4_ranges, | |
| 258 | - | 4, 0, 0, NULL, 0, 0), | |
| 258 | + | ARRAY_SIZE(tps65224_bucks_2_3_4_ranges), 0, 0, NULL, 0, 0), | |
| 259 | 259 | }; | |
| 260 | 260 | ||
| 261 | 261 | static const struct tps6594_regulator_irq_type tps6594_buck1_irq_types[] = { | |
modified drivers/rtc/dev.c
| @@ -216,7 +216,7 @@ static long rtc_dev_ioctl(struct file *file, | |||
| 216 | 216 | struct rtc_device *rtc = file->private_data; | |
| 217 | 217 | const struct rtc_class_ops *ops = rtc->ops; | |
| 218 | 218 | struct rtc_time tm; | |
| 219 | - | struct rtc_wkalrm alarm; | |
| 219 | + | struct rtc_wkalrm alarm = { 0 }; | |
| 220 | 220 | struct rtc_param param; | |
| 221 | 221 | void __user *uarg = (void __user *)arg; | |
| 222 | 222 | ||
modified drivers/rtc/rtc-ac100.c
| @@ -317,10 +317,12 @@ static int ac100_rtc_register_clks(struct ac100_rtc_dev *chip) | |||
| 317 | 317 | if (!chip->clk_data) | |
| 318 | 318 | return -ENOMEM; | |
| 319 | 319 | ||
| 320 | - | chip->rtc_32k_clk = clk_hw_register_fixed_rate(chip->dev, | |
| 321 | - | AC100_RTC_32K_NAME, | |
| 322 | - | NULL, 0, | |
| 323 | - | AC100_RTC_32K_RATE); | |
| 320 | + | chip->clk_data->num = AC100_CLKOUT_NUM; | |
| 321 | + | ||
| 322 | + | chip->rtc_32k_clk = devm_clk_hw_register_fixed_rate(chip->dev, | |
| 323 | + | AC100_RTC_32K_NAME, | |
| 324 | + | NULL, 0, | |
| 325 | + | AC100_RTC_32K_RATE); | |
| 324 | 326 | if (IS_ERR(chip->rtc_32k_clk)) { | |
| 325 | 327 | ret = PTR_ERR(chip->rtc_32k_clk); | |
| 326 | 328 | dev_err(chip->dev, "Failed to register RTC-32k clock: %d\n", | |
| @@ -354,29 +356,14 @@ static int ac100_rtc_register_clks(struct ac100_rtc_dev *chip) | |||
| 354 | 356 | if (ret) { | |
| 355 | 357 | dev_err(chip->dev, "Failed to register clk '%s': %d\n", | |
| 356 | 358 | init.name, ret); | |
| 357 | - | goto err_unregister_rtc_32k; | |
| 359 | + | return ret; | |
| 358 | 360 | } | |
| 359 | 361 | ||
| 360 | 362 | chip->clk_data->hws[i] = &clk->hw; | |
| 361 | 363 | } | |
| 362 | 364 | ||
| 363 | - | chip->clk_data->num = i; | |
| 364 | - | ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, chip->clk_data); | |
| 365 | - | if (ret) | |
| 366 | - | goto err_unregister_rtc_32k; | |
| 367 | - | ||
| 368 | - | return 0; | |
| 369 | - | ||
| 370 | - | err_unregister_rtc_32k: | |
| 371 | - | clk_unregister_fixed_rate(chip->rtc_32k_clk->clk); | |
| 372 | - | ||
| 373 | - | return ret; | |
| 374 | - | } | |
| 375 | - | ||
| 376 | - | static void ac100_rtc_unregister_clks(struct ac100_rtc_dev *chip) | |
| 377 | - | { | |
| 378 | - | of_clk_del_provider(chip->dev->of_node); | |
| 379 | - | clk_unregister_fixed_rate(chip->rtc_32k_clk->clk); | |
| 365 | + | return devm_of_clk_add_hw_provider(chip->dev, of_clk_hw_onecell_get, | |
| 366 | + | chip->clk_data); | |
| 380 | 367 | } | |
| 381 | 368 | ||
| 382 | 369 | /* | |
| @@ -614,13 +601,6 @@ static int ac100_rtc_probe(struct platform_device *pdev) | |||
| 614 | 601 | return devm_rtc_register_device(chip->rtc); | |
| 615 | 602 | } | |
| 616 | 603 | ||
| 617 | - | static void ac100_rtc_remove(struct platform_device *pdev) | |
| 618 | - | { | |
| 619 | - | struct ac100_rtc_dev *chip = platform_get_drvdata(pdev); | |
| 620 | - | ||
| 621 | - | ac100_rtc_unregister_clks(chip); | |
| 622 | - | } | |
| 623 | - | ||
| 624 | 604 | static const struct of_device_id ac100_rtc_match[] = { | |
| 625 | 605 | { .compatible = "x-powers,ac100-rtc" }, | |
| 626 | 606 | { }, | |
| @@ -629,7 +609,6 @@ MODULE_DEVICE_TABLE(of, ac100_rtc_match); | |||
| 629 | 609 | ||
| 630 | 610 | static struct platform_driver ac100_rtc_driver = { | |
| 631 | 611 | .probe = ac100_rtc_probe, | |
| 632 | - | .remove = ac100_rtc_remove, | |
| 633 | 612 | .driver = { | |
| 634 | 613 | .name = "ac100-rtc", | |
| 635 | 614 | .of_match_table = of_match_ptr(ac100_rtc_match), | |
modified drivers/rtc/rtc-efi.c
| @@ -52,6 +52,7 @@ compute_wday(efi_time_t *eft, int yday) | |||
| 52 | 52 | static void | |
| 53 | 53 | convert_to_efi_time(struct rtc_time *wtime, efi_time_t *eft) | |
| 54 | 54 | { | |
| 55 | + | memset(eft, 0, sizeof(*eft)); | |
| 55 | 56 | eft->year = wtime->tm_year + 1900; | |
| 56 | 57 | eft->month = wtime->tm_mon + 1; | |
| 57 | 58 | eft->day = wtime->tm_mday; | |
| @@ -112,6 +113,35 @@ convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime) | |||
| 112 | 113 | return true; | |
| 113 | 114 | } | |
| 114 | 115 | ||
| 116 | + | static int efi_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |
| 117 | + | { | |
| 118 | + | efi_time_t eft; | |
| 119 | + | efi_status_t status; | |
| 120 | + | ||
| 121 | + | memset(&eft, 0, sizeof(eft)); | |
| 122 | + | status = efi.get_wakeup_time((efi_bool_t *)&wkalrm->enabled, | |
| 123 | + | (efi_bool_t *)&wkalrm->pending, &eft); | |
| 124 | + | if (status != EFI_SUCCESS) | |
| 125 | + | return -EINVAL; | |
| 126 | + | ||
| 127 | + | if (!convert_from_efi_time(&eft, &wkalrm->time)) | |
| 128 | + | return -EIO; | |
| 129 | + | ||
| 130 | + | return rtc_valid_tm(&wkalrm->time); | |
| 131 | + | } | |
| 132 | + | ||
| 133 | + | static int efi_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |
| 134 | + | { | |
| 135 | + | efi_time_t eft; | |
| 136 | + | efi_status_t status; | |
| 137 | + | ||
| 138 | + | convert_to_efi_time(&wkalrm->time, &eft); | |
| 139 | + | ||
| 140 | + | status = efi.set_wakeup_time((efi_bool_t)!!wkalrm->enabled, &eft); | |
| 141 | + | ||
| 142 | + | return status == EFI_SUCCESS ? 0 : -EINVAL; | |
| 143 | + | } | |
| 144 | + | ||
| 115 | 145 | static int efi_read_time(struct device *dev, struct rtc_time *tm) | |
| 116 | 146 | { | |
| 117 | 147 | efi_status_t status; | |
| @@ -146,13 +176,21 @@ static int efi_set_time(struct device *dev, struct rtc_time *tm) | |||
| 146 | 176 | ||
| 147 | 177 | static int efi_procfs(struct device *dev, struct seq_file *seq) | |
| 148 | 178 | { | |
| 149 | - | efi_time_t eft; | |
| 179 | + | efi_time_t eft, alm; | |
| 150 | 180 | efi_time_cap_t cap; | |
| 181 | + | efi_bool_t enabled, pending; | |
| 182 | + | struct rtc_device *rtc = dev_get_drvdata(dev); | |
| 151 | 183 | ||
| 152 | 184 | memset(&eft, 0, sizeof(eft)); | |
| 185 | + | memset(&alm, 0, sizeof(alm)); | |
| 153 | 186 | memset(&cap, 0, sizeof(cap)); | |
| 154 | 187 | ||
| 155 | 188 | efi.get_time(&eft, &cap); | |
| 189 | + | if (test_bit(RTC_FEATURE_ALARM, rtc->features) && | |
| 190 | + | efi.get_wakeup_time(&enabled, &pending, &alm) != EFI_SUCCESS) { | |
| 191 | + | enabled = 0; | |
| 192 | + | pending = 0; | |
| 193 | + | } | |
| 156 | 194 | ||
| 157 | 195 | seq_printf(seq, | |
| 158 | 196 | "Time\t\t: %u:%u:%u.%09u\n" | |
| @@ -168,6 +206,25 @@ static int efi_procfs(struct device *dev, struct seq_file *seq) | |||
| 168 | 206 | /* XXX fixme: convert to string? */ | |
| 169 | 207 | seq_printf(seq, "Timezone\t: %u\n", eft.timezone); | |
| 170 | 208 | ||
| 209 | + | if (test_bit(RTC_FEATURE_ALARM, rtc->features)) { | |
| 210 | + | seq_printf(seq, | |
| 211 | + | "Alarm Time\t: %u:%u:%u.%09u\n" | |
| 212 | + | "Alarm Date\t: %u-%u-%u\n" | |
| 213 | + | "Alarm Daylight\t: %u\n" | |
| 214 | + | "Enabled\t\t: %s\n" | |
| 215 | + | "Pending\t\t: %s\n", | |
| 216 | + | alm.hour, alm.minute, alm.second, alm.nanosecond, | |
| 217 | + | alm.year, alm.month, alm.day, | |
| 218 | + | alm.daylight, | |
| 219 | + | enabled == 1 ? "yes" : "no", | |
| 220 | + | pending == 1 ? "yes" : "no"); | |
| 221 | + | ||
| 222 | + | if (alm.timezone == EFI_UNSPECIFIED_TIMEZONE) | |
| 223 | + | seq_puts(seq, "Alarm Timezone\t: unspecified\n"); | |
| 224 | + | else | |
| 225 | + | seq_printf(seq, "Alarm Timezone\t: %d\n", alm.timezone); | |
| 226 | + | } | |
| 227 | + | ||
| 171 | 228 | /* | |
| 172 | 229 | * now prints the capabilities | |
| 173 | 230 | */ | |
| @@ -183,6 +240,8 @@ static int efi_procfs(struct device *dev, struct seq_file *seq) | |||
| 183 | 240 | static const struct rtc_class_ops efi_rtc_ops = { | |
| 184 | 241 | .read_time = efi_read_time, | |
| 185 | 242 | .set_time = efi_set_time, | |
| 243 | + | .read_alarm = efi_read_alarm, | |
| 244 | + | .set_alarm = efi_set_alarm, | |
| 186 | 245 | .proc = efi_procfs, | |
| 187 | 246 | }; | |
| 188 | 247 | ||
| @@ -191,6 +250,7 @@ static int __init efi_rtc_probe(struct platform_device *dev) | |||
| 191 | 250 | struct rtc_device *rtc; | |
| 192 | 251 | efi_time_t eft; | |
| 193 | 252 | efi_time_cap_t cap; | |
| 253 | + | efi_bool_t enabled, pending; | |
| 194 | 254 | ||
| 195 | 255 | /* First check if the RTC is usable */ | |
| 196 | 256 | if (efi.get_time(&eft, &cap) != EFI_SUCCESS) | |
| @@ -203,7 +263,23 @@ static int __init efi_rtc_probe(struct platform_device *dev) | |||
| 203 | 263 | platform_set_drvdata(dev, rtc); | |
| 204 | 264 | ||
| 205 | 265 | rtc->ops = &efi_rtc_ops; | |
| 206 | - | clear_bit(RTC_FEATURE_ALARM, rtc->features); | |
| 266 | + | clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features); | |
| 267 | + | ||
| 268 | + | /* | |
| 269 | + | * The EFI_RT_SUPPORTED_WAKEUP_SERVICES bit defaults to enabled | |
| 270 | + | * and only gets cleared when the RT_PROP table explicitly says | |
| 271 | + | * wakeup is unsupported. Many platforms lack an RT_PROP table | |
| 272 | + | * even though they don't implement the wakeup runtime service, | |
| 273 | + | * so probe by actually calling GetWakeupTime() to avoid exposing | |
| 274 | + | * a broken alarm to userspace. | |
| 275 | + | */ | |
| 276 | + | if (efi_rt_services_supported(EFI_RT_SUPPORTED_WAKEUP_SERVICES) && | |
| 277 | + | efi.get_wakeup_time(&enabled, &pending, &eft) == EFI_SUCCESS) { | |
| 278 | + | set_bit(RTC_FEATURE_ALARM, rtc->features); | |
| 279 | + | set_bit(RTC_FEATURE_ALARM_WAKEUP_ONLY, rtc->features); | |
| 280 | + | } else { | |
| 281 | + | clear_bit(RTC_FEATURE_ALARM, rtc->features); | |
| 282 | + | } | |
| 207 | 283 | ||
| 208 | 284 | device_init_wakeup(&dev->dev, true); | |
| 209 | 285 | ||
modified drivers/rtc/rtc-mpfs.c
| @@ -256,8 +256,12 @@ static int mpfs_rtc_probe(struct platform_device *pdev) | |||
| 256 | 256 | return ret; | |
| 257 | 257 | } | |
| 258 | 258 | ||
| 259 | + | clk = devm_clk_get(&pdev->dev, "rtcref"); | |
| 260 | + | if (IS_ERR(clk)) | |
| 261 | + | return PTR_ERR(clk); | |
| 262 | + | ||
| 259 | 263 | /* prescaler hardware adds 1 to reg value */ | |
| 260 | - | prescaler = clk_get_rate(devm_clk_get(&pdev->dev, "rtcref")) - 1; | |
| 264 | + | prescaler = clk_get_rate(clk) - 1; | |
| 261 | 265 | if (prescaler > MAX_PRESCALER_COUNT) { | |
| 262 | 266 | dev_dbg(&pdev->dev, "invalid prescaler %lu\n", prescaler); | |
| 263 | 267 | return -EINVAL; | |
modified drivers/rtc/rtc-spear.c
| @@ -363,6 +363,12 @@ static int spear_rtc_probe(struct platform_device *pdev) | |||
| 363 | 363 | if (irq < 0) | |
| 364 | 364 | return irq; | |
| 365 | 365 | ||
| 366 | + | config->ioaddr = devm_platform_ioremap_resource(pdev, 0); | |
| 367 | + | if (IS_ERR(config->ioaddr)) | |
| 368 | + | return PTR_ERR(config->ioaddr); | |
| 369 | + | ||
| 370 | + | spin_lock_init(&config->lock); | |
| 371 | + | ||
| 366 | 372 | status = devm_request_irq(&pdev->dev, irq, spear_rtc_irq, 0, pdev->name, | |
| 367 | 373 | config); | |
| 368 | 374 | if (status) { | |
| @@ -371,10 +377,6 @@ static int spear_rtc_probe(struct platform_device *pdev) | |||
| 371 | 377 | return status; | |
| 372 | 378 | } | |
| 373 | 379 | ||
| 374 | - | config->ioaddr = devm_platform_ioremap_resource(pdev, 0); | |
| 375 | - | if (IS_ERR(config->ioaddr)) | |
| 376 | - | return PTR_ERR(config->ioaddr); | |
| 377 | - | ||
| 378 | 380 | config->clk = devm_clk_get(&pdev->dev, NULL); | |
| 379 | 381 | if (IS_ERR(config->clk)) | |
| 380 | 382 | return PTR_ERR(config->clk); | |
| @@ -383,7 +385,6 @@ static int spear_rtc_probe(struct platform_device *pdev) | |||
| 383 | 385 | if (status < 0) | |
| 384 | 386 | return status; | |
| 385 | 387 | ||
| 386 | - | spin_lock_init(&config->lock); | |
| 387 | 388 | platform_set_drvdata(pdev, config); | |
| 388 | 389 | ||
| 389 | 390 | config->rtc->ops = &spear_rtc_ops; | |
modified drivers/scsi/ch.c
| @@ -112,7 +112,6 @@ typedef struct { | |||
| 112 | 112 | int minor; | |
| 113 | 113 | char name[8]; | |
| 114 | 114 | struct scsi_device *device; | |
| 115 | - | struct scsi_device **dt; /* ptrs to data transfer elements */ | |
| 116 | 115 | u_int firsts[CH_TYPES]; | |
| 117 | 116 | u_int counts[CH_TYPES]; | |
| 118 | 117 | u_int voltags; | |
| @@ -363,15 +362,10 @@ ch_readconfig(scsi_changer *ch) | |||
| 363 | 362 | vendor_labels[i]); | |
| 364 | 363 | } | |
| 365 | 364 | ||
| 366 | - | /* look up the devices of the data transfer elements */ | |
| 367 | - | ch->dt = kzalloc_objs(*ch->dt, ch->counts[CHET_DT]); | |
| 368 | - | ||
| 369 | - | if (!ch->dt) { | |
| 370 | - | kfree(buffer); | |
| 371 | - | return -ENOMEM; | |
| 372 | - | } | |
| 373 | - | ||
| 365 | + | /* report the devices of the data transfer elements */ | |
| 374 | 366 | for (elem = 0; elem < ch->counts[CHET_DT]; elem++) { | |
| 367 | + | struct scsi_device *sdev; | |
| 368 | + | ||
| 375 | 369 | id = -1; | |
| 376 | 370 | lun = 0; | |
| 377 | 371 | if (elem < CH_DT_MAX && -1 != dt_id[elem]) { | |
| @@ -387,10 +381,8 @@ ch_readconfig(scsi_changer *ch) | |||
| 387 | 381 | VPRINTK(KERN_INFO, "dt 0x%x: ",elem+ch->firsts[CHET_DT]); | |
| 388 | 382 | if (data[6] & 0x80) { | |
| 389 | 383 | VPRINTK(KERN_CONT, "not this SCSI bus\n"); | |
| 390 | - | ch->dt[elem] = NULL; | |
| 391 | 384 | } else if (0 == (data[6] & 0x30)) { | |
| 392 | 385 | VPRINTK(KERN_CONT, "ID/LUN unknown\n"); | |
| 393 | - | ch->dt[elem] = NULL; | |
| 394 | 386 | } else { | |
| 395 | 387 | id = ch->device->id; | |
| 396 | 388 | lun = 0; | |
| @@ -400,18 +392,16 @@ ch_readconfig(scsi_changer *ch) | |||
| 400 | 392 | } | |
| 401 | 393 | if (-1 != id) { | |
| 402 | 394 | VPRINTK(KERN_CONT, "ID %i, LUN %i, ",id,lun); | |
| 403 | - | ch->dt[elem] = | |
| 404 | - | scsi_device_lookup(ch->device->host, | |
| 405 | - | ch->device->channel, | |
| 406 | - | id,lun); | |
| 407 | - | if (!ch->dt[elem]) { | |
| 395 | + | sdev = scsi_device_lookup(ch->device->host, | |
| 396 | + | ch->device->channel, | |
| 397 | + | id, lun); | |
| 398 | + | if (!sdev) { | |
| 408 | 399 | /* should not happen */ | |
| 409 | 400 | VPRINTK(KERN_CONT, "Huh? device not found!\n"); | |
| 410 | 401 | } else { | |
| 411 | 402 | VPRINTK(KERN_CONT, "name: %8.8s %16.16s %4.4s\n", | |
| 412 | - | ch->dt[elem]->vendor, | |
| 413 | - | ch->dt[elem]->model, | |
| 414 | - | ch->dt[elem]->rev); | |
| 403 | + | sdev->vendor, sdev->model, sdev->rev); | |
| 404 | + | scsi_device_put(sdev); | |
| 415 | 405 | } | |
| 416 | 406 | } | |
| 417 | 407 | } | |
| @@ -575,7 +565,6 @@ static void ch_destroy(struct kref *ref) | |||
| 575 | 565 | scsi_changer *ch = container_of(ref, scsi_changer, ref); | |
| 576 | 566 | ||
| 577 | 567 | ch->device = NULL; | |
| 578 | - | kfree(ch->dt); | |
| 579 | 568 | kfree(ch); | |
| 580 | 569 | } | |
| 581 | 570 | ||
modified drivers/scsi/qedi/qedi_main.c
| @@ -2652,8 +2652,6 @@ retry_probe: | |||
| 2652 | 2652 | snprintf(host_buf, sizeof(host_buf), "host_%d", qedi->shost->host_no); | |
| 2653 | 2653 | qedi_ops->common->set_name(qedi->cdev, host_buf); | |
| 2654 | 2654 | ||
| 2655 | - | qedi_ops->register_ops(qedi->cdev, &qedi_cb_ops, qedi); | |
| 2656 | - | ||
| 2657 | 2655 | memset(¶ms, 0, sizeof(params)); | |
| 2658 | 2656 | params.mtu = DEF_PATH_MTU + IPV6_HDR_LEN + TCP_HDR_LEN; | |
| 2659 | 2657 | qedi->ll2_mtu = DEF_PATH_MTU; | |
| @@ -2670,6 +2668,7 @@ retry_probe: | |||
| 2670 | 2668 | spin_lock_init(&qedi->task_idx_lock); | |
| 2671 | 2669 | mutex_init(&qedi->stats_lock); | |
| 2672 | 2670 | } | |
| 2671 | + | qedi_ops->register_ops(qedi->cdev, &qedi_cb_ops, qedi); | |
| 2673 | 2672 | qedi_ops->ll2->register_cb_ops(qedi->cdev, &qedi_ll2_cb_ops, qedi); | |
| 2674 | 2673 | qedi_ops->ll2->start(qedi->cdev, ¶ms); | |
| 2675 | 2674 | ||
modified drivers/spi/spi-cadence-quadspi.c
| @@ -1056,8 +1056,7 @@ static int cqspi_write_setup(struct cqspi_flash_pdata *f_pdata, | |||
| 1056 | 1056 | * care of polling the status register. | |
| 1057 | 1057 | */ | |
| 1058 | 1058 | if (cqspi->wr_completion) { | |
| 1059 | - | reg = readl(reg_base + CQSPI_REG_WR_COMPLETION_CTRL); | |
| 1060 | - | reg |= CQSPI_REG_WR_DISABLE_AUTO_POLL; | |
| 1059 | + | reg = CQSPI_REG_WR_DISABLE_AUTO_POLL; | |
| 1061 | 1060 | writel(reg, reg_base + CQSPI_REG_WR_COMPLETION_CTRL); | |
| 1062 | 1061 | /* | |
| 1063 | 1062 | * DAC mode require auto polling as flash needs to be polled | |
modified drivers/spi/spi-cs42l43.c
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | #include <linux/bitfield.h> | |
| 12 | 12 | #include <linux/cleanup.h> | |
| 13 | 13 | #include <linux/device.h> | |
| 14 | + | #include <linux/dmi.h> | |
| 14 | 15 | #include <linux/errno.h> | |
| 15 | 16 | #include <linux/gpio/consumer.h> | |
| 16 | 17 | #include <linux/gpio/machine.h> | |
| @@ -215,12 +216,108 @@ static size_t cs42l43_spi_max_length(struct spi_device *spi) | |||
| 215 | 216 | return CS42L43_SPI_MAX_LENGTH; | |
| 216 | 217 | } | |
| 217 | 218 | ||
| 219 | + | /* | |
| 220 | + | * Workaround needed for two speaker ID pins in one ACPI GpioIo() but | |
| 221 | + | * the Linux-specific _DSD property only contains one pin. | |
| 222 | + | * Create a temporary acpi_gpio_mapping pointing at both pins. | |
| 223 | + | */ | |
| 224 | + | static const struct acpi_gpio_params cs42l43_2bit_speaker_id_from_one_gpioio_params[] = { | |
| 225 | + | [0] = { | |
| 226 | + | .crs_entry_index = 0, | |
| 227 | + | .line_index = 0, | |
| 228 | + | }, | |
| 229 | + | [1] = { | |
| 230 | + | .crs_entry_index = 0, | |
| 231 | + | .line_index = 1, | |
| 232 | + | }, | |
| 233 | + | }; | |
| 234 | + | ||
| 235 | + | static const struct acpi_gpio_mapping cs42l43_2bit_speaker_id_from_one_gpioio_mapping[] = { | |
| 236 | + | { | |
| 237 | + | .name = "spk-id-quirk-gpios", | |
| 238 | + | .data = cs42l43_2bit_speaker_id_from_one_gpioio_params, | |
| 239 | + | .size = ARRAY_SIZE(cs42l43_2bit_speaker_id_from_one_gpioio_params), | |
| 240 | + | }, | |
| 241 | + | { } | |
| 242 | + | }; | |
| 243 | + | ||
| 244 | + | static int cs42l43_get_2bit_speaker_id_from_one_gpioio(struct cs42l43_spi *priv, int *result) | |
| 245 | + | { | |
| 246 | + | struct fwnode_reference_args args; | |
| 247 | + | struct acpi_device *adev; | |
| 248 | + | struct gpio_desc *desc; | |
| 249 | + | u32 spkid = 0; | |
| 250 | + | int i, ret; | |
| 251 | + | ||
| 252 | + | /* Use the _DSD property to get the node containing the GpioIo() */ | |
| 253 | + | ret = fwnode_property_get_reference_args(dev_fwnode(priv->dev), "spk-id-gpios", | |
| 254 | + | NULL, 3, 0, &args); | |
| 255 | + | if (ret) | |
| 256 | + | return ret; | |
| 257 | + | ||
| 258 | + | struct fwnode_handle *fwnode __free(fwnode_handle) = args.fwnode; | |
| 259 | + | ||
| 260 | + | /* An acpi_gpio_mapping must be added to the node that contains the GpioIo() */ | |
| 261 | + | adev = to_acpi_device_node(fwnode); | |
| 262 | + | if (!adev) | |
| 263 | + | return -EINVAL; | |
| 264 | + | ||
| 265 | + | ret = acpi_dev_add_driver_gpios(adev, cs42l43_2bit_speaker_id_from_one_gpioio_mapping); | |
| 266 | + | if (ret) | |
| 267 | + | return ret; | |
| 268 | + | ||
| 269 | + | /* gpiod_get_array() can't read from a mapping in a child node */ | |
| 270 | + | for (i = 0; i < ARRAY_SIZE(cs42l43_2bit_speaker_id_from_one_gpioio_params); i++) { | |
| 271 | + | desc = fwnode_gpiod_get_index(fwnode, "spk-id-quirk", i, GPIOD_IN, | |
| 272 | + | dev_name(priv->dev)); | |
| 273 | + | if (IS_ERR(desc)) { | |
| 274 | + | ret = PTR_ERR(desc); | |
| 275 | + | goto out; | |
| 276 | + | } | |
| 277 | + | ||
| 278 | + | ret = gpiod_get_value_cansleep(desc); | |
| 279 | + | gpiod_put(desc); | |
| 280 | + | if (ret < 0) | |
| 281 | + | goto out; | |
| 282 | + | ||
| 283 | + | spkid |= (u32)ret << i; | |
| 284 | + | } | |
| 285 | + | ||
| 286 | + | dev_dbg(priv->dev, "spk-id-gpios = %u\n", spkid); | |
| 287 | + | *result = spkid; | |
| 288 | + | ret = 0; | |
| 289 | + | out: | |
| 290 | + | acpi_dev_remove_driver_gpios(adev); | |
| 291 | + | ||
| 292 | + | return ret; | |
| 293 | + | } | |
| 294 | + | ||
| 295 | + | static const struct dmi_system_id cs42l43_spk_id_quirks[] = { | |
| 296 | + | { | |
| 297 | + | .ident = "Dell XPS 13 DX13260", | |
| 298 | + | .matches = { | |
| 299 | + | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), | |
| 300 | + | DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0E53"), | |
| 301 | + | }, | |
| 302 | + | .driver_data = cs42l43_get_2bit_speaker_id_from_one_gpioio, | |
| 303 | + | }, | |
| 304 | + | { } | |
| 305 | + | }; | |
| 306 | + | ||
| 218 | 307 | static int cs42l43_get_speaker_id_gpios(struct cs42l43_spi *priv, int *result) | |
| 219 | 308 | { | |
| 309 | + | const struct dmi_system_id *dmi_id; | |
| 220 | 310 | struct gpio_descs *descs; | |
| 221 | 311 | u32 spkid; | |
| 222 | 312 | int i, ret; | |
| 223 | 313 | ||
| 314 | + | dmi_id = dmi_first_match(cs42l43_spk_id_quirks); | |
| 315 | + | if (dmi_id) { | |
| 316 | + | int (*get_speaker_id)(struct cs42l43_spi *priv, int *result) = dmi_id->driver_data; | |
| 317 | + | ||
| 318 | + | return get_speaker_id(priv, result); | |
| 319 | + | } | |
| 320 | + | ||
| 224 | 321 | descs = gpiod_get_array_optional(priv->dev, "spk-id", GPIOD_IN); | |
| 225 | 322 | if (!descs) | |
| 226 | 323 | return 0; | |
modified drivers/spi/spi-nxp-fspi.c
| @@ -898,10 +898,10 @@ static int nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi, | |||
| 898 | 898 | dev_dbg(f->dev, "Target device [CS:%x] selected\n", spi_get_chipselect(spi, 0)); | |
| 899 | 899 | ||
| 900 | 900 | /* | |
| 901 | - | * Per the FlexSPI reference manual (initialization sequence), MCR0 and | |
| 902 | - | * the DLL control registers should be configured while the module is in | |
| 903 | - | * stop mode (MCR0[MDIS] = 1). Enter stop mode before reconfiguring the | |
| 904 | - | * RX sample clock source and the DLL, then exit stop mode afterwards. | |
| 901 | + | * Per the FlexSPI reference manual (initialization sequence), MCR0 | |
| 902 | + | * should be configured while the module is in stop mode (MCR0[MDIS] = 1). | |
| 903 | + | * Enter stop mode before reconfiguring the RX sample clock source, then | |
| 904 | + | * exit stop mode afterwards. | |
| 905 | 905 | */ | |
| 906 | 906 | reg = fspi_readl(f, f->iobase + FSPI_MCR0); | |
| 907 | 907 | fspi_writel(f, reg | FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0); | |
| @@ -936,6 +936,16 @@ static int nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi, | |||
| 936 | 936 | if (ret) | |
| 937 | 937 | return ret; | |
| 938 | 938 | ||
| 939 | + | /* | |
| 940 | + | * Exit stop mode before running the DLL calibration. The DLL | |
| 941 | + | * reference clock is derived from the module clock domain, which is | |
| 942 | + | * gated while MCR0[MDIS] = 1. Calibrating the DLL in stop mode leaves | |
| 943 | + | * the STS2 lock bits stuck at 0 (the DLL never runs), so clear MDIS | |
| 944 | + | * first and let the module and reference clock run. | |
| 945 | + | */ | |
| 946 | + | reg = fspi_readl(f, f->iobase + FSPI_MCR0); | |
| 947 | + | fspi_writel(f, reg & ~FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0); | |
| 948 | + | ||
| 939 | 949 | /* | |
| 940 | 950 | * If clock rate > 100MHz, then switch from DLL override mode to | |
| 941 | 951 | * DLL calibration mode. | |
| @@ -945,10 +955,6 @@ static int nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi, | |||
| 945 | 955 | else | |
| 946 | 956 | nxp_fspi_dll_override(f); | |
| 947 | 957 | ||
| 948 | - | /* Exit stop mode now that MCR0 and the DLL have been reconfigured. */ | |
| 949 | - | reg = fspi_readl(f, f->iobase + FSPI_MCR0); | |
| 950 | - | fspi_writel(f, reg & ~FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0); | |
| 951 | - | ||
| 952 | 958 | f->pre_op_rate = op->max_freq; | |
| 953 | 959 | ||
| 954 | 960 | f->selected = spi_get_chipselect(spi, 0); | |
modified drivers/spi/spi-sg2044-nor.c
| @@ -307,15 +307,15 @@ static ssize_t sg2044_spifmc_tran_cmd(struct sg2044_spifmc *spifmc, | |||
| 307 | 307 | return 0; | |
| 308 | 308 | } | |
| 309 | 309 | ||
| 310 | - | static void sg2044_spifmc_trans(struct sg2044_spifmc *spifmc, | |
| 311 | - | const struct spi_mem_op *op) | |
| 310 | + | static int sg2044_spifmc_trans(struct sg2044_spifmc *spifmc, | |
| 311 | + | const struct spi_mem_op *op) | |
| 312 | 312 | { | |
| 313 | 313 | if (op->data.dir == SPI_MEM_DATA_IN) | |
| 314 | - | sg2044_spifmc_read(spifmc, op); | |
| 314 | + | return sg2044_spifmc_read(spifmc, op); | |
| 315 | 315 | else if (op->data.dir == SPI_MEM_DATA_OUT) | |
| 316 | - | sg2044_spifmc_write(spifmc, op); | |
| 316 | + | return sg2044_spifmc_write(spifmc, op); | |
| 317 | 317 | else | |
| 318 | - | sg2044_spifmc_tran_cmd(spifmc, op); | |
| 318 | + | return sg2044_spifmc_tran_cmd(spifmc, op); | |
| 319 | 319 | } | |
| 320 | 320 | ||
| 321 | 321 | static ssize_t sg2044_spifmc_trans_reg(struct sg2044_spifmc *spifmc, | |
| @@ -385,29 +385,64 @@ static ssize_t sg2044_spifmc_trans_reg(struct sg2044_spifmc *spifmc, | |||
| 385 | 385 | return 0; | |
| 386 | 386 | } | |
| 387 | 387 | ||
| 388 | + | static int sg2044_spifmc_set_speed(struct sg2044_spifmc *spifmc, | |
| 389 | + | unsigned int speed_hz) | |
| 390 | + | { | |
| 391 | + | unsigned long rate = clk_get_rate(spifmc->clk); | |
| 392 | + | u64 div; | |
| 393 | + | u32 reg; | |
| 394 | + | ||
| 395 | + | if (!rate) | |
| 396 | + | return -EINVAL; | |
| 397 | + | ||
| 398 | + | /* SCK = HCLK / (2 * (SckDiv + 1)); round down the resulting SCK. */ | |
| 399 | + | div = speed_hz ? DIV_ROUND_UP_ULL(rate, 2ULL * speed_hz) : 1; | |
| 400 | + | if (div > SPIFMC_CTRL_SCK_DIV_MASK + 1) | |
| 401 | + | return -EINVAL; | |
| 402 | + | ||
| 403 | + | reg = readl(spifmc->io_base + SPIFMC_CTRL); | |
| 404 | + | reg &= ~SPIFMC_CTRL_SCK_DIV_MASK; | |
| 405 | + | reg |= div - 1; | |
| 406 | + | writel(reg, spifmc->io_base + SPIFMC_CTRL); | |
| 407 | + | ||
| 408 | + | return 0; | |
| 409 | + | } | |
| 410 | + | ||
| 388 | 411 | static int sg2044_spifmc_exec_op(struct spi_mem *mem, | |
| 389 | 412 | const struct spi_mem_op *op) | |
| 390 | 413 | { | |
| 391 | 414 | struct sg2044_spifmc *spifmc; | |
| 415 | + | int ret; | |
| 392 | 416 | ||
| 393 | 417 | spifmc = spi_controller_get_devdata(mem->spi->controller); | |
| 394 | 418 | ||
| 395 | 419 | mutex_lock(&spifmc->lock); | |
| 396 | 420 | ||
| 421 | + | ret = sg2044_spifmc_set_speed(spifmc, op->max_freq ? | |
| 422 | + | min(op->max_freq, mem->spi->max_speed_hz) : | |
| 423 | + | mem->spi->max_speed_hz); | |
| 424 | + | if (ret) | |
| 425 | + | goto out_unlock; | |
| 426 | + | ||
| 397 | 427 | if (op->addr.nbytes == 0) | |
| 398 | - | sg2044_spifmc_trans_reg(spifmc, op); | |
| 428 | + | ret = sg2044_spifmc_trans_reg(spifmc, op); | |
| 399 | 429 | else | |
| 400 | - | sg2044_spifmc_trans(spifmc, op); | |
| 430 | + | ret = sg2044_spifmc_trans(spifmc, op); | |
| 401 | 431 | ||
| 432 | + | out_unlock: | |
| 402 | 433 | mutex_unlock(&spifmc->lock); | |
| 403 | 434 | ||
| 404 | - | return 0; | |
| 435 | + | return ret; | |
| 405 | 436 | } | |
| 406 | 437 | ||
| 407 | 438 | static const struct spi_controller_mem_ops sg2044_spifmc_mem_ops = { | |
| 408 | 439 | .exec_op = sg2044_spifmc_exec_op, | |
| 409 | 440 | }; | |
| 410 | 441 | ||
| 442 | + | static const struct spi_controller_mem_caps sg2044_spifmc_mem_caps = { | |
| 443 | + | .per_op_freq = true, | |
| 444 | + | }; | |
| 445 | + | ||
| 411 | 446 | static void sg2044_spifmc_init(struct sg2044_spifmc *spifmc) | |
| 412 | 447 | { | |
| 413 | 448 | u32 tran_csr; | |
| @@ -447,6 +482,10 @@ static int sg2044_spifmc_probe(struct platform_device *pdev) | |||
| 447 | 482 | if (IS_ERR(spifmc->clk)) | |
| 448 | 483 | return dev_err_probe(dev, PTR_ERR(spifmc->clk), "Cannot get and enable AHB clock\n"); | |
| 449 | 484 | ||
| 485 | + | ctrl->max_speed_hz = clk_get_rate(spifmc->clk) / 2; | |
| 486 | + | if (!ctrl->max_speed_hz) | |
| 487 | + | return dev_err_probe(dev, -EINVAL, "Invalid AHB clock rate\n"); | |
| 488 | + | ||
| 450 | 489 | spifmc->dev = &pdev->dev; | |
| 451 | 490 | spifmc->ctrl = ctrl; | |
| 452 | 491 | ||
| @@ -458,6 +497,7 @@ static int sg2044_spifmc_probe(struct platform_device *pdev) | |||
| 458 | 497 | ctrl->bits_per_word_mask = SPI_BPW_MASK(8); | |
| 459 | 498 | ctrl->auto_runtime_pm = false; | |
| 460 | 499 | ctrl->mem_ops = &sg2044_spifmc_mem_ops; | |
| 500 | + | ctrl->mem_caps = &sg2044_spifmc_mem_caps; | |
| 461 | 501 | ctrl->mode_bits = SPI_RX_DUAL | SPI_TX_DUAL | SPI_RX_QUAD | SPI_TX_QUAD; | |
| 462 | 502 | ||
| 463 | 503 | ret = devm_mutex_init(dev, &spifmc->lock); | |
modified drivers/staging/greybus/uart.c
| @@ -948,7 +948,8 @@ static int gb_tty_init(void) | |||
| 948 | 948 | int retval = 0; | |
| 949 | 949 | ||
| 950 | 950 | gb_tty_driver = tty_alloc_driver(GB_NUM_MINORS, TTY_DRIVER_REAL_RAW | | |
| 951 | - | TTY_DRIVER_DYNAMIC_DEV); | |
| 951 | + | TTY_DRIVER_DYNAMIC_DEV | | |
| 952 | + | TTY_DRIVER_RESET_SAVED_TERMIOS); | |
| 952 | 953 | if (IS_ERR(gb_tty_driver)) { | |
| 953 | 954 | pr_err("Can not allocate tty driver\n"); | |
| 954 | 955 | retval = PTR_ERR(gb_tty_driver); | |
modified drivers/tee/optee/ffa_abi.c
| @@ -198,7 +198,8 @@ static int to_msg_param_ffa_mem(struct optee_msg_param *mp, | |||
| 198 | 198 | if (shm) { | |
| 199 | 199 | u64 shm_offs = p->u.memref.shm_offs; | |
| 200 | 200 | ||
| 201 | - | mp->u.fmem.internal_offs = shm->offset; | |
| 201 | + | mp->u.fmem.internal_offs = tee_shm_get_page_offset(shm) & | |
| 202 | + | (FFA_PAGE_SIZE - 1); | |
| 202 | 203 | ||
| 203 | 204 | mp->u.fmem.offs_low = shm_offs; | |
| 204 | 205 | mp->u.fmem.offs_high = shm_offs >> 32; | |
| @@ -284,14 +285,26 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm, | |||
| 284 | 285 | .nattrs = 1, | |
| 285 | 286 | }; | |
| 286 | 287 | struct sg_table sgt; | |
| 288 | + | size_t ffa_offs; | |
| 287 | 289 | int rc; | |
| 288 | 290 | ||
| 291 | + | if (!num_pages) | |
| 292 | + | return -EINVAL; | |
| 293 | + | ||
| 289 | 294 | rc = optee_check_mem_type(start, num_pages); | |
| 290 | 295 | if (rc) | |
| 291 | 296 | return rc; | |
| 292 | 297 | ||
| 293 | - | rc = sg_alloc_table_from_pages(&sgt, pages, num_pages, 0, | |
| 294 | - | num_pages * PAGE_SIZE, GFP_KERNEL); | |
| 298 | + | /* | |
| 299 | + | * Start the FF-A descriptor at the 4 KiB page containing the shared | |
| 300 | + | * buffer, skipping unused leading 4 KiB pages when PAGE_SIZE is | |
| 301 | + | * larger. Same approach as optee_fill_pages_list() in the SMC ABI. | |
| 302 | + | * This leaves only the offset into that 4 KiB page for internal_offs. | |
| 303 | + | */ | |
| 304 | + | ffa_offs = round_down(tee_shm_get_page_offset(shm), FFA_PAGE_SIZE); | |
| 305 | + | rc = sg_alloc_table_from_pages(&sgt, pages, num_pages, ffa_offs, | |
| 306 | + | num_pages * PAGE_SIZE - ffa_offs, | |
| 307 | + | GFP_KERNEL); | |
| 295 | 308 | if (rc) | |
| 296 | 309 | return rc; | |
| 297 | 310 | args.sg = sgt.sgl; | |
| @@ -458,7 +471,8 @@ static void handle_ffa_rpc_func_cmd_shm_alloc(struct tee_context *ctx, | |||
| 458 | 471 | .attr = OPTEE_MSG_ATTR_TYPE_FMEM_OUTPUT, | |
| 459 | 472 | .u.fmem.size = tee_shm_get_size(shm), | |
| 460 | 473 | .u.fmem.global_id = shm->sec_world_id, | |
| 461 | - | .u.fmem.internal_offs = shm->offset, | |
| 474 | + | .u.fmem.internal_offs = tee_shm_get_page_offset(shm) & | |
| 475 | + | (FFA_PAGE_SIZE - 1), | |
| 462 | 476 | }; | |
| 463 | 477 | ||
| 464 | 478 | arg->ret = TEEC_SUCCESS; | |
| @@ -1123,14 +1137,6 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev) | |||
| 1123 | 1137 | ||
| 1124 | 1138 | optee_set_dev_group(optee); | |
| 1125 | 1139 | ||
| 1126 | - | rc = tee_device_register(optee->teedev); | |
| 1127 | - | if (rc) | |
| 1128 | - | goto err_unreg_supp_teedev; | |
| 1129 | - | ||
| 1130 | - | rc = tee_device_register(optee->supp_teedev); | |
| 1131 | - | if (rc) | |
| 1132 | - | goto err_unreg_supp_teedev; | |
| 1133 | - | ||
| 1134 | 1140 | rc = rhashtable_init(&optee->ffa.global_ids, &shm_rhash_params); | |
| 1135 | 1141 | if (rc) | |
| 1136 | 1142 | goto err_unreg_supp_teedev; | |
| @@ -1159,6 +1165,14 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev) | |||
| 1159 | 1165 | if (optee_ffa_protmem_pool_init(optee, sec_caps)) | |
| 1160 | 1166 | pr_info("Protected memory service not available\n"); | |
| 1161 | 1167 | ||
| 1168 | + | rc = tee_device_register(optee->teedev); | |
| 1169 | + | if (rc) | |
| 1170 | + | goto err_unregister_devices; | |
| 1171 | + | ||
| 1172 | + | rc = tee_device_register(optee->supp_teedev); | |
| 1173 | + | if (rc) | |
| 1174 | + | goto err_unregister_devices; | |
| 1175 | + | ||
| 1162 | 1176 | rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES); | |
| 1163 | 1177 | if (rc) | |
| 1164 | 1178 | goto err_unregister_devices; | |
modified drivers/tee/optee/optee_msg.h
| @@ -136,8 +136,8 @@ struct optee_msg_param_rmem { | |||
| 136 | 136 | * struct optee_msg_param_fmem - FF-A memory reference parameter | |
| 137 | 137 | * @offs_low: lower bits of offset into shared memory reference | |
| 138 | 138 | * @offs_high: higher bits of offset into shared memory reference | |
| 139 | - | * @internal_offs: internal offset into the first page of shared memory | |
| 140 | - | * reference | |
| 139 | + | * @internal_offs: offset into the first 4 KiB page of the FF-A shared | |
| 140 | + | * memory region | |
| 141 | 141 | * @size: size of the buffer | |
| 142 | 142 | * @global_id: global identifier of the shared memory | |
| 143 | 143 | */ | |
modified drivers/tee/optee/smc_abi.c
| @@ -1849,14 +1849,6 @@ static int optee_probe(struct platform_device *pdev) | |||
| 1849 | 1849 | ||
| 1850 | 1850 | optee_set_dev_group(optee); | |
| 1851 | 1851 | ||
| 1852 | - | rc = tee_device_register(optee->teedev); | |
| 1853 | - | if (rc) | |
| 1854 | - | goto err_unreg_supp_teedev; | |
| 1855 | - | ||
| 1856 | - | rc = tee_device_register(optee->supp_teedev); | |
| 1857 | - | if (rc) | |
| 1858 | - | goto err_unreg_supp_teedev; | |
| 1859 | - | ||
| 1860 | 1852 | optee_cq_init(&optee->call_queue, thread_count); | |
| 1861 | 1853 | optee_supp_init(&optee->supp); | |
| 1862 | 1854 | optee->smc.memremaped_shm = memremaped_shm; | |
| @@ -1916,6 +1908,14 @@ static int optee_probe(struct platform_device *pdev) | |||
| 1916 | 1908 | if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM) | |
| 1917 | 1909 | pr_info("dynamic shared memory is enabled\n"); | |
| 1918 | 1910 | ||
| 1911 | + | rc = tee_device_register(optee->teedev); | |
| 1912 | + | if (rc) | |
| 1913 | + | goto err_disable_shm_cache; | |
| 1914 | + | ||
| 1915 | + | rc = tee_device_register(optee->supp_teedev); | |
| 1916 | + | if (rc) | |
| 1917 | + | goto err_disable_shm_cache; | |
| 1918 | + | ||
| 1919 | 1919 | rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES); | |
| 1920 | 1920 | if (rc) | |
| 1921 | 1921 | goto err_disable_shm_cache; | |
| @@ -1942,7 +1942,6 @@ err_supp_uninit: | |||
| 1942 | 1942 | optee_shm_arg_cache_uninit(optee); | |
| 1943 | 1943 | optee_supp_uninit(&optee->supp); | |
| 1944 | 1944 | mutex_destroy(&optee->call_queue.mutex); | |
| 1945 | - | err_unreg_supp_teedev: | |
| 1946 | 1945 | tee_device_unregister(optee->supp_teedev); | |
| 1947 | 1946 | err_unreg_teedev: | |
| 1948 | 1947 | tee_device_unregister(optee->teedev); | |
modified drivers/tee/qcomtee/async.c
| @@ -97,10 +97,10 @@ static void qcomtee_get_async_buffer(struct qcomtee_object_invoke_ctx *oic, | |||
| 97 | 97 | /** | |
| 98 | 98 | * async_release() - Process QTEE async release requests. | |
| 99 | 99 | * @oic: context used for the current invocation. | |
| 100 | - | * @msg: async message for object release. | |
| 100 | + | * @async_msg: async message for object release. | |
| 101 | 101 | * @size: size of the async buffer available. | |
| 102 | 102 | * | |
| 103 | - | * Return: Size of the outbound buffer used when processing @msg. | |
| 103 | + | * Return: Size of the outbound buffer used when processing @async_msg. | |
| 104 | 104 | */ | |
| 105 | 105 | static size_t async_release(struct qcomtee_object_invoke_ctx *oic, | |
| 106 | 106 | struct qcomtee_async_msg_hdr *async_msg, | |
modified drivers/tee/qcomtee/qcomtee_msg.h
| @@ -112,7 +112,7 @@ union qcomtee_msg_arg { | |||
| 112 | 112 | ||
| 113 | 113 | /** | |
| 114 | 114 | * struct qcomtee_msg_object_invoke - Direct object invocation message. | |
| 115 | - | * @ctx: object ID hosted in QTEE. | |
| 115 | + | * @cxt: object ID hosted in QTEE. | |
| 116 | 116 | * @op: operation for the object. | |
| 117 | 117 | * @counts: number of different types of arguments in @args. | |
| 118 | 118 | * @args: array of arguments. | |
modified drivers/tee/qcomtee/qcomtee_object.h
| @@ -74,6 +74,7 @@ enum qcomtee_object_type { | |||
| 74 | 74 | * @QCOMTEE_ARG_TYPE_OO: output object (OO). | |
| 75 | 75 | * @QCOMTEE_ARG_TYPE_IB: input buffer (IB). | |
| 76 | 76 | * @QCOMTEE_ARG_TYPE_IO: input object (IO). | |
| 77 | + | * @QCOMTEE_ARG_TYPE_NR: number of argument types. | |
| 77 | 78 | * | |
| 78 | 79 | * Use the invalid type to specify the end of the argument array. | |
| 79 | 80 | */ | |
modified drivers/tee/tee_shm.c
| @@ -343,6 +343,10 @@ int tee_dyn_shm_alloc_helper(struct tee_shm *shm, size_t size, size_t align, | |||
| 343 | 343 | unsigned int i; | |
| 344 | 344 | int rc = 0; | |
| 345 | 345 | ||
| 346 | + | /* get_order(0) is undefined and exceeds MAX_PAGE_ORDER. */ | |
| 347 | + | if (!nr_pages) | |
| 348 | + | return -EINVAL; | |
| 349 | + | ||
| 346 | 350 | /* | |
| 347 | 351 | * Ignore alignment since this is already going to be page aligned | |
| 348 | 352 | * and there's no need for any larger alignment. | |
modified drivers/thunderbolt/ctl.c
| @@ -73,7 +73,6 @@ struct tb_ctl { | |||
| 73 | 73 | #define tb_ctl_dbg_once(ctl, format, arg...) \ | |
| 74 | 74 | dev_dbg_once((ctl)->nhi->dev, format, ## arg) | |
| 75 | 75 | ||
| 76 | - | static DECLARE_WAIT_QUEUE_HEAD(tb_cfg_request_cancel_queue); | |
| 77 | 76 | /* Serializes access to request kref_get/put */ | |
| 78 | 77 | static DEFINE_MUTEX(tb_cfg_request_lock); | |
| 79 | 78 | ||
| @@ -133,41 +132,42 @@ void tb_cfg_request_put(struct tb_cfg_request *req) | |||
| 133 | 132 | static int tb_cfg_request_enqueue(struct tb_ctl *ctl, | |
| 134 | 133 | struct tb_cfg_request *req) | |
| 135 | 134 | { | |
| 135 | + | tb_cfg_request_get(req); | |
| 136 | + | ||
| 136 | 137 | WARN_ON(test_bit(TB_CFG_REQUEST_ACTIVE, &req->flags)); | |
| 137 | 138 | WARN_ON(req->ctl); | |
| 138 | 139 | ||
| 139 | - | mutex_lock(&ctl->request_queue_lock); | |
| 140 | + | guard(mutex)(&ctl->request_queue_lock); | |
| 140 | 141 | if (!ctl->running) { | |
| 141 | - | mutex_unlock(&ctl->request_queue_lock); | |
| 142 | + | tb_cfg_request_put(req); | |
| 142 | 143 | return -ENOTCONN; | |
| 143 | 144 | } | |
| 144 | 145 | req->ctl = ctl; | |
| 145 | 146 | list_add_tail(&req->list, &ctl->request_queue); | |
| 146 | 147 | set_bit(TB_CFG_REQUEST_ACTIVE, &req->flags); | |
| 147 | - | mutex_unlock(&ctl->request_queue_lock); | |
| 148 | 148 | return 0; | |
| 149 | 149 | } | |
| 150 | 150 | ||
| 151 | - | static void tb_cfg_request_dequeue(struct tb_cfg_request *req) | |
| 151 | + | static bool tb_cfg_request_is_active(struct tb_cfg_request *req) | |
| 152 | 152 | { | |
| 153 | - | struct tb_ctl *ctl = req->ctl; | |
| 154 | - | ||
| 155 | - | mutex_lock(&ctl->request_queue_lock); | |
| 156 | - | if (!test_bit(TB_CFG_REQUEST_ACTIVE, &req->flags)) { | |
| 157 | - | mutex_unlock(&ctl->request_queue_lock); | |
| 158 | - | return; | |
| 159 | - | } | |
| 153 | + | return test_bit(TB_CFG_REQUEST_ACTIVE, &req->flags); | |
| 154 | + | } | |
| 160 | 155 | ||
| 161 | - | list_del(&req->list); | |
| 162 | - | clear_bit(TB_CFG_REQUEST_ACTIVE, &req->flags); | |
| 163 | - | if (test_bit(TB_CFG_REQUEST_CANCELED, &req->flags)) | |
| 164 | - | wake_up(&tb_cfg_request_cancel_queue); | |
| 165 | - | mutex_unlock(&ctl->request_queue_lock); | |
| 156 | + | static bool tb_cfg_request_is_canceled(struct tb_cfg_request *req) | |
| 157 | + | { | |
| 158 | + | return test_bit(TB_CFG_REQUEST_CANCELED, &req->flags); | |
| 166 | 159 | } | |
| 167 | 160 | ||
| 168 | - | static bool tb_cfg_request_is_active(struct tb_cfg_request *req) | |
| 161 | + | static void tb_cfg_request_dequeue(struct tb_cfg_request *req) | |
| 169 | 162 | { | |
| 170 | - | return test_bit(TB_CFG_REQUEST_ACTIVE, &req->flags); | |
| 163 | + | struct tb_ctl *ctl = req->ctl; | |
| 164 | + | ||
| 165 | + | guard(mutex)(&ctl->request_queue_lock); | |
| 166 | + | if (tb_cfg_request_is_active(req)) { | |
| 167 | + | list_del(&req->list); | |
| 168 | + | clear_bit(TB_CFG_REQUEST_ACTIVE, &req->flags); | |
| 169 | + | tb_cfg_request_put(req); | |
| 170 | + | } | |
| 171 | 171 | } | |
| 172 | 172 | ||
| 173 | 173 | static struct tb_cfg_request * | |
| @@ -178,7 +178,7 @@ tb_cfg_request_find(struct tb_ctl *ctl, struct ctl_pkg *pkg) | |||
| 178 | 178 | mutex_lock(&pkg->ctl->request_queue_lock); | |
| 179 | 179 | list_for_each_entry(iter, &pkg->ctl->request_queue, list) { | |
| 180 | 180 | tb_cfg_request_get(iter); | |
| 181 | - | if (iter->match(iter, pkg)) { | |
| 181 | + | if (!tb_cfg_request_is_canceled(iter) && iter->match(iter, pkg)) { | |
| 182 | 182 | req = iter; | |
| 183 | 183 | break; | |
| 184 | 184 | } | |
| @@ -512,8 +512,11 @@ static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame, | |||
| 512 | 512 | trace_tb_rx(pkg->ctl->index, frame->eof, pkg->buffer, frame->size, !req); | |
| 513 | 513 | ||
| 514 | 514 | if (req) { | |
| 515 | - | if (req->copy(req, pkg)) | |
| 516 | - | schedule_work(&req->work); | |
| 515 | + | scoped_guard(mutex, &pkg->ctl->request_queue_lock) { | |
| 516 | + | if (!tb_cfg_request_is_canceled(req) && | |
| 517 | + | req->copy(req, pkg)) | |
| 518 | + | schedule_work(&req->work); | |
| 519 | + | } | |
| 517 | 520 | tb_cfg_request_put(req); | |
| 518 | 521 | } | |
| 519 | 522 | ||
| @@ -525,11 +528,10 @@ static void tb_cfg_request_work(struct work_struct *work) | |||
| 525 | 528 | { | |
| 526 | 529 | struct tb_cfg_request *req = container_of(work, typeof(*req), work); | |
| 527 | 530 | ||
| 528 | - | if (!test_bit(TB_CFG_REQUEST_CANCELED, &req->flags)) | |
| 531 | + | if (!tb_cfg_request_is_canceled(req)) | |
| 529 | 532 | req->callback(req->callback_data); | |
| 530 | 533 | ||
| 531 | 534 | tb_cfg_request_dequeue(req); | |
| 532 | - | tb_cfg_request_put(req); | |
| 533 | 535 | } | |
| 534 | 536 | ||
| 535 | 537 | /** | |
| @@ -555,10 +557,9 @@ int tb_cfg_request(struct tb_ctl *ctl, struct tb_cfg_request *req, | |||
| 555 | 557 | INIT_WORK(&req->work, tb_cfg_request_work); | |
| 556 | 558 | INIT_LIST_HEAD(&req->list); | |
| 557 | 559 | ||
| 558 | - | tb_cfg_request_get(req); | |
| 559 | 560 | ret = tb_cfg_request_enqueue(ctl, req); | |
| 560 | 561 | if (ret) | |
| 561 | - | goto err_put; | |
| 562 | + | return ret; | |
| 562 | 563 | ||
| 563 | 564 | ret = tb_ctl_tx(ctl, req->request, req->request_size, | |
| 564 | 565 | req->request_type); | |
| @@ -572,9 +573,6 @@ int tb_cfg_request(struct tb_ctl *ctl, struct tb_cfg_request *req, | |||
| 572 | 573 | ||
| 573 | 574 | err_dequeue: | |
| 574 | 575 | tb_cfg_request_dequeue(req); | |
| 575 | - | err_put: | |
| 576 | - | tb_cfg_request_put(req); | |
| 577 | - | ||
| 578 | 576 | return ret; | |
| 579 | 577 | } | |
| 580 | 578 | ||
| @@ -588,9 +586,10 @@ err_put: | |||
| 588 | 586 | */ | |
| 589 | 587 | void tb_cfg_request_cancel(struct tb_cfg_request *req, int err) | |
| 590 | 588 | { | |
| 591 | - | set_bit(TB_CFG_REQUEST_CANCELED, &req->flags); | |
| 592 | - | schedule_work(&req->work); | |
| 593 | - | wait_event(tb_cfg_request_cancel_queue, !tb_cfg_request_is_active(req)); | |
| 589 | + | scoped_guard(mutex, &req->ctl->request_queue_lock) | |
| 590 | + | set_bit(TB_CFG_REQUEST_CANCELED, &req->flags); | |
| 591 | + | cancel_work_sync(&req->work); | |
| 592 | + | tb_cfg_request_dequeue(req); | |
| 594 | 593 | req->result.err = err; | |
| 595 | 594 | } | |
| 596 | 595 | ||
modified drivers/thunderbolt/domain.c
| @@ -788,21 +788,6 @@ int tb_domain_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd, | |||
| 788 | 788 | transmit_ring, receive_path, receive_ring); | |
| 789 | 789 | } | |
| 790 | 790 | ||
| 791 | - | static void tb_domain_reset_interface(struct tb *tb) | |
| 792 | - | { | |
| 793 | - | struct tb_nhi *nhi = tb->nhi; | |
| 794 | - | ||
| 795 | - | if (!nhi->ops->reset_interface) | |
| 796 | - | return; | |
| 797 | - | ||
| 798 | - | guard(mutex)(&tb->lock); | |
| 799 | - | ||
| 800 | - | /* The reset clears the ring state so stop the control channel */ | |
| 801 | - | tb_ctl_stop(tb->ctl); | |
| 802 | - | nhi->ops->reset_interface(nhi); | |
| 803 | - | tb_ctl_start(tb->ctl); | |
| 804 | - | } | |
| 805 | - | ||
| 806 | 791 | /** | |
| 807 | 792 | * tb_domain_disconnect_xdomain_paths() - Disable DMA paths for XDomain | |
| 808 | 793 | * @tb: Domain disabling the DMA paths | |
| @@ -825,20 +810,11 @@ int tb_domain_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd, | |||
| 825 | 810 | int transmit_path, int transmit_ring, | |
| 826 | 811 | int receive_path, int receive_ring) | |
| 827 | 812 | { | |
| 828 | - | int ret; | |
| 829 | - | ||
| 830 | 813 | if (!tb->cm_ops->disconnect_xdomain_paths) | |
| 831 | 814 | return -ENOTSUPP; | |
| 832 | 815 | ||
| 833 | - | ret = tb->cm_ops->disconnect_xdomain_paths(tb, xd, transmit_path, | |
| 816 | + | return tb->cm_ops->disconnect_xdomain_paths(tb, xd, transmit_path, | |
| 834 | 817 | transmit_ring, receive_path, receive_ring); | |
| 835 | - | if (ret) | |
| 836 | - | return ret; | |
| 837 | - | ||
| 838 | - | if (tb->nhi->quirks & QUIRK_RESET_DMA_ON_TEARDOWN) | |
| 839 | - | tb_domain_reset_interface(tb); | |
| 840 | - | ||
| 841 | - | return 0; | |
| 842 | 818 | } | |
| 843 | 819 | ||
| 844 | 820 | static int disconnect_xdomain(struct device *dev, void *data) | |
modified drivers/thunderbolt/nhi.c
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | #include <linux/dma-mapping.h> | |
| 16 | 16 | #include <linux/interrupt.h> | |
| 17 | 17 | #include <linux/iommu.h> | |
| 18 | + | #include <linux/lockdep.h> | |
| 18 | 19 | #include <linux/module.h> | |
| 19 | 20 | #include <linux/delay.h> | |
| 20 | 21 | #include <linux/property.h> | |
| @@ -560,6 +561,8 @@ static struct tb_ring *tb_ring_alloc(struct tb_nhi *nhi, u32 hop, int size, | |||
| 560 | 561 | INIT_LIST_HEAD(&ring->in_flight); | |
| 561 | 562 | INIT_WORK(&ring->work, ring_work); | |
| 562 | 563 | init_waitqueue_head(&ring->wait); | |
| 564 | + | lockdep_register_key(&ring->lock_key); | |
| 565 | + | lockdep_init_map(&ring->work.lockdep_map, "ring.work", &ring->lock_key, 0); | |
| 563 | 566 | ||
| 564 | 567 | ring->nhi = nhi; | |
| 565 | 568 | ring->hop = hop; | |
| @@ -599,6 +602,7 @@ err_free_descs: | |||
| 599 | 602 | ring->size * sizeof(*ring->descriptors), | |
| 600 | 603 | ring->descriptors, ring->descriptors_dma); | |
| 601 | 604 | err_free_ring: | |
| 605 | + | lockdep_unregister_key(&ring->lock_key); | |
| 602 | 606 | kfree(ring); | |
| 603 | 607 | ||
| 604 | 608 | return NULL; | |
| @@ -848,6 +852,7 @@ void tb_ring_free(struct tb_ring *ring) | |||
| 848 | 852 | * to finish before freeing the ring. | |
| 849 | 853 | */ | |
| 850 | 854 | flush_work(&ring->work); | |
| 855 | + | lockdep_unregister_key(&ring->lock_key); | |
| 851 | 856 | kfree(ring); | |
| 852 | 857 | } | |
| 853 | 858 | EXPORT_SYMBOL_GPL(tb_ring_free); | |
| @@ -1175,32 +1180,6 @@ static void nhi_reset(struct tb_nhi *nhi) | |||
| 1175 | 1180 | dev_warn(nhi->dev, "timeout resetting host router\n"); | |
| 1176 | 1181 | } | |
| 1177 | 1182 | ||
| 1178 | - | /** | |
| 1179 | - | * nhi_reset_interface() - Reset the host interface | |
| 1180 | - | * @nhi: Host interface to reset | |
| 1181 | - | * | |
| 1182 | - | * Brings the registers in the memory BAR back to their default state and | |
| 1183 | - | * clears the End-to-End Flow Control state. The caller is responsible for | |
| 1184 | - | * stopping the control channel over the reset because it clears the ring | |
| 1185 | - | * state as well. | |
| 1186 | - | */ | |
| 1187 | - | void nhi_reset_interface(struct tb_nhi *nhi) | |
| 1188 | - | { | |
| 1189 | - | u32 val; | |
| 1190 | - | ||
| 1191 | - | val = ioread32(nhi->iobase + REG_CAPS); | |
| 1192 | - | /* Only v1 host interfaces implement the reset */ | |
| 1193 | - | if (FIELD_GET(REG_CAPS_VERSION_MASK, val) >= REG_CAPS_VERSION_2) | |
| 1194 | - | return; | |
| 1195 | - | ||
| 1196 | - | dev_dbg(nhi->dev, "issuing host interface reset\n"); | |
| 1197 | - | ||
| 1198 | - | iowrite32(REG_HOST_INTERFACE_RESET_RST, | |
| 1199 | - | nhi->iobase + REG_HOST_INTERFACE_RESET); | |
| 1200 | - | /* Wait for tHIReset (10 ms) to complete */ | |
| 1201 | - | usleep_range(10000, 20000); | |
| 1202 | - | } | |
| 1203 | - | ||
| 1204 | 1183 | static struct tb *nhi_select_cm(struct tb_nhi *nhi) | |
| 1205 | 1184 | { | |
| 1206 | 1185 | struct tb *tb; | |
modified drivers/thunderbolt/nhi.h
| @@ -36,8 +36,6 @@ irqreturn_t nhi_msi(int irq, void *data); | |||
| 36 | 36 | irqreturn_t ring_msix(int irq, void *data); | |
| 37 | 37 | int nhi_probe(struct tb_nhi *nhi); | |
| 38 | 38 | void nhi_shutdown(struct tb_nhi *nhi); | |
| 39 | - | void nhi_reset_interface(struct tb_nhi *nhi); | |
| 40 | - | ||
| 41 | 39 | extern const struct dev_pm_ops nhi_pm_ops; | |
| 42 | 40 | ||
| 43 | 41 | /** | |
| @@ -54,7 +52,6 @@ extern const struct dev_pm_ops nhi_pm_ops; | |||
| 54 | 52 | * @release_ring_irq: NHI specific interrupt release hook | |
| 55 | 53 | * @is_present: Whether the device is currently present on the parent bus | |
| 56 | 54 | * @init_interrupts: NHI specific interrupt initialization hook | |
| 57 | - | * @reset_interface: Resets the host interface | |
| 58 | 55 | */ | |
| 59 | 56 | struct tb_nhi_ops { | |
| 60 | 57 | int (*init)(struct tb_nhi *nhi); | |
| @@ -69,7 +66,6 @@ struct tb_nhi_ops { | |||
| 69 | 66 | void (*release_ring_irq)(struct tb_ring *ring); | |
| 70 | 67 | bool (*is_present)(struct tb_nhi *nhi); | |
| 71 | 68 | int (*init_interrupts)(struct tb_nhi *nhi); | |
| 72 | - | void (*reset_interface)(struct tb_nhi *nhi); | |
| 73 | 69 | }; | |
| 74 | 70 | ||
| 75 | 71 | /* | |
| @@ -120,24 +116,11 @@ struct tb_nhi_ops { | |||
| 120 | 116 | #define PCI_DEVICE_ID_INTEL_PTL_P_NHI0 0xe433 | |
| 121 | 117 | #define PCI_DEVICE_ID_INTEL_PTL_P_NHI1 0xe434 | |
| 122 | 118 | ||
| 123 | - | #define PCI_DEVICE_ID_AMD_1AH_M60H_NHI0 0x1120 | |
| 124 | - | #define PCI_DEVICE_ID_AMD_1AH_M60H_NHI1 0x1121 | |
| 125 | - | #define PCI_DEVICE_ID_AMD_1AH_M68H_NHI0 0x113b | |
| 126 | - | #define PCI_DEVICE_ID_AMD_1AH_M68H_NHI1 0x113c | |
| 127 | - | #define PCI_DEVICE_ID_AMD_1AH_M80H_NHI0 0x1155 | |
| 128 | - | #define PCI_DEVICE_ID_AMD_1AH_M80H_NHI1 0x1158 | |
| 129 | - | #define PCI_DEVICE_ID_AMD_1AH_M80H_NHI2 0x1159 | |
| 130 | - | #define PCI_DEVICE_ID_AMD_1AH_M24H_NHI0 0x151c | |
| 131 | - | #define PCI_DEVICE_ID_AMD_1AH_M24H_NHI1 0x151d | |
| 132 | - | #define PCI_DEVICE_ID_AMD_1AH_M70H_NHI0 0x158d | |
| 133 | - | #define PCI_DEVICE_ID_AMD_1AH_M70H_NHI1 0x158e | |
| 134 | - | ||
| 135 | 119 | #define PCI_CLASS_SERIAL_USB_USB4 0x0c0340 | |
| 136 | 120 | ||
| 137 | 121 | /* Host interface quirks */ | |
| 138 | - | #define QUIRK_AUTO_CLEAR_INT BIT(0) | |
| 139 | - | #define QUIRK_E2E BIT(1) | |
| 140 | - | #define QUIRK_RESET_DMA_ON_TEARDOWN BIT(2) | |
| 122 | + | #define QUIRK_AUTO_CLEAR_INT BIT(0) | |
| 123 | + | #define QUIRK_E2E BIT(1) | |
| 141 | 124 | ||
| 142 | 125 | /* | |
| 143 | 126 | * Minimal number of vectors when we use MSI-X. Two for control channel | |
modified drivers/thunderbolt/nhi_regs.h
| @@ -115,10 +115,6 @@ struct ring_desc { | |||
| 115 | 115 | #define REG_CAPS_VERSION_MASK GENMASK(23, 16) | |
| 116 | 116 | #define REG_CAPS_VERSION_2 0x40 | |
| 117 | 117 | ||
| 118 | - | /* Host Interface Reset - resets TX/RX rings and E2E flow control counters */ | |
| 119 | - | #define REG_HOST_INTERFACE_RESET 0x39858 | |
| 120 | - | #define REG_HOST_INTERFACE_RESET_RST BIT(0) | |
| 121 | - | ||
| 122 | 118 | #define REG_DMA_MISC 0x39864 | |
| 123 | 119 | #define REG_DMA_MISC_INT_AUTO_CLEAR BIT(2) | |
| 124 | 120 | #define REG_DMA_MISC_DISABLE_AUTO_CLEAR BIT(17) | |
modified drivers/thunderbolt/pci.c
| @@ -62,27 +62,6 @@ static void nhi_pci_check_quirks(struct tb_nhi_pci *nhi_pci) | |||
| 62 | 62 | nhi->quirks |= QUIRK_E2E; | |
| 63 | 63 | break; | |
| 64 | 64 | } | |
| 65 | - | } else if (pdev->vendor == PCI_VENDOR_ID_AMD) { | |
| 66 | - | switch (pdev->device) { | |
| 67 | - | case PCI_DEVICE_ID_AMD_1AH_M60H_NHI0: | |
| 68 | - | case PCI_DEVICE_ID_AMD_1AH_M60H_NHI1: | |
| 69 | - | case PCI_DEVICE_ID_AMD_1AH_M68H_NHI0: | |
| 70 | - | case PCI_DEVICE_ID_AMD_1AH_M68H_NHI1: | |
| 71 | - | case PCI_DEVICE_ID_AMD_1AH_M80H_NHI0: | |
| 72 | - | case PCI_DEVICE_ID_AMD_1AH_M80H_NHI1: | |
| 73 | - | case PCI_DEVICE_ID_AMD_1AH_M80H_NHI2: | |
| 74 | - | case PCI_DEVICE_ID_AMD_1AH_M24H_NHI0: | |
| 75 | - | case PCI_DEVICE_ID_AMD_1AH_M24H_NHI1: | |
| 76 | - | case PCI_DEVICE_ID_AMD_1AH_M70H_NHI0: | |
| 77 | - | case PCI_DEVICE_ID_AMD_1AH_M70H_NHI1: | |
| 78 | - | /* | |
| 79 | - | * These AMD hosts may hang the Tx ring when the | |
| 80 | - | * DMA paths are torn down so they need the host | |
| 81 | - | * interface reset after each teardown. | |
| 82 | - | */ | |
| 83 | - | nhi->quirks |= QUIRK_RESET_DMA_ON_TEARDOWN; | |
| 84 | - | break; | |
| 85 | - | } | |
| 86 | 65 | } | |
| 87 | 66 | } | |
| 88 | 67 | ||
| @@ -279,7 +258,6 @@ static const struct tb_nhi_ops pci_nhi_default_ops = { | |||
| 279 | 258 | .shutdown = nhi_pci_release_irq, | |
| 280 | 259 | .is_present = nhi_pci_is_present, | |
| 281 | 260 | .init_interrupts = nhi_pci_init_msi, | |
| 282 | - | .reset_interface = nhi_reset_interface, | |
| 283 | 261 | }; | |
| 284 | 262 | ||
| 285 | 263 | /* Ice Lake specific NHI operations */ | |
| @@ -463,7 +441,6 @@ static const struct tb_nhi_ops icl_nhi_ops = { | |||
| 463 | 441 | .release_ring_irq = nhi_pci_ring_release_msix, | |
| 464 | 442 | .is_present = nhi_pci_is_present, | |
| 465 | 443 | .init_interrupts = nhi_pci_init_msi, | |
| 466 | - | .reset_interface = nhi_reset_interface, | |
| 467 | 444 | }; | |
| 468 | 445 | ||
| 469 | 446 | static int nhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |
modified drivers/thunderbolt/quirks.c
| @@ -99,6 +99,9 @@ static const struct tb_quirk tb_quirks[] = { | |||
| 99 | 99 | quirk_usb3_maximum_bandwidth }, | |
| 100 | 100 | { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HUB_40G_BRIDGE, 0x0000, 0x0000, | |
| 101 | 101 | quirk_usb3_maximum_bandwidth }, | |
| 102 | + | /* CLx is unstable on the Anker Prime TB5 dock (DROM 01ea:83b5) */ | |
| 103 | + | { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HUB_80G_BRIDGE, 0x01ea, 0x83b5, | |
| 104 | + | quirk_clx_disable }, | |
| 102 | 105 | /* | |
| 103 | 106 | * Block Runtime PM in DP redrive mode for Intel Barlow Ridge host | |
| 104 | 107 | * controllers. | |
modified drivers/thunderbolt/stream.c
| @@ -978,6 +978,9 @@ static int tbstream_dev_fops_open(struct inode *inode, struct file *file) | |||
| 978 | 978 | } | |
| 979 | 979 | ||
| 980 | 980 | mutex_unlock(&sdev->lock); | |
| 981 | + | ||
| 982 | + | /* Stream handles IOCB_NOWAIT just fine */ | |
| 983 | + | file->f_mode |= FMODE_NOWAIT; | |
| 981 | 984 | return 0; | |
| 982 | 985 | ||
| 983 | 986 | err_unlock: | |
modified drivers/thunderbolt/switch.c
| @@ -774,6 +774,7 @@ static int tb_port_alloc_hopid(struct tb_port *port, bool in, int min_hopid, | |||
| 774 | 774 | { | |
| 775 | 775 | int port_max_hopid; | |
| 776 | 776 | struct ida *ida; | |
| 777 | + | int ret; | |
| 777 | 778 | ||
| 778 | 779 | if (in) { | |
| 779 | 780 | port_max_hopid = port->config.max_in_hop_id; | |
| @@ -793,7 +794,11 @@ static int tb_port_alloc_hopid(struct tb_port *port, bool in, int min_hopid, | |||
| 793 | 794 | if (max_hopid < 0 || max_hopid > port_max_hopid) | |
| 794 | 795 | max_hopid = port_max_hopid; | |
| 795 | 796 | ||
| 796 | - | return ida_alloc_range(ida, min_hopid, max_hopid, GFP_KERNEL); | |
| 797 | + | ret = ida_alloc_range(ida, min_hopid, max_hopid, GFP_KERNEL); | |
| 798 | + | if (ret >= 0) | |
| 799 | + | tb_switch_get(port->sw); | |
| 800 | + | ||
| 801 | + | return ret; | |
| 797 | 802 | } | |
| 798 | 803 | ||
| 799 | 804 | /** | |
| @@ -832,6 +837,7 @@ int tb_port_alloc_out_hopid(struct tb_port *port, int min_hopid, int max_hopid) | |||
| 832 | 837 | void tb_port_release_in_hopid(struct tb_port *port, int hopid) | |
| 833 | 838 | { | |
| 834 | 839 | ida_free(&port->in_hopids, hopid); | |
| 840 | + | tb_switch_put(port->sw); | |
| 835 | 841 | } | |
| 836 | 842 | ||
| 837 | 843 | /** | |
| @@ -842,6 +848,7 @@ void tb_port_release_in_hopid(struct tb_port *port, int hopid) | |||
| 842 | 848 | void tb_port_release_out_hopid(struct tb_port *port, int hopid) | |
| 843 | 849 | { | |
| 844 | 850 | ida_free(&port->out_hopids, hopid); | |
| 851 | + | tb_switch_put(port->sw); | |
| 845 | 852 | } | |
| 846 | 853 | ||
| 847 | 854 | static inline bool tb_switch_is_reachable(const struct tb_switch *parent, | |
modified drivers/thunderbolt/tb.c
| @@ -89,6 +89,7 @@ static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port, | |||
| 89 | 89 | const char *reason); | |
| 90 | 90 | static void tb_queue_dp_bandwidth_request(struct tb *tb, u64 route, u8 port, | |
| 91 | 91 | int retry, unsigned long delay); | |
| 92 | + | static void tb_dp_tunnel_active(struct tb_tunnel *tunnel, void *data); | |
| 92 | 93 | ||
| 93 | 94 | static void tb_queue_hotplug(struct tb *tb, u64 route, u8 port, bool unplug) | |
| 94 | 95 | { | |
| @@ -385,7 +386,8 @@ static void tb_switch_discover_tunnels(struct tb_switch *sw, | |||
| 385 | 386 | ||
| 386 | 387 | switch (port->config.type) { | |
| 387 | 388 | case TB_TYPE_DP_HDMI_IN: | |
| 388 | - | tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids); | |
| 389 | + | tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids, | |
| 390 | + | tb_dp_tunnel_active, tb); | |
| 389 | 391 | tb_increase_tmu_accuracy(tunnel); | |
| 390 | 392 | break; | |
| 391 | 393 | ||
| @@ -1910,6 +1912,18 @@ static void tb_dp_tunnel_active(struct tb_tunnel *tunnel, void *data) | |||
| 1910 | 1912 | struct tb *tb = data; | |
| 1911 | 1913 | ||
| 1912 | 1914 | mutex_lock(&tb->lock); | |
| 1915 | + | ||
| 1916 | + | /* | |
| 1917 | + | * If the DPRX read was canceled the tunnel is already being torn | |
| 1918 | + | * down by whoever canceled it. Do not touch the adapters here | |
| 1919 | + | * because the routers may be gone by now. | |
| 1920 | + | */ | |
| 1921 | + | if (tunnel->dprx_canceled) { | |
| 1922 | + | tb_tunnel_dbg(tunnel, "DPRX read canceled, not activating\n"); | |
| 1923 | + | mutex_unlock(&tb->lock); | |
| 1924 | + | return; | |
| 1925 | + | } | |
| 1926 | + | ||
| 1913 | 1927 | if (tb_tunnel_is_active(tunnel)) { | |
| 1914 | 1928 | int consumed_up, consumed_down, ret; | |
| 1915 | 1929 | ||
| @@ -1964,8 +1978,6 @@ static void tb_dp_tunnel_active(struct tb_tunnel *tunnel, void *data) | |||
| 1964 | 1978 | tb_dp_resource_unavailable(tb, in, "DPRX negotiation failed"); | |
| 1965 | 1979 | } | |
| 1966 | 1980 | mutex_unlock(&tb->lock); | |
| 1967 | - | ||
| 1968 | - | tb_domain_put(tb); | |
| 1969 | 1981 | } | |
| 1970 | 1982 | ||
| 1971 | 1983 | static void tb_tunnel_one_dp(struct tb *tb, struct tb_port *in, | |
| @@ -2026,8 +2038,7 @@ static void tb_tunnel_one_dp(struct tb *tb, struct tb_port *in, | |||
| 2026 | 2038 | available_up, available_down); | |
| 2027 | 2039 | ||
| 2028 | 2040 | tunnel = tb_tunnel_alloc_dp(tb, in, out, link_nr, available_up, | |
| 2029 | - | available_down, tb_dp_tunnel_active, | |
| 2030 | - | tb_domain_get(tb)); | |
| 2041 | + | available_down, tb_dp_tunnel_active, tb); | |
| 2031 | 2042 | if (!tunnel) { | |
| 2032 | 2043 | tb_port_dbg(out, "could not allocate DP tunnel\n"); | |
| 2033 | 2044 | goto err_reclaim_usb; | |
| @@ -2048,7 +2059,6 @@ err_free: | |||
| 2048 | 2059 | tb_tunnel_put(tunnel); | |
| 2049 | 2060 | err_reclaim_usb: | |
| 2050 | 2061 | tb_reclaim_usb3_bandwidth(tb, in, out); | |
| 2051 | - | tb_domain_put(tb); | |
| 2052 | 2062 | err_detach_group: | |
| 2053 | 2063 | tb_detach_bandwidth_group(in); | |
| 2054 | 2064 | err_dealloc_dp: | |
| @@ -2950,11 +2960,12 @@ static void tb_stop(struct tb *tb) | |||
| 2950 | 2960 | /* tunnels are only present after everything has been initialized */ | |
| 2951 | 2961 | list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { | |
| 2952 | 2962 | /* | |
| 2953 | - | * DMA tunnels require the driver to be functional so we | |
| 2954 | - | * tear them down. Other protocol tunnels can be left | |
| 2955 | - | * intact. | |
| 2963 | + | * DMA tunnels and DP tunnels which are not yet active require | |
| 2964 | + | * the driver to be functional so we tear them down. | |
| 2965 | + | * Other protocol tunnels can be left intact. | |
| 2956 | 2966 | */ | |
| 2957 | - | if (tb_tunnel_is_dma(tunnel)) | |
| 2967 | + | if (tb_tunnel_is_dma(tunnel) || | |
| 2968 | + | (tb_tunnel_is_dp(tunnel) && !tb_tunnel_is_active(tunnel))) | |
| 2958 | 2969 | tb_tunnel_deactivate(tunnel); | |
| 2959 | 2970 | tb_tunnel_put(tunnel); | |
| 2960 | 2971 | } | |
| @@ -3274,11 +3285,11 @@ static void tb_remove_work(struct work_struct *work) | |||
| 3274 | 3285 | struct tb *tb = tcm_to_tb(tcm); | |
| 3275 | 3286 | ||
| 3276 | 3287 | mutex_lock(&tb->lock); | |
| 3277 | - | if (tb->root_switch) | |
| 3288 | + | if (tb->root_switch) { | |
| 3278 | 3289 | tb_free_unplugged_children(tb->root_switch); | |
| 3290 | + | tb_free_unplugged_xdomains(tb->root_switch); | |
| 3291 | + | } | |
| 3279 | 3292 | mutex_unlock(&tb->lock); | |
| 3280 | - | ||
| 3281 | - | tb_free_unplugged_xdomains(tb->root_switch); | |
| 3282 | 3293 | } | |
| 3283 | 3294 | ||
| 3284 | 3295 | static int tb_runtime_resume(struct tb *tb) | |
modified drivers/thunderbolt/test.c
| @@ -33,6 +33,18 @@ static void kunit_ida_init(struct kunit *test, struct ida *ida) | |||
| 33 | 33 | kunit_alloc_resource(test, __ida_init, __ida_destroy, GFP_KERNEL, ida); | |
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | + | static void tb_test_switch_release(struct device *dev) | |
| 37 | + | { | |
| 38 | + | /* The memory is owned by KUnit, nothing to do here */ | |
| 39 | + | } | |
| 40 | + | ||
| 41 | + | static void tb_test_switch_put(void *data) | |
| 42 | + | { | |
| 43 | + | struct tb_switch *sw = data; | |
| 44 | + | ||
| 45 | + | put_device(&sw->dev); | |
| 46 | + | } | |
| 47 | + | ||
| 36 | 48 | static struct tb_switch *alloc_switch(struct kunit *test, u64 route, | |
| 37 | 49 | u8 upstream_port, u8 max_port_number) | |
| 38 | 50 | { | |
| @@ -44,6 +56,15 @@ static struct tb_switch *alloc_switch(struct kunit *test, u64 route, | |||
| 44 | 56 | if (!sw) | |
| 45 | 57 | return NULL; | |
| 46 | 58 | ||
| 59 | + | /* | |
| 60 | + | * HopID allocations take a reference to their routers and those devices | |
| 61 | + | * have to be initialized for that to work. | |
| 62 | + | */ | |
| 63 | + | sw->dev.release = tb_test_switch_release; | |
| 64 | + | device_initialize(&sw->dev); | |
| 65 | + | if (kunit_add_action_or_reset(test, tb_test_switch_put, sw)) | |
| 66 | + | return NULL; | |
| 67 | + | ||
| 47 | 68 | sw->config.upstream_port_number = upstream_port; | |
| 48 | 69 | sw->config.depth = tb_route_length(route); | |
| 49 | 70 | sw->config.route_hi = upper_32_bits(route); | |
| @@ -1386,6 +1407,10 @@ static void tb_test_tunnel_pcie(struct kunit *test) | |||
| 1386 | 1407 | tb_tunnel_put(tunnel1); | |
| 1387 | 1408 | } | |
| 1388 | 1409 | ||
| 1410 | + | static void tb_test_dp_tunnel_active(struct tb_tunnel *tunnel, void *data) | |
| 1411 | + | { | |
| 1412 | + | } | |
| 1413 | + | ||
| 1389 | 1414 | static void tb_test_tunnel_dp(struct kunit *test) | |
| 1390 | 1415 | { | |
| 1391 | 1416 | struct tb_switch *host, *dev; | |
| @@ -1406,7 +1431,8 @@ static void tb_test_tunnel_dp(struct kunit *test) | |||
| 1406 | 1431 | in = &host->ports[5]; | |
| 1407 | 1432 | out = &dev->ports[13]; | |
| 1408 | 1433 | ||
| 1409 | - | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, NULL, NULL); | |
| 1434 | + | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, | |
| 1435 | + | tb_test_dp_tunnel_active, NULL); | |
| 1410 | 1436 | KUNIT_ASSERT_NOT_NULL(test, tunnel); | |
| 1411 | 1437 | KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); | |
| 1412 | 1438 | KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); | |
| @@ -1452,7 +1478,8 @@ static void tb_test_tunnel_dp_chain(struct kunit *test) | |||
| 1452 | 1478 | in = &host->ports[5]; | |
| 1453 | 1479 | out = &dev4->ports[14]; | |
| 1454 | 1480 | ||
| 1455 | - | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, NULL, NULL); | |
| 1481 | + | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, | |
| 1482 | + | tb_test_dp_tunnel_active, NULL); | |
| 1456 | 1483 | KUNIT_ASSERT_NOT_NULL(test, tunnel); | |
| 1457 | 1484 | KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); | |
| 1458 | 1485 | KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); | |
| @@ -1502,7 +1529,8 @@ static void tb_test_tunnel_dp_tree(struct kunit *test) | |||
| 1502 | 1529 | in = &dev2->ports[13]; | |
| 1503 | 1530 | out = &dev5->ports[13]; | |
| 1504 | 1531 | ||
| 1505 | - | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, NULL, NULL); | |
| 1532 | + | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, | |
| 1533 | + | tb_test_dp_tunnel_active, NULL); | |
| 1506 | 1534 | KUNIT_ASSERT_NOT_NULL(test, tunnel); | |
| 1507 | 1535 | KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); | |
| 1508 | 1536 | KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); | |
| @@ -1567,7 +1595,8 @@ static void tb_test_tunnel_dp_max_length(struct kunit *test) | |||
| 1567 | 1595 | in = &dev6->ports[13]; | |
| 1568 | 1596 | out = &dev12->ports[13]; | |
| 1569 | 1597 | ||
| 1570 | - | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, NULL, NULL); | |
| 1598 | + | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, | |
| 1599 | + | tb_test_dp_tunnel_active, NULL); | |
| 1571 | 1600 | KUNIT_ASSERT_NOT_NULL(test, tunnel); | |
| 1572 | 1601 | KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); | |
| 1573 | 1602 | KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); | |
| @@ -1637,7 +1666,8 @@ static void tb_test_tunnel_3dp(struct kunit *test) | |||
| 1637 | 1666 | out2 = &dev5->ports[13]; | |
| 1638 | 1667 | out3 = &dev4->ports[14]; | |
| 1639 | 1668 | ||
| 1640 | - | tunnel1 = tb_tunnel_alloc_dp(NULL, in1, out1, 1, 0, 0, NULL, NULL); | |
| 1669 | + | tunnel1 = tb_tunnel_alloc_dp(NULL, in1, out1, 1, 0, 0, | |
| 1670 | + | tb_test_dp_tunnel_active, NULL); | |
| 1641 | 1671 | KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); | |
| 1642 | 1672 | KUNIT_EXPECT_EQ(test, tunnel1->type, TB_TUNNEL_DP); | |
| 1643 | 1673 | KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, in1); | |
| @@ -1645,7 +1675,8 @@ static void tb_test_tunnel_3dp(struct kunit *test) | |||
| 1645 | 1675 | KUNIT_ASSERT_EQ(test, tunnel1->npaths, 3); | |
| 1646 | 1676 | KUNIT_ASSERT_EQ(test, tunnel1->paths[0]->path_length, 3); | |
| 1647 | 1677 | ||
| 1648 | - | tunnel2 = tb_tunnel_alloc_dp(NULL, in2, out2, 1, 0, 0, NULL, NULL); | |
| 1678 | + | tunnel2 = tb_tunnel_alloc_dp(NULL, in2, out2, 1, 0, 0, | |
| 1679 | + | tb_test_dp_tunnel_active, NULL); | |
| 1649 | 1680 | KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); | |
| 1650 | 1681 | KUNIT_EXPECT_EQ(test, tunnel2->type, TB_TUNNEL_DP); | |
| 1651 | 1682 | KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, in2); | |
| @@ -1653,7 +1684,8 @@ static void tb_test_tunnel_3dp(struct kunit *test) | |||
| 1653 | 1684 | KUNIT_ASSERT_EQ(test, tunnel2->npaths, 3); | |
| 1654 | 1685 | KUNIT_ASSERT_EQ(test, tunnel2->paths[0]->path_length, 4); | |
| 1655 | 1686 | ||
| 1656 | - | tunnel3 = tb_tunnel_alloc_dp(NULL, in3, out3, 1, 0, 0, NULL, NULL); | |
| 1687 | + | tunnel3 = tb_tunnel_alloc_dp(NULL, in3, out3, 1, 0, 0, | |
| 1688 | + | tb_test_dp_tunnel_active, NULL); | |
| 1657 | 1689 | KUNIT_ASSERT_TRUE(test, tunnel3 != NULL); | |
| 1658 | 1690 | KUNIT_EXPECT_EQ(test, tunnel3->type, TB_TUNNEL_DP); | |
| 1659 | 1691 | KUNIT_EXPECT_PTR_EQ(test, tunnel3->src_port, in3); | |
| @@ -1751,7 +1783,8 @@ static void tb_test_tunnel_port_on_path(struct kunit *test) | |||
| 1751 | 1783 | in = &dev2->ports[13]; | |
| 1752 | 1784 | out = &dev5->ports[13]; | |
| 1753 | 1785 | ||
| 1754 | - | dp_tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, NULL, NULL); | |
| 1786 | + | dp_tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, | |
| 1787 | + | tb_test_dp_tunnel_active, NULL); | |
| 1755 | 1788 | KUNIT_ASSERT_NOT_NULL(test, dp_tunnel); | |
| 1756 | 1789 | ||
| 1757 | 1790 | KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, in)); | |
| @@ -2183,7 +2216,8 @@ static void tb_test_credit_alloc_dp(struct kunit *test) | |||
| 2183 | 2216 | in = &host->ports[5]; | |
| 2184 | 2217 | out = &dev->ports[14]; | |
| 2185 | 2218 | ||
| 2186 | - | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, NULL, NULL); | |
| 2219 | + | tunnel = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, | |
| 2220 | + | tb_test_dp_tunnel_active, NULL); | |
| 2187 | 2221 | KUNIT_ASSERT_NOT_NULL(test, tunnel); | |
| 2188 | 2222 | KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)3); | |
| 2189 | 2223 | ||
| @@ -2419,7 +2453,8 @@ static struct tb_tunnel *TB_TEST_DP_TUNNEL1(struct kunit *test, | |||
| 2419 | 2453 | ||
| 2420 | 2454 | in = &host->ports[5]; | |
| 2421 | 2455 | out = &dev->ports[13]; | |
| 2422 | - | dp_tunnel1 = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, NULL, NULL); | |
| 2456 | + | dp_tunnel1 = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, | |
| 2457 | + | tb_test_dp_tunnel_active, NULL); | |
| 2423 | 2458 | KUNIT_ASSERT_NOT_NULL(test, dp_tunnel1); | |
| 2424 | 2459 | KUNIT_ASSERT_EQ(test, dp_tunnel1->npaths, (size_t)3); | |
| 2425 | 2460 | ||
| @@ -2456,7 +2491,8 @@ static struct tb_tunnel *TB_TEST_DP_TUNNEL2(struct kunit *test, | |||
| 2456 | 2491 | ||
| 2457 | 2492 | in = &host->ports[6]; | |
| 2458 | 2493 | out = &dev->ports[14]; | |
| 2459 | - | dp_tunnel2 = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, NULL, NULL); | |
| 2494 | + | dp_tunnel2 = tb_tunnel_alloc_dp(NULL, in, out, 1, 0, 0, | |
| 2495 | + | tb_test_dp_tunnel_active, NULL); | |
| 2460 | 2496 | KUNIT_ASSERT_NOT_NULL(test, dp_tunnel2); | |
| 2461 | 2497 | KUNIT_ASSERT_EQ(test, dp_tunnel2->npaths, (size_t)3); | |
| 2462 | 2498 | ||
modified drivers/thunderbolt/tunnel.c
| @@ -510,6 +510,7 @@ struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down, | |||
| 510 | 510 | goto err_deactivate; | |
| 511 | 511 | } | |
| 512 | 512 | ||
| 513 | + | tb_tunnel_set_active(tunnel, true); | |
| 513 | 514 | tb_tunnel_dbg(tunnel, "discovered\n"); | |
| 514 | 515 | return tunnel; | |
| 515 | 516 | ||
| @@ -1093,8 +1094,14 @@ static void tb_dp_dprx_work(struct work_struct *work) | |||
| 1093 | 1094 | struct tb_tunnel *tunnel = container_of(work, typeof(*tunnel), dprx_work.work); | |
| 1094 | 1095 | struct tb *tb = tunnel->tb; | |
| 1095 | 1096 | ||
| 1097 | + | /* | |
| 1098 | + | * The DPRX read can be canceled while this work is waiting for | |
| 1099 | + | * tb->lock. Check the flag only once it is held: while the lock is | |
| 1100 | + | * held the tunnel cannot be torn down under us and the adapters are | |
| 1101 | + | * safe to access. | |
| 1102 | + | */ | |
| 1103 | + | mutex_lock(&tb->lock); | |
| 1096 | 1104 | if (!tunnel->dprx_canceled) { | |
| 1097 | - | mutex_lock(&tb->lock); | |
| 1098 | 1105 | if (tb_dp_is_usb4(tunnel->src_port->sw) && | |
| 1099 | 1106 | tb_dp_wait_dprx(tunnel, TB_DPRX_WAIT_TIMEOUT)) { | |
| 1100 | 1107 | if (ktime_before(ktime_get(), tunnel->dprx_timeout)) { | |
| @@ -1106,41 +1113,42 @@ static void tb_dp_dprx_work(struct work_struct *work) | |||
| 1106 | 1113 | } else { | |
| 1107 | 1114 | tb_tunnel_set_active(tunnel, true); | |
| 1108 | 1115 | } | |
| 1109 | - | mutex_unlock(&tb->lock); | |
| 1110 | 1116 | } | |
| 1117 | + | mutex_unlock(&tb->lock); | |
| 1111 | 1118 | ||
| 1112 | - | if (tunnel->callback) | |
| 1113 | - | tunnel->callback(tunnel, tunnel->callback_data); | |
| 1119 | + | tunnel->callback(tunnel, tunnel->callback_data); | |
| 1114 | 1120 | tb_tunnel_put(tunnel); | |
| 1121 | + | tb_domain_put(tb); | |
| 1115 | 1122 | } | |
| 1116 | 1123 | ||
| 1117 | 1124 | static int tb_dp_dprx_start(struct tb_tunnel *tunnel) | |
| 1118 | 1125 | { | |
| 1119 | 1126 | /* | |
| 1120 | - | * Bump up the reference to keep the tunnel around. It will be | |
| 1121 | - | * dropped in tb_dp_dprx_stop() once the tunnel is deactivated. | |
| 1127 | + | * Bump up the references to keep the tunnel and the domain around | |
| 1128 | + | * until the work has run or has been canceled. | |
| 1122 | 1129 | */ | |
| 1123 | 1130 | tb_tunnel_get(tunnel); | |
| 1131 | + | tb_domain_get(tunnel->tb); | |
| 1124 | 1132 | ||
| 1125 | 1133 | tunnel->dprx_started = true; | |
| 1134 | + | tunnel->dprx_canceled = false; | |
| 1135 | + | tunnel->dprx_timeout = dprx_timeout_to_ktime(dprx_timeout); | |
| 1136 | + | queue_delayed_work(tunnel->tb->wq, &tunnel->dprx_work, 0); | |
| 1126 | 1137 | ||
| 1127 | - | if (tunnel->callback) { | |
| 1128 | - | tunnel->dprx_timeout = dprx_timeout_to_ktime(dprx_timeout); | |
| 1129 | - | queue_delayed_work(tunnel->tb->wq, &tunnel->dprx_work, 0); | |
| 1130 | - | return -EINPROGRESS; | |
| 1131 | - | } | |
| 1132 | - | ||
| 1133 | - | return tb_dp_is_usb4(tunnel->src_port->sw) ? | |
| 1134 | - | tb_dp_wait_dprx(tunnel, dprx_timeout) : 0; | |
| 1138 | + | return -EINPROGRESS; | |
| 1135 | 1139 | } | |
| 1136 | 1140 | ||
| 1137 | 1141 | static void tb_dp_dprx_stop(struct tb_tunnel *tunnel) | |
| 1138 | 1142 | { | |
| 1143 | + | struct tb *tb = tunnel->tb; | |
| 1144 | + | ||
| 1139 | 1145 | if (tunnel->dprx_started) { | |
| 1140 | 1146 | tunnel->dprx_started = false; | |
| 1141 | 1147 | tunnel->dprx_canceled = true; | |
| 1142 | - | if (cancel_delayed_work(&tunnel->dprx_work)) | |
| 1148 | + | if (cancel_delayed_work(&tunnel->dprx_work)) { | |
| 1143 | 1149 | tb_tunnel_put(tunnel); | |
| 1150 | + | tb_domain_put(tb); | |
| 1151 | + | } | |
| 1144 | 1152 | } | |
| 1145 | 1153 | } | |
| 1146 | 1154 | ||
| @@ -1582,20 +1590,28 @@ static void tb_dp_dump(struct tb_tunnel *tunnel) | |||
| 1582 | 1590 | * @tb: Pointer to the domain structure | |
| 1583 | 1591 | * @in: DP in adapter | |
| 1584 | 1592 | * @alloc_hopid: Allocate HopIDs from visited ports | |
| 1593 | + | * @callback: Callback that is called when the DP tunnel is fully | |
| 1594 | + | * activated (or there is an error) | |
| 1595 | + | * @callback_data: Data for @callback | |
| 1585 | 1596 | * | |
| 1586 | 1597 | * If @in adapter is active, follows the tunnel to the DP out adapter | |
| 1587 | 1598 | * and back. Returns the discovered tunnel or %NULL if there was no | |
| 1588 | - | * tunnel. | |
| 1599 | + | * tunnel. See tb_tunnel_alloc_dp() for @callback. | |
| 1589 | 1600 | * | |
| 1590 | 1601 | * Return: Pointer to &struct tb_tunnel or %NULL if no tunnel found. | |
| 1591 | 1602 | */ | |
| 1592 | 1603 | struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in, | |
| 1593 | - | bool alloc_hopid) | |
| 1604 | + | bool alloc_hopid, | |
| 1605 | + | void (*callback)(struct tb_tunnel *, void *), | |
| 1606 | + | void *callback_data) | |
| 1594 | 1607 | { | |
| 1595 | 1608 | struct tb_tunnel *tunnel; | |
| 1596 | 1609 | struct tb_port *port; | |
| 1597 | 1610 | struct tb_path *path; | |
| 1598 | 1611 | ||
| 1612 | + | if (WARN_ON(!callback)) | |
| 1613 | + | return NULL; | |
| 1614 | + | ||
| 1599 | 1615 | if (!tb_dp_port_is_enabled(in)) | |
| 1600 | 1616 | return NULL; | |
| 1601 | 1617 | ||
| @@ -1611,6 +1627,9 @@ struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in, | |||
| 1611 | 1627 | tunnel->alloc_bandwidth = tb_dp_alloc_bandwidth; | |
| 1612 | 1628 | tunnel->consumed_bandwidth = tb_dp_consumed_bandwidth; | |
| 1613 | 1629 | tunnel->src_port = in; | |
| 1630 | + | tunnel->callback = callback; | |
| 1631 | + | tunnel->callback_data = callback_data; | |
| 1632 | + | INIT_DELAYED_WORK(&tunnel->dprx_work, tb_dp_dprx_work); | |
| 1614 | 1633 | ||
| 1615 | 1634 | path = tb_path_discover(in, TB_DP_VIDEO_HOPID, NULL, -1, | |
| 1616 | 1635 | &tunnel->dst_port, "Video", alloc_hopid); | |
| @@ -1656,6 +1675,7 @@ struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in, | |||
| 1656 | 1675 | ||
| 1657 | 1676 | tb_dp_dump(tunnel); | |
| 1658 | 1677 | ||
| 1678 | + | tb_tunnel_set_active(tunnel, true); | |
| 1659 | 1679 | tb_tunnel_dbg(tunnel, "discovered\n"); | |
| 1660 | 1680 | return tunnel; | |
| 1661 | 1681 | ||
| @@ -1677,16 +1697,16 @@ err_free: | |||
| 1677 | 1697 | * %0 if no available bandwidth. | |
| 1678 | 1698 | * @max_down: Maximum available downstream bandwidth for the DP tunnel. | |
| 1679 | 1699 | * %0 if no available bandwidth. | |
| 1680 | - | * @callback: Optional callback that is called when the DP tunnel is | |
| 1681 | - | * fully activated (or there is an error) | |
| 1682 | - | * @callback_data: Optional data for @callback | |
| 1700 | + | * @callback: Callback that is called when the DP tunnel is fully | |
| 1701 | + | * activated (or there is an error) | |
| 1702 | + | * @callback_data: Data for @callback | |
| 1683 | 1703 | * | |
| 1684 | 1704 | * Allocates a tunnel between @in and @out that is capable of tunneling | |
| 1685 | - | * Display Port traffic. If @callback is not %NULL it will be called | |
| 1686 | - | * after tb_tunnel_activate() once the tunnel has been fully activated. | |
| 1687 | - | * It can call tb_tunnel_is_active() to check if activation was | |
| 1688 | - | * successful (or if it returns %false there was some sort of issue). | |
| 1689 | - | * The @callback is called without @tb->lock held. | |
| 1705 | + | * Display Port traffic. The @callback is called after tb_tunnel_activate() | |
| 1706 | + | * once the tunnel has been fully activated. It can call | |
| 1707 | + | * tb_tunnel_is_active() to check if activation was successful (or if it | |
| 1708 | + | * returns %false there was some sort of issue). The @callback is called | |
| 1709 | + | * without @tb->lock held. | |
| 1690 | 1710 | * | |
| 1691 | 1711 | * Return: Pointer to @struct tb_tunnel or %NULL in case of failure. | |
| 1692 | 1712 | */ | |
| @@ -1701,7 +1721,7 @@ struct tb_tunnel *tb_tunnel_alloc_dp(struct tb *tb, struct tb_port *in, | |||
| 1701 | 1721 | struct tb_path *path; | |
| 1702 | 1722 | bool pm_support; | |
| 1703 | 1723 | ||
| 1704 | - | if (WARN_ON(!in->cap_adap || !out->cap_adap)) | |
| 1724 | + | if (WARN_ON(!in->cap_adap || !out->cap_adap || !callback)) | |
| 1705 | 1725 | return NULL; | |
| 1706 | 1726 | ||
| 1707 | 1727 | tunnel = tb_tunnel_alloc(tb, 3, TB_TUNNEL_DP); | |
| @@ -2288,6 +2308,7 @@ struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down, | |||
| 2288 | 2308 | tb_usb3_reclaim_available_bandwidth; | |
| 2289 | 2309 | } | |
| 2290 | 2310 | ||
| 2311 | + | tb_tunnel_set_active(tunnel, true); | |
| 2291 | 2312 | tb_tunnel_dbg(tunnel, "discovered\n"); | |
| 2292 | 2313 | return tunnel; | |
| 2293 | 2314 | ||
modified drivers/thunderbolt/tunnel.h
| @@ -66,8 +66,8 @@ enum tb_tunnel_state { | |||
| 66 | 66 | * @dprx_canceled: Was DPRX capabilities read poll canceled | |
| 67 | 67 | * @dprx_timeout: If set DPRX capabilities read poll work will timeout after this passes | |
| 68 | 68 | * @dprx_work: Worker that is scheduled to poll completion of DPRX capabilities read | |
| 69 | - | * @callback: Optional callback called when DP tunnel is fully activated | |
| 70 | - | * @callback_data: Optional data for @callback | |
| 69 | + | * @callback: Callback called when DP tunnel is fully activated | |
| 70 | + | * @callback_data: Data for @callback | |
| 71 | 71 | * @paths: All paths required by the tunnel | |
| 72 | 72 | */ | |
| 73 | 73 | struct tb_tunnel { | |
| @@ -117,7 +117,9 @@ struct tb_tunnel *tb_tunnel_alloc_pci(struct tb *tb, struct tb_port *up, | |||
| 117 | 117 | bool tb_tunnel_reserved_pci(struct tb_port *port, int *reserved_up, | |
| 118 | 118 | int *reserved_down); | |
| 119 | 119 | struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in, | |
| 120 | - | bool alloc_hopid); | |
| 120 | + | bool alloc_hopid, | |
| 121 | + | void (*callback)(struct tb_tunnel *, void *), | |
| 122 | + | void *callback_data); | |
| 121 | 123 | struct tb_tunnel *tb_tunnel_alloc_dp(struct tb *tb, struct tb_port *in, | |
| 122 | 124 | struct tb_port *out, int link_nr, | |
| 123 | 125 | int max_up, int max_down, | |
modified drivers/thunderbolt/xdomain.c
| @@ -377,6 +377,10 @@ static int tb_xdp_properties_request(struct tb_ctl *ctl, u64 route, | |||
| 377 | 377 | ||
| 378 | 378 | len += sizeof(res->hdr.xd_hdr) / 4; | |
| 379 | 379 | len -= sizeof(*res) / 4; | |
| 380 | + | if (len > TB_XDP_PROPERTIES_MAX_DATA_LENGTH) { | |
| 381 | + | ret = -EINVAL; | |
| 382 | + | goto err; | |
| 383 | + | } | |
| 380 | 384 | ||
| 381 | 385 | if (res->offset != req.offset) { | |
| 382 | 386 | ret = -EINVAL; | |
| @@ -1814,7 +1818,6 @@ static void tb_xdomain_state_work(struct work_struct *work) | |||
| 1814 | 1818 | tb_xdomain_failed(xd); | |
| 1815 | 1819 | } else { | |
| 1816 | 1820 | xd->state = XDOMAIN_STATE_ENUMERATED; | |
| 1817 | - | tb_xdomain_queue_properties_changed(xd); | |
| 1818 | 1821 | } | |
| 1819 | 1822 | break; | |
| 1820 | 1823 | ||
modified drivers/tty/amiserial.c
| @@ -1138,11 +1138,6 @@ static int rs_ioctl(struct tty_struct *tty, | |||
| 1138 | 1138 | local_irq_save(flags); | |
| 1139 | 1139 | cnow = info->icount; /* atomic copy */ | |
| 1140 | 1140 | local_irq_restore(flags); | |
| 1141 | - | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && | |
| 1142 | - | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { | |
| 1143 | - | ret = -EIO; /* no change => error */ | |
| 1144 | - | break; | |
| 1145 | - | } | |
| 1146 | 1141 | if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || | |
| 1147 | 1142 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || | |
| 1148 | 1143 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || | |
| @@ -1150,6 +1145,10 @@ static int rs_ioctl(struct tty_struct *tty, | |||
| 1150 | 1145 | ret = 0; | |
| 1151 | 1146 | break; | |
| 1152 | 1147 | } | |
| 1148 | + | if (tty_io_error(tty)) { | |
| 1149 | + | ret = -EIO; | |
| 1150 | + | break; | |
| 1151 | + | } | |
| 1153 | 1152 | schedule(); | |
| 1154 | 1153 | /* see if a signal did it */ | |
| 1155 | 1154 | if (signal_pending(current)) { | |
modified drivers/tty/n_gsm.c
| @@ -454,14 +454,13 @@ static const u8 gsm_fcs8[256] = { | |||
| 454 | 454 | ||
| 455 | 455 | static void gsm_dlci_close(struct gsm_dlci *dlci); | |
| 456 | 456 | static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len); | |
| 457 | - | static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk); | |
| 457 | + | static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk, bool wait); | |
| 458 | 458 | static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len, | |
| 459 | 459 | u8 ctrl); | |
| 460 | 460 | static int gsm_send_packet(struct gsm_mux *gsm, struct gsm_msg *msg); | |
| 461 | 461 | static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr); | |
| 462 | 462 | static void gsmld_write_trigger(struct gsm_mux *gsm); | |
| 463 | 463 | static void gsmld_write_task(struct work_struct *work); | |
| 464 | - | static int gsm_modem_send_initial_msc(struct gsm_dlci *dlci); | |
| 465 | 464 | ||
| 466 | 465 | /** | |
| 467 | 466 | * gsm_fcs_add - update FCS | |
| @@ -2174,7 +2173,7 @@ static void gsm_dlci_open(struct gsm_dlci *dlci) | |||
| 2174 | 2173 | pr_debug("DLCI %d goes open.\n", dlci->addr); | |
| 2175 | 2174 | /* Send current modem state */ | |
| 2176 | 2175 | if (dlci->addr) { | |
| 2177 | - | gsm_modem_send_initial_msc(dlci); | |
| 2176 | + | gsm_modem_update(dlci, 0, false); | |
| 2178 | 2177 | } else { | |
| 2179 | 2178 | /* Start keep-alive control */ | |
| 2180 | 2179 | gsm->ka_num = 0; | |
| @@ -4136,9 +4135,10 @@ static void gsm_modem_upd_via_data(struct gsm_dlci *dlci, u8 brk) | |||
| 4136 | 4135 | * gsm_modem_upd_via_msc - send modem bits via control frame | |
| 4137 | 4136 | * @dlci: channel | |
| 4138 | 4137 | * @brk: break signal | |
| 4138 | + | * @wait: wait for the MSC command | |
| 4139 | 4139 | */ | |
| 4140 | 4140 | ||
| 4141 | - | static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk) | |
| 4141 | + | static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk, bool wait) | |
| 4142 | 4142 | { | |
| 4143 | 4143 | u8 modembits[3]; | |
| 4144 | 4144 | struct gsm_control *ctrl; | |
| @@ -4155,41 +4155,22 @@ static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk) | |||
| 4155 | 4155 | modembits[2] = (brk << 4) | 2 | EA; /* Length, Break, EA */ | |
| 4156 | 4156 | len++; | |
| 4157 | 4157 | } | |
| 4158 | + | if (!wait) | |
| 4159 | + | return gsm_control_command(dlci->gsm, CMD_MSC, modembits, len); | |
| 4158 | 4160 | ctrl = gsm_control_send(dlci->gsm, CMD_MSC, modembits, len); | |
| 4159 | 4161 | if (ctrl == NULL) | |
| 4160 | 4162 | return -ENOMEM; | |
| 4161 | 4163 | return gsm_control_wait(dlci->gsm, ctrl); | |
| 4162 | 4164 | } | |
| 4163 | 4165 | ||
| 4164 | - | /** | |
| 4165 | - | * gsm_modem_send_initial_msc - Send initial modem status message | |
| 4166 | - | * | |
| 4167 | - | * @dlci: channel | |
| 4168 | - | * | |
| 4169 | - | * Send an initial MSC message after DLCI open to set the initial | |
| 4170 | - | * modem status lines. This is only done for basic mode. | |
| 4171 | - | * Does not wait for a response as we cannot block the input queue | |
| 4172 | - | * processing. | |
| 4173 | - | */ | |
| 4174 | - | static int gsm_modem_send_initial_msc(struct gsm_dlci *dlci) | |
| 4175 | - | { | |
| 4176 | - | u8 modembits[2]; | |
| 4177 | - | ||
| 4178 | - | if (dlci->adaption != 1 || dlci->gsm->encoding != GSM_BASIC_OPT) | |
| 4179 | - | return 0; | |
| 4180 | - | ||
| 4181 | - | modembits[0] = (dlci->addr << 2) | 2 | EA; /* DLCI, Valid, EA */ | |
| 4182 | - | modembits[1] = (gsm_encode_modem(dlci) << 1) | EA; | |
| 4183 | - | return gsm_control_command(dlci->gsm, CMD_MSC, (const u8 *)&modembits, 2); | |
| 4184 | - | } | |
| 4185 | - | ||
| 4186 | 4166 | /** | |
| 4187 | 4167 | * gsm_modem_update - send modem status line state | |
| 4188 | 4168 | * @dlci: channel | |
| 4189 | 4169 | * @brk: break signal | |
| 4170 | + | * @wait: wait for the MSC command | |
| 4190 | 4171 | */ | |
| 4191 | 4172 | ||
| 4192 | - | static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk) | |
| 4173 | + | static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk, bool wait) | |
| 4193 | 4174 | { | |
| 4194 | 4175 | if (dlci->gsm->dead) | |
| 4195 | 4176 | return -EL2HLT; | |
| @@ -4199,7 +4180,7 @@ static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk) | |||
| 4199 | 4180 | return 0; | |
| 4200 | 4181 | } else if (dlci->gsm->encoding == GSM_BASIC_OPT) { | |
| 4201 | 4182 | /* Send as MSC control message. */ | |
| 4202 | - | return gsm_modem_upd_via_msc(dlci, brk); | |
| 4183 | + | return gsm_modem_upd_via_msc(dlci, brk, wait); | |
| 4203 | 4184 | } | |
| 4204 | 4185 | ||
| 4205 | 4186 | /* Modem status lines are not supported. */ | |
| @@ -4265,7 +4246,7 @@ static void gsm_dtr_rts(struct tty_port *port, bool active) | |||
| 4265 | 4246 | modem_tx &= ~(TIOCM_DTR | TIOCM_RTS); | |
| 4266 | 4247 | if (modem_tx != dlci->modem_tx) { | |
| 4267 | 4248 | dlci->modem_tx = modem_tx; | |
| 4268 | - | gsm_modem_update(dlci, 0); | |
| 4249 | + | gsm_modem_update(dlci, 0, true); | |
| 4269 | 4250 | } | |
| 4270 | 4251 | } | |
| 4271 | 4252 | ||
| @@ -4471,7 +4452,7 @@ static int gsmtty_tiocmset(struct tty_struct *tty, | |||
| 4471 | 4452 | ||
| 4472 | 4453 | if (modem_tx != dlci->modem_tx) { | |
| 4473 | 4454 | dlci->modem_tx = modem_tx; | |
| 4474 | - | return gsm_modem_update(dlci, 0); | |
| 4455 | + | return gsm_modem_update(dlci, 0, true); | |
| 4475 | 4456 | } | |
| 4476 | 4457 | return 0; | |
| 4477 | 4458 | } | |
| @@ -4553,7 +4534,7 @@ static void gsmtty_throttle(struct tty_struct *tty) | |||
| 4553 | 4534 | dlci->modem_tx &= ~TIOCM_RTS; | |
| 4554 | 4535 | dlci->throttled = true; | |
| 4555 | 4536 | /* Send an MSC with RTS cleared */ | |
| 4556 | - | gsm_modem_update(dlci, 0); | |
| 4537 | + | gsm_modem_update(dlci, 0, true); | |
| 4557 | 4538 | } | |
| 4558 | 4539 | ||
| 4559 | 4540 | static void gsmtty_unthrottle(struct tty_struct *tty) | |
| @@ -4565,7 +4546,7 @@ static void gsmtty_unthrottle(struct tty_struct *tty) | |||
| 4565 | 4546 | dlci->modem_tx |= TIOCM_RTS; | |
| 4566 | 4547 | dlci->throttled = false; | |
| 4567 | 4548 | /* Send an MSC with RTS set */ | |
| 4568 | - | gsm_modem_update(dlci, 0); | |
| 4549 | + | gsm_modem_update(dlci, 0, true); | |
| 4569 | 4550 | } | |
| 4570 | 4551 | ||
| 4571 | 4552 | static int gsmtty_break_ctl(struct tty_struct *tty, int state) | |
| @@ -4583,7 +4564,7 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state) | |||
| 4583 | 4564 | if (encode > 0x0F) | |
| 4584 | 4565 | encode = 0x0F; /* Best effort */ | |
| 4585 | 4566 | } | |
| 4586 | - | return gsm_modem_update(dlci, encode); | |
| 4567 | + | return gsm_modem_update(dlci, encode, true); | |
| 4587 | 4568 | } | |
| 4588 | 4569 | ||
| 4589 | 4570 | static void gsmtty_cleanup(struct tty_struct *tty) | |
modified drivers/tty/serial/8250/8250_bcm7271.c
| @@ -1121,8 +1121,8 @@ static void brcmuart_remove(struct platform_device *pdev) | |||
| 1121 | 1121 | struct brcmuart_priv *priv = platform_get_drvdata(pdev); | |
| 1122 | 1122 | ||
| 1123 | 1123 | debugfs_remove_recursive(priv->debugfs_dir); | |
| 1124 | - | hrtimer_cancel(&priv->hrt); | |
| 1125 | 1124 | serial8250_unregister_port(priv->line); | |
| 1125 | + | hrtimer_cancel(&priv->hrt); | |
| 1126 | 1126 | brcmuart_free_bufs(&pdev->dev, priv); | |
| 1127 | 1127 | if (priv->dma_enabled) | |
| 1128 | 1128 | brcmuart_arbitration(priv, 0); | |
modified drivers/tty/serial/8250/8250_omap.c
| @@ -711,12 +711,6 @@ static int omap_8250_startup(struct uart_port *port) | |||
| 711 | 711 | struct uart_8250_dma *dma = &priv->omap8250_dma; | |
| 712 | 712 | int ret; | |
| 713 | 713 | ||
| 714 | - | if (priv->wakeirq) { | |
| 715 | - | ret = dev_pm_set_dedicated_wake_irq(port->dev, priv->wakeirq); | |
| 716 | - | if (ret) | |
| 717 | - | return ret; | |
| 718 | - | } | |
| 719 | - | ||
| 720 | 714 | #ifdef CONFIG_PM | |
| 721 | 715 | up->capabilities |= UART_CAP_RPM; | |
| 722 | 716 | #endif | |
| @@ -787,7 +781,6 @@ static void omap_8250_shutdown(struct uart_port *port) | |||
| 787 | 781 | } | |
| 788 | 782 | ||
| 789 | 783 | disable_irq_nosync(port->irq); | |
| 790 | - | dev_pm_clear_wake_irq(port->dev); | |
| 791 | 784 | ||
| 792 | 785 | serial8250_release_dma(up); | |
| 793 | 786 | up->dma = NULL; | |
| @@ -1588,6 +1581,12 @@ static int omap8250_probe(struct platform_device *pdev) | |||
| 1588 | 1581 | ||
| 1589 | 1582 | priv->wakeirq = irq_of_parse_and_map(np, 1); | |
| 1590 | 1583 | ||
| 1584 | + | if (priv->wakeirq) { | |
| 1585 | + | ret = dev_pm_set_dedicated_wake_irq(&pdev->dev, priv->wakeirq); | |
| 1586 | + | if (ret) | |
| 1587 | + | goto err; | |
| 1588 | + | } | |
| 1589 | + | ||
| 1591 | 1590 | ret = serial8250_register_8250_port(&up); | |
| 1592 | 1591 | if (ret < 0) { | |
| 1593 | 1592 | dev_err(&pdev->dev, "unable to register 8250 port\n"); | |
| @@ -1603,6 +1602,7 @@ static int omap8250_probe(struct platform_device *pdev) | |||
| 1603 | 1602 | ||
| 1604 | 1603 | return 0; | |
| 1605 | 1604 | err: | |
| 1605 | + | dev_pm_clear_wake_irq(&pdev->dev); | |
| 1606 | 1606 | pm_runtime_dont_use_autosuspend(&pdev->dev); | |
| 1607 | 1607 | pm_runtime_put_sync(&pdev->dev); | |
| 1608 | 1608 | flush_work(&priv->qos_work); | |
| @@ -1625,6 +1625,7 @@ static void omap8250_remove(struct platform_device *pdev) | |||
| 1625 | 1625 | omap_8250_shutdown(&up->port); | |
| 1626 | 1626 | serial8250_unregister_port(priv->line); | |
| 1627 | 1627 | priv->line = -ENODEV; | |
| 1628 | + | dev_pm_clear_wake_irq(&pdev->dev); | |
| 1628 | 1629 | pm_runtime_dont_use_autosuspend(&pdev->dev); | |
| 1629 | 1630 | pm_runtime_put_sync(&pdev->dev); | |
| 1630 | 1631 | flush_work(&priv->qos_work); | |
modified drivers/tty/serial/8250/8250_port.c
| @@ -3417,8 +3417,11 @@ static void __serial8250_console_write(struct uart_8250_port *up, | |||
| 3417 | 3417 | * If the console printer did not fully output the previous line, it | |
| 3418 | 3418 | * must have been handed or taken over. Insert a newline in order to | |
| 3419 | 3419 | * maintain clean output. | |
| 3420 | + | * | |
| 3421 | + | * Braille consoles are an exception. The serial port is not used | |
| 3422 | + | * for printk(). The driver is supposed to write exactly what it gets. | |
| 3420 | 3423 | */ | |
| 3421 | - | if (!up->console_line_ended) { | |
| 3424 | + | if (unlikely(!up->console_line_ended && !nbcon_write_context_is_braille(wctxt))) { | |
| 3422 | 3425 | if (use_fifo) | |
| 3423 | 3426 | __serial8250_console_fifo_write(up, wctxt, "\n", 1); | |
| 3424 | 3427 | else | |
| @@ -3597,7 +3600,7 @@ int serial8250_console_setup(struct uart_port *port, char *options, bool probe) | |||
| 3597 | 3600 | ||
| 3598 | 3601 | up->console_line_ended = true; | |
| 3599 | 3602 | up->console_msr_work_allow = true; | |
| 3600 | - | init_irq_work(&up->console_msr_work, console_msr_handler); | |
| 3603 | + | up->console_msr_work = IRQ_WORK_INIT_LAZY(console_msr_handler); | |
| 3601 | 3604 | ||
| 3602 | 3605 | if (options) | |
| 3603 | 3606 | uart_parse_options(options, &baud, &parity, &bits, &flow); | |
modified drivers/tty/serial/amba-pl011.c
| @@ -2656,7 +2656,7 @@ pl011_console_write_atomic(struct console *co, struct nbcon_write_context *wctxt | |||
| 2656 | 2656 | uap, REG_CR); | |
| 2657 | 2657 | } | |
| 2658 | 2658 | ||
| 2659 | - | if (!uap->console_line_ended) | |
| 2659 | + | if (unlikely(!uap->console_line_ended && !nbcon_is_braille(co))) | |
| 2660 | 2660 | uart_console_write(&uap->port, "\n", 1, pl011_console_putchar); | |
| 2661 | 2661 | uart_console_write(&uap->port, wctxt->outbuf, wctxt->len, pl011_console_putchar); | |
| 2662 | 2662 | ||
modified drivers/tty/serial/imx.c
| @@ -2136,7 +2136,7 @@ static void imx_uart_console_write_atomic(struct console *co, | |||
| 2136 | 2136 | imx_uart_writel(sport, ucr1, UCR1); | |
| 2137 | 2137 | imx_uart_writel(sport, old_ucr.ucr2 | UCR2_TXEN, UCR2); | |
| 2138 | 2138 | ||
| 2139 | - | if (!sport->last_putchar_was_newline) | |
| 2139 | + | if (unlikely(!sport->last_putchar_was_newline && !nbcon_is_braille(co))) | |
| 2140 | 2140 | uart_console_write(port, "\n", 1, imx_uart_console_putchar); | |
| 2141 | 2141 | uart_console_write(port, wctxt->outbuf, wctxt->len, | |
| 2142 | 2142 | imx_uart_console_putchar); | |
modified drivers/tty/serial/kgdboc.c
| @@ -188,6 +188,11 @@ static void cleanup_kgdboc(void) | |||
| 188 | 188 | ||
| 189 | 189 | kgdboc_unregister_kbd(); | |
| 190 | 190 | kgdb_unregister_io_module(&kgdboc_io_ops); | |
| 191 | + | ||
| 192 | + | if (kgdb_tty_driver) { | |
| 193 | + | tty_driver_kref_put(kgdb_tty_driver); | |
| 194 | + | kgdb_tty_driver = NULL; | |
| 195 | + | } | |
| 191 | 196 | } | |
| 192 | 197 | ||
| 193 | 198 | static int configure_kgdboc(void) | |
| @@ -254,6 +259,10 @@ do_register: | |||
| 254 | 259 | ||
| 255 | 260 | noconfig: | |
| 256 | 261 | kgdboc_unregister_kbd(); | |
| 262 | + | if (kgdb_tty_driver) { | |
| 263 | + | tty_driver_kref_put(kgdb_tty_driver); | |
| 264 | + | kgdb_tty_driver = NULL; | |
| 265 | + | } | |
| 257 | 266 | configured = 0; | |
| 258 | 267 | ||
| 259 | 268 | return err; | |
modified drivers/tty/serial/ma35d1_serial.c
| @@ -728,7 +728,7 @@ static int ma35d1serial_probe(struct platform_device *pdev) | |||
| 728 | 728 | ||
| 729 | 729 | ret = clk_prepare_enable(up->clk); | |
| 730 | 730 | if (ret) | |
| 731 | - | goto err_iounmap; | |
| 731 | + | goto err_put_clk; | |
| 732 | 732 | ||
| 733 | 733 | if (up->port.line != 0) | |
| 734 | 734 | up->port.uartclk = clk_get_rate(up->clk); | |
| @@ -755,6 +755,9 @@ err_free_irq: | |||
| 755 | 755 | err_clk_disable: | |
| 756 | 756 | clk_disable_unprepare(up->clk); | |
| 757 | 757 | ||
| 758 | + | err_put_clk: | |
| 759 | + | clk_put(up->clk); | |
| 760 | + | ||
| 758 | 761 | err_iounmap: | |
| 759 | 762 | iounmap(up->port.membase); | |
| 760 | 763 | return ret; | |
| @@ -770,6 +773,7 @@ static void ma35d1serial_remove(struct platform_device *dev) | |||
| 770 | 773 | ||
| 771 | 774 | uart_remove_one_port(&ma35d1serial_reg, port); | |
| 772 | 775 | clk_disable_unprepare(up->clk); | |
| 776 | + | clk_put(up->clk); | |
| 773 | 777 | } | |
| 774 | 778 | ||
| 775 | 779 | static int ma35d1serial_suspend(struct platform_device *dev, pm_message_t state) | |
modified drivers/tty/serial/max3100.c
| @@ -535,11 +535,11 @@ static void max3100_shutdown(struct uart_port *port) | |||
| 535 | 535 | timer_delete_sync(&s->timer); | |
| 536 | 536 | ||
| 537 | 537 | if (s->workqueue) { | |
| 538 | + | free_irq(port->irq, s); | |
| 539 | + | cancel_work_sync(&s->work); | |
| 538 | 540 | destroy_workqueue(s->workqueue); | |
| 539 | 541 | s->workqueue = NULL; | |
| 540 | 542 | } | |
| 541 | - | if (port->irq) | |
| 542 | - | free_irq(port->irq, s); | |
| 543 | 543 | ||
| 544 | 544 | /* set shutdown mode to save power */ | |
| 545 | 545 | max3100_sr(s, MAX3100_WC | MAX3100_SHDN, &rx); | |
| @@ -753,6 +753,15 @@ static void max3100_remove(struct spi_device *spi) | |||
| 753 | 753 | if (max3100s[i] == s) { | |
| 754 | 754 | dev_dbg(&spi->dev, "%s: removing port %d\n", __func__, i); | |
| 755 | 755 | uart_remove_one_port(&max3100_uart_driver, &max3100s[i]->port); | |
| 756 | + | ||
| 757 | + | s->force_end_work = 1; | |
| 758 | + | timer_shutdown_sync(&s->timer); | |
| 759 | + | if (s->workqueue) { | |
| 760 | + | free_irq(s->port.irq, s); | |
| 761 | + | cancel_work_sync(&s->work); | |
| 762 | + | destroy_workqueue(s->workqueue); | |
| 763 | + | s->workqueue = NULL; | |
| 764 | + | } | |
| 756 | 765 | kfree(max3100s[i]); | |
| 757 | 766 | max3100s[i] = NULL; | |
| 758 | 767 | break; | |
modified drivers/tty/serial/mpc52xx_uart.c
| @@ -634,6 +634,9 @@ static void __exit mpc512x_psc_fifoc_uninit(void) | |||
| 634 | 634 | } | |
| 635 | 635 | } | |
| 636 | 636 | ||
| 637 | + | static struct clk *psc_mclk_clk[MPC52xx_PSC_MAXNUM]; | |
| 638 | + | static struct clk *psc_ipg_clk[MPC52xx_PSC_MAXNUM]; | |
| 639 | + | ||
| 637 | 640 | /* 512x specific interrupt handler. The caller holds the port lock */ | |
| 638 | 641 | static irqreturn_t mpc512x_psc_handle_irq(struct uart_port *port) | |
| 639 | 642 | { | |
| @@ -654,9 +657,6 @@ static irqreturn_t mpc512x_psc_handle_irq(struct uart_port *port) | |||
| 654 | 657 | return IRQ_NONE; | |
| 655 | 658 | } | |
| 656 | 659 | ||
| 657 | - | static struct clk *psc_mclk_clk[MPC52xx_PSC_MAXNUM]; | |
| 658 | - | static struct clk *psc_ipg_clk[MPC52xx_PSC_MAXNUM]; | |
| 659 | - | ||
| 660 | 660 | /* called from within the .request_port() callback (allocation) */ | |
| 661 | 661 | static int mpc512x_psc_alloc_clock(struct uart_port *port) | |
| 662 | 662 | { | |
modified drivers/tty/serial/qcom_geni_serial.c
| @@ -171,7 +171,6 @@ static void qcom_geni_serial_cancel_tx_cmd(struct uart_port *uport); | |||
| 171 | 171 | static int qcom_geni_serial_port_setup(struct uart_port *uport); | |
| 172 | 172 | static void qcom_geni_serial_start_tx_fifo(struct uart_port *uport); | |
| 173 | 173 | static void qcom_geni_serial_resume_tx(struct uart_port *uport); | |
| 174 | - | static void qcom_geni_serial_poll_rx_fifo_locked(struct uart_port *uport); | |
| 175 | 174 | ||
| 176 | 175 | static inline struct qcom_geni_serial_port *to_dev_port(struct uart_port *uport) | |
| 177 | 176 | { | |
| @@ -467,6 +466,102 @@ static int qcom_geni_serial_poll_init(struct uart_port *uport) | |||
| 467 | 466 | #endif | |
| 468 | 467 | ||
| 469 | 468 | #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE | |
| 469 | + | static void handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) | |
| 470 | + | { | |
| 471 | + | u32 i; | |
| 472 | + | unsigned char buf[sizeof(u32)]; | |
| 473 | + | struct tty_port *tport; | |
| 474 | + | struct qcom_geni_serial_port *port = to_dev_port(uport); | |
| 475 | + | ||
| 476 | + | tport = &uport->state->port; | |
| 477 | + | for (i = 0; i < bytes; ) { | |
| 478 | + | int c; | |
| 479 | + | int chunk = min_t(int, bytes - i, BYTES_PER_FIFO_WORD); | |
| 480 | + | ||
| 481 | + | ioread32_rep(uport->membase + SE_GENI_RX_FIFOn, buf, 1); | |
| 482 | + | i += chunk; | |
| 483 | + | if (drop) | |
| 484 | + | continue; | |
| 485 | + | ||
| 486 | + | for (c = 0; c < chunk; c++) { | |
| 487 | + | int sysrq; | |
| 488 | + | ||
| 489 | + | uport->icount.rx++; | |
| 490 | + | if (port->brk && buf[c] == 0) { | |
| 491 | + | port->brk = false; | |
| 492 | + | if (uart_handle_break(uport)) | |
| 493 | + | continue; | |
| 494 | + | } | |
| 495 | + | ||
| 496 | + | sysrq = uart_prepare_sysrq_char(uport, buf[c]); | |
| 497 | + | ||
| 498 | + | if (!sysrq) | |
| 499 | + | tty_insert_flip_char(tport, buf[c], TTY_NORMAL); | |
| 500 | + | } | |
| 501 | + | } | |
| 502 | + | if (!drop) | |
| 503 | + | tty_flip_buffer_push(tport); | |
| 504 | + | } | |
| 505 | + | #else | |
| 506 | + | static void handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) | |
| 507 | + | { | |
| 508 | + | ||
| 509 | + | } | |
| 510 | + | #endif | |
| 511 | + | ||
| 512 | + | static void qcom_geni_serial_handle_rx_fifo(struct uart_port *uport, bool drop) | |
| 513 | + | { | |
| 514 | + | u32 status; | |
| 515 | + | u32 word_cnt; | |
| 516 | + | u32 last_word_byte_cnt; | |
| 517 | + | u32 last_word_partial; | |
| 518 | + | u32 total_bytes; | |
| 519 | + | ||
| 520 | + | status = readl(uport->membase + SE_GENI_RX_FIFO_STATUS); | |
| 521 | + | word_cnt = status & RX_FIFO_WC_MSK; | |
| 522 | + | last_word_partial = status & RX_LAST; | |
| 523 | + | last_word_byte_cnt = (status & RX_LAST_BYTE_VALID_MSK) >> | |
| 524 | + | RX_LAST_BYTE_VALID_SHFT; | |
| 525 | + | ||
| 526 | + | if (!word_cnt) | |
| 527 | + | return; | |
| 528 | + | total_bytes = BYTES_PER_FIFO_WORD * (word_cnt - 1); | |
| 529 | + | if (last_word_partial && last_word_byte_cnt) | |
| 530 | + | total_bytes += last_word_byte_cnt; | |
| 531 | + | else | |
| 532 | + | total_bytes += BYTES_PER_FIFO_WORD; | |
| 533 | + | handle_rx_console(uport, total_bytes, drop); | |
| 534 | + | } | |
| 535 | + | ||
| 536 | + | #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE | |
| 537 | + | /* Caller holds the UART port lock. */ | |
| 538 | + | static void qcom_geni_serial_poll_rx_fifo_locked(struct uart_port *uport) | |
| 539 | + | { | |
| 540 | + | struct qcom_geni_serial_port *port = to_dev_port(uport); | |
| 541 | + | struct tty_port *tport = &uport->state->port; | |
| 542 | + | u32 s_irq_status; | |
| 543 | + | bool drop_rx = false; | |
| 544 | + | ||
| 545 | + | s_irq_status = readl(uport->membase + SE_GENI_S_IRQ_STATUS); | |
| 546 | + | writel(s_irq_status, uport->membase + SE_GENI_S_IRQ_CLEAR); | |
| 547 | + | ||
| 548 | + | if (s_irq_status & S_RX_FIFO_WR_ERR_EN) { | |
| 549 | + | uport->icount.overrun++; | |
| 550 | + | tty_insert_flip_char(tport, 0, TTY_OVERRUN); | |
| 551 | + | } | |
| 552 | + | ||
| 553 | + | if (s_irq_status & (S_GP_IRQ_0_EN | S_GP_IRQ_1_EN)) { | |
| 554 | + | if (s_irq_status & S_GP_IRQ_0_EN) | |
| 555 | + | uport->icount.parity++; | |
| 556 | + | drop_rx = true; | |
| 557 | + | } else if (s_irq_status & (S_GP_IRQ_2_EN | S_GP_IRQ_3_EN)) { | |
| 558 | + | uport->icount.brk++; | |
| 559 | + | port->brk = true; | |
| 560 | + | } | |
| 561 | + | ||
| 562 | + | qcom_geni_serial_handle_rx_fifo(uport, drop_rx); | |
| 563 | + | } | |
| 564 | + | ||
| 470 | 565 | static void qcom_geni_serial_drain_fifo(struct uart_port *uport) | |
| 471 | 566 | { | |
| 472 | 567 | struct qcom_geni_serial_port *port = to_dev_port(uport); | |
| @@ -676,47 +771,6 @@ static void qcom_geni_serial_console_device_unlock(struct console *co, | |||
| 676 | 771 | #endif | |
| 677 | 772 | } | |
| 678 | 773 | ||
| 679 | - | static void handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) | |
| 680 | - | { | |
| 681 | - | u32 i; | |
| 682 | - | unsigned char buf[sizeof(u32)]; | |
| 683 | - | struct tty_port *tport; | |
| 684 | - | struct qcom_geni_serial_port *port = to_dev_port(uport); | |
| 685 | - | ||
| 686 | - | tport = &uport->state->port; | |
| 687 | - | for (i = 0; i < bytes; ) { | |
| 688 | - | int c; | |
| 689 | - | int chunk = min_t(int, bytes - i, BYTES_PER_FIFO_WORD); | |
| 690 | - | ||
| 691 | - | ioread32_rep(uport->membase + SE_GENI_RX_FIFOn, buf, 1); | |
| 692 | - | i += chunk; | |
| 693 | - | if (drop) | |
| 694 | - | continue; | |
| 695 | - | ||
| 696 | - | for (c = 0; c < chunk; c++) { | |
| 697 | - | int sysrq; | |
| 698 | - | ||
| 699 | - | uport->icount.rx++; | |
| 700 | - | if (port->brk && buf[c] == 0) { | |
| 701 | - | port->brk = false; | |
| 702 | - | if (uart_handle_break(uport)) | |
| 703 | - | continue; | |
| 704 | - | } | |
| 705 | - | ||
| 706 | - | sysrq = uart_prepare_sysrq_char(uport, buf[c]); | |
| 707 | - | ||
| 708 | - | if (!sysrq) | |
| 709 | - | tty_insert_flip_char(tport, buf[c], TTY_NORMAL); | |
| 710 | - | } | |
| 711 | - | } | |
| 712 | - | if (!drop) | |
| 713 | - | tty_flip_buffer_push(tport); | |
| 714 | - | } | |
| 715 | - | #else | |
| 716 | - | static void handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) | |
| 717 | - | { | |
| 718 | - | ||
| 719 | - | } | |
| 720 | 774 | #endif /* CONFIG_SERIAL_QCOM_GENI_CONSOLE */ | |
| 721 | 775 | ||
| 722 | 776 | static void handle_rx_uart(struct uart_port *uport, u32 bytes) | |
| @@ -890,58 +944,6 @@ static void qcom_geni_serial_cancel_tx_cmd(struct uart_port *uport) | |||
| 890 | 944 | port->tx_queued = 0; | |
| 891 | 945 | } | |
| 892 | 946 | ||
| 893 | - | static void qcom_geni_serial_handle_rx_fifo(struct uart_port *uport, bool drop) | |
| 894 | - | { | |
| 895 | - | u32 status; | |
| 896 | - | u32 word_cnt; | |
| 897 | - | u32 last_word_byte_cnt; | |
| 898 | - | u32 last_word_partial; | |
| 899 | - | u32 total_bytes; | |
| 900 | - | ||
| 901 | - | status = readl(uport->membase + SE_GENI_RX_FIFO_STATUS); | |
| 902 | - | word_cnt = status & RX_FIFO_WC_MSK; | |
| 903 | - | last_word_partial = status & RX_LAST; | |
| 904 | - | last_word_byte_cnt = (status & RX_LAST_BYTE_VALID_MSK) >> | |
| 905 | - | RX_LAST_BYTE_VALID_SHFT; | |
| 906 | - | ||
| 907 | - | if (!word_cnt) | |
| 908 | - | return; | |
| 909 | - | total_bytes = BYTES_PER_FIFO_WORD * (word_cnt - 1); | |
| 910 | - | if (last_word_partial && last_word_byte_cnt) | |
| 911 | - | total_bytes += last_word_byte_cnt; | |
| 912 | - | else | |
| 913 | - | total_bytes += BYTES_PER_FIFO_WORD; | |
| 914 | - | handle_rx_console(uport, total_bytes, drop); | |
| 915 | - | } | |
| 916 | - | ||
| 917 | - | /* Caller holds the UART port lock. */ | |
| 918 | - | static void qcom_geni_serial_poll_rx_fifo_locked(struct uart_port *uport) | |
| 919 | - | { | |
| 920 | - | struct qcom_geni_serial_port *port = to_dev_port(uport); | |
| 921 | - | struct tty_port *tport = &uport->state->port; | |
| 922 | - | u32 s_irq_status; | |
| 923 | - | bool drop_rx = false; | |
| 924 | - | ||
| 925 | - | s_irq_status = readl(uport->membase + SE_GENI_S_IRQ_STATUS); | |
| 926 | - | writel(s_irq_status, uport->membase + SE_GENI_S_IRQ_CLEAR); | |
| 927 | - | ||
| 928 | - | if (s_irq_status & S_RX_FIFO_WR_ERR_EN) { | |
| 929 | - | uport->icount.overrun++; | |
| 930 | - | tty_insert_flip_char(tport, 0, TTY_OVERRUN); | |
| 931 | - | } | |
| 932 | - | ||
| 933 | - | if (s_irq_status & (S_GP_IRQ_0_EN | S_GP_IRQ_1_EN)) { | |
| 934 | - | if (s_irq_status & S_GP_IRQ_0_EN) | |
| 935 | - | uport->icount.parity++; | |
| 936 | - | drop_rx = true; | |
| 937 | - | } else if (s_irq_status & (S_GP_IRQ_2_EN | S_GP_IRQ_3_EN)) { | |
| 938 | - | uport->icount.brk++; | |
| 939 | - | port->brk = true; | |
| 940 | - | } | |
| 941 | - | ||
| 942 | - | qcom_geni_serial_handle_rx_fifo(uport, drop_rx); | |
| 943 | - | } | |
| 944 | - | ||
| 945 | 947 | static void qcom_geni_serial_stop_rx_fifo(struct uart_port *uport) | |
| 946 | 948 | { | |
| 947 | 949 | u32 irq_en; | |
| @@ -1482,9 +1484,8 @@ static int geni_serial_set_rate(struct geni_se *se, unsigned long baud) | |||
| 1482 | 1484 | * Bump up BW vote on CPU and CORE path as driver supports FIFO mode | |
| 1483 | 1485 | * only. | |
| 1484 | 1486 | */ | |
| 1485 | - | avg_bw_core = (baud > 115200) ? Bps_to_icc(CORE_2X_50_MHZ) | |
| 1486 | - | : GENI_DEFAULT_BW; | |
| 1487 | - | port->se.icc_paths[GENI_TO_CORE].avg_bw = avg_bw_core; | |
| 1487 | + | avg_bw_core = baud > 115200 ? CORE_2X_50_MHZ : CORE_2X_19_2_MHZ; | |
| 1488 | + | port->se.icc_paths[GENI_TO_CORE].avg_bw = Bps_to_icc(avg_bw_core); | |
| 1488 | 1489 | port->se.icc_paths[CPU_TO_GENI].avg_bw = Bps_to_icc(baud); | |
| 1489 | 1490 | geni_icc_set_bw(&port->se); | |
| 1490 | 1491 | ||
| @@ -1625,16 +1626,37 @@ static int qcom_geni_console_setup(struct console *co, char *options) | |||
| 1625 | 1626 | if (unlikely(!uport->membase)) | |
| 1626 | 1627 | return -ENXIO; | |
| 1627 | 1628 | ||
| 1629 | + | ret = pm_runtime_resume_and_get(uport->dev); | |
| 1630 | + | if (ret < 0) | |
| 1631 | + | return ret; | |
| 1632 | + | ||
| 1628 | 1633 | if (!port->setup) { | |
| 1629 | 1634 | ret = qcom_geni_serial_port_setup(uport); | |
| 1630 | - | if (ret) | |
| 1635 | + | if (ret) { | |
| 1636 | + | pm_runtime_put_sync(uport->dev); | |
| 1631 | 1637 | return ret; | |
| 1638 | + | } | |
| 1632 | 1639 | } | |
| 1633 | 1640 | ||
| 1634 | 1641 | if (options) | |
| 1635 | 1642 | uart_parse_options(options, &baud, &parity, &bits, &flow); | |
| 1636 | 1643 | ||
| 1637 | - | return uart_set_options(uport, co, baud, parity, bits, flow); | |
| 1644 | + | ret = uart_set_options(uport, co, baud, parity, bits, flow); | |
| 1645 | + | if (ret) | |
| 1646 | + | pm_runtime_put_sync(uport->dev); | |
| 1647 | + | ||
| 1648 | + | return ret; | |
| 1649 | + | } | |
| 1650 | + | ||
| 1651 | + | static int qcom_geni_console_exit(struct console *co) | |
| 1652 | + | { | |
| 1653 | + | struct qcom_geni_serial_port *port; | |
| 1654 | + | ||
| 1655 | + | port = get_port_from_line(co->index, true, NULL); | |
| 1656 | + | if (IS_ERR(port)) | |
| 1657 | + | return PTR_ERR(port); | |
| 1658 | + | ||
| 1659 | + | return pm_runtime_put_sync(port->uport.dev); | |
| 1638 | 1660 | } | |
| 1639 | 1661 | ||
| 1640 | 1662 | static void qcom_geni_serial_earlycon_write(struct console *con, | |
| @@ -1751,6 +1773,7 @@ static struct console cons_ops = { | |||
| 1751 | 1773 | .device_unlock = qcom_geni_serial_console_device_unlock, | |
| 1752 | 1774 | .device = uart_console_device, | |
| 1753 | 1775 | .setup = qcom_geni_console_setup, | |
| 1776 | + | .exit = qcom_geni_console_exit, | |
| 1754 | 1777 | .flags = CON_PRINTBUFFER | CON_NBCON, | |
| 1755 | 1778 | .index = -1, | |
| 1756 | 1779 | .data = &qcom_geni_console_driver, | |
| @@ -2099,9 +2122,11 @@ static int qcom_geni_serial_resume(struct device *dev) | |||
| 2099 | 2122 | struct uart_port *uport = &port->uport; | |
| 2100 | 2123 | struct qcom_geni_private_data *private_data = uport->private_data; | |
| 2101 | 2124 | ||
| 2102 | - | ret = pm_runtime_force_resume(dev); | |
| 2103 | - | if (ret) | |
| 2104 | - | return ret; | |
| 2125 | + | if (console_suspend_enabled || !uart_console(uport)) { | |
| 2126 | + | ret = pm_runtime_force_resume(dev); | |
| 2127 | + | if (ret) | |
| 2128 | + | return ret; | |
| 2129 | + | } | |
| 2105 | 2130 | ||
| 2106 | 2131 | ret = uart_resume_port(private_data->drv, uport); | |
| 2107 | 2132 | if (uart_console(uport)) { | |
modified drivers/tty/serial/sc16is7xx.c
| @@ -216,6 +216,8 @@ | |||
| 216 | 216 | #define SC16IS7XX_TLR_TX_TRIGGER(words) ((((words) / 4) & 0x0f) << 0) | |
| 217 | 217 | #define SC16IS7XX_TLR_RX_TRIGGER(words) ((((words) / 4) & 0x0f) << 4) | |
| 218 | 218 | ||
| 219 | + | #define SC16IS7XX_TX_TRIGGER_LEVEL 32 | |
| 220 | + | ||
| 219 | 221 | /* IOControl register bits (Only 75x/76x) */ | |
| 220 | 222 | #define SC16IS7XX_IOCONTROL_LATCH_BIT BIT(0) /* Enable input latching */ | |
| 221 | 223 | #define SC16IS7XX_IOCONTROL_MODEM_A_BIT BIT(1) /* Enable GPIO[7:4] as modem A pins */ | |
| @@ -647,12 +649,26 @@ static void sc16is7xx_handle_rx(struct uart_port *port, unsigned int rxlen, | |||
| 647 | 649 | tty_flip_buffer_push(&port->state->port); | |
| 648 | 650 | } | |
| 649 | 651 | ||
| 652 | + | static unsigned int sc16is7xx_txlvl(struct uart_port *port) | |
| 653 | + | { | |
| 654 | + | unsigned int txlvl; | |
| 655 | + | ||
| 656 | + | txlvl = sc16is7xx_port_read(port, SC16IS7XX_TXLVL_REG); | |
| 657 | + | if (txlvl > SC16IS7XX_FIFO_SIZE) { | |
| 658 | + | dev_err_ratelimited(port->dev, | |
| 659 | + | "chip reports %u free bytes in TX FIFO, but it only has %u\n", | |
| 660 | + | txlvl, SC16IS7XX_FIFO_SIZE); | |
| 661 | + | return 0; | |
| 662 | + | } | |
| 663 | + | ||
| 664 | + | return txlvl; | |
| 665 | + | } | |
| 666 | + | ||
| 650 | 667 | static void sc16is7xx_handle_tx(struct uart_port *port) | |
| 651 | 668 | { | |
| 652 | 669 | struct tty_port *tport = &port->state->port; | |
| 653 | 670 | unsigned long flags; | |
| 654 | 671 | unsigned int txlen; | |
| 655 | - | unsigned char *tail; | |
| 656 | 672 | ||
| 657 | 673 | if (unlikely(port->x_char)) { | |
| 658 | 674 | sc16is7xx_port_write(port, SC16IS7XX_THR_REG, port->x_char); | |
| @@ -669,17 +685,28 @@ static void sc16is7xx_handle_tx(struct uart_port *port) | |||
| 669 | 685 | } | |
| 670 | 686 | ||
| 671 | 687 | /* Limit to space available in TX FIFO */ | |
| 672 | - | txlen = sc16is7xx_port_read(port, SC16IS7XX_TXLVL_REG); | |
| 673 | - | if (txlen > SC16IS7XX_FIFO_SIZE) { | |
| 674 | - | dev_err_ratelimited(port->dev, | |
| 675 | - | "chip reports %d free bytes in TX fifo, but it only has %d", | |
| 676 | - | txlen, SC16IS7XX_FIFO_SIZE); | |
| 677 | - | txlen = 0; | |
| 678 | - | } | |
| 688 | + | txlen = sc16is7xx_txlvl(port); | |
| 689 | + | ||
| 690 | + | /* Handle circular buffer wrap-around by sending multiple segments */ | |
| 691 | + | while (txlen > 0 && !kfifo_is_empty(&tport->xmit_fifo)) { | |
| 692 | + | unsigned char *tail; | |
| 693 | + | unsigned int to_send; | |
| 694 | + | ||
| 695 | + | to_send = kfifo_out_linear_ptr(&tport->xmit_fifo, &tail, txlen); | |
| 696 | + | if (!to_send) | |
| 697 | + | break; | |
| 679 | 698 | ||
| 680 | - | txlen = kfifo_out_linear_ptr(&tport->xmit_fifo, &tail, txlen); | |
| 681 | - | sc16is7xx_fifo_write(port, tail, txlen); | |
| 682 | - | uart_xmit_advance(port, txlen); | |
| 699 | + | sc16is7xx_fifo_write(port, tail, to_send); | |
| 700 | + | uart_xmit_advance(port, to_send); | |
| 701 | + | ||
| 702 | + | if (kfifo_is_empty(&tport->xmit_fifo)) | |
| 703 | + | break; | |
| 704 | + | ||
| 705 | + | /* Refill below the trigger to enable the next THRI crossing. */ | |
| 706 | + | txlen = sc16is7xx_txlvl(port); | |
| 707 | + | if (txlen < SC16IS7XX_TX_TRIGGER_LEVEL) | |
| 708 | + | break; | |
| 709 | + | } | |
| 683 | 710 | ||
| 684 | 711 | uart_port_lock_irqsave(port, &flags); | |
| 685 | 712 | if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS) | |
| @@ -1130,6 +1157,10 @@ static int sc16is7xx_startup(struct uart_port *port) | |||
| 1130 | 1157 | SC16IS7XX_TCR_RX_RESUME(24) | | |
| 1131 | 1158 | SC16IS7XX_TCR_RX_HALT(48)); | |
| 1132 | 1159 | ||
| 1160 | + | /* Sync hardware and software TX trigger levels */ | |
| 1161 | + | sc16is7xx_port_write(port, SC16IS7XX_TLR_REG, | |
| 1162 | + | SC16IS7XX_TLR_TX_TRIGGER(SC16IS7XX_TX_TRIGGER_LEVEL)); | |
| 1163 | + | ||
| 1133 | 1164 | /* Disable TCR/TLR access */ | |
| 1134 | 1165 | sc16is7xx_port_update(port, SC16IS7XX_MCR_REG, SC16IS7XX_MCR_TCRTLR_BIT, 0); | |
| 1135 | 1166 | ||
modified drivers/tty/serial/serial-tegra.c
| @@ -306,11 +306,19 @@ static void tegra_uart_fifo_reset(struct tegra_uart_port *tup, u8 fcr_bits) | |||
| 306 | 306 | { | |
| 307 | 307 | unsigned long fcr = tup->fcr_shadow; | |
| 308 | 308 | unsigned int lsr, tmout = 10000; | |
| 309 | + | bool clear_tx = !!(fcr_bits & UART_FCR_CLEAR_XMIT); | |
| 309 | 310 | ||
| 310 | 311 | if (tup->rts_active) | |
| 311 | 312 | set_rts(tup, false); | |
| 312 | 313 | ||
| 313 | - | if (tup->cdata->allow_txfifo_reset_fifo_mode) { | |
| 314 | + | /* | |
| 315 | + | * Leaving FIFO mode below is a workaround for a Tegra30 | |
| 316 | + | * restriction on clearing the Tx FIFO while FIFO mode is | |
| 317 | + | * enabled. It empties both FIFOs, so applying it to an | |
| 318 | + | * Rx-only reset would destroy an in-flight transmission. | |
| 319 | + | * Only take that path when the caller asked for CLEAR_XMIT. | |
| 320 | + | */ | |
| 321 | + | if (tup->cdata->allow_txfifo_reset_fifo_mode || !clear_tx) { | |
| 314 | 322 | fcr |= fcr_bits & (UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); | |
| 315 | 323 | tegra_uart_write(tup, fcr, UART_FCR); | |
| 316 | 324 | } else { | |
| @@ -335,9 +343,15 @@ static void tegra_uart_fifo_reset(struct tegra_uart_port *tup, u8 fcr_bits) | |||
| 335 | 343 | */ | |
| 336 | 344 | tegra_uart_wait_cycle_time(tup, 32); | |
| 337 | 345 | ||
| 346 | + | /* | |
| 347 | + | * Only wait for the transmitter to drain when the Tx FIFO was | |
| 348 | + | * part of the reset. For an Rx-only reset it is left intact, | |
| 349 | + | * and waiting for TEMT here would spin for a full frame time. | |
| 350 | + | */ | |
| 338 | 351 | do { | |
| 339 | 352 | lsr = tegra_uart_read(tup, UART_LSR); | |
| 340 | - | if ((lsr & UART_LSR_TEMT) && !(lsr & UART_LSR_DR)) | |
| 353 | + | if ((!clear_tx || (lsr & UART_LSR_TEMT)) && | |
| 354 | + | !(lsr & UART_LSR_DR)) | |
| 341 | 355 | break; | |
| 342 | 356 | udelay(1); | |
| 343 | 357 | } while (--tmout); | |
modified drivers/tty/serial/serial_core.c
| @@ -896,7 +896,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, | |||
| 896 | 896 | upf_t old_flags, new_flags; | |
| 897 | 897 | int retval; | |
| 898 | 898 | ||
| 899 | - | if (!uport) | |
| 899 | + | if (!uport || tty_io_error(tty)) | |
| 900 | 900 | return -EIO; | |
| 901 | 901 | ||
| 902 | 902 | new_port = new_info->port; | |
| @@ -1119,7 +1119,7 @@ static int uart_break_ctl(struct tty_struct *tty, int break_state) | |||
| 1119 | 1119 | guard(mutex)(&port->mutex); | |
| 1120 | 1120 | ||
| 1121 | 1121 | uport = uart_port_check(state); | |
| 1122 | - | if (!uport) | |
| 1122 | + | if (!uport || tty_io_error(tty)) | |
| 1123 | 1123 | return -EIO; | |
| 1124 | 1124 | ||
| 1125 | 1125 | if (uport->type != PORT_UNKNOWN && uport->ops->break_ctl) | |
| @@ -1144,7 +1144,7 @@ static int uart_do_autoconfig(struct tty_struct *tty, struct uart_state *state) | |||
| 1144 | 1144 | */ | |
| 1145 | 1145 | scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &port->mutex) { | |
| 1146 | 1146 | uport = uart_port_check(state); | |
| 1147 | - | if (!uport) | |
| 1147 | + | if (!uport || tty_io_error(tty)) | |
| 1148 | 1148 | return -EIO; | |
| 1149 | 1149 | ||
| 1150 | 1150 | if (tty_port_users(port) != 1) | |
| @@ -1199,7 +1199,7 @@ static void uart_enable_ms(struct uart_port *uport) | |||
| 1199 | 1199 | * FIXME: This wants extracting into a common all driver implementation | |
| 1200 | 1200 | * of TIOCMWAIT using tty_port. | |
| 1201 | 1201 | */ | |
| 1202 | - | static int uart_wait_modem_status(struct uart_state *state, unsigned long arg) | |
| 1202 | + | static int uart_wait_modem_status(struct tty_struct *tty, struct uart_state *state, unsigned long arg) | |
| 1203 | 1203 | { | |
| 1204 | 1204 | struct uart_port *uport; | |
| 1205 | 1205 | struct tty_port *port = &state->port; | |
| @@ -1213,18 +1213,29 @@ static int uart_wait_modem_status(struct uart_state *state, unsigned long arg) | |||
| 1213 | 1213 | uport = uart_port_ref(state); | |
| 1214 | 1214 | if (!uport) | |
| 1215 | 1215 | return -EIO; | |
| 1216 | - | scoped_guard(uart_port_lock_irq, uport) { | |
| 1217 | - | memcpy(&cprev, &uport->icount, sizeof(struct uart_icount)); | |
| 1218 | - | uart_enable_ms(uport); | |
| 1216 | + | ||
| 1217 | + | mutex_lock(&port->mutex); | |
| 1218 | + | if (tty_io_error(tty)) { | |
| 1219 | + | mutex_unlock(&port->mutex); | |
| 1220 | + | ret = -EIO; | |
| 1221 | + | goto out_deref; | |
| 1219 | 1222 | } | |
| 1220 | 1223 | ||
| 1224 | + | uart_port_lock_irq(uport); | |
| 1225 | + | memcpy(&cprev, &uport->icount, sizeof(struct uart_icount)); | |
| 1226 | + | uart_enable_ms(uport); | |
| 1227 | + | uart_port_unlock_irq(uport); | |
| 1228 | + | ||
| 1229 | + | mutex_unlock(&port->mutex); | |
| 1230 | + | ||
| 1221 | 1231 | add_wait_queue(&port->delta_msr_wait, &wait); | |
| 1222 | 1232 | for (;;) { | |
| 1223 | - | scoped_guard(uart_port_lock_irq, uport) | |
| 1224 | - | memcpy(&cnow, &uport->icount, sizeof(struct uart_icount)); | |
| 1225 | - | ||
| 1226 | 1233 | set_current_state(TASK_INTERRUPTIBLE); | |
| 1227 | 1234 | ||
| 1235 | + | uart_port_lock_irq(uport); | |
| 1236 | + | memcpy(&cnow, &uport->icount, sizeof(struct uart_icount)); | |
| 1237 | + | uart_port_unlock_irq(uport); | |
| 1238 | + | ||
| 1228 | 1239 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || | |
| 1229 | 1240 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || | |
| 1230 | 1241 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || | |
| @@ -1233,6 +1244,11 @@ static int uart_wait_modem_status(struct uart_state *state, unsigned long arg) | |||
| 1233 | 1244 | break; | |
| 1234 | 1245 | } | |
| 1235 | 1246 | ||
| 1247 | + | if (tty_io_error(tty)) { | |
| 1248 | + | ret = -EIO; | |
| 1249 | + | break; | |
| 1250 | + | } | |
| 1251 | + | ||
| 1236 | 1252 | schedule(); | |
| 1237 | 1253 | ||
| 1238 | 1254 | /* see if a signal did it */ | |
| @@ -1245,6 +1261,7 @@ static int uart_wait_modem_status(struct uart_state *state, unsigned long arg) | |||
| 1245 | 1261 | } | |
| 1246 | 1262 | __set_current_state(TASK_RUNNING); | |
| 1247 | 1263 | remove_wait_queue(&port->delta_msr_wait, &wait); | |
| 1264 | + | out_deref: | |
| 1248 | 1265 | uart_port_deref(uport); | |
| 1249 | 1266 | ||
| 1250 | 1267 | return ret; | |
| @@ -1567,7 +1584,7 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) | |||
| 1567 | 1584 | ||
| 1568 | 1585 | /* This should only be used when the hardware is present. */ | |
| 1569 | 1586 | if (cmd == TIOCMIWAIT) | |
| 1570 | - | return uart_wait_modem_status(state, arg); | |
| 1587 | + | return uart_wait_modem_status(tty, state, arg); | |
| 1571 | 1588 | ||
| 1572 | 1589 | /* rs485_config requires more locking than others */ | |
| 1573 | 1590 | if (cmd == TIOCSRS485) | |
| @@ -1623,14 +1640,13 @@ static void uart_set_ldisc(struct tty_struct *tty) | |||
| 1623 | 1640 | { | |
| 1624 | 1641 | struct uart_state *state = tty->driver_data; | |
| 1625 | 1642 | struct uart_port *uport; | |
| 1626 | - | struct tty_port *port = &state->port; | |
| 1627 | - | ||
| 1628 | - | if (!tty_port_initialized(port)) | |
| 1629 | - | return; | |
| 1630 | 1643 | ||
| 1631 | 1644 | guard(mutex)(&state->port.mutex); | |
| 1632 | 1645 | uport = uart_port_check(state); | |
| 1633 | - | if (uport && uport->ops->set_ldisc) | |
| 1646 | + | if (!uport || tty_io_error(tty)) | |
| 1647 | + | return; | |
| 1648 | + | ||
| 1649 | + | if (uport->ops->set_ldisc) | |
| 1634 | 1650 | uport->ops->set_ldisc(uport, &tty->termios); | |
| 1635 | 1651 | } | |
| 1636 | 1652 | ||
| @@ -1646,7 +1662,7 @@ static void uart_set_termios(struct tty_struct *tty, | |||
| 1646 | 1662 | guard(mutex)(&state->port.mutex); | |
| 1647 | 1663 | ||
| 1648 | 1664 | uport = uart_port_check(state); | |
| 1649 | - | if (!uport) | |
| 1665 | + | if (!uport || tty_io_error(tty)) | |
| 1650 | 1666 | return; | |
| 1651 | 1667 | ||
| 1652 | 1668 | /* | |
| @@ -1798,7 +1814,14 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout) | |||
| 1798 | 1814 | * 'timeout' / 'expire' give us the maximum amount of time | |
| 1799 | 1815 | * we wait. | |
| 1800 | 1816 | */ | |
| 1801 | - | while (!port->ops->tx_empty(port)) { | |
| 1817 | + | for (;;) { | |
| 1818 | + | mutex_lock(&state->port.mutex); | |
| 1819 | + | if (tty_io_error(tty) || port->ops->tx_empty(port)) { | |
| 1820 | + | mutex_unlock(&state->port.mutex); | |
| 1821 | + | break; | |
| 1822 | + | } | |
| 1823 | + | mutex_unlock(&state->port.mutex); | |
| 1824 | + | ||
| 1802 | 1825 | msleep_interruptible(jiffies_to_msecs(char_time)); | |
| 1803 | 1826 | if (signal_pending(current)) | |
| 1804 | 1827 | break; | |
| @@ -3358,6 +3381,7 @@ int serial_core_register_port(struct uart_driver *drv, struct uart_port *port) | |||
| 3358 | 3381 | ||
| 3359 | 3382 | err_unregister_port_dev: | |
| 3360 | 3383 | serial_base_port_device_remove(port->port_dev); | |
| 3384 | + | port->port_dev = NULL; | |
| 3361 | 3385 | ||
| 3362 | 3386 | err_unregister_ctrl_dev: | |
| 3363 | 3387 | serial_base_ctrl_device_remove(new_ctrl_dev); | |
| @@ -3372,12 +3396,24 @@ err_unregister_ctrl_dev: | |||
| 3372 | 3396 | void serial_core_unregister_port(struct uart_driver *drv, struct uart_port *port) | |
| 3373 | 3397 | { | |
| 3374 | 3398 | struct device *phys_dev = port->dev; | |
| 3375 | - | struct serial_port_device *port_dev = port->port_dev; | |
| 3376 | - | struct serial_ctrl_device *ctrl_dev = serial_core_get_ctrl_dev(port_dev); | |
| 3399 | + | struct serial_port_device *port_dev; | |
| 3400 | + | struct serial_ctrl_device *ctrl_dev; | |
| 3377 | 3401 | int ctrl_id = port->ctrl_id; | |
| 3378 | 3402 | ||
| 3379 | 3403 | guard(mutex)(&port_mutex); | |
| 3380 | 3404 | ||
| 3405 | + | /* | |
| 3406 | + | * A NULL port device means there is no registered port device to | |
| 3407 | + | * remove: serial_core_remove_one_port() clears port_dev on | |
| 3408 | + | * teardown, and it is never set if registration failed before | |
| 3409 | + | * serial_core_port_device_add(). | |
| 3410 | + | */ | |
| 3411 | + | port_dev = port->port_dev; | |
| 3412 | + | if (!port_dev) | |
| 3413 | + | return; | |
| 3414 | + | ||
| 3415 | + | ctrl_dev = serial_core_get_ctrl_dev(port_dev); | |
| 3416 | + | ||
| 3381 | 3417 | port->flags |= UPF_DEAD; | |
| 3382 | 3418 | ||
| 3383 | 3419 | serial_core_remove_one_port(drv, port); | |
modified drivers/tty/serial/sifive.c
| @@ -821,7 +821,7 @@ static void sifive_serial_console_write_atomic(struct console *co, | |||
| 821 | 821 | ier = __ssp_readl(ssp, SIFIVE_SERIAL_IE_OFFS); | |
| 822 | 822 | __ssp_writel(0, SIFIVE_SERIAL_IE_OFFS, ssp); | |
| 823 | 823 | ||
| 824 | - | if (!ssp->console_line_ended) | |
| 824 | + | if (unlikely(!ssp->console_line_ended && !nbcon_is_braille(co))) | |
| 825 | 825 | uart_console_write(port, "\n", 1, sifive_serial_console_putchar); | |
| 826 | 826 | uart_console_write(port, wctxt->outbuf, wctxt->len, | |
| 827 | 827 | sifive_serial_console_putchar); | |
modified drivers/tty/serial/vt8500_serial.c
| @@ -656,6 +656,7 @@ static int vt8500_serial_probe(struct platform_device *pdev) | |||
| 656 | 656 | ret = clk_prepare_enable(vt8500_port->clk); | |
| 657 | 657 | if (ret) { | |
| 658 | 658 | dev_err(&pdev->dev, "failed to enable clock\n"); | |
| 659 | + | clk_put(vt8500_port->clk); | |
| 659 | 660 | return ret; | |
| 660 | 661 | } | |
| 661 | 662 | ||
modified drivers/tty/tty_io.c
| @@ -620,6 +620,8 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session) | |||
| 620 | 620 | ||
| 621 | 621 | tty_ldisc_hangup(tty, cons_filp != NULL); | |
| 622 | 622 | ||
| 623 | + | wake_up_interruptible(&tty->break_wait); | |
| 624 | + | ||
| 623 | 625 | spin_lock_irq(&tty->ctrl.lock); | |
| 624 | 626 | clear_bit(TTY_THROTTLED, &tty->flags); | |
| 625 | 627 | clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | |
| @@ -2431,6 +2433,7 @@ static int tiocgetd(struct tty_struct *tty, int __user *p) | |||
| 2431 | 2433 | * send_break - performed time break | |
| 2432 | 2434 | * @tty: device to break on | |
| 2433 | 2435 | * @duration: timeout in mS | |
| 2436 | + | * @file: file object | |
| 2434 | 2437 | * | |
| 2435 | 2438 | * Perform a timed break on hardware that lacks its own driver level timed | |
| 2436 | 2439 | * break functionality. | |
| @@ -2438,8 +2441,9 @@ static int tiocgetd(struct tty_struct *tty, int __user *p) | |||
| 2438 | 2441 | * Locking: | |
| 2439 | 2442 | * @tty->atomic_write_lock serializes | |
| 2440 | 2443 | */ | |
| 2441 | - | static int send_break(struct tty_struct *tty, unsigned int duration) | |
| 2444 | + | static int send_break(struct file *file, struct tty_struct *tty, unsigned int duration) | |
| 2442 | 2445 | { | |
| 2446 | + | long timeout; | |
| 2443 | 2447 | int retval; | |
| 2444 | 2448 | ||
| 2445 | 2449 | if (tty->ops->break_ctl == NULL) | |
| @@ -2453,13 +2457,26 @@ static int send_break(struct tty_struct *tty, unsigned int duration) | |||
| 2453 | 2457 | return -EINTR; | |
| 2454 | 2458 | ||
| 2455 | 2459 | retval = tty->ops->break_ctl(tty, -1); | |
| 2456 | - | if (!retval) { | |
| 2457 | - | msleep_interruptible(duration); | |
| 2458 | - | retval = tty->ops->break_ctl(tty, 0); | |
| 2459 | - | } else if (retval == -EOPNOTSUPP) { | |
| 2460 | - | /* some drivers can tell only dynamically */ | |
| 2461 | - | retval = 0; | |
| 2460 | + | if (retval) { | |
| 2461 | + | if (retval == -EOPNOTSUPP) { | |
| 2462 | + | /* some drivers can tell only dynamically */ | |
| 2463 | + | retval = 0; | |
| 2464 | + | } | |
| 2465 | + | goto out_unlock; | |
| 2466 | + | } | |
| 2467 | + | ||
| 2468 | + | timeout = msecs_to_jiffies(duration); | |
| 2469 | + | timeout = wait_event_interruptible_timeout(tty->break_wait, | |
| 2470 | + | tty_hung_up_p(file), | |
| 2471 | + | timeout); | |
| 2472 | + | /* return early on hangup only */ | |
| 2473 | + | if (timeout > 0) { | |
| 2474 | + | retval = -EIO; | |
| 2475 | + | goto out_unlock; | |
| 2462 | 2476 | } | |
| 2477 | + | ||
| 2478 | + | retval = tty->ops->break_ctl(tty, 0); | |
| 2479 | + | out_unlock: | |
| 2463 | 2480 | tty_write_unlock(tty); | |
| 2464 | 2481 | ||
| 2465 | 2482 | if (signal_pending(current)) | |
| @@ -2727,10 +2744,10 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 2727 | 2744 | * This is used by the tcdrain() termios function. | |
| 2728 | 2745 | */ | |
| 2729 | 2746 | if (!arg) | |
| 2730 | - | return send_break(tty, 250); | |
| 2747 | + | return send_break(file, tty, 250); | |
| 2731 | 2748 | return 0; | |
| 2732 | 2749 | case TCSBRKP: /* support for POSIX tcsendbreak() */ | |
| 2733 | - | return send_break(tty, arg ? arg*100 : 250); | |
| 2750 | + | return send_break(file, tty, arg ? arg * 100 : 250); | |
| 2734 | 2751 | ||
| 2735 | 2752 | case TIOCMGET: | |
| 2736 | 2753 | return tty_tiocmget(tty, p); | |
| @@ -3090,6 +3107,7 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx) | |||
| 3090 | 3107 | init_ldsem(&tty->ldisc_sem); | |
| 3091 | 3108 | init_waitqueue_head(&tty->write_wait); | |
| 3092 | 3109 | init_waitqueue_head(&tty->read_wait); | |
| 3110 | + | init_waitqueue_head(&tty->break_wait); | |
| 3093 | 3111 | INIT_WORK(&tty->hangup_work, do_tty_hangup); | |
| 3094 | 3112 | mutex_init(&tty->atomic_write_lock); | |
| 3095 | 3113 | spin_lock_init(&tty->ctrl.lock); | |
| @@ -3238,14 +3256,16 @@ struct device *tty_register_device_attr(struct tty_driver *driver, | |||
| 3238 | 3256 | goto err_put; | |
| 3239 | 3257 | ||
| 3240 | 3258 | if (!(driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)) { | |
| 3241 | - | /* | |
| 3242 | - | * Free any saved termios data so that the termios state is | |
| 3243 | - | * reset when reusing a minor number. | |
| 3244 | - | */ | |
| 3245 | - | tp = driver->termios[index]; | |
| 3246 | - | if (tp) { | |
| 3247 | - | driver->termios[index] = NULL; | |
| 3248 | - | kfree(tp); | |
| 3259 | + | if (driver->flags & TTY_DRIVER_RESET_SAVED_TERMIOS) { | |
| 3260 | + | /* | |
| 3261 | + | * Free any saved termios data so that the termios | |
| 3262 | + | * state is reset when reusing a minor number. | |
| 3263 | + | */ | |
| 3264 | + | tp = driver->termios[index]; | |
| 3265 | + | if (tp) { | |
| 3266 | + | driver->termios[index] = NULL; | |
| 3267 | + | kfree(tp); | |
| 3268 | + | } | |
| 3249 | 3269 | } | |
| 3250 | 3270 | ||
| 3251 | 3271 | retval = tty_cdev_add(driver, devt, index, 1); | |
modified drivers/tty/tty_port.c
| @@ -340,19 +340,9 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) | |||
| 340 | 340 | } | |
| 341 | 341 | EXPORT_SYMBOL(tty_port_tty_set); | |
| 342 | 342 | ||
| 343 | - | /** | |
| 344 | - | * tty_port_shutdown - internal helper to shutdown the device | |
| 345 | - | * @port: tty port to be shut down | |
| 346 | - | * @tty: the associated tty | |
| 347 | - | * | |
| 348 | - | * It is used by tty_port_hangup() and tty_port_close(). Its task is to | |
| 349 | - | * shutdown the device if it was initialized (note consoles remain | |
| 350 | - | * functioning). It lowers DTR/RTS (if @tty has HUPCL set) and invokes | |
| 351 | - | * @port->ops->shutdown(). | |
| 352 | - | */ | |
| 353 | - | static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) | |
| 343 | + | static void tty_port_shutdown_locked(struct tty_port *port, struct tty_struct *tty) | |
| 354 | 344 | { | |
| 355 | - | guard(mutex)(&port->mutex); | |
| 345 | + | lockdep_assert_held(&port->mutex); | |
| 356 | 346 | ||
| 357 | 347 | if (port->console) | |
| 358 | 348 | return; | |
| @@ -372,6 +362,23 @@ static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) | |||
| 372 | 362 | port->ops->shutdown(port); | |
| 373 | 363 | } | |
| 374 | 364 | ||
| 365 | + | /** | |
| 366 | + | * tty_port_shutdown - internal helper to shutdown the device | |
| 367 | + | * @port: tty port to be shut down | |
| 368 | + | * @tty: the associated tty | |
| 369 | + | * | |
| 370 | + | * It is used by tty_port_hangup() and tty_port_close(). Its task is to | |
| 371 | + | * shutdown the device if it was initialized (note consoles remain | |
| 372 | + | * functioning). It lowers DTR/RTS (if @tty has HUPCL set) and invokes | |
| 373 | + | * @port->ops->shutdown(). | |
| 374 | + | */ | |
| 375 | + | static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) | |
| 376 | + | { | |
| 377 | + | guard(mutex)(&port->mutex); | |
| 378 | + | ||
| 379 | + | tty_port_shutdown_locked(port, tty); | |
| 380 | + | } | |
| 381 | + | ||
| 375 | 382 | /** | |
| 376 | 383 | * tty_port_hangup - hangup helper | |
| 377 | 384 | * @port: tty port | |
| @@ -385,36 +392,58 @@ void tty_port_hangup(struct tty_port *port) | |||
| 385 | 392 | { | |
| 386 | 393 | struct tty_struct *tty; | |
| 387 | 394 | ||
| 388 | - | scoped_guard(spinlock_irqsave, &port->lock) { | |
| 389 | - | port->count = 0; | |
| 390 | - | tty = port->tty; | |
| 391 | - | if (tty) | |
| 392 | - | set_bit(TTY_IO_ERROR, &tty->flags); | |
| 393 | - | port->tty = NULL; | |
| 394 | - | } | |
| 395 | + | scoped_guard(mutex, &port->mutex) { | |
| 396 | + | scoped_guard(spinlock_irqsave, &port->lock) { | |
| 397 | + | port->count = 0; | |
| 398 | + | tty = port->tty; | |
| 399 | + | if (tty) | |
| 400 | + | set_bit(TTY_IO_ERROR, &tty->flags); | |
| 401 | + | port->tty = NULL; | |
| 402 | + | } | |
| 395 | 403 | ||
| 396 | - | tty_port_set_active(port, false); | |
| 397 | - | tty_port_shutdown(port, tty); | |
| 404 | + | tty_port_set_active(port, false); | |
| 405 | + | tty_port_shutdown_locked(port, tty); | |
| 406 | + | } | |
| 398 | 407 | tty_kref_put(tty); | |
| 399 | 408 | wake_up_interruptible(&port->open_wait); | |
| 400 | 409 | wake_up_interruptible(&port->delta_msr_wait); | |
| 401 | 410 | } | |
| 402 | 411 | EXPORT_SYMBOL(tty_port_hangup); | |
| 403 | 412 | ||
| 404 | - | void __tty_port_tty_hangup(struct tty_port *port, bool check_clocal, bool async) | |
| 413 | + | /** | |
| 414 | + | * tty_port_tty_hangup - helper to hang up a tty asynchronously | |
| 415 | + | * @port: tty port | |
| 416 | + | * @check_clocal: hang only ttys with %CLOCAL unset? | |
| 417 | + | */ | |
| 418 | + | void tty_port_tty_hangup(struct tty_port *port, bool check_clocal) | |
| 405 | 419 | { | |
| 406 | 420 | scoped_guard(tty_port_tty, port) { | |
| 407 | 421 | struct tty_struct *tty = scoped_tty(); | |
| 408 | 422 | ||
| 409 | - | if (!check_clocal || !C_CLOCAL(tty)) { | |
| 410 | - | if (async) | |
| 411 | - | tty_hangup(tty); | |
| 412 | - | else | |
| 413 | - | tty_vhangup(tty); | |
| 414 | - | } | |
| 423 | + | if (!check_clocal || !C_CLOCAL(tty)) | |
| 424 | + | tty_hangup(tty); | |
| 425 | + | } | |
| 426 | + | } | |
| 427 | + | EXPORT_SYMBOL_GPL(tty_port_tty_hangup); | |
| 428 | + | ||
| 429 | + | /** | |
| 430 | + | * tty_port_tty_vhangup - helper to hang up a tty synchronously | |
| 431 | + | * @port: tty port | |
| 432 | + | */ | |
| 433 | + | void tty_port_tty_vhangup(struct tty_port *port) | |
| 434 | + | { | |
| 435 | + | struct tty_struct *tty; | |
| 436 | + | ||
| 437 | + | mutex_lock(&port->mutex); | |
| 438 | + | tty = tty_port_tty_get(port); | |
| 439 | + | mutex_unlock(&port->mutex); | |
| 440 | + | ||
| 441 | + | if (tty) { | |
| 442 | + | tty_vhangup(tty); | |
| 443 | + | tty_kref_put(tty); | |
| 415 | 444 | } | |
| 416 | 445 | } | |
| 417 | - | EXPORT_SYMBOL_GPL(__tty_port_tty_hangup); | |
| 446 | + | EXPORT_SYMBOL_GPL(tty_port_tty_vhangup); | |
| 418 | 447 | ||
| 419 | 448 | /** | |
| 420 | 449 | * tty_port_tty_wakeup - helper to wake up a tty | |
| @@ -767,8 +796,10 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty, | |||
| 767 | 796 | clear_bit(TTY_IO_ERROR, &tty->flags); | |
| 768 | 797 | if (port->ops->activate) { | |
| 769 | 798 | int retval = port->ops->activate(port, tty); | |
| 770 | - | if (retval) | |
| 799 | + | if (retval) { | |
| 800 | + | set_bit(TTY_IO_ERROR, &tty->flags); | |
| 771 | 801 | return retval; | |
| 802 | + | } | |
| 772 | 803 | } | |
| 773 | 804 | tty_port_set_initialized(port, true); | |
| 774 | 805 | } | |
modified drivers/tty/vcc.c
| @@ -492,7 +492,7 @@ static ssize_t domain_show(struct device *dev, | |||
| 492 | 492 | ||
| 493 | 493 | static int vcc_send_ctl(struct vcc_port *port, int ctl) | |
| 494 | 494 | { | |
| 495 | - | struct vio_vcc pkt; | |
| 495 | + | struct vio_vcc pkt = {}; | |
| 496 | 496 | int rv; | |
| 497 | 497 | ||
| 498 | 498 | pkt.tag.type = VIO_TYPE_CTRL; | |
| @@ -986,7 +986,8 @@ static void vcc_cleanup(struct tty_struct *tty) | |||
| 986 | 986 | ||
| 987 | 987 | port = vcc_get(tty->index, true); | |
| 988 | 988 | if (port) { | |
| 989 | - | port->tty = NULL; | |
| 989 | + | scoped_guard(spinlock_irqsave, &port->lock) | |
| 990 | + | port->tty = NULL; | |
| 990 | 991 | ||
| 991 | 992 | if (port->removed) { | |
| 992 | 993 | vcc_table_remove(tty->index); | |
modified drivers/tty/vt/selection.c
| @@ -434,8 +434,8 @@ int paste_selection(struct tty_struct *tty) | |||
| 434 | 434 | bps = NULL; | |
| 435 | 435 | } | |
| 436 | 436 | ||
| 437 | - | count = vc_sel.buf_len - pasted; | |
| 438 | - | if (count) { | |
| 437 | + | if (vc_sel.buf_len > pasted) { | |
| 438 | + | count = vc_sel.buf_len - pasted; | |
| 439 | 439 | pasted += tty_ldisc_receive_buf(ld, vc_sel.buffer + pasted, | |
| 440 | 440 | NULL, count); | |
| 441 | 441 | if (vc_sel.buf_len > pasted) | |
modified drivers/tty/vt/vc_screen.c
| @@ -631,6 +631,18 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | |||
| 631 | 631 | ret = copy_from_user(con_buf, buf, this_round); | |
| 632 | 632 | console_lock(); | |
| 633 | 633 | ||
| 634 | + | /* The vc might have been freed or vcs_size might have changed | |
| 635 | + | * while we slept to grab the user buffer; recheck here, before | |
| 636 | + | * if (ret), so every break path below passes a fresh vc to the | |
| 637 | + | * post-loop vcs_scr_updated(). Return data written so far. | |
| 638 | + | */ | |
| 639 | + | vc = vcs_vc(inode, &viewed); | |
| 640 | + | if (!vc) { | |
| 641 | + | if (written) | |
| 642 | + | break; | |
| 643 | + | return -ENXIO; | |
| 644 | + | } | |
| 645 | + | ||
| 634 | 646 | if (ret) { | |
| 635 | 647 | this_round -= ret; | |
| 636 | 648 | if (!this_round) { | |
| @@ -642,17 +654,6 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | |||
| 642 | 654 | return -EFAULT; | |
| 643 | 655 | } | |
| 644 | 656 | } | |
| 645 | - | ||
| 646 | - | /* The vc might have been freed or vcs_size might have changed | |
| 647 | - | * while we slept to grab the user buffer, so recheck. | |
| 648 | - | * Return data written up to now on failure. | |
| 649 | - | */ | |
| 650 | - | vc = vcs_vc(inode, &viewed); | |
| 651 | - | if (!vc) { | |
| 652 | - | if (written) | |
| 653 | - | break; | |
| 654 | - | return -ENXIO; | |
| 655 | - | } | |
| 656 | 657 | size = vcs_size(vc, attr, false); | |
| 657 | 658 | if (size < 0) { | |
| 658 | 659 | if (written) | |
modified drivers/tty/vt/vt.c
| @@ -1134,6 +1134,8 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ | |||
| 1134 | 1134 | return 0; | |
| 1135 | 1135 | err_free: | |
| 1136 | 1136 | visual_deinit(vc); | |
| 1137 | + | if (*vc->uni_pagedict_loc) | |
| 1138 | + | con_free_unimap(vc); | |
| 1137 | 1139 | kfree(vc); | |
| 1138 | 1140 | vc_cons[currcons].d = NULL; | |
| 1139 | 1141 | return err; | |
| @@ -2860,7 +2862,8 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) | |||
| 2860 | 2862 | csi_J(vc, CSI_J_VISIBLE); | |
| 2861 | 2863 | vc->vc_video_erase_char = | |
| 2862 | 2864 | (vc->vc_video_erase_char & 0xff00) | ' '; | |
| 2863 | - | do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); | |
| 2865 | + | if (con_should_update(vc)) | |
| 2866 | + | do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); | |
| 2864 | 2867 | } | |
| 2865 | 2868 | return; | |
| 2866 | 2869 | case ESsetG0: /* ESC ( */ | |
modified drivers/ufs/core/ufs-mcq.c
| @@ -312,20 +312,24 @@ static int ufshcd_mcq_get_tag(struct ufs_hba *hba, struct cq_entry *cqe) | |||
| 312 | 312 | UFSHCD_NUM_RESERVED; | |
| 313 | 313 | } | |
| 314 | 314 | ||
| 315 | + | static void ufshcd_mcq_compl_cqe(struct ufs_hba *hba, struct cq_entry *cqe) | |
| 316 | + | { | |
| 317 | + | int tag = ufshcd_mcq_get_tag(hba, cqe); | |
| 318 | + | ||
| 319 | + | ufshcd_compl_one_cqe(hba, tag, cqe); | |
| 320 | + | /* After processing the CQE, mark it as an empty (invalid) entry. */ | |
| 321 | + | cqe->command_desc_base_addr = 0; | |
| 322 | + | } | |
| 323 | + | ||
| 315 | 324 | static void ufshcd_mcq_process_cqe(struct ufs_hba *hba, | |
| 316 | 325 | struct ufs_hw_queue *hwq) | |
| 317 | 326 | { | |
| 318 | 327 | struct cq_entry *cqe = ufshcd_mcq_cur_cqe(hwq); | |
| 319 | 328 | ||
| 320 | - | if (cqe->command_desc_base_addr) { | |
| 321 | - | int tag = ufshcd_mcq_get_tag(hba, cqe); | |
| 322 | - | ||
| 323 | - | ufshcd_compl_one_cqe(hba, tag, cqe); | |
| 324 | - | /* After processed the cqe, mark it empty (invalid) entry */ | |
| 325 | - | cqe->command_desc_base_addr = 0; | |
| 326 | - | } else { | |
| 329 | + | if (cqe->command_desc_base_addr) | |
| 330 | + | ufshcd_mcq_compl_cqe(hba, cqe); | |
| 331 | + | else | |
| 327 | 332 | dev_err(hba->dev, "Abnormal CQ entry!\n"); | |
| 328 | - | } | |
| 329 | 333 | } | |
| 330 | 334 | ||
| 331 | 335 | /* | |
| @@ -333,7 +337,7 @@ static void ufshcd_mcq_process_cqe(struct ufs_hba *hba, | |||
| 333 | 337 | * controller disabled (HCE = 0). Reading host controller registers, e.g. the | |
| 334 | 338 | * CQ tail pointer (CQTPy), may not be safe with the host controller disabled. | |
| 335 | 339 | * Hence, iterate over all completion queue entries. This won't result in | |
| 336 | - | * double completions because ufshcd_mcq_process_cqe() clears a CQE after it | |
| 340 | + | * double completions because ufshcd_mcq_compl_cqe() clears a CQE after it | |
| 337 | 341 | * has been processed. | |
| 338 | 342 | */ | |
| 339 | 343 | void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba, | |
| @@ -344,13 +348,13 @@ void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba, | |||
| 344 | 348 | ||
| 345 | 349 | spin_lock_irqsave(&hwq->cq_lock, flags); | |
| 346 | 350 | while (entries > 0) { | |
| 347 | - | ufshcd_mcq_process_cqe(hba, hwq); | |
| 351 | + | struct cq_entry *cqe = ufshcd_mcq_cur_cqe(hwq); | |
| 352 | + | ||
| 353 | + | if (cqe->command_desc_base_addr) | |
| 354 | + | ufshcd_mcq_compl_cqe(hba, cqe); | |
| 348 | 355 | ufshcd_mcq_inc_cq_head_slot(hwq); | |
| 349 | 356 | entries--; | |
| 350 | 357 | } | |
| 351 | - | ||
| 352 | - | ufshcd_mcq_update_cq_tail_slot(hwq); | |
| 353 | - | hwq->cq_head_slot = hwq->cq_tail_slot; | |
| 354 | 358 | spin_unlock_irqrestore(&hwq->cq_lock, flags); | |
| 355 | 359 | } | |
| 356 | 360 | ||
modified drivers/ufs/core/ufshcd.c
| @@ -6044,8 +6044,6 @@ static bool ufshcd_mcq_force_compl_one(struct request *rq, void *priv) | |||
| 6044 | 6044 | if (blk_mq_is_reserved_rq(rq) || !hwq) | |
| 6045 | 6045 | return true; | |
| 6046 | 6046 | ||
| 6047 | - | ufshcd_mcq_compl_all_cqes_lock(hba, hwq); | |
| 6048 | - | ||
| 6049 | 6047 | /* | |
| 6050 | 6048 | * For those cmds of which the cqes are not present in the cq, complete | |
| 6051 | 6049 | * them explicitly. | |
| @@ -6061,19 +6059,6 @@ static bool ufshcd_mcq_force_compl_one(struct request *rq, void *priv) | |||
| 6061 | 6059 | return true; | |
| 6062 | 6060 | } | |
| 6063 | 6061 | ||
| 6064 | - | static bool ufshcd_mcq_compl_one(struct request *rq, void *priv) | |
| 6065 | - | { | |
| 6066 | - | struct scsi_device *sdev = rq->q->queuedata; | |
| 6067 | - | struct Scsi_Host *shost = sdev->host; | |
| 6068 | - | struct ufs_hba *hba = shost_priv(shost); | |
| 6069 | - | struct ufs_hw_queue *hwq = ufshcd_mcq_req_to_hwq(hba, rq); | |
| 6070 | - | ||
| 6071 | - | if (!blk_mq_is_reserved_rq(rq) && hwq) | |
| 6072 | - | ufshcd_mcq_poll_cqe_lock(hba, hwq); | |
| 6073 | - | ||
| 6074 | - | return true; | |
| 6075 | - | } | |
| 6076 | - | ||
| 6077 | 6062 | /** | |
| 6078 | 6063 | * ufshcd_mcq_compl_pending_transfer - MCQ mode function. It is | |
| 6079 | 6064 | * invoked from the error handler context or ufshcd_host_reset_and_restore() | |
| @@ -6088,10 +6073,18 @@ static bool ufshcd_mcq_compl_one(struct request *rq, void *priv) | |||
| 6088 | 6073 | static void ufshcd_mcq_compl_pending_transfer(struct ufs_hba *hba, | |
| 6089 | 6074 | bool force_compl) | |
| 6090 | 6075 | { | |
| 6091 | - | blk_mq_tagset_busy_iter(&hba->host->tag_set, | |
| 6092 | - | force_compl ? ufshcd_mcq_force_compl_one : | |
| 6093 | - | ufshcd_mcq_compl_one, | |
| 6094 | - | NULL); | |
| 6076 | + | int i; | |
| 6077 | + | ||
| 6078 | + | for (i = 0; i < hba->nr_hw_queues; i++) { | |
| 6079 | + | if (force_compl) | |
| 6080 | + | ufshcd_mcq_compl_all_cqes_lock(hba, &hba->uhq[i]); | |
| 6081 | + | else | |
| 6082 | + | ufshcd_mcq_poll_cqe_lock(hba, &hba->uhq[i]); | |
| 6083 | + | } | |
| 6084 | + | ||
| 6085 | + | if (force_compl) | |
| 6086 | + | blk_mq_tagset_busy_iter(&hba->host->tag_set, | |
| 6087 | + | ufshcd_mcq_force_compl_one, NULL); | |
| 6095 | 6088 | } | |
| 6096 | 6089 | ||
| 6097 | 6090 | /** | |
| @@ -9556,6 +9549,7 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie) | |||
| 9556 | 9549 | ret = ufshcd_add_lus(hba); | |
| 9557 | 9550 | ||
| 9558 | 9551 | out: | |
| 9552 | + | ufshcd_release(hba); | |
| 9559 | 9553 | pm_runtime_put_sync(hba->dev); | |
| 9560 | 9554 | ||
| 9561 | 9555 | if (ret) | |
| @@ -11278,6 +11272,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) | |||
| 11278 | 11272 | ||
| 11279 | 11273 | ufshcd_init_clk_gating(hba); | |
| 11280 | 11274 | ||
| 11275 | + | /* Released by ufshcd_async_scan(), or by out_release on failure. */ | |
| 11276 | + | ufshcd_hold(hba); | |
| 11277 | + | ||
| 11281 | 11278 | ufshcd_init_clk_scaling(hba); | |
| 11282 | 11279 | ||
| 11283 | 11280 | /* | |
| @@ -11298,7 +11295,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) | |||
| 11298 | 11295 | err = devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba); | |
| 11299 | 11296 | if (err) { | |
| 11300 | 11297 | dev_err(hba->dev, "request irq failed\n"); | |
| 11301 | - | goto out_disable; | |
| 11298 | + | goto out_release; | |
| 11302 | 11299 | } else { | |
| 11303 | 11300 | hba->is_irq_enabled = true; | |
| 11304 | 11301 | } | |
| @@ -11314,7 +11311,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) | |||
| 11314 | 11311 | dev_err(hba->dev, "Host controller enable failed\n"); | |
| 11315 | 11312 | ufshcd_print_evt_hist(hba); | |
| 11316 | 11313 | ufshcd_print_host_state(hba); | |
| 11317 | - | goto out_disable; | |
| 11314 | + | goto out_release; | |
| 11318 | 11315 | } | |
| 11319 | 11316 | ||
| 11320 | 11317 | INIT_DELAYED_WORK(&hba->rpm_dev_flush_recheck_work, ufshcd_rpm_dev_flush_recheck_work); | |
| @@ -11328,7 +11325,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) | |||
| 11328 | 11325 | ||
| 11329 | 11326 | err = ufshcd_add_scsi_host(hba); | |
| 11330 | 11327 | if (err) | |
| 11331 | - | goto out_disable; | |
| 11328 | + | goto out_release; | |
| 11332 | 11329 | ||
| 11333 | 11330 | /* Hold auto suspend until async scan completes */ | |
| 11334 | 11331 | pm_runtime_get_sync(dev); | |
| @@ -11348,7 +11345,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) | |||
| 11348 | 11345 | ||
| 11349 | 11346 | err = ufshcd_link_startup(hba); | |
| 11350 | 11347 | if (err) | |
| 11351 | - | goto out_disable; | |
| 11348 | + | goto out_release; | |
| 11352 | 11349 | ||
| 11353 | 11350 | if (hba->mcq_enabled) | |
| 11354 | 11351 | ufshcd_config_mcq(hba); | |
| @@ -11365,23 +11362,23 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) | |||
| 11365 | 11362 | /* Verify device initialization by sending NOP OUT UPIU */ | |
| 11366 | 11363 | err = ufshcd_verify_dev_init(hba); | |
| 11367 | 11364 | if (err) | |
| 11368 | - | goto out_disable; | |
| 11365 | + | goto out_release; | |
| 11369 | 11366 | ||
| 11370 | 11367 | /* Initiate UFS initialization, and waiting until completion */ | |
| 11371 | 11368 | err = ufshcd_complete_dev_init(hba); | |
| 11372 | 11369 | if (err) | |
| 11373 | - | goto out_disable; | |
| 11370 | + | goto out_release; | |
| 11374 | 11371 | ||
| 11375 | 11372 | err = ufshcd_device_params_init(hba); | |
| 11376 | 11373 | if (err) | |
| 11377 | - | goto out_disable; | |
| 11374 | + | goto out_release; | |
| 11378 | 11375 | ||
| 11379 | 11376 | err = ufshcd_post_device_init(hba); | |
| 11380 | 11377 | ||
| 11381 | 11378 | initialized: | |
| 11382 | 11379 | ufshcd_process_probe_result(hba, probe_start, err); | |
| 11383 | 11380 | if (err) | |
| 11384 | - | goto out_disable; | |
| 11381 | + | goto out_release; | |
| 11385 | 11382 | ||
| 11386 | 11383 | ufs_sysfs_add_nodes(hba->dev); | |
| 11387 | 11384 | hba->dme_qos_sysfs_handle = sysfs_get_dirent(hba->dev->kobj.sd, | |
| @@ -11392,6 +11389,8 @@ initialized: | |||
| 11392 | 11389 | ufshcd_pm_qos_init(hba); | |
| 11393 | 11390 | return 0; | |
| 11394 | 11391 | ||
| 11392 | + | out_release: | |
| 11393 | + | ufshcd_release(hba); | |
| 11395 | 11394 | out_disable: | |
| 11396 | 11395 | hba->is_irq_enabled = false; | |
| 11397 | 11396 | ufshcd_hba_exit(hba); | |
modified drivers/ufs/host/ufs-mediatek.c
| @@ -509,6 +509,7 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on) | |||
| 509 | 509 | struct ufs_mtk_host *host = ufshcd_get_variant(hba); | |
| 510 | 510 | struct phy *mphy = host->mphy; | |
| 511 | 511 | struct arm_smccc_res res; | |
| 512 | + | int err; | |
| 512 | 513 | int ret = 0; | |
| 513 | 514 | ||
| 514 | 515 | if (!mphy || !(on ^ host->mphy_powered_on)) | |
| @@ -523,7 +524,18 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on) | |||
| 523 | 524 | usleep_range(200, 210); | |
| 524 | 525 | ufs_mtk_va09_pwr_ctrl(res, 1); | |
| 525 | 526 | } | |
| 526 | - | phy_power_on(mphy); | |
| 527 | + | ret = phy_power_on(mphy); | |
| 528 | + | if (ret) { | |
| 529 | + | if (ufs_mtk_is_va09_supported(hba)) { | |
| 530 | + | ufs_mtk_va09_pwr_ctrl(res, 0); | |
| 531 | + | err = regulator_disable(host->reg_va09); | |
| 532 | + | if (err) | |
| 533 | + | dev_err(hba->dev, | |
| 534 | + | "failed to unwind va09: %d\n", err); | |
| 535 | + | } | |
| 536 | + | dev_err(hba->dev, "failed to enable mphy: %d\n", ret); | |
| 537 | + | return ret; | |
| 538 | + | } | |
| 527 | 539 | } else { | |
| 528 | 540 | phy_power_off(mphy); | |
| 529 | 541 | if (ufs_mtk_is_va09_supported(hba)) { | |
| @@ -1295,7 +1307,9 @@ static int ufs_mtk_init(struct ufs_hba *hba) | |||
| 1295 | 1307 | * | |
| 1296 | 1308 | * Enable phy clocks specifically here. | |
| 1297 | 1309 | */ | |
| 1298 | - | ufs_mtk_mphy_power_on(hba, true); | |
| 1310 | + | err = ufs_mtk_mphy_power_on(hba, true); | |
| 1311 | + | if (err) | |
| 1312 | + | goto out_variant_clear; | |
| 1299 | 1313 | ||
| 1300 | 1314 | if (ufs_mtk_is_rtff_mtcmos(hba)) { | |
| 1301 | 1315 | /* First Restore here, to avoid backup unexpected value */ | |
modified drivers/usb/cdns3/cdns3-gadget.c
| @@ -3269,6 +3269,10 @@ static void cdns3_gadget_exit(struct cdns *cdns) | |||
| 3269 | 3269 | usb_del_gadget(&priv_dev->gadget); | |
| 3270 | 3270 | devm_free_irq(cdns->dev, cdns->dev_irq, priv_dev); | |
| 3271 | 3271 | ||
| 3272 | + | /* The works can still be queued until the IRQ is freed. */ | |
| 3273 | + | cancel_work_sync(&priv_dev->pending_status_wq); | |
| 3274 | + | cancel_work_sync(&priv_dev->aligned_buf_wq); | |
| 3275 | + | ||
| 3272 | 3276 | cdns3_free_all_eps(priv_dev); | |
| 3273 | 3277 | ||
| 3274 | 3278 | while (!list_empty(&priv_dev->aligned_buf_list)) { | |
modified drivers/usb/cdns3/cdns3-pci-wrap.c
| @@ -96,6 +96,11 @@ static int cdns3_pci_probe(struct pci_dev *pdev, | |||
| 96 | 96 | ||
| 97 | 97 | if (pci_is_enabled(func)) { | |
| 98 | 98 | wrap = pci_get_drvdata(func); | |
| 99 | + | if (!wrap) { | |
| 100 | + | dev_err(&pdev->dev, | |
| 101 | + | "second function not initialized, retrying\n"); | |
| 102 | + | return -EPROBE_DEFER; | |
| 103 | + | } | |
| 99 | 104 | } else { | |
| 100 | 105 | wrap = kzalloc_obj(*wrap); | |
| 101 | 106 | if (!wrap) | |
modified drivers/usb/chipidea/ci_hdrc_tegra.c
| @@ -306,8 +306,10 @@ static int tegra_usb_probe(struct platform_device *pdev) | |||
| 306 | 306 | ||
| 307 | 307 | pm_runtime_enable(&pdev->dev); | |
| 308 | 308 | err = pm_runtime_resume_and_get(&pdev->dev); | |
| 309 | - | if (err) | |
| 309 | + | if (err) { | |
| 310 | + | pm_runtime_disable(&pdev->dev); | |
| 310 | 311 | return err; | |
| 312 | + | } | |
| 311 | 313 | ||
| 312 | 314 | if (device_property_present(&pdev->dev, "nvidia,needs-double-reset")) | |
| 313 | 315 | usb->needs_double_reset = true; | |
modified drivers/usb/class/cdc-acm.c
| @@ -331,7 +331,6 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf) | |||
| 331 | 331 | ||
| 332 | 332 | spin_lock_irqsave(&acm->read_lock, flags); | |
| 333 | 333 | acm->ctrlin = newctrl; | |
| 334 | - | acm->oldcount = acm->iocount; | |
| 335 | 334 | ||
| 336 | 335 | if (difference & USB_CDC_SERIAL_STATE_DSR) | |
| 337 | 336 | acm->iocount.dsr++; | |
| @@ -788,6 +787,9 @@ static void acm_port_shutdown(struct tty_port *port) | |||
| 788 | 787 | usb_autopm_put_interface_async(acm->control); | |
| 789 | 788 | } | |
| 790 | 789 | ||
| 790 | + | if (acm->disconnected) | |
| 791 | + | return; | |
| 792 | + | ||
| 791 | 793 | acm_unpoison_urbs(acm); | |
| 792 | 794 | ||
| 793 | 795 | if (acm->quirks & ALWAYS_POLL_CTRL) { | |
| @@ -1027,11 +1029,16 @@ static int wait_serial_change(struct acm *acm, unsigned long arg) | |||
| 1027 | 1029 | DECLARE_WAITQUEUE(wait, current); | |
| 1028 | 1030 | struct async_icount old, new; | |
| 1029 | 1031 | ||
| 1030 | - | do { | |
| 1032 | + | spin_lock_irq(&acm->read_lock); | |
| 1033 | + | old = acm->iocount; | |
| 1034 | + | spin_unlock_irq(&acm->read_lock); | |
| 1035 | + | ||
| 1036 | + | add_wait_queue(&acm->wioctl, &wait); | |
| 1037 | + | for (;;) { | |
| 1038 | + | set_current_state(TASK_INTERRUPTIBLE); | |
| 1039 | + | ||
| 1031 | 1040 | spin_lock_irq(&acm->read_lock); | |
| 1032 | - | old = acm->oldcount; | |
| 1033 | 1041 | new = acm->iocount; | |
| 1034 | - | acm->oldcount = new; | |
| 1035 | 1042 | spin_unlock_irq(&acm->read_lock); | |
| 1036 | 1043 | ||
| 1037 | 1044 | if ((arg & TIOCM_DSR) && | |
| @@ -1044,22 +1051,20 @@ static int wait_serial_change(struct acm *acm, unsigned long arg) | |||
| 1044 | 1051 | old.rng != new.rng) | |
| 1045 | 1052 | break; | |
| 1046 | 1053 | ||
| 1047 | - | add_wait_queue(&acm->wioctl, &wait); | |
| 1048 | - | set_current_state(TASK_INTERRUPTIBLE); | |
| 1049 | - | schedule(); | |
| 1050 | - | remove_wait_queue(&acm->wioctl, &wait); | |
| 1051 | 1054 | if (acm->disconnected) { | |
| 1052 | - | if (arg & TIOCM_CD) | |
| 1053 | - | break; | |
| 1054 | - | else | |
| 1055 | - | rv = -ENODEV; | |
| 1056 | - | } else { | |
| 1057 | - | if (signal_pending(current)) | |
| 1058 | - | rv = -ERESTARTSYS; | |
| 1055 | + | rv = -ENODEV; | |
| 1056 | + | break; | |
| 1059 | 1057 | } | |
| 1060 | - | } while (!rv); | |
| 1061 | 1058 | ||
| 1062 | - | ||
| 1059 | + | schedule(); | |
| 1060 | + | ||
| 1061 | + | if (signal_pending(current)) { | |
| 1062 | + | rv = -ERESTARTSYS; | |
| 1063 | + | break; | |
| 1064 | + | } | |
| 1065 | + | } | |
| 1066 | + | __set_current_state(TASK_RUNNING); | |
| 1067 | + | remove_wait_queue(&acm->wioctl, &wait); | |
| 1063 | 1068 | ||
| 1064 | 1069 | return rv; | |
| 1065 | 1070 | } | |
| @@ -2140,7 +2145,7 @@ static int __init acm_init(void) | |||
| 2140 | 2145 | { | |
| 2141 | 2146 | int retval; | |
| 2142 | 2147 | acm_tty_driver = tty_alloc_driver(ACM_TTY_MINORS, TTY_DRIVER_REAL_RAW | | |
| 2143 | - | TTY_DRIVER_DYNAMIC_DEV); | |
| 2148 | + | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_RESET_SAVED_TERMIOS); | |
| 2144 | 2149 | if (IS_ERR(acm_tty_driver)) | |
| 2145 | 2150 | return PTR_ERR(acm_tty_driver); | |
| 2146 | 2151 | acm_tty_driver->driver_name = "acm", | |
modified drivers/usb/class/cdc-acm.h
| @@ -90,7 +90,6 @@ struct acm { | |||
| 90 | 90 | unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ | |
| 91 | 91 | unsigned int ctrlout; /* output control lines (DTR, RTS) */ | |
| 92 | 92 | struct async_icount iocount; /* counters for control line changes */ | |
| 93 | - | struct async_icount oldcount; /* for comparison of counter */ | |
| 94 | 93 | wait_queue_head_t wioctl; /* for ioctl */ | |
| 95 | 94 | unsigned int writesize; /* max packet size for the output bulk endpoint */ | |
| 96 | 95 | unsigned int readsize,ctrlsize; /* buffer sizes for freeing */ | |
modified drivers/usb/core/hub.c
| @@ -73,8 +73,11 @@ | |||
| 73 | 73 | /* | |
| 74 | 74 | * Give SS hubs 200ms time after wake to train downstream links before | |
| 75 | 75 | * assuming no port activity and allowing hub to runtime suspend back. | |
| 76 | + | * Root hubs have no upstream hub whose wake propagation needs to be | |
| 77 | + | * accounted for, so they need less time, use 120ms for them. | |
| 76 | 78 | */ | |
| 77 | 79 | #define USB_SS_PORT_U0_WAKE_TIME 200 /* ms */ | |
| 80 | + | #define USB_SS_RH_PORT_U0_WAKE_TIME 120 /* ms */ | |
| 78 | 81 | ||
| 79 | 82 | /* Protect struct usb_device->state and ->children members | |
| 80 | 83 | * Note: Both are also protected by ->dev.sem, except that ->state can | |
| @@ -1358,7 +1361,9 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
| 1358 | 1361 | ||
| 1359 | 1362 | queue_delayed_work(system_power_efficient_wq, | |
| 1360 | 1363 | &hub->post_resume_work, | |
| 1361 | - | msecs_to_jiffies(USB_SS_PORT_U0_WAKE_TIME)); | |
| 1364 | + | msecs_to_jiffies(hdev->parent ? | |
| 1365 | + | USB_SS_PORT_U0_WAKE_TIME : | |
| 1366 | + | USB_SS_RH_PORT_U0_WAKE_TIME)); | |
| 1362 | 1367 | return; | |
| 1363 | 1368 | } | |
| 1364 | 1369 | ||
modified drivers/usb/core/message.c
| @@ -1337,7 +1337,8 @@ static void remove_intf_ep_devs(struct usb_interface *intf) | |||
| 1337 | 1337 | * | |
| 1338 | 1338 | * Disables the endpoint for URB submission and nukes all pending URBs. | |
| 1339 | 1339 | * If @reset_hardware is set then also deallocates hcd/hardware state | |
| 1340 | - | * for the endpoint. | |
| 1340 | + | * for the endpoint (clearing both ep_in and ep_out pointers for | |
| 1341 | + | * bidirectional non-ep0 control endpoints). | |
| 1341 | 1342 | */ | |
| 1342 | 1343 | void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr, | |
| 1343 | 1344 | bool reset_hardware) | |
| @@ -1358,6 +1359,11 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr, | |||
| 1358 | 1359 | dev->ep_in[epnum] = NULL; | |
| 1359 | 1360 | } | |
| 1360 | 1361 | if (ep) { | |
| 1362 | + | if (reset_hardware && epnum != 0 && | |
| 1363 | + | usb_endpoint_xfer_control(&ep->desc)) { | |
| 1364 | + | dev->ep_out[epnum] = NULL; | |
| 1365 | + | dev->ep_in[epnum] = NULL; | |
| 1366 | + | } | |
| 1361 | 1367 | ep->enabled = 0; | |
| 1362 | 1368 | usb_hcd_flush_endpoint(dev, ep); | |
| 1363 | 1369 | if (reset_hardware) | |
modified drivers/usb/dwc2/hcd.c
| @@ -5082,14 +5082,13 @@ static void dwc2_hcd_free(struct dwc2_hsotg *hsotg) | |||
| 5082 | 5082 | } | |
| 5083 | 5083 | ||
| 5084 | 5084 | cancel_work_sync(&hsotg->phy_reset_work); | |
| 5085 | - | ||
| 5086 | - | timer_delete(&hsotg->wkp_timer); | |
| 5087 | 5085 | } | |
| 5088 | 5086 | ||
| 5089 | 5087 | static void dwc2_hcd_release(struct dwc2_hsotg *hsotg) | |
| 5090 | 5088 | { | |
| 5091 | 5089 | /* Turn off all host-specific interrupts */ | |
| 5092 | 5090 | dwc2_disable_host_interrupts(hsotg); | |
| 5091 | + | timer_shutdown_sync(&hsotg->wkp_timer); | |
| 5093 | 5092 | ||
| 5094 | 5093 | dwc2_hcd_free(hsotg); | |
| 5095 | 5094 | } | |
modified drivers/usb/dwc3/core.h
| @@ -49,6 +49,7 @@ | |||
| 49 | 49 | #define DWC3_ENDPOINTS_NUM 32 | |
| 50 | 50 | #define DWC3_XHCI_RESOURCES_NUM 2 | |
| 51 | 51 | #define DWC3_ISOC_MAX_RETRIES 5 | |
| 52 | + | #define DWC3_ERR_RECOVERY_MAX 3 | |
| 52 | 53 | ||
| 53 | 54 | #define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */ | |
| 54 | 55 | #define DWC3_EVENT_BUFFERS_SIZE 4096 | |
| @@ -841,6 +842,12 @@ enum dwc3_link_state { | |||
| 841 | 842 | DWC3_LINK_STATE_MASK = 0x0f, | |
| 842 | 843 | }; | |
| 843 | 844 | ||
| 845 | + | enum dwc3_err_state { | |
| 846 | + | DWC3_ERR_NONE = 0, | |
| 847 | + | DWC3_ERR_RECOVERY, | |
| 848 | + | DWC3_ERR_UNRECOVERABLE, | |
| 849 | + | }; | |
| 850 | + | ||
| 844 | 851 | /* TRB Length, PCM and Status */ | |
| 845 | 852 | #define DWC3_TRB_SIZE_MASK (0x00ffffff) | |
| 846 | 853 | #define DWC3_TRB_SIZE_LENGTH(n) ((n) & DWC3_TRB_SIZE_MASK) | |
| @@ -1004,6 +1011,7 @@ struct dwc3_glue_ops { | |||
| 1004 | 1011 | /** | |
| 1005 | 1012 | * struct dwc3 - representation of our controller | |
| 1006 | 1013 | * @drd_work: workqueue used for role swapping | |
| 1014 | + | * @err_recovery_work: workqueue used for controller error recovery | |
| 1007 | 1015 | * @ep0_trb: trb which is used for the ctrl_req | |
| 1008 | 1016 | * @bounce: address of bounce buffer | |
| 1009 | 1017 | * @setup_buf: used while precessing STD USB requests | |
| @@ -1013,6 +1021,7 @@ struct dwc3_glue_ops { | |||
| 1013 | 1021 | * @ep0_in_setup: one control transfer is completed and enter setup phase | |
| 1014 | 1022 | * @lock: for synchronizing | |
| 1015 | 1023 | * @mutex: for mode switching | |
| 1024 | + | * @connect_mutex: for the pull-up and err_recovery_work | |
| 1016 | 1025 | * @dev: pointer to our struct device | |
| 1017 | 1026 | * @sysdev: pointer to the DMA-capable device | |
| 1018 | 1027 | * @xhci: pointer to our xHCI child | |
| @@ -1079,6 +1088,9 @@ struct dwc3_glue_ops { | |||
| 1079 | 1088 | * @ep0_next_event: hold the next expected event | |
| 1080 | 1089 | * @ep0state: state of endpoint zero | |
| 1081 | 1090 | * @link_state: link state | |
| 1091 | + | * @err_state: current error recovery state. | |
| 1092 | + | * @err_recovery_count: number of consecutive error recovery attempts until | |
| 1093 | + | * confirmed healthy and reset to 0 on reset event. | |
| 1082 | 1094 | * @speed: device speed (super, high, full, low) | |
| 1083 | 1095 | * @hwparams: copy of hwparams registers | |
| 1084 | 1096 | * @regset: debugfs pointer to regdump file | |
| @@ -1189,6 +1201,7 @@ struct dwc3_glue_ops { | |||
| 1189 | 1201 | */ | |
| 1190 | 1202 | struct dwc3 { | |
| 1191 | 1203 | struct work_struct drd_work; | |
| 1204 | + | struct work_struct err_recovery_work; | |
| 1192 | 1205 | struct dwc3_trb *ep0_trb; | |
| 1193 | 1206 | void *bounce; | |
| 1194 | 1207 | u8 *setup_buf; | |
| @@ -1203,6 +1216,9 @@ struct dwc3 { | |||
| 1203 | 1216 | /* mode switching lock */ | |
| 1204 | 1217 | struct mutex mutex; | |
| 1205 | 1218 | ||
| 1219 | + | /* serializes pull-up run/stop vs error recovery */ | |
| 1220 | + | struct mutex connect_mutex; | |
| 1221 | + | ||
| 1206 | 1222 | struct device *dev; | |
| 1207 | 1223 | struct device *sysdev; | |
| 1208 | 1224 | ||
| @@ -1332,6 +1348,9 @@ struct dwc3 { | |||
| 1332 | 1348 | enum dwc3_ep0_next ep0_next_event; | |
| 1333 | 1349 | enum dwc3_ep0_state ep0state; | |
| 1334 | 1350 | enum dwc3_link_state link_state; | |
| 1351 | + | enum dwc3_err_state err_state; | |
| 1352 | + | ||
| 1353 | + | u32 err_recovery_count; | |
| 1335 | 1354 | ||
| 1336 | 1355 | u16 u2sel; | |
| 1337 | 1356 | u16 u2pel; | |
modified drivers/usb/dwc3/dwc3-am62.c
| @@ -299,6 +299,7 @@ static int dwc3_ti_probe(struct platform_device *pdev) | |||
| 299 | 299 | ||
| 300 | 300 | err_pm_disable: | |
| 301 | 301 | clk_disable_unprepare(am62->usb2_refclk); | |
| 302 | + | pm_runtime_put_noidle(dev); | |
| 302 | 303 | pm_runtime_disable(dev); | |
| 303 | 304 | pm_runtime_set_suspended(dev); | |
| 304 | 305 | return ret; | |
modified drivers/usb/dwc3/ep0.c
| @@ -200,6 +200,11 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, | |||
| 200 | 200 | int ret; | |
| 201 | 201 | ||
| 202 | 202 | spin_lock_irqsave(&dwc->lock, flags); | |
| 203 | + | if (dwc->err_state != DWC3_ERR_NONE) { | |
| 204 | + | ret = -ESHUTDOWN; | |
| 205 | + | goto out; | |
| 206 | + | } | |
| 207 | + | ||
| 203 | 208 | if (!dep->endpoint.desc || !dwc->pullups_connected || !dwc->connected) { | |
| 204 | 209 | dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n", | |
| 205 | 210 | dep->name); | |
| @@ -271,6 +276,10 @@ int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value) | |||
| 271 | 276 | int ret; | |
| 272 | 277 | ||
| 273 | 278 | spin_lock_irqsave(&dwc->lock, flags); | |
| 279 | + | if (dwc->err_state != DWC3_ERR_NONE) { | |
| 280 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 281 | + | return -ESHUTDOWN; | |
| 282 | + | } | |
| 274 | 283 | ret = __dwc3_gadget_ep0_set_halt(ep, value); | |
| 275 | 284 | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 276 | 285 | ||
modified drivers/usb/dwc3/gadget.c
| @@ -1149,6 +1149,10 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, | |||
| 1149 | 1149 | return 0; | |
| 1150 | 1150 | ||
| 1151 | 1151 | spin_lock_irqsave(&dwc->lock, flags); | |
| 1152 | + | if (dwc->err_state != DWC3_ERR_NONE) { | |
| 1153 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 1154 | + | return -ESHUTDOWN; | |
| 1155 | + | } | |
| 1152 | 1156 | ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_INIT); | |
| 1153 | 1157 | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 1154 | 1158 | ||
| @@ -2060,6 +2064,10 @@ static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request, | |||
| 2060 | 2064 | int ret; | |
| 2061 | 2065 | ||
| 2062 | 2066 | spin_lock_irqsave(&dwc->lock, flags); | |
| 2067 | + | if (dwc->err_state != DWC3_ERR_NONE) { | |
| 2068 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 2069 | + | return -ESHUTDOWN; | |
| 2070 | + | } | |
| 2063 | 2071 | ret = __dwc3_gadget_ep_queue(dep, req); | |
| 2064 | 2072 | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 2065 | 2073 | ||
| @@ -2292,6 +2300,10 @@ static int dwc3_gadget_ep_set_halt(struct usb_ep *ep, int value) | |||
| 2292 | 2300 | int ret; | |
| 2293 | 2301 | ||
| 2294 | 2302 | spin_lock_irqsave(&dwc->lock, flags); | |
| 2303 | + | if (dwc->err_state != DWC3_ERR_NONE) { | |
| 2304 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 2305 | + | return -ESHUTDOWN; | |
| 2306 | + | } | |
| 2295 | 2307 | ret = __dwc3_gadget_ep_set_halt(dep, value, false); | |
| 2296 | 2308 | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 2297 | 2309 | ||
| @@ -2306,6 +2318,10 @@ static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep) | |||
| 2306 | 2318 | int ret; | |
| 2307 | 2319 | ||
| 2308 | 2320 | spin_lock_irqsave(&dwc->lock, flags); | |
| 2321 | + | if (dwc->err_state != DWC3_ERR_NONE) { | |
| 2322 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 2323 | + | return -ESHUTDOWN; | |
| 2324 | + | } | |
| 2309 | 2325 | dep->flags |= DWC3_EP_WEDGE; | |
| 2310 | 2326 | ||
| 2311 | 2327 | if (dep->number == 0 || dep->number == 1) | |
| @@ -2437,6 +2453,10 @@ static int dwc3_gadget_wakeup(struct usb_gadget *g) | |||
| 2437 | 2453 | } | |
| 2438 | 2454 | ||
| 2439 | 2455 | spin_lock_irqsave(&dwc->lock, flags); | |
| 2456 | + | if (dwc->err_state != DWC3_ERR_NONE) { | |
| 2457 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 2458 | + | return -ESHUTDOWN; | |
| 2459 | + | } | |
| 2440 | 2460 | if (!dwc->gadget->wakeup_armed) { | |
| 2441 | 2461 | dev_err(dwc->dev, "not armed for remote wakeup\n"); | |
| 2442 | 2462 | spin_unlock_irqrestore(&dwc->lock, flags); | |
| @@ -2464,6 +2484,10 @@ static int dwc3_gadget_func_wakeup(struct usb_gadget *g, int intf_id) | |||
| 2464 | 2484 | } | |
| 2465 | 2485 | ||
| 2466 | 2486 | spin_lock_irqsave(&dwc->lock, flags); | |
| 2487 | + | if (dwc->err_state != DWC3_ERR_NONE) { | |
| 2488 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 2489 | + | return -ESHUTDOWN; | |
| 2490 | + | } | |
| 2467 | 2491 | /* | |
| 2468 | 2492 | * If the link is in U3, signal for remote wakeup and wait for the | |
| 2469 | 2493 | * link to transition to U0 before sending device notification. | |
| @@ -2833,10 +2857,13 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) | |||
| 2833 | 2857 | ||
| 2834 | 2858 | synchronize_irq(dwc->irq_gadget); | |
| 2835 | 2859 | ||
| 2860 | + | /* Serialize against dwc3_err_recovery_work() */ | |
| 2861 | + | mutex_lock(&dwc->connect_mutex); | |
| 2836 | 2862 | if (!is_on) | |
| 2837 | 2863 | ret = dwc3_gadget_soft_disconnect(dwc); | |
| 2838 | 2864 | else | |
| 2839 | 2865 | ret = dwc3_gadget_soft_connect(dwc); | |
| 2866 | + | mutex_unlock(&dwc->connect_mutex); | |
| 2840 | 2867 | ||
| 2841 | 2868 | pm_runtime_put(dwc->dev); | |
| 2842 | 2869 | ||
| @@ -4153,6 +4180,10 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) | |||
| 4153 | 4180 | ||
| 4154 | 4181 | dwc->suspended = false; | |
| 4155 | 4182 | ||
| 4183 | + | /* The controller is recovered. */ | |
| 4184 | + | if (dwc->err_state == DWC3_ERR_NONE) | |
| 4185 | + | dwc->err_recovery_count = 0; | |
| 4186 | + | ||
| 4156 | 4187 | /* | |
| 4157 | 4188 | * Ideally, dwc3_reset_gadget() would trigger the function | |
| 4158 | 4189 | * drivers to stop any active transfers through ep disable. | |
| @@ -4640,6 +4671,12 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void *_evt) | |||
| 4640 | 4671 | return ret; | |
| 4641 | 4672 | } | |
| 4642 | 4673 | ||
| 4674 | + | static void dwc3_schedule_err_recovery(struct dwc3 *dwc) | |
| 4675 | + | { | |
| 4676 | + | dwc->err_state = DWC3_ERR_RECOVERY; | |
| 4677 | + | schedule_work(&dwc->err_recovery_work); | |
| 4678 | + | } | |
| 4679 | + | ||
| 4643 | 4680 | static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt) | |
| 4644 | 4681 | { | |
| 4645 | 4682 | struct dwc3 *dwc = evt->dwc; | |
| @@ -4673,9 +4710,21 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt) | |||
| 4673 | 4710 | return IRQ_NONE; | |
| 4674 | 4711 | ||
| 4675 | 4712 | if (count > evt->length) { | |
| 4676 | - | dev_err_ratelimited(dwc->dev, "invalid count(%u) > evt->length(%u)\n", | |
| 4713 | + | dev_err(dwc->dev, "invalid count(%u) > evt->length(%u)\n", | |
| 4677 | 4714 | count, evt->length); | |
| 4678 | - | return IRQ_NONE; | |
| 4715 | + | /* | |
| 4716 | + | * This is a fatal error - the driver and controller are out of | |
| 4717 | + | * sync on which event has been consumed. Reinitializing the | |
| 4718 | + | * controller is required to recover. Write the bogus count back | |
| 4719 | + | * to GEVNTCOUNT to clear the IRQ source, consistent with the | |
| 4720 | + | * stale event clearing in dwc3_event_buffers_setup(), then | |
| 4721 | + | * schedule error recovery. | |
| 4722 | + | */ | |
| 4723 | + | spin_lock(&dwc->lock); | |
| 4724 | + | dwc3_schedule_err_recovery(dwc); | |
| 4725 | + | spin_unlock(&dwc->lock); | |
| 4726 | + | dwc3_writel(dwc, DWC3_GEVNTCOUNT(0), count); | |
| 4727 | + | return IRQ_HANDLED; | |
| 4679 | 4728 | } | |
| 4680 | 4729 | ||
| 4681 | 4730 | evt->count = count; | |
| @@ -4735,6 +4784,57 @@ static void dwc_gadget_release(struct device *dev) | |||
| 4735 | 4784 | kfree(gadget); | |
| 4736 | 4785 | } | |
| 4737 | 4786 | ||
| 4787 | + | static void dwc3_err_recovery_work(struct work_struct *work) | |
| 4788 | + | { | |
| 4789 | + | struct dwc3 *dwc = container_of(work, struct dwc3, err_recovery_work); | |
| 4790 | + | unsigned long flags; | |
| 4791 | + | int ret; | |
| 4792 | + | ||
| 4793 | + | /* serializes against dwc3_gadget_pullup() */ | |
| 4794 | + | mutex_lock(&dwc->connect_mutex); | |
| 4795 | + | ||
| 4796 | + | ret = dwc3_gadget_soft_disconnect(dwc); | |
| 4797 | + | ||
| 4798 | + | dwc3_disconnect_gadget_sleepable(dwc); | |
| 4799 | + | ||
| 4800 | + | if (ret) | |
| 4801 | + | goto err_unrecoverable; | |
| 4802 | + | ||
| 4803 | + | if (dwc->softconnect) { | |
| 4804 | + | u32 count; | |
| 4805 | + | /* | |
| 4806 | + | * Wait irq to finish before soft_connect resets evt->lpos and | |
| 4807 | + | * the event buffer registers to avoid racing with | |
| 4808 | + | * dwc3_process_event_buf(). | |
| 4809 | + | */ | |
| 4810 | + | synchronize_irq(dwc->irq_gadget); | |
| 4811 | + | ||
| 4812 | + | spin_lock_irqsave(&dwc->lock, flags); | |
| 4813 | + | count = ++dwc->err_recovery_count; | |
| 4814 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 4815 | + | ||
| 4816 | + | if (count > DWC3_ERR_RECOVERY_MAX) | |
| 4817 | + | goto err_unrecoverable; | |
| 4818 | + | ||
| 4819 | + | ret = dwc3_gadget_soft_connect(dwc); | |
| 4820 | + | if (ret) | |
| 4821 | + | goto err_unrecoverable; | |
| 4822 | + | } | |
| 4823 | + | mutex_unlock(&dwc->connect_mutex); | |
| 4824 | + | ||
| 4825 | + | spin_lock_irqsave(&dwc->lock, flags); | |
| 4826 | + | dwc->err_state = DWC3_ERR_NONE; | |
| 4827 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 4828 | + | return; | |
| 4829 | + | ||
| 4830 | + | err_unrecoverable: | |
| 4831 | + | dev_err(dwc->dev, "Unable to recover the controller\n"); | |
| 4832 | + | mutex_unlock(&dwc->connect_mutex); | |
| 4833 | + | spin_lock_irqsave(&dwc->lock, flags); | |
| 4834 | + | dwc->err_state = DWC3_ERR_UNRECOVERABLE; | |
| 4835 | + | spin_unlock_irqrestore(&dwc->lock, flags); | |
| 4836 | + | } | |
| 4837 | + | ||
| 4738 | 4838 | /** | |
| 4739 | 4839 | * dwc3_gadget_init - initializes gadget related registers | |
| 4740 | 4840 | * @dwc: pointer to our controller context structure | |
| @@ -4778,6 +4878,8 @@ int dwc3_gadget_init(struct dwc3 *dwc) | |||
| 4778 | 4878 | } | |
| 4779 | 4879 | ||
| 4780 | 4880 | init_completion(&dwc->ep0_in_setup); | |
| 4881 | + | INIT_WORK(&dwc->err_recovery_work, dwc3_err_recovery_work); | |
| 4882 | + | mutex_init(&dwc->connect_mutex); | |
| 4781 | 4883 | dwc->gadget = kzalloc_obj(struct usb_gadget); | |
| 4782 | 4884 | if (!dwc->gadget) { | |
| 4783 | 4885 | ret = -ENOMEM; | |
| @@ -4874,6 +4976,8 @@ void dwc3_gadget_exit(struct dwc3 *dwc) | |||
| 4874 | 4976 | if (!dwc->gadget) | |
| 4875 | 4977 | return; | |
| 4876 | 4978 | ||
| 4979 | + | cancel_work_sync(&dwc->err_recovery_work); | |
| 4980 | + | mutex_destroy(&dwc->connect_mutex); | |
| 4877 | 4981 | dwc3_enable_susphy(dwc, true); | |
| 4878 | 4982 | usb_del_gadget(dwc->gadget); | |
| 4879 | 4983 | dwc3_gadget_free_endpoints(dwc); | |
modified drivers/usb/gadget/function/f_fs.c
| @@ -1877,8 +1877,9 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, | |||
| 1877 | 1877 | break; | |
| 1878 | 1878 | case FUNCTIONFS_ENDPOINT_DESC: | |
| 1879 | 1879 | { | |
| 1880 | + | const struct usb_endpoint_descriptor *desc; | |
| 1881 | + | struct usb_endpoint_descriptor desc1; | |
| 1880 | 1882 | int desc_idx; | |
| 1881 | - | struct usb_endpoint_descriptor desc1, *desc; | |
| 1882 | 1883 | ||
| 1883 | 1884 | switch (epfile->ffs->gadget->speed) { | |
| 1884 | 1885 | case USB_SPEED_SUPER: | |
| @@ -1892,7 +1893,17 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, | |||
| 1892 | 1893 | desc_idx = 0; | |
| 1893 | 1894 | } | |
| 1894 | 1895 | ||
| 1895 | - | desc = epfile->ep->descs[desc_idx]; | |
| 1896 | + | do { | |
| 1897 | + | desc = epfile->ep->descs[desc_idx]; | |
| 1898 | + | } while (!desc && --desc_idx >= 0); | |
| 1899 | + | ||
| 1900 | + | if (!desc) | |
| 1901 | + | desc = epfile->ep->ep->desc; | |
| 1902 | + | if (!desc) { | |
| 1903 | + | ret = -EINVAL; | |
| 1904 | + | break; | |
| 1905 | + | } | |
| 1906 | + | ||
| 1896 | 1907 | memcpy(&desc1, desc, desc->bLength); | |
| 1897 | 1908 | ||
| 1898 | 1909 | spin_unlock_irq(&epfile->ffs->eps_lock); | |
modified drivers/usb/gadget/function/f_midi2.c
| @@ -1633,8 +1633,8 @@ struct f_midi2_usb_config { | |||
| 1633 | 1633 | ||
| 1634 | 1634 | /* MIDI 1.0 jacks */ | |
| 1635 | 1635 | unsigned char jack_in, jack_out, jack_id; | |
| 1636 | - | struct usb_midi_in_jack_descriptor jack_ins[MAX_CABLES]; | |
| 1637 | - | struct usb_midi_out_jack_descriptor_1 jack_outs[MAX_CABLES]; | |
| 1636 | + | struct usb_midi_in_jack_descriptor jack_ins[MAX_CABLES * 2]; | |
| 1637 | + | struct usb_midi_out_jack_descriptor_1 jack_outs[MAX_CABLES * 2]; | |
| 1638 | 1638 | }; | |
| 1639 | 1639 | ||
| 1640 | 1640 | static int append_config(struct f_midi2_usb_config *config, void *d) | |
modified drivers/usb/gadget/function/f_uac1_legacy.c
| @@ -797,6 +797,9 @@ fail: | |||
| 797 | 797 | ||
| 798 | 798 | static int generic_set_cmd(struct usb_audio_control *con, u8 cmd, int value) | |
| 799 | 799 | { | |
| 800 | + | if (cmd >= ARRAY_SIZE(con->data)) | |
| 801 | + | return -EINVAL; | |
| 802 | + | ||
| 800 | 803 | con->data[cmd] = value; | |
| 801 | 804 | ||
| 802 | 805 | return 0; | |
| @@ -804,6 +807,9 @@ static int generic_set_cmd(struct usb_audio_control *con, u8 cmd, int value) | |||
| 804 | 807 | ||
| 805 | 808 | static int generic_get_cmd(struct usb_audio_control *con, u8 cmd) | |
| 806 | 809 | { | |
| 810 | + | if (cmd >= ARRAY_SIZE(con->data)) | |
| 811 | + | return -EINVAL; | |
| 812 | + | ||
| 807 | 813 | return con->data[cmd]; | |
| 808 | 814 | } | |
| 809 | 815 | ||
modified drivers/usb/gadget/udc/aspeed-vhub/core.c
| @@ -267,6 +267,9 @@ static void ast_vhub_remove(struct platform_device *pdev) | |||
| 267 | 267 | for (i = 0; i < vhub->max_ports; i++) | |
| 268 | 268 | ast_vhub_del_dev(&vhub->ports[i].dev); | |
| 269 | 269 | ||
| 270 | + | /* Final drain; the worker takes vhub->lock, so stay outside of it */ | |
| 271 | + | cancel_work_sync(&vhub->wake_work); | |
| 272 | + | ||
| 270 | 273 | spin_lock_irqsave(&vhub->lock, flags); | |
| 271 | 274 | ||
| 272 | 275 | /* Mask & ack all interrupts */ | |
| @@ -328,6 +331,7 @@ static int ast_vhub_probe(struct platform_device *pdev) | |||
| 328 | 331 | return -ENOMEM; | |
| 329 | 332 | ||
| 330 | 333 | spin_lock_init(&vhub->lock); | |
| 334 | + | INIT_WORK(&vhub->wake_work, ast_vhub_wake_work); | |
| 331 | 335 | vhub->pdev = pdev; | |
| 332 | 336 | vhub->port_irq_mask = GENMASK(VHUB_IRQ_DEV1_BIT + vhub->max_ports - 1, | |
| 333 | 337 | VHUB_IRQ_DEV1_BIT); | |
modified drivers/usb/gadget/udc/aspeed-vhub/dev.c
| @@ -280,7 +280,7 @@ static int ast_vhub_udc_wakeup(struct usb_gadget* gadget) | |||
| 280 | 280 | int rc = -EINVAL; | |
| 281 | 281 | ||
| 282 | 282 | spin_lock_irqsave(&d->vhub->lock, flags); | |
| 283 | - | if (!d->wakeup_en) | |
| 283 | + | if (!d->wakeup_en || !d->registered) | |
| 284 | 284 | goto err; | |
| 285 | 285 | ||
| 286 | 286 | DDBG(d, "Device initiated wakeup\n"); | |
modified drivers/usb/gadget/udc/aspeed-vhub/hub.c
| @@ -558,7 +558,7 @@ void ast_vhub_device_connect(struct ast_vhub *vhub, | |||
| 558 | 558 | ast_vhub_send_host_wakeup(vhub); | |
| 559 | 559 | } | |
| 560 | 560 | ||
| 561 | - | static void ast_vhub_wake_work(struct work_struct *work) | |
| 561 | + | void ast_vhub_wake_work(struct work_struct *work) | |
| 562 | 562 | { | |
| 563 | 563 | struct ast_vhub *vhub = container_of(work, | |
| 564 | 564 | struct ast_vhub, | |
| @@ -588,6 +588,8 @@ static void ast_vhub_wake_work(struct work_struct *work) | |||
| 588 | 588 | ||
| 589 | 589 | void ast_vhub_hub_wake_all(struct ast_vhub *vhub) | |
| 590 | 590 | { | |
| 591 | + | lockdep_assert_held(&vhub->lock); | |
| 592 | + | ||
| 591 | 593 | /* | |
| 592 | 594 | * A device is trying to wake the world, because this | |
| 593 | 595 | * can recurse into the device, we break the call chain | |
| @@ -1076,7 +1078,6 @@ static int ast_vhub_init_desc(struct ast_vhub *vhub) | |||
| 1076 | 1078 | int ast_vhub_init_hub(struct ast_vhub *vhub) | |
| 1077 | 1079 | { | |
| 1078 | 1080 | vhub->speed = USB_SPEED_UNKNOWN; | |
| 1079 | - | INIT_WORK(&vhub->wake_work, ast_vhub_wake_work); | |
| 1080 | 1081 | ||
| 1081 | 1082 | return ast_vhub_init_desc(vhub); | |
| 1082 | 1083 | } | |
modified drivers/usb/gadget/udc/aspeed-vhub/vhub.h
| @@ -547,6 +547,7 @@ void ast_vhub_hub_suspend(struct ast_vhub *vhub); | |||
| 547 | 547 | void ast_vhub_hub_resume(struct ast_vhub *vhub); | |
| 548 | 548 | void ast_vhub_hub_reset(struct ast_vhub *vhub); | |
| 549 | 549 | void ast_vhub_hub_wake_all(struct ast_vhub *vhub); | |
| 550 | + | void ast_vhub_wake_work(struct work_struct *work); | |
| 550 | 551 | ||
| 551 | 552 | /* dev.c */ | |
| 552 | 553 | int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx); | |
modified drivers/usb/gadget/udc/dummy_hcd.c
| @@ -343,9 +343,11 @@ static void dummy_giveback(struct dummy *dum, struct usb_ep *_ep, | |||
| 343 | 343 | { | |
| 344 | 344 | bool fifo = req == &dum->fifo_req; | |
| 345 | 345 | ||
| 346 | + | ++dum->callback_usage; | |
| 346 | 347 | spin_unlock(&dum->lock); | |
| 347 | 348 | usb_gadget_giveback_request(_ep, &req->req); | |
| 348 | 349 | spin_lock(&dum->lock); | |
| 350 | + | --dum->callback_usage; | |
| 349 | 351 | if (fifo) | |
| 350 | 352 | dum->fifo_req_busy = 0; | |
| 351 | 353 | } | |
| @@ -759,11 +761,13 @@ static int dummy_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
| 759 | 761 | req->req.complete = fifo_complete; | |
| 760 | 762 | ||
| 761 | 763 | list_add_tail(&req->queue, &ep->queue); | |
| 764 | + | ++dum->callback_usage; | |
| 762 | 765 | spin_unlock(&dum->lock); | |
| 763 | 766 | _req->actual = _req->length; | |
| 764 | 767 | _req->status = 0; | |
| 765 | 768 | usb_gadget_giveback_request(_ep, _req); | |
| 766 | 769 | spin_lock(&dum->lock); | |
| 770 | + | --dum->callback_usage; | |
| 767 | 771 | } else | |
| 768 | 772 | list_add_tail(&req->queue, &ep->queue); | |
| 769 | 773 | spin_unlock_irqrestore(&dum->lock, flags); | |
modified drivers/usb/host/octeon-hcd.c
| @@ -378,8 +378,22 @@ struct octeon_hcd { | |||
| 378 | 378 | struct cvmx_usb_transaction *active_split; | |
| 379 | 379 | struct cvmx_usb_tx_fifo periodic; | |
| 380 | 380 | struct cvmx_usb_tx_fifo nonperiodic; | |
| 381 | + | struct hrtimer sof_timer; | |
| 381 | 382 | }; | |
| 382 | 383 | ||
| 384 | + | static int cvmx_usb_poll(struct octeon_hcd *usb); | |
| 385 | + | ||
| 386 | + | static enum hrtimer_restart octeon_usb_sof_timer(struct hrtimer *t) | |
| 387 | + | { | |
| 388 | + | struct octeon_hcd *usb = container_of(t, struct octeon_hcd, sof_timer); | |
| 389 | + | unsigned long flags; | |
| 390 | + | ||
| 391 | + | spin_lock_irqsave(&usb->lock, flags); | |
| 392 | + | cvmx_usb_poll(usb); | |
| 393 | + | spin_unlock_irqrestore(&usb->lock, flags); | |
| 394 | + | return HRTIMER_NORESTART; | |
| 395 | + | } | |
| 396 | + | ||
| 383 | 397 | /* | |
| 384 | 398 | * This macro logically sets a single field in a CSR. It does the sequence | |
| 385 | 399 | * read, modify, and write | |
| @@ -578,7 +592,7 @@ static int cvmx_wait_tx_rx(struct octeon_hcd *usb, int fflsh_type) | |||
| 578 | 592 | int result; | |
| 579 | 593 | u64 address = CVMX_USBCX_GRSTCTL(usb->index); | |
| 580 | 594 | u64 done = cvmx_get_cycle() + 100 * | |
| 581 | - | (u64)octeon_get_clock_rate / 1000000; | |
| 595 | + | (u64)octeon_get_clock_rate() / 1000000; | |
| 582 | 596 | union cvmx_usbcx_grstctl c; | |
| 583 | 597 | ||
| 584 | 598 | while (1) { | |
| @@ -853,6 +867,14 @@ retry: | |||
| 853 | 867 | * USBC_GAHBCFG[PTXFEMPLVL] | |
| 854 | 868 | * Global interrupt mask, USBC_GAHBCFG[GLBLINTRMSK] = 1 | |
| 855 | 869 | */ | |
| 870 | + | usbcx_gahbcfg.u32 = cvmx_usb_read_csr32(usb, | |
| 871 | + | CVMX_USBCX_GHWCFG3(usb->index)); | |
| 872 | + | if (usbcx_gahbcfg.u32 == 0xffffffff || usbcx_gahbcfg.u32 == 0) { | |
| 873 | + | dev_err(dev, "USB core is not responding (GHWCFG3=0x%08x)\n", | |
| 874 | + | usbcx_gahbcfg.u32); | |
| 875 | + | return -ENODEV; | |
| 876 | + | } | |
| 877 | + | ||
| 856 | 878 | usbcx_gahbcfg.u32 = 0; | |
| 857 | 879 | usbcx_gahbcfg.s.dmaen = !(usb->init_flags & | |
| 858 | 880 | CVMX_USB_INITIALIZE_FLAGS_NO_DMA); | |
| @@ -1900,6 +1922,7 @@ static void cvmx_usb_schedule(struct octeon_hcd *usb, int is_sof) | |||
| 1900 | 1922 | int channel; | |
| 1901 | 1923 | struct cvmx_usb_pipe *pipe; | |
| 1902 | 1924 | int need_sof; | |
| 1925 | + | u64 min_due; | |
| 1903 | 1926 | enum cvmx_usb_transfer ttype; | |
| 1904 | 1927 | ||
| 1905 | 1928 | if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { | |
| @@ -1940,15 +1963,33 @@ done: | |||
| 1940 | 1963 | * future that might need to be scheduled | |
| 1941 | 1964 | */ | |
| 1942 | 1965 | need_sof = 0; | |
| 1966 | + | min_due = ~0ull; | |
| 1943 | 1967 | for (ttype = CVMX_USB_TRANSFER_CONTROL; | |
| 1944 | 1968 | ttype <= CVMX_USB_TRANSFER_INTERRUPT; ttype++) { | |
| 1945 | 1969 | list_for_each_entry(pipe, &usb->active_pipes[ttype], node) { | |
| 1946 | - | if (pipe->next_tx_frame > usb->frame_number) { | |
| 1947 | - | need_sof = 1; | |
| 1948 | - | break; | |
| 1949 | - | } | |
| 1970 | + | if (pipe->next_tx_frame > usb->frame_number && | |
| 1971 | + | pipe->next_tx_frame < min_due) | |
| 1972 | + | min_due = pipe->next_tx_frame; | |
| 1950 | 1973 | } | |
| 1951 | 1974 | } | |
| 1975 | + | if (min_due != ~0ull) { | |
| 1976 | + | u64 delta = min_due - usb->frame_number; | |
| 1977 | + | ||
| 1978 | + | /* | |
| 1979 | + | * frame_number is resynced from HFNUM on every poll, so a | |
| 1980 | + | * deadline that is many frames away does not need an | |
| 1981 | + | * interrupt on every SOF to count them down - sleep on the | |
| 1982 | + | * timer instead and keep SOF interrupts for deadlines within | |
| 1983 | + | * a few frames. Stay well below the 16383-frame wrap of | |
| 1984 | + | * HFNUM. One (micro)frame is 125us in high-speed mode. | |
| 1985 | + | */ | |
| 1986 | + | if (delta <= 4 || delta > 8000) | |
| 1987 | + | need_sof = 1; | |
| 1988 | + | else | |
| 1989 | + | hrtimer_start(&usb->sof_timer, | |
| 1990 | + | ns_to_ktime((delta - 2) * 125000), | |
| 1991 | + | HRTIMER_MODE_REL); | |
| 1992 | + | } | |
| 1952 | 1993 | USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), | |
| 1953 | 1994 | cvmx_usbcx_gintmsk, sofmsk, need_sof); | |
| 1954 | 1995 | } | |
| @@ -3638,6 +3679,8 @@ static int octeon_usb_probe(struct platform_device *pdev) | |||
| 3638 | 3679 | usb = (struct octeon_hcd *)hcd->hcd_priv; | |
| 3639 | 3680 | ||
| 3640 | 3681 | spin_lock_init(&usb->lock); | |
| 3682 | + | hrtimer_setup(&usb->sof_timer, octeon_usb_sof_timer, CLOCK_MONOTONIC, | |
| 3683 | + | HRTIMER_MODE_REL); | |
| 3641 | 3684 | ||
| 3642 | 3685 | usb->init_flags = initialize_flags; | |
| 3643 | 3686 | ||
| @@ -3688,6 +3731,7 @@ static void octeon_usb_remove(struct platform_device *pdev) | |||
| 3688 | 3731 | unsigned long flags; | |
| 3689 | 3732 | ||
| 3690 | 3733 | usb_remove_hcd(hcd); | |
| 3734 | + | hrtimer_cancel(&usb->sof_timer); | |
| 3691 | 3735 | spin_lock_irqsave(&usb->lock, flags); | |
| 3692 | 3736 | status = cvmx_usb_shutdown(usb); | |
| 3693 | 3737 | spin_unlock_irqrestore(&usb->lock, flags); | |
modified drivers/usb/host/ohci-da8xx.c
| @@ -447,6 +447,7 @@ static int ohci_da8xx_probe(struct platform_device *pdev) | |||
| 447 | 447 | ||
| 448 | 448 | err_remove_hcd: | |
| 449 | 449 | usb_remove_hcd(hcd); | |
| 450 | + | device_wakeup_disable(hcd->self.controller); | |
| 450 | 451 | err: | |
| 451 | 452 | usb_put_hcd(hcd); | |
| 452 | 453 | return error; | |
| @@ -457,6 +458,7 @@ static void ohci_da8xx_remove(struct platform_device *pdev) | |||
| 457 | 458 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | |
| 458 | 459 | ||
| 459 | 460 | usb_remove_hcd(hcd); | |
| 461 | + | device_wakeup_disable(hcd->self.controller); | |
| 460 | 462 | usb_put_hcd(hcd); | |
| 461 | 463 | } | |
| 462 | 464 | ||
modified drivers/usb/host/ohci-s3c2410.c
| @@ -335,6 +335,7 @@ ohci_hcd_s3c2410_remove(struct platform_device *dev) | |||
| 335 | 335 | struct usb_hcd *hcd = platform_get_drvdata(dev); | |
| 336 | 336 | ||
| 337 | 337 | usb_remove_hcd(hcd); | |
| 338 | + | device_wakeup_disable(hcd->self.controller); | |
| 338 | 339 | s3c2410_stop_hc(dev); | |
| 339 | 340 | usb_put_hcd(hcd); | |
| 340 | 341 | } | |
modified drivers/usb/host/ohci-spear.c
| @@ -103,6 +103,7 @@ static void spear_ohci_hcd_drv_remove(struct platform_device *pdev) | |||
| 103 | 103 | struct spear_ohci *sohci_p = to_spear_ohci(hcd); | |
| 104 | 104 | ||
| 105 | 105 | usb_remove_hcd(hcd); | |
| 106 | + | device_wakeup_disable(hcd->self.controller); | |
| 106 | 107 | clk_disable_unprepare(sohci_p->clk); | |
| 107 | 108 | ||
| 108 | 109 | usb_put_hcd(hcd); | |
modified drivers/usb/host/ohci-st.c
| @@ -235,6 +235,7 @@ static void st_ohci_platform_remove(struct platform_device *dev) | |||
| 235 | 235 | int clk; | |
| 236 | 236 | ||
| 237 | 237 | usb_remove_hcd(hcd); | |
| 238 | + | device_wakeup_disable(hcd->self.controller); | |
| 238 | 239 | ||
| 239 | 240 | if (pdata->power_off) | |
| 240 | 241 | pdata->power_off(dev); | |
modified drivers/usb/mtu3/mtu3_trace.h
| @@ -224,6 +224,7 @@ DECLARE_EVENT_CLASS(mtu3_log_ep, | |||
| 224 | 224 | __field(unsigned int, flags) | |
| 225 | 225 | __field(unsigned int, direction) | |
| 226 | 226 | __field(struct mtu3_gpd_ring *, gpd_ring) | |
| 227 | + | __field(dma_addr_t, gpd_ring_dma) | |
| 227 | 228 | ), | |
| 228 | 229 | TP_fast_assign( | |
| 229 | 230 | __assign_str(name); | |
| @@ -235,12 +236,13 @@ DECLARE_EVENT_CLASS(mtu3_log_ep, | |||
| 235 | 236 | __entry->flags = mep->flags; | |
| 236 | 237 | __entry->direction = mep->is_in; | |
| 237 | 238 | __entry->gpd_ring = &mep->gpd_ring; | |
| 239 | + | __entry->gpd_ring_dma = mep->gpd_ring.dma | |
| 238 | 240 | ), | |
| 239 | 241 | TP_printk("%s: type %s maxp %d slot %d mult %d burst %d ring %p/%pad flags %c:%c%c%c:%c", | |
| 240 | 242 | __get_str(name), usb_ep_type_string(__entry->type), | |
| 241 | 243 | __entry->maxp, __entry->slot, | |
| 242 | 244 | __entry->mult, __entry->maxburst, | |
| 243 | - | __entry->gpd_ring, &__entry->gpd_ring->dma, | |
| 245 | + | __entry->gpd_ring, &__entry->gpd_ring_dma, | |
| 244 | 246 | __entry->flags & MTU3_EP_ENABLED ? 'E' : 'e', | |
| 245 | 247 | __entry->flags & MTU3_EP_STALL ? 'S' : 's', | |
| 246 | 248 | __entry->flags & MTU3_EP_WEDGE ? 'W' : 'w', | |
modified drivers/usb/serial/bus.c
| @@ -165,7 +165,11 @@ int usb_serial_bus_register(struct usb_serial_driver *driver) | |||
| 165 | 165 | ||
| 166 | 166 | void usb_serial_bus_deregister(struct usb_serial_driver *driver) | |
| 167 | 167 | { | |
| 168 | - | free_dynids(driver); | |
| 169 | 168 | driver_unregister(&driver->driver); | |
| 169 | + | free_dynids(driver); | |
| 170 | 170 | } | |
| 171 | 171 | ||
| 172 | + | void usb_serial_bus_remove_new_id(struct usb_serial_driver *driver) | |
| 173 | + | { | |
| 174 | + | driver_remove_file(&driver->driver, &driver_attr_new_id); | |
| 175 | + | } | |
modified drivers/usb/serial/cp210x.c
| @@ -223,6 +223,7 @@ static const struct usb_device_id id_table[] = { | |||
| 223 | 223 | { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */ | |
| 224 | 224 | { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ | |
| 225 | 225 | { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */ | |
| 226 | + | { USB_DEVICE(0x1B1C, 0x1C02) }, /* Corsair AX1500i Power Supply */ | |
| 226 | 227 | { USB_DEVICE(0x1B93, 0x1013) }, /* Phoenix Contact UPS Device */ | |
| 227 | 228 | { USB_DEVICE(0x1BA4, 0x0002) }, /* Silicon Labs 358x factory default */ | |
| 228 | 229 | { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ | |
modified drivers/usb/serial/generic.c
| @@ -266,6 +266,7 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_chars_in_buffer); | |||
| 266 | 266 | void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout) | |
| 267 | 267 | { | |
| 268 | 268 | struct usb_serial_port *port = tty->driver_data; | |
| 269 | + | struct tty_port *tport = &port->port; | |
| 269 | 270 | unsigned int bps; | |
| 270 | 271 | unsigned long period; | |
| 271 | 272 | unsigned long expire; | |
| @@ -285,7 +286,14 @@ void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout) | |||
| 285 | 286 | __func__, jiffies_to_msecs(timeout), | |
| 286 | 287 | jiffies_to_msecs(period)); | |
| 287 | 288 | expire = jiffies + timeout; | |
| 288 | - | while (!port->serial->type->tx_empty(port)) { | |
| 289 | + | for (;;) { | |
| 290 | + | mutex_lock(&tport->mutex); | |
| 291 | + | if (tty_io_error(tty) || port->serial->type->tx_empty(port)) { | |
| 292 | + | mutex_unlock(&tport->mutex); | |
| 293 | + | break; | |
| 294 | + | } | |
| 295 | + | mutex_unlock(&tport->mutex); | |
| 296 | + | ||
| 289 | 297 | schedule_timeout_interruptible(period); | |
| 290 | 298 | if (signal_pending(current)) | |
| 291 | 299 | break; | |
modified drivers/usb/serial/option.c
| @@ -260,6 +260,7 @@ static void option_instat_callback(struct urb *urb); | |||
| 260 | 260 | #define QUECTEL_PRODUCT_EM060K_12a 0x012a | |
| 261 | 261 | #define QUECTEL_PRODUCT_EM060K_12b 0x012b | |
| 262 | 262 | #define QUECTEL_PRODUCT_EM060K_12c 0x012c | |
| 263 | + | #define QUECTEL_PRODUCT_RG660QB 0x013d | |
| 263 | 264 | #define QUECTEL_PRODUCT_EG91 0x0191 | |
| 264 | 265 | #define QUECTEL_PRODUCT_EG95 0x0195 | |
| 265 | 266 | #define QUECTEL_PRODUCT_BG96 0x0296 | |
| @@ -280,6 +281,7 @@ static void option_instat_callback(struct urb *urb); | |||
| 280 | 281 | #define QUECTEL_PRODUCT_EC200U 0x0901 | |
| 281 | 282 | #define QUECTEL_PRODUCT_EG912Y 0x6001 | |
| 282 | 283 | #define QUECTEL_PRODUCT_EC200S_CN 0x6002 | |
| 284 | + | #define QUECTEL_PRODUCT_EG060W 0x6004 | |
| 283 | 285 | #define QUECTEL_PRODUCT_EC200A 0x6005 | |
| 284 | 286 | #define QUECTEL_PRODUCT_EG916Q 0x6007 | |
| 285 | 287 | #define QUECTEL_PRODUCT_EM061K_LWW 0x6008 | |
| @@ -1268,12 +1270,15 @@ static const struct usb_device_id option_ids[] = { | |||
| 1268 | 1270 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200A, 0xff, 0, 0) }, | |
| 1269 | 1271 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200U, 0xff, 0, 0) }, | |
| 1270 | 1272 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200S_CN, 0xff, 0, 0) }, | |
| 1273 | + | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG060W, 0xff, 0, 0) }, | |
| 1271 | 1274 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200T, 0xff, 0, 0) }, | |
| 1272 | 1275 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG912Y, 0xff, 0, 0) }, | |
| 1273 | 1276 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG916Q, 0xff, 0x00, 0x00) }, | |
| 1274 | 1277 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500K, 0xff, 0x00, 0x00) }, | |
| 1275 | 1278 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG650V, 0xff, 0xff, 0x30) }, | |
| 1276 | 1279 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG650V, 0xff, 0, 0) }, | |
| 1280 | + | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG660QB, 0xff, 0xff, 0x30) }, | |
| 1281 | + | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG660QB, 0xff, 0, 0) }, | |
| 1277 | 1282 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG255C, 0xff, 0xff, 0x30) }, | |
| 1278 | 1283 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG255C, 0xff, 0, 0) }, | |
| 1279 | 1284 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG255C, 0xff, 0xff, 0x40) }, | |
| @@ -2168,6 +2173,8 @@ static const struct usb_device_id option_ids[] = { | |||
| 2168 | 2173 | { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9003, 0xff) }, /* Simcom SIM7500/SIM7600 MBIM mode */ | |
| 2169 | 2174 | { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9011, 0xff), /* Simcom SIM7500/SIM7600 RNDIS mode */ | |
| 2170 | 2175 | .driver_info = RSVD(7) }, | |
| 2176 | + | { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x902b, 0xff), | |
| 2177 | + | .driver_info = RSVD(4) }, | |
| 2171 | 2178 | { USB_DEVICE(0x1e0e, 0x9071), /* Simcom SIM8230 RMNET mode */ | |
| 2172 | 2179 | .driver_info = RSVD(3) | RSVD(4) }, | |
| 2173 | 2180 | { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9078, 0xff), /* Simcom SIM8230 ECM mode */ | |
| @@ -2429,6 +2436,13 @@ static const struct usb_device_id option_ids[] = { | |||
| 2429 | 2436 | .driver_info = RSVD(5) }, | |
| 2430 | 2437 | { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe167, 0xff), /* Foxconn T99W640 MBIM */ | |
| 2431 | 2438 | .driver_info = RSVD(3) }, | |
| 2439 | + | { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x01) }, /* Compal EXC-T1 */ | |
| 2440 | + | { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x02) }, | |
| 2441 | + | { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x03) }, | |
| 2442 | + | { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x04) }, | |
| 2443 | + | { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x30) }, /* Compal EXM-G1x */ | |
| 2444 | + | { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x40) }, | |
| 2445 | + | { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x60) }, | |
| 2432 | 2446 | { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 (IOT version) */ | |
| 2433 | 2447 | .driver_info = RSVD(4) | RSVD(5) | RSVD(6) }, | |
| 2434 | 2448 | { USB_DEVICE(0x1782, 0x4d10) }, /* Fibocom L610 (AT mode) */ | |
modified drivers/usb/serial/quatech2.c
| @@ -52,6 +52,7 @@ | |||
| 52 | 52 | #define QT2_XMIT_FLUSH 0x05 /* no following info */ | |
| 53 | 53 | #define QT2_CONTROL_ESCAPE 0xff /* pass through previous 2 control bytes */ | |
| 54 | 54 | ||
| 55 | + | #define MIN_BAUD_RATE 50 | |
| 55 | 56 | #define MAX_BAUD_RATE 921600 | |
| 56 | 57 | #define DEFAULT_BAUD_RATE 9600 | |
| 57 | 58 | ||
| @@ -156,7 +157,7 @@ static inline int calc_baud_divisor(int baudrate) | |||
| 156 | 157 | ||
| 157 | 158 | static inline int qt2_set_port_config(struct usb_device *dev, | |
| 158 | 159 | unsigned char port_number, | |
| 159 | - | u16 baudrate, u16 lcr) | |
| 160 | + | speed_t baudrate, u16 lcr) | |
| 160 | 161 | { | |
| 161 | 162 | int divisor = calc_baud_divisor(baudrate); | |
| 162 | 163 | u16 index = ((u16) (lcr << 8) | (u16) (port_number)); | |
| @@ -257,9 +258,9 @@ static void qt2_set_termios(struct tty_struct *tty, | |||
| 257 | 258 | struct usb_device *dev = port->serial->dev; | |
| 258 | 259 | struct qt2_port_private *port_priv; | |
| 259 | 260 | struct ktermios *termios = &tty->termios; | |
| 260 | - | u16 baud; | |
| 261 | 261 | unsigned int cflag = termios->c_cflag; | |
| 262 | 262 | u16 new_lcr = 0; | |
| 263 | + | speed_t baud; | |
| 263 | 264 | int status; | |
| 264 | 265 | ||
| 265 | 266 | port_priv = usb_get_serial_port_data(port); | |
| @@ -277,6 +278,18 @@ static void qt2_set_termios(struct tty_struct *tty, | |||
| 277 | 278 | if (!baud) | |
| 278 | 279 | baud = 9600; | |
| 279 | 280 | ||
| 281 | + | if (baud < MIN_BAUD_RATE || baud > MAX_BAUD_RATE) { | |
| 282 | + | if (old_termios) | |
| 283 | + | baud = tty_termios_baud_rate(old_termios); | |
| 284 | + | else | |
| 285 | + | baud = clamp(baud, MIN_BAUD_RATE, MAX_BAUD_RATE); | |
| 286 | + | ||
| 287 | + | tty_encode_baud_rate(tty, baud, baud); | |
| 288 | + | ||
| 289 | + | if (!baud) | |
| 290 | + | baud = 9600; | |
| 291 | + | } | |
| 292 | + | ||
| 280 | 293 | status = qt2_set_port_config(dev, port_priv->device_port, baud, | |
| 281 | 294 | new_lcr); | |
| 282 | 295 | if (status < 0) | |
| @@ -373,7 +386,7 @@ static int qt2_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
| 373 | 386 | port_priv->device_port = (u8) device_port; | |
| 374 | 387 | ||
| 375 | 388 | if (tty) | |
| 376 | - | qt2_set_termios(tty, port, &tty->termios); | |
| 389 | + | qt2_set_termios(tty, port, NULL); | |
| 377 | 390 | ||
| 378 | 391 | return 0; | |
| 379 | 392 | ||
modified drivers/usb/serial/ssu100.c
| @@ -32,6 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | 33 | #define SERIAL_EVEN_PARITY (UART_LCR_PARITY | UART_LCR_EPAR) | |
| 34 | 34 | ||
| 35 | + | #define MIN_BAUD_RATE 50 | |
| 35 | 36 | #define MAX_BAUD_RATE 460800 | |
| 36 | 37 | ||
| 37 | 38 | #define ATC_DISABLED 0x00 | |
| @@ -217,9 +218,10 @@ static void ssu100_set_termios(struct tty_struct *tty, | |||
| 217 | 218 | { | |
| 218 | 219 | struct usb_device *dev = port->serial->dev; | |
| 219 | 220 | struct ktermios *termios = &tty->termios; | |
| 220 | - | u16 baud, divisor, remainder; | |
| 221 | + | speed_t baud, remainder; | |
| 221 | 222 | unsigned int cflag = termios->c_cflag; | |
| 222 | 223 | u16 urb_value = 0; /* will hold the new flags */ | |
| 224 | + | u16 divisor; | |
| 223 | 225 | int result; | |
| 224 | 226 | ||
| 225 | 227 | if (cflag & PARENB) { | |
| @@ -235,6 +237,18 @@ static void ssu100_set_termios(struct tty_struct *tty, | |||
| 235 | 237 | if (!baud) | |
| 236 | 238 | baud = 9600; | |
| 237 | 239 | ||
| 240 | + | if (baud < MIN_BAUD_RATE || baud > MAX_BAUD_RATE) { | |
| 241 | + | if (old_termios) | |
| 242 | + | baud = tty_termios_baud_rate(old_termios); | |
| 243 | + | else | |
| 244 | + | baud = clamp(baud, MIN_BAUD_RATE, MAX_BAUD_RATE); | |
| 245 | + | ||
| 246 | + | tty_encode_baud_rate(tty, baud, baud); | |
| 247 | + | ||
| 248 | + | if (!baud) | |
| 249 | + | baud = 9600; | |
| 250 | + | } | |
| 251 | + | ||
| 238 | 252 | dev_dbg(&port->dev, "%s - got baud = %d\n", __func__, baud); | |
| 239 | 253 | ||
| 240 | 254 | ||
| @@ -310,7 +324,7 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
| 310 | 324 | dev_dbg(&port->dev, "%s - set uart failed\n", __func__); | |
| 311 | 325 | ||
| 312 | 326 | if (tty) | |
| 313 | - | ssu100_set_termios(tty, port, &tty->termios); | |
| 327 | + | ssu100_set_termios(tty, port, NULL); | |
| 314 | 328 | ||
| 315 | 329 | return usb_serial_generic_open(tty, port); | |
| 316 | 330 | } | |
modified drivers/usb/serial/usb-serial.c
| @@ -400,17 +400,13 @@ static unsigned int serial_chars_in_buffer(struct tty_struct *tty) | |||
| 400 | 400 | static void serial_wait_until_sent(struct tty_struct *tty, int timeout) | |
| 401 | 401 | { | |
| 402 | 402 | struct usb_serial_port *port = tty->driver_data; | |
| 403 | - | struct usb_serial *serial = port->serial; | |
| 404 | 403 | ||
| 405 | 404 | dev_dbg(&port->dev, "%s\n", __func__); | |
| 406 | 405 | ||
| 407 | 406 | if (!port->serial->type->wait_until_sent) | |
| 408 | 407 | return; | |
| 409 | 408 | ||
| 410 | - | mutex_lock(&serial->disc_mutex); | |
| 411 | - | if (!serial->disconnected) | |
| 412 | - | port->serial->type->wait_until_sent(tty, timeout); | |
| 413 | - | mutex_unlock(&serial->disc_mutex); | |
| 409 | + | port->serial->type->wait_until_sent(tty, timeout); | |
| 414 | 410 | } | |
| 415 | 411 | ||
| 416 | 412 | static void serial_throttle(struct tty_struct *tty) | |
| @@ -438,8 +434,13 @@ static int serial_get_serial(struct tty_struct *tty, struct serial_struct *ss) | |||
| 438 | 434 | struct usb_serial_port *port = tty->driver_data; | |
| 439 | 435 | struct tty_port *tport = &port->port; | |
| 440 | 436 | unsigned int close_delay, closing_wait; | |
| 437 | + | int ret = 0; | |
| 441 | 438 | ||
| 442 | 439 | mutex_lock(&tport->mutex); | |
| 440 | + | if (tty_io_error(tty)) { | |
| 441 | + | ret = -EIO; | |
| 442 | + | goto out_unlock; | |
| 443 | + | } | |
| 443 | 444 | ||
| 444 | 445 | close_delay = jiffies_to_msecs(tport->close_delay) / 10; | |
| 445 | 446 | closing_wait = tport->closing_wait; | |
| @@ -452,10 +453,10 @@ static int serial_get_serial(struct tty_struct *tty, struct serial_struct *ss) | |||
| 452 | 453 | ||
| 453 | 454 | if (port->serial->type->get_serial) | |
| 454 | 455 | port->serial->type->get_serial(tty, ss); | |
| 455 | - | ||
| 456 | + | out_unlock: | |
| 456 | 457 | mutex_unlock(&tport->mutex); | |
| 457 | 458 | ||
| 458 | - | return 0; | |
| 459 | + | return ret; | |
| 459 | 460 | } | |
| 460 | 461 | ||
| 461 | 462 | static int serial_set_serial(struct tty_struct *tty, struct serial_struct *ss) | |
| @@ -471,6 +472,10 @@ static int serial_set_serial(struct tty_struct *tty, struct serial_struct *ss) | |||
| 471 | 472 | closing_wait = msecs_to_jiffies(closing_wait * 10); | |
| 472 | 473 | ||
| 473 | 474 | mutex_lock(&tport->mutex); | |
| 475 | + | if (tty_io_error(tty)) { | |
| 476 | + | ret = -EIO; | |
| 477 | + | goto out_unlock; | |
| 478 | + | } | |
| 474 | 479 | ||
| 475 | 480 | if (!capable(CAP_SYS_ADMIN)) { | |
| 476 | 481 | if (close_delay != tport->close_delay || | |
| @@ -498,6 +503,7 @@ static int serial_ioctl(struct tty_struct *tty, | |||
| 498 | 503 | unsigned int cmd, unsigned long arg) | |
| 499 | 504 | { | |
| 500 | 505 | struct usb_serial_port *port = tty->driver_data; | |
| 506 | + | struct tty_port *tport = &port->port; | |
| 501 | 507 | int retval = -ENOIOCTLCMD; | |
| 502 | 508 | ||
| 503 | 509 | dev_dbg(&port->dev, "%s - cmd 0x%04x\n", __func__, cmd); | |
| @@ -508,8 +514,21 @@ static int serial_ioctl(struct tty_struct *tty, | |||
| 508 | 514 | retval = port->serial->type->tiocmiwait(tty, arg); | |
| 509 | 515 | break; | |
| 510 | 516 | default: | |
| 511 | - | if (port->serial->type->ioctl) | |
| 517 | + | if (!port->serial->type->ioctl) | |
| 518 | + | break; | |
| 519 | + | ||
| 520 | + | if (cmd == TIOCSRS485) | |
| 521 | + | down_write(&tty->termios_rwsem); | |
| 522 | + | ||
| 523 | + | mutex_lock(&tport->mutex); | |
| 524 | + | if (tty_io_error(tty)) | |
| 525 | + | retval = -EIO; | |
| 526 | + | else | |
| 512 | 527 | retval = port->serial->type->ioctl(tty, cmd, arg); | |
| 528 | + | mutex_unlock(&tport->mutex); | |
| 529 | + | ||
| 530 | + | if (cmd == TIOCSRS485) | |
| 531 | + | up_write(&tty->termios_rwsem); | |
| 513 | 532 | } | |
| 514 | 533 | ||
| 515 | 534 | return retval; | |
| @@ -519,25 +538,40 @@ static void serial_set_termios(struct tty_struct *tty, | |||
| 519 | 538 | const struct ktermios *old) | |
| 520 | 539 | { | |
| 521 | 540 | struct usb_serial_port *port = tty->driver_data; | |
| 541 | + | struct tty_port *tport = &port->port; | |
| 522 | 542 | ||
| 523 | 543 | dev_dbg(&port->dev, "%s\n", __func__); | |
| 524 | 544 | ||
| 525 | - | if (port->serial->type->set_termios) | |
| 526 | - | port->serial->type->set_termios(tty, port, old); | |
| 527 | - | else | |
| 545 | + | if (!port->serial->type->set_termios) { | |
| 528 | 546 | tty_termios_copy_hw(&tty->termios, old); | |
| 547 | + | return; | |
| 548 | + | } | |
| 549 | + | ||
| 550 | + | mutex_lock(&tport->mutex); | |
| 551 | + | if (!tty_io_error(tty)) | |
| 552 | + | port->serial->type->set_termios(tty, port, old); | |
| 553 | + | mutex_unlock(&tport->mutex); | |
| 529 | 554 | } | |
| 530 | 555 | ||
| 531 | 556 | static int serial_break(struct tty_struct *tty, int break_state) | |
| 532 | 557 | { | |
| 533 | 558 | struct usb_serial_port *port = tty->driver_data; | |
| 559 | + | struct tty_port *tport = &port->port; | |
| 560 | + | int ret; | |
| 534 | 561 | ||
| 535 | 562 | dev_dbg(&port->dev, "%s\n", __func__); | |
| 536 | 563 | ||
| 537 | - | if (port->serial->type->break_ctl) | |
| 538 | - | return port->serial->type->break_ctl(tty, break_state); | |
| 564 | + | if (!port->serial->type->break_ctl) | |
| 565 | + | return -ENOTTY; | |
| 539 | 566 | ||
| 540 | - | return -ENOTTY; | |
| 567 | + | mutex_lock(&tport->mutex); | |
| 568 | + | if (tty_io_error(tty)) | |
| 569 | + | ret = -EIO; | |
| 570 | + | else | |
| 571 | + | ret = port->serial->type->break_ctl(tty, break_state); | |
| 572 | + | mutex_unlock(&tport->mutex); | |
| 573 | + | ||
| 574 | + | return ret; | |
| 541 | 575 | } | |
| 542 | 576 | ||
| 543 | 577 | static int serial_proc_show(struct seq_file *m, void *v) | |
| @@ -578,24 +612,44 @@ static int serial_proc_show(struct seq_file *m, void *v) | |||
| 578 | 612 | static int serial_tiocmget(struct tty_struct *tty) | |
| 579 | 613 | { | |
| 580 | 614 | struct usb_serial_port *port = tty->driver_data; | |
| 615 | + | struct tty_port *tport = &port->port; | |
| 616 | + | int ret; | |
| 581 | 617 | ||
| 582 | 618 | dev_dbg(&port->dev, "%s\n", __func__); | |
| 583 | 619 | ||
| 584 | - | if (port->serial->type->tiocmget) | |
| 585 | - | return port->serial->type->tiocmget(tty); | |
| 586 | - | return -ENOTTY; | |
| 620 | + | if (!port->serial->type->tiocmget) | |
| 621 | + | return -ENOTTY; | |
| 622 | + | ||
| 623 | + | mutex_lock(&tport->mutex); | |
| 624 | + | if (tty_io_error(tty)) | |
| 625 | + | ret = -EIO; | |
| 626 | + | else | |
| 627 | + | ret = port->serial->type->tiocmget(tty); | |
| 628 | + | mutex_unlock(&tport->mutex); | |
| 629 | + | ||
| 630 | + | return ret; | |
| 587 | 631 | } | |
| 588 | 632 | ||
| 589 | 633 | static int serial_tiocmset(struct tty_struct *tty, | |
| 590 | 634 | unsigned int set, unsigned int clear) | |
| 591 | 635 | { | |
| 592 | 636 | struct usb_serial_port *port = tty->driver_data; | |
| 637 | + | struct tty_port *tport = &port->port; | |
| 638 | + | int ret; | |
| 593 | 639 | ||
| 594 | 640 | dev_dbg(&port->dev, "%s\n", __func__); | |
| 595 | 641 | ||
| 596 | - | if (port->serial->type->tiocmset) | |
| 597 | - | return port->serial->type->tiocmset(tty, set, clear); | |
| 598 | - | return -ENOTTY; | |
| 642 | + | if (!port->serial->type->tiocmset) | |
| 643 | + | return -ENOTTY; | |
| 644 | + | ||
| 645 | + | mutex_lock(&tport->mutex); | |
| 646 | + | if (tty_io_error(tty)) | |
| 647 | + | ret = -EIO; | |
| 648 | + | else | |
| 649 | + | ret = port->serial->type->tiocmset(tty, set, clear); | |
| 650 | + | mutex_unlock(&tport->mutex); | |
| 651 | + | ||
| 652 | + | return ret; | |
| 599 | 653 | } | |
| 600 | 654 | ||
| 601 | 655 | static int serial_get_icount(struct tty_struct *tty, | |
| @@ -1191,12 +1245,17 @@ static void usb_serial_disconnect(struct usb_interface *interface) | |||
| 1191 | 1245 | usb_serial_port_poison_urbs(port); | |
| 1192 | 1246 | wake_up_interruptible(&port->port.delta_msr_wait); | |
| 1193 | 1247 | cancel_work_sync(&port->work); | |
| 1194 | - | if (device_is_registered(&port->dev)) | |
| 1195 | - | device_del(&port->dev); | |
| 1196 | 1248 | } | |
| 1249 | + | ||
| 1197 | 1250 | if (serial->type->disconnect) | |
| 1198 | 1251 | serial->type->disconnect(serial); | |
| 1199 | 1252 | ||
| 1253 | + | for (i = 0; i < serial->num_ports; ++i) { | |
| 1254 | + | port = serial->port[i]; | |
| 1255 | + | if (device_is_registered(&port->dev)) | |
| 1256 | + | device_del(&port->dev); | |
| 1257 | + | } | |
| 1258 | + | ||
| 1200 | 1259 | release_sibling(serial, interface); | |
| 1201 | 1260 | ||
| 1202 | 1261 | /* let the last holder of this object cause it to be cleaned up */ | |
| @@ -1313,7 +1372,8 @@ static int __init usb_serial_init(void) | |||
| 1313 | 1372 | int result; | |
| 1314 | 1373 | ||
| 1315 | 1374 | usb_serial_tty_driver = tty_alloc_driver(USB_SERIAL_TTY_MINORS, | |
| 1316 | - | TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); | |
| 1375 | + | TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | | |
| 1376 | + | TTY_DRIVER_RESET_SAVED_TERMIOS); | |
| 1317 | 1377 | if (IS_ERR(usb_serial_tty_driver)) | |
| 1318 | 1378 | return PTR_ERR(usb_serial_tty_driver); | |
| 1319 | 1379 | ||
| @@ -1464,7 +1524,7 @@ int __usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers | |||
| 1464 | 1524 | { | |
| 1465 | 1525 | int rc; | |
| 1466 | 1526 | struct usb_driver *udriver; | |
| 1467 | - | struct usb_serial_driver * const *sd; | |
| 1527 | + | struct usb_serial_driver * const *sd, * const *s; | |
| 1468 | 1528 | ||
| 1469 | 1529 | /* | |
| 1470 | 1530 | * udriver must be registered before any of the serial drivers, | |
| @@ -1517,9 +1577,11 @@ int __usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers | |||
| 1517 | 1577 | return 0; | |
| 1518 | 1578 | ||
| 1519 | 1579 | err_deregister_drivers: | |
| 1580 | + | for (s = serial_drivers; s < sd; ++s) | |
| 1581 | + | usb_serial_bus_remove_new_id(*s); | |
| 1582 | + | usb_deregister(udriver); | |
| 1520 | 1583 | while (sd-- > serial_drivers) | |
| 1521 | 1584 | usb_serial_deregister(*sd); | |
| 1522 | - | usb_deregister(udriver); | |
| 1523 | 1585 | err_free_driver: | |
| 1524 | 1586 | kfree(udriver); | |
| 1525 | 1587 | return rc; | |
| @@ -1537,10 +1599,23 @@ EXPORT_SYMBOL_GPL(__usb_serial_register_drivers); | |||
| 1537 | 1599 | void usb_serial_deregister_drivers(struct usb_serial_driver *const serial_drivers[]) | |
| 1538 | 1600 | { | |
| 1539 | 1601 | struct usb_driver *udriver = (*serial_drivers)->usb_driver; | |
| 1602 | + | struct usb_serial_driver * const *sd; | |
| 1603 | + | ||
| 1604 | + | /* | |
| 1605 | + | * udriver must be deregistered before the serial drivers so that | |
| 1606 | + | * I/O is stopped before unbinding the ports. | |
| 1607 | + | * | |
| 1608 | + | * Remove the new_id attributes to prevent ids from being added and | |
| 1609 | + | * triggering a probe of udriver after it has been deregistered. | |
| 1610 | + | */ | |
| 1611 | + | for (sd = serial_drivers; *sd; ++sd) | |
| 1612 | + | usb_serial_bus_remove_new_id(*sd); | |
| 1540 | 1613 | ||
| 1541 | - | for (; *serial_drivers; ++serial_drivers) | |
| 1542 | - | usb_serial_deregister(*serial_drivers); | |
| 1543 | 1614 | usb_deregister(udriver); | |
| 1615 | + | ||
| 1616 | + | for (sd = serial_drivers; *sd; ++sd) | |
| 1617 | + | usb_serial_deregister(*sd); | |
| 1618 | + | ||
| 1544 | 1619 | kfree(udriver); | |
| 1545 | 1620 | } | |
| 1546 | 1621 | EXPORT_SYMBOL_GPL(usb_serial_deregister_drivers); | |
modified drivers/usb/serial/xr_serial.c
| @@ -850,12 +850,9 @@ static int xr_get_rs485_config(struct tty_struct *tty, | |||
| 850 | 850 | struct usb_serial_port *port = tty->driver_data; | |
| 851 | 851 | struct xr_data *data = usb_get_serial_port_data(port); | |
| 852 | 852 | ||
| 853 | - | down_read(&tty->termios_rwsem); | |
| 854 | - | if (copy_to_user(argp, &data->rs485, sizeof(data->rs485))) { | |
| 855 | - | up_read(&tty->termios_rwsem); | |
| 853 | + | /* core holds port mutex */ | |
| 854 | + | if (copy_to_user(argp, &data->rs485, sizeof(data->rs485))) | |
| 856 | 855 | return -EFAULT; | |
| 857 | - | } | |
| 858 | - | up_read(&tty->termios_rwsem); | |
| 859 | 856 | ||
| 860 | 857 | return 0; | |
| 861 | 858 | } | |
| @@ -871,10 +868,9 @@ static int xr_set_rs485_config(struct tty_struct *tty, | |||
| 871 | 868 | return -EFAULT; | |
| 872 | 869 | xr_sanitize_serial_rs485(&rs485); | |
| 873 | 870 | ||
| 874 | - | down_write(&tty->termios_rwsem); | |
| 871 | + | /* core holds termios rwsem and port mutex */ | |
| 875 | 872 | data->rs485 = rs485; | |
| 876 | 873 | xr_set_flow_mode(tty, port, NULL); | |
| 877 | - | up_write(&tty->termios_rwsem); | |
| 878 | 874 | ||
| 879 | 875 | if (copy_to_user(argp, &rs485, sizeof(rs485))) | |
| 880 | 876 | return -EFAULT; | |
modified drivers/usb/storage/sierra_ms.c
| @@ -77,6 +77,13 @@ static int sierra_get_swoc_info(struct usb_device *udev, | |||
| 77 | 77 | sizeof(struct swoc_info), /* __u16 size */ | |
| 78 | 78 | USB_CTRL_SET_TIMEOUT); /* int timeout */ | |
| 79 | 79 | ||
| 80 | + | /* | |
| 81 | + | * A short IN transfer leaves the tail of swocInfo uninitialized; | |
| 82 | + | * only a full transfer is valid. | |
| 83 | + | */ | |
| 84 | + | if (result != sizeof(struct swoc_info)) | |
| 85 | + | return -EIO; | |
| 86 | + | ||
| 80 | 87 | swocInfo->LinuxSKU = le16_to_cpu(swocInfo->LinuxSKU); | |
| 81 | 88 | swocInfo->LinuxVer = le16_to_cpu(swocInfo->LinuxVer); | |
| 82 | 89 | return result; | |
modified drivers/usb/typec/anx7411.c
| @@ -1566,8 +1566,11 @@ static void anx7411_i2c_remove(struct i2c_client *client) | |||
| 1566 | 1566 | anx7411_partner_unregister_altmode(plat); | |
| 1567 | 1567 | anx7411_unregister_partner(plat); | |
| 1568 | 1568 | ||
| 1569 | - | if (plat->workqueue) | |
| 1569 | + | if (plat->workqueue) { | |
| 1570 | + | disable_irq(plat->intp_irq); | |
| 1571 | + | cancel_work_sync(&plat->work); | |
| 1570 | 1572 | destroy_workqueue(plat->workqueue); | |
| 1573 | + | } | |
| 1571 | 1574 | ||
| 1572 | 1575 | i2c_unregister_device(plat->spi_client); | |
| 1573 | 1576 | ||
modified drivers/usb/typec/port-mapper.c
| @@ -42,6 +42,23 @@ static int usb4_port_compare(struct device *dev, void *fwnode) | |||
| 42 | 42 | return usb4_usb3_port_match(dev, fwnode); | |
| 43 | 43 | } | |
| 44 | 44 | ||
| 45 | + | static bool typec_has_usb4_host_interface(const struct fwnode_handle *fwnode) | |
| 46 | + | { | |
| 47 | + | if (!IS_REACHABLE(CONFIG_USB4)) | |
| 48 | + | return false; | |
| 49 | + | ||
| 50 | + | struct fwnode_handle *nhi_fwnode __free(fwnode_handle) = | |
| 51 | + | fwnode_find_reference(fwnode, "usb4-host-interface", 0); | |
| 52 | + | ||
| 53 | + | /* | |
| 54 | + | * The USB4 port can only appear if the host interface is enabled in | |
| 55 | + | * the firmware and has been enumerated as a device. The latter is | |
| 56 | + | * the same check as in usb_acpi_add_usb4_devlink(). | |
| 57 | + | */ | |
| 58 | + | return !IS_ERR(nhi_fwnode) && fwnode_device_is_available(nhi_fwnode) && | |
| 59 | + | nhi_fwnode->dev; | |
| 60 | + | } | |
| 61 | + | ||
| 45 | 62 | static int typec_port_compare(struct device *dev, void *fwnode) | |
| 46 | 63 | { | |
| 47 | 64 | return device_match_fwnode(dev, fwnode); | |
| @@ -64,11 +81,11 @@ static int typec_port_match(struct device *dev, void *data) | |||
| 64 | 81 | adev_fwnode); | |
| 65 | 82 | ||
| 66 | 83 | /* | |
| 67 | - | * If dev is USB 3.x port, it may have reference to the | |
| 84 | + | * If dev is USB 3.x port, it may have reference to an available | |
| 68 | 85 | * USB4 host interface in which case we can also link the | |
| 69 | 86 | * Type-C port with the USB4 port. | |
| 70 | 87 | */ | |
| 71 | - | if (fwnode_property_present(adev_fwnode, "usb4-host-interface")) | |
| 88 | + | if (typec_has_usb4_host_interface(adev_fwnode)) | |
| 72 | 89 | component_match_add(&arg->port->dev, &arg->match, | |
| 73 | 90 | usb4_port_compare, adev_fwnode); | |
| 74 | 91 | } | |
modified drivers/usb/typec/tcpm/tcpm.c
| @@ -1756,7 +1756,8 @@ static void mod_enable_frs_delayed_work(struct tcpm_port *port, unsigned int del | |||
| 1756 | 1756 | static void mod_vdm_discovery_cancel_delayed_work(struct tcpm_port *port) | |
| 1757 | 1757 | { | |
| 1758 | 1758 | hrtimer_cancel(&port->vdm_discovery_timer); | |
| 1759 | - | kthread_cancel_work_sync(&port->vdm_discovery_work); | |
| 1759 | + | if (port->wq) | |
| 1760 | + | kthread_cancel_work_sync(&port->vdm_discovery_work); | |
| 1760 | 1761 | } | |
| 1761 | 1762 | ||
| 1762 | 1763 | static void mod_vdm_discovery_delayed_work(struct tcpm_port *port, unsigned int delay_ms) | |
| @@ -7113,7 +7114,7 @@ static void tcpm_pd_event_handler(struct kthread_work *work) | |||
| 7113 | 7114 | port->upcoming_state = FR_SWAP_SEND; | |
| 7114 | 7115 | ret = tcpm_ams_start(port, FAST_ROLE_SWAP); | |
| 7115 | 7116 | if (ret == -EAGAIN) | |
| 7116 | - | port->upcoming_state = INVALID_STATE; | |
| 7117 | + | tcpm_set_state(port, ERROR_RECOVERY, 0); | |
| 7117 | 7118 | } else { | |
| 7118 | 7119 | tcpm_log(port, "Discarding FRS_SIGNAL! Not in sink ready"); | |
| 7119 | 7120 | } | |
| @@ -8977,6 +8978,7 @@ void tcpm_unregister_port(struct tcpm_port *port) | |||
| 8977 | 8978 | ||
| 8978 | 8979 | port->registered = false; | |
| 8979 | 8980 | kthread_destroy_worker(port->wq); | |
| 8981 | + | port->wq = NULL; | |
| 8980 | 8982 | ||
| 8981 | 8983 | hrtimer_cancel(&port->vdm_discovery_timer); | |
| 8982 | 8984 | hrtimer_cancel(&port->enable_frs_timer); | |
modified drivers/usb/typec/tipd/core.c
| @@ -343,7 +343,7 @@ static void tps6598x_set_data_role(struct tps6598x *tps, | |||
| 343 | 343 | ||
| 344 | 344 | static int tps6598x_connect(struct tps6598x *tps, u32 status) | |
| 345 | 345 | { | |
| 346 | - | struct typec_partner_desc desc; | |
| 346 | + | struct typec_partner_desc desc = { }; | |
| 347 | 347 | enum typec_pwr_opmode mode; | |
| 348 | 348 | int ret; | |
| 349 | 349 | ||
| @@ -354,7 +354,6 @@ static int tps6598x_connect(struct tps6598x *tps, u32 status) | |||
| 354 | 354 | ||
| 355 | 355 | desc.usb_pd = mode == TYPEC_PWR_MODE_PD; | |
| 356 | 356 | desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */ | |
| 357 | - | desc.identity = NULL; | |
| 358 | 357 | ||
| 359 | 358 | if (desc.usb_pd) { | |
| 360 | 359 | ret = tps6598x_read_partner_identity(tps); | |
| @@ -850,11 +849,10 @@ static void cd321x_update_work(struct work_struct *work) | |||
| 850 | 849 | ||
| 851 | 850 | /* Set up partner if we were previously disconnected (or changed). */ | |
| 852 | 851 | if (!tps->partner) { | |
| 853 | - | struct typec_partner_desc desc; | |
| 852 | + | struct typec_partner_desc desc = { }; | |
| 854 | 853 | ||
| 855 | 854 | desc.usb_pd = is_pd; | |
| 856 | 855 | desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */ | |
| 857 | - | desc.identity = NULL; | |
| 858 | 856 | ||
| 859 | 857 | if (desc.usb_pd) | |
| 860 | 858 | desc.identity = &st.partner_identity; | |
| @@ -1792,6 +1790,7 @@ static int tps6598x_probe(struct i2c_client *client) | |||
| 1792 | 1790 | const struct tipd_data *data; | |
| 1793 | 1791 | struct tps6598x *tps; | |
| 1794 | 1792 | struct fwnode_handle *fwnode; | |
| 1793 | + | bool patch_loaded = false; | |
| 1795 | 1794 | u32 status; | |
| 1796 | 1795 | u32 vid = 0; | |
| 1797 | 1796 | int ret; | |
| @@ -1847,6 +1846,7 @@ static int tps6598x_probe(struct i2c_client *client) | |||
| 1847 | 1846 | return ret; | |
| 1848 | 1847 | ||
| 1849 | 1848 | if (ret == TPS_MODE_PTCH) { | |
| 1849 | + | patch_loaded = true; | |
| 1850 | 1850 | ret = tps->data->init(tps); | |
| 1851 | 1851 | if (ret) | |
| 1852 | 1852 | return ret; | |
| @@ -1937,7 +1937,8 @@ err_clear_mask: | |||
| 1937 | 1937 | tps6598x_write64(tps, TPS_REG_INT_MASK1, 0); | |
| 1938 | 1938 | err_reset_controller: | |
| 1939 | 1939 | /* Reset PD controller to remove any applied patch */ | |
| 1940 | - | tps->data->reset(tps); | |
| 1940 | + | if (patch_loaded) | |
| 1941 | + | tps->data->reset(tps); | |
| 1941 | 1942 | ||
| 1942 | 1943 | return ret; | |
| 1943 | 1944 | } | |
modified drivers/usb/typec/ucsi/displayport.c
| @@ -71,11 +71,14 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo) | |||
| 71 | 71 | if (ret < 0) { | |
| 72 | 72 | if (ucsi->version > 0x0100) | |
| 73 | 73 | goto err_unlock; | |
| 74 | - | cur = 0xff; | |
| 75 | 74 | } | |
| 76 | 75 | ||
| 77 | - | if (cur < UCSI_MAX_ALTMODES) { | |
| 78 | - | ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY; | |
| 76 | + | if (cur != 0xff) { | |
| 77 | + | if (cur < UCSI_MAX_ALTMODES) | |
| 78 | + | ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY; | |
| 79 | + | else | |
| 80 | + | ret = -EINVAL; | |
| 81 | + | ||
| 79 | 82 | goto err_unlock; | |
| 80 | 83 | } | |
| 81 | 84 | ||
modified drivers/usb/typec/ucsi/ucsi.c
| @@ -1801,10 +1801,21 @@ static struct fwnode_handle *ucsi_find_fwnode(struct ucsi_connector *con) | |||
| 1801 | 1801 | { | |
| 1802 | 1802 | struct fwnode_handle *fwnode; | |
| 1803 | 1803 | int i = 1; | |
| 1804 | + | int ret; | |
| 1805 | + | u32 port; | |
| 1804 | 1806 | ||
| 1805 | - | device_for_each_child_node(con->ucsi->dev, fwnode) | |
| 1806 | - | if (i++ == con->num) | |
| 1807 | - | return fwnode; | |
| 1807 | + | device_for_each_child_node(con->ucsi->dev, fwnode) { | |
| 1808 | + | ret = fwnode_property_read_u32(fwnode, "reg", &port); | |
| 1809 | + | if (ret < 0) { | |
| 1810 | + | if (i == con->num) | |
| 1811 | + | return fwnode; | |
| 1812 | + | } else { | |
| 1813 | + | if (port == con->num - 1) | |
| 1814 | + | return fwnode; | |
| 1815 | + | } | |
| 1816 | + | ||
| 1817 | + | i++; | |
| 1818 | + | } | |
| 1808 | 1819 | return NULL; | |
| 1809 | 1820 | } | |
| 1810 | 1821 | ||
modified drivers/usb/typec/ucsi/ucsi_acpi.c
| @@ -121,6 +121,33 @@ static const struct ucsi_operations ucsi_acpi_ops = { | |||
| 121 | 121 | .async_control = ucsi_acpi_async_control | |
| 122 | 122 | }; | |
| 123 | 123 | ||
| 124 | + | static int ucsi_acer_read_version(struct ucsi *ucsi, u16 *version) | |
| 125 | + | { | |
| 126 | + | struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); | |
| 127 | + | int ret; | |
| 128 | + | ||
| 129 | + | ret = ucsi_acpi_read_version(ucsi, version); | |
| 130 | + | if (ret) | |
| 131 | + | return ret; | |
| 132 | + | ||
| 133 | + | if (!*version) { | |
| 134 | + | dev_warn(ua->dev, "UCSI version is zero, assuming 1.2\n"); | |
| 135 | + | *version = UCSI_VERSION_1_2; | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | return 0; | |
| 139 | + | } | |
| 140 | + | ||
| 141 | + | static const struct ucsi_operations ucsi_acer_ops = { | |
| 142 | + | .read_version = ucsi_acer_read_version, | |
| 143 | + | .read_cci = ucsi_acpi_read_cci, | |
| 144 | + | .poll_cci = ucsi_acpi_poll_cci, | |
| 145 | + | .read_message_in = ucsi_acpi_read_message_in, | |
| 146 | + | .write_message_out = ucsi_acpi_write_message_out, | |
| 147 | + | .sync_control = ucsi_sync_control_common, | |
| 148 | + | .async_control = ucsi_acpi_async_control | |
| 149 | + | }; | |
| 150 | + | ||
| 124 | 151 | static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci, | |
| 125 | 152 | void *val, size_t len, void *msg_out, | |
| 126 | 153 | size_t msg_out_size) | |
| @@ -162,6 +189,13 @@ static const struct ucsi_operations ucsi_gram_ops = { | |||
| 162 | 189 | }; | |
| 163 | 190 | ||
| 164 | 191 | static const struct dmi_system_id ucsi_acpi_quirks[] = { | |
| 192 | + | { | |
| 193 | + | .matches = { | |
| 194 | + | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | |
| 195 | + | DMI_MATCH(DMI_PRODUCT_NAME, "Nitro ANV15-41"), | |
| 196 | + | }, | |
| 197 | + | .driver_data = (void *)&ucsi_acer_ops, | |
| 198 | + | }, | |
| 165 | 199 | { | |
| 166 | 200 | .matches = { | |
| 167 | 201 | DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"), | |
modified drivers/usb/typec/ucsi/ucsi_glink.c
| @@ -362,6 +362,10 @@ static void pmic_glink_ucsi_destroy(void *data) | |||
| 362 | 362 | { | |
| 363 | 363 | struct pmic_glink_ucsi *ucsi = data; | |
| 364 | 364 | ||
| 365 | + | /* Drain the work items before ucsi_destroy() frees the ucsi instance */ | |
| 366 | + | cancel_work_sync(&ucsi->notify_work); | |
| 367 | + | cancel_work_sync(&ucsi->register_work); | |
| 368 | + | ||
| 365 | 369 | /* Protect to make sure we're not in a middle of a transaction from a glink callback */ | |
| 366 | 370 | mutex_lock(&ucsi->lock); | |
| 367 | 371 | ucsi_destroy(ucsi->ucsi); | |
| @@ -467,8 +471,15 @@ static void pmic_glink_ucsi_remove(struct auxiliary_device *adev) | |||
| 467 | 471 | { | |
| 468 | 472 | struct pmic_glink_ucsi *ucsi = dev_get_drvdata(&adev->dev); | |
| 469 | 473 | ||
| 470 | - | /* Unregister first to stop having read & writes */ | |
| 471 | - | ucsi_unregister(ucsi->ucsi); | |
| 474 | + | /* Callbacks can queue work until devres releases the client */ | |
| 475 | + | disable_work_sync(&ucsi->notify_work); | |
| 476 | + | disable_work_sync(&ucsi->register_work); | |
| 477 | + | ||
| 478 | + | /* register_work may have unregistered the instance already */ | |
| 479 | + | if (ucsi->ucsi_registered) { | |
| 480 | + | ucsi->ucsi_registered = false; | |
| 481 | + | ucsi_unregister(ucsi->ucsi); | |
| 482 | + | } | |
| 472 | 483 | } | |
| 473 | 484 | ||
| 474 | 485 | static const struct auxiliary_device_id pmic_glink_ucsi_id_table[] = { | |
modified drivers/virt/nitro_enclaves/ne_misc_dev.c
| @@ -1706,6 +1706,7 @@ static int ne_create_vm_ioctl(struct ne_pci_dev *ne_pci_dev, u64 __user *slot_ui | |||
| 1706 | 1706 | return enclave_fd; | |
| 1707 | 1707 | ||
| 1708 | 1708 | put_file: | |
| 1709 | + | enclave_file->private_data = NULL; | |
| 1709 | 1710 | fput(enclave_file); | |
| 1710 | 1711 | put_fd: | |
| 1711 | 1712 | put_unused_fd(enclave_fd); | |
modified drivers/virt/vmgenid.c
| @@ -25,7 +25,7 @@ struct vmgenid_state { | |||
| 25 | 25 | ||
| 26 | 26 | static void vmgenid_notify(struct device *device) | |
| 27 | 27 | { | |
| 28 | - | struct vmgenid_state *state = device->driver_data; | |
| 28 | + | struct vmgenid_state *state = dev_get_drvdata(device); | |
| 29 | 29 | u8 old_id[VMGENID_SIZE]; | |
| 30 | 30 | ||
| 31 | 31 | memcpy(old_id, state->this_id, sizeof(old_id)); | |
| @@ -75,13 +75,16 @@ static int vmgenid_add_acpi(struct device *dev, struct vmgenid_state *state) | |||
| 75 | 75 | phys_addr = (obj->package.elements[0].integer.value << 0) | | |
| 76 | 76 | (obj->package.elements[1].integer.value << 32); | |
| 77 | 77 | ||
| 78 | - | virt_addr = devm_memremap(&device->dev, phys_addr, VMGENID_SIZE, MEMREMAP_WB); | |
| 78 | + | virt_addr = devm_memremap(&device->dev, phys_addr, VMGENID_SIZE, | |
| 79 | + | MEMREMAP_WB | MEMREMAP_DEC); | |
| 79 | 80 | if (IS_ERR(virt_addr)) { | |
| 80 | 81 | ret = PTR_ERR(virt_addr); | |
| 81 | 82 | goto out; | |
| 82 | 83 | } | |
| 83 | 84 | setup_vmgenid_state(state, virt_addr); | |
| 84 | 85 | ||
| 86 | + | dev_set_drvdata(dev, state); | |
| 87 | + | ||
| 85 | 88 | status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, | |
| 86 | 89 | vmgenid_acpi_handler, dev); | |
| 87 | 90 | if (ACPI_FAILURE(status)) { | |
| @@ -89,7 +92,6 @@ static int vmgenid_add_acpi(struct device *dev, struct vmgenid_state *state) | |||
| 89 | 92 | goto out; | |
| 90 | 93 | } | |
| 91 | 94 | ||
| 92 | - | dev->driver_data = state; | |
| 93 | 95 | out: | |
| 94 | 96 | ACPI_FREE(parsed.pointer); | |
| 95 | 97 | return ret; | |
| @@ -123,12 +125,13 @@ static int vmgenid_add_of(struct platform_device *pdev, | |||
| 123 | 125 | if (ret < 0) | |
| 124 | 126 | return ret; | |
| 125 | 127 | ||
| 128 | + | dev_set_drvdata(&pdev->dev, state); | |
| 129 | + | ||
| 126 | 130 | ret = devm_request_irq(&pdev->dev, ret, vmgenid_of_irq_handler, | |
| 127 | 131 | IRQF_SHARED, "vmgenid", &pdev->dev); | |
| 128 | 132 | if (ret < 0) | |
| 129 | 133 | return ret; | |
| 130 | 134 | ||
| 131 | - | pdev->dev.driver_data = state; | |
| 132 | 135 | return 0; | |
| 133 | 136 | } | |
| 134 | 137 | ||
modified fs/btrfs/inode.c
| @@ -9623,7 +9623,6 @@ int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode, | |||
| 9623 | 9623 | struct completion sync_reads; | |
| 9624 | 9624 | unsigned long i = 0; | |
| 9625 | 9625 | struct btrfs_bio *bbio; | |
| 9626 | - | int ret; | |
| 9627 | 9626 | ||
| 9628 | 9627 | /* | |
| 9629 | 9628 | * Fast path for synchronous reads which completes in this call, io_uring | |
| @@ -9670,10 +9669,10 @@ int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode, | |||
| 9670 | 9669 | ||
| 9671 | 9670 | if (uring_ctx) { | |
| 9672 | 9671 | if (refcount_dec_and_test(&priv->pending_refs)) { | |
| 9673 | - | ret = blk_status_to_errno(READ_ONCE(priv->status)); | |
| 9674 | - | btrfs_uring_read_extent_endio(uring_ctx, ret); | |
| 9672 | + | int error = blk_status_to_errno(READ_ONCE(priv->status)); | |
| 9673 | + | ||
| 9674 | + | btrfs_uring_read_extent_endio(uring_ctx, error); | |
| 9675 | 9675 | kfree(priv); | |
| 9676 | - | return ret; | |
| 9677 | 9676 | } | |
| 9678 | 9677 | ||
| 9679 | 9678 | return -EIOCBQUEUED; | |
modified fs/btrfs/ioctl.c
| @@ -4601,7 +4601,7 @@ static void btrfs_uring_read_finished(struct io_tw_req tw_req, io_tw_token_t tw) | |||
| 4601 | 4601 | size_t page_offset; | |
| 4602 | 4602 | ssize_t ret; | |
| 4603 | 4603 | ||
| 4604 | - | /* The inode lock has already been acquired in btrfs_uring_read_extent. */ | |
| 4604 | + | /* The inode lock has already been acquired in btrfs_encoded_read(). */ | |
| 4605 | 4605 | btrfs_lockdep_inode_acquire(inode, i_rwsem); | |
| 4606 | 4606 | ||
| 4607 | 4607 | if (priv->err) { | |
| @@ -4667,7 +4667,6 @@ static int btrfs_uring_read_extent(struct kiocb *iocb, struct iov_iter *iter, | |||
| 4667 | 4667 | struct iovec *iov, struct io_uring_cmd *cmd) | |
| 4668 | 4668 | { | |
| 4669 | 4669 | struct btrfs_inode *inode = BTRFS_I(file_inode(iocb->ki_filp)); | |
| 4670 | - | struct extent_io_tree *io_tree = &inode->io_tree; | |
| 4671 | 4670 | struct page **pages = NULL; | |
| 4672 | 4671 | struct btrfs_uring_priv *priv = NULL; | |
| 4673 | 4672 | unsigned long nr_pages; | |
| @@ -4723,8 +4722,6 @@ static int btrfs_uring_read_extent(struct kiocb *iocb, struct iov_iter *iter, | |||
| 4723 | 4722 | return -EIOCBQUEUED; | |
| 4724 | 4723 | ||
| 4725 | 4724 | out_fail: | |
| 4726 | - | btrfs_unlock_extent(io_tree, start, lockend, &cached_state); | |
| 4727 | - | btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED); | |
| 4728 | 4725 | kfree(priv); | |
| 4729 | 4726 | for (int i = 0; i < nr_pages; i++) { | |
| 4730 | 4727 | if (pages[i]) | |
| @@ -4837,7 +4834,7 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue | |||
| 4837 | 4834 | ret = btrfs_encoded_read(&kiocb, &data->iter, &data->args, &cached_state, | |
| 4838 | 4835 | &disk_bytenr, &disk_io_size); | |
| 4839 | 4836 | if (ret == -EAGAIN) | |
| 4840 | - | goto out_acct; | |
| 4837 | + | goto out_free; | |
| 4841 | 4838 | if (ret < 0 && ret != -EIOCBQUEUED) | |
| 4842 | 4839 | goto out_free; | |
| 4843 | 4840 | ||
| @@ -4865,8 +4862,10 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue | |||
| 4865 | 4862 | cached_state, disk_bytenr, disk_io_size, | |
| 4866 | 4863 | count, data->args.compression, | |
| 4867 | 4864 | data->iov, cmd); | |
| 4868 | - | ||
| 4869 | - | goto out_acct; | |
| 4865 | + | if (ret == -EIOCBQUEUED) | |
| 4866 | + | goto out_acct; | |
| 4867 | + | btrfs_unlock_extent(io_tree, start, lockend, &cached_state); | |
| 4868 | + | btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED); | |
| 4870 | 4869 | } | |
| 4871 | 4870 | ||
| 4872 | 4871 | out_free: | |
| @@ -4877,8 +4876,10 @@ out_acct: | |||
| 4877 | 4876 | add_rchar(current, ret); | |
| 4878 | 4877 | inc_syscr(current); | |
| 4879 | 4878 | ||
| 4880 | - | if (ret != -EIOCBQUEUED && ret != -EAGAIN) | |
| 4879 | + | if (ret != -EIOCBQUEUED) { | |
| 4881 | 4880 | kfree(data); | |
| 4881 | + | bc->data = NULL; | |
| 4882 | + | } | |
| 4882 | 4883 | ||
| 4883 | 4884 | return ret; | |
| 4884 | 4885 | } | |
| @@ -4907,6 +4908,11 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu | |||
| 4907 | 4908 | goto out_acct; | |
| 4908 | 4909 | } | |
| 4909 | 4910 | ||
| 4911 | + | if (issue_flags & IO_URING_F_NONBLOCK) { | |
| 4912 | + | ret = -EAGAIN; | |
| 4913 | + | goto out_acct; | |
| 4914 | + | } | |
| 4915 | + | ||
| 4910 | 4916 | if (!data) { | |
| 4911 | 4917 | data = kzalloc_obj(*data, GFP_NOFS); | |
| 4912 | 4918 | if (!data) { | |
| @@ -4975,11 +4981,6 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu | |||
| 4975 | 4981 | } | |
| 4976 | 4982 | } | |
| 4977 | 4983 | ||
| 4978 | - | if (issue_flags & IO_URING_F_NONBLOCK) { | |
| 4979 | - | ret = -EAGAIN; | |
| 4980 | - | goto out_acct; | |
| 4981 | - | } | |
| 4982 | - | ||
| 4983 | 4984 | pos = data->args.offset; | |
| 4984 | 4985 | ret = rw_verify_area(WRITE, file, &pos, data->args.len); | |
| 4985 | 4986 | if (ret < 0) | |
| @@ -5005,8 +5006,8 @@ out_acct: | |||
| 5005 | 5006 | add_wchar(current, ret); | |
| 5006 | 5007 | inc_syscw(current); | |
| 5007 | 5008 | ||
| 5008 | - | if (ret != -EAGAIN) | |
| 5009 | - | kfree(data); | |
| 5009 | + | kfree(data); | |
| 5010 | + | bc->data = NULL; | |
| 5010 | 5011 | return ret; | |
| 5011 | 5012 | } | |
| 5012 | 5013 | ||
modified fs/btrfs/scrub.c
| @@ -536,8 +536,10 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes, | |||
| 536 | 536 | } | |
| 537 | 537 | ret = paths_from_inode(inum, ipath); | |
| 538 | 538 | ||
| 539 | - | if (ret < 0) | |
| 539 | + | if (ret < 0) { | |
| 540 | + | btrfs_put_root(local_root); | |
| 540 | 541 | goto err; | |
| 542 | + | } | |
| 541 | 543 | ||
| 542 | 544 | /* | |
| 543 | 545 | * we deliberately ignore the bit ipath might have been too small to | |
modified fs/btrfs/transaction.c
| @@ -432,6 +432,7 @@ static int record_root_in_trans(struct btrfs_trans_handle *trans, | |||
| 432 | 432 | spin_lock(&fs_info->fs_roots_radix_lock); | |
| 433 | 433 | if (btrfs_get_root_last_trans(root) == trans->transid && !force) { | |
| 434 | 434 | spin_unlock(&fs_info->fs_roots_radix_lock); | |
| 435 | + | clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); | |
| 435 | 436 | return 0; | |
| 436 | 437 | } | |
| 437 | 438 | radix_tree_tag_set(&fs_info->fs_roots_radix, | |
modified fs/btrfs/xattr.c
| @@ -161,6 +161,7 @@ int btrfs_setxattr(struct btrfs_trans_handle *trans, struct inode *inode, | |||
| 161 | 161 | const u16 old_data_len = btrfs_dir_data_len(leaf, di); | |
| 162 | 162 | const u32 item_size = btrfs_item_size(leaf, slot); | |
| 163 | 163 | const u32 data_size = sizeof(*di) + name_len + size; | |
| 164 | + | unsigned long name_ptr; | |
| 164 | 165 | unsigned long data_ptr; | |
| 165 | 166 | char *ptr; | |
| 166 | 167 | ||
| @@ -189,8 +190,16 @@ int btrfs_setxattr(struct btrfs_trans_handle *trans, struct inode *inode, | |||
| 189 | 190 | ptr = btrfs_item_ptr(leaf, slot, char); | |
| 190 | 191 | ptr += btrfs_item_size(leaf, slot) - data_size; | |
| 191 | 192 | di = (struct btrfs_dir_item *)ptr; | |
| 193 | + | memzero_extent_buffer(leaf, (unsigned long)ptr + | |
| 194 | + | offsetof(struct btrfs_dir_item, location), | |
| 195 | + | sizeof(struct btrfs_disk_key)); | |
| 196 | + | btrfs_set_dir_flags(leaf, di, BTRFS_FT_XATTR); | |
| 197 | + | btrfs_set_dir_transid(leaf, di, trans->transid); | |
| 198 | + | btrfs_set_dir_name_len(leaf, di, name_len); | |
| 192 | 199 | btrfs_set_dir_data_len(leaf, di, size); | |
| 200 | + | name_ptr = (unsigned long)(di + 1); | |
| 193 | 201 | data_ptr = ((unsigned long)(di + 1)) + name_len; | |
| 202 | + | write_extent_buffer(leaf, name, name_ptr, name_len); | |
| 194 | 203 | write_extent_buffer(leaf, value, data_ptr, size); | |
| 195 | 204 | } else { | |
| 196 | 205 | /* | |
| @@ -320,10 +329,8 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
| 320 | 329 | if (!size) | |
| 321 | 330 | goto next; | |
| 322 | 331 | ||
| 323 | - | if (!buffer || (name_len + 1) > size_left) { | |
| 324 | - | iter_ret = -ERANGE; | |
| 325 | - | break; | |
| 326 | - | } | |
| 332 | + | if (!buffer || (name_len + 1) > size_left) | |
| 333 | + | return -ERANGE; | |
| 327 | 334 | ||
| 328 | 335 | read_extent_buffer(leaf, buffer, name_ptr, name_len); | |
| 329 | 336 | buffer[name_len] = '\0'; | |
modified fs/dcache.c
| @@ -1583,6 +1583,8 @@ EXPORT_SYMBOL(path_has_submounts); | |||
| 1583 | 1583 | * | |
| 1584 | 1584 | * Only one of d_invalidate() and d_set_mounted() must succeed. For | |
| 1585 | 1585 | * this reason take rename_lock and d_lock on dentry and ancestors. | |
| 1586 | + | * Likewise for dont_mount() which marks a dentry that is being removed | |
| 1587 | + | * under d_lock. | |
| 1586 | 1588 | */ | |
| 1587 | 1589 | int d_set_mounted(struct dentry *dentry) | |
| 1588 | 1590 | { | |
| @@ -1599,7 +1601,7 @@ int d_set_mounted(struct dentry *dentry) | |||
| 1599 | 1601 | spin_unlock(&p->d_lock); | |
| 1600 | 1602 | } | |
| 1601 | 1603 | spin_lock(&dentry->d_lock); | |
| 1602 | - | if (!d_unlinked(dentry)) { | |
| 1604 | + | if (!d_unlinked(dentry) && !cant_mount(dentry)) { | |
| 1603 | 1605 | ret = -EBUSY; | |
| 1604 | 1606 | if (!d_mountpoint(dentry)) { | |
| 1605 | 1607 | dentry->d_flags |= DCACHE_MOUNTED; | |
modified fs/ext4/super.c
| @@ -5057,6 +5057,7 @@ out: | |||
| 5057 | 5057 | static int ext4_check_journal_data_mode(struct super_block *sb) | |
| 5058 | 5058 | { | |
| 5059 | 5059 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { | |
| 5060 | + | printk(KERN_WARNING "EXT4-fs: The data=journal mount option is deprecated and support will be removed in January 2028\n"); | |
| 5060 | 5061 | printk_once(KERN_WARNING "EXT4-fs: Warning: mounting with " | |
| 5061 | 5062 | "data=journal disables delayed allocation, " | |
| 5062 | 5063 | "dioread_nolock, O_DIRECT and fast_commit support!\n"); | |
modified fs/fcntl.c
| @@ -372,6 +372,9 @@ static long fcntl_set_rw_hint(struct file *file, unsigned long arg) | |||
| 372 | 372 | u64 __user *argp = (u64 __user *)arg; | |
| 373 | 373 | u64 hint; | |
| 374 | 374 | ||
| 375 | + | /* nothing is ever written to it */ | |
| 376 | + | if (IS_IMMUTABLE(inode)) | |
| 377 | + | return -EPERM; | |
| 375 | 378 | if (!inode_owner_or_capable(file_mnt_idmap(file), inode)) | |
| 376 | 379 | return -EPERM; | |
| 377 | 380 | ||
modified fs/fhandle.c
| @@ -298,6 +298,22 @@ static bool capable_wrt_mount(struct mount *mount) | |||
| 298 | 298 | return mnt_ns && ns_capable(mnt_ns->user_ns, CAP_SYS_ADMIN); | |
| 299 | 299 | } | |
| 300 | 300 | ||
| 301 | + | /* | |
| 302 | + | * Does the caller have an unobstructed way to everything below @root? Only | |
| 303 | + | * if the mount is mounted, the caller is privileged over its mount namespace | |
| 304 | + | * and no locked child covers something below @root->dentry. One answer from | |
| 305 | + | * under mount_lock: an umount in between clears ->mnt_ns and takes the | |
| 306 | + | * children off the mount, the locked ones too. | |
| 307 | + | */ | |
| 308 | + | static bool subtree_unobstructed(const struct path *root) | |
| 309 | + | { | |
| 310 | + | struct mount *mnt = real_mount(root->mnt); | |
| 311 | + | ||
| 312 | + | guard(mount_locked_reader)(); | |
| 313 | + | return is_mounted(root->mnt) && capable_wrt_mount(mnt) && | |
| 314 | + | !has_locked_children(mnt, root->dentry); | |
| 315 | + | } | |
| 316 | + | ||
| 301 | 317 | static inline int may_decode_fh(struct handle_to_path_ctx *ctx, | |
| 302 | 318 | unsigned int o_flags) | |
| 303 | 319 | { | |
| @@ -332,9 +348,7 @@ static inline int may_decode_fh(struct handle_to_path_ctx *ctx, | |||
| 332 | 348 | ||
| 333 | 349 | if (ns_capable(root->mnt->mnt_sb->s_user_ns, CAP_SYS_ADMIN)) | |
| 334 | 350 | ctx->flags = HANDLE_CHECK_PERMS; | |
| 335 | - | else if (is_mounted(root->mnt) && | |
| 336 | - | capable_wrt_mount(real_mount(root->mnt)) && | |
| 337 | - | !has_locked_children(real_mount(root->mnt), root->dentry)) | |
| 351 | + | else if (subtree_unobstructed(root)) | |
| 338 | 352 | ctx->flags = HANDLE_CHECK_PERMS | HANDLE_CHECK_SUBTREE; | |
| 339 | 353 | else | |
| 340 | 354 | return -EPERM; | |
modified fs/file_table.c
| @@ -520,7 +520,8 @@ static void __fput(struct file *file) | |||
| 520 | 520 | dput(dentry); | |
| 521 | 521 | if (unlikely(mode & FMODE_NEED_UNMOUNT)) | |
| 522 | 522 | dissolve_on_fput(mnt); | |
| 523 | - | mntput(mnt); | |
| 523 | + | else | |
| 524 | + | mntput(mnt); | |
| 524 | 525 | out: | |
| 525 | 526 | file_free(file); | |
| 526 | 527 | } | |
modified fs/fs_context.c
| @@ -315,6 +315,10 @@ struct fs_context *fs_context_for_reconfigure(struct dentry *dentry, | |||
| 315 | 315 | unsigned int sb_flags, | |
| 316 | 316 | unsigned int sb_flags_mask) | |
| 317 | 317 | { | |
| 318 | + | /* kernel-internal superblocks are nobody's to reconfigure */ | |
| 319 | + | if (dentry->d_sb->s_flags & SB_NOUSER) | |
| 320 | + | return ERR_PTR(-EINVAL); | |
| 321 | + | ||
| 318 | 322 | return alloc_fs_context(dentry->d_sb->s_type, dentry, sb_flags, | |
| 319 | 323 | sb_flags_mask, FS_CONTEXT_FOR_RECONFIGURE); | |
| 320 | 324 | } | |
modified fs/mount.h
| @@ -6,6 +6,8 @@ | |||
| 6 | 6 | #include <linux/fs_pin.h> | |
| 7 | 7 | ||
| 8 | 8 | extern struct file_system_type nullfs_fs_type; | |
| 9 | + | extern struct dentry *nullfs_new_file(struct super_block *sb); | |
| 10 | + | extern struct vfsmount *knullfs; | |
| 9 | 11 | extern struct list_head notify_list; | |
| 10 | 12 | ||
| 11 | 13 | struct mnt_namespace { | |
| @@ -33,16 +35,20 @@ struct mnt_namespace { | |||
| 33 | 35 | } __randomize_layout; | |
| 34 | 36 | ||
| 35 | 37 | struct mnt_pcp { | |
| 36 | - | int mnt_count; | |
| 38 | + | unsigned int mnt_gets; | |
| 39 | + | unsigned int mnt_puts; | |
| 37 | 40 | int mnt_writers; | |
| 38 | 41 | }; | |
| 39 | 42 | ||
| 40 | 43 | struct mountpoint { | |
| 41 | 44 | struct hlist_node m_hash; | |
| 42 | 45 | struct dentry *m_dentry; | |
| 43 | - | struct hlist_head m_list; | |
| 46 | + | struct hlist_head m_list; /* mounts on it and pins */ | |
| 47 | + | struct hlist_head m_covers; /* covers of unmounted parents */ | |
| 44 | 48 | }; | |
| 45 | 49 | ||
| 50 | + | struct mnt_cover; | |
| 51 | + | ||
| 46 | 52 | struct mount { | |
| 47 | 53 | struct hlist_node mnt_hash; | |
| 48 | 54 | struct mount *mnt_parent; | |
| @@ -84,7 +90,7 @@ struct mount { | |||
| 84 | 90 | struct mountpoint *mnt_mp; /* where is it mounted */ | |
| 85 | 91 | union { | |
| 86 | 92 | struct hlist_node mnt_mp_list; /* list mounts with the same mountpoint */ | |
| 87 | - | struct hlist_node mnt_umount; | |
| 93 | + | struct hlist_node mnt_umount; /* on the unmounted list */ | |
| 88 | 94 | }; | |
| 89 | 95 | #ifdef CONFIG_FSNOTIFY | |
| 90 | 96 | struct fsnotify_mark_connector __rcu *mnt_fsnotify_marks; | |
| @@ -98,7 +104,8 @@ struct mount { | |||
| 98 | 104 | int mnt_group_id; /* peer group identifier */ | |
| 99 | 105 | int mnt_expiry_mark; /* true if marked for expiry */ | |
| 100 | 106 | struct hlist_head mnt_pins; | |
| 101 | - | struct hlist_head mnt_stuck_children; | |
| 107 | + | struct mnt_cover *mnt_cover; /* the one it may leave behind */ | |
| 108 | + | struct hlist_head mnt_covers; /* left behind by its unmounted children */ | |
| 102 | 109 | struct hlist_node mnt_ns_visible; /* link in ns->mnt_visible_mounts */ | |
| 103 | 110 | struct mount *overmount; /* mounted on ->mnt_root */ | |
| 104 | 111 | } __randomize_layout; | |
| @@ -233,6 +240,9 @@ static inline struct mnt_namespace *to_mnt_ns(struct ns_common *ns) | |||
| 233 | 240 | #ifdef CONFIG_FSNOTIFY | |
| 234 | 241 | static inline void mnt_notify_add(struct mount *m) | |
| 235 | 242 | { | |
| 243 | + | /* queued already under this namespace_sem hold */ | |
| 244 | + | if (!list_empty(&m->to_notify)) | |
| 245 | + | return; | |
| 236 | 246 | /* Optimize the case where there are no watches */ | |
| 237 | 247 | if ((m->mnt_ns && m->mnt_ns->n_fsnotify_marks) || | |
| 238 | 248 | (m->prev_ns && m->prev_ns->n_fsnotify_marks)) | |
modified fs/namei.c
| @@ -2086,6 +2086,33 @@ all_done: // pure jump | |||
| 2086 | 2086 | return NULL; | |
| 2087 | 2087 | } | |
| 2088 | 2088 | ||
| 2089 | + | /* | |
| 2090 | + | * Be careful in case the dentry is unlinked or renamed. Any mounts | |
| 2091 | + | * stacked on top of it are going away. We need to make sure that we | |
| 2092 | + | * don't reveal the underyling dentry during refwalk. In rcuwalk we | |
| 2093 | + | * catch this via d_seq and another lookup for the name. Give the same | |
| 2094 | + | * guarantee in refwalk. | |
| 2095 | + | */ | |
| 2096 | + | static bool unlink_may_reveal(struct nameidata *nd, int flags, | |
| 2097 | + | struct path *path, struct dentry *dentry) | |
| 2098 | + | { | |
| 2099 | + | /* ".." and LOOKUP_DOWN may land on an unhashed directory */ | |
| 2100 | + | if (flags & WALK_NOFOLLOW) | |
| 2101 | + | return false; | |
| 2102 | + | if (nd->flags & LOOKUP_REVAL) | |
| 2103 | + | return false; | |
| 2104 | + | /* We crossed onto a mount and the name led us here while it still existed */ | |
| 2105 | + | if (path->mnt != nd->path.mnt) | |
| 2106 | + | return false; | |
| 2107 | + | /* only a name on its way out is flagged */ | |
| 2108 | + | if (likely(!cant_mount(dentry))) | |
| 2109 | + | return false; | |
| 2110 | + | if (!d_unlinked(dentry)) | |
| 2111 | + | return false; | |
| 2112 | + | dput(no_free_ptr(path->dentry)); | |
| 2113 | + | return true; | |
| 2114 | + | } | |
| 2115 | + | ||
| 2089 | 2116 | /* | |
| 2090 | 2117 | * Do we need to follow links? We _really_ want to be able | |
| 2091 | 2118 | * to do this check without having to look at inode->i_op, | |
| @@ -2115,6 +2142,8 @@ static noinline const char *step_into_slowpath(struct nameidata *nd, int flags, | |||
| 2115 | 2142 | if (unlikely(!inode)) | |
| 2116 | 2143 | return ERR_PTR(-ENOENT); | |
| 2117 | 2144 | } else { | |
| 2145 | + | if (unlikely(unlink_may_reveal(nd, flags, &path, dentry))) | |
| 2146 | + | return ERR_PTR(-ESTALE); | |
| 2118 | 2147 | dput(nd->path.dentry); | |
| 2119 | 2148 | if (nd->path.mnt != path.mnt) | |
| 2120 | 2149 | mntput(nd->path.mnt); | |
modified fs/namespace.c
| @@ -80,6 +80,8 @@ static u64 mnt_id_ctr = MNT_UNIQUE_ID_OFFSET; | |||
| 80 | 80 | static struct hlist_head *mount_hashtable __ro_after_init; | |
| 81 | 81 | static struct hlist_head *mountpoint_hashtable __ro_after_init; | |
| 82 | 82 | static struct kmem_cache *mnt_cache __ro_after_init; | |
| 83 | + | struct vfsmount *knullfs __ro_after_init; /* private nullfs instance */ | |
| 84 | + | static struct vfsmount *knullfs_file __ro_after_init; /* its regular file */ | |
| 83 | 85 | static DECLARE_RWSEM(namespace_sem); | |
| 84 | 86 | static HLIST_HEAD(unmounted); /* protected by namespace_sem */ | |
| 85 | 87 | static LIST_HEAD(ex_mountpoints); /* protected by namespace_sem */ | |
| @@ -130,7 +132,6 @@ static void mnt_ns_release(struct mnt_namespace *ns) | |||
| 130 | 132 | { | |
| 131 | 133 | /* keep alive for {list,stat}mount() */ | |
| 132 | 134 | if (ns && refcount_dec_and_test(&ns->passive)) { | |
| 133 | - | fsnotify_mntns_delete(ns); | |
| 134 | 135 | put_user_ns(ns->user_ns); | |
| 135 | 136 | kfree(ns); | |
| 136 | 137 | } | |
| @@ -210,6 +211,19 @@ static inline struct hlist_head *mp_hash(struct dentry *dentry) | |||
| 210 | 211 | return &mountpoint_hashtable[tmp & mp_hash_mask]; | |
| 211 | 212 | } | |
| 212 | 213 | ||
| 214 | + | /* | |
| 215 | + | * What an unmounted mount leaves behind at its unmounted parent instead of | |
| 216 | + | * staying attached to it. A lookup on the parent at the mountpoint finds | |
| 217 | + | * a stand-in for as long as the cover is there. The parent frees it. | |
| 218 | + | */ | |
| 219 | + | struct mnt_cover { | |
| 220 | + | struct hlist_node node; /* parent->mnt_covers, RCU */ | |
| 221 | + | struct hlist_node pin; /* mp->m_covers, keeps the mountpoint */ | |
| 222 | + | struct dentry *dentry; | |
| 223 | + | struct mountpoint *mp; | |
| 224 | + | struct rcu_head rcu; | |
| 225 | + | }; | |
| 226 | + | ||
| 213 | 227 | static int mnt_alloc_id(struct mount *mnt) | |
| 214 | 228 | { | |
| 215 | 229 | int res; | |
| @@ -249,16 +263,24 @@ void mnt_release_group_id(struct mount *mnt) | |||
| 249 | 263 | mnt->mnt_group_id = 0; | |
| 250 | 264 | } | |
| 251 | 265 | ||
| 252 | - | /* | |
| 253 | - | * vfsmount lock must be held for read | |
| 254 | - | */ | |
| 255 | - | static inline void mnt_add_count(struct mount *mnt, int n) | |
| 266 | + | static inline void mnt_inc_count(struct mount *mnt) | |
| 267 | + | { | |
| 268 | + | #ifdef CONFIG_SMP | |
| 269 | + | this_cpu_inc(mnt->mnt_pcp->mnt_gets); | |
| 270 | + | #else | |
| 271 | + | preempt_disable(); | |
| 272 | + | mnt->mnt_count++; | |
| 273 | + | preempt_enable(); | |
| 274 | + | #endif | |
| 275 | + | } | |
| 276 | + | ||
| 277 | + | static inline void mnt_dec_count(struct mount *mnt) | |
| 256 | 278 | { | |
| 257 | 279 | #ifdef CONFIG_SMP | |
| 258 | - | this_cpu_add(mnt->mnt_pcp->mnt_count, n); | |
| 280 | + | this_cpu_inc(mnt->mnt_pcp->mnt_puts); | |
| 259 | 281 | #else | |
| 260 | 282 | preempt_disable(); | |
| 261 | - | mnt->mnt_count += n; | |
| 283 | + | mnt->mnt_count--; | |
| 262 | 284 | preempt_enable(); | |
| 263 | 285 | #endif | |
| 264 | 286 | } | |
| @@ -269,14 +291,17 @@ static inline void mnt_add_count(struct mount *mnt, int n) | |||
| 269 | 291 | int mnt_get_count(struct mount *mnt) | |
| 270 | 292 | { | |
| 271 | 293 | #ifdef CONFIG_SMP | |
| 272 | - | int count = 0; | |
| 294 | + | unsigned int gets = 0, puts = 0; | |
| 273 | 295 | int cpu; | |
| 274 | 296 | ||
| 275 | - | for_each_possible_cpu(cpu) { | |
| 276 | - | count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count; | |
| 277 | - | } | |
| 297 | + | /* puts first, so a put counted here has its get counted below */ | |
| 298 | + | for_each_possible_cpu(cpu) | |
| 299 | + | puts += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_puts; | |
| 300 | + | smp_mb(); /* pairs with the smp_wmb() in mntput_no_expire() */ | |
| 301 | + | for_each_possible_cpu(cpu) | |
| 302 | + | gets += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_gets; | |
| 278 | 303 | ||
| 279 | - | return count; | |
| 304 | + | return gets - puts; | |
| 280 | 305 | #else | |
| 281 | 306 | return mnt->mnt_count; | |
| 282 | 307 | #endif | |
| @@ -288,6 +313,10 @@ static struct mount *alloc_vfsmnt(const char *name) | |||
| 288 | 313 | if (mnt) { | |
| 289 | 314 | int err; | |
| 290 | 315 | ||
| 316 | + | mnt->mnt_cover = kzalloc_obj(struct mnt_cover, GFP_KERNEL_ACCOUNT); | |
| 317 | + | if (!mnt->mnt_cover) | |
| 318 | + | goto out_free_cache; | |
| 319 | + | ||
| 291 | 320 | err = mnt_alloc_id(mnt); | |
| 292 | 321 | if (err) | |
| 293 | 322 | goto out_free_cache; | |
| @@ -305,7 +334,7 @@ static struct mount *alloc_vfsmnt(const char *name) | |||
| 305 | 334 | if (!mnt->mnt_pcp) | |
| 306 | 335 | goto out_free_devname; | |
| 307 | 336 | ||
| 308 | - | this_cpu_add(mnt->mnt_pcp->mnt_count, 1); | |
| 337 | + | this_cpu_inc(mnt->mnt_pcp->mnt_gets); | |
| 309 | 338 | #else | |
| 310 | 339 | mnt->mnt_count = 1; | |
| 311 | 340 | mnt->mnt_writers = 0; | |
| @@ -320,8 +349,11 @@ static struct mount *alloc_vfsmnt(const char *name) | |||
| 320 | 349 | INIT_HLIST_HEAD(&mnt->mnt_slave_list); | |
| 321 | 350 | INIT_HLIST_NODE(&mnt->mnt_slave); | |
| 322 | 351 | INIT_HLIST_NODE(&mnt->mnt_mp_list); | |
| 323 | - | INIT_HLIST_HEAD(&mnt->mnt_stuck_children); | |
| 352 | + | INIT_HLIST_HEAD(&mnt->mnt_covers); | |
| 324 | 353 | INIT_HLIST_NODE(&mnt->mnt_ns_visible); | |
| 354 | + | #ifdef CONFIG_FSNOTIFY | |
| 355 | + | INIT_LIST_HEAD(&mnt->to_notify); | |
| 356 | + | #endif | |
| 325 | 357 | RB_CLEAR_NODE(&mnt->mnt_node); | |
| 326 | 358 | mnt->mnt.mnt_idmap = &nop_mnt_idmap; | |
| 327 | 359 | } | |
| @@ -334,6 +366,7 @@ out_free_devname: | |||
| 334 | 366 | out_free_id: | |
| 335 | 367 | mnt_free_id(mnt); | |
| 336 | 368 | out_free_cache: | |
| 369 | + | kfree(mnt->mnt_cover); | |
| 337 | 370 | kmem_cache_free(mnt_cache, mnt); | |
| 338 | 371 | return NULL; | |
| 339 | 372 | } | |
| @@ -725,6 +758,8 @@ int sb_prepare_remount_readonly(struct super_block *sb) | |||
| 725 | 758 | static void free_vfsmnt(struct mount *mnt) | |
| 726 | 759 | { | |
| 727 | 760 | mnt_idmap_put(mnt_idmap(&mnt->mnt)); | |
| 761 | + | /* NULL if it left it behind */ | |
| 762 | + | kfree(mnt->mnt_cover); | |
| 728 | 763 | kfree_const(mnt->mnt_devname); | |
| 729 | 764 | #ifdef CONFIG_SMP | |
| 730 | 765 | free_percpu(mnt->mnt_pcp); | |
| @@ -746,13 +781,13 @@ int __legitimize_mnt(struct vfsmount *bastard, unsigned seq) | |||
| 746 | 781 | if (bastard == NULL) | |
| 747 | 782 | return 0; | |
| 748 | 783 | mnt = real_mount(bastard); | |
| 749 | - | mnt_add_count(mnt, 1); | |
| 750 | - | smp_mb(); // see mntput_no_expire() and do_umount() | |
| 784 | + | mnt_inc_count(mnt); | |
| 785 | + | smp_mb(); /* see mntput_no_expire_slowpath() and do_umount() */ | |
| 751 | 786 | if (likely(!read_seqretry(&mount_lock, seq))) | |
| 752 | 787 | return 0; | |
| 753 | 788 | lock_mount_hash(); | |
| 754 | 789 | if (unlikely(bastard->mnt_flags & (MNT_SYNC_UMOUNT | MNT_DOOMED))) { | |
| 755 | - | mnt_add_count(mnt, -1); | |
| 790 | + | mnt_dec_count(mnt); | |
| 756 | 791 | unlock_mount_hash(); | |
| 757 | 792 | return 1; | |
| 758 | 793 | } | |
| @@ -781,20 +816,31 @@ static bool legitimize_mnt(struct vfsmount *bastard, unsigned seq) | |||
| 781 | 816 | * @dentry: dentry of mountpoint | |
| 782 | 817 | * | |
| 783 | 818 | * If @mnt has a child mount @c mounted on @dentry find and return it. | |
| 819 | + | * If @mnt is unmounted and a child that was unmounted with it left its | |
| 820 | + | * cover behind at @dentry, return the stand-in for it instead: knullfs | |
| 821 | + | * for a directory, its regular file for anything else. | |
| 784 | 822 | * Caller must either hold the spinlock component of @mount_lock or | |
| 785 | 823 | * hold rcu_read_lock(), sample the seqcount component before the call | |
| 786 | 824 | * and recheck it afterwards. | |
| 787 | 825 | * | |
| 788 | - | * Return: The child of @mnt mounted on @dentry or %NULL. | |
| 826 | + | * Return: The child of @mnt mounted on @dentry, a stand-in or %NULL. | |
| 789 | 827 | */ | |
| 790 | 828 | struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry) | |
| 791 | 829 | { | |
| 792 | 830 | struct hlist_head *head = m_hash(mnt, dentry); | |
| 831 | + | struct mnt_cover *cover; | |
| 793 | 832 | struct mount *p; | |
| 794 | 833 | ||
| 795 | 834 | hlist_for_each_entry_rcu(p, head, mnt_hash) | |
| 796 | 835 | if (&p->mnt_parent->mnt == mnt && p->mnt_mountpoint == dentry) | |
| 797 | 836 | return p; | |
| 837 | + | /* an unmounted mount keeps the covers its unmounted children left */ | |
| 838 | + | /* a lockless caller rechecks mount_lock after a miss, a stale flag is harmless */ | |
| 839 | + | if (unlikely(data_race(mnt->mnt_flags) & MNT_UMOUNT)) { | |
| 840 | + | hlist_for_each_entry_rcu(cover, &real_mount(mnt)->mnt_covers, node) | |
| 841 | + | if (cover->dentry == dentry) | |
| 842 | + | return real_mount(d_is_dir(dentry) ? knullfs : knullfs_file); | |
| 843 | + | } | |
| 798 | 844 | return NULL; | |
| 799 | 845 | } | |
| 800 | 846 | ||
| @@ -910,6 +956,7 @@ mountpoint: | |||
| 910 | 956 | mp->m_dentry = dget(dentry); | |
| 911 | 957 | hlist_add_head(&mp->m_hash, mp_hash(dentry)); | |
| 912 | 958 | INIT_HLIST_HEAD(&mp->m_list); | |
| 959 | + | INIT_HLIST_HEAD(&mp->m_covers); | |
| 913 | 960 | hlist_add_head(&m->node, &mp->m_list); | |
| 914 | 961 | m->mp = no_free_ptr(mp); | |
| 915 | 962 | read_sequnlock_excl(&mount_lock); | |
| @@ -922,7 +969,7 @@ mountpoint: | |||
| 922 | 969 | */ | |
| 923 | 970 | static void maybe_free_mountpoint(struct mountpoint *mp, struct list_head *list) | |
| 924 | 971 | { | |
| 925 | - | if (hlist_empty(&mp->m_list)) { | |
| 972 | + | if (hlist_empty(&mp->m_list) && hlist_empty(&mp->m_covers)) { | |
| 926 | 973 | struct dentry *dentry = mp->m_dentry; | |
| 927 | 974 | spin_lock(&dentry->d_lock); | |
| 928 | 975 | dentry->d_flags &= ~DCACHE_MOUNTED; | |
| @@ -1009,6 +1056,36 @@ static void umount_mnt(struct mount *mnt) | |||
| 1009 | 1056 | __umount_mnt(mnt, &ex_mountpoints); | |
| 1010 | 1057 | } | |
| 1011 | 1058 | ||
| 1059 | + | /* | |
| 1060 | + | * @mnt is unmounted together with its parent and would have stayed attached | |
| 1061 | + | * to it. Leave its cover behind before it is detached so that a lookup on the | |
| 1062 | + | * parent at the mountpoint keeps finding a mount instead of what @mnt covered. | |
| 1063 | + | * | |
| 1064 | + | * locks: mount_lock[write_seqlock] | |
| 1065 | + | */ | |
| 1066 | + | static void leave_cover(struct mount *mnt) | |
| 1067 | + | { | |
| 1068 | + | struct mnt_cover *cover = mnt->mnt_cover; | |
| 1069 | + | ||
| 1070 | + | mnt->mnt_cover = NULL; | |
| 1071 | + | cover->dentry = mnt->mnt_mountpoint; | |
| 1072 | + | cover->mp = mnt->mnt_mp; | |
| 1073 | + | /* keeps the mountpoint once @mnt has let go of it */ | |
| 1074 | + | hlist_add_head(&cover->pin, &cover->mp->m_covers); | |
| 1075 | + | hlist_add_head_rcu(&cover->node, &mnt->mnt_parent->mnt_covers); | |
| 1076 | + | } | |
| 1077 | + | ||
| 1078 | + | /* | |
| 1079 | + | * locks: mount_lock[write_seqlock] | |
| 1080 | + | */ | |
| 1081 | + | static void drop_cover(struct mnt_cover *cover, struct list_head *shrink_list) | |
| 1082 | + | { | |
| 1083 | + | hlist_del_rcu(&cover->node); | |
| 1084 | + | hlist_del(&cover->pin); | |
| 1085 | + | maybe_free_mountpoint(cover->mp, shrink_list); | |
| 1086 | + | kfree_rcu(cover, rcu); | |
| 1087 | + | } | |
| 1088 | + | ||
| 1012 | 1089 | /* | |
| 1013 | 1090 | * vfsmount lock must be held for write | |
| 1014 | 1091 | */ | |
| @@ -1058,7 +1135,10 @@ static void attach_mnt(struct mount *mnt, struct mount *parent, | |||
| 1058 | 1135 | void mnt_change_mountpoint(struct mount *parent, struct mountpoint *mp, struct mount *mnt) | |
| 1059 | 1136 | { | |
| 1060 | 1137 | struct mountpoint *old_mp = mnt->mnt_mp; | |
| 1138 | + | struct mount *old_parent = mnt->mnt_parent; | |
| 1061 | 1139 | ||
| 1140 | + | if (old_parent->overmount == mnt) | |
| 1141 | + | old_parent->overmount = NULL; | |
| 1062 | 1142 | list_del_init(&mnt->mnt_child); | |
| 1063 | 1143 | hlist_del_init(&mnt->mnt_mp_list); | |
| 1064 | 1144 | hlist_del_init_rcu(&mnt->mnt_hash); | |
| @@ -1254,6 +1334,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, | |||
| 1254 | 1334 | ||
| 1255 | 1335 | mnt->mnt.mnt_flags = READ_ONCE(old->mnt.mnt_flags) & | |
| 1256 | 1336 | ~MNT_INTERNAL_FLAGS; | |
| 1337 | + | mnt->mnt_t_flags = old->mnt_t_flags & T_UNBINDABLE; | |
| 1257 | 1338 | ||
| 1258 | 1339 | if (flag & (CL_SLAVE | CL_PRIVATE)) | |
| 1259 | 1340 | mnt->mnt_group_id = 0; /* not a peer of original */ | |
| @@ -1296,8 +1377,6 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, | |||
| 1296 | 1377 | ||
| 1297 | 1378 | static void cleanup_mnt(struct mount *mnt) | |
| 1298 | 1379 | { | |
| 1299 | - | struct hlist_node *p; | |
| 1300 | - | struct mount *m; | |
| 1301 | 1380 | /* | |
| 1302 | 1381 | * The warning here probably indicates that somebody messed | |
| 1303 | 1382 | * up a mnt_want/drop_write() pair. If this happens, the | |
| @@ -1308,10 +1387,6 @@ static void cleanup_mnt(struct mount *mnt) | |||
| 1308 | 1387 | WARN_ON(mnt_get_writers(mnt)); | |
| 1309 | 1388 | if (unlikely(mnt->mnt_pins.first)) | |
| 1310 | 1389 | mnt_pin_kill(mnt); | |
| 1311 | - | hlist_for_each_entry_safe(m, p, &mnt->mnt_stuck_children, mnt_umount) { | |
| 1312 | - | hlist_del(&m->mnt_umount); | |
| 1313 | - | mntput(&m->mnt); | |
| 1314 | - | } | |
| 1315 | 1390 | fsnotify_vfsmount_delete(&mnt->mnt); | |
| 1316 | 1391 | dput(mnt->mnt.mnt_root); | |
| 1317 | 1392 | deactivate_super(mnt->mnt.mnt_sb); | |
| @@ -1337,6 +1412,8 @@ static DECLARE_DELAYED_WORK(delayed_mntput_work, delayed_mntput); | |||
| 1337 | 1412 | ||
| 1338 | 1413 | static void noinline mntput_no_expire_slowpath(struct mount *mnt) | |
| 1339 | 1414 | { | |
| 1415 | + | struct mnt_cover *cover; | |
| 1416 | + | struct hlist_node *n; | |
| 1340 | 1417 | LIST_HEAD(list); | |
| 1341 | 1418 | int count; | |
| 1342 | 1419 | ||
| @@ -1347,7 +1424,7 @@ static void noinline mntput_no_expire_slowpath(struct mount *mnt) | |||
| 1347 | 1424 | * mount_lock, we'll see their refcount increment here. | |
| 1348 | 1425 | */ | |
| 1349 | 1426 | smp_mb(); | |
| 1350 | - | mnt_add_count(mnt, -1); | |
| 1427 | + | mnt_dec_count(mnt); | |
| 1351 | 1428 | count = mnt_get_count(mnt); | |
| 1352 | 1429 | if (count != 0) { | |
| 1353 | 1430 | WARN_ON(count < 0); | |
| @@ -1367,13 +1444,10 @@ static void noinline mntput_no_expire_slowpath(struct mount *mnt) | |||
| 1367 | 1444 | if (unlikely(!list_empty(&mnt->mnt_expire))) | |
| 1368 | 1445 | list_del(&mnt->mnt_expire); | |
| 1369 | 1446 | ||
| 1370 | - | if (unlikely(!list_empty(&mnt->mnt_mounts))) { | |
| 1371 | - | struct mount *p, *tmp; | |
| 1372 | - | list_for_each_entry_safe(p, tmp, &mnt->mnt_mounts, mnt_child) { | |
| 1373 | - | __umount_mnt(p, &list); | |
| 1374 | - | hlist_add_head(&p->mnt_umount, &mnt->mnt_stuck_children); | |
| 1375 | - | } | |
| 1376 | - | } | |
| 1447 | + | /* nothing stays attached to an unmounted mount */ | |
| 1448 | + | VFS_WARN_ON_ONCE(!list_empty(&mnt->mnt_mounts)); | |
| 1449 | + | hlist_for_each_entry_safe(cover, n, &mnt->mnt_covers, node) | |
| 1450 | + | drop_cover(cover, &list); | |
| 1377 | 1451 | unlock_mount_hash(); | |
| 1378 | 1452 | shrink_dentry_list(&list); | |
| 1379 | 1453 | ||
| @@ -1404,7 +1478,8 @@ static void mntput_no_expire(struct mount *mnt) | |||
| 1404 | 1478 | * non-NULL under rcu_read_lock(), the reference | |
| 1405 | 1479 | * we are dropping is not the final one. | |
| 1406 | 1480 | */ | |
| 1407 | - | mnt_add_count(mnt, -1); | |
| 1481 | + | smp_wmb(); /* pairs with the smp_mb() in mnt_get_count() */ | |
| 1482 | + | mnt_dec_count(mnt); | |
| 1408 | 1483 | rcu_read_unlock(); | |
| 1409 | 1484 | return; | |
| 1410 | 1485 | } | |
| @@ -1426,7 +1501,7 @@ EXPORT_SYMBOL(mntput); | |||
| 1426 | 1501 | struct vfsmount *mntget(struct vfsmount *mnt) | |
| 1427 | 1502 | { | |
| 1428 | 1503 | if (mnt) | |
| 1429 | - | mnt_add_count(real_mount(mnt), 1); | |
| 1504 | + | mnt_inc_count(real_mount(mnt)); | |
| 1430 | 1505 | return mnt; | |
| 1431 | 1506 | } | |
| 1432 | 1507 | EXPORT_SYMBOL(mntget); | |
| @@ -1737,36 +1812,17 @@ static inline void namespace_lock(void) | |||
| 1737 | 1812 | enum umount_tree_flags { | |
| 1738 | 1813 | UMOUNT_SYNC = 1, | |
| 1739 | 1814 | UMOUNT_PROPAGATE = 2, | |
| 1740 | - | UMOUNT_CONNECTED = 4, | |
| 1815 | + | UMOUNT_COVER = 4, | |
| 1741 | 1816 | }; | |
| 1742 | 1817 | ||
| 1743 | - | static bool disconnect_mount(struct mount *mnt, enum umount_tree_flags how) | |
| 1818 | + | /* Do we need to leave the mountpoint on the parent covered? */ | |
| 1819 | + | static bool needs_cover(struct mount *mnt, enum umount_tree_flags how) | |
| 1744 | 1820 | { | |
| 1745 | - | /* Leaving mounts connected is only valid for lazy umounts */ | |
| 1746 | 1821 | if (how & UMOUNT_SYNC) | |
| 1747 | - | return true; | |
| 1748 | - | ||
| 1749 | - | /* A mount without a parent has nothing to be connected to */ | |
| 1750 | - | if (!mnt_has_parent(mnt)) | |
| 1751 | - | return true; | |
| 1752 | - | ||
| 1753 | - | /* Because the reference counting rules change when mounts are | |
| 1754 | - | * unmounted and connected, umounted mounts may not be | |
| 1755 | - | * connected to mounted mounts. | |
| 1756 | - | */ | |
| 1757 | - | if (!(mnt->mnt_parent->mnt.mnt_flags & MNT_UMOUNT)) | |
| 1758 | - | return true; | |
| 1759 | - | ||
| 1760 | - | /* Has it been requested that the mount remain connected? */ | |
| 1761 | - | if (how & UMOUNT_CONNECTED) | |
| 1762 | 1822 | return false; | |
| 1763 | - | ||
| 1764 | - | /* Is the mount locked such that it needs to remain connected? */ | |
| 1765 | - | if (IS_MNT_LOCKED(mnt)) | |
| 1823 | + | if (!(mnt->mnt_parent->mnt.mnt_flags & MNT_UMOUNT)) | |
| 1766 | 1824 | return false; | |
| 1767 | - | ||
| 1768 | - | /* By default disconnect the mount */ | |
| 1769 | - | return true; | |
| 1825 | + | return (how & UMOUNT_COVER) || IS_MNT_LOCKED(mnt); | |
| 1770 | 1826 | } | |
| 1771 | 1827 | ||
| 1772 | 1828 | /* | |
| @@ -1783,6 +1839,8 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how) | |||
| 1783 | 1839 | ||
| 1784 | 1840 | /* Gather the mounts to umount */ | |
| 1785 | 1841 | for (p = mnt; p; p = next_mnt(p, mnt)) { | |
| 1842 | + | /* A mount is unmounted once. */ | |
| 1843 | + | VFS_WARN_ON_ONCE(p->mnt.mnt_flags & MNT_UMOUNT); | |
| 1786 | 1844 | p->mnt.mnt_flags |= MNT_UMOUNT; | |
| 1787 | 1845 | if (mnt_ns_attached(p)) | |
| 1788 | 1846 | move_from_ns(p); | |
| @@ -1802,7 +1860,6 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how) | |||
| 1802 | 1860 | ||
| 1803 | 1861 | while (!list_empty(&tmp_list)) { | |
| 1804 | 1862 | struct mnt_namespace *ns; | |
| 1805 | - | bool disconnect; | |
| 1806 | 1863 | p = list_first_entry(&tmp_list, struct mount, mnt_list); | |
| 1807 | 1864 | list_del_init(&p->mnt_expire); | |
| 1808 | 1865 | list_del_init(&p->mnt_list); | |
| @@ -1815,17 +1872,12 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how) | |||
| 1815 | 1872 | if (how & UMOUNT_SYNC) | |
| 1816 | 1873 | p->mnt.mnt_flags |= MNT_SYNC_UMOUNT; | |
| 1817 | 1874 | ||
| 1818 | - | disconnect = disconnect_mount(p, how); | |
| 1819 | 1875 | if (mnt_has_parent(p)) { | |
| 1820 | - | if (!disconnect) { | |
| 1821 | - | /* Don't forget about p */ | |
| 1822 | - | list_add_tail(&p->mnt_child, &p->mnt_parent->mnt_mounts); | |
| 1823 | - | } else { | |
| 1824 | - | umount_mnt(p); | |
| 1825 | - | } | |
| 1876 | + | if (needs_cover(p, how)) | |
| 1877 | + | leave_cover(p); | |
| 1878 | + | umount_mnt(p); | |
| 1826 | 1879 | } | |
| 1827 | - | if (disconnect) | |
| 1828 | - | hlist_add_head(&p->mnt_umount, &unmounted); | |
| 1880 | + | hlist_add_head(&p->mnt_umount, &unmounted); | |
| 1829 | 1881 | ||
| 1830 | 1882 | /* | |
| 1831 | 1883 | * At this point p->mnt_ns is NULL, notification will be queued | |
| @@ -1976,11 +2028,16 @@ out: | |||
| 1976 | 2028 | * detach_mounts allows lazily unmounting those mounts instead of | |
| 1977 | 2029 | * leaking them. | |
| 1978 | 2030 | * | |
| 2031 | + | * The dentry is unhashed before the mounts go so that no lookup finds | |
| 2032 | + | * what they covered. The caller removes it for good afterwards. | |
| 2033 | + | * | |
| 1979 | 2034 | * The caller may hold dentry->d_inode->i_rwsem. | |
| 1980 | 2035 | */ | |
| 1981 | 2036 | void __detach_mounts(struct dentry *dentry) | |
| 1982 | 2037 | { | |
| 1983 | 2038 | struct pinned_mountpoint mp = {}; | |
| 2039 | + | struct mnt_cover *cover; | |
| 2040 | + | struct hlist_node *n; | |
| 1984 | 2041 | struct mount *mnt; | |
| 1985 | 2042 | ||
| 1986 | 2043 | guard(namespace_excl)(); | |
| @@ -1989,15 +2046,16 @@ void __detach_mounts(struct dentry *dentry) | |||
| 1989 | 2046 | if (!lookup_mountpoint(dentry, &mp)) | |
| 1990 | 2047 | return; | |
| 1991 | 2048 | ||
| 2049 | + | /* the name goes first, what covered it goes second */ | |
| 2050 | + | d_drop(dentry); | |
| 1992 | 2051 | event++; | |
| 1993 | 2052 | while (mp.node.next) { | |
| 1994 | 2053 | mnt = hlist_entry(mp.node.next, struct mount, mnt_mp_list); | |
| 1995 | - | if (mnt->mnt.mnt_flags & MNT_UMOUNT) { | |
| 1996 | - | umount_mnt(mnt); | |
| 1997 | - | hlist_add_head(&mnt->mnt_umount, &unmounted); | |
| 1998 | - | } | |
| 1999 | - | else umount_tree(mnt, UMOUNT_CONNECTED); | |
| 2054 | + | umount_tree(mnt, UMOUNT_COVER); | |
| 2000 | 2055 | } | |
| 2056 | + | /* the dentry goes away, so do the covers left behind on it */ | |
| 2057 | + | hlist_for_each_entry_safe(cover, n, &mp.mp->m_covers, pin) | |
| 2058 | + | drop_cover(cover, &ex_mountpoints); | |
| 2001 | 2059 | unpin_mountpoint(&mp); | |
| 2002 | 2060 | } | |
| 2003 | 2061 | ||
| @@ -2294,9 +2352,11 @@ void drop_collected_paths(const struct path *paths, const struct path *prealloc) | |||
| 2294 | 2352 | ||
| 2295 | 2353 | static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *, bool); | |
| 2296 | 2354 | ||
| 2355 | + | /* Consumes the caller's reference to @mnt. */ | |
| 2297 | 2356 | void dissolve_on_fput(struct vfsmount *mnt) | |
| 2298 | 2357 | { | |
| 2299 | - | struct mount *m = real_mount(mnt); | |
| 2358 | + | struct vfsmount *p __free(mntput) = mnt; | |
| 2359 | + | struct mount *m = real_mount(p); | |
| 2300 | 2360 | ||
| 2301 | 2361 | /* | |
| 2302 | 2362 | * m used to be the root of anon namespace; if it still is one, | |
| @@ -2319,13 +2379,14 @@ void dissolve_on_fput(struct vfsmount *mnt) | |||
| 2319 | 2379 | ||
| 2320 | 2380 | emptied_ns = m->mnt_ns; | |
| 2321 | 2381 | lock_mount_hash(); | |
| 2322 | - | umount_tree(m, UMOUNT_CONNECTED); | |
| 2382 | + | umount_tree(m, UMOUNT_COVER); | |
| 2323 | 2383 | unlock_mount_hash(); | |
| 2384 | + | mntput(no_free_ptr(p)); | |
| 2324 | 2385 | } | |
| 2325 | 2386 | } | |
| 2326 | 2387 | ||
| 2327 | 2388 | /* locks: namespace_shared && pinned(mnt) || mount_locked_reader */ | |
| 2328 | - | static bool __has_locked_children(struct mount *mnt, struct dentry *dentry) | |
| 2389 | + | bool has_locked_children(struct mount *mnt, struct dentry *dentry) | |
| 2329 | 2390 | { | |
| 2330 | 2391 | struct mount *child; | |
| 2331 | 2392 | ||
| @@ -2339,10 +2400,16 @@ static bool __has_locked_children(struct mount *mnt, struct dentry *dentry) | |||
| 2339 | 2400 | return false; | |
| 2340 | 2401 | } | |
| 2341 | 2402 | ||
| 2342 | - | bool has_locked_children(struct mount *mnt, struct dentry *dentry) | |
| 2403 | + | /* locks: namespace_shared && pinned(mnt) || mount_locked_reader */ | |
| 2404 | + | static bool __has_children(struct mount *mnt, struct dentry *dentry) | |
| 2343 | 2405 | { | |
| 2344 | - | guard(mount_locked_reader)(); | |
| 2345 | - | return __has_locked_children(mnt, dentry); | |
| 2406 | + | struct mount *child; | |
| 2407 | + | ||
| 2408 | + | list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) { | |
| 2409 | + | if (is_subdir(child->mnt_mountpoint, dentry)) | |
| 2410 | + | return true; | |
| 2411 | + | } | |
| 2412 | + | return false; | |
| 2346 | 2413 | } | |
| 2347 | 2414 | ||
| 2348 | 2415 | /* | |
| @@ -2401,7 +2468,7 @@ struct vfsmount *clone_private_mount(const struct path *path) | |||
| 2401 | 2468 | if (!ns_capable(old_mnt->mnt_ns->user_ns, CAP_SYS_ADMIN)) | |
| 2402 | 2469 | return ERR_PTR(-EPERM); | |
| 2403 | 2470 | ||
| 2404 | - | if (__has_locked_children(old_mnt, path->dentry)) | |
| 2471 | + | if (has_locked_children(old_mnt, path->dentry)) | |
| 2405 | 2472 | return ERR_PTR(-EINVAL); | |
| 2406 | 2473 | ||
| 2407 | 2474 | new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE); | |
| @@ -2564,11 +2631,11 @@ enum mnt_tree_flags_t { | |||
| 2564 | 2631 | static int attach_recursive_mnt(struct mount *source_mnt, | |
| 2565 | 2632 | const struct pinned_mountpoint *dest) | |
| 2566 | 2633 | { | |
| 2567 | - | struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns; | |
| 2568 | 2634 | struct mount *dest_mnt = dest->parent; | |
| 2569 | 2635 | struct mountpoint *dest_mp = dest->mp; | |
| 2570 | 2636 | HLIST_HEAD(tree_list); | |
| 2571 | 2637 | struct mnt_namespace *ns = dest_mnt->mnt_ns; | |
| 2638 | + | struct user_namespace *user_ns = ns->user_ns; | |
| 2572 | 2639 | struct pinned_mountpoint root = {}; | |
| 2573 | 2640 | struct mountpoint *shorter = NULL; | |
| 2574 | 2641 | struct mount *child, *p; | |
| @@ -2577,13 +2644,31 @@ static int attach_recursive_mnt(struct mount *source_mnt, | |||
| 2577 | 2644 | int err = 0; | |
| 2578 | 2645 | bool moving = mnt_has_parent(source_mnt); | |
| 2579 | 2646 | ||
| 2647 | + | /* | |
| 2648 | + | * A caller in an unprivileged mount namespaces may trigger an | |
| 2649 | + | * automount and propagate locked mounts into privileged mount | |
| 2650 | + | * namespaces. Take ownership from the target mount namespace. | |
| 2651 | + | * It's equivalent for everything but the automount case. | |
| 2652 | + | * | |
| 2653 | + | * Detached trees in anonymous mount namespaces by be handed | |
| 2654 | + | * over via SCM_RIGHTS or inherited in other ways on purpose | |
| 2655 | + | * the attaching task's mount namespace is authoritative, not | |
| 2656 | + | * the creator of the detached tree. | |
| 2657 | + | */ | |
| 2658 | + | if (is_anon_ns(ns)) | |
| 2659 | + | user_ns = current->nsproxy->mnt_ns->user_ns; | |
| 2660 | + | else | |
| 2661 | + | user_ns = ns->user_ns; | |
| 2662 | + | ||
| 2580 | 2663 | /* | |
| 2581 | 2664 | * Preallocate a mountpoint in case the new mounts need to be | |
| 2582 | 2665 | * mounted beneath mounts on the same mountpoint. | |
| 2583 | 2666 | */ | |
| 2584 | - | for (top = source_mnt; unlikely(top->overmount); top = top->overmount) { | |
| 2667 | + | for (top = source_mnt; ; top = top->overmount) { | |
| 2585 | 2668 | if (!shorter && is_mnt_ns_file(top->mnt.mnt_root)) | |
| 2586 | 2669 | shorter = top->mnt_mp; | |
| 2670 | + | if (likely(!top->overmount)) | |
| 2671 | + | break; | |
| 2587 | 2672 | } | |
| 2588 | 2673 | err = get_mountpoint(top->mnt.mnt_root, &root); | |
| 2589 | 2674 | if (err) | |
| @@ -2654,15 +2739,17 @@ static int attach_recursive_mnt(struct mount *source_mnt, | |||
| 2654 | 2739 | /* | |
| 2655 | 2740 | * If @q was locked it was meant to hide | |
| 2656 | 2741 | * whatever was under it. Let @child take over | |
| 2657 | - | * that job and lock it, then we can unlock @q. | |
| 2658 | - | * That'll allow another namespace to shed @q | |
| 2659 | - | * and reveal @child. Clearly, that mounter | |
| 2660 | - | * consented to this by not severing the mount | |
| 2661 | - | * relationship. Otherwise, what's the point. | |
| 2742 | + | * that job and lock it. If @child is the mount | |
| 2743 | + | * the caller placed we can then unlock @q: | |
| 2744 | + | * nothing another namespace does removes it | |
| 2745 | + | * again. A propagated copy goes away when the | |
| 2746 | + | * mounter of the original unmounts it, so @q | |
| 2747 | + | * keeps its lock. | |
| 2662 | 2748 | */ | |
| 2663 | 2749 | if (IS_MNT_LOCKED(q)) { | |
| 2664 | 2750 | child->mnt.mnt_flags |= MNT_LOCKED; | |
| 2665 | - | q->mnt.mnt_flags &= ~MNT_LOCKED; | |
| 2751 | + | if (child == source_mnt) | |
| 2752 | + | q->mnt.mnt_flags &= ~MNT_LOCKED; | |
| 2666 | 2753 | } | |
| 2667 | 2754 | mnt_change_mountpoint(r, mp, q); | |
| 2668 | 2755 | } | |
| @@ -2759,6 +2846,11 @@ static void do_lock_mount(const struct path *path, | |||
| 2759 | 2846 | ||
| 2760 | 2847 | scoped_guard(mount_locked_reader) { | |
| 2761 | 2848 | m = where_to_mount(path, &dentry, beneath); | |
| 2849 | + | /* sticky, so it takes no locks to refuse it */ | |
| 2850 | + | if (unlikely(cant_mount(dentry))) { | |
| 2851 | + | res->parent = ERR_PTR(-ENOENT); | |
| 2852 | + | return; | |
| 2853 | + | } | |
| 2762 | 2854 | if (&m->mnt != path->mnt) { | |
| 2763 | 2855 | mntget(&m->mnt); | |
| 2764 | 2856 | dget(dentry); | |
| @@ -2989,7 +3081,14 @@ static struct mount *__do_loopback(const struct path *old_path, | |||
| 2989 | 3081 | if (!may_copy_tree(old_path)) | |
| 2990 | 3082 | return ERR_PTR(-EINVAL); | |
| 2991 | 3083 | ||
| 2992 | - | if (!recurse && __has_locked_children(old, old_path->dentry)) | |
| 3084 | + | /* a pseudo dentry is freed without an RCU delay, no walk may find it */ | |
| 3085 | + | if (old_path->dentry->d_flags & DCACHE_NORCU) | |
| 3086 | + | return ERR_PTR(-EINVAL); | |
| 3087 | + | ||
| 3088 | + | if (recurse && !old->mnt_ns) | |
| 3089 | + | return ERR_PTR(-EINVAL); | |
| 3090 | + | ||
| 3091 | + | if (!recurse && has_locked_children(old, old_path->dentry)) | |
| 2993 | 3092 | return ERR_PTR(-EINVAL); | |
| 2994 | 3093 | ||
| 2995 | 3094 | if (recurse) | |
| @@ -3028,7 +3127,11 @@ static int do_loopback(const struct path *path, const char *old_name, | |||
| 3028 | 3127 | if (IS_ERR(mnt)) | |
| 3029 | 3128 | return PTR_ERR(mnt); | |
| 3030 | 3129 | ||
| 3031 | - | err = graft_tree(mnt, &mp); | |
| 3130 | + | /* the copy may carry mount namespace files from below the source */ | |
| 3131 | + | if (recurse && !check_for_nsfs_mounts(mnt)) | |
| 3132 | + | err = -EINVAL; | |
| 3133 | + | else | |
| 3134 | + | err = graft_tree(mnt, &mp); | |
| 3032 | 3135 | if (err) { | |
| 3033 | 3136 | lock_mount_hash(); | |
| 3034 | 3137 | umount_tree(mnt, UMOUNT_SYNC); | |
| @@ -3088,7 +3191,7 @@ static struct file *open_detached_copy(struct path *path, unsigned int flags) | |||
| 3088 | 3191 | path->mnt = mntget(&ns->root->mnt); | |
| 3089 | 3192 | file = dentry_open(path, O_PATH, current_cred()); | |
| 3090 | 3193 | if (IS_ERR(file)) | |
| 3091 | - | dissolve_on_fput(path->mnt); | |
| 3194 | + | dissolve_on_fput(no_free_ptr(path->mnt)); | |
| 3092 | 3195 | else | |
| 3093 | 3196 | file->f_mode |= FMODE_NEED_UNMOUNT; | |
| 3094 | 3197 | return file; | |
| @@ -3110,12 +3213,18 @@ static struct mnt_namespace *create_new_namespace(struct path *path, | |||
| 3110 | 3213 | struct mount *mnt; | |
| 3111 | 3214 | unsigned int copy_flags = 0; | |
| 3112 | 3215 | bool locked = false, recurse = flags & MOUNT_COPY_RECURSIVE; | |
| 3216 | + | bool foreign = user_ns != ns->user_ns; | |
| 3113 | 3217 | ||
| 3114 | 3218 | if (unlikely(!d_can_lookup(path->dentry))) | |
| 3115 | 3219 | return ERR_PTR(-ENOTDIR); | |
| 3116 | 3220 | ||
| 3117 | - | if (user_ns != ns->user_ns) | |
| 3118 | - | copy_flags |= CL_SLAVE; | |
| 3221 | + | /* | |
| 3222 | + | * Without privileges over the mount namespace the copy is made from | |
| 3223 | + | * nothing mounted below @path may be left out. It would reveal what | |
| 3224 | + | * it covers. That's what unshare() gives such a caller as well. | |
| 3225 | + | */ | |
| 3226 | + | if (foreign) | |
| 3227 | + | copy_flags |= CL_SLAVE | CL_COPY_UNBINDABLE; | |
| 3119 | 3228 | ||
| 3120 | 3229 | new_ns = alloc_mnt_ns(user_ns, false); | |
| 3121 | 3230 | if (IS_ERR(new_ns)) | |
| @@ -3149,10 +3258,14 @@ static struct mnt_namespace *create_new_namespace(struct path *path, | |||
| 3149 | 3258 | /* | |
| 3150 | 3259 | * We don't emulate unshare()ing a mount namespace. We stick to | |
| 3151 | 3260 | * the restrictions of creating detached bind-mounts. It has a | |
| 3152 | - | * lot saner and simpler semantics. | |
| 3261 | + | * lot saner and simpler semantics. A caller without privileges | |
| 3262 | + | * over the mount namespace can't leave out any child though. | |
| 3153 | 3263 | */ | |
| 3154 | 3264 | if (flags & MOUNT_COPY_NEW) | |
| 3155 | 3265 | mnt = clone_mnt(real_mount(path->mnt), path->dentry, copy_flags); | |
| 3266 | + | else if (foreign && !recurse && | |
| 3267 | + | __has_children(real_mount(path->mnt), path->dentry)) | |
| 3268 | + | mnt = ERR_PTR(-EINVAL); | |
| 3156 | 3269 | else | |
| 3157 | 3270 | mnt = __do_loopback(path, recurse, copy_flags); | |
| 3158 | 3271 | scoped_guard(mount_writer) { | |
| @@ -3169,7 +3282,7 @@ static struct mnt_namespace *create_new_namespace(struct path *path, | |||
| 3169 | 3282 | * of the real rootfs we created. | |
| 3170 | 3283 | */ | |
| 3171 | 3284 | attach_mnt(mnt, new_ns_root, mp.mp); | |
| 3172 | - | if (user_ns != ns->user_ns) | |
| 3285 | + | if (foreign) | |
| 3173 | 3286 | lock_mnt_tree(new_ns_root); | |
| 3174 | 3287 | } | |
| 3175 | 3288 | ||
| @@ -3463,11 +3576,11 @@ static int do_set_group(const struct path *from_path, const struct path *to_path | |||
| 3463 | 3576 | return -EINVAL; | |
| 3464 | 3577 | ||
| 3465 | 3578 | /* From mount should not have locked children in place of To's root */ | |
| 3466 | - | if (__has_locked_children(from, to->mnt.mnt_root)) | |
| 3579 | + | if (has_locked_children(from, to->mnt.mnt_root)) | |
| 3467 | 3580 | return -EINVAL; | |
| 3468 | 3581 | ||
| 3469 | 3582 | /* Setting sharing groups is only allowed on private mounts */ | |
| 3470 | - | if (IS_MNT_SHARED(to) || IS_MNT_SLAVE(to)) | |
| 3583 | + | if (IS_MNT_SHARED(to) || IS_MNT_SLAVE(to) || IS_MNT_UNBINDABLE(to)) | |
| 3471 | 3584 | return -EINVAL; | |
| 3472 | 3585 | ||
| 3473 | 3586 | /* From should not be private */ | |
| @@ -3743,7 +3856,7 @@ static int do_add_mount(struct mount *newmnt, const struct pinned_mountpoint *mp | |||
| 3743 | 3856 | if (!(mnt_flags & MNT_SHRINKABLE)) | |
| 3744 | 3857 | return -EINVAL; | |
| 3745 | 3858 | /* ... and for those we'd better have mountpoint still alive */ | |
| 3746 | - | if (!parent->mnt_ns) | |
| 3859 | + | if (!is_mounted(&parent->mnt)) | |
| 3747 | 3860 | return -EINVAL; | |
| 3748 | 3861 | } | |
| 3749 | 3862 | ||
| @@ -3953,6 +4066,8 @@ void mark_mounts_for_expiry(struct list_head *mounts) | |||
| 3953 | 4066 | list_for_each_entry_safe(mnt, next, mounts, mnt_expire) { | |
| 3954 | 4067 | if (!is_mounted(&mnt->mnt)) | |
| 3955 | 4068 | continue; | |
| 4069 | + | /* lock_mnt_tree() leaves expirable mounts alone */ | |
| 4070 | + | VFS_WARN_ON_ONCE(IS_MNT_LOCKED(mnt)); | |
| 3956 | 4071 | if (!xchg(&mnt->mnt_expiry_mark, 1) || | |
| 3957 | 4072 | propagate_mount_busy(mnt, 1)) | |
| 3958 | 4073 | continue; | |
| @@ -3960,6 +4075,11 @@ void mark_mounts_for_expiry(struct list_head *mounts) | |||
| 3960 | 4075 | } | |
| 3961 | 4076 | while (!list_empty(&graveyard)) { | |
| 3962 | 4077 | mnt = list_first_entry(&graveyard, struct mount, mnt_expire); | |
| 4078 | + | /* an earlier umount_tree() may have moved a busy mount here */ | |
| 4079 | + | if (propagate_mount_busy(mnt, 1)) { | |
| 4080 | + | list_move(&mnt->mnt_expire, mounts); | |
| 4081 | + | continue; | |
| 4082 | + | } | |
| 3963 | 4083 | touch_mnt_namespace(mnt->mnt_ns); | |
| 3964 | 4084 | umount_tree(mnt, UMOUNT_PROPAGATE|UMOUNT_SYNC); | |
| 3965 | 4085 | } | |
| @@ -3967,17 +4087,38 @@ void mark_mounts_for_expiry(struct list_head *mounts) | |||
| 3967 | 4087 | ||
| 3968 | 4088 | EXPORT_SYMBOL_GPL(mark_mounts_for_expiry); | |
| 3969 | 4089 | ||
| 4090 | + | /* | |
| 4091 | + | * Unmount @mnt if it's a shrinkable mount without children that nobody uses. | |
| 4092 | + | * | |
| 4093 | + | * mount_lock must be held for write | |
| 4094 | + | */ | |
| 4095 | + | static bool shrink_submount(struct mount *mnt) | |
| 4096 | + | { | |
| 4097 | + | /* not the kernel's to remove either */ | |
| 4098 | + | if (IS_MNT_LOCKED(mnt) || propagate_mount_busy(mnt, 1)) | |
| 4099 | + | return false; | |
| 4100 | + | touch_mnt_namespace(mnt->mnt_ns); | |
| 4101 | + | umount_tree(mnt, UMOUNT_PROPAGATE|UMOUNT_SYNC); | |
| 4102 | + | return true; | |
| 4103 | + | } | |
| 4104 | + | ||
| 3970 | 4105 | /* | |
| 3971 | 4106 | * Ripoff of 'select_parent()' | |
| 3972 | 4107 | * | |
| 3973 | - | * search the list of submounts for a given mountpoint, and move any | |
| 3974 | - | * shrinkable submounts to the 'graveyard' list. | |
| 4108 | + | * unmount the shrinkable submounts of @parent that aren't busy, children | |
| 4109 | + | * before their parent, and say whether anything went | |
| 4110 | + | * | |
| 4111 | + | * The cursor into the children of @this_parent survives the umount of a | |
| 4112 | + | * child mount without child mounts. The mounts that get umounted together with | |
| 4113 | + | * it are located under receiving mounts of @this_parent and never under | |
| 4114 | + | * @this_parent itself. The one exception is @this_parent getting unmounted | |
| 4115 | + | * then the walk starts over. | |
| 3975 | 4116 | */ | |
| 3976 | - | static int select_submounts(struct mount *parent, struct list_head *graveyard) | |
| 4117 | + | static bool __shrink_submounts(struct mount *parent) | |
| 3977 | 4118 | { | |
| 3978 | 4119 | struct mount *this_parent = parent; | |
| 3979 | 4120 | struct list_head *next; | |
| 3980 | - | int found = 0; | |
| 4121 | + | bool shrunk = false; | |
| 3981 | 4122 | ||
| 3982 | 4123 | repeat: | |
| 3983 | 4124 | next = this_parent->mnt_mounts.next; | |
| @@ -3996,42 +4137,45 @@ resume: | |||
| 3996 | 4137 | this_parent = mnt; | |
| 3997 | 4138 | goto repeat; | |
| 3998 | 4139 | } | |
| 3999 | - | ||
| 4000 | - | if (!propagate_mount_busy(mnt, 1)) { | |
| 4001 | - | list_move_tail(&mnt->mnt_expire, graveyard); | |
| 4002 | - | found++; | |
| 4003 | - | } | |
| 4140 | + | if (!shrink_submount(mnt)) | |
| 4141 | + | continue; | |
| 4142 | + | shrunk = true; | |
| 4143 | + | if (unlikely(this_parent->mnt.mnt_flags & MNT_UMOUNT)) | |
| 4144 | + | return true; | |
| 4004 | 4145 | } | |
| 4005 | 4146 | /* | |
| 4006 | 4147 | * All done at this level ... ascend and resume the search | |
| 4007 | 4148 | */ | |
| 4008 | 4149 | if (this_parent != parent) { | |
| 4009 | - | next = this_parent->mnt_child.next; | |
| 4010 | - | this_parent = this_parent->mnt_parent; | |
| 4150 | + | struct mount *mnt = this_parent; | |
| 4151 | + | ||
| 4152 | + | next = mnt->mnt_child.next; | |
| 4153 | + | this_parent = mnt->mnt_parent; | |
| 4154 | + | /* its children are gone, maybe it can go as well */ | |
| 4155 | + | if (shrink_submount(mnt)) { | |
| 4156 | + | shrunk = true; | |
| 4157 | + | if (unlikely(this_parent->mnt.mnt_flags & MNT_UMOUNT)) | |
| 4158 | + | return true; | |
| 4159 | + | } | |
| 4011 | 4160 | goto resume; | |
| 4012 | 4161 | } | |
| 4013 | - | return found; | |
| 4162 | + | return shrunk; | |
| 4014 | 4163 | } | |
| 4015 | 4164 | ||
| 4016 | 4165 | /* | |
| 4017 | - | * process a list of expirable mountpoints with the intent of discarding any | |
| 4018 | - | * submounts of a specific parent mountpoint | |
| 4166 | + | * unmount the shrinkable submounts of @mnt that aren't busy | |
| 4167 | + | * | |
| 4168 | + | * The busy check and the umount of a mount are adjacent. An umount can | |
| 4169 | + | * still empty or move a mount in a part of the tree that was walked | |
| 4170 | + | * already, so walk again until nothing goes. | |
| 4019 | 4171 | * | |
| 4020 | 4172 | * mount_lock must be held for write | |
| 4021 | 4173 | */ | |
| 4022 | 4174 | static void shrink_submounts(struct mount *mnt) | |
| 4023 | 4175 | { | |
| 4024 | - | LIST_HEAD(graveyard); | |
| 4025 | - | struct mount *m; | |
| 4026 | - | ||
| 4027 | - | /* extract submounts of 'mountpoint' from the expiration list */ | |
| 4028 | - | while (select_submounts(mnt, &graveyard)) { | |
| 4029 | - | while (!list_empty(&graveyard)) { | |
| 4030 | - | m = list_first_entry(&graveyard, struct mount, | |
| 4031 | - | mnt_expire); | |
| 4032 | - | touch_mnt_namespace(m->mnt_ns); | |
| 4033 | - | umount_tree(m, UMOUNT_PROPAGATE|UMOUNT_SYNC); | |
| 4034 | - | } | |
| 4176 | + | for (;;) { | |
| 4177 | + | if (!__shrink_submounts(mnt)) | |
| 4178 | + | break; | |
| 4035 | 4179 | } | |
| 4036 | 4180 | } | |
| 4037 | 4181 | ||
| @@ -4196,6 +4340,8 @@ static void free_mnt_ns(struct mnt_namespace *ns) | |||
| 4196 | 4340 | if (!is_anon_ns(ns)) | |
| 4197 | 4341 | ns_common_free(ns); | |
| 4198 | 4342 | dec_mnt_namespaces(ns->ucounts); | |
| 4343 | + | /* the last active reference is gone, no mark can show up anymore */ | |
| 4344 | + | fsnotify_mntns_delete(ns); | |
| 4199 | 4345 | mnt_ns_tree_remove(ns); | |
| 4200 | 4346 | } | |
| 4201 | 4347 | ||
| @@ -4545,7 +4691,7 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, | |||
| 4545 | 4691 | FD_PREPARE(fdf, (flags & FSMOUNT_CLOEXEC) ? O_CLOEXEC : 0, | |
| 4546 | 4692 | dentry_open(&new_path, O_PATH, fc->cred)); | |
| 4547 | 4693 | if (fdf.err) { | |
| 4548 | - | dissolve_on_fput(new_path.mnt); | |
| 4694 | + | dissolve_on_fput(no_free_ptr(new_path.mnt)); | |
| 4549 | 4695 | return fdf.err; | |
| 4550 | 4696 | } | |
| 4551 | 4697 | ||
| @@ -4697,14 +4843,15 @@ int path_pivot_root(struct path *new, struct path *old) | |||
| 4697 | 4843 | ||
| 4698 | 4844 | new_mnt = real_mount(new->mnt); | |
| 4699 | 4845 | root_mnt = real_mount(root.mnt); | |
| 4846 | + | /* only a mounted mount has a parent that namespace_sem pins */ | |
| 4847 | + | if (!check_mnt(root_mnt) || !check_mnt(new_mnt)) | |
| 4848 | + | return -EINVAL; | |
| 4700 | 4849 | ex_parent = new_mnt->mnt_parent; | |
| 4701 | 4850 | root_parent = root_mnt->mnt_parent; | |
| 4702 | 4851 | if (IS_MNT_SHARED(old_mnt) || | |
| 4703 | 4852 | IS_MNT_SHARED(ex_parent) || | |
| 4704 | 4853 | IS_MNT_SHARED(root_parent)) | |
| 4705 | 4854 | return -EINVAL; | |
| 4706 | - | if (!check_mnt(root_mnt) || !check_mnt(new_mnt)) | |
| 4707 | - | return -EINVAL; | |
| 4708 | 4855 | if (new_mnt->mnt.mnt_flags & MNT_LOCKED) | |
| 4709 | 4856 | return -EINVAL; | |
| 4710 | 4857 | if (d_unlinked(new->dentry)) | |
| @@ -4955,6 +5102,11 @@ static int do_mount_setattr(const struct path *path, struct mount_kattr *kattr) | |||
| 4955 | 5102 | * propagation. | |
| 4956 | 5103 | */ | |
| 4957 | 5104 | namespace_lock(); | |
| 5105 | + | /* invent_group_ids() walks the tree, only walk a mounted one */ | |
| 5106 | + | if (!anon_ns_root(mnt) && !check_mnt(mnt)) { | |
| 5107 | + | namespace_unlock(); | |
| 5108 | + | return -EINVAL; | |
| 5109 | + | } | |
| 4958 | 5110 | if (kattr->propagation == MS_SHARED) { | |
| 4959 | 5111 | err = invent_group_ids(mnt, kattr->kflags & MOUNT_KATTR_RECURSE); | |
| 4960 | 5112 | if (err) { | |
| @@ -4967,6 +5119,7 @@ static int do_mount_setattr(const struct path *path, struct mount_kattr *kattr) | |||
| 4967 | 5119 | err = -EINVAL; | |
| 4968 | 5120 | lock_mount_hash(); | |
| 4969 | 5121 | ||
| 5122 | + | /* Checked under namespace_sem already if the propagation changes. */ | |
| 4970 | 5123 | if (!anon_ns_root(mnt) && !check_mnt(mnt)) | |
| 4971 | 5124 | goto out; | |
| 4972 | 5125 | ||
| @@ -5319,15 +5472,25 @@ static void statmount_sb_basic(struct kstatmount *s) | |||
| 5319 | 5472 | s->sm.sb_flags = sb->s_flags & (SB_RDONLY|SB_SYNCHRONOUS|SB_DIRSYNC|SB_LAZYTIME); | |
| 5320 | 5473 | } | |
| 5321 | 5474 | ||
| 5475 | + | static void statmount_mnt_parent(struct kstatmount *s, const struct mount *m) | |
| 5476 | + | { | |
| 5477 | + | s->sm.mnt_parent_id = m->mnt_parent->mnt_id_unique; | |
| 5478 | + | s->sm.mnt_parent_id_old = m->mnt_parent->mnt_id; | |
| 5479 | + | } | |
| 5480 | + | ||
| 5322 | 5481 | static void statmount_mnt_basic(struct kstatmount *s) | |
| 5323 | 5482 | { | |
| 5324 | 5483 | struct mount *m = real_mount(s->mnt); | |
| 5325 | 5484 | ||
| 5326 | 5485 | s->sm.mask |= STATMOUNT_MNT_BASIC; | |
| 5327 | 5486 | s->sm.mnt_id = m->mnt_id_unique; | |
| 5328 | - | s->sm.mnt_parent_id = m->mnt_parent->mnt_id_unique; | |
| 5329 | 5487 | s->sm.mnt_id_old = m->mnt_id; | |
| 5330 | - | s->sm.mnt_parent_id_old = m->mnt_parent->mnt_id; | |
| 5488 | + | /* An unmounted mount is cut loose from its parent under mount_lock alone. */ | |
| 5489 | + | if (likely(is_mounted(s->mnt))) | |
| 5490 | + | statmount_mnt_parent(s, m); | |
| 5491 | + | else | |
| 5492 | + | scoped_guard(mount_locked_reader) | |
| 5493 | + | statmount_mnt_parent(s, m); | |
| 5331 | 5494 | s->sm.mnt_attr = mnt_to_attr_flags(&m->mnt); | |
| 5332 | 5495 | s->sm.mnt_propagation = mnt_to_propagation_flags(m); | |
| 5333 | 5496 | s->sm.mnt_peer_group = m->mnt_group_id; | |
| @@ -6199,6 +6362,25 @@ static void __init mount_rootfs_on_nullfs(struct vfsmount *mnt, | |||
| 6199 | 6362 | attach_mnt(real_mount(mnt), mp.parent, mp.mp); | |
| 6200 | 6363 | } | |
| 6201 | 6364 | ||
| 6365 | + | static struct vfsmount *__init knullfs_file_mount(void) | |
| 6366 | + | { | |
| 6367 | + | struct dentry *file; | |
| 6368 | + | struct mount *mnt; | |
| 6369 | + | ||
| 6370 | + | file = nullfs_new_file(knullfs->mnt_sb); | |
| 6371 | + | if (IS_ERR(file)) | |
| 6372 | + | return ERR_CAST(file); | |
| 6373 | + | mnt = clone_mnt(real_mount(knullfs), file, CL_PRIVATE); | |
| 6374 | + | dput(file); | |
| 6375 | + | if (IS_ERR(mnt)) | |
| 6376 | + | return ERR_CAST(mnt); | |
| 6377 | + | mnt->mnt_ns = MNT_NS_INTERNAL; | |
| 6378 | + | mnt->mnt.mnt_flags |= MNT_INTERNAL; | |
| 6379 | + | mnt->mnt.mnt_flags &= ~MNT_READONLY; | |
| 6380 | + | dont_mount(mnt->mnt.mnt_root); | |
| 6381 | + | return &mnt->mnt; | |
| 6382 | + | } | |
| 6383 | + | ||
| 6202 | 6384 | static void __init init_mount_tree(void) | |
| 6203 | 6385 | { | |
| 6204 | 6386 | struct vfsmount *mnt, *nullfs_mnt; | |
| @@ -6210,10 +6392,14 @@ static void __init init_mount_tree(void) | |||
| 6210 | 6392 | * | |
| 6211 | 6393 | * (1) nullfs with mount id 1 | |
| 6212 | 6394 | * (2) mutable rootfs with mount id 2 | |
| 6213 | - | * (3) private nullfs for kthreads (SB_KERNMOUNT) | |
| 6395 | + | * (3) private nullfs for kthreads (SB_KERNMOUNT), kept in knullfs | |
| 6396 | + | * (4) a second mount of (3) rooted on a regular file, kept in | |
| 6397 | + | * knullfs_file | |
| 6214 | 6398 | * | |
| 6215 | 6399 | * with (2) mounted on top of (1). The init_task's root and pwd | |
| 6216 | 6400 | * are pointed at (3) so all kthreads start isolated in nullfs. | |
| 6401 | + | * A lookup at the cover an unmounted mount left behind finds (3) | |
| 6402 | + | * or (4), see __lookup_mnt(). | |
| 6217 | 6403 | */ | |
| 6218 | 6404 | nullfs_mnt = vfs_kern_mount(&nullfs_fs_type, 0, "nullfs", NULL); | |
| 6219 | 6405 | if (IS_ERR(nullfs_mnt)) | |
| @@ -6245,11 +6431,18 @@ static void __init init_mount_tree(void) | |||
| 6245 | 6431 | init_mnt_ns.nr_mounts++; | |
| 6246 | 6432 | } | |
| 6247 | 6433 | ||
| 6248 | - | nullfs_mnt = kern_mount(&nullfs_fs_type); | |
| 6249 | - | if (IS_ERR(nullfs_mnt)) | |
| 6434 | + | knullfs = kern_mount(&nullfs_fs_type); | |
| 6435 | + | if (IS_ERR(knullfs)) | |
| 6250 | 6436 | panic("VFS: Failed to create private nullfs instance"); | |
| 6251 | - | root.mnt = nullfs_mnt; | |
| 6252 | - | root.dentry = nullfs_mnt->mnt_root; | |
| 6437 | + | /* nothing is ever mounted on the root of a kernel thread */ | |
| 6438 | + | dont_mount(knullfs->mnt_root); | |
| 6439 | + | /* and nothing is ever written through it */ | |
| 6440 | + | knullfs->mnt_flags |= MNT_READONLY; | |
| 6441 | + | knullfs_file = knullfs_file_mount(); | |
| 6442 | + | if (IS_ERR(knullfs_file)) | |
| 6443 | + | panic("VFS: Failed to create the nullfs file stand-in"); | |
| 6444 | + | root.mnt = knullfs; | |
| 6445 | + | root.dentry = knullfs->mnt_root; | |
| 6253 | 6446 | ||
| 6254 | 6447 | init_task.nsproxy->mnt_ns = &init_mnt_ns; | |
| 6255 | 6448 | get_mnt_ns(&init_mnt_ns); | |
modified fs/netfs/buffered_read.c
| @@ -541,6 +541,13 @@ static int netfs_read_gaps(struct file *file, struct folio *folio) | |||
| 541 | 541 | ||
| 542 | 542 | ret = netfs_wait_for_read(rreq); | |
| 543 | 543 | if (ret >= 0) { | |
| 544 | + | if (ret < flen) { | |
| 545 | + | struct iov_iter iter; | |
| 546 | + | ||
| 547 | + | iov_iter_bvec(&iter, ITER_DEST, bvec, i, flen); | |
| 548 | + | iov_iter_advance(&iter, ret); | |
| 549 | + | iov_iter_zero(flen - ret, &iter); | |
| 550 | + | } | |
| 544 | 551 | if (group) | |
| 545 | 552 | folio_change_private(folio, group); | |
| 546 | 553 | else | |
modified fs/netfs/buffered_write.c
| @@ -469,6 +469,7 @@ ssize_t netfs_buffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *fr | |||
| 469 | 469 | struct netfs_group *netfs_group) | |
| 470 | 470 | { | |
| 471 | 471 | struct file *file = iocb->ki_filp; | |
| 472 | + | struct inode *inode = file_inode(file); | |
| 472 | 473 | ssize_t ret; | |
| 473 | 474 | ||
| 474 | 475 | trace_netfs_write_iter(iocb, from); | |
| @@ -481,6 +482,14 @@ ssize_t netfs_buffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *fr | |||
| 481 | 482 | if (ret) | |
| 482 | 483 | return ret; | |
| 483 | 484 | ||
| 485 | + | if (iocb->ki_pos > i_size_read(inode)) { | |
| 486 | + | ret = netfs_clear_stale_pre_isize(inode, i_size_read(inode), | |
| 487 | + | iocb->ki_pos, | |
| 488 | + | iocb->ki_flags & IOCB_NOWAIT); | |
| 489 | + | if (ret) | |
| 490 | + | return ret; | |
| 491 | + | } | |
| 492 | + | ||
| 484 | 493 | return netfs_perform_write(iocb, from, netfs_group); | |
| 485 | 494 | } | |
| 486 | 495 | EXPORT_SYMBOL(netfs_buffered_write_iter_locked); | |
modified fs/netfs/direct_write.c
| @@ -359,6 +359,15 @@ ssize_t netfs_unbuffered_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
| 359 | 359 | ret = file_update_time(file); | |
| 360 | 360 | if (ret < 0) | |
| 361 | 361 | goto out; | |
| 362 | + | ||
| 363 | + | if (iocb->ki_pos > i_size_read(inode)) { | |
| 364 | + | ret = netfs_clear_stale_pre_isize(inode, i_size_read(inode), | |
| 365 | + | iocb->ki_pos, | |
| 366 | + | iocb->ki_flags & IOCB_NOWAIT); | |
| 367 | + | if (ret < 0) | |
| 368 | + | goto out; | |
| 369 | + | } | |
| 370 | + | ||
| 362 | 371 | if (iocb->ki_flags & IOCB_NOWAIT) { | |
| 363 | 372 | /* We could block if there are any pages in the range. */ | |
| 364 | 373 | ret = -EAGAIN; | |
modified fs/netfs/internal.h
| @@ -80,6 +80,8 @@ ssize_t netfs_wait_for_write(struct netfs_io_request *rreq); | |||
| 80 | 80 | void netfs_wait_for_paused_read(struct netfs_io_request *rreq); | |
| 81 | 81 | void netfs_wait_for_paused_write(struct netfs_io_request *rreq); | |
| 82 | 82 | void netfs_wait_for_put_ra_refs(struct netfs_io_request *rreq); | |
| 83 | + | int netfs_clear_stale_pre_isize(struct inode *inode, uoff_t from, | |
| 84 | + | uoff_t to, bool nowait); | |
| 83 | 85 | ||
| 84 | 86 | /* | |
| 85 | 87 | * objects.c | |
modified fs/netfs/misc.c
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | */ | |
| 7 | 7 | ||
| 8 | 8 | #include <linux/swap.h> | |
| 9 | + | #include <linux/rmap.h> | |
| 9 | 10 | #include "internal.h" | |
| 10 | 11 | ||
| 11 | 12 | /** | |
| @@ -582,3 +583,101 @@ void netfs_wait_for_put_ra_refs(struct netfs_io_request *rreq) | |||
| 582 | 583 | trace_netfs_rreq(rreq, netfs_rreq_trace_waited_put_ra_refs); | |
| 583 | 584 | finish_wait(&rreq->waitq, &myself); | |
| 584 | 585 | } | |
| 586 | + | ||
| 587 | + | /** | |
| 588 | + | * netfs_clear_stale_isize - Clear stale pagecache in a to-be-created hole | |
| 589 | + | * @inode: The inode to act upon. | |
| 590 | + | * @from: The base of the hole to be made. | |
| 591 | + | * @to: The top of the hole to be made. | |
| 592 | + | * @nowait: True to return -EAGAIN rather than block. | |
| 593 | + | * @exclusive: True if the caller holds i_rwsem exclusively for the resize. | |
| 594 | + | * | |
| 595 | + | * Zero any data left in the pagecache within the [@from, @to) hole by a | |
| 596 | + | * write through an mmap so that it isn't exposed as file content once the | |
| 597 | + | * file is extended. Only the uptodate folio straddling @from can hold such | |
| 598 | + | * data as pages wholly beyond the EOF can't be faulted in, so the zeroing | |
| 599 | + | * is limited to that folio. The folio is zeroed rather than dropped so | |
| 600 | + | * that a concurrent extending write can't lose data. | |
| 601 | + | * | |
| 602 | + | * If @exclusive is false, @from is re-read from i_size and used to clamp | |
| 603 | + | * the zeroed range, for callers that may race with another writer also | |
| 604 | + | * extending the file (eg. multiple buffered writes extending the same file | |
| 605 | + | * under a shared i_rwsem). If @exclusive is true, for callers that hold | |
| 606 | + | * i_rwsem exclusively across the whole resize and have already updated | |
| 607 | + | * i_size to @to, staleness is decided from the folio's dirty state instead: | |
| 608 | + | * since no genuine concurrent buffered writer can be racing, a lockless | |
| 609 | + | * stat() adopting a server-confirmed size mid-resize has no data behind it | |
| 610 | + | * and never dirties the folio, so it can't fool this check into skipping | |
| 611 | + | * the zeroing the way it could fool the @exclusive false clamp. | |
| 612 | + | * | |
| 613 | + | * pagecache_isize_extended() can't be reused here: it is keyed on a | |
| 614 | + | * sub-page block size (a no-op when the block size is >= PAGE_SIZE, as on | |
| 615 | + | * network filesystems), runs after i_size is updated, can't honour | |
| 616 | + | * @nowait, and doesn't wait for writeback. Keep the two in sync if either | |
| 617 | + | * is changed. | |
| 618 | + | * | |
| 619 | + | * Return: 0 on success, or -EAGAIN if @nowait is set and the folio is | |
| 620 | + | * mapped or under writeback and so can't be cleaned without blocking. | |
| 621 | + | */ | |
| 622 | + | static int netfs_clear_stale_isize(struct inode *inode, uoff_t from, | |
| 623 | + | uoff_t to, bool nowait, bool exclusive) | |
| 624 | + | { | |
| 625 | + | struct address_space *mapping = inode->i_mapping; | |
| 626 | + | fgf_t fgp = FGP_LOCK; | |
| 627 | + | struct folio *folio; | |
| 628 | + | int ret; | |
| 629 | + | ||
| 630 | + | if (from >= to) | |
| 631 | + | return 0; | |
| 632 | + | ||
| 633 | + | if (nowait) | |
| 634 | + | fgp |= FGP_NOWAIT; | |
| 635 | + | ||
| 636 | + | folio = __filemap_get_folio(mapping, from >> PAGE_SHIFT, fgp, 0); | |
| 637 | + | if (IS_ERR(folio)) | |
| 638 | + | return PTR_ERR(folio) == -EAGAIN ? -EAGAIN : 0; | |
| 639 | + | ||
| 640 | + | ret = 0; | |
| 641 | + | if (nowait && (folio_mapped(folio) || folio_test_writeback(folio))) { | |
| 642 | + | ret = -EAGAIN; | |
| 643 | + | goto out; | |
| 644 | + | } | |
| 645 | + | ||
| 646 | + | folio_wait_writeback(folio); | |
| 647 | + | ||
| 648 | + | if (folio_mkclean(folio)) | |
| 649 | + | folio_mark_dirty(folio); | |
| 650 | + | ||
| 651 | + | if (folio_test_uptodate(folio) && | |
| 652 | + | (!exclusive || folio_test_dirty(folio))) { | |
| 653 | + | uoff_t fpos = folio_pos(folio); | |
| 654 | + | ||
| 655 | + | if (!exclusive) | |
| 656 | + | from = umax(from, i_size_read(inode)); | |
| 657 | + | if (from < to && from < fpos + folio_size(folio)) { | |
| 658 | + | size_t end = umin(to - fpos, folio_size(folio)); | |
| 659 | + | size_t offset = from - fpos; | |
| 660 | + | ||
| 661 | + | folio_zero_segment(folio, offset, end); | |
| 662 | + | } | |
| 663 | + | } | |
| 664 | + | out: | |
| 665 | + | folio_unlock(folio); | |
| 666 | + | folio_put(folio); | |
| 667 | + | return ret; | |
| 668 | + | } | |
| 669 | + | ||
| 670 | + | /* Clear stale pagecache before an extending buffered/DIO write. */ | |
| 671 | + | int netfs_clear_stale_pre_isize(struct inode *inode, uoff_t from, | |
| 672 | + | uoff_t to, bool nowait) | |
| 673 | + | { | |
| 674 | + | return netfs_clear_stale_isize(inode, from, to, nowait, false); | |
| 675 | + | } | |
| 676 | + | ||
| 677 | + | /* Clear stale pagecache when extending a file under an exclusive resize. */ | |
| 678 | + | void netfs_clear_stale_post_isize(struct inode *inode, uoff_t from, | |
| 679 | + | uoff_t to) | |
| 680 | + | { | |
| 681 | + | netfs_clear_stale_isize(inode, from, to, false, true); | |
| 682 | + | } | |
| 683 | + | EXPORT_SYMBOL(netfs_clear_stale_post_isize); | |
modified fs/netfs/read_collect.c
| @@ -33,6 +33,22 @@ static void netfs_clear_unread(struct netfs_io_subrequest *subreq) | |||
| 33 | 33 | __set_bit(NETFS_SREQ_HIT_EOF, &subreq->flags); | |
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | + | static void netfs_clear_unread_dio(struct netfs_io_subrequest *subreq) | |
| 37 | + | { | |
| 38 | + | uoff_t pos = subreq->start + subreq->transferred; | |
| 39 | + | struct netfs_io_request *rreq = subreq->rreq; | |
| 40 | + | size_t fill; | |
| 41 | + | ||
| 42 | + | if (pos >= rreq->i_size) | |
| 43 | + | return; | |
| 44 | + | ||
| 45 | + | fill = min_t(uoff_t, rreq->i_size - pos, | |
| 46 | + | subreq->len - subreq->transferred); | |
| 47 | + | ||
| 48 | + | netfs_reset_iter(subreq); | |
| 49 | + | subreq->transferred += iov_iter_zero(fill, &subreq->io_iter); | |
| 50 | + | } | |
| 51 | + | ||
| 36 | 52 | /* | |
| 37 | 53 | * Cancel the copy-to-cache mark on a folio. | |
| 38 | 54 | */ | |
| @@ -311,6 +327,14 @@ reassess: | |||
| 311 | 327 | test_bit(NETFS_SREQ_HIT_EOF, &front->flags)) | |
| 312 | 328 | netfs_read_unlock_folios(rreq, ¬es); | |
| 313 | 329 | } else { | |
| 330 | + | if (!(notes & HIT_PENDING) && | |
| 331 | + | front->error == 0 && | |
| 332 | + | transferred < front->len && | |
| 333 | + | test_bit(NETFS_SREQ_CLEAR_TAIL, &front->flags)) { | |
| 334 | + | netfs_clear_unread_dio(front); | |
| 335 | + | transferred = front->transferred; | |
| 336 | + | trace_netfs_sreq(front, netfs_sreq_trace_clear); | |
| 337 | + | } | |
| 314 | 338 | stream->collected_to = front->start + transferred; | |
| 315 | 339 | rreq->collected_to = stream->collected_to; | |
| 316 | 340 | } | |
modified fs/notify/mark.c
| @@ -903,6 +903,10 @@ static int fsnotify_add_mark_list(struct fsnotify_mark *mark, void *obj, | |||
| 903 | 903 | if (WARN_ON(!fsnotify_valid_obj_type(obj_type))) | |
| 904 | 904 | return -EINVAL; | |
| 905 | 905 | ||
| 906 | + | /* the filesystem doesn't want its objects watched */ | |
| 907 | + | if (sb && (sb->s_type->fs_flags & FS_DISALLOW_NOTIFY)) | |
| 908 | + | return -EINVAL; | |
| 909 | + | ||
| 906 | 910 | /* | |
| 907 | 911 | * Attach the sb info before attaching a connector to any object on sb. | |
| 908 | 912 | * The sb info will remain attached as long as sb lives. | |
modified fs/nullfs.c
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | #include <linux/fs/super_types.h> | |
| 4 | 4 | #include <linux/fs_context.h> | |
| 5 | 5 | #include <linux/magic.h> | |
| 6 | + | #include <linux/splice.h> | |
| 7 | + | #include <linux/uio.h> | |
| 6 | 8 | ||
| 7 | 9 | #include "mount.h" | |
| 8 | 10 | ||
| @@ -10,6 +12,121 @@ static const struct super_operations nullfs_super_operations = { | |||
| 10 | 12 | .statfs = simple_statfs, | |
| 11 | 13 | }; | |
| 12 | 14 | ||
| 15 | + | static loff_t nullfs_dir_llseek(struct file *file, loff_t offset, int whence) | |
| 16 | + | { | |
| 17 | + | /* an empty directory has two entries . and .. at offsets 0 and 1 */ | |
| 18 | + | return generic_file_llseek_size(file, offset, whence, 2, 2); | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | static int nullfs_dir_readdir(struct file *file, struct dir_context *ctx) | |
| 22 | + | { | |
| 23 | + | dir_emit_dots(file, ctx); | |
| 24 | + | return 0; | |
| 25 | + | } | |
| 26 | + | ||
| 27 | + | /* the one inode of nullfs is shared by every holder, so no locks on it */ | |
| 28 | + | static int nullfs_nolock(struct file *file, int cmd, struct file_lock *fl) | |
| 29 | + | { | |
| 30 | + | return -ENOLCK; | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | /* what libfs gives an empty directory, plus the refusal of file locks */ | |
| 34 | + | static const struct file_operations nullfs_dir_operations = { | |
| 35 | + | .llseek = nullfs_dir_llseek, | |
| 36 | + | .read = generic_read_dir, | |
| 37 | + | .iterate_shared = nullfs_dir_readdir, | |
| 38 | + | .fsync = noop_fsync, | |
| 39 | + | .lock = nullfs_nolock, | |
| 40 | + | .flock = nullfs_nolock, | |
| 41 | + | .fop_flags = FOP_IMMUTABLE, | |
| 42 | + | }; | |
| 43 | + | ||
| 44 | + | static ssize_t nullfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) | |
| 45 | + | { | |
| 46 | + | return 0; | |
| 47 | + | } | |
| 48 | + | ||
| 49 | + | static ssize_t nullfs_file_splice_read(struct file *in, loff_t *ppos, | |
| 50 | + | struct pipe_inode_info *pipe, | |
| 51 | + | size_t len, unsigned int flags) | |
| 52 | + | { | |
| 53 | + | return 0; | |
| 54 | + | } | |
| 55 | + | ||
| 56 | + | static ssize_t nullfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |
| 57 | + | { | |
| 58 | + | size_t count = iov_iter_count(from); | |
| 59 | + | ||
| 60 | + | iov_iter_advance(from, count); | |
| 61 | + | return count; | |
| 62 | + | } | |
| 63 | + | ||
| 64 | + | static int nullfs_pipe_to_null(struct pipe_inode_info *pipe, | |
| 65 | + | struct pipe_buffer *buf, struct splice_desc *sd) | |
| 66 | + | { | |
| 67 | + | return sd->len; | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | static ssize_t nullfs_file_splice_write(struct pipe_inode_info *pipe, | |
| 71 | + | struct file *out, loff_t *ppos, | |
| 72 | + | size_t len, unsigned int flags) | |
| 73 | + | { | |
| 74 | + | return splice_from_pipe(pipe, out, ppos, len, flags, nullfs_pipe_to_null); | |
| 75 | + | } | |
| 76 | + | ||
| 77 | + | static int nullfs_file_setattr(struct mnt_idmap *idmap, struct dentry *dentry, | |
| 78 | + | struct iattr *attr) | |
| 79 | + | { | |
| 80 | + | if (attr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)) | |
| 81 | + | return -EPERM; | |
| 82 | + | return 0; | |
| 83 | + | } | |
| 84 | + | ||
| 85 | + | static const struct inode_operations nullfs_file_inode_operations = { | |
| 86 | + | .setattr = nullfs_file_setattr, | |
| 87 | + | }; | |
| 88 | + | ||
| 89 | + | static const struct file_operations nullfs_file_operations = { | |
| 90 | + | .llseek = generic_file_llseek, | |
| 91 | + | .read_iter = nullfs_file_read_iter, | |
| 92 | + | .write_iter = nullfs_file_write_iter, | |
| 93 | + | .splice_read = nullfs_file_splice_read, | |
| 94 | + | .splice_write = nullfs_file_splice_write, | |
| 95 | + | .fsync = noop_fsync, | |
| 96 | + | .lock = nullfs_nolock, | |
| 97 | + | .flock = nullfs_nolock, | |
| 98 | + | }; | |
| 99 | + | ||
| 100 | + | /* | |
| 101 | + | * An empty regular file on @sb as a dentry of its own, never hashed under | |
| 102 | + | * the root so no lookup finds it. | |
| 103 | + | */ | |
| 104 | + | struct dentry *nullfs_new_file(struct super_block *sb) | |
| 105 | + | { | |
| 106 | + | struct dentry *dentry; | |
| 107 | + | struct inode *inode; | |
| 108 | + | ||
| 109 | + | inode = new_inode(sb); | |
| 110 | + | if (!inode) | |
| 111 | + | return ERR_PTR(-ENOMEM); | |
| 112 | + | ||
| 113 | + | /* the root directory is 1 */ | |
| 114 | + | inode->i_ino = 2; | |
| 115 | + | inode->i_mode = S_IFREG | 0666; | |
| 116 | + | inode->i_op = &nullfs_file_inode_operations; | |
| 117 | + | inode->i_fop = &nullfs_file_operations; | |
| 118 | + | simple_inode_init_ts(inode); | |
| 119 | + | inode->i_flags |= S_NOATIME; | |
| 120 | + | ||
| 121 | + | dentry = d_alloc_anon(sb); | |
| 122 | + | if (!dentry) { | |
| 123 | + | iput(inode); | |
| 124 | + | return ERR_PTR(-ENOMEM); | |
| 125 | + | } | |
| 126 | + | d_instantiate(dentry, inode); | |
| 127 | + | return dentry; | |
| 128 | + | } | |
| 129 | + | ||
| 13 | 130 | static int nullfs_fs_fill_super(struct super_block *s, struct fs_context *fc) | |
| 14 | 131 | { | |
| 15 | 132 | struct inode *inode; | |
| @@ -30,10 +147,11 @@ static int nullfs_fs_fill_super(struct super_block *s, struct fs_context *fc) | |||
| 30 | 147 | ||
| 31 | 148 | /* nullfs is permanently empty... */ | |
| 32 | 149 | make_empty_dir_inode(inode); | |
| 150 | + | inode->i_fop = &nullfs_dir_operations; | |
| 33 | 151 | simple_inode_init_ts(inode); | |
| 34 | 152 | inode->i_ino = 1; | |
| 35 | - | /* ... and immutable. */ | |
| 36 | - | inode->i_flags |= S_IMMUTABLE; | |
| 153 | + | /* ... and immutable, reading it leaves no trace either. */ | |
| 154 | + | inode->i_flags |= S_IMMUTABLE | S_NOATIME; | |
| 37 | 155 | ||
| 38 | 156 | s->s_root = d_make_root(inode); | |
| 39 | 157 | if (!s->s_root) | |
| @@ -61,6 +179,7 @@ static int nullfs_init_fs_context(struct fs_context *fc) | |||
| 61 | 179 | ||
| 62 | 180 | struct file_system_type nullfs_fs_type = { | |
| 63 | 181 | .name = "nullfs", | |
| 182 | + | .fs_flags = FS_DISALLOW_NOTIFY, | |
| 64 | 183 | .init_fs_context = nullfs_init_fs_context, | |
| 65 | 184 | .kill_sb = kill_anon_super, | |
| 66 | 185 | }; | |
modified fs/pnode.c
| @@ -410,19 +410,99 @@ bool propagation_would_overmount(const struct mount *from, | |||
| 410 | 410 | return false; | |
| 411 | 411 | } | |
| 412 | 412 | ||
| 413 | + | /* Does @m receive propagation from @parent? */ | |
| 414 | + | static bool receives_from(struct mount *m, struct mount *parent) | |
| 415 | + | { | |
| 416 | + | if (m == parent) | |
| 417 | + | return false; | |
| 418 | + | for (; m; m = m->mnt_master) | |
| 419 | + | if (m == parent || peers(m, parent)) | |
| 420 | + | return true; | |
| 421 | + | return false; | |
| 422 | + | } | |
| 423 | + | ||
| 424 | + | /* | |
| 425 | + | * Does @m receive propagation from the victim's parent as well? If so, then | |
| 426 | + | * the mount at the victim's mountpoint inside of @m is a umount candidate as | |
| 427 | + | * well. So it's the next candidate in the chain. Otherwise the chain ends at | |
| 428 | + | * @m. | |
| 429 | + | */ | |
| 430 | + | static struct mount *next_candidate(struct mount *m, struct mount *victim) | |
| 431 | + | { | |
| 432 | + | if (!receives_from(m, victim->mnt_parent)) | |
| 433 | + | return NULL; | |
| 434 | + | return __lookup_mnt(&m->mnt, victim->mnt_mountpoint); | |
| 435 | + | } | |
| 436 | + | ||
| 437 | + | /* | |
| 438 | + | * Would propagate_umount() pull out a mount of the chain of candidates that | |
| 439 | + | * starts at @c, and does that mount have references beyond its own? | |
| 440 | + | * | |
| 441 | + | * This mirrors how trim_one(), trim_ancestors() and handle_locked() handle a | |
| 442 | + | * synchronous umount: | |
| 443 | + | * | |
| 444 | + | * - single victim | |
| 445 | + | * - without children | |
| 446 | + | * - with MNT_LOCKED already cleared on every candidate by propagate_mount_unlock() | |
| 447 | + | * | |
| 448 | + | * A copy of the victim gets unmounted when each of its children is | |
| 449 | + | * the next candidate in the chain or its overmount, unless the next | |
| 450 | + | * unmount candidate is not its overmount and some unmount candidate further | |
| 451 | + | * down has a child outside the chain. Keep this in sync with | |
| 452 | + | * Documentation/filesystems/propagate_umount.txt. | |
| 453 | + | */ | |
| 454 | + | static bool chain_busy(struct mount *c, struct mount *victim) | |
| 455 | + | { | |
| 456 | + | struct mount *m, *n, *next, *deepest = NULL; | |
| 457 | + | bool above; | |
| 458 | + | ||
| 459 | + | /* the deepest candidate with a child outside the chain */ | |
| 460 | + | for (m = c; m; m = next) { | |
| 461 | + | next = next_candidate(m, victim); | |
| 462 | + | list_for_each_entry(n, &m->mnt_mounts, mnt_child) { | |
| 463 | + | if (n != next && n != victim) { | |
| 464 | + | deepest = m; | |
| 465 | + | break; | |
| 466 | + | } | |
| 467 | + | } | |
| 468 | + | } | |
| 469 | + | ||
| 470 | + | above = deepest != NULL; /* @deepest is at or below @m */ | |
| 471 | + | for (m = c; m; m = next) { | |
| 472 | + | bool goes = true; | |
| 473 | + | ||
| 474 | + | next = next_candidate(m, victim); | |
| 475 | + | list_for_each_entry(n, &m->mnt_mounts, mnt_child) { | |
| 476 | + | if (n != next && n != m->overmount && n != victim) { | |
| 477 | + | goes = false; | |
| 478 | + | break; | |
| 479 | + | } | |
| 480 | + | } | |
| 481 | + | if (goes && next && next != m->overmount && above && m != deepest) | |
| 482 | + | goes = false; | |
| 483 | + | if (m == deepest) | |
| 484 | + | above = false; | |
| 485 | + | if (goes && do_refcount_check(m, 1)) | |
| 486 | + | return true; | |
| 487 | + | } | |
| 488 | + | return false; | |
| 489 | + | } | |
| 490 | + | ||
| 413 | 491 | /* | |
| 414 | 492 | * check if the mount 'mnt' can be unmounted successfully. | |
| 415 | 493 | * @mnt: the mount to be checked for unmount | |
| 416 | 494 | * NOTE: unmounting 'mnt' would naturally propagate to all | |
| 417 | 495 | * other mounts its parent propagates to. | |
| 418 | - | * Check if any of these mounts that **do not have submounts** | |
| 419 | - | * have more references than 'refcnt'. If so return busy. | |
| 496 | + | * Check if any of the mounts that propagate_umount() would pull out | |
| 497 | + | * along with it have more references than their own. If so return busy. | |
| 420 | 498 | * | |
| 421 | 499 | * vfsmount lock must be held for write | |
| 422 | 500 | */ | |
| 423 | 501 | int propagate_mount_busy(struct mount *mnt, int refcnt) | |
| 424 | 502 | { | |
| 425 | 503 | struct mount *parent = mnt->mnt_parent; | |
| 504 | + | struct dentry *mp = mnt->mnt_mountpoint; | |
| 505 | + | struct mount *m; | |
| 426 | 506 | ||
| 427 | 507 | /* | |
| 428 | 508 | * quickly check if the current mount can be unmounted. | |
| @@ -435,24 +515,16 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) | |||
| 435 | 515 | if (mnt == parent) | |
| 436 | 516 | return 0; | |
| 437 | 517 | ||
| 438 | - | for (struct mount *m = propagation_next(parent, parent); m; | |
| 439 | - | m = propagation_next(m, parent)) { | |
| 440 | - | struct list_head *head; | |
| 441 | - | struct mount *child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint); | |
| 518 | + | /* the candidates are the mounts at @mp below the receivers */ | |
| 519 | + | for (m = propagation_next(parent, parent); m; | |
| 520 | + | m = propagation_next(m, parent)) { | |
| 521 | + | struct mount *c = __lookup_mnt(&m->mnt, mp); | |
| 442 | 522 | ||
| 443 | - | if (!child) | |
| 523 | + | /* each chain once, from its top: skip receivers that are candidates */ | |
| 524 | + | if (!c || (mnt_has_parent(m) && m->mnt_mountpoint == mp && | |
| 525 | + | receives_from(m->mnt_parent, parent))) | |
| 444 | 526 | continue; | |
| 445 | - | ||
| 446 | - | head = &child->mnt_mounts; | |
| 447 | - | if (!list_empty(head)) { | |
| 448 | - | /* | |
| 449 | - | * a mount that covers child completely wouldn't prevent | |
| 450 | - | * it being pulled out; any other would. | |
| 451 | - | */ | |
| 452 | - | if (!list_is_singular(head) || !child->overmount) | |
| 453 | - | continue; | |
| 454 | - | } | |
| 455 | - | if (do_refcount_check(child, 1)) | |
| 527 | + | if (chain_busy(c, mnt)) | |
| 456 | 528 | return 1; | |
| 457 | 529 | } | |
| 458 | 530 | return 0; | |
| @@ -625,8 +697,8 @@ static void handle_locked(struct mount *m, struct list_head *to_umount) | |||
| 625 | 697 | * the same parent and mountpoint; that will be remedied as soon as we | |
| 626 | 698 | * return from propagate_umount() - its caller (umount_tree()) will detach | |
| 627 | 699 | * the stack from the parent it (and now @m) is attached to. umount_tree() | |
| 628 | - | * might choose to keep unmounted pieces stuck to each other, but it always | |
| 629 | - | * detaches them from the mounts that remain in the tree. | |
| 700 | + | * detaches every unmounted mount from its parent, whether that parent | |
| 701 | + | * remains in the tree or not. | |
| 630 | 702 | */ | |
| 631 | 703 | static void reparent(struct mount *m) | |
| 632 | 704 | { | |
modified fs/readdir.c
| @@ -87,6 +87,8 @@ EXPORT_SYMBOL(wrap_directory_iterator); | |||
| 87 | 87 | int iterate_dir(struct file *file, struct dir_context *ctx) | |
| 88 | 88 | { | |
| 89 | 89 | struct inode *inode = file_inode(file); | |
| 90 | + | /* never an entry, never removed: nothing for the lock to keep still */ | |
| 91 | + | bool locked = !(file->f_op->fop_flags & FOP_IMMUTABLE); | |
| 90 | 92 | int res = -ENOTDIR; | |
| 91 | 93 | ||
| 92 | 94 | if (!file->f_op->iterate_shared) | |
| @@ -100,9 +102,11 @@ int iterate_dir(struct file *file, struct dir_context *ctx) | |||
| 100 | 102 | if (res) | |
| 101 | 103 | goto out; | |
| 102 | 104 | ||
| 103 | - | res = down_read_killable(&inode->i_rwsem); | |
| 104 | - | if (res) | |
| 105 | - | goto out; | |
| 105 | + | if (locked) { | |
| 106 | + | res = down_read_killable(&inode->i_rwsem); | |
| 107 | + | if (res) | |
| 108 | + | goto out; | |
| 109 | + | } | |
| 106 | 110 | ||
| 107 | 111 | res = -ENOENT; | |
| 108 | 112 | if (!IS_DEADDIR(inode)) { | |
| @@ -112,7 +116,8 @@ int iterate_dir(struct file *file, struct dir_context *ctx) | |||
| 112 | 116 | fsnotify_access(file); | |
| 113 | 117 | file_accessed(file); | |
| 114 | 118 | } | |
| 115 | - | inode_unlock_shared(inode); | |
| 119 | + | if (locked) | |
| 120 | + | inode_unlock_shared(inode); | |
| 116 | 121 | out: | |
| 117 | 122 | return res; | |
| 118 | 123 | } | |
modified fs/smb/client/cifsfs.c
| @@ -1412,6 +1412,7 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, | |||
| 1412 | 1412 | * server could even support copy of range where source = target | |
| 1413 | 1413 | */ | |
| 1414 | 1414 | lock_two_nondirectories(target_inode, src_inode); | |
| 1415 | + | filemap_invalidate_lock(target_inode->i_mapping); | |
| 1415 | 1416 | ||
| 1416 | 1417 | if (len == 0) { | |
| 1417 | 1418 | loff_t src_size = i_size_read(src_inode); | |
| @@ -1467,9 +1468,15 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, | |||
| 1467 | 1468 | i_size = target_inode->i_size; | |
| 1468 | 1469 | spin_unlock(&target_inode->i_lock); | |
| 1469 | 1470 | ||
| 1470 | - | /* Discard all the folios that overlap the destination region. */ | |
| 1471 | + | /* | |
| 1472 | + | * Discard all the folios that overlap the destination region. Start at | |
| 1473 | + | * the old EOF when extending so the folio straddling it, which may hold | |
| 1474 | + | * data written past EOF through an mmap, is dropped too. | |
| 1475 | + | */ | |
| 1471 | 1476 | cifs_dbg(FYI, "about to discard pages %llx-%llx\n", fstart, fend); | |
| 1472 | - | truncate_inode_pages_range(&target_inode->i_data, fstart, fend); | |
| 1477 | + | truncate_inode_pages_range(&target_inode->i_data, | |
| 1478 | + | min(fstart, i_size), fend); | |
| 1479 | + | netfs_wait_for_outstanding_io(target_inode); | |
| 1473 | 1480 | ||
| 1474 | 1481 | fscache_invalidate(cifs_inode_cookie(target_inode), NULL, i_size, 0); | |
| 1475 | 1482 | ||
| @@ -1508,6 +1515,7 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, | |||
| 1508 | 1515 | if (rc) | |
| 1509 | 1516 | CIFS_I(target_inode)->time = 0; | |
| 1510 | 1517 | unlock: | |
| 1518 | + | filemap_invalidate_unlock(target_inode->i_mapping); | |
| 1511 | 1519 | /* although unlocking in the reverse order from locking is not | |
| 1512 | 1520 | strictly necessary here it is a little cleaner to be consistent */ | |
| 1513 | 1521 | unlock_two_nondirectories(src_inode, target_inode); | |
| @@ -1531,6 +1539,9 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, | |||
| 1531 | 1539 | struct cifs_tcon *target_tcon; | |
| 1532 | 1540 | ssize_t rc; | |
| 1533 | 1541 | ||
| 1542 | + | if (len == 0) | |
| 1543 | + | return 0; | |
| 1544 | + | ||
| 1534 | 1545 | cifs_dbg(FYI, "copychunk range\n"); | |
| 1535 | 1546 | ||
| 1536 | 1547 | if (!src_file->private_data || !dst_file->private_data) { | |
| @@ -1560,6 +1571,7 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, | |||
| 1560 | 1571 | * server could even support copy of range where source = target | |
| 1561 | 1572 | */ | |
| 1562 | 1573 | lock_two_nondirectories(target_inode, src_inode); | |
| 1574 | + | filemap_invalidate_lock(target_inode->i_mapping); | |
| 1563 | 1575 | ||
| 1564 | 1576 | cifs_dbg(FYI, "about to flush pages\n"); | |
| 1565 | 1577 | ||
| @@ -1581,10 +1593,28 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, | |||
| 1581 | 1593 | /* Flush and invalidate all the folios in the destination region. If | |
| 1582 | 1594 | * the copy was successful, then some of the flush is extra overhead, | |
| 1583 | 1595 | * but we need to allow for the copy failing in some way (eg. ENOSPC). | |
| 1596 | + | * | |
| 1597 | + | * Start at the old EOF when extending so the folio straddling it, which | |
| 1598 | + | * may hold data written past EOF through an mmap, is dropped too. | |
| 1584 | 1599 | */ | |
| 1585 | - | rc = filemap_invalidate_inode(target_inode, true, destoff, destoff + len - 1); | |
| 1586 | - | if (rc) | |
| 1587 | - | goto unlock; | |
| 1600 | + | if (target_inode->i_mapping->nrpages) { | |
| 1601 | + | loff_t fstart = min(destoff, i_size_read(target_inode)); | |
| 1602 | + | loff_t fend = destoff + len - 1; | |
| 1603 | + | ||
| 1604 | + | unmap_mapping_pages(target_inode->i_mapping, | |
| 1605 | + | fstart >> PAGE_SHIFT, | |
| 1606 | + | (fend >> PAGE_SHIFT) - | |
| 1607 | + | (fstart >> PAGE_SHIFT) + 1, | |
| 1608 | + | false); | |
| 1609 | + | rc = filemap_write_and_wait_range(target_inode->i_mapping, | |
| 1610 | + | fstart, fend); | |
| 1611 | + | if (rc) | |
| 1612 | + | goto unlock; | |
| 1613 | + | invalidate_inode_pages2_range(target_inode->i_mapping, | |
| 1614 | + | fstart >> PAGE_SHIFT, | |
| 1615 | + | fend >> PAGE_SHIFT); | |
| 1616 | + | } | |
| 1617 | + | netfs_wait_for_outstanding_io(target_inode); | |
| 1588 | 1618 | ||
| 1589 | 1619 | fscache_invalidate(cifs_inode_cookie(target_inode), NULL, | |
| 1590 | 1620 | i_size_read(target_inode), 0); | |
| @@ -1616,6 +1646,7 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, | |||
| 1616 | 1646 | CIFS_I(target_inode)->time = 0; | |
| 1617 | 1647 | ||
| 1618 | 1648 | unlock: | |
| 1649 | + | filemap_invalidate_unlock(target_inode->i_mapping); | |
| 1619 | 1650 | /* although unlocking in the reverse order from locking is not | |
| 1620 | 1651 | * strictly necessary here it is a little cleaner to be consistent | |
| 1621 | 1652 | */ | |
modified fs/smb/client/cifsfs.h
| @@ -146,8 +146,9 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, struct file *src_file, | |||
| 146 | 146 | unsigned int flags); | |
| 147 | 147 | ||
| 148 | 148 | long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg); | |
| 149 | - | void cifs_setsize(struct inode *inode, loff_t offset); | |
| 150 | - | void cifs_resize_file_locked(struct inode *inode, loff_t offset); | |
| 149 | + | void cifs_setsize(struct inode *inode, loff_t old_size, loff_t offset); | |
| 150 | + | void cifs_resize_file_locked(struct inode *inode, loff_t old_size, | |
| 151 | + | loff_t offset); | |
| 151 | 152 | ||
| 152 | 153 | struct fs_context; | |
| 153 | 154 | struct smb3_fs_context; | |
modified fs/smb/client/cifsglob.h
| @@ -1450,11 +1450,11 @@ struct cifsFileInfo { | |||
| 1450 | 1450 | struct dentry *dentry; | |
| 1451 | 1451 | struct tcon_link *tlink; | |
| 1452 | 1452 | unsigned int f_flags; | |
| 1453 | - | bool invalidHandle:1; /* file closed via session abend */ | |
| 1454 | - | bool swapfile:1; | |
| 1455 | - | bool oplock_break_cancelled:1; | |
| 1456 | - | bool status_file_deleted:1; /* file has been deleted */ | |
| 1457 | - | bool offload:1; /* offload final part of _put to a wq */ | |
| 1453 | + | bool invalidHandle; /* file closed via session abend */ | |
| 1454 | + | bool swapfile; | |
| 1455 | + | bool oplock_break_cancelled; | |
| 1456 | + | bool status_file_deleted; /* file has been deleted */ | |
| 1457 | + | bool offload; /* offload final part of _put to a wq */ | |
| 1458 | 1458 | __u16 oplock_epoch; /* epoch from the lease break */ | |
| 1459 | 1459 | __u32 oplock_level; /* oplock/lease level from the lease break */ | |
| 1460 | 1460 | int count; | |
modified fs/smb/client/file.c
| @@ -1012,11 +1012,14 @@ static int cifs_do_truncate(const unsigned int xid, struct dentry *dentry) | |||
| 1012 | 1012 | } | |
| 1013 | 1013 | mapping_set_error(inode->i_mapping, rc); | |
| 1014 | 1014 | ||
| 1015 | + | netfs_wait_for_outstanding_io(inode); | |
| 1016 | + | ||
| 1015 | 1017 | cfile = find_writable_file(cinode, FIND_FSUID_ONLY); | |
| 1016 | 1018 | rc = cifs_file_flush(xid, inode, cfile); | |
| 1017 | 1019 | if (!rc) { | |
| 1018 | 1020 | if (cfile) { | |
| 1019 | 1021 | struct netfs_inode *ictx = netfs_inode(inode); | |
| 1022 | + | loff_t old_size = i_size_read(inode); | |
| 1020 | 1023 | ||
| 1021 | 1024 | tcon = tlink_tcon(cfile->tlink); | |
| 1022 | 1025 | server = tcon->ses->server; | |
| @@ -1025,7 +1028,7 @@ static int cifs_do_truncate(const unsigned int xid, struct dentry *dentry) | |||
| 1025 | 1028 | cfile, 0, false); | |
| 1026 | 1029 | if (!rc) { | |
| 1027 | 1030 | netfs_resize_file(&cinode->netfs, 0, true); | |
| 1028 | - | cifs_setsize(inode, 0); | |
| 1031 | + | cifs_setsize(inode, old_size, 0); | |
| 1029 | 1032 | cifs_invalidate_cache(inode, 0); | |
| 1030 | 1033 | } | |
| 1031 | 1034 | netfs_wb_end(ictx); | |
modified fs/smb/client/inode.c
| @@ -88,6 +88,8 @@ static void cifs_set_ops(struct inode *inode) | |||
| 88 | 88 | else | |
| 89 | 89 | inode->i_data.a_ops = &cifs_addr_ops; | |
| 90 | 90 | mapping_set_large_folios(inode->i_mapping); | |
| 91 | + | if (tcon->ses->server->sign) | |
| 92 | + | mapping_set_stable_writes(inode->i_mapping); | |
| 91 | 93 | break; | |
| 92 | 94 | case S_IFDIR: | |
| 93 | 95 | if (IS_AUTOMOUNT(inode)) { | |
| @@ -3053,15 +3055,12 @@ int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start, | |||
| 3053 | 3055 | return -EOPNOTSUPP; | |
| 3054 | 3056 | } | |
| 3055 | 3057 | ||
| 3056 | - | void cifs_setsize(struct inode *inode, loff_t offset) | |
| 3058 | + | void cifs_setsize(struct inode *inode, loff_t old_size, loff_t offset) | |
| 3057 | 3059 | { | |
| 3058 | - | loff_t old_size; | |
| 3059 | 3060 | u64 blocks = CIFS_INO_BLOCKS(offset); | |
| 3060 | 3061 | ||
| 3061 | 3062 | spin_lock(&inode->i_lock); | |
| 3062 | - | old_size = i_size_read(inode); | |
| 3063 | 3063 | i_size_write(inode, offset); | |
| 3064 | - | ||
| 3065 | 3064 | /* | |
| 3066 | 3065 | * Extending EOF does not allocate the intervening range. Only clamp | |
| 3067 | 3066 | * i_blocks on shrink; allocation growth comes from writes or from the | |
| @@ -3071,20 +3070,28 @@ void cifs_setsize(struct inode *inode, loff_t offset) | |||
| 3071 | 3070 | inode->i_blocks = blocks; | |
| 3072 | 3071 | spin_unlock(&inode->i_lock); | |
| 3073 | 3072 | inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); | |
| 3073 | + | ||
| 3074 | + | /* | |
| 3075 | + | * Zero the tail of the folio straddling the old EOF so data dirtied | |
| 3076 | + | * past EOF through an mmap isn't exposed. truncate_pagecache() then | |
| 3077 | + | * drops any pagecache beyond the new EOF, as in truncate_setsize(). | |
| 3078 | + | */ | |
| 3074 | 3079 | if (offset > old_size) | |
| 3075 | - | pagecache_isize_extended(inode, old_size, offset); | |
| 3080 | + | netfs_clear_stale_post_isize(inode, old_size, offset); | |
| 3081 | + | ||
| 3076 | 3082 | truncate_pagecache(inode, offset); | |
| 3077 | 3083 | netfs_wait_for_outstanding_io(inode); | |
| 3078 | 3084 | } | |
| 3079 | 3085 | ||
| 3080 | - | void cifs_resize_file_locked(struct inode *inode, loff_t offset) | |
| 3086 | + | void cifs_resize_file_locked(struct inode *inode, loff_t old_size, | |
| 3087 | + | loff_t offset) | |
| 3081 | 3088 | { | |
| 3082 | 3089 | struct fscache_cookie *cookie = cifs_inode_cookie(inode); | |
| 3083 | 3090 | ||
| 3084 | 3091 | lockdep_assert_held_write(&inode->i_rwsem); | |
| 3085 | 3092 | ||
| 3086 | 3093 | netfs_resize_file(netfs_inode(inode), offset, true); | |
| 3087 | - | cifs_setsize(inode, offset); | |
| 3094 | + | cifs_setsize(inode, old_size, offset); | |
| 3088 | 3095 | ||
| 3089 | 3096 | if (!cookie) | |
| 3090 | 3097 | return; | |
| @@ -3101,6 +3108,7 @@ int cifs_file_set_size(const unsigned int xid, struct dentry *dentry, | |||
| 3101 | 3108 | struct inode *inode = d_inode(dentry); | |
| 3102 | 3109 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); | |
| 3103 | 3110 | struct cifsInodeInfo *cifsInode = CIFS_I(inode); | |
| 3111 | + | loff_t old_size = i_size_read(inode); | |
| 3104 | 3112 | struct tcon_link *tlink = NULL; | |
| 3105 | 3113 | struct cifs_tcon *tcon = NULL; | |
| 3106 | 3114 | struct TCP_Server_Info *server; | |
| @@ -3159,7 +3167,7 @@ int cifs_file_set_size(const unsigned int xid, struct dentry *dentry, | |||
| 3159 | 3167 | ||
| 3160 | 3168 | set_size_out: | |
| 3161 | 3169 | if (rc == 0) | |
| 3162 | - | cifs_resize_file_locked(inode, size); | |
| 3170 | + | cifs_resize_file_locked(inode, old_size, size); | |
| 3163 | 3171 | ||
| 3164 | 3172 | return rc; | |
| 3165 | 3173 | } | |
modified fs/smb/client/smb2ops.c
| @@ -2287,6 +2287,7 @@ smb2_duplicate_extents(const unsigned int xid, | |||
| 2287 | 2287 | struct duplicate_extents_to_file dup_ext_buf; | |
| 2288 | 2288 | struct timespec64 ts; | |
| 2289 | 2289 | struct cifs_tcon *tcon = tlink_tcon(trgtfile->tlink); | |
| 2290 | + | loff_t old_size; | |
| 2290 | 2291 | u64 asize; | |
| 2291 | 2292 | ||
| 2292 | 2293 | /* server fileays advertise duplicate extent support with this flag */ | |
| @@ -2305,11 +2306,12 @@ smb2_duplicate_extents(const unsigned int xid, | |||
| 2305 | 2306 | trgtfile->fid.volatile_fid, tcon->tid, | |
| 2306 | 2307 | tcon->ses->Suid, src_off, dest_off, len); | |
| 2307 | 2308 | inode = d_inode(trgtfile->dentry); | |
| 2308 | - | if (i_size_read(inode) < dest_off + len) { | |
| 2309 | + | old_size = i_size_read(inode); | |
| 2310 | + | if (old_size < dest_off + len) { | |
| 2309 | 2311 | rc = smb2_set_file_size(xid, tcon, trgtfile, dest_off + len, false); | |
| 2310 | 2312 | if (rc) | |
| 2311 | 2313 | goto duplicate_extents_out; | |
| 2312 | - | cifs_resize_file_locked(inode, dest_off + len); | |
| 2314 | + | cifs_resize_file_locked(inode, old_size, dest_off + len); | |
| 2313 | 2315 | } | |
| 2314 | 2316 | rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid, | |
| 2315 | 2317 | trgtfile->fid.volatile_fid, | |
| @@ -3520,6 +3522,21 @@ static long smb3_zero_data(struct file *file, struct cifs_tcon *tcon, | |||
| 3520 | 3522 | 0, NULL, NULL); | |
| 3521 | 3523 | } | |
| 3522 | 3524 | ||
| 3525 | + | static long query_server_eof(const unsigned int xid, | |
| 3526 | + | struct cifs_tcon *tcon, | |
| 3527 | + | struct cifsFileInfo *cfile, | |
| 3528 | + | unsigned long long *eof) | |
| 3529 | + | { | |
| 3530 | + | struct smb2_file_all_info file_inf = {}; | |
| 3531 | + | long rc; | |
| 3532 | + | ||
| 3533 | + | rc = SMB2_query_info(xid, tcon, cfile->fid.persistent_fid, | |
| 3534 | + | cfile->fid.volatile_fid, &file_inf); | |
| 3535 | + | if (!rc) | |
| 3536 | + | *eof = le64_to_cpu(file_inf.EndOfFile); | |
| 3537 | + | return rc; | |
| 3538 | + | } | |
| 3539 | + | ||
| 3523 | 3540 | static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, | |
| 3524 | 3541 | unsigned long long offset, unsigned long long len, | |
| 3525 | 3542 | bool keep_size) | |
| @@ -3547,25 +3564,32 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, | |||
| 3547 | 3564 | filemap_invalidate_lock(inode->i_mapping); | |
| 3548 | 3565 | ||
| 3549 | 3566 | netfs_read_sizes(inode, &i_size, &remote_i_size, &zero_point); | |
| 3550 | - | if (offset + len >= remote_i_size && offset < i_size) { | |
| 3551 | - | unsigned long long top = umin(offset + len, i_size); | |
| 3552 | 3567 | ||
| 3553 | - | rc = filemap_write_and_wait_range(inode->i_mapping, offset, top - 1); | |
| 3554 | - | if (rc < 0) | |
| 3555 | - | goto zero_range_exit; | |
| 3556 | - | } | |
| 3568 | + | rc = filemap_write_and_wait_range(inode->i_mapping, offset, | |
| 3569 | + | offset + len - 1); | |
| 3570 | + | if (rc < 0) | |
| 3571 | + | goto zero_range_exit; | |
| 3557 | 3572 | ||
| 3558 | 3573 | /* | |
| 3559 | 3574 | * We zero the range through ioctl, so we need remove the page caches | |
| 3560 | 3575 | * first, otherwise the data may be inconsistent with the server. | |
| 3576 | + | * | |
| 3577 | + | * Start at the old EOF when extending so the folio straddling it, which | |
| 3578 | + | * may hold data written past EOF through an mmap, is dropped too. | |
| 3561 | 3579 | */ | |
| 3562 | - | truncate_pagecache_range(inode, offset, offset + len - 1); | |
| 3580 | + | truncate_pagecache_range(inode, min(offset, i_size), offset + len - 1); | |
| 3563 | 3581 | netfs_wait_for_outstanding_io(inode); | |
| 3564 | 3582 | ||
| 3565 | - | /* if file not oplocked can't be sure whether asking to extend size */ | |
| 3566 | - | rc = -EOPNOTSUPP; | |
| 3567 | - | if (keep_size == false && !CIFS_CACHE_READ(cifsi)) | |
| 3568 | - | goto zero_range_exit; | |
| 3583 | + | if (!keep_size && !CIFS_CACHE_READ(cifsi)) { | |
| 3584 | + | rc = query_server_eof(xid, tcon, cfile, &remote_i_size); | |
| 3585 | + | if (rc) | |
| 3586 | + | goto zero_range_exit; | |
| 3587 | + | i_size = max(i_size, remote_i_size); | |
| 3588 | + | if (i_size < new_size) { | |
| 3589 | + | rc = -EOPNOTSUPP; | |
| 3590 | + | goto zero_range_exit; | |
| 3591 | + | } | |
| 3592 | + | } | |
| 3569 | 3593 | ||
| 3570 | 3594 | fscache_invalidate(cifs_inode_cookie(inode), NULL, | |
| 3571 | 3595 | i_size_read(inode), 0); | |
| @@ -3577,7 +3601,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, | |||
| 3577 | 3601 | /* | |
| 3578 | 3602 | * do we also need to change the size of the file? | |
| 3579 | 3603 | */ | |
| 3580 | - | if (keep_size == false && (unsigned long long)i_size_read(inode) < new_size) { | |
| 3604 | + | if (!keep_size && umax(i_size, i_size_read(inode)) < new_size) { | |
| 3581 | 3605 | rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, | |
| 3582 | 3606 | cfile->fid.volatile_fid, cfile->pid, new_size); | |
| 3583 | 3607 | if (rc >= 0) { | |
| @@ -3723,7 +3747,8 @@ static int smb3_simple_fallocate_write_range(unsigned int xid, | |||
| 3723 | 3747 | static int smb3_simple_fallocate_range(unsigned int xid, | |
| 3724 | 3748 | struct cifs_tcon *tcon, | |
| 3725 | 3749 | struct cifsFileInfo *cfile, | |
| 3726 | - | loff_t off, loff_t len) | |
| 3750 | + | loff_t off, loff_t len, | |
| 3751 | + | loff_t old_eof) | |
| 3727 | 3752 | { | |
| 3728 | 3753 | struct file_allocated_range_buffer in_data, *out_data = NULL, *tmp_data; | |
| 3729 | 3754 | struct inode *inode = d_inode(cfile->dentry); | |
| @@ -3739,12 +3764,30 @@ static int smb3_simple_fallocate_range(unsigned int xid, | |||
| 3739 | 3764 | goto out; | |
| 3740 | 3765 | } | |
| 3741 | 3766 | ||
| 3742 | - | if (off >= i_size_read(inode)) { | |
| 3767 | + | if (off >= old_eof) { | |
| 3743 | 3768 | rc = smb3_simple_fallocate_write_range(xid, tcon, cfile, | |
| 3744 | 3769 | off, len, buf); | |
| 3745 | 3770 | goto out; | |
| 3746 | 3771 | } | |
| 3747 | 3772 | ||
| 3773 | + | filemap_invalidate_lock(inode->i_mapping); | |
| 3774 | + | ||
| 3775 | + | /* | |
| 3776 | + | * Flush and commit the data to the server, otherwise | |
| 3777 | + | * FSCTL_QUERY_ALLOCATED_RANGES might report recently written data as | |
| 3778 | + | * unallocated holes on Windows Servers, and the loop below would | |
| 3779 | + | * then zero-fill them and corrupt the file. | |
| 3780 | + | */ | |
| 3781 | + | rc = filemap_write_and_wait_range(inode->i_mapping, off, | |
| 3782 | + | off + len - 1); | |
| 3783 | + | if (rc) | |
| 3784 | + | goto out_unlock; | |
| 3785 | + | netfs_wait_for_outstanding_io(inode); | |
| 3786 | + | rc = SMB2_flush(xid, tcon, cfile->fid.persistent_fid, | |
| 3787 | + | cfile->fid.volatile_fid); | |
| 3788 | + | if (rc) | |
| 3789 | + | goto out_unlock; | |
| 3790 | + | ||
| 3748 | 3791 | in_data.file_offset = cpu_to_le64(off); | |
| 3749 | 3792 | in_data.length = cpu_to_le64(len); | |
| 3750 | 3793 | rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, | |
| @@ -3754,7 +3797,7 @@ static int smb3_simple_fallocate_range(unsigned int xid, | |||
| 3754 | 3797 | 1024 * sizeof(struct file_allocated_range_buffer), | |
| 3755 | 3798 | (char **)&out_data, &out_data_len); | |
| 3756 | 3799 | if (rc) | |
| 3757 | - | goto out; | |
| 3800 | + | goto out_unlock; | |
| 3758 | 3801 | ||
| 3759 | 3802 | tmp_data = out_data; | |
| 3760 | 3803 | while (len) { | |
| @@ -3764,12 +3807,12 @@ static int smb3_simple_fallocate_range(unsigned int xid, | |||
| 3764 | 3807 | if (out_data_len == 0) { | |
| 3765 | 3808 | rc = smb3_simple_fallocate_write_range(xid, tcon, | |
| 3766 | 3809 | cfile, off, len, buf); | |
| 3767 | - | goto out; | |
| 3810 | + | goto out_unlock; | |
| 3768 | 3811 | } | |
| 3769 | 3812 | ||
| 3770 | 3813 | if (out_data_len < sizeof(struct file_allocated_range_buffer)) { | |
| 3771 | 3814 | rc = -EINVAL; | |
| 3772 | - | goto out; | |
| 3815 | + | goto out_unlock; | |
| 3773 | 3816 | } | |
| 3774 | 3817 | ||
| 3775 | 3818 | range_start = le64_to_cpu(tmp_data->file_offset); | |
| @@ -3777,7 +3820,7 @@ static int smb3_simple_fallocate_range(unsigned int xid, | |||
| 3777 | 3820 | if (check_add_overflow(range_start, range_len, &range_end) || | |
| 3778 | 3821 | range_end > S64_MAX) { | |
| 3779 | 3822 | rc = -EINVAL; | |
| 3780 | - | goto out; | |
| 3823 | + | goto out_unlock; | |
| 3781 | 3824 | } | |
| 3782 | 3825 | ||
| 3783 | 3826 | if (off < range_start) { | |
| @@ -3792,11 +3835,11 @@ static int smb3_simple_fallocate_range(unsigned int xid, | |||
| 3792 | 3835 | rc = smb3_simple_fallocate_write_range(xid, tcon, | |
| 3793 | 3836 | cfile, off, l, buf); | |
| 3794 | 3837 | if (rc) | |
| 3795 | - | goto out; | |
| 3838 | + | goto out_unlock; | |
| 3796 | 3839 | off = off + l; | |
| 3797 | 3840 | len = len - l; | |
| 3798 | 3841 | if (len == 0) | |
| 3799 | - | goto out; | |
| 3842 | + | goto out_unlock; | |
| 3800 | 3843 | } | |
| 3801 | 3844 | /* | |
| 3802 | 3845 | * We are at a section of allocated data, just skip forward | |
| @@ -3815,6 +3858,8 @@ static int smb3_simple_fallocate_range(unsigned int xid, | |||
| 3815 | 3858 | out_data_len -= sizeof(struct file_allocated_range_buffer); | |
| 3816 | 3859 | } | |
| 3817 | 3860 | ||
| 3861 | + | out_unlock: | |
| 3862 | + | filemap_invalidate_unlock(inode->i_mapping); | |
| 3818 | 3863 | out: | |
| 3819 | 3864 | kfree(out_data); | |
| 3820 | 3865 | kvfree(buf); | |
| @@ -3830,7 +3875,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, | |||
| 3830 | 3875 | struct cifsFileInfo *cfile = file->private_data; | |
| 3831 | 3876 | long rc = -EOPNOTSUPP; | |
| 3832 | 3877 | unsigned int xid; | |
| 3833 | - | loff_t old_eof, new_eof; | |
| 3878 | + | loff_t old_eof, new_eof, local_eof; | |
| 3834 | 3879 | struct smb2_file_all_info file_inf; | |
| 3835 | 3880 | u64 asize; | |
| 3836 | 3881 | int qrc; | |
| @@ -3839,18 +3884,37 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, | |||
| 3839 | 3884 | ||
| 3840 | 3885 | inode = d_inode(cfile->dentry); | |
| 3841 | 3886 | cifsi = CIFS_I(inode); | |
| 3842 | - | old_eof = i_size_read(inode); | |
| 3887 | + | old_eof = local_eof = i_size_read(inode); | |
| 3843 | 3888 | ||
| 3844 | 3889 | trace_smb3_falloc_enter(xid, cfile->fid.persistent_fid, tcon->tid, | |
| 3845 | 3890 | tcon->ses->Suid, off, len); | |
| 3846 | - | /* if file not oplocked can't be sure whether asking to extend size */ | |
| 3847 | - | if (!CIFS_CACHE_READ(cifsi)) | |
| 3848 | - | if (!keep_size) { | |
| 3891 | + | ||
| 3892 | + | if (!keep_size && !CIFS_CACHE_READ(cifsi)) { | |
| 3893 | + | unsigned long long server_eof; | |
| 3894 | + | ||
| 3895 | + | rc = filemap_write_and_wait(inode->i_mapping); | |
| 3896 | + | if (rc) { | |
| 3849 | 3897 | trace_smb3_falloc_err(xid, cfile->fid.persistent_fid, | |
| 3850 | 3898 | tcon->tid, tcon->ses->Suid, off, len, rc); | |
| 3851 | 3899 | free_xid(xid); | |
| 3852 | 3900 | return rc; | |
| 3853 | 3901 | } | |
| 3902 | + | netfs_wait_for_outstanding_io(inode); | |
| 3903 | + | ||
| 3904 | + | rc = query_server_eof(xid, tcon, cfile, &server_eof); | |
| 3905 | + | if (rc) { | |
| 3906 | + | trace_smb3_falloc_err(xid, cfile->fid.persistent_fid, | |
| 3907 | + | tcon->tid, tcon->ses->Suid, off, len, rc); | |
| 3908 | + | free_xid(xid); | |
| 3909 | + | return rc; | |
| 3910 | + | } | |
| 3911 | + | /* | |
| 3912 | + | * Only use the larger EOF to decide whether we're extending. | |
| 3913 | + | * The pagecache zeroing below must still key off the local | |
| 3914 | + | * i_size, so keep local_eof for that. | |
| 3915 | + | */ | |
| 3916 | + | old_eof = max_t(loff_t, old_eof, server_eof); | |
| 3917 | + | } | |
| 3854 | 3918 | ||
| 3855 | 3919 | /* | |
| 3856 | 3920 | * Extending the file | |
| @@ -3874,7 +3938,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, | |||
| 3874 | 3938 | } | |
| 3875 | 3939 | ||
| 3876 | 3940 | rc = smb3_simple_fallocate_range(xid, tcon, cfile, | |
| 3877 | - | off, len); | |
| 3941 | + | off, len, old_eof); | |
| 3878 | 3942 | if (rc) { | |
| 3879 | 3943 | spin_lock(&inode->i_lock); | |
| 3880 | 3944 | cifsi->time = 0; | |
| @@ -3883,7 +3947,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, | |||
| 3883 | 3947 | } | |
| 3884 | 3948 | ||
| 3885 | 3949 | new_eof = off + len; | |
| 3886 | - | cifs_resize_file_locked(inode, new_eof); | |
| 3950 | + | cifs_resize_file_locked(inode, local_eof, new_eof); | |
| 3887 | 3951 | ||
| 3888 | 3952 | qrc = SMB2_query_info(xid, tcon, | |
| 3889 | 3953 | cfile->fid.persistent_fid, | |
| @@ -3931,7 +3995,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, | |||
| 3931 | 3995 | if (rc) | |
| 3932 | 3996 | goto out; | |
| 3933 | 3997 | ||
| 3934 | - | cifs_resize_file_locked(inode, new_eof); | |
| 3998 | + | cifs_resize_file_locked(inode, local_eof, new_eof); | |
| 3935 | 3999 | ||
| 3936 | 4000 | qrc = SMB2_query_info(xid, tcon, | |
| 3937 | 4001 | cfile->fid.persistent_fid, | |
| @@ -3976,7 +4040,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, | |||
| 3976 | 4040 | } | |
| 3977 | 4041 | } | |
| 3978 | 4042 | ||
| 3979 | - | if ((keep_size == true) || (i_size_read(inode) >= off + len)) { | |
| 4043 | + | if (keep_size || old_eof >= off + len) { | |
| 3980 | 4044 | /* | |
| 3981 | 4045 | * At this point, we are trying to fallocate an internal | |
| 3982 | 4046 | * regions of a sparse file. Since smb2 does not have a | |
| @@ -3993,7 +4057,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, | |||
| 3993 | 4057 | */ | |
| 3994 | 4058 | if (len <= 1024 * 1024) { | |
| 3995 | 4059 | rc = smb3_simple_fallocate_range(xid, tcon, cfile, | |
| 3996 | - | off, len); | |
| 4060 | + | off, len, old_eof); | |
| 3997 | 4061 | goto out; | |
| 3998 | 4062 | } | |
| 3999 | 4063 | ||
| @@ -4005,7 +4069,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, | |||
| 4005 | 4069 | * ie potentially making a few extra pages at the beginning | |
| 4006 | 4070 | * or end of the file non-sparse via set_sparse is harmless. | |
| 4007 | 4071 | */ | |
| 4008 | - | if ((off > 8192) || (off + len + 8192 < i_size_read(inode))) { | |
| 4072 | + | if (off > 8192 || off + len + 8192 < old_eof) { | |
| 4009 | 4073 | rc = -EOPNOTSUPP; | |
| 4010 | 4074 | goto out; | |
| 4011 | 4075 | } | |
modified fs/smb/client/smb2pdu.c
| @@ -4796,14 +4796,20 @@ do_retry: | |||
| 4796 | 4796 | rdata->got_bytes); | |
| 4797 | 4797 | ||
| 4798 | 4798 | if (rdata->result == -ENODATA) { | |
| 4799 | - | __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); | |
| 4800 | 4799 | rdata->result = 0; | |
| 4800 | + | if (rdata->subreq.start + rdata->subreq.transferred >= i_size_read(inode)) | |
| 4801 | + | __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); | |
| 4802 | + | else | |
| 4803 | + | __set_bit(NETFS_SREQ_CLEAR_TAIL, &rdata->subreq.flags); | |
| 4801 | 4804 | } else { | |
| 4802 | 4805 | size_t trans = rdata->subreq.transferred + rdata->got_bytes; | |
| 4803 | 4806 | if (trans < rdata->subreq.len && | |
| 4804 | 4807 | rdata->subreq.start + trans >= netfs_read_remote_i_size(inode)) { | |
| 4805 | - | __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); | |
| 4806 | 4808 | rdata->result = 0; | |
| 4809 | + | if (rdata->subreq.start + trans >= i_size_read(inode)) | |
| 4810 | + | __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); | |
| 4811 | + | else | |
| 4812 | + | __set_bit(NETFS_SREQ_CLEAR_TAIL, &rdata->subreq.flags); | |
| 4807 | 4813 | } | |
| 4808 | 4814 | if (rdata->got_bytes) | |
| 4809 | 4815 | __set_bit(NETFS_SREQ_MADE_PROGRESS, &rdata->subreq.flags); | |
modified fs/verity/fsverity_private.h
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | #define pr_fmt(fmt) "fs-verity: " fmt | |
| 12 | 12 | ||
| 13 | 13 | #include <linux/fsverity.h> | |
| 14 | + | #include <linux/rcupdate.h> | |
| 14 | 15 | #include <linux/rhashtable.h> | |
| 15 | 16 | ||
| 16 | 17 | /* | |
| @@ -76,7 +77,19 @@ struct merkle_tree_params { | |||
| 76 | 77 | struct fsverity_info { | |
| 77 | 78 | struct rhash_head rhash_head; | |
| 78 | 79 | struct merkle_tree_params tree_params; | |
| 79 | - | u8 root_hash[FS_VERITY_MAX_DIGEST_SIZE]; | |
| 80 | + | union { | |
| 81 | + | u8 root_hash[FS_VERITY_MAX_DIGEST_SIZE]; | |
| 82 | + | ||
| 83 | + | /* | |
| 84 | + | * Used for final freeing of the struct, in which case root_hash | |
| 85 | + | * is no longer needed. Specifically, the only fields needed | |
| 86 | + | * besides the rcu_head are those needed by fsverity_free_info() | |
| 87 | + | * itself, and those that can be accessed by fsverity_get_info() | |
| 88 | + | * (rhash_head and inode) during the RCU-protected rhashtable | |
| 89 | + | * chain search trying to find another inode's fsverity_info. | |
| 90 | + | */ | |
| 91 | + | struct rcu_head rcu_head; | |
| 92 | + | }; | |
| 80 | 93 | u8 file_digest[FS_VERITY_MAX_DIGEST_SIZE]; | |
| 81 | 94 | struct inode *inode; | |
| 82 | 95 | unsigned long *hash_block_verified; | |
modified fs/verity/open.c
| @@ -399,11 +399,22 @@ void fsverity_free_info(struct fsverity_info *vi) | |||
| 399 | 399 | kmem_cache_free(fsverity_info_cachep, vi); | |
| 400 | 400 | } | |
| 401 | 401 | ||
| 402 | + | static void fsverity_free_info_rcu(struct rcu_head *head) | |
| 403 | + | { | |
| 404 | + | fsverity_free_info(container_of(head, struct fsverity_info, rcu_head)); | |
| 405 | + | } | |
| 406 | + | ||
| 402 | 407 | void fsverity_remove_info(struct fsverity_info *vi) | |
| 403 | 408 | { | |
| 404 | 409 | rhashtable_remove_fast(&fsverity_info_hash, &vi->rhash_head, | |
| 405 | 410 | fsverity_info_hash_params); | |
| 406 | - | fsverity_free_info(vi); | |
| 411 | + | /* | |
| 412 | + | * The freeing must be RCU-delayed because __fsverity_get_info() for a | |
| 413 | + | * *different* inode's fsverity_info in the same rhashtable hash chain | |
| 414 | + | * can still be accessing *this* fsverity_info's rhash_head and inode | |
| 415 | + | * fields as part of the RCU-protected hash chain search. | |
| 416 | + | */ | |
| 417 | + | call_rcu(&vi->rcu_head, fsverity_free_info_rcu); | |
| 407 | 418 | } | |
| 408 | 419 | ||
| 409 | 420 | void fsverity_cleanup_inode(struct inode *inode) | |
modified fs/xfs/libxfs/xfs_exchmaps.c
| @@ -49,7 +49,7 @@ struct xfs_exchmaps_adjacent { | |||
| 49 | 49 | .right2 = { .br_startblock = HOLESTARTBLOCK }, \ | |
| 50 | 50 | } | |
| 51 | 51 | ||
| 52 | - | /* Information to reset reflink flag / CoW fork state after an exchange. */ | |
| 52 | + | /* Information to reset CoW fork state after an exchange. */ | |
| 53 | 53 | ||
| 54 | 54 | /* | |
| 55 | 55 | * If the reflink flag is set on either inode, make sure it has an incore CoW | |
| @@ -127,9 +127,7 @@ xmi_has_more_exchange_work(const struct xfs_exchmaps_intent *xmi) | |||
| 127 | 127 | static inline bool | |
| 128 | 128 | xmi_has_postop_work(const struct xfs_exchmaps_intent *xmi) | |
| 129 | 129 | { | |
| 130 | - | return xmi->xmi_flags & (XFS_EXCHMAPS_CLEAR_INO1_REFLINK | | |
| 131 | - | XFS_EXCHMAPS_CLEAR_INO2_REFLINK | | |
| 132 | - | __XFS_EXCHMAPS_INO2_SHORTFORM); | |
| 130 | + | return xmi->xmi_flags & __XFS_EXCHMAPS_INO2_SHORTFORM; | |
| 133 | 131 | } | |
| 134 | 132 | ||
| 135 | 133 | /* Check all mappings to make sure we can actually exchange them. */ | |
| @@ -525,18 +523,6 @@ free: | |||
| 525 | 523 | return error; | |
| 526 | 524 | } | |
| 527 | 525 | ||
| 528 | - | /* Clear the reflink flag after an exchange. */ | |
| 529 | - | static inline void | |
| 530 | - | xfs_exchmaps_clear_reflink( | |
| 531 | - | struct xfs_trans *tp, | |
| 532 | - | struct xfs_inode *ip) | |
| 533 | - | { | |
| 534 | - | trace_xfs_reflink_unset_inode_flag(ip); | |
| 535 | - | ||
| 536 | - | ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; | |
| 537 | - | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | |
| 538 | - | } | |
| 539 | - | ||
| 540 | 526 | /* Finish whatever work might come after an exchange operation. */ | |
| 541 | 527 | static int | |
| 542 | 528 | xfs_exchmaps_do_postop_work( | |
| @@ -557,16 +543,6 @@ xfs_exchmaps_do_postop_work( | |||
| 557 | 543 | return error; | |
| 558 | 544 | } | |
| 559 | 545 | ||
| 560 | - | if (xmi->xmi_flags & XFS_EXCHMAPS_CLEAR_INO1_REFLINK) { | |
| 561 | - | xfs_exchmaps_clear_reflink(tp, xmi->xmi_ip1); | |
| 562 | - | xmi->xmi_flags &= ~XFS_EXCHMAPS_CLEAR_INO1_REFLINK; | |
| 563 | - | } | |
| 564 | - | ||
| 565 | - | if (xmi->xmi_flags & XFS_EXCHMAPS_CLEAR_INO2_REFLINK) { | |
| 566 | - | xfs_exchmaps_clear_reflink(tp, xmi->xmi_ip2); | |
| 567 | - | xmi->xmi_flags &= ~XFS_EXCHMAPS_CLEAR_INO2_REFLINK; | |
| 568 | - | } | |
| 569 | - | ||
| 570 | 546 | return 0; | |
| 571 | 547 | } | |
| 572 | 548 | ||
| @@ -948,46 +924,14 @@ xfs_exchmaps_intent_destroy_cache(void) | |||
| 948 | 924 | } | |
| 949 | 925 | ||
| 950 | 926 | /* | |
| 951 | - | * Decide if we will exchange the reflink flags between the two files after the | |
| 952 | - | * exchange. The only time we want to do this is if we're exchanging all | |
| 953 | - | * mappings under EOF and the inode reflink flags have different states. | |
| 927 | + | * Allocate and initialize a new incore intent item from a request. | |
| 954 | 928 | */ | |
| 955 | - | static inline bool | |
| 956 | - | xmi_can_exchange_reflink_flags( | |
| 957 | - | const struct xfs_exchmaps_req *req, | |
| 958 | - | unsigned int reflink_state) | |
| 959 | - | { | |
| 960 | - | struct xfs_mount *mp = req->ip1->i_mount; | |
| 961 | - | ||
| 962 | - | /* | |
| 963 | - | * The INO1_WRITTEN optimization can skip exchanging hole and | |
| 964 | - | * unwritten mappings, which means we cannot guarantee that all | |
| 965 | - | * shared extents actually moved to the other file. Clearing the | |
| 966 | - | * reflink flag of an inode that still holds shared extents breaks | |
| 967 | - | * the CoW write path, so refuse to exchange the flags in that case. | |
| 968 | - | */ | |
| 969 | - | if (req->flags & XFS_EXCHMAPS_INO1_WRITTEN) | |
| 970 | - | return false; | |
| 971 | - | ||
| 972 | - | if (hweight32(reflink_state) != 1) | |
| 973 | - | return false; | |
| 974 | - | if (req->startoff1 != 0 || req->startoff2 != 0) | |
| 975 | - | return false; | |
| 976 | - | if (req->blockcount != XFS_B_TO_FSB(mp, req->ip1->i_disk_size)) | |
| 977 | - | return false; | |
| 978 | - | if (req->blockcount != XFS_B_TO_FSB(mp, req->ip2->i_disk_size)) | |
| 979 | - | return false; | |
| 980 | - | return true; | |
| 981 | - | } | |
| 982 | - | ||
| 983 | - | ||
| 984 | - | /* Allocate and initialize a new incore intent item from a request. */ | |
| 985 | 929 | struct xfs_exchmaps_intent * | |
| 986 | 930 | xfs_exchmaps_init_intent( | |
| 987 | 931 | const struct xfs_exchmaps_req *req) | |
| 988 | 932 | { | |
| 989 | 933 | struct xfs_exchmaps_intent *xmi; | |
| 990 | - | unsigned int rs = 0; | |
| 934 | + | struct xfs_mount *mp = req->ip1->i_mount; | |
| 991 | 935 | ||
| 992 | 936 | xmi = kmem_cache_zalloc(xfs_exchmaps_intent_cache, | |
| 993 | 937 | GFP_NOFS | __GFP_NOFAIL); | |
| @@ -1005,27 +949,18 @@ xfs_exchmaps_init_intent( | |||
| 1005 | 949 | return xmi; | |
| 1006 | 950 | } | |
| 1007 | 951 | ||
| 1008 | - | if (req->flags & XFS_EXCHMAPS_SET_SIZES) { | |
| 1009 | - | xmi->xmi_flags |= XFS_EXCHMAPS_SET_SIZES; | |
| 1010 | - | xmi->xmi_isize1 = req->ip2->i_disk_size; | |
| 1011 | - | xmi->xmi_isize2 = req->ip1->i_disk_size; | |
| 1012 | - | } | |
| 1013 | - | ||
| 1014 | - | /* Record the state of each inode's reflink flag before the op. */ | |
| 1015 | - | if (xfs_is_reflink_inode(req->ip1)) | |
| 1016 | - | rs |= 1; | |
| 1017 | - | if (xfs_is_reflink_inode(req->ip2)) | |
| 1018 | - | rs |= 2; | |
| 1019 | - | ||
| 1020 | 952 | /* | |
| 1021 | - | * Figure out if we're clearing the reflink flags (which effectively | |
| 1022 | - | * exchanges them) after the operation. | |
| 953 | + | * If the caller wanted, set each file's size to that file's exchange | |
| 954 | + | * offset + length exchanged from the other file because the ranges in | |
| 955 | + | * each file might be different lengths. | |
| 1023 | 956 | */ | |
| 1024 | - | if (xmi_can_exchange_reflink_flags(req, rs)) { | |
| 1025 | - | if (rs & 1) | |
| 1026 | - | xmi->xmi_flags |= XFS_EXCHMAPS_CLEAR_INO1_REFLINK; | |
| 1027 | - | if (rs & 2) | |
| 1028 | - | xmi->xmi_flags |= XFS_EXCHMAPS_CLEAR_INO2_REFLINK; | |
| 957 | + | if (req->flags & XFS_EXCHMAPS_SET_SIZES) { | |
| 958 | + | loff_t off1 = XFS_FSB_TO_B(mp, xmi->xmi_startoff1); | |
| 959 | + | loff_t off2 = XFS_FSB_TO_B(mp, xmi->xmi_startoff2); | |
| 960 | + | ||
| 961 | + | xmi->xmi_flags |= XFS_EXCHMAPS_SET_SIZES; | |
| 962 | + | xmi->xmi_isize1 = off1 + (req->ip2->i_disk_size - off2); | |
| 963 | + | xmi->xmi_isize2 = off2 + (req->ip1->i_disk_size - off1); | |
| 1029 | 964 | } | |
| 1030 | 965 | ||
| 1031 | 966 | if (S_ISDIR(VFS_I(xmi->xmi_ip2)->i_mode) || | |
modified fs/xfs/libxfs/xfs_log_format.h
| @@ -927,10 +927,8 @@ struct xfs_xmi_log_format { | |||
| 927 | 927 | */ | |
| 928 | 928 | #define XFS_EXCHMAPS_INO1_WRITTEN (1ULL << 2) | |
| 929 | 929 | ||
| 930 | - | /* Clear the reflink flag from inode1 after the operation. */ | |
| 930 | + | /* No longer set, but older intents may carry them; keep them valid. */ | |
| 931 | 931 | #define XFS_EXCHMAPS_CLEAR_INO1_REFLINK (1ULL << 3) | |
| 932 | - | ||
| 933 | - | /* Clear the reflink flag from inode2 after the operation. */ | |
| 934 | 932 | #define XFS_EXCHMAPS_CLEAR_INO2_REFLINK (1ULL << 4) | |
| 935 | 933 | ||
| 936 | 934 | #define XFS_EXCHMAPS_LOGGED_FLAGS (XFS_EXCHMAPS_ATTR_FORK | \ | |
modified fs/xfs/xfs_bmap_util.c
| @@ -1544,7 +1544,6 @@ xfs_swap_extents( | |||
| 1544 | 1544 | struct xfs_bstat *sbp = &sxp->sx_stat; | |
| 1545 | 1545 | int src_log_flags, target_log_flags; | |
| 1546 | 1546 | int error = 0; | |
| 1547 | - | uint64_t f; | |
| 1548 | 1547 | int resblks = 0; | |
| 1549 | 1548 | unsigned int flags = 0; | |
| 1550 | 1549 | struct timespec64 ctime, mtime; | |
| @@ -1700,14 +1699,12 @@ xfs_swap_extents( | |||
| 1700 | 1699 | if (error) | |
| 1701 | 1700 | goto out_trans_cancel; | |
| 1702 | 1701 | ||
| 1703 | - | /* Do we have to swap reflink flags? */ | |
| 1704 | - | if ((ip->i_diflags2 & XFS_DIFLAG2_REFLINK) ^ | |
| 1705 | - | (tip->i_diflags2 & XFS_DIFLAG2_REFLINK)) { | |
| 1706 | - | f = ip->i_diflags2 & XFS_DIFLAG2_REFLINK; | |
| 1707 | - | ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; | |
| 1708 | - | ip->i_diflags2 |= tip->i_diflags2 & XFS_DIFLAG2_REFLINK; | |
| 1709 | - | tip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; | |
| 1710 | - | tip->i_diflags2 |= f & XFS_DIFLAG2_REFLINK; | |
| 1702 | + | /* Either inode may now own shared blocks; flag both, with CoW forks. */ | |
| 1703 | + | if ((ip->i_diflags2 | tip->i_diflags2) & XFS_DIFLAG2_REFLINK) { | |
| 1704 | + | ip->i_diflags2 |= XFS_DIFLAG2_REFLINK; | |
| 1705 | + | tip->i_diflags2 |= XFS_DIFLAG2_REFLINK; | |
| 1706 | + | xfs_ifork_init_cow(ip); | |
| 1707 | + | xfs_ifork_init_cow(tip); | |
| 1711 | 1708 | } | |
| 1712 | 1709 | ||
| 1713 | 1710 | /* Swap the cow forks. */ | |
modified fs/xfs/xfs_exchrange.c
| @@ -290,17 +290,20 @@ retry: | |||
| 290 | 290 | goto out_unlock; | |
| 291 | 291 | ||
| 292 | 292 | /* | |
| 293 | - | * If the caller wanted us to exchange the contents of two complete | |
| 294 | - | * files of unequal length, exchange the incore sizes now. This should | |
| 295 | - | * be safe because we flushed both files' page caches, exchanged all | |
| 296 | - | * the mappings, and updated the ondisk sizes. | |
| 293 | + | * If the caller wanted, set each file's size to that file's exchange | |
| 294 | + | * offset + length exchanged from the other file because the ranges in | |
| 295 | + | * each file might be different lengths. This should be safe because | |
| 296 | + | * we flushed both files' page caches, exchanged all the mappings, and | |
| 297 | + | * updated the ondisk sizes. | |
| 297 | 298 | */ | |
| 298 | 299 | if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) { | |
| 299 | - | loff_t temp; | |
| 300 | + | loff_t old_ip1_size = i_size_read(VFS_I(ip1)); | |
| 301 | + | loff_t old_ip2_size = i_size_read(VFS_I(ip2)); | |
| 300 | 302 | ||
| 301 | - | temp = i_size_read(VFS_I(ip2)); | |
| 302 | - | i_size_write(VFS_I(ip2), i_size_read(VFS_I(ip1))); | |
| 303 | - | i_size_write(VFS_I(ip1), temp); | |
| 303 | + | i_size_write(VFS_I(ip2), fxr->file2_offset + | |
| 304 | + | (old_ip1_size - fxr->file1_offset)); | |
| 305 | + | i_size_write(VFS_I(ip1), fxr->file1_offset + | |
| 306 | + | (old_ip2_size - fxr->file2_offset)); | |
| 304 | 307 | } | |
| 305 | 308 | ||
| 306 | 309 | out_unlock: | |
| @@ -445,6 +448,30 @@ xfs_exchange_range_checks( | |||
| 445 | 448 | return blen == fxr->length ? 0 : -EINVAL; | |
| 446 | 449 | } | |
| 447 | 450 | ||
| 451 | + | /* Flush all relevant dirty pagecache near the range to be exchanged. */ | |
| 452 | + | static inline int | |
| 453 | + | xfs_exchange_range_flush( | |
| 454 | + | struct xfs_inode *ip, | |
| 455 | + | const struct xfs_exchrange *fxr, | |
| 456 | + | loff_t offset) | |
| 457 | + | { | |
| 458 | + | /* | |
| 459 | + | * If TO_EOF is set, the ondisk file size update logic depends on the | |
| 460 | + | * ondisk file size matching the incore file size. Flush everything. | |
| 461 | + | */ | |
| 462 | + | if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) | |
| 463 | + | return filemap_write_and_wait(VFS_I(ip)->i_mapping); | |
| 464 | + | ||
| 465 | + | /* | |
| 466 | + | * Because we're updating the ondisk mappings, flush all dirty data | |
| 467 | + | * between the ondisk size and the exchange offset to reduce the chance | |
| 468 | + | * of zeroed file contents in that gap after a crash. | |
| 469 | + | */ | |
| 470 | + | return filemap_write_and_wait_range(VFS_I(ip)->i_mapping, | |
| 471 | + | min(offset, ip->i_disk_size), | |
| 472 | + | offset + fxr->length - 1); | |
| 473 | + | } | |
| 474 | + | ||
| 448 | 475 | /* | |
| 449 | 476 | * Check that the two inodes are eligible for range exchanges, the ranges make | |
| 450 | 477 | * sense, and then flush all dirty data. Caller must ensure that the inodes | |
| @@ -470,15 +497,11 @@ xfs_exchange_range_prep( | |||
| 470 | 497 | if (!same_inode) | |
| 471 | 498 | inode_dio_wait(inode2); | |
| 472 | 499 | ||
| 473 | - | error = filemap_write_and_wait_range(inode1->i_mapping, | |
| 474 | - | fxr->file1_offset, | |
| 475 | - | fxr->file1_offset + fxr->length - 1); | |
| 500 | + | error = xfs_exchange_range_flush(XFS_I(inode1), fxr, fxr->file1_offset); | |
| 476 | 501 | if (error) | |
| 477 | 502 | return error; | |
| 478 | 503 | ||
| 479 | - | error = filemap_write_and_wait_range(inode2->i_mapping, | |
| 480 | - | fxr->file2_offset, | |
| 481 | - | fxr->file2_offset + fxr->length - 1); | |
| 504 | + | error = xfs_exchange_range_flush(XFS_I(inode2), fxr, fxr->file2_offset); | |
| 482 | 505 | if (error) | |
| 483 | 506 | return error; | |
| 484 | 507 | ||
modified include/linux/bpf.h
| @@ -1258,11 +1258,15 @@ struct btf_func_model { | |||
| 1258 | 1258 | #define BPF_TRAMP_F_INDIRECT BIT(8) | |
| 1259 | 1259 | ||
| 1260 | 1260 | /* Each call __bpf_prog_enter + call bpf_func + call __bpf_prog_exit is ~50 | |
| 1261 | - | * bytes on x86. | |
| 1261 | + | * bytes on x86. The trampoline image has to fit in PAGE_SIZE. | |
| 1262 | 1262 | */ | |
| 1263 | 1263 | enum { | |
| 1264 | - | #if defined(__s390x__) | |
| 1264 | + | #if defined(__s390x__) || defined(__powerpc64__) | |
| 1265 | 1265 | BPF_MAX_TRAMP_LINKS = 27, | |
| 1266 | + | #elif defined(__x86_64__) | |
| 1267 | + | BPF_MAX_TRAMP_LINKS = 36, | |
| 1268 | + | #elif defined(__aarch64__) | |
| 1269 | + | BPF_MAX_TRAMP_LINKS = 37, | |
| 1266 | 1270 | #else | |
| 1267 | 1271 | BPF_MAX_TRAMP_LINKS = 38, | |
| 1268 | 1272 | #endif | |
| @@ -1315,6 +1319,7 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i | |||
| 1315 | 1319 | void *arch_alloc_bpf_trampoline(unsigned int size); | |
| 1316 | 1320 | void arch_free_bpf_trampoline(void *image, unsigned int size); | |
| 1317 | 1321 | int __must_check arch_protect_bpf_trampoline(void *image, unsigned int size); | |
| 1322 | + | int arch_bpf_trampoline_skip(void *nop, void *target); | |
| 1318 | 1323 | int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |
| 1319 | 1324 | struct bpf_tramp_nodes *tnodes, void *func_addr); | |
| 1320 | 1325 | ||
| @@ -1363,19 +1368,48 @@ enum bpf_tramp_prog_type { | |||
| 1363 | 1368 | BPF_TRAMP_FSESSION, | |
| 1364 | 1369 | }; | |
| 1365 | 1370 | ||
| 1371 | + | /* | |
| 1372 | + | * Each prog call in a trampoline image is preceded by a nop. When the prog is | |
| 1373 | + | * detached, the nop is patched to a jump to target, right after the call, so | |
| 1374 | + | * that tasks still running in the image skip the prog. | |
| 1375 | + | */ | |
| 1376 | + | struct bpf_tramp_skip { | |
| 1377 | + | struct bpf_prog *prog; | |
| 1378 | + | void *nop; | |
| 1379 | + | void *target; | |
| 1380 | + | }; | |
| 1381 | + | ||
| 1366 | 1382 | struct bpf_tramp_image { | |
| 1367 | 1383 | void *image; | |
| 1368 | 1384 | int size; | |
| 1369 | 1385 | struct bpf_ksym ksym; | |
| 1370 | 1386 | struct percpu_ref pcref; | |
| 1371 | - | void *ip_after_call; | |
| 1372 | - | void *ip_epilogue; | |
| 1387 | + | bool call_orig; | |
| 1388 | + | /* entry in tr->images, the image holds a reference on tr */ | |
| 1389 | + | struct bpf_trampoline *tr; | |
| 1390 | + | struct list_head list; | |
| 1391 | + | int nr_skips; | |
| 1392 | + | struct bpf_tramp_skip *skips; | |
| 1373 | 1393 | union { | |
| 1374 | 1394 | struct rcu_head rcu; | |
| 1375 | 1395 | struct work_struct work; | |
| 1376 | 1396 | }; | |
| 1377 | 1397 | }; | |
| 1378 | 1398 | ||
| 1399 | + | static inline void bpf_tramp_image_add_skip(struct bpf_tramp_image *im, struct bpf_prog *prog, | |
| 1400 | + | void *nop, void *target) | |
| 1401 | + | { | |
| 1402 | + | struct bpf_tramp_skip *skip; | |
| 1403 | + | ||
| 1404 | + | /* struct_ops trampolines and arch_bpf_trampoline_size() have no image */ | |
| 1405 | + | if (!im || !im->skips) | |
| 1406 | + | return; | |
| 1407 | + | skip = &im->skips[im->nr_skips++]; | |
| 1408 | + | skip->prog = prog; | |
| 1409 | + | skip->nop = nop; | |
| 1410 | + | skip->target = target; | |
| 1411 | + | } | |
| 1412 | + | ||
| 1379 | 1413 | struct bpf_trampoline { | |
| 1380 | 1414 | /* hlist for trampoline_key_table */ | |
| 1381 | 1415 | struct hlist_node hlist_key; | |
| @@ -1402,6 +1436,8 @@ struct bpf_trampoline { | |||
| 1402 | 1436 | int progs_cnt[BPF_TRAMP_MAX]; | |
| 1403 | 1437 | /* Executable image of trampoline */ | |
| 1404 | 1438 | struct bpf_tramp_image *cur_image; | |
| 1439 | + | /* Images not freed yet, cur_image and older ones still in use */ | |
| 1440 | + | struct list_head images; | |
| 1405 | 1441 | /* Used as temporary old image storage for multi_attach */ | |
| 1406 | 1442 | struct { | |
| 1407 | 1443 | struct bpf_tramp_image *old_image; | |
| @@ -1770,6 +1806,7 @@ struct bpf_prog_aux { | |||
| 1770 | 1806 | bool offload_requested; /* Program is bound and offloaded to the netdev. */ | |
| 1771 | 1807 | bool attach_btf_trace; /* true if attaching to BTF-enabled raw tp */ | |
| 1772 | 1808 | bool attach_tracing_prog; /* true if tracing another tracing program */ | |
| 1809 | + | bool tramp_linked; /* true if it was ever linked to a trampoline */ | |
| 1773 | 1810 | bool func_proto_unreliable; | |
| 1774 | 1811 | bool tail_call_reachable; | |
| 1775 | 1812 | bool xdp_has_frags; | |
modified include/linux/can/core.h
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | #include <linux/can.h> | |
| 18 | 18 | #include <linux/skbuff.h> | |
| 19 | 19 | #include <linux/netdevice.h> | |
| 20 | + | #include <net/can.h> | |
| 20 | 21 | ||
| 21 | 22 | #define DNAME(dev) ((dev) ? (dev)->name : "any") | |
| 22 | 23 | ||
| @@ -58,7 +59,7 @@ extern void can_rx_unregister(struct net *net, struct net_device *dev, | |||
| 58 | 59 | void *data); | |
| 59 | 60 | ||
| 60 | 61 | extern int can_send(struct sk_buff *skb, int loop); | |
| 61 | - | void can_set_skb_uid(struct sk_buff *skb); | |
| 62 | + | void can_set_skb_uid(struct can_skb_ext *csx); | |
| 62 | 63 | void can_sock_destruct(struct sock *sk); | |
| 63 | 64 | ||
| 64 | 65 | #endif /* !_CAN_CORE_H */ | |
modified include/linux/can/skb.h
| @@ -43,8 +43,10 @@ static inline struct can_skb_ext *can_skb_ext_add(struct sk_buff *skb) | |||
| 43 | 43 | struct can_skb_ext *csx = skb_ext_add(skb, SKB_EXT_CAN); | |
| 44 | 44 | ||
| 45 | 45 | /* skb_ext_add() returns uninitialized space */ | |
| 46 | - | if (csx) | |
| 46 | + | if (csx) { | |
| 47 | 47 | csx->can_gw_hops = 0; | |
| 48 | + | csx->can_skb_uid = 0; | |
| 49 | + | } | |
| 48 | 50 | ||
| 49 | 51 | return csx; | |
| 50 | 52 | } | |
modified include/linux/console.h
| @@ -615,6 +615,15 @@ extern bool nbcon_allow_unsafe_takeover(void); | |||
| 615 | 615 | extern bool nbcon_kdb_try_acquire(struct console *con, | |
| 616 | 616 | struct nbcon_write_context *wctxt); | |
| 617 | 617 | extern void nbcon_kdb_release(struct nbcon_write_context *wctxt); | |
| 618 | + | extern bool nbcon_write_context_is_braille(struct nbcon_write_context *wctxt); | |
| 619 | + | extern bool nbcon_braille_try_acquire(struct console *con, | |
| 620 | + | struct nbcon_write_context *wctxt); | |
| 621 | + | extern void nbcon_braille_release(struct nbcon_write_context *wctxt); | |
| 622 | + | ||
| 623 | + | static inline bool nbcon_is_braille(struct console *con) | |
| 624 | + | { | |
| 625 | + | return con && (con->flags & CON_BRL); | |
| 626 | + | } | |
| 618 | 627 | ||
| 619 | 628 | /* | |
| 620 | 629 | * Check if the given console is currently capable and allowed to print | |
| @@ -678,8 +687,14 @@ static inline void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt) { } | |||
| 678 | 687 | static inline bool nbcon_kdb_try_acquire(struct console *con, | |
| 679 | 688 | struct nbcon_write_context *wctxt) { return false; } | |
| 680 | 689 | static inline void nbcon_kdb_release(struct nbcon_write_context *wctxt) { } | |
| 690 | + | static inline | |
| 691 | + | bool nbcon_write_context_is_braille(struct nbcon_write_context *wctxt) { return false; } | |
| 681 | 692 | static inline bool console_is_usable(struct console *con, short flags, | |
| 682 | 693 | bool use_atomic) { return false; } | |
| 694 | + | static inline bool nbcon_braille_try_acquire(struct console *con, | |
| 695 | + | struct nbcon_write_context *wctxt) { return false; } | |
| 696 | + | static inline void nbcon_braille_release(struct nbcon_write_context *wctxt) { } | |
| 697 | + | static inline bool nbcon_is_braille(struct console *con) { return false; } | |
| 683 | 698 | #endif | |
| 684 | 699 | ||
| 685 | 700 | extern int console_set_on_cmdline; | |
modified include/linux/cpufreq.h
| @@ -420,6 +420,9 @@ struct cpufreq_driver { | |||
| 420 | 420 | /* Will be called after the driver is fully initialized */ | |
| 421 | 421 | void (*ready)(struct cpufreq_policy *policy); | |
| 422 | 422 | ||
| 423 | + | /* Return the capacity reference frequency for policy. */ | |
| 424 | + | unsigned int (*scale_freq_ref)(struct cpufreq_policy *policy); | |
| 425 | + | ||
| 423 | 426 | struct freq_attr **attr; | |
| 424 | 427 | ||
| 425 | 428 | /* platform specific boost support code */ | |
modified include/linux/fs.h
| @@ -1978,6 +1978,8 @@ struct file_operations { | |||
| 1978 | 1978 | #define FOP_ASYNC_LOCK ((__force fop_flags_t)(1 << 6)) | |
| 1979 | 1979 | /* File system supports uncached read/write buffered IO */ | |
| 1980 | 1980 | #define FOP_DONTCACHE ((__force fop_flags_t)(1 << 7)) | |
| 1981 | + | /* Never changes and is never removed, readdir of a directory takes no lock */ | |
| 1982 | + | #define FOP_IMMUTABLE ((__force fop_flags_t)(1 << 8)) | |
| 1981 | 1983 | ||
| 1982 | 1984 | /* Wrap a directory iterator that needs exclusive inode access */ | |
| 1983 | 1985 | int wrap_directory_iterator(struct file *, struct dir_context *, | |
| @@ -2296,6 +2298,7 @@ struct file_system_type { | |||
| 2296 | 2298 | #define FS_POWER_FREEZE 256 /* Always freeze on suspend/hibernate */ | |
| 2297 | 2299 | #define FS_USERNS_MOUNT_RESTRICTED 512 /* Restrict mount in userns if not already visible */ | |
| 2298 | 2300 | #define FS_USERNS_DELEGATABLE 1024 /* Can be mounted inside userns from outside */ | |
| 2301 | + | #define FS_DISALLOW_NOTIFY 2048 /* No fsnotify marks on its objects */ | |
| 2299 | 2302 | #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ | |
| 2300 | 2303 | int (*init_fs_context)(struct fs_context *); | |
| 2301 | 2304 | const struct fs_parameter_spec *parameters; | |
modified include/linux/hrtimer_rearm.h
| @@ -45,7 +45,7 @@ hrtimer_rearm_deferred_user_irq(unsigned long *tif_work, const unsigned long tif | |||
| 45 | 45 | clear_thread_flag(TIF_HRTIMER_REARM); | |
| 46 | 46 | __hrtimer_rearm_deferred(); | |
| 47 | 47 | /* Don't go into the loop if HRTIMER_REARM was the only flag */ | |
| 48 | - | *tif_work &= ~TIF_HRTIMER_REARM; | |
| 48 | + | *tif_work &= ~_TIF_HRTIMER_REARM; | |
| 49 | 49 | return !*tif_work; | |
| 50 | 50 | } | |
| 51 | 51 | return false; | |
modified include/linux/io_uring_types.h
| @@ -322,6 +322,8 @@ enum { | |||
| 322 | 322 | IO_RING_F_DRAIN_DISABLED = BIT(10), | |
| 323 | 323 | IO_RING_F_COMPAT = BIT(11), | |
| 324 | 324 | IO_RING_F_IOWQ_LIMITS_SET = BIT(12), | |
| 325 | + | /* restrictions were inherited from the task that created the ring */ | |
| 326 | + | IO_RING_F_RESTRICT_INHERITED = BIT(13), | |
| 325 | 327 | }; | |
| 326 | 328 | ||
| 327 | 329 | struct iou_ctx {}; | |
modified include/linux/kvm_host.h
| @@ -791,7 +791,6 @@ struct kvm { | |||
| 791 | 791 | /* The current active memslot set for each address space */ | |
| 792 | 792 | struct kvm_memslots __rcu *memslots[KVM_MAX_NR_ADDRESS_SPACES]; | |
| 793 | 793 | struct xarray vcpu_array; | |
| 794 | - | DECLARE_BITMAP(vcpu_ids, KVM_MAX_VCPU_IDS); | |
| 795 | 794 | /* | |
| 796 | 795 | * Protected by slots_lock, but can be read outside if an | |
| 797 | 796 | * incorrect answer is acceptable. | |
modified include/linux/mount.h
| @@ -52,7 +52,7 @@ enum mount_flags { | |||
| 52 | 52 | MNT_ATIME_MASK = MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME, | |
| 53 | 53 | ||
| 54 | 54 | MNT_INTERNAL_FLAGS = MNT_INTERNAL | MNT_DOOMED | | |
| 55 | - | MNT_SYNC_UMOUNT | MNT_LOCKED | |
| 55 | + | MNT_SYNC_UMOUNT | MNT_LOCKED | MNT_UMOUNT | |
| 56 | 56 | }; | |
| 57 | 57 | ||
| 58 | 58 | struct vfsmount { | |
modified include/linux/mtd/nand.h
| @@ -305,6 +305,8 @@ int nand_ecc_prepare_io_req(struct nand_device *nand, | |||
| 305 | 305 | struct nand_page_io_req *req); | |
| 306 | 306 | int nand_ecc_finish_io_req(struct nand_device *nand, | |
| 307 | 307 | struct nand_page_io_req *req); | |
| 308 | + | bool nand_ecc_is_pipelined(const struct nand_device *nand); | |
| 309 | + | ||
| 308 | 310 | bool nand_ecc_is_strong_enough(struct nand_device *nand); | |
| 309 | 311 | ||
| 310 | 312 | #if IS_REACHABLE(CONFIG_MTD_NAND_CORE) | |
modified include/linux/netdevice.h
| @@ -887,6 +887,7 @@ enum net_device_path_type { | |||
| 887 | 887 | DEV_PATH_DSA, | |
| 888 | 888 | DEV_PATH_MTK_WDMA, | |
| 889 | 889 | DEV_PATH_TUN, | |
| 890 | + | DEV_PATH_IEEE80211, | |
| 890 | 891 | }; | |
| 891 | 892 | ||
| 892 | 893 | struct net_device_path { | |
| @@ -953,6 +954,8 @@ struct net_device_path_ctx { | |||
| 953 | 954 | u16 id; | |
| 954 | 955 | __be16 proto; | |
| 955 | 956 | } vlan[NET_DEVICE_PATH_VLAN_MAX]; | |
| 957 | + | ||
| 958 | + | bool ieee80211; | |
| 956 | 959 | }; | |
| 957 | 960 | ||
| 958 | 961 | enum tc_setup_type { | |
modified include/linux/netfilter_netdev.h
| @@ -133,7 +133,7 @@ static inline struct sk_buff *nf_hook_egress(struct sk_buff *skb, int *rc, | |||
| 133 | 133 | ||
| 134 | 134 | static inline void nf_skip_egress(struct sk_buff *skb, bool skip) | |
| 135 | 135 | { | |
| 136 | - | #ifdef CONFIG_NETFILTER_SKIP_EGRESS | |
| 136 | + | #ifdef CONFIG_NET_EGRESS | |
| 137 | 137 | skb->nf_skip_egress = skip; | |
| 138 | 138 | #endif | |
| 139 | 139 | } | |
modified include/linux/netfs.h
| @@ -397,6 +397,8 @@ ssize_t netfs_unbuffered_write_iter(struct kiocb *iocb, struct iov_iter *from); | |||
| 397 | 397 | ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *iter, | |
| 398 | 398 | struct netfs_group *netfs_group); | |
| 399 | 399 | ssize_t netfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from); | |
| 400 | + | void netfs_clear_stale_post_isize(struct inode *inode, uoff_t from, | |
| 401 | + | uoff_t to); | |
| 400 | 402 | ||
| 401 | 403 | /* Single, monolithic object read/write API. */ | |
| 402 | 404 | void netfs_single_mark_inode_dirty(struct inode *inode); | |
modified include/linux/nsproxy.h
| @@ -100,6 +100,7 @@ void exit_cred_namespaces(struct task_struct *tsk); | |||
| 100 | 100 | void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new); | |
| 101 | 101 | int exec_task_namespaces(void); | |
| 102 | 102 | void deactivate_nsproxy(struct nsproxy *ns); | |
| 103 | + | void nsproxy_free(struct nsproxy *ns); | |
| 103 | 104 | int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **, | |
| 104 | 105 | struct cred *, struct fs_struct *); | |
| 105 | 106 | int __init nsproxy_cache_init(void); | |
modified include/linux/nvme.h
| @@ -1266,8 +1266,8 @@ enum { | |||
| 1266 | 1266 | NVME_ZRASF_ZONE_STATE_IMP_OPEN = 0x02, | |
| 1267 | 1267 | NVME_ZRASF_ZONE_STATE_EXP_OPEN = 0x03, | |
| 1268 | 1268 | NVME_ZRASF_ZONE_STATE_CLOSED = 0x04, | |
| 1269 | - | NVME_ZRASF_ZONE_STATE_READONLY = 0x05, | |
| 1270 | - | NVME_ZRASF_ZONE_STATE_FULL = 0x06, | |
| 1269 | + | NVME_ZRASF_ZONE_STATE_FULL = 0x05, | |
| 1270 | + | NVME_ZRASF_ZONE_STATE_READONLY = 0x06, | |
| 1271 | 1271 | NVME_ZRASF_ZONE_STATE_OFFLINE = 0x07, | |
| 1272 | 1272 | NVME_REPORT_ZONE_PARTIAL = 1, | |
| 1273 | 1273 | }; | |
modified include/linux/perf_event.h
| @@ -1506,9 +1506,10 @@ is_default_overflow_handler(struct perf_event *event) | |||
| 1506 | 1506 | } | |
| 1507 | 1507 | ||
| 1508 | 1508 | extern void | |
| 1509 | - | perf_event_header__init_id(struct perf_event_header *header, | |
| 1510 | - | struct perf_sample_data *data, | |
| 1511 | - | struct perf_event *event); | |
| 1509 | + | perf_event_header__init(struct perf_event_header *header, | |
| 1510 | + | struct perf_sample_data *data, | |
| 1511 | + | u32 type, u16 misc, u16 size, | |
| 1512 | + | struct perf_event *event); | |
| 1512 | 1513 | extern void | |
| 1513 | 1514 | perf_event__output_id_sample(struct perf_event *event, | |
| 1514 | 1515 | struct perf_output_handle *handle, | |
modified include/linux/rtnetlink.h
| @@ -186,7 +186,12 @@ void net_dec_ingress_queue(void); | |||
| 186 | 186 | #ifdef CONFIG_NET_EGRESS | |
| 187 | 187 | void net_inc_egress_queue(void); | |
| 188 | 188 | void net_dec_egress_queue(void); | |
| 189 | - | void netdev_xmit_skip_txqueue(bool skip); | |
| 189 | + | bool netdev_xmit_skip_txqueue(bool skip); | |
| 190 | + | #else | |
| 191 | + | static inline bool netdev_xmit_skip_txqueue(bool skip) | |
| 192 | + | { | |
| 193 | + | return false; | |
| 194 | + | } | |
| 190 | 195 | #endif | |
| 191 | 196 | ||
| 192 | 197 | void rtnetlink_init(void); | |
modified include/linux/sched/ext.h
| @@ -207,6 +207,7 @@ struct sched_ext_entity { | |||
| 207 | 207 | s32 holding_cpu; | |
| 208 | 208 | s32 selected_cpu; | |
| 209 | 209 | s32 runnable_cpu; /* cpu @p is runnable on, -1 if not */ | |
| 210 | + | u32 ops_qseq; /* protected by rq lock */ | |
| 210 | 211 | struct task_struct *kf_tasks[2]; /* see SCX_CALL_OP_TASK() */ | |
| 211 | 212 | ||
| 212 | 213 | struct list_head runnable_node; /* rq->scx.runnable_list */ | |
modified include/linux/siphash.h
| @@ -75,8 +75,10 @@ static inline u64 ___siphash_aligned(const __le64 *data, size_t len, | |||
| 75 | 75 | /** | |
| 76 | 76 | * siphash - compute 64-bit siphash PRF value | |
| 77 | 77 | * @data: buffer to hash | |
| 78 | - | * @size: size of @data | |
| 78 | + | * @len: size of @data | |
| 79 | 79 | * @key: the siphash key | |
| 80 | + | * | |
| 81 | + | * Returns: siphash PRF value | |
| 80 | 82 | */ | |
| 81 | 83 | static inline u64 siphash(const void *data, size_t len, | |
| 82 | 84 | const siphash_key_t *key) | |
| @@ -125,8 +127,10 @@ static inline u32 ___hsiphash_aligned(const __le32 *data, size_t len, | |||
| 125 | 127 | /** | |
| 126 | 128 | * hsiphash - compute 32-bit hsiphash PRF value | |
| 127 | 129 | * @data: buffer to hash | |
| 128 | - | * @size: size of @data | |
| 130 | + | * @len: size of @data | |
| 129 | 131 | * @key: the hsiphash key | |
| 132 | + | * | |
| 133 | + | * Returns: hsiphash PRF value | |
| 130 | 134 | */ | |
| 131 | 135 | static inline u32 hsiphash(const void *data, size_t len, | |
| 132 | 136 | const hsiphash_key_t *key) | |
modified include/linux/skbuff.h
| @@ -1020,7 +1020,7 @@ struct sk_buff { | |||
| 1020 | 1020 | #ifdef CONFIG_NET_REDIRECT | |
| 1021 | 1021 | __u8 from_ingress:1; | |
| 1022 | 1022 | #endif | |
| 1023 | - | #ifdef CONFIG_NETFILTER_SKIP_EGRESS | |
| 1023 | + | #ifdef CONFIG_NET_EGRESS | |
| 1024 | 1024 | __u8 nf_skip_egress:1; | |
| 1025 | 1025 | #endif | |
| 1026 | 1026 | #ifdef CONFIG_SKB_DECRYPTED | |
modified include/linux/soc/qcom/geni-se.h
| @@ -347,17 +347,12 @@ struct geni_se { | |||
| 347 | 347 | #define QUP_SE_VERSION_2_5 0x20050000 | |
| 348 | 348 | ||
| 349 | 349 | /* | |
| 350 | - | * Define bandwidth thresholds that cause the underlying Core 2X interconnect | |
| 351 | - | * clock to run at the named frequency. These baseline values are recommended | |
| 352 | - | * by the hardware team, and are not dynamically scaled with GENI bandwidth | |
| 353 | - | * beyond basic on/off. | |
| 350 | + | * QUP Core 2X clock votes used by GENI clients through the "qup-core" ICC | |
| 351 | + | * path. Values are in Bps and must be converted with Bps_to_icc() before | |
| 352 | + | * setting avg_bw. | |
| 354 | 353 | */ | |
| 355 | - | #define CORE_2X_19_2_MHZ 960 | |
| 356 | - | #define CORE_2X_50_MHZ 2500 | |
| 357 | - | #define CORE_2X_100_MHZ 5000 | |
| 358 | - | #define CORE_2X_150_MHZ 7500 | |
| 359 | - | #define CORE_2X_200_MHZ 10000 | |
| 360 | - | #define CORE_2X_236_MHZ 16383 | |
| 354 | + | #define CORE_2X_19_2_MHZ 9600000 | |
| 355 | + | #define CORE_2X_50_MHZ 25000000 | |
| 361 | 356 | ||
| 362 | 357 | #define GENI_DEFAULT_BW Bps_to_icc(1000) | |
| 363 | 358 | ||
modified include/linux/thunderbolt.h
| @@ -22,6 +22,7 @@ struct device; | |||
| 22 | 22 | #include <linux/device.h> | |
| 23 | 23 | #include <linux/idr.h> | |
| 24 | 24 | #include <linux/list.h> | |
| 25 | + | #include <linux/lockdep.h> | |
| 25 | 26 | #include <linux/mutex.h> | |
| 26 | 27 | #include <linux/device-id/tb.h> | |
| 27 | 28 | #include <linux/pci.h> | |
| @@ -565,6 +566,7 @@ struct tb_nhi { | |||
| 565 | 566 | * @interval_nsec: Interval counter if interrupt throttling is to be | |
| 566 | 567 | * used with this ring (in ns) | |
| 567 | 568 | * @wait: Used to signal that the ring may be empty now | |
| 569 | + | * @lock_key: Lock validator class key per-ring | |
| 568 | 570 | */ | |
| 569 | 571 | struct tb_ring { | |
| 570 | 572 | spinlock_t lock; | |
| @@ -590,6 +592,7 @@ struct tb_ring { | |||
| 590 | 592 | void *poll_data; | |
| 591 | 593 | unsigned int interval_nsec; | |
| 592 | 594 | wait_queue_head_t wait; | |
| 595 | + | struct lock_class_key lock_key; | |
| 593 | 596 | }; | |
| 594 | 597 | ||
| 595 | 598 | /* Leave ring interrupt enabled on suspend */ | |
modified include/linux/tty.h
| @@ -168,6 +168,7 @@ struct tty_operations; | |||
| 168 | 168 | * @write_wait: concurrent writers are waiting in this queue until they are | |
| 169 | 169 | * allowed to write | |
| 170 | 170 | * @read_wait: readers wait for data in this queue | |
| 171 | + | * @break_wait: wait queue for timed breaks | |
| 171 | 172 | * @hangup_work: normally a work to perform a hangup (do_tty_hangup()); while | |
| 172 | 173 | * freeing the tty, (re)used to release_one_tty() | |
| 173 | 174 | * @disc_data: pointer to @ldisc's private data (e.g. to &struct n_tty_data) | |
| @@ -230,6 +231,7 @@ struct tty_struct { | |||
| 230 | 231 | struct fasync_struct *fasync; | |
| 231 | 232 | wait_queue_head_t write_wait; | |
| 232 | 233 | wait_queue_head_t read_wait; | |
| 234 | + | wait_queue_head_t break_wait; | |
| 233 | 235 | struct work_struct hangup_work; | |
| 234 | 236 | void *disc_data; | |
| 235 | 237 | void *driver_data; | |
modified include/linux/tty_driver.h
| @@ -73,6 +73,11 @@ struct serial_struct; | |||
| 73 | 73 | * @TTY_DRIVER_NO_WORKQUEUE: | |
| 74 | 74 | * Do not create workqueue when tty_register_driver(). Whenever set, flip | |
| 75 | 75 | * buffer workqueue can be set by tty_port_link_wq() for every port. | |
| 76 | + | * | |
| 77 | + | * @TTY_DRIVER_RESET_SAVED_TERMIOS: | |
| 78 | + | * Reset any saved termios settings on device registration when reusing a | |
| 79 | + | * minor number. Must only be set by drivers that guarantee that the minor | |
| 80 | + | * number is no longer in use. | |
| 76 | 81 | */ | |
| 77 | 82 | enum tty_driver_flag { | |
| 78 | 83 | TTY_DRIVER_INSTALLED = BIT(0), | |
| @@ -84,6 +89,7 @@ enum tty_driver_flag { | |||
| 84 | 89 | TTY_DRIVER_DYNAMIC_ALLOC = BIT(6), | |
| 85 | 90 | TTY_DRIVER_UNNUMBERED_NODE = BIT(7), | |
| 86 | 91 | TTY_DRIVER_NO_WORKQUEUE = BIT(8), | |
| 92 | + | TTY_DRIVER_RESET_SAVED_TERMIOS = BIT(9), | |
| 87 | 93 | }; | |
| 88 | 94 | ||
| 89 | 95 | enum tty_driver_type { | |
modified include/linux/tty_port.h
| @@ -245,7 +245,8 @@ bool tty_port_carrier_raised(struct tty_port *port); | |||
| 245 | 245 | void tty_port_raise_dtr_rts(struct tty_port *port); | |
| 246 | 246 | void tty_port_lower_dtr_rts(struct tty_port *port); | |
| 247 | 247 | void tty_port_hangup(struct tty_port *port); | |
| 248 | - | void __tty_port_tty_hangup(struct tty_port *port, bool check_clocal, bool async); | |
| 248 | + | void tty_port_tty_hangup(struct tty_port *port, bool check_clocal); | |
| 249 | + | void tty_port_tty_vhangup(struct tty_port *port); | |
| 249 | 250 | void tty_port_tty_wakeup(struct tty_port *port); | |
| 250 | 251 | int tty_port_block_til_ready(struct tty_port *port, struct tty_struct *tty, | |
| 251 | 252 | struct file *filp); | |
| @@ -264,25 +265,6 @@ static inline int tty_port_users(struct tty_port *port) | |||
| 264 | 265 | return port->count + port->blocked_open; | |
| 265 | 266 | } | |
| 266 | 267 | ||
| 267 | - | /** | |
| 268 | - | * tty_port_tty_hangup - helper to hang up a tty asynchronously | |
| 269 | - | * @port: tty port | |
| 270 | - | * @check_clocal: hang only ttys with %CLOCAL unset? | |
| 271 | - | */ | |
| 272 | - | static inline void tty_port_tty_hangup(struct tty_port *port, bool check_clocal) | |
| 273 | - | { | |
| 274 | - | __tty_port_tty_hangup(port, check_clocal, true); | |
| 275 | - | } | |
| 276 | - | ||
| 277 | - | /** | |
| 278 | - | * tty_port_tty_vhangup - helper to hang up a tty synchronously | |
| 279 | - | * @port: tty port | |
| 280 | - | */ | |
| 281 | - | static inline void tty_port_tty_vhangup(struct tty_port *port) | |
| 282 | - | { | |
| 283 | - | __tty_port_tty_hangup(port, false, false); | |
| 284 | - | } | |
| 285 | - | ||
| 286 | 268 | #ifdef CONFIG_TTY | |
| 287 | 269 | void tty_kref_put(struct tty_struct *tty); | |
| 288 | 270 | __DEFINE_CLASS_IS_CONDITIONAL(tty_port_tty, true); | |
modified include/linux/usb/serial.h
| @@ -381,6 +381,7 @@ void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port, | |||
| 381 | 381 | ||
| 382 | 382 | int usb_serial_bus_register(struct usb_serial_driver *device); | |
| 383 | 383 | void usb_serial_bus_deregister(struct usb_serial_driver *device); | |
| 384 | + | void usb_serial_bus_remove_new_id(struct usb_serial_driver *driver); | |
| 384 | 385 | ||
| 385 | 386 | extern const struct bus_type usb_serial_bus_type; | |
| 386 | 387 | extern struct tty_driver *usb_serial_tty_driver; | |
modified include/linux/virtio_net.h
| @@ -111,48 +111,38 @@ static inline int __virtio_net_hdr_to_skb(struct sk_buff *skb, | |||
| 111 | 111 | p_off = nh_min_len + thlen; | |
| 112 | 112 | if (!pskb_may_pull(skb, p_off)) | |
| 113 | 113 | return -EINVAL; | |
| 114 | - | } else { | |
| 114 | + | } else if (gso_type) { | |
| 115 | 115 | /* gso packets without NEEDS_CSUM do not set transport_offset. | |
| 116 | 116 | * probe and drop if does not match one of the above types. | |
| 117 | 117 | */ | |
| 118 | - | if (gso_type && skb->network_header) { | |
| 119 | - | struct flow_keys_basic keys; | |
| 120 | - | ||
| 121 | - | if (!skb->protocol) { | |
| 122 | - | __be16 protocol = dev_parse_header_protocol(skb); | |
| 123 | - | ||
| 124 | - | if (!protocol) | |
| 125 | - | virtio_net_hdr_set_proto(skb, hdr); | |
| 126 | - | else if (!virtio_net_hdr_match_proto(protocol, | |
| 127 | - | hdr_gso_type)) | |
| 128 | - | return -EINVAL; | |
| 129 | - | else | |
| 130 | - | skb->protocol = protocol; | |
| 131 | - | } | |
| 118 | + | struct flow_keys_basic keys; | |
| 119 | + | ||
| 120 | + | if (!skb->protocol) { | |
| 121 | + | skb->protocol = dev_parse_header_protocol(skb); | |
| 122 | + | if (!skb->protocol) | |
| 123 | + | virtio_net_hdr_set_proto(skb, hdr); | |
| 124 | + | } | |
| 132 | 125 | retry: | |
| 133 | - | if (!skb_flow_dissect_flow_keys_basic(NULL, skb, &keys, | |
| 134 | - | NULL, 0, 0, 0, | |
| 135 | - | 0)) { | |
| 136 | - | /* UFO does not specify ipv4 or 6: try both */ | |
| 137 | - | if (gso_type & SKB_GSO_UDP && | |
| 138 | - | skb->protocol == htons(ETH_P_IP)) { | |
| 139 | - | skb->protocol = htons(ETH_P_IPV6); | |
| 140 | - | goto retry; | |
| 141 | - | } | |
| 142 | - | return -EINVAL; | |
| 126 | + | if (!skb_flow_dissect_flow_keys_basic(NULL, skb, &keys, | |
| 127 | + | NULL, 0, 0, 0, | |
| 128 | + | 0)) { | |
| 129 | + | /* UFO does not specify ipv4 or 6: try both */ | |
| 130 | + | if (gso_type & SKB_GSO_UDP && | |
| 131 | + | skb->protocol == htons(ETH_P_IP)) { | |
| 132 | + | skb->protocol = htons(ETH_P_IPV6); | |
| 133 | + | goto retry; | |
| 143 | 134 | } | |
| 135 | + | return -EINVAL; | |
| 136 | + | } | |
| 144 | 137 | ||
| 145 | - | p_off = keys.control.thoff + thlen; | |
| 146 | - | if (!pskb_may_pull(skb, p_off) || | |
| 147 | - | keys.basic.ip_proto != ip_proto) | |
| 148 | - | return -EINVAL; | |
| 138 | + | p_off = keys.control.thoff + thlen; | |
| 139 | + | if (!pskb_may_pull(skb, p_off) || | |
| 140 | + | keys.basic.ip_proto != ip_proto || | |
| 141 | + | !virtio_net_hdr_match_proto(keys.basic.n_proto, | |
| 142 | + | hdr_gso_type)) | |
| 143 | + | return -EINVAL; | |
| 149 | 144 | ||
| 150 | - | skb_set_transport_header(skb, keys.control.thoff); | |
| 151 | - | } else if (gso_type) { | |
| 152 | - | p_off = nh_min_len + thlen; | |
| 153 | - | if (!pskb_may_pull(skb, p_off)) | |
| 154 | - | return -EINVAL; | |
| 155 | - | } | |
| 145 | + | skb_set_transport_header(skb, keys.control.thoff); | |
| 156 | 146 | } | |
| 157 | 147 | ||
| 158 | 148 | if (hdr_gso_type != VIRTIO_NET_HDR_GSO_NONE) { | |
modified include/net/amt.h
| @@ -231,10 +231,6 @@ struct amt_relay_headers { | |||
| 231 | 231 | }; | |
| 232 | 232 | } __packed; | |
| 233 | 233 | ||
| 234 | - | struct amt_skb_cb { | |
| 235 | - | struct amt_tunnel_list *tunnel; | |
| 236 | - | }; | |
| 237 | - | ||
| 238 | 234 | struct amt_tunnel_list { | |
| 239 | 235 | struct list_head list; | |
| 240 | 236 | /* Protect All resources under an amt_tunne_list */ | |
modified include/net/bluetooth/hci_core.h
| @@ -62,7 +62,7 @@ struct inquiry_entry { | |||
| 62 | 62 | NAME_PENDING, | |
| 63 | 63 | NAME_KNOWN, | |
| 64 | 64 | } name_state; | |
| 65 | - | __u32 timestamp; | |
| 65 | + | unsigned long timestamp; | |
| 66 | 66 | struct inquiry_data data; | |
| 67 | 67 | }; | |
| 68 | 68 | ||
| @@ -78,7 +78,7 @@ struct discovery_state { | |||
| 78 | 78 | struct list_head all; /* All devices found during inquiry */ | |
| 79 | 79 | struct list_head unknown; /* Name state not known */ | |
| 80 | 80 | struct list_head resolve; /* Name needs to be resolved */ | |
| 81 | - | __u32 timestamp; | |
| 81 | + | unsigned long timestamp; | |
| 82 | 82 | bdaddr_t last_adv_addr; | |
| 83 | 83 | u8 last_adv_addr_type; | |
| 84 | 84 | s8 last_adv_rssi; | |
| @@ -562,6 +562,7 @@ struct hci_dev { | |||
| 562 | 562 | struct list_head link_keys; | |
| 563 | 563 | struct list_head long_term_keys; | |
| 564 | 564 | struct list_head identity_resolving_keys; | |
| 565 | + | struct mutex remote_oob_lock; | |
| 565 | 566 | struct list_head remote_oob_data; | |
| 566 | 567 | struct list_head le_accept_list; | |
| 567 | 568 | struct list_head le_resolv_list; | |
modified include/net/bluetooth/rfcomm.h
| @@ -207,6 +207,7 @@ struct rfcomm_dlc { | |||
| 207 | 207 | #define RFCOMM_AUTH_REJECT 7 | |
| 208 | 208 | #define RFCOMM_DEFER_SETUP 8 | |
| 209 | 209 | #define RFCOMM_ENC_DROP 9 | |
| 210 | + | #define RFCOMM_CLOSED 10 | |
| 210 | 211 | ||
| 211 | 212 | /* Scheduling flags and events */ | |
| 212 | 213 | #define RFCOMM_SCHED_WAKEUP 31 | |
modified include/net/can.h
| @@ -17,12 +17,14 @@ | |||
| 17 | 17 | * @can_framelen: cached echo CAN frame length for bql | |
| 18 | 18 | * @can_gw_hops: can-gw CAN frame time-to-live counter | |
| 19 | 19 | * @can_ext_flags: CAN skb extensions flags | |
| 20 | + | * @can_skb_uid: CAN skb UID for raw_rcv and isotp echo handling | |
| 20 | 21 | */ | |
| 21 | 22 | struct can_skb_ext { | |
| 22 | 23 | int can_iif; | |
| 23 | 24 | u16 can_framelen; | |
| 24 | 25 | u8 can_gw_hops; | |
| 25 | 26 | u8 can_ext_flags; | |
| 27 | + | u32 can_skb_uid; | |
| 26 | 28 | }; | |
| 27 | 29 | ||
| 28 | 30 | #endif /* _NET_CAN_H */ | |
modified include/net/gso.h
| @@ -19,10 +19,18 @@ struct skb_gso_cb { | |||
| 19 | 19 | int encap_level; | |
| 20 | 20 | __wsum csum; | |
| 21 | 21 | __u16 csum_start; | |
| 22 | + | /* Number of IPv4/IPv6 GSO handler entries for this packet. */ | |
| 23 | + | u8 recursion_counter; | |
| 22 | 24 | }; | |
| 23 | 25 | #define SKB_GSO_CB_OFFSET 32 | |
| 24 | 26 | #define SKB_GSO_CB(skb) ((struct skb_gso_cb *)((skb)->cb + SKB_GSO_CB_OFFSET)) | |
| 25 | 27 | ||
| 28 | + | static inline bool gso_recursion_inc_test(struct sk_buff *skb, | |
| 29 | + | unsigned int limit) | |
| 30 | + | { | |
| 31 | + | return ++SKB_GSO_CB(skb)->recursion_counter > limit; | |
| 32 | + | } | |
| 33 | + | ||
| 26 | 34 | static inline int skb_tnl_header_len(const struct sk_buff *inner_skb) | |
| 27 | 35 | { | |
| 28 | 36 | return (skb_mac_header(inner_skb) - inner_skb->head) - | |
modified include/net/ip.h
| @@ -74,6 +74,13 @@ static inline unsigned int ip_hdrlen(const struct sk_buff *skb) | |||
| 74 | 74 | return ip_hdr(skb)->ihl * 4; | |
| 75 | 75 | } | |
| 76 | 76 | ||
| 77 | + | static inline int ip_check_csum_start(const struct sk_buff *skb) | |
| 78 | + | { | |
| 79 | + | if (unlikely(skb->csum_start < skb->network_header + ip_hdrlen(skb))) | |
| 80 | + | return -EINVAL; | |
| 81 | + | return 0; | |
| 82 | + | } | |
| 83 | + | ||
| 77 | 84 | struct ipcm_cookie { | |
| 78 | 85 | struct sockcm_cookie sockc; | |
| 79 | 86 | __be32 addr; | |
modified include/net/mana/mana.h
| @@ -377,7 +377,18 @@ struct mana_recv_buf_oob { | |||
| 377 | 377 | #define MANA_RXBUF_PAD (SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) \ | |
| 378 | 378 | + ETH_HLEN) | |
| 379 | 379 | ||
| 380 | - | #define MANA_XDP_MTU_MAX (PAGE_SIZE - MANA_RXBUF_PAD - XDP_PACKET_HEADROOM) | |
| 380 | + | /* Headroom an RX buffer has to reserve while XDP is attached: the XDP program | |
| 381 | + | * needs XDP_PACKET_HEADROOM, and the TX path needs LL_RESERVED_SPACE() (see | |
| 382 | + | * mana_get_rxbuf_headroom()). LL_RESERVED_SPACE() grows with MAX_SKB_FRAGS and | |
| 383 | + | * exceeds XDP_PACKET_HEADROOM once CONFIG_MAX_SKB_FRAGS is 19 or more. | |
| 384 | + | */ | |
| 385 | + | static inline u32 mana_xdp_headroom(struct net_device *ndev) | |
| 386 | + | { | |
| 387 | + | return max_t(u32, LL_RESERVED_SPACE(ndev), XDP_PACKET_HEADROOM); | |
| 388 | + | } | |
| 389 | + | ||
| 390 | + | #define MANA_XDP_MTU_MAX(ndev) \ | |
| 391 | + | (PAGE_SIZE - MANA_RXBUF_PAD - mana_xdp_headroom(ndev)) | |
| 381 | 392 | ||
| 382 | 393 | struct mana_rxq { | |
| 383 | 394 | struct gdma_queue *gdma_rq; | |
| @@ -691,6 +702,7 @@ int mana_query_link_cfg(struct mana_port_context *apc); | |||
| 691 | 702 | int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed, | |
| 692 | 703 | int enable_clamping); | |
| 693 | 704 | void mana_query_phy_stats(struct mana_port_context *apc); | |
| 705 | + | bool mana_single_rxbuf_per_page_forced(struct mana_port_context *apc, u32 mtu); | |
| 694 | 706 | int mana_pre_alloc_rxbufs(struct mana_port_context *apc, int mtu, int num_queues); | |
| 695 | 707 | void mana_pre_dealloc_rxbufs(struct mana_port_context *apc); | |
| 696 | 708 | void mana_unmap_skb(struct sk_buff *skb, struct mana_port_context *apc); | |
modified include/net/netfilter/nf_flow_table.h
| @@ -183,10 +183,10 @@ enum nf_flow_flags { | |||
| 183 | 183 | NF_FLOW_DNAT, | |
| 184 | 184 | NF_FLOW_CLOSING, | |
| 185 | 185 | NF_FLOW_TEARDOWN, | |
| 186 | + | NF_FLOW_PENDING, | |
| 186 | 187 | NF_FLOW_HW, | |
| 187 | 188 | NF_FLOW_HW_DYING, | |
| 188 | 189 | NF_FLOW_HW_DEAD, | |
| 189 | - | NF_FLOW_HW_PENDING, | |
| 190 | 190 | NF_FLOW_HW_BIDIRECTIONAL, | |
| 191 | 191 | NF_FLOW_HW_ESTABLISHED, | |
| 192 | 192 | }; | |
modified include/net/sch_generic.h
| @@ -810,6 +810,15 @@ static inline bool skb_at_tc_ingress(const struct sk_buff *skb) | |||
| 810 | 810 | #endif | |
| 811 | 811 | } | |
| 812 | 812 | ||
| 813 | + | static inline bool skb_at_tc_egress(const struct sk_buff *skb) | |
| 814 | + | { | |
| 815 | + | #ifdef CONFIG_NET_EGRESS | |
| 816 | + | return skb->nf_skip_egress && !skb_at_tc_ingress(skb); | |
| 817 | + | #else | |
| 818 | + | return false; | |
| 819 | + | #endif | |
| 820 | + | } | |
| 821 | + | ||
| 813 | 822 | static inline bool skb_skip_tc_classify(struct sk_buff *skb) | |
| 814 | 823 | { | |
| 815 | 824 | #ifdef CONFIG_NET_CLS_ACT | |
modified include/net/strparser.h
| @@ -91,11 +91,11 @@ static inline struct strp_msg *strp_msg(struct sk_buff *skb) | |||
| 91 | 91 | struct strparser { | |
| 92 | 92 | struct sock *sk; | |
| 93 | 93 | ||
| 94 | - | u32 stopped : 1; | |
| 95 | - | u32 paused : 1; | |
| 96 | - | u32 aborted : 1; | |
| 97 | - | u32 interrupted : 1; | |
| 98 | - | u32 unrecov_intr : 1; | |
| 94 | + | u8 stopped; | |
| 95 | + | u8 paused; | |
| 96 | + | u8 aborted; | |
| 97 | + | u8 interrupted; | |
| 98 | + | u8 unrecov_intr; | |
| 99 | 99 | ||
| 100 | 100 | struct sk_buff **skb_nextp; | |
| 101 | 101 | struct sk_buff *skb_head; | |
modified include/net/xdp.h
| @@ -106,6 +106,11 @@ struct xdp_buff { | |||
| 106 | 106 | }; | |
| 107 | 107 | }; | |
| 108 | 108 | ||
| 109 | + | static __always_inline void xdp_reinit_buff(struct xdp_buff *xdp) | |
| 110 | + | { | |
| 111 | + | xdp->flags = 0; | |
| 112 | + | } | |
| 113 | + | ||
| 109 | 114 | static __always_inline bool xdp_buff_has_frags(const struct xdp_buff *xdp) | |
| 110 | 115 | { | |
| 111 | 116 | return !!(xdp->flags & XDP_FLAGS_HAS_FRAGS); | |
modified include/sound/core.h
| @@ -340,6 +340,15 @@ static inline void snd_card_unref(struct snd_card *card) | |||
| 340 | 340 | ||
| 341 | 341 | DEFINE_FREE(snd_card_unref, struct snd_card *, if (_T) snd_card_unref(_T)) | |
| 342 | 342 | ||
| 343 | + | /* | |
| 344 | + | * For automatic error handling at probe time, assign the card like: | |
| 345 | + | * struct snd_card *card __free(snd_card_free) = NULL; | |
| 346 | + | * then create and process as usual. | |
| 347 | + | * But, don't forget to clear to NULL at successful return for avoiding | |
| 348 | + | * the unexpected cleanup! | |
| 349 | + | */ | |
| 350 | + | DEFINE_FREE(snd_card_free, struct snd_card *, if (_T) snd_card_free(_T)) | |
| 351 | + | ||
| 343 | 352 | #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) | |
| 344 | 353 | ||
| 345 | 354 | /* device.c */ | |
modified include/sound/cs35l56.h
| @@ -312,6 +312,7 @@ struct snd_ctl_elem_value; | |||
| 312 | 312 | ||
| 313 | 313 | #define CS35L56_SDW1_PLAYBACK_PORT 1 | |
| 314 | 314 | #define CS35L56_SDW1_CAPTURE_PORT 3 | |
| 315 | + | #define CS35L56_OT25_CAPTURE_PORT 4 | |
| 315 | 316 | ||
| 316 | 317 | #define CS35L56_NUM_BULK_SUPPLIES 3 | |
| 317 | 318 | #define CS35L56_NUM_DSP_REGIONS 5 | |
modified include/uapi/linux/alloc_tag.h
| @@ -38,6 +38,7 @@ struct allocinfo_counter { | |||
| 38 | 38 | __u64 bytes; | |
| 39 | 39 | __u64 calls; | |
| 40 | 40 | __u8 accurate; | |
| 41 | + | __u8 pad[7]; | |
| 41 | 42 | } __attribute__((aligned(8))); | |
| 42 | 43 | ||
| 43 | 44 | struct allocinfo_tag_data { | |
modified include/uapi/linux/random.h
| @@ -58,7 +58,7 @@ struct rand_pool_info { | |||
| 58 | 58 | /** | |
| 59 | 59 | * struct vgetrandom_opaque_params - arguments for allocating memory for vgetrandom | |
| 60 | 60 | * | |
| 61 | - | * @size_per_opaque_state: Size of each state that is to be passed to vgetrandom(). | |
| 61 | + | * @size_of_opaque_state: Size of each state passed to vgetrandom(). | |
| 62 | 62 | * @mmap_prot: Value of the prot argument in mmap(2). | |
| 63 | 63 | * @mmap_flags: Value of the flags argument in mmap(2). | |
| 64 | 64 | * @reserved: Reserved for future use. | |
modified include/vdso/getrandom.h
| @@ -64,7 +64,7 @@ extern void __arch_chacha20_blocks_nostack(u8 *dst_bytes, const u32 *key, u32 *c | |||
| 64 | 64 | * @opaque_state: Passed to __cvdso_getrandom(). | |
| 65 | 65 | * @opaque_len: Passed to __cvdso_getrandom(); | |
| 66 | 66 | * | |
| 67 | - | * This function is implemented by making a single call to to __cvdso_getrandom(), whose | |
| 67 | + | * This function is implemented by making a single call to __cvdso_getrandom(), whose | |
| 68 | 68 | * documentation may be consulted for more information. | |
| 69 | 69 | * | |
| 70 | 70 | * Returns: The return value of __cvdso_getrandom(). | |
modified init/Kconfig
| @@ -173,6 +173,11 @@ config CC_HAS_ALLOC_TOKEN | |||
| 173 | 173 | config CC_HAS_MULTIDIMENSIONAL_NONSTRING | |
| 174 | 174 | def_bool $(success,echo 'char tag[][4] __attribute__((__nonstring__)) = { };' | $(CC) $(CLANG_FLAGS) -x c - -c -o /dev/null -Werror) | |
| 175 | 175 | ||
| 176 | + | config CC_OPT_INLINE_MEMSET | |
| 177 | + | string | |
| 178 | + | default "-finline-stringops=memset" if $(cc-option,-finline-stringops=memset) | |
| 179 | + | default "-mllvm -max-store-memset=4294967294" if $(cc-option,-mllvm -max-store-memset=4294967294) | |
| 180 | + | ||
| 176 | 181 | config LD_CAN_USE_KEEP_IN_OVERLAY | |
| 177 | 182 | # ld.lld prior to 21.0.0 did not support KEEP within an overlay description | |
| 178 | 183 | # https://github.com/llvm/llvm-project/pull/130661 | |
modified io_uring/bpf_filter.c
| @@ -253,6 +253,7 @@ void io_bpf_filter_clone(struct io_restriction *dst, struct io_restriction *src) | |||
| 253 | 253 | * If the src filter is going away, just ignore it. | |
| 254 | 254 | */ | |
| 255 | 255 | if (refcount_inc_not_zero(&src->bpf_filters->refs)) { | |
| 256 | + | src->bpf_filters_cow = true; | |
| 256 | 257 | dst->bpf_filters = src->bpf_filters; | |
| 257 | 258 | dst->bpf_filters_cow = true; | |
| 258 | 259 | } | |
modified io_uring/cancel.c
| @@ -634,12 +634,11 @@ __cold void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd) | |||
| 634 | 634 | prepare_to_wait(&tctx->wait, &wait, TASK_INTERRUPTIBLE); | |
| 635 | 635 | io_run_task_work(); | |
| 636 | 636 | io_uring_drop_tctx_refs(current); | |
| 637 | + | /* only skip the sleep for local work this task may run */ | |
| 637 | 638 | xa_for_each(&tctx->xa, index, node) { | |
| 638 | - | if (io_local_work_pending(node->ctx)) { | |
| 639 | - | WARN_ON_ONCE(node->ctx->submitter_task && | |
| 640 | - | node->ctx->submitter_task != current); | |
| 639 | + | if (io_local_work_pending(node->ctx) && | |
| 640 | + | io_allowed_defer_tw_run(node->ctx)) | |
| 641 | 641 | goto end_wait; | |
| 642 | - | } | |
| 643 | 642 | } | |
| 644 | 643 | /* | |
| 645 | 644 | * If we've seen completions, retry without waiting. This | |
modified io_uring/cmd_net.c
| @@ -69,8 +69,8 @@ static inline int io_uring_cmd_setsockopt(struct socket *sock, | |||
| 69 | 69 | optlen); | |
| 70 | 70 | } | |
| 71 | 71 | ||
| 72 | - | static bool io_process_timestamp_skb(struct io_uring_cmd *cmd, struct sock *sk, | |
| 73 | - | struct sk_buff *skb, unsigned issue_flags) | |
| 72 | + | static int io_process_timestamp_skb(struct io_uring_cmd *cmd, struct sock *sk, | |
| 73 | + | struct sk_buff *skb, unsigned int issue_flags) | |
| 74 | 74 | { | |
| 75 | 75 | struct sock_exterr_skb *serr = SKB_EXT_ERR(skb); | |
| 76 | 76 | struct io_uring_cqe cqe[2]; | |
| @@ -83,7 +83,7 @@ static bool io_process_timestamp_skb(struct io_uring_cmd *cmd, struct sock *sk, | |||
| 83 | 83 | ||
| 84 | 84 | ret = skb_get_tx_timestamp(skb, sk, &ts); | |
| 85 | 85 | if (ret < 0) | |
| 86 | - | return false; | |
| 86 | + | return ret; | |
| 87 | 87 | ||
| 88 | 88 | tskey = serr->ee.ee_data; | |
| 89 | 89 | tstype = serr->ee.ee_info; | |
| @@ -98,7 +98,9 @@ static bool io_process_timestamp_skb(struct io_uring_cmd *cmd, struct sock *sk, | |||
| 98 | 98 | iots = (struct io_timespec *)&cqe[1]; | |
| 99 | 99 | iots->tv_sec = ts.tv_sec; | |
| 100 | 100 | iots->tv_nsec = ts.tv_nsec; | |
| 101 | - | return io_uring_cmd_post_mshot_cqe32(cmd, issue_flags, cqe); | |
| 101 | + | if (!io_uring_cmd_post_mshot_cqe32(cmd, issue_flags, cqe)) | |
| 102 | + | return -ENOBUFS; | |
| 103 | + | return 0; | |
| 102 | 104 | } | |
| 103 | 105 | ||
| 104 | 106 | static int io_uring_cmd_timestamp(struct socket *sock, | |
| @@ -135,7 +137,8 @@ static int io_uring_cmd_timestamp(struct socket *sock, | |||
| 135 | 137 | skb = skb_peek(&list); | |
| 136 | 138 | if (!skb) | |
| 137 | 139 | break; | |
| 138 | - | if (!io_process_timestamp_skb(cmd, sk, skb, issue_flags)) | |
| 140 | + | ret = io_process_timestamp_skb(cmd, sk, skb, issue_flags); | |
| 141 | + | if (ret) | |
| 139 | 142 | break; | |
| 140 | 143 | __skb_dequeue(&list); | |
| 141 | 144 | consume_skb(skb); | |
| @@ -145,6 +148,12 @@ static int io_uring_cmd_timestamp(struct socket *sock, | |||
| 145 | 148 | scoped_guard(spinlock_irqsave, &q->lock) | |
| 146 | 149 | skb_queue_splice(&list, q); | |
| 147 | 150 | } | |
| 151 | + | /* | |
| 152 | + | * Aux CQEs cannot overflow and the poll is edge triggered, so nothing | |
| 153 | + | * re-runs the command once the CQ drains. End the multishot instead. | |
| 154 | + | */ | |
| 155 | + | if (ret == -ENOBUFS) | |
| 156 | + | return -ENOBUFS; | |
| 148 | 157 | return -EAGAIN; | |
| 149 | 158 | } | |
| 150 | 159 | ||
modified io_uring/io_uring.c
| @@ -733,7 +733,8 @@ bool io_cqe_cache_refill(struct io_ring_ctx *ctx, bool overflow, bool cqe32) | |||
| 733 | 733 | * Post dummy CQE if a 32b CQE is needed and there's only room for a | |
| 734 | 734 | * 16b CQE before the ring wraps. | |
| 735 | 735 | */ | |
| 736 | - | if (cqe32 && off + 1 == ctx->cq_entries) { | |
| 736 | + | if (cqe32 && (ctx->flags & IORING_SETUP_CQE_MIXED) && | |
| 737 | + | off + 1 == ctx->cq_entries) { | |
| 737 | 738 | if (!io_fill_nop_cqe(ctx, off)) | |
| 738 | 739 | return false; | |
| 739 | 740 | off = 0; | |
| @@ -742,12 +743,13 @@ bool io_cqe_cache_refill(struct io_ring_ctx *ctx, bool overflow, bool cqe32) | |||
| 742 | 743 | free = ctx->cq_entries - io_cqring_queued(ctx); | |
| 743 | 744 | /* we need a contiguous range, limit based on the current array offset */ | |
| 744 | 745 | len = min(free, ctx->cq_entries - off); | |
| 745 | - | if (len < (cqe32 + 1)) | |
| 746 | - | return false; | |
| 747 | - | ||
| 748 | 746 | if (ctx->flags & IORING_SETUP_CQE32) { | |
| 747 | + | if (!len) | |
| 748 | + | return false; | |
| 749 | 749 | off <<= 1; | |
| 750 | 750 | len <<= 1; | |
| 751 | + | } else if (len < (cqe32 + 1)) { | |
| 752 | + | return false; | |
| 751 | 753 | } | |
| 752 | 754 | ||
| 753 | 755 | ctx->cqe_cached = &rings->cqes[off]; | |
| @@ -781,7 +783,7 @@ static bool io_fill_cqe_aux(struct io_ring_ctx *ctx, u64 user_data, s32 res, | |||
| 781 | 783 | WRITE_ONCE(cqe->res, res); | |
| 782 | 784 | WRITE_ONCE(cqe->flags, cflags); | |
| 783 | 785 | ||
| 784 | - | if (cqe32) { | |
| 786 | + | if (cqe32 || (ctx->flags & IORING_SETUP_CQE32)) { | |
| 785 | 787 | WRITE_ONCE(cqe->big_cqe[0], 0); | |
| 786 | 788 | WRITE_ONCE(cqe->big_cqe[1], 0); | |
| 787 | 789 | } | |
| @@ -2068,8 +2070,9 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr) | |||
| 2068 | 2070 | ||
| 2069 | 2071 | static void io_rings_free(struct io_ring_ctx *ctx) | |
| 2070 | 2072 | { | |
| 2071 | - | io_free_region(ctx->user, &ctx->sq_region); | |
| 2072 | - | io_free_region(ctx->user, &ctx->ring_region); | |
| 2073 | + | /* ring memory is not charged to RLIMIT_MEMLOCK, hence no user */ | |
| 2074 | + | io_free_region(NULL, &ctx->sq_region); | |
| 2075 | + | io_free_region(NULL, &ctx->ring_region); | |
| 2073 | 2076 | ctx->rings = NULL; | |
| 2074 | 2077 | RCU_INIT_POINTER(ctx->rings_rcu, NULL); | |
| 2075 | 2078 | ctx->sq_sqes = NULL; | |
| @@ -2403,8 +2406,8 @@ static __cold void io_ring_exit_work(struct work_struct *work) | |||
| 2403 | 2406 | spin_lock(&ctx->completion_lock); | |
| 2404 | 2407 | spin_unlock(&ctx->completion_lock); | |
| 2405 | 2408 | ||
| 2406 | - | /* pairs with RCU read section in io_req_local_work_add() */ | |
| 2407 | - | if (ctx->flags & IORING_SETUP_DEFER_TASKRUN) | |
| 2409 | + | /* pairs with the RCU read sections in the task_work add paths */ | |
| 2410 | + | if (ctx->flags & (IORING_SETUP_DEFER_TASKRUN | IORING_SETUP_SQPOLL)) | |
| 2408 | 2411 | synchronize_rcu(); | |
| 2409 | 2412 | ||
| 2410 | 2413 | io_ring_ctx_free(ctx); | |
| @@ -2733,7 +2736,8 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx, | |||
| 2733 | 2736 | rd.user_addr = p->cq_off.user_addr; | |
| 2734 | 2737 | rd.flags |= IORING_MEM_REGION_TYPE_USER; | |
| 2735 | 2738 | } | |
| 2736 | - | ret = io_create_region(ctx, &ctx->ring_region, &rd, IORING_OFF_CQ_RING); | |
| 2739 | + | /* ring memory is not charged to RLIMIT_MEMLOCK, hence no user */ | |
| 2740 | + | ret = io_create_region(NULL, &ctx->ring_region, &rd, IORING_OFF_CQ_RING); | |
| 2737 | 2741 | if (ret) | |
| 2738 | 2742 | return ret; | |
| 2739 | 2743 | ctx->rings = rings = io_region_get_ptr(&ctx->ring_region); | |
| @@ -2747,7 +2751,7 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx, | |||
| 2747 | 2751 | rd.user_addr = p->sq_off.user_addr; | |
| 2748 | 2752 | rd.flags |= IORING_MEM_REGION_TYPE_USER; | |
| 2749 | 2753 | } | |
| 2750 | - | ret = io_create_region(ctx, &ctx->sq_region, &rd, IORING_OFF_SQES); | |
| 2754 | + | ret = io_create_region(NULL, &ctx->sq_region, &rd, IORING_OFF_SQES); | |
| 2751 | 2755 | if (ret) { | |
| 2752 | 2756 | io_rings_free(ctx); | |
| 2753 | 2757 | return ret; | |
| @@ -2958,7 +2962,8 @@ static void io_ctx_restriction_clone(struct io_ring_ctx *ctx, | |||
| 2958 | 2962 | if (dst->op_registered) | |
| 2959 | 2963 | ctx->int_flags |= IO_RING_F_OP_RESTRICTED; | |
| 2960 | 2964 | if (dst->reg_registered) | |
| 2961 | - | ctx->int_flags |= IO_RING_F_REG_RESTRICTED; | |
| 2965 | + | ctx->int_flags |= IO_RING_F_REG_RESTRICTED | | |
| 2966 | + | IO_RING_F_RESTRICT_INHERITED; | |
| 2962 | 2967 | } | |
| 2963 | 2968 | ||
| 2964 | 2969 | static __cold int io_uring_create(struct io_ctx_config *config) | |
modified io_uring/kbuf.c
| @@ -459,7 +459,7 @@ static int io_remove_buffers_legacy(struct io_ring_ctx *ctx, | |||
| 459 | 459 | static void io_put_bl(struct io_ring_ctx *ctx, struct io_buffer_list *bl) | |
| 460 | 460 | { | |
| 461 | 461 | if (bl->flags & IOBL_BUF_RING) | |
| 462 | - | io_free_region(ctx->user, &bl->region); | |
| 462 | + | io_free_region(NULL, &bl->region); | |
| 463 | 463 | else | |
| 464 | 464 | io_remove_buffers_legacy(ctx, bl, -1U); | |
| 465 | 465 | ||
| @@ -676,7 +676,7 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg) | |||
| 676 | 676 | rd.user_addr = reg.ring_addr; | |
| 677 | 677 | rd.flags |= IORING_MEM_REGION_TYPE_USER; | |
| 678 | 678 | } | |
| 679 | - | ret = io_create_region(ctx, &bl->region, &rd, mmap_offset); | |
| 679 | + | ret = io_create_region(NULL, &bl->region, &rd, mmap_offset); | |
| 680 | 680 | if (ret) | |
| 681 | 681 | goto fail; | |
| 682 | 682 | br = io_region_get_ptr(&bl->region); | |
| @@ -709,7 +709,7 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg) | |||
| 709 | 709 | if (!ret) | |
| 710 | 710 | return 0; | |
| 711 | 711 | fail: | |
| 712 | - | io_free_region(ctx->user, &bl->region); | |
| 712 | + | io_free_region(NULL, &bl->region); | |
| 713 | 713 | kfree(bl); | |
| 714 | 714 | return ret; | |
| 715 | 715 | } | |
modified io_uring/loop.c
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | #include "io_uring.h" | |
| 3 | 3 | #include "wait.h" | |
| 4 | 4 | #include "loop.h" | |
| 5 | + | #include "tctx.h" | |
| 5 | 6 | ||
| 6 | 7 | static inline int io_loop_nr_cqes(const struct io_ring_ctx *ctx, | |
| 7 | 8 | const struct iou_loop_params *lp) | |
| @@ -81,6 +82,10 @@ int io_run_loop(struct io_ring_ctx *ctx) | |||
| 81 | 82 | { | |
| 82 | 83 | int ret; | |
| 83 | 84 | ||
| 85 | + | ret = io_uring_add_tctx_node(ctx); | |
| 86 | + | if (unlikely(ret)) | |
| 87 | + | return ret; | |
| 88 | + | ||
| 84 | 89 | if (!io_allowed_run_tw(ctx)) | |
| 85 | 90 | return -EEXIST; | |
| 86 | 91 | ||
modified io_uring/memmap.c
| @@ -204,7 +204,7 @@ done: | |||
| 204 | 204 | return 0; | |
| 205 | 205 | } | |
| 206 | 206 | ||
| 207 | - | int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr, | |
| 207 | + | int io_create_region(struct user_struct *user, struct io_mapped_region *mr, | |
| 208 | 208 | struct io_uring_region_desc *reg, | |
| 209 | 209 | unsigned long mmap_offset) | |
| 210 | 210 | { | |
| @@ -230,8 +230,8 @@ int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr, | |||
| 230 | 230 | return -EOVERFLOW; | |
| 231 | 231 | ||
| 232 | 232 | nr_pages = reg->size >> PAGE_SHIFT; | |
| 233 | - | if (ctx->user) { | |
| 234 | - | ret = __io_account_mem(ctx->user, nr_pages); | |
| 233 | + | if (user) { | |
| 234 | + | ret = __io_account_mem(user, nr_pages); | |
| 235 | 235 | if (ret) | |
| 236 | 236 | return ret; | |
| 237 | 237 | } | |
| @@ -240,7 +240,7 @@ int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr, | |||
| 240 | 240 | if (reg->flags & IORING_MEM_REGION_TYPE_USER) | |
| 241 | 241 | ret = io_region_pin_pages(mr, reg); | |
| 242 | 242 | else | |
| 243 | - | ret = io_region_allocate_pages(mr, reg, mmap_offset, ctx->user); | |
| 243 | + | ret = io_region_allocate_pages(mr, reg, mmap_offset, user); | |
| 244 | 244 | if (ret) | |
| 245 | 245 | goto out_free; | |
| 246 | 246 | ||
| @@ -249,7 +249,7 @@ int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr, | |||
| 249 | 249 | goto out_free; | |
| 250 | 250 | return 0; | |
| 251 | 251 | out_free: | |
| 252 | - | io_free_region(ctx->user, mr); | |
| 252 | + | io_free_region(user, mr); | |
| 253 | 253 | return ret; | |
| 254 | 254 | } | |
| 255 | 255 | ||
modified io_uring/memmap.h
| @@ -18,7 +18,7 @@ unsigned long io_uring_get_unmapped_area(struct file *file, unsigned long addr, | |||
| 18 | 18 | int io_uring_mmap(struct file *file, struct vm_area_struct *vma); | |
| 19 | 19 | ||
| 20 | 20 | void io_free_region(struct user_struct *user, struct io_mapped_region *mr); | |
| 21 | - | int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr, | |
| 21 | + | int io_create_region(struct user_struct *user, struct io_mapped_region *mr, | |
| 22 | 22 | struct io_uring_region_desc *reg, | |
| 23 | 23 | unsigned long mmap_offset); | |
| 24 | 24 | ||
modified io_uring/net.c
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | #include <linux/un.h> | |
| 8 | 8 | #include <linux/compat.h> | |
| 9 | 9 | #include <net/compat.h> | |
| 10 | + | #include <net/ipv6.h> | |
| 10 | 11 | #include <linux/io_uring.h> | |
| 11 | 12 | ||
| 12 | 13 | #include <uapi/linux/io_uring.h> | |
| @@ -1741,7 +1742,8 @@ void io_connect_bpf_populate(struct io_uring_bpf_ctx *bctx, struct io_kiocb *req | |||
| 1741 | 1742 | case AF_INET6: { | |
| 1742 | 1743 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ss; | |
| 1743 | 1744 | ||
| 1744 | - | if (conn->addr_len < (int)sizeof(*sin6)) | |
| 1745 | + | /* The IPv6 stack accepts SIN6_LEN_RFC2133; port and addr are in it. */ | |
| 1746 | + | if (conn->addr_len < SIN6_LEN_RFC2133) | |
| 1745 | 1747 | break; | |
| 1746 | 1748 | bctx->connect.port = sin6->sin6_port; | |
| 1747 | 1749 | memcpy(bctx->connect.v6_addr, &sin6->sin6_addr, | |
modified io_uring/register.c
| @@ -480,8 +480,9 @@ struct io_ring_ctx_rings { | |||
| 480 | 480 | static void io_register_free_rings(struct io_ring_ctx *ctx, | |
| 481 | 481 | struct io_ring_ctx_rings *r) | |
| 482 | 482 | { | |
| 483 | - | io_free_region(ctx->user, &r->sq_region); | |
| 484 | - | io_free_region(ctx->user, &r->ring_region); | |
| 483 | + | /* ring memory is not charged to RLIMIT_MEMLOCK, hence no user */ | |
| 484 | + | io_free_region(NULL, &r->sq_region); | |
| 485 | + | io_free_region(NULL, &r->ring_region); | |
| 485 | 486 | } | |
| 486 | 487 | ||
| 487 | 488 | #define swap_old(ctx, o, n, field) \ | |
| @@ -529,7 +530,7 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg) | |||
| 529 | 530 | rd.user_addr = p->cq_off.user_addr; | |
| 530 | 531 | rd.flags |= IORING_MEM_REGION_TYPE_USER; | |
| 531 | 532 | } | |
| 532 | - | ret = io_create_region(ctx, &n.ring_region, &rd, IORING_OFF_CQ_RING); | |
| 533 | + | ret = io_create_region(NULL, &n.ring_region, &rd, IORING_OFF_CQ_RING); | |
| 533 | 534 | if (ret) | |
| 534 | 535 | return ret; | |
| 535 | 536 | ||
| @@ -559,7 +560,7 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg) | |||
| 559 | 560 | rd.user_addr = p->sq_off.user_addr; | |
| 560 | 561 | rd.flags |= IORING_MEM_REGION_TYPE_USER; | |
| 561 | 562 | } | |
| 562 | - | ret = io_create_region(ctx, &n.sq_region, &rd, IORING_OFF_SQES); | |
| 563 | + | ret = io_create_region(NULL, &n.sq_region, &rd, IORING_OFF_SQES); | |
| 563 | 564 | if (ret) { | |
| 564 | 565 | io_register_free_rings(ctx, &n); | |
| 565 | 566 | return ret; | |
| @@ -730,7 +731,8 @@ static int io_register_mem_region(struct io_ring_ctx *ctx, void __user *uarg) | |||
| 730 | 731 | !(ctx->flags & IORING_SETUP_R_DISABLED)) | |
| 731 | 732 | return -EINVAL; | |
| 732 | 733 | ||
| 733 | - | ret = io_create_region(ctx, ®ion, &rd, IORING_MAP_OFF_PARAM_REGION); | |
| 734 | + | ret = io_create_region(ctx->user, ®ion, &rd, | |
| 735 | + | IORING_MAP_OFF_PARAM_REGION); | |
| 734 | 736 | if (ret) | |
| 735 | 737 | return ret; | |
| 736 | 738 | if (copy_to_user(rd_uptr, &rd, sizeof(rd))) { | |
| @@ -764,7 +766,14 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, | |||
| 764 | 766 | if (ctx->submitter_task && ctx->submitter_task != current) | |
| 765 | 767 | return -EEXIST; | |
| 766 | 768 | ||
| 767 | - | if ((ctx->int_flags & IO_RING_F_REG_RESTRICTED) && !(ctx->flags & IORING_SETUP_R_DISABLED)) { | |
| 769 | + | /* | |
| 770 | + | * A disabled ring is exempt from its own register restrictions, so | |
| 771 | + | * that the creator can set them up and then enable the ring. That | |
| 772 | + | * does not apply to restrictions inherited from the task. | |
| 773 | + | */ | |
| 774 | + | if ((ctx->int_flags & IO_RING_F_REG_RESTRICTED) && | |
| 775 | + | (!(ctx->flags & IORING_SETUP_R_DISABLED) || | |
| 776 | + | (ctx->int_flags & IO_RING_F_RESTRICT_INHERITED))) { | |
| 768 | 777 | opcode = array_index_nospec(opcode, IORING_REGISTER_LAST); | |
| 769 | 778 | if (!test_bit(opcode, ctx->restrictions.register_op)) | |
| 770 | 779 | return -EACCES; | |
modified io_uring/tw.c
| @@ -210,6 +210,9 @@ void io_req_normal_work_add(struct io_kiocb *req) | |||
| 210 | 210 | struct io_uring_task *tctx = req->tctx; | |
| 211 | 211 | struct io_ring_ctx *ctx = req->ctx; | |
| 212 | 212 | ||
| 213 | + | /* SQPOLL can retire the request on push, see io_ring_exit_work() */ | |
| 214 | + | guard(rcu)(); | |
| 215 | + | ||
| 213 | 216 | /* tw run already pending, nothing else to do */ | |
| 214 | 217 | if (!mpscq_push(&tctx->task_list, &req->io_task_work.node)) | |
| 215 | 218 | return; | |
modified io_uring/zcrx.c
| @@ -374,6 +374,7 @@ struct io_zcrx_args { | |||
| 374 | 374 | struct io_kiocb *req; | |
| 375 | 375 | struct io_zcrx_ifq *ifq; | |
| 376 | 376 | unsigned nr_skbs; | |
| 377 | + | bool stopped_early; | |
| 377 | 378 | }; | |
| 378 | 379 | ||
| 379 | 380 | static const struct memory_provider_ops io_uring_pp_zc_ops; | |
| @@ -431,7 +432,7 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx, | |||
| 431 | 432 | mmap_offset = IORING_MAP_OFF_ZCRX_REGION; | |
| 432 | 433 | mmap_offset += (u64)id << IORING_OFF_ZCRX_SHIFT; | |
| 433 | 434 | ||
| 434 | - | ret = io_create_region(ctx, &ifq->rq_region, rd, mmap_offset); | |
| 435 | + | ret = io_create_region(ctx->user, &ifq->rq_region, rd, mmap_offset); | |
| 435 | 436 | if (ret < 0) | |
| 436 | 437 | return ret; | |
| 437 | 438 | ||
| @@ -1899,6 +1900,9 @@ io_zcrx_recv_skb(read_descriptor_t *desc, struct sk_buff *skb, | |||
| 1899 | 1900 | } | |
| 1900 | 1901 | ||
| 1901 | 1902 | out: | |
| 1903 | + | /* Bytes left in len mean an error stopped the walk early. */ | |
| 1904 | + | if (len) | |
| 1905 | + | args->stopped_early = true; | |
| 1902 | 1906 | if (offset == start_off) | |
| 1903 | 1907 | return ret; | |
| 1904 | 1908 | desc->count -= (offset - start_off); | |
| @@ -1935,8 +1939,9 @@ static int io_zcrx_tcp_recvmsg(struct io_kiocb *req, struct io_zcrx_ifq *ifq, | |||
| 1935 | 1939 | ret = -ENOTCONN; | |
| 1936 | 1940 | else | |
| 1937 | 1941 | ret = -EAGAIN; | |
| 1938 | - | } else if (unlikely(args.nr_skbs > IO_SKBS_PER_CALL_LIMIT) && | |
| 1939 | - | (issue_flags & IO_URING_F_MULTISHOT)) { | |
| 1942 | + | } else if ((issue_flags & IO_URING_F_MULTISHOT) && | |
| 1943 | + | (unlikely(args.nr_skbs > IO_SKBS_PER_CALL_LIMIT) || | |
| 1944 | + | args.stopped_early)) { | |
| 1940 | 1945 | ret = IOU_REQUEUE; | |
| 1941 | 1946 | } else if (sock_flag(sk, SOCK_DONE)) { | |
| 1942 | 1947 | /* Make it to retry until it finally gets 0. */ | |
modified kernel/audit_tree.c
| @@ -545,22 +545,38 @@ static void kill_rules(struct audit_context *context, struct audit_tree *tree) | |||
| 545 | 545 | { | |
| 546 | 546 | struct audit_krule *rule, *next; | |
| 547 | 547 | struct audit_entry *entry; | |
| 548 | + | bool need_sync = false; | |
| 548 | 549 | ||
| 549 | 550 | list_for_each_entry_safe(rule, next, &tree->rules, rlist) { | |
| 550 | 551 | entry = container_of(rule, struct audit_entry, rule); | |
| 551 | 552 | ||
| 552 | - | list_del_init(&rule->rlist); | |
| 553 | 553 | if (rule->tree) { | |
| 554 | 554 | /* not a half-baked one */ | |
| 555 | 555 | audit_tree_log_remove_rule(context, rule); | |
| 556 | - | if (entry->rule.exe) | |
| 557 | - | audit_remove_mark(entry->rule.exe); | |
| 558 | 556 | rule->tree = NULL; | |
| 559 | 557 | list_del_rcu(&entry->list); | |
| 560 | 558 | list_del(&entry->rule.list); | |
| 561 | - | call_rcu(&entry->rcu, audit_free_rule_rcu); | |
| 559 | + | if (entry->rule.exe) | |
| 560 | + | need_sync = true; | |
| 561 | + | } else { | |
| 562 | + | list_del_init(&rule->rlist); | |
| 562 | 563 | } | |
| 563 | 564 | } | |
| 565 | + | ||
| 566 | + | if (list_empty(&tree->rules)) | |
| 567 | + | return; | |
| 568 | + | ||
| 569 | + | if (need_sync) | |
| 570 | + | synchronize_rcu(); | |
| 571 | + | ||
| 572 | + | list_for_each_entry_safe(rule, next, &tree->rules, rlist) { | |
| 573 | + | entry = container_of(rule, struct audit_entry, rule); | |
| 574 | + | ||
| 575 | + | list_del_init(&rule->rlist); | |
| 576 | + | if (entry->rule.exe) | |
| 577 | + | audit_remove_mark(entry->rule.exe); | |
| 578 | + | call_rcu(&entry->rcu, audit_free_rule_rcu); | |
| 579 | + | } | |
| 564 | 580 | } | |
| 565 | 581 | ||
| 566 | 582 | /* | |
modified kernel/bpf/core.c
| @@ -1362,7 +1362,7 @@ static int bpf_jit_blind_insn(const struct bpf_insn *from, | |||
| 1362 | 1362 | { | |
| 1363 | 1363 | struct bpf_insn *to = to_buff; | |
| 1364 | 1364 | u32 imm_rnd = get_random_u32(); | |
| 1365 | - | s16 off; | |
| 1365 | + | int off; | |
| 1366 | 1366 | ||
| 1367 | 1367 | BUILD_BUG_ON(BPF_REG_PARAMS + 2 != MAX_BPF_JIT_REG); | |
| 1368 | 1368 | BUILD_BUG_ON(BPF_REG_AX + 1 != MAX_BPF_JIT_REG); | |
| @@ -1438,6 +1438,8 @@ static int bpf_jit_blind_insn(const struct bpf_insn *from, | |||
| 1438 | 1438 | off = from->off; | |
| 1439 | 1439 | if (off < 0) | |
| 1440 | 1440 | off -= 2; | |
| 1441 | + | if (off < S16_MIN) | |
| 1442 | + | return -ERANGE; | |
| 1441 | 1443 | *to++ = BPF_ALU64_IMM(BPF_MOV, BPF_REG_AX, imm_rnd ^ from->imm); | |
| 1442 | 1444 | *to++ = BPF_ALU64_IMM(BPF_XOR, BPF_REG_AX, imm_rnd); | |
| 1443 | 1445 | *to++ = BPF_JMP_REG(from->code, from->dst_reg, BPF_REG_AX, off); | |
| @@ -1458,6 +1460,8 @@ static int bpf_jit_blind_insn(const struct bpf_insn *from, | |||
| 1458 | 1460 | off = from->off; | |
| 1459 | 1461 | if (off < 0) | |
| 1460 | 1462 | off -= 2; | |
| 1463 | + | if (off < S16_MIN) | |
| 1464 | + | return -ERANGE; | |
| 1461 | 1465 | *to++ = BPF_ALU32_IMM(BPF_MOV, BPF_REG_AX, imm_rnd ^ from->imm); | |
| 1462 | 1466 | *to++ = BPF_ALU32_IMM(BPF_XOR, BPF_REG_AX, imm_rnd); | |
| 1463 | 1467 | *to++ = BPF_JMP32_REG(from->code, from->dst_reg, BPF_REG_AX, | |
| @@ -1606,7 +1610,9 @@ struct bpf_prog *bpf_jit_blind_constants(struct bpf_verifier_env *env, struct bp | |||
| 1606 | 1610 | if (!rewritten) | |
| 1607 | 1611 | continue; | |
| 1608 | 1612 | ||
| 1609 | - | if (env) | |
| 1613 | + | if (rewritten < 0) | |
| 1614 | + | tmp = ERR_PTR(rewritten); | |
| 1615 | + | else if (env) | |
| 1610 | 1616 | tmp = bpf_patch_insn_data(env, i, insn_buff, rewritten); | |
| 1611 | 1617 | else | |
| 1612 | 1618 | tmp = bpf_patch_insn_single(clone, i, insn_buff, rewritten); | |
modified kernel/bpf/hashtab.c
| @@ -128,6 +128,7 @@ struct htab_elem { | |||
| 128 | 128 | ||
| 129 | 129 | struct htab_btf_record { | |
| 130 | 130 | struct btf_record *record; | |
| 131 | + | struct btf *btf; | |
| 131 | 132 | u32 key_size; | |
| 132 | 133 | }; | |
| 133 | 134 | ||
| @@ -497,8 +498,13 @@ static void htab_dtor_ctx_free(void *ctx) | |||
| 497 | 498 | { | |
| 498 | 499 | struct htab_btf_record *hrec = ctx; | |
| 499 | 500 | ||
| 501 | + | /* | |
| 502 | + | * The duplicated record still points into the map BTF, so free it | |
| 503 | + | * before dropping the reference that keeps that BTF alive. | |
| 504 | + | */ | |
| 500 | 505 | btf_record_free(hrec->record); | |
| 501 | - | kfree(ctx); | |
| 506 | + | btf_put(hrec->btf); | |
| 507 | + | kfree(hrec); | |
| 502 | 508 | } | |
| 503 | 509 | ||
| 504 | 510 | static int bpf_ma_set_dtor(struct bpf_map *map, struct bpf_mem_alloc *ma, | |
| @@ -521,6 +527,15 @@ static int bpf_ma_set_dtor(struct bpf_map *map, struct bpf_mem_alloc *ma, | |||
| 521 | 527 | kfree(hrec); | |
| 522 | 528 | return err; | |
| 523 | 529 | } | |
| 530 | + | /* | |
| 531 | + | * btf_record_dup() only acquires kernel and module BTF. Fields whose | |
| 532 | + | * types live in the map BTF keep pointing into it: kptrs to local | |
| 533 | + | * types refer to map->btf, and graph roots carry a value record owned | |
| 534 | + | * by its struct meta table. The context can outlive the map when the | |
| 535 | + | * allocator defers its teardown, so hold a reference of our own. | |
| 536 | + | */ | |
| 537 | + | hrec->btf = map->btf; | |
| 538 | + | btf_get(hrec->btf); | |
| 524 | 539 | bpf_mem_alloc_set_dtor(ma, dtor, htab_dtor_ctx_free, hrec); | |
| 525 | 540 | return 0; | |
| 526 | 541 | } | |
| @@ -3359,8 +3374,10 @@ static int __rhtab_map_lookup_and_delete_batch(struct bpf_map *map, | |||
| 3359 | 3374 | } | |
| 3360 | 3375 | ||
| 3361 | 3376 | if (do_delete) { | |
| 3377 | + | migrate_disable(); | |
| 3362 | 3378 | for (i = 0; i < total; i++) | |
| 3363 | 3379 | rhtab_delete_elem(rhtab, del_elems[i], NULL, 0); | |
| 3380 | + | migrate_enable(); | |
| 3364 | 3381 | } | |
| 3365 | 3382 | ||
| 3366 | 3383 | rcu_read_unlock(); | |
modified kernel/bpf/memalloc.c
| @@ -118,6 +118,11 @@ struct bpf_mem_cache { | |||
| 118 | 118 | struct llist_head free_by_rcu_ttrace; | |
| 119 | 119 | struct llist_head waiting_for_gp_ttrace; | |
| 120 | 120 | struct rcu_head rcu_ttrace; | |
| 121 | + | /* | |
| 122 | + | * 0 - idle | |
| 123 | + | * 1 - __free_rcu() is queued | |
| 124 | + | * 2 - __free_rcu() is queued and free_by_rcu_ttrace got more objects since | |
| 125 | + | */ | |
| 121 | 126 | atomic_t call_rcu_ttrace_in_progress; | |
| 122 | 127 | raw_spinlock_t lock; | |
| 123 | 128 | }; | |
| @@ -276,6 +281,8 @@ static int free_all(struct bpf_mem_cache *c, struct llist_node *llnode, bool per | |||
| 276 | 281 | return cnt; | |
| 277 | 282 | } | |
| 278 | 283 | ||
| 284 | + | static void __do_call_rcu_ttrace(struct bpf_mem_cache *c); | |
| 285 | + | ||
| 279 | 286 | static void __free_rcu(struct rcu_head *head) | |
| 280 | 287 | { | |
| 281 | 288 | struct bpf_mem_cache *c = container_of(head, struct bpf_mem_cache, rcu_ttrace); | |
| @@ -285,7 +292,19 @@ static void __free_rcu(struct rcu_head *head) | |||
| 285 | 292 | llnode = llist_del_all(&c->waiting_for_gp_ttrace); | |
| 286 | 293 | ||
| 287 | 294 | free_all(c, llnode, !!c->percpu_size); | |
| 288 | - | atomic_set(&c->call_rcu_ttrace_in_progress, 0); | |
| 295 | + | ||
| 296 | + | /* | |
| 297 | + | * do_call_rcu_ttrace() that ran while GP was in flight left its objects | |
| 298 | + | * in free_by_rcu_ttrace. This cache may never free or alloc in bulk | |
| 299 | + | * again, so start the next GP from here. | |
| 300 | + | * 'c' can be freed as soon as call_rcu_ttrace_in_progress is zero. | |
| 301 | + | */ | |
| 302 | + | if (atomic_cmpxchg(&c->call_rcu_ttrace_in_progress, 1, 0) == 1) | |
| 303 | + | return; | |
| 304 | + | ||
| 305 | + | /* Pairs with synchronize_rcu() in free_mem_alloc() */ | |
| 306 | + | guard(rcu)(); | |
| 307 | + | __do_call_rcu_ttrace(c); | |
| 289 | 308 | } | |
| 290 | 309 | ||
| 291 | 310 | static void enque_to_free(struct bpf_mem_cache *c, void *obj) | |
| @@ -298,18 +317,15 @@ static void enque_to_free(struct bpf_mem_cache *c, void *obj) | |||
| 298 | 317 | llist_add(llnode, &c->free_by_rcu_ttrace); | |
| 299 | 318 | } | |
| 300 | 319 | ||
| 301 | - | static void do_call_rcu_ttrace(struct bpf_mem_cache *c) | |
| 320 | + | static void __do_call_rcu_ttrace(struct bpf_mem_cache *c) | |
| 302 | 321 | { | |
| 303 | 322 | struct llist_node *llnode, *t; | |
| 304 | 323 | ||
| 305 | - | if (atomic_xchg(&c->call_rcu_ttrace_in_progress, 1)) { | |
| 306 | - | if (unlikely(READ_ONCE(c->draining))) { | |
| 307 | - | scoped_guard(raw_spinlock_irqsave, &c->lock) | |
| 308 | - | llnode = llist_del_all(&c->free_by_rcu_ttrace); | |
| 309 | - | free_all(c, llnode, !!c->percpu_size); | |
| 310 | - | } | |
| 311 | - | return; | |
| 312 | - | } | |
| 324 | + | /* | |
| 325 | + | * Must be done before llist_del_all(). Objects that it misses were | |
| 326 | + | * added by do_call_rcu_ttrace() that will set 2 after this store. | |
| 327 | + | */ | |
| 328 | + | atomic_set(&c->call_rcu_ttrace_in_progress, 1); | |
| 313 | 329 | ||
| 314 | 330 | WARN_ON_ONCE(!llist_empty(&c->waiting_for_gp_ttrace)); | |
| 315 | 331 | llist_for_each_safe(llnode, t, llist_del_all(&c->free_by_rcu_ttrace)) | |
| @@ -328,6 +344,22 @@ static void do_call_rcu_ttrace(struct bpf_mem_cache *c) | |||
| 328 | 344 | call_rcu_tasks_trace(&c->rcu_ttrace, __free_rcu); | |
| 329 | 345 | } | |
| 330 | 346 | ||
| 347 | + | static void do_call_rcu_ttrace(struct bpf_mem_cache *c) | |
| 348 | + | { | |
| 349 | + | struct llist_node *llnode; | |
| 350 | + | ||
| 351 | + | if (atomic_xchg(&c->call_rcu_ttrace_in_progress, 2)) { | |
| 352 | + | if (unlikely(READ_ONCE(c->draining))) { | |
| 353 | + | scoped_guard(raw_spinlock_irqsave, &c->lock) | |
| 354 | + | llnode = llist_del_all(&c->free_by_rcu_ttrace); | |
| 355 | + | free_all(c, llnode, !!c->percpu_size); | |
| 356 | + | } | |
| 357 | + | return; | |
| 358 | + | } | |
| 359 | + | ||
| 360 | + | __do_call_rcu_ttrace(c); | |
| 361 | + | } | |
| 362 | + | ||
| 331 | 363 | static void free_bulk(struct bpf_mem_cache *c) | |
| 332 | 364 | { | |
| 333 | 365 | struct bpf_mem_cache *tgt = c->tgt; | |
| @@ -700,7 +732,12 @@ static void free_mem_alloc(struct bpf_mem_alloc *ma) | |||
| 700 | 732 | * to wait for the pending __free_by_rcu(), and __free_rcu(). RCU Tasks | |
| 701 | 733 | * Trace grace period implies RCU grace period, so all __free_rcu don't | |
| 702 | 734 | * need extra call_rcu() (and thus extra rcu_barrier() here). | |
| 735 | + | * | |
| 736 | + | * __free_rcu() queues itself again unless it sees 'draining'. After | |
| 737 | + | * synchronize_rcu() it either did that already or will not do it, so | |
| 738 | + | * rcu_barrier_tasks_trace() cannot miss it. | |
| 703 | 739 | */ | |
| 740 | + | synchronize_rcu(); | |
| 704 | 741 | rcu_barrier(); /* wait for __free_by_rcu */ | |
| 705 | 742 | rcu_barrier_tasks_trace(); /* wait for __free_rcu */ | |
| 706 | 743 | free_mem_alloc_no_barrier(ma); | |
modified kernel/bpf/syscall.c
| @@ -2448,6 +2448,21 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu) | |||
| 2448 | 2448 | bpf_prog_free(aux->prog); | |
| 2449 | 2449 | } | |
| 2450 | 2450 | ||
| 2451 | + | /* | |
| 2452 | + | * Progs called from a trampoline can also be reached by a task that was | |
| 2453 | + | * preempted in the trampoline before the prog's enter helper took its RCU | |
| 2454 | + | * read lock, wait for those first. | |
| 2455 | + | */ | |
| 2456 | + | static void __bpf_prog_put_rcu_tasks(struct rcu_head *rcu) | |
| 2457 | + | { | |
| 2458 | + | struct bpf_prog *prog = container_of(rcu, struct bpf_prog_aux, rcu)->prog; | |
| 2459 | + | ||
| 2460 | + | if (prog->sleepable) | |
| 2461 | + | call_rcu_tasks_trace(rcu, __bpf_prog_put_rcu); | |
| 2462 | + | else | |
| 2463 | + | call_rcu(rcu, __bpf_prog_put_rcu); | |
| 2464 | + | } | |
| 2465 | + | ||
| 2451 | 2466 | static void __bpf_prog_put_noref(struct bpf_prog *prog, bool deferred) | |
| 2452 | 2467 | { | |
| 2453 | 2468 | bpf_prog_kallsyms_del_all(prog); | |
| @@ -2461,7 +2476,9 @@ static void __bpf_prog_put_noref(struct bpf_prog *prog, bool deferred) | |||
| 2461 | 2476 | btf_put(prog->aux->attach_btf); | |
| 2462 | 2477 | ||
| 2463 | 2478 | if (deferred) { | |
| 2464 | - | if (prog->sleepable) | |
| 2479 | + | if (IS_ENABLED(CONFIG_TASKS_RCU) && prog->aux->tramp_linked) | |
| 2480 | + | call_rcu_tasks(&prog->aux->rcu, __bpf_prog_put_rcu_tasks); | |
| 2481 | + | else if (prog->sleepable) | |
| 2465 | 2482 | call_rcu_tasks_trace(&prog->aux->rcu, __bpf_prog_put_rcu); | |
| 2466 | 2483 | else | |
| 2467 | 2484 | call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); | |
modified kernel/bpf/trampoline.c
| @@ -401,6 +401,7 @@ static struct bpf_trampoline *bpf_trampoline_lookup(u64 key, unsigned long ip) | |||
| 401 | 401 | head = &trampoline_ip_table[hash_64(tr->ip, TRAMPOLINE_HASH_BITS)]; | |
| 402 | 402 | hlist_add_head(&tr->hlist_ip, head); | |
| 403 | 403 | refcount_set(&tr->refcnt, 1); | |
| 404 | + | INIT_LIST_HEAD(&tr->images); | |
| 404 | 405 | for (i = 0; i < BPF_TRAMP_MAX; i++) | |
| 405 | 406 | INIT_HLIST_HEAD(&tr->progs_hlist[i]); | |
| 406 | 407 | out: | |
| @@ -565,15 +566,22 @@ static void bpf_tramp_image_free(struct bpf_tramp_image *im) | |||
| 565 | 566 | arch_free_bpf_trampoline(im->image, im->size); | |
| 566 | 567 | bpf_jit_uncharge_modmem(im->size); | |
| 567 | 568 | percpu_ref_exit(&im->pcref); | |
| 569 | + | kfree(im->skips); | |
| 568 | 570 | kfree_rcu(im, rcu); | |
| 569 | 571 | } | |
| 570 | 572 | ||
| 571 | 573 | static void __bpf_tramp_image_put_deferred(struct work_struct *work) | |
| 572 | 574 | { | |
| 573 | 575 | struct bpf_tramp_image *im; | |
| 576 | + | struct bpf_trampoline *tr; | |
| 574 | 577 | ||
| 575 | 578 | im = container_of(work, struct bpf_tramp_image, work); | |
| 579 | + | tr = im->tr; | |
| 580 | + | trampoline_lock(tr); | |
| 581 | + | list_del(&im->list); | |
| 582 | + | trampoline_unlock(tr); | |
| 576 | 583 | bpf_tramp_image_free(im); | |
| 584 | + | bpf_trampoline_put(tr); | |
| 577 | 585 | } | |
| 578 | 586 | ||
| 579 | 587 | /* callback, fexit step 3 or fentry step 2 */ | |
| @@ -601,7 +609,7 @@ static void __bpf_tramp_image_put_rcu_tasks(struct rcu_head *rcu) | |||
| 601 | 609 | struct bpf_tramp_image *im; | |
| 602 | 610 | ||
| 603 | 611 | im = container_of(rcu, struct bpf_tramp_image, rcu); | |
| 604 | - | if (im->ip_after_call) | |
| 612 | + | if (im->call_orig) | |
| 605 | 613 | /* the case of fmod_ret/fexit trampoline and CONFIG_PREEMPTION=y */ | |
| 606 | 614 | percpu_ref_kill(&im->pcref); | |
| 607 | 615 | else | |
| @@ -621,9 +629,9 @@ static void bpf_tramp_image_put(struct bpf_tramp_image *im) | |||
| 621 | 629 | * | |
| 622 | 630 | * The trampoline is unreachable before bpf_tramp_image_put(). | |
| 623 | 631 | * | |
| 624 | - | * First, patch the trampoline to avoid calling into fexit progs. | |
| 625 | - | * The progs will be freed even if the original function is still | |
| 626 | - | * executing or sleeping. | |
| 632 | + | * Progs are patched out of the image when they are detached, see | |
| 633 | + | * bpf_trampoline_skip_prog(), so they can be freed even if a task is | |
| 634 | + | * still in the image. | |
| 627 | 635 | * In case of CONFIG_PREEMPT=y use call_rcu_tasks() to wait on | |
| 628 | 636 | * first few asm instructions to execute and call into | |
| 629 | 637 | * __bpf_tramp_enter->percpu_ref_get. | |
| @@ -637,11 +645,7 @@ static void bpf_tramp_image_put(struct bpf_tramp_image *im) | |||
| 637 | 645 | * percpu_ref_kill will be waiting for. Hence the first | |
| 638 | 646 | * call_rcu_tasks() is not necessary. | |
| 639 | 647 | */ | |
| 640 | - | if (im->ip_after_call) { | |
| 641 | - | int err = bpf_arch_text_poke(im->ip_after_call, BPF_MOD_NOP, | |
| 642 | - | BPF_MOD_JUMP, NULL, | |
| 643 | - | im->ip_epilogue); | |
| 644 | - | WARN_ON(err); | |
| 648 | + | if (im->call_orig) { | |
| 645 | 649 | if (IS_ENABLED(CONFIG_TASKS_RCU)) | |
| 646 | 650 | call_rcu_tasks(&im->rcu, __bpf_tramp_image_put_rcu_tasks); | |
| 647 | 651 | else | |
| @@ -658,7 +662,7 @@ static void bpf_tramp_image_put(struct bpf_tramp_image *im) | |||
| 658 | 662 | call_rcu_tasks_trace(&im->rcu, __bpf_tramp_image_put_rcu_tasks); | |
| 659 | 663 | } | |
| 660 | 664 | ||
| 661 | - | static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key, int size) | |
| 665 | + | static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key, int size, int nr_progs) | |
| 662 | 666 | { | |
| 663 | 667 | struct bpf_tramp_image *im; | |
| 664 | 668 | struct bpf_ksym *ksym; | |
| @@ -669,6 +673,10 @@ static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key, int size) | |||
| 669 | 673 | if (!im) | |
| 670 | 674 | goto out; | |
| 671 | 675 | ||
| 676 | + | im->skips = kzalloc_objs(*im->skips, nr_progs); | |
| 677 | + | if (!im->skips) | |
| 678 | + | goto out_free_im; | |
| 679 | + | ||
| 672 | 680 | err = bpf_jit_charge_modmem(size); | |
| 673 | 681 | if (err) | |
| 674 | 682 | goto out_free_im; | |
| @@ -695,6 +703,7 @@ out_free_image: | |||
| 695 | 703 | out_uncharge: | |
| 696 | 704 | bpf_jit_uncharge_modmem(size); | |
| 697 | 705 | out_free_im: | |
| 706 | + | kfree(im->skips); | |
| 698 | 707 | kfree(im); | |
| 699 | 708 | out: | |
| 700 | 709 | return ERR_PTR(err); | |
| @@ -771,11 +780,12 @@ again: | |||
| 771 | 780 | goto out; | |
| 772 | 781 | } | |
| 773 | 782 | ||
| 774 | - | im = bpf_tramp_image_alloc(tr->key, size); | |
| 783 | + | im = bpf_tramp_image_alloc(tr->key, size, total); | |
| 775 | 784 | if (IS_ERR(im)) { | |
| 776 | 785 | err = PTR_ERR(im); | |
| 777 | 786 | goto out; | |
| 778 | 787 | } | |
| 788 | + | im->call_orig = tr->flags & BPF_TRAMP_F_CALL_ORIG; | |
| 779 | 789 | ||
| 780 | 790 | err = arch_prepare_bpf_trampoline(im, im->image, im->image + size, | |
| 781 | 791 | &tr->func.model, tr->flags, tnodes, | |
| @@ -806,8 +816,14 @@ again: | |||
| 806 | 816 | #endif | |
| 807 | 817 | ||
| 808 | 818 | out_free: | |
| 809 | - | if (err) | |
| 819 | + | if (err) { | |
| 810 | 820 | bpf_tramp_image_free(im); | |
| 821 | + | } else { | |
| 822 | + | /* track the image until it is freed, for bpf_trampoline_skip_prog() */ | |
| 823 | + | refcount_inc(&tr->refcnt); | |
| 824 | + | im->tr = tr; | |
| 825 | + | list_add(&im->list, &tr->images); | |
| 826 | + | } | |
| 811 | 827 | out: | |
| 812 | 828 | /* If any error happens, restore previous flags */ | |
| 813 | 829 | if (err) | |
| @@ -907,6 +923,7 @@ static int bpf_trampoline_add_prog(struct bpf_trampoline *tr, | |||
| 907 | 923 | } | |
| 908 | 924 | ||
| 909 | 925 | hlist_add_head(&node->tramp_hlist, prog_list); | |
| 926 | + | node->link->prog->aux->tramp_linked = true; | |
| 910 | 927 | if (kind == BPF_TRAMP_FSESSION) { | |
| 911 | 928 | tr->progs_cnt[BPF_TRAMP_FENTRY]++; | |
| 912 | 929 | fexit = fsession_exit(node); | |
| @@ -920,6 +937,41 @@ static int bpf_trampoline_add_prog(struct bpf_trampoline *tr, | |||
| 920 | 937 | return 0; | |
| 921 | 938 | } | |
| 922 | 939 | ||
| 940 | + | /* | |
| 941 | + | * Patch the nop in front of a prog call to a jump over it. A task can be | |
| 942 | + | * preempted anywhere in the image, so archs that need several instructions for | |
| 943 | + | * a jump of any range patch a single near branch here instead. | |
| 944 | + | */ | |
| 945 | + | int __weak arch_bpf_trampoline_skip(void *nop, void *target) | |
| 946 | + | { | |
| 947 | + | return bpf_arch_text_poke(nop, BPF_MOD_NOP, BPF_MOD_JUMP, NULL, target); | |
| 948 | + | } | |
| 949 | + | ||
| 950 | + | /* | |
| 951 | + | * prog was detached and can be freed, but tasks may still be running in images | |
| 952 | + | * that call it, sleeping in an earlier prog for example. They can be in any | |
| 953 | + | * image that is not freed yet, not only in cur_image, so patch all of them to | |
| 954 | + | * jump over prog. | |
| 955 | + | */ | |
| 956 | + | static void bpf_trampoline_skip_prog(struct bpf_trampoline *tr, struct bpf_prog *prog) | |
| 957 | + | { | |
| 958 | + | struct bpf_tramp_image *im; | |
| 959 | + | int i, err; | |
| 960 | + | ||
| 961 | + | list_for_each_entry(im, &tr->images, list) { | |
| 962 | + | for (i = 0; i < im->nr_skips; i++) { | |
| 963 | + | struct bpf_tramp_skip *skip = &im->skips[i]; | |
| 964 | + | ||
| 965 | + | if (skip->prog != prog) | |
| 966 | + | continue; | |
| 967 | + | err = arch_bpf_trampoline_skip(skip->nop, skip->target); | |
| 968 | + | WARN_ON_ONCE(err); | |
| 969 | + | /* not a nop anymore, and prog's address can be reused */ | |
| 970 | + | skip->prog = NULL; | |
| 971 | + | } | |
| 972 | + | } | |
| 973 | + | } | |
| 974 | + | ||
| 923 | 975 | static void bpf_trampoline_remove_prog(struct bpf_trampoline *tr, | |
| 924 | 976 | struct bpf_tramp_node *node) | |
| 925 | 977 | { | |
| @@ -937,6 +989,7 @@ static void bpf_trampoline_remove_prog(struct bpf_trampoline *tr, | |||
| 937 | 989 | } | |
| 938 | 990 | hlist_del_init(&node->tramp_hlist); | |
| 939 | 991 | tr->progs_cnt[kind]--; | |
| 992 | + | bpf_trampoline_skip_prog(tr, node->link->prog); | |
| 940 | 993 | } | |
| 941 | 994 | ||
| 942 | 995 | static int __bpf_trampoline_link_prog(struct bpf_tramp_node *node, | |
| @@ -1245,11 +1298,9 @@ void bpf_trampoline_put(struct bpf_trampoline *tr) | |||
| 1245 | 1298 | if (WARN_ON_ONCE(!hlist_empty(&tr->progs_hlist[i]))) | |
| 1246 | 1299 | goto out; | |
| 1247 | 1300 | ||
| 1248 | - | /* This code will be executed even when the last bpf_tramp_image | |
| 1249 | - | * is alive. All progs are detached from the trampoline and the | |
| 1250 | - | * trampoline image is patched with jmp into epilogue to skip | |
| 1251 | - | * fexit progs. The fentry-only trampoline will be freed via | |
| 1252 | - | * multiple rcu callbacks. | |
| 1301 | + | /* | |
| 1302 | + | * All progs are detached and the last image has been freed, images | |
| 1303 | + | * hold a reference on the trampoline until then. | |
| 1253 | 1304 | */ | |
| 1254 | 1305 | hlist_del(&tr->hlist_key); | |
| 1255 | 1306 | hlist_del(&tr->hlist_ip); | |
modified kernel/bpf/verifier.c
| @@ -14826,7 +14826,15 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, struct bpf_insn | |||
| 14826 | 14826 | "Tighten the scalar bounds before the arithmetic so the resulting pointer remains within the allowed range."); | |
| 14827 | 14827 | return -EINVAL; | |
| 14828 | 14828 | } | |
| 14829 | - | reg_bounds_sync(dst_reg); | |
| 14829 | + | /* | |
| 14830 | + | * A packet pointer that keeps its id or range is checked against a | |
| 14831 | + | * range set from the checked pointer's umax, so var_off must not tighten | |
| 14832 | + | * its umax. r32 must still match var_off for reg_bounds_sanity_check(). | |
| 14833 | + | */ | |
| 14834 | + | if (reg_is_pkt_pointer(dst_reg) && (known || dst_reg->range > 0)) | |
| 14835 | + | __update_reg32_bounds(dst_reg); | |
| 14836 | + | else | |
| 14837 | + | reg_bounds_sync(dst_reg); | |
| 14830 | 14838 | bounds_ret = sanitize_check_bounds(env, insn, dst_reg); | |
| 14831 | 14839 | if (bounds_ret == -EACCES) | |
| 14832 | 14840 | return bounds_ret; | |
modified kernel/cgroup/cpuset.c
| @@ -152,6 +152,12 @@ static cpumask_var_t isolated_cpus; /* CSCB */ | |||
| 152 | 152 | */ | |
| 153 | 153 | static bool update_housekeeping; /* RWCS */ | |
| 154 | 154 | ||
| 155 | + | /* | |
| 156 | + | * Set if "cpuset_v2_mode" mount option is used | |
| 157 | + | * Cached at bind time and not lock protected; accessed via {READ,WRITE}_ONCE | |
| 158 | + | */ | |
| 159 | + | static bool cpuset_v2_mode; | |
| 160 | + | ||
| 155 | 161 | /* | |
| 156 | 162 | * Copy of isolated_cpus to be passed to housekeeping_update() | |
| 157 | 163 | */ | |
| @@ -439,8 +445,7 @@ static inline bool cpuset_v2(void) | |||
| 439 | 445 | */ | |
| 440 | 446 | static inline bool is_in_v2_mode(void) | |
| 441 | 447 | { | |
| 442 | - | return cpuset_v2() || | |
| 443 | - | (cpuset_cgrp_subsys.root->flags & CGRP_ROOT_CPUSET_V2_MODE); | |
| 448 | + | return cpuset_v2() || READ_ONCE(cpuset_v2_mode); | |
| 444 | 449 | } | |
| 445 | 450 | ||
| 446 | 451 | /** | |
| @@ -513,10 +518,26 @@ static void guarantee_active_cpus(struct task_struct *tsk, | |||
| 513 | 518 | rcu_read_lock(); | |
| 514 | 519 | cs = task_cs(tsk); | |
| 515 | 520 | ||
| 516 | - | while (!cpumask_intersects(cs->effective_cpus, pmask)) | |
| 521 | + | while (!cpumask_intersects(cs->effective_cpus, pmask)) { | |
| 517 | 522 | cs = parent_cs(cs); | |
| 518 | - | ||
| 523 | + | if (unlikely(!cs)) { | |
| 524 | + | /* | |
| 525 | + | * The top cpuset doesn't have any active cpu as a | |
| 526 | + | * consequence of a race between its caller and the cpu | |
| 527 | + | * hotplug operation where cpu_active_mask is updated | |
| 528 | + | * asynchronously before cpuset_handle_hotplug() is | |
| 529 | + | * being called to adjust the effective_cpus of the | |
| 530 | + | * affected cpusets. But we know the top cpuset's | |
| 531 | + | * effective_cpus is on its way to be identical to | |
| 532 | + | * cpu_active_mask minus the exclusive CPUs dedicated | |
| 533 | + | * to other valid cpuset partitions. Just pass back | |
| 534 | + | * the filtered cpu_active_mask in this case. | |
| 535 | + | */ | |
| 536 | + | goto out_unlock; | |
| 537 | + | } | |
| 538 | + | } | |
| 519 | 539 | cpumask_and(pmask, pmask, cs->effective_cpus); | |
| 540 | + | out_unlock: | |
| 520 | 541 | rcu_read_unlock(); | |
| 521 | 542 | } | |
| 522 | 543 | ||
| @@ -3732,6 +3753,8 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css) | |||
| 3732 | 3753 | mutex_lock(&cpuset_mutex); | |
| 3733 | 3754 | spin_lock_irq(&callback_lock); | |
| 3734 | 3755 | ||
| 3756 | + | WRITE_ONCE(cpuset_v2_mode, | |
| 3757 | + | !!(cpuset_cgrp_subsys.root->flags & CGRP_ROOT_CPUSET_V2_MODE)); | |
| 3735 | 3758 | if (is_in_v2_mode()) { | |
| 3736 | 3759 | cpumask_copy(top_cpuset.cpus_allowed, cpu_possible_mask); | |
| 3737 | 3760 | cpumask_copy(top_cpuset.effective_xcpus, cpu_possible_mask); | |
| @@ -4044,15 +4067,16 @@ static void cpuset_handle_hotplug(void) | |||
| 4044 | 4067 | static cpumask_t new_cpus; | |
| 4045 | 4068 | static nodemask_t new_mems; | |
| 4046 | 4069 | bool cpus_updated, mems_updated; | |
| 4047 | - | bool on_dfl = is_in_v2_mode(); | |
| 4070 | + | bool on_dfl; | |
| 4048 | 4071 | struct tmpmasks tmp, *ptmp = NULL; | |
| 4049 | 4072 | ||
| 4050 | - | if (on_dfl && !alloc_tmpmasks(&tmp)) | |
| 4051 | - | ptmp = &tmp; | |
| 4052 | - | ||
| 4053 | 4073 | lockdep_assert_cpus_held(); | |
| 4054 | 4074 | mutex_lock(&cpuset_mutex); | |
| 4055 | 4075 | ||
| 4076 | + | on_dfl = is_in_v2_mode(); | |
| 4077 | + | if (on_dfl && !alloc_tmpmasks(&tmp)) | |
| 4078 | + | ptmp = &tmp; | |
| 4079 | + | ||
| 4056 | 4080 | /* fetch the available cpus/mems and find out which changed how */ | |
| 4057 | 4081 | cpumask_copy(&new_cpus, cpu_active_mask); | |
| 4058 | 4082 | new_mems = node_states[N_MEMORY]; | |
modified kernel/dma/swiotlb.c
| @@ -1844,10 +1844,10 @@ phys_addr_t default_swiotlb_base(void) | |||
| 1844 | 1844 | phys_addr_t default_swiotlb_limit(void) | |
| 1845 | 1845 | { | |
| 1846 | 1846 | #ifdef CONFIG_SWIOTLB_DYNAMIC | |
| 1847 | - | return io_tlb_default_mem.phys_limit; | |
| 1848 | - | #else | |
| 1849 | - | return io_tlb_default_mem.defpool.end - 1; | |
| 1847 | + | if (io_tlb_default_mem.can_grow) | |
| 1848 | + | return io_tlb_default_mem.phys_limit; | |
| 1850 | 1849 | #endif | |
| 1850 | + | return io_tlb_default_mem.defpool.end - 1; | |
| 1851 | 1851 | } | |
| 1852 | 1852 | ||
| 1853 | 1853 | #ifdef CONFIG_DEBUG_FS | |
modified kernel/events/core.c
| @@ -7626,9 +7626,11 @@ static void perf_sigtrap(struct perf_event *event) | |||
| 7626 | 7626 | { | |
| 7627 | 7627 | /* | |
| 7628 | 7628 | * Both perf_pending_task() and perf_pending_irq() can race with the | |
| 7629 | - | * task exiting. | |
| 7629 | + | * task exiting or exec-ing. We can determine if such a race has | |
| 7630 | + | * occurred by checking if perf_event_exit_task(), which will set | |
| 7631 | + | * ctx->task to TASK_TOMBSTONE, has already been called. | |
| 7630 | 7632 | */ | |
| 7631 | - | if (current->flags & PF_EXITING) | |
| 7633 | + | if (event->ctx->task == TASK_TOMBSTONE) | |
| 7632 | 7634 | return; | |
| 7633 | 7635 | ||
| 7634 | 7636 | /* | |
| @@ -8129,10 +8131,15 @@ static void __perf_event_header__init_id(struct perf_sample_data *data, | |||
| 8129 | 8131 | } | |
| 8130 | 8132 | } | |
| 8131 | 8133 | ||
| 8132 | - | void perf_event_header__init_id(struct perf_event_header *header, | |
| 8133 | - | struct perf_sample_data *data, | |
| 8134 | - | struct perf_event *event) | |
| 8134 | + | void perf_event_header__init(struct perf_event_header *header, | |
| 8135 | + | struct perf_sample_data *data, | |
| 8136 | + | u32 type, u16 misc, u16 size, | |
| 8137 | + | struct perf_event *event) | |
| 8135 | 8138 | { | |
| 8139 | + | header->type = type; | |
| 8140 | + | header->misc = misc; | |
| 8141 | + | header->size = size; | |
| 8142 | + | ||
| 8136 | 8143 | if (event->attr.sample_id_all) { | |
| 8137 | 8144 | header->size += event->id_header_size; | |
| 8138 | 8145 | __perf_event_header__init_id(data, event, event->attr.sample_type); | |
| @@ -8969,17 +8976,16 @@ perf_event_read_event(struct perf_event *event, | |||
| 8969 | 8976 | struct perf_output_handle handle; | |
| 8970 | 8977 | struct perf_sample_data sample; | |
| 8971 | 8978 | struct perf_read_event read_event = { | |
| 8972 | - | .header = { | |
| 8973 | - | .type = PERF_RECORD_READ, | |
| 8974 | - | .misc = 0, | |
| 8975 | - | .size = sizeof(read_event) + event->read_size, | |
| 8976 | - | }, | |
| 8977 | 8979 | .pid = perf_event_pid(event, task), | |
| 8978 | 8980 | .tid = perf_event_tid(event, task), | |
| 8979 | 8981 | }; | |
| 8980 | 8982 | int ret; | |
| 8981 | 8983 | ||
| 8982 | - | perf_event_header__init_id(&read_event.header, &sample, event); | |
| 8984 | + | perf_event_header__init(&read_event.header, &sample, | |
| 8985 | + | PERF_RECORD_READ, | |
| 8986 | + | /* misc= */ 0, | |
| 8987 | + | sizeof(read_event) + event->read_size, | |
| 8988 | + | event); | |
| 8983 | 8989 | ret = perf_output_begin(&handle, &sample, event, read_event.header.size); | |
| 8984 | 8990 | if (ret) | |
| 8985 | 8991 | return; | |
| @@ -9220,6 +9226,7 @@ struct perf_task_event { | |||
| 9220 | 9226 | u32 ptid; | |
| 9221 | 9227 | u64 time; | |
| 9222 | 9228 | } event_id; | |
| 9229 | + | int new; | |
| 9223 | 9230 | }; | |
| 9224 | 9231 | ||
| 9225 | 9232 | static int perf_event_task_match(struct perf_event *event) | |
| @@ -9236,17 +9243,21 @@ static void perf_event_task_output(struct perf_event *event, | |||
| 9236 | 9243 | struct perf_output_handle handle; | |
| 9237 | 9244 | struct perf_sample_data sample; | |
| 9238 | 9245 | struct task_struct *task = task_event->task; | |
| 9239 | - | int ret, size = task_event->event_id.header.size; | |
| 9246 | + | int ret; | |
| 9240 | 9247 | ||
| 9241 | 9248 | if (!perf_event_task_match(event)) | |
| 9242 | 9249 | return; | |
| 9243 | 9250 | ||
| 9244 | - | perf_event_header__init_id(&task_event->event_id.header, &sample, event); | |
| 9251 | + | perf_event_header__init(&task_event->event_id.header, &sample, | |
| 9252 | + | task_event->new ? PERF_RECORD_FORK : PERF_RECORD_EXIT, | |
| 9253 | + | /* misc= */ 0, | |
| 9254 | + | sizeof(task_event->event_id), | |
| 9255 | + | event); | |
| 9245 | 9256 | ||
| 9246 | 9257 | ret = perf_output_begin(&handle, &sample, event, | |
| 9247 | 9258 | task_event->event_id.header.size); | |
| 9248 | 9259 | if (ret) | |
| 9249 | - | goto out; | |
| 9260 | + | return; | |
| 9250 | 9261 | ||
| 9251 | 9262 | task_event->event_id.pid = perf_event_pid(event, task); | |
| 9252 | 9263 | task_event->event_id.tid = perf_event_tid(event, task); | |
| @@ -9268,8 +9279,6 @@ static void perf_event_task_output(struct perf_event *event, | |||
| 9268 | 9279 | perf_event__output_id_sample(event, &handle, &sample); | |
| 9269 | 9280 | ||
| 9270 | 9281 | perf_output_end(&handle); | |
| 9271 | - | out: | |
| 9272 | - | task_event->event_id.header.size = size; | |
| 9273 | 9282 | } | |
| 9274 | 9283 | ||
| 9275 | 9284 | static void perf_event_task(struct task_struct *task, | |
| @@ -9286,18 +9295,7 @@ static void perf_event_task(struct task_struct *task, | |||
| 9286 | 9295 | task_event = (struct perf_task_event){ | |
| 9287 | 9296 | .task = task, | |
| 9288 | 9297 | .task_ctx = task_ctx, | |
| 9289 | - | .event_id = { | |
| 9290 | - | .header = { | |
| 9291 | - | .type = new ? PERF_RECORD_FORK : PERF_RECORD_EXIT, | |
| 9292 | - | .misc = 0, | |
| 9293 | - | .size = sizeof(task_event.event_id), | |
| 9294 | - | }, | |
| 9295 | - | /* .pid */ | |
| 9296 | - | /* .ppid */ | |
| 9297 | - | /* .tid */ | |
| 9298 | - | /* .ptid */ | |
| 9299 | - | /* .time */ | |
| 9300 | - | }, | |
| 9298 | + | .new = new, | |
| 9301 | 9299 | }; | |
| 9302 | 9300 | ||
| 9303 | 9301 | perf_iterate_sb(perf_event_task_output, | |
| @@ -9374,6 +9372,7 @@ struct perf_comm_event { | |||
| 9374 | 9372 | u32 pid; | |
| 9375 | 9373 | u32 tid; | |
| 9376 | 9374 | } event_id; | |
| 9375 | + | bool exec; | |
| 9377 | 9376 | }; | |
| 9378 | 9377 | ||
| 9379 | 9378 | static int perf_event_comm_match(struct perf_event *event) | |
| @@ -9387,18 +9386,21 @@ static void perf_event_comm_output(struct perf_event *event, | |||
| 9387 | 9386 | struct perf_comm_event *comm_event = data; | |
| 9388 | 9387 | struct perf_output_handle handle; | |
| 9389 | 9388 | struct perf_sample_data sample; | |
| 9390 | - | int size = comm_event->event_id.header.size; | |
| 9391 | 9389 | int ret; | |
| 9392 | 9390 | ||
| 9393 | 9391 | if (!perf_event_comm_match(event)) | |
| 9394 | 9392 | return; | |
| 9395 | 9393 | ||
| 9396 | - | perf_event_header__init_id(&comm_event->event_id.header, &sample, event); | |
| 9394 | + | perf_event_header__init(&comm_event->event_id.header, &sample, | |
| 9395 | + | PERF_RECORD_COMM, | |
| 9396 | + | comm_event->exec ? PERF_RECORD_MISC_COMM_EXEC : 0, | |
| 9397 | + | sizeof(comm_event->event_id) + comm_event->comm_size, | |
| 9398 | + | event); | |
| 9397 | 9399 | ret = perf_output_begin(&handle, &sample, event, | |
| 9398 | 9400 | comm_event->event_id.header.size); | |
| 9399 | 9401 | ||
| 9400 | 9402 | if (ret) | |
| 9401 | - | goto out; | |
| 9403 | + | return; | |
| 9402 | 9404 | ||
| 9403 | 9405 | comm_event->event_id.pid = perf_event_pid(event, comm_event->task); | |
| 9404 | 9406 | comm_event->event_id.tid = perf_event_tid(event, comm_event->task); | |
| @@ -9410,8 +9412,6 @@ static void perf_event_comm_output(struct perf_event *event, | |||
| 9410 | 9412 | perf_event__output_id_sample(event, &handle, &sample); | |
| 9411 | 9413 | ||
| 9412 | 9414 | perf_output_end(&handle); | |
| 9413 | - | out: | |
| 9414 | - | comm_event->event_id.header.size = size; | |
| 9415 | 9415 | } | |
| 9416 | 9416 | ||
| 9417 | 9417 | static void perf_event_comm_event(struct perf_comm_event *comm_event) | |
| @@ -9426,8 +9426,6 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event) | |||
| 9426 | 9426 | comm_event->comm = comm; | |
| 9427 | 9427 | comm_event->comm_size = size; | |
| 9428 | 9428 | ||
| 9429 | - | comm_event->event_id.header.size = sizeof(comm_event->event_id) + size; | |
| 9430 | - | ||
| 9431 | 9429 | perf_iterate_sb(perf_event_comm_output, | |
| 9432 | 9430 | comm_event, | |
| 9433 | 9431 | NULL); | |
| @@ -9444,15 +9442,8 @@ void perf_event_comm(struct task_struct *task, bool exec) | |||
| 9444 | 9442 | .task = task, | |
| 9445 | 9443 | /* .comm */ | |
| 9446 | 9444 | /* .comm_size */ | |
| 9447 | - | .event_id = { | |
| 9448 | - | .header = { | |
| 9449 | - | .type = PERF_RECORD_COMM, | |
| 9450 | - | .misc = exec ? PERF_RECORD_MISC_COMM_EXEC : 0, | |
| 9451 | - | /* .size */ | |
| 9452 | - | }, | |
| 9453 | - | /* .pid */ | |
| 9454 | - | /* .tid */ | |
| 9455 | - | }, | |
| 9445 | + | /* .event_id */ | |
| 9446 | + | .exec = exec, | |
| 9456 | 9447 | }; | |
| 9457 | 9448 | ||
| 9458 | 9449 | perf_event_comm_event(&comm_event); | |
| @@ -9486,18 +9477,20 @@ static void perf_event_namespaces_output(struct perf_event *event, | |||
| 9486 | 9477 | struct perf_namespaces_event *namespaces_event = data; | |
| 9487 | 9478 | struct perf_output_handle handle; | |
| 9488 | 9479 | struct perf_sample_data sample; | |
| 9489 | - | u16 header_size = namespaces_event->event_id.header.size; | |
| 9490 | 9480 | int ret; | |
| 9491 | 9481 | ||
| 9492 | 9482 | if (!perf_event_namespaces_match(event)) | |
| 9493 | 9483 | return; | |
| 9494 | 9484 | ||
| 9495 | - | perf_event_header__init_id(&namespaces_event->event_id.header, | |
| 9496 | - | &sample, event); | |
| 9485 | + | perf_event_header__init(&namespaces_event->event_id.header, &sample, | |
| 9486 | + | PERF_RECORD_NAMESPACES, | |
| 9487 | + | /* misc= */ 0, | |
| 9488 | + | sizeof(namespaces_event->event_id), | |
| 9489 | + | event); | |
| 9497 | 9490 | ret = perf_output_begin(&handle, &sample, event, | |
| 9498 | 9491 | namespaces_event->event_id.header.size); | |
| 9499 | 9492 | if (ret) | |
| 9500 | - | goto out; | |
| 9493 | + | return; | |
| 9501 | 9494 | ||
| 9502 | 9495 | namespaces_event->event_id.pid = perf_event_pid(event, | |
| 9503 | 9496 | namespaces_event->task); | |
| @@ -9509,8 +9502,6 @@ static void perf_event_namespaces_output(struct perf_event *event, | |||
| 9509 | 9502 | perf_event__output_id_sample(event, &handle, &sample); | |
| 9510 | 9503 | ||
| 9511 | 9504 | perf_output_end(&handle); | |
| 9512 | - | out: | |
| 9513 | - | namespaces_event->event_id.header.size = header_size; | |
| 9514 | 9505 | } | |
| 9515 | 9506 | ||
| 9516 | 9507 | static void perf_fill_ns_link_info(struct perf_ns_link_info *ns_link_info, | |
| @@ -9541,11 +9532,7 @@ void perf_event_namespaces(struct task_struct *task) | |||
| 9541 | 9532 | namespaces_event = (struct perf_namespaces_event){ | |
| 9542 | 9533 | .task = task, | |
| 9543 | 9534 | .event_id = { | |
| 9544 | - | .header = { | |
| 9545 | - | .type = PERF_RECORD_NAMESPACES, | |
| 9546 | - | .misc = 0, | |
| 9547 | - | .size = sizeof(namespaces_event.event_id), | |
| 9548 | - | }, | |
| 9535 | + | /* .header */ | |
| 9549 | 9536 | /* .pid */ | |
| 9550 | 9537 | /* .tid */ | |
| 9551 | 9538 | .nr_namespaces = NR_NAMESPACES, | |
| @@ -9613,18 +9600,19 @@ static void perf_event_cgroup_output(struct perf_event *event, void *data) | |||
| 9613 | 9600 | struct perf_cgroup_event *cgroup_event = data; | |
| 9614 | 9601 | struct perf_output_handle handle; | |
| 9615 | 9602 | struct perf_sample_data sample; | |
| 9616 | - | u16 header_size = cgroup_event->event_id.header.size; | |
| 9617 | 9603 | int ret; | |
| 9604 | + | u16 size = sizeof(cgroup_event->event_id) + cgroup_event->path_size; | |
| 9618 | 9605 | ||
| 9619 | 9606 | if (!perf_event_cgroup_match(event)) | |
| 9620 | 9607 | return; | |
| 9621 | 9608 | ||
| 9622 | - | perf_event_header__init_id(&cgroup_event->event_id.header, | |
| 9623 | - | &sample, event); | |
| 9609 | + | perf_event_header__init(&cgroup_event->event_id.header, &sample, | |
| 9610 | + | PERF_RECORD_CGROUP, /* misc= */ 0, size, | |
| 9611 | + | event); | |
| 9624 | 9612 | ret = perf_output_begin(&handle, &sample, event, | |
| 9625 | 9613 | cgroup_event->event_id.header.size); | |
| 9626 | 9614 | if (ret) | |
| 9627 | - | goto out; | |
| 9615 | + | return; | |
| 9628 | 9616 | ||
| 9629 | 9617 | perf_output_put(&handle, cgroup_event->event_id); | |
| 9630 | 9618 | __output_copy(&handle, cgroup_event->path, cgroup_event->path_size); | |
| @@ -9632,8 +9620,6 @@ static void perf_event_cgroup_output(struct perf_event *event, void *data) | |||
| 9632 | 9620 | perf_event__output_id_sample(event, &handle, &sample); | |
| 9633 | 9621 | ||
| 9634 | 9622 | perf_output_end(&handle); | |
| 9635 | - | out: | |
| 9636 | - | cgroup_event->event_id.header.size = header_size; | |
| 9637 | 9623 | } | |
| 9638 | 9624 | ||
| 9639 | 9625 | static void perf_event_cgroup(struct cgroup *cgrp) | |
| @@ -9648,11 +9634,6 @@ static void perf_event_cgroup(struct cgroup *cgrp) | |||
| 9648 | 9634 | ||
| 9649 | 9635 | cgroup_event = (struct perf_cgroup_event){ | |
| 9650 | 9636 | .event_id = { | |
| 9651 | - | .header = { | |
| 9652 | - | .type = PERF_RECORD_CGROUP, | |
| 9653 | - | .misc = 0, | |
| 9654 | - | .size = sizeof(cgroup_event.event_id), | |
| 9655 | - | }, | |
| 9656 | 9637 | .id = cgroup_id(cgrp), | |
| 9657 | 9638 | }, | |
| 9658 | 9639 | }; | |
| @@ -9675,7 +9656,6 @@ static void perf_event_cgroup(struct cgroup *cgrp) | |||
| 9675 | 9656 | while (!IS_ALIGNED(size, sizeof(u64))) | |
| 9676 | 9657 | cgroup_event.path[size++] = '\0'; | |
| 9677 | 9658 | ||
| 9678 | - | cgroup_event.event_id.header.size += size; | |
| 9679 | 9659 | cgroup_event.path_size = size; | |
| 9680 | 9660 | ||
| 9681 | 9661 | perf_iterate_sb(perf_event_cgroup_output, | |
| @@ -9731,38 +9711,40 @@ static void perf_event_mmap_output(struct perf_event *event, | |||
| 9731 | 9711 | struct perf_mmap_event *mmap_event = data; | |
| 9732 | 9712 | struct perf_output_handle handle; | |
| 9733 | 9713 | struct perf_sample_data sample; | |
| 9734 | - | int size = mmap_event->event_id.header.size; | |
| 9735 | - | u32 type = mmap_event->event_id.header.type; | |
| 9736 | - | bool use_build_id; | |
| 9714 | + | int size = sizeof(mmap_event->event_id) + mmap_event->file_size; | |
| 9715 | + | u32 type = PERF_RECORD_MMAP; | |
| 9716 | + | u16 misc = PERF_RECORD_MISC_USER; | |
| 9717 | + | bool use_build_id = false; | |
| 9737 | 9718 | int ret; | |
| 9738 | 9719 | ||
| 9739 | 9720 | if (!perf_event_mmap_match(event, data)) | |
| 9740 | 9721 | return; | |
| 9741 | 9722 | ||
| 9742 | 9723 | if (event->attr.mmap2) { | |
| 9743 | - | mmap_event->event_id.header.type = PERF_RECORD_MMAP2; | |
| 9744 | - | mmap_event->event_id.header.size += sizeof(mmap_event->maj); | |
| 9745 | - | mmap_event->event_id.header.size += sizeof(mmap_event->min); | |
| 9746 | - | mmap_event->event_id.header.size += sizeof(mmap_event->ino); | |
| 9747 | - | mmap_event->event_id.header.size += sizeof(mmap_event->ino_generation); | |
| 9748 | - | mmap_event->event_id.header.size += sizeof(mmap_event->prot); | |
| 9749 | - | mmap_event->event_id.header.size += sizeof(mmap_event->flags); | |
| 9750 | - | } | |
| 9751 | - | ||
| 9752 | - | perf_event_header__init_id(&mmap_event->event_id.header, &sample, event); | |
| 9724 | + | type = PERF_RECORD_MMAP2; | |
| 9725 | + | size += sizeof(mmap_event->maj); | |
| 9726 | + | size += sizeof(mmap_event->min); | |
| 9727 | + | size += sizeof(mmap_event->ino); | |
| 9728 | + | size += sizeof(mmap_event->ino_generation); | |
| 9729 | + | size += sizeof(mmap_event->prot); | |
| 9730 | + | size += sizeof(mmap_event->flags); | |
| 9731 | + | use_build_id = event->attr.build_id && mmap_event->build_id_size; | |
| 9732 | + | if (use_build_id) | |
| 9733 | + | misc |= PERF_RECORD_MISC_MMAP_BUILD_ID; | |
| 9734 | + | } | |
| 9735 | + | if (!(mmap_event->vma->vm_flags & VM_EXEC)) | |
| 9736 | + | misc |= PERF_RECORD_MISC_MMAP_DATA; | |
| 9737 | + | ||
| 9738 | + | perf_event_header__init(&mmap_event->event_id.header, &sample, | |
| 9739 | + | type, misc, size, event); | |
| 9753 | 9740 | ret = perf_output_begin(&handle, &sample, event, | |
| 9754 | 9741 | mmap_event->event_id.header.size); | |
| 9755 | 9742 | if (ret) | |
| 9756 | - | goto out; | |
| 9743 | + | return; | |
| 9757 | 9744 | ||
| 9758 | 9745 | mmap_event->event_id.pid = perf_event_pid(event, current); | |
| 9759 | 9746 | mmap_event->event_id.tid = perf_event_tid(event, current); | |
| 9760 | 9747 | ||
| 9761 | - | use_build_id = event->attr.build_id && mmap_event->build_id_size; | |
| 9762 | - | ||
| 9763 | - | if (event->attr.mmap2 && use_build_id) | |
| 9764 | - | mmap_event->event_id.header.misc |= PERF_RECORD_MISC_MMAP_BUILD_ID; | |
| 9765 | - | ||
| 9766 | 9748 | perf_output_put(&handle, mmap_event->event_id); | |
| 9767 | 9749 | ||
| 9768 | 9750 | if (event->attr.mmap2) { | |
| @@ -9787,9 +9769,6 @@ static void perf_event_mmap_output(struct perf_event *event, | |||
| 9787 | 9769 | perf_event__output_id_sample(event, &handle, &sample); | |
| 9788 | 9770 | ||
| 9789 | 9771 | perf_output_end(&handle); | |
| 9790 | - | out: | |
| 9791 | - | mmap_event->event_id.header.size = size; | |
| 9792 | - | mmap_event->event_id.header.type = type; | |
| 9793 | 9772 | } | |
| 9794 | 9773 | ||
| 9795 | 9774 | static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) | |
| @@ -9885,11 +9864,6 @@ got_name: | |||
| 9885 | 9864 | mmap_event->prot = prot; | |
| 9886 | 9865 | mmap_event->flags = flags; | |
| 9887 | 9866 | ||
| 9888 | - | if (!(vma->vm_flags & VM_EXEC)) | |
| 9889 | - | mmap_event->event_id.header.misc |= PERF_RECORD_MISC_MMAP_DATA; | |
| 9890 | - | ||
| 9891 | - | mmap_event->event_id.header.size = sizeof(mmap_event->event_id) + size; | |
| 9892 | - | ||
| 9893 | 9867 | if (atomic_read(&nr_build_id_events)) | |
| 9894 | 9868 | build_id_parse_nofault(vma, mmap_event->build_id, &mmap_event->build_id_size); | |
| 9895 | 9869 | ||
| @@ -10009,11 +9983,7 @@ void perf_event_mmap(struct vm_area_struct *vma) | |||
| 10009 | 9983 | /* .file_name */ | |
| 10010 | 9984 | /* .file_size */ | |
| 10011 | 9985 | .event_id = { | |
| 10012 | - | .header = { | |
| 10013 | - | .type = PERF_RECORD_MMAP, | |
| 10014 | - | .misc = PERF_RECORD_MISC_USER, | |
| 10015 | - | /* .size */ | |
| 10016 | - | }, | |
| 9986 | + | /* .header */ | |
| 10017 | 9987 | /* .pid */ | |
| 10018 | 9988 | /* .tid */ | |
| 10019 | 9989 | .start = vma->vm_start, | |
| @@ -10043,18 +10013,15 @@ void perf_event_aux_event(struct perf_event *event, unsigned long head, | |||
| 10043 | 10013 | u64 size; | |
| 10044 | 10014 | u64 flags; | |
| 10045 | 10015 | } rec = { | |
| 10046 | - | .header = { | |
| 10047 | - | .type = PERF_RECORD_AUX, | |
| 10048 | - | .misc = 0, | |
| 10049 | - | .size = sizeof(rec), | |
| 10050 | - | }, | |
| 10051 | 10016 | .offset = head, | |
| 10052 | 10017 | .size = size, | |
| 10053 | 10018 | .flags = flags, | |
| 10054 | 10019 | }; | |
| 10055 | 10020 | int ret; | |
| 10056 | 10021 | ||
| 10057 | - | perf_event_header__init_id(&rec.header, &sample, event); | |
| 10022 | + | perf_event_header__init(&rec.header, &sample, | |
| 10023 | + | PERF_RECORD_AUX, /* misc= */ 0, sizeof(rec), | |
| 10024 | + | event); | |
| 10058 | 10025 | ret = perf_output_begin(&handle, &sample, event, rec.header.size); | |
| 10059 | 10026 | ||
| 10060 | 10027 | if (ret) | |
| @@ -10079,15 +10046,14 @@ void perf_log_lost_samples(struct perf_event *event, u64 lost) | |||
| 10079 | 10046 | struct perf_event_header header; | |
| 10080 | 10047 | u64 lost; | |
| 10081 | 10048 | } lost_samples_event = { | |
| 10082 | - | .header = { | |
| 10083 | - | .type = PERF_RECORD_LOST_SAMPLES, | |
| 10084 | - | .misc = 0, | |
| 10085 | - | .size = sizeof(lost_samples_event), | |
| 10086 | - | }, | |
| 10087 | 10049 | .lost = lost, | |
| 10088 | 10050 | }; | |
| 10089 | 10051 | ||
| 10090 | - | perf_event_header__init_id(&lost_samples_event.header, &sample, event); | |
| 10052 | + | perf_event_header__init(&lost_samples_event.header, &sample, | |
| 10053 | + | PERF_RECORD_LOST_SAMPLES, | |
| 10054 | + | /* misc= */ 0, | |
| 10055 | + | sizeof(lost_samples_event), | |
| 10056 | + | event); | |
| 10091 | 10057 | ||
| 10092 | 10058 | ret = perf_output_begin(&handle, &sample, event, | |
| 10093 | 10059 | lost_samples_event.header.size); | |
| @@ -10112,6 +10078,8 @@ struct perf_switch_event { | |||
| 10112 | 10078 | u32 next_prev_pid; | |
| 10113 | 10079 | u32 next_prev_tid; | |
| 10114 | 10080 | } event_id; | |
| 10081 | + | bool sched_in; | |
| 10082 | + | bool preempt; | |
| 10115 | 10083 | }; | |
| 10116 | 10084 | ||
| 10117 | 10085 | static int perf_event_switch_match(struct perf_event *event) | |
| @@ -10124,6 +10092,9 @@ static void perf_event_switch_output(struct perf_event *event, void *data) | |||
| 10124 | 10092 | struct perf_switch_event *se = data; | |
| 10125 | 10093 | struct perf_output_handle handle; | |
| 10126 | 10094 | struct perf_sample_data sample; | |
| 10095 | + | u32 type; | |
| 10096 | + | u16 misc; | |
| 10097 | + | u16 size; | |
| 10127 | 10098 | int ret; | |
| 10128 | 10099 | ||
| 10129 | 10100 | if (!perf_event_switch_match(event)) | |
| @@ -10131,18 +10102,22 @@ static void perf_event_switch_output(struct perf_event *event, void *data) | |||
| 10131 | 10102 | ||
| 10132 | 10103 | /* Only CPU-wide events are allowed to see next/prev pid/tid */ | |
| 10133 | 10104 | if (event->ctx->task) { | |
| 10134 | - | se->event_id.header.type = PERF_RECORD_SWITCH; | |
| 10135 | - | se->event_id.header.size = sizeof(se->event_id.header); | |
| 10105 | + | type = PERF_RECORD_SWITCH; | |
| 10106 | + | size = sizeof(se->event_id.header); | |
| 10136 | 10107 | } else { | |
| 10137 | - | se->event_id.header.type = PERF_RECORD_SWITCH_CPU_WIDE; | |
| 10138 | - | se->event_id.header.size = sizeof(se->event_id); | |
| 10108 | + | type = PERF_RECORD_SWITCH_CPU_WIDE; | |
| 10109 | + | size = sizeof(se->event_id); | |
| 10139 | 10110 | se->event_id.next_prev_pid = | |
| 10140 | 10111 | perf_event_pid(event, se->next_prev); | |
| 10141 | 10112 | se->event_id.next_prev_tid = | |
| 10142 | 10113 | perf_event_tid(event, se->next_prev); | |
| 10143 | 10114 | } | |
| 10115 | + | misc = se->sched_in ? 0 : PERF_RECORD_MISC_SWITCH_OUT; | |
| 10116 | + | if (se->preempt) | |
| 10117 | + | misc |= PERF_RECORD_MISC_SWITCH_OUT_PREEMPT; | |
| 10144 | 10118 | ||
| 10145 | - | perf_event_header__init_id(&se->event_id.header, &sample, event); | |
| 10119 | + | perf_event_header__init(&se->event_id.header, &sample, | |
| 10120 | + | type, misc, size, event); | |
| 10146 | 10121 | ||
| 10147 | 10122 | ret = perf_output_begin(&handle, &sample, event, se->event_id.header.size); | |
| 10148 | 10123 | if (ret) | |
| @@ -10168,22 +10143,11 @@ static void perf_event_switch(struct task_struct *task, | |||
| 10168 | 10143 | switch_event = (struct perf_switch_event){ | |
| 10169 | 10144 | .task = task, | |
| 10170 | 10145 | .next_prev = next_prev, | |
| 10171 | - | .event_id = { | |
| 10172 | - | .header = { | |
| 10173 | - | /* .type */ | |
| 10174 | - | .misc = sched_in ? 0 : PERF_RECORD_MISC_SWITCH_OUT, | |
| 10175 | - | /* .size */ | |
| 10176 | - | }, | |
| 10177 | - | /* .next_prev_pid */ | |
| 10178 | - | /* .next_prev_tid */ | |
| 10179 | - | }, | |
| 10146 | + | /* .event_id */ | |
| 10147 | + | .sched_in = sched_in, | |
| 10148 | + | .preempt = !sched_in && task_is_runnable(task), | |
| 10180 | 10149 | }; | |
| 10181 | 10150 | ||
| 10182 | - | if (!sched_in && task_is_runnable(task)) { | |
| 10183 | - | switch_event.event_id.header.misc |= | |
| 10184 | - | PERF_RECORD_MISC_SWITCH_OUT_PREEMPT; | |
| 10185 | - | } | |
| 10186 | - | ||
| 10187 | 10151 | perf_iterate_sb(perf_event_switch_output, &switch_event, NULL); | |
| 10188 | 10152 | } | |
| 10189 | 10153 | ||
| @@ -10203,20 +10167,17 @@ static void perf_log_throttle(struct perf_event *event, int enable) | |||
| 10203 | 10167 | u64 id; | |
| 10204 | 10168 | u64 stream_id; | |
| 10205 | 10169 | } throttle_event = { | |
| 10206 | - | .header = { | |
| 10207 | - | .type = PERF_RECORD_THROTTLE, | |
| 10208 | - | .misc = 0, | |
| 10209 | - | .size = sizeof(throttle_event), | |
| 10210 | - | }, | |
| 10211 | 10170 | .time = perf_event_clock(event), | |
| 10212 | 10171 | .id = primary_event_id(event), | |
| 10213 | 10172 | .stream_id = event->id, | |
| 10214 | 10173 | }; | |
| 10215 | 10174 | ||
| 10216 | - | if (enable) | |
| 10217 | - | throttle_event.header.type = PERF_RECORD_UNTHROTTLE; | |
| 10218 | - | ||
| 10219 | - | perf_event_header__init_id(&throttle_event.header, &sample, event); | |
| 10175 | + | perf_event_header__init(&throttle_event.header, &sample, | |
| 10176 | + | enable ? PERF_RECORD_UNTHROTTLE | |
| 10177 | + | : PERF_RECORD_THROTTLE, | |
| 10178 | + | /* misc= */ 0, | |
| 10179 | + | sizeof(throttle_event), | |
| 10180 | + | event); | |
| 10220 | 10181 | ||
| 10221 | 10182 | ret = perf_output_begin(&handle, &sample, event, | |
| 10222 | 10183 | throttle_event.header.size); | |
| @@ -10255,12 +10216,14 @@ static void perf_event_ksymbol_output(struct perf_event *event, void *data) | |||
| 10255 | 10216 | struct perf_output_handle handle; | |
| 10256 | 10217 | struct perf_sample_data sample; | |
| 10257 | 10218 | int ret; | |
| 10219 | + | u16 size = sizeof(ksymbol_event->event_id) + ksymbol_event->name_len; | |
| 10258 | 10220 | ||
| 10259 | 10221 | if (!perf_event_ksymbol_match(event)) | |
| 10260 | 10222 | return; | |
| 10261 | 10223 | ||
| 10262 | - | perf_event_header__init_id(&ksymbol_event->event_id.header, | |
| 10263 | - | &sample, event); | |
| 10224 | + | perf_event_header__init(&ksymbol_event->event_id.header, &sample, | |
| 10225 | + | PERF_RECORD_KSYMBOL, /* misc= */ 0, size, | |
| 10226 | + | event); | |
| 10264 | 10227 | ret = perf_output_begin(&handle, &sample, event, | |
| 10265 | 10228 | ksymbol_event->event_id.header.size); | |
| 10266 | 10229 | if (ret) | |
| @@ -10301,11 +10264,6 @@ void perf_event_ksymbol(u16 ksym_type, u64 addr, u32 len, bool unregister, | |||
| 10301 | 10264 | .name = name, | |
| 10302 | 10265 | .name_len = name_len, | |
| 10303 | 10266 | .event_id = { | |
| 10304 | - | .header = { | |
| 10305 | - | .type = PERF_RECORD_KSYMBOL, | |
| 10306 | - | .size = sizeof(ksymbol_event.event_id) + | |
| 10307 | - | name_len, | |
| 10308 | - | }, | |
| 10309 | 10267 | .addr = addr, | |
| 10310 | 10268 | .len = len, | |
| 10311 | 10269 | .ksym_type = ksym_type, | |
| @@ -10349,8 +10307,11 @@ static void perf_event_bpf_output(struct perf_event *event, void *data) | |||
| 10349 | 10307 | if (!perf_event_bpf_match(event)) | |
| 10350 | 10308 | return; | |
| 10351 | 10309 | ||
| 10352 | - | perf_event_header__init_id(&bpf_event->event_id.header, | |
| 10353 | - | &sample, event); | |
| 10310 | + | perf_event_header__init(&bpf_event->event_id.header, &sample, | |
| 10311 | + | PERF_RECORD_BPF_EVENT, | |
| 10312 | + | /* misc= */ 0, | |
| 10313 | + | sizeof(bpf_event->event_id), | |
| 10314 | + | event); | |
| 10354 | 10315 | ret = perf_output_begin(&handle, &sample, event, | |
| 10355 | 10316 | bpf_event->event_id.header.size); | |
| 10356 | 10317 | if (ret) | |
| @@ -10406,10 +10367,6 @@ void perf_event_bpf_event(struct bpf_prog *prog, | |||
| 10406 | 10367 | bpf_event = (struct perf_bpf_event){ | |
| 10407 | 10368 | .prog = prog, | |
| 10408 | 10369 | .event_id = { | |
| 10409 | - | .header = { | |
| 10410 | - | .type = PERF_RECORD_BPF_EVENT, | |
| 10411 | - | .size = sizeof(bpf_event.event_id), | |
| 10412 | - | }, | |
| 10413 | 10370 | .type = type, | |
| 10414 | 10371 | .flags = flags, | |
| 10415 | 10372 | .id = prog->aux->id, | |
| @@ -10437,18 +10394,23 @@ static void perf_callchain_deferred_output(struct perf_event *event, void *data) | |||
| 10437 | 10394 | struct perf_callchain_deferred_event *deferred_event = data; | |
| 10438 | 10395 | struct perf_output_handle handle; | |
| 10439 | 10396 | struct perf_sample_data sample; | |
| 10440 | - | int ret, size = deferred_event->event.header.size; | |
| 10397 | + | int ret; | |
| 10398 | + | u16 size = sizeof(deferred_event->event) + (deferred_event->trace->nr * sizeof(u64)); | |
| 10441 | 10399 | ||
| 10442 | 10400 | if (!event->attr.defer_output) | |
| 10443 | 10401 | return; | |
| 10444 | 10402 | ||
| 10445 | 10403 | /* XXX do we really need sample_id_all for this ??? */ | |
| 10446 | - | perf_event_header__init_id(&deferred_event->event.header, &sample, event); | |
| 10404 | + | perf_event_header__init(&deferred_event->event.header, &sample, | |
| 10405 | + | PERF_RECORD_CALLCHAIN_DEFERRED, | |
| 10406 | + | PERF_RECORD_MISC_USER, | |
| 10407 | + | size, | |
| 10408 | + | event); | |
| 10447 | 10409 | ||
| 10448 | 10410 | ret = perf_output_begin(&handle, &sample, event, | |
| 10449 | 10411 | deferred_event->event.header.size); | |
| 10450 | 10412 | if (ret) | |
| 10451 | - | goto out; | |
| 10413 | + | return; | |
| 10452 | 10414 | ||
| 10453 | 10415 | perf_output_put(&handle, deferred_event->event); | |
| 10454 | 10416 | for (int i = 0; i < deferred_event->trace->nr; i++) { | |
| @@ -10458,8 +10420,6 @@ static void perf_callchain_deferred_output(struct perf_event *event, void *data) | |||
| 10458 | 10420 | perf_event__output_id_sample(event, &handle, &sample); | |
| 10459 | 10421 | ||
| 10460 | 10422 | perf_output_end(&handle); | |
| 10461 | - | out: | |
| 10462 | - | deferred_event->event.header.size = size; | |
| 10463 | 10423 | } | |
| 10464 | 10424 | ||
| 10465 | 10425 | static void perf_unwind_deferred_callback(struct unwind_work *work, | |
| @@ -10468,12 +10428,6 @@ static void perf_unwind_deferred_callback(struct unwind_work *work, | |||
| 10468 | 10428 | struct perf_callchain_deferred_event deferred_event = { | |
| 10469 | 10429 | .trace = trace, | |
| 10470 | 10430 | .event = { | |
| 10471 | - | .header = { | |
| 10472 | - | .type = PERF_RECORD_CALLCHAIN_DEFERRED, | |
| 10473 | - | .misc = PERF_RECORD_MISC_USER, | |
| 10474 | - | .size = sizeof(deferred_event.event) + | |
| 10475 | - | (trace->nr * sizeof(u64)), | |
| 10476 | - | }, | |
| 10477 | 10431 | .cookie = cookie, | |
| 10478 | 10432 | .nr = trace->nr, | |
| 10479 | 10433 | }, | |
| @@ -10485,7 +10439,8 @@ static void perf_unwind_deferred_callback(struct unwind_work *work, | |||
| 10485 | 10439 | struct perf_text_poke_event { | |
| 10486 | 10440 | const void *old_bytes; | |
| 10487 | 10441 | const void *new_bytes; | |
| 10488 | - | size_t pad; | |
| 10442 | + | u16 tot; | |
| 10443 | + | u16 pad; | |
| 10489 | 10444 | u16 old_len; | |
| 10490 | 10445 | u16 new_len; | |
| 10491 | 10446 | ||
| @@ -10506,13 +10461,18 @@ static void perf_event_text_poke_output(struct perf_event *event, void *data) | |||
| 10506 | 10461 | struct perf_text_poke_event *text_poke_event = data; | |
| 10507 | 10462 | struct perf_output_handle handle; | |
| 10508 | 10463 | struct perf_sample_data sample; | |
| 10464 | + | u16 size = sizeof(text_poke_event->event_id) + text_poke_event->tot + text_poke_event->pad; | |
| 10509 | 10465 | u64 padding = 0; | |
| 10510 | 10466 | int ret; | |
| 10511 | 10467 | ||
| 10512 | 10468 | if (!perf_event_text_poke_match(event)) | |
| 10513 | 10469 | return; | |
| 10514 | 10470 | ||
| 10515 | - | perf_event_header__init_id(&text_poke_event->event_id.header, &sample, event); | |
| 10471 | + | perf_event_header__init(&text_poke_event->event_id.header, &sample, | |
| 10472 | + | PERF_RECORD_TEXT_POKE, | |
| 10473 | + | PERF_RECORD_MISC_KERNEL, | |
| 10474 | + | size, | |
| 10475 | + | event); | |
| 10516 | 10476 | ||
| 10517 | 10477 | ret = perf_output_begin(&handle, &sample, event, | |
| 10518 | 10478 | text_poke_event->event_id.header.size); | |
| @@ -10550,15 +10510,11 @@ void perf_event_text_poke(const void *addr, const void *old_bytes, | |||
| 10550 | 10510 | text_poke_event = (struct perf_text_poke_event){ | |
| 10551 | 10511 | .old_bytes = old_bytes, | |
| 10552 | 10512 | .new_bytes = new_bytes, | |
| 10513 | + | .tot = tot, | |
| 10553 | 10514 | .pad = pad, | |
| 10554 | 10515 | .old_len = old_len, | |
| 10555 | 10516 | .new_len = new_len, | |
| 10556 | 10517 | .event_id = { | |
| 10557 | - | .header = { | |
| 10558 | - | .type = PERF_RECORD_TEXT_POKE, | |
| 10559 | - | .misc = PERF_RECORD_MISC_KERNEL, | |
| 10560 | - | .size = sizeof(text_poke_event.event_id) + tot + pad, | |
| 10561 | - | }, | |
| 10562 | 10518 | .addr = (unsigned long)addr, | |
| 10563 | 10519 | }, | |
| 10564 | 10520 | }; | |
| @@ -10589,13 +10545,12 @@ static void perf_log_itrace_start(struct perf_event *event) | |||
| 10589 | 10545 | event->attach_state & PERF_ATTACH_ITRACE) | |
| 10590 | 10546 | return; | |
| 10591 | 10547 | ||
| 10592 | - | rec.header.type = PERF_RECORD_ITRACE_START; | |
| 10593 | - | rec.header.misc = 0; | |
| 10594 | - | rec.header.size = sizeof(rec); | |
| 10595 | 10548 | rec.pid = perf_event_pid(event, current); | |
| 10596 | 10549 | rec.tid = perf_event_tid(event, current); | |
| 10597 | 10550 | ||
| 10598 | - | perf_event_header__init_id(&rec.header, &sample, event); | |
| 10551 | + | perf_event_header__init(&rec.header, &sample, | |
| 10552 | + | PERF_RECORD_ITRACE_START, /* misc= */ 0, sizeof(rec), | |
| 10553 | + | event); | |
| 10599 | 10554 | ret = perf_output_begin(&handle, &sample, event, rec.header.size); | |
| 10600 | 10555 | ||
| 10601 | 10556 | if (ret) | |
| @@ -10620,12 +10575,10 @@ void perf_report_aux_output_id(struct perf_event *event, u64 hw_id) | |||
| 10620 | 10575 | if (event->parent) | |
| 10621 | 10576 | event = event->parent; | |
| 10622 | 10577 | ||
| 10623 | - | rec.header.type = PERF_RECORD_AUX_OUTPUT_HW_ID; | |
| 10624 | - | rec.header.misc = 0; | |
| 10625 | - | rec.header.size = sizeof(rec); | |
| 10626 | - | rec.hw_id = hw_id; | |
| 10627 | - | ||
| 10628 | - | perf_event_header__init_id(&rec.header, &sample, event); | |
| 10578 | + | rec.hw_id = hw_id; | |
| 10579 | + | perf_event_header__init(&rec.header, &sample, | |
| 10580 | + | PERF_RECORD_AUX_OUTPUT_HW_ID, /* misc= */ 0, | |
| 10581 | + | sizeof(rec), event); | |
| 10629 | 10582 | ret = perf_output_begin(&handle, &sample, event, rec.header.size); | |
| 10630 | 10583 | ||
| 10631 | 10584 | if (ret) | |
| @@ -13953,7 +13906,7 @@ SYSCALL_DEFINE5(perf_event_open, | |||
| 13953 | 13906 | if (err) | |
| 13954 | 13907 | return err; | |
| 13955 | 13908 | ||
| 13956 | - | if (!attr.exclude_kernel || | |
| 13909 | + | if (!attr.exclude_kernel || attr.text_poke || | |
| 13957 | 13910 | ((attr.sample_type & PERF_SAMPLE_CALLCHAIN) && | |
| 13958 | 13911 | !attr.exclude_callchain_kernel)) { | |
| 13959 | 13912 | err = perf_allow_kernel(); | |
modified kernel/events/ring_buffer.c
| @@ -246,14 +246,13 @@ __perf_output_begin(struct perf_output_handle *handle, | |||
| 246 | 246 | handle->size = (1UL << page_shift) - offset; | |
| 247 | 247 | ||
| 248 | 248 | if (unlikely(have_lost)) { | |
| 249 | - | lost_event.header.size = sizeof(lost_event); | |
| 250 | - | lost_event.header.type = PERF_RECORD_LOST; | |
| 251 | - | lost_event.header.misc = 0; | |
| 252 | 249 | lost_event.id = event->id; | |
| 253 | 250 | lost_event.lost = local_xchg(&rb->lost, 0); | |
| 254 | 251 | ||
| 255 | 252 | /* XXX mostly redundant; @data is already fully initializes */ | |
| 256 | - | perf_event_header__init_id(&lost_event.header, data, event); | |
| 253 | + | perf_event_header__init(&lost_event.header, data, | |
| 254 | + | PERF_RECORD_LOST, /* misc= */ 0, | |
| 255 | + | sizeof(lost_event), event); | |
| 257 | 256 | perf_output_put(handle, lost_event); | |
| 258 | 257 | perf_event__output_id_sample(event, handle, data); | |
| 259 | 258 | } | |
modified kernel/fork.c
| @@ -3317,14 +3317,17 @@ int ksys_unshare(unsigned long unshare_flags) | |||
| 3317 | 3317 | shm_init_task(current); | |
| 3318 | 3318 | } | |
| 3319 | 3319 | ||
| 3320 | + | if (new_fs) { | |
| 3321 | + | new_fs = switch_fs_struct(new_fs); | |
| 3322 | + | if (new_fs) | |
| 3323 | + | free_fs_struct(no_free_ptr(new_fs)); | |
| 3324 | + | } | |
| 3325 | + | ||
| 3320 | 3326 | if (new_nsproxy) { | |
| 3321 | 3327 | switch_task_namespaces(current, new_nsproxy); | |
| 3322 | 3328 | new_nsproxy = NULL; | |
| 3323 | 3329 | } | |
| 3324 | 3330 | ||
| 3325 | - | if (new_fs) | |
| 3326 | - | new_fs = switch_fs_struct(new_fs); | |
| 3327 | - | ||
| 3328 | 3331 | if (new_fd) { | |
| 3329 | 3332 | guard(task_lock)(current); | |
| 3330 | 3333 | swap(current->files, new_fd); | |
| @@ -3340,8 +3343,9 @@ int ksys_unshare(unsigned long unshare_flags) | |||
| 3340 | 3343 | perf_event_namespaces(current); | |
| 3341 | 3344 | ||
| 3342 | 3345 | bad_unshare_cleanup_nsproxy: | |
| 3346 | + | /* never installed, so no active references to drop */ | |
| 3343 | 3347 | if (new_nsproxy) | |
| 3344 | - | put_nsproxy(new_nsproxy); | |
| 3348 | + | nsproxy_free(new_nsproxy); | |
| 3345 | 3349 | bad_unshare_cleanup_cred: | |
| 3346 | 3350 | if (new_cred) | |
| 3347 | 3351 | put_cred(new_cred); | |
modified kernel/futex/core.c
| @@ -213,10 +213,12 @@ static bool __futex_pivot_hash(struct mm_struct *mm, struct futex_private_hash * | |||
| 213 | 213 | futex_rehash_private(fph, new); | |
| 214 | 214 | } | |
| 215 | 215 | new->state = FR_PERCPU; | |
| 216 | - | scoped_guard(rcu) { | |
| 217 | - | mmph->batches = get_state_synchronize_rcu(); | |
| 218 | - | rcu_assign_pointer(mmph->hash, new); | |
| 219 | - | } | |
| 216 | + | rcu_assign_pointer(mmph->hash, new); | |
| 217 | + | /* | |
| 218 | + | * mmph->batches must reference a grace period which started after | |
| 219 | + | * mmph->hash was assigned. See futex_ref_drop(). | |
| 220 | + | */ | |
| 221 | + | mmph->batches = get_state_synchronize_rcu(); | |
| 220 | 222 | kvfree_rcu(fph, rcu); | |
| 221 | 223 | return true; | |
| 222 | 224 | } | |
modified kernel/irq/Kconfig
| @@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST | |||
| 150 | 150 | ||
| 151 | 151 | If unsure, say N. | |
| 152 | 152 | ||
| 153 | + | config REFCOUNT_INTERRUPT_KUNIT_TEST | |
| 154 | + | tristate "Test refcounted interrupt enable/disable" if !KUNIT_ALL_TESTS | |
| 155 | + | depends on KUNIT | |
| 156 | + | default KUNIT_ALL_TESTS | |
| 157 | + | help | |
| 158 | + | This builds the kunit tests for the refcounted interrupt | |
| 159 | + | infrastructure. It verifies the correctness of single, nested, | |
| 160 | + | and multiple interrupt enable/disable state changes and ensures | |
| 161 | + | that the underlying reference counting mechanisms work as expected. | |
| 162 | + | ||
| 163 | + | If unsure, say N. | |
| 164 | + | ||
| 153 | 165 | endmenu | |
| 154 | 166 | ||
| 155 | 167 | config GENERIC_IRQ_MULTI_HANDLER | |
modified kernel/irq/Makefile
| @@ -16,4 +16,4 @@ obj-$(CONFIG_SMP) += affinity.o | |||
| 16 | 16 | obj-$(CONFIG_GENERIC_IRQ_DEBUGFS) += debugfs.o | |
| 17 | 17 | obj-$(CONFIG_GENERIC_IRQ_MATRIX_ALLOCATOR) += matrix.o | |
| 18 | 18 | obj-$(CONFIG_IRQ_KUNIT_TEST) += irq_test.o | |
| 19 | - | obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o | |
| 19 | + | obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o | |
modified kernel/kprobes.c
| @@ -496,14 +496,16 @@ static bool kprobe_queued(struct kprobe *p) | |||
| 496 | 496 | static struct kprobe *get_optimized_kprobe(kprobe_opcode_t *addr) | |
| 497 | 497 | { | |
| 498 | 498 | int i; | |
| 499 | - | struct kprobe *p = NULL; | |
| 499 | + | struct kprobe *p; | |
| 500 | 500 | struct optimized_kprobe *op; | |
| 501 | 501 | ||
| 502 | 502 | /* Don't check i == 0, since that is a breakpoint case. */ | |
| 503 | - | for (i = 1; !p && i < MAX_OPTIMIZED_LENGTH / sizeof(kprobe_opcode_t); i++) | |
| 503 | + | for (i = 1; i < MAX_OPTIMIZED_LENGTH / sizeof(kprobe_opcode_t); i++) { | |
| 504 | 504 | p = get_kprobe(addr - i); | |
| 505 | + | /* A disabled probe can have prepared, but inactive, optinsns. */ | |
| 506 | + | if (!p || !kprobe_optready(p) || kprobe_disarmed(p)) | |
| 507 | + | continue; | |
| 505 | 508 | ||
| 506 | - | if (p && kprobe_optready(p)) { | |
| 507 | 509 | op = container_of(p, struct optimized_kprobe, kp); | |
| 508 | 510 | if (arch_within_optimized_kprobe(op, addr)) | |
| 509 | 511 | return p; | |
modified kernel/module/main.c
| @@ -3581,8 +3581,9 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
| 3581 | 3581 | goto sysfs_cleanup; | |
| 3582 | 3582 | } | |
| 3583 | 3583 | ||
| 3584 | - | if (codetag_load_module(mod)) | |
| 3585 | - | goto sysfs_cleanup; | |
| 3584 | + | err = codetag_load_module(mod); | |
| 3585 | + | if (err) | |
| 3586 | + | goto livepatch_cleanup; | |
| 3586 | 3587 | ||
| 3587 | 3588 | /* Get rid of temporary copy. */ | |
| 3588 | 3589 | free_copy(info, flags); | |
| @@ -3592,6 +3593,9 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
| 3592 | 3593 | ||
| 3593 | 3594 | return do_init_module(mod); | |
| 3594 | 3595 | ||
| 3596 | + | livepatch_cleanup: | |
| 3597 | + | if (is_livepatch_module(mod)) | |
| 3598 | + | free_module_elf(mod); | |
| 3595 | 3599 | sysfs_cleanup: | |
| 3596 | 3600 | mod_sysfs_teardown(mod); | |
| 3597 | 3601 | coming_cleanup: | |
modified kernel/nsproxy.c
| @@ -61,7 +61,7 @@ static inline struct nsproxy *create_nsproxy(void) | |||
| 61 | 61 | return nsproxy; | |
| 62 | 62 | } | |
| 63 | 63 | ||
| 64 | - | static inline void nsproxy_free(struct nsproxy *ns) | |
| 64 | + | void nsproxy_free(struct nsproxy *ns) | |
| 65 | 65 | { | |
| 66 | 66 | put_mnt_ns(ns->mnt_ns); | |
| 67 | 67 | put_uts_ns(ns->uts_ns); | |
modified kernel/printk/nbcon.c
| @@ -1887,6 +1887,7 @@ bool nbcon_device_try_acquire(struct console *con) | |||
| 1887 | 1887 | ||
| 1888 | 1888 | memset(ctxt, 0, sizeof(*ctxt)); | |
| 1889 | 1889 | ctxt->console = con; | |
| 1890 | + | /* Keep in sync with nbcon_braille_try_acquire(). */ | |
| 1890 | 1891 | ctxt->prio = NBCON_PRIO_NORMAL; | |
| 1891 | 1892 | ||
| 1892 | 1893 | if (!nbcon_context_try_acquire(ctxt, false)) | |
| @@ -2002,3 +2003,81 @@ void nbcon_kdb_release(struct nbcon_write_context *wctxt) | |||
| 2002 | 2003 | */ | |
| 2003 | 2004 | __nbcon_atomic_flush_pending_con(ctxt->console, prb_next_reserve_seq(prb)); | |
| 2004 | 2005 | } | |
| 2006 | + | ||
| 2007 | + | /** | |
| 2008 | + | * nbcon_is_braille - Checks whether the nbcon write context is using Braille console | |
| 2009 | + | * | |
| 2010 | + | * @wctxt: checked nbcon write context | |
| 2011 | + | * | |
| 2012 | + | * Return: True when the write context is associated with a Braille console. | |
| 2013 | + | * Otherwise, return false. | |
| 2014 | + | * | |
| 2015 | + | * Context: Can be called in any context but only when Braille console is | |
| 2016 | + | * registered and the struct console could not disappear. | |
| 2017 | + | */ | |
| 2018 | + | bool nbcon_write_context_is_braille(struct nbcon_write_context *wctxt) | |
| 2019 | + | { | |
| 2020 | + | struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt); | |
| 2021 | + | struct console *con = ctxt->console; | |
| 2022 | + | ||
| 2023 | + | return con && con->flags & CON_BRL; | |
| 2024 | + | } | |
| 2025 | + | EXPORT_SYMBOL_GPL(nbcon_write_context_is_braille); | |
| 2026 | + | ||
| 2027 | + | /** | |
| 2028 | + | * nbcon_braille_try_acquire - Try to acquire nbcon console for braille_write() | |
| 2029 | + | * | |
| 2030 | + | * @con: The nbcon console to acquire | |
| 2031 | + | * @wctxt: The nbcon write context to be used on success | |
| 2032 | + | * | |
| 2033 | + | * Context: braille_write() for emitting a single buffer on Braille console. | |
| 2034 | + | * | |
| 2035 | + | * Return: True if the console was acquired. False otherwise. | |
| 2036 | + | * | |
| 2037 | + | * Braille console is not registered as a proper printk consoles. Instead, | |
| 2038 | + | * it is integrated with the graphical virtual terminal. | |
| 2039 | + | * | |
| 2040 | + | * This function is going to synchronize the Braille write against other | |
| 2041 | + | * operations on the used serial port. The port can be used also for a user | |
| 2042 | + | * input but printk() won't emit the messages there directly. It means | |
| 2043 | + | * the other operations will get synchronized using nbcon_device_try_acquire(). | |
| 2044 | + | */ | |
| 2045 | + | bool nbcon_braille_try_acquire(struct console *con, | |
| 2046 | + | struct nbcon_write_context *wctxt) | |
| 2047 | + | { | |
| 2048 | + | struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt); | |
| 2049 | + | bool success; | |
| 2050 | + | ||
| 2051 | + | memset(ctxt, 0, sizeof(*ctxt)); | |
| 2052 | + | ctxt->console = con; | |
| 2053 | + | /* Keep in sync with nbcon_device_try_acquire(). */ | |
| 2054 | + | if (panic_on_this_cpu()) | |
| 2055 | + | ctxt->prio = NBCON_PRIO_PANIC; | |
| 2056 | + | else | |
| 2057 | + | ctxt->prio = NBCON_PRIO_NORMAL; | |
| 2058 | + | ||
| 2059 | + | success = nbcon_context_try_acquire(ctxt, false); | |
| 2060 | + | /* | |
| 2061 | + | * Try hard in panic, otherwise the Braille console would | |
| 2062 | + | * miss a text on the related VT. | |
| 2063 | + | */ | |
| 2064 | + | if (panic_on_this_cpu() && !success) { | |
| 2065 | + | ctxt->allow_unsafe_takeover = true; | |
| 2066 | + | success = nbcon_context_try_acquire(ctxt, false); | |
| 2067 | + | } | |
| 2068 | + | ||
| 2069 | + | return success; | |
| 2070 | + | } | |
| 2071 | + | ||
| 2072 | + | /** | |
| 2073 | + | * nbcon_braille_release - Release the nbcon console | |
| 2074 | + | * | |
| 2075 | + | * @wctxt: The nbcon write context initialized by a successful | |
| 2076 | + | * nbcon_braille_try_acquire() | |
| 2077 | + | */ | |
| 2078 | + | void nbcon_braille_release(struct nbcon_write_context *wctxt) | |
| 2079 | + | { | |
| 2080 | + | struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt); | |
| 2081 | + | ||
| 2082 | + | nbcon_context_release(ctxt); | |
| 2083 | + | } | |
modified kernel/rcu/srcutree.c
| @@ -704,7 +704,7 @@ void cleanup_srcu_struct(struct srcu_struct *ssp) | |||
| 704 | 704 | // Call srcu_barrier() before this cleanup_srcu_struct() | |
| 705 | 705 | // to avoid triggering this WARN_ON(). | |
| 706 | 706 | if (WARN_ON(timer_delete_sync(&sdp->delay_work) && | |
| 707 | - | rcu_segcblist_n_cbs(&sdp->srcu_cblist)) && | |
| 707 | + | !rcu_segcblist_empty(&sdp->srcu_cblist)) && | |
| 708 | 708 | rcu_cpu_beenfullyonline(sdp->cpu)) | |
| 709 | 709 | queue_work_on(sdp->cpu, rcu_gp_wq, &sdp->work); | |
| 710 | 710 | flush_work(&sdp->work); | |
modified kernel/sched/ext/ext.c
| @@ -2057,8 +2057,14 @@ void scx_do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags, | |||
| 2057 | 2057 | if (unlikely(!SCX_HAS_OP(sch, enqueue))) | |
| 2058 | 2058 | goto global; | |
| 2059 | 2059 | ||
| 2060 | - | /* DSQ bypass didn't trigger, enqueue on the BPF scheduler */ | |
| 2061 | - | qseq = rq->scx.ops_qseq++ << SCX_OPSS_QSEQ_SHIFT; | |
| 2060 | + | /* | |
| 2061 | + | * DSQ bypass didn't trigger, enqueue on the BPF scheduler. Wrap the | |
| 2062 | + | * per-task qseq counter where the QSEQ field wraps and skip 0, which is | |
| 2063 | + | * what scx_bpf_dsq_insert() records for a task in NONE or DISPATCHING. | |
| 2064 | + | */ | |
| 2065 | + | p->scx.ops_qseq = ((p->scx.ops_qseq + 1) & | |
| 2066 | + | (SCX_OPSS_QSEQ_MASK >> SCX_OPSS_QSEQ_SHIFT)) ?: 1; | |
| 2067 | + | qseq = (unsigned long)p->scx.ops_qseq << SCX_OPSS_QSEQ_SHIFT; | |
| 2062 | 2068 | ||
| 2063 | 2069 | WARN_ON_ONCE(atomic_long_read(&p->scx.ops_state) != SCX_OPSS_NONE); | |
| 2064 | 2070 | atomic_long_set(&p->scx.ops_state, SCX_OPSS_QUEUEING | qseq); | |
| @@ -2123,8 +2129,8 @@ static void set_task_runnable(struct rq *rq, struct task_struct *p) | |||
| 2123 | 2129 | } | |
| 2124 | 2130 | ||
| 2125 | 2131 | /* | |
| 2126 | - | * list_add_tail() must be used. scx_bypass() depends on tasks being | |
| 2127 | - | * appended to the runnable_list. | |
| 2132 | + | * list_add_tail() must be used. scx_bypass() and rq_offline_scx() | |
| 2133 | + | * depend on tasks being appended to the runnable_list. | |
| 2128 | 2134 | */ | |
| 2129 | 2135 | list_add_tail(&p->scx.runnable_node, &rq->scx.runnable_list); | |
| 2130 | 2136 | ||
| @@ -2152,6 +2158,13 @@ static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int core_enq_ | |||
| 2152 | 2158 | int sticky_cpu = p->scx.sticky_cpu; | |
| 2153 | 2159 | u64 enq_flags = core_enq_flags | rq->scx.remote_activate_enq_flags; | |
| 2154 | 2160 | ||
| 2161 | + | /* | |
| 2162 | + | * An SCX-internal migration ends on arrival. Clear sticky_cpu so @p can | |
| 2163 | + | * leave custody when inserted into the destination DSQ. | |
| 2164 | + | */ | |
| 2165 | + | if (sticky_cpu >= 0) | |
| 2166 | + | p->scx.sticky_cpu = -1; | |
| 2167 | + | ||
| 2155 | 2168 | /* | |
| 2156 | 2169 | * SCX_RQ_IN_WAKEUP promises a task_woken_scx() call once this enqueue | |
| 2157 | 2170 | * returns. Only the core's wakeup path delivers one. The flags stashed | |
| @@ -2190,9 +2203,6 @@ static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int core_enq_ | |||
| 2190 | 2203 | dl_server_start(&rq->ext_server); | |
| 2191 | 2204 | ||
| 2192 | 2205 | scx_do_enqueue_task(rq, p, enq_flags, sticky_cpu); | |
| 2193 | - | ||
| 2194 | - | if (sticky_cpu >= 0) | |
| 2195 | - | p->scx.sticky_cpu = -1; | |
| 2196 | 2206 | out: | |
| 2197 | 2207 | rq->scx.flags &= ~SCX_RQ_IN_WAKEUP; | |
| 2198 | 2208 | ||
| @@ -3731,8 +3741,26 @@ static void rq_online_scx(struct rq *rq) | |||
| 3731 | 3741 | ||
| 3732 | 3742 | static void rq_offline_scx(struct rq *rq) | |
| 3733 | 3743 | { | |
| 3744 | + | struct task_struct *p, *n; | |
| 3745 | + | ||
| 3734 | 3746 | rq->scx.flags &= ~SCX_RQ_ONLINE; | |
| 3747 | + | ||
| 3748 | + | /* sched domain rebuilds call rq_offline with the CPU staying alive */ | |
| 3749 | + | if (cpu_active(cpu_of(rq))) | |
| 3750 | + | return; | |
| 3751 | + | ||
| 3735 | 3752 | scx_rescue_flush(rq); | |
| 3753 | + | ||
| 3754 | + | /* | |
| 3755 | + | * An offline CPU no longer calls ops.dispatch(). Re-enqueue its tasks | |
| 3756 | + | * onto the local DSQ so that they run here and balance_push() moves | |
| 3757 | + | * them off. | |
| 3758 | + | */ | |
| 3759 | + | list_for_each_entry_safe_reverse(p, n, &rq->scx.runnable_list, scx.runnable_node) { | |
| 3760 | + | if (p->scx.dsq == &rq->scx.local_dsq) | |
| 3761 | + | continue; | |
| 3762 | + | guard(sched_change)(p, DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK); | |
| 3763 | + | } | |
| 3736 | 3764 | } | |
| 3737 | 3765 | ||
| 3738 | 3766 | static bool check_rq_for_timeouts(struct rq *rq) | |
| @@ -6947,9 +6975,9 @@ static void scx_dump_cpu(struct scx_sched *sch, struct seq_buf *s, | |||
| 6947 | 6975 | seq_buf_init(&ns, buf, avail); | |
| 6948 | 6976 | ||
| 6949 | 6977 | dump_newline(&ns); | |
| 6950 | - | scx_dump_line(&ns, "CPU %-4d: nr_run=%u flags=0x%x cpu_rel=%d ops_qseq=%lu ksync=%lu", | |
| 6978 | + | scx_dump_line(&ns, "CPU %-4d: nr_run=%u flags=0x%x cpu_rel=%d ksync=%lu", | |
| 6951 | 6979 | cpu, rq->scx.nr_running, rq->scx.flags, rq->scx.cpu_released, | |
| 6952 | - | rq->scx.ops_qseq, rq->scx.kick_sync); | |
| 6980 | + | rq->scx.kick_sync); | |
| 6953 | 6981 | scx_rescue_dump(&ns, rq); | |
| 6954 | 6982 | scx_dump_line(&ns, " curr=%s[%d] class=%ps", | |
| 6955 | 6983 | rq->curr->comm, rq->curr->pid, rq->curr->sched_class); | |
modified kernel/sched/ext/inlines.h
| @@ -70,7 +70,13 @@ scx_dispatch_sched(struct scx_sched *sch, struct rq *rq, | |||
| 70 | 70 | #endif /* CONFIG_EXT_SUB_SCHED */ | |
| 71 | 71 | } | |
| 72 | 72 | ||
| 73 | - | if (unlikely(!SCX_HAS_OP(sch, dispatch)) || !scx_rq_online(rq)) | |
| 73 | + | /* | |
| 74 | + | * scx_rq_online() can't be used. Its cpu_active() test goes false | |
| 75 | + | * before CPU hotplug waits for an RCU grace period, and | |
| 76 | + | * rq_offline_scx() moves this CPU's tasks to the local DSQ only after | |
| 77 | + | * the wait. The grace period can depend on those tasks running. | |
| 78 | + | */ | |
| 79 | + | if (unlikely(!SCX_HAS_OP(sch, dispatch)) || !(rq->scx.flags & SCX_RQ_ONLINE)) | |
| 74 | 80 | return SCX_DSP_NONE; | |
| 75 | 81 | ||
| 76 | 82 | dspc->rq = rq; | |
modified kernel/sched/ext/internal.h
| @@ -1998,6 +1998,11 @@ enum scx_ops_state { | |||
| 1998 | 1998 | * dequeue/requeue, the dispatcher can tell whether it still has a claim | |
| 1999 | 1999 | * on the task being dispatched. | |
| 2000 | 2000 | * | |
| 2001 | + | * QSEQ is generated from the per-task p->scx.ops_qseq counter so that | |
| 2002 | + | * it doesn't repeat across QUEUED instances of the same task even if | |
| 2003 | + | * the task moves between rqs. 0 is never used as a valid QSEQ since | |
| 2004 | + | * NONE and DISPATCHING map to this value. | |
| 2005 | + | * | |
| 2001 | 2006 | * As some 32bit archs can't do 64bit store_release/load_acquire, | |
| 2002 | 2007 | * p->scx.ops_state is atomic_long_t which leaves 30 bits for QSEQ on | |
| 2003 | 2008 | * 32bit machines. The dispatch race window QSEQ protects is very narrow | |
modified kernel/sched/ext/sub.c
| @@ -585,10 +585,6 @@ void scx_rescue_flush(struct rq *rq) | |||
| 585 | 585 | ||
| 586 | 586 | lockdep_assert_rq_held(rq); | |
| 587 | 587 | ||
| 588 | - | /* sched domain rebuilds call rq_offline with the CPU staying alive */ | |
| 589 | - | if (cpu_active(cpu_of(rq))) | |
| 590 | - | return; | |
| 591 | - | ||
| 592 | 588 | /* end the current rescue */ | |
| 593 | 589 | if (rq->scx.rescue.curr) | |
| 594 | 590 | scx_task_slice_ended(rq, rq->scx.rescue.curr); | |
modified kernel/sched/sched.h
| @@ -816,7 +816,6 @@ struct scx_rq { | |||
| 816 | 816 | #endif | |
| 817 | 817 | struct list_head runnable_list; /* runnable tasks on this rq */ | |
| 818 | 818 | struct list_head ddsp_deferred_locals; /* deferred ddsps from enq */ | |
| 819 | - | unsigned long ops_qseq; | |
| 820 | 819 | /* both stashed across the activate_task() in move_remote_task_to_local_dsq() */ | |
| 821 | 820 | u64 remote_activate_enq_flags; | |
| 822 | 821 | struct scx_sched *remote_activate_sch; | |
| @@ -4222,8 +4221,9 @@ extern void balance_callbacks(struct rq *rq, struct balance_callback *head); | |||
| 4222 | 4221 | * after which it is enqueued again. | |
| 4223 | 4222 | * | |
| 4224 | 4223 | * Typically this must be called while holding task_rq_lock, since most/all | |
| 4225 | - | * properties are serialized under those locks. There is currently one | |
| 4226 | - | * exception to this rule in sched/ext which only holds rq->lock. | |
| 4224 | + | * properties are serialized under those locks. There are currently two | |
| 4225 | + | * exceptions to this rule in sched/ext which only hold rq->lock: scx_bypass() | |
| 4226 | + | * and rq_offline_scx(). | |
| 4227 | 4227 | */ | |
| 4228 | 4228 | ||
| 4229 | 4229 | /* | |
modified kernel/sysctl.c
| @@ -483,7 +483,7 @@ int proc_int_k2u_conv_kop(ulong *u_ptr, const int *k_ptr, bool *negp, | |||
| 483 | 483 | ||
| 484 | 484 | if (val < 0) { | |
| 485 | 485 | *negp = true; | |
| 486 | - | *u_ptr = k_ptr_op ? -k_ptr_op((ulong)val) : -(ulong)val; | |
| 486 | + | *u_ptr = k_ptr_op ? k_ptr_op(-(ulong)val) : -(ulong)val; | |
| 487 | 487 | } else { | |
| 488 | 488 | *negp = false; | |
| 489 | 489 | *u_ptr = k_ptr_op ? k_ptr_op((ulong)val) : (ulong) val; | |
modified kernel/time/jiffies.c
| @@ -101,6 +101,8 @@ void __init register_refined_jiffies(long cycles_per_second) | |||
| 101 | 101 | #ifdef CONFIG_SYSCTL | |
| 102 | 102 | static ulong mult_hz(const ulong val) | |
| 103 | 103 | { | |
| 104 | + | if (val >= ULONG_MAX / HZ) | |
| 105 | + | return ULONG_MAX; | |
| 104 | 106 | return val * HZ; | |
| 105 | 107 | } | |
| 106 | 108 | ||
modified kernel/trace/fprobe.c
| @@ -47,6 +47,10 @@ static struct rhltable fprobe_ip_table; | |||
| 47 | 47 | static DEFINE_MUTEX(fprobe_mutex); | |
| 48 | 48 | static struct fgraph_ops fprobe_graph_ops; | |
| 49 | 49 | ||
| 50 | + | DEFINE_LOCK_GUARD_0(rcu_sched_notrace, | |
| 51 | + | rcu_read_lock_sched_notrace(), | |
| 52 | + | rcu_read_unlock_sched_notrace()) | |
| 53 | + | ||
| 50 | 54 | static u32 fprobe_node_hashfn(const void *data, u32 len, u32 seed) | |
| 51 | 55 | { | |
| 52 | 56 | return hash_ptr(*(unsigned long **)data, 32); | |
| @@ -329,16 +333,14 @@ static void fprobe_ftrace_entry(unsigned long ip, unsigned long parent_ip, | |||
| 329 | 333 | struct fprobe *fp; | |
| 330 | 334 | int bit; | |
| 331 | 335 | ||
| 336 | + | if (!rcu_is_watching()) | |
| 337 | + | return; | |
| 338 | + | ||
| 332 | 339 | bit = ftrace_test_recursion_trylock(ip, parent_ip); | |
| 333 | 340 | if (bit < 0) | |
| 334 | 341 | return; | |
| 335 | 342 | ||
| 336 | - | /* | |
| 337 | - | * ftrace_test_recursion_trylock() disables preemption, but | |
| 338 | - | * rhltable_lookup() checks whether rcu_read_lcok is held. | |
| 339 | - | * So we take rcu_read_lock() here. | |
| 340 | - | */ | |
| 341 | - | rcu_read_lock(); | |
| 343 | + | guard(rcu_sched_notrace)(); | |
| 342 | 344 | head = rhltable_lookup(&fprobe_ip_table, &ip, fprobe_rht_params); | |
| 343 | 345 | ||
| 344 | 346 | rhl_for_each_entry_rcu(node, pos, head, hlist) { | |
| @@ -353,7 +355,6 @@ static void fprobe_ftrace_entry(unsigned long ip, unsigned long parent_ip, | |||
| 353 | 355 | else | |
| 354 | 356 | __fprobe_handler(ip, parent_ip, fp, fregs, NULL); | |
| 355 | 357 | } | |
| 356 | - | rcu_read_unlock(); | |
| 357 | 358 | ftrace_test_recursion_unlock(bit); | |
| 358 | 359 | } | |
| 359 | 360 | NOKPROBE_SYMBOL(fprobe_ftrace_entry); | |
| @@ -567,10 +568,13 @@ static int fprobe_fgraph_entry(struct ftrace_graph_ent *trace, struct fgraph_ops | |||
| 567 | 568 | struct fprobe *fp; | |
| 568 | 569 | int used, ret; | |
| 569 | 570 | ||
| 571 | + | if (!rcu_is_watching()) | |
| 572 | + | return 0; | |
| 573 | + | ||
| 570 | 574 | if (WARN_ON_ONCE(!fregs)) | |
| 571 | 575 | return 0; | |
| 572 | 576 | ||
| 573 | - | guard(rcu)(); | |
| 577 | + | guard(rcu_sched_notrace)(); | |
| 574 | 578 | head = rhltable_lookup(&fprobe_ip_table, &func, fprobe_rht_params); | |
| 575 | 579 | reserved_words = 0; | |
| 576 | 580 | rhl_for_each_entry_rcu(node, pos, head, hlist) { | |
| @@ -665,13 +669,16 @@ static void fprobe_return(struct ftrace_graph_ret *trace, | |||
| 665 | 669 | int size, curr; | |
| 666 | 670 | int size_words; | |
| 667 | 671 | ||
| 672 | + | if (!rcu_is_watching()) | |
| 673 | + | return; | |
| 674 | + | ||
| 668 | 675 | fgraph_data = (unsigned long *)fgraph_retrieve_data(gops->idx, &size); | |
| 669 | 676 | if (WARN_ON_ONCE(!fgraph_data)) | |
| 670 | 677 | return; | |
| 671 | 678 | size_words = SIZE_IN_LONG(size); | |
| 672 | 679 | ret_ip = ftrace_regs_get_instruction_pointer(fregs); | |
| 673 | 680 | ||
| 674 | - | preempt_disable_notrace(); | |
| 681 | + | guard(rcu_sched_notrace)(); | |
| 675 | 682 | ||
| 676 | 683 | curr = 0; | |
| 677 | 684 | while (size_words > curr) { | |
| @@ -687,7 +694,6 @@ static void fprobe_return(struct ftrace_graph_ret *trace, | |||
| 687 | 694 | } | |
| 688 | 695 | curr += size; | |
| 689 | 696 | } | |
| 690 | - | preempt_enable_notrace(); | |
| 691 | 697 | } | |
| 692 | 698 | NOKPROBE_SYMBOL(fprobe_return); | |
| 693 | 699 | ||
modified kernel/workqueue.c
| @@ -2290,7 +2290,7 @@ static bool is_chained_work(struct workqueue_struct *wq) | |||
| 2290 | 2290 | * Return %true iff I'm a worker executing a work item on @wq. If | |
| 2291 | 2291 | * I'm @worker, it's safe to dereference it without locking. | |
| 2292 | 2292 | */ | |
| 2293 | - | return worker && worker->current_pwq->wq == wq; | |
| 2293 | + | return worker && worker->current_pwq && worker->current_pwq->wq == wq; | |
| 2294 | 2294 | } | |
| 2295 | 2295 | ||
| 2296 | 2296 | /* | |
modified lib/Kconfig.debug
| @@ -2906,6 +2906,21 @@ config LIVEUPDATE_TEST | |||
| 2906 | 2906 | ||
| 2907 | 2907 | If unsure, say N | |
| 2908 | 2908 | ||
| 2909 | + | config DIMLIB_KUNIT_TEST | |
| 2910 | + | tristate "KUnit test for the DIM library" if !KUNIT_ALL_TESTS | |
| 2911 | + | depends on KUNIT && NET | |
| 2912 | + | select DIMLIB | |
| 2913 | + | default KUNIT_ALL_TESTS | |
| 2914 | + | help | |
| 2915 | + | This builds the KUnit test for the Dynamic Interrupt Moderation | |
| 2916 | + | library (lib/dim/), which checks the rate statistics computed by | |
| 2917 | + | dim_calc_stats(). | |
| 2918 | + | ||
| 2919 | + | For more information on KUnit and unit tests in general please refer | |
| 2920 | + | to the KUnit documentation in Documentation/dev-tools/kunit/. | |
| 2921 | + | ||
| 2922 | + | If unsure, say N. | |
| 2923 | + | ||
| 2909 | 2924 | config CMDLINE_KUNIT_TEST | |
| 2910 | 2925 | tristate "KUnit test for cmdline API" if !KUNIT_ALL_TESTS | |
| 2911 | 2926 | depends on KUNIT | |
modified lib/dim/Makefile
| @@ -5,3 +5,5 @@ | |||
| 5 | 5 | obj-$(CONFIG_DIMLIB) += dimlib.o | |
| 6 | 6 | ||
| 7 | 7 | dimlib-y := dim.o net_dim.o rdma_dim.o | |
| 8 | + | ||
| 9 | + | obj-$(CONFIG_DIMLIB_KUNIT_TEST) += dim_kunit.o | |
modified lib/dim/dim.c
| @@ -69,11 +69,15 @@ bool dim_calc_stats(const struct dim_sample *start, | |||
| 69 | 69 | if (!delta_us) | |
| 70 | 70 | return false; | |
| 71 | 71 | ||
| 72 | - | curr_stats->ppms = DIV_ROUND_UP(npkts * USEC_PER_MSEC, delta_us); | |
| 73 | - | curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us); | |
| 72 | + | /* u32 * USEC_PER_MSEC overflows a 32-bit long */ | |
| 73 | + | curr_stats->ppms = DIV_ROUND_UP_ULL((u64)npkts * USEC_PER_MSEC, | |
| 74 | + | delta_us); | |
| 75 | + | curr_stats->bpms = DIV_ROUND_UP_ULL((u64)nbytes * USEC_PER_MSEC, | |
| 76 | + | delta_us); | |
| 74 | 77 | curr_stats->epms = DIV_ROUND_UP(DIM_NEVENTS * USEC_PER_MSEC, | |
| 75 | 78 | delta_us); | |
| 76 | - | curr_stats->cpms = DIV_ROUND_UP(ncomps * USEC_PER_MSEC, delta_us); | |
| 79 | + | curr_stats->cpms = DIV_ROUND_UP_ULL((u64)ncomps * USEC_PER_MSEC, | |
| 80 | + | delta_us); | |
| 77 | 81 | if (curr_stats->epms != 0) | |
| 78 | 82 | curr_stats->cpe_ratio = DIV_ROUND_DOWN_ULL( | |
| 79 | 83 | curr_stats->cpms * 100, curr_stats->epms); | |
added lib/dim/dim_kunit.c mode 100644
| @@ -0,0 +1,126 @@ | |||
| 1 | + | // SPDX-License-Identifier: GPL-2.0 | |
| 2 | + | /* | |
| 3 | + | * KUnit tests for the Dynamic Interrupt Moderation library | |
| 4 | + | */ | |
| 5 | + | ||
| 6 | + | #include <kunit/test.h> | |
| 7 | + | #include <linux/dim.h> | |
| 8 | + | #include <linux/ktime.h> | |
| 9 | + | #include <linux/module.h> | |
| 10 | + | ||
| 11 | + | struct dim_calc_stats_case { | |
| 12 | + | const char *name; | |
| 13 | + | u32 delta_us; | |
| 14 | + | u32 start_pkts, end_pkts; | |
| 15 | + | u32 start_bytes, end_bytes; | |
| 16 | + | u32 start_comps, end_comps; | |
| 17 | + | int ppms, bpms, cpms; | |
| 18 | + | }; | |
| 19 | + | ||
| 20 | + | static const struct dim_calc_stats_case dim_calc_stats_cases[] = { | |
| 21 | + | { | |
| 22 | + | .name = "small", | |
| 23 | + | .delta_us = 1000, | |
| 24 | + | .end_pkts = 640, .end_bytes = 640 * 1500, .end_comps = 64, | |
| 25 | + | .ppms = 640, .bpms = 960000, .cpms = 64, | |
| 26 | + | }, | |
| 27 | + | { | |
| 28 | + | .name = "round_up", | |
| 29 | + | .delta_us = 3000, | |
| 30 | + | .end_pkts = 10, .end_bytes = 10, .end_comps = 1, | |
| 31 | + | .ppms = 4, .bpms = 4, .cpms = 1, | |
| 32 | + | }, | |
| 33 | + | { | |
| 34 | + | .name = "counter_wrap", | |
| 35 | + | .delta_us = 1000, | |
| 36 | + | .start_pkts = 0xffffff00, .end_pkts = 0x100, | |
| 37 | + | .start_bytes = 0xfffff000, .end_bytes = 0x1000, | |
| 38 | + | .start_comps = 0xfffffff0, .end_comps = 0x10, | |
| 39 | + | .ppms = 0x200, .bpms = 0x2000, .cpms = 0x20, | |
| 40 | + | }, | |
| 41 | + | { | |
| 42 | + | /* 30 MB in 10 ms (24 Gbit/s): nbytes * 1000 exceeds 32 bits */ | |
| 43 | + | .name = "many_bytes", | |
| 44 | + | .delta_us = 10000, | |
| 45 | + | .end_pkts = 20000, .end_bytes = 30000000, .end_comps = 64, | |
| 46 | + | .ppms = 2000, .bpms = 3000000, .cpms = 7, | |
| 47 | + | }, | |
| 48 | + | { | |
| 49 | + | /* 4.3 MB in 16 ms (2.15 Gbit/s), just above the 32-bit limit */ | |
| 50 | + | .name = "bytes_32bit_limit", | |
| 51 | + | .delta_us = 16000, | |
| 52 | + | .end_pkts = 2900, .end_bytes = 4300000, .end_comps = 64, | |
| 53 | + | .ppms = 182, .bpms = 268750, .cpms = 4, | |
| 54 | + | }, | |
| 55 | + | { | |
| 56 | + | /* 5 MB in 40 ms: a 1 Gbit/s link at line rate */ | |
| 57 | + | .name = "gigabit", | |
| 58 | + | .delta_us = 40000, | |
| 59 | + | .end_pkts = 3300, .end_bytes = 5000000, .end_comps = 64, | |
| 60 | + | .ppms = 83, .bpms = 125000, .cpms = 2, | |
| 61 | + | }, | |
| 62 | + | { | |
| 63 | + | /* 5 million packets and completions in 2 s */ | |
| 64 | + | .name = "many_packets", | |
| 65 | + | .delta_us = 2000000, | |
| 66 | + | .end_pkts = 5000000, .end_bytes = 5000000, .end_comps = 5000000, | |
| 67 | + | .ppms = 2500, .bpms = 2500, .cpms = 2500, | |
| 68 | + | }, | |
| 69 | + | }; | |
| 70 | + | ||
| 71 | + | static void dim_calc_stats_case_desc(const struct dim_calc_stats_case *t, | |
| 72 | + | char *desc) | |
| 73 | + | { | |
| 74 | + | strscpy(desc, t->name, KUNIT_PARAM_DESC_SIZE); | |
| 75 | + | } | |
| 76 | + | ||
| 77 | + | KUNIT_ARRAY_PARAM(dim_calc_stats, dim_calc_stats_cases, | |
| 78 | + | dim_calc_stats_case_desc); | |
| 79 | + | ||
| 80 | + | static void dim_calc_stats_test(struct kunit *test) | |
| 81 | + | { | |
| 82 | + | const struct dim_calc_stats_case *t = test->param_value; | |
| 83 | + | struct dim_sample start = {}, end = {}; | |
| 84 | + | struct dim_stats stats = {}; | |
| 85 | + | ||
| 86 | + | dim_update_sample_with_comps(0, t->start_pkts, t->start_bytes, | |
| 87 | + | t->start_comps, &start); | |
| 88 | + | dim_update_sample_with_comps(DIM_NEVENTS, t->end_pkts, t->end_bytes, | |
| 89 | + | t->end_comps, &end); | |
| 90 | + | /* dim_update_sample() stamps ktime_get(); use fixed times instead */ | |
| 91 | + | start.time = ktime_set(1000, 0); | |
| 92 | + | end.time = ktime_add_us(start.time, t->delta_us); | |
| 93 | + | ||
| 94 | + | KUNIT_ASSERT_TRUE(test, dim_calc_stats(&start, &end, &stats)); | |
| 95 | + | KUNIT_EXPECT_EQ(test, stats.ppms, t->ppms); | |
| 96 | + | KUNIT_EXPECT_EQ(test, stats.bpms, t->bpms); | |
| 97 | + | KUNIT_EXPECT_EQ(test, stats.cpms, t->cpms); | |
| 98 | + | KUNIT_EXPECT_EQ(test, stats.epms, | |
| 99 | + | (int)DIV_ROUND_UP(DIM_NEVENTS * USEC_PER_MSEC, | |
| 100 | + | t->delta_us)); | |
| 101 | + | } | |
| 102 | + | ||
| 103 | + | static void dim_calc_stats_no_time_test(struct kunit *test) | |
| 104 | + | { | |
| 105 | + | struct dim_sample sample = {}; | |
| 106 | + | struct dim_stats stats = {}; | |
| 107 | + | ||
| 108 | + | dim_update_sample_with_comps(0, 100, 1000, 10, &sample); | |
| 109 | + | KUNIT_EXPECT_FALSE(test, dim_calc_stats(&sample, &sample, &stats)); | |
| 110 | + | } | |
| 111 | + | ||
| 112 | + | static struct kunit_case dim_test_cases[] = { | |
| 113 | + | KUNIT_CASE_PARAM(dim_calc_stats_test, dim_calc_stats_gen_params), | |
| 114 | + | KUNIT_CASE(dim_calc_stats_no_time_test), | |
| 115 | + | {} | |
| 116 | + | }; | |
| 117 | + | ||
| 118 | + | static struct kunit_suite dim_test_suite = { | |
| 119 | + | .name = "dim", | |
| 120 | + | .test_cases = dim_test_cases, | |
| 121 | + | }; | |
| 122 | + | ||
| 123 | + | kunit_test_suite(dim_test_suite); | |
| 124 | + | ||
| 125 | + | MODULE_DESCRIPTION("KUnit tests for the DIM library"); | |
| 126 | + | MODULE_LICENSE("GPL"); | |
modified mm/damon/core.c
| @@ -3147,7 +3147,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) | |||
| 3147 | 3147 | unsigned long cumulated_sz, cached_esz; | |
| 3148 | 3148 | unsigned int score, max_score = 0; | |
| 3149 | 3149 | ||
| 3150 | - | if (!quota->ms && !quota->sz && list_empty("a->goals)) | |
| 3150 | + | if (!damos_quota_is_set(quota)) | |
| 3151 | 3151 | return; | |
| 3152 | 3152 | ||
| 3153 | 3153 | /* First charge window */ | |
modified mm/kasan/common.c
| @@ -114,12 +114,23 @@ void kasan_unpoison_task_stack(struct task_struct *task) | |||
| 114 | 114 | /* Unpoison the stack for the current task beyond a watermark sp value. */ | |
| 115 | 115 | asmlinkage void kasan_unpoison_task_stack_below(const void *watermark) | |
| 116 | 116 | { | |
| 117 | + | void *base; | |
| 118 | + | ||
| 119 | + | /* | |
| 120 | + | * Only the generic mode needs this. In the tag-based mode the | |
| 121 | + | * compiler fully initializes the shadow of stack variables on | |
| 122 | + | * function entry, so stale tags left below the watermark are | |
| 123 | + | * harmless. | |
| 124 | + | */ | |
| 125 | + | if (!IS_ENABLED(CONFIG_KASAN_GENERIC)) | |
| 126 | + | return; | |
| 127 | + | ||
| 117 | 128 | /* | |
| 118 | 129 | * Calculate the task stack base address. Avoid using 'current' | |
| 119 | 130 | * because this function is called by early resume code which hasn't | |
| 120 | 131 | * yet set up the percpu register (%gs). | |
| 121 | 132 | */ | |
| 122 | - | void *base = (void *)((unsigned long)watermark & ~(THREAD_SIZE - 1)); | |
| 133 | + | base = (void *)((unsigned long)watermark & ~(THREAD_SIZE - 1)); | |
| 123 | 134 | ||
| 124 | 135 | kasan_unpoison(base, watermark - base, false); | |
| 125 | 136 | } | |
modified mm/mremap.c
| @@ -1037,6 +1037,7 @@ static void vrm_stat_account(struct vma_remap_struct *vrm, | |||
| 1037 | 1037 | } | |
| 1038 | 1038 | ||
| 1039 | 1039 | static bool __check_map_count_against_split(struct mm_struct *mm, | |
| 1040 | + | bool pre_split, | |
| 1040 | 1041 | bool before_unmaps) | |
| 1041 | 1042 | { | |
| 1042 | 1043 | const int sys_map_count = get_sysctl_max_map_count(); | |
| @@ -1088,26 +1089,42 @@ static bool __check_map_count_against_split(struct mm_struct *mm, | |||
| 1088 | 1089 | * Therefore we must check to ensure we have headroom of 2 additional | |
| 1089 | 1090 | * VMAs. | |
| 1090 | 1091 | */ | |
| 1091 | - | return map_count + 2 <= sys_map_count; | |
| 1092 | + | map_count += 2; | |
| 1093 | + | ||
| 1094 | + | /* If pre-split, the -1 observed above doesn't apply. */ | |
| 1095 | + | if (pre_split) | |
| 1096 | + | map_count++; | |
| 1097 | + | ||
| 1098 | + | return map_count <= sys_map_count; | |
| 1099 | + | } | |
| 1100 | + | ||
| 1101 | + | static bool needs_pre_split(struct vma_remap_struct *vrm) | |
| 1102 | + | { | |
| 1103 | + | /* | |
| 1104 | + | * An MREMAP_DONTUNMAP of a mlock()'d VMA needs to unlock the | |
| 1105 | + | * source VMA, so split in this case. | |
| 1106 | + | */ | |
| 1107 | + | return (vrm->flags & MREMAP_DONTUNMAP) && | |
| 1108 | + | vma_test(vrm->vma, VMA_LOCKED_BIT); | |
| 1092 | 1109 | } | |
| 1093 | 1110 | ||
| 1094 | 1111 | /* Do we violate the map count limit if we split VMAs when moving the VMA? */ | |
| 1095 | - | static bool check_map_count_against_split(void) | |
| 1112 | + | static bool check_map_count_against_split(struct vma_remap_struct *vrm) | |
| 1096 | 1113 | { | |
| 1097 | 1114 | return __check_map_count_against_split(current->mm, | |
| 1098 | - | /*before_unmaps=*/false); | |
| 1115 | + | needs_pre_split(vrm), /*before_unmaps=*/false); | |
| 1099 | 1116 | } | |
| 1100 | 1117 | ||
| 1101 | 1118 | /* Do we violate the map count limit if we split VMAs prior to early unmaps? */ | |
| 1102 | - | static bool check_map_count_against_split_early(void) | |
| 1119 | + | static bool check_map_count_against_split_early(struct vma_remap_struct *vrm) | |
| 1103 | 1120 | { | |
| 1104 | 1121 | return __check_map_count_against_split(current->mm, | |
| 1105 | - | /*before_unmaps=*/true); | |
| 1122 | + | vrm->flags & MREMAP_DONTUNMAP, /*before_unmaps=*/true); | |
| 1106 | 1123 | } | |
| 1107 | 1124 | ||
| 1108 | 1125 | /* | |
| 1109 | - | * Perform checks before attempting to write a VMA prior to it being | |
| 1110 | - | * moved. | |
| 1126 | + | * Perform checks and preparation before attempting to write a VMA prior to it | |
| 1127 | + | * being moved. | |
| 1111 | 1128 | */ | |
| 1112 | 1129 | static unsigned long prep_move_vma(struct vma_remap_struct *vrm) | |
| 1113 | 1130 | { | |
| @@ -1116,19 +1133,17 @@ static unsigned long prep_move_vma(struct vma_remap_struct *vrm) | |||
| 1116 | 1133 | unsigned long old_addr = vrm->addr; | |
| 1117 | 1134 | unsigned long old_len = vrm->old_len; | |
| 1118 | 1135 | vm_flags_t dummy = vma->vm_flags; | |
| 1136 | + | const bool split_before = vma->vm_start != old_addr; | |
| 1137 | + | const bool split_after = vma->vm_end != old_addr + old_len; | |
| 1119 | 1138 | ||
| 1120 | - | /* | |
| 1121 | - | * We'd prefer to avoid failure later on in do_munmap: we copy a VMA, | |
| 1122 | - | * which may not merge, then (if MREMAP_DONTUNMAP is not set) unmap the | |
| 1123 | - | * source, which may split, causing a net increase of 2 mappings. | |
| 1124 | - | */ | |
| 1125 | - | if (!check_map_count_against_split()) | |
| 1139 | + | /* Avoid failure later on. */ | |
| 1140 | + | if (!check_map_count_against_split(vrm)) | |
| 1126 | 1141 | return -ENOMEM; | |
| 1127 | 1142 | ||
| 1128 | 1143 | if (vma->vm_ops && vma->vm_ops->may_split) { | |
| 1129 | - | if (vma->vm_start != old_addr) | |
| 1144 | + | if (split_before) | |
| 1130 | 1145 | err = vma->vm_ops->may_split(vma, old_addr); | |
| 1131 | - | if (!err && vma->vm_end != old_addr + old_len) | |
| 1146 | + | if (!err && split_after) | |
| 1132 | 1147 | err = vma->vm_ops->may_split(vma, old_addr + old_len); | |
| 1133 | 1148 | if (err) | |
| 1134 | 1149 | return err; | |
| @@ -1146,6 +1161,21 @@ static unsigned long prep_move_vma(struct vma_remap_struct *vrm) | |||
| 1146 | 1161 | if (err) | |
| 1147 | 1162 | return err; | |
| 1148 | 1163 | ||
| 1164 | + | /* | |
| 1165 | + | * To account mlock()'d pages correctly in the MREMAP_DONTUNMAP | |
| 1166 | + | * case perform any split ahead of time for an mlock()'d VMA. | |
| 1167 | + | */ | |
| 1168 | + | if (needs_pre_split(vrm)) { | |
| 1169 | + | VMA_ITERATOR(vmi, vma->vm_mm, old_addr); | |
| 1170 | + | ||
| 1171 | + | if (split_before) | |
| 1172 | + | err = split_vma(&vmi, vma, old_addr, 1); | |
| 1173 | + | if (!err && split_after) | |
| 1174 | + | err = split_vma(&vmi, vma, old_addr + old_len, 0); | |
| 1175 | + | vrm->vmi_needs_invalidate = true; | |
| 1176 | + | return err; | |
| 1177 | + | } | |
| 1178 | + | ||
| 1149 | 1179 | return 0; | |
| 1150 | 1180 | } | |
| 1151 | 1181 | ||
| @@ -1275,7 +1305,8 @@ static int copy_vma_and_data(struct vma_remap_struct *vrm, | |||
| 1275 | 1305 | PAGETABLE_MOVE(pmc, NULL, NULL, vrm->addr, vrm->new_addr, vrm->old_len); | |
| 1276 | 1306 | ||
| 1277 | 1307 | new_vma = copy_vma(&vma, vrm->new_addr, vrm->new_len, new_pgoff, | |
| 1278 | - | new_anon_pgoff, &pmc.need_rmap_locks); | |
| 1308 | + | new_anon_pgoff, &pmc.need_rmap_locks, | |
| 1309 | + | vrm->flags & MREMAP_DONTUNMAP); | |
| 1279 | 1310 | if (!new_vma) { | |
| 1280 | 1311 | vrm_uncharge(vrm); | |
| 1281 | 1312 | *new_vma_ptr = NULL; | |
| @@ -1335,6 +1366,9 @@ static void dontunmap_complete(struct vma_remap_struct *vrm, | |||
| 1335 | 1366 | unsigned long old_start = vma->vm_start; | |
| 1336 | 1367 | unsigned long old_end = vma->vm_end; | |
| 1337 | 1368 | ||
| 1369 | + | /* Self-merge is disallowed. */ | |
| 1370 | + | VM_WARN_ON_ONCE(new_vma == vma); | |
| 1371 | + | ||
| 1338 | 1372 | /* We always clear VMA_LOCKED[ONFAULT]_BIT on the old VMA. */ | |
| 1339 | 1373 | vma_clear_flags_mask(vma, VMA_LOCKED_MASK); | |
| 1340 | 1374 | ||
| @@ -1342,7 +1376,7 @@ static void dontunmap_complete(struct vma_remap_struct *vrm, | |||
| 1342 | 1376 | * anon_vma links of the old vma is no longer needed after its page | |
| 1343 | 1377 | * table has been moved. | |
| 1344 | 1378 | */ | |
| 1345 | - | if (new_vma != vma && start == old_start && end == old_end) { | |
| 1379 | + | if (start == old_start && end == old_end) { | |
| 1346 | 1380 | const pgoff_t pgoff_unfaulted = vma->vm_start >> PAGE_SHIFT; | |
| 1347 | 1381 | ||
| 1348 | 1382 | unlink_anon_vmas(vma); | |
| @@ -2002,7 +2036,7 @@ static unsigned long do_mremap(struct vma_remap_struct *vrm) | |||
| 2002 | 2036 | return -EINTR; | |
| 2003 | 2037 | vrm->mmap_locked = true; | |
| 2004 | 2038 | ||
| 2005 | - | if (!check_map_count_against_split_early()) { | |
| 2039 | + | if (!check_map_count_against_split_early(vrm)) { | |
| 2006 | 2040 | mmap_write_unlock(mm); | |
| 2007 | 2041 | return -ENOMEM; | |
| 2008 | 2042 | } | |
modified mm/pgtable-generic.c
| @@ -438,12 +438,30 @@ static void kernel_pgtable_work_func(struct work_struct *work) | |||
| 438 | 438 | __pagetable_free(pt); | |
| 439 | 439 | } | |
| 440 | 440 | ||
| 441 | + | static void schedule_kernel_pgtable_free(void) | |
| 442 | + | { | |
| 443 | + | schedule_work(&kernel_pgtable_work.work); | |
| 444 | + | } | |
| 445 | + | ||
| 441 | 446 | void pagetable_free_kernel(struct ptdesc *pt) | |
| 442 | 447 | { | |
| 443 | 448 | spin_lock(&kernel_pgtable_work.lock); | |
| 444 | 449 | list_add(&pt->pt_list, &kernel_pgtable_work.list); | |
| 445 | 450 | spin_unlock(&kernel_pgtable_work.lock); | |
| 446 | 451 | ||
| 447 | - | schedule_work(&kernel_pgtable_work.work); | |
| 452 | + | /* | |
| 453 | + | * The workqueue may not exist yet while the system is booting. | |
| 454 | + | * kernel_pgtable_drain_early() schedules the work once it does. | |
| 455 | + | */ | |
| 456 | + | if (system_state != SYSTEM_BOOTING) | |
| 457 | + | schedule_kernel_pgtable_free(); | |
| 458 | + | } | |
| 459 | + | ||
| 460 | + | static int __init kernel_pgtable_drain_early(void) | |
| 461 | + | { | |
| 462 | + | /* Free the kernel page tables queued while booting. */ | |
| 463 | + | schedule_kernel_pgtable_free(); | |
| 464 | + | return 0; | |
| 448 | 465 | } | |
| 466 | + | core_initcall(kernel_pgtable_drain_early); | |
| 449 | 467 | #endif | |
modified mm/shmem.c
| @@ -1847,8 +1847,11 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode, | |||
| 1847 | 1847 | ||
| 1848 | 1848 | global_orders = shmem_huge_global_enabled(inode, index, write_end, | |
| 1849 | 1849 | shmem_huge_force, vma, vm_flags); | |
| 1850 | - | /* Tmpfs huge pages allocation */ | |
| 1851 | - | if (!vma || !vma_is_anon_shmem(vma)) | |
| 1850 | + | /* | |
| 1851 | + | * Tmpfs huge pages allocation or forced collapse ignores | |
| 1852 | + | * sysfs configs. | |
| 1853 | + | */ | |
| 1854 | + | if (!vma || !vma_is_anon_shmem(vma) || shmem_huge_force) | |
| 1852 | 1855 | return global_orders; | |
| 1853 | 1856 | ||
| 1854 | 1857 | /* | |
modified mm/slub.c
| @@ -5969,7 +5969,8 @@ alloc_empty: | |||
| 5969 | 5969 | if (!allow_spin) | |
| 5970 | 5970 | return NULL; | |
| 5971 | 5971 | ||
| 5972 | - | empty = alloc_empty_sheaf(s, GFP_NOWAIT, SLAB_ALLOC_DEFAULT); | |
| 5972 | + | /* Don't wake up kswapd, it will cause deadlock under pi_lock */ | |
| 5973 | + | empty = alloc_empty_sheaf(s, __GFP_NOWARN, SLAB_ALLOC_DEFAULT); | |
| 5973 | 5974 | if (empty) | |
| 5974 | 5975 | goto got_empty; | |
| 5975 | 5976 | ||
| @@ -6128,7 +6129,6 @@ bool __kfree_rcu_sheaf(struct kmem_cache *s, void *obj, unsigned int free_flags) | |||
| 6128 | 6129 | struct slab_sheaf *empty; | |
| 6129 | 6130 | struct node_barn *barn; | |
| 6130 | 6131 | unsigned int alloc_flags = to_alloc_flags(free_flags); | |
| 6131 | - | gfp_t gfp = allow_spin ? GFP_NOWAIT : __GFP_NOWARN; | |
| 6132 | 6132 | ||
| 6133 | 6133 | /* Bootstrap or debug cache, fall back */ | |
| 6134 | 6134 | if (unlikely(!cache_has_sheaves(s))) { | |
| @@ -6157,7 +6157,8 @@ bool __kfree_rcu_sheaf(struct kmem_cache *s, void *obj, unsigned int free_flags) | |||
| 6157 | 6157 | ||
| 6158 | 6158 | local_unlock(&s->cpu_sheaves->lock); | |
| 6159 | 6159 | ||
| 6160 | - | empty = alloc_empty_sheaf(s, gfp, alloc_flags); | |
| 6160 | + | /* Don't wake up kswapd, it will cause deadlock under pi_lock */ | |
| 6161 | + | empty = alloc_empty_sheaf(s, __GFP_NOWARN, alloc_flags); | |
| 6161 | 6162 | ||
| 6162 | 6163 | if (!empty) | |
| 6163 | 6164 | goto fail; | |
modified mm/vma.c
| @@ -634,8 +634,8 @@ out_free_vma: | |||
| 634 | 634 | * Split a vma into two pieces at address 'addr', a new vma is allocated | |
| 635 | 635 | * either for the first part or the tail. | |
| 636 | 636 | */ | |
| 637 | - | static int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, | |
| 638 | - | unsigned long addr, int new_below) | |
| 637 | + | int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, | |
| 638 | + | unsigned long addr, int new_below) | |
| 639 | 639 | { | |
| 640 | 640 | if (vma->vm_mm->map_count >= get_sysctl_max_map_count()) | |
| 641 | 641 | return -ENOMEM; | |
| @@ -1943,7 +1943,7 @@ static int vma_link(struct mm_struct *mm, struct vm_area_struct *vma) | |||
| 1943 | 1943 | */ | |
| 1944 | 1944 | struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, | |
| 1945 | 1945 | unsigned long addr, unsigned long len, pgoff_t pgoff, | |
| 1946 | - | pgoff_t anon_pgoff, bool *need_rmap_locks) | |
| 1946 | + | pgoff_t anon_pgoff, bool *need_rmap_locks, bool keep_source) | |
| 1947 | 1947 | { | |
| 1948 | 1948 | struct vm_area_struct *vma = *vmap; | |
| 1949 | 1949 | unsigned long old_vma_start = vma->vm_start; | |
| @@ -1981,6 +1981,21 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, | |||
| 1981 | 1981 | vmg.pgoff = pgoff; | |
| 1982 | 1982 | vmg.anon_pgoff = anon_pgoff; | |
| 1983 | 1983 | vmg.next = vma_iter_next_rewind(&vmi, NULL); | |
| 1984 | + | ||
| 1985 | + | /* | |
| 1986 | + | * If the original VMA is kept (MREMAP_DONTUNMAP), the source and | |
| 1987 | + | * destination VMA must be treated distinctly. | |
| 1988 | + | * | |
| 1989 | + | * A merge violates this, so in this case disallow a self-merge. | |
| 1990 | + | */ | |
| 1991 | + | if (can_self_merge && keep_source) { | |
| 1992 | + | if (vmg.prev == vma) | |
| 1993 | + | vmg.prev = NULL; | |
| 1994 | + | if (vmg.next == vma) | |
| 1995 | + | vmg.next = NULL; | |
| 1996 | + | can_self_merge = false; | |
| 1997 | + | } | |
| 1998 | + | ||
| 1984 | 1999 | new_vma = vma_merge_copied_range(&vmg); | |
| 1985 | 2000 | ||
| 1986 | 2001 | if (new_vma) { | |
| @@ -2849,7 +2864,7 @@ static unsigned long __mmap_region(struct file *file, unsigned long addr, | |||
| 2849 | 2864 | { | |
| 2850 | 2865 | struct mm_struct *mm = current->mm; | |
| 2851 | 2866 | struct vm_area_struct *vma = NULL; | |
| 2852 | - | bool have_mmap_prepare = file && file->f_op->mmap_prepare; | |
| 2867 | + | const bool have_mmap_prepare = file && file->f_op->mmap_prepare; | |
| 2853 | 2868 | VMA_ITERATOR(vmi, mm, addr); | |
| 2854 | 2869 | const pgoff_t anon_pgoff = addr >> PAGE_SHIFT; | |
| 2855 | 2870 | MMAP_STATE(map, mm, &vmi, addr, len, pgoff, anon_pgoff, vma_flags, file); | |
| @@ -2892,7 +2907,7 @@ static unsigned long __mmap_region(struct file *file, unsigned long addr, | |||
| 2892 | 2907 | allocated_new = true; | |
| 2893 | 2908 | } | |
| 2894 | 2909 | ||
| 2895 | - | if (have_mmap_prepare) | |
| 2910 | + | if (have_mmap_prepare && allocated_new) | |
| 2896 | 2911 | set_vma_user_defined_fields(vma, &map); | |
| 2897 | 2912 | ||
| 2898 | 2913 | __mmap_complete(&map, vma); | |
modified mm/vma.h
| @@ -535,7 +535,7 @@ void unlink_file_vma_batch_add(struct unlink_vma_file_batch *vb, | |||
| 535 | 535 | ||
| 536 | 536 | struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, | |
| 537 | 537 | unsigned long addr, unsigned long len, pgoff_t pgoff, | |
| 538 | - | pgoff_t anon_pgoff, bool *need_rmap_locks); | |
| 538 | + | pgoff_t anon_pgoff, bool *need_rmap_locks, bool keep_source); | |
| 539 | 539 | ||
This diff is too large to show in full - only the first part is shown.