Merge tag 'sound-6.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 9 Sep 2022 11:36:10 +0000 (07:36 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 9 Sep 2022 11:36:10 +0000 (07:36 -0400)
Pull sound fixes from Takashi Iwai:
 "Lots of small fixes for various drivers at this time, hopefully it
  will be the last big bump before 6.0 release.

  The significant changes are regression fixes for (yet again) HD-audio
  memory allocations and USB-audio PCM parameter handling, while there
  are many small ASoC device-specific fixes as well as a few
  out-of-bounds and race issues spotted by fuzzers"

* tag 'sound-6.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (29 commits)
  ALSA: usb-audio: Clear fixed clock rate at closing EP
  ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc()
  ALSA: hda: Once again fix regression of page allocations with IOMMU
  ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface()
  ALSA: hda/tegra: Align BDL entry to 4KB boundary
  ALSA: hda/sigmatel: Fix unused variable warning for beep power change
  ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC
  ALSA: hda/sigmatel: Keep power up while beep is enabled
  ALSA: aloop: Fix random zeros in capture data when using jiffies timer
  ALSA: usb-audio: Split endpoint setups for hw_params and prepare
  ALSA: usb-audio: Register card again for iface over delayed_register option
  ALSA: usb-audio: Inform the delayed registration more properly
  ASoC: fsl_aud2htx: Add error handler for pm_runtime_enable
  ASoC: fsl_aud2htx: register platform component before registering cpu dai
  ASoC: SOF: ipc4-topology: fix alh_group_ida max value
  ASoC: mchp-spdiftx: Fix clang -Wbitfield-constant-conversion
  ASoC: SOF: Kconfig: Make IPC_MESSAGE_INJECTOR depend on SND_SOC_SOF
  ASoC: SOF: Kconfig: Make IPC_FLOOD_TEST depend on SND_SOC_SOF
  ASoC: fsl_mqs: Fix supported clock DAI format
  ASoC: nau8540: Implement hw constraint for rates
  ...

818 files changed:
.get_maintainer.ignore
.mailmap
Documentation/ABI/testing/sysfs-devices-system-cpu
Documentation/admin-guide/README.rst
Documentation/admin-guide/hw-vuln/processor_mmio_stale_data.rst
Documentation/admin-guide/kernel-parameters.txt
Documentation/admin-guide/mm/damon/usage.rst
Documentation/admin-guide/sysctl/net.rst
Documentation/arm64/elf_hwcaps.rst
Documentation/arm64/silicon-errata.rst
Documentation/atomic_bitops.txt
Documentation/block/index.rst
Documentation/block/ublk.rst [new file with mode: 0644]
Documentation/conf.py
Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml
Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.yaml
Documentation/devicetree/bindings/thermal/thermal-zones.yaml
Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
Documentation/input/joydev/joystick.rst
Documentation/networking/devlink/netdevsim.rst
Documentation/networking/driver.rst
Documentation/networking/ip-sysctl.rst
Documentation/networking/ipvlan.rst
Documentation/networking/l2tp.rst
Documentation/networking/rxrpc.rst
Documentation/networking/switchdev.rst
Documentation/sphinx/kerneldoc-preamble.sty
Documentation/translations/ja_JP/SubmittingPatches
MAINTAINERS
Makefile
arch/Kconfig
arch/alpha/include/asm/bitops.h
arch/arm/boot/dts/arm-realview-eb.dtsi
arch/arm/boot/dts/arm-realview-pb1176.dts
arch/arm/boot/dts/arm-realview-pb11mp.dts
arch/arm/boot/dts/arm-realview-pbx.dtsi
arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi
arch/arm/boot/dts/at91-sama5d2_icp.dts
arch/arm/boot/dts/at91-sama7g5ek.dts
arch/arm/boot/dts/bcm63178.dtsi
arch/arm/boot/dts/bcm6846.dtsi
arch/arm/boot/dts/bcm6878.dtsi
arch/arm/boot/dts/imx6qdl-kontron-samx6i.dtsi
arch/arm/boot/dts/imx6qdl-vicut1.dtsi
arch/arm/boot/dts/integratorap-im-pd1.dts
arch/arm/boot/dts/versatile-ab.dts
arch/arm/configs/at91_dt_defconfig
arch/arm/configs/sama7_defconfig
arch/arm/kernel/irq.c
arch/arm/mach-at91/pm.c
arch/arm/mach-at91/pm_suspend.S
arch/arm/mach-ixp4xx/ixp4xx-of.c
arch/arm64/Kconfig
arch/arm64/boot/dts/arm/juno-base.dtsi
arch/arm64/boot/dts/arm/juno-cs-r1r2.dtsi
arch/arm64/boot/dts/freescale/fsl-ls1028a-qds-65bb.dts
arch/arm64/boot/dts/freescale/imx8mm-venice-gw7901.dts
arch/arm64/boot/dts/freescale/imx8mm-verdin.dtsi
arch/arm64/boot/dts/freescale/imx8mp-dhcom-som.dtsi
arch/arm64/boot/dts/freescale/imx8mp-venice-gw74xx.dts
arch/arm64/boot/dts/freescale/imx8mp-verdin.dtsi
arch/arm64/boot/dts/freescale/imx8mq-tqma8mq.dtsi
arch/arm64/boot/dts/renesas/r8a779g0.dtsi
arch/arm64/include/asm/cache.h
arch/arm64/include/asm/fpsimd.h
arch/arm64/include/asm/kernel-pgtable.h
arch/arm64/include/asm/setup.h
arch/arm64/include/asm/sysreg.h
arch/arm64/kernel/cacheinfo.c
arch/arm64/kernel/cpu_errata.c
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/entry.S
arch/arm64/kernel/fpsimd.c
arch/arm64/kernel/head.S
arch/arm64/kernel/machine_kexec_file.c
arch/arm64/kernel/pi/kaslr_early.c
arch/arm64/kernel/ptrace.c
arch/arm64/kernel/signal.c
arch/arm64/kernel/topology.c
arch/arm64/mm/mmu.c
arch/arm64/tools/cpucaps
arch/hexagon/include/asm/bitops.h
arch/ia64/include/asm/bitops.h
arch/loongarch/Kconfig
arch/loongarch/include/asm/acpi.h
arch/loongarch/include/asm/addrspace.h
arch/loongarch/include/asm/cmpxchg.h
arch/loongarch/include/asm/io.h
arch/loongarch/include/asm/page.h
arch/loongarch/include/asm/percpu.h
arch/loongarch/include/asm/pgtable.h
arch/loongarch/include/asm/reboot.h [deleted file]
arch/loongarch/kernel/acpi.c
arch/loongarch/kernel/reset.c
arch/loongarch/kernel/signal.c
arch/loongarch/kernel/vmlinux.lds.S
arch/loongarch/lib/dump_tlb.c
arch/loongarch/mm/fault.c
arch/loongarch/mm/init.c
arch/loongarch/mm/mmap.c
arch/loongarch/vdso/vgetcpu.c
arch/loongarch/vdso/vgettimeofday.c
arch/m68k/include/asm/bitops.h
arch/parisc/Kconfig
arch/parisc/include/asm/bitops.h
arch/parisc/kernel/head.S
arch/parisc/kernel/irq.c
arch/parisc/kernel/unaligned.c
arch/powerpc/include/asm/firmware.h
arch/powerpc/include/asm/hw_irq.h
arch/powerpc/kernel/irq.c
arch/powerpc/kernel/pci_32.c
arch/powerpc/kernel/rtas_entry.S
arch/powerpc/kernel/systbl.S
arch/powerpc/platforms/pseries/papr_scm.c
arch/riscv/boot/dts/microchip/mpfs-icicle-kit.dts
arch/riscv/boot/dts/microchip/mpfs-polarberry.dts
arch/riscv/boot/dts/microchip/mpfs.dtsi
arch/riscv/include/asm/kvm_vcpu_sbi.h
arch/riscv/include/asm/signal.h [new file with mode: 0644]
arch/riscv/include/asm/thread_info.h
arch/riscv/kernel/signal.c
arch/riscv/kernel/traps.c
arch/riscv/kvm/vcpu_sbi.c
arch/riscv/kvm/vcpu_timer.c
arch/riscv/mm/pageattr.c
arch/s390/configs/debug_defconfig
arch/s390/configs/defconfig
arch/s390/configs/zfcpdump_defconfig
arch/s390/include/asm/bitops.h
arch/s390/include/asm/hugetlb.h
arch/s390/include/asm/kvm_host.h
arch/s390/include/asm/softirq_stack.h
arch/s390/kernel/process.c
arch/s390/kernel/vmlinux.lds.S
arch/s390/kvm/pci.c
arch/s390/mm/fault.c
arch/s390/pci/Makefile
arch/s390/pci/pci_kvm_hook.c [new file with mode: 0644]
arch/sh/include/asm/bitops-op32.h
arch/sh/kernel/irq.c
arch/sparc/kernel/irq_64.c
arch/x86/boot/compressed/misc.h
arch/x86/boot/compressed/sev.c
arch/x86/configs/xen.config
arch/x86/entry/entry_64_compat.S
arch/x86/events/intel/core.c
arch/x86/events/intel/ds.c
arch/x86/events/intel/lbr.c
arch/x86/events/intel/uncore_snb.c
arch/x86/include/asm/bitops.h
arch/x86/include/asm/cpufeatures.h
arch/x86/include/asm/intel-family.h
arch/x86/include/asm/irq_stack.h
arch/x86/include/asm/nospec-branch.h
arch/x86/include/asm/sev.h
arch/x86/kernel/cpu/bugs.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/irq_32.c
arch/x86/kernel/sev.c
arch/x86/kernel/unwind_orc.c
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/mmu/spte.h
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c
arch/x86/mm/pat/memtype.c
block/blk-mq.c
drivers/acpi/processor_thermal.c
drivers/acpi/property.c
drivers/amba/bus.c
drivers/android/binder.c
drivers/android/binder_alloc.c
drivers/base/arch_topology.c
drivers/base/dd.c
drivers/base/firmware_loader/sysfs.c
drivers/base/firmware_loader/sysfs.h
drivers/base/firmware_loader/sysfs_upload.c
drivers/base/power/domain.c
drivers/base/regmap/regmap-spi.c
drivers/block/loop.c
drivers/block/xen-blkback/common.h
drivers/block/xen-blkback/xenbus.c
drivers/block/xen-blkfront.c
drivers/block/zram/zram_drv.c
drivers/block/zram/zram_drv.h
drivers/bus/mhi/host/main.c
drivers/char/mem.c
drivers/clk/bcm/clk-raspberrypi.c
drivers/clk/clk.c
drivers/clk/ti/clk.c
drivers/cpufreq/cpufreq.c
drivers/dma-buf/dma-resv.c
drivers/firmware/dmi_scan.c
drivers/firmware/efi/capsule-loader.c
drivers/firmware/efi/libstub/Makefile
drivers/firmware/efi/libstub/x86-stub.c
drivers/gpio/gpio-104-dio-48e.c
drivers/gpio/gpio-104-idi-48.c
drivers/gpio/gpio-104-idio-16.c
drivers/gpio/gpio-mockup.c
drivers/gpio/gpio-pca953x.c
drivers/gpio/gpio-pxa.c
drivers/gpio/gpio-realtek-otto.c
drivers/gpio/gpio-ws16c48.c
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c
drivers/gpu/drm/amd/amdgpu/nbio_v7_7.c
drivers/gpu/drm/amd/amdgpu/soc21.c
drivers/gpu/drm/amd/amdkfd/kfd_device.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dio_link_encoder.c
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_dio_stream_encoder.c
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_optc.c
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_dccg.c
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_dio_stream_encoder.c
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
drivers/gpu/drm/amd/display/dc/link/link_hwss_hpo_dp.c
drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_7_7_0_offset.h
drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_7_7_0_sh_mask.h
drivers/gpu/drm/amd/include/mes_v11_api_def.h
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
drivers/gpu/drm/drm_gem.c
drivers/gpu/drm/drm_internal.h
drivers/gpu/drm/drm_prime.c
drivers/gpu/drm/i915/display/icl_dsi.c
drivers/gpu/drm/i915/display/intel_backlight.c
drivers/gpu/drm/i915/display/intel_bios.c
drivers/gpu/drm/i915/display/intel_bw.c
drivers/gpu/drm/i915/display/intel_dp.c
drivers/gpu/drm/i915/display/intel_quirks.c
drivers/gpu/drm/i915/display/vlv_dsi.c
drivers/gpu/drm/i915/gt/intel_migrate.c
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
drivers/gpu/drm/i915/gvt/aperture_gm.c
drivers/gpu/drm/i915/gvt/gtt.c
drivers/gpu/drm/i915/gvt/handlers.c
drivers/gpu/drm/i915/gvt/mmio_context.c
drivers/gpu/drm/i915/intel_gvt_mmio_table.c
drivers/gpu/drm/i915/intel_pm.c
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
drivers/gpu/drm/msm/dp/dp_ctrl.c
drivers/gpu/drm/msm/dsi/dsi_cfg.c
drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_gpu_devfreq.c
drivers/gpu/drm/msm/msm_rd.c
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/vc4/Kconfig
drivers/gpu/drm/vc4/vc4_hdmi.c
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
drivers/hid/hid-asus.c
drivers/hid/hid-ids.h
drivers/hid/hid-input.c
drivers/hid/hid-nintendo.c
drivers/hid/hid-quirks.c
drivers/hid/hid-steam.c
drivers/hid/hid-thrustmaster.c
drivers/hid/hidraw.c
drivers/hid/intel-ish-hid/ipc/hw-ish.h
drivers/hid/intel-ish-hid/ipc/pci-ish.c
drivers/hid/intel-ish-hid/ishtp-hid.h
drivers/hid/intel-ish-hid/ishtp/client.c
drivers/hwmon/gpio-fan.c
drivers/hwmon/pmbus/pmbus_core.c
drivers/iio/adc/ad7292.c
drivers/iio/adc/mcp3911.c
drivers/iio/light/cm32181.c
drivers/iio/light/cm3605.c
drivers/input/joystick/iforce/iforce-main.c
drivers/input/joystick/iforce/iforce-serio.c
drivers/input/joystick/iforce/iforce-usb.c
drivers/input/joystick/iforce/iforce.h
drivers/input/misc/rk805-pwrkey.c
drivers/input/touchscreen/goodix.c
drivers/iommu/of_iommu.c
drivers/md/md.c
drivers/md/raid10.c
drivers/media/rc/mceusb.c
drivers/misc/fastrpc.c
drivers/mmc/core/sd.c
drivers/mmc/host/Kconfig
drivers/net/bonding/bond_3ad.c
drivers/net/bonding/bond_main.c
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.h
drivers/net/dsa/ocelot/felix_vsc9959.c
drivers/net/dsa/qca/qca8k-8xxx.c
drivers/net/dsa/xrs700x/xrs700x.c
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/cortina/gemini.c
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
drivers/net/ethernet/freescale/fec.h
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/freescale/fec_ptp.c
drivers/net/ethernet/fungible/funeth/funeth_txrx.h
drivers/net/ethernet/google/gve/gve_ethtool.c
drivers/net/ethernet/google/gve/gve_main.c
drivers/net/ethernet/huawei/hinic/hinic_rx.c
drivers/net/ethernet/huawei/hinic/hinic_tx.c
drivers/net/ethernet/intel/i40e/i40e_client.c
drivers/net/ethernet/intel/i40e/i40e_ethtool.c
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/i40e/i40e_txrx.c
drivers/net/ethernet/intel/iavf/iavf_main.c
drivers/net/ethernet/intel/ice/ice.h
drivers/net/ethernet/intel/ice/ice_base.c
drivers/net/ethernet/intel/ice/ice_lib.c
drivers/net/ethernet/intel/ice/ice_main.c
drivers/net/ethernet/intel/ice/ice_xsk.c
drivers/net/ethernet/intel/ice/ice_xsk.h
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
drivers/net/ethernet/lantiq_xrx200.c
drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/mediatek/mtk_eth_soc.h
drivers/net/ethernet/mediatek/mtk_ppe.c
drivers/net/ethernet/mediatek/mtk_ppe.h
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
drivers/net/ethernet/mellanox/mlx5/core/main.c
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
drivers/net/ethernet/mellanox/mlx5/core/sriov.c
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
drivers/net/ethernet/moxa/moxart_ether.c
drivers/net/ethernet/netronome/nfp/flower/qos_conf.c
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c
drivers/net/ethernet/pensando/ionic/ionic_lif.c
drivers/net/ethernet/pensando/ionic/ionic_main.c
drivers/net/ethernet/rocker/rocker_ofdpa.c
drivers/net/ethernet/smsc/smsc911x.c
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ieee802154/adf7242.c
drivers/net/ieee802154/ca8210.c
drivers/net/ieee802154/cc2520.c
drivers/net/ipa/ipa_mem.c
drivers/net/ipvlan/ipvtap.c
drivers/net/macsec.c
drivers/net/mdio/fwnode_mdio.c
drivers/net/netdevsim/netdev.c
drivers/net/phy/meson-gxl.c
drivers/net/phy/micrel.c
drivers/net/phy/microchip_t1.c
drivers/net/phy/phy_device.c
drivers/net/usb/cdc_ether.c
drivers/net/usb/qmi_wwan.c
drivers/net/usb/r8152.c
drivers/net/wireless/intel/iwlegacy/4965-rs.c
drivers/net/wireless/mac80211_hwsim.c
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c
drivers/net/wireless/microchip/wilc1000/netdev.h
drivers/net/wireless/microchip/wilc1000/sdio.c
drivers/net/wireless/microchip/wilc1000/wlan.c
drivers/net/xen-netback/xenbus.c
drivers/nfc/pn533/uart.c
drivers/nvme/host/pci.c
drivers/nvme/target/auth.c
drivers/nvme/target/tcp.c
drivers/parisc/ccio-dma.c
drivers/parisc/led.c
drivers/peci/controller/peci-aspeed.c
drivers/peci/cpu.c
drivers/perf/arm_pmu_platform.c
drivers/platform/mellanox/mlxreg-lc.c
drivers/platform/surface/surface_aggregator_registry.c
drivers/platform/x86/acer-wmi.c
drivers/platform/x86/asus-wmi.c
drivers/platform/x86/p2sb.c
drivers/platform/x86/pmc_atom.c
drivers/platform/x86/thinkpad_acpi.c
drivers/platform/x86/x86-android-tablets.c
drivers/regulator/core.c
drivers/regulator/pfuze100-regulator.c
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/megaraid/megaraid_sas_fusion.c
drivers/scsi/qla2xxx/qla_target.c
drivers/scsi/scsi_lib.c
drivers/scsi/sd.c
drivers/scsi/sd.h
drivers/scsi/storvsc_drv.c
drivers/soc/bcm/brcmstb/pm/pm-arm.c
drivers/soc/fsl/Kconfig
drivers/soc/imx/gpcv2.c
drivers/soc/imx/imx8m-blk-ctrl.c
drivers/soundwire/qcom.c
drivers/spi/spi-bitbang-txrx.h
drivers/spi/spi-cadence-quadspi.c
drivers/spi/spi-mux.c
drivers/spi/spi.c
drivers/staging/r8188eu/os_dep/os_intfs.c
drivers/staging/r8188eu/os_dep/usb_intf.c
drivers/staging/rtl8712/rtl8712_cmd.c
drivers/tee/tee_shm.c
drivers/thermal/intel/int340x_thermal/int3400_thermal.c
drivers/thermal/thermal_core.c
drivers/thunderbolt/ctl.c
drivers/thunderbolt/switch.c
drivers/tty/n_gsm.c
drivers/tty/serial/atmel_serial.c
drivers/tty/serial/fsl_lpuart.c
drivers/tty/tty_buffer.c
drivers/tty/vt/vt.c
drivers/ufs/core/ufshcd.c
drivers/ufs/host/ufs-exynos.c
drivers/usb/cdns3/cdns3-gadget.c
drivers/usb/class/cdc-acm.c
drivers/usb/core/hub.c
drivers/usb/dwc2/platform.c
drivers/usb/dwc3/core.c
drivers/usb/dwc3/dwc3-pci.c
drivers/usb/dwc3/dwc3-qcom.c
drivers/usb/dwc3/gadget.c
drivers/usb/dwc3/host.c
drivers/usb/gadget/function/f_uac2.c
drivers/usb/gadget/function/storage_common.c
drivers/usb/gadget/udc/core.c
drivers/usb/host/xhci-hub.c
drivers/usb/host/xhci-mtk-sch.c
drivers/usb/host/xhci-plat.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h
drivers/usb/misc/onboard_usb_hub.c
drivers/usb/musb/Kconfig
drivers/usb/serial/ch341.c
drivers/usb/serial/cp210x.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/ftdi_sio_ids.h
drivers/usb/serial/option.c
drivers/usb/storage/unusual_devs.h
drivers/usb/storage/unusual_uas.h
drivers/usb/typec/altmodes/displayport.c
drivers/usb/typec/class.c
drivers/usb/typec/mux/intel_pmc_mux.c
drivers/usb/typec/tcpm/tcpm.c
drivers/usb/typec/ucsi/ucsi.c
drivers/vfio/pci/vfio_pci_zdev.c
drivers/video/console/sticore.c
drivers/video/fbdev/aty/atyfb_base.c
drivers/video/fbdev/aty/radeon_base.c
drivers/video/fbdev/bw2.c
drivers/video/fbdev/chipsfb.c
drivers/video/fbdev/cirrusfb.c
drivers/video/fbdev/clps711x-fb.c
drivers/video/fbdev/core/fbcon.c
drivers/video/fbdev/core/fbsysfs.c
drivers/video/fbdev/cyber2000fb.c
drivers/video/fbdev/ffb.c
drivers/video/fbdev/geode/gx1fb_core.c
drivers/video/fbdev/gxt4500.c
drivers/video/fbdev/i740fb.c
drivers/video/fbdev/imxfb.c
drivers/video/fbdev/matrox/matroxfb_base.c
drivers/video/fbdev/omap/omapfb_main.c
drivers/video/fbdev/omap2/omapfb/omapfb-main.c
drivers/video/fbdev/pm2fb.c
drivers/video/fbdev/pxa168fb.c
drivers/video/fbdev/pxafb.c
drivers/video/fbdev/s3fb.c
drivers/video/fbdev/simplefb.c
drivers/video/fbdev/sis/sis_main.c
drivers/video/fbdev/sm501fb.c
drivers/video/fbdev/ssd1307fb.c
drivers/video/fbdev/sstfb.c
drivers/video/fbdev/sunxvr1000.c
drivers/video/fbdev/sunxvr2500.c
drivers/video/fbdev/sunxvr500.c
drivers/video/fbdev/tcx.c
drivers/video/fbdev/tdfxfb.c
drivers/video/fbdev/tgafb.c
drivers/video/fbdev/tridentfb.c
drivers/xen/grant-table.c
drivers/xen/privcmd.c
drivers/xen/xen-scsiback.c
drivers/xen/xenbus/xenbus_probe_frontend.c
fs/afs/flock.c
fs/afs/fsclient.c
fs/afs/internal.h
fs/afs/misc.c
fs/afs/rxrpc.c
fs/afs/yfsclient.c
fs/btrfs/block-group.c
fs/btrfs/block-group.h
fs/btrfs/ctree.h
fs/btrfs/dev-replace.c
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/root-tree.c
fs/btrfs/volumes.c
fs/btrfs/xattr.c
fs/cachefiles/internal.h
fs/cachefiles/ondemand.c
fs/cifs/cifsencrypt.c
fs/cifs/cifsfs.c
fs/cifs/cifsglob.h
fs/cifs/connect.c
fs/cifs/smb2ops.c
fs/cifs/smb2pdu.c
fs/cifs/transport.c
fs/erofs/fscache.c
fs/erofs/internal.h
fs/erofs/zmap.c
fs/fs-writeback.c
fs/inode.c
fs/locks.c
fs/namespace.c
fs/nfs/dir.c
fs/nfs/file.c
fs/nfs/inode.c
fs/nfs/nfs4file.c
fs/nfs/pnfs.c
fs/nfs/write.c
fs/ntfs3/xattr.c
fs/ocfs2/dlmglue.c
fs/ocfs2/super.c
fs/overlayfs/inode.c
fs/posix_acl.c
fs/proc/task_mmu.c
fs/squashfs/file.c
fs/squashfs/file_direct.c
fs/squashfs/page_actor.c
fs/squashfs/page_actor.h
fs/tracefs/inode.c
fs/userfaultfd.c
include/asm-generic/bitops/generic-non-atomic.h
include/asm-generic/bitops/instrumented-non-atomic.h
include/asm-generic/bitops/non-atomic.h
include/asm-generic/bitops/non-instrumented-non-atomic.h
include/asm-generic/sections.h
include/asm-generic/softirq_stack.h
include/linux/amba/bus.h
include/linux/bitops.h
include/linux/buffer_head.h
include/linux/cgroup.h
include/linux/compiler.h
include/linux/device/driver.h
include/linux/fscache.h
include/linux/ieee80211.h
include/linux/lsm_hook_defs.h
include/linux/lsm_hooks.h
include/linux/memcontrol.h
include/linux/mlx5/driver.h
include/linux/mm.h
include/linux/netdevice.h
include/linux/netfilter_bridge/ebtables.h
include/linux/nfs_fs.h
include/linux/overflow.h
include/linux/platform_data/x86/pmc_atom.h
include/linux/psi.h
include/linux/rmap.h
include/linux/security.h
include/linux/serial_core.h
include/linux/shmem_fs.h
include/linux/skbuff.h
include/linux/spi/spi.h
include/linux/trace_events.h
include/linux/udp.h
include/linux/usb.h
include/linux/usb/typec_dp.h
include/linux/userfaultfd_k.h
include/linux/vm_event_item.h
include/linux/wait_bit.h
include/net/af_rxrpc.h
include/net/bond_3ad.h
include/net/busy_poll.h
include/net/dropreason.h
include/net/gro.h
include/net/ip_tunnels.h
include/net/netfilter/nf_conntrack.h
include/net/netfilter/nf_flow_table.h
include/net/netfilter/nf_tables.h
include/net/netns/conntrack.h
include/net/netns/ipv4.h
include/net/udp_tunnel.h
include/soc/at91/sama7-ddr.h
include/trace/events/skb.h
include/uapi/linux/bpf.h
include/uapi/linux/io_uring.h
include/uapi/linux/virtio_net.h
include/uapi/linux/xfrm.h
include/ufs/ufshci.h
init/main.c
io_uring/cancel.c
io_uring/io_uring.c
io_uring/net.c
io_uring/net.h
io_uring/notif.c
io_uring/notif.h
io_uring/opdef.c
io_uring/opdef.h
io_uring/rsrc.c
io_uring/rsrc.h
io_uring/uring_cmd.c
kernel/audit_fsnotify.c
kernel/auditsc.c
kernel/bpf/cgroup.c
kernel/bpf/core.c
kernel/bpf/syscall.c
kernel/bpf/verifier.c
kernel/cgroup/cgroup-v1.c
kernel/cgroup/cgroup.c
kernel/cgroup/cpuset.c
kernel/crash_core.c
kernel/kprobes.c
kernel/module/main.c
kernel/sched/psi.c
kernel/sched/wait_bit.c
kernel/sys_ni.c
kernel/trace/ftrace.c
kernel/trace/rv/monitors/wip/wip.h
kernel/trace/rv/monitors/wwnr/wwnr.h
kernel/trace/rv/reactor_panic.c
kernel/trace/rv/reactor_printk.c
kernel/trace/trace_events_trigger.c
kernel/trace/trace_preemptirq.c
kernel/tracepoint.c
lib/Kconfig.debug
lib/Makefile
lib/cpumask_kunit.c [moved from lib/test_cpumask.c with 58% similarity]
lib/crypto/Kconfig
lib/ratelimit.c
mm/backing-dev.c
mm/bootmem_info.c
mm/damon/dbgfs.c
mm/gup.c
mm/huge_memory.c
mm/hugetlb.c
mm/mmap.c
mm/mprotect.c
mm/page-writeback.c
mm/pagewalk.c
mm/ptdump.c
mm/rmap.c
mm/shmem.c
mm/slab_common.c
mm/userfaultfd.c
mm/vmstat.c
mm/zsmalloc.c
net/bluetooth/hci_event.c
net/bluetooth/hci_sync.c
net/bluetooth/hidp/core.c
net/bluetooth/iso.c
net/bluetooth/l2cap_core.c
net/bluetooth/mgmt.c
net/bridge/br_netfilter_hooks.c
net/bridge/br_netfilter_ipv6.c
net/bridge/netfilter/ebtable_broute.c
net/bridge/netfilter/ebtable_filter.c
net/bridge/netfilter/ebtable_nat.c
net/bridge/netfilter/ebtables.c
net/core/.gitignore [deleted file]
net/core/Makefile
net/core/bpf_sk_storage.c
net/core/datagram.c
net/core/dev.c
net/core/filter.c
net/core/gro_cells.c
net/core/neighbour.c
net/core/skbuff.c
net/core/skmsg.c
net/core/sock.c
net/core/sysctl_net_core.c
net/dsa/slave.c
net/dsa/tag_hellcreek.c
net/ipv4/devinet.c
net/ipv4/fib_frontend.c
net/ipv4/ip_gre.c
net/ipv4/ip_output.c
net/ipv4/ip_sockglue.c
net/ipv4/ip_tunnel.c
net/ipv4/tcp.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_output.c
net/ipv4/udp.c
net/ipv4/udp_tunnel_core.c
net/ipv6/addrconf.c
net/ipv6/ipv6_sockglue.c
net/ipv6/netfilter/nf_conntrack_reasm.c
net/ipv6/seg6.c
net/ipv6/udp.c
net/kcm/kcmsock.c
net/key/af_key.c
net/mac80211/ibss.c
net/mac80211/mlme.c
net/mac80211/rx.c
net/mac80211/scan.c
net/mac80211/sta_info.c
net/mac80211/tx.c
net/mac80211/wpa.c
net/mac802154/rx.c
net/mpls/af_mpls.c
net/mptcp/protocol.c
net/netfilter/ipvs/ip_vs_sync.c
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_helper.c
net/netfilter/nf_conntrack_irc.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nf_conntrack_proto_tcp.c
net/netfilter/nf_conntrack_standalone.c
net/netfilter/nf_flow_table_core.c
net/netfilter/nf_flow_table_offload.c
net/netfilter/nf_tables_api.c
net/netfilter/nft_ct.c
net/netfilter/nft_osf.c
net/netfilter/nft_payload.c
net/netfilter/nft_tproxy.c
net/netfilter/nft_tunnel.c
net/openvswitch/datapath.c
net/rose/rose_loopback.c
net/rxrpc/ar-internal.h
net/rxrpc/call_event.c
net/rxrpc/call_object.c
net/rxrpc/local_object.c
net/rxrpc/peer_event.c
net/rxrpc/recvmsg.c
net/rxrpc/rxkad.c
net/rxrpc/sendmsg.c
net/sched/sch_generic.c
net/sched/sch_sfb.c
net/sched/sch_tbf.c
net/smc/af_smc.c
net/smc/smc_core.c
net/smc/smc_core.h
net/smc/smc_wr.c
net/smc/smc_wr.h
net/socket.c
net/sunrpc/clnt.c
net/tipc/monitor.c
net/wireless/debugfs.c
net/wireless/lib80211_crypt_ccmp.c
net/xdp/xsk_buff_pool.c
net/xfrm/espintcp.c
net/xfrm/xfrm_input.c
net/xfrm/xfrm_output.c
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_state.c
scripts/Makefile.extrawarn
security/landlock/fs.c
security/security.c
security/selinux/hooks.c
security/selinux/include/classmap.h
security/smack/smack_lsm.c
tools/arch/arm64/include/uapi/asm/kvm.h
tools/include/linux/compiler_types.h
tools/lib/perf/evlist.c
tools/objtool/check.c
tools/perf/Documentation/intel-hybrid.txt
tools/perf/Documentation/perf-record.txt
tools/perf/Makefile.config
tools/perf/Makefile.perf
tools/perf/builtin-c2c.c
tools/perf/builtin-lock.c
tools/perf/builtin-record.c
tools/perf/builtin-sched.c
tools/perf/builtin-script.c
tools/perf/builtin-stat.c
tools/perf/dlfilters/dlfilter-show-cycles.c
tools/perf/tests/shell/stat.sh
tools/perf/util/affinity.c
tools/perf/util/genelf.c
tools/perf/util/metricgroup.c
tools/perf/util/stat-shadow.c
tools/testing/selftests/Makefile
tools/testing/selftests/bpf/DENYLIST.s390x
tools/testing/selftests/bpf/verifier/precise.c
tools/testing/selftests/drivers/net/bonding/Makefile [new file with mode: 0644]
tools/testing/selftests/drivers/net/bonding/bond-break-lacpdu-tx.sh [new file with mode: 0755]
tools/testing/selftests/drivers/net/bonding/config [new file with mode: 0644]
tools/testing/selftests/drivers/net/bonding/settings [new file with mode: 0644]
tools/testing/selftests/kvm/include/x86_64/processor.h
tools/testing/selftests/landlock/fs_test.c
tools/testing/selftests/lib.mk
tools/testing/selftests/net/.gitignore
tools/testing/selftests/net/io_uring_zerocopy_tx.c
tools/testing/selftests/net/io_uring_zerocopy_tx.sh
tools/testing/selftests/netfilter/nft_conntrack_helper.sh
tools/testing/selftests/sgx/sigstruct.c

index a64d219..c298bab 100644 (file)
@@ -1,2 +1,4 @@
+Alan Cox <alan@lxorguk.ukuu.org.uk>
+Alan Cox <root@hraefn.swansea.linux.org.uk>
 Christoph Hellwig <hch@lst.de>
 Marc Gonzalez <marc.w.gonzalez@free.fr>
index 38255d4..8ded2e7 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -98,8 +98,7 @@ Christian Brauner <brauner@kernel.org> <christian.brauner@ubuntu.com>
 Christian Marangi <ansuelsmth@gmail.com>
 Christophe Ricard <christophe.ricard@gmail.com>
 Christoph Hellwig <hch@lst.de>
-Colin Ian King <colin.king@intel.com> <colin.king@canonical.com>
-Colin Ian King <colin.king@intel.com> <colin.i.king@gmail.com>
+Colin Ian King <colin.i.king@gmail.com> <colin.king@canonical.com>
 Corey Minyard <minyard@acm.org>
 Damian Hobson-Garcia <dhobsong@igel.co.jp>
 Daniel Borkmann <daniel@iogearbox.net> <danborkmann@googlemail.com>
@@ -150,6 +149,8 @@ Greg Kroah-Hartman <gregkh@suse.de>
 Greg Kroah-Hartman <greg@kroah.com>
 Greg Kurz <groug@kaod.org> <gkurz@linux.vnet.ibm.com>
 Gregory CLEMENT <gregory.clement@bootlin.com> <gregory.clement@free-electrons.com>
+Guilherme G. Piccoli <kernel@gpiccoli.net> <gpiccoli@linux.vnet.ibm.com>
+Guilherme G. Piccoli <kernel@gpiccoli.net> <gpiccoli@canonical.com>
 Guo Ren <guoren@kernel.org> <guoren@linux.alibaba.com>
 Guo Ren <guoren@kernel.org> <ren_guo@c-sky.com>
 Gustavo Padovan <gustavo@las.ic.unicamp.br>
@@ -253,6 +254,7 @@ Linus Lüssing <linus.luessing@c0d3.blue> <linus.luessing@web.de>
 Li Yang <leoyang.li@nxp.com> <leoli@freescale.com>
 Li Yang <leoyang.li@nxp.com> <leo@zh-kernel.org>
 Lorenzo Pieralisi <lpieralisi@kernel.org> <lorenzo.pieralisi@arm.com>
+Luca Ceresoli <luca.ceresoli@bootlin.com> <luca@lucaceresoli.net>
 Lukasz Luba <lukasz.luba@arm.com> <l.luba@partner.samsung.com>
 Maciej W. Rozycki <macro@mips.com> <macro@imgtec.com>
 Maciej W. Rozycki <macro@orcam.me.uk> <macro@linux-mips.org>
index 5bf6188..760c889 100644 (file)
@@ -523,6 +523,7 @@ What:               /sys/devices/system/cpu/vulnerabilities
                /sys/devices/system/cpu/vulnerabilities/tsx_async_abort
                /sys/devices/system/cpu/vulnerabilities/itlb_multihit
                /sys/devices/system/cpu/vulnerabilities/mmio_stale_data
+               /sys/devices/system/cpu/vulnerabilities/retbleed
 Date:          January 2018
 Contact:       Linux kernel mailing list <linux-kernel@vger.kernel.org>
 Description:   Information about CPU vulnerabilities
index caa3c09..9eb6b90 100644 (file)
@@ -1,9 +1,9 @@
 .. _readme:
 
-Linux kernel release 5.x <http://kernel.org/>
+Linux kernel release 6.x <http://kernel.org/>
 =============================================
 
-These are the release notes for Linux version 5.  Read them carefully,
+These are the release notes for Linux version 6.  Read them carefully,
 as they tell you what this is all about, explain how to install the
 kernel, and what to do if something goes wrong.
 
@@ -63,7 +63,7 @@ Installing the kernel source
    directory where you have permissions (e.g. your home directory) and
    unpack it::
 
-     xz -cd linux-5.x.tar.xz | tar xvf -
+     xz -cd linux-6.x.tar.xz | tar xvf -
 
    Replace "X" with the version number of the latest kernel.
 
@@ -72,12 +72,12 @@ Installing the kernel source
    files.  They should match the library, and not get messed up by
    whatever the kernel-du-jour happens to be.
 
- - You can also upgrade between 5.x releases by patching.  Patches are
+ - You can also upgrade between 6.x releases by patching.  Patches are
    distributed in the xz format.  To install by patching, get all the
    newer patch files, enter the top level directory of the kernel source
-   (linux-5.x) and execute::
+   (linux-6.x) and execute::
 
-     xz -cd ../patch-5.x.xz | patch -p1
+     xz -cd ../patch-6.x.xz | patch -p1
 
    Replace "x" for all versions bigger than the version "x" of your current
    source tree, **in_order**, and you should be ok.  You may want to remove
@@ -85,13 +85,13 @@ Installing the kernel source
    that there are no failed patches (some-file-name# or some-file-name.rej).
    If there are, either you or I have made a mistake.
 
-   Unlike patches for the 5.x kernels, patches for the 5.x.y kernels
+   Unlike patches for the 6.x kernels, patches for the 6.x.y kernels
    (also known as the -stable kernels) are not incremental but instead apply
-   directly to the base 5.x kernel.  For example, if your base kernel is 5.0
-   and you want to apply the 5.0.3 patch, you must not first apply the 5.0.1
-   and 5.0.2 patches. Similarly, if you are running kernel version 5.0.2 and
-   want to jump to 5.0.3, you must first reverse the 5.0.2 patch (that is,
-   patch -R) **before** applying the 5.0.3 patch. You can read more on this in
+   directly to the base 6.x kernel.  For example, if your base kernel is 6.0
+   and you want to apply the 6.0.3 patch, you must not first apply the 6.0.1
+   and 6.0.2 patches. Similarly, if you are running kernel version 6.0.2 and
+   want to jump to 6.0.3, you must first reverse the 6.0.2 patch (that is,
+   patch -R) **before** applying the 6.0.3 patch. You can read more on this in
    :ref:`Documentation/process/applying-patches.rst <applying_patches>`.
 
    Alternatively, the script patch-kernel can be used to automate this
@@ -114,7 +114,7 @@ Installing the kernel source
 Software requirements
 ---------------------
 
-   Compiling and running the 5.x kernels requires up-to-date
+   Compiling and running the 6.x kernels requires up-to-date
    versions of various software packages.  Consult
    :ref:`Documentation/process/changes.rst <changes>` for the minimum version numbers
    required and how to get updates for these packages.  Beware that using
@@ -132,12 +132,12 @@ Build directory for the kernel
    place for the output files (including .config).
    Example::
 
-     kernel source code: /usr/src/linux-5.x
+     kernel source code: /usr/src/linux-6.x
      build directory:    /home/name/build/kernel
 
    To configure and build the kernel, use::
 
-     cd /usr/src/linux-5.x
+     cd /usr/src/linux-6.x
      make O=/home/name/build/kernel menuconfig
      make O=/home/name/build/kernel
      sudo make O=/home/name/build/kernel modules_install install
index 9393c50..c98fd11 100644 (file)
@@ -230,6 +230,20 @@ The possible values in this file are:
      * - 'Mitigation: Clear CPU buffers'
        - The processor is vulnerable and the CPU buffer clearing mitigation is
          enabled.
+     * - 'Unknown: No mitigations'
+       - The processor vulnerability status is unknown because it is
+        out of Servicing period. Mitigation is not attempted.
+
+Definitions:
+------------
+
+Servicing period: The process of providing functional and security updates to
+Intel processors or platforms, utilizing the Intel Platform Update (IPU)
+process or other similar mechanisms.
+
+End of Servicing Updates (ESU): ESU is the date at which Intel will no
+longer provide Servicing, such as through IPU or other similar update
+processes. ESU dates will typically be aligned to end of quarter.
 
 If the processor is vulnerable then the following information is appended to
 the above information:
index d7f3090..426fa89 100644 (file)
        rodata=         [KNL]
                on      Mark read-only kernel memory as read-only (default).
                off     Leave read-only kernel memory writable for debugging.
+               full    Mark read-only kernel memory and aliases as read-only
+                       [arm64]
 
        rockchip.usb_uart
                        Enable the uart passthrough on the designated usb port
index d52f572..ca91ecc 100644 (file)
@@ -50,10 +50,10 @@ For a short example, users can monitor the virtual address space of a given
 workload as below. ::
 
     # cd /sys/kernel/mm/damon/admin/
-    # echo 1 > kdamonds/nr && echo 1 > kdamonds/0/contexts/nr
+    # echo 1 > kdamonds/nr_kdamonds && echo 1 > kdamonds/0/contexts/nr_contexts
     # echo vaddr > kdamonds/0/contexts/0/operations
-    # echo 1 > kdamonds/0/contexts/0/targets/nr
-    # echo $(pidof <workload>) > kdamonds/0/contexts/0/targets/0/pid
+    # echo 1 > kdamonds/0/contexts/0/targets/nr_targets
+    # echo $(pidof <workload>) > kdamonds/0/contexts/0/targets/0/pid_target
     # echo on > kdamonds/0/state
 
 Files Hierarchy
@@ -366,12 +366,12 @@ memory rate becomes larger than 60%, or lower than 30%". ::
     # echo 1 > kdamonds/0/contexts/0/schemes/nr_schemes
     # cd kdamonds/0/contexts/0/schemes/0
     # # set the basic access pattern and the action
-    # echo 4096 > access_patterns/sz/min
-    # echo 8192 > access_patterns/sz/max
-    # echo 0 > access_patterns/nr_accesses/min
-    # echo 5 > access_patterns/nr_accesses/max
-    # echo 10 > access_patterns/age/min
-    # echo 20 > access_patterns/age/max
+    # echo 4096 > access_pattern/sz/min
+    # echo 8192 > access_pattern/sz/max
+    # echo 0 > access_pattern/nr_accesses/min
+    # echo 5 > access_pattern/nr_accesses/max
+    # echo 10 > access_pattern/age/min
+    # echo 20 > access_pattern/age/max
     # echo pageout > action
     # # set quotas
     # echo 10 > quotas/ms
index 805f228..60d4416 100644 (file)
@@ -271,7 +271,7 @@ poll cycle or the number of packets processed reaches netdev_budget.
 netdev_max_backlog
 ------------------
 
-Maximum number  of  packets,  queued  on  the  INPUT  side, when the interface
+Maximum number of packets, queued on the INPUT side, when the interface
 receives packets faster than kernel can process them.
 
 netdev_rss_key
index 52b75a2..311021f 100644 (file)
@@ -242,44 +242,34 @@ HWCAP2_MTE3
     by Documentation/arm64/memory-tagging-extension.rst.
 
 HWCAP2_SME
-
     Functionality implied by ID_AA64PFR1_EL1.SME == 0b0001, as described
     by Documentation/arm64/sme.rst.
 
 HWCAP2_SME_I16I64
-
     Functionality implied by ID_AA64SMFR0_EL1.I16I64 == 0b1111.
 
 HWCAP2_SME_F64F64
-
     Functionality implied by ID_AA64SMFR0_EL1.F64F64 == 0b1.
 
 HWCAP2_SME_I8I32
-
     Functionality implied by ID_AA64SMFR0_EL1.I8I32 == 0b1111.
 
 HWCAP2_SME_F16F32
-
     Functionality implied by ID_AA64SMFR0_EL1.F16F32 == 0b1.
 
 HWCAP2_SME_B16F32
-
     Functionality implied by ID_AA64SMFR0_EL1.B16F32 == 0b1.
 
 HWCAP2_SME_F32F32
-
     Functionality implied by ID_AA64SMFR0_EL1.F32F32 == 0b1.
 
 HWCAP2_SME_FA64
-
     Functionality implied by ID_AA64SMFR0_EL1.FA64 == 0b1.
 
 HWCAP2_WFXT
-
     Functionality implied by ID_AA64ISAR2_EL1.WFXT == 0b0010.
 
 HWCAP2_EBF16
-
     Functionality implied by ID_AA64ISAR1_EL1.BF16 == 0b0010.
 
 4. Unused AT_HWCAP bits
index 33b04db..fda97b3 100644 (file)
@@ -52,6 +52,8 @@ stable kernels.
 | Allwinner      | A64/R18         | UNKNOWN1        | SUN50I_ERRATUM_UNKNOWN1     |
 +----------------+-----------------+-----------------+-----------------------------+
 +----------------+-----------------+-----------------+-----------------------------+
+| ARM            | Cortex-A510     | #2457168        | ARM64_ERRATUM_2457168       |
++----------------+-----------------+-----------------+-----------------------------+
 | ARM            | Cortex-A510     | #2064142        | ARM64_ERRATUM_2064142       |
 +----------------+-----------------+-----------------+-----------------------------+
 | ARM            | Cortex-A510     | #2038923        | ARM64_ERRATUM_2038923       |
index d8b101c..edea465 100644 (file)
@@ -58,13 +58,11 @@ Like with atomic_t, the rule of thumb is:
 
  - RMW operations that have a return value are fully ordered.
 
- - RMW operations that are conditional are unordered on FAILURE,
-   otherwise the above rules apply. In the case of test_and_set_bit_lock(),
-   if the bit in memory is unchanged by the operation then it is deemed to have
-   failed.
+ - RMW operations that are conditional are fully ordered.
 
-Except for a successful test_and_set_bit_lock() which has ACQUIRE semantics and
-clear_bit_unlock() which has RELEASE semantics.
+Except for a successful test_and_set_bit_lock() which has ACQUIRE semantics,
+clear_bit_unlock() which has RELEASE semantics and test_bit_acquire which has
+ACQUIRE semantics.
 
 Since a platform only has a single means of achieving atomic operations
 the same barriers as for atomic_t are used, see atomic_t.txt.
index 68f115f..c4c73db 100644 (file)
@@ -23,3 +23,4 @@ Block
    stat
    switching-sched
    writeback_cache_control
+   ublk
diff --git a/Documentation/block/ublk.rst b/Documentation/block/ublk.rst
new file mode 100644 (file)
index 0000000..2122d1a
--- /dev/null
@@ -0,0 +1,253 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+===========================================
+Userspace block device driver (ublk driver)
+===========================================
+
+Overview
+========
+
+ublk is a generic framework for implementing block device logic from userspace.
+The motivation behind it is that moving virtual block drivers into userspace,
+such as loop, nbd and similar can be very helpful. It can help to implement
+new virtual block device such as ublk-qcow2 (there are several attempts of
+implementing qcow2 driver in kernel).
+
+Userspace block devices are attractive because:
+
+- They can be written many programming languages.
+- They can use libraries that are not available in the kernel.
+- They can be debugged with tools familiar to application developers.
+- Crashes do not kernel panic the machine.
+- Bugs are likely to have a lower security impact than bugs in kernel
+  code.
+- They can be installed and updated independently of the kernel.
+- They can be used to simulate block device easily with user specified
+  parameters/setting for test/debug purpose
+
+ublk block device (``/dev/ublkb*``) is added by ublk driver. Any IO request
+on the device will be forwarded to ublk userspace program. For convenience,
+in this document, ``ublk server`` refers to generic ublk userspace
+program. ``ublksrv`` [#userspace]_ is one of such implementation. It
+provides ``libublksrv`` [#userspace_lib]_ library for developing specific
+user block device conveniently, while also generic type block device is
+included, such as loop and null. Richard W.M. Jones wrote userspace nbd device
+``nbdublk`` [#userspace_nbdublk]_  based on ``libublksrv`` [#userspace_lib]_.
+
+After the IO is handled by userspace, the result is committed back to the
+driver, thus completing the request cycle. This way, any specific IO handling
+logic is totally done by userspace, such as loop's IO handling, NBD's IO
+communication, or qcow2's IO mapping.
+
+``/dev/ublkb*`` is driven by blk-mq request-based driver. Each request is
+assigned by one queue wide unique tag. ublk server assigns unique tag to each
+IO too, which is 1:1 mapped with IO of ``/dev/ublkb*``.
+
+Both the IO request forward and IO handling result committing are done via
+``io_uring`` passthrough command; that is why ublk is also one io_uring based
+block driver. It has been observed that using io_uring passthrough command can
+give better IOPS than block IO; which is why ublk is one of high performance
+implementation of userspace block device: not only IO request communication is
+done by io_uring, but also the preferred IO handling in ublk server is io_uring
+based approach too.
+
+ublk provides control interface to set/get ublk block device parameters.
+The interface is extendable and kabi compatible: basically any ublk request
+queue's parameter or ublk generic feature parameters can be set/get via the
+interface. Thus, ublk is generic userspace block device framework.
+For example, it is easy to setup a ublk device with specified block
+parameters from userspace.
+
+Using ublk
+==========
+
+ublk requires userspace ublk server to handle real block device logic.
+
+Below is example of using ``ublksrv`` to provide ublk-based loop device.
+
+- add a device::
+
+     ublk add -t loop -f ublk-loop.img
+
+- format with xfs, then use it::
+
+     mkfs.xfs /dev/ublkb0
+     mount /dev/ublkb0 /mnt
+     # do anything. all IOs are handled by io_uring
+     ...
+     umount /mnt
+
+- list the devices with their info::
+
+     ublk list
+
+- delete the device::
+
+     ublk del -a
+     ublk del -n $ublk_dev_id
+
+See usage details in README of ``ublksrv`` [#userspace_readme]_.
+
+Design
+======
+
+Control plane
+-------------
+
+ublk driver provides global misc device node (``/dev/ublk-control``) for
+managing and controlling ublk devices with help of several control commands:
+
+- ``UBLK_CMD_ADD_DEV``
+
+  Add a ublk char device (``/dev/ublkc*``) which is talked with ublk server
+  WRT IO command communication. Basic device info is sent together with this
+  command. It sets UAPI structure of ``ublksrv_ctrl_dev_info``,
+  such as ``nr_hw_queues``, ``queue_depth``, and max IO request buffer size,
+  for which the info is negotiated with the driver and sent back to the server.
+  When this command is completed, the basic device info is immutable.
+
+- ``UBLK_CMD_SET_PARAMS`` / ``UBLK_CMD_GET_PARAMS``
+
+  Set or get parameters of the device, which can be either generic feature
+  related, or request queue limit related, but can't be IO logic specific,
+  because the driver does not handle any IO logic. This command has to be
+  sent before sending ``UBLK_CMD_START_DEV``.
+
+- ``UBLK_CMD_START_DEV``
+
+  After the server prepares userspace resources (such as creating per-queue
+  pthread & io_uring for handling ublk IO), this command is sent to the
+  driver for allocating & exposing ``/dev/ublkb*``. Parameters set via
+  ``UBLK_CMD_SET_PARAMS`` are applied for creating the device.
+
+- ``UBLK_CMD_STOP_DEV``
+
+  Halt IO on ``/dev/ublkb*`` and remove the device. When this command returns,
+  ublk server will release resources (such as destroying per-queue pthread &
+  io_uring).
+
+- ``UBLK_CMD_DEL_DEV``
+
+  Remove ``/dev/ublkc*``. When this command returns, the allocated ublk device
+  number can be reused.
+
+- ``UBLK_CMD_GET_QUEUE_AFFINITY``
+
+  When ``/dev/ublkc`` is added, the driver creates block layer tagset, so
+  that each queue's affinity info is available. The server sends
+  ``UBLK_CMD_GET_QUEUE_AFFINITY`` to retrieve queue affinity info. It can
+  set up the per-queue context efficiently, such as bind affine CPUs with IO
+  pthread and try to allocate buffers in IO thread context.
+
+- ``UBLK_CMD_GET_DEV_INFO``
+
+  For retrieving device info via ``ublksrv_ctrl_dev_info``. It is the server's
+  responsibility to save IO target specific info in userspace.
+
+Data plane
+----------
+
+ublk server needs to create per-queue IO pthread & io_uring for handling IO
+commands via io_uring passthrough. The per-queue IO pthread
+focuses on IO handling and shouldn't handle any control & management
+tasks.
+
+The's IO is assigned by a unique tag, which is 1:1 mapping with IO
+request of ``/dev/ublkb*``.
+
+UAPI structure of ``ublksrv_io_desc`` is defined for describing each IO from
+the driver. A fixed mmaped area (array) on ``/dev/ublkc*`` is provided for
+exporting IO info to the server; such as IO offset, length, OP/flags and
+buffer address. Each ``ublksrv_io_desc`` instance can be indexed via queue id
+and IO tag directly.
+
+The following IO commands are communicated via io_uring passthrough command,
+and each command is only for forwarding the IO and committing the result
+with specified IO tag in the command data:
+
+- ``UBLK_IO_FETCH_REQ``
+
+  Sent from the server IO pthread for fetching future incoming IO requests
+  destined to ``/dev/ublkb*``. This command is sent only once from the server
+  IO pthread for ublk driver to setup IO forward environment.
+
+- ``UBLK_IO_COMMIT_AND_FETCH_REQ``
+
+  When an IO request is destined to ``/dev/ublkb*``, the driver stores
+  the IO's ``ublksrv_io_desc`` to the specified mapped area; then the
+  previous received IO command of this IO tag (either ``UBLK_IO_FETCH_REQ``
+  or ``UBLK_IO_COMMIT_AND_FETCH_REQ)`` is completed, so the server gets
+  the IO notification via io_uring.
+
+  After the server handles the IO, its result is committed back to the
+  driver by sending ``UBLK_IO_COMMIT_AND_FETCH_REQ`` back. Once ublkdrv
+  received this command, it parses the result and complete the request to
+  ``/dev/ublkb*``. In the meantime setup environment for fetching future
+  requests with the same IO tag. That is, ``UBLK_IO_COMMIT_AND_FETCH_REQ``
+  is reused for both fetching request and committing back IO result.
+
+- ``UBLK_IO_NEED_GET_DATA``
+
+  With ``UBLK_F_NEED_GET_DATA`` enabled, the WRITE request will be firstly
+  issued to ublk server without data copy. Then, IO backend of ublk server
+  receives the request and it can allocate data buffer and embed its addr
+  inside this new io command. After the kernel driver gets the command,
+  data copy is done from request pages to this backend's buffer. Finally,
+  backend receives the request again with data to be written and it can
+  truly handle the request.
+
+  ``UBLK_IO_NEED_GET_DATA`` adds one additional round-trip and one
+  io_uring_enter() syscall. Any user thinks that it may lower performance
+  should not enable UBLK_F_NEED_GET_DATA. ublk server pre-allocates IO
+  buffer for each IO by default. Any new project should try to use this
+  buffer to communicate with ublk driver. However, existing project may
+  break or not able to consume the new buffer interface; that's why this
+  command is added for backwards compatibility so that existing projects
+  can still consume existing buffers.
+
+- data copy between ublk server IO buffer and ublk block IO request
+
+  The driver needs to copy the block IO request pages into the server buffer
+  (pages) first for WRITE before notifying the server of the coming IO, so
+  that the server can handle WRITE request.
+
+  When the server handles READ request and sends
+  ``UBLK_IO_COMMIT_AND_FETCH_REQ`` to the server, ublkdrv needs to copy
+  the server buffer (pages) read to the IO request pages.
+
+Future development
+==================
+
+Container-aware ublk deivice
+----------------------------
+
+ublk driver doesn't handle any IO logic. Its function is well defined
+for now and very limited userspace interfaces are needed, which is also
+well defined too. It is possible to make ublk devices container-aware block
+devices in future as Stefan Hajnoczi suggested [#stefan]_, by removing
+ADMIN privilege.
+
+Zero copy
+---------
+
+Zero copy is a generic requirement for nbd, fuse or similar drivers. A
+problem [#xiaoguang]_ Xiaoguang mentioned is that pages mapped to userspace
+can't be remapped any more in kernel with existing mm interfaces. This can
+occurs when destining direct IO to ``/dev/ublkb*``. Also, he reported that
+big requests (IO size >= 256 KB) may benefit a lot from zero copy.
+
+
+References
+==========
+
+.. [#userspace] https://github.com/ming1/ubdsrv
+
+.. [#userspace_lib] https://github.com/ming1/ubdsrv/tree/master/lib
+
+.. [#userspace_nbdublk] https://gitlab.com/rwmjones/libnbd/-/tree/nbdublk
+
+.. [#userspace_readme] https://github.com/ming1/ubdsrv/blob/master/README
+
+.. [#stefan] https://lore.kernel.org/linux-block/YoOr6jBfgVm8GvWg@stefanha-x1.localdomain/
+
+.. [#xiaoguang] https://lore.kernel.org/linux-block/YoOr6jBfgVm8GvWg@stefanha-x1.localdomain/
index 934727e..255384d 100644 (file)
@@ -86,6 +86,7 @@ if major >= 3:
             "__used",
             "__weak",
             "noinline",
+            "__fix_address",
 
             # include/linux/memblock.h:
             "__init_memblock",
index b6bbc31..1414ba9 100644 (file)
@@ -24,8 +24,10 @@ properties:
 
   interrupts:
     minItems: 1
+    maxItems: 2
     description:
       Should be configured with type IRQ_TYPE_EDGE_RISING.
+      If two interrupts are provided, expected order is INT1 and INT2.
 
 required:
   - compatible
index 93f2ce3..19ac9da 100644 (file)
@@ -16,6 +16,7 @@ properties:
   compatible:
     enum:
       - goodix,gt1151
+      - goodix,gt1158
       - goodix,gt5663
       - goodix,gt5688
       - goodix,gt911
index 8b7c4af..faa4af9 100644 (file)
@@ -35,6 +35,7 @@ patternProperties:
     description: List of regulators and its properties
     type: object
     $ref: regulator.yaml#
+    unevaluatedProperties: false
 
     properties:
       qcom,ocp-max-retries:
@@ -100,8 +101,6 @@ patternProperties:
           SAW controlled gang leader. Will be configured as SAW regulator.
         type: boolean
 
-      unevaluatedProperties: false
-
 required:
   - compatible
 
index 2d34f3c..8d2c6d7 100644 (file)
@@ -214,6 +214,7 @@ patternProperties:
       - polling-delay
       - polling-delay-passive
       - thermal-sensors
+      - trips
 
     additionalProperties: false
 
index e63b665..b019d49 100644 (file)
@@ -24,6 +24,7 @@ properties:
           - mediatek,mt2712-mtu3
           - mediatek,mt8173-mtu3
           - mediatek,mt8183-mtu3
+          - mediatek,mt8188-mtu3
           - mediatek,mt8192-mtu3
           - mediatek,mt8195-mtu3
       - const: mediatek,mtu3
index fea3e70..cd2f7cb 100644 (file)
@@ -33,6 +33,7 @@ properties:
           - qcom,sm6115-dwc3
           - qcom,sm6125-dwc3
           - qcom,sm6350-dwc3
+          - qcom,sm6375-dwc3
           - qcom,sm8150-dwc3
           - qcom,sm8250-dwc3
           - qcom,sm8350-dwc3
@@ -108,12 +109,17 @@ properties:
       HS/FS/LS modes are supported.
     type: boolean
 
+  wakeup-source: true
+
 # Required child node:
 
 patternProperties:
   "^usb@[0-9a-f]+$":
     $ref: snps,dwc3.yaml#
 
+    properties:
+      wakeup-source: false
+
 required:
   - compatible
   - reg
index f615906..6d72139 100644 (file)
@@ -517,6 +517,7 @@ All I-Force devices are supported by the iforce module. This includes:
 * AVB Mag Turbo Force
 * AVB Top Shot Pegasus
 * AVB Top Shot Force Feedback Racing Wheel
+* Boeder Force Feedback Wheel
 * Logitech WingMan Force
 * Logitech WingMan Force Wheel
 * Guillemot Race Leader Force Feedback
index 8a292fb..ec5e6d7 100644 (file)
@@ -67,7 +67,7 @@ The ``netdevsim`` driver supports rate objects management, which includes:
 - setting tx_share and tx_max rate values for any rate object type;
 - setting parent node for any rate object type.
 
-Rate nodes and it's parameters are exposed in ``netdevsim`` debugfs in RO mode.
+Rate nodes and their parameters are exposed in ``netdevsim`` debugfs in RO mode.
 For example created rate node with name ``some_group``:
 
 .. code:: shell
index c8f59db..64f7236 100644 (file)
@@ -8,7 +8,7 @@ Transmit path guidelines:
 
 1) The ndo_start_xmit method must not return NETDEV_TX_BUSY under
    any normal circumstances.  It is considered a hard error unless
-   there is no way your device can tell ahead of time when it's
+   there is no way your device can tell ahead of time when its
    transmit function will become busy.
 
    Instead it must maintain the queue properly.  For example,
index 56cd4ea..a759872 100644 (file)
@@ -1035,7 +1035,10 @@ tcp_limit_output_bytes - INTEGER
 tcp_challenge_ack_limit - INTEGER
        Limits number of Challenge ACK sent per second, as recommended
        in RFC 5961 (Improving TCP's Robustness to Blind In-Window Attacks)
-       Default: 1000
+       Note that this per netns rate limit can allow some side channel
+       attacks and probably should not be enabled.
+       TCP stack implements per TCP socket limits anyway.
+       Default: INT_MAX (unlimited)
 
 UDP variables
 =============
index 694adcb..0000c1d 100644 (file)
@@ -11,7 +11,7 @@ Initial Release:
 ================
 This is conceptually very similar to the macvlan driver with one major
 exception of using L3 for mux-ing /demux-ing among slaves. This property makes
-the master device share the L2 with it's slave devices. I have developed this
+the master device share the L2 with its slave devices. I have developed this
 driver in conjunction with network namespaces and not sure if there is use case
 outside of it.
 
index 498b382..7f383e9 100644 (file)
@@ -530,7 +530,7 @@ its tunnel close actions. For L2TPIP sockets, the socket's close
 handler initiates the same tunnel close actions. All sessions are
 first closed. Each session drops its tunnel ref. When the tunnel ref
 reaches zero, the tunnel puts its socket ref. When the socket is
-eventually destroyed, it's sk_destruct finally frees the L2TP tunnel
+eventually destroyed, its sk_destruct finally frees the L2TP tunnel
 context.
 
 Sessions
index 39c2249..39494a6 100644 (file)
@@ -1055,17 +1055,6 @@ The kernel interface functions are as follows:
      first function to change.  Note that this must be called in TASK_RUNNING
      state.
 
- (#) Get reply timestamp::
-
-       bool rxrpc_kernel_get_reply_time(struct socket *sock,
-                                        struct rxrpc_call *call,
-                                        ktime_t *_ts)
-
-     This allows the timestamp on the first DATA packet of the reply of a
-     client call to be queried, provided that it is still in the Rx ring.  If
-     successful, the timestamp will be stored into ``*_ts`` and true will be
-     returned; false will be returned otherwise.
-
  (#) Get remote client epoch::
 
        u32 rxrpc_kernel_get_epoch(struct socket *sock,
index f1f4e6a..bbf272e 100644 (file)
@@ -159,7 +159,7 @@ tools such as iproute2.
 
 The switchdev driver can know a particular port's position in the topology by
 monitoring NETDEV_CHANGEUPPER notifications.  For example, a port moved into a
-bond will see it's upper master change.  If that bond is moved into a bridge,
+bond will see its upper master change.  If that bond is moved into a bridge,
 the bond's upper master will change.  And so on.  The driver will track such
 movements to know what position a port is in in the overall topology by
 registering for netdevice events and acting on NETDEV_CHANGEUPPER.
index 2a29cbe..9707e03 100644 (file)
 
 % Translations have Asian (CJK) characters which are only displayed if
 % xeCJK is used
+\usepackage{ifthen}
+\newboolean{enablecjk}
+\setboolean{enablecjk}{false}
 \IfFontExistsTF{Noto Sans CJK SC}{
-    % Load xeCJK when CJK font is available
+    \IfFileExists{xeCJK.sty}{
+       \setboolean{enablecjk}{true}
+    }{}
+}{}
+\ifthenelse{\boolean{enablecjk}}{
+    % Load xeCJK when both the Noto Sans CJK font and xeCJK.sty are available.
     \usepackage{xeCJK}
     % Noto CJK fonts don't provide slant shape. [AutoFakeSlant] permits
     % its emulation.
     % Inactivate CJK after tableofcontents
     \apptocmd{\sphinxtableofcontents}{\kerneldocCJKoff}{}{}
     \xeCJKsetup{CJKspace = true}% For inter-phrase space of Korean TOC
-}{ % No CJK font found
+}{ % Don't enable CJK
     % Custom macros to on/off CJK and switch CJK fonts (Dummy)
     \newcommand{\kerneldocCJKon}{}
     \newcommand{\kerneldocCJKoff}{}
     %% and ignore the argument (#1) in their definitions, whole contents of
     %% CJK chapters can be ignored.
     \newcommand{\kerneldocBeginSC}[1]{%
-       %% Put a note on missing CJK fonts in place of zh_CN translation.
-       \begin{sphinxadmonition}{note}{Note on missing fonts:}
+       %% Put a note on missing CJK fonts or the xecjk package in place of
+       %% zh_CN translation.
+       \begin{sphinxadmonition}{note}{Note on missing fonts and a package:}
            Translations of Simplified Chinese (zh\_CN), Traditional Chinese
            (zh\_TW), Korean (ko\_KR), and Japanese (ja\_JP) were skipped
-           due to the lack of suitable font families.
+           due to the lack of suitable font families and/or the texlive-xecjk
+           package.
 
            If you want them, please install ``Noto Sans CJK'' font families
-           by following instructions from
+           along with the texlive-xecjk package by following instructions from
            \sphinxcode{./scripts/sphinx-pre-install}.
            Having optional ``Noto Serif CJK'' font families will improve
            the looks of those translations.
index 66ce0d8..04deb77 100644 (file)
@@ -35,8 +35,7 @@ Linux カーネルに変更を加えたいと思っている個人又は会社
 てもらえやすくする提案を集めたものです。
 
 コードを投稿する前に、Documentation/process/submit-checklist.rst の項目リストに目
-を通してチェックしてください。もしあなたがドライバーを投稿しようとし
-ているなら、Documentation/process/submitting-drivers.rst にも目を通してください。
+を通してチェックしてください。
 
 --------------------------------------------
 セクション1 パッチの作り方と送り方
index 9d7f64d..2f02f7c 100644 (file)
@@ -3612,6 +3612,7 @@ F:        include/linux/find.h
 F:     include/linux/nodemask.h
 F:     lib/bitmap.c
 F:     lib/cpumask.c
+F:     lib/cpumask_kunit.c
 F:     lib/find_bit.c
 F:     lib/find_bit_benchmark.c
 F:     lib/test_bitmap.c
@@ -3679,6 +3680,7 @@ F:        Documentation/networking/bonding.rst
 F:     drivers/net/bonding/
 F:     include/net/bond*
 F:     include/uapi/linux/if_bonding.h
+F:     tools/testing/selftests/drivers/net/bonding/
 
 BOSCH SENSORTEC BMA400 ACCELEROMETER IIO DRIVER
 M:     Dan Robertson <dan@dlrobertson.com>
@@ -9781,7 +9783,7 @@ M:        Christian Brauner <brauner@kernel.org>
 M:     Seth Forshee <sforshee@kernel.org>
 L:     linux-fsdevel@vger.kernel.org
 S:     Maintained
-T:     git git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git
+T:     git://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping.git
 F:     Documentation/filesystems/idmappings.rst
 F:     tools/testing/selftests/mount_setattr/
 F:     include/linux/mnt_idmapping.h
@@ -10030,6 +10032,7 @@ F:      Documentation/devicetree/bindings/input/
 F:     Documentation/devicetree/bindings/serio/
 F:     Documentation/input/
 F:     drivers/input/
+F:     include/dt-bindings/input/
 F:     include/linux/input.h
 F:     include/linux/input/
 F:     include/uapi/linux/input-event-codes.h
@@ -10658,6 +10661,7 @@ T:      git git://git.kernel.dk/linux-block
 T:     git git://git.kernel.dk/liburing
 F:     io_uring/
 F:     include/linux/io_uring.h
+F:     include/linux/io_uring_types.h
 F:     include/uapi/linux/io_uring.h
 F:     tools/io_uring/
 
@@ -17528,9 +17532,19 @@ M:     Conor Dooley <conor.dooley@microchip.com>
 M:     Daire McNamara <daire.mcnamara@microchip.com>
 L:     linux-riscv@lists.infradead.org
 S:     Supported
+F:     Documentation/devicetree/bindings/clock/microchip,mpfs.yaml
+F:     Documentation/devicetree/bindings/gpio/microchip,mpfs-gpio.yaml
+F:     Documentation/devicetree/bindings/i2c/microchip,corei2c.yaml
+F:     Documentation/devicetree/bindings/mailbox/microchip,mpfs-mailbox.yaml
+F:     Documentation/devicetree/bindings/net/can/microchip,mpfs-can.yaml
+F:     Documentation/devicetree/bindings/pwm/microchip,corepwm.yaml
+F:     Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-sys-controller.yaml
+F:     Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml
+F:     Documentation/devicetree/bindings/usb/microchip,mpfs-musb.yaml
 F:     arch/riscv/boot/dts/microchip/
 F:     drivers/char/hw_random/mpfs-rng.c
 F:     drivers/clk/microchip/clk-mpfs.c
+F:     drivers/i2c/busses/i2c-microchip-core.c
 F:     drivers/mailbox/mailbox-mpfs.c
 F:     drivers/pci/controller/pcie-microchip-host.c
 F:     drivers/rtc/rtc-mpfs.c
@@ -17731,6 +17745,17 @@ L:     linux-rdma@vger.kernel.org
 S:     Maintained
 F:     drivers/infiniband/ulp/rtrs/
 
+RUNTIME VERIFICATION (RV)
+M:     Daniel Bristot de Oliveira <bristot@kernel.org>
+M:     Steven Rostedt <rostedt@goodmis.org>
+L:     linux-trace-devel@vger.kernel.org
+S:     Maintained
+F:     Documentation/trace/rv/
+F:     include/linux/rv.h
+F:     include/rv/
+F:     kernel/trace/rv/
+F:     tools/verification/
+
 RXRPC SOCKETS (AF_RXRPC)
 M:     David Howells <dhowells@redhat.com>
 M:     Marc Dionne <marc.dionne@auristor.com>
@@ -20597,6 +20622,7 @@ F:      include/*/ftrace.h
 F:     include/linux/trace*.h
 F:     include/trace/
 F:     kernel/trace/
+F:     scripts/tracing/
 F:     tools/testing/selftests/ftrace/
 
 TRACING MMIO ACCESSES (MMIOTRACE)
@@ -20761,6 +20787,7 @@ UBLK USERSPACE BLOCK DRIVER
 M:     Ming Lei <ming.lei@redhat.com>
 L:     linux-block@vger.kernel.org
 S:     Maintained
+F:     Documentation/block/ublk.rst
 F:     drivers/block/ublk_drv.c
 F:     include/uapi/linux/ublk_cmd.h
 
@@ -22302,7 +22329,7 @@ M:      Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
 R:     Srinivas Neeli <srinivas.neeli@xilinx.com>
 R:     Michal Simek <michal.simek@xilinx.com>
 S:     Maintained
-F:     Documentation/devicetree/bindings/gpio/gpio-xilinx.txt
+F:     Documentation/devicetree/bindings/gpio/xlnx,gpio-xilinx.yaml
 F:     Documentation/devicetree/bindings/gpio/gpio-zynq.yaml
 F:     drivers/gpio/gpio-xilinx.c
 F:     drivers/gpio/gpio-zynq.c
index c7705f7..a4f7107 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 VERSION = 6
 PATCHLEVEL = 0
 SUBLEVEL = 0
-EXTRAVERSION = -rc2
+EXTRAVERSION = -rc4
 NAME = Hurr durr I'ma ninja sloth
 
 # *DOCUMENTATION*
index 5dbf11a..8b311e4 100644 (file)
@@ -923,6 +923,9 @@ config HAVE_SOFTIRQ_ON_OWN_STACK
          Architecture provides a function to run __do_softirq() on a
          separate stack.
 
+config SOFTIRQ_ON_OWN_STACK
+       def_bool HAVE_SOFTIRQ_ON_OWN_STACK && !PREEMPT_RT
+
 config ALTERNATE_USER_ADDRESS_SPACE
        bool
        help
index 492c771..bafb1c1 100644 (file)
@@ -283,11 +283,8 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
        return (old & mask) != 0;
 }
 
-static __always_inline bool
-arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
-{
-       return (1UL & (((const int *) addr)[nr >> 5] >> (nr & 31))) != 0UL;
-}
+#define arch_test_bit generic_test_bit
+#define arch_test_bit_acquire generic_test_bit_acquire
 
 /*
  * ffz = Find First Zero in word. Undefined if no zero exists,
index 2dfb32b..fbb2258 100644 (file)
                        compatible = "arm,pl022", "arm,primecell";
                        reg = <0x1000d000 0x1000>;
                        clocks = <&sspclk>, <&pclk>;
-                       clock-names = "SSPCLK", "apb_pclk";
+                       clock-names = "sspclk", "apb_pclk";
                };
 
                wdog: watchdog@10010000 {
index 06b8723..efed325 100644 (file)
                        interrupt-parent = <&intc_dc1176>;
                        interrupts = <0 17 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&sspclk>, <&pclk>;
-                       clock-names = "SSPCLK", "apb_pclk";
+                       clock-names = "sspclk", "apb_pclk";
                };
 
                pb1176_serial0: serial@1010c000 {
index 295aef4..89103d5 100644 (file)
                        interrupt-parent = <&intc_pb11mp>;
                        interrupts = <0 11 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&sspclk>, <&pclk>;
-                       clock-names = "SSPCLK", "apb_pclk";
+                       clock-names = "sspclk", "apb_pclk";
                };
 
                watchdog@1000f000 {
index 6f61f96..ec1507c 100644 (file)
                        compatible = "arm,pl022", "arm,primecell";
                        reg = <0x1000d000 0x1000>;
                        clocks = <&sspclk>, <&pclk>;
-                       clock-names = "SSPCLK", "apb_pclk";
+                       clock-names = "sspclk", "apb_pclk";
                };
 
                wdog0: watchdog@1000f000 {
index 76b2025..83bcf9f 100644 (file)
@@ -76,8 +76,8 @@
                regulators {
                        vdd_3v3: VDD_IO {
                                regulator-name = "VDD_IO";
-                               regulator-min-microvolt = <1200000>;
-                               regulator-max-microvolt = <3700000>;
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
                                regulator-initial-mode = <2>;
                                regulator-allowed-modes = <2>, <4>;
                                regulator-always-on;
@@ -95,8 +95,8 @@
 
                        vddio_ddr: VDD_DDR {
                                regulator-name = "VDD_DDR";
-                               regulator-min-microvolt = <600000>;
-                               regulator-max-microvolt = <1850000>;
+                               regulator-min-microvolt = <1200000>;
+                               regulator-max-microvolt = <1200000>;
                                regulator-initial-mode = <2>;
                                regulator-allowed-modes = <2>, <4>;
                                regulator-always-on;
 
                        vdd_core: VDD_CORE {
                                regulator-name = "VDD_CORE";
-                               regulator-min-microvolt = <600000>;
-                               regulator-max-microvolt = <1850000>;
+                               regulator-min-microvolt = <1250000>;
+                               regulator-max-microvolt = <1250000>;
                                regulator-initial-mode = <2>;
                                regulator-allowed-modes = <2>, <4>;
                                regulator-always-on;
 
                        LDO1 {
                                regulator-name = "LDO1";
-                               regulator-min-microvolt = <1200000>;
-                               regulator-max-microvolt = <3700000>;
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
                                regulator-always-on;
 
                                regulator-state-standby {
 
                        LDO2 {
                                regulator-name = "LDO2";
-                               regulator-min-microvolt = <1200000>;
-                               regulator-max-microvolt = <3700000>;
-                               regulator-always-on;
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <3300000>;
 
                                regulator-state-standby {
                                        regulator-on-in-suspend;
index 6865be8..dd1dec9 100644 (file)
                        regulators {
                                vdd_io_reg: VDD_IO {
                                        regulator-name = "VDD_IO";
-                                       regulator-min-microvolt = <1200000>;
-                                       regulator-max-microvolt = <3700000>;
+                                       regulator-min-microvolt = <3300000>;
+                                       regulator-max-microvolt = <3300000>;
                                        regulator-initial-mode = <2>;
                                        regulator-allowed-modes = <2>, <4>;
                                        regulator-always-on;
 
                                VDD_DDR {
                                        regulator-name = "VDD_DDR";
-                                       regulator-min-microvolt = <600000>;
-                                       regulator-max-microvolt = <1850000>;
+                                       regulator-min-microvolt = <1350000>;
+                                       regulator-max-microvolt = <1350000>;
                                        regulator-initial-mode = <2>;
                                        regulator-allowed-modes = <2>, <4>;
                                        regulator-always-on;
 
                                VDD_CORE {
                                        regulator-name = "VDD_CORE";
-                                       regulator-min-microvolt = <600000>;
-                                       regulator-max-microvolt = <1850000>;
+                                       regulator-min-microvolt = <1250000>;
+                                       regulator-max-microvolt = <1250000>;
                                        regulator-initial-mode = <2>;
                                        regulator-allowed-modes = <2>, <4>;
                                        regulator-always-on;
                                        regulator-max-microvolt = <1850000>;
                                        regulator-initial-mode = <2>;
                                        regulator-allowed-modes = <2>, <4>;
-                                       regulator-always-on;
 
                                        regulator-state-standby {
                                                regulator-on-in-suspend;
 
                                LDO1 {
                                        regulator-name = "LDO1";
-                                       regulator-min-microvolt = <1200000>;
-                                       regulator-max-microvolt = <3700000>;
+                                       regulator-min-microvolt = <2500000>;
+                                       regulator-max-microvolt = <2500000>;
                                        regulator-always-on;
 
                                        regulator-state-standby {
 
                                LDO2 {
                                        regulator-name = "LDO2";
-                                       regulator-min-microvolt = <1200000>;
-                                       regulator-max-microvolt = <3700000>;
+                                       regulator-min-microvolt = <3300000>;
+                                       regulator-max-microvolt = <3300000>;
                                        regulator-always-on;
 
                                        regulator-state-standby {
index de44da2..3b25c67 100644 (file)
                        regulators {
                                vdd_3v3: VDD_IO {
                                        regulator-name = "VDD_IO";
-                                       regulator-min-microvolt = <1200000>;
-                                       regulator-max-microvolt = <3700000>;
+                                       regulator-min-microvolt = <3300000>;
+                                       regulator-max-microvolt = <3300000>;
                                        regulator-initial-mode = <2>;
                                        regulator-allowed-modes = <2>, <4>;
                                        regulator-always-on;
 
                                vddioddr: VDD_DDR {
                                        regulator-name = "VDD_DDR";
-                                       regulator-min-microvolt = <1300000>;
-                                       regulator-max-microvolt = <1450000>;
+                                       regulator-min-microvolt = <1350000>;
+                                       regulator-max-microvolt = <1350000>;
                                        regulator-initial-mode = <2>;
                                        regulator-allowed-modes = <2>, <4>;
                                        regulator-always-on;
 
                                vddcore: VDD_CORE {
                                        regulator-name = "VDD_CORE";
-                                       regulator-min-microvolt = <1100000>;
-                                       regulator-max-microvolt = <1850000>;
+                                       regulator-min-microvolt = <1150000>;
+                                       regulator-max-microvolt = <1150000>;
                                        regulator-initial-mode = <2>;
                                        regulator-allowed-modes = <2>, <4>;
                                        regulator-always-on;
                                vddcpu: VDD_OTHER {
                                        regulator-name = "VDD_OTHER";
                                        regulator-min-microvolt = <1050000>;
-                                       regulator-max-microvolt = <1850000>;
+                                       regulator-max-microvolt = <1250000>;
                                        regulator-initial-mode = <2>;
                                        regulator-allowed-modes = <2>, <4>;
                                        regulator-ramp-delay = <3125>;
 
                                vldo1: LDO1 {
                                        regulator-name = "LDO1";
-                                       regulator-min-microvolt = <1200000>;
-                                       regulator-max-microvolt = <3700000>;
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
                                        regulator-always-on;
 
                                        regulator-state-standby {
index 5463443..cbd094d 100644 (file)
@@ -32,6 +32,7 @@
                        next-level-cache = <&L2_0>;
                        enable-method = "psci";
                };
+
                CA7_2: cpu@2 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a7";
@@ -39,6 +40,7 @@
                        next-level-cache = <&L2_0>;
                        enable-method = "psci";
                };
+
                L2_0: l2-cache0 {
                        compatible = "cache";
                };
 
        timer {
                compatible = "arm,armv7-timer";
-               interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                       <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                       <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                       <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
+               interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(3) | IRQ_TYPE_LEVEL_LOW)>,
+                       <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(3) | IRQ_TYPE_LEVEL_LOW)>,
+                       <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(3) | IRQ_TYPE_LEVEL_LOW)>,
+                       <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(3) | IRQ_TYPE_LEVEL_LOW)>;
                arm,cpu-registers-not-fw-configured;
        };
 
        psci {
                compatible = "arm,psci-0.2";
                method = "smc";
-               cpu_off = <1>;
-               cpu_on = <2>;
        };
 
        axi@81000000 {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
-               ranges = <0 0x81000000 0x4000>;
+               ranges = <0 0x81000000 0x8000>;
 
                gic: interrupt-controller@1000 {
                        compatible = "arm,cortex-a7-gic";
                        #interrupt-cells = <3>;
-                       #address-cells = <0>;
                        interrupt-controller;
+                       interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(3) | IRQ_TYPE_LEVEL_HIGH)>;
                        reg = <0x1000 0x1000>,
-                               <0x2000 0x2000>;
+                               <0x2000 0x2000>,
+                               <0x4000 0x2000>,
+                               <0x6000 0x2000>;
                };
        };
 
index e610c10..8aa47a2 100644 (file)
 
        timer {
                compatible = "arm,armv7-timer";
-               interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                       <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                       <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                       <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
+               interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                       <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                       <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                       <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
                arm,cpu-registers-not-fw-configured;
        };
 
        psci {
                compatible = "arm,psci-0.2";
                method = "smc";
-               cpu_off = <1>;
-               cpu_on = <2>;
        };
 
        axi@81000000 {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
-               ranges = <0 0x81000000 0x4000>;
+               ranges = <0 0x81000000 0x8000>;
 
                gic: interrupt-controller@1000 {
                        compatible = "arm,cortex-a7-gic";
                        #interrupt-cells = <3>;
-                       #address-cells = <0>;
                        interrupt-controller;
+                       interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_HIGH)>;
                        reg = <0x1000 0x1000>,
-                               <0x2000 0x2000>;
+                               <0x2000 0x2000>,
+                               <0x4000 0x2000>,
+                               <0x6000 0x2000>;
                };
        };
 
index a7dff59..1e8b5fa 100644 (file)
@@ -32,6 +32,7 @@
                        next-level-cache = <&L2_0>;
                        enable-method = "psci";
                };
+
                L2_0: l2-cache0 {
                        compatible = "cache";
                };
 
        timer {
                compatible = "arm,armv7-timer";
-               interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                       <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                       <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                       <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
+               interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                       <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                       <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                       <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
                arm,cpu-registers-not-fw-configured;
        };
 
index 095c914..6b791d5 100644 (file)
                vin-supply = <&reg_3p3v_s5>;
        };
 
-       reg_3p3v_s0: regulator-3p3v-s0 {
-               compatible = "regulator-fixed";
-               regulator-name = "V_3V3_S0";
-               regulator-min-microvolt = <3300000>;
-               regulator-max-microvolt = <3300000>;
-               regulator-always-on;
-               regulator-boot-on;
-               vin-supply = <&reg_3p3v_s5>;
-       };
-
        reg_3p3v_s5: regulator-3p3v-s5 {
                compatible = "regulator-fixed";
                regulator-name = "V_3V3_S5";
 
        /* default boot source: workaround #1 for errata ERR006282 */
        smarc_flash: flash@0 {
-               compatible = "winbond,w25q16dw", "jedec,spi-nor";
+               compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <20000000>;
        };
index a1676b5..c5a98b0 100644 (file)
@@ -28,7 +28,7 @@
                enable-gpios = <&gpio4 28 GPIO_ACTIVE_HIGH>;
        };
 
-       backlight_led: backlight_led {
+       backlight_led: backlight-led {
                compatible = "pwm-backlight";
                pwms = <&pwm3 0 5000000 0>;
                brightness-levels = <0 16 64 255>;
index d47bfb6..4c22e44 100644 (file)
                clock-names = "uartclk", "apb_pclk";
        };
 
-       ssp@300000 {
+       spi@300000 {
                compatible = "arm,pl022", "arm,primecell";
                reg = <0x00300000 0x1000>;
                interrupts-extended = <&impd1_vic 3>;
                clocks = <&impd1_sspclk>, <&sysclk>;
-               clock-names = "spiclk", "apb_pclk";
+               clock-names = "sspclk", "apb_pclk";
        };
 
        impd1_gpio0: gpio@400000 {
index 79f7cc2..a520615 100644 (file)
                        reg = <0x101f4000 0x1000>;
                        interrupts = <11>;
                        clocks = <&xtal24mhz>, <&pclk>;
-                       clock-names = "SSPCLK", "apb_pclk";
+                       clock-names = "sspclk", "apb_pclk";
                };
 
                fpga {
index da90ce9..e185eee 100644 (file)
@@ -196,7 +196,6 @@ CONFIG_RTC_DRV_AT91SAM9=y
 CONFIG_DMADEVICES=y
 CONFIG_AT_HDMAC=y
 CONFIG_AT_XDMAC=y
-CONFIG_MICROCHIP_PIT64B=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_IIO=y
 CONFIG_AT91_ADC=y
index 0384030..b2311f0 100644 (file)
@@ -188,7 +188,6 @@ CONFIG_RTC_DRV_AT91SAM9=y
 CONFIG_DMADEVICES=y
 CONFIG_AT_XDMAC=y
 CONFIG_STAGING=y
-CONFIG_MICROCHIP_PIT64B=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_IIO=y
 CONFIG_IIO_SW_TRIGGER=y
index 034cb48..fe28fc1 100644 (file)
@@ -70,7 +70,7 @@ static void __init init_irq_stacks(void)
        }
 }
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 static void ____do_softirq(void *arg)
 {
        __do_softirq();
index df6d673..f4501de 100644 (file)
@@ -541,10 +541,42 @@ extern u32 at91_pm_suspend_in_sram_sz;
 
 static int at91_suspend_finish(unsigned long val)
 {
+       unsigned char modified_gray_code[] = {
+               0x00, 0x01, 0x02, 0x03, 0x06, 0x07, 0x04, 0x05, 0x0c, 0x0d,
+               0x0e, 0x0f, 0x0a, 0x0b, 0x08, 0x09, 0x18, 0x19, 0x1a, 0x1b,
+               0x1e, 0x1f, 0x1c, 0x1d, 0x14, 0x15, 0x16, 0x17, 0x12, 0x13,
+               0x10, 0x11,
+       };
+       unsigned int tmp, index;
        int i;
 
        if (soc_pm.data.mode == AT91_PM_BACKUP && soc_pm.data.ramc_phy) {
                /*
+                * Bootloader will perform DDR recalibration and will try to
+                * restore the ZQ0SR0 with the value saved here. But the
+                * calibration is buggy and restoring some values from ZQ0SR0
+                * is forbidden and risky thus we need to provide processed
+                * values for these (modified gray code values).
+                */
+               tmp = readl(soc_pm.data.ramc_phy + DDR3PHY_ZQ0SR0);
+
+               /* Store pull-down output impedance select. */
+               index = (tmp >> DDR3PHY_ZQ0SR0_PDO_OFF) & 0x1f;
+               soc_pm.bu->ddr_phy_calibration[0] = modified_gray_code[index];
+
+               /* Store pull-up output impedance select. */
+               index = (tmp >> DDR3PHY_ZQ0SR0_PUO_OFF) & 0x1f;
+               soc_pm.bu->ddr_phy_calibration[0] |= modified_gray_code[index];
+
+               /* Store pull-down on-die termination impedance select. */
+               index = (tmp >> DDR3PHY_ZQ0SR0_PDODT_OFF) & 0x1f;
+               soc_pm.bu->ddr_phy_calibration[0] |= modified_gray_code[index];
+
+               /* Store pull-up on-die termination impedance select. */
+               index = (tmp >> DDR3PHY_ZQ0SRO_PUODT_OFF) & 0x1f;
+               soc_pm.bu->ddr_phy_calibration[0] |= modified_gray_code[index];
+
+               /*
                 * The 1st 8 words of memory might get corrupted in the process
                 * of DDR PHY recalibration; it is saved here in securam and it
                 * will be restored later, after recalibration, by bootloader
@@ -1066,10 +1098,6 @@ static int __init at91_pm_backup_init(void)
                of_scan_flat_dt(at91_pm_backup_scan_memcs, &located);
                if (!located)
                        goto securam_fail;
-
-               /* DDR3PHY_ZQ0SR0 */
-               soc_pm.bu->ddr_phy_calibration[0] = readl(soc_pm.data.ramc_phy +
-                                                         0x188);
        }
 
        return 0;
index abe4ced..ffed4d9 100644 (file)
@@ -172,9 +172,15 @@ sr_ena_2:
        /* Put DDR PHY's DLL in bypass mode for non-backup modes. */
        cmp     r7, #AT91_PM_BACKUP
        beq     sr_ena_3
-       ldr     tmp1, [r3, #DDR3PHY_PIR]
-       orr     tmp1, tmp1, #DDR3PHY_PIR_DLLBYP
-       str     tmp1, [r3, #DDR3PHY_PIR]
+
+       /* Disable DX DLLs. */
+       ldr     tmp1, [r3, #DDR3PHY_DX0DLLCR]
+       orr     tmp1, tmp1, #DDR3PHY_DXDLLCR_DLLDIS
+       str     tmp1, [r3, #DDR3PHY_DX0DLLCR]
+
+       ldr     tmp1, [r3, #DDR3PHY_DX1DLLCR]
+       orr     tmp1, tmp1, #DDR3PHY_DXDLLCR_DLLDIS
+       str     tmp1, [r3, #DDR3PHY_DX1DLLCR]
 
 sr_ena_3:
        /* Power down DDR PHY data receivers. */
@@ -221,10 +227,14 @@ sr_ena_3:
        bic     tmp1, tmp1, #DDR3PHY_DSGCR_ODTPDD_ODT0
        str     tmp1, [r3, #DDR3PHY_DSGCR]
 
-       /* Take DDR PHY's DLL out of bypass mode. */
-       ldr     tmp1, [r3, #DDR3PHY_PIR]
-       bic     tmp1, tmp1, #DDR3PHY_PIR_DLLBYP
-       str     tmp1, [r3, #DDR3PHY_PIR]
+       /* Enable DX DLLs. */
+       ldr     tmp1, [r3, #DDR3PHY_DX0DLLCR]
+       bic     tmp1, tmp1, #DDR3PHY_DXDLLCR_DLLDIS
+       str     tmp1, [r3, #DDR3PHY_DX0DLLCR]
+
+       ldr     tmp1, [r3, #DDR3PHY_DX1DLLCR]
+       bic     tmp1, tmp1, #DDR3PHY_DXDLLCR_DLLDIS
+       str     tmp1, [r3, #DDR3PHY_DX1DLLCR]
 
        /* Enable quasi-dynamic programming. */
        mov     tmp1, #0
index f990471..f543e2a 100644 (file)
@@ -46,7 +46,7 @@ static void __init ixp4xx_of_map_io(void)
 }
 
 /*
- * We handle 4 differen SoC families. These compatible strings are enough
+ * We handle 4 different SoC families. These compatible strings are enough
  * to provide the core so that different boards can add their more detailed
  * specifics.
  */
index 571cc23..9fb9fff 100644 (file)
@@ -917,6 +917,23 @@ config ARM64_ERRATUM_1902691
 
          If unsure, say Y.
 
+config ARM64_ERRATUM_2457168
+       bool "Cortex-A510: 2457168: workaround for AMEVCNTR01 incrementing incorrectly"
+       depends on ARM64_AMU_EXTN
+       default y
+       help
+         This option adds the workaround for ARM Cortex-A510 erratum 2457168.
+
+         The AMU counter AMEVCNTR01 (constant counter) should increment at the same rate
+         as the system counter. On affected Cortex-A510 cores AMEVCNTR01 increments
+         incorrectly giving a significantly higher output value.
+
+         Work around this problem by returning 0 when reading the affected counter in
+         key locations that results in disabling all users of this counter. This effect
+         is the same to firmware disabling affected counters.
+
+         If unsure, say Y.
+
 config CAVIUM_ERRATUM_22375
        bool "Cavium erratum 22375, 24313"
        default y
index 8d0d45d..2f27619 100644 (file)
@@ -26,7 +26,8 @@
                compatible = "arm,mhu", "arm,primecell";
                reg = <0x0 0x2b1f0000 0x0 0x1000>;
                interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
+                            <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
                #mbox-cells = <1>;
                clocks = <&soc_refclk100mhz>;
                clock-names = "apb_pclk";
index ba88d15..09d2b69 100644 (file)
@@ -67,7 +67,6 @@
                        port@0 {
                                reg = <0>;
                                csys2_funnel_in_port0: endpoint {
-                                       slave-mode;
                                        remote-endpoint = <&etf0_out_port>;
                                };
                        };
@@ -75,7 +74,6 @@
                        port@1 {
                                reg = <1>;
                                csys2_funnel_in_port1: endpoint {
-                                       slave-mode;
                                        remote-endpoint = <&etf1_out_port>;
                                };
                        };
index 40d34c8..b949cac 100644 (file)
@@ -25,7 +25,6 @@
 &enetc_port0 {
        phy-handle = <&slot1_sgmii>;
        phy-mode = "2500base-x";
-       managed = "in-band-status";
        status = "okay";
 };
 
index 35fb929..d3ee6fc 100644 (file)
                        lan1: port@0 {
                                reg = <0>;
                                label = "lan1";
+                               phy-mode = "internal";
                                local-mac-address = [00 00 00 00 00 00];
                        };
 
                        lan2: port@1 {
                                reg = <1>;
                                label = "lan2";
+                               phy-mode = "internal";
                                local-mac-address = [00 00 00 00 00 00];
                        };
 
                        lan3: port@2 {
                                reg = <2>;
                                label = "lan3";
+                               phy-mode = "internal";
                                local-mac-address = [00 00 00 00 00 00];
                        };
 
                        lan4: port@3 {
                                reg = <3>;
                                label = "lan4";
+                               phy-mode = "internal";
                                local-mac-address = [00 00 00 00 00 00];
                        };
 
index d1b4582..b379c46 100644 (file)
        };
 
        /* Fixed clock dedicated to SPI CAN controller */
-       clk20m: oscillator {
+       clk40m: oscillator {
                compatible = "fixed-clock";
                #clock-cells = <0>;
-               clock-frequency = <20000000>;
+               clock-frequency = <40000000>;
        };
 
        gpio-keys {
 
        can1: can@0 {
                compatible = "microchip,mcp251xfd";
-               clocks = <&clk20m>;
-               interrupts-extended = <&gpio1 6 IRQ_TYPE_EDGE_FALLING>;
+               clocks = <&clk40m>;
+               interrupts-extended = <&gpio1 6 IRQ_TYPE_LEVEL_LOW>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_can1_int>;
                reg = <0>;
                pinctrl-0 = <&pinctrl_gpio_9_dsi>, <&pinctrl_i2s_2_bclk_touch_reset>;
                reg = <0x4a>;
                /* Verdin I2S_2_BCLK (TOUCH_RESET#, SODIMM 42) */
-               reset-gpios = <&gpio3 23 GPIO_ACTIVE_HIGH>;
+               reset-gpios = <&gpio3 23 GPIO_ACTIVE_LOW>;
                status = "disabled";
        };
 
 };
 
 &usbphynop2 {
+       power-domains = <&pgc_otg2>;
        vcc-supply = <&reg_vdd_3v3>;
 };
 
index a616eb3..0f13ee3 100644 (file)
@@ -70,7 +70,7 @@
 &ecspi1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_ecspi1>;
-       cs-gpios = <&gpio5 9 GPIO_ACTIVE_LOW>;
+       cs-gpios = <&gpio5 17 GPIO_ACTIVE_LOW>;
        status = "disabled";
 };
 
        pinctrl-names = "default", "gpio";
        pinctrl-0 = <&pinctrl_i2c5>;
        pinctrl-1 = <&pinctrl_i2c5_gpio>;
-       scl-gpios = <&gpio5 26 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
-       sda-gpios = <&gpio5 27 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+       scl-gpios = <&gpio3 26 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+       sda-gpios = <&gpio3 27 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
        status = "okay";
 };
 
 
        pinctrl_ecspi1: dhcom-ecspi1-grp {
                fsl,pins = <
-                       MX8MP_IOMUXC_ECSPI1_SCLK__ECSPI1_SCLK           0x44
-                       MX8MP_IOMUXC_ECSPI1_MOSI__ECSPI1_MOSI           0x44
-                       MX8MP_IOMUXC_ECSPI1_MISO__ECSPI1_MISO           0x44
-                       MX8MP_IOMUXC_ECSPI1_SS0__GPIO5_IO09             0x40
+                       MX8MP_IOMUXC_I2C1_SCL__ECSPI1_SCLK              0x44
+                       MX8MP_IOMUXC_I2C1_SDA__ECSPI1_MOSI              0x44
+                       MX8MP_IOMUXC_I2C2_SCL__ECSPI1_MISO              0x44
+                       MX8MP_IOMUXC_I2C2_SDA__GPIO5_IO17               0x40
                >;
        };
 
index 5212155..6630ec5 100644 (file)
 
        pinctrl_sai2: sai2grp {
                fsl,pins = <
-                       MX8MP_IOMUXC_SAI2_TXFS__AUDIOMIX_SAI2_TX_SYNC
-                       MX8MP_IOMUXC_SAI2_TXD0__AUDIOMIX_SAI2_TX_DATA00
-                       MX8MP_IOMUXC_SAI2_TXC__AUDIOMIX_SAI2_TX_BCLK
-                       MX8MP_IOMUXC_SAI2_MCLK__AUDIOMIX_SAI2_MCLK
+                       MX8MP_IOMUXC_SAI2_TXFS__AUDIOMIX_SAI2_TX_SYNC   0xd6
+                       MX8MP_IOMUXC_SAI2_TXD0__AUDIOMIX_SAI2_TX_DATA00 0xd6
+                       MX8MP_IOMUXC_SAI2_TXC__AUDIOMIX_SAI2_TX_BCLK    0xd6
+                       MX8MP_IOMUXC_SAI2_MCLK__AUDIOMIX_SAI2_MCLK      0xd6
                >;
        };
 
index c5987bd..1c74c6a 100644 (file)
                interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
                reg = <0x4a>;
                /* Verdin GPIO_2 (SODIMM 208) */
-               reset-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
+               reset-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
                status = "disabled";
        };
 };
                pinctrl-0 = <&pinctrl_gpio_9_dsi>, <&pinctrl_i2s_2_bclk_touch_reset>;
                reg = <0x4a>;
                /* Verdin I2S_2_BCLK (TOUCH_RESET#, SODIMM 42) */
-               reset-gpios = <&gpio5 0 GPIO_ACTIVE_HIGH>;
+               reset-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
                status = "disabled";
        };
 
index 899e8e7..802ad6e 100644 (file)
                reg = <0x51>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_rtc>;
-               interrupt-names = "irq";
                interrupt-parent = <&gpio1>;
                interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
                quartz-load-femtofarads = <7000>;
index 7cbb0de..1c15726 100644 (file)
@@ -85,7 +85,7 @@
                                     "renesas,rcar-gen4-hscif",
                                     "renesas,hscif";
                        reg = <0 0xe6540000 0 96>;
-                       interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 514>,
                                 <&cpg CPG_CORE R8A779G0_CLK_S0D3_PER>,
                                 <&scif_clk>;
index ca9b487..34256bd 100644 (file)
@@ -71,7 +71,7 @@ static __always_inline int icache_is_vpipt(void)
 
 static inline u32 cache_type_cwg(void)
 {
-       return (read_cpuid_cachetype() >> CTR_EL0_CWG_SHIFT) & CTR_EL0_CWG_MASK;
+       return SYS_FIELD_GET(CTR_EL0, CWG, read_cpuid_cachetype());
 }
 
 #define __read_mostly __section(".data..read_mostly")
index 9bb1873..6f86b7a 100644 (file)
@@ -153,7 +153,7 @@ struct vl_info {
 
 #ifdef CONFIG_ARM64_SVE
 
-extern void sve_alloc(struct task_struct *task);
+extern void sve_alloc(struct task_struct *task, bool flush);
 extern void fpsimd_release_task(struct task_struct *task);
 extern void fpsimd_sync_to_sve(struct task_struct *task);
 extern void fpsimd_force_sync_to_sve(struct task_struct *task);
@@ -256,7 +256,7 @@ size_t sve_state_size(struct task_struct const *task);
 
 #else /* ! CONFIG_ARM64_SVE */
 
-static inline void sve_alloc(struct task_struct *task) { }
+static inline void sve_alloc(struct task_struct *task, bool flush) { }
 static inline void fpsimd_release_task(struct task_struct *task) { }
 static inline void sve_sync_to_fpsimd(struct task_struct *task) { }
 static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { }
index 02e59fa..32d14f4 100644 (file)
 #define EARLY_KASLR    (0)
 #endif
 
-#define EARLY_ENTRIES(vstart, vend, shift) \
-       ((((vend) - 1) >> (shift)) - ((vstart) >> (shift)) + 1 + EARLY_KASLR)
+#define EARLY_ENTRIES(vstart, vend, shift, add) \
+       ((((vend) - 1) >> (shift)) - ((vstart) >> (shift)) + 1 + add)
 
-#define EARLY_PGDS(vstart, vend) (EARLY_ENTRIES(vstart, vend, PGDIR_SHIFT))
+#define EARLY_PGDS(vstart, vend, add) (EARLY_ENTRIES(vstart, vend, PGDIR_SHIFT, add))
 
 #if SWAPPER_PGTABLE_LEVELS > 3
-#define EARLY_PUDS(vstart, vend) (EARLY_ENTRIES(vstart, vend, PUD_SHIFT))
+#define EARLY_PUDS(vstart, vend, add) (EARLY_ENTRIES(vstart, vend, PUD_SHIFT, add))
 #else
-#define EARLY_PUDS(vstart, vend) (0)
+#define EARLY_PUDS(vstart, vend, add) (0)
 #endif
 
 #if SWAPPER_PGTABLE_LEVELS > 2
-#define EARLY_PMDS(vstart, vend) (EARLY_ENTRIES(vstart, vend, SWAPPER_TABLE_SHIFT))
+#define EARLY_PMDS(vstart, vend, add) (EARLY_ENTRIES(vstart, vend, SWAPPER_TABLE_SHIFT, add))
 #else
-#define EARLY_PMDS(vstart, vend) (0)
+#define EARLY_PMDS(vstart, vend, add) (0)
 #endif
 
-#define EARLY_PAGES(vstart, vend) ( 1                  /* PGDIR page */                                \
-                       + EARLY_PGDS((vstart), (vend))  /* each PGDIR needs a next level page table */  \
-                       + EARLY_PUDS((vstart), (vend))  /* each PUD needs a next level page table */    \
-                       + EARLY_PMDS((vstart), (vend))) /* each PMD needs a next level page table */
-#define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR, _end))
+#define EARLY_PAGES(vstart, vend, add) ( 1                     /* PGDIR page */                                \
+                       + EARLY_PGDS((vstart), (vend), add)     /* each PGDIR needs a next level page table */  \
+                       + EARLY_PUDS((vstart), (vend), add)     /* each PUD needs a next level page table */    \
+                       + EARLY_PMDS((vstart), (vend), add))    /* each PMD needs a next level page table */
+#define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR, _end, EARLY_KASLR))
 
 /* the initial ID map may need two extra pages if it needs to be extended */
 #if VA_BITS < 48
@@ -93,7 +93,7 @@
 #else
 #define INIT_IDMAP_DIR_SIZE    (INIT_IDMAP_DIR_PAGES * PAGE_SIZE)
 #endif
-#define INIT_IDMAP_DIR_PAGES   EARLY_PAGES(KIMAGE_VADDR, _end + MAX_FDT_SIZE + SWAPPER_BLOCK_SIZE)
+#define INIT_IDMAP_DIR_PAGES   EARLY_PAGES(KIMAGE_VADDR, _end + MAX_FDT_SIZE + SWAPPER_BLOCK_SIZE, 1)
 
 /* Initial memory map size */
 #if ARM64_KERNEL_USES_PMD_MAPS
index 6437df6..f4af547 100644 (file)
@@ -3,6 +3,8 @@
 #ifndef __ARM64_ASM_SETUP_H
 #define __ARM64_ASM_SETUP_H
 
+#include <linux/string.h>
+
 #include <uapi/asm/setup.h>
 
 void *get_early_fdt_ptr(void);
@@ -14,4 +16,19 @@ void early_fdt_map(u64 dt_phys);
 extern phys_addr_t __fdt_pointer __initdata;
 extern u64 __cacheline_aligned boot_args[4];
 
+static inline bool arch_parse_debug_rodata(char *arg)
+{
+       extern bool rodata_enabled;
+       extern bool rodata_full;
+
+       if (arg && !strcmp(arg, "full")) {
+               rodata_enabled = true;
+               rodata_full = true;
+               return true;
+       }
+
+       return false;
+}
+#define arch_parse_debug_rodata arch_parse_debug_rodata
+
 #endif
index 7c71358..818df93 100644 (file)
 
 #else
 
+#include <linux/bitfield.h>
 #include <linux/build_bug.h>
 #include <linux/types.h>
 #include <asm/alternative.h>
        par;                                                            \
 })
 
-#endif
-
 #define SYS_FIELD_GET(reg, field, val)         \
                 FIELD_GET(reg##_##field##_MASK, val)
 
 #define SYS_FIELD_PREP_ENUM(reg, field, val)           \
                 FIELD_PREP(reg##_##field##_MASK, reg##_##field##_##val)
 
+#endif
+
 #endif /* __ASM_SYSREG_H */
index 587543c..97c42be 100644 (file)
@@ -45,7 +45,8 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
 
 int init_cache_level(unsigned int cpu)
 {
-       unsigned int ctype, level, leaves, fw_level;
+       unsigned int ctype, level, leaves;
+       int fw_level;
        struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 
        for (level = 1, leaves = 0; level <= MAX_CACHE_LEVEL; level++) {
@@ -63,6 +64,9 @@ int init_cache_level(unsigned int cpu)
        else
                fw_level = acpi_find_last_cache_level(cpu);
 
+       if (fw_level < 0)
+               return fw_level;
+
        if (level < fw_level) {
                /*
                 * some external caches not specified in CLIDR_EL1
index 7e6289e..53b973b 100644 (file)
@@ -208,6 +208,8 @@ static const struct arm64_cpu_capabilities arm64_repeat_tlbi_list[] = {
 #ifdef CONFIG_ARM64_ERRATUM_1286807
        {
                ERRATA_MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 0),
+       },
+       {
                /* Kryo4xx Gold (rcpe to rfpe) => (r0p0 to r3p0) */
                ERRATA_MIDR_RANGE(MIDR_QCOM_KRYO_4XX_GOLD, 0xc, 0xe, 0xf, 0xe),
        },
@@ -654,6 +656,16 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
                ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2)
        },
 #endif
+#ifdef CONFIG_ARM64_ERRATUM_2457168
+       {
+               .desc = "ARM erratum 2457168",
+               .capability = ARM64_WORKAROUND_2457168,
+               .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
+
+               /* Cortex-A510 r0p0-r1p1 */
+               CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1)
+       },
+#endif
 #ifdef CONFIG_ARM64_ERRATUM_2038923
        {
                .desc = "ARM erratum 2038923",
index 907401e..af4de81 100644 (file)
@@ -1870,7 +1870,10 @@ static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
                pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n",
                        smp_processor_id());
                cpumask_set_cpu(smp_processor_id(), &amu_cpus);
-               update_freq_counters_refs();
+
+               /* 0 reference values signal broken/disabled counters */
+               if (!this_cpu_has_cap(ARM64_WORKAROUND_2457168))
+                       update_freq_counters_refs();
        }
 }
 
index 254fe31..2d73b3e 100644 (file)
@@ -502,7 +502,7 @@ tsk .req    x28             // current thread_info
 SYM_CODE_START(vectors)
        kernel_ventry   1, t, 64, sync          // Synchronous EL1t
        kernel_ventry   1, t, 64, irq           // IRQ EL1t
-       kernel_ventry   1, t, 64, fiq           // FIQ EL1h
+       kernel_ventry   1, t, 64, fiq           // FIQ EL1t
        kernel_ventry   1, t, 64, error         // Error EL1t
 
        kernel_ventry   1, h, 64, sync          // Synchronous EL1h
index dd63ffc..23834d9 100644 (file)
@@ -715,10 +715,12 @@ size_t sve_state_size(struct task_struct const *task)
  * do_sve_acc() case, there is no ABI requirement to hide stale data
  * written previously be task.
  */
-void sve_alloc(struct task_struct *task)
+void sve_alloc(struct task_struct *task, bool flush)
 {
        if (task->thread.sve_state) {
-               memset(task->thread.sve_state, 0, sve_state_size(task));
+               if (flush)
+                       memset(task->thread.sve_state, 0,
+                              sve_state_size(task));
                return;
        }
 
@@ -1388,7 +1390,7 @@ void do_sve_acc(unsigned long esr, struct pt_regs *regs)
                return;
        }
 
-       sve_alloc(current);
+       sve_alloc(current, true);
        if (!current->thread.sve_state) {
                force_sig(SIGKILL);
                return;
@@ -1439,7 +1441,7 @@ void do_sme_acc(unsigned long esr, struct pt_regs *regs)
                return;
        }
 
-       sve_alloc(current);
+       sve_alloc(current, false);
        sme_alloc(current);
        if (!current->thread.sve_state || !current->thread.za_state) {
                force_sig(SIGKILL);
@@ -1460,17 +1462,6 @@ void do_sme_acc(unsigned long esr, struct pt_regs *regs)
                fpsimd_bind_task_to_cpu();
        }
 
-       /*
-        * If SVE was not already active initialise the SVE registers,
-        * any non-shared state between the streaming and regular SVE
-        * registers is architecturally guaranteed to be zeroed when
-        * we enter streaming mode.  We do not need to initialize ZA
-        * since ZA must be disabled at this point and enabling ZA is
-        * architecturally defined to zero ZA.
-        */
-       if (system_supports_sve() && !test_thread_flag(TIF_SVE))
-               sve_init_regs();
-
        put_cpu_fpsimd_context();
 }
 
index cefe6a7..814b658 100644 (file)
@@ -371,7 +371,9 @@ SYM_FUNC_END(create_idmap)
 SYM_FUNC_START_LOCAL(create_kernel_mapping)
        adrp    x0, init_pg_dir
        mov_q   x5, KIMAGE_VADDR                // compile time __va(_text)
+#ifdef CONFIG_RELOCATABLE
        add     x5, x5, x23                     // add KASLR displacement
+#endif
        adrp    x6, _end                        // runtime __pa(_end)
        adrp    x3, _text                       // runtime __pa(_text)
        sub     x6, x6, x3                      // _end - _text
index 8899512..a11a6e1 100644 (file)
@@ -47,7 +47,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)
        u64 i;
        phys_addr_t start, end;
 
-       nr_ranges = 1; /* for exclusion of crashkernel region */
+       nr_ranges = 2; /* for exclusion of crashkernel region */
        for_each_mem_range(i, &start, &end)
                nr_ranges++;
 
index 6c3855e..17bff6e 100644 (file)
@@ -94,11 +94,9 @@ asmlinkage u64 kaslr_early_init(void *fdt)
 
        seed = get_kaslr_seed(fdt);
        if (!seed) {
-#ifdef CONFIG_ARCH_RANDOM
-                if (!__early_cpu_has_rndr() ||
-                    !__arm64_rndr((unsigned long *)&seed))
-#endif
-               return 0;
+               if (!__early_cpu_has_rndr() ||
+                   !__arm64_rndr((unsigned long *)&seed))
+                       return 0;
        }
 
        /*
index 21da831..eb7c08d 100644 (file)
@@ -882,7 +882,7 @@ static int sve_set_common(struct task_struct *target,
                 * state and ensure there's storage.
                 */
                if (target->thread.svcr != old_svcr)
-                       sve_alloc(target);
+                       sve_alloc(target, true);
        }
 
        /* Registers: FPSIMD-only case */
@@ -912,7 +912,7 @@ static int sve_set_common(struct task_struct *target,
                goto out;
        }
 
-       sve_alloc(target);
+       sve_alloc(target, true);
        if (!target->thread.sve_state) {
                ret = -ENOMEM;
                clear_tsk_thread_flag(target, TIF_SVE);
@@ -1082,7 +1082,7 @@ static int za_set(struct task_struct *target,
 
        /* Ensure there is some SVE storage for streaming mode */
        if (!target->thread.sve_state) {
-               sve_alloc(target);
+               sve_alloc(target, false);
                if (!target->thread.sve_state) {
                        clear_thread_flag(TIF_SME);
                        ret = -ENOMEM;
index 3e6d035..9ad911f 100644 (file)
@@ -91,7 +91,7 @@ static size_t sigframe_size(struct rt_sigframe_user_layout const *user)
  * not taken into account.  This limit is not a guarantee and is
  * NOT ABI.
  */
-#define SIGFRAME_MAXSZ SZ_64K
+#define SIGFRAME_MAXSZ SZ_256K
 
 static int __sigframe_alloc(struct rt_sigframe_user_layout *user,
                            unsigned long *offset, size_t size, bool extend)
@@ -310,7 +310,7 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user)
        fpsimd_flush_task_state(current);
        /* From now, fpsimd_thread_switch() won't touch thread.sve_state */
 
-       sve_alloc(current);
+       sve_alloc(current, true);
        if (!current->thread.sve_state) {
                clear_thread_flag(TIF_SVE);
                return -ENOMEM;
@@ -926,6 +926,16 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
 
        /* Signal handlers are invoked with ZA and streaming mode disabled */
        if (system_supports_sme()) {
+               /*
+                * If we were in streaming mode the saved register
+                * state was SVE but we will exit SM and use the
+                * FPSIMD register state - flush the saved FPSIMD
+                * register state in case it gets loaded.
+                */
+               if (current->thread.svcr & SVCR_SM_MASK)
+                       memset(&current->thread.uw.fpsimd_state, 0,
+                              sizeof(current->thread.uw.fpsimd_state));
+
                current->thread.svcr &= ~(SVCR_ZA_MASK |
                                          SVCR_SM_MASK);
                sme_smstop();
index 869ffc4..ad2bfc7 100644 (file)
@@ -296,12 +296,25 @@ core_initcall(init_amu_fie);
 
 static void cpu_read_corecnt(void *val)
 {
+       /*
+        * A value of 0 can be returned if the current CPU does not support AMUs
+        * or if the counter is disabled for this CPU. A return value of 0 at
+        * counter read is properly handled as an error case by the users of the
+        * counter.
+        */
        *(u64 *)val = read_corecnt();
 }
 
 static void cpu_read_constcnt(void *val)
 {
-       *(u64 *)val = read_constcnt();
+       /*
+        * Return 0 if the current CPU is affected by erratum 2457168. A value
+        * of 0 is also returned if the current CPU does not support AMUs or if
+        * the counter is disabled. A return value of 0 at counter read is
+        * properly handled as an error case by the users of the counter.
+        */
+       *(u64 *)val = this_cpu_has_cap(ARM64_WORKAROUND_2457168) ?
+                     0UL : read_constcnt();
 }
 
 static inline
@@ -328,7 +341,22 @@ int counters_read_on_cpu(int cpu, smp_call_func_t func, u64 *val)
  */
 bool cpc_ffh_supported(void)
 {
-       return freq_counters_valid(get_cpu_with_amu_feat());
+       int cpu = get_cpu_with_amu_feat();
+
+       /*
+        * FFH is considered supported if there is at least one present CPU that
+        * supports AMUs. Using FFH to read core and reference counters for CPUs
+        * that do not support AMUs, have counters disabled or that are affected
+        * by errata, will result in a return value of 0.
+        *
+        * This is done to allow any enabled and valid counters to be read
+        * through FFH, knowing that potentially returning 0 as counter value is
+        * properly handled by the users of these counters.
+        */
+       if ((cpu >= nr_cpu_ids) || !cpumask_test_cpu(cpu, cpu_present_mask))
+               return false;
+
+       return true;
 }
 
 int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val)
index db7c4e6..e7ad445 100644 (file)
@@ -642,24 +642,6 @@ static void __init map_kernel_segment(pgd_t *pgdp, void *va_start, void *va_end,
        vm_area_add_early(vma);
 }
 
-static int __init parse_rodata(char *arg)
-{
-       int ret = strtobool(arg, &rodata_enabled);
-       if (!ret) {
-               rodata_full = false;
-               return 0;
-       }
-
-       /* permit 'full' in addition to boolean options */
-       if (strcmp(arg, "full"))
-               return -EINVAL;
-
-       rodata_enabled = true;
-       rodata_full = true;
-       return 0;
-}
-early_param("rodata", parse_rodata);
-
 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
 static int __init map_entry_trampoline(void)
 {
index 7796537..63b2484 100644 (file)
@@ -67,6 +67,7 @@ WORKAROUND_1902691
 WORKAROUND_2038923
 WORKAROUND_2064142
 WORKAROUND_2077057
+WORKAROUND_2457168
 WORKAROUND_TRBE_OVERWRITE_FILL_MODE
 WORKAROUND_TSB_FLUSH_FAILURE
 WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
index da50047..160d8f3 100644 (file)
@@ -179,6 +179,21 @@ arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
        return retval;
 }
 
+static __always_inline bool
+arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr)
+{
+       int retval;
+
+       asm volatile(
+       "{P0 = tstbit(%1,%2); if (P0.new) %0 = #1; if (!P0.new) %0 = #0;}\n"
+       : "=&r" (retval)
+       : "r" (addr[BIT_WORD(nr)]), "r" (nr % BITS_PER_LONG)
+       : "p0", "memory"
+       );
+
+       return retval;
+}
+
 /*
  * ffz - find first zero in word.
  * @word: The word to search
index 9f62af7..1accb78 100644 (file)
@@ -331,11 +331,8 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
        return (old & bit) != 0;
 }
 
-static __always_inline bool
-arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
-{
-       return 1 & (((const volatile __u32 *) addr)[nr >> 5] >> (nr & 31));
-}
+#define arch_test_bit generic_test_bit
+#define arch_test_bit_acquire generic_test_bit_acquire
 
 /**
  * ffz - find the first zero bit in a long word
index 4abc9a2..c7dd6ad 100644 (file)
@@ -39,6 +39,7 @@ config LOONGARCH
        select ARCH_INLINE_SPIN_UNLOCK_BH if !PREEMPTION
        select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPTION
        select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPTION
+       select ARCH_KEEP_MEMBLOCK
        select ARCH_MIGHT_HAVE_PC_PARPORT
        select ARCH_MIGHT_HAVE_PC_SERIO
        select ARCH_SPARSEMEM_ENABLE
@@ -51,6 +52,7 @@ config LOONGARCH
        select ARCH_USE_CMPXCHG_LOCKREF
        select ARCH_USE_QUEUED_RWLOCKS
        select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
+       select ARCH_WANT_LD_ORPHAN_WARN
        select ARCH_WANTS_NO_INSTR
        select BUILDTIME_TABLE_SORT
        select COMMON_CLK
@@ -111,6 +113,7 @@ config LOONGARCH
        select PCI_ECAM if ACPI
        select PCI_LOONGSON
        select PCI_MSI_ARCH_FALLBACKS
+       select PCI_QUIRKS
        select PERF_USE_VMALLOC
        select RTC_LIB
        select SMP
index c510821..17162f4 100644 (file)
@@ -15,7 +15,7 @@ extern int acpi_pci_disabled;
 extern int acpi_noirq;
 
 #define acpi_os_ioremap acpi_os_ioremap
-void __init __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
+void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
 
 static inline void disable_acpi(void)
 {
index b91e073..d342935 100644 (file)
@@ -109,4 +109,20 @@ extern unsigned long vm_map_base;
  */
 #define PHYSADDR(a)            ((_ACAST64_(a)) & TO_PHYS_MASK)
 
+/*
+ * On LoongArch, I/O ports mappring is following:
+ *
+ *              |         ....          |
+ *              |-----------------------|
+ *              | pci io ports(16K~32M) |
+ *              |-----------------------|
+ *              | isa io ports(0  ~16K) |
+ * PCI_IOBASE ->|-----------------------|
+ *              |         ....          |
+ */
+#define PCI_IOBASE     ((void __iomem *)(vm_map_base + (2 * PAGE_SIZE)))
+#define PCI_IOSIZE     SZ_32M
+#define ISA_IOSIZE     SZ_16K
+#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)
+
 #endif /* _ASM_ADDRSPACE_H */
index 0a9b0fa..ae19e33 100644 (file)
@@ -5,8 +5,9 @@
 #ifndef __ASM_CMPXCHG_H
 #define __ASM_CMPXCHG_H
 
-#include <asm/barrier.h>
+#include <linux/bits.h>
 #include <linux/build_bug.h>
+#include <asm/barrier.h>
 
 #define __xchg_asm(amswap_db, m, val)          \
 ({                                             \
                __ret;                          \
 })
 
+static inline unsigned int __xchg_small(volatile void *ptr, unsigned int val,
+                                       unsigned int size)
+{
+       unsigned int shift;
+       u32 old32, mask, temp;
+       volatile u32 *ptr32;
+
+       /* Mask value to the correct size. */
+       mask = GENMASK((size * BITS_PER_BYTE) - 1, 0);
+       val &= mask;
+
+       /*
+        * Calculate a shift & mask that correspond to the value we wish to
+        * exchange within the naturally aligned 4 byte integerthat includes
+        * it.
+        */
+       shift = (unsigned long)ptr & 0x3;
+       shift *= BITS_PER_BYTE;
+       mask <<= shift;
+
+       /*
+        * Calculate a pointer to the naturally aligned 4 byte integer that
+        * includes our byte of interest, and load its value.
+        */
+       ptr32 = (volatile u32 *)((unsigned long)ptr & ~0x3);
+
+       asm volatile (
+       "1:     ll.w            %0, %3          \n"
+       "       andn            %1, %0, %z4     \n"
+       "       or              %1, %1, %z5     \n"
+       "       sc.w            %1, %2          \n"
+       "       beqz            %1, 1b          \n"
+       : "=&r" (old32), "=&r" (temp), "=ZC" (*ptr32)
+       : "ZC" (*ptr32), "Jr" (mask), "Jr" (val << shift)
+       : "memory");
+
+       return (old32 & mask) >> shift;
+}
+
 static inline unsigned long __xchg(volatile void *ptr, unsigned long x,
                                   int size)
 {
        switch (size) {
+       case 1:
+       case 2:
+               return __xchg_small(ptr, x, size);
+
        case 4:
                return __xchg_asm("amswap_db.w", (volatile u32 *)ptr, (u32)x);
 
@@ -67,10 +111,62 @@ static inline unsigned long __xchg(volatile void *ptr, unsigned long x,
        __ret;                                                          \
 })
 
+static inline unsigned int __cmpxchg_small(volatile void *ptr, unsigned int old,
+                                          unsigned int new, unsigned int size)
+{
+       unsigned int shift;
+       u32 old32, mask, temp;
+       volatile u32 *ptr32;
+
+       /* Mask inputs to the correct size. */
+       mask = GENMASK((size * BITS_PER_BYTE) - 1, 0);
+       old &= mask;
+       new &= mask;
+
+       /*
+        * Calculate a shift & mask that correspond to the value we wish to
+        * compare & exchange within the naturally aligned 4 byte integer
+        * that includes it.
+        */
+       shift = (unsigned long)ptr & 0x3;
+       shift *= BITS_PER_BYTE;
+       old <<= shift;
+       new <<= shift;
+       mask <<= shift;
+
+       /*
+        * Calculate a pointer to the naturally aligned 4 byte integer that
+        * includes our byte of interest, and load its value.
+        */
+       ptr32 = (volatile u32 *)((unsigned long)ptr & ~0x3);
+
+       asm volatile (
+       "1:     ll.w            %0, %3          \n"
+       "       and             %1, %0, %z4     \n"
+       "       bne             %1, %z5, 2f     \n"
+       "       andn            %1, %0, %z4     \n"
+       "       or              %1, %1, %z6     \n"
+       "       sc.w            %1, %2          \n"
+       "       beqz            %1, 1b          \n"
+       "       b               3f              \n"
+       "2:                                     \n"
+       __WEAK_LLSC_MB
+       "3:                                     \n"
+       : "=&r" (old32), "=&r" (temp), "=ZC" (*ptr32)
+       : "ZC" (*ptr32), "Jr" (mask), "Jr" (old), "Jr" (new)
+       : "memory");
+
+       return (old32 & mask) >> shift;
+}
+
 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
                                      unsigned long new, unsigned int size)
 {
        switch (size) {
+       case 1:
+       case 2:
+               return __cmpxchg_small(ptr, old, new, size);
+
        case 4:
                return __cmpxchg_asm("ll.w", "sc.w", (volatile u32 *)ptr,
                                     (u32)old, new);
index 8845997..999944e 100644 (file)
@@ -7,35 +7,16 @@
 
 #define ARCH_HAS_IOREMAP_WC
 
-#include <linux/compiler.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 
 #include <asm/addrspace.h>
-#include <asm/bug.h>
-#include <asm/byteorder.h>
 #include <asm/cpu.h>
 #include <asm/page.h>
 #include <asm/pgtable-bits.h>
 #include <asm/string.h>
 
 /*
- * On LoongArch, I/O ports mappring is following:
- *
- *              |         ....          |
- *              |-----------------------|
- *              | pci io ports(64K~32M) |
- *              |-----------------------|
- *              | isa io ports(0  ~16K) |
- * PCI_IOBASE ->|-----------------------|
- *              |         ....          |
- */
-#define PCI_IOBASE     ((void __iomem *)(vm_map_base + (2 * PAGE_SIZE)))
-#define PCI_IOSIZE     SZ_32M
-#define ISA_IOSIZE     SZ_16K
-#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)
-
-/*
  * Change "struct page" to physical address.
  */
 #define page_to_phys(page)     ((phys_addr_t)page_to_pfn(page) << PAGE_SHIFT)
index a37324a..53f284a 100644 (file)
@@ -95,7 +95,7 @@ static inline int pfn_valid(unsigned long pfn)
 
 #endif
 
-#define virt_to_pfn(kaddr)     PFN_DOWN(virt_to_phys((void *)(kaddr)))
+#define virt_to_pfn(kaddr)     PFN_DOWN(PHYSADDR(kaddr))
 #define virt_to_page(kaddr)    pfn_to_page(virt_to_pfn(kaddr))
 
 extern int __virt_addr_valid(volatile void *kaddr);
index e6569f1..0bd6b01 100644 (file)
@@ -123,6 +123,10 @@ static inline unsigned long __percpu_xchg(void *ptr, unsigned long val,
                                                int size)
 {
        switch (size) {
+       case 1:
+       case 2:
+               return __xchg_small((volatile void *)ptr, val, size);
+
        case 4:
                return __xchg_asm("amswap.w", (volatile u32 *)ptr, (u32)val);
 
@@ -204,9 +208,13 @@ do {                                                                       \
 #define this_cpu_write_4(pcp, val) _percpu_write(pcp, val)
 #define this_cpu_write_8(pcp, val) _percpu_write(pcp, val)
 
+#define this_cpu_xchg_1(pcp, val) _percpu_xchg(pcp, val)
+#define this_cpu_xchg_2(pcp, val) _percpu_xchg(pcp, val)
 #define this_cpu_xchg_4(pcp, val) _percpu_xchg(pcp, val)
 #define this_cpu_xchg_8(pcp, val) _percpu_xchg(pcp, val)
 
+#define this_cpu_cmpxchg_1(ptr, o, n) _protect_cmpxchg_local(ptr, o, n)
+#define this_cpu_cmpxchg_2(ptr, o, n) _protect_cmpxchg_local(ptr, o, n)
 #define this_cpu_cmpxchg_4(ptr, o, n) _protect_cmpxchg_local(ptr, o, n)
 #define this_cpu_cmpxchg_8(ptr, o, n) _protect_cmpxchg_local(ptr, o, n)
 
index e03443a..8ea57e2 100644 (file)
@@ -59,7 +59,6 @@
 #include <linux/mm_types.h>
 #include <linux/mmzone.h>
 #include <asm/fixmap.h>
-#include <asm/io.h>
 
 struct mm_struct;
 struct vm_area_struct;
@@ -145,7 +144,7 @@ static inline void set_p4d(p4d_t *p4d, p4d_t p4dval)
        *p4d = p4dval;
 }
 
-#define p4d_phys(p4d)          virt_to_phys((void *)p4d_val(p4d))
+#define p4d_phys(p4d)          PHYSADDR(p4d_val(p4d))
 #define p4d_page(p4d)          (pfn_to_page(p4d_phys(p4d) >> PAGE_SHIFT))
 
 #endif
@@ -188,7 +187,7 @@ static inline pmd_t *pud_pgtable(pud_t pud)
 
 #define set_pud(pudptr, pudval) do { *(pudptr) = (pudval); } while (0)
 
-#define pud_phys(pud)          virt_to_phys((void *)pud_val(pud))
+#define pud_phys(pud)          PHYSADDR(pud_val(pud))
 #define pud_page(pud)          (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT))
 
 #endif
@@ -221,7 +220,7 @@ static inline void pmd_clear(pmd_t *pmdp)
 
 #define set_pmd(pmdptr, pmdval) do { *(pmdptr) = (pmdval); } while (0)
 
-#define pmd_phys(pmd)          virt_to_phys((void *)pmd_val(pmd))
+#define pmd_phys(pmd)          PHYSADDR(pmd_val(pmd))
 
 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
 #define pmd_page(pmd)          (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
diff --git a/arch/loongarch/include/asm/reboot.h b/arch/loongarch/include/asm/reboot.h
deleted file mode 100644 (file)
index 5115174..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
- */
-#ifndef _ASM_REBOOT_H
-#define _ASM_REBOOT_H
-
-extern void (*pm_restart)(void);
-
-#endif /* _ASM_REBOOT_H */
index f1c9286..3353984 100644 (file)
@@ -48,7 +48,7 @@ void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
        early_memunmap(map, size);
 }
 
-void __init __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
+void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
 {
        if (!memblock_is_memory(phys))
                return ioremap(phys, size);
index 800c965..8c82021 100644 (file)
 #include <acpi/reboot.h>
 #include <asm/idle.h>
 #include <asm/loongarch.h>
-#include <asm/reboot.h>
 
-static void default_halt(void)
+void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
+
+void machine_halt(void)
 {
+#ifdef CONFIG_SMP
+       preempt_disable();
+       smp_send_stop();
+#endif
        local_irq_disable();
        clear_csr_ecfg(ECFG0_IM);
 
@@ -30,18 +36,29 @@ static void default_halt(void)
        }
 }
 
-static void default_poweroff(void)
+void machine_power_off(void)
 {
+#ifdef CONFIG_SMP
+       preempt_disable();
+       smp_send_stop();
+#endif
+       do_kernel_power_off();
 #ifdef CONFIG_EFI
        efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
 #endif
+
        while (true) {
                __arch_cpu_idle();
        }
 }
 
-static void default_restart(void)
+void machine_restart(char *command)
 {
+#ifdef CONFIG_SMP
+       preempt_disable();
+       smp_send_stop();
+#endif
+       do_kernel_restart(command);
 #ifdef CONFIG_EFI
        if (efi_capsule_pending(NULL))
                efi_reboot(REBOOT_WARM, NULL);
@@ -55,47 +72,3 @@ static void default_restart(void)
                __arch_cpu_idle();
        }
 }
-
-void (*pm_restart)(void);
-EXPORT_SYMBOL(pm_restart);
-
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
-void machine_halt(void)
-{
-#ifdef CONFIG_SMP
-       preempt_disable();
-       smp_send_stop();
-#endif
-       default_halt();
-}
-
-void machine_power_off(void)
-{
-#ifdef CONFIG_SMP
-       preempt_disable();
-       smp_send_stop();
-#endif
-       pm_power_off();
-}
-
-void machine_restart(char *command)
-{
-#ifdef CONFIG_SMP
-       preempt_disable();
-       smp_send_stop();
-#endif
-       do_kernel_restart(command);
-       pm_restart();
-}
-
-static int __init loongarch_reboot_setup(void)
-{
-       pm_restart = default_restart;
-       pm_power_off = default_poweroff;
-
-       return 0;
-}
-
-arch_initcall(loongarch_reboot_setup);
index 7f4889d..8f5b798 100644 (file)
@@ -529,11 +529,11 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
        signal_setup_done(ret, ksig, 0);
 }
 
-void arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal)
+void arch_do_signal_or_restart(struct pt_regs *regs)
 {
        struct ksignal ksig;
 
-       if (has_signal && get_signal(&ksig)) {
+       if (get_signal(&ksig)) {
                /* Whee!  Actually deliver the signal.  */
                handle_signal(&ksig, regs);
                return;
index 69c76f2..f4831df 100644 (file)
@@ -77,6 +77,8 @@ SECTIONS
        PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
 #endif
 
+       .rela.dyn : ALIGN(8) { *(.rela.dyn) *(.rela*) }
+
        .init.bss : {
                *(.init.bss)
        }
index cda2c6b..c2cc7ce 100644 (file)
@@ -18,11 +18,11 @@ void dump_tlb_regs(void)
 {
        const int field = 2 * sizeof(unsigned long);
 
-       pr_info("Index    : %0x\n", read_csr_tlbidx());
-       pr_info("PageSize : %0x\n", read_csr_pagesize());
-       pr_info("EntryHi  : %0*llx\n", field, read_csr_entryhi());
-       pr_info("EntryLo0 : %0*llx\n", field, read_csr_entrylo0());
-       pr_info("EntryLo1 : %0*llx\n", field, read_csr_entrylo1());
+       pr_info("Index    : 0x%0x\n", read_csr_tlbidx());
+       pr_info("PageSize : 0x%0x\n", read_csr_pagesize());
+       pr_info("EntryHi  : 0x%0*llx\n", field, read_csr_entryhi());
+       pr_info("EntryLo0 : 0x%0*llx\n", field, read_csr_entrylo0());
+       pr_info("EntryLo1 : 0x%0*llx\n", field, read_csr_entrylo1());
 }
 
 static void dump_tlb(int first, int last)
@@ -33,8 +33,8 @@ static void dump_tlb(int first, int last)
        unsigned int s_index, s_asid;
        unsigned int pagesize, c0, c1, i;
        unsigned long asidmask = cpu_asid_mask(&current_cpu_data);
-       int pwidth = 11;
-       int vwidth = 11;
+       int pwidth = 16;
+       int vwidth = 16;
        int asidwidth = DIV_ROUND_UP(ilog2(asidmask) + 1, 4);
 
        s_entryhi = read_csr_entryhi();
@@ -64,22 +64,22 @@ static void dump_tlb(int first, int last)
                /*
                 * Only print entries in use
                 */
-               pr_info("Index: %2d pgsize=%x ", i, (1 << pagesize));
+               pr_info("Index: %4d pgsize=0x%x ", i, (1 << pagesize));
 
                c0 = (entrylo0 & ENTRYLO_C) >> ENTRYLO_C_SHIFT;
                c1 = (entrylo1 & ENTRYLO_C) >> ENTRYLO_C_SHIFT;
 
-               pr_cont("va=%0*lx asid=%0*lx",
+               pr_cont("va=0x%0*lx asid=0x%0*lx",
                        vwidth, (entryhi & ~0x1fffUL), asidwidth, asid & asidmask);
 
                /* NR/NX are in awkward places, so mask them off separately */
                pa = entrylo0 & ~(ENTRYLO_NR | ENTRYLO_NX);
                pa = pa & PAGE_MASK;
                pr_cont("\n\t[");
-               pr_cont("ri=%d xi=%d ",
+               pr_cont("nr=%d nx=%d ",
                        (entrylo0 & ENTRYLO_NR) ? 1 : 0,
                        (entrylo0 & ENTRYLO_NX) ? 1 : 0);
-               pr_cont("pa=%0*llx c=%d d=%d v=%d g=%d plv=%lld] [",
+               pr_cont("pa=0x%0*llx c=%d d=%d v=%d g=%d plv=%lld] [",
                        pwidth, pa, c0,
                        (entrylo0 & ENTRYLO_D) ? 1 : 0,
                        (entrylo0 & ENTRYLO_V) ? 1 : 0,
@@ -88,10 +88,10 @@ static void dump_tlb(int first, int last)
                /* NR/NX are in awkward places, so mask them off separately */
                pa = entrylo1 & ~(ENTRYLO_NR | ENTRYLO_NX);
                pa = pa & PAGE_MASK;
-               pr_cont("ri=%d xi=%d ",
+               pr_cont("nr=%d nx=%d ",
                        (entrylo1 & ENTRYLO_NR) ? 1 : 0,
                        (entrylo1 & ENTRYLO_NX) ? 1 : 0);
-               pr_cont("pa=%0*llx c=%d d=%d v=%d g=%d plv=%lld]\n",
+               pr_cont("pa=0x%0*llx c=%d d=%d v=%d g=%d plv=%lld]\n",
                        pwidth, pa, c1,
                        (entrylo1 & ENTRYLO_D) ? 1 : 0,
                        (entrylo1 & ENTRYLO_V) ? 1 : 0,
index 605579b..1ccd536 100644 (file)
@@ -216,6 +216,10 @@ good_area:
                return;
        }
 
+       /* The fault is fully completed (including releasing mmap lock) */
+       if (fault & VM_FAULT_COMPLETED)
+               return;
+
        if (unlikely(fault & VM_FAULT_RETRY)) {
                flags |= FAULT_FLAG_TRIED;
 
index 7094a68..0532ed5 100644 (file)
@@ -131,18 +131,6 @@ int arch_add_memory(int nid, u64 start, u64 size, struct mhp_params *params)
        return ret;
 }
 
-#ifdef CONFIG_NUMA
-int memory_add_physaddr_to_nid(u64 start)
-{
-       int nid;
-
-       nid = pa_to_nid(start);
-       return nid;
-}
-EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
-#endif
-
-#ifdef CONFIG_MEMORY_HOTREMOVE
 void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = start >> PAGE_SHIFT;
@@ -154,6 +142,13 @@ void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
                page += vmem_altmap_offset(altmap);
        __remove_pages(start_pfn, nr_pages, altmap);
 }
+
+#ifdef CONFIG_NUMA
+int memory_add_physaddr_to_nid(u64 start)
+{
+       return pa_to_nid(start);
+}
+EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
 #endif
 #endif
 
index 52e40f0..381a569 100644 (file)
@@ -2,16 +2,9 @@
 /*
  * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  */
-#include <linux/compiler.h>
-#include <linux/elf-randomize.h>
-#include <linux/errno.h>
+#include <linux/export.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
-#include <linux/export.h>
-#include <linux/personality.h>
-#include <linux/random.h>
-#include <linux/sched/signal.h>
-#include <linux/sched/mm.h>
 
 unsigned long shm_align_mask = PAGE_SIZE - 1;  /* Sane caches */
 EXPORT_SYMBOL(shm_align_mask);
@@ -120,6 +113,6 @@ int __virt_addr_valid(volatile void *kaddr)
        if ((vaddr < PAGE_OFFSET) || (vaddr >= vm_map_base))
                return 0;
 
-       return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
+       return pfn_valid(PFN_DOWN(PHYSADDR(kaddr)));
 }
 EXPORT_SYMBOL_GPL(__virt_addr_valid);
index 43a0078..e02e775 100644 (file)
@@ -24,6 +24,8 @@ static __always_inline const struct vdso_pcpu_data *get_pcpu_data(void)
        return (struct vdso_pcpu_data *)(get_vdso_base() - VDSO_DATA_SIZE);
 }
 
+extern
+int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused);
 int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused)
 {
        int cpu_id;
index b1f4548..8f22863 100644 (file)
@@ -6,20 +6,23 @@
  */
 #include <linux/types.h>
 
-int __vdso_clock_gettime(clockid_t clock,
-                        struct __kernel_timespec *ts)
+extern
+int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts);
+int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
 {
        return __cvdso_clock_gettime(clock, ts);
 }
 
-int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
-                       struct timezone *tz)
+extern
+int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
+int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
 {
        return __cvdso_gettimeofday(tv, tz);
 }
 
-int __vdso_clock_getres(clockid_t clock_id,
-                       struct __kernel_timespec *res)
+extern
+int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res);
+int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res)
 {
        return __cvdso_clock_getres(clock_id, res);
 }
index 470aed9..e984af7 100644 (file)
@@ -157,11 +157,8 @@ arch___change_bit(unsigned long nr, volatile unsigned long *addr)
        change_bit(nr, addr);
 }
 
-static __always_inline bool
-arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
-{
-       return (addr[nr >> 5] & (1UL << (nr & 31))) != 0;
-}
+#define arch_test_bit generic_test_bit
+#define arch_test_bit_acquire generic_test_bit_acquire
 
 static inline int bset_reg_test_and_set_bit(int nr,
                                            volatile unsigned long *vaddr)
index 7f059cd..9aede24 100644 (file)
@@ -146,10 +146,10 @@ menu "Processor type and features"
 
 choice
        prompt "Processor type"
-       default PA7000
+       default PA7000 if "$(ARCH)" = "parisc"
 
 config PA7000
-       bool "PA7000/PA7100"
+       bool "PA7000/PA7100" if "$(ARCH)" = "parisc"
        help
          This is the processor type of your CPU.  This information is
          used for optimizing purposes.  In order to compile a kernel
@@ -160,21 +160,21 @@ config PA7000
          which is required on some machines.
 
 config PA7100LC
-       bool "PA7100LC"
+       bool "PA7100LC" if "$(ARCH)" = "parisc"
        help
          Select this option for the PCX-L processor, as used in the
          712, 715/64, 715/80, 715/100, 715/100XC, 725/100, 743, 748,
          D200, D210, D300, D310 and E-class
 
 config PA7200
-       bool "PA7200"
+       bool "PA7200" if "$(ARCH)" = "parisc"
        help
          Select this option for the PCX-T' processor, as used in the
          C100, C110, J100, J110, J210XC, D250, D260, D350, D360,
          K100, K200, K210, K220, K400, K410 and K420
 
 config PA7300LC
-       bool "PA7300LC"
+       bool "PA7300LC" if "$(ARCH)" = "parisc"
        help
          Select this option for the PCX-L2 processor, as used in the
          744, A180, B132L, B160L, B180L, C132L, C160L, C180L,
@@ -224,17 +224,8 @@ config MLONGCALLS
          Enabling this option will probably slow down your kernel.
 
 config 64BIT
-       bool "64-bit kernel"
+       def_bool "$(ARCH)" = "parisc64"
        depends on PA8X00
-       help
-         Enable this if you want to support 64bit kernel on PA-RISC platform.
-
-         At the moment, only people willing to use more than 2GB of RAM,
-         or having a 64bit-only capable PA-RISC machine should say Y here.
-
-         Since there is no 64bit userland on PA-RISC, there is no point to
-         enable this option otherwise. The 64bit kernel is significantly bigger
-         and slower than the 32bit one.
 
 choice
        prompt "Kernel page size"
index 56ffd26..0ec9cfc 100644 (file)
 #include <asm/barrier.h>
 #include <linux/atomic.h>
 
-/* compiler build environment sanity checks: */
-#if !defined(CONFIG_64BIT) && defined(__LP64__)
-#error "Please use 'ARCH=parisc' to build the 32-bit kernel."
-#endif
-#if defined(CONFIG_64BIT) && !defined(__LP64__)
-#error "Please use 'ARCH=parisc64' to build the 64-bit kernel."
-#endif
-
 /* See http://marc.theaimsgroup.com/?t=108826637900003 for discussion
  * on use of volatile and __*_bit() (set/clear/change):
  *     *_bit() want use of volatile.
index e0a9e96..fd15fd4 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/init.h>
 #include <linux/pgtable.h>
 
-       .level  PA_ASM_LEVEL
+       .level  1.1
 
        __INITDATA
 ENTRY(boot_args)
@@ -70,6 +70,47 @@ $bss_loop:
        stw,ma          %arg2,4(%r1)
        stw,ma          %arg3,4(%r1)
 
+#if !defined(CONFIG_64BIT) && defined(CONFIG_PA20)
+       /* This 32-bit kernel was compiled for PA2.0 CPUs. Check current CPU
+        * and halt kernel if we detect a PA1.x CPU. */
+       ldi             32,%r10
+       mtctl           %r10,%cr11
+       .level 2.0
+       mfctl,w         %cr11,%r10
+       .level 1.1
+       comib,<>,n      0,%r10,$cpu_ok
+
+       load32          PA(msg1),%arg0
+       ldi             msg1_end-msg1,%arg1
+$iodc_panic:
+       copy            %arg0, %r10
+       copy            %arg1, %r11
+       load32          PA(init_stack),%sp
+#define MEM_CONS 0x3A0
+       ldw             MEM_CONS+32(%r0),%arg0  // HPA
+       ldi             ENTRY_IO_COUT,%arg1
+       ldw             MEM_CONS+36(%r0),%arg2  // SPA
+       ldw             MEM_CONS+8(%r0),%arg3   // layers
+       load32          PA(__bss_start),%r1
+       stw             %r1,-52(%sp)            // arg4
+       stw             %r0,-56(%sp)            // arg5
+       stw             %r10,-60(%sp)           // arg6 = ptr to text
+       stw             %r11,-64(%sp)           // arg7 = len
+       stw             %r0,-68(%sp)            // arg8
+       load32          PA(.iodc_panic_ret), %rp
+       ldw             MEM_CONS+40(%r0),%r1    // ENTRY_IODC
+       bv,n            (%r1)
+.iodc_panic_ret:
+       b .                             /* wait endless with ... */
+       or              %r10,%r10,%r10  /* qemu idle sleep */
+msg1:  .ascii "Can't boot kernel which was built for PA8x00 CPUs on this machine.\r\n"
+msg1_end:
+
+$cpu_ok:
+#endif
+
+       .level  PA_ASM_LEVEL
+
        /* Initialize startup VM. Just map first 16/32 MB of memory */
        load32          PA(swapper_pg_dir),%r4
        mtctl           %r4,%cr24       /* Initialize kernel root pointer */
index fbb882c..b05055f 100644 (file)
@@ -480,7 +480,7 @@ static void execute_on_irq_stack(void *func, unsigned long param1)
        *irq_stack_in_use = 1;
 }
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 void do_softirq_own_stack(void)
 {
        execute_on_irq_stack(__do_softirq, 0);
index bac581b..e8a4d77 100644 (file)
@@ -93,7 +93,7 @@
 #define R1(i) (((i)>>21)&0x1f)
 #define R2(i) (((i)>>16)&0x1f)
 #define R3(i) ((i)&0x1f)
-#define FR3(i) ((((i)<<1)&0x1f)|(((i)>>6)&1))
+#define FR3(i) ((((i)&0x1f)<<1)|(((i)>>6)&1))
 #define IM(i,n) (((i)>>1&((1<<(n-1))-1))|((i)&1?((0-1L)<<(n-1)):0))
 #define IM5_2(i) IM((i)>>16,5)
 #define IM5_3(i) IM((i),5)
index 398e0b5..ed6db13 100644 (file)
@@ -83,6 +83,8 @@ enum {
        FW_FEATURE_POWERNV_ALWAYS = 0,
        FW_FEATURE_PS3_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
        FW_FEATURE_PS3_ALWAYS = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
+       FW_FEATURE_NATIVE_POSSIBLE = 0,
+       FW_FEATURE_NATIVE_ALWAYS = 0,
        FW_FEATURE_POSSIBLE =
 #ifdef CONFIG_PPC_PSERIES
                FW_FEATURE_PSERIES_POSSIBLE |
@@ -93,6 +95,9 @@ enum {
 #ifdef CONFIG_PPC_PS3
                FW_FEATURE_PS3_POSSIBLE |
 #endif
+#ifdef CONFIG_PPC_HASH_MMU_NATIVE
+               FW_FEATURE_NATIVE_ALWAYS |
+#endif
                0,
        FW_FEATURE_ALWAYS =
 #ifdef CONFIG_PPC_PSERIES
@@ -104,6 +109,9 @@ enum {
 #ifdef CONFIG_PPC_PS3
                FW_FEATURE_PS3_ALWAYS &
 #endif
+#ifdef CONFIG_PPC_HASH_MMU_NATIVE
+               FW_FEATURE_NATIVE_ALWAYS &
+#endif
                FW_FEATURE_POSSIBLE,
 
 #else /* CONFIG_PPC64 */
index 26ede09..9835518 100644 (file)
@@ -113,7 +113,14 @@ static inline void __hard_RI_enable(void)
 
 static inline notrace unsigned long irq_soft_mask_return(void)
 {
-       return READ_ONCE(local_paca->irq_soft_mask);
+       unsigned long flags;
+
+       asm volatile(
+               "lbz %0,%1(13)"
+               : "=r" (flags)
+               : "i" (offsetof(struct paca_struct, irq_soft_mask)));
+
+       return flags;
 }
 
 /*
@@ -140,24 +147,46 @@ static inline notrace void irq_soft_mask_set(unsigned long mask)
        if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
                WARN_ON(mask && !(mask & IRQS_DISABLED));
 
-       WRITE_ONCE(local_paca->irq_soft_mask, mask);
-       barrier();
+       asm volatile(
+               "stb %0,%1(13)"
+               :
+               : "r" (mask),
+                 "i" (offsetof(struct paca_struct, irq_soft_mask))
+               : "memory");
 }
 
 static inline notrace unsigned long irq_soft_mask_set_return(unsigned long mask)
 {
-       unsigned long flags = irq_soft_mask_return();
+       unsigned long flags;
 
-       irq_soft_mask_set(mask);
+#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
+       WARN_ON(mask && !(mask & IRQS_DISABLED));
+#endif
+
+       asm volatile(
+               "lbz %0,%1(13); stb %2,%1(13)"
+               : "=&r" (flags)
+               : "i" (offsetof(struct paca_struct, irq_soft_mask)),
+                 "r" (mask)
+               : "memory");
 
        return flags;
 }
 
 static inline notrace unsigned long irq_soft_mask_or_return(unsigned long mask)
 {
-       unsigned long flags = irq_soft_mask_return();
+       unsigned long flags, tmp;
+
+       asm volatile(
+               "lbz %0,%2(13); or %1,%0,%3; stb %1,%2(13)"
+               : "=&r" (flags), "=r" (tmp)
+               : "i" (offsetof(struct paca_struct, irq_soft_mask)),
+                 "r" (mask)
+               : "memory");
 
-       irq_soft_mask_set(flags | mask);
+#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
+       WARN_ON((mask | flags) && !((mask | flags) & IRQS_DISABLED));
+#endif
 
        return flags;
 }
@@ -282,7 +311,8 @@ static inline bool pmi_irq_pending(void)
        flags = irq_soft_mask_set_return(IRQS_ALL_DISABLED);            \
        local_paca->irq_happened |= PACA_IRQ_HARD_DIS;                  \
        if (!arch_irqs_disabled_flags(flags)) {                         \
-               WRITE_ONCE(local_paca->saved_r1, current_stack_pointer);\
+               asm volatile("std%X0 %1,%0" : "=m" (local_paca->saved_r1) \
+                                           : "r" (current_stack_pointer)); \
                trace_hardirqs_off();                                   \
        }                                                               \
 } while(0)
index 0f17268..9ede61a 100644 (file)
@@ -199,7 +199,7 @@ static inline void check_stack_overflow(unsigned long sp)
        }
 }
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 static __always_inline void call_do_softirq(const void *sp)
 {
        /* Temporarily switch r1 to sp, call __do_softirq() then restore r1. */
@@ -335,7 +335,7 @@ void *mcheckirq_ctx[NR_CPUS] __read_mostly;
 void *softirq_ctx[NR_CPUS] __read_mostly;
 void *hardirq_ctx[NR_CPUS] __read_mostly;
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 void do_softirq_own_stack(void)
 {
        call_do_softirq(softirq_ctx[smp_processor_id()]);
index 433965b..855b598 100644 (file)
@@ -245,6 +245,15 @@ static int __init pcibios_init(void)
 
        printk(KERN_INFO "PCI: Probing PCI hardware\n");
 
+#ifdef CONFIG_PPC_PCI_BUS_NUM_DOMAIN_DEPENDENT
+       /*
+        * Enable PCI domains in /proc when PCI bus numbers are not unique
+        * across all PCI domains to prevent conflicts. And keep PCI domain 0
+        * backward compatible in /proc for video cards.
+        */
+       pci_add_flags(PCI_ENABLE_PROC_DOMAINS | PCI_COMPAT_DOMAIN_0);
+#endif
+
        if (pci_has_flag(PCI_REASSIGN_ALL_BUS))
                pci_assign_all_buses = 1;
 
index 9a434d4..6ce95dd 100644 (file)
@@ -109,8 +109,12 @@ __enter_rtas:
         * its critical regions (as specified in PAPR+ section 7.2.1). MSR[S]
         * is not impacted by RFI_TO_KERNEL (only urfid can unset it). So if
         * MSR[S] is set, it will remain when entering RTAS.
+        * If we're in HV mode, RTAS must also run in HV mode, so extract MSR_HV
+        * from the saved MSR value and insert into the value RTAS will use.
         */
+       extrdi  r0, r6, 1, 63 - MSR_HV_LG
        LOAD_REG_IMMEDIATE(r6, MSR_ME | MSR_RI)
+       insrdi  r6, r0, 1, 63 - MSR_HV_LG
 
        li      r0,0
        mtmsrd  r0,1                    /* disable RI before using SRR0/1 */
index cb33588..6c1db3b 100644 (file)
@@ -18,6 +18,7 @@
        .p2align        3
 #define __SYSCALL(nr, entry)   .8byte entry
 #else
+       .p2align        2
 #define __SYSCALL(nr, entry)   .long entry
 #endif
 
index 20f6ed8..2f83855 100644 (file)
@@ -124,9 +124,6 @@ struct papr_scm_priv {
 
        /* The bits which needs to be overridden */
        u64 health_bitmap_inject_mask;
-
-       /* array to have event_code and stat_id mappings */
-       u8 *nvdimm_events_map;
 };
 
 static int papr_scm_pmem_flush(struct nd_region *nd_region,
@@ -350,6 +347,25 @@ static ssize_t drc_pmem_query_stats(struct papr_scm_priv *p,
 #ifdef CONFIG_PERF_EVENTS
 #define to_nvdimm_pmu(_pmu)    container_of(_pmu, struct nvdimm_pmu, pmu)
 
+static const char * const nvdimm_events_map[] = {
+       [1] = "CtlResCt",
+       [2] = "CtlResTm",
+       [3] = "PonSecs ",
+       [4] = "MemLife ",
+       [5] = "CritRscU",
+       [6] = "HostLCnt",
+       [7] = "HostSCnt",
+       [8] = "HostSDur",
+       [9] = "HostLDur",
+       [10] = "MedRCnt ",
+       [11] = "MedWCnt ",
+       [12] = "MedRDur ",
+       [13] = "MedWDur ",
+       [14] = "CchRHCnt",
+       [15] = "CchWHCnt",
+       [16] = "FastWCnt",
+};
+
 static int papr_scm_pmu_get_value(struct perf_event *event, struct device *dev, u64 *count)
 {
        struct papr_scm_perf_stat *stat;
@@ -357,11 +373,15 @@ static int papr_scm_pmu_get_value(struct perf_event *event, struct device *dev,
        struct papr_scm_priv *p = dev_get_drvdata(dev);
        int rc, size;
 
+       /* Invalid eventcode */
+       if (event->attr.config == 0 || event->attr.config >= ARRAY_SIZE(nvdimm_events_map))
+               return -EINVAL;
+
        /* Allocate request buffer enough to hold single performance stat */
        size = sizeof(struct papr_scm_perf_stats) +
                sizeof(struct papr_scm_perf_stat);
 
-       if (!p || !p->nvdimm_events_map)
+       if (!p)
                return -EINVAL;
 
        stats = kzalloc(size, GFP_KERNEL);
@@ -370,7 +390,7 @@ static int papr_scm_pmu_get_value(struct perf_event *event, struct device *dev,
 
        stat = &stats->scm_statistic[0];
        memcpy(&stat->stat_id,
-              &p->nvdimm_events_map[event->attr.config * sizeof(stat->stat_id)],
+              nvdimm_events_map[event->attr.config],
                sizeof(stat->stat_id));
        stat->stat_val = 0;
 
@@ -458,56 +478,6 @@ static void papr_scm_pmu_del(struct perf_event *event, int flags)
        papr_scm_pmu_read(event);
 }
 
-static int papr_scm_pmu_check_events(struct papr_scm_priv *p, struct nvdimm_pmu *nd_pmu)
-{
-       struct papr_scm_perf_stat *stat;
-       struct papr_scm_perf_stats *stats;
-       u32 available_events;
-       int index, rc = 0;
-
-       if (!p->stat_buffer_len)
-               return -ENOENT;
-
-       available_events = (p->stat_buffer_len  - sizeof(struct papr_scm_perf_stats))
-                       / sizeof(struct papr_scm_perf_stat);
-       if (available_events == 0)
-               return -EOPNOTSUPP;
-
-       /* Allocate the buffer for phyp where stats are written */
-       stats = kzalloc(p->stat_buffer_len, GFP_KERNEL);
-       if (!stats) {
-               rc = -ENOMEM;
-               return rc;
-       }
-
-       /* Called to get list of events supported */
-       rc = drc_pmem_query_stats(p, stats, 0);
-       if (rc)
-               goto out;
-
-       /*
-        * Allocate memory and populate nvdimm_event_map.
-        * Allocate an extra element for NULL entry
-        */
-       p->nvdimm_events_map = kcalloc(available_events + 1,
-                                      sizeof(stat->stat_id),
-                                      GFP_KERNEL);
-       if (!p->nvdimm_events_map) {
-               rc = -ENOMEM;
-               goto out;
-       }
-
-       /* Copy all stat_ids to event map */
-       for (index = 0, stat = stats->scm_statistic;
-            index < available_events; index++, ++stat) {
-               memcpy(&p->nvdimm_events_map[index * sizeof(stat->stat_id)],
-                      &stat->stat_id, sizeof(stat->stat_id));
-       }
-out:
-       kfree(stats);
-       return rc;
-}
-
 static void papr_scm_pmu_register(struct papr_scm_priv *p)
 {
        struct nvdimm_pmu *nd_pmu;
@@ -519,9 +489,10 @@ static void papr_scm_pmu_register(struct papr_scm_priv *p)
                goto pmu_err_print;
        }
 
-       rc = papr_scm_pmu_check_events(p, nd_pmu);
-       if (rc)
+       if (!p->stat_buffer_len) {
+               rc = -ENOENT;
                goto pmu_check_events_err;
+       }
 
        nd_pmu->pmu.task_ctx_nr = perf_invalid_context;
        nd_pmu->pmu.name = nvdimm_name(p->nvdimm);
@@ -539,7 +510,7 @@ static void papr_scm_pmu_register(struct papr_scm_priv *p)
 
        rc = register_nvdimm_pmu(nd_pmu, p->pdev);
        if (rc)
-               goto pmu_register_err;
+               goto pmu_check_events_err;
 
        /*
         * Set archdata.priv value to nvdimm_pmu structure, to handle the
@@ -548,8 +519,6 @@ static void papr_scm_pmu_register(struct papr_scm_priv *p)
        p->pdev->archdata.priv = nd_pmu;
        return;
 
-pmu_register_err:
-       kfree(p->nvdimm_events_map);
 pmu_check_events_err:
        kfree(nd_pmu);
 pmu_err_print:
@@ -1560,7 +1529,6 @@ static int papr_scm_remove(struct platform_device *pdev)
                unregister_nvdimm_pmu(pdev->archdata.priv);
 
        pdev->archdata.priv = NULL;
-       kfree(p->nvdimm_events_map);
        kfree(p->bus_desc.provider_name);
        kfree(p);
 
index 044982a..f3f87ed 100644 (file)
 
        phy1: ethernet-phy@9 {
                reg = <9>;
-               ti,fifo-depth = <0x1>;
        };
 
        phy0: ethernet-phy@8 {
                reg = <8>;
-               ti,fifo-depth = <0x1>;
        };
 };
 
        disable-wp;
        cap-sd-highspeed;
        cap-mmc-highspeed;
-       card-detect-delay = <200>;
        mmc-ddr-1_8v;
        mmc-hs200-1_8v;
        sd-uhs-sdr12;
index 82c93c8..c87cc2d 100644 (file)
 
        phy1: ethernet-phy@5 {
                reg = <5>;
-               ti,fifo-depth = <0x01>;
        };
 
        phy0: ethernet-phy@4 {
                reg = <4>;
-               ti,fifo-depth = <0x01>;
        };
 };
 
@@ -72,7 +70,6 @@
        disable-wp;
        cap-sd-highspeed;
        cap-mmc-highspeed;
-       card-detect-delay = <200>;
        mmc-ddr-1_8v;
        mmc-hs200-1_8v;
        sd-uhs-sdr12;
index 499c2e6..7449334 100644 (file)
                        cache-size = <2097152>;
                        cache-unified;
                        interrupt-parent = <&plic>;
-                       interrupts = <1>, <2>, <3>;
+                       interrupts = <1>, <3>, <4>, <2>;
                };
 
                clint: clint@2000000 {
                        ranges = <0x3000000 0x0 0x8000000 0x20 0x8000000 0x0 0x80000000>;
                        msi-parent = <&pcie>;
                        msi-controller;
-                       microchip,axi-m-atr0 = <0x10 0x0>;
                        status = "disabled";
-                       pcie_intc: legacy-interrupt-controller {
+                       pcie_intc: interrupt-controller {
                                #address-cells = <0>;
                                #interrupt-cells = <1>;
                                interrupt-controller;
index 83d6d4d..26a446a 100644 (file)
@@ -33,4 +33,16 @@ void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu,
                                     u32 type, u64 flags);
 const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext(unsigned long extid);
 
+#ifdef CONFIG_RISCV_SBI_V01
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_v01;
+#endif
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_base;
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_time;
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_ipi;
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_rfence;
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_srst;
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_hsm;
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experimental;
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor;
+
 #endif /* __RISCV_KVM_VCPU_SBI_H__ */
diff --git a/arch/riscv/include/asm/signal.h b/arch/riscv/include/asm/signal.h
new file mode 100644 (file)
index 0000000..532c29e
--- /dev/null
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_SIGNAL_H
+#define __ASM_SIGNAL_H
+
+#include <uapi/asm/signal.h>
+#include <uapi/asm/ptrace.h>
+
+asmlinkage __visible
+void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags);
+
+#endif
index 78933ac..67322f8 100644 (file)
@@ -42,6 +42,8 @@
 
 #ifndef __ASSEMBLY__
 
+extern long shadow_stack[SHADOW_OVERFLOW_STACK_SIZE / sizeof(long)];
+
 #include <asm/processor.h>
 #include <asm/csr.h>
 
index 38b05ca..5a2de6b 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <asm/ucontext.h>
 #include <asm/vdso.h>
+#include <asm/signal.h>
 #include <asm/signal32.h>
 #include <asm/switch_to.h>
 #include <asm/csr.h>
index 39d0f8b..635e6ec 100644 (file)
 
 #include <asm/asm-prototypes.h>
 #include <asm/bug.h>
+#include <asm/csr.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
-#include <asm/csr.h>
+#include <asm/thread_info.h>
 
 int show_unhandled_signals = 1;
 
index d45e7da..f96991d 100644 (file)
@@ -32,23 +32,13 @@ static int kvm_linux_err_map_sbi(int err)
        };
 }
 
-#ifdef CONFIG_RISCV_SBI_V01
-extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_v01;
-#else
+#ifndef CONFIG_RISCV_SBI_V01
 static const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_v01 = {
        .extid_start = -1UL,
        .extid_end = -1UL,
        .handler = NULL,
 };
 #endif
-extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_base;
-extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_time;
-extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_ipi;
-extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_rfence;
-extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_srst;
-extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_hsm;
-extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experimental;
-extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor;
 
 static const struct kvm_vcpu_sbi_extension *sbi_ext[] = {
        &vcpu_sbi_ext_v01,
index 16f50c4..185f238 100644 (file)
@@ -299,7 +299,6 @@ static void kvm_riscv_vcpu_update_timedelta(struct kvm_vcpu *vcpu)
 
 void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu)
 {
-       struct kvm_vcpu_csr *csr;
        struct kvm_vcpu_timer *t = &vcpu->arch.timer;
 
        kvm_riscv_vcpu_update_timedelta(vcpu);
@@ -307,7 +306,6 @@ void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu)
        if (!t->sstc_enabled)
                return;
 
-       csr = &vcpu->arch.guest_csr;
 #if defined(CONFIG_32BIT)
        csr_write(CSR_VSTIMECMP, (u32)t->next_cycles);
        csr_write(CSR_VSTIMECMPH, (u32)(t->next_cycles >> 32));
@@ -324,13 +322,11 @@ void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu)
 
 void kvm_riscv_vcpu_timer_save(struct kvm_vcpu *vcpu)
 {
-       struct kvm_vcpu_csr *csr;
        struct kvm_vcpu_timer *t = &vcpu->arch.timer;
 
        if (!t->sstc_enabled)
                return;
 
-       csr = &vcpu->arch.guest_csr;
        t = &vcpu->arch.timer;
 #if defined(CONFIG_32BIT)
        t->next_cycles = csr_read(CSR_VSTIMECMP);
index 5e49e4b..86c5661 100644 (file)
@@ -118,10 +118,10 @@ static int __set_memory(unsigned long addr, int numpages, pgprot_t set_mask,
        if (!numpages)
                return 0;
 
-       mmap_read_lock(&init_mm);
+       mmap_write_lock(&init_mm);
        ret =  walk_page_range_novma(&init_mm, start, end, &pageattr_ops, NULL,
                                     &masks);
-       mmap_read_unlock(&init_mm);
+       mmap_write_unlock(&init_mm);
 
        flush_tlb_kernel_range(start, end);
 
index f6dfde5..2a82700 100644 (file)
@@ -40,8 +40,6 @@ CONFIG_CHECKPOINT_RESTORE=y
 CONFIG_SCHED_AUTOGROUP=y
 CONFIG_EXPERT=y
 # CONFIG_SYSFS_SYSCALL is not set
-CONFIG_USERFAULTFD=y
-# CONFIG_COMPAT_BRK is not set
 CONFIG_PROFILING=y
 CONFIG_LIVEPATCH=y
 CONFIG_MARCH_ZEC12=y
@@ -74,6 +72,7 @@ CONFIG_MODULES=y
 CONFIG_MODULE_FORCE_LOAD=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODULE_UNLOAD_TAINT_TRACKING=y
 CONFIG_MODVERSIONS=y
 CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_MODULE_SIG_SHA256=y
@@ -93,6 +92,10 @@ CONFIG_UNIXWARE_DISKLABEL=y
 CONFIG_IOSCHED_BFQ=y
 CONFIG_BFQ_GROUP_IOSCHED=y
 CONFIG_BINFMT_MISC=m
+CONFIG_ZSWAP=y
+CONFIG_ZSMALLOC_STAT=y
+CONFIG_SLUB_STATS=y
+# CONFIG_COMPAT_BRK is not set
 CONFIG_MEMORY_HOTPLUG=y
 CONFIG_MEMORY_HOTREMOVE=y
 CONFIG_KSM=y
@@ -102,14 +105,12 @@ CONFIG_CMA_DEBUGFS=y
 CONFIG_CMA_SYSFS=y
 CONFIG_CMA_AREAS=7
 CONFIG_MEM_SOFT_DIRTY=y
-CONFIG_ZSWAP=y
-CONFIG_ZSMALLOC=y
-CONFIG_ZSMALLOC_STAT=y
 CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
 CONFIG_IDLE_PAGE_TRACKING=y
 CONFIG_PERCPU_STATS=y
 CONFIG_GUP_TEST=y
 CONFIG_ANON_VMA_NAME=y
+CONFIG_USERFAULTFD=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_PACKET_DIAG=m
@@ -167,6 +168,7 @@ CONFIG_BRIDGE_NETFILTER=m
 CONFIG_NETFILTER_NETLINK_HOOK=m
 CONFIG_NF_CONNTRACK=m
 CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_PROCFS=y
 CONFIG_NF_CONNTRACK_EVENTS=y
 CONFIG_NF_CONNTRACK_TIMEOUT=y
 CONFIG_NF_CONNTRACK_TIMESTAMP=y
@@ -493,7 +495,6 @@ CONFIG_NLMON=m
 # CONFIG_NET_VENDOR_ASIX is not set
 # CONFIG_NET_VENDOR_ATHEROS is not set
 # CONFIG_NET_VENDOR_BROADCOM is not set
-# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_CADENCE is not set
 # CONFIG_NET_VENDOR_CAVIUM is not set
 # CONFIG_NET_VENDOR_CHELSIO is not set
@@ -509,7 +510,7 @@ CONFIG_NLMON=m
 # CONFIG_NET_VENDOR_GOOGLE is not set
 # CONFIG_NET_VENDOR_HUAWEI is not set
 # CONFIG_NET_VENDOR_INTEL is not set
-# CONFIG_NET_VENDOR_MICROSOFT is not set
+# CONFIG_NET_VENDOR_WANGXUN is not set
 # CONFIG_NET_VENDOR_LITEX is not set
 # CONFIG_NET_VENDOR_MARVELL is not set
 CONFIG_MLX4_EN=m
@@ -518,16 +519,18 @@ CONFIG_MLX5_CORE_EN=y
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_MICROCHIP is not set
 # CONFIG_NET_VENDOR_MICROSEMI is not set
+# CONFIG_NET_VENDOR_MICROSOFT is not set
 # CONFIG_NET_VENDOR_MYRI is not set
+# CONFIG_NET_VENDOR_NI is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
 # CONFIG_NET_VENDOR_NETERION is not set
 # CONFIG_NET_VENDOR_NETRONOME is not set
-# CONFIG_NET_VENDOR_NI is not set
 # CONFIG_NET_VENDOR_NVIDIA is not set
 # CONFIG_NET_VENDOR_OKI is not set
 # CONFIG_NET_VENDOR_PACKET_ENGINES is not set
 # CONFIG_NET_VENDOR_PENSANDO is not set
 # CONFIG_NET_VENDOR_QLOGIC is not set
+# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RDC is not set
 # CONFIG_NET_VENDOR_REALTEK is not set
@@ -535,9 +538,9 @@ CONFIG_MLX5_CORE_EN=y
 # CONFIG_NET_VENDOR_ROCKER is not set
 # CONFIG_NET_VENDOR_SAMSUNG is not set
 # CONFIG_NET_VENDOR_SEEQ is not set
-# CONFIG_NET_VENDOR_SOLARFLARE is not set
 # CONFIG_NET_VENDOR_SILAN is not set
 # CONFIG_NET_VENDOR_SIS is not set
+# CONFIG_NET_VENDOR_SOLARFLARE is not set
 # CONFIG_NET_VENDOR_SMSC is not set
 # CONFIG_NET_VENDOR_SOCIONEXT is not set
 # CONFIG_NET_VENDOR_STMICRO is not set
@@ -570,6 +573,8 @@ CONFIG_VIRTIO_CONSOLE=m
 CONFIG_HW_RANDOM_VIRTIO=m
 CONFIG_HANGCHECK_TIMER=m
 CONFIG_TN3270_FS=y
+# CONFIG_RANDOM_TRUST_CPU is not set
+# CONFIG_RANDOM_TRUST_BOOTLOADER is not set
 CONFIG_PPS=m
 # CONFIG_PTP_1588_CLOCK is not set
 # CONFIG_HWMON is not set
@@ -727,18 +732,26 @@ CONFIG_CRYPTO_LRW=m
 CONFIG_CRYPTO_PCBC=m
 CONFIG_CRYPTO_KEYWRAP=m
 CONFIG_CRYPTO_ADIANTUM=m
+CONFIG_CRYPTO_HCTR2=m
 CONFIG_CRYPTO_XCBC=m
 CONFIG_CRYPTO_VMAC=m
 CONFIG_CRYPTO_CRC32=m
-CONFIG_CRYPTO_BLAKE2S=m
+CONFIG_CRYPTO_CRC32_S390=y
 CONFIG_CRYPTO_MD4=m
 CONFIG_CRYPTO_MD5=y
 CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_RMD160=m
+CONFIG_CRYPTO_SHA512_S390=m
+CONFIG_CRYPTO_SHA1_S390=m
+CONFIG_CRYPTO_SHA256_S390=m
 CONFIG_CRYPTO_SHA3=m
-CONFIG_CRYPTO_SM3=m
+CONFIG_CRYPTO_SHA3_256_S390=m
+CONFIG_CRYPTO_SHA3_512_S390=m
+CONFIG_CRYPTO_SM3_GENERIC=m
 CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_GHASH_S390=m
 CONFIG_CRYPTO_AES_TI=m
+CONFIG_CRYPTO_AES_S390=m
 CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_ARC4=m
 CONFIG_CRYPTO_BLOWFISH=m
@@ -746,11 +759,14 @@ CONFIG_CRYPTO_CAMELLIA=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
 CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_DES_S390=m
 CONFIG_CRYPTO_FCRYPT=m
 CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_CHACHA_S390=m
 CONFIG_CRYPTO_SEED=m
+CONFIG_CRYPTO_ARIA=m
 CONFIG_CRYPTO_SERPENT=m
-CONFIG_CRYPTO_SM4=m
+CONFIG_CRYPTO_SM4_GENERIC=m
 CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_TWOFISH=m
 CONFIG_CRYPTO_842=m
@@ -766,16 +782,6 @@ CONFIG_CRYPTO_STATS=y
 CONFIG_ZCRYPT=m
 CONFIG_PKEY=m
 CONFIG_CRYPTO_PAES_S390=m
-CONFIG_CRYPTO_SHA1_S390=m
-CONFIG_CRYPTO_SHA256_S390=m
-CONFIG_CRYPTO_SHA512_S390=m
-CONFIG_CRYPTO_SHA3_256_S390=m
-CONFIG_CRYPTO_SHA3_512_S390=m
-CONFIG_CRYPTO_DES_S390=m
-CONFIG_CRYPTO_AES_S390=m
-CONFIG_CRYPTO_CHACHA_S390=m
-CONFIG_CRYPTO_GHASH_S390=m
-CONFIG_CRYPTO_CRC32_S390=y
 CONFIG_CRYPTO_DEV_VIRTIO=m
 CONFIG_CORDIC=m
 CONFIG_CRYPTO_LIB_CURVE25519=m
@@ -797,6 +803,7 @@ CONFIG_HEADERS_INSTALL=y
 CONFIG_DEBUG_SECTION_MISMATCH=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_PAGEALLOC=y
+CONFIG_SLUB_DEBUG_ON=y
 CONFIG_PAGE_OWNER=y
 CONFIG_DEBUG_RODATA_TEST=y
 CONFIG_DEBUG_WX=y
@@ -808,8 +815,6 @@ CONFIG_DEBUG_OBJECTS_TIMERS=y
 CONFIG_DEBUG_OBJECTS_WORK=y
 CONFIG_DEBUG_OBJECTS_RCU_HEAD=y
 CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER=y
-CONFIG_SLUB_DEBUG_ON=y
-CONFIG_SLUB_STATS=y
 CONFIG_DEBUG_STACK_USAGE=y
 CONFIG_DEBUG_VM=y
 CONFIG_DEBUG_VM_PGFLAGS=y
index 706df3a..fb780e8 100644 (file)
@@ -38,8 +38,6 @@ CONFIG_CHECKPOINT_RESTORE=y
 CONFIG_SCHED_AUTOGROUP=y
 CONFIG_EXPERT=y
 # CONFIG_SYSFS_SYSCALL is not set
-CONFIG_USERFAULTFD=y
-# CONFIG_COMPAT_BRK is not set
 CONFIG_PROFILING=y
 CONFIG_LIVEPATCH=y
 CONFIG_MARCH_ZEC12=y
@@ -69,6 +67,7 @@ CONFIG_MODULES=y
 CONFIG_MODULE_FORCE_LOAD=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODULE_UNLOAD_TAINT_TRACKING=y
 CONFIG_MODVERSIONS=y
 CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_MODULE_SIG_SHA256=y
@@ -88,6 +87,9 @@ CONFIG_UNIXWARE_DISKLABEL=y
 CONFIG_IOSCHED_BFQ=y
 CONFIG_BFQ_GROUP_IOSCHED=y
 CONFIG_BINFMT_MISC=m
+CONFIG_ZSWAP=y
+CONFIG_ZSMALLOC_STAT=y
+# CONFIG_COMPAT_BRK is not set
 CONFIG_MEMORY_HOTPLUG=y
 CONFIG_MEMORY_HOTREMOVE=y
 CONFIG_KSM=y
@@ -95,13 +97,11 @@ CONFIG_TRANSPARENT_HUGEPAGE=y
 CONFIG_CMA_SYSFS=y
 CONFIG_CMA_AREAS=7
 CONFIG_MEM_SOFT_DIRTY=y
-CONFIG_ZSWAP=y
-CONFIG_ZSMALLOC=y
-CONFIG_ZSMALLOC_STAT=y
 CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
 CONFIG_IDLE_PAGE_TRACKING=y
 CONFIG_PERCPU_STATS=y
 CONFIG_ANON_VMA_NAME=y
+CONFIG_USERFAULTFD=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_PACKET_DIAG=m
@@ -159,6 +159,7 @@ CONFIG_BRIDGE_NETFILTER=m
 CONFIG_NETFILTER_NETLINK_HOOK=m
 CONFIG_NF_CONNTRACK=m
 CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_PROCFS=y
 CONFIG_NF_CONNTRACK_EVENTS=y
 CONFIG_NF_CONNTRACK_TIMEOUT=y
 CONFIG_NF_CONNTRACK_TIMESTAMP=y
@@ -484,7 +485,6 @@ CONFIG_NLMON=m
 # CONFIG_NET_VENDOR_ASIX is not set
 # CONFIG_NET_VENDOR_ATHEROS is not set
 # CONFIG_NET_VENDOR_BROADCOM is not set
-# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_CADENCE is not set
 # CONFIG_NET_VENDOR_CAVIUM is not set
 # CONFIG_NET_VENDOR_CHELSIO is not set
@@ -500,7 +500,7 @@ CONFIG_NLMON=m
 # CONFIG_NET_VENDOR_GOOGLE is not set
 # CONFIG_NET_VENDOR_HUAWEI is not set
 # CONFIG_NET_VENDOR_INTEL is not set
-# CONFIG_NET_VENDOR_MICROSOFT is not set
+# CONFIG_NET_VENDOR_WANGXUN is not set
 # CONFIG_NET_VENDOR_LITEX is not set
 # CONFIG_NET_VENDOR_MARVELL is not set
 CONFIG_MLX4_EN=m
@@ -509,16 +509,18 @@ CONFIG_MLX5_CORE_EN=y
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_MICROCHIP is not set
 # CONFIG_NET_VENDOR_MICROSEMI is not set
+# CONFIG_NET_VENDOR_MICROSOFT is not set
 # CONFIG_NET_VENDOR_MYRI is not set
+# CONFIG_NET_VENDOR_NI is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
 # CONFIG_NET_VENDOR_NETERION is not set
 # CONFIG_NET_VENDOR_NETRONOME is not set
-# CONFIG_NET_VENDOR_NI is not set
 # CONFIG_NET_VENDOR_NVIDIA is not set
 # CONFIG_NET_VENDOR_OKI is not set
 # CONFIG_NET_VENDOR_PACKET_ENGINES is not set
 # CONFIG_NET_VENDOR_PENSANDO is not set
 # CONFIG_NET_VENDOR_QLOGIC is not set
+# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RDC is not set
 # CONFIG_NET_VENDOR_REALTEK is not set
@@ -526,9 +528,9 @@ CONFIG_MLX5_CORE_EN=y
 # CONFIG_NET_VENDOR_ROCKER is not set
 # CONFIG_NET_VENDOR_SAMSUNG is not set
 # CONFIG_NET_VENDOR_SEEQ is not set
-# CONFIG_NET_VENDOR_SOLARFLARE is not set
 # CONFIG_NET_VENDOR_SILAN is not set
 # CONFIG_NET_VENDOR_SIS is not set
+# CONFIG_NET_VENDOR_SOLARFLARE is not set
 # CONFIG_NET_VENDOR_SMSC is not set
 # CONFIG_NET_VENDOR_SOCIONEXT is not set
 # CONFIG_NET_VENDOR_STMICRO is not set
@@ -561,6 +563,8 @@ CONFIG_VIRTIO_CONSOLE=m
 CONFIG_HW_RANDOM_VIRTIO=m
 CONFIG_HANGCHECK_TIMER=m
 CONFIG_TN3270_FS=y
+# CONFIG_RANDOM_TRUST_CPU is not set
+# CONFIG_RANDOM_TRUST_BOOTLOADER is not set
 # CONFIG_PTP_1588_CLOCK is not set
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
@@ -713,18 +717,26 @@ CONFIG_CRYPTO_OFB=m
 CONFIG_CRYPTO_PCBC=m
 CONFIG_CRYPTO_KEYWRAP=m
 CONFIG_CRYPTO_ADIANTUM=m
+CONFIG_CRYPTO_HCTR2=m
 CONFIG_CRYPTO_XCBC=m
 CONFIG_CRYPTO_VMAC=m
 CONFIG_CRYPTO_CRC32=m
-CONFIG_CRYPTO_BLAKE2S=m
+CONFIG_CRYPTO_CRC32_S390=y
 CONFIG_CRYPTO_MD4=m
 CONFIG_CRYPTO_MD5=y
 CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_RMD160=m
+CONFIG_CRYPTO_SHA512_S390=m
+CONFIG_CRYPTO_SHA1_S390=m
+CONFIG_CRYPTO_SHA256_S390=m
 CONFIG_CRYPTO_SHA3=m
-CONFIG_CRYPTO_SM3=m
+CONFIG_CRYPTO_SHA3_256_S390=m
+CONFIG_CRYPTO_SHA3_512_S390=m
+CONFIG_CRYPTO_SM3_GENERIC=m
 CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_GHASH_S390=m
 CONFIG_CRYPTO_AES_TI=m
+CONFIG_CRYPTO_AES_S390=m
 CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_ARC4=m
 CONFIG_CRYPTO_BLOWFISH=m
@@ -732,11 +744,14 @@ CONFIG_CRYPTO_CAMELLIA=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
 CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_DES_S390=m
 CONFIG_CRYPTO_FCRYPT=m
 CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_CHACHA_S390=m
 CONFIG_CRYPTO_SEED=m
+CONFIG_CRYPTO_ARIA=m
 CONFIG_CRYPTO_SERPENT=m
-CONFIG_CRYPTO_SM4=m
+CONFIG_CRYPTO_SM4_GENERIC=m
 CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_TWOFISH=m
 CONFIG_CRYPTO_842=m
@@ -752,16 +767,6 @@ CONFIG_CRYPTO_STATS=y
 CONFIG_ZCRYPT=m
 CONFIG_PKEY=m
 CONFIG_CRYPTO_PAES_S390=m
-CONFIG_CRYPTO_SHA1_S390=m
-CONFIG_CRYPTO_SHA256_S390=m
-CONFIG_CRYPTO_SHA512_S390=m
-CONFIG_CRYPTO_SHA3_256_S390=m
-CONFIG_CRYPTO_SHA3_512_S390=m
-CONFIG_CRYPTO_DES_S390=m
-CONFIG_CRYPTO_AES_S390=m
-CONFIG_CRYPTO_CHACHA_S390=m
-CONFIG_CRYPTO_GHASH_S390=m
-CONFIG_CRYPTO_CRC32_S390=y
 CONFIG_CRYPTO_DEV_VIRTIO=m
 CONFIG_CORDIC=m
 CONFIG_PRIME_NUMBERS=m
index f4976f6..a5576b8 100644 (file)
@@ -1,4 +1,3 @@
-# CONFIG_SWAP is not set
 CONFIG_NO_HZ_IDLE=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_BPF_SYSCALL=y
@@ -9,7 +8,6 @@ CONFIG_BPF_SYSCALL=y
 # CONFIG_NET_NS is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-# CONFIG_COMPAT_BRK is not set
 CONFIG_MARCH_ZEC12=y
 CONFIG_TUNE_ZEC12=y
 # CONFIG_COMPAT is not set
@@ -28,6 +26,8 @@ CONFIG_CRASH_DUMP=y
 # CONFIG_BLOCK_LEGACY_AUTOLOAD is not set
 CONFIG_PARTITION_ADVANCED=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_SWAP is not set
+# CONFIG_COMPAT_BRK is not set
 # CONFIG_COMPACTION is not set
 # CONFIG_MIGRATION is not set
 CONFIG_NET=y
@@ -53,10 +53,12 @@ CONFIG_ZFCP=y
 # CONFIG_HVC_IUCV is not set
 # CONFIG_HW_RANDOM_S390 is not set
 # CONFIG_HMC_DRV is not set
+# CONFIG_S390_UV_UAPI is not set
 # CONFIG_S390_TAPE is not set
 # CONFIG_VMCP is not set
 # CONFIG_MONWRITER is not set
 # CONFIG_S390_VMUR is not set
+# CONFIG_RANDOM_TRUST_BOOTLOADER is not set
 # CONFIG_HID is not set
 # CONFIG_VIRTIO_MENU is not set
 # CONFIG_VHOST_MENU is not set
index 9a7d15d..2de74fc 100644 (file)
@@ -176,14 +176,8 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
        return old & mask;
 }
 
-static __always_inline bool
-arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
-{
-       const volatile unsigned long *p = __bitops_word(nr, addr);
-       unsigned long mask = __bitops_mask(nr);
-
-       return *p & mask;
-}
+#define arch_test_bit generic_test_bit
+#define arch_test_bit_acquire generic_test_bit_acquire
 
 static inline bool arch_test_and_set_bit_lock(unsigned long nr,
                                              volatile unsigned long *ptr)
index f22beda..ccdbccf 100644 (file)
@@ -28,9 +28,11 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
 static inline int prepare_hugepage_range(struct file *file,
                        unsigned long addr, unsigned long len)
 {
-       if (len & ~HPAGE_MASK)
+       struct hstate *h = hstate_file(file);
+
+       if (len & ~huge_page_mask(h))
                return -EINVAL;
-       if (addr & ~HPAGE_MASK)
+       if (addr & ~huge_page_mask(h))
                return -EINVAL;
        return 0;
 }
index f39092e..b1e98a9 100644 (file)
@@ -1038,16 +1038,11 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}
 #define __KVM_HAVE_ARCH_VM_FREE
 void kvm_arch_free_vm(struct kvm *kvm);
 
-#ifdef CONFIG_VFIO_PCI_ZDEV_KVM
-int kvm_s390_pci_register_kvm(struct zpci_dev *zdev, struct kvm *kvm);
-void kvm_s390_pci_unregister_kvm(struct zpci_dev *zdev);
-#else
-static inline int kvm_s390_pci_register_kvm(struct zpci_dev *dev,
-                                           struct kvm *kvm)
-{
-       return -EPERM;
-}
-static inline void kvm_s390_pci_unregister_kvm(struct zpci_dev *dev) {}
-#endif
+struct zpci_kvm_hook {
+       int (*kvm_register)(void *opaque, struct kvm *kvm);
+       void (*kvm_unregister)(void *opaque);
+};
+
+extern struct zpci_kvm_hook zpci_kvm_hook;
 
 #endif
index af68d6c..1ac5115 100644 (file)
@@ -5,7 +5,7 @@
 #include <asm/lowcore.h>
 #include <asm/stacktrace.h>
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 static inline void do_softirq_own_stack(void)
 {
        call_on_stack(0, S390_lowcore.async_stack, void, __do_softirq);
index 89949b9..d5119e0 100644 (file)
@@ -91,6 +91,18 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 
        memcpy(dst, src, arch_task_struct_size);
        dst->thread.fpu.regs = dst->thread.fpu.fprs;
+
+       /*
+        * Don't transfer over the runtime instrumentation or the guarded
+        * storage control block pointers. These fields are cleared here instead
+        * of in copy_thread() to avoid premature freeing of associated memory
+        * on fork() failure. Wait to clear the RI flag because ->stack still
+        * refers to the source thread.
+        */
+       dst->thread.ri_cb = NULL;
+       dst->thread.gs_cb = NULL;
+       dst->thread.gs_bc_cb = NULL;
+
        return 0;
 }
 
@@ -150,13 +162,11 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
        frame->childregs.flags = 0;
        if (new_stackp)
                frame->childregs.gprs[15] = new_stackp;
-
-       /* Don't copy runtime instrumentation info */
-       p->thread.ri_cb = NULL;
+       /*
+        * Clear the runtime instrumentation flag after the above childregs
+        * copy. The CB pointer was already cleared in arch_dup_task_struct().
+        */
        frame->childregs.psw.mask &= ~PSW_MASK_RI;
-       /* Don't copy guarded storage control block */
-       p->thread.gs_cb = NULL;
-       p->thread.gs_bc_cb = NULL;
 
        /* Set a new TLS ?  */
        if (clone_flags & CLONE_SETTLS) {
index 2e526f1..5ea3830 100644 (file)
@@ -131,6 +131,7 @@ SECTIONS
        /*
         * Table with the patch locations to undo expolines
        */
+       . = ALIGN(4);
        .nospec_call_table : {
                __nospec_call_start = . ;
                *(.s390_indirect*)
index 4946fb7..bb8c335 100644 (file)
@@ -431,8 +431,9 @@ static void kvm_s390_pci_dev_release(struct zpci_dev *zdev)
  * available, enable them and let userspace indicate whether or not they will
  * be used (specify SHM bit to disable).
  */
-int kvm_s390_pci_register_kvm(struct zpci_dev *zdev, struct kvm *kvm)
+static int kvm_s390_pci_register_kvm(void *opaque, struct kvm *kvm)
 {
+       struct zpci_dev *zdev = opaque;
        int rc;
 
        if (!zdev)
@@ -510,10 +511,10 @@ err:
        kvm_put_kvm(kvm);
        return rc;
 }
-EXPORT_SYMBOL_GPL(kvm_s390_pci_register_kvm);
 
-void kvm_s390_pci_unregister_kvm(struct zpci_dev *zdev)
+static void kvm_s390_pci_unregister_kvm(void *opaque)
 {
+       struct zpci_dev *zdev = opaque;
        struct kvm *kvm;
 
        if (!zdev)
@@ -566,7 +567,6 @@ out:
 
        kvm_put_kvm(kvm);
 }
-EXPORT_SYMBOL_GPL(kvm_s390_pci_unregister_kvm);
 
 void kvm_s390_pci_init_list(struct kvm *kvm)
 {
@@ -678,6 +678,8 @@ int kvm_s390_pci_init(void)
 
        spin_lock_init(&aift->gait_lock);
        mutex_init(&aift->aift_lock);
+       zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm;
+       zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;
 
        return 0;
 }
@@ -685,6 +687,8 @@ int kvm_s390_pci_init(void)
 void kvm_s390_pci_exit(void)
 {
        mutex_destroy(&aift->aift_lock);
+       zpci_kvm_hook.kvm_register = NULL;
+       zpci_kvm_hook.kvm_unregister = NULL;
 
        kfree(aift);
 }
index 1344994..9ab6ca6 100644 (file)
@@ -379,7 +379,9 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access)
        flags = FAULT_FLAG_DEFAULT;
        if (user_mode(regs))
                flags |= FAULT_FLAG_USER;
-       if (access == VM_WRITE || is_write)
+       if (is_write)
+               access = VM_WRITE;
+       if (access == VM_WRITE)
                flags |= FAULT_FLAG_WRITE;
        mmap_read_lock(mm);
 
@@ -419,8 +421,6 @@ retry:
        if (unlikely(!(vma->vm_flags & access)))
                goto out_up;
 
-       if (is_vm_hugetlb_page(vma))
-               address &= HPAGE_MASK;
        /*
         * If for any reason at all we couldn't handle the fault,
         * make sure we exit gracefully rather than endlessly redo
index bf557a1..5ae31ca 100644 (file)
@@ -5,5 +5,5 @@
 
 obj-$(CONFIG_PCI)      += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \
                           pci_event.o pci_debug.o pci_insn.o pci_mmio.o \
-                          pci_bus.o
+                          pci_bus.o pci_kvm_hook.o
 obj-$(CONFIG_PCI_IOV)  += pci_iov.o
diff --git a/arch/s390/pci/pci_kvm_hook.c b/arch/s390/pci/pci_kvm_hook.c
new file mode 100644 (file)
index 0000000..ff34baf
--- /dev/null
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * VFIO ZPCI devices support
+ *
+ * Copyright (C) IBM Corp. 2022.  All rights reserved.
+ *     Author(s): Pierre Morel <pmorel@linux.ibm.com>
+ */
+#include <linux/kvm_host.h>
+
+struct zpci_kvm_hook zpci_kvm_hook;
+EXPORT_SYMBOL_GPL(zpci_kvm_hook);
index 565a85d..5ace89b 100644 (file)
@@ -135,16 +135,8 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
        return (old & mask) != 0;
 }
 
-/**
- * arch_test_bit - Determine whether a bit is set
- * @nr: bit number to test
- * @addr: Address to start counting from
- */
-static __always_inline bool
-arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
-{
-       return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
-}
+#define arch_test_bit generic_test_bit
+#define arch_test_bit_acquire generic_test_bit_acquire
 
 #include <asm-generic/bitops/non-instrumented-non-atomic.h>
 
index 9092767..4e6835d 100644 (file)
@@ -149,7 +149,7 @@ void irq_ctx_exit(int cpu)
        hardirq_ctx[cpu] = NULL;
 }
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 void do_softirq_own_stack(void)
 {
        struct thread_info *curctx;
index 41fa1be..72da2e1 100644 (file)
@@ -855,7 +855,7 @@ void __irq_entry handler_irq(int pil, struct pt_regs *regs)
        set_irq_regs(old_regs);
 }
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 void do_softirq_own_stack(void)
 {
        void *orig_sp, *sp = softirq_stack[smp_processor_id()];
index 4910bf2..62208ec 100644 (file)
@@ -132,7 +132,17 @@ void snp_set_page_private(unsigned long paddr);
 void snp_set_page_shared(unsigned long paddr);
 void sev_prep_identity_maps(unsigned long top_level_pgt);
 #else
-static inline void sev_enable(struct boot_params *bp) { }
+static inline void sev_enable(struct boot_params *bp)
+{
+       /*
+        * bp->cc_blob_address should only be set by boot/compressed kernel.
+        * Initialize it to 0 unconditionally (thus here in this stub too) to
+        * ensure that uninitialized values from buggy bootloaders aren't
+        * propagated.
+        */
+       if (bp)
+               bp->cc_blob_address = 0;
+}
 static inline void sev_es_shutdown_ghcb(void) { }
 static inline bool sev_es_check_ghcb_fault(unsigned long address)
 {
index 52f989f..c93930d 100644 (file)
@@ -277,6 +277,14 @@ void sev_enable(struct boot_params *bp)
        bool snp;
 
        /*
+        * bp->cc_blob_address should only be set by boot/compressed kernel.
+        * Initialize it to 0 to ensure that uninitialized values from
+        * buggy bootloaders aren't propagated.
+        */
+       if (bp)
+               bp->cc_blob_address = 0;
+
+       /*
         * Setup/preliminary detection of SNP. This will be sanity-checked
         * against CPUID/MSR values later.
         */
index d9fc713..5812962 100644 (file)
@@ -14,7 +14,6 @@ CONFIG_CPU_FREQ=y
 
 # x86 xen specific config options
 CONFIG_XEN_PVH=y
-CONFIG_XEN_MAX_DOMAIN_MEMORY=500
 CONFIG_XEN_SAVE_RESTORE=y
 # CONFIG_XEN_DEBUG_FS is not set
 CONFIG_XEN_MCE_LOG=y
index 682338e..4dd1981 100644 (file)
@@ -311,7 +311,7 @@ SYM_CODE_START(entry_INT80_compat)
         * Interrupts are off on entry.
         */
        ASM_CLAC                        /* Do this early to minimize exposure */
-       SWAPGS
+       ALTERNATIVE "swapgs", "", X86_FEATURE_XENPV
 
        /*
         * User tracing code (ptrace or signal handlers) might assume that
index 2db9349..c601939 100644 (file)
@@ -4052,8 +4052,9 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data)
                /* Disable guest PEBS if host PEBS is enabled. */
                arr[pebs_enable].guest = 0;
        } else {
-               /* Disable guest PEBS for cross-mapped PEBS counters. */
+               /* Disable guest PEBS thoroughly for cross-mapped PEBS counters. */
                arr[pebs_enable].guest &= ~kvm_pmu->host_cross_mapped_mask;
+               arr[global_ctrl].guest &= ~kvm_pmu->host_cross_mapped_mask;
                /* Set hw GLOBAL_CTRL bits for PEBS counter when it runs for guest */
                arr[global_ctrl].guest |= arr[pebs_enable].guest;
        }
@@ -6291,10 +6292,8 @@ __init int intel_pmu_init(void)
                x86_pmu.pebs_aliases = NULL;
                x86_pmu.pebs_prec_dist = true;
                x86_pmu.pebs_block = true;
-               x86_pmu.pebs_capable = ~0ULL;
                x86_pmu.flags |= PMU_FL_HAS_RSP_1;
                x86_pmu.flags |= PMU_FL_NO_HT_SHARING;
-               x86_pmu.flags |= PMU_FL_PEBS_ALL;
                x86_pmu.flags |= PMU_FL_INSTR_LATENCY;
                x86_pmu.flags |= PMU_FL_MEM_LOADS_AUX;
 
@@ -6337,10 +6336,8 @@ __init int intel_pmu_init(void)
                x86_pmu.pebs_aliases = NULL;
                x86_pmu.pebs_prec_dist = true;
                x86_pmu.pebs_block = true;
-               x86_pmu.pebs_capable = ~0ULL;
                x86_pmu.flags |= PMU_FL_HAS_RSP_1;
                x86_pmu.flags |= PMU_FL_NO_HT_SHARING;
-               x86_pmu.flags |= PMU_FL_PEBS_ALL;
                x86_pmu.flags |= PMU_FL_INSTR_LATENCY;
                x86_pmu.flags |= PMU_FL_MEM_LOADS_AUX;
                x86_pmu.lbr_pt_coexist = true;
index ba60427..de1f55d 100644 (file)
@@ -291,6 +291,7 @@ static u64 load_latency_data(struct perf_event *event, u64 status)
 static u64 store_latency_data(struct perf_event *event, u64 status)
 {
        union intel_x86_pebs_dse dse;
+       union perf_mem_data_src src;
        u64 val;
 
        dse.val = status;
@@ -304,7 +305,14 @@ static u64 store_latency_data(struct perf_event *event, u64 status)
 
        val |= P(BLK, NA);
 
-       return val;
+       /*
+        * the pebs_data_source table is only for loads
+        * so override the mem_op to say STORE instead
+        */
+       src.val = val;
+       src.mem_op = P(OP,STORE);
+
+       return src.val;
 }
 
 struct pebs_record_core {
@@ -822,7 +830,7 @@ struct event_constraint intel_glm_pebs_event_constraints[] = {
 
 struct event_constraint intel_grt_pebs_event_constraints[] = {
        /* Allow all events as PEBS with no flags */
-       INTEL_HYBRID_LAT_CONSTRAINT(0x5d0, 0xf),
+       INTEL_HYBRID_LAT_CONSTRAINT(0x5d0, 0x3),
        INTEL_HYBRID_LAT_CONSTRAINT(0x6d0, 0xf),
        EVENT_CONSTRAINT_END
 };
@@ -2262,6 +2270,7 @@ void __init intel_ds_init(void)
                                        PERF_SAMPLE_BRANCH_STACK |
                                        PERF_SAMPLE_TIME;
                                x86_pmu.flags |= PMU_FL_PEBS_ALL;
+                               x86_pmu.pebs_capable = ~0ULL;
                                pebs_qual = "-baseline";
                                x86_get_pmu(smp_processor_id())->capabilities |= PERF_PMU_CAP_EXTENDED_REGS;
                        } else {
index 4f70fb6..47fca6a 100644 (file)
@@ -1097,6 +1097,14 @@ static int intel_pmu_setup_hw_lbr_filter(struct perf_event *event)
 
        if (static_cpu_has(X86_FEATURE_ARCH_LBR)) {
                reg->config = mask;
+
+               /*
+                * The Arch LBR HW can retrieve the common branch types
+                * from the LBR_INFO. It doesn't require the high overhead
+                * SW disassemble.
+                * Enable the branch type by default for the Arch LBR.
+                */
+               reg->reg |= X86_BR_TYPE_SAVE;
                return 0;
        }
 
index ce44001..1ef4f78 100644 (file)
@@ -841,6 +841,22 @@ int snb_pci2phy_map_init(int devid)
        return 0;
 }
 
+static u64 snb_uncore_imc_read_counter(struct intel_uncore_box *box, struct perf_event *event)
+{
+       struct hw_perf_event *hwc = &event->hw;
+
+       /*
+        * SNB IMC counters are 32-bit and are laid out back to back
+        * in MMIO space. Therefore we must use a 32-bit accessor function
+        * using readq() from uncore_mmio_read_counter() causes problems
+        * because it is reading 64-bit at a time. This is okay for the
+        * uncore_perf_event_update() function because it drops the upper
+        * 32-bits but not okay for plain uncore_read_counter() as invoked
+        * in uncore_pmu_event_start().
+        */
+       return (u64)readl(box->io_addr + hwc->event_base);
+}
+
 static struct pmu snb_uncore_imc_pmu = {
        .task_ctx_nr    = perf_invalid_context,
        .event_init     = snb_uncore_imc_event_init,
@@ -860,7 +876,7 @@ static struct intel_uncore_ops snb_uncore_imc_ops = {
        .disable_event  = snb_uncore_imc_disable_event,
        .enable_event   = snb_uncore_imc_enable_event,
        .hw_config      = snb_uncore_imc_hw_config,
-       .read_counter   = uncore_mmio_read_counter,
+       .read_counter   = snb_uncore_imc_read_counter,
 };
 
 static struct intel_uncore_type snb_uncore_imc = {
index 973c6bd..0fe9de5 100644 (file)
@@ -207,6 +207,20 @@ static __always_inline bool constant_test_bit(long nr, const volatile unsigned l
                (addr[nr >> _BITOPS_LONG_SHIFT])) != 0;
 }
 
+static __always_inline bool constant_test_bit_acquire(long nr, const volatile unsigned long *addr)
+{
+       bool oldbit;
+
+       asm volatile("testb %2,%1"
+                    CC_SET(nz)
+                    : CC_OUT(nz) (oldbit)
+                    : "m" (((unsigned char *)addr)[nr >> 3]),
+                      "i" (1 << (nr & 7))
+                    :"memory");
+
+       return oldbit;
+}
+
 static __always_inline bool variable_test_bit(long nr, volatile const unsigned long *addr)
 {
        bool oldbit;
@@ -226,6 +240,13 @@ arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
                                          variable_test_bit(nr, addr);
 }
 
+static __always_inline bool
+arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr)
+{
+       return __builtin_constant_p(nr) ? constant_test_bit_acquire(nr, addr) :
+                                         variable_test_bit(nr, addr);
+}
+
 /**
  * __ffs - find first set bit in word
  * @word: The word to search
index 235dc85..ef4775c 100644 (file)
 #define X86_BUG_ITLB_MULTIHIT          X86_BUG(23) /* CPU may incur MCE during certain page attribute changes */
 #define X86_BUG_SRBDS                  X86_BUG(24) /* CPU may leak RNG bits if not mitigated */
 #define X86_BUG_MMIO_STALE_DATA                X86_BUG(25) /* CPU is affected by Processor MMIO Stale Data vulnerabilities */
-#define X86_BUG_RETBLEED               X86_BUG(26) /* CPU is affected by RETBleed */
-#define X86_BUG_EIBRS_PBRSB            X86_BUG(27) /* EIBRS is vulnerable to Post Barrier RSB Predictions */
+#define X86_BUG_MMIO_UNKNOWN           X86_BUG(26) /* CPU is too old and its MMIO Stale Data status is unknown */
+#define X86_BUG_RETBLEED               X86_BUG(27) /* CPU is affected by RETBleed */
+#define X86_BUG_EIBRS_PBRSB            X86_BUG(28) /* EIBRS is vulnerable to Post Barrier RSB Predictions */
 
 #endif /* _ASM_X86_CPUFEATURES_H */
index def6ca1..aeb3802 100644 (file)
@@ -27,6 +27,7 @@
  *             _X      - regular server parts
  *             _D      - micro server parts
  *             _N,_P   - other mobile parts
+ *             _S      - other client parts
  *
  *             Historical OPTDIFFs:
  *
 
 #define INTEL_FAM6_RAPTORLAKE          0xB7
 #define INTEL_FAM6_RAPTORLAKE_P                0xBA
+#define INTEL_FAM6_RAPTORLAKE_S                0xBF
 
 /* "Small Core" Processors (Atom) */
 
index 63f818a..147cb8f 100644 (file)
                              IRQ_CONSTRAINTS, regs, vector);           \
 }
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 /*
  * Macro to invoke __do_softirq on the irq stack. This is only called from
  * task context when bottom halves are about to be reenabled and soft
index e64fd20..c936ce9 100644 (file)
 #define RSB_CLEAR_LOOPS                32      /* To forcibly overwrite all entries */
 
 /*
+ * Common helper for __FILL_RETURN_BUFFER and __FILL_ONE_RETURN.
+ */
+#define __FILL_RETURN_SLOT                     \
+       ANNOTATE_INTRA_FUNCTION_CALL;           \
+       call    772f;                           \
+       int3;                                   \
+772:
+
+/*
+ * Stuff the entire RSB.
+ *
  * Google experimented with loop-unrolling and this turned out to be
  * the optimal version - two calls, each with their own speculation
  * trap should their return address end up getting used, in a loop.
  */
-#define __FILL_RETURN_BUFFER(reg, nr, sp)      \
-       mov     $(nr/2), reg;                   \
-771:                                           \
-       ANNOTATE_INTRA_FUNCTION_CALL;           \
-       call    772f;                           \
-773:   /* speculation trap */                  \
-       UNWIND_HINT_EMPTY;                      \
-       pause;                                  \
-       lfence;                                 \
-       jmp     773b;                           \
-772:                                           \
-       ANNOTATE_INTRA_FUNCTION_CALL;           \
-       call    774f;                           \
-775:   /* speculation trap */                  \
-       UNWIND_HINT_EMPTY;                      \
-       pause;                                  \
-       lfence;                                 \
-       jmp     775b;                           \
-774:                                           \
-       add     $(BITS_PER_LONG/8) * 2, sp;     \
-       dec     reg;                            \
-       jnz     771b;                           \
-       /* barrier for jnz misprediction */     \
+#ifdef CONFIG_X86_64
+#define __FILL_RETURN_BUFFER(reg, nr)                  \
+       mov     $(nr/2), reg;                           \
+771:                                                   \
+       __FILL_RETURN_SLOT                              \
+       __FILL_RETURN_SLOT                              \
+       add     $(BITS_PER_LONG/8) * 2, %_ASM_SP;       \
+       dec     reg;                                    \
+       jnz     771b;                                   \
+       /* barrier for jnz misprediction */             \
+       lfence;
+#else
+/*
+ * i386 doesn't unconditionally have LFENCE, as such it can't
+ * do a loop.
+ */
+#define __FILL_RETURN_BUFFER(reg, nr)                  \
+       .rept nr;                                       \
+       __FILL_RETURN_SLOT;                             \
+       .endr;                                          \
+       add     $(BITS_PER_LONG/8) * nr, %_ASM_SP;
+#endif
+
+/*
+ * Stuff a single RSB slot.
+ *
+ * To mitigate Post-Barrier RSB speculation, one CALL instruction must be
+ * forced to retire before letting a RET instruction execute.
+ *
+ * On PBRSB-vulnerable CPUs, it is not safe for a RET to be executed
+ * before this point.
+ */
+#define __FILL_ONE_RETURN                              \
+       __FILL_RETURN_SLOT                              \
+       add     $(BITS_PER_LONG/8), %_ASM_SP;           \
        lfence;
 
 #ifdef __ASSEMBLY__
 #endif
 .endm
 
-.macro ISSUE_UNBALANCED_RET_GUARD
-       ANNOTATE_INTRA_FUNCTION_CALL
-       call .Lunbalanced_ret_guard_\@
-       int3
-.Lunbalanced_ret_guard_\@:
-       add $(BITS_PER_LONG/8), %_ASM_SP
-       lfence
-.endm
-
  /*
   * A simpler FILL_RETURN_BUFFER macro. Don't make people use the CPP
   * monstrosity above, manually.
   */
-.macro FILL_RETURN_BUFFER reg:req nr:req ftr:req ftr2
-.ifb \ftr2
-       ALTERNATIVE "jmp .Lskip_rsb_\@", "", \ftr
-.else
-       ALTERNATIVE_2 "jmp .Lskip_rsb_\@", "", \ftr, "jmp .Lunbalanced_\@", \ftr2
-.endif
-       __FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP)
-.Lunbalanced_\@:
-       ISSUE_UNBALANCED_RET_GUARD
+.macro FILL_RETURN_BUFFER reg:req nr:req ftr:req ftr2=ALT_NOT(X86_FEATURE_ALWAYS)
+       ALTERNATIVE_2 "jmp .Lskip_rsb_\@", \
+               __stringify(__FILL_RETURN_BUFFER(\reg,\nr)), \ftr, \
+               __stringify(__FILL_ONE_RETURN), \ftr2
+
 .Lskip_rsb_\@:
 .endm
 
index 4a23e52..ebc271b 100644 (file)
@@ -195,7 +195,7 @@ void snp_set_memory_shared(unsigned long vaddr, unsigned int npages);
 void snp_set_memory_private(unsigned long vaddr, unsigned int npages);
 void snp_set_wakeup_secondary_cpu(void);
 bool snp_init(struct boot_params *bp);
-void snp_abort(void);
+void __init __noreturn snp_abort(void);
 int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned long *fw_err);
 #else
 static inline void sev_es_ist_enter(struct pt_regs *regs) { }
index 510d852..da7c361 100644 (file)
@@ -433,7 +433,8 @@ static void __init mmio_select_mitigation(void)
        u64 ia32_cap;
 
        if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA) ||
-           cpu_mitigations_off()) {
+            boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN) ||
+            cpu_mitigations_off()) {
                mmio_mitigation = MMIO_MITIGATION_OFF;
                return;
        }
@@ -538,6 +539,8 @@ out:
                pr_info("TAA: %s\n", taa_strings[taa_mitigation]);
        if (boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA))
                pr_info("MMIO Stale Data: %s\n", mmio_strings[mmio_mitigation]);
+       else if (boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN))
+               pr_info("MMIO Stale Data: Unknown: No mitigations\n");
 }
 
 static void __init md_clear_select_mitigation(void)
@@ -2275,6 +2278,9 @@ static ssize_t tsx_async_abort_show_state(char *buf)
 
 static ssize_t mmio_stale_data_show_state(char *buf)
 {
+       if (boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN))
+               return sysfs_emit(buf, "Unknown: No mitigations\n");
+
        if (mmio_mitigation == MMIO_MITIGATION_OFF)
                return sysfs_emit(buf, "%s\n", mmio_strings[mmio_mitigation]);
 
@@ -2421,6 +2427,7 @@ static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr
                return srbds_show_state(buf);
 
        case X86_BUG_MMIO_STALE_DATA:
+       case X86_BUG_MMIO_UNKNOWN:
                return mmio_stale_data_show_state(buf);
 
        case X86_BUG_RETBLEED:
@@ -2480,7 +2487,10 @@ ssize_t cpu_show_srbds(struct device *dev, struct device_attribute *attr, char *
 
 ssize_t cpu_show_mmio_stale_data(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_STALE_DATA);
+       if (boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN))
+               return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_UNKNOWN);
+       else
+               return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_STALE_DATA);
 }
 
 ssize_t cpu_show_retbleed(struct device *dev, struct device_attribute *attr, char *buf)
index 64a73f4..3e508f2 100644 (file)
@@ -1135,7 +1135,8 @@ static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
 #define NO_SWAPGS              BIT(6)
 #define NO_ITLB_MULTIHIT       BIT(7)
 #define NO_SPECTRE_V2          BIT(8)
-#define NO_EIBRS_PBRSB         BIT(9)
+#define NO_MMIO                        BIT(9)
+#define NO_EIBRS_PBRSB         BIT(10)
 
 #define VULNWL(vendor, family, model, whitelist)       \
        X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, whitelist)
@@ -1158,6 +1159,11 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
        VULNWL(VORTEX,  6, X86_MODEL_ANY,       NO_SPECULATION),
 
        /* Intel Family 6 */
+       VULNWL_INTEL(TIGERLAKE,                 NO_MMIO),
+       VULNWL_INTEL(TIGERLAKE_L,               NO_MMIO),
+       VULNWL_INTEL(ALDERLAKE,                 NO_MMIO),
+       VULNWL_INTEL(ALDERLAKE_L,               NO_MMIO),
+
        VULNWL_INTEL(ATOM_SALTWELL,             NO_SPECULATION | NO_ITLB_MULTIHIT),
        VULNWL_INTEL(ATOM_SALTWELL_TABLET,      NO_SPECULATION | NO_ITLB_MULTIHIT),
        VULNWL_INTEL(ATOM_SALTWELL_MID,         NO_SPECULATION | NO_ITLB_MULTIHIT),
@@ -1176,9 +1182,9 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
        VULNWL_INTEL(ATOM_AIRMONT_MID,          NO_L1TF | MSBDS_ONLY | NO_SWAPGS | NO_ITLB_MULTIHIT),
        VULNWL_INTEL(ATOM_AIRMONT_NP,           NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT),
 
-       VULNWL_INTEL(ATOM_GOLDMONT,             NO_MDS | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT),
-       VULNWL_INTEL(ATOM_GOLDMONT_D,           NO_MDS | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT),
-       VULNWL_INTEL(ATOM_GOLDMONT_PLUS,        NO_MDS | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_EIBRS_PBRSB),
+       VULNWL_INTEL(ATOM_GOLDMONT,             NO_MDS | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO),
+       VULNWL_INTEL(ATOM_GOLDMONT_D,           NO_MDS | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO),
+       VULNWL_INTEL(ATOM_GOLDMONT_PLUS,        NO_MDS | NO_L1TF | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO | NO_EIBRS_PBRSB),
 
        /*
         * Technically, swapgs isn't serializing on AMD (despite it previously
@@ -1193,18 +1199,18 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
        VULNWL_INTEL(ATOM_TREMONT_D,            NO_ITLB_MULTIHIT | NO_EIBRS_PBRSB),
 
        /* AMD Family 0xf - 0x12 */
-       VULNWL_AMD(0x0f,        NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT),
-       VULNWL_AMD(0x10,        NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT),
-       VULNWL_AMD(0x11,        NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT),
-       VULNWL_AMD(0x12,        NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT),
+       VULNWL_AMD(0x0f,        NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO),
+       VULNWL_AMD(0x10,        NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO),
+       VULNWL_AMD(0x11,        NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO),
+       VULNWL_AMD(0x12,        NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO),
 
        /* FAMILY_ANY must be last, otherwise 0x0f - 0x12 matches won't work */
-       VULNWL_AMD(X86_FAMILY_ANY,      NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT),
-       VULNWL_HYGON(X86_FAMILY_ANY,    NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT),
+       VULNWL_AMD(X86_FAMILY_ANY,      NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO),
+       VULNWL_HYGON(X86_FAMILY_ANY,    NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO),
 
        /* Zhaoxin Family 7 */
-       VULNWL(CENTAUR, 7, X86_MODEL_ANY,       NO_SPECTRE_V2 | NO_SWAPGS),
-       VULNWL(ZHAOXIN, 7, X86_MODEL_ANY,       NO_SPECTRE_V2 | NO_SWAPGS),
+       VULNWL(CENTAUR, 7, X86_MODEL_ANY,       NO_SPECTRE_V2 | NO_SWAPGS | NO_MMIO),
+       VULNWL(ZHAOXIN, 7, X86_MODEL_ANY,       NO_SPECTRE_V2 | NO_SWAPGS | NO_MMIO),
        {}
 };
 
@@ -1358,10 +1364,16 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
         * Affected CPU list is generally enough to enumerate the vulnerability,
         * but for virtualization case check for ARCH_CAP MSR bits also, VMM may
         * not want the guest to enumerate the bug.
+        *
+        * Set X86_BUG_MMIO_UNKNOWN for CPUs that are neither in the blacklist,
+        * nor in the whitelist and also don't enumerate MSR ARCH_CAP MMIO bits.
         */
-       if (cpu_matches(cpu_vuln_blacklist, MMIO) &&
-           !arch_cap_mmio_immune(ia32_cap))
-               setup_force_cpu_bug(X86_BUG_MMIO_STALE_DATA);
+       if (!arch_cap_mmio_immune(ia32_cap)) {
+               if (cpu_matches(cpu_vuln_blacklist, MMIO))
+                       setup_force_cpu_bug(X86_BUG_MMIO_STALE_DATA);
+               else if (!cpu_matches(cpu_vuln_whitelist, NO_MMIO))
+                       setup_force_cpu_bug(X86_BUG_MMIO_UNKNOWN);
+       }
 
        if (!cpu_has(c, X86_FEATURE_BTC_NO)) {
                if (cpu_matches(cpu_vuln_blacklist, RETBLEED) || (ia32_cap & ARCH_CAP_RSBA))
index e5dd6da..01833eb 100644 (file)
@@ -132,7 +132,7 @@ int irq_init_percpu_irqstack(unsigned int cpu)
        return 0;
 }
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 void do_softirq_own_stack(void)
 {
        struct irq_stack *irqstk;
index 63dc626..a428c62 100644 (file)
@@ -701,7 +701,13 @@ e_term:
 void __init early_snp_set_memory_private(unsigned long vaddr, unsigned long paddr,
                                         unsigned int npages)
 {
-       if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
+       /*
+        * This can be invoked in early boot while running identity mapped, so
+        * use an open coded check for SNP instead of using cc_platform_has().
+        * This eliminates worries about jump tables or checking boot_cpu_data
+        * in the cc_platform_has() function.
+        */
+       if (!(sev_status & MSR_AMD64_SEV_SNP_ENABLED))
                return;
 
         /*
@@ -717,7 +723,13 @@ void __init early_snp_set_memory_private(unsigned long vaddr, unsigned long padd
 void __init early_snp_set_memory_shared(unsigned long vaddr, unsigned long paddr,
                                        unsigned int npages)
 {
-       if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
+       /*
+        * This can be invoked in early boot while running identity mapped, so
+        * use an open coded check for SNP instead of using cc_platform_has().
+        * This eliminates worries about jump tables or checking boot_cpu_data
+        * in the cc_platform_has() function.
+        */
+       if (!(sev_status & MSR_AMD64_SEV_SNP_ENABLED))
                return;
 
        /* Invalidate the memory pages before they are marked shared in the RMP table. */
@@ -2100,7 +2112,7 @@ bool __init snp_init(struct boot_params *bp)
        return true;
 }
 
-void __init snp_abort(void)
+void __init __noreturn snp_abort(void)
 {
        sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED);
 }
index 38185ae..0ea57da 100644 (file)
@@ -93,22 +93,27 @@ static struct orc_entry *orc_find(unsigned long ip);
 static struct orc_entry *orc_ftrace_find(unsigned long ip)
 {
        struct ftrace_ops *ops;
-       unsigned long caller;
+       unsigned long tramp_addr, offset;
 
        ops = ftrace_ops_trampoline(ip);
        if (!ops)
                return NULL;
 
+       /* Set tramp_addr to the start of the code copied by the trampoline */
        if (ops->flags & FTRACE_OPS_FL_SAVE_REGS)
-               caller = (unsigned long)ftrace_regs_call;
+               tramp_addr = (unsigned long)ftrace_regs_caller;
        else
-               caller = (unsigned long)ftrace_call;
+               tramp_addr = (unsigned long)ftrace_caller;
+
+       /* Now place tramp_addr to the location within the trampoline ip is at */
+       offset = ip - ops->trampoline;
+       tramp_addr += offset;
 
        /* Prevent unlikely recursion */
-       if (ip == caller)
+       if (ip == tramp_addr)
                return NULL;
 
-       return orc_find(caller);
+       return orc_find(tramp_addr);
 }
 #else
 static struct orc_entry *orc_ftrace_find(unsigned long ip)
index 126fa9a..e418ef3 100644 (file)
@@ -5361,19 +5361,6 @@ void kvm_mmu_free_obsolete_roots(struct kvm_vcpu *vcpu)
        __kvm_mmu_free_obsolete_roots(vcpu->kvm, &vcpu->arch.guest_mmu);
 }
 
-static bool need_remote_flush(u64 old, u64 new)
-{
-       if (!is_shadow_present_pte(old))
-               return false;
-       if (!is_shadow_present_pte(new))
-               return true;
-       if ((old ^ new) & SPTE_BASE_ADDR_MASK)
-               return true;
-       old ^= shadow_nx_mask;
-       new ^= shadow_nx_mask;
-       return (old & ~new & SPTE_PERM_MASK) != 0;
-}
-
 static u64 mmu_pte_write_fetch_gpte(struct kvm_vcpu *vcpu, gpa_t *gpa,
                                    int *bytes)
 {
@@ -5519,7 +5506,7 @@ static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
                        mmu_page_zap_pte(vcpu->kvm, sp, spte, NULL);
                        if (gentry && sp->role.level != PG_LEVEL_4K)
                                ++vcpu->kvm->stat.mmu_pde_zapped;
-                       if (need_remote_flush(entry, *spte))
+                       if (is_shadow_present_pte(entry))
                                flush = true;
                        ++spte;
                }
@@ -6085,47 +6072,18 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
                                      const struct kvm_memory_slot *memslot,
                                      int start_level)
 {
-       bool flush = false;
-
        if (kvm_memslots_have_rmaps(kvm)) {
                write_lock(&kvm->mmu_lock);
-               flush = slot_handle_level(kvm, memslot, slot_rmap_write_protect,
-                                         start_level, KVM_MAX_HUGEPAGE_LEVEL,
-                                         false);
+               slot_handle_level(kvm, memslot, slot_rmap_write_protect,
+                                 start_level, KVM_MAX_HUGEPAGE_LEVEL, false);
                write_unlock(&kvm->mmu_lock);
        }
 
        if (is_tdp_mmu_enabled(kvm)) {
                read_lock(&kvm->mmu_lock);
-               flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, start_level);
+               kvm_tdp_mmu_wrprot_slot(kvm, memslot, start_level);
                read_unlock(&kvm->mmu_lock);
        }
-
-       /*
-        * Flush TLBs if any SPTEs had to be write-protected to ensure that
-        * guest writes are reflected in the dirty bitmap before the memslot
-        * update completes, i.e. before enabling dirty logging is visible to
-        * userspace.
-        *
-        * Perform the TLB flush outside the mmu_lock to reduce the amount of
-        * time the lock is held. However, this does mean that another CPU can
-        * now grab mmu_lock and encounter a write-protected SPTE while CPUs
-        * still have a writable mapping for the associated GFN in their TLB.
-        *
-        * This is safe but requires KVM to be careful when making decisions
-        * based on the write-protection status of an SPTE. Specifically, KVM
-        * also write-protects SPTEs to monitor changes to guest page tables
-        * during shadow paging, and must guarantee no CPUs can write to those
-        * page before the lock is dropped. As mentioned in the previous
-        * paragraph, a write-protected SPTE is no guarantee that CPU cannot
-        * perform writes. So to determine if a TLB flush is truly required, KVM
-        * will clear a separate software-only bit (MMU-writable) and skip the
-        * flush if-and-only-if this bit was already clear.
-        *
-        * See is_writable_pte() for more details.
-        */
-       if (flush)
-               kvm_arch_flush_remote_tlbs_memslot(kvm, memslot);
 }
 
 static inline bool need_topup(struct kvm_mmu_memory_cache *cache, int min)
@@ -6493,32 +6451,30 @@ void kvm_arch_flush_remote_tlbs_memslot(struct kvm *kvm,
 void kvm_mmu_slot_leaf_clear_dirty(struct kvm *kvm,
                                   const struct kvm_memory_slot *memslot)
 {
-       bool flush = false;
-
        if (kvm_memslots_have_rmaps(kvm)) {
                write_lock(&kvm->mmu_lock);
                /*
                 * Clear dirty bits only on 4k SPTEs since the legacy MMU only
                 * support dirty logging at a 4k granularity.
                 */
-               flush = slot_handle_level_4k(kvm, memslot, __rmap_clear_dirty, false);
+               slot_handle_level_4k(kvm, memslot, __rmap_clear_dirty, false);
                write_unlock(&kvm->mmu_lock);
        }
 
        if (is_tdp_mmu_enabled(kvm)) {
                read_lock(&kvm->mmu_lock);
-               flush |= kvm_tdp_mmu_clear_dirty_slot(kvm, memslot);
+               kvm_tdp_mmu_clear_dirty_slot(kvm, memslot);
                read_unlock(&kvm->mmu_lock);
        }
 
        /*
+        * The caller will flush the TLBs after this function returns.
+        *
         * It's also safe to flush TLBs out of mmu lock here as currently this
         * function is only used for dirty logging, in which case flushing TLB
         * out of mmu lock also guarantees no dirty pages will be lost in
         * dirty_bitmap.
         */
-       if (flush)
-               kvm_arch_flush_remote_tlbs_memslot(kvm, memslot);
 }
 
 void kvm_mmu_zap_all(struct kvm *kvm)
index f3744ee..7670c13 100644 (file)
@@ -343,7 +343,7 @@ static __always_inline bool is_rsvd_spte(struct rsvd_bits_validate *rsvd_check,
 }
 
 /*
- * An shadow-present leaf SPTE may be non-writable for 3 possible reasons:
+ * A shadow-present leaf SPTE may be non-writable for 4 possible reasons:
  *
  *  1. To intercept writes for dirty logging. KVM write-protects huge pages
  *     so that they can be split be split down into the dirty logging
@@ -361,8 +361,13 @@ static __always_inline bool is_rsvd_spte(struct rsvd_bits_validate *rsvd_check,
  *     read-only memslot or guest memory backed by a read-only VMA. Writes to
  *     such pages are disallowed entirely.
  *
- * To keep track of why a given SPTE is write-protected, KVM uses 2
- * software-only bits in the SPTE:
+ *  4. To emulate the Accessed bit for SPTEs without A/D bits.  Note, in this
+ *     case, the SPTE is access-protected, not just write-protected!
+ *
+ * For cases #1 and #4, KVM can safely make such SPTEs writable without taking
+ * mmu_lock as capturing the Accessed/Dirty state doesn't require taking it.
+ * To differentiate #1 and #4 from #2 and #3, KVM uses two software-only bits
+ * in the SPTE:
  *
  *  shadow_mmu_writable_mask, aka MMU-writable -
  *    Cleared on SPTEs that KVM is currently write-protecting for shadow paging
@@ -391,7 +396,8 @@ static __always_inline bool is_rsvd_spte(struct rsvd_bits_validate *rsvd_check,
  * shadow page tables between vCPUs. Write-protecting an SPTE for dirty logging
  * (which does not clear the MMU-writable bit), does not flush TLBs before
  * dropping the lock, as it only needs to synchronize guest writes with the
- * dirty bitmap.
+ * dirty bitmap. Similarly, making the SPTE inaccessible (and non-writable) for
+ * access-tracking via the clear_young() MMU notifier also does not flush TLBs.
  *
  * So, there is the problem: clearing the MMU-writable bit can encounter a
  * write-protected SPTE while CPUs still have writable mappings for that SPTE
index d7f8331..c9b49a0 100644 (file)
@@ -843,8 +843,7 @@ static bool msr_write_intercepted(struct vcpu_vmx *vmx, u32 msr)
        if (!(exec_controls_get(vmx) & CPU_BASED_USE_MSR_BITMAPS))
                return true;
 
-       return vmx_test_msr_bitmap_write(vmx->loaded_vmcs->msr_bitmap,
-                                        MSR_IA32_SPEC_CTRL);
+       return vmx_test_msr_bitmap_write(vmx->loaded_vmcs->msr_bitmap, msr);
 }
 
 unsigned int __vmx_vcpu_run_flags(struct vcpu_vmx *vmx)
index 205ebdc..43a6a7e 100644 (file)
@@ -1557,12 +1557,32 @@ static const u32 msr_based_features_all[] = {
 static u32 msr_based_features[ARRAY_SIZE(msr_based_features_all)];
 static unsigned int num_msr_based_features;
 
+/*
+ * Some IA32_ARCH_CAPABILITIES bits have dependencies on MSRs that KVM
+ * does not yet virtualize. These include:
+ *   10 - MISC_PACKAGE_CTRLS
+ *   11 - ENERGY_FILTERING_CTL
+ *   12 - DOITM
+ *   18 - FB_CLEAR_CTRL
+ *   21 - XAPIC_DISABLE_STATUS
+ *   23 - OVERCLOCKING_STATUS
+ */
+
+#define KVM_SUPPORTED_ARCH_CAP \
+       (ARCH_CAP_RDCL_NO | ARCH_CAP_IBRS_ALL | ARCH_CAP_RSBA | \
+        ARCH_CAP_SKIP_VMENTRY_L1DFLUSH | ARCH_CAP_SSB_NO | ARCH_CAP_MDS_NO | \
+        ARCH_CAP_PSCHANGE_MC_NO | ARCH_CAP_TSX_CTRL_MSR | ARCH_CAP_TAA_NO | \
+        ARCH_CAP_SBDR_SSDP_NO | ARCH_CAP_FBSDP_NO | ARCH_CAP_PSDP_NO | \
+        ARCH_CAP_FB_CLEAR | ARCH_CAP_RRSBA | ARCH_CAP_PBRSB_NO)
+
 static u64 kvm_get_arch_capabilities(void)
 {
        u64 data = 0;
 
-       if (boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES))
+       if (boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES)) {
                rdmsrl(MSR_IA32_ARCH_CAPABILITIES, data);
+               data &= KVM_SUPPORTED_ARCH_CAP;
+       }
 
        /*
         * If nx_huge_pages is enabled, KVM's shadow paging will ensure that
@@ -1610,9 +1630,6 @@ static u64 kvm_get_arch_capabilities(void)
                 */
        }
 
-       /* Guests don't need to know "Fill buffer clear control" exists */
-       data &= ~ARCH_CAP_FB_CLEAR_CTRL;
-
        return data;
 }
 
@@ -10652,7 +10669,8 @@ static inline int vcpu_block(struct kvm_vcpu *vcpu)
        case KVM_MP_STATE_INIT_RECEIVED:
                break;
        default:
-               return -EINTR;
+               WARN_ON_ONCE(1);
+               break;
        }
        return 1;
 }
@@ -11093,9 +11111,22 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
 
        vcpu_load(vcpu);
 
-       if (!lapic_in_kernel(vcpu) &&
-           mp_state->mp_state != KVM_MP_STATE_RUNNABLE)
+       switch (mp_state->mp_state) {
+       case KVM_MP_STATE_UNINITIALIZED:
+       case KVM_MP_STATE_HALTED:
+       case KVM_MP_STATE_AP_RESET_HOLD:
+       case KVM_MP_STATE_INIT_RECEIVED:
+       case KVM_MP_STATE_SIPI_RECEIVED:
+               if (!lapic_in_kernel(vcpu))
+                       goto out;
+               break;
+
+       case KVM_MP_STATE_RUNNABLE:
+               break;
+
+       default:
                goto out;
+       }
 
        /*
         * KVM_MP_STATE_INIT_RECEIVED means the processor is in
@@ -11563,7 +11594,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
        vcpu->arch.mci_ctl2_banks = kcalloc(KVM_MAX_MCE_BANKS, sizeof(u64),
                                            GFP_KERNEL_ACCOUNT);
        if (!vcpu->arch.mce_banks || !vcpu->arch.mci_ctl2_banks)
-               goto fail_free_pio_data;
+               goto fail_free_mce_banks;
        vcpu->arch.mcg_cap = KVM_MAX_MCE_BANKS;
 
        if (!zalloc_cpumask_var(&vcpu->arch.wbinvd_dirty_mask,
@@ -11617,7 +11648,6 @@ free_wbinvd_dirty_mask:
 fail_free_mce_banks:
        kfree(vcpu->arch.mce_banks);
        kfree(vcpu->arch.mci_ctl2_banks);
-fail_free_pio_data:
        free_page((unsigned long)vcpu->arch.pio_data);
 fail_free_lapic:
        kvm_free_lapic(vcpu);
@@ -12473,6 +12503,50 @@ static void kvm_mmu_slot_apply_flags(struct kvm *kvm,
                } else {
                        kvm_mmu_slot_remove_write_access(kvm, new, PG_LEVEL_4K);
                }
+
+               /*
+                * Unconditionally flush the TLBs after enabling dirty logging.
+                * A flush is almost always going to be necessary (see below),
+                * and unconditionally flushing allows the helpers to omit
+                * the subtly complex checks when removing write access.
+                *
+                * Do the flush outside of mmu_lock to reduce the amount of
+                * time mmu_lock is held.  Flushing after dropping mmu_lock is
+                * safe as KVM only needs to guarantee the slot is fully
+                * write-protected before returning to userspace, i.e. before
+                * userspace can consume the dirty status.
+                *
+                * Flushing outside of mmu_lock requires KVM to be careful when
+                * making decisions based on writable status of an SPTE, e.g. a
+                * !writable SPTE doesn't guarantee a CPU can't perform writes.
+                *
+                * Specifically, KVM also write-protects guest page tables to
+                * monitor changes when using shadow paging, and must guarantee
+                * no CPUs can write to those page before mmu_lock is dropped.
+                * Because CPUs may have stale TLB entries at this point, a
+                * !writable SPTE doesn't guarantee CPUs can't perform writes.
+                *
+                * KVM also allows making SPTES writable outside of mmu_lock,
+                * e.g. to allow dirty logging without taking mmu_lock.
+                *
+                * To handle these scenarios, KVM uses a separate software-only
+                * bit (MMU-writable) to track if a SPTE is !writable due to
+                * a guest page table being write-protected (KVM clears the
+                * MMU-writable flag when write-protecting for shadow paging).
+                *
+                * The use of MMU-writable is also the primary motivation for
+                * the unconditional flush.  Because KVM must guarantee that a
+                * CPU doesn't contain stale, writable TLB entries for a
+                * !MMU-writable SPTE, KVM must flush if it encounters any
+                * MMU-writable SPTE regardless of whether the actual hardware
+                * writable bit was set.  I.e. KVM is almost guaranteed to need
+                * to flush, while unconditionally flushing allows the "remove
+                * write access" helpers to ignore MMU-writable entirely.
+                *
+                * See is_writable_pte() for more details (the case involving
+                * access-tracked SPTEs is particularly relevant).
+                */
+               kvm_arch_flush_remote_tlbs_memslot(kvm, new);
        }
 }
 
index d5ef64d..66a209f 100644 (file)
@@ -62,6 +62,7 @@
 
 static bool __read_mostly pat_bp_initialized;
 static bool __read_mostly pat_disabled = !IS_ENABLED(CONFIG_X86_PAT);
+static bool __initdata pat_force_disabled = !IS_ENABLED(CONFIG_X86_PAT);
 static bool __read_mostly pat_bp_enabled;
 static bool __read_mostly pat_cm_initialized;
 
@@ -86,6 +87,7 @@ void pat_disable(const char *msg_reason)
 static int __init nopat(char *str)
 {
        pat_disable("PAT support disabled via boot option.");
+       pat_force_disabled = true;
        return 0;
 }
 early_param("nopat", nopat);
@@ -272,7 +274,7 @@ static void pat_ap_init(u64 pat)
        wrmsrl(MSR_IA32_CR_PAT, pat);
 }
 
-void init_cache_modes(void)
+void __init init_cache_modes(void)
 {
        u64 pat = 0;
 
@@ -313,6 +315,12 @@ void init_cache_modes(void)
                 */
                pat = PAT(0, WB) | PAT(1, WT) | PAT(2, UC_MINUS) | PAT(3, UC) |
                      PAT(4, WB) | PAT(5, WT) | PAT(6, UC_MINUS) | PAT(7, UC);
+       } else if (!pat_force_disabled && cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) {
+               /*
+                * Clearly PAT is enabled underneath. Allow pat_enabled() to
+                * reflect this.
+                */
+               pat_bp_enabled = true;
        }
 
        __init_cache_modes(pat);
index 3c1e6b6..c96c8c4 100644 (file)
@@ -1931,7 +1931,8 @@ out:
        /* If we didn't flush the entire list, we could have told the driver
         * there was more coming, but that turned out to be a lie.
         */
-       if ((!list_empty(list) || errors) && q->mq_ops->commit_rqs && queued)
+       if ((!list_empty(list) || errors || needs_resource ||
+            ret == BLK_STS_DEV_RESOURCE) && q->mq_ops->commit_rqs && queued)
                q->mq_ops->commit_rqs(hctx);
        /*
         * Any items that need requeuing? Stuff them into hctx->dispatch,
@@ -2660,6 +2661,7 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
                list_del_init(&rq->queuelist);
                ret = blk_mq_request_issue_directly(rq, list_empty(list));
                if (ret != BLK_STS_OK) {
+                       errors++;
                        if (ret == BLK_STS_RESOURCE ||
                                        ret == BLK_STS_DEV_RESOURCE) {
                                blk_mq_request_bypass_insert(rq, false,
@@ -2667,7 +2669,6 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
                                break;
                        }
                        blk_mq_end_request(rq, ret);
-                       errors++;
                } else
                        queued++;
        }
index db6ac54..e534fd4 100644 (file)
@@ -151,7 +151,7 @@ void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy)
        unsigned int cpu;
 
        for_each_cpu(cpu, policy->related_cpus) {
-               struct acpi_processor *pr = per_cpu(processors, policy->cpu);
+               struct acpi_processor *pr = per_cpu(processors, cpu);
 
                if (pr)
                        freq_qos_remove_request(&pr->thermal_req);
index 7b3ad8e..d4c168c 100644 (file)
@@ -370,7 +370,7 @@ static bool acpi_tie_nondev_subnodes(struct acpi_device_data *data)
                bool ret;
 
                status = acpi_attach_data(dn->handle, acpi_nondev_subnode_tag, dn);
-               if (ACPI_FAILURE(status)) {
+               if (ACPI_FAILURE(status) && status != AE_ALREADY_EXISTS) {
                        acpi_handle_err(dn->handle, "Can't tag data node\n");
                        return false;
                }
@@ -1043,11 +1043,10 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
                                break;                                  \
                        }                                               \
                        if (__items[i].integer.value > _Generic(__val,  \
-                                                               u8: U8_MAX, \
-                                                               u16: U16_MAX, \
-                                                               u32: U32_MAX, \
-                                                               u64: U64_MAX, \
-                                                               default: 0U)) { \
+                                                               u8 *: U8_MAX, \
+                                                               u16 *: U16_MAX, \
+                                                               u32 *: U32_MAX, \
+                                                               u64 *: U64_MAX)) { \
                                ret = -EOVERFLOW;                       \
                                break;                                  \
                        }                                               \
index 32b0e0b..110a535 100644 (file)
@@ -209,6 +209,7 @@ static int amba_match(struct device *dev, struct device_driver *drv)
        struct amba_device *pcdev = to_amba_device(dev);
        struct amba_driver *pcdrv = to_amba_driver(drv);
 
+       mutex_lock(&pcdev->periphid_lock);
        if (!pcdev->periphid) {
                int ret = amba_read_periphid(pcdev);
 
@@ -218,11 +219,14 @@ static int amba_match(struct device *dev, struct device_driver *drv)
                 * permanent failure in reading pid and cid, simply map it to
                 * -EPROBE_DEFER.
                 */
-               if (ret)
+               if (ret) {
+                       mutex_unlock(&pcdev->periphid_lock);
                        return -EPROBE_DEFER;
+               }
                dev_set_uevent_suppress(dev, false);
                kobject_uevent(&dev->kobj, KOBJ_ADD);
        }
+       mutex_unlock(&pcdev->periphid_lock);
 
        /* When driver_override is set, only bind to the matching driver */
        if (pcdev->driver_override)
@@ -532,6 +536,7 @@ static void amba_device_release(struct device *dev)
 
        if (d->res.parent)
                release_resource(&d->res);
+       mutex_destroy(&d->periphid_lock);
        kfree(d);
 }
 
@@ -584,6 +589,7 @@ static void amba_device_initialize(struct amba_device *dev, const char *name)
        dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
        dev->dev.dma_parms = &dev->dma_parms;
        dev->res.name = dev_name(&dev->dev);
+       mutex_init(&dev->periphid_lock);
 }
 
 /**
index c964d7c..6428f6b 100644 (file)
@@ -1385,6 +1385,18 @@ static int binder_inc_ref_for_node(struct binder_proc *proc,
        }
        ret = binder_inc_ref_olocked(ref, strong, target_list);
        *rdata = ref->data;
+       if (ret && ref == new_ref) {
+               /*
+                * Cleanup the failed reference here as the target
+                * could now be dead and have already released its
+                * references by now. Calling on the new reference
+                * with strong=0 and a tmp_refs will not decrement
+                * the node. The new_ref gets kfree'd below.
+                */
+               binder_cleanup_ref_olocked(new_ref);
+               ref = NULL;
+       }
+
        binder_proc_unlock(proc);
        if (new_ref && ref != new_ref)
                /*
index 1014beb..9b1778c 100644 (file)
@@ -322,7 +322,6 @@ static inline void binder_alloc_set_vma(struct binder_alloc *alloc,
         */
        if (vma) {
                vm_start = vma->vm_start;
-               alloc->vma_vm_mm = vma->vm_mm;
                mmap_assert_write_locked(alloc->vma_vm_mm);
        } else {
                mmap_assert_locked(alloc->vma_vm_mm);
@@ -402,12 +401,15 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
        size_t size, data_offsets_size;
        int ret;
 
+       mmap_read_lock(alloc->vma_vm_mm);
        if (!binder_alloc_get_vma(alloc)) {
+               mmap_read_unlock(alloc->vma_vm_mm);
                binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
                                   "%d: binder_alloc_buf, no vma\n",
                                   alloc->pid);
                return ERR_PTR(-ESRCH);
        }
+       mmap_read_unlock(alloc->vma_vm_mm);
 
        data_offsets_size = ALIGN(data_size, sizeof(void *)) +
                ALIGN(offsets_size, sizeof(void *));
@@ -792,7 +794,6 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
        binder_insert_free_buffer(alloc, buffer);
        alloc->free_async_space = alloc->buffer_size / 2;
        binder_alloc_set_vma(alloc, vma);
-       mmgrab(alloc->vma_vm_mm);
 
        return 0;
 
@@ -929,17 +930,25 @@ void binder_alloc_print_pages(struct seq_file *m,
         * Make sure the binder_alloc is fully initialized, otherwise we might
         * read inconsistent state.
         */
-       if (binder_alloc_get_vma(alloc) != NULL) {
-               for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
-                       page = &alloc->pages[i];
-                       if (!page->page_ptr)
-                               free++;
-                       else if (list_empty(&page->lru))
-                               active++;
-                       else
-                               lru++;
-               }
+
+       mmap_read_lock(alloc->vma_vm_mm);
+       if (binder_alloc_get_vma(alloc) == NULL) {
+               mmap_read_unlock(alloc->vma_vm_mm);
+               goto uninitialized;
        }
+
+       mmap_read_unlock(alloc->vma_vm_mm);
+       for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
+               page = &alloc->pages[i];
+               if (!page->page_ptr)
+                       free++;
+               else if (list_empty(&page->lru))
+                       active++;
+               else
+                       lru++;
+       }
+
+uninitialized:
        mutex_unlock(&alloc->mutex);
        seq_printf(m, "  pages: %d:%d:%d\n", active, lru, free);
        seq_printf(m, "  pages high watermark: %zu\n", alloc->pages_high);
@@ -1080,6 +1089,8 @@ static struct shrinker binder_shrinker = {
 void binder_alloc_init(struct binder_alloc *alloc)
 {
        alloc->pid = current->group_leader->pid;
+       alloc->vma_vm_mm = current->mm;
+       mmgrab(alloc->vma_vm_mm);
        mutex_init(&alloc->mutex);
        INIT_LIST_HEAD(&alloc->buffers);
 }
index 0424b59..eaa1b8d 100644 (file)
@@ -735,7 +735,7 @@ void update_siblings_masks(unsigned int cpuid)
        int cpu, ret;
 
        ret = detect_cache_attributes(cpuid);
-       if (ret)
+       if (ret && ret != -ENOENT)
                pr_info("Early cacheinfo failed, ret = %d\n", ret);
 
        /* update core and thread sibling masks */
index 70f79fc..ec69b43 100644 (file)
@@ -274,12 +274,42 @@ static int __init deferred_probe_timeout_setup(char *str)
 }
 __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
 
+/**
+ * driver_deferred_probe_check_state() - Check deferred probe state
+ * @dev: device to check
+ *
+ * Return:
+ * * -ENODEV if initcalls have completed and modules are disabled.
+ * * -ETIMEDOUT if the deferred probe timeout was set and has expired
+ *   and modules are enabled.
+ * * -EPROBE_DEFER in other cases.
+ *
+ * Drivers or subsystems can opt-in to calling this function instead of directly
+ * returning -EPROBE_DEFER.
+ */
+int driver_deferred_probe_check_state(struct device *dev)
+{
+       if (!IS_ENABLED(CONFIG_MODULES) && initcalls_done) {
+               dev_warn(dev, "ignoring dependency for device, assuming no driver\n");
+               return -ENODEV;
+       }
+
+       if (!driver_deferred_probe_timeout && initcalls_done) {
+               dev_warn(dev, "deferred probe timeout, ignoring dependency\n");
+               return -ETIMEDOUT;
+       }
+
+       return -EPROBE_DEFER;
+}
+EXPORT_SYMBOL_GPL(driver_deferred_probe_check_state);
+
 static void deferred_probe_timeout_work_func(struct work_struct *work)
 {
        struct device_private *p;
 
        fw_devlink_drivers_done();
 
+       driver_deferred_probe_timeout = 0;
        driver_deferred_probe_trigger();
        flush_work(&deferred_probe_work);
 
@@ -881,6 +911,11 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
                dev_dbg(dev, "Device match requests probe deferral\n");
                dev->can_match = true;
                driver_deferred_probe_add(dev);
+               /*
+                * Device can't match with a driver right now, so don't attempt
+                * to match or bind with other drivers on the bus.
+                */
+               return ret;
        } else if (ret < 0) {
                dev_dbg(dev, "Bus failed to match device: %d\n", ret);
                return ret;
@@ -1120,6 +1155,11 @@ static int __driver_attach(struct device *dev, void *data)
                dev_dbg(dev, "Device match requests probe deferral\n");
                dev->can_match = true;
                driver_deferred_probe_add(dev);
+               /*
+                * Driver could not match with device, but may match with
+                * another device on the bus.
+                */
+               return 0;
        } else if (ret < 0) {
                dev_dbg(dev, "Bus failed to match device: %d\n", ret);
                return ret;
index 77bad32..5b66b3d 100644 (file)
@@ -93,10 +93,9 @@ static void fw_dev_release(struct device *dev)
 {
        struct fw_sysfs *fw_sysfs = to_fw_sysfs(dev);
 
-       if (fw_sysfs->fw_upload_priv) {
-               free_fw_priv(fw_sysfs->fw_priv);
-               kfree(fw_sysfs->fw_upload_priv);
-       }
+       if (fw_sysfs->fw_upload_priv)
+               fw_upload_free(fw_sysfs);
+
        kfree(fw_sysfs);
 }
 
index 5d8ff16..df1d5ad 100644 (file)
@@ -106,12 +106,17 @@ extern struct device_attribute dev_attr_cancel;
 extern struct device_attribute dev_attr_remaining_size;
 
 int fw_upload_start(struct fw_sysfs *fw_sysfs);
+void fw_upload_free(struct fw_sysfs *fw_sysfs);
 umode_t fw_upload_is_visible(struct kobject *kobj, struct attribute *attr, int n);
 #else
 static inline int fw_upload_start(struct fw_sysfs *fw_sysfs)
 {
        return 0;
 }
+
+static inline void fw_upload_free(struct fw_sysfs *fw_sysfs)
+{
+}
 #endif
 
 #endif /* __FIRMWARE_SYSFS_H */
index 87044d5..a0af8f5 100644 (file)
@@ -264,6 +264,15 @@ int fw_upload_start(struct fw_sysfs *fw_sysfs)
        return 0;
 }
 
+void fw_upload_free(struct fw_sysfs *fw_sysfs)
+{
+       struct fw_upload_priv *fw_upload_priv = fw_sysfs->fw_upload_priv;
+
+       free_fw_priv(fw_sysfs->fw_priv);
+       kfree(fw_upload_priv->fw_upload);
+       kfree(fw_upload_priv);
+}
+
 /**
  * firmware_upload_register() - register for the firmware upload sysfs API
  * @module: kernel module of this device
@@ -377,6 +386,7 @@ void firmware_upload_unregister(struct fw_upload *fw_upload)
 {
        struct fw_sysfs *fw_sysfs = fw_upload->priv;
        struct fw_upload_priv *fw_upload_priv = fw_sysfs->fw_upload_priv;
+       struct module *module = fw_upload_priv->module;
 
        mutex_lock(&fw_upload_priv->lock);
        if (fw_upload_priv->progress == FW_UPLOAD_PROG_IDLE) {
@@ -392,6 +402,6 @@ void firmware_upload_unregister(struct fw_upload *fw_upload)
 
 unregister:
        device_unregister(&fw_sysfs->dev);
-       module_put(fw_upload_priv->module);
+       module_put(module);
 }
 EXPORT_SYMBOL_GPL(firmware_upload_unregister);
index 5a2e023..55a10e6 100644 (file)
@@ -2733,7 +2733,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
                mutex_unlock(&gpd_list_lock);
                dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
                        __func__, PTR_ERR(pd));
-               return -ENODEV;
+               return driver_deferred_probe_check_state(base_dev);
        }
 
        dev_dbg(dev, "adding to PM domain %s\n", pd->name);
index 719323b..37ab23a 100644 (file)
@@ -113,6 +113,7 @@ static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi,
                                                   const struct regmap_config *config)
 {
        size_t max_size = spi_max_transfer_size(spi);
+       size_t max_msg_size, reg_reserve_size;
        struct regmap_bus *bus;
 
        if (max_size != SIZE_MAX) {
@@ -120,9 +121,16 @@ static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi,
                if (!bus)
                        return ERR_PTR(-ENOMEM);
 
+               max_msg_size = spi_max_message_size(spi);
+               reg_reserve_size = config->reg_bits / BITS_PER_BYTE
+                                + config->pad_bits / BITS_PER_BYTE;
+               if (max_size + reg_reserve_size > max_msg_size)
+                       max_size -= reg_reserve_size;
+
                bus->free_on_exit = true;
                bus->max_raw_read = max_size;
                bus->max_raw_write = max_size;
+
                return bus;
        }
 
index e3c0ba9..ad92192 100644 (file)
@@ -979,6 +979,11 @@ loop_set_status_from_info(struct loop_device *lo,
 
        lo->lo_offset = info->lo_offset;
        lo->lo_sizelimit = info->lo_sizelimit;
+
+       /* loff_t vars have been assigned __u64 */
+       if (lo->lo_offset < 0 || lo->lo_sizelimit < 0)
+               return -EOVERFLOW;
+
        memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE);
        lo->lo_file_name[LO_NAME_SIZE-1] = 0;
        lo->lo_flags = info->lo_flags;
index bda5c81..a284734 100644 (file)
@@ -226,6 +226,9 @@ struct xen_vbd {
        sector_t                size;
        unsigned int            flush_support:1;
        unsigned int            discard_secure:1;
+       /* Connect-time cached feature_persistent parameter value */
+       unsigned int            feature_gnt_persistent_parm:1;
+       /* Persistent grants feature negotiation result */
        unsigned int            feature_gnt_persistent:1;
        unsigned int            overflow_max_grants:1;
 };
index ee7ad2f..c0227df 100644 (file)
@@ -907,7 +907,7 @@ again:
        xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
 
        err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u",
-                       be->blkif->vbd.feature_gnt_persistent);
+                       be->blkif->vbd.feature_gnt_persistent_parm);
        if (err) {
                xenbus_dev_fatal(dev, err, "writing %s/feature-persistent",
                                 dev->nodename);
@@ -1085,7 +1085,9 @@ static int connect_ring(struct backend_info *be)
                return -ENOSYS;
        }
 
-       blkif->vbd.feature_gnt_persistent = feature_persistent &&
+       blkif->vbd.feature_gnt_persistent_parm = feature_persistent;
+       blkif->vbd.feature_gnt_persistent =
+               blkif->vbd.feature_gnt_persistent_parm &&
                xenbus_read_unsigned(dev->otherend, "feature-persistent", 0);
 
        blkif->vbd.overflow_max_grants = 0;
index 8e56e69..35b9bca 100644 (file)
@@ -213,6 +213,9 @@ struct blkfront_info
        unsigned int feature_fua:1;
        unsigned int feature_discard:1;
        unsigned int feature_secdiscard:1;
+       /* Connect-time cached feature_persistent parameter */
+       unsigned int feature_persistent_parm:1;
+       /* Persistent grants feature negotiation result */
        unsigned int feature_persistent:1;
        unsigned int bounce:1;
        unsigned int discard_granularity;
@@ -1756,6 +1759,12 @@ abort_transaction:
        return err;
 }
 
+/* Enable the persistent grants feature. */
+static bool feature_persistent = true;
+module_param(feature_persistent, bool, 0644);
+MODULE_PARM_DESC(feature_persistent,
+               "Enables the persistent grants feature");
+
 /* Common code used when first setting up, and when resuming. */
 static int talk_to_blkback(struct xenbus_device *dev,
                           struct blkfront_info *info)
@@ -1847,8 +1856,9 @@ again:
                message = "writing protocol";
                goto abort_transaction;
        }
+       info->feature_persistent_parm = feature_persistent;
        err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u",
-                       info->feature_persistent);
+                       info->feature_persistent_parm);
        if (err)
                dev_warn(&dev->dev,
                         "writing persistent grants feature to xenbus");
@@ -1916,12 +1926,6 @@ static int negotiate_mq(struct blkfront_info *info)
        return 0;
 }
 
-/* Enable the persistent grants feature. */
-static bool feature_persistent = true;
-module_param(feature_persistent, bool, 0644);
-MODULE_PARM_DESC(feature_persistent,
-               "Enables the persistent grants feature");
-
 /*
  * Entry point to this code when a new device is created.  Allocate the basic
  * structures and the ring buffer for communication with the backend, and
@@ -2281,7 +2285,7 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)
        if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0))
                blkfront_setup_discard(info);
 
-       if (feature_persistent)
+       if (info->feature_persistent_parm)
                info->feature_persistent =
                        !!xenbus_read_unsigned(info->xbdev->otherend,
                                               "feature-persistent", 0);
index 92cb929..226ea76 100644 (file)
@@ -1146,14 +1146,15 @@ static ssize_t bd_stat_show(struct device *dev,
 static ssize_t debug_stat_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       int version = 2;
+       int version = 1;
        struct zram *zram = dev_to_zram(dev);
        ssize_t ret;
 
        down_read(&zram->init_lock);
        ret = scnprintf(buf, PAGE_SIZE,
-                       "version: %d\n%8llu\n",
+                       "version: %d\n%8llu %8llu\n",
                        version,
+                       (u64)atomic64_read(&zram->stats.writestall),
                        (u64)atomic64_read(&zram->stats.miss_free));
        up_read(&zram->init_lock);
 
@@ -1351,7 +1352,7 @@ static int __zram_bvec_write(struct zram *zram, struct bio_vec *bvec,
 {
        int ret = 0;
        unsigned long alloced_pages;
-       unsigned long handle = 0;
+       unsigned long handle = -ENOMEM;
        unsigned int comp_len = 0;
        void *src, *dst, *mem;
        struct zcomp_strm *zstrm;
@@ -1369,6 +1370,7 @@ static int __zram_bvec_write(struct zram *zram, struct bio_vec *bvec,
        }
        kunmap_atomic(mem);
 
+compress_again:
        zstrm = zcomp_stream_get(zram->comp);
        src = kmap_atomic(page);
        ret = zcomp_compress(zstrm, src, &comp_len);
@@ -1377,20 +1379,39 @@ static int __zram_bvec_write(struct zram *zram, struct bio_vec *bvec,
        if (unlikely(ret)) {
                zcomp_stream_put(zram->comp);
                pr_err("Compression failed! err=%d\n", ret);
+               zs_free(zram->mem_pool, handle);
                return ret;
        }
 
        if (comp_len >= huge_class_size)
                comp_len = PAGE_SIZE;
-
-       handle = zs_malloc(zram->mem_pool, comp_len,
-                       __GFP_KSWAPD_RECLAIM |
-                       __GFP_NOWARN |
-                       __GFP_HIGHMEM |
-                       __GFP_MOVABLE);
-
+       /*
+        * handle allocation has 2 paths:
+        * a) fast path is executed with preemption disabled (for
+        *  per-cpu streams) and has __GFP_DIRECT_RECLAIM bit clear,
+        *  since we can't sleep;
+        * b) slow path enables preemption and attempts to allocate
+        *  the page with __GFP_DIRECT_RECLAIM bit set. we have to
+        *  put per-cpu compression stream and, thus, to re-do
+        *  the compression once handle is allocated.
+        *
+        * if we have a 'non-null' handle here then we are coming
+        * from the slow path and handle has already been allocated.
+        */
+       if (IS_ERR((void *)handle))
+               handle = zs_malloc(zram->mem_pool, comp_len,
+                               __GFP_KSWAPD_RECLAIM |
+                               __GFP_NOWARN |
+                               __GFP_HIGHMEM |
+                               __GFP_MOVABLE);
        if (IS_ERR((void *)handle)) {
                zcomp_stream_put(zram->comp);
+               atomic64_inc(&zram->stats.writestall);
+               handle = zs_malloc(zram->mem_pool, comp_len,
+                               GFP_NOIO | __GFP_HIGHMEM |
+                               __GFP_MOVABLE);
+               if (!IS_ERR((void *)handle))
+                       goto compress_again;
                return PTR_ERR((void *)handle);
        }
 
@@ -1948,6 +1969,7 @@ static int zram_add(void)
        if (ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE)
                blk_queue_max_write_zeroes_sectors(zram->disk->queue, UINT_MAX);
 
+       blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, zram->disk->queue);
        ret = device_add_disk(NULL, zram->disk, zram_disk_groups);
        if (ret)
                goto out_cleanup_disk;
index 158c91e..80c3b43 100644 (file)
@@ -81,6 +81,7 @@ struct zram_stats {
        atomic64_t huge_pages_since;    /* no. of huge pages since zram set up */
        atomic64_t pages_stored;        /* no. of pages currently stored */
        atomic_long_t max_used_pages;   /* no. of maximum pages stored */
+       atomic64_t writestall;          /* no. of write slow paths */
        atomic64_t miss_free;           /* no. of missed free */
 #ifdef CONFIG_ZRAM_WRITEBACK
        atomic64_t bd_count;            /* no. of pages in backing device */
index f3aef77..df0fbfe 100644 (file)
@@ -430,12 +430,25 @@ irqreturn_t mhi_irq_handler(int irq_number, void *dev)
 {
        struct mhi_event *mhi_event = dev;
        struct mhi_controller *mhi_cntrl = mhi_event->mhi_cntrl;
-       struct mhi_event_ctxt *er_ctxt =
-               &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index];
+       struct mhi_event_ctxt *er_ctxt;
        struct mhi_ring *ev_ring = &mhi_event->ring;
-       dma_addr_t ptr = le64_to_cpu(er_ctxt->rp);
+       dma_addr_t ptr;
        void *dev_rp;
 
+       /*
+        * If CONFIG_DEBUG_SHIRQ is set, the IRQ handler will get invoked during __free_irq()
+        * and by that time mhi_ctxt() would've freed. So check for the existence of mhi_ctxt
+        * before handling the IRQs.
+        */
+       if (!mhi_cntrl->mhi_ctxt) {
+               dev_dbg(&mhi_cntrl->mhi_dev->dev,
+                       "mhi_ctxt has been freed\n");
+               return IRQ_HANDLED;
+       }
+
+       er_ctxt = &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index];
+       ptr = le64_to_cpu(er_ctxt->rp);
+
        if (!is_valid_ring_ptr(ev_ring, ptr)) {
                dev_err(&mhi_cntrl->mhi_dev->dev,
                        "Event ring rp points outside of the event ring\n");
index 84ca98e..32a932a 100644 (file)
@@ -480,6 +480,11 @@ static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out,
        return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null);
 }
 
+static int uring_cmd_null(struct io_uring_cmd *ioucmd, unsigned int issue_flags)
+{
+       return 0;
+}
+
 static ssize_t read_iter_zero(struct kiocb *iocb, struct iov_iter *iter)
 {
        size_t written = 0;
@@ -663,6 +668,7 @@ static const struct file_operations null_fops = {
        .read_iter      = read_iter_null,
        .write_iter     = write_iter_null,
        .splice_write   = splice_write_null,
+       .uring_cmd      = uring_cmd_null,
 };
 
 static const struct file_operations __maybe_unused port_fops = {
index 7351800..876b37b 100644 (file)
@@ -203,7 +203,7 @@ static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
        ret = raspberrypi_clock_property(rpi->firmware, data,
                                         RPI_FIRMWARE_GET_CLOCK_RATE, &val);
        if (ret)
-               return ret;
+               return 0;
 
        return val;
 }
@@ -220,7 +220,7 @@ static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate,
        ret = raspberrypi_clock_property(rpi->firmware, data,
                                         RPI_FIRMWARE_SET_CLOCK_RATE, &_rate);
        if (ret)
-               dev_err_ratelimited(rpi->dev, "Failed to change %s frequency: %d",
+               dev_err_ratelimited(rpi->dev, "Failed to change %s frequency: %d\n",
                                    clk_hw_get_name(hw), ret);
 
        return ret;
@@ -288,7 +288,7 @@ static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
                                         RPI_FIRMWARE_GET_MIN_CLOCK_RATE,
                                         &min_rate);
        if (ret) {
-               dev_err(rpi->dev, "Failed to get clock %d min freq: %d",
+               dev_err(rpi->dev, "Failed to get clock %d min freq: %d\n",
                        id, ret);
                return ERR_PTR(ret);
        }
@@ -344,8 +344,13 @@ static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi,
        struct rpi_firmware_get_clocks_response *clks;
        int ret;
 
+       /*
+        * The firmware doesn't guarantee that the last element of
+        * RPI_FIRMWARE_GET_CLOCKS is zeroed. So allocate an additional
+        * zero element as sentinel.
+        */
        clks = devm_kcalloc(rpi->dev,
-                           RPI_FIRMWARE_NUM_CLK_ID, sizeof(*clks),
+                           RPI_FIRMWARE_NUM_CLK_ID + 1, sizeof(*clks),
                            GFP_KERNEL);
        if (!clks)
                return -ENOMEM;
@@ -360,7 +365,8 @@ static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi,
                struct raspberrypi_clk_variant *variant;
 
                if (clks->id > RPI_FIRMWARE_NUM_CLK_ID) {
-                       dev_err(rpi->dev, "Unknown clock id: %u", clks->id);
+                       dev_err(rpi->dev, "Unknown clock id: %u (max: %u)\n",
+                                          clks->id, RPI_FIRMWARE_NUM_CLK_ID);
                        return -EINVAL;
                }
 
index 7fc191c..bd0b35c 100644 (file)
@@ -840,10 +840,9 @@ static void clk_core_unprepare(struct clk_core *core)
        if (core->ops->unprepare)
                core->ops->unprepare(core->hw);
 
-       clk_pm_runtime_put(core);
-
        trace_clk_unprepare_complete(core);
        clk_core_unprepare(core->parent);
+       clk_pm_runtime_put(core);
 }
 
 static void clk_core_unprepare_lock(struct clk_core *core)
index ef2a445..373e943 100644 (file)
@@ -135,6 +135,7 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
                        continue;
 
                if (!strncmp(n, tmp, strlen(tmp))) {
+                       of_node_get(np);
                        found = true;
                        break;
                }
index 7820c4e..69b3d61 100644 (file)
@@ -532,7 +532,7 @@ static unsigned int __resolve_freq(struct cpufreq_policy *policy,
 
        target_freq = clamp_val(target_freq, policy->min, policy->max);
 
-       if (!cpufreq_driver->target_index)
+       if (!policy->freq_table)
                return target_freq;
 
        idx = cpufreq_frequency_table_target(policy, target_freq, relation);
index 205acb2..e3885c9 100644 (file)
@@ -295,7 +295,8 @@ void dma_resv_add_fence(struct dma_resv *obj, struct dma_fence *fence,
                enum dma_resv_usage old_usage;
 
                dma_resv_list_entry(fobj, i, obj, &old, &old_usage);
-               if ((old->context == fence->context && old_usage >= usage) ||
+               if ((old->context == fence->context && old_usage >= usage &&
+                    dma_fence_is_later(fence, old)) ||
                    dma_fence_is_signaled(old)) {
                        dma_resv_list_set(fobj, i, fence, usage);
                        dma_fence_put(old);
index f191a1f..0eb6b61 100644 (file)
@@ -630,7 +630,7 @@ static int __init dmi_smbios3_present(const u8 *buf)
 {
        if (memcmp(buf, "_SM3_", 5) == 0 &&
            buf[6] < 32 && dmi_checksum(buf, buf[6])) {
-               dmi_ver = get_unaligned_be32(buf + 6) & 0xFFFFFF;
+               dmi_ver = get_unaligned_be24(buf + 7);
                dmi_num = 0;                    /* No longer specified */
                dmi_len = get_unaligned_le32(buf + 12);
                dmi_base = get_unaligned_le64(buf + 16);
index 4dde8ed..3e8d4b5 100644 (file)
@@ -243,29 +243,6 @@ failed:
 }
 
 /**
- * efi_capsule_flush - called by file close or file flush
- * @file: file pointer
- * @id: not used
- *
- *     If a capsule is being partially uploaded then calling this function
- *     will be treated as upload termination and will free those completed
- *     buffer pages and -ECANCELED will be returned.
- **/
-static int efi_capsule_flush(struct file *file, fl_owner_t id)
-{
-       int ret = 0;
-       struct capsule_info *cap_info = file->private_data;
-
-       if (cap_info->index > 0) {
-               pr_err("capsule upload not complete\n");
-               efi_free_all_buff_pages(cap_info);
-               ret = -ECANCELED;
-       }
-
-       return ret;
-}
-
-/**
  * efi_capsule_release - called by file close
  * @inode: not used
  * @file: file pointer
@@ -277,6 +254,13 @@ static int efi_capsule_release(struct inode *inode, struct file *file)
 {
        struct capsule_info *cap_info = file->private_data;
 
+       if (cap_info->index > 0 &&
+           (cap_info->header.headersize == 0 ||
+            cap_info->count < cap_info->total_size)) {
+               pr_err("capsule upload not complete\n");
+               efi_free_all_buff_pages(cap_info);
+       }
+
        kfree(cap_info->pages);
        kfree(cap_info->phys);
        kfree(file->private_data);
@@ -324,7 +308,6 @@ static const struct file_operations efi_capsule_fops = {
        .owner = THIS_MODULE,
        .open = efi_capsule_open,
        .write = efi_capsule_write,
-       .flush = efi_capsule_flush,
        .release = efi_capsule_release,
        .llseek = no_llseek,
 };
index d053757..2c67f71 100644 (file)
@@ -37,6 +37,13 @@ KBUILD_CFLAGS                        := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \
                                   $(call cc-option,-fno-addrsig) \
                                   -D__DISABLE_EXPORTS
 
+#
+# struct randomization only makes sense for Linux internal types, which the EFI
+# stub code never touches, so let's turn off struct randomization for the stub
+# altogether
+#
+KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS), $(KBUILD_CFLAGS))
+
 # remove SCS flags from all objects in this directory
 KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
 # disable LTO
index 05ae8bc..43ca665 100644 (file)
@@ -220,7 +220,6 @@ adjust_memory_range_protection(unsigned long start, unsigned long size)
        unsigned long end, next;
        unsigned long rounded_start, rounded_end;
        unsigned long unprotect_start, unprotect_size;
-       int has_system_memory = 0;
 
        if (efi_dxe_table == NULL)
                return;
index a415518..74cc71b 100644 (file)
@@ -164,6 +164,7 @@ static void dio48e_irq_mask(struct irq_data *data)
                dio48egpio->irq_mask &= ~BIT(0);
        else
                dio48egpio->irq_mask &= ~BIT(1);
+       gpiochip_disable_irq(chip, offset);
 
        if (!dio48egpio->irq_mask)
                /* disable interrupts */
@@ -191,6 +192,7 @@ static void dio48e_irq_unmask(struct irq_data *data)
                iowrite8(0x00, &dio48egpio->reg->enable_interrupt);
        }
 
+       gpiochip_enable_irq(chip, offset);
        if (offset == 19)
                dio48egpio->irq_mask |= BIT(0);
        else
@@ -213,12 +215,14 @@ static int dio48e_irq_set_type(struct irq_data *data, unsigned int flow_type)
        return 0;
 }
 
-static struct irq_chip dio48e_irqchip = {
+static const struct irq_chip dio48e_irqchip = {
        .name = "104-dio-48e",
        .irq_ack = dio48e_irq_ack,
        .irq_mask = dio48e_irq_mask,
        .irq_unmask = dio48e_irq_unmask,
-       .irq_set_type = dio48e_irq_set_type
+       .irq_set_type = dio48e_irq_set_type,
+       .flags = IRQCHIP_IMMUTABLE,
+       GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static irqreturn_t dio48e_irq_handler(int irq, void *dev_id)
@@ -322,7 +326,7 @@ static int dio48e_probe(struct device *dev, unsigned int id)
        dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple;
 
        girq = &dio48egpio->chip.irq;
-       girq->chip = &dio48e_irqchip;
+       gpio_irq_chip_set_chip(girq, &dio48e_irqchip);
        /* This will let us handle the parent IRQ in the driver */
        girq->parent_handler = NULL;
        girq->num_parents = 0;
index 40be76e..3286b91 100644 (file)
@@ -113,6 +113,7 @@ static void idi_48_irq_mask(struct irq_data *data)
        spin_lock_irqsave(&idi48gpio->lock, flags);
 
        idi48gpio->irq_mask[boundary] &= ~mask;
+       gpiochip_disable_irq(chip, offset);
 
        /* Exit early if there are still input lines with IRQ unmasked */
        if (idi48gpio->irq_mask[boundary])
@@ -140,6 +141,7 @@ static void idi_48_irq_unmask(struct irq_data *data)
 
        prev_irq_mask = idi48gpio->irq_mask[boundary];
 
+       gpiochip_enable_irq(chip, offset);
        idi48gpio->irq_mask[boundary] |= mask;
 
        /* Exit early if IRQ was already unmasked for this boundary */
@@ -164,12 +166,14 @@ static int idi_48_irq_set_type(struct irq_data *data, unsigned int flow_type)
        return 0;
 }
 
-static struct irq_chip idi_48_irqchip = {
+static const struct irq_chip idi_48_irqchip = {
        .name = "104-idi-48",
        .irq_ack = idi_48_irq_ack,
        .irq_mask = idi_48_irq_mask,
        .irq_unmask = idi_48_irq_unmask,
-       .irq_set_type = idi_48_irq_set_type
+       .irq_set_type = idi_48_irq_set_type,
+       .flags = IRQCHIP_IMMUTABLE,
+       GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static irqreturn_t idi_48_irq_handler(int irq, void *dev_id)
@@ -267,7 +271,7 @@ static int idi_48_probe(struct device *dev, unsigned int id)
        idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple;
 
        girq = &idi48gpio->chip.irq;
-       girq->chip = &idi_48_irqchip;
+       gpio_irq_chip_set_chip(girq, &idi_48_irqchip);
        /* This will let us handle the parent IRQ in the driver */
        girq->parent_handler = NULL;
        girq->num_parents = 0;
index 65a5f58..4756e58 100644 (file)
@@ -174,10 +174,11 @@ static void idio_16_irq_mask(struct irq_data *data)
 {
        struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
        struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
-       const unsigned long mask = BIT(irqd_to_hwirq(data));
+       const unsigned long offset = irqd_to_hwirq(data);
        unsigned long flags;
 
-       idio16gpio->irq_mask &= ~mask;
+       idio16gpio->irq_mask &= ~BIT(offset);
+       gpiochip_disable_irq(chip, offset);
 
        if (!idio16gpio->irq_mask) {
                raw_spin_lock_irqsave(&idio16gpio->lock, flags);
@@ -192,11 +193,12 @@ static void idio_16_irq_unmask(struct irq_data *data)
 {
        struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
        struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
-       const unsigned long mask = BIT(irqd_to_hwirq(data));
+       const unsigned long offset = irqd_to_hwirq(data);
        const unsigned long prev_irq_mask = idio16gpio->irq_mask;
        unsigned long flags;
 
-       idio16gpio->irq_mask |= mask;
+       gpiochip_enable_irq(chip, offset);
+       idio16gpio->irq_mask |= BIT(offset);
 
        if (!prev_irq_mask) {
                raw_spin_lock_irqsave(&idio16gpio->lock, flags);
@@ -217,12 +219,14 @@ static int idio_16_irq_set_type(struct irq_data *data, unsigned int flow_type)
        return 0;
 }
 
-static struct irq_chip idio_16_irqchip = {
+static const struct irq_chip idio_16_irqchip = {
        .name = "104-idio-16",
        .irq_ack = idio_16_irq_ack,
        .irq_mask = idio_16_irq_mask,
        .irq_unmask = idio_16_irq_unmask,
-       .irq_set_type = idio_16_irq_set_type
+       .irq_set_type = idio_16_irq_set_type,
+       .flags = IRQCHIP_IMMUTABLE,
+       GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static irqreturn_t idio_16_irq_handler(int irq, void *dev_id)
@@ -299,7 +303,7 @@ static int idio_16_probe(struct device *dev, unsigned int id)
        idio16gpio->out_state = 0xFFFF;
 
        girq = &idio16gpio->chip.irq;
-       girq->chip = &idio_16_irqchip;
+       gpio_irq_chip_set_chip(girq, &idio_16_irqchip);
        /* This will let us handle the parent IRQ in the driver */
        girq->parent_handler = NULL;
        girq->num_parents = 0;
index 8943cea..a2e505a 100644 (file)
@@ -373,6 +373,13 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
        }
 }
 
+static void gpio_mockup_debugfs_cleanup(void *data)
+{
+       struct gpio_mockup_chip *chip = data;
+
+       debugfs_remove_recursive(chip->dbg_dir);
+}
+
 static void gpio_mockup_dispose_mappings(void *data)
 {
        struct gpio_mockup_chip *chip = data;
@@ -455,7 +462,7 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 
        gpio_mockup_debugfs_setup(dev, chip);
 
-       return 0;
+       return devm_add_action_or_reset(dev, gpio_mockup_debugfs_cleanup, chip);
 }
 
 static const struct of_device_id gpio_mockup_of_match[] = {
index ecd7d16..2925f4d 100644 (file)
@@ -1175,7 +1175,9 @@ static int pca953x_suspend(struct device *dev)
 {
        struct pca953x_chip *chip = dev_get_drvdata(dev);
 
+       mutex_lock(&chip->i2c_lock);
        regcache_cache_only(chip->regmap, true);
+       mutex_unlock(&chip->i2c_lock);
 
        if (atomic_read(&chip->wakeup_path))
                device_set_wakeup_path(dev);
@@ -1198,13 +1200,17 @@ static int pca953x_resume(struct device *dev)
                }
        }
 
+       mutex_lock(&chip->i2c_lock);
        regcache_cache_only(chip->regmap, false);
        regcache_mark_dirty(chip->regmap);
        ret = pca953x_regcache_sync(dev);
-       if (ret)
+       if (ret) {
+               mutex_unlock(&chip->i2c_lock);
                return ret;
+       }
 
        ret = regcache_sync(chip->regmap);
+       mutex_unlock(&chip->i2c_lock);
        if (ret) {
                dev_err(dev, "Failed to restore register map: %d\n", ret);
                return ret;
index c7fbfa3..1198ab0 100644 (file)
@@ -661,24 +661,17 @@ static int pxa_gpio_probe(struct platform_device *pdev)
        if (IS_ERR(gpio_reg_base))
                return PTR_ERR(gpio_reg_base);
 
-       clk = clk_get(&pdev->dev, NULL);
+       clk = devm_clk_get_enabled(&pdev->dev, NULL);
        if (IS_ERR(clk)) {
                dev_err(&pdev->dev, "Error %ld to get gpio clock\n",
                        PTR_ERR(clk));
                return PTR_ERR(clk);
        }
-       ret = clk_prepare_enable(clk);
-       if (ret) {
-               clk_put(clk);
-               return ret;
-       }
 
        /* Initialize GPIO chips */
        ret = pxa_init_gpio_chip(pchip, pxa_last_gpio + 1, gpio_reg_base);
-       if (ret) {
-               clk_put(clk);
+       if (ret)
                return ret;
-       }
 
        /* clear all GPIO edge detects */
        for_each_gpio_bank(gpio, c, pchip) {
index 63dcf42..d6418f8 100644 (file)
  * @lock: Lock for accessing the IRQ registers and values
  * @intr_mask: Mask for interrupts lines
  * @intr_type: Interrupt type selection
+ * @bank_read: Read a bank setting as a single 32-bit value
+ * @bank_write: Write a bank setting as a single 32-bit value
+ * @imr_line_pos: Bit shift of an IRQ line's IMR value.
+ *
+ * The DIR, DATA, and ISR registers consist of four 8-bit port values, packed
+ * into a single 32-bit register. Use @bank_read (@bank_write) to get (assign)
+ * a value from (to) these registers. The IMR register consists of four 16-bit
+ * port values, packed into two 32-bit registers. Use @imr_line_pos to get the
+ * bit shift of the 2-bit field for a line's IMR settings. Shifts larger than
+ * 32 overflow into the second register.
  *
  * Because the interrupt mask register (IMR) combines the function of IRQ type
  * selection and masking, two extra values are stored. @intr_mask is used to
- * mask/unmask the interrupts for a GPIO port, and @intr_type is used to store
+ * mask/unmask the interrupts for a GPIO line, and @intr_type is used to store
  * the selected interrupt types. The logical AND of these values is written to
  * IMR on changes.
  */
@@ -59,10 +69,11 @@ struct realtek_gpio_ctrl {
        void __iomem *cpumask_base;
        struct cpumask cpu_irq_maskable;
        raw_spinlock_t lock;
-       u16 intr_mask[REALTEK_GPIO_PORTS_PER_BANK];
-       u16 intr_type[REALTEK_GPIO_PORTS_PER_BANK];
-       unsigned int (*port_offset_u8)(unsigned int port);
-       unsigned int (*port_offset_u16)(unsigned int port);
+       u8 intr_mask[REALTEK_GPIO_MAX];
+       u8 intr_type[REALTEK_GPIO_MAX];
+       u32 (*bank_read)(void __iomem *reg);
+       void (*bank_write)(void __iomem *reg, u32 value);
+       unsigned int (*line_imr_pos)(unsigned int line);
 };
 
 /* Expand with more flags as devices with other quirks are added */
@@ -101,14 +112,22 @@ static struct realtek_gpio_ctrl *irq_data_to_ctrl(struct irq_data *data)
  * port. The two interrupt mask registers store two bits per GPIO, so use u16
  * values.
  */
-static unsigned int realtek_gpio_port_offset_u8(unsigned int port)
+static u32 realtek_gpio_bank_read_swapped(void __iomem *reg)
 {
-       return port;
+       return ioread32be(reg);
 }
 
-static unsigned int realtek_gpio_port_offset_u16(unsigned int port)
+static void realtek_gpio_bank_write_swapped(void __iomem *reg, u32 value)
 {
-       return 2 * port;
+       iowrite32be(value, reg);
+}
+
+static unsigned int realtek_gpio_line_imr_pos_swapped(unsigned int line)
+{
+       unsigned int port_pin = line % 8;
+       unsigned int port = line / 8;
+
+       return 2 * (8 * (port ^ 1) + port_pin);
 }
 
 /*
@@ -119,66 +138,67 @@ static unsigned int realtek_gpio_port_offset_u16(unsigned int port)
  * per GPIO, so use u16 values. The first register contains ports 1 and 0, the
  * second ports 3 and 2.
  */
-static unsigned int realtek_gpio_port_offset_u8_rev(unsigned int port)
+static u32 realtek_gpio_bank_read(void __iomem *reg)
 {
-       return 3 - port;
+       return ioread32(reg);
 }
 
-static unsigned int realtek_gpio_port_offset_u16_rev(unsigned int port)
+static void realtek_gpio_bank_write(void __iomem *reg, u32 value)
 {
-       return 2 * (port ^ 1);
+       iowrite32(value, reg);
 }
 
-static void realtek_gpio_write_imr(struct realtek_gpio_ctrl *ctrl,
-       unsigned int port, u16 irq_type, u16 irq_mask)
+static unsigned int realtek_gpio_line_imr_pos(unsigned int line)
 {
-       iowrite16(irq_type & irq_mask,
-               ctrl->base + REALTEK_GPIO_REG_IMR + ctrl->port_offset_u16(port));
+       return 2 * line;
 }
 
-static void realtek_gpio_clear_isr(struct realtek_gpio_ctrl *ctrl,
-       unsigned int port, u8 mask)
+static void realtek_gpio_clear_isr(struct realtek_gpio_ctrl *ctrl, u32 mask)
 {
-       iowrite8(mask, ctrl->base + REALTEK_GPIO_REG_ISR + ctrl->port_offset_u8(port));
+       ctrl->bank_write(ctrl->base + REALTEK_GPIO_REG_ISR, mask);
 }
 
-static u8 realtek_gpio_read_isr(struct realtek_gpio_ctrl *ctrl, unsigned int port)
+static u32 realtek_gpio_read_isr(struct realtek_gpio_ctrl *ctrl)
 {
-       return ioread8(ctrl->base + REALTEK_GPIO_REG_ISR + ctrl->port_offset_u8(port));
+       return ctrl->bank_read(ctrl->base + REALTEK_GPIO_REG_ISR);
 }
 
-/* Set the rising and falling edge mask bits for a GPIO port pin */
-static u16 realtek_gpio_imr_bits(unsigned int pin, u16 value)
+/* Set the rising and falling edge mask bits for a GPIO pin */
+static void realtek_gpio_update_line_imr(struct realtek_gpio_ctrl *ctrl, unsigned int line)
 {
-       return (value & REALTEK_GPIO_IMR_LINE_MASK) << 2 * pin;
+       void __iomem *reg = ctrl->base + REALTEK_GPIO_REG_IMR;
+       unsigned int line_shift = ctrl->line_imr_pos(line);
+       unsigned int shift = line_shift % 32;
+       u32 irq_type = ctrl->intr_type[line];
+       u32 irq_mask = ctrl->intr_mask[line];
+       u32 reg_val;
+
+       reg += 4 * (line_shift / 32);
+       reg_val = ioread32(reg);
+       reg_val &= ~(REALTEK_GPIO_IMR_LINE_MASK << shift);
+       reg_val |= (irq_type & irq_mask & REALTEK_GPIO_IMR_LINE_MASK) << shift;
+       iowrite32(reg_val, reg);
 }
 
 static void realtek_gpio_irq_ack(struct irq_data *data)
 {
        struct realtek_gpio_ctrl *ctrl = irq_data_to_ctrl(data);
        irq_hw_number_t line = irqd_to_hwirq(data);
-       unsigned int port = line / 8;
-       unsigned int port_pin = line % 8;
 
-       realtek_gpio_clear_isr(ctrl, port, BIT(port_pin));
+       realtek_gpio_clear_isr(ctrl, BIT(line));
 }
 
 static void realtek_gpio_irq_unmask(struct irq_data *data)
 {
        struct realtek_gpio_ctrl *ctrl = irq_data_to_ctrl(data);
        unsigned int line = irqd_to_hwirq(data);
-       unsigned int port = line / 8;
-       unsigned int port_pin = line % 8;
        unsigned long flags;
-       u16 m;
 
        gpiochip_enable_irq(&ctrl->gc, line);
 
        raw_spin_lock_irqsave(&ctrl->lock, flags);
-       m = ctrl->intr_mask[port];
-       m |= realtek_gpio_imr_bits(port_pin, REALTEK_GPIO_IMR_LINE_MASK);
-       ctrl->intr_mask[port] = m;
-       realtek_gpio_write_imr(ctrl, port, ctrl->intr_type[port], m);
+       ctrl->intr_mask[line] = REALTEK_GPIO_IMR_LINE_MASK;
+       realtek_gpio_update_line_imr(ctrl, line);
        raw_spin_unlock_irqrestore(&ctrl->lock, flags);
 }
 
@@ -186,16 +206,11 @@ static void realtek_gpio_irq_mask(struct irq_data *data)
 {
        struct realtek_gpio_ctrl *ctrl = irq_data_to_ctrl(data);
        unsigned int line = irqd_to_hwirq(data);
-       unsigned int port = line / 8;
-       unsigned int port_pin = line % 8;
        unsigned long flags;
-       u16 m;
 
        raw_spin_lock_irqsave(&ctrl->lock, flags);
-       m = ctrl->intr_mask[port];
-       m &= ~realtek_gpio_imr_bits(port_pin, REALTEK_GPIO_IMR_LINE_MASK);
-       ctrl->intr_mask[port] = m;
-       realtek_gpio_write_imr(ctrl, port, ctrl->intr_type[port], m);
+       ctrl->intr_mask[line] = 0;
+       realtek_gpio_update_line_imr(ctrl, line);
        raw_spin_unlock_irqrestore(&ctrl->lock, flags);
 
        gpiochip_disable_irq(&ctrl->gc, line);
@@ -205,10 +220,8 @@ static int realtek_gpio_irq_set_type(struct irq_data *data, unsigned int flow_ty
 {
        struct realtek_gpio_ctrl *ctrl = irq_data_to_ctrl(data);
        unsigned int line = irqd_to_hwirq(data);
-       unsigned int port = line / 8;
-       unsigned int port_pin = line % 8;
        unsigned long flags;
-       u16 type, t;
+       u8 type;
 
        switch (flow_type & IRQ_TYPE_SENSE_MASK) {
        case IRQ_TYPE_EDGE_FALLING:
@@ -227,11 +240,8 @@ static int realtek_gpio_irq_set_type(struct irq_data *data, unsigned int flow_ty
        irq_set_handler_locked(data, handle_edge_irq);
 
        raw_spin_lock_irqsave(&ctrl->lock, flags);
-       t = ctrl->intr_type[port];
-       t &= ~realtek_gpio_imr_bits(port_pin, REALTEK_GPIO_IMR_LINE_MASK);
-       t |= realtek_gpio_imr_bits(port_pin, type);
-       ctrl->intr_type[port] = t;
-       realtek_gpio_write_imr(ctrl, port, t, ctrl->intr_mask[port]);
+       ctrl->intr_type[line] = type;
+       realtek_gpio_update_line_imr(ctrl, line);
        raw_spin_unlock_irqrestore(&ctrl->lock, flags);
 
        return 0;
@@ -242,28 +252,21 @@ static void realtek_gpio_irq_handler(struct irq_desc *desc)
        struct gpio_chip *gc = irq_desc_get_handler_data(desc);
        struct realtek_gpio_ctrl *ctrl = gpiochip_get_data(gc);
        struct irq_chip *irq_chip = irq_desc_get_chip(desc);
-       unsigned int lines_done;
-       unsigned int port_pin_count;
        unsigned long status;
        int offset;
 
        chained_irq_enter(irq_chip, desc);
 
-       for (lines_done = 0; lines_done < gc->ngpio; lines_done += 8) {
-               status = realtek_gpio_read_isr(ctrl, lines_done / 8);
-               port_pin_count = min(gc->ngpio - lines_done, 8U);
-               for_each_set_bit(offset, &status, port_pin_count)
-                       generic_handle_domain_irq(gc->irq.domain, offset + lines_done);
-       }
+       status = realtek_gpio_read_isr(ctrl);
+       for_each_set_bit(offset, &status, gc->ngpio)
+               generic_handle_domain_irq(gc->irq.domain, offset);
 
        chained_irq_exit(irq_chip, desc);
 }
 
-static inline void __iomem *realtek_gpio_irq_cpu_mask(struct realtek_gpio_ctrl *ctrl,
-       unsigned int port, int cpu)
+static inline void __iomem *realtek_gpio_irq_cpu_mask(struct realtek_gpio_ctrl *ctrl, int cpu)
 {
-       return ctrl->cpumask_base + ctrl->port_offset_u8(port) +
-               REALTEK_GPIO_PORTS_PER_BANK * cpu;
+       return ctrl->cpumask_base + REALTEK_GPIO_PORTS_PER_BANK * cpu;
 }
 
 static int realtek_gpio_irq_set_affinity(struct irq_data *data,
@@ -271,12 +274,10 @@ static int realtek_gpio_irq_set_affinity(struct irq_data *data,
 {
        struct realtek_gpio_ctrl *ctrl = irq_data_to_ctrl(data);
        unsigned int line = irqd_to_hwirq(data);
-       unsigned int port = line / 8;
-       unsigned int port_pin = line % 8;
        void __iomem *irq_cpu_mask;
        unsigned long flags;
        int cpu;
-       u8 v;
+       u32 v;
 
        if (!ctrl->cpumask_base)
                return -ENXIO;
@@ -284,15 +285,15 @@ static int realtek_gpio_irq_set_affinity(struct irq_data *data,
        raw_spin_lock_irqsave(&ctrl->lock, flags);
 
        for_each_cpu(cpu, &ctrl->cpu_irq_maskable) {
-               irq_cpu_mask = realtek_gpio_irq_cpu_mask(ctrl, port, cpu);
-               v = ioread8(irq_cpu_mask);
+               irq_cpu_mask = realtek_gpio_irq_cpu_mask(ctrl, cpu);
+               v = ctrl->bank_read(irq_cpu_mask);
 
                if (cpumask_test_cpu(cpu, dest))
-                       v |= BIT(port_pin);
+                       v |= BIT(line);
                else
-                       v &= ~BIT(port_pin);
+                       v &= ~BIT(line);
 
-               iowrite8(v, irq_cpu_mask);
+               ctrl->bank_write(irq_cpu_mask, v);
        }
 
        raw_spin_unlock_irqrestore(&ctrl->lock, flags);
@@ -305,16 +306,17 @@ static int realtek_gpio_irq_set_affinity(struct irq_data *data,
 static int realtek_gpio_irq_init(struct gpio_chip *gc)
 {
        struct realtek_gpio_ctrl *ctrl = gpiochip_get_data(gc);
-       unsigned int port;
+       u32 mask_all = GENMASK(gc->ngpio - 1, 0);
+       unsigned int line;
        int cpu;
 
-       for (port = 0; (port * 8) < gc->ngpio; port++) {
-               realtek_gpio_write_imr(ctrl, port, 0, 0);
-               realtek_gpio_clear_isr(ctrl, port, GENMASK(7, 0));
+       for (line = 0; line < gc->ngpio; line++)
+               realtek_gpio_update_line_imr(ctrl, line);
 
-               for_each_cpu(cpu, &ctrl->cpu_irq_maskable)
-                       iowrite8(GENMASK(7, 0), realtek_gpio_irq_cpu_mask(ctrl, port, cpu));
-       }
+       realtek_gpio_clear_isr(ctrl, mask_all);
+
+       for_each_cpu(cpu, &ctrl->cpu_irq_maskable)
+               ctrl->bank_write(realtek_gpio_irq_cpu_mask(ctrl, cpu), mask_all);
 
        return 0;
 }
@@ -387,12 +389,14 @@ static int realtek_gpio_probe(struct platform_device *pdev)
 
        if (dev_flags & GPIO_PORTS_REVERSED) {
                bgpio_flags = 0;
-               ctrl->port_offset_u8 = realtek_gpio_port_offset_u8_rev;
-               ctrl->port_offset_u16 = realtek_gpio_port_offset_u16_rev;
+               ctrl->bank_read = realtek_gpio_bank_read;
+               ctrl->bank_write = realtek_gpio_bank_write;
+               ctrl->line_imr_pos = realtek_gpio_line_imr_pos;
        } else {
                bgpio_flags = BGPIOF_BIG_ENDIAN_BYTE_ORDER;
-               ctrl->port_offset_u8 = realtek_gpio_port_offset_u8;
-               ctrl->port_offset_u16 = realtek_gpio_port_offset_u16;
+               ctrl->bank_read = realtek_gpio_bank_read_swapped;
+               ctrl->bank_write = realtek_gpio_bank_write_swapped;
+               ctrl->line_imr_pos = realtek_gpio_line_imr_pos_swapped;
        }
 
        err = bgpio_init(&ctrl->gc, dev, 4,
index b098f2d..59fb106 100644 (file)
@@ -265,6 +265,7 @@ static void ws16c48_irq_mask(struct irq_data *data)
        raw_spin_lock_irqsave(&ws16c48gpio->lock, flags);
 
        ws16c48gpio->irq_mask &= ~mask;
+       gpiochip_disable_irq(chip, offset);
        port_state = ws16c48gpio->irq_mask >> (8 * port);
 
        /* Select Register Page 2; Unlock all I/O ports */
@@ -295,6 +296,7 @@ static void ws16c48_irq_unmask(struct irq_data *data)
 
        raw_spin_lock_irqsave(&ws16c48gpio->lock, flags);
 
+       gpiochip_enable_irq(chip, offset);
        ws16c48gpio->irq_mask |= mask;
        port_state = ws16c48gpio->irq_mask >> (8 * port);
 
@@ -356,12 +358,14 @@ static int ws16c48_irq_set_type(struct irq_data *data, unsigned flow_type)
        return 0;
 }
 
-static struct irq_chip ws16c48_irqchip = {
+static const struct irq_chip ws16c48_irqchip = {
        .name = "ws16c48",
        .irq_ack = ws16c48_irq_ack,
        .irq_mask = ws16c48_irq_mask,
        .irq_unmask = ws16c48_irq_unmask,
-       .irq_set_type = ws16c48_irq_set_type
+       .irq_set_type = ws16c48_irq_set_type,
+       .flags = IRQCHIP_IMMUTABLE,
+       GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static irqreturn_t ws16c48_irq_handler(int irq, void *dev_id)
@@ -463,7 +467,7 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
        ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple;
 
        girq = &ws16c48gpio->chip.irq;
-       girq->chip = &ws16c48_irqchip;
+       gpio_irq_chip_set_chip(girq, &ws16c48_irqchip);
        /* This will let us handle the parent IRQ in the driver */
        girq->parent_handler = NULL;
        girq->num_parents = 0;
index e8a0b19..1400abe 100644 (file)
@@ -2456,12 +2456,14 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
                        if (!hive->reset_domain ||
                            !amdgpu_reset_get_reset_domain(hive->reset_domain)) {
                                r = -ENOENT;
+                               amdgpu_put_xgmi_hive(hive);
                                goto init_failed;
                        }
 
                        /* Drop the early temporary reset domain we created for device */
                        amdgpu_reset_put_reset_domain(adev->reset_domain);
                        adev->reset_domain = hive->reset_domain;
+                       amdgpu_put_xgmi_hive(hive);
                }
        }
 
@@ -4413,8 +4415,6 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
 retry:
        amdgpu_amdkfd_pre_reset(adev);
 
-       amdgpu_amdkfd_pre_reset(adev);
-
        if (from_hypervisor)
                r = amdgpu_virt_request_full_gpu(adev, true);
        else
@@ -5524,7 +5524,8 @@ bool amdgpu_device_is_peer_accessible(struct amdgpu_device *adev,
                ~*peer_adev->dev->dma_mask : ~((1ULL << 32) - 1);
        resource_size_t aper_limit =
                adev->gmc.aper_base + adev->gmc.aper_size - 1;
-       bool p2p_access = !(pci_p2pdma_distance_many(adev->pdev,
+       bool p2p_access = !adev->gmc.xgmi.connected_to_cpu &&
+                         !(pci_p2pdma_distance_many(adev->pdev,
                                        &peer_adev->dev, 1, true) < 0);
 
        return pcie_p2p && p2p_access && (adev->gmc.visible_vram_size &&
index ecada5e..e325150 100644 (file)
@@ -66,10 +66,15 @@ static bool is_fru_eeprom_supported(struct amdgpu_device *adev)
                return true;
        case CHIP_SIENNA_CICHLID:
                if (strnstr(atom_ctx->vbios_version, "D603",
+                   sizeof(atom_ctx->vbios_version))) {
+                       if (strnstr(atom_ctx->vbios_version, "D603GLXE",
                            sizeof(atom_ctx->vbios_version)))
-                       return true;
-               else
+                               return false;
+                       else
+                               return true;
+               } else {
                        return false;
+               }
        default:
                return false;
        }
index b1099ee..c2fd6f3 100644 (file)
@@ -159,7 +159,10 @@ void amdgpu_job_free(struct amdgpu_job *job)
        amdgpu_sync_free(&job->sync);
        amdgpu_sync_free(&job->sched_sync);
 
-       dma_fence_put(&job->hw_fence);
+       if (!job->hw_fence.ops)
+               kfree(job);
+       else
+               dma_fence_put(&job->hw_fence);
 }
 
 int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,
index b067ce4..9f7a5e3 100644 (file)
@@ -2401,7 +2401,7 @@ static int psp_load_smu_fw(struct psp_context *psp)
 static bool fw_load_skip_check(struct psp_context *psp,
                               struct amdgpu_firmware_info *ucode)
 {
-       if (!ucode->fw)
+       if (!ucode->fw || !ucode->ucode_size)
                return true;
 
        if (ucode->ucode_id == AMDGPU_UCODE_ID_SMC &&
@@ -2641,6 +2641,9 @@ static int psp_hw_fini(void *handle)
                psp_rap_terminate(psp);
                psp_dtm_terminate(psp);
                psp_hdcp_terminate(psp);
+
+               if (adev->gmc.xgmi.num_physical_nodes > 1)
+                       psp_xgmi_terminate(psp);
        }
 
        psp_asd_terminate(psp);
index 1b108d0..f2aebbf 100644 (file)
@@ -742,7 +742,7 @@ int amdgpu_xgmi_remove_device(struct amdgpu_device *adev)
                amdgpu_put_xgmi_hive(hive);
        }
 
-       return psp_xgmi_terminate(&adev->psp);
+       return 0;
 }
 
 static int amdgpu_xgmi_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block)
index a2a4dc1..a3cd5c1 100644 (file)
@@ -4274,35 +4274,45 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)
 
                }
 
-               info = &adev->firmware.ucode[AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS];
-               info->ucode_id = AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS;
-               info->fw = adev->gfx.rlc_fw;
-               adev->firmware.fw_size +=
-                       ALIGN(adev->gfx.rlc.global_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               if (adev->gfx.rlc.global_tap_delays_ucode_size_bytes) {
+                       info = &adev->firmware.ucode[AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS];
+                       info->ucode_id = AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS;
+                       info->fw = adev->gfx.rlc_fw;
+                       adev->firmware.fw_size +=
+                               ALIGN(adev->gfx.rlc.global_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               }
 
-               info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE0_TAP_DELAYS];
-               info->ucode_id = AMDGPU_UCODE_ID_SE0_TAP_DELAYS;
-               info->fw = adev->gfx.rlc_fw;
-               adev->firmware.fw_size +=
-                       ALIGN(adev->gfx.rlc.se0_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               if (adev->gfx.rlc.se0_tap_delays_ucode_size_bytes) {
+                       info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE0_TAP_DELAYS];
+                       info->ucode_id = AMDGPU_UCODE_ID_SE0_TAP_DELAYS;
+                       info->fw = adev->gfx.rlc_fw;
+                       adev->firmware.fw_size +=
+                               ALIGN(adev->gfx.rlc.se0_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               }
 
-               info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE1_TAP_DELAYS];
-               info->ucode_id = AMDGPU_UCODE_ID_SE1_TAP_DELAYS;
-               info->fw = adev->gfx.rlc_fw;
-               adev->firmware.fw_size +=
-                       ALIGN(adev->gfx.rlc.se1_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               if (adev->gfx.rlc.se1_tap_delays_ucode_size_bytes) {
+                       info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE1_TAP_DELAYS];
+                       info->ucode_id = AMDGPU_UCODE_ID_SE1_TAP_DELAYS;
+                       info->fw = adev->gfx.rlc_fw;
+                       adev->firmware.fw_size +=
+                               ALIGN(adev->gfx.rlc.se1_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               }
 
-               info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE2_TAP_DELAYS];
-               info->ucode_id = AMDGPU_UCODE_ID_SE2_TAP_DELAYS;
-               info->fw = adev->gfx.rlc_fw;
-               adev->firmware.fw_size +=
-                       ALIGN(adev->gfx.rlc.se2_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               if (adev->gfx.rlc.se2_tap_delays_ucode_size_bytes) {
+                       info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE2_TAP_DELAYS];
+                       info->ucode_id = AMDGPU_UCODE_ID_SE2_TAP_DELAYS;
+                       info->fw = adev->gfx.rlc_fw;
+                       adev->firmware.fw_size +=
+                               ALIGN(adev->gfx.rlc.se2_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               }
 
-               info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE3_TAP_DELAYS];
-               info->ucode_id = AMDGPU_UCODE_ID_SE3_TAP_DELAYS;
-               info->fw = adev->gfx.rlc_fw;
-               adev->firmware.fw_size +=
-                       ALIGN(adev->gfx.rlc.se3_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               if (adev->gfx.rlc.se3_tap_delays_ucode_size_bytes) {
+                       info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE3_TAP_DELAYS];
+                       info->ucode_id = AMDGPU_UCODE_ID_SE3_TAP_DELAYS;
+                       info->fw = adev->gfx.rlc_fw;
+                       adev->firmware.fw_size +=
+                               ALIGN(adev->gfx.rlc.se3_tap_delays_ucode_size_bytes, PAGE_SIZE);
+               }
 
                info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1];
                info->ucode_id = AMDGPU_UCODE_ID_CP_MEC1;
index 158d87e..f6b1bb4 100644 (file)
@@ -131,6 +131,8 @@ static void gfx_v11_0_ring_invalidate_tlbs(struct amdgpu_ring *ring,
                                           bool all_hub, uint8_t dst_sel);
 static void gfx_v11_0_set_safe_mode(struct amdgpu_device *adev);
 static void gfx_v11_0_unset_safe_mode(struct amdgpu_device *adev);
+static void gfx_v11_0_update_perf_clk(struct amdgpu_device *adev,
+                                     bool enable);
 
 static void gfx11_kiq_set_resources(struct amdgpu_ring *kiq_ring, uint64_t queue_mask)
 {
@@ -1139,6 +1141,7 @@ static const struct amdgpu_gfx_funcs gfx_v11_0_gfx_funcs = {
        .read_wave_vgprs = &gfx_v11_0_read_wave_vgprs,
        .select_me_pipe_q = &gfx_v11_0_select_me_pipe_q,
        .init_spm_golden = &gfx_v11_0_init_spm_golden_registers,
+       .update_perfmon_mgcg = &gfx_v11_0_update_perf_clk,
 };
 
 static int gfx_v11_0_gpu_early_init(struct amdgpu_device *adev)
@@ -5182,9 +5185,12 @@ static void gfx_v11_0_update_coarse_grain_clock_gating(struct amdgpu_device *ade
                data = REG_SET_FIELD(data, SDMA0_RLC_CGCG_CTRL, CGCG_INT_ENABLE, 1);
                WREG32_SOC15(GC, 0, regSDMA0_RLC_CGCG_CTRL, data);
 
-               data = RREG32_SOC15(GC, 0, regSDMA1_RLC_CGCG_CTRL);
-               data = REG_SET_FIELD(data, SDMA1_RLC_CGCG_CTRL, CGCG_INT_ENABLE, 1);
-               WREG32_SOC15(GC, 0, regSDMA1_RLC_CGCG_CTRL, data);
+               /* Some ASICs only have one SDMA instance, not need to configure SDMA1 */
+               if (adev->sdma.num_instances > 1) {
+                       data = RREG32_SOC15(GC, 0, regSDMA1_RLC_CGCG_CTRL);
+                       data = REG_SET_FIELD(data, SDMA1_RLC_CGCG_CTRL, CGCG_INT_ENABLE, 1);
+                       WREG32_SOC15(GC, 0, regSDMA1_RLC_CGCG_CTRL, data);
+               }
        } else {
                /* Program RLC_CGCG_CGLS_CTRL */
                def = data = RREG32_SOC15(GC, 0, regRLC_CGCG_CGLS_CTRL);
@@ -5213,9 +5219,12 @@ static void gfx_v11_0_update_coarse_grain_clock_gating(struct amdgpu_device *ade
                data &= ~SDMA0_RLC_CGCG_CTRL__CGCG_INT_ENABLE_MASK;
                WREG32_SOC15(GC, 0, regSDMA0_RLC_CGCG_CTRL, data);
 
-               data = RREG32_SOC15(GC, 0, regSDMA1_RLC_CGCG_CTRL);
-               data &= ~SDMA1_RLC_CGCG_CTRL__CGCG_INT_ENABLE_MASK;
-               WREG32_SOC15(GC, 0, regSDMA1_RLC_CGCG_CTRL, data);
+               /* Some ASICs only have one SDMA instance, not need to configure SDMA1 */
+               if (adev->sdma.num_instances > 1) {
+                       data = RREG32_SOC15(GC, 0, regSDMA1_RLC_CGCG_CTRL);
+                       data &= ~SDMA1_RLC_CGCG_CTRL__CGCG_INT_ENABLE_MASK;
+                       WREG32_SOC15(GC, 0, regSDMA1_RLC_CGCG_CTRL, data);
+               }
        }
 }
 
@@ -5328,8 +5337,7 @@ static int gfx_v11_0_set_powergating_state(void *handle,
                break;
        case IP_VERSION(11, 0, 1):
                gfx_v11_cntl_pg(adev, enable);
-               /* TODO: Enable this when GFXOFF is ready */
-               // amdgpu_gfx_off_ctrl(adev, enable);
+               amdgpu_gfx_off_ctrl(adev, enable);
                break;
        default:
                break;
index c6e0f93..fc9c104 100644 (file)
@@ -2587,7 +2587,8 @@ static void gfx_v9_0_constants_init(struct amdgpu_device *adev)
 
        gfx_v9_0_tiling_mode_table_init(adev);
 
-       gfx_v9_0_setup_rb(adev);
+       if (adev->gfx.num_gfx_rings)
+               gfx_v9_0_setup_rb(adev);
        gfx_v9_0_get_cu_info(adev, &adev->gfx.cu_info);
        adev->gfx.config.db_debug2 = RREG32_SOC15(GC, 0, mmDB_DEBUG2);
 
index 120ea29..cc3fdbb 100644 (file)
@@ -183,6 +183,7 @@ static int mes_v11_0_add_hw_queue(struct amdgpu_mes *mes,
        mes_add_queue_pkt.trap_handler_addr = input->tba_addr;
        mes_add_queue_pkt.tma_addr = input->tma_addr;
        mes_add_queue_pkt.is_kfd_process = input->is_kfd_process;
+       mes_add_queue_pkt.trap_en = 1;
 
        return mes_v11_0_submit_pkt_and_poll_completion(mes,
                        &mes_add_queue_pkt, sizeof(mes_add_queue_pkt),
index 3f44a09..3e51e77 100644 (file)
@@ -176,6 +176,7 @@ static void mmhub_v1_0_init_cache_regs(struct amdgpu_device *adev)
        tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_L2_CACHE, 1);
        WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL2, tmp);
 
+       tmp = mmVM_L2_CNTL3_DEFAULT;
        if (adev->gmc.translate_further) {
                tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 12);
                tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3,
index 6e0145b..445cb06 100644 (file)
@@ -295,9 +295,17 @@ static void mmhub_v9_4_disable_identity_aperture(struct amdgpu_device *adev,
 static void mmhub_v9_4_setup_vmid_config(struct amdgpu_device *adev, int hubid)
 {
        struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_MMHUB_0];
+       unsigned int num_level, block_size;
        uint32_t tmp;
        int i;
 
+       num_level = adev->vm_manager.num_level;
+       block_size = adev->vm_manager.block_size;
+       if (adev->gmc.translate_further)
+               num_level -= 1;
+       else
+               block_size -= 9;
+
        for (i = 0; i <= 14; i++) {
                tmp = RREG32_SOC15_OFFSET(MMHUB, 0, mmVML2VC0_VM_CONTEXT1_CNTL,
                                hubid * MMHUB_INSTANCE_REGISTER_OFFSET + i);
@@ -305,7 +313,7 @@ static void mmhub_v9_4_setup_vmid_config(struct amdgpu_device *adev, int hubid)
                                    ENABLE_CONTEXT, 1);
                tmp = REG_SET_FIELD(tmp, VML2VC0_VM_CONTEXT1_CNTL,
                                    PAGE_TABLE_DEPTH,
-                                   adev->vm_manager.num_level);
+                                   num_level);
                tmp = REG_SET_FIELD(tmp, VML2VC0_VM_CONTEXT1_CNTL,
                                    RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
                tmp = REG_SET_FIELD(tmp, VML2VC0_VM_CONTEXT1_CNTL,
@@ -323,7 +331,7 @@ static void mmhub_v9_4_setup_vmid_config(struct amdgpu_device *adev, int hubid)
                                    EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
                tmp = REG_SET_FIELD(tmp, VML2VC0_VM_CONTEXT1_CNTL,
                                    PAGE_TABLE_BLOCK_SIZE,
-                                   adev->vm_manager.block_size - 9);
+                                   block_size);
                /* Send no-retry XNACK on fault to suppress VM fault storm. */
                tmp = REG_SET_FIELD(tmp, VML2VC0_VM_CONTEXT1_CNTL,
                                    RETRY_PERMISSION_OR_INVALID_PAGE_FAULT,
index 01e8288..1dc95ef 100644 (file)
@@ -247,6 +247,81 @@ static void nbio_v7_7_init_registers(struct amdgpu_device *adev)
 
 }
 
+static void nbio_v7_7_update_medium_grain_clock_gating(struct amdgpu_device *adev,
+                                                      bool enable)
+{
+       uint32_t def, data;
+
+       if (enable && !(adev->cg_flags & AMD_CG_SUPPORT_BIF_MGCG))
+               return;
+
+       def = data = RREG32_SOC15(NBIO, 0, regBIF0_CPM_CONTROL);
+       if (enable) {
+               data |= (BIF0_CPM_CONTROL__LCLK_DYN_GATE_ENABLE_MASK |
+                        BIF0_CPM_CONTROL__TXCLK_DYN_GATE_ENABLE_MASK |
+                        BIF0_CPM_CONTROL__TXCLK_LCNT_GATE_ENABLE_MASK |
+                        BIF0_CPM_CONTROL__TXCLK_REGS_GATE_ENABLE_MASK |
+                        BIF0_CPM_CONTROL__TXCLK_PRBS_GATE_ENABLE_MASK |
+                        BIF0_CPM_CONTROL__REFCLK_REGS_GATE_ENABLE_MASK);
+       } else {
+               data &= ~(BIF0_CPM_CONTROL__LCLK_DYN_GATE_ENABLE_MASK |
+                         BIF0_CPM_CONTROL__TXCLK_DYN_GATE_ENABLE_MASK |
+                         BIF0_CPM_CONTROL__TXCLK_LCNT_GATE_ENABLE_MASK |
+                         BIF0_CPM_CONTROL__TXCLK_REGS_GATE_ENABLE_MASK |
+                         BIF0_CPM_CONTROL__TXCLK_PRBS_GATE_ENABLE_MASK |
+                         BIF0_CPM_CONTROL__REFCLK_REGS_GATE_ENABLE_MASK);
+       }
+
+       if (def != data)
+               WREG32_SOC15(NBIO, 0, regBIF0_CPM_CONTROL, data);
+}
+
+static void nbio_v7_7_update_medium_grain_light_sleep(struct amdgpu_device *adev,
+                                                     bool enable)
+{
+       uint32_t def, data;
+
+       if (enable && !(adev->cg_flags & AMD_CG_SUPPORT_BIF_LS))
+               return;
+
+       def = data = RREG32_SOC15(NBIO, 0, regBIF0_PCIE_CNTL2);
+       if (enable)
+               data |= BIF0_PCIE_CNTL2__SLV_MEM_LS_EN_MASK;
+       else
+               data &= ~BIF0_PCIE_CNTL2__SLV_MEM_LS_EN_MASK;
+
+       if (def != data)
+               WREG32_SOC15(NBIO, 0, regBIF0_PCIE_CNTL2, data);
+
+       def = data = RREG32_SOC15(NBIO, 0, regBIF0_PCIE_TX_POWER_CTRL_1);
+       if (enable) {
+               data |= (BIF0_PCIE_TX_POWER_CTRL_1__MST_MEM_LS_EN_MASK |
+                       BIF0_PCIE_TX_POWER_CTRL_1__REPLAY_MEM_LS_EN_MASK);
+       } else {
+               data &= ~(BIF0_PCIE_TX_POWER_CTRL_1__MST_MEM_LS_EN_MASK |
+                       BIF0_PCIE_TX_POWER_CTRL_1__REPLAY_MEM_LS_EN_MASK);
+       }
+
+       if (def != data)
+               WREG32_SOC15(NBIO, 0, regBIF0_PCIE_TX_POWER_CTRL_1, data);
+}
+
+static void nbio_v7_7_get_clockgating_state(struct amdgpu_device *adev,
+                                           u64 *flags)
+{
+       uint32_t data;
+
+       /* AMD_CG_SUPPORT_BIF_MGCG */
+       data = RREG32_SOC15(NBIO, 0, regBIF0_CPM_CONTROL);
+       if (data & BIF0_CPM_CONTROL__LCLK_DYN_GATE_ENABLE_MASK)
+               *flags |= AMD_CG_SUPPORT_BIF_MGCG;
+
+       /* AMD_CG_SUPPORT_BIF_LS */
+       data = RREG32_SOC15(NBIO, 0, regBIF0_PCIE_CNTL2);
+       if (data & BIF0_PCIE_CNTL2__SLV_MEM_LS_EN_MASK)
+               *flags |= AMD_CG_SUPPORT_BIF_LS;
+}
+
 const struct amdgpu_nbio_funcs nbio_v7_7_funcs = {
        .get_hdp_flush_req_offset = nbio_v7_7_get_hdp_flush_req_offset,
        .get_hdp_flush_done_offset = nbio_v7_7_get_hdp_flush_done_offset,
@@ -262,6 +337,9 @@ const struct amdgpu_nbio_funcs nbio_v7_7_funcs = {
        .enable_doorbell_aperture = nbio_v7_7_enable_doorbell_aperture,
        .enable_doorbell_selfring_aperture = nbio_v7_7_enable_doorbell_selfring_aperture,
        .ih_doorbell_range = nbio_v7_7_ih_doorbell_range,
+       .update_medium_grain_clock_gating = nbio_v7_7_update_medium_grain_clock_gating,
+       .update_medium_grain_light_sleep = nbio_v7_7_update_medium_grain_light_sleep,
+       .get_clockgating_state = nbio_v7_7_get_clockgating_state,
        .ih_control = nbio_v7_7_ih_control,
        .init_registers = nbio_v7_7_init_registers,
 };
index 1ff7fc7..55284b2 100644 (file)
@@ -494,6 +494,20 @@ static void soc21_pre_asic_init(struct amdgpu_device *adev)
 {
 }
 
+static int soc21_update_umd_stable_pstate(struct amdgpu_device *adev,
+                                         bool enter)
+{
+       if (enter)
+               amdgpu_gfx_rlc_enter_safe_mode(adev);
+       else
+               amdgpu_gfx_rlc_exit_safe_mode(adev);
+
+       if (adev->gfx.funcs->update_perfmon_mgcg)
+               adev->gfx.funcs->update_perfmon_mgcg(adev, !enter);
+
+       return 0;
+}
+
 static const struct amdgpu_asic_funcs soc21_asic_funcs =
 {
        .read_disabled_bios = &soc21_read_disabled_bios,
@@ -513,6 +527,7 @@ static const struct amdgpu_asic_funcs soc21_asic_funcs =
        .supports_baco = &amdgpu_dpm_is_baco_supported,
        .pre_asic_init = &soc21_pre_asic_init,
        .query_video_codecs = &soc21_query_video_codecs,
+       .update_umd_stable_pstate = &soc21_update_umd_stable_pstate,
 };
 
 static int soc21_common_early_init(void *handle)
@@ -603,6 +618,8 @@ static int soc21_common_early_init(void *handle)
                        AMD_CG_SUPPORT_ATHUB_MGCG |
                        AMD_CG_SUPPORT_ATHUB_LS |
                        AMD_CG_SUPPORT_IH_CG |
+                       AMD_CG_SUPPORT_BIF_MGCG |
+                       AMD_CG_SUPPORT_BIF_LS |
                        AMD_CG_SUPPORT_VCN_MGCG |
                        AMD_CG_SUPPORT_JPEG_MGCG;
                adev->pg_flags =
@@ -702,6 +719,7 @@ static int soc21_common_set_clockgating_state(void *handle,
        switch (adev->ip_versions[NBIO_HWIP][0]) {
        case IP_VERSION(4, 3, 0):
        case IP_VERSION(4, 3, 1):
+       case IP_VERSION(7, 7, 0):
                adev->nbio.funcs->update_medium_grain_clock_gating(adev,
                                state == AMD_CG_STATE_GATE);
                adev->nbio.funcs->update_medium_grain_light_sleep(adev,
@@ -709,10 +727,6 @@ static int soc21_common_set_clockgating_state(void *handle,
                adev->hdp.funcs->update_clock_gating(adev,
                                state == AMD_CG_STATE_GATE);
                break;
-       case IP_VERSION(7, 7, 0):
-               adev->hdp.funcs->update_clock_gating(adev,
-                               state == AMD_CG_STATE_GATE);
-               break;
        default:
                break;
        }
index 357298e..22c0929 100644 (file)
@@ -382,12 +382,8 @@ struct kfd_dev *kgd2kfd_probe(struct amdgpu_device *adev, bool vf)
                                f2g = &gfx_v10_3_kfd2kgd;
                        break;
                case IP_VERSION(10, 3, 6):
-                       gfx_target_version = 100306;
-                       if (!vf)
-                               f2g = &gfx_v10_3_kfd2kgd;
-                       break;
                case IP_VERSION(10, 3, 7):
-                       gfx_target_version = 100307;
+                       gfx_target_version = 100306;
                        if (!vf)
                                f2g = &gfx_v10_3_kfd2kgd;
                        break;
index fca7cf9..987bde4 100644 (file)
@@ -34,6 +34,7 @@
 #include "dal_asic_id.h"
 #include "amdgpu_display.h"
 #include "amdgpu_dm_trace.h"
+#include "amdgpu_dm_plane.h"
 #include "gc/gc_11_0_0_offset.h"
 #include "gc/gc_11_0_0_sh_mask.h"
 
@@ -149,12 +150,12 @@ static void add_modifier(uint64_t **mods, uint64_t *size, uint64_t *cap, uint64_
        *size += 1;
 }
 
-bool modifier_has_dcc(uint64_t modifier)
+static bool modifier_has_dcc(uint64_t modifier)
 {
        return IS_AMD_FMT_MOD(modifier) && AMD_FMT_MOD_GET(DCC, modifier);
 }
 
-unsigned modifier_gfx9_swizzle_mode(uint64_t modifier)
+static unsigned modifier_gfx9_swizzle_mode(uint64_t modifier)
 {
        if (modifier == DRM_FORMAT_MOD_LINEAR)
                return 0;
index 95168c2..286981a 100644 (file)
@@ -36,17 +36,9 @@ int fill_dc_scaling_info(struct amdgpu_device *adev,
                         const struct drm_plane_state *state,
                         struct dc_scaling_info *scaling_info);
 
-void get_min_max_dc_plane_scaling(struct drm_device *dev,
-                                 struct drm_framebuffer *fb,
-                                 int *min_downscale, int *max_upscale);
-
 int dm_plane_helper_check_state(struct drm_plane_state *state,
                                struct drm_crtc_state *new_crtc_state);
 
-bool modifier_has_dcc(uint64_t modifier);
-
-unsigned int modifier_gfx9_swizzle_mode(uint64_t modifier);
-
 int fill_plane_buffer_attributes(struct amdgpu_device *adev,
                                 const struct amdgpu_framebuffer *afb,
                                 const enum surface_pixel_format format,
index aeecca6..fb22c3d 100644 (file)
@@ -1094,7 +1094,8 @@ static void disable_dangling_plane(struct dc *dc, struct dc_state *context)
                                dc->current_state->stream_count != context->stream_count)
                        should_disable = true;
 
-               if (old_stream && !dc->current_state->res_ctx.pipe_ctx[i].top_pipe) {
+               if (old_stream && !dc->current_state->res_ctx.pipe_ctx[i].top_pipe &&
+                               !dc->current_state->res_ctx.pipe_ctx[i].prev_odm_pipe) {
                        struct pipe_ctx *old_pipe, *new_pipe;
 
                        old_pipe = &dc->current_state->res_ctx.pipe_ctx[i];
index a788d16..ab70ebd 100644 (file)
@@ -104,6 +104,9 @@ static bool has_query_dp_alt(struct link_encoder *enc)
 {
        struct dc_dmub_srv *dc_dmub_srv = enc->ctx->dmub_srv;
 
+       if (enc->ctx->dce_version >= DCN_VERSION_3_15)
+               return true;
+
        /* Supports development firmware and firmware >= 4.0.11 */
        return dc_dmub_srv &&
               !(dc_dmub_srv->dmub->fw_version >= DMUB_FW_VERSION(4, 0, 0) &&
index b384f30..e3351dd 100644 (file)
@@ -317,6 +317,7 @@ static void enc314_stream_encoder_dp_unblank(
        /* switch DP encoder to CRTC data, but reset it the fifo first. It may happen
         * that it overflows during mode transition, and sometimes doesn't recover.
         */
+       REG_UPDATE(DIG_FIFO_CTRL0, DIG_FIFO_READ_START_LEVEL, 0x7);
        REG_UPDATE(DP_STEER_FIFO, DP_STEER_FIFO_RESET, 1);
        udelay(10);
 
index 0c79802..38aa28e 100644 (file)
@@ -98,7 +98,8 @@ static void optc314_set_odm_combine(struct timing_generator *optc, int *opp_id,
        REG_UPDATE(OPTC_WIDTH_CONTROL,
                        OPTC_SEGMENT_WIDTH, mpcc_hactive);
 
-       REG_SET(OTG_H_TIMING_CNTL, 0, OTG_H_TIMING_DIV_MODE, opp_cnt - 1);
+       REG_UPDATE(OTG_H_TIMING_CNTL,
+                       OTG_H_TIMING_DIV_MODE, opp_cnt - 1);
        optc1->opp_count = opp_cnt;
 }
 
index 85f3220..2a2a4a9 100644 (file)
@@ -454,6 +454,7 @@ static const struct dcn31_hpo_dp_stream_encoder_registers hpo_dp_stream_enc_regs
        hpo_dp_stream_encoder_reg_list(0),
        hpo_dp_stream_encoder_reg_list(1),
        hpo_dp_stream_encoder_reg_list(2),
+       hpo_dp_stream_encoder_reg_list(3)
 };
 
 static const struct dcn31_hpo_dp_stream_encoder_shift hpo_dp_se_shift = {
@@ -1750,6 +1751,7 @@ static bool dcn314_resource_construct(
        dc->caps.post_blend_color_processing = true;
        dc->caps.force_dp_tps4_for_cp2520 = true;
        dc->caps.dp_hpo = true;
+       dc->caps.dp_hdmi21_pcon_support = true;
        dc->caps.edp_dsc_support = true;
        dc->caps.extended_aux_timeout_support = true;
        dc->caps.dmcub_support = true;
index a31c64b..0d5e8a4 100644 (file)
@@ -225,19 +225,19 @@ void dccg32_set_dpstreamclk(
        case 0:
                REG_UPDATE_2(DPSTREAMCLK_CNTL,
                             DPSTREAMCLK0_EN,
-                            (src == REFCLK) ? 0 : 1, DPSTREAMCLK0_SRC_SEL, 0);
+                            (src == REFCLK) ? 0 : 1, DPSTREAMCLK0_SRC_SEL, otg_inst);
                break;
        case 1:
                REG_UPDATE_2(DPSTREAMCLK_CNTL, DPSTREAMCLK1_EN,
-                            (src == REFCLK) ? 0 : 1, DPSTREAMCLK1_SRC_SEL, 1);
+                            (src == REFCLK) ? 0 : 1, DPSTREAMCLK1_SRC_SEL, otg_inst);
                break;
        case 2:
                REG_UPDATE_2(DPSTREAMCLK_CNTL, DPSTREAMCLK2_EN,
-                            (src == REFCLK) ? 0 : 1, DPSTREAMCLK2_SRC_SEL, 2);
+                            (src == REFCLK) ? 0 : 1, DPSTREAMCLK2_SRC_SEL, otg_inst);
                break;
        case 3:
                REG_UPDATE_2(DPSTREAMCLK_CNTL, DPSTREAMCLK3_EN,
-                            (src == REFCLK) ? 0 : 1, DPSTREAMCLK3_SRC_SEL, 3);
+                            (src == REFCLK) ? 0 : 1, DPSTREAMCLK3_SRC_SEL, otg_inst);
                break;
        default:
                BREAK_TO_DEBUGGER();
index 26648ce..38a4898 100644 (file)
@@ -310,6 +310,11 @@ static void enc32_stream_encoder_dp_unblank(
        // TODO: Confirm if we need to wait for DIG_SYMCLK_FE_ON
        REG_WAIT(DIG_FE_CNTL, DIG_SYMCLK_FE_ON, 1, 10, 5000);
 
+       /* read start level = 0 will bring underflow / overflow and DIG_FIFO_ERROR = 1
+        * so set it to 1/2 full = 7 before reset as suggested by hardware team.
+        */
+       REG_UPDATE(DIG_FIFO_CTRL0, DIG_FIFO_READ_START_LEVEL, 0x7);
+
        REG_UPDATE(DIG_FIFO_CTRL0, DIG_FIFO_RESET, 1);
 
        REG_WAIT(DIG_FIFO_CTRL0, DIG_FIFO_RESET_DONE, 1, 10, 5000);
index ebd3945..8d9d96c 100644 (file)
@@ -295,24 +295,38 @@ static uint32_t dcn32_calculate_cab_allocation(struct dc *dc, struct dc_state *c
                }
 
                // Include cursor size for CAB allocation
-               if (stream->cursor_position.enable && plane->address.grph.cursor_cache_addr.quad_part) {
-                       cursor_size = dc->caps.max_cursor_size * dc->caps.max_cursor_size;
-                       switch (stream->cursor_attributes.color_format) {
-                       case CURSOR_MODE_MONO:
-                               cursor_size /= 2;
-                               break;
-                       case CURSOR_MODE_COLOR_1BIT_AND:
-                       case CURSOR_MODE_COLOR_PRE_MULTIPLIED_ALPHA:
-                       case CURSOR_MODE_COLOR_UN_PRE_MULTIPLIED_ALPHA:
-                               cursor_size *= 4;
-                               break;
+               for (j = 0; j < dc->res_pool->pipe_count; j++) {
+                       struct pipe_ctx *pipe = &ctx->res_ctx.pipe_ctx[j];
+                       struct hubp *hubp = pipe->plane_res.hubp;
 
-                       case CURSOR_MODE_COLOR_64BIT_FP_PRE_MULTIPLIED:
-                       case CURSOR_MODE_COLOR_64BIT_FP_UN_PRE_MULTIPLIED:
-                               cursor_size *= 8;
-                               break;
-                       }
-                       cache_lines_used += dcn32_cache_lines_for_surface(dc, surface_size,
+                       if (pipe->stream && pipe->plane_state && hubp)
+                               /* Find the cursor plane and use the exact size instead of
+                                * using the max for calculation
+                                */
+                               if (hubp->curs_attr.width > 0) {
+                                       cursor_size = hubp->curs_attr.width * hubp->curs_attr.height;
+                                       break;
+                               }
+               }
+
+               switch (stream->cursor_attributes.color_format) {
+               case CURSOR_MODE_MONO:
+                       cursor_size /= 2;
+                       break;
+               case CURSOR_MODE_COLOR_1BIT_AND:
+               case CURSOR_MODE_COLOR_PRE_MULTIPLIED_ALPHA:
+               case CURSOR_MODE_COLOR_UN_PRE_MULTIPLIED_ALPHA:
+                       cursor_size *= 4;
+                       break;
+
+               case CURSOR_MODE_COLOR_64BIT_FP_PRE_MULTIPLIED:
+               case CURSOR_MODE_COLOR_64BIT_FP_UN_PRE_MULTIPLIED:
+                       cursor_size *= 8;
+                       break;
+               }
+
+               if (stream->cursor_position.enable && plane->address.grph.cursor_cache_addr.quad_part) {
+                       cache_lines_used += dcn32_cache_lines_for_surface(dc, cursor_size,
                                        plane->address.grph.cursor_cache_addr.quad_part);
                }
        }
@@ -325,6 +339,26 @@ static uint32_t dcn32_calculate_cab_allocation(struct dc *dc, struct dc_state *c
        if (cache_lines_used % lines_per_way > 0)
                num_ways++;
 
+       for (i = 0; i < ctx->stream_count; i++) {
+               stream = ctx->streams[i];
+               for (j = 0; j < ctx->stream_status[i].plane_count; j++) {
+                       plane = ctx->stream_status[i].plane_states[j];
+
+                       if (stream->cursor_position.enable && plane &&
+                               !plane->address.grph.cursor_cache_addr.quad_part &&
+                               cursor_size > 16384) {
+                               /* Cursor caching is not supported since it won't be on the same line.
+                                * So we need an extra line to accommodate it. With large cursors and a single 4k monitor
+                                * this case triggers corruption. If we're at the edge, then dont trigger display refresh
+                                * from MALL. We only need to cache cursor if its greater that 64x64 at 4 bpp.
+                                */
+                               num_ways++;
+                               /* We only expect one cursor plane */
+                               break;
+                       }
+               }
+       }
+
        return num_ways;
 }
 
index 955f52e..ab918fe 100644 (file)
@@ -144,7 +144,7 @@ bool dcn32_all_pipes_have_stream_and_plane(struct dc *dc,
                struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
 
                if (!pipe->stream)
-                       continue;
+                       return false;
 
                if (!pipe->plane_state)
                        return false;
index 8118cfc..8e4c9d0 100644 (file)
@@ -1014,6 +1014,15 @@ static void dcn32_full_validate_bw_helper(struct dc *dc,
            dc->debug.force_subvp_mclk_switch)) {
 
                dcn32_merge_pipes_for_subvp(dc, context);
+               // to re-initialize viewport after the pipe merge
+               for (int i = 0; i < dc->res_pool->pipe_count; i++) {
+                       struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
+
+                       if (!pipe_ctx->plane_state || !pipe_ctx->stream)
+                               continue;
+
+                       resource_build_scaling_params(pipe_ctx);
+               }
 
                while (!found_supported_config && dcn32_enough_pipes_for_subvp(dc, context) &&
                        dcn32_assign_subvp_pipe(dc, context, &dc_pipe_idx)) {
index db7b0b1..226af06 100644 (file)
@@ -116,7 +116,7 @@ static void setup_hpo_dp_stream_encoder(struct pipe_ctx *pipe_ctx)
        dto_params.timing = &pipe_ctx->stream->timing;
        dto_params.ref_dtbclk_khz = dc->clk_mgr->funcs->get_dtb_ref_clk_frequency(dc->clk_mgr);
 
-       dccg->funcs->set_dpstreamclk(dccg, DTBCLK0, tg->inst, link_enc->inst);
+       dccg->funcs->set_dpstreamclk(dccg, DTBCLK0, tg->inst, stream_enc->inst);
        dccg->funcs->enable_symclk32_se(dccg, stream_enc->inst, phyd32clk);
        dccg->funcs->set_dtbclk_dto(dccg, &dto_params);
        stream_enc->funcs->enable_stream(stream_enc);
@@ -137,7 +137,7 @@ static void reset_hpo_dp_stream_encoder(struct pipe_ctx *pipe_ctx)
        stream_enc->funcs->disable(stream_enc);
        dccg->funcs->set_dtbclk_dto(dccg, &dto_params);
        dccg->funcs->disable_symclk32_se(dccg, stream_enc->inst);
-       dccg->funcs->set_dpstreamclk(dccg, REFCLK, tg->inst,  pipe_ctx->link_res.hpo_dp_link_enc->inst);
+       dccg->funcs->set_dpstreamclk(dccg, REFCLK, tg->inst, stream_enc->inst);
 }
 
 static void setup_hpo_dp_stream_attribute(struct pipe_ctx *pipe_ctx)
index 2ed9579..cf8d60c 100644 (file)
 #define regBIF0_PCIE_TX_TRACKING_ADDR_HI_BASE_IDX                                                       5
 #define regBIF0_PCIE_TX_TRACKING_CTRL_STATUS                                                            0x420186
 #define regBIF0_PCIE_TX_TRACKING_CTRL_STATUS_BASE_IDX                                                   5
+#define regBIF0_PCIE_TX_POWER_CTRL_1                                                                    0x420187
+#define regBIF0_PCIE_TX_POWER_CTRL_1_BASE_IDX                                                           5
 #define regBIF0_PCIE_TX_CTRL_4                                                                          0x42018b
 #define regBIF0_PCIE_TX_CTRL_4_BASE_IDX                                                                 5
 #define regBIF0_PCIE_TX_STATUS                                                                          0x420194
index eb62a18..3d60c9e 100644 (file)
 #define BIF0_PCIE_TX_TRACKING_CTRL_STATUS__TX_TRACKING_PORT_MASK                                              0x0000000EL
 #define BIF0_PCIE_TX_TRACKING_CTRL_STATUS__TX_TRACKING_UNIT_ID_MASK                                           0x00007F00L
 #define BIF0_PCIE_TX_TRACKING_CTRL_STATUS__TX_TRACKING_STATUS_VALID_MASK                                      0x00008000L
+//BIF0_PCIE_TX_POWER_CTRL_1
+#define BIF0_PCIE_TX_POWER_CTRL_1__MST_MEM_LS_EN__SHIFT                                                       0x0
+#define BIF0_PCIE_TX_POWER_CTRL_1__MST_MEM_DS_EN__SHIFT                                                       0x1
+#define BIF0_PCIE_TX_POWER_CTRL_1__MST_MEM_SD_EN__SHIFT                                                       0x2
+#define BIF0_PCIE_TX_POWER_CTRL_1__REPLAY_MEM_LS_EN__SHIFT                                                    0x3
+#define BIF0_PCIE_TX_POWER_CTRL_1__REPLAY_MEM_DS_EN__SHIFT                                                    0x4
+#define BIF0_PCIE_TX_POWER_CTRL_1__REPLAY_MEM_SD_EN__SHIFT                                                    0x5
+#define BIF0_PCIE_TX_POWER_CTRL_1__MST_MEM_LS_EN_MASK                                                         0x00000001L
+#define BIF0_PCIE_TX_POWER_CTRL_1__MST_MEM_DS_EN_MASK                                                         0x00000002L
+#define BIF0_PCIE_TX_POWER_CTRL_1__MST_MEM_SD_EN_MASK                                                         0x00000004L
+#define BIF0_PCIE_TX_POWER_CTRL_1__REPLAY_MEM_LS_EN_MASK                                                      0x00000008L
+#define BIF0_PCIE_TX_POWER_CTRL_1__REPLAY_MEM_DS_EN_MASK                                                      0x00000010L
+#define BIF0_PCIE_TX_POWER_CTRL_1__REPLAY_MEM_SD_EN_MASK                                                      0x00000020L
 //BIF0_PCIE_TX_CTRL_4
 #define BIF0_PCIE_TX_CTRL_4__TX_PORT_ACCESS_TIMER_SKEW__SHIFT                                                 0x0
 #define BIF0_PCIE_TX_CTRL_4__TX_PORT_ACCESS_TIMER_SKEW_MASK                                                   0x0000000FL
index 80dab11..50bfa51 100644 (file)
@@ -268,7 +268,8 @@ union MESAPI__ADD_QUEUE {
                        uint32_t is_tmz_queue           : 1;
                        uint32_t map_kiq_utility_queue  : 1;
                        uint32_t is_kfd_process         : 1;
-                       uint32_t reserved               : 22;
+                       uint32_t trap_en                : 1;
+                       uint32_t reserved               : 21;
                };
                struct MES_API_STATUS           api_status;
                uint64_t                        tma_addr;
index 78620b0..063f4a7 100644 (file)
 #ifndef SMU13_DRIVER_IF_V13_0_0_H
 #define SMU13_DRIVER_IF_V13_0_0_H
 
-// *** IMPORTANT ***
-// PMFW TEAM: Always increment the interface version on any change to this file
-#define SMU13_DRIVER_IF_VERSION  0x23
-
 //Increment this version if SkuTable_t or BoardTable_t change
-#define PPTABLE_VERSION 0x1D
+#define PPTABLE_VERSION 0x24
 
 #define NUM_GFXCLK_DPM_LEVELS    16
 #define NUM_SOCCLK_DPM_LEVELS    8
@@ -1193,8 +1189,17 @@ typedef struct {
   // SECTION: Advanced Options
   uint32_t          DebugOverrides;
 
+  // Section: Total Board Power idle vs active coefficients
+  uint8_t     TotalBoardPowerSupport;
+  uint8_t     TotalBoardPowerPadding[3];
+
+  int16_t     TotalIdleBoardPowerM;
+  int16_t     TotalIdleBoardPowerB;
+  int16_t     TotalBoardPowerM;
+  int16_t     TotalBoardPowerB;
+
   // SECTION: Sku Reserved
-  uint32_t         Spare[64];
+  uint32_t         Spare[61];
 
   // Padding for MMHUB - do not modify this
   uint32_t     MmHubPadding[8];
@@ -1259,7 +1264,8 @@ typedef struct {
   // SECTION: Clock Spread Spectrum
 
   // UCLK Spread Spectrum
-  uint16_t     UclkSpreadPadding;
+  uint8_t      UclkTrainingModeSpreadPercent;
+  uint8_t      UclkSpreadPadding;
   uint16_t     UclkSpreadFreq;      // kHz
 
   // UCLK Spread Spectrum
@@ -1272,11 +1278,7 @@ typedef struct {
 
   // Section: Memory Config
   uint8_t      DramWidth; // Width of interface to the channel for each DRAM module. See DRAM_BIT_WIDTH_TYPE_e
-  uint8_t      PaddingMem1[3];
-
-  // Section: Total Board Power
-  uint16_t     TotalBoardPower;     //Only needed for TCP Estimated case, where TCP = TGP+Total Board Power
-  uint16_t     BoardPowerPadding;
+  uint8_t      PaddingMem1[7];
 
   // SECTION: UMC feature flags
   uint8_t      HsrEnabled;
@@ -1375,8 +1377,11 @@ typedef struct {
   uint16_t Vcn1ActivityPercentage  ;
 
   uint32_t EnergyAccumulator;
-  uint16_t AverageSocketPower    ;
+  uint16_t AverageSocketPower;
+  uint16_t AverageTotalBoardPower;
+
   uint16_t AvgTemperature[TEMP_COUNT];
+  uint16_t TempPadding;
 
   uint8_t  PcieRate               ;
   uint8_t  PcieWidth              ;
index 6fe2fe9..f442bf0 100644 (file)
@@ -30,7 +30,7 @@
 #define SMU13_DRIVER_IF_VERSION_ALDE 0x08
 #define SMU13_DRIVER_IF_VERSION_SMU_V13_0_4 0x05
 #define SMU13_DRIVER_IF_VERSION_SMU_V13_0_5 0x04
-#define SMU13_DRIVER_IF_VERSION_SMU_V13_0_0 0x2C
+#define SMU13_DRIVER_IF_VERSION_SMU_V13_0_0 0x30
 #define SMU13_DRIVER_IF_VERSION_SMU_V13_0_7 0x2C
 
 #define SMU13_MODE1_RESET_WAIT_TIME_IN_MS 500  //500ms
@@ -291,5 +291,11 @@ int smu_v13_0_set_default_dpm_tables(struct smu_context *smu);
 void smu_v13_0_set_smu_mailbox_registers(struct smu_context *smu);
 
 int smu_v13_0_mode1_reset(struct smu_context *smu);
+
+int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu,
+                                       void **table,
+                                       uint32_t *size,
+                                       uint32_t pptable_id);
+
 #endif
 #endif
index 18ee3b5..24488f4 100644 (file)
@@ -84,9 +84,6 @@ MODULE_FIRMWARE("amdgpu/smu_13_0_7.bin");
 static const int link_width[] = {0, 1, 2, 4, 8, 12, 16};
 static const int link_speed[] = {25, 50, 80, 160};
 
-static int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, void **table, uint32_t *size,
-                                              uint32_t pptable_id);
-
 int smu_v13_0_init_microcode(struct smu_context *smu)
 {
        struct amdgpu_device *adev = smu->adev;
@@ -224,23 +221,19 @@ int smu_v13_0_init_pptable_microcode(struct smu_context *smu)
 
                /*
                 * Temporary solution for SMU V13.0.0 with SCPM enabled:
-                *   - use 36831 signed pptable when pp_table_id is 3683
-                *   - use 37151 signed pptable when pp_table_id is 3715
-                *   - use 36641 signed pptable when pp_table_id is 3664 or 0
-                * TODO: drop these when the pptable carried in vbios is ready.
+                *   - use vbios carried pptable when pptable_id is 3664, 3715 or 3795
+                *   - use 36831 soft pptable when pptable_id is 3683
                 */
                if (adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 0)) {
                        switch (pptable_id) {
-                       case 0:
                        case 3664:
-                               pptable_id = 36641;
+                       case 3715:
+                       case 3795:
+                               pptable_id = 0;
                                break;
                        case 3683:
                                pptable_id = 36831;
                                break;
-                       case 3715:
-                               pptable_id = 37151;
-                               break;
                        default:
                                dev_err(adev->dev, "Unsupported pptable id %d\n", pptable_id);
                                return -EINVAL;
@@ -425,8 +418,10 @@ static int smu_v13_0_get_pptable_from_vbios(struct smu_context *smu, void **tabl
        return 0;
 }
 
-static int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, void **table, uint32_t *size,
-                                              uint32_t pptable_id)
+int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu,
+                                       void **table,
+                                       uint32_t *size,
+                                       uint32_t pptable_id)
 {
        const struct smc_firmware_header_v1_0 *hdr;
        struct amdgpu_device *adev = smu->adev;
index df4a47a..7db2fd9 100644 (file)
@@ -388,11 +388,29 @@ static int smu_v13_0_0_append_powerplay_table(struct smu_context *smu)
        return 0;
 }
 
-static int smu_v13_0_0_setup_pptable(struct smu_context *smu)
+static int smu_v13_0_0_get_pptable_from_pmfw(struct smu_context *smu,
+                                            void **table,
+                                            uint32_t *size)
 {
        struct smu_table_context *smu_table = &smu->smu_table;
        void *combo_pptable = smu_table->combo_pptable;
+       int ret = 0;
+
+       ret = smu_cmn_get_combo_pptable(smu);
+       if (ret)
+               return ret;
+
+       *table = combo_pptable;
+       *size = sizeof(struct smu_13_0_0_powerplay_table);
+
+       return 0;
+}
+
+static int smu_v13_0_0_setup_pptable(struct smu_context *smu)
+{
+       struct smu_table_context *smu_table = &smu->smu_table;
        struct amdgpu_device *adev = smu->adev;
+       uint32_t pptable_id;
        int ret = 0;
 
        /*
@@ -401,17 +419,51 @@ static int smu_v13_0_0_setup_pptable(struct smu_context *smu)
         * rely on the combo pptable(and its revelant SMU message).
         */
        if (adev->scpm_enabled) {
-               ret = smu_cmn_get_combo_pptable(smu);
-               if (ret)
-                       return ret;
-
-               smu->smu_table.power_play_table = combo_pptable;
-               smu->smu_table.power_play_table_size = sizeof(struct smu_13_0_0_powerplay_table);
+               ret = smu_v13_0_0_get_pptable_from_pmfw(smu,
+                                                       &smu_table->power_play_table,
+                                                       &smu_table->power_play_table_size);
        } else {
-               ret = smu_v13_0_setup_pptable(smu);
-               if (ret)
-                       return ret;
+               /* override pptable_id from driver parameter */
+               if (amdgpu_smu_pptable_id >= 0) {
+                       pptable_id = amdgpu_smu_pptable_id;
+                       dev_info(adev->dev, "override pptable id %d\n", pptable_id);
+               } else {
+                       pptable_id = smu_table->boot_values.pp_table_id;
+               }
+
+               /*
+                * Temporary solution for SMU V13.0.0 with SCPM disabled:
+                *   - use vbios carried pptable when pptable_id is 3664, 3715 or 3795
+                *   - use soft pptable when pptable_id is 3683
+                */
+               if (adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 0)) {
+                       switch (pptable_id) {
+                       case 3664:
+                       case 3715:
+                       case 3795:
+                               pptable_id = 0;
+                               break;
+                       case 3683:
+                               break;
+                       default:
+                               dev_err(adev->dev, "Unsupported pptable id %d\n", pptable_id);
+                               return -EINVAL;
+                       }
+               }
+
+               /* force using vbios pptable in sriov mode */
+               if ((amdgpu_sriov_vf(adev) || !pptable_id) && (amdgpu_emu_mode != 1))
+                       ret = smu_v13_0_0_get_pptable_from_pmfw(smu,
+                                                               &smu_table->power_play_table,
+                                                               &smu_table->power_play_table_size);
+               else
+                       ret = smu_v13_0_get_pptable_from_firmware(smu,
+                                                                 &smu_table->power_play_table,
+                                                                 &smu_table->power_play_table_size,
+                                                                 pptable_id);
        }
+       if (ret)
+               return ret;
 
        ret = smu_v13_0_0_store_powerplay_table(smu);
        if (ret)
index 1016d1c..fcf24c5 100644 (file)
@@ -400,11 +400,27 @@ static int smu_v13_0_7_append_powerplay_table(struct smu_context *smu)
        return 0;
 }
 
+static int smu_v13_0_7_get_pptable_from_pmfw(struct smu_context *smu,
+                                            void **table,
+                                            uint32_t *size)
+{
+       struct smu_table_context *smu_table = &smu->smu_table;
+       void *combo_pptable = smu_table->combo_pptable;
+       int ret = 0;
+
+       ret = smu_cmn_get_combo_pptable(smu);
+       if (ret)
+               return ret;
+
+       *table = combo_pptable;
+       *size = sizeof(struct smu_13_0_7_powerplay_table);
+
+       return 0;
+}
 
 static int smu_v13_0_7_setup_pptable(struct smu_context *smu)
 {
        struct smu_table_context *smu_table = &smu->smu_table;
-       void *combo_pptable = smu_table->combo_pptable;
        struct amdgpu_device *adev = smu->adev;
        int ret = 0;
 
@@ -413,18 +429,11 @@ static int smu_v13_0_7_setup_pptable(struct smu_context *smu)
         * be used directly by driver. To get the raw pptable, we need to
         * rely on the combo pptable(and its revelant SMU message).
         */
-       if (adev->scpm_enabled) {
-               ret = smu_cmn_get_combo_pptable(smu);
-               if (ret)
-                       return ret;
-
-               smu->smu_table.power_play_table = combo_pptable;
-               smu->smu_table.power_play_table_size = sizeof(struct smu_13_0_7_powerplay_table);
-       } else {
-               ret = smu_v13_0_setup_pptable(smu);
-               if (ret)
-                       return ret;
-       }
+       ret = smu_v13_0_7_get_pptable_from_pmfw(smu,
+                                               &smu_table->power_play_table,
+                                               &smu_table->power_play_table_size);
+       if (ret)
+               return ret;
 
        ret = smu_v13_0_7_store_powerplay_table(smu);
        if (ret)
index 86d670c..ad06886 100644 (file)
@@ -168,21 +168,6 @@ void drm_gem_private_object_init(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_gem_private_object_init);
 
-static void
-drm_gem_remove_prime_handles(struct drm_gem_object *obj, struct drm_file *filp)
-{
-       /*
-        * Note: obj->dma_buf can't disappear as long as we still hold a
-        * handle reference in obj->handle_count.
-        */
-       mutex_lock(&filp->prime.lock);
-       if (obj->dma_buf) {
-               drm_prime_remove_buf_handle_locked(&filp->prime,
-                                                  obj->dma_buf);
-       }
-       mutex_unlock(&filp->prime.lock);
-}
-
 /**
  * drm_gem_object_handle_free - release resources bound to userspace handles
  * @obj: GEM object to clean up.
@@ -253,7 +238,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
        if (obj->funcs->close)
                obj->funcs->close(obj, file_priv);
 
-       drm_gem_remove_prime_handles(obj, file_priv);
+       drm_prime_remove_buf_handle(&file_priv->prime, id);
        drm_vma_node_revoke(&obj->vma_node, file_priv);
 
        drm_gem_object_handle_put_unlocked(obj);
index 1fbbc19..7bb98e6 100644 (file)
@@ -74,8 +74,8 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
 
 void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
 void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
-void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv,
-                                       struct dma_buf *dma_buf);
+void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
+                                uint32_t handle);
 
 /* drm_drv.c */
 struct drm_minor *drm_minor_acquire(unsigned int minor_id);
index a3f1806..eb09e86 100644 (file)
@@ -190,29 +190,33 @@ static int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpri
        return -ENOENT;
 }
 
-void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv,
-                                       struct dma_buf *dma_buf)
+void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
+                                uint32_t handle)
 {
        struct rb_node *rb;
 
-       rb = prime_fpriv->dmabufs.rb_node;
+       mutex_lock(&prime_fpriv->lock);
+
+       rb = prime_fpriv->handles.rb_node;
        while (rb) {
                struct drm_prime_member *member;
 
-               member = rb_entry(rb, struct drm_prime_member, dmabuf_rb);
-               if (member->dma_buf == dma_buf) {
+               member = rb_entry(rb, struct drm_prime_member, handle_rb);
+               if (member->handle == handle) {
                        rb_erase(&member->handle_rb, &prime_fpriv->handles);
                        rb_erase(&member->dmabuf_rb, &prime_fpriv->dmabufs);
 
-                       dma_buf_put(dma_buf);
+                       dma_buf_put(member->dma_buf);
                        kfree(member);
-                       return;
-               } else if (member->dma_buf < dma_buf) {
+                       break;
+               } else if (member->handle < handle) {
                        rb = rb->rb_right;
                } else {
                        rb = rb->rb_left;
                }
        }
+
+       mutex_unlock(&prime_fpriv->lock);
 }
 
 void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv)
index 5dcfa7f..885c74f 100644 (file)
@@ -2070,7 +2070,14 @@ void icl_dsi_init(struct drm_i915_private *dev_priv)
        else
                intel_dsi->ports = BIT(port);
 
+       if (drm_WARN_ON(&dev_priv->drm, intel_connector->panel.vbt.dsi.bl_ports & ~intel_dsi->ports))
+               intel_connector->panel.vbt.dsi.bl_ports &= intel_dsi->ports;
+
        intel_dsi->dcs_backlight_ports = intel_connector->panel.vbt.dsi.bl_ports;
+
+       if (drm_WARN_ON(&dev_priv->drm, intel_connector->panel.vbt.dsi.cabc_ports & ~intel_dsi->ports))
+               intel_connector->panel.vbt.dsi.cabc_ports &= intel_dsi->ports;
+
        intel_dsi->dcs_cabc_ports = intel_connector->panel.vbt.dsi.cabc_ports;
 
        for_each_dsi_port(port, intel_dsi->ports) {
index 110fc98..f5e1d69 100644 (file)
@@ -16,6 +16,7 @@
 #include "intel_dsi_dcs_backlight.h"
 #include "intel_panel.h"
 #include "intel_pci_config.h"
+#include "intel_pps.h"
 
 /**
  * scale - scale values from one range to another
@@ -971,26 +972,24 @@ int intel_backlight_device_register(struct intel_connector *connector)
        if (!name)
                return -ENOMEM;
 
-       bd = backlight_device_register(name, connector->base.kdev, connector,
-                                      &intel_backlight_device_ops, &props);
-
-       /*
-        * Using the same name independent of the drm device or connector
-        * prevents registration of multiple backlight devices in the
-        * driver. However, we need to use the default name for backward
-        * compatibility. Use unique names for subsequent backlight devices as a
-        * fallback when the default name already exists.
-        */
-       if (IS_ERR(bd) && PTR_ERR(bd) == -EEXIST) {
+       bd = backlight_device_get_by_name(name);
+       if (bd) {
+               put_device(&bd->dev);
+               /*
+                * Using the same name independent of the drm device or connector
+                * prevents registration of multiple backlight devices in the
+                * driver. However, we need to use the default name for backward
+                * compatibility. Use unique names for subsequent backlight devices as a
+                * fallback when the default name already exists.
+                */
                kfree(name);
                name = kasprintf(GFP_KERNEL, "card%d-%s-backlight",
                                 i915->drm.primary->index, connector->base.name);
                if (!name)
                        return -ENOMEM;
-
-               bd = backlight_device_register(name, connector->base.kdev, connector,
-                                              &intel_backlight_device_ops, &props);
        }
+       bd = backlight_device_register(name, connector->base.kdev, connector,
+                                      &intel_backlight_device_ops, &props);
 
        if (IS_ERR(bd)) {
                drm_err(&i915->drm,
@@ -1773,9 +1772,13 @@ void intel_backlight_init_funcs(struct intel_panel *panel)
                panel->backlight.pwm_funcs = &i9xx_pwm_funcs;
        }
 
-       if (connector->base.connector_type == DRM_MODE_CONNECTOR_eDP &&
-           intel_dp_aux_init_backlight_funcs(connector) == 0)
-               return;
+       if (connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) {
+               if (intel_dp_aux_init_backlight_funcs(connector) == 0)
+                       return;
+
+               if (!(dev_priv->quirks & QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK))
+                       connector->panel.backlight.power = intel_pps_backlight_power;
+       }
 
        /* We're using a standard PWM backlight interface */
        panel->backlight.funcs = &pwm_bl_funcs;
index 51dde5b..198a2f4 100644 (file)
@@ -1596,6 +1596,8 @@ static void parse_dsi_backlight_ports(struct drm_i915_private *i915,
                                      struct intel_panel *panel,
                                      enum port port)
 {
+       enum port port_bc = DISPLAY_VER(i915) >= 11 ? PORT_B : PORT_C;
+
        if (!panel->vbt.dsi.config->dual_link || i915->vbt.version < 197) {
                panel->vbt.dsi.bl_ports = BIT(port);
                if (panel->vbt.dsi.config->cabc_supported)
@@ -1609,11 +1611,11 @@ static void parse_dsi_backlight_ports(struct drm_i915_private *i915,
                panel->vbt.dsi.bl_ports = BIT(PORT_A);
                break;
        case DL_DCS_PORT_C:
-               panel->vbt.dsi.bl_ports = BIT(PORT_C);
+               panel->vbt.dsi.bl_ports = BIT(port_bc);
                break;
        default:
        case DL_DCS_PORT_A_AND_C:
-               panel->vbt.dsi.bl_ports = BIT(PORT_A) | BIT(PORT_C);
+               panel->vbt.dsi.bl_ports = BIT(PORT_A) | BIT(port_bc);
                break;
        }
 
@@ -1625,12 +1627,12 @@ static void parse_dsi_backlight_ports(struct drm_i915_private *i915,
                panel->vbt.dsi.cabc_ports = BIT(PORT_A);
                break;
        case DL_DCS_PORT_C:
-               panel->vbt.dsi.cabc_ports = BIT(PORT_C);
+               panel->vbt.dsi.cabc_ports = BIT(port_bc);
                break;
        default:
        case DL_DCS_PORT_A_AND_C:
                panel->vbt.dsi.cabc_ports =
-                                       BIT(PORT_A) | BIT(PORT_C);
+                                       BIT(PORT_A) | BIT(port_bc);
                break;
        }
 }
index 79269d2..3699869 100644 (file)
@@ -404,15 +404,17 @@ static int tgl_get_bw_info(struct drm_i915_private *dev_priv, const struct intel
                int clpchgroup;
                int j;
 
-               if (i < num_groups - 1)
-                       bi_next = &dev_priv->max_bw[i + 1];
-
                clpchgroup = (sa->deburst * qi.deinterleave / num_channels) << i;
 
-               if (i < num_groups - 1 && clpchgroup < clperchgroup)
-                       bi_next->num_planes = (ipqdepth - clpchgroup) / clpchgroup + 1;
-               else
-                       bi_next->num_planes = 0;
+               if (i < num_groups - 1) {
+                       bi_next = &dev_priv->max_bw[i + 1];
+
+                       if (clpchgroup < clperchgroup)
+                               bi_next->num_planes = (ipqdepth - clpchgroup) /
+                                                      clpchgroup + 1;
+                       else
+                               bi_next->num_planes = 0;
+               }
 
                bi->num_qgv_points = qi.num_points;
                bi->num_psf_gv_points = qi.num_psf_points;
index 32292c0..ac90d45 100644 (file)
@@ -5293,8 +5293,6 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
 
        intel_panel_init(intel_connector);
 
-       if (!(dev_priv->quirks & QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK))
-               intel_connector->panel.backlight.power = intel_pps_backlight_power;
        intel_backlight_setup(intel_connector, pipe);
 
        intel_edp_add_properties(intel_dp);
index c8488f5..e415cd7 100644 (file)
@@ -191,6 +191,9 @@ static struct intel_quirk intel_quirks[] = {
        /* ASRock ITX*/
        { 0x3185, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
        { 0x3184, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
+       /* ECS Liva Q2 */
+       { 0x3185, 0x1019, 0xa94d, quirk_increase_ddi_disabled_time },
+       { 0x3184, 0x1019, 0xa94d, quirk_increase_ddi_disabled_time },
 };
 
 void intel_init_quirks(struct drm_i915_private *i915)
index b9b1fed..35136d2 100644 (file)
@@ -1933,7 +1933,14 @@ void vlv_dsi_init(struct drm_i915_private *dev_priv)
        else
                intel_dsi->ports = BIT(port);
 
+       if (drm_WARN_ON(&dev_priv->drm, intel_connector->panel.vbt.dsi.bl_ports & ~intel_dsi->ports))
+               intel_connector->panel.vbt.dsi.bl_ports &= intel_dsi->ports;
+
        intel_dsi->dcs_backlight_ports = intel_connector->panel.vbt.dsi.bl_ports;
+
+       if (drm_WARN_ON(&dev_priv->drm, intel_connector->panel.vbt.dsi.cabc_ports & ~intel_dsi->ports))
+               intel_connector->panel.vbt.dsi.cabc_ports &= intel_dsi->ports;
+
        intel_dsi->dcs_cabc_ports = intel_connector->panel.vbt.dsi.cabc_ports;
 
        /* Create a DSI host (and a device) for each port. */
index 2b10b96..933648c 100644 (file)
@@ -638,9 +638,9 @@ static int emit_copy(struct i915_request *rq,
        return 0;
 }
 
-static int scatter_list_length(struct scatterlist *sg)
+static u64 scatter_list_length(struct scatterlist *sg)
 {
-       int len = 0;
+       u64 len = 0;
 
        while (sg && sg_dma_len(sg)) {
                len += sg_dma_len(sg);
@@ -650,28 +650,26 @@ static int scatter_list_length(struct scatterlist *sg)
        return len;
 }
 
-static void
+static int
 calculate_chunk_sz(struct drm_i915_private *i915, bool src_is_lmem,
-                  int *src_sz, u32 bytes_to_cpy, u32 ccs_bytes_to_cpy)
+                  u64 bytes_to_cpy, u64 ccs_bytes_to_cpy)
 {
-       if (ccs_bytes_to_cpy) {
-               if (!src_is_lmem)
-                       /*
-                        * When CHUNK_SZ is passed all the pages upto CHUNK_SZ
-                        * will be taken for the blt. in Flat-ccs supported
-                        * platform Smem obj will have more pages than required
-                        * for main meory hence limit it to the required size
-                        * for main memory
-                        */
-                       *src_sz = min_t(int, bytes_to_cpy, CHUNK_SZ);
-       } else { /* ccs handling is not required */
-               *src_sz = CHUNK_SZ;
-       }
+       if (ccs_bytes_to_cpy && !src_is_lmem)
+               /*
+                * When CHUNK_SZ is passed all the pages upto CHUNK_SZ
+                * will be taken for the blt. in Flat-ccs supported
+                * platform Smem obj will have more pages than required
+                * for main meory hence limit it to the required size
+                * for main memory
+                */
+               return min_t(u64, bytes_to_cpy, CHUNK_SZ);
+       else
+               return CHUNK_SZ;
 }
 
-static void get_ccs_sg_sgt(struct sgt_dma *it, u32 bytes_to_cpy)
+static void get_ccs_sg_sgt(struct sgt_dma *it, u64 bytes_to_cpy)
 {
-       u32 len;
+       u64 len;
 
        do {
                GEM_BUG_ON(!it->sg || !sg_dma_len(it->sg));
@@ -702,12 +700,12 @@ intel_context_migrate_copy(struct intel_context *ce,
 {
        struct sgt_dma it_src = sg_sgt(src), it_dst = sg_sgt(dst), it_ccs;
        struct drm_i915_private *i915 = ce->engine->i915;
-       u32 ccs_bytes_to_cpy = 0, bytes_to_cpy;
+       u64 ccs_bytes_to_cpy = 0, bytes_to_cpy;
        enum i915_cache_level ccs_cache_level;
        u32 src_offset, dst_offset;
        u8 src_access, dst_access;
        struct i915_request *rq;
-       int src_sz, dst_sz;
+       u64 src_sz, dst_sz;
        bool ccs_is_src, overwrite_ccs;
        int err;
 
@@ -790,8 +788,8 @@ intel_context_migrate_copy(struct intel_context *ce,
                if (err)
                        goto out_rq;
 
-               calculate_chunk_sz(i915, src_is_lmem, &src_sz,
-                                  bytes_to_cpy, ccs_bytes_to_cpy);
+               src_sz = calculate_chunk_sz(i915, src_is_lmem,
+                                           bytes_to_cpy, ccs_bytes_to_cpy);
 
                len = emit_pte(rq, &it_src, src_cache_level, src_is_lmem,
                               src_offset, src_sz);
index 76916ae..834c707 100644 (file)
@@ -4027,6 +4027,13 @@ static inline void guc_init_lrc_mapping(struct intel_guc *guc)
        xa_destroy(&guc->context_lookup);
 
        /*
+        * A reset might have occurred while we had a pending stalled request,
+        * so make sure we clean that up.
+        */
+       guc->stalled_request = NULL;
+       guc->submission_stall_reason = STALL_NONE;
+
+       /*
         * Some contexts might have been pinned before we enabled GuC
         * submission, so we need to add them to the GuC bookeeping.
         * Also, after a reset the of the GuC we want to make sure that the
index 557f331..3b81a6d 100644 (file)
@@ -298,7 +298,7 @@ no_enough_resource:
 }
 
 /**
- * inte_gvt_free_vgpu_resource - free HW resource owned by a vGPU
+ * intel_vgpu_free_resource() - free HW resource owned by a vGPU
  * @vgpu: a vGPU
  *
  * This function is used to free the HW resource owned by a vGPU.
@@ -328,7 +328,7 @@ void intel_vgpu_reset_resource(struct intel_vgpu *vgpu)
 }
 
 /**
- * intel_alloc_vgpu_resource - allocate HW resource for a vGPU
+ * intel_vgpu_alloc_resource() - allocate HW resource for a vGPU
  * @vgpu: vGPU
  * @param: vGPU creation params
  *
index b4f6936..ce0eb03 100644 (file)
@@ -2341,7 +2341,7 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
                        gvt_vgpu_err("fail to populate guest ggtt entry\n");
                        /* guest driver may read/write the entry when partial
                         * update the entry in this situation p2m will fail
-                        * settting the shadow entry to point to a scratch page
+                        * setting the shadow entry to point to a scratch page
                         */
                        ops->set_pfn(&m, gvt->gtt.scratch_mfn);
                } else
index beea589..61423da 100644 (file)
@@ -905,7 +905,7 @@ static int update_fdi_rx_iir_status(struct intel_vgpu *vgpu,
        else if (FDI_RX_IMR_TO_PIPE(offset) != INVALID_INDEX)
                index = FDI_RX_IMR_TO_PIPE(offset);
        else {
-               gvt_vgpu_err("Unsupport registers %x\n", offset);
+               gvt_vgpu_err("Unsupported registers %x\n", offset);
                return -EINVAL;
        }
 
@@ -3052,7 +3052,7 @@ int intel_vgpu_default_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
 }
 
 /**
- * intel_t_default_mmio_write - default MMIO write handler
+ * intel_vgpu_default_mmio_write() - default MMIO write handler
  * @vgpu: a vGPU
  * @offset: access offset
  * @p_data: write data buffer
index c85bafe..1c6e941 100644 (file)
@@ -546,7 +546,7 @@ static void switch_mmio(struct intel_vgpu *pre,
 }
 
 /**
- * intel_gvt_switch_render_mmio - switch mmio context of specific engine
+ * intel_gvt_switch_mmio - switch mmio context of specific engine
  * @pre: the last vGPU that own the engine
  * @next: the vGPU to switch to
  * @engine: the engine
index 157e166..5595639 100644 (file)
@@ -1076,7 +1076,8 @@ static int iterate_skl_plus_mmio(struct intel_gvt_mmio_table_iter *iter)
        MMIO_D(GEN8_HDC_CHICKEN1);
        MMIO_D(GEN9_WM_CHICKEN3);
 
-       if (IS_KABYLAKE(dev_priv) || IS_COFFEELAKE(dev_priv))
+       if (IS_KABYLAKE(dev_priv) ||
+           IS_COFFEELAKE(dev_priv) || IS_COMETLAKE(dev_priv))
                MMIO_D(GAMT_CHKN_BIT_REG);
        if (!IS_BROXTON(dev_priv))
                MMIO_D(GEN9_CTX_PREEMPT_REG);
index f06babd..9fe4b58 100644 (file)
@@ -6561,7 +6561,10 @@ void skl_wm_get_hw_state(struct drm_i915_private *dev_priv)
                enum plane_id plane_id;
                u8 slices;
 
-               skl_pipe_wm_get_hw_state(crtc, &crtc_state->wm.skl.optimal);
+               memset(&crtc_state->wm.skl.optimal, 0,
+                      sizeof(crtc_state->wm.skl.optimal));
+               if (crtc_state->hw.active)
+                       skl_pipe_wm_get_hw_state(crtc, &crtc_state->wm.skl.optimal);
                crtc_state->wm.skl.raw = crtc_state->wm.skl.optimal;
 
                memset(&dbuf_state->ddb[pipe], 0, sizeof(dbuf_state->ddb[pipe]));
@@ -6572,6 +6575,9 @@ void skl_wm_get_hw_state(struct drm_i915_private *dev_priv)
                        struct skl_ddb_entry *ddb_y =
                                &crtc_state->wm.skl.plane_ddb_y[plane_id];
 
+                       if (!crtc_state->hw.active)
+                               continue;
+
                        skl_ddb_get_hw_plane_state(dev_priv, crtc->pipe,
                                                   plane_id, ddb, ddb_y);
 
index c682d4e..52a6261 100644 (file)
@@ -2061,6 +2061,12 @@ void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc)
 
        intf_cfg.stream_sel = 0; /* Don't care value for video mode */
        intf_cfg.mode_3d = dpu_encoder_helper_get_3d_blend_mode(phys_enc);
+
+       if (phys_enc->hw_intf)
+               intf_cfg.intf = phys_enc->hw_intf->idx;
+       if (phys_enc->hw_wb)
+               intf_cfg.wb = phys_enc->hw_wb->idx;
+
        if (phys_enc->hw_pp->merge_3d)
                intf_cfg.merge_3d = phys_enc->hw_pp->merge_3d->idx;
 
index ab6aa13..013ca02 100644 (file)
@@ -1214,7 +1214,7 @@ static int dp_ctrl_link_train_2(struct dp_ctrl_private *ctrl,
        if (ret)
                return ret;
 
-       dp_ctrl_train_pattern_set(ctrl, pattern | DP_RECOVERED_CLOCK_OUT_EN);
+       dp_ctrl_train_pattern_set(ctrl, pattern);
 
        for (tries = 0; tries <= maximum_retries; tries++) {
                drm_dp_link_train_channel_eq_delay(ctrl->aux, ctrl->panel->dpcd);
index 2c23324..72c018e 100644 (file)
@@ -109,7 +109,7 @@ static const char * const dsi_8996_bus_clk_names[] = {
 static const struct msm_dsi_config msm8996_dsi_cfg = {
        .io_offset = DSI_6G_REG_SHIFT,
        .reg_cfg = {
-               .num = 2,
+               .num = 3,
                .regs = {
                        {"vdda", 18160, 1 },    /* 1.25 V */
                        {"vcca", 17000, 32 },   /* 0.925 V */
@@ -148,7 +148,7 @@ static const char * const dsi_sdm660_bus_clk_names[] = {
 static const struct msm_dsi_config sdm660_dsi_cfg = {
        .io_offset = DSI_6G_REG_SHIFT,
        .reg_cfg = {
-               .num = 2,
+               .num = 1,
                .regs = {
                        {"vdda", 12560, 4 },    /* 1.2 V */
                },
index a39de3b..56dfa2d 100644 (file)
@@ -347,7 +347,7 @@ int msm_dsi_dphy_timing_calc_v3(struct msm_dsi_dphy_timing *timing,
        } else {
                timing->shared_timings.clk_pre =
                        linear_inter(tmax, tmin, pcnt2, 0, false);
-                       timing->shared_timings.clk_pre_inc_by_2 = 0;
+               timing->shared_timings.clk_pre_inc_by_2 = 0;
        }
 
        timing->ta_go = 3;
index 1ed4cd0..16884db 100644 (file)
@@ -469,6 +469,8 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
                }
        }
 
+       drm_helper_move_panel_connectors_to_head(ddev);
+
        ddev->mode_config.funcs = &mode_config_funcs;
        ddev->mode_config.helper_private = &mode_config_helper_funcs;
 
index d1f7042..85c443a 100644 (file)
@@ -213,6 +213,8 @@ void msm_devfreq_init(struct msm_gpu *gpu)
 
        if (IS_ERR(df->devfreq)) {
                DRM_DEV_ERROR(&gpu->pdev->dev, "Couldn't initialize GPU devfreq\n");
+               dev_pm_qos_remove_request(&df->idle_freq);
+               dev_pm_qos_remove_request(&df->boost_freq);
                df->devfreq = NULL;
                return;
        }
index a92ffde..db2f847 100644 (file)
@@ -196,6 +196,9 @@ static int rd_open(struct inode *inode, struct file *file)
        file->private_data = rd;
        rd->open = true;
 
+       /* Reset fifo to clear any previously unread data: */
+       rd->fifo.head = rd->fifo.tail = 0;
+
        /* the parsing tools need to know gpu-id to know which
         * register database to load.
         *
index 05076e5..e29175e 100644 (file)
@@ -820,6 +820,15 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict,
                if (ret == 0) {
                        ret = nouveau_fence_new(chan, false, &fence);
                        if (ret == 0) {
+                               /* TODO: figure out a better solution here
+                                *
+                                * wait on the fence here explicitly as going through
+                                * ttm_bo_move_accel_cleanup somehow doesn't seem to do it.
+                                *
+                                * Without this the operation can timeout and we'll fallback to a
+                                * software copy, which might take several minutes to finish.
+                                */
+                               nouveau_fence_wait(fence, false, false);
                                ret = ttm_bo_move_accel_cleanup(bo,
                                                                &fence->base,
                                                                evict, false,
index 2b12389..ee01656 100644 (file)
@@ -1605,6 +1605,9 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,
                if (r) {
                        /* delay GPU reset to resume */
                        radeon_fence_driver_force_completion(rdev, i);
+               } else {
+                       /* finish executing delayed work */
+                       flush_delayed_work(&rdev->fence_drv[i].lockup_work);
                }
        }
 
index 061be9a..b0f3117 100644 (file)
@@ -8,6 +8,7 @@ config DRM_VC4
        depends on DRM
        depends on SND && SND_SOC
        depends on COMMON_CLK
+       depends on PM
        select DRM_DISPLAY_HDMI_HELPER
        select DRM_DISPLAY_HELPER
        select DRM_KMS_HELPER
index 592c3b5..1e5f687 100644 (file)
@@ -2855,7 +2855,7 @@ static int vc5_hdmi_init_resources(struct vc4_hdmi *vc4_hdmi)
        return 0;
 }
 
-static int __maybe_unused vc4_hdmi_runtime_suspend(struct device *dev)
+static int vc4_hdmi_runtime_suspend(struct device *dev)
 {
        struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev);
 
@@ -2972,17 +2972,15 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
                        vc4_hdmi->disable_4kp60 = true;
        }
 
+       pm_runtime_enable(dev);
+
        /*
-        * We need to have the device powered up at this point to call
-        * our reset hook and for the CEC init.
+        *  We need to have the device powered up at this point to call
+        *  our reset hook and for the CEC init.
         */
-       ret = vc4_hdmi_runtime_resume(dev);
+       ret = pm_runtime_resume_and_get(dev);
        if (ret)
-               goto err_put_ddc;
-
-       pm_runtime_get_noresume(dev);
-       pm_runtime_set_active(dev);
-       pm_runtime_enable(dev);
+               goto err_disable_runtime_pm;
 
        if ((of_device_is_compatible(dev->of_node, "brcm,bcm2711-hdmi0") ||
             of_device_is_compatible(dev->of_node, "brcm,bcm2711-hdmi1")) &&
@@ -3028,6 +3026,7 @@ err_destroy_conn:
 err_destroy_encoder:
        drm_encoder_cleanup(encoder);
        pm_runtime_put_sync(dev);
+err_disable_runtime_pm:
        pm_runtime_disable(dev);
 err_put_ddc:
        put_device(&vc4_hdmi->ddc->dev);
index 4b90c86..47774b9 100644 (file)
@@ -288,11 +288,29 @@ int amd_sfh_irq_init(struct amd_mp2_dev *privdata)
        return 0;
 }
 
+static const struct dmi_system_id dmi_nodevs[] = {
+       {
+               /*
+                * Google Chromebooks use Chrome OS Embedded Controller Sensor
+                * Hub instead of Sensor Hub Fusion and leaves MP2
+                * uninitialized, which disables all functionalities, even
+                * including the registers necessary for feature detections.
+                */
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Google"),
+               },
+       },
+       { }
+};
+
 static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
        struct amd_mp2_dev *privdata;
        int rc;
 
+       if (dmi_first_match(dmi_nodevs))
+               return -ENODEV;
+
        privdata = devm_kzalloc(&pdev->dev, sizeof(*privdata), GFP_KERNEL);
        if (!privdata)
                return -ENOMEM;
index 08c9a9a..b59c3da 100644 (file)
@@ -1212,6 +1212,13 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
                rdesc = new_rdesc;
        }
 
+       if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD &&
+                       *rsize == 331 && rdesc[190] == 0x85 && rdesc[191] == 0x5a &&
+                       rdesc[204] == 0x95 && rdesc[205] == 0x05) {
+               hid_info(hdev, "Fixing up Asus N-KEY keyb report descriptor\n");
+               rdesc[205] = 0x01;
+       }
+
        return rdesc;
 }
 
index 0fb720a..f80d619 100644 (file)
 #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021   0x029c
 #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021   0x029a
 #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021   0x029f
+#define USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT 0x8102
+#define USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY 0x8302
 
 #define USB_VENDOR_ID_ASUS             0x0486
 #define USB_DEVICE_ID_ASUS_T91MT       0x0185
 #define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN   0x2706
 #define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN   0x261A
 #define I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN  0x2A1C
+#define I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN     0x279F
 
 #define USB_VENDOR_ID_ELECOM           0x056e
 #define USB_DEVICE_ID_ELECOM_BM084     0x0061
index 48c1c02..859aeb0 100644 (file)
@@ -383,6 +383,8 @@ static const struct hid_device_id hid_battery_quirks[] = {
          HID_BATTERY_QUIRK_IGNORE },
        { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN),
          HID_BATTERY_QUIRK_IGNORE },
+       { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN),
+         HID_BATTERY_QUIRK_IGNORE },
        {}
 };
 
@@ -1532,7 +1534,10 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
                         * assume ours
                         */
                        if (!report->tool)
-                               hid_report_set_tool(report, input, usage->code);
+                               report->tool = usage->code;
+
+                       /* drivers may have changed the value behind our back, resend it */
+                       hid_report_set_tool(report, input, report->tool);
                } else {
                        hid_report_release_tool(report, input, usage->code);
                }
index 92ac4f6..6028af3 100644 (file)
@@ -1221,6 +1221,7 @@ static void joycon_parse_report(struct joycon_ctlr *ctlr,
 
        spin_lock_irqsave(&ctlr->lock, flags);
        if (IS_ENABLED(CONFIG_NINTENDO_FF) && rep->vibrator_report &&
+           ctlr->ctlr_state != JOYCON_CTLR_STATE_REMOVED &&
            (msecs - ctlr->rumble_msecs) >= JC_RUMBLE_PERIOD_MS &&
            (ctlr->rumble_queue_head != ctlr->rumble_queue_tail ||
             ctlr->rumble_zero_countdown > 0)) {
@@ -1545,12 +1546,13 @@ static int joycon_set_rumble(struct joycon_ctlr *ctlr, u16 amp_r, u16 amp_l,
                ctlr->rumble_queue_head = 0;
        memcpy(ctlr->rumble_data[ctlr->rumble_queue_head], data,
               JC_RUMBLE_DATA_SIZE);
-       spin_unlock_irqrestore(&ctlr->lock, flags);
 
        /* don't wait for the periodic send (reduces latency) */
-       if (schedule_now)
+       if (schedule_now && ctlr->ctlr_state != JOYCON_CTLR_STATE_REMOVED)
                queue_work(ctlr->rumble_queue, &ctlr->rumble_worker);
 
+       spin_unlock_irqrestore(&ctlr->lock, flags);
+
        return 0;
 }
 
index dc67717..70f602c 100644 (file)
@@ -314,6 +314,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) },
 #endif
 #if IS_ENABLED(CONFIG_HID_APPLEIR)
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },
index a3b151b..fc616db 100644 (file)
@@ -134,6 +134,11 @@ static int steam_recv_report(struct steam_device *steam,
        int ret;
 
        r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0];
+       if (!r) {
+               hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted -  nothing to read\n");
+               return -EINVAL;
+       }
+
        if (hid_report_len(r) < 64)
                return -EINVAL;
 
@@ -165,6 +170,11 @@ static int steam_send_report(struct steam_device *steam,
        int ret;
 
        r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0];
+       if (!r) {
+               hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted -  nothing to read\n");
+               return -EINVAL;
+       }
+
        if (hid_report_len(r) < 64)
                return -EINVAL;
 
index c3e6d69..cf1679b 100644 (file)
@@ -67,12 +67,13 @@ static const struct tm_wheel_info tm_wheels_infos[] = {
        {0x0200, 0x0005, "Thrustmaster T300RS (Missing Attachment)"},
        {0x0206, 0x0005, "Thrustmaster T300RS"},
        {0x0209, 0x0005, "Thrustmaster T300RS (Open Wheel Attachment)"},
+       {0x020a, 0x0005, "Thrustmaster T300RS (Sparco R383 Mod)"},
        {0x0204, 0x0005, "Thrustmaster T300 Ferrari Alcantara Edition"},
        {0x0002, 0x0002, "Thrustmaster T500RS"}
        //{0x0407, 0x0001, "Thrustmaster TMX"}
 };
 
-static const uint8_t tm_wheels_infos_length = 4;
+static const uint8_t tm_wheels_infos_length = 7;
 
 /*
  * This structs contains (in little endian) the response data
index 681614a..197b1e7 100644 (file)
@@ -350,6 +350,8 @@ static int hidraw_release(struct inode * inode, struct file * file)
        down_write(&minors_rwsem);
 
        spin_lock_irqsave(&hidraw_table[minor]->list_lock, flags);
+       for (int i = list->tail; i < list->head; i++)
+               kfree(list->buffer[i].value);
        list_del(&list->node);
        spin_unlock_irqrestore(&hidraw_table[minor]->list_lock, flags);
        kfree(list);
index e600dbf..fc108f1 100644 (file)
@@ -32,6 +32,7 @@
 #define ADL_P_DEVICE_ID                0x51FC
 #define ADL_N_DEVICE_ID                0x54FC
 #define RPL_S_DEVICE_ID                0x7A78
+#define MTL_P_DEVICE_ID                0x7E45
 
 #define        REVISION_ID_CHT_A0      0x6
 #define        REVISION_ID_CHT_Ax_SI   0x0
index 2c67ec1..7120b30 100644 (file)
@@ -43,6 +43,7 @@ static const struct pci_device_id ish_pci_tbl[] = {
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ADL_P_DEVICE_ID)},
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ADL_N_DEVICE_ID)},
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, RPL_S_DEVICE_ID)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MTL_P_DEVICE_ID)},
        {0, }
 };
 MODULE_DEVICE_TABLE(pci, ish_pci_tbl);
index 6a5cc11..35dddc5 100644 (file)
@@ -105,7 +105,7 @@ struct report_list {
  * @multi_packet_cnt:  Count of fragmented packet count
  *
  * This structure is used to store completion flags and per client data like
- * like report description, number of HID devices etc.
+ * report description, number of HID devices etc.
  */
 struct ishtp_cl_data {
        /* completion flags */
index 405e0d5..df0a825 100644 (file)
@@ -626,13 +626,14 @@ static void ishtp_cl_read_complete(struct ishtp_cl_rb *rb)
 }
 
 /**
- * ipc_tx_callback() - IPC tx callback function
+ * ipc_tx_send() - IPC tx send function
  * @prm: Pointer to client device instance
  *
- * Send message over IPC either first time or on callback on previous message
- * completion
+ * Send message over IPC. Message will be split into fragments
+ * if message size is bigger than IPC FIFO size, and all
+ * fragments will be sent one by one.
  */
-static void ipc_tx_callback(void *prm)
+static void ipc_tx_send(void *prm)
 {
        struct ishtp_cl *cl = prm;
        struct ishtp_cl_tx_ring *cl_msg;
@@ -677,32 +678,41 @@ static void ipc_tx_callback(void *prm)
                            list);
        rem = cl_msg->send_buf.size - cl->tx_offs;
 
-       ishtp_hdr.host_addr = cl->host_client_id;
-       ishtp_hdr.fw_addr = cl->fw_client_id;
-       ishtp_hdr.reserved = 0;
-       pmsg = cl_msg->send_buf.data + cl->tx_offs;
+       while (rem > 0) {
+               ishtp_hdr.host_addr = cl->host_client_id;
+               ishtp_hdr.fw_addr = cl->fw_client_id;
+               ishtp_hdr.reserved = 0;
+               pmsg = cl_msg->send_buf.data + cl->tx_offs;
+
+               if (rem <= dev->mtu) {
+                       /* Last fragment or only one packet */
+                       ishtp_hdr.length = rem;
+                       ishtp_hdr.msg_complete = 1;
+                       /* Submit to IPC queue with no callback */
+                       ishtp_write_message(dev, &ishtp_hdr, pmsg);
+                       cl->tx_offs = 0;
+                       cl->sending = 0;
 
-       if (rem <= dev->mtu) {
-               ishtp_hdr.length = rem;
-               ishtp_hdr.msg_complete = 1;
-               cl->sending = 0;
-               list_del_init(&cl_msg->list);   /* Must be before write */
-               spin_unlock_irqrestore(&cl->tx_list_spinlock, tx_flags);
-               /* Submit to IPC queue with no callback */
-               ishtp_write_message(dev, &ishtp_hdr, pmsg);
-               spin_lock_irqsave(&cl->tx_free_list_spinlock, tx_free_flags);
-               list_add_tail(&cl_msg->list, &cl->tx_free_list.list);
-               ++cl->tx_ring_free_size;
-               spin_unlock_irqrestore(&cl->tx_free_list_spinlock,
-                       tx_free_flags);
-       } else {
-               /* Send IPC fragment */
-               spin_unlock_irqrestore(&cl->tx_list_spinlock, tx_flags);
-               cl->tx_offs += dev->mtu;
-               ishtp_hdr.length = dev->mtu;
-               ishtp_hdr.msg_complete = 0;
-               ishtp_send_msg(dev, &ishtp_hdr, pmsg, ipc_tx_callback, cl);
+                       break;
+               } else {
+                       /* Send ipc fragment */
+                       ishtp_hdr.length = dev->mtu;
+                       ishtp_hdr.msg_complete = 0;
+                       /* All fregments submitted to IPC queue with no callback */
+                       ishtp_write_message(dev, &ishtp_hdr, pmsg);
+                       cl->tx_offs += dev->mtu;
+                       rem = cl_msg->send_buf.size - cl->tx_offs;
+               }
        }
+
+       list_del_init(&cl_msg->list);
+       spin_unlock_irqrestore(&cl->tx_list_spinlock, tx_flags);
+
+       spin_lock_irqsave(&cl->tx_free_list_spinlock, tx_free_flags);
+       list_add_tail(&cl_msg->list, &cl->tx_free_list.list);
+       ++cl->tx_ring_free_size;
+       spin_unlock_irqrestore(&cl->tx_free_list_spinlock,
+               tx_free_flags);
 }
 
 /**
@@ -720,7 +730,7 @@ static void ishtp_cl_send_msg_ipc(struct ishtp_device *dev,
                return;
 
        cl->tx_offs = 0;
-       ipc_tx_callback(cl);
+       ipc_tx_send(cl);
        ++cl->send_msg_cnt_ipc;
 }
 
index befe989..fbf3f5a 100644 (file)
@@ -391,6 +391,9 @@ static int gpio_fan_set_cur_state(struct thermal_cooling_device *cdev,
        if (!fan_data)
                return -EINVAL;
 
+       if (state >= fan_data->num_speed)
+               return -EINVAL;
+
        set_fan_speed(fan_data, state);
        return 0;
 }
index f10bac8..81d3f91 100644 (file)
@@ -2861,7 +2861,7 @@ static int pmbus_regulator_get_low_margin(struct i2c_client *client, int page)
                .data = -1,
        };
 
-       if (!data->vout_low[page]) {
+       if (data->vout_low[page] < 0) {
                if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MIN))
                        s.data = _pmbus_read_word_data(client, page, 0xff,
                                                       PMBUS_MFR_VOUT_MIN);
@@ -2887,7 +2887,7 @@ static int pmbus_regulator_get_high_margin(struct i2c_client *client, int page)
                .data = -1,
        };
 
-       if (!data->vout_high[page]) {
+       if (data->vout_high[page] < 0) {
                if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MAX))
                        s.data = _pmbus_read_word_data(client, page, 0xff,
                                                       PMBUS_MFR_VOUT_MAX);
@@ -3016,11 +3016,10 @@ static int pmbus_regulator_register(struct pmbus_data *data)
 
                rdev = devm_regulator_register(dev, &info->reg_desc[i],
                                               &config);
-               if (IS_ERR(rdev)) {
-                       dev_err(dev, "Failed to register %s regulator\n",
-                               info->reg_desc[i].name);
-                       return PTR_ERR(rdev);
-               }
+               if (IS_ERR(rdev))
+                       return dev_err_probe(dev, PTR_ERR(rdev),
+                                            "Failed to register %s regulator\n",
+                                            info->reg_desc[i].name);
        }
 
        return 0;
@@ -3320,6 +3319,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
        struct pmbus_data *data;
        size_t groups_num = 0;
        int ret;
+       int i;
        char *name;
 
        if (!info)
@@ -3353,6 +3353,11 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
        data->currpage = -1;
        data->currphase = -1;
 
+       for (i = 0; i < ARRAY_SIZE(data->vout_low); i++) {
+               data->vout_low[i] = -1;
+               data->vout_high[i] = -1;
+       }
+
        ret = pmbus_init_common(client, data, info);
        if (ret < 0)
                return ret;
index 92c68d4..a2f9fda 100644 (file)
@@ -287,10 +287,8 @@ static int ad7292_probe(struct spi_device *spi)
 
                ret = devm_add_action_or_reset(&spi->dev,
                                               ad7292_regulator_disable, st);
-               if (ret) {
-                       regulator_disable(st->reg);
+               if (ret)
                        return ret;
-               }
 
                ret = regulator_get_voltage(st->reg);
                if (ret < 0)
index 1cb4590..890af7d 100644 (file)
@@ -40,8 +40,8 @@
 #define MCP3911_CHANNEL(x)             (MCP3911_REG_CHANNEL0 + x * 3)
 #define MCP3911_OFFCAL(x)              (MCP3911_REG_OFFCAL_CH0 + x * 6)
 
-/* Internal voltage reference in uV */
-#define MCP3911_INT_VREF_UV            1200000
+/* Internal voltage reference in mV */
+#define MCP3911_INT_VREF_MV            1200
 
 #define MCP3911_REG_READ(reg, id)      ((((reg) << 1) | ((id) << 5) | (1 << 0)) & 0xff)
 #define MCP3911_REG_WRITE(reg, id)     ((((reg) << 1) | ((id) << 5) | (0 << 0)) & 0xff)
@@ -113,6 +113,8 @@ static int mcp3911_read_raw(struct iio_dev *indio_dev,
                if (ret)
                        goto out;
 
+               *val = sign_extend32(*val, 23);
+
                ret = IIO_VAL_INT;
                break;
 
@@ -137,11 +139,18 @@ static int mcp3911_read_raw(struct iio_dev *indio_dev,
 
                        *val = ret / 1000;
                } else {
-                       *val = MCP3911_INT_VREF_UV;
+                       *val = MCP3911_INT_VREF_MV;
                }
 
-               *val2 = 24;
-               ret = IIO_VAL_FRACTIONAL_LOG2;
+               /*
+                * For 24bit Conversion
+                * Raw = ((Voltage)/(Vref) * 2^23 * Gain * 1.5
+                * Voltage = Raw * (Vref)/(2^23 * Gain * 1.5)
+                */
+
+               /* val2 = (2^23 * 1.5) */
+               *val2 = 12582912;
+               ret = IIO_VAL_FRACTIONAL;
                break;
        }
 
@@ -208,7 +217,14 @@ static int mcp3911_config(struct mcp3911 *adc)
        u32 configreg;
        int ret;
 
-       device_property_read_u32(dev, "device-addr", &adc->dev_addr);
+       ret = device_property_read_u32(dev, "microchip,device-addr", &adc->dev_addr);
+
+       /*
+        * Fallback to "device-addr" due to historical mismatch between
+        * dt-bindings and implementation
+        */
+       if (ret)
+               device_property_read_u32(dev, "device-addr", &adc->dev_addr);
        if (adc->dev_addr > 3) {
                dev_err(&adc->spi->dev,
                        "invalid device address (%i). Must be in range 0-3.\n",
index edbe6a3..001055d 100644 (file)
@@ -505,7 +505,7 @@ static int cm32181_resume(struct device *dev)
                                         cm32181->conf_regs[CM32181_REG_ADDR_CMD]);
 }
 
-DEFINE_SIMPLE_DEV_PM_OPS(cm32181_pm_ops, cm32181_suspend, cm32181_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(cm32181_pm_ops, cm32181_suspend, cm32181_resume);
 
 static const struct of_device_id cm32181_of_match[] = {
        { .compatible = "capella,cm3218" },
index c721b69..0b30db7 100644 (file)
@@ -226,8 +226,10 @@ static int cm3605_probe(struct platform_device *pdev)
        }
 
        irq = platform_get_irq(pdev, 0);
-       if (irq < 0)
-               return dev_err_probe(dev, irq, "failed to get irq\n");
+       if (irq < 0) {
+               ret = dev_err_probe(dev, irq, "failed to get irq\n");
+               goto out_disable_aset;
+       }
 
        ret = devm_request_threaded_irq(dev, irq, cm3605_prox_irq,
                                        NULL, 0, "cm3605", indio_dev);
index b2a68bc..b86de13 100644 (file)
@@ -50,6 +50,7 @@ static struct iforce_device iforce_device[] = {
        { 0x046d, 0xc291, "Logitech WingMan Formula Force",             btn_wheel, abs_wheel, ff_iforce },
        { 0x05ef, 0x020a, "AVB Top Shot Pegasus",                       btn_joystick_avb, abs_avb_pegasus, ff_iforce },
        { 0x05ef, 0x8884, "AVB Mag Turbo Force",                        btn_wheel, abs_wheel, ff_iforce },
+       { 0x05ef, 0x8886, "Boeder Force Feedback Wheel",                btn_wheel, abs_wheel, ff_iforce },
        { 0x05ef, 0x8888, "AVB Top Shot Force Feedback Racing Wheel",   btn_wheel, abs_wheel, ff_iforce }, //?
        { 0x061c, 0xc0a4, "ACT LABS Force RS",                          btn_wheel, abs_wheel, ff_iforce }, //?
        { 0x061c, 0xc084, "ACT LABS Force RS",                          btn_wheel, abs_wheel, ff_iforce },
index f95a81b..2380546 100644 (file)
@@ -39,7 +39,7 @@ static void iforce_serio_xmit(struct iforce *iforce)
 
 again:
        if (iforce->xmit.head == iforce->xmit.tail) {
-               clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags);
+               iforce_clear_xmit_and_wake(iforce);
                spin_unlock_irqrestore(&iforce->xmit_lock, flags);
                return;
        }
@@ -64,7 +64,7 @@ again:
        if (test_and_clear_bit(IFORCE_XMIT_AGAIN, iforce->xmit_flags))
                goto again;
 
-       clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags);
+       iforce_clear_xmit_and_wake(iforce);
 
        spin_unlock_irqrestore(&iforce->xmit_lock, flags);
 }
@@ -169,7 +169,7 @@ static irqreturn_t iforce_serio_irq(struct serio *serio,
                        iforce_serio->cmd_response_len = iforce_serio->len;
 
                        /* Signal that command is done */
-                       wake_up(&iforce->wait);
+                       wake_up_all(&iforce->wait);
                } else if (likely(iforce->type)) {
                        iforce_process_packet(iforce, iforce_serio->id,
                                              iforce_serio->data_in,
index ea58805..cba92bd 100644 (file)
@@ -30,7 +30,7 @@ static void __iforce_usb_xmit(struct iforce *iforce)
        spin_lock_irqsave(&iforce->xmit_lock, flags);
 
        if (iforce->xmit.head == iforce->xmit.tail) {
-               clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags);
+               iforce_clear_xmit_and_wake(iforce);
                spin_unlock_irqrestore(&iforce->xmit_lock, flags);
                return;
        }
@@ -58,9 +58,9 @@ static void __iforce_usb_xmit(struct iforce *iforce)
        XMIT_INC(iforce->xmit.tail, n);
 
        if ( (n=usb_submit_urb(iforce_usb->out, GFP_ATOMIC)) ) {
-               clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags);
                dev_warn(&iforce_usb->intf->dev,
                         "usb_submit_urb failed %d\n", n);
+               iforce_clear_xmit_and_wake(iforce);
        }
 
        /* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended.
@@ -175,15 +175,15 @@ static void iforce_usb_out(struct urb *urb)
        struct iforce *iforce = &iforce_usb->iforce;
 
        if (urb->status) {
-               clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags);
                dev_dbg(&iforce_usb->intf->dev, "urb->status %d, exiting\n",
                        urb->status);
+               iforce_clear_xmit_and_wake(iforce);
                return;
        }
 
        __iforce_usb_xmit(iforce);
 
-       wake_up(&iforce->wait);
+       wake_up_all(&iforce->wait);
 }
 
 static int iforce_usb_probe(struct usb_interface *intf,
index 6aa761e..9ccb910 100644 (file)
@@ -119,6 +119,12 @@ static inline int iforce_get_id_packet(struct iforce *iforce, u8 id,
                                         response_data, response_len);
 }
 
+static inline void iforce_clear_xmit_and_wake(struct iforce *iforce)
+{
+       clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags);
+       wake_up_all(&iforce->wait);
+}
+
 /* Public functions */
 /* iforce-main.c */
 int iforce_init_device(struct device *parent, u16 bustype,
index 3fb64db..76873aa 100644 (file)
@@ -98,6 +98,7 @@ static struct platform_driver rk805_pwrkey_driver = {
 };
 module_platform_driver(rk805_pwrkey_driver);
 
+MODULE_ALIAS("platform:rk805-pwrkey");
 MODULE_AUTHOR("Joseph Chen <chenjh@rock-chips.com>");
 MODULE_DESCRIPTION("RK805 PMIC Power Key driver");
 MODULE_LICENSE("GPL");
index d016505..21c0ddd 100644 (file)
@@ -95,6 +95,7 @@ static const struct goodix_chip_data gt9x_chip_data = {
 
 static const struct goodix_chip_id goodix_chip_ids[] = {
        { .id = "1151", .data = &gt1x_chip_data },
+       { .id = "1158", .data = &gt1x_chip_data },
        { .id = "5663", .data = &gt1x_chip_data },
        { .id = "5688", .data = &gt1x_chip_data },
        { .id = "917S", .data = &gt1x_chip_data },
@@ -1508,6 +1509,7 @@ MODULE_DEVICE_TABLE(acpi, goodix_acpi_match);
 #ifdef CONFIG_OF
 static const struct of_device_id goodix_of_match[] = {
        { .compatible = "goodix,gt1151" },
+       { .compatible = "goodix,gt1158" },
        { .compatible = "goodix,gt5663" },
        { .compatible = "goodix,gt5688" },
        { .compatible = "goodix,gt911" },
index 41f4eb0..5696314 100644 (file)
@@ -40,7 +40,7 @@ static int of_iommu_xlate(struct device *dev,
         * a proper probe-ordering dependency mechanism in future.
         */
        if (!ops)
-               return -ENODEV;
+               return driver_deferred_probe_check_state(dev);
 
        if (!try_module_get(ops->owner))
                return -ENODEV;
index afaf36b..729be2c 100644 (file)
@@ -5620,6 +5620,7 @@ struct mddev *md_alloc(dev_t dev, char *name)
         * removed (mddev_delayed_delete).
         */
        flush_workqueue(md_misc_wq);
+       flush_workqueue(md_rdev_misc_wq);
 
        mutex_lock(&disks_mutex);
        mddev = mddev_alloc(dev);
@@ -6238,11 +6239,11 @@ static void mddev_detach(struct mddev *mddev)
 static void __md_stop(struct mddev *mddev)
 {
        struct md_personality *pers = mddev->pers;
+       md_bitmap_destroy(mddev);
        mddev_detach(mddev);
        /* Ensure ->event_work is done */
        if (mddev->event_work.func)
                flush_workqueue(md_misc_wq);
-       md_bitmap_destroy(mddev);
        spin_lock(&mddev->lock);
        mddev->pers = NULL;
        spin_unlock(&mddev->lock);
@@ -6260,6 +6261,7 @@ void md_stop(struct mddev *mddev)
        /* stop the array and free an attached data structures.
         * This is called from dm-raid
         */
+       __md_stop_writes(mddev);
        __md_stop(mddev);
        bioset_exit(&mddev->bio_set);
        bioset_exit(&mddev->sync_set);
index 9117fcd..64d6e4c 100644 (file)
@@ -2639,18 +2639,18 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
 }
 
 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
-                           int sectors, struct page *page, int rw)
+                           int sectors, struct page *page, enum req_op op)
 {
        sector_t first_bad;
        int bad_sectors;
 
        if (is_badblock(rdev, sector, sectors, &first_bad, &bad_sectors)
-           && (rw == READ || test_bit(WriteErrorSeen, &rdev->flags)))
+           && (op == REQ_OP_READ || test_bit(WriteErrorSeen, &rdev->flags)))
                return -1;
-       if (sync_page_io(rdev, sector, sectors << 9, page, rw, false))
+       if (sync_page_io(rdev, sector, sectors << 9, page, op, false))
                /* success */
                return 1;
-       if (rw == WRITE) {
+       if (op == REQ_OP_WRITE) {
                set_bit(WriteErrorSeen, &rdev->flags);
                if (!test_and_set_bit(WantReplacement, &rdev->flags))
                        set_bit(MD_RECOVERY_NEEDED,
@@ -2780,7 +2780,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
                        if (r10_sync_page_io(rdev,
                                             r10_bio->devs[sl].addr +
                                             sect,
-                                            s, conf->tmppage, WRITE)
+                                            s, conf->tmppage, REQ_OP_WRITE)
                            == 0) {
                                /* Well, this device is dead */
                                pr_notice("md/raid10:%s: read correction write failed (%d sectors at %llu on %pg)\n",
@@ -2814,8 +2814,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
                        switch (r10_sync_page_io(rdev,
                                             r10_bio->devs[sl].addr +
                                             sect,
-                                            s, conf->tmppage,
-                                                READ)) {
+                                            s, conf->tmppage, REQ_OP_READ)) {
                        case 0:
                                /* Well, this device is dead */
                                pr_notice("md/raid10:%s: unable to read back corrected sectors (%d sectors at %llu on %pg)\n",
index 0834d5f..39d2b03 100644 (file)
@@ -1416,42 +1416,37 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
 {
        int ret;
        struct device *dev = ir->dev;
-       char *data;
-
-       data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL);
-       if (!data) {
-               dev_err(dev, "%s: memory allocation failed!", __func__);
-               return;
-       }
+       char data[USB_CTRL_MSG_SZ];
 
        /*
         * This is a strange one. Windows issues a set address to the device
         * on the receive control pipe and expect a certain value pair back
         */
-       ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
-                             USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0,
-                             data, USB_CTRL_MSG_SZ, 3000);
+       ret = usb_control_msg_recv(ir->usbdev, 0, USB_REQ_SET_ADDRESS,
+                                  USB_DIR_IN | USB_TYPE_VENDOR,
+                                  0, 0, data, USB_CTRL_MSG_SZ, 3000,
+                                  GFP_KERNEL);
        dev_dbg(dev, "set address - ret = %d", ret);
        dev_dbg(dev, "set address - data[0] = %d, data[1] = %d",
                                                data[0], data[1]);
 
        /* set feature: bit rate 38400 bps */
-       ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
-                             USB_REQ_SET_FEATURE, USB_TYPE_VENDOR,
-                             0xc04e, 0x0000, NULL, 0, 3000);
+       ret = usb_control_msg_send(ir->usbdev, 0,
+                                  USB_REQ_SET_FEATURE, USB_TYPE_VENDOR,
+                                  0xc04e, 0x0000, NULL, 0, 3000, GFP_KERNEL);
 
        dev_dbg(dev, "set feature - ret = %d", ret);
 
        /* bRequest 4: set char length to 8 bits */
-       ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
-                             4, USB_TYPE_VENDOR,
-                             0x0808, 0x0000, NULL, 0, 3000);
+       ret = usb_control_msg_send(ir->usbdev, 0,
+                                  4, USB_TYPE_VENDOR,
+                                  0x0808, 0x0000, NULL, 0, 3000, GFP_KERNEL);
        dev_dbg(dev, "set char length - retB = %d", ret);
 
        /* bRequest 2: set handshaking to use DTR/DSR */
-       ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
-                             2, USB_TYPE_VENDOR,
-                             0x0000, 0x0100, NULL, 0, 3000);
+       ret = usb_control_msg_send(ir->usbdev, 0,
+                                  2, USB_TYPE_VENDOR,
+                                  0x0000, 0x0100, NULL, 0, 3000, GFP_KERNEL);
        dev_dbg(dev, "set handshake  - retC = %d", ret);
 
        /* device resume */
@@ -1459,8 +1454,6 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
 
        /* get hw/sw revision? */
        mce_command_out(ir, GET_REVISION, sizeof(GET_REVISION));
-
-       kfree(data);
 }
 
 static void mceusb_gen2_init(struct mceusb_dev *ir)
index 93ebd17..5d9e348 100644 (file)
@@ -25,7 +25,7 @@
 #define SDSP_DOMAIN_ID (2)
 #define CDSP_DOMAIN_ID (3)
 #define FASTRPC_DEV_MAX                4 /* adsp, mdsp, slpi, cdsp*/
-#define FASTRPC_MAX_SESSIONS   13 /*12 compute, 1 cpz*/
+#define FASTRPC_MAX_SESSIONS   14
 #define FASTRPC_MAX_VMIDS      16
 #define FASTRPC_ALIGN          128
 #define FASTRPC_MAX_FDLIST     16
@@ -1943,7 +1943,12 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
        of_property_read_u32(dev->of_node, "qcom,nsessions", &sessions);
 
        spin_lock_irqsave(&cctx->lock, flags);
-       sess = &cctx->session[cctx->sesscount];
+       if (cctx->sesscount >= FASTRPC_MAX_SESSIONS) {
+               dev_err(&pdev->dev, "too many sessions\n");
+               spin_unlock_irqrestore(&cctx->lock, flags);
+               return -ENOSPC;
+       }
+       sess = &cctx->session[cctx->sesscount++];
        sess->used = false;
        sess->valid = true;
        sess->dev = dev;
@@ -1956,13 +1961,12 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
                struct fastrpc_session_ctx *dup_sess;
 
                for (i = 1; i < sessions; i++) {
-                       if (cctx->sesscount++ >= FASTRPC_MAX_SESSIONS)
+                       if (cctx->sesscount >= FASTRPC_MAX_SESSIONS)
                                break;
-                       dup_sess = &cctx->session[cctx->sesscount];
+                       dup_sess = &cctx->session[cctx->sesscount++];
                        memcpy(dup_sess, sess, sizeof(*dup_sess));
                }
        }
-       cctx->sesscount++;
        spin_unlock_irqrestore(&cctx->lock, flags);
        rc = dma_set_mask(dev, DMA_BIT_MASK(32));
        if (rc) {
index cee4c0b..06aa62c 100644 (file)
@@ -949,16 +949,17 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card,
 
                /* Erase init depends on CSD and SSR */
                mmc_init_erase(card);
-
-               /*
-                * Fetch switch information from card.
-                */
-               err = mmc_read_switch(card);
-               if (err)
-                       return err;
        }
 
        /*
+        * Fetch switch information from card. Note, sd3_bus_mode can change if
+        * voltage switch outcome changes, so do this always.
+        */
+       err = mmc_read_switch(card);
+       if (err)
+               return err;
+
+       /*
         * For SPI, enable CRC as appropriate.
         * This CRC enable is located AFTER the reading of the
         * card registers because some SDHC cards are not able
@@ -1480,26 +1481,15 @@ retry:
        if (!v18_fixup_failed && !mmc_host_is_spi(host) && mmc_host_uhs(host) &&
            mmc_sd_card_using_v18(card) &&
            host->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_180) {
-               /*
-                * Re-read switch information in case it has changed since
-                * oldcard was initialized.
-                */
-               if (oldcard) {
-                       err = mmc_read_switch(card);
-                       if (err)
-                               goto free_card;
-               }
-               if (mmc_sd_card_using_v18(card)) {
-                       if (mmc_host_set_uhs_voltage(host) ||
-                           mmc_sd_init_uhs_card(card)) {
-                               v18_fixup_failed = true;
-                               mmc_power_cycle(host, ocr);
-                               if (!oldcard)
-                                       mmc_remove_card(card);
-                               goto retry;
-                       }
-                       goto done;
+               if (mmc_host_set_uhs_voltage(host) ||
+                   mmc_sd_init_uhs_card(card)) {
+                       v18_fixup_failed = true;
+                       mmc_power_cycle(host, ocr);
+                       if (!oldcard)
+                               mmc_remove_card(card);
+                       goto retry;
                }
+               goto cont;
        }
 
        /* Initialization sequence for UHS-I cards */
@@ -1534,7 +1524,7 @@ retry:
                        mmc_set_bus_width(host, MMC_BUS_WIDTH_4);
                }
        }
-
+cont:
        if (!oldcard) {
                /* Read/parse the extension registers. */
                err = sd_read_ext_regs(card);
@@ -1566,7 +1556,7 @@ retry:
                err = -EINVAL;
                goto free_card;
        }
-done:
+
        host->card = card;
        return 0;
 
index 10c5639..e636088 100644 (file)
@@ -171,6 +171,7 @@ config MMC_SDHCI_OF_ASPEED
 config MMC_SDHCI_OF_ASPEED_TEST
        bool "Tests for the ASPEED SDHCI driver" if !KUNIT_ALL_TESTS
        depends on MMC_SDHCI_OF_ASPEED && KUNIT
+       depends on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y)
        default KUNIT_ALL_TESTS
        help
          Enable KUnit tests for the ASPEED SDHCI driver. Select this
index d7fb33c..184608b 100644 (file)
@@ -84,7 +84,8 @@ enum ad_link_speed_type {
 static const u8 null_mac_addr[ETH_ALEN + 2] __long_aligned = {
        0, 0, 0, 0, 0, 0
 };
-static u16 ad_ticks_per_sec;
+
+static const u16 ad_ticks_per_sec = 1000 / AD_TIMER_INTERVAL;
 static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL * HZ) / 1000;
 
 static const u8 lacpdu_mcast_addr[ETH_ALEN + 2] __long_aligned =
@@ -2001,36 +2002,24 @@ void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout)
 /**
  * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures
  * @bond: bonding struct to work on
- * @tick_resolution: tick duration (millisecond resolution)
  *
  * Can be called only after the mac address of the bond is set.
  */
-void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution)
+void bond_3ad_initialize(struct bonding *bond)
 {
-       /* check that the bond is not initialized yet */
-       if (!MAC_ADDRESS_EQUAL(&(BOND_AD_INFO(bond).system.sys_mac_addr),
-                               bond->dev->dev_addr)) {
-
-               BOND_AD_INFO(bond).aggregator_identifier = 0;
-
-               BOND_AD_INFO(bond).system.sys_priority =
-                       bond->params.ad_actor_sys_prio;
-               if (is_zero_ether_addr(bond->params.ad_actor_system))
-                       BOND_AD_INFO(bond).system.sys_mac_addr =
-                           *((struct mac_addr *)bond->dev->dev_addr);
-               else
-                       BOND_AD_INFO(bond).system.sys_mac_addr =
-                           *((struct mac_addr *)bond->params.ad_actor_system);
-
-               /* initialize how many times this module is called in one
-                * second (should be about every 100ms)
-                */
-               ad_ticks_per_sec = tick_resolution;
+       BOND_AD_INFO(bond).aggregator_identifier = 0;
+       BOND_AD_INFO(bond).system.sys_priority =
+               bond->params.ad_actor_sys_prio;
+       if (is_zero_ether_addr(bond->params.ad_actor_system))
+               BOND_AD_INFO(bond).system.sys_mac_addr =
+                   *((struct mac_addr *)bond->dev->dev_addr);
+       else
+               BOND_AD_INFO(bond).system.sys_mac_addr =
+                   *((struct mac_addr *)bond->params.ad_actor_system);
 
-               bond_3ad_initiate_agg_selection(bond,
-                                               AD_AGGREGATOR_SELECTION_TIMER *
-                                               ad_ticks_per_sec);
-       }
+       bond_3ad_initiate_agg_selection(bond,
+                                       AD_AGGREGATOR_SELECTION_TIMER *
+                                       ad_ticks_per_sec);
 }
 
 /**
index 50e6084..5c2febe 100644 (file)
@@ -2081,7 +2081,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
                        /* Initialize AD with the number of times that the AD timer is called in 1 second
                         * can be called only after the mac address of the bond is set
                         */
-                       bond_3ad_initialize(bond, 1000/AD_TIMER_INTERVAL);
+                       bond_3ad_initialize(bond);
                } else {
                        SLAVE_AD_INFO(new_slave)->id =
                                SLAVE_AD_INFO(prev_slave)->id + 1;
@@ -3167,6 +3167,9 @@ static void bond_ns_send_all(struct bonding *bond, struct slave *slave)
 found:
                if (!ipv6_dev_get_saddr(dev_net(dst->dev), dst->dev, &targets[i], 0, &saddr))
                        bond_ns_send(slave, &targets[i], &saddr, tags);
+               else
+                       bond_ns_send(slave, &targets[i], &in6addr_any, tags);
+
                dst_release(dst);
                kfree(tags);
        }
@@ -3198,12 +3201,19 @@ static bool bond_has_this_ip6(struct bonding *bond, struct in6_addr *addr)
        return ret;
 }
 
-static void bond_validate_ns(struct bonding *bond, struct slave *slave,
+static void bond_validate_na(struct bonding *bond, struct slave *slave,
                             struct in6_addr *saddr, struct in6_addr *daddr)
 {
        int i;
 
-       if (ipv6_addr_any(saddr) || !bond_has_this_ip6(bond, daddr)) {
+       /* Ignore NAs that:
+        * 1. Source address is unspecified address.
+        * 2. Dest address is neither all-nodes multicast address nor
+        *    exist on bond interface.
+        */
+       if (ipv6_addr_any(saddr) ||
+           (!ipv6_addr_equal(daddr, &in6addr_linklocal_allnodes) &&
+            !bond_has_this_ip6(bond, daddr))) {
                slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c tip %pI6c not found\n",
                          __func__, saddr, daddr);
                return;
@@ -3246,14 +3256,14 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
         * see bond_arp_rcv().
         */
        if (bond_is_active_slave(slave))
-               bond_validate_ns(bond, slave, saddr, daddr);
+               bond_validate_na(bond, slave, saddr, daddr);
        else if (curr_active_slave &&
                 time_after(slave_last_rx(bond, curr_active_slave),
                            curr_active_slave->last_link_up))
-               bond_validate_ns(bond, slave, saddr, daddr);
+               bond_validate_na(bond, slave, saddr, daddr);
        else if (curr_arp_slave &&
                 bond_time_in_interval(bond, slave_last_tx(curr_arp_slave), 1))
-               bond_validate_ns(bond, slave, saddr, daddr);
+               bond_validate_na(bond, slave, saddr, daddr);
 
 out:
        return RX_HANDLER_ANOTHER;
index ed7d137..872aba6 100644 (file)
@@ -170,6 +170,13 @@ static const struct ksz_dev_ops ksz8_dev_ops = {
        .exit = ksz8_switch_exit,
 };
 
+static void ksz9477_phylink_mac_link_up(struct ksz_device *dev, int port,
+                                       unsigned int mode,
+                                       phy_interface_t interface,
+                                       struct phy_device *phydev, int speed,
+                                       int duplex, bool tx_pause,
+                                       bool rx_pause);
+
 static const struct ksz_dev_ops ksz9477_dev_ops = {
        .setup = ksz9477_setup,
        .get_port_addr = ksz9477_get_port_addr,
@@ -196,6 +203,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = {
        .mdb_del = ksz9477_mdb_del,
        .change_mtu = ksz9477_change_mtu,
        .max_mtu = ksz9477_max_mtu,
+       .phylink_mac_link_up = ksz9477_phylink_mac_link_up,
        .config_cpu_port = ksz9477_config_cpu_port,
        .enable_stp_addr = ksz9477_enable_stp_addr,
        .reset = ksz9477_reset_switch,
@@ -230,6 +238,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = {
        .mdb_del = ksz9477_mdb_del,
        .change_mtu = lan937x_change_mtu,
        .max_mtu = ksz9477_max_mtu,
+       .phylink_mac_link_up = ksz9477_phylink_mac_link_up,
        .config_cpu_port = lan937x_config_cpu_port,
        .enable_stp_addr = ksz9477_enable_stp_addr,
        .reset = lan937x_reset_switch,
@@ -803,9 +812,15 @@ static void ksz_phylink_get_caps(struct dsa_switch *ds, int port,
        if (dev->info->supports_rgmii[port])
                phy_interface_set_rgmii(config->supported_interfaces);
 
-       if (dev->info->internal_phy[port])
+       if (dev->info->internal_phy[port]) {
                __set_bit(PHY_INTERFACE_MODE_INTERNAL,
                          config->supported_interfaces);
+               /* Compatibility for phylib's default interface type when the
+                * phy-mode property is absent
+                */
+               __set_bit(PHY_INTERFACE_MODE_GMII,
+                         config->supported_interfaces);
+       }
 
        if (dev->dev_ops->get_caps)
                dev->dev_ops->get_caps(dev, port, config);
@@ -962,6 +977,7 @@ static void ksz_update_port_member(struct ksz_device *dev, int port)
 static int ksz_setup(struct dsa_switch *ds)
 {
        struct ksz_device *dev = ds->priv;
+       struct ksz_port *p;
        const u16 *regs;
        int ret;
 
@@ -1001,6 +1017,14 @@ static int ksz_setup(struct dsa_switch *ds)
                        return ret;
        }
 
+       /* Start with learning disabled on standalone user ports, and enabled
+        * on the CPU port. In lack of other finer mechanisms, learning on the
+        * CPU port will avoid flooding bridge local addresses on the network
+        * in some cases.
+        */
+       p = &dev->ports[dev->cpu_port];
+       p->learning = true;
+
        /* start switch */
        regmap_update_bits(dev->regmap[0], regs[S_START_CTRL],
                           SW_START, SW_START);
@@ -1277,6 +1301,8 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
        ksz_pread8(dev, port, regs[P_STP_CTRL], &data);
        data &= ~(PORT_TX_ENABLE | PORT_RX_ENABLE | PORT_LEARN_DISABLE);
 
+       p = &dev->ports[port];
+
        switch (state) {
        case BR_STATE_DISABLED:
                data |= PORT_LEARN_DISABLE;
@@ -1286,9 +1312,13 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
                break;
        case BR_STATE_LEARNING:
                data |= PORT_RX_ENABLE;
+               if (!p->learning)
+                       data |= PORT_LEARN_DISABLE;
                break;
        case BR_STATE_FORWARDING:
                data |= (PORT_TX_ENABLE | PORT_RX_ENABLE);
+               if (!p->learning)
+                       data |= PORT_LEARN_DISABLE;
                break;
        case BR_STATE_BLOCKING:
                data |= PORT_LEARN_DISABLE;
@@ -1300,12 +1330,38 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
 
        ksz_pwrite8(dev, port, regs[P_STP_CTRL], data);
 
-       p = &dev->ports[port];
        p->stp_state = state;
 
        ksz_update_port_member(dev, port);
 }
 
+static int ksz_port_pre_bridge_flags(struct dsa_switch *ds, int port,
+                                    struct switchdev_brport_flags flags,
+                                    struct netlink_ext_ack *extack)
+{
+       if (flags.mask & ~BR_LEARNING)
+               return -EINVAL;
+
+       return 0;
+}
+
+static int ksz_port_bridge_flags(struct dsa_switch *ds, int port,
+                                struct switchdev_brport_flags flags,
+                                struct netlink_ext_ack *extack)
+{
+       struct ksz_device *dev = ds->priv;
+       struct ksz_port *p = &dev->ports[port];
+
+       if (flags.mask & BR_LEARNING) {
+               p->learning = !!(flags.val & BR_LEARNING);
+
+               /* Make the change take effect immediately */
+               ksz_port_stp_state_set(ds, port, p->stp_state);
+       }
+
+       return 0;
+}
+
 static enum dsa_tag_protocol ksz_get_tag_protocol(struct dsa_switch *ds,
                                                  int port,
                                                  enum dsa_tag_protocol mp)
@@ -1609,13 +1665,13 @@ static void ksz_duplex_flowctrl(struct ksz_device *dev, int port, int duplex,
        ksz_prmw8(dev, port, regs[P_XMII_CTRL_0], mask, val);
 }
 
-static void ksz_phylink_mac_link_up(struct dsa_switch *ds, int port,
-                                   unsigned int mode,
-                                   phy_interface_t interface,
-                                   struct phy_device *phydev, int speed,
-                                   int duplex, bool tx_pause, bool rx_pause)
+static void ksz9477_phylink_mac_link_up(struct ksz_device *dev, int port,
+                                       unsigned int mode,
+                                       phy_interface_t interface,
+                                       struct phy_device *phydev, int speed,
+                                       int duplex, bool tx_pause,
+                                       bool rx_pause)
 {
-       struct ksz_device *dev = ds->priv;
        struct ksz_port *p;
 
        p = &dev->ports[port];
@@ -1629,6 +1685,15 @@ static void ksz_phylink_mac_link_up(struct dsa_switch *ds, int port,
        ksz_port_set_xmii_speed(dev, port, speed);
 
        ksz_duplex_flowctrl(dev, port, duplex, tx_pause, rx_pause);
+}
+
+static void ksz_phylink_mac_link_up(struct dsa_switch *ds, int port,
+                                   unsigned int mode,
+                                   phy_interface_t interface,
+                                   struct phy_device *phydev, int speed,
+                                   int duplex, bool tx_pause, bool rx_pause)
+{
+       struct ksz_device *dev = ds->priv;
 
        if (dev->dev_ops->phylink_mac_link_up)
                dev->dev_ops->phylink_mac_link_up(dev, port, mode, interface,
@@ -1719,6 +1784,8 @@ static const struct dsa_switch_ops ksz_switch_ops = {
        .port_bridge_join       = ksz_port_bridge_join,
        .port_bridge_leave      = ksz_port_bridge_leave,
        .port_stp_state_set     = ksz_port_stp_state_set,
+       .port_pre_bridge_flags  = ksz_port_pre_bridge_flags,
+       .port_bridge_flags      = ksz_port_bridge_flags,
        .port_fast_age          = ksz_port_fast_age,
        .port_vlan_filtering    = ksz_port_vlan_filtering,
        .port_vlan_add          = ksz_port_vlan_add,
index 764ada3..0d9520d 100644 (file)
@@ -65,6 +65,7 @@ struct ksz_chip_data {
 
 struct ksz_port {
        bool remove_tag;                /* Remove Tag flag set, for ksz8795 only */
+       bool learning;
        int stp_state;
        struct phy_device phydev;
 
index 1cdce8a..f8f19a8 100644 (file)
@@ -22,6 +22,7 @@
 #define VSC9959_NUM_PORTS              6
 
 #define VSC9959_TAS_GCL_ENTRY_MAX      63
+#define VSC9959_TAS_MIN_GATE_LEN_NS    33
 #define VSC9959_VCAP_POLICER_BASE      63
 #define VSC9959_VCAP_POLICER_MAX       383
 #define VSC9959_SWITCH_PCI_BAR         4
@@ -1478,6 +1479,23 @@ static void vsc9959_mdio_bus_free(struct ocelot *ocelot)
        mdiobus_free(felix->imdio);
 }
 
+/* The switch considers any frame (regardless of size) as eligible for
+ * transmission if the traffic class gate is open for at least 33 ns.
+ * Overruns are prevented by cropping an interval at the end of the gate time
+ * slot for which egress scheduling is blocked, but we need to still keep 33 ns
+ * available for one packet to be transmitted, otherwise the port tc will hang.
+ * This function returns the size of a gate interval that remains available for
+ * setting the guard band, after reserving the space for one egress frame.
+ */
+static u64 vsc9959_tas_remaining_gate_len_ps(u64 gate_len_ns)
+{
+       /* Gate always open */
+       if (gate_len_ns == U64_MAX)
+               return U64_MAX;
+
+       return (gate_len_ns - VSC9959_TAS_MIN_GATE_LEN_NS) * PSEC_PER_NSEC;
+}
+
 /* Extract shortest continuous gate open intervals in ns for each traffic class
  * of a cyclic tc-taprio schedule. If a gate is always open, the duration is
  * considered U64_MAX. If the gate is always closed, it is considered 0.
@@ -1539,6 +1557,65 @@ static void vsc9959_tas_min_gate_lengths(struct tc_taprio_qopt_offload *taprio,
                        min_gate_len[tc] = 0;
 }
 
+/* ocelot_write_rix is a macro that concatenates QSYS_MAXSDU_CFG_* with _RSZ,
+ * so we need to spell out the register access to each traffic class in helper
+ * functions, to simplify callers
+ */
+static void vsc9959_port_qmaxsdu_set(struct ocelot *ocelot, int port, int tc,
+                                    u32 max_sdu)
+{
+       switch (tc) {
+       case 0:
+               ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_0,
+                                port);
+               break;
+       case 1:
+               ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_1,
+                                port);
+               break;
+       case 2:
+               ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_2,
+                                port);
+               break;
+       case 3:
+               ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_3,
+                                port);
+               break;
+       case 4:
+               ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_4,
+                                port);
+               break;
+       case 5:
+               ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_5,
+                                port);
+               break;
+       case 6:
+               ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_6,
+                                port);
+               break;
+       case 7:
+               ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_7,
+                                port);
+               break;
+       }
+}
+
+static u32 vsc9959_port_qmaxsdu_get(struct ocelot *ocelot, int port, int tc)
+{
+       switch (tc) {
+       case 0: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_0, port);
+       case 1: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_1, port);
+       case 2: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_2, port);
+       case 3: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_3, port);
+       case 4: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_4, port);
+       case 5: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_5, port);
+       case 6: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_6, port);
+       case 7: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_7, port);
+       default:
+               return 0;
+       }
+}
+
 /* Update QSYS_PORT_MAX_SDU to make sure the static guard bands added by the
  * switch (see the ALWAYS_GUARD_BAND_SCH_Q comment) are correct at all MTU
  * values (the default value is 1518). Also, for traffic class windows smaller
@@ -1595,11 +1672,16 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port)
 
        vsc9959_tas_min_gate_lengths(ocelot_port->taprio, min_gate_len);
 
+       mutex_lock(&ocelot->fwd_domain_lock);
+
        for (tc = 0; tc < OCELOT_NUM_TC; tc++) {
+               u64 remaining_gate_len_ps;
                u32 max_sdu;
 
-               if (min_gate_len[tc] == U64_MAX /* Gate always open */ ||
-                   min_gate_len[tc] * PSEC_PER_NSEC > needed_bit_time_ps) {
+               remaining_gate_len_ps =
+                       vsc9959_tas_remaining_gate_len_ps(min_gate_len[tc]);
+
+               if (remaining_gate_len_ps > needed_bit_time_ps) {
                        /* Setting QMAXSDU_CFG to 0 disables oversized frame
                         * dropping.
                         */
@@ -1612,9 +1694,15 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port)
                        /* If traffic class doesn't support a full MTU sized
                         * frame, make sure to enable oversize frame dropping
                         * for frames larger than the smallest that would fit.
+                        *
+                        * However, the exact same register, QSYS_QMAXSDU_CFG_*,
+                        * controls not only oversized frame dropping, but also
+                        * per-tc static guard band lengths, so it reduces the
+                        * useful gate interval length. Therefore, be careful
+                        * to calculate a guard band (and therefore max_sdu)
+                        * that still leaves 33 ns available in the time slot.
                         */
-                       max_sdu = div_u64(min_gate_len[tc] * PSEC_PER_NSEC,
-                                         picos_per_byte);
+                       max_sdu = div_u64(remaining_gate_len_ps, picos_per_byte);
                        /* A TC gate may be completely closed, which is a
                         * special case where all packets are oversized.
                         * Any limit smaller than 64 octets accomplishes this
@@ -1637,47 +1725,14 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port)
                                 max_sdu);
                }
 
-               /* ocelot_write_rix is a macro that concatenates
-                * QSYS_MAXSDU_CFG_* with _RSZ, so we need to spell out
-                * the writes to each traffic class
-                */
-               switch (tc) {
-               case 0:
-                       ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_0,
-                                        port);
-                       break;
-               case 1:
-                       ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_1,
-                                        port);
-                       break;
-               case 2:
-                       ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_2,
-                                        port);
-                       break;
-               case 3:
-                       ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_3,
-                                        port);
-                       break;
-               case 4:
-                       ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_4,
-                                        port);
-                       break;
-               case 5:
-                       ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_5,
-                                        port);
-                       break;
-               case 6:
-                       ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_6,
-                                        port);
-                       break;
-               case 7:
-                       ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_7,
-                                        port);
-                       break;
-               }
+               vsc9959_port_qmaxsdu_set(ocelot, port, tc, max_sdu);
        }
 
        ocelot_write_rix(ocelot, maxlen, QSYS_PORT_MAX_SDU, port);
+
+       ocelot->ops->cut_through_fwd(ocelot);
+
+       mutex_unlock(&ocelot->fwd_domain_lock);
 }
 
 static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port,
@@ -1704,13 +1759,13 @@ static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port,
                break;
        }
 
+       mutex_lock(&ocelot->tas_lock);
+
        ocelot_rmw_rix(ocelot,
                       QSYS_TAG_CONFIG_LINK_SPEED(tas_speed),
                       QSYS_TAG_CONFIG_LINK_SPEED_M,
                       QSYS_TAG_CONFIG, port);
 
-       mutex_lock(&ocelot->tas_lock);
-
        if (ocelot_port->taprio)
                vsc9959_tas_guard_bands_update(ocelot, port);
 
@@ -2770,7 +2825,7 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot)
 {
        struct felix *felix = ocelot_to_felix(ocelot);
        struct dsa_switch *ds = felix->ds;
-       int port, other_port;
+       int tc, port, other_port;
 
        lockdep_assert_held(&ocelot->fwd_domain_lock);
 
@@ -2814,19 +2869,27 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot)
                                min_speed = other_ocelot_port->speed;
                }
 
-               /* Enable cut-through forwarding for all traffic classes. */
-               if (ocelot_port->speed == min_speed)
+               /* Enable cut-through forwarding for all traffic classes that
+                * don't have oversized dropping enabled, since this check is
+                * bypassed in cut-through mode.
+                */
+               if (ocelot_port->speed == min_speed) {
                        val = GENMASK(7, 0);
 
+                       for (tc = 0; tc < OCELOT_NUM_TC; tc++)
+                               if (vsc9959_port_qmaxsdu_get(ocelot, port, tc))
+                                       val &= ~BIT(tc);
+               }
+
 set:
                tmp = ocelot_read_rix(ocelot, ANA_CUT_THRU_CFG, port);
                if (tmp == val)
                        continue;
 
                dev_dbg(ocelot->dev,
-                       "port %d fwd mask 0x%lx speed %d min_speed %d, %s cut-through forwarding\n",
+                       "port %d fwd mask 0x%lx speed %d min_speed %d, %s cut-through forwarding on TC mask 0x%x\n",
                        port, mask, ocelot_port->speed, min_speed,
-                       val ? "enabling" : "disabling");
+                       val ? "enabling" : "disabling", val);
 
                ocelot_write_rix(ocelot, val, ANA_CUT_THRU_CFG, port);
        }
index 1d3e778..c181346 100644 (file)
@@ -1889,9 +1889,9 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
        if (!priv)
                return -ENOMEM;
 
-       priv->info = of_device_get_match_data(priv->dev);
        priv->bus = mdiodev->bus;
        priv->dev = &mdiodev->dev;
+       priv->info = of_device_get_match_data(priv->dev);
 
        priv->reset_gpio = devm_gpiod_get_optional(priv->dev, "reset",
                                                   GPIOD_ASIS);
index 3887ed3..fa62263 100644 (file)
@@ -109,6 +109,7 @@ static void xrs700x_read_port_counters(struct xrs700x *priv, int port)
 {
        struct xrs700x_port *p = &priv->ports[port];
        struct rtnl_link_stats64 stats;
+       unsigned long flags;
        int i;
 
        memset(&stats, 0, sizeof(stats));
@@ -138,9 +139,9 @@ static void xrs700x_read_port_counters(struct xrs700x *priv, int port)
         */
        stats.rx_packets += stats.multicast;
 
-       u64_stats_update_begin(&p->syncp);
+       flags = u64_stats_update_begin_irqsave(&p->syncp);
        p->stats64 = stats;
-       u64_stats_update_end(&p->syncp);
+       u64_stats_update_end_irqrestore(&p->syncp, flags);
 
        mutex_unlock(&p->mib_mutex);
 }
index ba0f1ff..f46eefb 100644 (file)
@@ -11178,10 +11178,7 @@ static netdev_features_t bnxt_fix_features(struct net_device *dev,
        if ((features & NETIF_F_NTUPLE) && !bnxt_rfs_capable(bp))
                features &= ~NETIF_F_NTUPLE;
 
-       if (bp->flags & BNXT_FLAG_NO_AGG_RINGS)
-               features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW);
-
-       if (!(bp->flags & BNXT_FLAG_TPA))
+       if ((bp->flags & BNXT_FLAG_NO_AGG_RINGS) || bp->xdp_prog)
                features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW);
 
        if (!(features & NETIF_F_GRO))
index 075c620..b1b17f9 100644 (file)
@@ -2130,6 +2130,7 @@ struct bnxt {
 #define BNXT_DUMP_CRASH                1
 
        struct bpf_prog         *xdp_prog;
+       u8                      xdp_has_frags;
 
        struct bnxt_ptp_cfg     *ptp_cfg;
        u8                      ptp_all_rx_tstamp;
index 059f96f..a36803e 100644 (file)
@@ -1306,6 +1306,7 @@ int bnxt_dl_register(struct bnxt *bp)
        if (rc)
                goto err_dl_port_unreg;
 
+       devlink_set_features(dl, DEVLINK_F_RELOAD);
 out:
        devlink_register(dl);
        return 0;
index 730febd..a4cba7c 100644 (file)
@@ -623,7 +623,7 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs, bool reset)
                hw_resc->max_stat_ctxs -= le16_to_cpu(req->min_stat_ctx) * n;
                hw_resc->max_vnics -= le16_to_cpu(req->min_vnics) * n;
                if (bp->flags & BNXT_FLAG_CHIP_P5)
-                       hw_resc->max_irqs -= vf_msix * n;
+                       hw_resc->max_nqs -= vf_msix;
 
                rc = pf->active_vfs;
        }
index f53387e..c3065ec 100644 (file)
@@ -181,6 +181,7 @@ void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
                        struct xdp_buff *xdp)
 {
        struct bnxt_sw_rx_bd *rx_buf;
+       u32 buflen = PAGE_SIZE;
        struct pci_dev *pdev;
        dma_addr_t mapping;
        u32 offset;
@@ -192,7 +193,10 @@ void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
        mapping = rx_buf->mapping - bp->rx_dma_offset;
        dma_sync_single_for_cpu(&pdev->dev, mapping + offset, *len, bp->rx_dir);
 
-       xdp_init_buff(xdp, BNXT_PAGE_MODE_BUF_SIZE + offset, &rxr->xdp_rxq);
+       if (bp->xdp_has_frags)
+               buflen = BNXT_PAGE_MODE_BUF_SIZE + offset;
+
+       xdp_init_buff(xdp, buflen, &rxr->xdp_rxq);
        xdp_prepare_buff(xdp, *data_ptr - offset, offset, *len, false);
 }
 
@@ -397,8 +401,10 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)
                netdev_warn(dev, "ethtool rx/tx channels must be combined to support XDP.\n");
                return -EOPNOTSUPP;
        }
-       if (prog)
+       if (prog) {
                tx_xdp = bp->rx_nr_rings;
+               bp->xdp_has_frags = prog->aux->xdp_has_frags;
+       }
 
        tc = netdev_get_num_tc(dev);
        if (!tc)
index db1e9d8..89889d8 100644 (file)
@@ -18076,16 +18076,20 @@ static void tg3_shutdown(struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
        struct tg3 *tp = netdev_priv(dev);
 
+       tg3_reset_task_cancel(tp);
+
        rtnl_lock();
+
        netif_device_detach(dev);
 
        if (netif_running(dev))
                dev_close(dev);
 
-       if (system_state == SYSTEM_POWER_OFF)
-               tg3_power_down(tp);
+       tg3_power_down(tp);
 
        rtnl_unlock();
+
+       pci_disable_device(pdev);
 }
 
 /**
index 9e6de2f..6dae768 100644 (file)
@@ -1919,7 +1919,7 @@ static void gmac_get_stats64(struct net_device *netdev,
 
        /* Racing with RX NAPI */
        do {
-               start = u64_stats_fetch_begin(&port->rx_stats_syncp);
+               start = u64_stats_fetch_begin_irq(&port->rx_stats_syncp);
 
                stats->rx_packets = port->stats.rx_packets;
                stats->rx_bytes = port->stats.rx_bytes;
@@ -1931,11 +1931,11 @@ static void gmac_get_stats64(struct net_device *netdev,
                stats->rx_crc_errors = port->stats.rx_crc_errors;
                stats->rx_frame_errors = port->stats.rx_frame_errors;
 
-       } while (u64_stats_fetch_retry(&port->rx_stats_syncp, start));
+       } while (u64_stats_fetch_retry_irq(&port->rx_stats_syncp, start));
 
        /* Racing with MIB and TX completion interrupts */
        do {
-               start = u64_stats_fetch_begin(&port->ir_stats_syncp);
+               start = u64_stats_fetch_begin_irq(&port->ir_stats_syncp);
 
                stats->tx_errors = port->stats.tx_errors;
                stats->tx_packets = port->stats.tx_packets;
@@ -1945,15 +1945,15 @@ static void gmac_get_stats64(struct net_device *netdev,
                stats->rx_missed_errors = port->stats.rx_missed_errors;
                stats->rx_fifo_errors = port->stats.rx_fifo_errors;
 
-       } while (u64_stats_fetch_retry(&port->ir_stats_syncp, start));
+       } while (u64_stats_fetch_retry_irq(&port->ir_stats_syncp, start));
 
        /* Racing with hard_start_xmit */
        do {
-               start = u64_stats_fetch_begin(&port->tx_stats_syncp);
+               start = u64_stats_fetch_begin_irq(&port->tx_stats_syncp);
 
                stats->tx_dropped = port->stats.tx_dropped;
 
-       } while (u64_stats_fetch_retry(&port->tx_stats_syncp, start));
+       } while (u64_stats_fetch_retry_irq(&port->tx_stats_syncp, start));
 
        stats->rx_dropped += stats->rx_missed_errors;
 }
@@ -2031,18 +2031,18 @@ static void gmac_get_ethtool_stats(struct net_device *netdev,
        /* Racing with MIB interrupt */
        do {
                p = values;
-               start = u64_stats_fetch_begin(&port->ir_stats_syncp);
+               start = u64_stats_fetch_begin_irq(&port->ir_stats_syncp);
 
                for (i = 0; i < RX_STATS_NUM; i++)
                        *p++ = port->hw_stats[i];
 
-       } while (u64_stats_fetch_retry(&port->ir_stats_syncp, start));
+       } while (u64_stats_fetch_retry_irq(&port->ir_stats_syncp, start));
        values = p;
 
        /* Racing with RX NAPI */
        do {
                p = values;
-               start = u64_stats_fetch_begin(&port->rx_stats_syncp);
+               start = u64_stats_fetch_begin_irq(&port->rx_stats_syncp);
 
                for (i = 0; i < RX_STATUS_NUM; i++)
                        *p++ = port->rx_stats[i];
@@ -2050,13 +2050,13 @@ static void gmac_get_ethtool_stats(struct net_device *netdev,
                        *p++ = port->rx_csum_stats[i];
                *p++ = port->rx_napi_exits;
 
-       } while (u64_stats_fetch_retry(&port->rx_stats_syncp, start));
+       } while (u64_stats_fetch_retry_irq(&port->rx_stats_syncp, start));
        values = p;
 
        /* Racing with TX start_xmit */
        do {
                p = values;
-               start = u64_stats_fetch_begin(&port->tx_stats_syncp);
+               start = u64_stats_fetch_begin_irq(&port->tx_stats_syncp);
 
                for (i = 0; i < TX_MAX_FRAGS; i++) {
                        *values++ = port->tx_frag_stats[i];
@@ -2065,7 +2065,7 @@ static void gmac_get_ethtool_stats(struct net_device *netdev,
                *values++ = port->tx_frags_linearized;
                *values++ = port->tx_hw_csummed;
 
-       } while (u64_stats_fetch_retry(&port->tx_stats_syncp, start));
+       } while (u64_stats_fetch_retry_irq(&port->tx_stats_syncp, start));
 }
 
 static int gmac_get_ksettings(struct net_device *netdev,
index 4563457..a770bab 100644 (file)
@@ -2886,6 +2886,7 @@ static void dpaa_adjust_link(struct net_device *net_dev)
 
 /* The Aquantia PHYs are capable of performing rate adaptation */
 #define PHY_VEND_AQUANTIA      0x03a1b400
+#define PHY_VEND_AQUANTIA2     0x31c31c00
 
 static int dpaa_phy_init(struct net_device *net_dev)
 {
@@ -2893,6 +2894,7 @@ static int dpaa_phy_init(struct net_device *net_dev)
        struct mac_device *mac_dev;
        struct phy_device *phy_dev;
        struct dpaa_priv *priv;
+       u32 phy_vendor;
 
        priv = netdev_priv(net_dev);
        mac_dev = priv->mac_dev;
@@ -2905,9 +2907,11 @@ static int dpaa_phy_init(struct net_device *net_dev)
                return -ENODEV;
        }
 
+       phy_vendor = phy_dev->drv->phy_id & GENMASK(31, 10);
        /* Unless the PHY is capable of rate adaptation */
        if (mac_dev->phy_if != PHY_INTERFACE_MODE_XGMII ||
-           ((phy_dev->drv->phy_id & GENMASK(31, 10)) != PHY_VEND_AQUANTIA)) {
+           (phy_vendor != PHY_VEND_AQUANTIA &&
+            phy_vendor != PHY_VEND_AQUANTIA2)) {
                /* remove any features not supported by the controller */
                ethtool_convert_legacy_u32_to_link_mode(mask,
                                                        mac_dev->if_support);
index ed7301b..d77ee89 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/clocksource.h>
 #include <linux/net_tstamp.h>
+#include <linux/pm_qos.h>
 #include <linux/ptp_clock_kernel.h>
 #include <linux/timecounter.h>
 
@@ -498,6 +499,9 @@ struct bufdesc_ex {
 /* i.MX8MQ SoC integration mix wakeup interrupt signal into "int2" interrupt line. */
 #define FEC_QUIRK_WAKEUP_FROM_INT2     (1 << 22)
 
+/* i.MX6Q adds pm_qos support */
+#define FEC_QUIRK_HAS_PMQOS                    BIT(23)
+
 struct bufdesc_prop {
        int qid;
        /* Address of Rx and Tx buffers */
@@ -557,7 +561,6 @@ struct fec_enet_private {
        struct clk *clk_2x_txclk;
 
        bool ptp_clk_on;
-       struct mutex ptp_clk_mutex;
        unsigned int num_tx_queues;
        unsigned int num_rx_queues;
 
@@ -608,6 +611,7 @@ struct fec_enet_private {
        struct delayed_work time_keep;
        struct regulator *reg_phy;
        struct fec_stop_mode_gpr stop_gpr;
+       struct pm_qos_request pm_qos_req;
 
        unsigned int tx_align;
        unsigned int rx_align;
@@ -634,6 +638,13 @@ struct fec_enet_private {
        int pps_enable;
        unsigned int next_counter;
 
+       struct {
+               struct timespec64 ts_phc;
+               u64 ns_sys;
+               u32 at_corr;
+               u8 at_inc_corr;
+       } ptp_saved_state;
+
        u64 ethtool_stats[];
 };
 
@@ -644,5 +655,8 @@ void fec_ptp_disable_hwts(struct net_device *ndev);
 int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr);
 int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr);
 
+void fec_ptp_save_state(struct fec_enet_private *fep);
+int fec_ptp_restore_state(struct fec_enet_private *fep);
+
 /****************************************************************************/
 #endif /* FEC_H */
index e8e2aa1..6152f6d 100644 (file)
@@ -111,7 +111,8 @@ static const struct fec_devinfo fec_imx6q_info = {
        .quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
                  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
                  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358 |
-                 FEC_QUIRK_HAS_RACC | FEC_QUIRK_CLEAR_SETUP_MII,
+                 FEC_QUIRK_HAS_RACC | FEC_QUIRK_CLEAR_SETUP_MII |
+                 FEC_QUIRK_HAS_PMQOS,
 };
 
 static const struct fec_devinfo fec_mvf600_info = {
@@ -285,8 +286,11 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
 #define FEC_MMFR_TA            (2 << 16)
 #define FEC_MMFR_DATA(v)       (v & 0xffff)
 /* FEC ECR bits definition */
-#define FEC_ECR_MAGICEN                (1 << 2)
-#define FEC_ECR_SLEEP          (1 << 3)
+#define FEC_ECR_RESET   BIT(0)
+#define FEC_ECR_ETHEREN BIT(1)
+#define FEC_ECR_MAGICEN BIT(2)
+#define FEC_ECR_SLEEP   BIT(3)
+#define FEC_ECR_EN1588  BIT(4)
 
 #define FEC_MII_TIMEOUT                30000 /* us */
 
@@ -982,6 +986,9 @@ fec_restart(struct net_device *ndev)
        u32 temp_mac[2];
        u32 rcntl = OPT_FRAME_SIZE | 0x04;
        u32 ecntl = 0x2; /* ETHEREN */
+       struct ptp_clock_request ptp_rq = { .type = PTP_CLK_REQ_PPS };
+
+       fec_ptp_save_state(fep);
 
        /* Whack a reset.  We should wait for this.
         * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
@@ -1135,7 +1142,7 @@ fec_restart(struct net_device *ndev)
        }
 
        if (fep->bufdesc_ex)
-               ecntl |= (1 << 4);
+               ecntl |= FEC_ECR_EN1588;
 
        if (fep->quirks & FEC_QUIRK_DELAYED_CLKS_SUPPORT &&
            fep->rgmii_txc_dly)
@@ -1156,6 +1163,14 @@ fec_restart(struct net_device *ndev)
        if (fep->bufdesc_ex)
                fec_ptp_start_cyclecounter(ndev);
 
+       /* Restart PPS if needed */
+       if (fep->pps_enable) {
+               /* Clear flag so fec_ptp_enable_pps() doesn't return immediately */
+               fep->pps_enable = 0;
+               fec_ptp_restore_state(fep);
+               fep->ptp_caps.enable(&fep->ptp_caps, &ptp_rq, 1);
+       }
+
        /* Enable interrupts we wish to service */
        if (fep->link)
                writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
@@ -1206,6 +1221,8 @@ fec_stop(struct net_device *ndev)
        struct fec_enet_private *fep = netdev_priv(ndev);
        u32 rmii_mode = readl(fep->hwp + FEC_R_CNTRL) & (1 << 8);
        u32 val;
+       struct ptp_clock_request ptp_rq = { .type = PTP_CLK_REQ_PPS };
+       u32 ecntl = 0;
 
        /* We cannot expect a graceful transmit stop without link !!! */
        if (fep->link) {
@@ -1215,6 +1232,8 @@ fec_stop(struct net_device *ndev)
                        netdev_err(ndev, "Graceful transmit stop did not complete!\n");
        }
 
+       fec_ptp_save_state(fep);
+
        /* Whack a reset.  We should wait for this.
         * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
         * instead of reset MAC itself.
@@ -1234,12 +1253,28 @@ fec_stop(struct net_device *ndev)
        writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
        writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
 
+       if (fep->bufdesc_ex)
+               ecntl |= FEC_ECR_EN1588;
+
        /* We have to keep ENET enabled to have MII interrupt stay working */
        if (fep->quirks & FEC_QUIRK_ENET_MAC &&
                !(fep->wol_flag & FEC_WOL_FLAG_SLEEP_ON)) {
-               writel(2, fep->hwp + FEC_ECNTRL);
+               ecntl |= FEC_ECR_ETHEREN;
                writel(rmii_mode, fep->hwp + FEC_R_CNTRL);
        }
+
+       writel(ecntl, fep->hwp + FEC_ECNTRL);
+
+       if (fep->bufdesc_ex)
+               fec_ptp_start_cyclecounter(ndev);
+
+       /* Restart PPS if needed */
+       if (fep->pps_enable) {
+               /* Clear flag so fec_ptp_enable_pps() doesn't return immediately */
+               fep->pps_enable = 0;
+               fec_ptp_restore_state(fep);
+               fep->ptp_caps.enable(&fep->ptp_caps, &ptp_rq, 1);
+       }
 }
 
 
@@ -1994,6 +2029,7 @@ static void fec_enet_phy_reset_after_clk_enable(struct net_device *ndev)
 static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
 {
        struct fec_enet_private *fep = netdev_priv(ndev);
+       unsigned long flags;
        int ret;
 
        if (enable) {
@@ -2002,15 +2038,15 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
                        return ret;
 
                if (fep->clk_ptp) {
-                       mutex_lock(&fep->ptp_clk_mutex);
+                       spin_lock_irqsave(&fep->tmreg_lock, flags);
                        ret = clk_prepare_enable(fep->clk_ptp);
                        if (ret) {
-                               mutex_unlock(&fep->ptp_clk_mutex);
+                               spin_unlock_irqrestore(&fep->tmreg_lock, flags);
                                goto failed_clk_ptp;
                        } else {
                                fep->ptp_clk_on = true;
                        }
-                       mutex_unlock(&fep->ptp_clk_mutex);
+                       spin_unlock_irqrestore(&fep->tmreg_lock, flags);
                }
 
                ret = clk_prepare_enable(fep->clk_ref);
@@ -2025,10 +2061,10 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
        } else {
                clk_disable_unprepare(fep->clk_enet_out);
                if (fep->clk_ptp) {
-                       mutex_lock(&fep->ptp_clk_mutex);
+                       spin_lock_irqsave(&fep->tmreg_lock, flags);
                        clk_disable_unprepare(fep->clk_ptp);
                        fep->ptp_clk_on = false;
-                       mutex_unlock(&fep->ptp_clk_mutex);
+                       spin_unlock_irqrestore(&fep->tmreg_lock, flags);
                }
                clk_disable_unprepare(fep->clk_ref);
                clk_disable_unprepare(fep->clk_2x_txclk);
@@ -2041,10 +2077,10 @@ failed_clk_2x_txclk:
                clk_disable_unprepare(fep->clk_ref);
 failed_clk_ref:
        if (fep->clk_ptp) {
-               mutex_lock(&fep->ptp_clk_mutex);
+               spin_lock_irqsave(&fep->tmreg_lock, flags);
                clk_disable_unprepare(fep->clk_ptp);
                fep->ptp_clk_on = false;
-               mutex_unlock(&fep->ptp_clk_mutex);
+               spin_unlock_irqrestore(&fep->tmreg_lock, flags);
        }
 failed_clk_ptp:
        clk_disable_unprepare(fep->clk_enet_out);
@@ -3210,6 +3246,9 @@ fec_enet_open(struct net_device *ndev)
        if (fep->quirks & FEC_QUIRK_ERR006687)
                imx6q_cpuidle_fec_irqs_used();
 
+       if (fep->quirks & FEC_QUIRK_HAS_PMQOS)
+               cpu_latency_qos_add_request(&fep->pm_qos_req, 0);
+
        napi_enable(&fep->napi);
        phy_start(ndev->phydev);
        netif_tx_start_all_queues(ndev);
@@ -3251,6 +3290,9 @@ fec_enet_close(struct net_device *ndev)
        fec_enet_update_ethtool_stats(ndev);
 
        fec_enet_clk_enable(ndev, false);
+       if (fep->quirks & FEC_QUIRK_HAS_PMQOS)
+               cpu_latency_qos_remove_request(&fep->pm_qos_req);
+
        pinctrl_pm_select_sleep_state(&fep->pdev->dev);
        pm_runtime_mark_last_busy(&fep->pdev->dev);
        pm_runtime_put_autosuspend(&fep->pdev->dev);
@@ -3873,7 +3915,7 @@ fec_probe(struct platform_device *pdev)
        }
 
        fep->ptp_clk_on = false;
-       mutex_init(&fep->ptp_clk_mutex);
+       spin_lock_init(&fep->tmreg_lock);
 
        /* clk_ref is optional, depends on board */
        fep->clk_ref = devm_clk_get_optional(&pdev->dev, "enet_clk_ref");
index 3dc3c0b..8dd5a26 100644 (file)
@@ -365,21 +365,19 @@ static int fec_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
  */
 static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
-       struct fec_enet_private *adapter =
+       struct fec_enet_private *fep =
            container_of(ptp, struct fec_enet_private, ptp_caps);
        u64 ns;
        unsigned long flags;
 
-       mutex_lock(&adapter->ptp_clk_mutex);
+       spin_lock_irqsave(&fep->tmreg_lock, flags);
        /* Check the ptp clock */
-       if (!adapter->ptp_clk_on) {
-               mutex_unlock(&adapter->ptp_clk_mutex);
+       if (!fep->ptp_clk_on) {
+               spin_unlock_irqrestore(&fep->tmreg_lock, flags);
                return -EINVAL;
        }
-       spin_lock_irqsave(&adapter->tmreg_lock, flags);
-       ns = timecounter_read(&adapter->tc);
-       spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
-       mutex_unlock(&adapter->ptp_clk_mutex);
+       ns = timecounter_read(&fep->tc);
+       spin_unlock_irqrestore(&fep->tmreg_lock, flags);
 
        *ts = ns_to_timespec64(ns);
 
@@ -404,10 +402,10 @@ static int fec_ptp_settime(struct ptp_clock_info *ptp,
        unsigned long flags;
        u32 counter;
 
-       mutex_lock(&fep->ptp_clk_mutex);
+       spin_lock_irqsave(&fep->tmreg_lock, flags);
        /* Check the ptp clock */
        if (!fep->ptp_clk_on) {
-               mutex_unlock(&fep->ptp_clk_mutex);
+               spin_unlock_irqrestore(&fep->tmreg_lock, flags);
                return -EINVAL;
        }
 
@@ -417,11 +415,9 @@ static int fec_ptp_settime(struct ptp_clock_info *ptp,
         */
        counter = ns & fep->cc.mask;
 
-       spin_lock_irqsave(&fep->tmreg_lock, flags);
        writel(counter, fep->hwp + FEC_ATIME);
        timecounter_init(&fep->tc, &fep->cc, ns);
        spin_unlock_irqrestore(&fep->tmreg_lock, flags);
-       mutex_unlock(&fep->ptp_clk_mutex);
        return 0;
 }
 
@@ -518,13 +514,11 @@ static void fec_time_keep(struct work_struct *work)
        struct fec_enet_private *fep = container_of(dwork, struct fec_enet_private, time_keep);
        unsigned long flags;
 
-       mutex_lock(&fep->ptp_clk_mutex);
+       spin_lock_irqsave(&fep->tmreg_lock, flags);
        if (fep->ptp_clk_on) {
-               spin_lock_irqsave(&fep->tmreg_lock, flags);
                timecounter_read(&fep->tc);
-               spin_unlock_irqrestore(&fep->tmreg_lock, flags);
        }
-       mutex_unlock(&fep->ptp_clk_mutex);
+       spin_unlock_irqrestore(&fep->tmreg_lock, flags);
 
        schedule_delayed_work(&fep->time_keep, HZ);
 }
@@ -599,8 +593,6 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx)
        }
        fep->ptp_inc = NSEC_PER_SEC / fep->cycle_speed;
 
-       spin_lock_init(&fep->tmreg_lock);
-
        fec_ptp_start_cyclecounter(ndev);
 
        INIT_DELAYED_WORK(&fep->time_keep, fec_time_keep);
@@ -633,7 +625,36 @@ void fec_ptp_stop(struct platform_device *pdev)
        struct net_device *ndev = platform_get_drvdata(pdev);
        struct fec_enet_private *fep = netdev_priv(ndev);
 
+       if (fep->pps_enable)
+               fec_ptp_enable_pps(fep, 0);
+
        cancel_delayed_work_sync(&fep->time_keep);
        if (fep->ptp_clock)
                ptp_clock_unregister(fep->ptp_clock);
 }
+
+void fec_ptp_save_state(struct fec_enet_private *fep)
+{
+       u32 atime_inc_corr;
+
+       fec_ptp_gettime(&fep->ptp_caps, &fep->ptp_saved_state.ts_phc);
+       fep->ptp_saved_state.ns_sys = ktime_get_ns();
+
+       fep->ptp_saved_state.at_corr = readl(fep->hwp + FEC_ATIME_CORR);
+       atime_inc_corr = readl(fep->hwp + FEC_ATIME_INC) & FEC_T_INC_CORR_MASK;
+       fep->ptp_saved_state.at_inc_corr = (u8)(atime_inc_corr >> FEC_T_INC_CORR_OFFSET);
+}
+
+int fec_ptp_restore_state(struct fec_enet_private *fep)
+{
+       u32 atime_inc = readl(fep->hwp + FEC_ATIME_INC) & FEC_T_INC_MASK;
+       u64 ns_sys;
+
+       writel(fep->ptp_saved_state.at_corr, fep->hwp + FEC_ATIME_CORR);
+       atime_inc |= ((u32)fep->ptp_saved_state.at_inc_corr) << FEC_T_INC_CORR_OFFSET;
+       writel(atime_inc, fep->hwp + FEC_ATIME_INC);
+
+       ns_sys = ktime_get_ns() - fep->ptp_saved_state.ns_sys;
+       timespec64_add_ns(&fep->ptp_saved_state.ts_phc, ns_sys);
+       return fec_ptp_settime(&fep->ptp_caps, &fep->ptp_saved_state.ts_phc);
+}
index 53b7e95..671f511 100644 (file)
@@ -206,9 +206,9 @@ struct funeth_rxq {
 
 #define FUN_QSTAT_READ(q, seq, stats_copy) \
        do { \
-               seq = u64_stats_fetch_begin(&(q)->syncp); \
+               seq = u64_stats_fetch_begin_irq(&(q)->syncp); \
                stats_copy = (q)->stats; \
-       } while (u64_stats_fetch_retry(&(q)->syncp, (seq)))
+       } while (u64_stats_fetch_retry_irq(&(q)->syncp, (seq)))
 
 #define FUN_INT_NAME_LEN (IFNAMSIZ + 16)
 
index 50b3849..7b9a2d9 100644 (file)
@@ -177,14 +177,14 @@ gve_get_ethtool_stats(struct net_device *netdev,
                                struct gve_rx_ring *rx = &priv->rx[ring];
 
                                start =
-                                 u64_stats_fetch_begin(&priv->rx[ring].statss);
+                                 u64_stats_fetch_begin_irq(&priv->rx[ring].statss);
                                tmp_rx_pkts = rx->rpackets;
                                tmp_rx_bytes = rx->rbytes;
                                tmp_rx_skb_alloc_fail = rx->rx_skb_alloc_fail;
                                tmp_rx_buf_alloc_fail = rx->rx_buf_alloc_fail;
                                tmp_rx_desc_err_dropped_pkt =
                                        rx->rx_desc_err_dropped_pkt;
-                       } while (u64_stats_fetch_retry(&priv->rx[ring].statss,
+                       } while (u64_stats_fetch_retry_irq(&priv->rx[ring].statss,
                                                       start));
                        rx_pkts += tmp_rx_pkts;
                        rx_bytes += tmp_rx_bytes;
@@ -198,10 +198,10 @@ gve_get_ethtool_stats(struct net_device *netdev,
                if (priv->tx) {
                        do {
                                start =
-                                 u64_stats_fetch_begin(&priv->tx[ring].statss);
+                                 u64_stats_fetch_begin_irq(&priv->tx[ring].statss);
                                tmp_tx_pkts = priv->tx[ring].pkt_done;
                                tmp_tx_bytes = priv->tx[ring].bytes_done;
-                       } while (u64_stats_fetch_retry(&priv->tx[ring].statss,
+                       } while (u64_stats_fetch_retry_irq(&priv->tx[ring].statss,
                                                       start));
                        tx_pkts += tmp_tx_pkts;
                        tx_bytes += tmp_tx_bytes;
@@ -259,13 +259,13 @@ gve_get_ethtool_stats(struct net_device *netdev,
                        data[i++] = rx->fill_cnt - rx->cnt;
                        do {
                                start =
-                                 u64_stats_fetch_begin(&priv->rx[ring].statss);
+                                 u64_stats_fetch_begin_irq(&priv->rx[ring].statss);
                                tmp_rx_bytes = rx->rbytes;
                                tmp_rx_skb_alloc_fail = rx->rx_skb_alloc_fail;
                                tmp_rx_buf_alloc_fail = rx->rx_buf_alloc_fail;
                                tmp_rx_desc_err_dropped_pkt =
                                        rx->rx_desc_err_dropped_pkt;
-                       } while (u64_stats_fetch_retry(&priv->rx[ring].statss,
+                       } while (u64_stats_fetch_retry_irq(&priv->rx[ring].statss,
                                                       start));
                        data[i++] = tmp_rx_bytes;
                        data[i++] = rx->rx_cont_packet_cnt;
@@ -331,9 +331,9 @@ gve_get_ethtool_stats(struct net_device *netdev,
                        }
                        do {
                                start =
-                                 u64_stats_fetch_begin(&priv->tx[ring].statss);
+                                 u64_stats_fetch_begin_irq(&priv->tx[ring].statss);
                                tmp_tx_bytes = tx->bytes_done;
-                       } while (u64_stats_fetch_retry(&priv->tx[ring].statss,
+                       } while (u64_stats_fetch_retry_irq(&priv->tx[ring].statss,
                                                       start));
                        data[i++] = tmp_tx_bytes;
                        data[i++] = tx->wake_queue;
index 6cafee5..044db3e 100644 (file)
@@ -51,10 +51,10 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s)
                for (ring = 0; ring < priv->rx_cfg.num_queues; ring++) {
                        do {
                                start =
-                                 u64_stats_fetch_begin(&priv->rx[ring].statss);
+                                 u64_stats_fetch_begin_irq(&priv->rx[ring].statss);
                                packets = priv->rx[ring].rpackets;
                                bytes = priv->rx[ring].rbytes;
-                       } while (u64_stats_fetch_retry(&priv->rx[ring].statss,
+                       } while (u64_stats_fetch_retry_irq(&priv->rx[ring].statss,
                                                       start));
                        s->rx_packets += packets;
                        s->rx_bytes += bytes;
@@ -64,10 +64,10 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s)
                for (ring = 0; ring < priv->tx_cfg.num_queues; ring++) {
                        do {
                                start =
-                                 u64_stats_fetch_begin(&priv->tx[ring].statss);
+                                 u64_stats_fetch_begin_irq(&priv->tx[ring].statss);
                                packets = priv->tx[ring].pkt_done;
                                bytes = priv->tx[ring].bytes_done;
-                       } while (u64_stats_fetch_retry(&priv->tx[ring].statss,
+                       } while (u64_stats_fetch_retry_irq(&priv->tx[ring].statss,
                                                       start));
                        s->tx_packets += packets;
                        s->tx_bytes += bytes;
@@ -1274,9 +1274,9 @@ void gve_handle_report_stats(struct gve_priv *priv)
                        }
 
                        do {
-                               start = u64_stats_fetch_begin(&priv->tx[idx].statss);
+                               start = u64_stats_fetch_begin_irq(&priv->tx[idx].statss);
                                tx_bytes = priv->tx[idx].bytes_done;
-                       } while (u64_stats_fetch_retry(&priv->tx[idx].statss, start));
+                       } while (u64_stats_fetch_retry_irq(&priv->tx[idx].statss, start));
                        stats[stats_idx++] = (struct stats) {
                                .stat_name = cpu_to_be32(TX_WAKE_CNT),
                                .value = cpu_to_be64(priv->tx[idx].wake_queue),
index a866bea..e5828a6 100644 (file)
@@ -74,14 +74,14 @@ void hinic_rxq_get_stats(struct hinic_rxq *rxq, struct hinic_rxq_stats *stats)
        unsigned int start;
 
        do {
-               start = u64_stats_fetch_begin(&rxq_stats->syncp);
+               start = u64_stats_fetch_begin_irq(&rxq_stats->syncp);
                stats->pkts = rxq_stats->pkts;
                stats->bytes = rxq_stats->bytes;
                stats->errors = rxq_stats->csum_errors +
                                rxq_stats->other_errors;
                stats->csum_errors = rxq_stats->csum_errors;
                stats->other_errors = rxq_stats->other_errors;
-       } while (u64_stats_fetch_retry(&rxq_stats->syncp, start));
+       } while (u64_stats_fetch_retry_irq(&rxq_stats->syncp, start));
 }
 
 /**
index 5051cdf..3b6c7b5 100644 (file)
@@ -99,14 +99,14 @@ void hinic_txq_get_stats(struct hinic_txq *txq, struct hinic_txq_stats *stats)
        unsigned int start;
 
        do {
-               start = u64_stats_fetch_begin(&txq_stats->syncp);
+               start = u64_stats_fetch_begin_irq(&txq_stats->syncp);
                stats->pkts    = txq_stats->pkts;
                stats->bytes   = txq_stats->bytes;
                stats->tx_busy = txq_stats->tx_busy;
                stats->tx_wake = txq_stats->tx_wake;
                stats->tx_dropped = txq_stats->tx_dropped;
                stats->big_frags_pkts = txq_stats->big_frags_pkts;
-       } while (u64_stats_fetch_retry(&txq_stats->syncp, start));
+       } while (u64_stats_fetch_retry_irq(&txq_stats->syncp, start));
 }
 
 /**
index ea2bb01..10d7a98 100644 (file)
@@ -177,6 +177,10 @@ void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset)
                        "Cannot locate client instance close routine\n");
                return;
        }
+       if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
+               dev_dbg(&pf->pdev->dev, "Client is not open, abort close\n");
+               return;
+       }
        cdev->client->ops->close(&cdev->lan_info, cdev->client, reset);
        clear_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
        i40e_client_release_qvlist(&cdev->lan_info);
@@ -429,7 +433,6 @@ void i40e_client_subtask(struct i40e_pf *pf)
                                /* Remove failed client instance */
                                clear_bit(__I40E_CLIENT_INSTANCE_OPENED,
                                          &cdev->state);
-                               i40e_client_del_instance(pf);
                                return;
                        }
                }
index 156e92c..e9cd0fa 100644 (file)
@@ -4485,7 +4485,7 @@ static int i40e_check_fdir_input_set(struct i40e_vsi *vsi,
                                    (struct in6_addr *)&ipv6_full_mask))
                        new_mask |= I40E_L3_V6_DST_MASK;
                else if (ipv6_addr_any((struct in6_addr *)
-                                      &usr_ip6_spec->ip6src))
+                                      &usr_ip6_spec->ip6dst))
                        new_mask &= ~I40E_L3_V6_DST_MASK;
                else
                        return -EOPNOTSUPP;
index 9f1d5de..10c1e1e 100644 (file)
@@ -6659,6 +6659,9 @@ static int i40e_configure_queue_channels(struct i40e_vsi *vsi)
                        vsi->tc_seid_map[i] = ch->seid;
                }
        }
+
+       /* reset to reconfigure TX queue contexts */
+       i40e_do_reset(vsi->back, I40E_PF_RESET_FLAG, true);
        return ret;
 
 err_free:
index d422616..69e67eb 100644 (file)
@@ -3688,7 +3688,8 @@ u16 i40e_lan_select_queue(struct net_device *netdev,
        u8 prio;
 
        /* is DCB enabled at all? */
-       if (vsi->tc_config.numtc == 1)
+       if (vsi->tc_config.numtc == 1 ||
+           i40e_is_tc_mqprio_enabled(vsi->back))
                return netdev_pick_tx(netdev, skb, sb_dev);
 
        prio = skb->priority;
index f39440a..10aa99d 100644 (file)
@@ -2877,6 +2877,11 @@ static void iavf_reset_task(struct work_struct *work)
        int i = 0, err;
        bool running;
 
+       /* Detach interface to avoid subsequent NDO callbacks */
+       rtnl_lock();
+       netif_device_detach(netdev);
+       rtnl_unlock();
+
        /* When device is being removed it doesn't make sense to run the reset
         * task, just return in such a case.
         */
@@ -2884,7 +2889,7 @@ static void iavf_reset_task(struct work_struct *work)
                if (adapter->state != __IAVF_REMOVE)
                        queue_work(iavf_wq, &adapter->reset_task);
 
-               return;
+               goto reset_finish;
        }
 
        while (!mutex_trylock(&adapter->client_lock))
@@ -2954,7 +2959,6 @@ continue_reset:
 
        if (running) {
                netif_carrier_off(netdev);
-               netif_tx_stop_all_queues(netdev);
                adapter->link_up = false;
                iavf_napi_disable_all(adapter);
        }
@@ -3084,7 +3088,7 @@ continue_reset:
        mutex_unlock(&adapter->client_lock);
        mutex_unlock(&adapter->crit_lock);
 
-       return;
+       goto reset_finish;
 reset_err:
        if (running) {
                set_bit(__IAVF_VSI_DOWN, adapter->vsi.state);
@@ -3095,6 +3099,10 @@ reset_err:
        mutex_unlock(&adapter->client_lock);
        mutex_unlock(&adapter->crit_lock);
        dev_err(&adapter->pdev->dev, "failed to allocate resources during reinit\n");
+reset_finish:
+       rtnl_lock();
+       netif_device_attach(netdev);
+       rtnl_unlock();
 }
 
 /**
index cc5b85a..841fa14 100644 (file)
@@ -684,8 +684,8 @@ static inline void ice_set_ring_xdp(struct ice_tx_ring *ring)
  * ice_xsk_pool - get XSK buffer pool bound to a ring
  * @ring: Rx ring to use
  *
- * Returns a pointer to xdp_umem structure if there is a buffer pool present,
- * NULL otherwise.
+ * Returns a pointer to xsk_buff_pool structure if there is a buffer pool
+ * present, NULL otherwise.
  */
 static inline struct xsk_buff_pool *ice_xsk_pool(struct ice_rx_ring *ring)
 {
@@ -699,23 +699,33 @@ static inline struct xsk_buff_pool *ice_xsk_pool(struct ice_rx_ring *ring)
 }
 
 /**
- * ice_tx_xsk_pool - get XSK buffer pool bound to a ring
- * @ring: Tx ring to use
+ * ice_tx_xsk_pool - assign XSK buff pool to XDP ring
+ * @vsi: pointer to VSI
+ * @qid: index of a queue to look at XSK buff pool presence
  *
- * Returns a pointer to xdp_umem structure if there is a buffer pool present,
- * NULL otherwise. Tx equivalent of ice_xsk_pool.
+ * Sets XSK buff pool pointer on XDP ring.
+ *
+ * XDP ring is picked from Rx ring, whereas Rx ring is picked based on provided
+ * queue id. Reason for doing so is that queue vectors might have assigned more
+ * than one XDP ring, e.g. when user reduced the queue count on netdev; Rx ring
+ * carries a pointer to one of these XDP rings for its own purposes, such as
+ * handling XDP_TX action, therefore we can piggyback here on the
+ * rx_ring->xdp_ring assignment that was done during XDP rings initialization.
  */
-static inline struct xsk_buff_pool *ice_tx_xsk_pool(struct ice_tx_ring *ring)
+static inline void ice_tx_xsk_pool(struct ice_vsi *vsi, u16 qid)
 {
-       struct ice_vsi *vsi = ring->vsi;
-       u16 qid;
+       struct ice_tx_ring *ring;
 
-       qid = ring->q_index - vsi->alloc_txq;
+       ring = vsi->rx_rings[qid]->xdp_ring;
+       if (!ring)
+               return;
 
-       if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps))
-               return NULL;
+       if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps)) {
+               ring->xsk_pool = NULL;
+               return;
+       }
 
-       return xsk_get_pool_from_qid(vsi->netdev, qid);
+       ring->xsk_pool = xsk_get_pool_from_qid(vsi->netdev, qid);
 }
 
 /**
index 136d791..1e32438 100644 (file)
@@ -7,18 +7,6 @@
 #include "ice_dcb_lib.h"
 #include "ice_sriov.h"
 
-static bool ice_alloc_rx_buf_zc(struct ice_rx_ring *rx_ring)
-{
-       rx_ring->xdp_buf = kcalloc(rx_ring->count, sizeof(*rx_ring->xdp_buf), GFP_KERNEL);
-       return !!rx_ring->xdp_buf;
-}
-
-static bool ice_alloc_rx_buf(struct ice_rx_ring *rx_ring)
-{
-       rx_ring->rx_buf = kcalloc(rx_ring->count, sizeof(*rx_ring->rx_buf), GFP_KERNEL);
-       return !!rx_ring->rx_buf;
-}
-
 /**
  * __ice_vsi_get_qs_contig - Assign a contiguous chunk of queues to VSI
  * @qs_cfg: gathered variables needed for PF->VSI queues assignment
@@ -519,11 +507,8 @@ int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
                        xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev,
                                         ring->q_index, ring->q_vector->napi.napi_id);
 
-               kfree(ring->rx_buf);
                ring->xsk_pool = ice_xsk_pool(ring);
                if (ring->xsk_pool) {
-                       if (!ice_alloc_rx_buf_zc(ring))
-                               return -ENOMEM;
                        xdp_rxq_info_unreg_mem_model(&ring->xdp_rxq);
 
                        ring->rx_buf_len =
@@ -538,8 +523,6 @@ int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
                        dev_info(dev, "Registered XDP mem model MEM_TYPE_XSK_BUFF_POOL on Rx ring %d\n",
                                 ring->q_index);
                } else {
-                       if (!ice_alloc_rx_buf(ring))
-                               return -ENOMEM;
                        if (!xdp_rxq_info_is_reg(&ring->xdp_rxq))
                                /* coverity[check_return] */
                                xdp_rxq_info_reg(&ring->xdp_rxq,
index 733c455..0c4ec92 100644 (file)
@@ -1986,8 +1986,8 @@ int ice_vsi_cfg_xdp_txqs(struct ice_vsi *vsi)
        if (ret)
                return ret;
 
-       ice_for_each_xdp_txq(vsi, i)
-               vsi->xdp_rings[i]->xsk_pool = ice_tx_xsk_pool(vsi->xdp_rings[i]);
+       ice_for_each_rxq(vsi, i)
+               ice_tx_xsk_pool(vsi, i);
 
        return ret;
 }
index 4ecaf40..8c30eea 100644 (file)
@@ -2581,7 +2581,6 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)
                if (ice_setup_tx_ring(xdp_ring))
                        goto free_xdp_rings;
                ice_set_ring_xdp(xdp_ring);
-               xdp_ring->xsk_pool = ice_tx_xsk_pool(xdp_ring);
                spin_lock_init(&xdp_ring->tx_lock);
                for (j = 0; j < xdp_ring->count; j++) {
                        tx_desc = ICE_TX_DESC(xdp_ring, j);
@@ -2589,13 +2588,6 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)
                }
        }
 
-       ice_for_each_rxq(vsi, i) {
-               if (static_key_enabled(&ice_xdp_locking_key))
-                       vsi->rx_rings[i]->xdp_ring = vsi->xdp_rings[i % vsi->num_xdp_txq];
-               else
-                       vsi->rx_rings[i]->xdp_ring = vsi->xdp_rings[i];
-       }
-
        return 0;
 
 free_xdp_rings:
@@ -2685,6 +2677,23 @@ int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog)
                xdp_rings_rem -= xdp_rings_per_v;
        }
 
+       ice_for_each_rxq(vsi, i) {
+               if (static_key_enabled(&ice_xdp_locking_key)) {
+                       vsi->rx_rings[i]->xdp_ring = vsi->xdp_rings[i % vsi->num_xdp_txq];
+               } else {
+                       struct ice_q_vector *q_vector = vsi->rx_rings[i]->q_vector;
+                       struct ice_tx_ring *ring;
+
+                       ice_for_each_tx_ring(ring, q_vector->tx) {
+                               if (ice_ring_is_xdp(ring)) {
+                                       vsi->rx_rings[i]->xdp_ring = ring;
+                                       break;
+                               }
+                       }
+               }
+               ice_tx_xsk_pool(vsi, i);
+       }
+
        /* omit the scheduler update if in reset path; XDP queues will be
         * taken into account at the end of ice_vsi_rebuild, where
         * ice_cfg_vsi_lan is being called
@@ -2889,10 +2898,18 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
                        if (xdp_ring_err)
                                NL_SET_ERR_MSG_MOD(extack, "Setting up XDP Tx resources failed");
                }
+               /* reallocate Rx queues that are used for zero-copy */
+               xdp_ring_err = ice_realloc_zc_buf(vsi, true);
+               if (xdp_ring_err)
+                       NL_SET_ERR_MSG_MOD(extack, "Setting up XDP Rx resources failed");
        } else if (ice_is_xdp_ena_vsi(vsi) && !prog) {
                xdp_ring_err = ice_destroy_xdp_rings(vsi);
                if (xdp_ring_err)
                        NL_SET_ERR_MSG_MOD(extack, "Freeing XDP Tx resources failed");
+               /* reallocate Rx queues that were used for zero-copy */
+               xdp_ring_err = ice_realloc_zc_buf(vsi, false);
+               if (xdp_ring_err)
+                       NL_SET_ERR_MSG_MOD(extack, "Freeing XDP Rx resources failed");
        } else {
                /* safe to call even when prog == vsi->xdp_prog as
                 * dev_xdp_install in net/core/dev.c incremented prog's
@@ -3896,7 +3913,7 @@ static int ice_init_pf(struct ice_pf *pf)
 
        pf->avail_rxqs = bitmap_zalloc(pf->max_pf_rxqs, GFP_KERNEL);
        if (!pf->avail_rxqs) {
-               devm_kfree(ice_pf_to_dev(pf), pf->avail_txqs);
+               bitmap_free(pf->avail_txqs);
                pf->avail_txqs = NULL;
                return -ENOMEM;
        }
index 49ba8bf..03ce85f 100644 (file)
@@ -192,6 +192,7 @@ static int ice_qp_dis(struct ice_vsi *vsi, u16 q_idx)
        err = ice_vsi_ctrl_one_rx_ring(vsi, false, q_idx, true);
        if (err)
                return err;
+       ice_clean_rx_ring(rx_ring);
 
        ice_qvec_toggle_napi(vsi, q_vector, false);
        ice_qp_clean_rings(vsi, q_idx);
@@ -243,7 +244,7 @@ static int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx)
                if (err)
                        goto free_buf;
                ice_set_ring_xdp(xdp_ring);
-               xdp_ring->xsk_pool = ice_tx_xsk_pool(xdp_ring);
+               ice_tx_xsk_pool(vsi, q_idx);
        }
 
        err = ice_vsi_cfg_rxq(rx_ring);
@@ -317,6 +318,62 @@ ice_xsk_pool_enable(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
 }
 
 /**
+ * ice_realloc_rx_xdp_bufs - reallocate for either XSK or normal buffer
+ * @rx_ring: Rx ring
+ * @pool_present: is pool for XSK present
+ *
+ * Try allocating memory and return ENOMEM, if failed to allocate.
+ * If allocation was successful, substitute buffer with allocated one.
+ * Returns 0 on success, negative on failure
+ */
+static int
+ice_realloc_rx_xdp_bufs(struct ice_rx_ring *rx_ring, bool pool_present)
+{
+       size_t elem_size = pool_present ? sizeof(*rx_ring->xdp_buf) :
+                                         sizeof(*rx_ring->rx_buf);
+       void *sw_ring = kcalloc(rx_ring->count, elem_size, GFP_KERNEL);
+
+       if (!sw_ring)
+               return -ENOMEM;
+
+       if (pool_present) {
+               kfree(rx_ring->rx_buf);
+               rx_ring->rx_buf = NULL;
+               rx_ring->xdp_buf = sw_ring;
+       } else {
+               kfree(rx_ring->xdp_buf);
+               rx_ring->xdp_buf = NULL;
+               rx_ring->rx_buf = sw_ring;
+       }
+
+       return 0;
+}
+
+/**
+ * ice_realloc_zc_buf - reallocate XDP ZC queue pairs
+ * @vsi: Current VSI
+ * @zc: is zero copy set
+ *
+ * Reallocate buffer for rx_rings that might be used by XSK.
+ * XDP requires more memory, than rx_buf provides.
+ * Returns 0 on success, negative on failure
+ */
+int ice_realloc_zc_buf(struct ice_vsi *vsi, bool zc)
+{
+       struct ice_rx_ring *rx_ring;
+       unsigned long q;
+
+       for_each_set_bit(q, vsi->af_xdp_zc_qps,
+                        max_t(int, vsi->alloc_txq, vsi->alloc_rxq)) {
+               rx_ring = vsi->rx_rings[q];
+               if (ice_realloc_rx_xdp_bufs(rx_ring, zc))
+                       return -ENOMEM;
+       }
+
+       return 0;
+}
+
+/**
  * ice_xsk_pool_setup - enable/disable a buffer pool region depending on its state
  * @vsi: Current VSI
  * @pool: buffer pool to enable/associate to a ring, NULL to disable
@@ -329,6 +386,12 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
        bool if_running, pool_present = !!pool;
        int ret = 0, pool_failure = 0;
 
+       if (qid >= vsi->num_rxq || qid >= vsi->num_txq) {
+               netdev_err(vsi->netdev, "Please use queue id in scope of combined queues count\n");
+               pool_failure = -EINVAL;
+               goto failure;
+       }
+
        if (!is_power_of_2(vsi->rx_rings[qid]->count) ||
            !is_power_of_2(vsi->tx_rings[qid]->count)) {
                netdev_err(vsi->netdev, "Please align ring sizes to power of 2\n");
@@ -339,11 +402,17 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
        if_running = netif_running(vsi->netdev) && ice_is_xdp_ena_vsi(vsi);
 
        if (if_running) {
+               struct ice_rx_ring *rx_ring = vsi->rx_rings[qid];
+
                ret = ice_qp_dis(vsi, qid);
                if (ret) {
                        netdev_err(vsi->netdev, "ice_qp_dis error = %d\n", ret);
                        goto xsk_pool_if_up;
                }
+
+               ret = ice_realloc_rx_xdp_bufs(rx_ring, pool_present);
+               if (ret)
+                       goto xsk_pool_if_up;
        }
 
        pool_failure = pool_present ? ice_xsk_pool_enable(vsi, pool, qid) :
@@ -353,7 +422,7 @@ xsk_pool_if_up:
        if (if_running) {
                ret = ice_qp_ena(vsi, qid);
                if (!ret && pool_present)
-                       napi_schedule(&vsi->xdp_rings[qid]->q_vector->napi);
+                       napi_schedule(&vsi->rx_rings[qid]->xdp_ring->q_vector->napi);
                else if (ret)
                        netdev_err(vsi->netdev, "ice_qp_ena error = %d\n", ret);
        }
@@ -944,13 +1013,13 @@ ice_xsk_wakeup(struct net_device *netdev, u32 queue_id,
        if (!ice_is_xdp_ena_vsi(vsi))
                return -EINVAL;
 
-       if (queue_id >= vsi->num_txq)
+       if (queue_id >= vsi->num_txq || queue_id >= vsi->num_rxq)
                return -EINVAL;
 
-       if (!vsi->xdp_rings[queue_id]->xsk_pool)
-               return -EINVAL;
+       ring = vsi->rx_rings[queue_id]->xdp_ring;
 
-       ring = vsi->xdp_rings[queue_id];
+       if (!ring->xsk_pool)
+               return -EINVAL;
 
        /* The idea here is that if NAPI is running, mark a miss, so
         * it will run again. If not, trigger an interrupt and
index 21faec8..4edbe81 100644 (file)
@@ -27,6 +27,7 @@ bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi);
 void ice_xsk_clean_rx_ring(struct ice_rx_ring *rx_ring);
 void ice_xsk_clean_xdp_ring(struct ice_tx_ring *xdp_ring);
 bool ice_xmit_zc(struct ice_tx_ring *xdp_ring, u32 budget, int napi_budget);
+int ice_realloc_zc_buf(struct ice_vsi *vsi, bool zc);
 #else
 static inline bool
 ice_xmit_zc(struct ice_tx_ring __always_unused *xdp_ring,
@@ -72,5 +73,12 @@ ice_xsk_wakeup(struct net_device __always_unused *netdev,
 
 static inline void ice_xsk_clean_rx_ring(struct ice_rx_ring *rx_ring) { }
 static inline void ice_xsk_clean_xdp_ring(struct ice_tx_ring *xdp_ring) { }
+
+static inline int
+ice_realloc_zc_buf(struct ice_vsi __always_unused *vsi,
+                  bool __always_unused zc)
+{
+       return 0;
+}
 #endif /* CONFIG_XDP_SOCKETS */
 #endif /* !_ICE_XSK_H_ */
index 9f06896..f8605f5 100644 (file)
@@ -1214,7 +1214,6 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
        struct cyclecounter cc;
        unsigned long flags;
        u32 incval = 0;
-       u32 tsauxc = 0;
        u32 fuse0 = 0;
 
        /* For some of the boards below this mask is technically incorrect.
@@ -1249,18 +1248,6 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
        case ixgbe_mac_x550em_a:
        case ixgbe_mac_X550:
                cc.read = ixgbe_ptp_read_X550;
-
-               /* enable SYSTIME counter */
-               IXGBE_WRITE_REG(hw, IXGBE_SYSTIMR, 0);
-               IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0);
-               IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0);
-               tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
-               IXGBE_WRITE_REG(hw, IXGBE_TSAUXC,
-                               tsauxc & ~IXGBE_TSAUXC_DISABLE_SYSTIME);
-               IXGBE_WRITE_REG(hw, IXGBE_TSIM, IXGBE_TSIM_TXTS);
-               IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_TIMESYNC);
-
-               IXGBE_WRITE_FLUSH(hw);
                break;
        case ixgbe_mac_X540:
                cc.read = ixgbe_ptp_read_82599;
@@ -1293,6 +1280,50 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
 }
 
 /**
+ * ixgbe_ptp_init_systime - Initialize SYSTIME registers
+ * @adapter: the ixgbe private board structure
+ *
+ * Initialize and start the SYSTIME registers.
+ */
+static void ixgbe_ptp_init_systime(struct ixgbe_adapter *adapter)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+       u32 tsauxc;
+
+       switch (hw->mac.type) {
+       case ixgbe_mac_X550EM_x:
+       case ixgbe_mac_x550em_a:
+       case ixgbe_mac_X550:
+               tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
+
+               /* Reset SYSTIME registers to 0 */
+               IXGBE_WRITE_REG(hw, IXGBE_SYSTIMR, 0);
+               IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0);
+               IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0);
+
+               /* Reset interrupt settings */
+               IXGBE_WRITE_REG(hw, IXGBE_TSIM, IXGBE_TSIM_TXTS);
+               IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_TIMESYNC);
+
+               /* Activate the SYSTIME counter */
+               IXGBE_WRITE_REG(hw, IXGBE_TSAUXC,
+                               tsauxc & ~IXGBE_TSAUXC_DISABLE_SYSTIME);
+               break;
+       case ixgbe_mac_X540:
+       case ixgbe_mac_82599EB:
+               /* Reset SYSTIME registers to 0 */
+               IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0);
+               IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0);
+               break;
+       default:
+               /* Other devices aren't supported */
+               return;
+       };
+
+       IXGBE_WRITE_FLUSH(hw);
+}
+
+/**
  * ixgbe_ptp_reset
  * @adapter: the ixgbe private board structure
  *
@@ -1318,6 +1349,8 @@ void ixgbe_ptp_reset(struct ixgbe_adapter *adapter)
 
        ixgbe_ptp_start_cyclecounter(adapter);
 
+       ixgbe_ptp_init_systime(adapter);
+
        spin_lock_irqsave(&adapter->tmreg_lock, flags);
        timecounter_init(&adapter->hw_tc, &adapter->hw_cc,
                         ktime_to_ns(ktime_get_real()));
index 5edb68a..57f27cc 100644 (file)
@@ -193,6 +193,7 @@ static int xrx200_alloc_buf(struct xrx200_chan *ch, void *(*alloc)(unsigned int
 
        ch->rx_buff[ch->dma.desc] = alloc(priv->rx_skb_size);
        if (!ch->rx_buff[ch->dma.desc]) {
+               ch->rx_buff[ch->dma.desc] = buf;
                ret = -ENOMEM;
                goto skip;
        }
@@ -239,6 +240,12 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
        }
 
        skb = build_skb(buf, priv->rx_skb_size);
+       if (!skb) {
+               skb_free_frag(buf);
+               net_dev->stats.rx_dropped++;
+               return -ENOMEM;
+       }
+
        skb_reserve(skb, NET_SKB_PAD);
        skb_put(skb, len);
 
@@ -288,7 +295,7 @@ static int xrx200_poll_rx(struct napi_struct *napi, int budget)
                        if (ret == XRX200_DMA_PACKET_IN_PROGRESS)
                                continue;
                        if (ret != XRX200_DMA_PACKET_COMPLETE)
-                               return ret;
+                               break;
                        rx++;
                } else {
                        break;
index 4a3baa7..0eec05d 100644 (file)
@@ -700,10 +700,10 @@ void mvpp2_dbgfs_cleanup(struct mvpp2 *priv)
 
 void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name)
 {
-       struct dentry *mvpp2_dir, *mvpp2_root;
+       static struct dentry *mvpp2_root;
+       struct dentry *mvpp2_dir;
        int ret, i;
 
-       mvpp2_root = debugfs_lookup(MVPP2_DRIVER_NAME, NULL);
        if (!mvpp2_root)
                mvpp2_root = debugfs_create_dir(MVPP2_DRIVER_NAME, NULL);
 
index 8aff4c0..5ace460 100644 (file)
@@ -1891,10 +1891,19 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
                skb->dev = netdev;
                bytes += skb->len;
 
-               if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
+               if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
+                       hash = trxd.rxd5 & MTK_RXD5_FOE_ENTRY;
+                       if (hash != MTK_RXD5_FOE_ENTRY)
+                               skb_set_hash(skb, jhash_1word(hash, 0),
+                                            PKT_HASH_TYPE_L4);
                        rxdcsum = &trxd.rxd3;
-               else
+               } else {
+                       hash = trxd.rxd4 & MTK_RXD4_FOE_ENTRY;
+                       if (hash != MTK_RXD4_FOE_ENTRY)
+                               skb_set_hash(skb, jhash_1word(hash, 0),
+                                            PKT_HASH_TYPE_L4);
                        rxdcsum = &trxd.rxd4;
+               }
 
                if (*rxdcsum & eth->soc->txrx.rx_dma_l4_valid)
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -1902,16 +1911,9 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
                        skb_checksum_none_assert(skb);
                skb->protocol = eth_type_trans(skb, netdev);
 
-               hash = trxd.rxd4 & MTK_RXD4_FOE_ENTRY;
-               if (hash != MTK_RXD4_FOE_ENTRY) {
-                       hash = jhash_1word(hash, 0);
-                       skb_set_hash(skb, hash, PKT_HASH_TYPE_L4);
-               }
-
                reason = FIELD_GET(MTK_RXD4_PPE_CPU_REASON, trxd.rxd4);
                if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
-                       mtk_ppe_check_skb(eth->ppe, skb,
-                                         trxd.rxd4 & MTK_RXD4_FOE_ENTRY);
+                       mtk_ppe_check_skb(eth->ppe, skb, hash);
 
                if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) {
                        if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
index 7405c97..ecf85e9 100644 (file)
 #define RX_DMA_L4_VALID_PDMA   BIT(30)         /* when PDMA is used */
 #define RX_DMA_SPECIAL_TAG     BIT(22)
 
+/* PDMA descriptor rxd5 */
+#define MTK_RXD5_FOE_ENTRY     GENMASK(14, 0)
+#define MTK_RXD5_PPE_CPU_REASON        GENMASK(22, 18)
+#define MTK_RXD5_SRC_PORT      GENMASK(29, 26)
+
 #define RX_DMA_GET_SPORT(x)    (((x) >> 19) & 0xf)
 #define RX_DMA_GET_SPORT_V2(x) (((x) >> 26) & 0x7)
 
index dab8f3f..cfe804b 100644 (file)
@@ -412,7 +412,7 @@ __mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
        if (entry->hash != 0xffff) {
                ppe->foe_table[entry->hash].ib1 &= ~MTK_FOE_IB1_STATE;
                ppe->foe_table[entry->hash].ib1 |= FIELD_PREP(MTK_FOE_IB1_STATE,
-                                                             MTK_FOE_STATE_BIND);
+                                                             MTK_FOE_STATE_UNBIND);
                dma_wmb();
        }
        entry->hash = 0xffff;
index 1f5cf1c..69ffce0 100644 (file)
@@ -293,6 +293,9 @@ mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash)
        if (!ppe)
                return;
 
+       if (hash > MTK_PPE_HASH_MASK)
+               return;
+
        now = (u16)jiffies;
        diff = now - ppe->foe_check_time[hash];
        if (diff < HZ / 10)
index 3752235..c8e5ca6 100644 (file)
@@ -79,6 +79,10 @@ tc_act_police_offload(struct mlx5e_priv *priv,
        struct mlx5e_flow_meter_handle *meter;
        int err = 0;
 
+       err = mlx5e_policer_validate(&fl_act->action, act, fl_act->extack);
+       if (err)
+               return err;
+
        err = fill_meter_params_from_act(act, &params);
        if (err)
                return err;
index 0aef695..3a1f76e 100644 (file)
@@ -246,7 +246,7 @@ static void mlx5e_tls_priv_tx_cleanup(struct mlx5e_ktls_offload_context_tx *priv
 static void mlx5e_tls_priv_tx_list_cleanup(struct mlx5_core_dev *mdev,
                                           struct list_head *list, int size)
 {
-       struct mlx5e_ktls_offload_context_tx *obj;
+       struct mlx5e_ktls_offload_context_tx *obj, *n;
        struct mlx5e_async_ctx *bulk_async;
        int i;
 
@@ -255,7 +255,7 @@ static void mlx5e_tls_priv_tx_list_cleanup(struct mlx5_core_dev *mdev,
                return;
 
        i = 0;
-       list_for_each_entry(obj, list, list_node) {
+       list_for_each_entry_safe(obj, n, list, list_node) {
                mlx5e_tls_priv_tx_cleanup(obj, &bulk_async[i]);
                i++;
        }
index e2a9b9b..e0ce5a2 100644 (file)
@@ -1395,10 +1395,11 @@ struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,
        }
 
        return fs;
-err_free_fs:
-       kvfree(fs);
+
 err_free_vlan:
        mlx5e_fs_vlan_free(fs);
+err_free_fs:
+       kvfree(fs);
 err:
        return NULL;
 }
index d858667..02eb2f0 100644 (file)
@@ -3682,7 +3682,9 @@ static int set_feature_hw_tc(struct net_device *netdev, bool enable)
        int err = 0;
 
 #if IS_ENABLED(CONFIG_MLX5_CLS_ACT)
-       if (!enable && mlx5e_tc_num_filters(priv, MLX5_TC_FLAG(NIC_OFFLOAD))) {
+       int tc_flag = mlx5e_is_uplink_rep(priv) ? MLX5_TC_FLAG(ESW_OFFLOAD) :
+                                                 MLX5_TC_FLAG(NIC_OFFLOAD);
+       if (!enable && mlx5e_tc_num_filters(priv, tc_flag)) {
                netdev_err(netdev,
                           "Active offloaded tc filters, can't turn hw_tc_offload off\n");
                return -EINVAL;
@@ -4769,14 +4771,6 @@ void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16
        /* RQ */
        mlx5e_build_rq_params(mdev, params);
 
-       /* HW LRO */
-       if (MLX5_CAP_ETH(mdev, lro_cap) &&
-           params->rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ) {
-               /* No XSK params: checking the availability of striding RQ in general. */
-               if (!mlx5e_rx_mpwqe_is_linear_skb(mdev, params, NULL))
-                       params->packet_merge.type = slow_pci_heuristic(mdev) ?
-                               MLX5E_PACKET_MERGE_NONE : MLX5E_PACKET_MERGE_LRO;
-       }
        params->packet_merge.timeout = mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_LRO_TIMEOUT);
 
        /* CQ moderation params */
index 0c66774..759f7d3 100644 (file)
@@ -662,6 +662,8 @@ static void mlx5e_build_rep_params(struct net_device *netdev)
 
        params->mqprio.num_tc       = 1;
        params->tunneled_offload_en = false;
+       if (rep->vport != MLX5_VPORT_UPLINK)
+               params->vlan_strip_disable = true;
 
        mlx5_query_min_inline(mdev, &params->tx_min_inline_mode);
 }
index ed73132..a9f4c65 100644 (file)
@@ -427,7 +427,8 @@ esw_setup_vport_dest(struct mlx5_flow_destination *dest, struct mlx5_flow_act *f
                dest[dest_idx].vport.vhca_id =
                        MLX5_CAP_GEN(esw_attr->dests[attr_idx].mdev, vhca_id);
                dest[dest_idx].vport.flags |= MLX5_FLOW_DEST_VPORT_VHCA_ID;
-               if (mlx5_lag_mpesw_is_activated(esw->dev))
+               if (dest[dest_idx].vport.num == MLX5_VPORT_UPLINK &&
+                   mlx5_lag_mpesw_is_activated(esw->dev))
                        dest[dest_idx].type = MLX5_FLOW_DESTINATION_TYPE_UPLINK;
        }
        if (esw_attr->dests[attr_idx].flags & MLX5_ESW_DEST_ENCAP) {
@@ -3115,8 +3116,10 @@ esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, const u32 *out)
 
                err = mlx5_eswitch_load_vf_vports(esw, new_num_vfs,
                                                  MLX5_VPORT_UC_ADDR_CHANGE);
-               if (err)
+               if (err) {
+                       devl_unlock(devlink);
                        return;
+               }
        }
        esw->esw_funcs.num_vfs = new_num_vfs;
        devl_unlock(devlink);
index 0f34e3c..0651022 100644 (file)
@@ -1067,30 +1067,32 @@ static void mlx5_ldev_add_netdev(struct mlx5_lag *ldev,
                                 struct net_device *netdev)
 {
        unsigned int fn = mlx5_get_dev_index(dev);
+       unsigned long flags;
 
        if (fn >= ldev->ports)
                return;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev->pf[fn].netdev = netdev;
        ldev->tracker.netdev_state[fn].link_up = 0;
        ldev->tracker.netdev_state[fn].tx_enabled = 0;
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
 }
 
 static void mlx5_ldev_remove_netdev(struct mlx5_lag *ldev,
                                    struct net_device *netdev)
 {
+       unsigned long flags;
        int i;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        for (i = 0; i < ldev->ports; i++) {
                if (ldev->pf[i].netdev == netdev) {
                        ldev->pf[i].netdev = NULL;
                        break;
                }
        }
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
 }
 
 static void mlx5_ldev_add_mdev(struct mlx5_lag *ldev,
@@ -1234,7 +1236,7 @@ void mlx5_lag_add_netdev(struct mlx5_core_dev *dev,
        mlx5_ldev_add_netdev(ldev, dev, netdev);
 
        for (i = 0; i < ldev->ports; i++)
-               if (!ldev->pf[i].dev)
+               if (!ldev->pf[i].netdev)
                        break;
 
        if (i >= ldev->ports)
@@ -1246,12 +1248,13 @@ void mlx5_lag_add_netdev(struct mlx5_core_dev *dev,
 bool mlx5_lag_is_roce(struct mlx5_core_dev *dev)
 {
        struct mlx5_lag *ldev;
+       unsigned long flags;
        bool res;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev = mlx5_lag_dev(dev);
        res  = ldev && __mlx5_lag_is_roce(ldev);
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
 
        return res;
 }
@@ -1260,12 +1263,13 @@ EXPORT_SYMBOL(mlx5_lag_is_roce);
 bool mlx5_lag_is_active(struct mlx5_core_dev *dev)
 {
        struct mlx5_lag *ldev;
+       unsigned long flags;
        bool res;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev = mlx5_lag_dev(dev);
        res  = ldev && __mlx5_lag_is_active(ldev);
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
 
        return res;
 }
@@ -1274,13 +1278,14 @@ EXPORT_SYMBOL(mlx5_lag_is_active);
 bool mlx5_lag_is_master(struct mlx5_core_dev *dev)
 {
        struct mlx5_lag *ldev;
+       unsigned long flags;
        bool res;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev = mlx5_lag_dev(dev);
        res = ldev && __mlx5_lag_is_active(ldev) &&
                dev == ldev->pf[MLX5_LAG_P1].dev;
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
 
        return res;
 }
@@ -1289,12 +1294,13 @@ EXPORT_SYMBOL(mlx5_lag_is_master);
 bool mlx5_lag_is_sriov(struct mlx5_core_dev *dev)
 {
        struct mlx5_lag *ldev;
+       unsigned long flags;
        bool res;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev = mlx5_lag_dev(dev);
        res  = ldev && __mlx5_lag_is_sriov(ldev);
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
 
        return res;
 }
@@ -1303,13 +1309,14 @@ EXPORT_SYMBOL(mlx5_lag_is_sriov);
 bool mlx5_lag_is_shared_fdb(struct mlx5_core_dev *dev)
 {
        struct mlx5_lag *ldev;
+       unsigned long flags;
        bool res;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev = mlx5_lag_dev(dev);
        res = ldev && __mlx5_lag_is_sriov(ldev) &&
              test_bit(MLX5_LAG_MODE_FLAG_SHARED_FDB, &ldev->mode_flags);
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
 
        return res;
 }
@@ -1352,9 +1359,10 @@ struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev)
 {
        struct net_device *ndev = NULL;
        struct mlx5_lag *ldev;
+       unsigned long flags;
        int i;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev = mlx5_lag_dev(dev);
 
        if (!(ldev && __mlx5_lag_is_roce(ldev)))
@@ -1373,7 +1381,7 @@ struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev)
                dev_hold(ndev);
 
 unlock:
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
 
        return ndev;
 }
@@ -1383,10 +1391,11 @@ u8 mlx5_lag_get_slave_port(struct mlx5_core_dev *dev,
                           struct net_device *slave)
 {
        struct mlx5_lag *ldev;
+       unsigned long flags;
        u8 port = 0;
        int i;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev = mlx5_lag_dev(dev);
        if (!(ldev && __mlx5_lag_is_roce(ldev)))
                goto unlock;
@@ -1401,7 +1410,7 @@ u8 mlx5_lag_get_slave_port(struct mlx5_core_dev *dev,
        port = ldev->v2p_map[port * ldev->buckets];
 
 unlock:
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
        return port;
 }
 EXPORT_SYMBOL(mlx5_lag_get_slave_port);
@@ -1422,8 +1431,9 @@ struct mlx5_core_dev *mlx5_lag_get_peer_mdev(struct mlx5_core_dev *dev)
 {
        struct mlx5_core_dev *peer_dev = NULL;
        struct mlx5_lag *ldev;
+       unsigned long flags;
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev = mlx5_lag_dev(dev);
        if (!ldev)
                goto unlock;
@@ -1433,7 +1443,7 @@ struct mlx5_core_dev *mlx5_lag_get_peer_mdev(struct mlx5_core_dev *dev)
                           ldev->pf[MLX5_LAG_P1].dev;
 
 unlock:
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
        return peer_dev;
 }
 EXPORT_SYMBOL(mlx5_lag_get_peer_mdev);
@@ -1446,6 +1456,7 @@ int mlx5_lag_query_cong_counters(struct mlx5_core_dev *dev,
        int outlen = MLX5_ST_SZ_BYTES(query_cong_statistics_out);
        struct mlx5_core_dev **mdev;
        struct mlx5_lag *ldev;
+       unsigned long flags;
        int num_ports;
        int ret, i, j;
        void *out;
@@ -1462,7 +1473,7 @@ int mlx5_lag_query_cong_counters(struct mlx5_core_dev *dev,
 
        memset(values, 0, sizeof(*values) * num_counters);
 
-       spin_lock(&lag_lock);
+       spin_lock_irqsave(&lag_lock, flags);
        ldev = mlx5_lag_dev(dev);
        if (ldev && __mlx5_lag_is_active(ldev)) {
                num_ports = ldev->ports;
@@ -1472,7 +1483,7 @@ int mlx5_lag_query_cong_counters(struct mlx5_core_dev *dev,
                num_ports = 1;
                mdev[MLX5_LAG_P1] = dev;
        }
-       spin_unlock(&lag_lock);
+       spin_unlock_irqrestore(&lag_lock, flags);
 
        for (i = 0; i < num_ports; ++i) {
                u32 in[MLX5_ST_SZ_DW(query_cong_statistics_in)] = {};
index bec8d6d..c085b03 100644 (file)
@@ -1530,7 +1530,9 @@ int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
        memcpy(&dev->profile, &profile[profile_idx], sizeof(dev->profile));
        INIT_LIST_HEAD(&priv->ctx_list);
        spin_lock_init(&priv->ctx_lock);
+       lockdep_register_key(&dev->lock_key);
        mutex_init(&dev->intf_state_mutex);
+       lockdep_set_class(&dev->intf_state_mutex, &dev->lock_key);
 
        mutex_init(&priv->bfregs.reg_head.lock);
        mutex_init(&priv->bfregs.wc_head.lock);
@@ -1597,6 +1599,7 @@ err_timeout_init:
        mutex_destroy(&priv->bfregs.wc_head.lock);
        mutex_destroy(&priv->bfregs.reg_head.lock);
        mutex_destroy(&dev->intf_state_mutex);
+       lockdep_unregister_key(&dev->lock_key);
        return err;
 }
 
@@ -1618,6 +1621,7 @@ void mlx5_mdev_uninit(struct mlx5_core_dev *dev)
        mutex_destroy(&priv->bfregs.wc_head.lock);
        mutex_destroy(&priv->bfregs.reg_head.lock);
        mutex_destroy(&dev->intf_state_mutex);
+       lockdep_unregister_key(&dev->lock_key);
 }
 
 static int probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
index ec76a8b..6059635 100644 (file)
@@ -376,8 +376,8 @@ retry:
                        goto out_dropped;
                }
        }
+       err = mlx5_cmd_check(dev, err, in, out);
        if (err) {
-               err = mlx5_cmd_check(dev, err, in, out);
                mlx5_core_warn(dev, "func_id 0x%x, npages %d, err %d\n",
                               func_id, npages, err);
                goto out_dropped;
@@ -524,10 +524,13 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
                dev->priv.reclaim_pages_discard += npages;
        }
        /* if triggered by FW event and failed by FW then ignore */
-       if (event && err == -EREMOTEIO)
+       if (event && err == -EREMOTEIO) {
                err = 0;
+               goto out_free;
+       }
+
+       err = mlx5_cmd_check(dev, err, in, out);
        if (err) {
-               err = mlx5_cmd_check(dev, err, in, out);
                mlx5_core_err(dev, "failed reclaiming pages: err %d\n", err);
                goto out_free;
        }
index ee2e1b7..c0e6c48 100644 (file)
@@ -159,11 +159,11 @@ static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs)
 
        devl_lock(devlink);
        err = mlx5_device_enable_sriov(dev, num_vfs);
+       devl_unlock(devlink);
        if (err) {
                mlx5_core_warn(dev, "mlx5_device_enable_sriov failed : %d\n", err);
                return err;
        }
-       devl_unlock(devlink);
 
        err = pci_enable_sriov(pdev, num_vfs);
        if (err) {
index 5fdf9b7..5a1027b 100644 (file)
@@ -75,6 +75,7 @@ struct mlxbf_gige {
        struct net_device *netdev;
        struct platform_device *pdev;
        void __iomem *mdio_io;
+       void __iomem *clk_io;
        struct mii_bus *mdiobus;
        spinlock_t lock;      /* for packet processing indices */
        u16 rx_q_entries;
@@ -137,7 +138,8 @@ enum mlxbf_gige_res {
        MLXBF_GIGE_RES_MDIO9,
        MLXBF_GIGE_RES_GPIO0,
        MLXBF_GIGE_RES_LLU,
-       MLXBF_GIGE_RES_PLU
+       MLXBF_GIGE_RES_PLU,
+       MLXBF_GIGE_RES_CLK
 };
 
 /* Version of register data returned by mlxbf_gige_get_regs() */
index 2e6c1b7..85155cd 100644 (file)
 #include <linux/property.h>
 
 #include "mlxbf_gige.h"
+#include "mlxbf_gige_regs.h"
 
 #define MLXBF_GIGE_MDIO_GW_OFFSET      0x0
 #define MLXBF_GIGE_MDIO_CFG_OFFSET     0x4
 
+#define MLXBF_GIGE_MDIO_FREQ_REFERENCE 156250000ULL
+#define MLXBF_GIGE_MDIO_COREPLL_CONST  16384ULL
+#define MLXBF_GIGE_MDC_CLK_NS          400
+#define MLXBF_GIGE_MDIO_PLL_I1CLK_REG1 0x4
+#define MLXBF_GIGE_MDIO_PLL_I1CLK_REG2 0x8
+#define MLXBF_GIGE_MDIO_CORE_F_SHIFT   0
+#define MLXBF_GIGE_MDIO_CORE_F_MASK    GENMASK(25, 0)
+#define MLXBF_GIGE_MDIO_CORE_R_SHIFT   26
+#define MLXBF_GIGE_MDIO_CORE_R_MASK    GENMASK(31, 26)
+#define MLXBF_GIGE_MDIO_CORE_OD_SHIFT  0
+#define MLXBF_GIGE_MDIO_CORE_OD_MASK   GENMASK(3, 0)
+
 /* Support clause 22 */
 #define MLXBF_GIGE_MDIO_CL22_ST1       0x1
 #define MLXBF_GIGE_MDIO_CL22_WRITE     0x1
 #define MLXBF_GIGE_MDIO_CFG_MDIO_IN_SAMP_MASK          GENMASK(23, 16)
 #define MLXBF_GIGE_MDIO_CFG_MDIO_OUT_SAMP_MASK         GENMASK(31, 24)
 
+#define MLXBF_GIGE_MDIO_CFG_VAL (FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO_MODE_MASK, 1) | \
+                                FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO3_3_MASK, 1) | \
+                                FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO_FULL_DRIVE_MASK, 1) | \
+                                FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO_IN_SAMP_MASK, 6) | \
+                                FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO_OUT_SAMP_MASK, 13))
+
+#define MLXBF_GIGE_BF2_COREPLL_ADDR 0x02800c30
+#define MLXBF_GIGE_BF2_COREPLL_SIZE 0x0000000c
+
+static struct resource corepll_params[] = {
+       [MLXBF_GIGE_VERSION_BF2] = {
+               .start = MLXBF_GIGE_BF2_COREPLL_ADDR,
+               .end = MLXBF_GIGE_BF2_COREPLL_ADDR + MLXBF_GIGE_BF2_COREPLL_SIZE - 1,
+               .name = "COREPLL_RES"
+       },
+};
+
+/* Returns core clock i1clk in Hz */
+static u64 calculate_i1clk(struct mlxbf_gige *priv)
+{
+       u8 core_od, core_r;
+       u64 freq_output;
+       u32 reg1, reg2;
+       u32 core_f;
+
+       reg1 = readl(priv->clk_io + MLXBF_GIGE_MDIO_PLL_I1CLK_REG1);
+       reg2 = readl(priv->clk_io + MLXBF_GIGE_MDIO_PLL_I1CLK_REG2);
+
+       core_f = (reg1 & MLXBF_GIGE_MDIO_CORE_F_MASK) >>
+               MLXBF_GIGE_MDIO_CORE_F_SHIFT;
+       core_r = (reg1 & MLXBF_GIGE_MDIO_CORE_R_MASK) >>
+               MLXBF_GIGE_MDIO_CORE_R_SHIFT;
+       core_od = (reg2 & MLXBF_GIGE_MDIO_CORE_OD_MASK) >>
+               MLXBF_GIGE_MDIO_CORE_OD_SHIFT;
+
+       /* Compute PLL output frequency as follow:
+        *
+        *                                     CORE_F / 16384
+        * freq_output = freq_reference * ----------------------------
+        *                              (CORE_R + 1) * (CORE_OD + 1)
+        */
+       freq_output = div_u64((MLXBF_GIGE_MDIO_FREQ_REFERENCE * core_f),
+                             MLXBF_GIGE_MDIO_COREPLL_CONST);
+       freq_output = div_u64(freq_output, (core_r + 1) * (core_od + 1));
+
+       return freq_output;
+}
+
 /* Formula for encoding the MDIO period. The encoded value is
  * passed to the MDIO config register.
  *
- * mdc_clk = 2*(val + 1)*i1clk
+ * mdc_clk = 2*(val + 1)*(core clock in sec)
  *
- * 400 ns = 2*(val + 1)*(((1/430)*1000) ns)
+ * i1clk is in Hz:
+ * 400 ns = 2*(val + 1)*(1/i1clk)
  *
- * val = (((400 * 430 / 1000) / 2) - 1)
+ * val = (((400/10^9) / (1/i1clk) / 2) - 1)
+ * val = (400/2 * i1clk)/10^9 - 1
  */
-#define MLXBF_GIGE_I1CLK_MHZ           430
-#define MLXBF_GIGE_MDC_CLK_NS          400
+static u8 mdio_period_map(struct mlxbf_gige *priv)
+{
+       u8 mdio_period;
+       u64 i1clk;
 
-#define MLXBF_GIGE_MDIO_PERIOD (((MLXBF_GIGE_MDC_CLK_NS * MLXBF_GIGE_I1CLK_MHZ / 1000) / 2) - 1)
+       i1clk = calculate_i1clk(priv);
 
-#define MLXBF_GIGE_MDIO_CFG_VAL (FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO_MODE_MASK, 1) | \
-                                FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO3_3_MASK, 1) | \
-                                FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO_FULL_DRIVE_MASK, 1) | \
-                                FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDC_PERIOD_MASK, \
-                                           MLXBF_GIGE_MDIO_PERIOD) | \
-                                FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO_IN_SAMP_MASK, 6) | \
-                                FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDIO_OUT_SAMP_MASK, 13))
+       mdio_period = div_u64((MLXBF_GIGE_MDC_CLK_NS >> 1) * i1clk, 1000000000) - 1;
+
+       return mdio_period;
+}
 
 static u32 mlxbf_gige_mdio_create_cmd(u16 data, int phy_add,
                                      int phy_reg, u32 opcode)
@@ -124,9 +186,9 @@ static int mlxbf_gige_mdio_write(struct mii_bus *bus, int phy_add,
                                 int phy_reg, u16 val)
 {
        struct mlxbf_gige *priv = bus->priv;
+       u32 temp;
        u32 cmd;
        int ret;
-       u32 temp;
 
        if (phy_reg & MII_ADDR_C45)
                return -EOPNOTSUPP;
@@ -144,18 +206,44 @@ static int mlxbf_gige_mdio_write(struct mii_bus *bus, int phy_add,
        return ret;
 }
 
+static void mlxbf_gige_mdio_cfg(struct mlxbf_gige *priv)
+{
+       u8 mdio_period;
+       u32 val;
+
+       mdio_period = mdio_period_map(priv);
+
+       val = MLXBF_GIGE_MDIO_CFG_VAL;
+       val |= FIELD_PREP(MLXBF_GIGE_MDIO_CFG_MDC_PERIOD_MASK, mdio_period);
+       writel(val, priv->mdio_io + MLXBF_GIGE_MDIO_CFG_OFFSET);
+}
+
 int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv)
 {
        struct device *dev = &pdev->dev;
+       struct resource *res;
        int ret;
 
        priv->mdio_io = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MDIO9);
        if (IS_ERR(priv->mdio_io))
                return PTR_ERR(priv->mdio_io);
 
-       /* Configure mdio parameters */
-       writel(MLXBF_GIGE_MDIO_CFG_VAL,
-              priv->mdio_io + MLXBF_GIGE_MDIO_CFG_OFFSET);
+       /* clk resource shared with other drivers so cannot use
+        * devm_platform_ioremap_resource
+        */
+       res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_CLK);
+       if (!res) {
+               /* For backward compatibility with older ACPI tables, also keep
+                * CLK resource internal to the driver.
+                */
+               res = &corepll_params[MLXBF_GIGE_VERSION_BF2];
+       }
+
+       priv->clk_io = devm_ioremap(dev, res->start, resource_size(res));
+       if (IS_ERR(priv->clk_io))
+               return PTR_ERR(priv->clk_io);
+
+       mlxbf_gige_mdio_cfg(priv);
 
        priv->mdiobus = devm_mdiobus_alloc(dev);
        if (!priv->mdiobus) {
index 5fb33c9..7be3a79 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef __MLXBF_GIGE_REGS_H__
 #define __MLXBF_GIGE_REGS_H__
 
+#define MLXBF_GIGE_VERSION                            0x0000
+#define MLXBF_GIGE_VERSION_BF2                        0x0
 #define MLXBF_GIGE_STATUS                             0x0010
 #define MLXBF_GIGE_STATUS_READY                       BIT(0)
 #define MLXBF_GIGE_INT_STATUS                         0x0028
index 39904da..b3472fb 100644 (file)
@@ -423,7 +423,8 @@ mlxsw_sp_span_gretap4_route(const struct net_device *to_dev,
 
        parms = mlxsw_sp_ipip_netdev_parms4(to_dev);
        ip_tunnel_init_flow(&fl4, parms.iph.protocol, *daddrp, *saddrp,
-                           0, 0, dev_net(to_dev), parms.link, tun->fwmark, 0);
+                           0, 0, dev_net(to_dev), parms.link, tun->fwmark, 0,
+                           0);
 
        rt = ip_route_output_key(tun->net, &fl4);
        if (IS_ERR(rt))
index 6dea7f8..51f8a08 100644 (file)
@@ -425,7 +425,8 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx)
        lan966x_ifh_get_src_port(skb->data, &src_port);
        lan966x_ifh_get_timestamp(skb->data, &timestamp);
 
-       WARN_ON(src_port >= lan966x->num_phys_ports);
+       if (WARN_ON(src_port >= lan966x->num_phys_ports))
+               goto free_skb;
 
        skb->dev = lan966x->ports[src_port]->dev;
        skb_pull(skb, IFH_LEN * sizeof(u32));
@@ -449,6 +450,8 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx)
 
        return skb;
 
+free_skb:
+       kfree_skb(skb);
 unmap_page:
        dma_unmap_page(lan966x->dev, (dma_addr_t)db->dataptr,
                       FDMA_DCB_STATUS_BLOCKL(db->status),
index 304f84a..21844be 100644 (file)
@@ -113,6 +113,8 @@ static void sparx5_xtr_grp(struct sparx5 *sparx5, u8 grp, bool byte_swap)
                        /* This assumes STATUS_WORD_POS == 1, Status
                         * just after last data
                         */
+                       if (!byte_swap)
+                               val = ntohl((__force __be32)val);
                        byte_cnt -= (4 - XTR_VALID_BYTES(val));
                        eof_flag = true;
                        break;
index 19009a6..9e57d23 100644 (file)
@@ -71,11 +71,6 @@ static int moxart_set_mac_address(struct net_device *ndev, void *addr)
 static void moxart_mac_free_memory(struct net_device *ndev)
 {
        struct moxart_mac_priv_t *priv = netdev_priv(ndev);
-       int i;
-
-       for (i = 0; i < RX_DESC_NUM; i++)
-               dma_unmap_single(&priv->pdev->dev, priv->rx_mapping[i],
-                                priv->rx_buf_size, DMA_FROM_DEVICE);
 
        if (priv->tx_desc_base)
                dma_free_coherent(&priv->pdev->dev,
@@ -187,6 +182,7 @@ static int moxart_mac_open(struct net_device *ndev)
 static int moxart_mac_stop(struct net_device *ndev)
 {
        struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+       int i;
 
        napi_disable(&priv->napi);
 
@@ -198,6 +194,11 @@ static int moxart_mac_stop(struct net_device *ndev)
        /* disable all functions */
        writel(0, priv->base + REG_MAC_CTRL);
 
+       /* unmap areas mapped in moxart_mac_setup_desc_ring() */
+       for (i = 0; i < RX_DESC_NUM; i++)
+               dma_unmap_single(&priv->pdev->dev, priv->rx_mapping[i],
+                                priv->rx_buf_size, DMA_FROM_DEVICE);
+
        return 0;
 }
 
index 4e5df9f..7b92026 100644 (file)
@@ -127,10 +127,11 @@ static int nfp_policer_validate(const struct flow_action *action,
                return -EOPNOTSUPP;
        }
 
-       if (act->police.notexceed.act_id != FLOW_ACTION_PIPE &&
+       if (act->police.notexceed.act_id != FLOW_ACTION_CONTINUE &&
+           act->police.notexceed.act_id != FLOW_ACTION_PIPE &&
            act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) {
                NL_SET_ERR_MSG_MOD(extack,
-                                  "Offload not supported when conform action is not pipe or ok");
+                                  "Offload not supported when conform action is not continue, pipe or ok");
                return -EOPNOTSUPP;
        }
 
index cf4d6f1..349a2b1 100644 (file)
@@ -1630,21 +1630,21 @@ static void nfp_net_stat64(struct net_device *netdev,
                unsigned int start;
 
                do {
-                       start = u64_stats_fetch_begin(&r_vec->rx_sync);
+                       start = u64_stats_fetch_begin_irq(&r_vec->rx_sync);
                        data[0] = r_vec->rx_pkts;
                        data[1] = r_vec->rx_bytes;
                        data[2] = r_vec->rx_drops;
-               } while (u64_stats_fetch_retry(&r_vec->rx_sync, start));
+               } while (u64_stats_fetch_retry_irq(&r_vec->rx_sync, start));
                stats->rx_packets += data[0];
                stats->rx_bytes += data[1];
                stats->rx_dropped += data[2];
 
                do {
-                       start = u64_stats_fetch_begin(&r_vec->tx_sync);
+                       start = u64_stats_fetch_begin_irq(&r_vec->tx_sync);
                        data[0] = r_vec->tx_pkts;
                        data[1] = r_vec->tx_bytes;
                        data[2] = r_vec->tx_errors;
-               } while (u64_stats_fetch_retry(&r_vec->tx_sync, start));
+               } while (u64_stats_fetch_retry_irq(&r_vec->tx_sync, start));
                stats->tx_packets += data[0];
                stats->tx_bytes += data[1];
                stats->tx_errors += data[2];
index eeb1455..b1b1b64 100644 (file)
@@ -649,7 +649,7 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data)
                unsigned int start;
 
                do {
-                       start = u64_stats_fetch_begin(&nn->r_vecs[i].rx_sync);
+                       start = u64_stats_fetch_begin_irq(&nn->r_vecs[i].rx_sync);
                        data[0] = nn->r_vecs[i].rx_pkts;
                        tmp[0] = nn->r_vecs[i].hw_csum_rx_ok;
                        tmp[1] = nn->r_vecs[i].hw_csum_rx_inner_ok;
@@ -657,10 +657,10 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data)
                        tmp[3] = nn->r_vecs[i].hw_csum_rx_error;
                        tmp[4] = nn->r_vecs[i].rx_replace_buf_alloc_fail;
                        tmp[5] = nn->r_vecs[i].hw_tls_rx;
-               } while (u64_stats_fetch_retry(&nn->r_vecs[i].rx_sync, start));
+               } while (u64_stats_fetch_retry_irq(&nn->r_vecs[i].rx_sync, start));
 
                do {
-                       start = u64_stats_fetch_begin(&nn->r_vecs[i].tx_sync);
+                       start = u64_stats_fetch_begin_irq(&nn->r_vecs[i].tx_sync);
                        data[1] = nn->r_vecs[i].tx_pkts;
                        data[2] = nn->r_vecs[i].tx_busy;
                        tmp[6] = nn->r_vecs[i].hw_csum_tx;
@@ -670,7 +670,7 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data)
                        tmp[10] = nn->r_vecs[i].hw_tls_tx;
                        tmp[11] = nn->r_vecs[i].tls_tx_fallback;
                        tmp[12] = nn->r_vecs[i].tls_tx_no_fallback;
-               } while (u64_stats_fetch_retry(&nn->r_vecs[i].tx_sync, start));
+               } while (u64_stats_fetch_retry_irq(&nn->r_vecs[i].tx_sync, start));
 
                data += NN_RVEC_PER_Q_STATS;
 
index edd3000..4cc3879 100644 (file)
@@ -507,6 +507,7 @@ int nfp_eth_set_idmode(struct nfp_cpp *cpp, unsigned int idx, bool state)
        if (nfp_nsp_get_abi_ver_minor(nsp) < 32) {
                nfp_err(nfp_nsp_cpp(nsp),
                        "set id mode operation not supported, please update flash\n");
+               nfp_eth_config_cleanup_end(nsp);
                return -EOPNOTSUPP;
        }
 
index 1443f78..0be79c5 100644 (file)
@@ -1564,8 +1564,67 @@ static int ionic_set_features(struct net_device *netdev,
        return err;
 }
 
+static int ionic_set_attr_mac(struct ionic_lif *lif, u8 *mac)
+{
+       struct ionic_admin_ctx ctx = {
+               .work = COMPLETION_INITIALIZER_ONSTACK(ctx.work),
+               .cmd.lif_setattr = {
+                       .opcode = IONIC_CMD_LIF_SETATTR,
+                       .index = cpu_to_le16(lif->index),
+                       .attr = IONIC_LIF_ATTR_MAC,
+               },
+       };
+
+       ether_addr_copy(ctx.cmd.lif_setattr.mac, mac);
+       return ionic_adminq_post_wait(lif, &ctx);
+}
+
+static int ionic_get_attr_mac(struct ionic_lif *lif, u8 *mac_addr)
+{
+       struct ionic_admin_ctx ctx = {
+               .work = COMPLETION_INITIALIZER_ONSTACK(ctx.work),
+               .cmd.lif_getattr = {
+                       .opcode = IONIC_CMD_LIF_GETATTR,
+                       .index = cpu_to_le16(lif->index),
+                       .attr = IONIC_LIF_ATTR_MAC,
+               },
+       };
+       int err;
+
+       err = ionic_adminq_post_wait(lif, &ctx);
+       if (err)
+               return err;
+
+       ether_addr_copy(mac_addr, ctx.comp.lif_getattr.mac);
+       return 0;
+}
+
+static int ionic_program_mac(struct ionic_lif *lif, u8 *mac)
+{
+       u8  get_mac[ETH_ALEN];
+       int err;
+
+       err = ionic_set_attr_mac(lif, mac);
+       if (err)
+               return err;
+
+       err = ionic_get_attr_mac(lif, get_mac);
+       if (err)
+               return err;
+
+       /* To deal with older firmware that silently ignores the set attr mac:
+        * doesn't actually change the mac and doesn't return an error, so we
+        * do the get attr to verify whether or not the set actually happened
+        */
+       if (!ether_addr_equal(get_mac, mac))
+               return 1;
+
+       return 0;
+}
+
 static int ionic_set_mac_address(struct net_device *netdev, void *sa)
 {
+       struct ionic_lif *lif = netdev_priv(netdev);
        struct sockaddr *addr = sa;
        u8 *mac;
        int err;
@@ -1574,6 +1633,14 @@ static int ionic_set_mac_address(struct net_device *netdev, void *sa)
        if (ether_addr_equal(netdev->dev_addr, mac))
                return 0;
 
+       err = ionic_program_mac(lif, mac);
+       if (err < 0)
+               return err;
+
+       if (err > 0)
+               netdev_dbg(netdev, "%s: SET and GET ATTR Mac are not equal-due to old FW running\n",
+                          __func__);
+
        err = eth_prepare_mac_addr_change(netdev, addr);
        if (err)
                return err;
@@ -2963,6 +3030,9 @@ static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
 
        mutex_lock(&lif->queue_lock);
 
+       if (test_and_clear_bit(IONIC_LIF_F_BROKEN, lif->state))
+               dev_info(ionic->dev, "FW Up: clearing broken state\n");
+
        err = ionic_qcqs_alloc(lif);
        if (err)
                goto err_unlock;
@@ -3169,6 +3239,7 @@ static int ionic_station_set(struct ionic_lif *lif)
                        .attr = IONIC_LIF_ATTR_MAC,
                },
        };
+       u8 mac_address[ETH_ALEN];
        struct sockaddr addr;
        int err;
 
@@ -3177,8 +3248,23 @@ static int ionic_station_set(struct ionic_lif *lif)
                return err;
        netdev_dbg(lif->netdev, "found initial MAC addr %pM\n",
                   ctx.comp.lif_getattr.mac);
-       if (is_zero_ether_addr(ctx.comp.lif_getattr.mac))
-               return 0;
+       ether_addr_copy(mac_address, ctx.comp.lif_getattr.mac);
+
+       if (is_zero_ether_addr(mac_address)) {
+               eth_hw_addr_random(netdev);
+               netdev_dbg(netdev, "Random Mac generated: %pM\n", netdev->dev_addr);
+               ether_addr_copy(mac_address, netdev->dev_addr);
+
+               err = ionic_program_mac(lif, mac_address);
+               if (err < 0)
+                       return err;
+
+               if (err > 0) {
+                       netdev_dbg(netdev, "%s:SET/GET ATTR Mac are not same-due to old FW running\n",
+                                  __func__);
+                       return 0;
+               }
+       }
 
        if (!is_zero_ether_addr(netdev->dev_addr)) {
                /* If the netdev mac is non-zero and doesn't match the default
@@ -3186,12 +3272,11 @@ static int ionic_station_set(struct ionic_lif *lif)
                 * likely here again after a fw-upgrade reset.  We need to be
                 * sure the netdev mac is in our filter list.
                 */
-               if (!ether_addr_equal(ctx.comp.lif_getattr.mac,
-                                     netdev->dev_addr))
+               if (!ether_addr_equal(mac_address, netdev->dev_addr))
                        ionic_lif_addr_add(lif, netdev->dev_addr);
        } else {
                /* Update the netdev mac with the device's mac */
-               memcpy(addr.sa_data, ctx.comp.lif_getattr.mac, netdev->addr_len);
+               ether_addr_copy(addr.sa_data, mac_address);
                addr.sa_family = AF_INET;
                err = eth_prepare_mac_addr_change(netdev, &addr);
                if (err) {
index 4029b4e..56f93b0 100644 (file)
@@ -474,8 +474,8 @@ try_again:
                                ionic_opcode_to_str(opcode), opcode,
                                ionic_error_to_str(err), err);
 
-                       msleep(1000);
                        iowrite32(0, &idev->dev_cmd_regs->done);
+                       msleep(1000);
                        iowrite32(1, &idev->dev_cmd_regs->doorbell);
                        goto try_again;
                }
@@ -488,6 +488,8 @@ try_again:
                return ionic_error_to_errno(err);
        }
 
+       ionic_dev_cmd_clean(ionic);
+
        return 0;
 }
 
index bc70c6a..58cf7cc 100644 (file)
@@ -1273,7 +1273,7 @@ static int ofdpa_port_ipv4_neigh(struct ofdpa_port *ofdpa_port,
        bool removing;
        int err = 0;
 
-       entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+       entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
        if (!entry)
                return -ENOMEM;
 
index 3bf2021..3829c28 100644 (file)
@@ -1037,6 +1037,8 @@ static int smsc911x_mii_probe(struct net_device *dev)
                return ret;
        }
 
+       /* Indicate that the MAC is responsible for managing PHY PM */
+       phydev->mac_managed_pm = true;
        phy_attached_info(phydev);
 
        phy_set_max_speed(phydev, SPEED_100);
@@ -2587,6 +2589,8 @@ static int smsc911x_suspend(struct device *dev)
        if (netif_running(ndev)) {
                netif_stop_queue(ndev);
                netif_device_detach(ndev);
+               if (!device_may_wakeup(dev))
+                       phy_stop(ndev->phydev);
        }
 
        /* enable wake on LAN, energy detection and the external PME
@@ -2628,6 +2632,8 @@ static int smsc911x_resume(struct device *dev)
        if (netif_running(ndev)) {
                netif_device_attach(ndev);
                netif_start_queue(ndev);
+               if (!device_may_wakeup(dev))
+                       phy_start(ndev->phydev);
        }
 
        return 0;
index 4f2b82a..9af25be 100644 (file)
@@ -1136,8 +1136,6 @@ static void intel_eth_pci_remove(struct pci_dev *pdev)
 
        clk_disable_unprepare(priv->plat->stmmac_clk);
        clk_unregister_fixed_rate(priv->plat->stmmac_clk);
-
-       pcim_iounmap_regions(pdev, BIT(0));
 }
 
 static int __maybe_unused intel_eth_pci_suspend(struct device *dev)
index caa4bfc..9b6138b 100644 (file)
@@ -258,14 +258,18 @@ EXPORT_SYMBOL_GPL(stmmac_set_mac_addr);
 /* Enable disable MAC RX/TX */
 void stmmac_set_mac(void __iomem *ioaddr, bool enable)
 {
-       u32 value = readl(ioaddr + MAC_CTRL_REG);
+       u32 old_val, value;
+
+       old_val = readl(ioaddr + MAC_CTRL_REG);
+       value = old_val;
 
        if (enable)
                value |= MAC_ENABLE_RX | MAC_ENABLE_TX;
        else
                value &= ~(MAC_ENABLE_TX | MAC_ENABLE_RX);
 
-       writel(value, ioaddr + MAC_CTRL_REG);
+       if (value != old_val)
+               writel(value, ioaddr + MAC_CTRL_REG);
 }
 
 void stmmac_get_mac_addr(void __iomem *ioaddr, unsigned char *addr,
index 070b5ef..592d29a 100644 (file)
@@ -986,10 +986,10 @@ static void stmmac_mac_link_up(struct phylink_config *config,
                               bool tx_pause, bool rx_pause)
 {
        struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
-       u32 ctrl;
+       u32 old_ctrl, ctrl;
 
-       ctrl = readl(priv->ioaddr + MAC_CTRL_REG);
-       ctrl &= ~priv->hw->link.speed_mask;
+       old_ctrl = readl(priv->ioaddr + MAC_CTRL_REG);
+       ctrl = old_ctrl & ~priv->hw->link.speed_mask;
 
        if (interface == PHY_INTERFACE_MODE_USXGMII) {
                switch (speed) {
@@ -1064,7 +1064,8 @@ static void stmmac_mac_link_up(struct phylink_config *config,
        if (tx_pause && rx_pause)
                stmmac_mac_flow_ctrl(priv, duplex);
 
-       writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
+       if (ctrl != old_ctrl)
+               writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
 
        stmmac_mac_set(priv, priv->ioaddr, true);
        if (phy && priv->dma_cap.eee) {
index 6afdf16..5cf218c 100644 (file)
@@ -1310,10 +1310,11 @@ static void adf7242_remove(struct spi_device *spi)
 
        debugfs_remove_recursive(lp->debugfs_root);
 
+       ieee802154_unregister_hw(lp->hw);
+
        cancel_delayed_work_sync(&lp->work);
        destroy_workqueue(lp->wqueue);
 
-       ieee802154_unregister_hw(lp->hw);
        mutex_destroy(&lp->bmux);
        ieee802154_free_hw(lp->hw);
 }
index 42c0b45..450b16a 100644 (file)
@@ -2293,7 +2293,7 @@ static int ca8210_set_csma_params(
  * @retries:  Number of retries
  *
  * Sets the number of times to retry a transmission if no acknowledgment was
- * was received from the other end when one was requested.
+ * received from the other end when one was requested.
  *
  * Return: 0 or linux error code
  */
index 1e1f40f..c69b87d 100644 (file)
@@ -504,6 +504,7 @@ cc2520_tx(struct ieee802154_hw *hw, struct sk_buff *skb)
                goto err_tx;
 
        if (status & CC2520_STATUS_TX_UNDERFLOW) {
+               rc = -EINVAL;
                dev_err(&priv->spi->dev, "cc2520 tx underflow exception\n");
                goto err_tx;
        }
index 1e9eae2..53a1dbe 100644 (file)
@@ -568,7 +568,7 @@ static int ipa_smem_init(struct ipa *ipa, u32 item, size_t size)
        }
 
        /* Align the address down and the size up to a page boundary */
-       addr = qcom_smem_virt_to_phys(virt) & PAGE_MASK;
+       addr = qcom_smem_virt_to_phys(virt);
        phys = addr & PAGE_MASK;
        size = PAGE_ALIGN(size + addr - phys);
        iova = phys;    /* We just want a direct mapping */
index ef02f2c..cbabca1 100644 (file)
@@ -194,7 +194,7 @@ static struct notifier_block ipvtap_notifier_block __read_mostly = {
        .notifier_call  = ipvtap_device_event,
 };
 
-static int ipvtap_init(void)
+static int __init ipvtap_init(void)
 {
        int err;
 
@@ -228,7 +228,7 @@ out1:
 }
 module_init(ipvtap_init);
 
-static void ipvtap_exit(void)
+static void __exit ipvtap_exit(void)
 {
        rtnl_link_unregister(&ipvtap_link_ops);
        unregister_netdevice_notifier(&ipvtap_notifier_block);
index ee6087e..c6d271e 100644 (file)
@@ -462,11 +462,6 @@ static struct macsec_eth_header *macsec_ethhdr(struct sk_buff *skb)
        return (struct macsec_eth_header *)skb_mac_header(skb);
 }
 
-static sci_t dev_to_sci(struct net_device *dev, __be16 port)
-{
-       return make_sci(dev->dev_addr, port);
-}
-
 static void __macsec_pn_wrapped(struct macsec_secy *secy,
                                struct macsec_tx_sa *tx_sa)
 {
@@ -3661,7 +3656,6 @@ static int macsec_set_mac_address(struct net_device *dev, void *p)
 
 out:
        eth_hw_addr_set(dev, addr->sa_data);
-       macsec->secy.sci = dev_to_sci(dev, MACSEC_PORT_ES);
 
        /* If h/w offloading is available, propagate to the device */
        if (macsec_is_offloaded(macsec)) {
@@ -4000,6 +3994,11 @@ static bool sci_exists(struct net_device *dev, sci_t sci)
        return false;
 }
 
+static sci_t dev_to_sci(struct net_device *dev, __be16 port)
+{
+       return make_sci(dev->dev_addr, port);
+}
+
 static int macsec_add_dev(struct net_device *dev, sci_t sci, u8 icv_len)
 {
        struct macsec_dev *macsec = macsec_priv(dev);
index 3e79c2c..1c1584f 100644 (file)
@@ -47,7 +47,9 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
         * just fall back to poll mode
         */
        if (rc == -EPROBE_DEFER)
-               rc = -ENODEV;
+               rc = driver_deferred_probe_check_state(&phy->mdio.dev);
+       if (rc == -EPROBE_DEFER)
+               return rc;
 
        if (rc > 0) {
                phy->irq = rc;
index e470e33..9a1a5b2 100644 (file)
@@ -67,10 +67,10 @@ nsim_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
        unsigned int start;
 
        do {
-               start = u64_stats_fetch_begin(&ns->syncp);
+               start = u64_stats_fetch_begin_irq(&ns->syncp);
                stats->tx_bytes = ns->tx_bytes;
                stats->tx_packets = ns->tx_packets;
-       } while (u64_stats_fetch_retry(&ns->syncp, start));
+       } while (u64_stats_fetch_retry_irq(&ns->syncp, start));
 }
 
 static int
index 73f7962..c49062a 100644 (file)
@@ -243,13 +243,7 @@ static irqreturn_t meson_gxl_handle_interrupt(struct phy_device *phydev)
            irq_status == INTSRC_ENERGY_DETECT)
                return IRQ_HANDLED;
 
-       /* Give PHY some time before MAC starts sending data. This works
-        * around an issue where network doesn't come up properly.
-        */
-       if (!(irq_status & INTSRC_LINK_DOWN))
-               phy_queue_state_machine(phydev, msecs_to_jiffies(100));
-       else
-               phy_trigger_machine(phydev);
+       phy_trigger_machine(phydev);
 
        return IRQ_HANDLED;
 }
index e78d0bf..6f52b4f 100644 (file)
@@ -2873,12 +2873,18 @@ static int lan8814_config_init(struct phy_device *phydev)
        return 0;
 }
 
+/* It is expected that there will not be any 'lan8814_take_coma_mode'
+ * function called in suspend. Because the GPIO line can be shared, so if one of
+ * the phys goes back in coma mode, then all the other PHYs will go, which is
+ * wrong.
+ */
 static int lan8814_release_coma_mode(struct phy_device *phydev)
 {
        struct gpio_desc *gpiod;
 
        gpiod = devm_gpiod_get_optional(&phydev->mdio.dev, "coma-mode",
-                                       GPIOD_OUT_HIGH_OPEN_DRAIN);
+                                       GPIOD_OUT_HIGH_OPEN_DRAIN |
+                                       GPIOD_FLAGS_BIT_NONEXCLUSIVE);
        if (IS_ERR(gpiod))
                return PTR_ERR(gpiod);
 
index d4c93d5..8569a54 100644 (file)
 
 /* Interrupt Source Register */
 #define LAN87XX_INTERRUPT_SOURCE                (0x18)
+#define LAN87XX_INTERRUPT_SOURCE_2              (0x08)
 
 /* Interrupt Mask Register */
 #define LAN87XX_INTERRUPT_MASK                  (0x19)
 #define LAN87XX_MASK_LINK_UP                    (0x0004)
 #define LAN87XX_MASK_LINK_DOWN                  (0x0002)
 
+#define LAN87XX_INTERRUPT_MASK_2                (0x09)
+#define LAN87XX_MASK_COMM_RDY                  BIT(10)
+
 /* MISC Control 1 Register */
 #define LAN87XX_CTRL_1                          (0x11)
 #define LAN87XX_MASK_RGMII_TXC_DLY_EN           (0x4000)
@@ -424,17 +428,55 @@ static int lan87xx_phy_config_intr(struct phy_device *phydev)
        int rc, val = 0;
 
        if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
-               /* unmask all source and clear them before enable */
-               rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, 0x7FFF);
+               /* clear all interrupt */
+               rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, val);
+               if (rc < 0)
+                       return rc;
+
                rc = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE);
-               val = LAN87XX_MASK_LINK_UP | LAN87XX_MASK_LINK_DOWN;
+               if (rc < 0)
+                       return rc;
+
+               rc = access_ereg(phydev, PHYACC_ATTR_MODE_WRITE,
+                                PHYACC_ATTR_BANK_MISC,
+                                LAN87XX_INTERRUPT_MASK_2, val);
+               if (rc < 0)
+                       return rc;
+
+               rc = access_ereg(phydev, PHYACC_ATTR_MODE_READ,
+                                PHYACC_ATTR_BANK_MISC,
+                                LAN87XX_INTERRUPT_SOURCE_2, 0);
+               if (rc < 0)
+                       return rc;
+
+               /* enable link down and comm ready interrupt */
+               val = LAN87XX_MASK_LINK_DOWN;
                rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, val);
+               if (rc < 0)
+                       return rc;
+
+               val = LAN87XX_MASK_COMM_RDY;
+               rc = access_ereg(phydev, PHYACC_ATTR_MODE_WRITE,
+                                PHYACC_ATTR_BANK_MISC,
+                                LAN87XX_INTERRUPT_MASK_2, val);
        } else {
                rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, val);
-               if (rc)
+               if (rc < 0)
                        return rc;
 
                rc = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE);
+               if (rc < 0)
+                       return rc;
+
+               rc = access_ereg(phydev, PHYACC_ATTR_MODE_WRITE,
+                                PHYACC_ATTR_BANK_MISC,
+                                LAN87XX_INTERRUPT_MASK_2, val);
+               if (rc < 0)
+                       return rc;
+
+               rc = access_ereg(phydev, PHYACC_ATTR_MODE_READ,
+                                PHYACC_ATTR_BANK_MISC,
+                                LAN87XX_INTERRUPT_SOURCE_2, 0);
        }
 
        return rc < 0 ? rc : 0;
@@ -444,6 +486,14 @@ static irqreturn_t lan87xx_handle_interrupt(struct phy_device *phydev)
 {
        int irq_status;
 
+       irq_status  = access_ereg(phydev, PHYACC_ATTR_MODE_READ,
+                                 PHYACC_ATTR_BANK_MISC,
+                                 LAN87XX_INTERRUPT_SOURCE_2, 0);
+       if (irq_status < 0) {
+               phy_error(phydev);
+               return IRQ_NONE;
+       }
+
        irq_status = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE);
        if (irq_status < 0) {
                phy_error(phydev);
index 0c6efd7..12ff276 100644 (file)
@@ -316,11 +316,11 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
 
        phydev->suspended_by_mdio_bus = 0;
 
-       /* If we managed to get here with the PHY state machine in a state other
-        * than PHY_HALTED this is an indication that something went wrong and
-        * we should most likely be using MAC managed PM and we are not.
+       /* If we manged to get here with the PHY state machine in a state neither
+        * PHY_HALTED nor PHY_READY this is an indication that something went wrong
+        * and we should most likely be using MAC managed PM and we are not.
         */
-       WARN_ON(phydev->state != PHY_HALTED && !phydev->mac_managed_pm);
+       WARN_ON(phydev->state != PHY_HALTED && phydev->state != PHY_READY);
 
        ret = phy_init_hw(phydev);
        if (ret < 0)
index 2de09ad..e11f709 100644 (file)
@@ -777,6 +777,13 @@ static const struct usb_device_id  products[] = {
 },
 #endif
 
+/* Lenovo ThinkPad OneLink+ Dock (based on Realtek RTL8153) */
+{
+       USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3054, USB_CLASS_COMM,
+                       USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
+       .driver_info = 0,
+},
+
 /* ThinkPad USB-C Dock (based on Realtek RTL8153) */
 {
        USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3062, USB_CLASS_COMM,
index 709e3c5..0cb187d 100644 (file)
@@ -1087,6 +1087,7 @@ static const struct usb_device_id products[] = {
        {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0512)},   /* Quectel EG12/EM12 */
        {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0620)},   /* Quectel EM160R-GL */
        {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0800)},   /* Quectel RM500Q-GL */
+       {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0801)},   /* Quectel RM520N */
 
        /* 3. Combined interface devices matching on interface number */
        {QMI_FIXED_INTF(0x0408, 0xea42, 4)},    /* Yota / Megafon M100-1 */
index 0f6efaa..688905e 100644 (file)
@@ -770,6 +770,7 @@ enum rtl8152_flags {
        RX_EPROTO,
 };
 
+#define DEVICE_ID_THINKPAD_ONELINK_PLUS_DOCK           0x3054
 #define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2      0x3082
 #define DEVICE_ID_THINKPAD_USB_C_DONGLE                        0x720c
 #define DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2             0xa387
@@ -5906,6 +5907,11 @@ static void r8153_enter_oob(struct r8152 *tp)
        ocp_data &= ~NOW_IS_OOB;
        ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);
 
+       /* RX FIFO settings for OOB */
+       ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL0, RXFIFO_THR1_OOB);
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_OOB);
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_OOB);
+
        rtl_disable(tp);
        rtl_reset_bmu(tp);
 
@@ -6431,21 +6437,8 @@ static void r8156_fc_parameter(struct r8152 *tp)
        u32 pause_on = tp->fc_pause_on ? tp->fc_pause_on : fc_pause_on_auto(tp);
        u32 pause_off = tp->fc_pause_off ? tp->fc_pause_off : fc_pause_off_auto(tp);
 
-       switch (tp->version) {
-       case RTL_VER_10:
-       case RTL_VER_11:
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, pause_on / 8);
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, pause_off / 8);
-               break;
-       case RTL_VER_12:
-       case RTL_VER_13:
-       case RTL_VER_15:
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, pause_on / 16);
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, pause_off / 16);
-               break;
-       default:
-               break;
-       }
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, pause_on / 16);
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, pause_off / 16);
 }
 
 static void rtl8156_change_mtu(struct r8152 *tp)
@@ -6557,6 +6550,11 @@ static void rtl8156_down(struct r8152 *tp)
        ocp_data &= ~NOW_IS_OOB;
        ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);
 
+       /* RX FIFO settings for OOB */
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_RXFIFO_FULL, 64 / 16);
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, 1024 / 16);
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, 4096 / 16);
+
        rtl_disable(tp);
        rtl_reset_bmu(tp);
 
@@ -9584,6 +9582,7 @@ static bool rtl8152_supports_lenovo_macpassthru(struct usb_device *udev)
 
        if (vendor_id == VENDOR_ID_LENOVO) {
                switch (product_id) {
+               case DEVICE_ID_THINKPAD_ONELINK_PLUS_DOCK:
                case DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2:
                case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2:
                case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN3:
@@ -9831,6 +9830,7 @@ static const struct usb_device_id rtl8152_table[] = {
        REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927),
        REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101),
        REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x304f),
+       REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x3054),
        REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x3062),
        REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x3069),
        REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x3082),
index c62f299..d8a5dbf 100644 (file)
@@ -2403,7 +2403,7 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,
                /* Repeat initial/next rate.
                 * For legacy IL_NUMBER_TRY == 1, this loop will not execute.
                 * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */
-               while (repeat_rate > 0) {
+               while (repeat_rate > 0 && idx < (LINK_QUAL_MAX_RETRY_NUM - 1)) {
                        if (is_legacy(tbl_type.lq_type)) {
                                if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE)
                                        ant_toggle_cnt++;
@@ -2422,8 +2422,6 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,
                            cpu_to_le32(new_rate);
                        repeat_rate--;
                        idx++;
-                       if (idx >= LINK_QUAL_MAX_RETRY_NUM)
-                               goto out;
                }
 
                il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band,
@@ -2468,7 +2466,6 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,
                repeat_rate--;
        }
 
-out:
        lq_cmd->agg_params.agg_frame_cnt_limit = LINK_QUAL_AGG_FRAME_LIMIT_DEF;
        lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
 
index 6e55f15..1f301a5 100644 (file)
@@ -5060,6 +5060,10 @@ static int hwsim_virtio_handle_cmd(struct sk_buff *skb)
 
        nlh = nlmsg_hdr(skb);
        gnlh = nlmsg_data(nlh);
+
+       if (skb->len < nlh->nlmsg_len)
+               return -EINVAL;
+
        err = genlmsg_parse(nlh, &hwsim_genl_family, tb, HWSIM_ATTR_MAX,
                            hwsim_genl_policy, NULL);
        if (err) {
@@ -5102,7 +5106,8 @@ static void hwsim_virtio_rx_work(struct work_struct *work)
        spin_unlock_irqrestore(&hwsim_virtio_lock, flags);
 
        skb->data = skb->head;
-       skb_set_tail_pointer(skb, len);
+       skb_reset_tail_pointer(skb);
+       skb_put(skb, len);
        hwsim_virtio_handle_cmd(skb);
 
        spin_lock_irqsave(&hwsim_virtio_lock, flags);
index e180067..576a014 100644 (file)
@@ -261,7 +261,7 @@ int mt7921e_mac_reset(struct mt7921_dev *dev)
 
        err = mt7921e_driver_own(dev);
        if (err)
-               return err;
+               goto out;
 
        err = mt7921_run_firmware(dev);
        if (err)
index 43c085c..bb1a315 100644 (file)
@@ -245,6 +245,7 @@ struct wilc {
        u8 *rx_buffer;
        u32 rx_buffer_offset;
        u8 *tx_buffer;
+       u32 *vmm_table;
 
        struct txq_handle txq[NQUEUES];
        int txq_entries;
index 600cc57..7390f94 100644 (file)
@@ -28,6 +28,7 @@ struct wilc_sdio {
        u32 block_size;
        bool isinit;
        int has_thrpt_enh3;
+       u8 *cmd53_buf;
 };
 
 struct sdio_cmd52 {
@@ -47,6 +48,7 @@ struct sdio_cmd53 {
        u32 count:              9;
        u8 *buffer;
        u32 block_size;
+       bool use_global_buf;
 };
 
 static const struct wilc_hif_func wilc_hif_sdio;
@@ -91,6 +93,8 @@ static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd)
 {
        struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
        int size, ret;
+       struct wilc_sdio *sdio_priv = wilc->bus_data;
+       u8 *buf = cmd->buffer;
 
        sdio_claim_host(func);
 
@@ -101,12 +105,23 @@ static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd)
        else
                size = cmd->count;
 
+       if (cmd->use_global_buf) {
+               if (size > sizeof(u32))
+                       return -EINVAL;
+
+               buf = sdio_priv->cmd53_buf;
+       }
+
        if (cmd->read_write) {  /* write */
-               ret = sdio_memcpy_toio(func, cmd->address,
-                                      (void *)cmd->buffer, size);
+               if (cmd->use_global_buf)
+                       memcpy(buf, cmd->buffer, size);
+
+               ret = sdio_memcpy_toio(func, cmd->address, buf, size);
        } else {        /* read */
-               ret = sdio_memcpy_fromio(func, (void *)cmd->buffer,
-                                        cmd->address,  size);
+               ret = sdio_memcpy_fromio(func, buf, cmd->address, size);
+
+               if (cmd->use_global_buf)
+                       memcpy(cmd->buffer, buf, size);
        }
 
        sdio_release_host(func);
@@ -128,6 +143,12 @@ static int wilc_sdio_probe(struct sdio_func *func,
        if (!sdio_priv)
                return -ENOMEM;
 
+       sdio_priv->cmd53_buf = kzalloc(sizeof(u32), GFP_KERNEL);
+       if (!sdio_priv->cmd53_buf) {
+               ret = -ENOMEM;
+               goto free;
+       }
+
        ret = wilc_cfg80211_init(&wilc, &func->dev, WILC_HIF_SDIO,
                                 &wilc_hif_sdio);
        if (ret)
@@ -161,6 +182,7 @@ dispose_irq:
        irq_dispose_mapping(wilc->dev_irq_num);
        wilc_netdev_cleanup(wilc);
 free:
+       kfree(sdio_priv->cmd53_buf);
        kfree(sdio_priv);
        return ret;
 }
@@ -172,6 +194,7 @@ static void wilc_sdio_remove(struct sdio_func *func)
 
        clk_disable_unprepare(wilc->rtc_clk);
        wilc_netdev_cleanup(wilc);
+       kfree(sdio_priv->cmd53_buf);
        kfree(sdio_priv);
 }
 
@@ -375,8 +398,9 @@ static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, u32 data)
                cmd.address = WILC_SDIO_FBR_DATA_REG;
                cmd.block_mode = 0;
                cmd.increment = 1;
-               cmd.count = 4;
+               cmd.count = sizeof(u32);
                cmd.buffer = (u8 *)&data;
+               cmd.use_global_buf = true;
                cmd.block_size = sdio_priv->block_size;
                ret = wilc_sdio_cmd53(wilc, &cmd);
                if (ret)
@@ -414,6 +438,7 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
        nblk = size / block_size;
        nleft = size % block_size;
 
+       cmd.use_global_buf = false;
        if (nblk > 0) {
                cmd.block_mode = 1;
                cmd.increment = 1;
@@ -492,8 +517,9 @@ static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data)
                cmd.address = WILC_SDIO_FBR_DATA_REG;
                cmd.block_mode = 0;
                cmd.increment = 1;
-               cmd.count = 4;
+               cmd.count = sizeof(u32);
                cmd.buffer = (u8 *)data;
+               cmd.use_global_buf = true;
 
                cmd.block_size = sdio_priv->block_size;
                ret = wilc_sdio_cmd53(wilc, &cmd);
@@ -535,6 +561,7 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
        nblk = size / block_size;
        nleft = size % block_size;
 
+       cmd.use_global_buf = false;
        if (nblk > 0) {
                cmd.block_mode = 1;
                cmd.increment = 1;
index 947d9a0..58bbf50 100644 (file)
@@ -714,7 +714,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
        int ret = 0;
        int counter;
        int timeout;
-       u32 vmm_table[WILC_VMM_TBL_SIZE];
+       u32 *vmm_table = wilc->vmm_table;
        u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0};
        const struct wilc_hif_func *func;
        int srcu_idx;
@@ -1252,6 +1252,8 @@ void wilc_wlan_cleanup(struct net_device *dev)
        while ((rqe = wilc_wlan_rxq_remove(wilc)))
                kfree(rqe);
 
+       kfree(wilc->vmm_table);
+       wilc->vmm_table = NULL;
        kfree(wilc->rx_buffer);
        wilc->rx_buffer = NULL;
        kfree(wilc->tx_buffer);
@@ -1489,6 +1491,14 @@ int wilc_wlan_init(struct net_device *dev)
                        goto fail;
        }
 
+       if (!wilc->vmm_table)
+               wilc->vmm_table = kzalloc(WILC_VMM_TBL_SIZE, GFP_KERNEL);
+
+       if (!wilc->vmm_table) {
+               ret = -ENOBUFS;
+               goto fail;
+       }
+
        if (!wilc->tx_buffer)
                wilc->tx_buffer = kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL);
 
@@ -1513,7 +1523,8 @@ int wilc_wlan_init(struct net_device *dev)
        return 0;
 
 fail:
-
+       kfree(wilc->vmm_table);
+       wilc->vmm_table = NULL;
        kfree(wilc->rx_buffer);
        wilc->rx_buffer = NULL;
        kfree(wilc->tx_buffer);
index 990360d..e85b3c5 100644 (file)
@@ -256,7 +256,6 @@ static void backend_disconnect(struct backend_info *be)
                unsigned int queue_index;
 
                xen_unregister_watchers(vif);
-               xenbus_rm(XBT_NIL, be->dev->nodename, "hotplug-status");
 #ifdef CONFIG_DEBUG_FS
                xenvif_debugfs_delif(vif);
 #endif /* CONFIG_DEBUG_FS */
@@ -984,6 +983,7 @@ static int netback_remove(struct xenbus_device *dev)
        struct backend_info *be = dev_get_drvdata(&dev->dev);
 
        unregister_hotplug_status_watch(be);
+       xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status");
        if (be->vif) {
                kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
                backend_disconnect(be);
index 2caf997..07596bf 100644 (file)
@@ -310,6 +310,7 @@ static void pn532_uart_remove(struct serdev_device *serdev)
        pn53x_unregister_nfc(pn532->priv);
        serdev_device_close(serdev);
        pn53x_common_clean(pn532->priv);
+       del_timer_sync(&pn532->cmd_timeout);
        kfree_skb(pn532->recv_skb);
        kfree(pn532);
 }
index 3a1c37f..98864b8 100644 (file)
@@ -3517,6 +3517,8 @@ static const struct pci_device_id nvme_id_table[] = {
                .driver_data = NVME_QUIRK_NO_DEEPEST_PS, },
        { PCI_DEVICE(0xc0a9, 0x540a),   /* Crucial P2 */
                .driver_data = NVME_QUIRK_BOGUS_NID, },
+       { PCI_DEVICE(0x1d97, 0x2263), /* Lexar NM610 */
+               .driver_data = NVME_QUIRK_BOGUS_NID, },
        { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0x0061),
                .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, },
        { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0x0065),
index cf690df..c4113b4 100644 (file)
@@ -196,6 +196,7 @@ int nvmet_setup_auth(struct nvmet_ctrl *ctrl)
        if (IS_ERR(ctrl->ctrl_key)) {
                ret = PTR_ERR(ctrl->ctrl_key);
                ctrl->ctrl_key = NULL;
+               goto out_free_hash;
        }
        pr_debug("%s: using ctrl hash %s key %*ph\n", __func__,
                 ctrl->ctrl_key->hash > 0 ?
index dc3b4dc..a3694a3 100644 (file)
@@ -1506,6 +1506,9 @@ static void nvmet_tcp_state_change(struct sock *sk)
                goto done;
 
        switch (sk->sk_state) {
+       case TCP_FIN_WAIT2:
+       case TCP_LAST_ACK:
+               break;
        case TCP_FIN_WAIT1:
        case TCP_CLOSE_WAIT:
        case TCP_CLOSE:
index 9be007c..f223afe 100644 (file)
@@ -268,7 +268,7 @@ static int ioc_count;
 *   Each bit can represent a number of pages.
 *   LSbs represent lower addresses (IOVA's).
 *
-*   This was was copied from sba_iommu.c. Don't try to unify
+*   This was copied from sba_iommu.c. Don't try to unify
 *   the two resource managers unless a way to have different
 *   allocation policies is also adjusted. We'd like to avoid
 *   I/O TLB thrashing by having resource allocation policy
@@ -1380,15 +1380,17 @@ ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr)
        }
 }
 
-static void __init ccio_init_resources(struct ioc *ioc)
+static int __init ccio_init_resources(struct ioc *ioc)
 {
        struct resource *res = ioc->mmio_region;
        char *name = kmalloc(14, GFP_KERNEL);
-
+       if (unlikely(!name))
+               return -ENOMEM;
        snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path);
 
        ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low);
        ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv);
+       return 0;
 }
 
 static int new_ioc_area(struct resource *res, unsigned long size,
@@ -1543,7 +1545,10 @@ static int __init ccio_probe(struct parisc_device *dev)
                return -ENOMEM;
        }
        ccio_ioc_init(ioc);
-       ccio_init_resources(ioc);
+       if (ccio_init_resources(ioc)) {
+               kfree(ioc);
+               return -ENOMEM;
+       }
        hppa_dma_ops = &ccio_ops;
 
        hba = kzalloc(sizeof(*hba), GFP_KERNEL);
index 1e4a566..d4be9d2 100644 (file)
@@ -646,7 +646,7 @@ int lcd_print( const char *str )
                cancel_delayed_work_sync(&led_task);
 
        /* copy display string to buffer for procfs */
-       strlcpy(lcd_text, str, sizeof(lcd_text));
+       strscpy(lcd_text, str, sizeof(lcd_text));
 
        /* Set LCD Cursor to 1st character */
        gsc_writeb(lcd_info.reset_cmd1, LCD_CMD_REG);
index 1925ddc..731c5d8 100644 (file)
@@ -523,7 +523,7 @@ static int aspeed_peci_probe(struct platform_device *pdev)
                return PTR_ERR(priv->base);
 
        priv->irq = platform_get_irq(pdev, 0);
-       if (!priv->irq)
+       if (priv->irq < 0)
                return priv->irq;
 
        ret = devm_request_irq(&pdev->dev, priv->irq, aspeed_peci_irq_handler,
index 68eb61c..de4a7b3 100644 (file)
@@ -188,8 +188,6 @@ static void adev_release(struct device *dev)
 {
        struct auxiliary_device *adev = to_auxiliary_dev(dev);
 
-       auxiliary_device_uninit(adev);
-
        kfree(adev->name);
        kfree(adev);
 }
@@ -234,6 +232,7 @@ static void unregister_adev(void *_adev)
        struct auxiliary_device *adev = _adev;
 
        auxiliary_device_delete(adev);
+       auxiliary_device_uninit(adev);
 }
 
 static int devm_adev_add(struct device *dev, int idx)
index 513de1f..933b96e 100644 (file)
@@ -117,7 +117,7 @@ static int pmu_parse_irqs(struct arm_pmu *pmu)
 
        if (num_irqs == 1) {
                int irq = platform_get_irq(pdev, 0);
-               if (irq && irq_is_percpu_devid(irq))
+               if ((irq > 0) && irq_is_percpu_devid(irq))
                        return pmu_parse_percpu_irq(pmu, irq);
        }
 
index 55834cc..1e071df 100644 (file)
@@ -460,8 +460,6 @@ static int mlxreg_lc_power_on_off(struct mlxreg_lc *mlxreg_lc, u8 action)
        u32 regval;
        int err;
 
-       mutex_lock(&mlxreg_lc->lock);
-
        err = regmap_read(mlxreg_lc->par_regmap, mlxreg_lc->data->reg_pwr, &regval);
        if (err)
                goto regmap_read_fail;
@@ -474,7 +472,6 @@ static int mlxreg_lc_power_on_off(struct mlxreg_lc *mlxreg_lc, u8 action)
        err = regmap_write(mlxreg_lc->par_regmap, mlxreg_lc->data->reg_pwr, regval);
 
 regmap_read_fail:
-       mutex_unlock(&mlxreg_lc->lock);
        return err;
 }
 
@@ -491,8 +488,6 @@ static int mlxreg_lc_enable_disable(struct mlxreg_lc *mlxreg_lc, bool action)
         * line card which is already has been enabled. Disabling does not affect the disabled line
         * card.
         */
-       mutex_lock(&mlxreg_lc->lock);
-
        err = regmap_read(mlxreg_lc->par_regmap, mlxreg_lc->data->reg_ena, &regval);
        if (err)
                goto regmap_read_fail;
@@ -505,7 +500,6 @@ static int mlxreg_lc_enable_disable(struct mlxreg_lc *mlxreg_lc, bool action)
        err = regmap_write(mlxreg_lc->par_regmap, mlxreg_lc->data->reg_ena, regval);
 
 regmap_read_fail:
-       mutex_unlock(&mlxreg_lc->lock);
        return err;
 }
 
@@ -538,6 +532,15 @@ mlxreg_lc_sn4800_c16_config_init(struct mlxreg_lc *mlxreg_lc, void *regmap,
 static void
 mlxreg_lc_state_update(struct mlxreg_lc *mlxreg_lc, enum mlxreg_lc_state state, u8 action)
 {
+       if (action)
+               mlxreg_lc->state |= state;
+       else
+               mlxreg_lc->state &= ~state;
+}
+
+static void
+mlxreg_lc_state_update_locked(struct mlxreg_lc *mlxreg_lc, enum mlxreg_lc_state state, u8 action)
+{
        mutex_lock(&mlxreg_lc->lock);
 
        if (action)
@@ -560,8 +563,11 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
        dev_info(mlxreg_lc->dev, "linecard#%d state %d event kind %d action %d\n",
                 mlxreg_lc->data->slot, mlxreg_lc->state, kind, action);
 
-       if (!(mlxreg_lc->state & MLXREG_LC_INITIALIZED))
+       mutex_lock(&mlxreg_lc->lock);
+       if (!(mlxreg_lc->state & MLXREG_LC_INITIALIZED)) {
+               mutex_unlock(&mlxreg_lc->lock);
                return 0;
+       }
 
        switch (kind) {
        case MLXREG_HOTPLUG_LC_SYNCED:
@@ -574,7 +580,7 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
                if (!(mlxreg_lc->state & MLXREG_LC_POWERED) && action) {
                        err = mlxreg_lc_power_on_off(mlxreg_lc, 1);
                        if (err)
-                               return err;
+                               goto mlxreg_lc_power_on_off_fail;
                }
                /* In case line card is configured - enable it. */
                if (mlxreg_lc->state & MLXREG_LC_CONFIGURED && action)
@@ -588,12 +594,13 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
                                /* In case line card is configured - enable it. */
                                if (mlxreg_lc->state & MLXREG_LC_CONFIGURED)
                                        err = mlxreg_lc_enable_disable(mlxreg_lc, 1);
+                               mutex_unlock(&mlxreg_lc->lock);
                                return err;
                        }
                        err = mlxreg_lc_create_static_devices(mlxreg_lc, mlxreg_lc->main_devs,
                                                              mlxreg_lc->main_devs_num);
                        if (err)
-                               return err;
+                               goto mlxreg_lc_create_static_devices_fail;
 
                        /* In case line card is already in ready state - enable it. */
                        if (mlxreg_lc->state & MLXREG_LC_CONFIGURED)
@@ -620,6 +627,10 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
                break;
        }
 
+mlxreg_lc_power_on_off_fail:
+mlxreg_lc_create_static_devices_fail:
+       mutex_unlock(&mlxreg_lc->lock);
+
        return err;
 }
 
@@ -665,7 +676,7 @@ static int mlxreg_lc_completion_notify(void *handle, struct i2c_adapter *parent,
                if (err)
                        goto mlxreg_lc_create_static_devices_failed;
 
-               mlxreg_lc_state_update(mlxreg_lc, MLXREG_LC_POWERED, 1);
+               mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_POWERED, 1);
        }
 
        /* Verify if line card is synchronized. */
@@ -676,7 +687,7 @@ static int mlxreg_lc_completion_notify(void *handle, struct i2c_adapter *parent,
        /* Power on line card if necessary. */
        if (regval & mlxreg_lc->data->mask) {
                mlxreg_lc->state |= MLXREG_LC_SYNCED;
-               mlxreg_lc_state_update(mlxreg_lc, MLXREG_LC_SYNCED, 1);
+               mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_SYNCED, 1);
                if (mlxreg_lc->state & ~MLXREG_LC_POWERED) {
                        err = mlxreg_lc_power_on_off(mlxreg_lc, 1);
                        if (err)
@@ -684,7 +695,7 @@ static int mlxreg_lc_completion_notify(void *handle, struct i2c_adapter *parent,
                }
        }
 
-       mlxreg_lc_state_update(mlxreg_lc, MLXREG_LC_INITIALIZED, 1);
+       mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_INITIALIZED, 1);
 
        return 0;
 
@@ -814,10 +825,9 @@ static int mlxreg_lc_probe(struct platform_device *pdev)
 
        mutex_init(&mlxreg_lc->lock);
        /* Set event notification callback. */
-       if (data->notifier) {
-               data->notifier->user_handler = mlxreg_lc_event_handler;
-               data->notifier->handle = mlxreg_lc;
-       }
+       data->notifier->user_handler = mlxreg_lc_event_handler;
+       data->notifier->handle = mlxreg_lc;
+
        data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr);
        if (!data->hpdev.adapter) {
                dev_err(&pdev->dev, "Failed to get adapter for bus %d\n",
@@ -863,7 +873,6 @@ static int mlxreg_lc_probe(struct platform_device *pdev)
        if (err) {
                dev_err(&pdev->dev, "Failed to sync regmap for client %s at bus %d at addr 0x%02x\n",
                        data->hpdev.brdinfo->type, data->hpdev.nr, data->hpdev.brdinfo->addr);
-               err = PTR_ERR(regmap);
                goto regcache_sync_fail;
        }
 
@@ -878,16 +887,14 @@ static int mlxreg_lc_probe(struct platform_device *pdev)
        if (err)
                goto mlxreg_lc_config_init_fail;
 
-       return err;
+       return 0;
 
 mlxreg_lc_config_init_fail:
 regcache_sync_fail:
 regmap_write_fail:
 devm_regmap_init_i2c_fail:
-       if (data->hpdev.client) {
-               i2c_unregister_device(data->hpdev.client);
-               data->hpdev.client = NULL;
-       }
+       i2c_unregister_device(data->hpdev.client);
+       data->hpdev.client = NULL;
 i2c_new_device_fail:
        i2c_put_adapter(data->hpdev.adapter);
        data->hpdev.adapter = NULL;
@@ -905,6 +912,8 @@ static int mlxreg_lc_remove(struct platform_device *pdev)
        struct mlxreg_core_data *data = dev_get_platdata(&pdev->dev);
        struct mlxreg_lc *mlxreg_lc = platform_get_drvdata(pdev);
 
+       mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_INITIALIZED, 0);
+
        /*
         * Probing and removing are invoked by hotplug events raised upon line card insertion and
         * removing. If probing procedure fails all data is cleared. However, hotplug event still
index d5655f6..5859110 100644 (file)
@@ -86,38 +86,38 @@ static const struct software_node ssam_node_bas_dtx = {
        .parent = &ssam_node_root,
 };
 
-/* HID keyboard (TID1). */
-static const struct software_node ssam_node_hid_tid1_keyboard = {
+/* HID keyboard (SAM, TID=1). */
+static const struct software_node ssam_node_hid_sam_keyboard = {
        .name = "ssam:01:15:01:01:00",
        .parent = &ssam_node_root,
 };
 
-/* HID pen stash (TID1; pen taken / stashed away evens). */
-static const struct software_node ssam_node_hid_tid1_penstash = {
+/* HID pen stash (SAM, TID=1; pen taken / stashed away evens). */
+static const struct software_node ssam_node_hid_sam_penstash = {
        .name = "ssam:01:15:01:02:00",
        .parent = &ssam_node_root,
 };
 
-/* HID touchpad (TID1). */
-static const struct software_node ssam_node_hid_tid1_touchpad = {
+/* HID touchpad (SAM, TID=1). */
+static const struct software_node ssam_node_hid_sam_touchpad = {
        .name = "ssam:01:15:01:03:00",
        .parent = &ssam_node_root,
 };
 
-/* HID device instance 6 (TID1, unknown HID device). */
-static const struct software_node ssam_node_hid_tid1_iid6 = {
+/* HID device instance 6 (SAM, TID=1, HID sensor collection). */
+static const struct software_node ssam_node_hid_sam_sensors = {
        .name = "ssam:01:15:01:06:00",
        .parent = &ssam_node_root,
 };
 
-/* HID device instance 7 (TID1, unknown HID device). */
-static const struct software_node ssam_node_hid_tid1_iid7 = {
+/* HID device instance 7 (SAM, TID=1, UCM UCSI HID client). */
+static const struct software_node ssam_node_hid_sam_ucm_ucsi = {
        .name = "ssam:01:15:01:07:00",
        .parent = &ssam_node_root,
 };
 
-/* HID system controls (TID1). */
-static const struct software_node ssam_node_hid_tid1_sysctrl = {
+/* HID system controls (SAM, TID=1). */
+static const struct software_node ssam_node_hid_sam_sysctrl = {
        .name = "ssam:01:15:01:08:00",
        .parent = &ssam_node_root,
 };
@@ -182,8 +182,8 @@ static const struct software_node ssam_node_hid_kip_touchpad = {
        .parent = &ssam_node_hub_kip,
 };
 
-/* HID device instance 5 (KIP hub, unknown HID device). */
-static const struct software_node ssam_node_hid_kip_iid5 = {
+/* HID device instance 5 (KIP hub, type-cover firmware update). */
+static const struct software_node ssam_node_hid_kip_fwupd = {
        .name = "ssam:01:15:02:05:00",
        .parent = &ssam_node_hub_kip,
 };
@@ -241,12 +241,12 @@ static const struct software_node *ssam_node_group_sls[] = {
        &ssam_node_bat_main,
        &ssam_node_tmp_pprof,
        &ssam_node_pos_tablet_switch,
-       &ssam_node_hid_tid1_keyboard,
-       &ssam_node_hid_tid1_penstash,
-       &ssam_node_hid_tid1_touchpad,
-       &ssam_node_hid_tid1_iid6,
-       &ssam_node_hid_tid1_iid7,
-       &ssam_node_hid_tid1_sysctrl,
+       &ssam_node_hid_sam_keyboard,
+       &ssam_node_hid_sam_penstash,
+       &ssam_node_hid_sam_touchpad,
+       &ssam_node_hid_sam_sensors,
+       &ssam_node_hid_sam_ucm_ucsi,
+       &ssam_node_hid_sam_sysctrl,
        NULL,
 };
 
@@ -278,7 +278,9 @@ static const struct software_node *ssam_node_group_sp8[] = {
        &ssam_node_hid_kip_keyboard,
        &ssam_node_hid_kip_penstash,
        &ssam_node_hid_kip_touchpad,
-       &ssam_node_hid_kip_iid5,
+       &ssam_node_hid_kip_fwupd,
+       &ssam_node_hid_sam_sensors,
+       &ssam_node_hid_sam_ucm_ucsi,
        NULL,
 };
 
@@ -325,6 +327,9 @@ static const struct acpi_device_id ssam_platform_hub_match[] = {
        /* Surface Laptop Go 1 */
        { "MSHW0118", (unsigned long)ssam_node_group_slg1 },
 
+       /* Surface Laptop Go 2 */
+       { "MSHW0290", (unsigned long)ssam_node_group_slg1 },
+
        /* Surface Laptop Studio */
        { "MSHW0123", (unsigned long)ssam_node_group_sls },
 
index e0230ea..f1259d8 100644 (file)
@@ -99,6 +99,7 @@ static const struct key_entry acer_wmi_keymap[] __initconst = {
        {KE_KEY, 0x22, {KEY_PROG2} },    /* Arcade */
        {KE_KEY, 0x23, {KEY_PROG3} },    /* P_Key */
        {KE_KEY, 0x24, {KEY_PROG4} },    /* Social networking_Key */
+       {KE_KEY, 0x27, {KEY_HELP} },
        {KE_KEY, 0x29, {KEY_PROG3} },    /* P_Key for TM8372 */
        {KE_IGNORE, 0x41, {KEY_MUTE} },
        {KE_IGNORE, 0x42, {KEY_PREVIOUSSONG} },
@@ -112,7 +113,13 @@ static const struct key_entry acer_wmi_keymap[] __initconst = {
        {KE_IGNORE, 0x48, {KEY_VOLUMEUP} },
        {KE_IGNORE, 0x49, {KEY_VOLUMEDOWN} },
        {KE_IGNORE, 0x4a, {KEY_VOLUMEDOWN} },
-       {KE_IGNORE, 0x61, {KEY_SWITCHVIDEOMODE} },
+       /*
+        * 0x61 is KEY_SWITCHVIDEOMODE. Usually this is a duplicate input event
+        * with the "Video Bus" input device events. But sometimes it is not
+        * a dup. Map it to KEY_UNKNOWN instead of using KE_IGNORE so that
+        * udev/hwdb can override it on systems where it is not a dup.
+        */
+       {KE_KEY, 0x61, {KEY_UNKNOWN} },
        {KE_IGNORE, 0x62, {KEY_BRIGHTNESSUP} },
        {KE_IGNORE, 0x63, {KEY_BRIGHTNESSDOWN} },
        {KE_KEY, 0x64, {KEY_SWITCHVIDEOMODE} }, /* Display Switch */
index 89b604e..eec7d0e 100644 (file)
@@ -107,7 +107,7 @@ module_param(fnlock_default, bool, 0444);
 #define WMI_EVENT_MASK                 0xFFFF
 
 #define FAN_CURVE_POINTS               8
-#define FAN_CURVE_BUF_LEN              (FAN_CURVE_POINTS * 2)
+#define FAN_CURVE_BUF_LEN              32
 #define FAN_CURVE_DEV_CPU              0x00
 #define FAN_CURVE_DEV_GPU              0x01
 /* Mask to determine if setting temperature or percentage */
@@ -1118,7 +1118,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
        }
 
        if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MICMUTE_LED)) {
-               asus->micmute_led.name = "asus::micmute";
+               asus->micmute_led.name = "platform::micmute";
                asus->micmute_led.max_brightness = 1;
                asus->micmute_led.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
                asus->micmute_led.brightness_set_blocking = micmute_led_set;
@@ -2233,8 +2233,10 @@ static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev)
        curves = &asus->custom_fan_curves[fan_idx];
        err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf,
                                           FAN_CURVE_BUF_LEN);
-       if (err)
+       if (err) {
+               pr_warn("%s (0x%08x) failed: %d\n", __func__, fan_dev, err);
                return err;
+       }
 
        fan_curve_copy_from_buf(curves, buf);
        curves->device_id = fan_dev;
@@ -2252,9 +2254,6 @@ static int fan_curve_check_present(struct asus_wmi *asus, bool *available,
 
        err = fan_curve_get_factory_default(asus, fan_dev);
        if (err) {
-               pr_debug("fan_curve_get_factory_default(0x%08x) failed: %d\n",
-                        fan_dev, err);
-               /* Don't cause probe to fail on devices without fan-curves */
                return 0;
        }
 
index fb2e141..384d096 100644 (file)
@@ -42,10 +42,24 @@ static int p2sb_get_devfn(unsigned int *devfn)
        return 0;
 }
 
+/* Copy resource from the first BAR of the device in question */
 static int p2sb_read_bar0(struct pci_dev *pdev, struct resource *mem)
 {
-       /* Copy resource from the first BAR of the device in question */
-       *mem = pdev->resource[0];
+       struct resource *bar0 = &pdev->resource[0];
+
+       /* Make sure we have no dangling pointers in the output */
+       memset(mem, 0, sizeof(*mem));
+
+       /*
+        * We copy only selected fields from the original resource.
+        * Because a PCI device will be removed soon, we may not use
+        * any allocated data, hence we may not copy any pointers.
+        */
+       mem->start = bar0->start;
+       mem->end = bar0->end;
+       mem->flags = bar0->flags;
+       mem->desc = bar0->desc;
+
        return 0;
 }
 
index 154317e..5c757c7 100644 (file)
@@ -232,7 +232,7 @@ static void pmc_power_off(void)
        pm1_cnt_port = acpi_base_addr + PM1_CNT;
 
        pm1_cnt_value = inl(pm1_cnt_port);
-       pm1_cnt_value &= SLEEP_TYPE_MASK;
+       pm1_cnt_value &= ~SLEEP_TYPE_MASK;
        pm1_cnt_value |= SLEEP_TYPE_S5;
        pm1_cnt_value |= SLEEP_ENABLE;
 
index 22d4e86..2dbb9fc 100644 (file)
@@ -10592,10 +10592,9 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
        /* Ensure initial values are correct */
        dytc_profile_refresh();
 
-       /* Set AMT correctly now we know current profile */
-       if ((dytc_capabilities & BIT(DYTC_FC_PSC)) &&
-           (dytc_capabilities & BIT(DYTC_FC_AMT)))
-           dytc_control_amt(dytc_current_profile == PLATFORM_PROFILE_BALANCED);
+       /* Workaround for https://bugzilla.kernel.org/show_bug.cgi?id=216347 */
+       if (dytc_capabilities & BIT(DYTC_FC_PSC))
+               dytc_profile_set(NULL, PLATFORM_PROFILE_BALANCED);
 
        return 0;
 }
index 4803759..4acd6fa 100644 (file)
@@ -663,9 +663,23 @@ static const struct x86_i2c_client_info chuwi_hi8_i2c_clients[] __initconst = {
        },
 };
 
+static int __init chuwi_hi8_init(void)
+{
+       /*
+        * Avoid the acpi_unregister_gsi() call in x86_acpi_irq_helper_get()
+        * breaking the touchscreen + logging various errors when the Windows
+        * BIOS is used.
+        */
+       if (acpi_dev_present("MSSL0001", NULL, 1))
+               return -ENODEV;
+
+       return 0;
+}
+
 static const struct x86_dev_info chuwi_hi8_info __initconst = {
        .i2c_client_info = chuwi_hi8_i2c_clients,
        .i2c_client_count = ARRAY_SIZE(chuwi_hi8_i2c_clients),
+       .init = chuwi_hi8_init,
 };
 
 #define CZC_EC_EXTRA_PORT      0x68
index d8373cb..d3e8dc3 100644 (file)
@@ -2733,13 +2733,18 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
  */
 static int _regulator_handle_consumer_enable(struct regulator *regulator)
 {
+       int ret;
        struct regulator_dev *rdev = regulator->rdev;
 
        lockdep_assert_held_once(&rdev->mutex.base);
 
        regulator->enable_count++;
-       if (regulator->uA_load && regulator->enable_count == 1)
-               return drms_uA_update(rdev);
+       if (regulator->uA_load && regulator->enable_count == 1) {
+               ret = drms_uA_update(rdev);
+               if (ret)
+                       regulator->enable_count--;
+               return ret;
+       }
 
        return 0;
 }
index 6b61702..d899d6e 100644 (file)
@@ -766,7 +766,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
                ((pfuze_chip->chip_id == PFUZE3000) ? "3000" : "3001"))));
 
        memcpy(pfuze_chip->regulator_descs, pfuze_chip->pfuze_regulators,
-               sizeof(pfuze_chip->regulator_descs));
+               regulator_num * sizeof(struct pfuze_regulator));
 
        ret = pfuze_parse_regulators_dt(pfuze_chip);
        if (ret)
index a3e117a..f6c37a9 100644 (file)
@@ -7153,22 +7153,18 @@ static int megasas_alloc_ctrl_mem(struct megasas_instance *instance)
        switch (instance->adapter_type) {
        case MFI_SERIES:
                if (megasas_alloc_mfi_ctrl_mem(instance))
-                       goto fail;
+                       return -ENOMEM;
                break;
        case AERO_SERIES:
        case VENTURA_SERIES:
        case THUNDERBOLT_SERIES:
        case INVADER_SERIES:
                if (megasas_alloc_fusion_context(instance))
-                       goto fail;
+                       return -ENOMEM;
                break;
        }
 
        return 0;
- fail:
-       kfree(instance->reply_map);
-       instance->reply_map = NULL;
-       return -ENOMEM;
 }
 
 /*
index e48d426..09c5fe3 100644 (file)
@@ -5310,7 +5310,6 @@ megasas_alloc_fusion_context(struct megasas_instance *instance)
                if (!fusion->log_to_span) {
                        dev_err(&instance->pdev->dev, "Failed from %s %d\n",
                                __func__, __LINE__);
-                       kfree(instance->ctrl_context);
                        return -ENOMEM;
                }
        }
index 2b2f682..62666df 100644 (file)
@@ -6935,14 +6935,8 @@ qlt_24xx_config_rings(struct scsi_qla_host *vha)
 
        if (ha->flags.msix_enabled) {
                if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
-                       if (IS_QLA2071(ha)) {
-                               /* 4 ports Baker: Enable Interrupt Handshake */
-                               icb->msix_atio = 0;
-                               icb->firmware_options_2 |= cpu_to_le32(BIT_26);
-                       } else {
-                               icb->msix_atio = cpu_to_le16(msix->entry);
-                               icb->firmware_options_2 &= cpu_to_le32(~BIT_26);
-                       }
+                       icb->msix_atio = cpu_to_le16(msix->entry);
+                       icb->firmware_options_2 &= cpu_to_le32(~BIT_26);
                        ql_dbg(ql_dbg_init, vha, 0xf072,
                            "Registering ICB vector 0x%x for atio que.\n",
                            msix->entry);
index 4dbd29a..ef08029 100644 (file)
@@ -111,7 +111,7 @@ scsi_set_blocked(struct scsi_cmnd *cmd, int reason)
        }
 }
 
-static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd)
+static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd, unsigned long msecs)
 {
        struct request *rq = scsi_cmd_to_rq(cmd);
 
@@ -121,7 +121,12 @@ static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd)
        } else {
                WARN_ON_ONCE(true);
        }
-       blk_mq_requeue_request(rq, true);
+
+       if (msecs) {
+               blk_mq_requeue_request(rq, false);
+               blk_mq_delay_kick_requeue_list(rq->q, msecs);
+       } else
+               blk_mq_requeue_request(rq, true);
 }
 
 /**
@@ -651,14 +656,6 @@ static unsigned int scsi_rq_err_bytes(const struct request *rq)
        return bytes;
 }
 
-/* Helper for scsi_io_completion() when "reprep" action required. */
-static void scsi_io_completion_reprep(struct scsi_cmnd *cmd,
-                                     struct request_queue *q)
-{
-       /* A new command will be prepared and issued. */
-       scsi_mq_requeue_cmd(cmd);
-}
-
 static bool scsi_cmd_runtime_exceeced(struct scsi_cmnd *cmd)
 {
        struct request *req = scsi_cmd_to_rq(cmd);
@@ -676,14 +673,21 @@ static bool scsi_cmd_runtime_exceeced(struct scsi_cmnd *cmd)
        return false;
 }
 
+/*
+ * When ALUA transition state is returned, reprep the cmd to
+ * use the ALUA handler's transition timeout. Delay the reprep
+ * 1 sec to avoid aggressive retries of the target in that
+ * state.
+ */
+#define ALUA_TRANSITION_REPREP_DELAY   1000
+
 /* Helper for scsi_io_completion() when special action required. */
 static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
 {
-       struct request_queue *q = cmd->device->request_queue;
        struct request *req = scsi_cmd_to_rq(cmd);
        int level = 0;
-       enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY,
-             ACTION_DELAYED_RETRY} action;
+       enum {ACTION_FAIL, ACTION_REPREP, ACTION_DELAYED_REPREP,
+             ACTION_RETRY, ACTION_DELAYED_RETRY} action;
        struct scsi_sense_hdr sshdr;
        bool sense_valid;
        bool sense_current = true;      /* false implies "deferred sense" */
@@ -772,8 +776,8 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
                                        action = ACTION_DELAYED_RETRY;
                                        break;
                                case 0x0a: /* ALUA state transition */
-                                       blk_stat = BLK_STS_TRANSPORT;
-                                       fallthrough;
+                                       action = ACTION_DELAYED_REPREP;
+                                       break;
                                default:
                                        action = ACTION_FAIL;
                                        break;
@@ -832,7 +836,10 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
                        return;
                fallthrough;
        case ACTION_REPREP:
-               scsi_io_completion_reprep(cmd, q);
+               scsi_mq_requeue_cmd(cmd, 0);
+               break;
+       case ACTION_DELAYED_REPREP:
+               scsi_mq_requeue_cmd(cmd, ALUA_TRANSITION_REPREP_DELAY);
                break;
        case ACTION_RETRY:
                /* Retry the same command immediately */
@@ -926,7 +933,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
  * command block will be released and the queue function will be goosed. If we
  * are not done then we have to figure out what to do next:
  *
- *   a) We can call scsi_io_completion_reprep().  The request will be
+ *   a) We can call scsi_mq_requeue_cmd().  The request will be
  *     unprepared and put back on the queue.  Then a new command will
  *     be created for it.  This should be used if we made forward
  *     progress, or if we want to switch from READ(10) to READ(6) for
@@ -942,7 +949,6 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
 void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 {
        int result = cmd->result;
-       struct request_queue *q = cmd->device->request_queue;
        struct request *req = scsi_cmd_to_rq(cmd);
        blk_status_t blk_stat = BLK_STS_OK;
 
@@ -979,7 +985,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
         * request just queue the command up again.
         */
        if (likely(result == 0))
-               scsi_io_completion_reprep(cmd, q);
+               scsi_mq_requeue_cmd(cmd, 0);
        else
                scsi_io_completion_action(cmd, result);
 }
@@ -1542,7 +1548,6 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
        scsi_init_command(sdev, cmd);
 
        cmd->eh_eflags = 0;
-       cmd->allowed = 0;
        cmd->prot_type = 0;
        cmd->prot_flags = 0;
        cmd->submitter = 0;
@@ -1593,6 +1598,8 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
                        return ret;
        }
 
+       /* Usually overridden by the ULP */
+       cmd->allowed = 0;
        memset(cmd->cmnd, 0, sizeof(cmd->cmnd));
        return scsi_cmd_to_driver(cmd)->init_command(cmd);
 }
index 8f79fa6..eb76ba0 100644 (file)
@@ -103,7 +103,6 @@ static void sd_config_discard(struct scsi_disk *, unsigned int);
 static void sd_config_write_same(struct scsi_disk *);
 static int  sd_revalidate_disk(struct gendisk *);
 static void sd_unlock_native_capacity(struct gendisk *disk);
-static void sd_start_done_work(struct work_struct *work);
 static int  sd_probe(struct device *);
 static int  sd_remove(struct device *);
 static void sd_shutdown(struct device *);
@@ -3471,7 +3470,6 @@ static int sd_probe(struct device *dev)
        sdkp->max_retries = SD_MAX_RETRIES;
        atomic_set(&sdkp->openers, 0);
        atomic_set(&sdkp->device->ioerr_cnt, 0);
-       INIT_WORK(&sdkp->start_done_work, sd_start_done_work);
 
        if (!sdp->request_queue->rq_timeout) {
                if (sdp->type != TYPE_MOD)
@@ -3594,69 +3592,12 @@ static void scsi_disk_release(struct device *dev)
        kfree(sdkp);
 }
 
-/* Process sense data after a START command finished. */
-static void sd_start_done_work(struct work_struct *work)
-{
-       struct scsi_disk *sdkp = container_of(work, typeof(*sdkp),
-                                             start_done_work);
-       struct scsi_sense_hdr sshdr;
-       int res = sdkp->start_result;
-
-       if (res == 0)
-               return;
-
-       sd_print_result(sdkp, "Start/Stop Unit failed", res);
-
-       if (res < 0)
-               return;
-
-       if (scsi_normalize_sense(sdkp->start_sense_buffer,
-                                sdkp->start_sense_len, &sshdr))
-               sd_print_sense_hdr(sdkp, &sshdr);
-}
-
-/* A START command finished. May be called from interrupt context. */
-static void sd_start_done(struct request *req, blk_status_t status)
-{
-       const struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req);
-       struct scsi_disk *sdkp = scsi_disk(req->q->disk);
-
-       sdkp->start_result = scmd->result;
-       WARN_ON_ONCE(scmd->sense_len > SCSI_SENSE_BUFFERSIZE);
-       sdkp->start_sense_len = scmd->sense_len;
-       memcpy(sdkp->start_sense_buffer, scmd->sense_buffer,
-              ARRAY_SIZE(sdkp->start_sense_buffer));
-       WARN_ON_ONCE(!schedule_work(&sdkp->start_done_work));
-}
-
-/* Submit a START command asynchronously. */
-static int sd_submit_start(struct scsi_disk *sdkp, u8 cmd[], u8 cmd_len)
-{
-       struct scsi_device *sdev = sdkp->device;
-       struct request_queue *q = sdev->request_queue;
-       struct request *req;
-       struct scsi_cmnd *scmd;
-
-       req = scsi_alloc_request(q, REQ_OP_DRV_IN, BLK_MQ_REQ_PM);
-       if (IS_ERR(req))
-               return PTR_ERR(req);
-
-       scmd = blk_mq_rq_to_pdu(req);
-       scmd->cmd_len = cmd_len;
-       memcpy(scmd->cmnd, cmd, cmd_len);
-       scmd->allowed = sdkp->max_retries;
-       req->timeout = SD_TIMEOUT;
-       req->rq_flags |= RQF_PM | RQF_QUIET;
-       req->end_io = sd_start_done;
-       blk_execute_rq_nowait(req, /*at_head=*/true);
-
-       return 0;
-}
-
 static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
 {
        unsigned char cmd[6] = { START_STOP };  /* START_VALID */
+       struct scsi_sense_hdr sshdr;
        struct scsi_device *sdp = sdkp->device;
+       int res;
 
        if (start)
                cmd[4] |= 1;    /* START */
@@ -3667,10 +3608,23 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
        if (!scsi_device_online(sdp))
                return -ENODEV;
 
-       /* Wait until processing of sense data has finished. */
-       flush_work(&sdkp->start_done_work);
+       res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
+                       SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL);
+       if (res) {
+               sd_print_result(sdkp, "Start/Stop Unit failed", res);
+               if (res > 0 && scsi_sense_valid(&sshdr)) {
+                       sd_print_sense_hdr(sdkp, &sshdr);
+                       /* 0x3a is medium not present */
+                       if (sshdr.asc == 0x3a)
+                               res = 0;
+               }
+       }
 
-       return sd_submit_start(sdkp, cmd, sizeof(cmd));
+       /* SCSI error codes must not go to the generic layer */
+       if (res)
+               return -EIO;
+
+       return 0;
 }
 
 /*
@@ -3697,8 +3651,6 @@ static void sd_shutdown(struct device *dev)
                sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
                sd_start_stop_device(sdkp, 0);
        }
-
-       flush_work(&sdkp->start_done_work);
 }
 
 static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
index b891877..5eea762 100644 (file)
@@ -150,11 +150,6 @@ struct scsi_disk {
        unsigned        urswrz : 1;
        unsigned        security : 1;
        unsigned        ignore_medium_access_errors : 1;
-
-       int             start_result;
-       u32             start_sense_len;
-       u8              start_sense_buffer[SCSI_SENSE_BUFFERSIZE];
-       struct work_struct start_done_work;
 };
 #define to_scsi_disk(obj) container_of(obj, struct scsi_disk, disk_dev)
 
index fe000da..8ced292 100644 (file)
@@ -2012,7 +2012,7 @@ static int storvsc_probe(struct hv_device *device,
         */
        host_dev->handle_error_wq =
                        alloc_ordered_workqueue("storvsc_error_wq_%d",
-                                               WQ_MEM_RECLAIM,
+                                               0,
                                                host->host_no);
        if (!host_dev->handle_error_wq) {
                ret = -ENOMEM;
index d6b30d5..775da69 100644 (file)
@@ -684,13 +684,14 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
        const struct of_device_id *of_id = NULL;
        struct device_node *dn;
        void __iomem *base;
-       int ret, i;
+       int ret, i, s;
 
        /* AON ctrl registers */
        base = brcmstb_ioremap_match(aon_ctrl_dt_ids, 0, NULL);
        if (IS_ERR(base)) {
                pr_err("error mapping AON_CTRL\n");
-               return PTR_ERR(base);
+               ret = PTR_ERR(base);
+               goto aon_err;
        }
        ctrl.aon_ctrl_base = base;
 
@@ -700,8 +701,10 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
                /* Assume standard offset */
                ctrl.aon_sram = ctrl.aon_ctrl_base +
                                     AON_CTRL_SYSTEM_DATA_RAM_OFS;
+               s = 0;
        } else {
                ctrl.aon_sram = base;
+               s = 1;
        }
 
        writel_relaxed(0, ctrl.aon_sram + AON_REG_PANIC);
@@ -711,7 +714,8 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
                                     (const void **)&ddr_phy_data);
        if (IS_ERR(base)) {
                pr_err("error mapping DDR PHY\n");
-               return PTR_ERR(base);
+               ret = PTR_ERR(base);
+               goto ddr_phy_err;
        }
        ctrl.support_warm_boot = ddr_phy_data->supports_warm_boot;
        ctrl.pll_status_offset = ddr_phy_data->pll_status_offset;
@@ -731,17 +735,20 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
        for_each_matching_node(dn, ddr_shimphy_dt_ids) {
                i = ctrl.num_memc;
                if (i >= MAX_NUM_MEMC) {
+                       of_node_put(dn);
                        pr_warn("too many MEMCs (max %d)\n", MAX_NUM_MEMC);
                        break;
                }
 
                base = of_io_request_and_map(dn, 0, dn->full_name);
                if (IS_ERR(base)) {
+                       of_node_put(dn);
                        if (!ctrl.support_warm_boot)
                                break;
 
                        pr_err("error mapping DDR SHIMPHY %d\n", i);
-                       return PTR_ERR(base);
+                       ret = PTR_ERR(base);
+                       goto ddr_shimphy_err;
                }
                ctrl.memcs[i].ddr_shimphy_base = base;
                ctrl.num_memc++;
@@ -752,14 +759,18 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
        for_each_matching_node(dn, brcmstb_memc_of_match) {
                base = of_iomap(dn, 0);
                if (!base) {
+                       of_node_put(dn);
                        pr_err("error mapping DDR Sequencer %d\n", i);
-                       return -ENOMEM;
+                       ret = -ENOMEM;
+                       goto brcmstb_memc_err;
                }
 
                of_id = of_match_node(brcmstb_memc_of_match, dn);
                if (!of_id) {
                        iounmap(base);
-                       return -EINVAL;
+                       of_node_put(dn);
+                       ret = -EINVAL;
+                       goto brcmstb_memc_err;
                }
 
                ddr_seq_data = of_id->data;
@@ -779,21 +790,24 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
        dn = of_find_matching_node(NULL, sram_dt_ids);
        if (!dn) {
                pr_err("SRAM not found\n");
-               return -EINVAL;
+               ret = -EINVAL;
+               goto brcmstb_memc_err;
        }
 
        ret = brcmstb_init_sram(dn);
        of_node_put(dn);
        if (ret) {
                pr_err("error setting up SRAM for PM\n");
-               return ret;
+               goto brcmstb_memc_err;
        }
 
        ctrl.pdev = pdev;
 
        ctrl.s3_params = kmalloc(sizeof(*ctrl.s3_params), GFP_KERNEL);
-       if (!ctrl.s3_params)
-               return -ENOMEM;
+       if (!ctrl.s3_params) {
+               ret = -ENOMEM;
+               goto s3_params_err;
+       }
        ctrl.s3_params_pa = dma_map_single(&pdev->dev, ctrl.s3_params,
                                           sizeof(*ctrl.s3_params),
                                           DMA_TO_DEVICE);
@@ -813,7 +827,21 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
 
 out:
        kfree(ctrl.s3_params);
-
+s3_params_err:
+       iounmap(ctrl.boot_sram);
+brcmstb_memc_err:
+       for (i--; i >= 0; i--)
+               iounmap(ctrl.memcs[i].ddr_ctrl);
+ddr_shimphy_err:
+       for (i = 0; i < ctrl.num_memc; i++)
+               iounmap(ctrl.memcs[i].ddr_shimphy_base);
+
+       iounmap(ctrl.memcs[0].ddr_phy_base);
+ddr_phy_err:
+       iounmap(ctrl.aon_ctrl_base);
+       if (s)
+               iounmap(ctrl.aon_sram);
+aon_err:
        pr_warn("PM: initialization failed with code %d\n", ret);
 
        return ret;
index 07d52ca..fcec6ed 100644 (file)
@@ -24,6 +24,7 @@ config FSL_MC_DPIO
         tristate "QorIQ DPAA2 DPIO driver"
         depends on FSL_MC_BUS
         select SOC_BUS
+        select FSL_GUTS
         select DIMLIB
         help
          Driver for the DPAA2 DPIO object.  A DPIO provides queue and
index 6383a4e..88aee59 100644 (file)
@@ -335,6 +335,8 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd)
                }
        }
 
+       reset_control_assert(domain->reset);
+
        /* Enable reset clocks for all devices in the domain */
        ret = clk_bulk_prepare_enable(domain->num_clks, domain->clks);
        if (ret) {
@@ -342,7 +344,8 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd)
                goto out_regulator_disable;
        }
 
-       reset_control_assert(domain->reset);
+       /* delays for reset to propagate */
+       udelay(5);
 
        if (domain->bits.pxx) {
                /* request the domain to power up */
index dff7529..972f289 100644 (file)
@@ -243,7 +243,6 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
                        ret = PTR_ERR(domain->power_dev);
                        goto cleanup_pds;
                }
-               dev_set_name(domain->power_dev, "%s", data->name);
 
                domain->genpd.name = data->name;
                domain->genpd.power_on = imx8m_blk_ctrl_power_on;
index 9df970e..3a992a6 100644 (file)
@@ -169,7 +169,7 @@ struct qcom_swrm_ctrl {
        u8 wcmd_id;
        struct qcom_swrm_port_config pconfig[QCOM_SDW_MAX_PORTS];
        struct sdw_stream_runtime *sruntime[SWRM_MAX_DAIS];
-       enum sdw_slave_status status[SDW_MAX_DEVICES];
+       enum sdw_slave_status status[SDW_MAX_DEVICES + 1];
        int (*reg_read)(struct qcom_swrm_ctrl *ctrl, int reg, u32 *val);
        int (*reg_write)(struct qcom_swrm_ctrl *ctrl, int reg, int val);
        u32 slave_status;
@@ -420,7 +420,7 @@ static int qcom_swrm_get_alert_slave_dev_num(struct qcom_swrm_ctrl *ctrl)
 
        ctrl->reg_read(ctrl, SWRM_MCP_SLV_STATUS, &val);
 
-       for (dev_num = 0; dev_num < SDW_MAX_DEVICES; dev_num++) {
+       for (dev_num = 0; dev_num <= SDW_MAX_DEVICES; dev_num++) {
                status = (val >> (dev_num * SWRM_MCP_SLV_STATUS_SZ));
 
                if ((status & SWRM_MCP_SLV_STATUS_MASK) == SDW_SLAVE_ALERT) {
@@ -440,7 +440,7 @@ static void qcom_swrm_get_device_status(struct qcom_swrm_ctrl *ctrl)
        ctrl->reg_read(ctrl, SWRM_MCP_SLV_STATUS, &val);
        ctrl->slave_status = val;
 
-       for (i = 0; i < SDW_MAX_DEVICES; i++) {
+       for (i = 0; i <= SDW_MAX_DEVICES; i++) {
                u32 s;
 
                s = (val >> (i * 2));
@@ -1356,10 +1356,6 @@ static int qcom_swrm_probe(struct platform_device *pdev)
        ctrl->bus.compute_params = &qcom_swrm_compute_params;
        ctrl->bus.clk_stop_timeout = 300;
 
-       ctrl->audio_cgcr = devm_reset_control_get_exclusive(dev, "swr_audio_cgcr");
-       if (IS_ERR(ctrl->audio_cgcr))
-               dev_err(dev, "Failed to get audio_cgcr reset required for soundwire-v1.6.0\n");
-
        ret = qcom_swrm_get_port_config(ctrl);
        if (ret)
                goto err_clk;
index 267342d..2dcbe16 100644 (file)
@@ -116,6 +116,7 @@ bitbang_txrx_le_cpha0(struct spi_device *spi,
 {
        /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */
 
+       u8 rxbit = bits - 1;
        u32 oldbit = !(word & 1);
        /* clock starts at inactive polarity */
        for (; likely(bits); bits--) {
@@ -135,7 +136,7 @@ bitbang_txrx_le_cpha0(struct spi_device *spi,
                /* sample LSB (from slave) on leading edge */
                word >>= 1;
                if ((flags & SPI_MASTER_NO_RX) == 0)
-                       word |= getmiso(spi) << (bits - 1);
+                       word |= getmiso(spi) << rxbit;
                setsck(spi, cpol);
        }
        return word;
@@ -148,6 +149,7 @@ bitbang_txrx_le_cpha1(struct spi_device *spi,
 {
        /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */
 
+       u8 rxbit = bits - 1;
        u32 oldbit = !(word & 1);
        /* clock starts at inactive polarity */
        for (; likely(bits); bits--) {
@@ -168,7 +170,7 @@ bitbang_txrx_le_cpha1(struct spi_device *spi,
                /* sample LSB (from slave) on trailing edge */
                word >>= 1;
                if ((flags & SPI_MASTER_NO_RX) == 0)
-                       word |= getmiso(spi) << (bits - 1);
+                       word |= getmiso(spi) << rxbit;
        }
        return word;
 }
index 72b1a5a..e12ab5b 100644 (file)
@@ -39,6 +39,7 @@
 #define CQSPI_DISABLE_DAC_MODE         BIT(1)
 #define CQSPI_SUPPORT_EXTERNAL_DMA     BIT(2)
 #define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3)
+#define CQSPI_SLOW_SRAM                BIT(4)
 
 /* Capabilities */
 #define CQSPI_SUPPORTS_OCTAL           BIT(0)
@@ -87,6 +88,7 @@ struct cqspi_st {
        bool                    use_dma_read;
        u32                     pd_dev_id;
        bool                    wr_completion;
+       bool                    slow_sram;
 };
 
 struct cqspi_driver_platdata {
@@ -333,7 +335,10 @@ static irqreturn_t cqspi_irq_handler(int this_irq, void *dev)
                }
        }
 
-       irq_status &= CQSPI_IRQ_MASK_RD | CQSPI_IRQ_MASK_WR;
+       else if (!cqspi->slow_sram)
+               irq_status &= CQSPI_IRQ_MASK_RD | CQSPI_IRQ_MASK_WR;
+       else
+               irq_status &= CQSPI_REG_IRQ_WATERMARK | CQSPI_IRQ_MASK_WR;
 
        if (irq_status)
                complete(&cqspi->transfer_complete);
@@ -673,7 +678,18 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
        /* Clear all interrupts. */
        writel(CQSPI_IRQ_STATUS_MASK, reg_base + CQSPI_REG_IRQSTATUS);
 
-       writel(CQSPI_IRQ_MASK_RD, reg_base + CQSPI_REG_IRQMASK);
+       /*
+        * On SoCFPGA platform reading the SRAM is slow due to
+        * hardware limitation and causing read interrupt storm to CPU,
+        * so enabling only watermark interrupt to disable all read
+        * interrupts later as we want to run "bytes to read" loop with
+        * all the read interrupts disabled for max performance.
+        */
+
+       if (!cqspi->slow_sram)
+               writel(CQSPI_IRQ_MASK_RD, reg_base + CQSPI_REG_IRQMASK);
+       else
+               writel(CQSPI_REG_IRQ_WATERMARK, reg_base + CQSPI_REG_IRQMASK);
 
        reinit_completion(&cqspi->transfer_complete);
        writel(CQSPI_REG_INDIRECTRD_START_MASK,
@@ -684,6 +700,13 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
                                                 msecs_to_jiffies(CQSPI_READ_TIMEOUT_MS)))
                        ret = -ETIMEDOUT;
 
+               /*
+                * Disable all read interrupts until
+                * we are out of "bytes to read"
+                */
+               if (cqspi->slow_sram)
+                       writel(0x0, reg_base + CQSPI_REG_IRQMASK);
+
                bytes_to_read = cqspi_get_rd_sram_level(cqspi);
 
                if (ret && bytes_to_read == 0) {
@@ -715,8 +738,11 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
                        bytes_to_read = cqspi_get_rd_sram_level(cqspi);
                }
 
-               if (remaining > 0)
+               if (remaining > 0) {
                        reinit_completion(&cqspi->transfer_complete);
+                       if (cqspi->slow_sram)
+                               writel(CQSPI_REG_IRQ_WATERMARK, reg_base + CQSPI_REG_IRQMASK);
+               }
        }
 
        /* Check indirect done status */
@@ -1667,6 +1693,8 @@ static int cqspi_probe(struct platform_device *pdev)
                        cqspi->use_dma_read = true;
                if (ddata->quirks & CQSPI_NO_SUPPORT_WR_COMPLETION)
                        cqspi->wr_completion = false;
+               if (ddata->quirks & CQSPI_SLOW_SRAM)
+                       cqspi->slow_sram = true;
 
                if (of_device_is_compatible(pdev->dev.of_node,
                                            "xlnx,versal-ospi-1.0"))
@@ -1779,7 +1807,9 @@ static const struct cqspi_driver_platdata intel_lgm_qspi = {
 };
 
 static const struct cqspi_driver_platdata socfpga_qspi = {
-       .quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_NO_SUPPORT_WR_COMPLETION,
+       .quirks = CQSPI_DISABLE_DAC_MODE
+                       | CQSPI_NO_SUPPORT_WR_COMPLETION
+                       | CQSPI_SLOW_SRAM,
 };
 
 static const struct cqspi_driver_platdata versal_ospi = {
index f5d32ec..0709e98 100644 (file)
@@ -161,6 +161,7 @@ static int spi_mux_probe(struct spi_device *spi)
        ctlr->num_chipselect = mux_control_states(priv->mux);
        ctlr->bus_num = -1;
        ctlr->dev.of_node = spi->dev.of_node;
+       ctlr->must_async = true;
 
        ret = devm_spi_register_controller(&spi->dev, ctlr);
        if (ret)
index 83da886..32c01e6 100644 (file)
@@ -1727,8 +1727,7 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
        spin_unlock_irqrestore(&ctlr->queue_lock, flags);
 
        ret = __spi_pump_transfer_message(ctlr, msg, was_busy);
-       if (!ret)
-               kthread_queue_work(ctlr->kworker, &ctlr->pump_messages);
+       kthread_queue_work(ctlr->kworker, &ctlr->pump_messages);
 
        ctlr->cur_msg = NULL;
        ctlr->fallback = false;
@@ -4033,7 +4032,7 @@ static int __spi_sync(struct spi_device *spi, struct spi_message *message)
         * guard against reentrancy from a different context. The io_mutex
         * will catch those cases.
         */
-       if (READ_ONCE(ctlr->queue_empty)) {
+       if (READ_ONCE(ctlr->queue_empty) && !ctlr->must_async) {
                message->actual_length = 0;
                message->status = -EINPROGRESS;
 
index cac9553..aa100b5 100644 (file)
@@ -18,6 +18,7 @@ MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Realtek Wireless Lan Driver");
 MODULE_AUTHOR("Realtek Semiconductor Corp.");
 MODULE_VERSION(DRIVERVERSION);
+MODULE_FIRMWARE("rtlwifi/rtl8188eufw.bin");
 
 #define CONFIG_BR_EXT_BRNAME "br0"
 #define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */
index cc2b44f..9147d17 100644 (file)
@@ -28,6 +28,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
        /*=== Realtek demoboard ===*/
        {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8179)}, /* 8188EUS */
        {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */
+       {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill USB-N150 Nano */
        /*=== Customer ID ===*/
        /****** 8188EUS ********/
        {USB_DEVICE(0x07B8, 0x8179)}, /* Abocom - Abocom */
index 2326aae..bb7db96 100644 (file)
@@ -117,34 +117,6 @@ static void r871x_internal_cmd_hdl(struct _adapter *padapter, u8 *pbuf)
        kfree(pdrvcmd->pbuf);
 }
 
-static u8 read_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
-{
-       void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj      *pcmd);
-       struct cmd_obj *pcmd  = (struct cmd_obj *)pbuf;
-
-       /*  invoke cmd->callback function */
-       pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
-       if (!pcmd_callback)
-               r8712_free_cmd_obj(pcmd);
-       else
-               pcmd_callback(padapter, pcmd);
-       return H2C_SUCCESS;
-}
-
-static u8 write_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
-{
-       void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj      *pcmd);
-       struct cmd_obj *pcmd  = (struct cmd_obj *)pbuf;
-
-       /*  invoke cmd->callback function */
-       pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
-       if (!pcmd_callback)
-               r8712_free_cmd_obj(pcmd);
-       else
-               pcmd_callback(padapter, pcmd);
-       return H2C_SUCCESS;
-}
-
 static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
 {
        struct cmd_obj *pcmd  = (struct cmd_obj *)pbuf;
@@ -213,14 +185,6 @@ static struct cmd_obj *cmd_hdl_filter(struct _adapter *padapter,
        pcmd_r = NULL;
 
        switch (pcmd->cmdcode) {
-       case GEN_CMD_CODE(_Read_MACREG):
-               read_macreg_hdl(padapter, (u8 *)pcmd);
-               pcmd_r = pcmd;
-               break;
-       case GEN_CMD_CODE(_Write_MACREG):
-               write_macreg_hdl(padapter, (u8 *)pcmd);
-               pcmd_r = pcmd;
-               break;
        case GEN_CMD_CODE(_Read_BBREG):
                read_bbreg_hdl(padapter, (u8 *)pcmd);
                break;
index 1175f3a..27295bd 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/tee_drv.h>
+#include <linux/uaccess.h>
 #include <linux/uio.h>
 #include "tee_private.h"
 
index 80d4e06..365489b 100644 (file)
@@ -527,7 +527,7 @@ static void int3400_setup_gddv(struct int3400_thermal_priv *priv)
        priv->data_vault = kmemdup(obj->package.elements[0].buffer.pointer,
                                   obj->package.elements[0].buffer.length,
                                   GFP_KERNEL);
-       if (!priv->data_vault)
+       if (ZERO_OR_NULL_PTR(priv->data_vault))
                goto out_free;
 
        bin_attr_data_vault.private = priv->data_vault;
@@ -597,7 +597,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
                        goto free_imok;
        }
 
-       if (priv->data_vault) {
+       if (!ZERO_OR_NULL_PTR(priv->data_vault)) {
                result = sysfs_create_group(&pdev->dev.kobj,
                                            &data_attribute_group);
                if (result)
@@ -615,7 +615,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)
 free_sysfs:
        cleanup_odvp(priv);
        if (priv->data_vault) {
-               sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
+               if (!ZERO_OR_NULL_PTR(priv->data_vault))
+                       sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
                kfree(priv->data_vault);
        }
 free_uuid:
@@ -647,7 +648,7 @@ static int int3400_thermal_remove(struct platform_device *pdev)
        if (!priv->rel_misc_dev_res)
                acpi_thermal_rel_misc_device_remove(priv->adev->handle);
 
-       if (priv->data_vault)
+       if (!ZERO_OR_NULL_PTR(priv->data_vault))
                sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
        sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group);
        sysfs_remove_group(&pdev->dev.kobj, &imok_attribute_group);
index 6a5d0ae..50d50ce 100644 (file)
@@ -1329,6 +1329,7 @@ free_tz:
        kfree(tz);
        return ERR_PTR(result);
 }
+EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips);
 
 struct thermal_zone_device *thermal_zone_device_register(const char *type, int ntrips, int mask,
                                                         void *devdata, struct thermal_zone_device_ops *ops,
index e5ede5d..0c661a7 100644 (file)
@@ -407,7 +407,7 @@ static void tb_ctl_rx_submit(struct ctl_pkg *pkg)
 
 static int tb_async_error(const struct ctl_pkg *pkg)
 {
-       const struct cfg_error_pkg *error = (const struct cfg_error_pkg *)pkg;
+       const struct cfg_error_pkg *error = pkg->buffer;
 
        if (pkg->frame.eof != TB_CFG_PKG_ERROR)
                return false;
index 244f8cd..c63c1f4 100644 (file)
@@ -3786,14 +3786,18 @@ int tb_switch_pcie_l1_enable(struct tb_switch *sw)
  */
 int tb_switch_xhci_connect(struct tb_switch *sw)
 {
-       bool usb_port1, usb_port3, xhci_port1, xhci_port3;
        struct tb_port *port1, *port3;
        int ret;
 
+       if (sw->generation != 3)
+               return 0;
+
        port1 = &sw->ports[1];
        port3 = &sw->ports[3];
 
        if (tb_switch_is_alpine_ridge(sw)) {
+               bool usb_port1, usb_port3, xhci_port1, xhci_port3;
+
                usb_port1 = tb_lc_is_usb_plugged(port1);
                usb_port3 = tb_lc_is_usb_plugged(port3);
                xhci_port1 = tb_lc_is_xhci_connected(port1);
index caa5c14..01c112e 100644 (file)
@@ -248,7 +248,7 @@ struct gsm_mux {
        bool constipated;               /* Asked by remote to shut up */
        bool has_devices;               /* Devices were registered */
 
-       spinlock_t tx_lock;
+       struct mutex tx_mutex;
        unsigned int tx_bytes;          /* TX data outstanding */
 #define TX_THRESH_HI           8192
 #define TX_THRESH_LO           2048
@@ -256,7 +256,7 @@ struct gsm_mux {
        struct list_head tx_data_list;  /* Pending data packets */
 
        /* Control messages */
-       struct timer_list kick_timer;   /* Kick TX queuing on timeout */
+       struct delayed_work kick_timeout;       /* Kick TX queuing on timeout */
        struct timer_list t2_timer;     /* Retransmit timer for commands */
        int cretries;                   /* Command retry counter */
        struct gsm_control *pending_cmd;/* Our current pending command */
@@ -680,7 +680,6 @@ static int gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
        struct gsm_msg *msg;
        u8 *dp;
        int ocr;
-       unsigned long flags;
 
        msg = gsm_data_alloc(gsm, addr, 0, control);
        if (!msg)
@@ -702,10 +701,10 @@ static int gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
 
        gsm_print_packet("Q->", addr, cr, control, NULL, 0);
 
-       spin_lock_irqsave(&gsm->tx_lock, flags);
+       mutex_lock(&gsm->tx_mutex);
        list_add_tail(&msg->list, &gsm->tx_ctrl_list);
        gsm->tx_bytes += msg->len;
-       spin_unlock_irqrestore(&gsm->tx_lock, flags);
+       mutex_unlock(&gsm->tx_mutex);
        gsmld_write_trigger(gsm);
 
        return 0;
@@ -730,7 +729,7 @@ static void gsm_dlci_clear_queues(struct gsm_mux *gsm, struct gsm_dlci *dlci)
        spin_unlock_irqrestore(&dlci->lock, flags);
 
        /* Clear data packets in MUX write queue */
-       spin_lock_irqsave(&gsm->tx_lock, flags);
+       mutex_lock(&gsm->tx_mutex);
        list_for_each_entry_safe(msg, nmsg, &gsm->tx_data_list, list) {
                if (msg->addr != addr)
                        continue;
@@ -738,7 +737,7 @@ static void gsm_dlci_clear_queues(struct gsm_mux *gsm, struct gsm_dlci *dlci)
                list_del(&msg->list);
                kfree(msg);
        }
-       spin_unlock_irqrestore(&gsm->tx_lock, flags);
+       mutex_unlock(&gsm->tx_mutex);
 }
 
 /**
@@ -1009,7 +1008,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
        gsm->tx_bytes += msg->len;
 
        gsmld_write_trigger(gsm);
-       mod_timer(&gsm->kick_timer, jiffies + 10 * gsm->t1 * HZ / 100);
+       schedule_delayed_work(&gsm->kick_timeout, 10 * gsm->t1 * HZ / 100);
 }
 
 /**
@@ -1024,10 +1023,9 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
 
 static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
 {
-       unsigned long flags;
-       spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
+       mutex_lock(&dlci->gsm->tx_mutex);
        __gsm_data_queue(dlci, msg);
-       spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
+       mutex_unlock(&dlci->gsm->tx_mutex);
 }
 
 /**
@@ -1039,7 +1037,7 @@ static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
  *     is data. Keep to the MRU of the mux. This path handles the usual tty
  *     interface which is a byte stream with optional modem data.
  *
- *     Caller must hold the tx_lock of the mux.
+ *     Caller must hold the tx_mutex of the mux.
  */
 
 static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
@@ -1099,7 +1097,7 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
  *     is data. Keep to the MRU of the mux. This path handles framed data
  *     queued as skbuffs to the DLCI.
  *
- *     Caller must hold the tx_lock of the mux.
+ *     Caller must hold the tx_mutex of the mux.
  */
 
 static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
@@ -1115,7 +1113,7 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
        if (dlci->adaption == 4)
                overhead = 1;
 
-       /* dlci->skb is locked by tx_lock */
+       /* dlci->skb is locked by tx_mutex */
        if (dlci->skb == NULL) {
                dlci->skb = skb_dequeue_tail(&dlci->skb_list);
                if (dlci->skb == NULL)
@@ -1169,7 +1167,7 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
  *     Push an empty frame in to the transmit queue to update the modem status
  *     bits and to transmit an optional break.
  *
- *     Caller must hold the tx_lock of the mux.
+ *     Caller must hold the tx_mutex of the mux.
  */
 
 static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,
@@ -1283,13 +1281,12 @@ static int gsm_dlci_data_sweep(struct gsm_mux *gsm)
 
 static void gsm_dlci_data_kick(struct gsm_dlci *dlci)
 {
-       unsigned long flags;
        int sweep;
 
        if (dlci->constipated)
                return;
 
-       spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
+       mutex_lock(&dlci->gsm->tx_mutex);
        /* If we have nothing running then we need to fire up */
        sweep = (dlci->gsm->tx_bytes < TX_THRESH_LO);
        if (dlci->gsm->tx_bytes == 0) {
@@ -1300,7 +1297,7 @@ static void gsm_dlci_data_kick(struct gsm_dlci *dlci)
        }
        if (sweep)
                gsm_dlci_data_sweep(dlci->gsm);
-       spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
+       mutex_unlock(&dlci->gsm->tx_mutex);
 }
 
 /*
@@ -1984,24 +1981,23 @@ static void gsm_dlci_command(struct gsm_dlci *dlci, const u8 *data, int len)
 }
 
 /**
- *     gsm_kick_timer  -       transmit if possible
- *     @t: timer contained in our gsm object
+ *     gsm_kick_timeout        -       transmit if possible
+ *     @work: work contained in our gsm object
  *
  *     Transmit data from DLCIs if the queue is empty. We can't rely on
  *     a tty wakeup except when we filled the pipe so we need to fire off
  *     new data ourselves in other cases.
  */
-static void gsm_kick_timer(struct timer_list *t)
+static void gsm_kick_timeout(struct work_struct *work)
 {
-       struct gsm_mux *gsm = from_timer(gsm, t, kick_timer);
-       unsigned long flags;
+       struct gsm_mux *gsm = container_of(work, struct gsm_mux, kick_timeout.work);
        int sent = 0;
 
-       spin_lock_irqsave(&gsm->tx_lock, flags);
+       mutex_lock(&gsm->tx_mutex);
        /* If we have nothing running then we need to fire up */
        if (gsm->tx_bytes < TX_THRESH_LO)
                sent = gsm_dlci_data_sweep(gsm);
-       spin_unlock_irqrestore(&gsm->tx_lock, flags);
+       mutex_unlock(&gsm->tx_mutex);
 
        if (sent && debug & 4)
                pr_info("%s TX queue stalled\n", __func__);
@@ -2458,7 +2454,7 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc)
        }
 
        /* Finish outstanding timers, making sure they are done */
-       del_timer_sync(&gsm->kick_timer);
+       cancel_delayed_work_sync(&gsm->kick_timeout);
        del_timer_sync(&gsm->t2_timer);
 
        /* Finish writing to ldisc */
@@ -2501,13 +2497,6 @@ static int gsm_activate_mux(struct gsm_mux *gsm)
        if (dlci == NULL)
                return -ENOMEM;
 
-       timer_setup(&gsm->kick_timer, gsm_kick_timer, 0);
-       timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0);
-       INIT_WORK(&gsm->tx_work, gsmld_write_task);
-       init_waitqueue_head(&gsm->event);
-       spin_lock_init(&gsm->control_lock);
-       spin_lock_init(&gsm->tx_lock);
-
        if (gsm->encoding == 0)
                gsm->receive = gsm0_receive;
        else
@@ -2538,6 +2527,7 @@ static void gsm_free_mux(struct gsm_mux *gsm)
                        break;
                }
        }
+       mutex_destroy(&gsm->tx_mutex);
        mutex_destroy(&gsm->mutex);
        kfree(gsm->txframe);
        kfree(gsm->buf);
@@ -2609,9 +2599,15 @@ static struct gsm_mux *gsm_alloc_mux(void)
        }
        spin_lock_init(&gsm->lock);
        mutex_init(&gsm->mutex);
+       mutex_init(&gsm->tx_mutex);
        kref_init(&gsm->ref);
        INIT_LIST_HEAD(&gsm->tx_ctrl_list);
        INIT_LIST_HEAD(&gsm->tx_data_list);
+       INIT_DELAYED_WORK(&gsm->kick_timeout, gsm_kick_timeout);
+       timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0);
+       INIT_WORK(&gsm->tx_work, gsmld_write_task);
+       init_waitqueue_head(&gsm->event);
+       spin_lock_init(&gsm->control_lock);
 
        gsm->t1 = T1;
        gsm->t2 = T2;
@@ -2636,6 +2632,7 @@ static struct gsm_mux *gsm_alloc_mux(void)
        }
        spin_unlock(&gsm_mux_lock);
        if (i == MAX_MUX) {
+               mutex_destroy(&gsm->tx_mutex);
                mutex_destroy(&gsm->mutex);
                kfree(gsm->txframe);
                kfree(gsm->buf);
@@ -2791,17 +2788,16 @@ static void gsmld_write_trigger(struct gsm_mux *gsm)
 static void gsmld_write_task(struct work_struct *work)
 {
        struct gsm_mux *gsm = container_of(work, struct gsm_mux, tx_work);
-       unsigned long flags;
        int i, ret;
 
        /* All outstanding control channel and control messages and one data
         * frame is sent.
         */
        ret = -ENODEV;
-       spin_lock_irqsave(&gsm->tx_lock, flags);
+       mutex_lock(&gsm->tx_mutex);
        if (gsm->tty)
                ret = gsm_data_kick(gsm);
-       spin_unlock_irqrestore(&gsm->tx_lock, flags);
+       mutex_unlock(&gsm->tx_mutex);
 
        if (ret >= 0)
                for (i = 0; i < NUM_DLCI; i++)
@@ -2858,7 +2854,8 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
                        flags = *fp++;
                switch (flags) {
                case TTY_NORMAL:
-                       gsm->receive(gsm, *cp);
+                       if (gsm->receive)
+                               gsm->receive(gsm, *cp);
                        break;
                case TTY_OVERRUN:
                case TTY_BREAK:
@@ -2946,10 +2943,6 @@ static int gsmld_open(struct tty_struct *tty)
 
        gsmld_attach_gsm(tty, gsm);
 
-       timer_setup(&gsm->kick_timer, gsm_kick_timer, 0);
-       timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0);
-       INIT_WORK(&gsm->tx_work, gsmld_write_task);
-
        return 0;
 }
 
@@ -3012,7 +3005,6 @@ static ssize_t gsmld_write(struct tty_struct *tty, struct file *file,
                           const unsigned char *buf, size_t nr)
 {
        struct gsm_mux *gsm = tty->disc_data;
-       unsigned long flags;
        int space;
        int ret;
 
@@ -3020,13 +3012,13 @@ static ssize_t gsmld_write(struct tty_struct *tty, struct file *file,
                return -ENODEV;
 
        ret = -ENOBUFS;
-       spin_lock_irqsave(&gsm->tx_lock, flags);
+       mutex_lock(&gsm->tx_mutex);
        space = tty_write_room(tty);
        if (space >= nr)
                ret = tty->ops->write(tty, buf, nr);
        else
                set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-       spin_unlock_irqrestore(&gsm->tx_lock, flags);
+       mutex_unlock(&gsm->tx_mutex);
 
        return ret;
 }
@@ -3323,14 +3315,13 @@ static struct tty_ldisc_ops tty_ldisc_packet = {
 static void gsm_modem_upd_via_data(struct gsm_dlci *dlci, u8 brk)
 {
        struct gsm_mux *gsm = dlci->gsm;
-       unsigned long flags;
 
        if (dlci->state != DLCI_OPEN || dlci->adaption != 2)
                return;
 
-       spin_lock_irqsave(&gsm->tx_lock, flags);
+       mutex_lock(&gsm->tx_mutex);
        gsm_dlci_modem_output(gsm, dlci, brk);
-       spin_unlock_irqrestore(&gsm->tx_lock, flags);
+       mutex_unlock(&gsm->tx_mutex);
 }
 
 /**
index 30ba9ee..7450d38 100644 (file)
@@ -294,9 +294,6 @@ static int atmel_config_rs485(struct uart_port *port, struct ktermios *termios,
 
        mode = atmel_uart_readl(port, ATMEL_US_MR);
 
-       /* Resetting serial mode to RS232 (0x0) */
-       mode &= ~ATMEL_US_USMODE;
-
        if (rs485conf->flags & SER_RS485_ENABLED) {
                dev_dbg(port->dev, "Setting UART to RS485\n");
                if (rs485conf->flags & SER_RS485_RX_DURING_TX)
@@ -306,6 +303,7 @@ static int atmel_config_rs485(struct uart_port *port, struct ktermios *termios,
 
                atmel_uart_writel(port, ATMEL_US_TTGR,
                                  rs485conf->delay_rts_after_send);
+               mode &= ~ATMEL_US_USMODE;
                mode |= ATMEL_US_USMODE_RS485;
        } else {
                dev_dbg(port->dev, "Setting UART to RS232\n");
index f6c33cd..b20f6f2 100644 (file)
@@ -1394,9 +1394,9 @@ static int lpuart_config_rs485(struct uart_port *port, struct ktermios *termios,
                 * Note: UART is assumed to be active high.
                 */
                if (rs485->flags & SER_RS485_RTS_ON_SEND)
-                       modem &= ~UARTMODEM_TXRTSPOL;
-               else if (rs485->flags & SER_RS485_RTS_AFTER_SEND)
                        modem |= UARTMODEM_TXRTSPOL;
+               else if (rs485->flags & SER_RS485_RTS_AFTER_SEND)
+                       modem &= ~UARTMODEM_TXRTSPOL;
        }
 
        writeb(modem, sport->port.membase + UARTMODEM);
@@ -2191,6 +2191,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
        uart_update_timeout(port, termios->c_cflag, baud);
 
        /* wait transmit engin complete */
+       lpuart32_write(&sport->port, 0, UARTMODIR);
        lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC);
 
        /* disable transmit and receive */
index 9fdecc7..5e287de 100644 (file)
@@ -470,7 +470,6 @@ static void lookahead_bufs(struct tty_port *port, struct tty_buffer *head)
 
        while (head) {
                struct tty_buffer *next;
-               unsigned char *p, *f = NULL;
                unsigned int count;
 
                /*
@@ -489,11 +488,16 @@ static void lookahead_bufs(struct tty_port *port, struct tty_buffer *head)
                        continue;
                }
 
-               p = char_buf_ptr(head, head->lookahead);
-               if (~head->flags & TTYB_NORMAL)
-                       f = flag_buf_ptr(head, head->lookahead);
+               if (port->client_ops->lookahead_buf) {
+                       unsigned char *p, *f = NULL;
+
+                       p = char_buf_ptr(head, head->lookahead);
+                       if (~head->flags & TTYB_NORMAL)
+                               f = flag_buf_ptr(head, head->lookahead);
+
+                       port->client_ops->lookahead_buf(port, p, f, count);
+               }
 
-               port->client_ops->lookahead_buf(port, p, f, count);
                head->lookahead += count;
        }
 }
index ae9c926..0b669c8 100644 (file)
@@ -4662,9 +4662,11 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
        console_lock();
        if (vc->vc_mode != KD_TEXT)
                rc = -EINVAL;
-       else if (vc->vc_sw->con_font_set)
+       else if (vc->vc_sw->con_font_set) {
+               if (vc_is_sel(vc))
+                       clear_selection();
                rc = vc->vc_sw->con_font_set(vc, &font, op->flags);
-       else
+       else
                rc = -ENOSYS;
        console_unlock();
        kfree(font.data);
@@ -4691,9 +4693,11 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
                console_unlock();
                return -EINVAL;
        }
-       if (vc->vc_sw->con_font_default)
+       if (vc->vc_sw->con_font_default) {
+               if (vc_is_sel(vc))
+                       clear_selection();
                rc = vc->vc_sw->con_font_default(vc, &font, s);
-       else
+       else
                rc = -ENOSYS;
        console_unlock();
        if (!rc) {
index 6bc679d..a202d7d 100644 (file)
@@ -8741,6 +8741,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
        struct scsi_device *sdp;
        unsigned long flags;
        int ret, retries;
+       unsigned long deadline;
+       int32_t remaining;
 
        spin_lock_irqsave(hba->host->host_lock, flags);
        sdp = hba->ufs_device_wlun;
@@ -8773,9 +8775,14 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
         * callbacks hence set the RQF_PM flag so that it doesn't resume the
         * already suspended childs.
         */
+       deadline = jiffies + 10 * HZ;
        for (retries = 3; retries > 0; --retries) {
+               ret = -ETIMEDOUT;
+               remaining = deadline - jiffies;
+               if (remaining <= 0)
+                       break;
                ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
-                               START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL);
+                                  remaining / HZ, 0, 0, RQF_PM, NULL);
                if (!scsi_status_is_check_condition(ret) ||
                                !scsi_sense_valid(&sshdr) ||
                                sshdr.sense_key != UNIT_ATTENTION)
index eced975..c3628a8 100644 (file)
@@ -1711,7 +1711,7 @@ static struct exynos_ufs_uic_attr fsd_uic_attr = {
        .pa_dbg_option_suite            = 0x2E820183,
 };
 
-struct exynos_ufs_drv_data fsd_ufs_drvs = {
+static const struct exynos_ufs_drv_data fsd_ufs_drvs = {
        .uic_attr               = &fsd_uic_attr,
        .quirks                 = UFSHCD_QUIRK_PRDT_BYTE_GRAN |
                                  UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR |
index d21b699..5adcb34 100644 (file)
@@ -1530,7 +1530,8 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev,
                                                TRB_LEN(le32_to_cpu(trb->length));
 
                                if (priv_req->num_of_trb > 1 &&
-                                       le32_to_cpu(trb->control) & TRB_SMM)
+                                       le32_to_cpu(trb->control) & TRB_SMM &&
+                                       le32_to_cpu(trb->control) & TRB_CHAIN)
                                        transfer_end = true;
 
                                cdns3_ep_inc_deq(priv_ep);
@@ -1690,6 +1691,7 @@ static int cdns3_check_ep_interrupt_proceed(struct cdns3_endpoint *priv_ep)
                                ep_cfg &= ~EP_CFG_ENABLE;
                                writel(ep_cfg, &priv_dev->regs->ep_cfg);
                                priv_ep->flags &= ~EP_QUIRK_ISO_OUT_EN;
+                               priv_ep->flags |= EP_UPDATE_EP_TRBADDR;
                        }
                        cdns3_transfer_completed(priv_dev, priv_ep);
                } else if (!(priv_ep->flags & EP_STALLED) &&
index 483bcb1..cc637c4 100644 (file)
@@ -1810,6 +1810,9 @@ static const struct usb_device_id acm_ids[] = {
        { USB_DEVICE(0x09d8, 0x0320), /* Elatec GmbH TWN3 */
        .driver_info = NO_UNION_NORMAL, /* has misplaced union descriptor */
        },
+       { USB_DEVICE(0x0c26, 0x0020), /* Icom ICF3400 Serie */
+       .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
+       },
        { USB_DEVICE(0x0ca6, 0xa050), /* Castles VEGA3000 */
        .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
        },
index 2633acd..d4b1e70 100644 (file)
@@ -6038,6 +6038,11 @@ re_enumerate:
  * the reset is over (using their post_reset method).
  *
  * Return: The same as for usb_reset_and_verify_device().
+ * However, if a reset is already in progress (for instance, if a
+ * driver doesn't have pre_ or post_reset() callbacks, and while
+ * being unbound or re-bound during the ongoing reset its disconnect()
+ * or probe() routine tries to perform a second, nested reset), the
+ * routine returns -EINPROGRESS.
  *
  * Note:
  * The caller must own the device lock.  For example, it's safe to use
@@ -6071,6 +6076,10 @@ int usb_reset_device(struct usb_device *udev)
                return -EISDIR;
        }
 
+       if (udev->reset_in_progress)
+               return -EINPROGRESS;
+       udev->reset_in_progress = 1;
+
        port_dev = hub->ports[udev->portnum - 1];
 
        /*
@@ -6135,6 +6144,7 @@ int usb_reset_device(struct usb_device *udev)
 
        usb_autosuspend_device(udev);
        memalloc_noio_restore(noio_flag);
+       udev->reset_in_progress = 0;
        return ret;
 }
 EXPORT_SYMBOL_GPL(usb_reset_device);
index c8ba87d..fd0ccf6 100644 (file)
@@ -154,9 +154,9 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
        } else if (hsotg->plat && hsotg->plat->phy_init) {
                ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
        } else {
-               ret = phy_power_on(hsotg->phy);
+               ret = phy_init(hsotg->phy);
                if (ret == 0)
-                       ret = phy_init(hsotg->phy);
+                       ret = phy_power_on(hsotg->phy);
        }
 
        return ret;
@@ -188,9 +188,9 @@ static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)
        } else if (hsotg->plat && hsotg->plat->phy_exit) {
                ret = hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
        } else {
-               ret = phy_exit(hsotg->phy);
+               ret = phy_power_off(hsotg->phy);
                if (ret == 0)
-                       ret = phy_power_off(hsotg->phy);
+                       ret = phy_exit(hsotg->phy);
        }
        if (ret)
                return ret;
index c5c238a..8c8e326 100644 (file)
@@ -833,15 +833,16 @@ static void dwc3_core_exit(struct dwc3 *dwc)
 {
        dwc3_event_buffers_cleanup(dwc);
 
+       usb_phy_set_suspend(dwc->usb2_phy, 1);
+       usb_phy_set_suspend(dwc->usb3_phy, 1);
+       phy_power_off(dwc->usb2_generic_phy);
+       phy_power_off(dwc->usb3_generic_phy);
+
        usb_phy_shutdown(dwc->usb2_phy);
        usb_phy_shutdown(dwc->usb3_phy);
        phy_exit(dwc->usb2_generic_phy);
        phy_exit(dwc->usb3_generic_phy);
 
-       usb_phy_set_suspend(dwc->usb2_phy, 1);
-       usb_phy_set_suspend(dwc->usb3_phy, 1);
-       phy_power_off(dwc->usb2_generic_phy);
-       phy_power_off(dwc->usb3_generic_phy);
        dwc3_clk_disable(dwc);
        reset_control_assert(dwc->reset);
 }
@@ -1821,7 +1822,6 @@ static int dwc3_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, dwc);
        dwc3_cache_hwparams(dwc);
-       device_init_wakeup(&pdev->dev, of_property_read_bool(dev->of_node, "wakeup-source"));
 
        spin_lock_init(&dwc->lock);
        mutex_init(&dwc->mutex);
@@ -1879,16 +1879,16 @@ err5:
        dwc3_debugfs_exit(dwc);
        dwc3_event_buffers_cleanup(dwc);
 
-       usb_phy_shutdown(dwc->usb2_phy);
-       usb_phy_shutdown(dwc->usb3_phy);
-       phy_exit(dwc->usb2_generic_phy);
-       phy_exit(dwc->usb3_generic_phy);
-
        usb_phy_set_suspend(dwc->usb2_phy, 1);
        usb_phy_set_suspend(dwc->usb3_phy, 1);
        phy_power_off(dwc->usb2_generic_phy);
        phy_power_off(dwc->usb3_generic_phy);
 
+       usb_phy_shutdown(dwc->usb2_phy);
+       usb_phy_shutdown(dwc->usb3_phy);
+       phy_exit(dwc->usb2_generic_phy);
+       phy_exit(dwc->usb3_generic_phy);
+
        dwc3_ulpi_exit(dwc);
 
 err4:
@@ -1983,7 +1983,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
                dwc3_core_exit(dwc);
                break;
        case DWC3_GCTL_PRTCAP_HOST:
-               if (!PMSG_IS_AUTO(msg) && !device_can_wakeup(dwc->dev)) {
+               if (!PMSG_IS_AUTO(msg) && !device_may_wakeup(dwc->dev)) {
                        dwc3_core_exit(dwc);
                        break;
                }
@@ -2044,7 +2044,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
                spin_unlock_irqrestore(&dwc->lock, flags);
                break;
        case DWC3_GCTL_PRTCAP_HOST:
-               if (!PMSG_IS_AUTO(msg) && !device_can_wakeup(dwc->dev)) {
+               if (!PMSG_IS_AUTO(msg) && !device_may_wakeup(dwc->dev)) {
                        ret = dwc3_core_init_for_resume(dwc);
                        if (ret)
                                return ret;
index 6b01804..4ee4ca0 100644 (file)
@@ -44,6 +44,7 @@
 #define PCI_DEVICE_ID_INTEL_ADLP               0x51ee
 #define PCI_DEVICE_ID_INTEL_ADLM               0x54ee
 #define PCI_DEVICE_ID_INTEL_ADLS               0x7ae1
+#define PCI_DEVICE_ID_INTEL_RPL                        0x460e
 #define PCI_DEVICE_ID_INTEL_RPLS               0x7a61
 #define PCI_DEVICE_ID_INTEL_MTLP               0x7ec1
 #define PCI_DEVICE_ID_INTEL_MTL                        0x7e7e
@@ -456,6 +457,9 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADLS),
          (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
+       { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_RPL),
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
+
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_RPLS),
          (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
index c5e482f..d3f3937 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/phy/phy.h>
-#include <linux/pm_domain.h>
 #include <linux/usb/of.h>
 #include <linux/reset.h>
 #include <linux/iopoll.h>
@@ -299,11 +298,24 @@ static void dwc3_qcom_interconnect_exit(struct dwc3_qcom *qcom)
        icc_put(qcom->icc_path_apps);
 }
 
+/* Only usable in contexts where the role can not change. */
+static bool dwc3_qcom_is_host(struct dwc3_qcom *qcom)
+{
+       struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3);
+
+       return dwc->xhci;
+}
+
 static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
 {
        struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3);
-       struct usb_hcd *hcd = platform_get_drvdata(dwc->xhci);
        struct usb_device *udev;
+       struct usb_hcd __maybe_unused *hcd;
+
+       /*
+        * FIXME: Fix this layering violation.
+        */
+       hcd = platform_get_drvdata(dwc->xhci);
 
        /*
         * It is possible to query the speed of all children of
@@ -311,8 +323,11 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
         * currently supports only 1 port per controller. So
         * this is sufficient.
         */
+#ifdef CONFIG_USB
        udev = usb_hub_find_child(hcd->self.root_hub, 1);
-
+#else
+       udev = NULL;
+#endif
        if (!udev)
                return USB_SPEED_UNKNOWN;
 
@@ -387,7 +402,7 @@ static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
        dwc3_qcom_enable_wakeup_irq(qcom->ss_phy_irq, 0);
 }
 
-static int dwc3_qcom_suspend(struct dwc3_qcom *qcom)
+static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
 {
        u32 val;
        int i, ret;
@@ -406,7 +421,11 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom)
        if (ret)
                dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
 
-       if (device_may_wakeup(qcom->dev)) {
+       /*
+        * The role is stable during suspend as role switching is done from a
+        * freezable workqueue.
+        */
+       if (dwc3_qcom_is_host(qcom) && wakeup) {
                qcom->usb2_speed = dwc3_qcom_read_usb2_speed(qcom);
                dwc3_qcom_enable_interrupts(qcom);
        }
@@ -416,7 +435,7 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom)
        return 0;
 }
 
-static int dwc3_qcom_resume(struct dwc3_qcom *qcom)
+static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup)
 {
        int ret;
        int i;
@@ -424,7 +443,7 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom)
        if (!qcom->is_suspended)
                return 0;
 
-       if (device_may_wakeup(qcom->dev))
+       if (dwc3_qcom_is_host(qcom) && wakeup)
                dwc3_qcom_disable_interrupts(qcom);
 
        for (i = 0; i < qcom->num_clocks; i++) {
@@ -458,7 +477,11 @@ static irqreturn_t qcom_dwc3_resume_irq(int irq, void *data)
        if (qcom->pm_suspended)
                return IRQ_HANDLED;
 
-       if (dwc->xhci)
+       /*
+        * This is safe as role switching is done from a freezable workqueue
+        * and the wakeup interrupts are disabled as part of resume.
+        */
+       if (dwc3_qcom_is_host(qcom))
                pm_runtime_resume(&dwc->xhci->dev);
 
        return IRQ_HANDLED;
@@ -757,13 +780,13 @@ dwc3_qcom_create_urs_usb_platdev(struct device *dev)
 
 static int dwc3_qcom_probe(struct platform_device *pdev)
 {
-       struct device_node *np = pdev->dev.of_node;
-       struct device *dev = &pdev->dev;
-       struct dwc3_qcom *qcom;
-       struct resource *res, *parent_res = NULL;
-       int ret, i;
-       bool ignore_pipe_clk;
-       struct generic_pm_domain *genpd;
+       struct device_node      *np = pdev->dev.of_node;
+       struct device           *dev = &pdev->dev;
+       struct dwc3_qcom        *qcom;
+       struct resource         *res, *parent_res = NULL;
+       int                     ret, i;
+       bool                    ignore_pipe_clk;
+       bool                    wakeup_source;
 
        qcom = devm_kzalloc(&pdev->dev, sizeof(*qcom), GFP_KERNEL);
        if (!qcom)
@@ -772,8 +795,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, qcom);
        qcom->dev = &pdev->dev;
 
-       genpd = pd_to_genpd(qcom->dev->pm_domain);
-
        if (has_acpi_companion(dev)) {
                qcom->acpi_pdata = acpi_device_get_match_data(dev);
                if (!qcom->acpi_pdata) {
@@ -881,16 +902,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
        if (ret)
                goto interconnect_exit;
 
-       if (device_can_wakeup(&qcom->dwc3->dev)) {
-               /*
-                * Setting GENPD_FLAG_ALWAYS_ON flag takes care of keeping
-                * genpd on in both runtime suspend and system suspend cases.
-                */
-               genpd->flags |= GENPD_FLAG_ALWAYS_ON;
-               device_init_wakeup(&pdev->dev, true);
-       } else {
-               genpd->flags |= GENPD_FLAG_RPM_ALWAYS_ON;
-       }
+       wakeup_source = of_property_read_bool(dev->of_node, "wakeup-source");
+       device_init_wakeup(&pdev->dev, wakeup_source);
+       device_init_wakeup(&qcom->dwc3->dev, wakeup_source);
 
        qcom->is_suspended = false;
        pm_runtime_set_active(dev);
@@ -944,39 +958,45 @@ static int dwc3_qcom_remove(struct platform_device *pdev)
 static int __maybe_unused dwc3_qcom_pm_suspend(struct device *dev)
 {
        struct dwc3_qcom *qcom = dev_get_drvdata(dev);
-       int ret = 0;
+       bool wakeup = device_may_wakeup(dev);
+       int ret;
 
-       ret = dwc3_qcom_suspend(qcom);
-       if (!ret)
-               qcom->pm_suspended = true;
+       ret = dwc3_qcom_suspend(qcom, wakeup);
+       if (ret)
+               return ret;
 
-       return ret;
+       qcom->pm_suspended = true;
+
+       return 0;
 }
 
 static int __maybe_unused dwc3_qcom_pm_resume(struct device *dev)
 {
        struct dwc3_qcom *qcom = dev_get_drvdata(dev);
+       bool wakeup = device_may_wakeup(dev);
        int ret;
 
-       ret = dwc3_qcom_resume(qcom);
-       if (!ret)
-               qcom->pm_suspended = false;
+       ret = dwc3_qcom_resume(qcom, wakeup);
+       if (ret)
+               return ret;
 
-       return ret;
+       qcom->pm_suspended = false;
+
+       return 0;
 }
 
 static int __maybe_unused dwc3_qcom_runtime_suspend(struct device *dev)
 {
        struct dwc3_qcom *qcom = dev_get_drvdata(dev);
 
-       return dwc3_qcom_suspend(qcom);
+       return dwc3_qcom_suspend(qcom, true);
 }
 
 static int __maybe_unused dwc3_qcom_runtime_resume(struct device *dev)
 {
        struct dwc3_qcom *qcom = dev_get_drvdata(dev);
 
-       return dwc3_qcom_resume(qcom);
+       return dwc3_qcom_resume(qcom, true);
 }
 
 static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = {
index aeeec75..eca945f 100644 (file)
@@ -2539,9 +2539,6 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
 
        is_on = !!is_on;
 
-       if (dwc->pullups_connected == is_on)
-               return 0;
-
        dwc->softconnect = is_on;
 
        /*
@@ -2566,6 +2563,11 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
                return 0;
        }
 
+       if (dwc->pullups_connected == is_on) {
+               pm_runtime_put(dwc->dev);
+               return 0;
+       }
+
        if (!is_on) {
                ret = dwc3_gadget_soft_disconnect(dwc);
        } else {
index f56c30c..a7154fe 100644 (file)
 #include <linux/of.h>
 #include <linux/platform_device.h>
 
+#include "../host/xhci-plat.h"
 #include "core.h"
 
+static const struct xhci_plat_priv dwc3_xhci_plat_priv = {
+       .quirks = XHCI_SKIP_PHY_INIT,
+};
+
 static void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc,
                                        int irq, char *name)
 {
@@ -92,6 +97,11 @@ int dwc3_host_init(struct dwc3 *dwc)
                goto err;
        }
 
+       ret = platform_device_add_data(xhci, &dwc3_xhci_plat_priv,
+                                       sizeof(dwc3_xhci_plat_priv));
+       if (ret)
+               goto err;
+
        memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props));
 
        if (dwc->usb3_lpm_capable)
@@ -135,4 +145,5 @@ err:
 void dwc3_host_exit(struct dwc3 *dwc)
 {
        platform_device_unregister(dwc->xhci);
+       dwc->xhci = NULL;
 }
index 1905a8d..08726e4 100644 (file)
@@ -291,6 +291,12 @@ static struct usb_endpoint_descriptor ss_ep_int_desc = {
        .bInterval = 4,
 };
 
+static struct usb_ss_ep_comp_descriptor ss_ep_int_desc_comp = {
+       .bLength = sizeof(ss_ep_int_desc_comp),
+       .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+       .wBytesPerInterval = cpu_to_le16(6),
+};
+
 /* Audio Streaming OUT Interface - Alt0 */
 static struct usb_interface_descriptor std_as_out_if0_desc = {
        .bLength = sizeof std_as_out_if0_desc,
@@ -604,7 +610,8 @@ static struct usb_descriptor_header *ss_audio_desc[] = {
        (struct usb_descriptor_header *)&in_feature_unit_desc,
        (struct usb_descriptor_header *)&io_out_ot_desc,
 
-  (struct usb_descriptor_header *)&ss_ep_int_desc,
+       (struct usb_descriptor_header *)&ss_ep_int_desc,
+       (struct usb_descriptor_header *)&ss_ep_int_desc_comp,
 
        (struct usb_descriptor_header *)&std_as_out_if0_desc,
        (struct usb_descriptor_header *)&std_as_out_if1_desc,
@@ -800,6 +807,7 @@ static void setup_headers(struct f_uac2_opts *opts,
        struct usb_ss_ep_comp_descriptor *epout_desc_comp = NULL;
        struct usb_ss_ep_comp_descriptor *epin_desc_comp = NULL;
        struct usb_ss_ep_comp_descriptor *epin_fback_desc_comp = NULL;
+       struct usb_ss_ep_comp_descriptor *ep_int_desc_comp = NULL;
        struct usb_endpoint_descriptor *epout_desc;
        struct usb_endpoint_descriptor *epin_desc;
        struct usb_endpoint_descriptor *epin_fback_desc;
@@ -827,6 +835,7 @@ static void setup_headers(struct f_uac2_opts *opts,
                epin_fback_desc = &ss_epin_fback_desc;
                epin_fback_desc_comp = &ss_epin_fback_desc_comp;
                ep_int_desc = &ss_ep_int_desc;
+               ep_int_desc_comp = &ss_ep_int_desc_comp;
        }
 
        i = 0;
@@ -855,8 +864,11 @@ static void setup_headers(struct f_uac2_opts *opts,
        if (EPOUT_EN(opts))
                headers[i++] = USBDHDR(&io_out_ot_desc);
 
-       if (FUOUT_EN(opts) || FUIN_EN(opts))
+       if (FUOUT_EN(opts) || FUIN_EN(opts)) {
                headers[i++] = USBDHDR(ep_int_desc);
+               if (ep_int_desc_comp)
+                       headers[i++] = USBDHDR(ep_int_desc_comp);
+       }
 
        if (EPOUT_EN(opts)) {
                headers[i++] = USBDHDR(&std_as_out_if0_desc);
index 03035db..208c6a9 100644 (file)
@@ -294,8 +294,10 @@ EXPORT_SYMBOL_GPL(fsg_lun_fsync_sub);
 void store_cdrom_address(u8 *dest, int msf, u32 addr)
 {
        if (msf) {
-               /* Convert to Minutes-Seconds-Frames */
-               addr >>= 2;             /* Convert to 2048-byte frames */
+               /*
+                * Convert to Minutes-Seconds-Frames.
+                * Sector size is already set to 2048 bytes.
+                */
                addr += 2*75;           /* Lead-in occupies 2 seconds */
                dest[3] = addr % 75;    /* Frames */
                addr /= 75;
index cafcf26..c63c0c2 100644 (file)
@@ -736,7 +736,10 @@ int usb_gadget_disconnect(struct usb_gadget *gadget)
        ret = gadget->ops->pullup(gadget, 0);
        if (!ret) {
                gadget->connected = 0;
-               gadget->udc->driver->disconnect(gadget);
+               mutex_lock(&udc_lock);
+               if (gadget->udc->driver)
+                       gadget->udc->driver->disconnect(gadget);
+               mutex_unlock(&udc_lock);
        }
 
 out:
@@ -1489,7 +1492,6 @@ static int gadget_bind_driver(struct device *dev)
 
        usb_gadget_udc_set_speed(udc, driver->max_speed);
 
-       mutex_lock(&udc_lock);
        ret = driver->bind(udc->gadget, driver);
        if (ret)
                goto err_bind;
@@ -1499,7 +1501,6 @@ static int gadget_bind_driver(struct device *dev)
                goto err_start;
        usb_gadget_enable_async_callbacks(udc);
        usb_udc_connect_control(udc);
-       mutex_unlock(&udc_lock);
 
        kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
        return 0;
@@ -1512,6 +1513,7 @@ static int gadget_bind_driver(struct device *dev)
                dev_err(&udc->dev, "failed to start %s: %d\n",
                        driver->function, ret);
 
+       mutex_lock(&udc_lock);
        udc->driver = NULL;
        driver->is_bound = false;
        mutex_unlock(&udc_lock);
@@ -1529,7 +1531,6 @@ static void gadget_unbind_driver(struct device *dev)
 
        kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
 
-       mutex_lock(&udc_lock);
        usb_gadget_disconnect(gadget);
        usb_gadget_disable_async_callbacks(udc);
        if (gadget->irq)
@@ -1537,6 +1538,7 @@ static void gadget_unbind_driver(struct device *dev)
        udc->driver->unbind(gadget);
        usb_gadget_udc_stop(udc);
 
+       mutex_lock(&udc_lock);
        driver->is_bound = false;
        udc->driver = NULL;
        mutex_unlock(&udc_lock);
@@ -1612,7 +1614,7 @@ static ssize_t soft_connect_store(struct device *dev,
        struct usb_udc          *udc = container_of(dev, struct usb_udc, dev);
        ssize_t                 ret;
 
-       mutex_lock(&udc_lock);
+       device_lock(&udc->gadget->dev);
        if (!udc->driver) {
                dev_err(dev, "soft-connect without a gadget driver\n");
                ret = -EOPNOTSUPP;
@@ -1633,7 +1635,7 @@ static ssize_t soft_connect_store(struct device *dev,
 
        ret = n;
 out:
-       mutex_unlock(&udc_lock);
+       device_unlock(&udc->gadget->dev);
        return ret;
 }
 static DEVICE_ATTR_WO(soft_connect);
@@ -1652,11 +1654,15 @@ static ssize_t function_show(struct device *dev, struct device_attribute *attr,
                             char *buf)
 {
        struct usb_udc          *udc = container_of(dev, struct usb_udc, dev);
-       struct usb_gadget_driver *drv = udc->driver;
+       struct usb_gadget_driver *drv;
+       int                     rc = 0;
 
-       if (!drv || !drv->function)
-               return 0;
-       return scnprintf(buf, PAGE_SIZE, "%s\n", drv->function);
+       mutex_lock(&udc_lock);
+       drv = udc->driver;
+       if (drv && drv->function)
+               rc = scnprintf(buf, PAGE_SIZE, "%s\n", drv->function);
+       mutex_unlock(&udc_lock);
+       return rc;
 }
 static DEVICE_ATTR_RO(function);
 
index 0fdc014..4619d5e 100644 (file)
@@ -652,7 +652,7 @@ struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd)
  * It will release and re-aquire the lock while calling ACPI
  * method.
  */
-void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd,
+static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd,
                                u16 index, bool on, unsigned long *flags)
        __must_hold(&xhci->lock)
 {
@@ -1648,6 +1648,17 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
 
        status = bus_state->resuming_ports;
 
+       /*
+        * SS devices are only visible to roothub after link training completes.
+        * Keep polling roothubs for a grace period after xHC start
+        */
+       if (xhci->run_graceperiod) {
+               if (time_before(jiffies, xhci->run_graceperiod))
+                       status = 1;
+               else
+                       xhci->run_graceperiod = 0;
+       }
+
        mask = PORT_CSC | PORT_PEC | PORT_OCC | PORT_PLC | PORT_WRC | PORT_CEC;
 
        /* For each port, did anything change?  If so, set that bit in buf. */
index 06a6b19..579899e 100644 (file)
@@ -425,7 +425,6 @@ static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
 
 static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
 {
-       u32 extra_cs_count;
        u32 start_ss, last_ss;
        u32 start_cs, last_cs;
 
@@ -461,18 +460,12 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
                if (last_cs > 7)
                        return -ESCH_CS_OVERFLOW;
 
-               if (sch_ep->ep_type == ISOC_IN_EP)
-                       extra_cs_count = (last_cs == 7) ? 1 : 2;
-               else /*  ep_type : INTR IN / INTR OUT */
-                       extra_cs_count = 1;
-
-               cs_count += extra_cs_count;
                if (cs_count > 7)
                        cs_count = 7; /* HW limit */
 
                sch_ep->cs_count = cs_count;
-               /* one for ss, the other for idle */
-               sch_ep->num_budget_microframes = cs_count + 2;
+               /* ss, idle are ignored */
+               sch_ep->num_budget_microframes = cs_count;
 
                /*
                 * if interval=1, maxp >752, num_budge_micoframe is larger
@@ -771,8 +764,8 @@ int xhci_mtk_drop_ep(struct usb_hcd *hcd, struct usb_device *udev,
        if (ret)
                return ret;
 
-       if (ep->hcpriv)
-               drop_ep_quirk(hcd, udev, ep);
+       /* needn't check @ep->hcpriv, xhci_endpoint_disable set it NULL */
+       drop_ep_quirk(hcd, udev, ep);
 
        return 0;
 }
index 0448558..a8641b6 100644 (file)
@@ -398,12 +398,17 @@ static int xhci_plat_remove(struct platform_device *dev)
        pm_runtime_get_sync(&dev->dev);
        xhci->xhc_state |= XHCI_STATE_REMOVING;
 
-       usb_remove_hcd(shared_hcd);
-       xhci->shared_hcd = NULL;
+       if (shared_hcd) {
+               usb_remove_hcd(shared_hcd);
+               xhci->shared_hcd = NULL;
+       }
+
        usb_phy_shutdown(hcd->usb_phy);
 
        usb_remove_hcd(hcd);
-       usb_put_hcd(shared_hcd);
+
+       if (shared_hcd)
+               usb_put_hcd(shared_hcd);
 
        clk_disable_unprepare(clk);
        clk_disable_unprepare(reg_clk);
index 65858f6..3864928 100644 (file)
@@ -151,9 +151,11 @@ int xhci_start(struct xhci_hcd *xhci)
                xhci_err(xhci, "Host took too long to start, "
                                "waited %u microseconds.\n",
                                XHCI_MAX_HALT_USEC);
-       if (!ret)
+       if (!ret) {
                /* clear state flags. Including dying, halted or removing */
                xhci->xhc_state = 0;
+               xhci->run_graceperiod = jiffies + msecs_to_jiffies(500);
+       }
 
        return ret;
 }
@@ -791,8 +793,6 @@ static void xhci_stop(struct usb_hcd *hcd)
 void xhci_shutdown(struct usb_hcd *hcd)
 {
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       unsigned long flags;
-       int i;
 
        if (xhci->quirks & XHCI_SPURIOUS_REBOOT)
                usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
@@ -808,21 +808,12 @@ void xhci_shutdown(struct usb_hcd *hcd)
                del_timer_sync(&xhci->shared_hcd->rh_timer);
        }
 
-       spin_lock_irqsave(&xhci->lock, flags);
+       spin_lock_irq(&xhci->lock);
        xhci_halt(xhci);
-
-       /* Power off USB2 ports*/
-       for (i = 0; i < xhci->usb2_rhub.num_ports; i++)
-               xhci_set_port_power(xhci, xhci->main_hcd, i, false, &flags);
-
-       /* Power off USB3 ports*/
-       for (i = 0; i < xhci->usb3_rhub.num_ports; i++)
-               xhci_set_port_power(xhci, xhci->shared_hcd, i, false, &flags);
-
        /* Workaround for spurious wakeups at shutdown with HSW */
        if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
                xhci_reset(xhci, XHCI_RESET_SHORT_USEC);
-       spin_unlock_irqrestore(&xhci->lock, flags);
+       spin_unlock_irq(&xhci->lock);
 
        xhci_cleanup_msix(xhci);
 
index 1960b47..7caa0db 100644 (file)
@@ -1826,7 +1826,7 @@ struct xhci_hcd {
 
        /* Host controller watchdog timer structures */
        unsigned int            xhc_state;
-
+       unsigned long           run_graceperiod;
        u32                     command;
        struct s3_save          s3;
 /* Host controller is dying - not responding to commands. "I'm not dead yet!"
@@ -2196,8 +2196,6 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
 int xhci_hub_status_data(struct usb_hcd *hcd, char *buf);
 int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1);
 struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd);
-void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd, u16 index,
-                        bool on, unsigned long *flags);
 
 void xhci_hc_died(struct xhci_hcd *xhci);
 
index d1df153..d63c639 100644 (file)
@@ -71,10 +71,7 @@ static int onboard_hub_power_off(struct onboard_hub *hub)
 {
        int err;
 
-       if (hub->reset_gpio) {
-               gpiod_set_value_cansleep(hub->reset_gpio, 1);
-               fsleep(hub->pdata->reset_us);
-       }
+       gpiod_set_value_cansleep(hub->reset_gpio, 1);
 
        err = regulator_disable(hub->vdd);
        if (err) {
index f906dfd..6c8f776 100644 (file)
@@ -86,7 +86,7 @@ config USB_MUSB_TUSB6010
        tristate "TUSB6010"
        depends on HAS_IOMEM
        depends on ARCH_OMAP2PLUS || COMPILE_TEST
-       depends on NOP_USB_XCEIV = USB_MUSB_HDRC # both built-in or both modules
+       depends on NOP_USB_XCEIV!=m || USB_MUSB_HDRC=m
 
 config USB_MUSB_OMAP2PLUS
        tristate "OMAP2430 and onwards"
index 2798fca..af01a46 100644 (file)
@@ -97,7 +97,10 @@ struct ch341_private {
        u8 mcr;
        u8 msr;
        u8 lcr;
+
        unsigned long quirks;
+       u8 version;
+
        unsigned long break_end;
 };
 
@@ -250,8 +253,12 @@ static int ch341_set_baudrate_lcr(struct usb_device *dev,
        /*
         * CH341A buffers data until a full endpoint-size packet (32 bytes)
         * has been received unless bit 7 is set.
+        *
+        * At least one device with version 0x27 appears to have this bit
+        * inverted.
         */
-       val |= BIT(7);
+       if (priv->version > 0x27)
+               val |= BIT(7);
 
        r = ch341_control_out(dev, CH341_REQ_WRITE_REG,
                              CH341_REG_DIVISOR << 8 | CH341_REG_PRESCALER,
@@ -265,6 +272,9 @@ static int ch341_set_baudrate_lcr(struct usb_device *dev,
         * (stop bits, parity and word length). Version 0x30 and above use
         * CH341_REG_LCR only and CH341_REG_LCR2 is always set to zero.
         */
+       if (priv->version < 0x30)
+               return 0;
+
        r = ch341_control_out(dev, CH341_REQ_WRITE_REG,
                              CH341_REG_LCR2 << 8 | CH341_REG_LCR, lcr);
        if (r)
@@ -308,7 +318,9 @@ static int ch341_configure(struct usb_device *dev, struct ch341_private *priv)
        r = ch341_control_in(dev, CH341_REQ_READ_VERSION, 0, 0, buffer, size);
        if (r)
                return r;
-       dev_dbg(&dev->dev, "Chip version: 0x%02x\n", buffer[0]);
+
+       priv->version = buffer[0];
+       dev_dbg(&dev->dev, "Chip version: 0x%02x\n", priv->version);
 
        r = ch341_control_out(dev, CH341_REQ_SERIAL_INIT, 0, 0);
        if (r < 0)
index c374620..a34957c 100644 (file)
@@ -130,6 +130,7 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x10C4, 0x83AA) }, /* Mark-10 Digital Force Gauge */
        { USB_DEVICE(0x10C4, 0x83D8) }, /* DekTec DTA Plus VHF/UHF Booster/Attenuator */
        { USB_DEVICE(0x10C4, 0x8411) }, /* Kyocera GPS Module */
+       { USB_DEVICE(0x10C4, 0x8414) }, /* Decagon USB Cable Adapter */
        { USB_DEVICE(0x10C4, 0x8418) }, /* IRZ Automation Teleport SG-10 GSM/GPRS Modem */
        { USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */
        { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */
index d5a3986..52d59be 100644 (file)
@@ -1045,6 +1045,8 @@ static const struct usb_device_id id_table_combined[] = {
        /* IDS GmbH devices */
        { USB_DEVICE(IDS_VID, IDS_SI31A_PID) },
        { USB_DEVICE(IDS_VID, IDS_CM31A_PID) },
+       /* Omron devices */
+       { USB_DEVICE(OMRON_VID, OMRON_CS1W_CIF31_PID) },
        /* U-Blox devices */
        { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ZED_PID) },
        { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ODIN_PID) },
index 4e92c16..31c8cca 100644 (file)
 #define INFINEON_TRIBOARD_TC2X7_PID    0x0043 /* DAS JTAG TriBoard TC2X7 V1.0 */
 
 /*
+ * Omron corporation (https://www.omron.com)
+ */
+ #define OMRON_VID                     0x0590
+ #define OMRON_CS1W_CIF31_PID          0x00b2
+
+/*
  * Acton Research Corp.
  */
 #define ACTON_VID              0x0647  /* Vendor ID */
index de59fa9..a5e8374 100644 (file)
@@ -253,6 +253,7 @@ static void option_instat_callback(struct urb *urb);
 #define QUECTEL_PRODUCT_BG96                   0x0296
 #define QUECTEL_PRODUCT_EP06                   0x0306
 #define QUECTEL_PRODUCT_EM05G                  0x030a
+#define QUECTEL_PRODUCT_EM060K                 0x030b
 #define QUECTEL_PRODUCT_EM12                   0x0512
 #define QUECTEL_PRODUCT_RM500Q                 0x0800
 #define QUECTEL_PRODUCT_EC200S_CN              0x6002
@@ -438,6 +439,8 @@ static void option_instat_callback(struct urb *urb);
 #define CINTERION_PRODUCT_MV31_2_RMNET         0x00b9
 #define CINTERION_PRODUCT_MV32_WA              0x00f1
 #define CINTERION_PRODUCT_MV32_WB              0x00f2
+#define CINTERION_PRODUCT_MV32_WA_RMNET                0x00f3
+#define CINTERION_PRODUCT_MV32_WB_RMNET                0x00f4
 
 /* Olivetti products */
 #define OLIVETTI_VENDOR_ID                     0x0b3c
@@ -573,6 +576,10 @@ static void option_instat_callback(struct urb *urb);
 #define WETELECOM_PRODUCT_6802                 0x6802
 #define WETELECOM_PRODUCT_WMD300               0x6803
 
+/* OPPO products */
+#define OPPO_VENDOR_ID                         0x22d9
+#define OPPO_PRODUCT_R11                       0x276c
+
 
 /* Device flags */
 
@@ -1138,6 +1145,9 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
        { USB_DEVICE_INTERFACE_CLASS(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM05G, 0xff),
          .driver_info = RSVD(6) | ZLP },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM060K, 0xff, 0x00, 0x40) },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM060K, 0xff, 0xff, 0x30) },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM060K, 0xff, 0xff, 0x40) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0xff, 0xff),
          .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0, 0) },
@@ -1993,8 +2003,12 @@ static const struct usb_device_id option_ids[] = {
          .driver_info = RSVD(0)},
        { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_MV32_WA, 0xff),
          .driver_info = RSVD(3)},
+       { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_MV32_WA_RMNET, 0xff),
+         .driver_info = RSVD(0) },
        { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_MV32_WB, 0xff),
          .driver_info = RSVD(3)},
+       { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_MV32_WB_RMNET, 0xff),
+         .driver_info = RSVD(0) },
        { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100),
          .driver_info = RSVD(4) },
        { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD120),
@@ -2155,6 +2169,7 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) },                   /* GosunCn GM500 RNDIS */
        { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1405, 0xff) },                   /* GosunCn GM500 MBIM */
        { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1406, 0xff) },                   /* GosunCn GM500 ECM/NCM */
+       { USB_DEVICE_AND_INTERFACE_INFO(OPPO_VENDOR_ID, OPPO_PRODUCT_R11, 0xff, 0xff, 0x30) },
        { } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, option_ids);
index 1a05e3d..4993227 100644 (file)
@@ -2294,6 +2294,13 @@ UNUSUAL_DEV( 0x1e74, 0x4621, 0x0000, 0x0000,
                USB_SC_DEVICE, USB_PR_DEVICE, NULL,
                US_FL_BULK_IGNORE_TAG | US_FL_MAX_SECTORS_64 ),
 
+/* Reported by Witold Lipieta <witold.lipieta@thaumatec.com> */
+UNUSUAL_DEV( 0x1fc9, 0x0117, 0x0100, 0x0100,
+               "NXP Semiconductors",
+               "PN7462AU",
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+               US_FL_IGNORE_RESIDUE ),
+
 /* Supplied with some Castlewood ORB removable drives */
 UNUSUAL_DEV(  0x2027, 0xa001, 0x0000, 0x9999,
                "Double-H Technology",
index 4051c8c..23ab3b0 100644 (file)
@@ -62,6 +62,13 @@ UNUSUAL_DEV(0x0984, 0x0301, 0x0128, 0x0128,
                USB_SC_DEVICE, USB_PR_DEVICE, NULL,
                US_FL_IGNORE_UAS),
 
+/* Reported-by: Tom Hu <huxiaoying@kylinos.cn> */
+UNUSUAL_DEV(0x0b05, 0x1932, 0x0000, 0x9999,
+               "ASUS",
+               "External HDD",
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+               US_FL_IGNORE_UAS),
+
 /* Reported-by: David Webb <djw@noc.ac.uk> */
 UNUSUAL_DEV(0x0bc2, 0x331a, 0x0000, 0x9999,
                "Seagate",
index c1d8c23..de66a29 100644 (file)
@@ -99,8 +99,8 @@ static int dp_altmode_configure(struct dp_altmode *dp, u8 con)
        case DP_STATUS_CON_UFP_D:
        case DP_STATUS_CON_BOTH: /* NOTE: First acting as DP source */
                conf |= DP_CONF_UFP_U_AS_UFP_D;
-               pin_assign = DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo) &
-                            DP_CAP_UFP_D_PIN_ASSIGN(dp->port->vdo);
+               pin_assign = DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo) &
+                                DP_CAP_PIN_ASSIGN_DFP_D(dp->port->vdo);
                break;
        default:
                break;
index ebc29ec..bd5e5dd 100644 (file)
@@ -2346,6 +2346,7 @@ static void __exit typec_exit(void)
        ida_destroy(&typec_index_ida);
        bus_unregister(&typec_bus);
        class_unregister(&typec_mux_class);
+       class_unregister(&retimer_class);
 }
 module_exit(typec_exit);
 
index 47b733f..a8e273f 100644 (file)
@@ -571,9 +571,11 @@ err_unregister_switch:
 
 static int is_memory(struct acpi_resource *res, void *data)
 {
-       struct resource r;
+       struct resource_win win = {};
+       struct resource *r = &win.res;
 
-       return !acpi_dev_resource_memory(res, &r);
+       return !(acpi_dev_resource_memory(res, r) ||
+                acpi_dev_resource_address_space(res, &win));
 }
 
 /* IOM ACPI IDs and IOM_PORT_STATUS_OFFSET */
@@ -583,6 +585,9 @@ static const struct acpi_device_id iom_acpi_ids[] = {
 
        /* AlderLake */
        { "INTC1079", 0x160, },
+
+       /* Meteor Lake */
+       { "INTC107A", 0x160, },
        {}
 };
 
index ea5a917..904c7b4 100644 (file)
@@ -6320,6 +6320,13 @@ static int tcpm_psy_set_prop(struct power_supply *psy,
        struct tcpm_port *port = power_supply_get_drvdata(psy);
        int ret;
 
+       /*
+        * All the properties below are related to USB PD. The check needs to be
+        * property specific when a non-pd related property is added.
+        */
+       if (!port->pd_supported)
+               return -EOPNOTSUPP;
+
        switch (psp) {
        case POWER_SUPPLY_PROP_ONLINE:
                ret = tcpm_psy_set_online(port, val);
index 1aea464..7f2624f 100644 (file)
@@ -1200,32 +1200,6 @@ out_unlock:
        return ret;
 }
 
-static void ucsi_unregister_connectors(struct ucsi *ucsi)
-{
-       struct ucsi_connector *con;
-       int i;
-
-       if (!ucsi->connector)
-               return;
-
-       for (i = 0; i < ucsi->cap.num_connectors; i++) {
-               con = &ucsi->connector[i];
-
-               if (!con->wq)
-                       break;
-
-               cancel_work_sync(&con->work);
-               ucsi_unregister_partner(con);
-               ucsi_unregister_altmodes(con, UCSI_RECIPIENT_CON);
-               ucsi_unregister_port_psy(con);
-               destroy_workqueue(con->wq);
-               typec_unregister_port(con->port);
-       }
-
-       kfree(ucsi->connector);
-       ucsi->connector = NULL;
-}
-
 /**
  * ucsi_init - Initialize UCSI interface
  * @ucsi: UCSI to be initialized
@@ -1234,6 +1208,7 @@ static void ucsi_unregister_connectors(struct ucsi *ucsi)
  */
 static int ucsi_init(struct ucsi *ucsi)
 {
+       struct ucsi_connector *con;
        u64 command;
        int ret;
        int i;
@@ -1264,7 +1239,7 @@ static int ucsi_init(struct ucsi *ucsi)
        }
 
        /* Allocate the connectors. Released in ucsi_unregister() */
-       ucsi->connector = kcalloc(ucsi->cap.num_connectors,
+       ucsi->connector = kcalloc(ucsi->cap.num_connectors + 1,
                                  sizeof(*ucsi->connector), GFP_KERNEL);
        if (!ucsi->connector) {
                ret = -ENOMEM;
@@ -1288,7 +1263,15 @@ static int ucsi_init(struct ucsi *ucsi)
        return 0;
 
 err_unregister:
-       ucsi_unregister_connectors(ucsi);
+       for (con = ucsi->connector; con->port; con++) {
+               ucsi_unregister_partner(con);
+               ucsi_unregister_altmodes(con, UCSI_RECIPIENT_CON);
+               ucsi_unregister_port_psy(con);
+               if (con->wq)
+                       destroy_workqueue(con->wq);
+               typec_unregister_port(con->port);
+               con->port = NULL;
+       }
 
 err_reset:
        memset(&ucsi->cap, 0, sizeof(ucsi->cap));
@@ -1402,6 +1385,7 @@ EXPORT_SYMBOL_GPL(ucsi_register);
 void ucsi_unregister(struct ucsi *ucsi)
 {
        u64 cmd = UCSI_SET_NOTIFICATION_ENABLE;
+       int i;
 
        /* Make sure that we are not in the middle of driver initialization */
        cancel_delayed_work_sync(&ucsi->work);
@@ -1409,7 +1393,18 @@ void ucsi_unregister(struct ucsi *ucsi)
        /* Disable notifications */
        ucsi->ops->async_write(ucsi, UCSI_CONTROL, &cmd, sizeof(cmd));
 
-       ucsi_unregister_connectors(ucsi);
+       for (i = 0; i < ucsi->cap.num_connectors; i++) {
+               cancel_work_sync(&ucsi->connector[i].work);
+               ucsi_unregister_partner(&ucsi->connector[i]);
+               ucsi_unregister_altmodes(&ucsi->connector[i],
+                                        UCSI_RECIPIENT_CON);
+               ucsi_unregister_port_psy(&ucsi->connector[i]);
+               if (ucsi->connector[i].wq)
+                       destroy_workqueue(ucsi->connector[i].wq);
+               typec_unregister_port(ucsi->connector[i].port);
+       }
+
+       kfree(ucsi->connector);
 }
 EXPORT_SYMBOL_GPL(ucsi_unregister);
 
index e163aa9..0cbdcd1 100644 (file)
@@ -151,7 +151,10 @@ int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
        if (!vdev->vdev.kvm)
                return 0;
 
-       return kvm_s390_pci_register_kvm(zdev, vdev->vdev.kvm);
+       if (zpci_kvm_hook.kvm_register)
+               return zpci_kvm_hook.kvm_register(zdev, vdev->vdev.kvm);
+
+       return -ENOENT;
 }
 
 void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)
@@ -161,5 +164,6 @@ void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)
        if (!zdev || !vdev->vdev.kvm)
                return;
 
-       kvm_s390_pci_unregister_kvm(zdev);
+       if (zpci_kvm_hook.kvm_unregister)
+               zpci_kvm_hook.kvm_unregister(zdev);
 }
index bd4dc97..db568f6 100644 (file)
@@ -290,7 +290,7 @@ static char default_sti_path[21] __read_mostly;
 static int __init sti_setup(char *str)
 {
        if (str)
-               strlcpy (default_sti_path, str, sizeof (default_sti_path));
+               strscpy(default_sti_path, str, sizeof(default_sti_path));
        
        return 1;
 }
index a3e6fae..14eb718 100644 (file)
@@ -3891,7 +3891,7 @@ static int __init atyfb_setup(char *options)
                         && (!strncmp(this_opt, "Mach64:", 7))) {
                        static unsigned char m64_num;
                        static char mach64_str[80];
-                       strlcpy(mach64_str, this_opt + 7, sizeof(mach64_str));
+                       strscpy(mach64_str, this_opt + 7, sizeof(mach64_str));
                        if (!store_video_par(mach64_str, m64_num)) {
                                m64_num++;
                                mach64_count = m64_num;
index 6851f47..a14a8d7 100644 (file)
@@ -1980,7 +1980,7 @@ static int radeon_set_fbinfo(struct radeonfb_info *rinfo)
        info->screen_base = rinfo->fb_base;
        info->screen_size = rinfo->mapped_vram;
        /* Fill fix common fields */
-       strlcpy(info->fix.id, rinfo->name, sizeof(info->fix.id));
+       strscpy(info->fix.id, rinfo->name, sizeof(info->fix.id));
         info->fix.smem_start = rinfo->fb_base_phys;
         info->fix.smem_len = rinfo->video_ram;
         info->fix.type = FB_TYPE_PACKED_PIXELS;
@@ -2094,34 +2094,34 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo)
        u32 tmp;
 
        /* framebuffer size */
-        if ((rinfo->family == CHIP_FAMILY_RS100) ||
+       if ((rinfo->family == CHIP_FAMILY_RS100) ||
             (rinfo->family == CHIP_FAMILY_RS200) ||
             (rinfo->family == CHIP_FAMILY_RS300) ||
             (rinfo->family == CHIP_FAMILY_RC410) ||
             (rinfo->family == CHIP_FAMILY_RS400) ||
            (rinfo->family == CHIP_FAMILY_RS480) ) {
-          u32 tom = INREG(NB_TOM);
-          tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024);
-
-               radeon_fifo_wait(6);
-          OUTREG(MC_FB_LOCATION, tom);
-          OUTREG(DISPLAY_BASE_ADDR, (tom & 0xffff) << 16);
-          OUTREG(CRTC2_DISPLAY_BASE_ADDR, (tom & 0xffff) << 16);
-          OUTREG(OV0_BASE_ADDR, (tom & 0xffff) << 16);
-
-          /* This is supposed to fix the crtc2 noise problem. */
-          OUTREG(GRPH2_BUFFER_CNTL, INREG(GRPH2_BUFFER_CNTL) & ~0x7f0000);
-
-          if ((rinfo->family == CHIP_FAMILY_RS100) ||
-              (rinfo->family == CHIP_FAMILY_RS200)) {
-             /* This is to workaround the asic bug for RMX, some versions
-                of BIOS doesn't have this register initialized correctly.
-             */
-             OUTREGP(CRTC_MORE_CNTL, CRTC_H_CUTOFF_ACTIVE_EN,
-                     ~CRTC_H_CUTOFF_ACTIVE_EN);
-          }
-        } else {
-          tmp = INREG(CNFG_MEMSIZE);
+               u32 tom = INREG(NB_TOM);
+
+               tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024);
+               radeon_fifo_wait(6);
+               OUTREG(MC_FB_LOCATION, tom);
+               OUTREG(DISPLAY_BASE_ADDR, (tom & 0xffff) << 16);
+               OUTREG(CRTC2_DISPLAY_BASE_ADDR, (tom & 0xffff) << 16);
+               OUTREG(OV0_BASE_ADDR, (tom & 0xffff) << 16);
+
+               /* This is supposed to fix the crtc2 noise problem. */
+               OUTREG(GRPH2_BUFFER_CNTL, INREG(GRPH2_BUFFER_CNTL) & ~0x7f0000);
+
+               if ((rinfo->family == CHIP_FAMILY_RS100) ||
+                   (rinfo->family == CHIP_FAMILY_RS200)) {
+                       /* This is to workaround the asic bug for RMX, some versions
+                        * of BIOS doesn't have this register initialized correctly.
+                        */
+                       OUTREGP(CRTC_MORE_CNTL, CRTC_H_CUTOFF_ACTIVE_EN,
+                               ~CRTC_H_CUTOFF_ACTIVE_EN);
+               }
+       } else {
+               tmp = INREG(CNFG_MEMSIZE);
         }
 
        /* mem size is bits [28:0], mask off the rest */
index e7702fe..6403ae0 100644 (file)
@@ -182,7 +182,7 @@ static int bw2_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
 
 static void bw2_init_fix(struct fb_info *info, int linebytes)
 {
-       strlcpy(info->fix.id, "bwtwo", sizeof(info->fix.id));
+       strscpy(info->fix.id, "bwtwo", sizeof(info->fix.id));
 
        info->fix.type = FB_TYPE_PACKED_PIXELS;
        info->fix.visual = FB_VISUAL_MONO01;
index 393894a..2b00a9d 100644 (file)
@@ -430,6 +430,7 @@ static int chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
  err_release_fb:
        framebuffer_release(p);
  err_disable:
+       pci_disable_device(dp);
  err_out:
        return rc;
 }
index a41a758..2a9fa06 100644 (file)
@@ -1999,7 +1999,7 @@ static int cirrusfb_set_fbinfo(struct fb_info *info)
        }
 
        /* Fill fix common fields */
-       strlcpy(info->fix.id, cirrusfb_board_info[cinfo->btype].name,
+       strscpy(info->fix.id, cirrusfb_board_info[cinfo->btype].name,
                sizeof(info->fix.id));
 
        /* monochrome: only 1 memory plane */
index 771ce1f..a1061c2 100644 (file)
@@ -326,7 +326,7 @@ static int clps711x_fb_probe(struct platform_device *pdev)
        info->var.vmode = FB_VMODE_NONINTERLACED;
        info->fix.type = FB_TYPE_PACKED_PIXELS;
        info->fix.accel = FB_ACCEL_NONE;
-       strlcpy(info->fix.id, CLPS711X_FB_NAME, sizeof(info->fix.id));
+       strscpy(info->fix.id, CLPS711X_FB_NAME, sizeof(info->fix.id));
        fb_videomode_to_var(&info->var, &cfb->mode);
 
        ret = fb_alloc_cmap(&info->cmap, BIT(CLPS711X_FB_BPP_MAX), 0);
index cf9ac4d..098b62f 100644 (file)
@@ -412,7 +412,7 @@ static int __init fb_console_setup(char *this_opt)
 
        while ((options = strsep(&this_opt, ",")) != NULL) {
                if (!strncmp(options, "font:", 5)) {
-                       strlcpy(fontname, options + 5, sizeof(fontname));
+                       strscpy(fontname, options + 5, sizeof(fontname));
                        continue;
                }
                
@@ -2401,15 +2401,21 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,
        struct fb_info *info = fbcon_info_from_console(vc->vc_num);
        struct fbcon_ops *ops = info->fbcon_par;
        struct fbcon_display *p = &fb_display[vc->vc_num];
-       int resize;
+       int resize, ret, old_userfont, old_width, old_height, old_charcount;
        char *old_data = NULL;
 
        resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
        if (p->userfont)
                old_data = vc->vc_font.data;
        vc->vc_font.data = (void *)(p->fontdata = data);
+       old_userfont = p->userfont;
        if ((p->userfont = userfont))
                REFCOUNT(data)++;
+
+       old_width = vc->vc_font.width;
+       old_height = vc->vc_font.height;
+       old_charcount = vc->vc_font.charcount;
+
        vc->vc_font.width = w;
        vc->vc_font.height = h;
        vc->vc_font.charcount = charcount;
@@ -2425,7 +2431,9 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,
                rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
                cols /= w;
                rows /= h;
-               vc_resize(vc, cols, rows);
+               ret = vc_resize(vc, cols, rows);
+               if (ret)
+                       goto err_out;
        } else if (con_is_visible(vc)
                   && vc->vc_mode == KD_TEXT) {
                fbcon_clear_margins(vc, 0);
@@ -2435,6 +2443,21 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,
        if (old_data && (--REFCOUNT(old_data) == 0))
                kfree(old_data - FONT_EXTRA_WORDS * sizeof(int));
        return 0;
+
+err_out:
+       p->fontdata = old_data;
+       vc->vc_font.data = (void *)old_data;
+
+       if (userfont) {
+               p->userfont = old_userfont;
+               REFCOUNT(data)--;
+       }
+
+       vc->vc_font.width = old_width;
+       vc->vc_font.height = old_height;
+       vc->vc_font.charcount = old_charcount;
+
+       return ret;
 }
 
 /*
index c2a60b1..4d7f638 100644 (file)
@@ -84,6 +84,10 @@ void framebuffer_release(struct fb_info *info)
        if (WARN_ON(refcount_read(&info->count)))
                return;
 
+#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
+       mutex_destroy(&info->bl_curve_mutex);
+#endif
+
        kfree(info->apertures);
        kfree(info);
 }
index d45355b..8f041f9 100644 (file)
@@ -1134,7 +1134,7 @@ int cyber2000fb_attach(struct cyberpro_info *info, int idx)
                info->fb_size         = int_cfb_info->fb.fix.smem_len;
                info->info            = int_cfb_info;
 
-               strlcpy(info->dev_name, int_cfb_info->fb.fix.id,
+               strscpy(info->dev_name, int_cfb_info->fb.fix.id,
                        sizeof(info->dev_name));
        }
 
@@ -1229,7 +1229,7 @@ static int cyber2000fb_ddc_getsda(void *data)
 
 static int cyber2000fb_setup_ddc_bus(struct cfb_info *cfb)
 {
-       strlcpy(cfb->ddc_adapter.name, cfb->fb.fix.id,
+       strscpy(cfb->ddc_adapter.name, cfb->fb.fix.id,
                sizeof(cfb->ddc_adapter.name));
        cfb->ddc_adapter.owner          = THIS_MODULE;
        cfb->ddc_adapter.class          = I2C_CLASS_DDC;
@@ -1304,7 +1304,7 @@ static int cyber2000fb_i2c_getscl(void *data)
 
 static int cyber2000fb_i2c_register(struct cfb_info *cfb)
 {
-       strlcpy(cfb->i2c_adapter.name, cfb->fb.fix.id,
+       strscpy(cfb->i2c_adapter.name, cfb->fb.fix.id,
                sizeof(cfb->i2c_adapter.name));
        cfb->i2c_adapter.owner = THIS_MODULE;
        cfb->i2c_adapter.algo_data = &cfb->i2c_algo;
@@ -1500,7 +1500,7 @@ static int cyber2000fb_setup(char *options)
                if (strncmp(opt, "font:", 5) == 0) {
                        static char default_font_storage[40];
 
-                       strlcpy(default_font_storage, opt + 5,
+                       strscpy(default_font_storage, opt + 5,
                                sizeof(default_font_storage));
                        default_font = default_font_storage;
                        continue;
index b3d580e..7cba396 100644 (file)
@@ -883,7 +883,7 @@ static void ffb_init_fix(struct fb_info *info)
        } else
                ffb_type_name = "Elite 3D";
 
-       strlcpy(info->fix.id, ffb_type_name, sizeof(info->fix.id));
+       strscpy(info->fix.id, ffb_type_name, sizeof(info->fix.id));
 
        info->fix.type = FB_TYPE_PACKED_PIXELS;
        info->fix.visual = FB_VISUAL_TRUECOLOR;
index 5d34d89..e41204e 100644 (file)
@@ -410,13 +410,13 @@ static void __init gx1fb_setup(char *options)
                        continue;
 
                if (!strncmp(this_opt, "mode:", 5))
-                       strlcpy(mode_option, this_opt + 5, sizeof(mode_option));
+                       strscpy(mode_option, this_opt + 5, sizeof(mode_option));
                else if (!strncmp(this_opt, "crt:", 4))
                        crt_option = !!simple_strtoul(this_opt + 4, NULL, 0);
                else if (!strncmp(this_opt, "panel:", 6))
-                       strlcpy(panel_option, this_opt + 6, sizeof(panel_option));
+                       strscpy(panel_option, this_opt + 6, sizeof(panel_option));
                else
-                       strlcpy(mode_option, this_opt, sizeof(mode_option));
+                       strscpy(mode_option, this_opt, sizeof(mode_option));
        }
 }
 #endif
index e5475ae..94588b8 100644 (file)
@@ -650,7 +650,7 @@ static int gxt4500_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        cardtype = ent->driver_data;
        par->refclk_ps = cardinfo[cardtype].refclk_ps;
        info->fix = gxt4500_fix;
-       strlcpy(info->fix.id, cardinfo[cardtype].cardname,
+       strscpy(info->fix.id, cardinfo[cardtype].cardname,
                sizeof(info->fix.id));
        info->pseudo_palette = par->pseudo_palette;
 
index 7f09a0d..bd30d83 100644 (file)
@@ -159,7 +159,7 @@ static int i740fb_setup_ddc_bus(struct fb_info *info)
 {
        struct i740fb_par *par = info->par;
 
-       strlcpy(par->ddc_adapter.name, info->fix.id,
+       strscpy(par->ddc_adapter.name, info->fix.id,
                sizeof(par->ddc_adapter.name));
        par->ddc_adapter.owner          = THIS_MODULE;
        par->ddc_adapter.class          = I2C_CLASS_DDC;
index d97d745..94f3bc6 100644 (file)
@@ -681,7 +681,7 @@ static int imxfb_init_fbinfo(struct platform_device *pdev)
 
        fbi->devtype = pdev->id_entry->driver_data;
 
-       strlcpy(info->fix.id, IMX_NAME, sizeof(info->fix.id));
+       strscpy(info->fix.id, IMX_NAME, sizeof(info->fix.id));
 
        info->fix.type                  = FB_TYPE_PACKED_PIXELS;
        info->fix.type_aux              = 0;
index 236521b..68bba26 100644 (file)
@@ -2383,9 +2383,9 @@ static int __init matroxfb_setup(char *options) {
                else if (!strncmp(this_opt, "mem:", 4))
                        mem = simple_strtoul(this_opt+4, NULL, 0);
                else if (!strncmp(this_opt, "mode:", 5))
-                       strlcpy(videomode, this_opt+5, sizeof(videomode));
+                       strscpy(videomode, this_opt + 5, sizeof(videomode));
                else if (!strncmp(this_opt, "outputs:", 8))
-                       strlcpy(outputs, this_opt+8, sizeof(outputs));
+                       strscpy(outputs, this_opt + 8, sizeof(outputs));
                else if (!strncmp(this_opt, "dfp:", 4)) {
                        dfp_type = simple_strtoul(this_opt+4, NULL, 0);
                        dfp = 1;
@@ -2455,7 +2455,7 @@ static int __init matroxfb_setup(char *options) {
                        else if (!strcmp(this_opt, "dfp"))
                                dfp = value;
                        else {
-                               strlcpy(videomode, this_opt, sizeof(videomode));
+                               strscpy(videomode, this_opt, sizeof(videomode));
                        }
                }
        }
index dfb4ddc..17cda57 100644 (file)
@@ -1642,15 +1642,13 @@ static int omapfb_do_probe(struct platform_device *pdev,
                goto cleanup;
        }
        fbdev->int_irq = platform_get_irq(pdev, 0);
-       if (!fbdev->int_irq) {
-               dev_err(&pdev->dev, "unable to get irq\n");
+       if (fbdev->int_irq < 0) {
                r = ENXIO;
                goto cleanup;
        }
 
        fbdev->ext_irq = platform_get_irq(pdev, 1);
-       if (!fbdev->ext_irq) {
-               dev_err(&pdev->dev, "unable to get irq\n");
+       if (fbdev->ext_irq < 0) {
                r = ENXIO;
                goto cleanup;
        }
index afa688e..5ccddcf 100644 (file)
@@ -1331,7 +1331,7 @@ static void clear_fb_info(struct fb_info *fbi)
 {
        memset(&fbi->var, 0, sizeof(fbi->var));
        memset(&fbi->fix, 0, sizeof(fbi->fix));
-       strlcpy(fbi->fix.id, MODULE_NAME, sizeof(fbi->fix.id));
+       strscpy(fbi->fix.id, MODULE_NAME, sizeof(fbi->fix.id));
 }
 
 static int omapfb_free_all_fbmem(struct omapfb2_device *fbdev)
index d3be2c6..8fd79de 100644 (file)
@@ -617,6 +617,11 @@ static int pm2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
                return -EINVAL;
        }
 
+       if (!var->pixclock) {
+               DPRINTK("pixclock is zero\n");
+               return -EINVAL;
+       }
+
        if (PICOS2KHZ(var->pixclock) > PM2_MAX_PIXCLOCK) {
                DPRINTK("pixclock too high (%ldKHz)\n",
                        PICOS2KHZ(var->pixclock));
index e943300..d5d0bbd 100644 (file)
@@ -640,7 +640,7 @@ static int pxa168fb_probe(struct platform_device *pdev)
        info->flags = FBINFO_DEFAULT | FBINFO_PARTIAL_PAN_OK |
                      FBINFO_HWACCEL_XPAN | FBINFO_HWACCEL_YPAN;
        info->node = -1;
-       strlcpy(info->fix.id, mi->id, 16);
+       strscpy(info->fix.id, mi->id, 16);
        info->fix.type = FB_TYPE_PACKED_PIXELS;
        info->fix.type_aux = 0;
        info->fix.xpanstep = 0;
index 66cfc3e..696ac54 100644 (file)
@@ -2042,7 +2042,7 @@ static int __init pxafb_setup_options(void)
                return -ENODEV;
 
        if (options)
-               strlcpy(g_options, options, sizeof(g_options));
+               strscpy(g_options, options, sizeof(g_options));
 
        return 0;
 }
index 5069f6f..67b63a7 100644 (file)
@@ -248,7 +248,7 @@ static int s3fb_setup_ddc_bus(struct fb_info *info)
 {
        struct s3fb_info *par = info->par;
 
-       strlcpy(par->ddc_adapter.name, info->fix.id,
+       strscpy(par->ddc_adapter.name, info->fix.id,
                sizeof(par->ddc_adapter.name));
        par->ddc_adapter.owner          = THIS_MODULE;
        par->ddc_adapter.class          = I2C_CLASS_DDC;
index cf2a90e..e770b4a 100644 (file)
@@ -355,7 +355,7 @@ static int simplefb_regulators_get(struct simplefb_par *par,
                if (!p || p == prop->name)
                        continue;
 
-               strlcpy(name, prop->name,
+               strscpy(name, prop->name,
                        strlen(prop->name) - strlen(SUPPLY_SUFFIX) + 1);
                regulator = devm_regulator_get_optional(&pdev->dev, name);
                if (IS_ERR(regulator)) {
index f28fd69..c9e7742 100644 (file)
@@ -649,37 +649,37 @@ sisfb_validate_mode(struct sis_video_info *ivideo, int myindex, u32 vbflags)
        u16 xres=0, yres, myres;
 
 #ifdef CONFIG_FB_SIS_300
-       if(ivideo->sisvga_engine == SIS_300_VGA) {
-               if(!(sisbios_mode[myindex].chipset & MD_SIS300))
+       if (ivideo->sisvga_engine == SIS_300_VGA) {
+               if (!(sisbios_mode[myindex].chipset & MD_SIS300))
                        return -1 ;
        }
 #endif
 #ifdef CONFIG_FB_SIS_315
-       if(ivideo->sisvga_engine == SIS_315_VGA) {
-               if(!(sisbios_mode[myindex].chipset & MD_SIS315))
+       if (ivideo->sisvga_engine == SIS_315_VGA) {
+               if (!(sisbios_mode[myindex].chipset & MD_SIS315))
                        return -1;
        }
 #endif
 
        myres = sisbios_mode[myindex].yres;
 
-       switch(vbflags & VB_DISPTYPE_DISP2) {
+       switch (vbflags & VB_DISPTYPE_DISP2) {
 
        case CRT2_LCD:
                xres = ivideo->lcdxres; yres = ivideo->lcdyres;
 
-               if((ivideo->SiS_Pr.SiS_CustomT != CUT_PANEL848) &&
-                  (ivideo->SiS_Pr.SiS_CustomT != CUT_PANEL856)) {
-                       if(sisbios_mode[myindex].xres > xres)
+               if ((ivideo->SiS_Pr.SiS_CustomT != CUT_PANEL848) &&
+                   (ivideo->SiS_Pr.SiS_CustomT != CUT_PANEL856)) {
+                       if (sisbios_mode[myindex].xres > xres)
                                return -1;
-                       if(myres > yres)
+                       if (myres > yres)
                                return -1;
                }
 
-               if(ivideo->sisfb_fstn) {
-                       if(sisbios_mode[myindex].xres == 320) {
-                               if(myres == 240) {
-                                       switch(sisbios_mode[myindex].mode_no[1]) {
+               if (ivideo->sisfb_fstn) {
+                       if (sisbios_mode[myindex].xres == 320) {
+                               if (myres == 240) {
+                                       switch (sisbios_mode[myindex].mode_no[1]) {
                                                case 0x50: myindex = MODE_FSTN_8;  break;
                                                case 0x56: myindex = MODE_FSTN_16; break;
                                                case 0x53: return -1;
@@ -688,7 +688,7 @@ sisfb_validate_mode(struct sis_video_info *ivideo, int myindex, u32 vbflags)
                        }
                }
 
-               if(SiS_GetModeID_LCD(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres,
+               if (SiS_GetModeID_LCD(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres,
                                sisbios_mode[myindex].yres, 0, ivideo->sisfb_fstn,
                                ivideo->SiS_Pr.SiS_CustomT, xres, yres, ivideo->vbflags2) < 0x14) {
                        return -1;
@@ -696,14 +696,14 @@ sisfb_validate_mode(struct sis_video_info *ivideo, int myindex, u32 vbflags)
                break;
 
        case CRT2_TV:
-               if(SiS_GetModeID_TV(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres,
+               if (SiS_GetModeID_TV(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres,
                                sisbios_mode[myindex].yres, 0, ivideo->vbflags2) < 0x14) {
                        return -1;
                }
                break;
 
        case CRT2_VGA:
-               if(SiS_GetModeID_VGA2(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres,
+               if (SiS_GetModeID_VGA2(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres,
                                sisbios_mode[myindex].yres, 0, ivideo->vbflags2) < 0x14) {
                        return -1;
                }
@@ -1872,7 +1872,7 @@ sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
 
        memset(fix, 0, sizeof(struct fb_fix_screeninfo));
 
-       strlcpy(fix->id, ivideo->myid, sizeof(fix->id));
+       strscpy(fix->id, ivideo->myid, sizeof(fix->id));
 
        mutex_lock(&info->mm_lock);
        fix->smem_start  = ivideo->video_base + ivideo->video_offset;
@@ -2204,82 +2204,88 @@ static bool sisfb_test_DDC1(struct sis_video_info *ivideo)
 
 static void sisfb_sense_crt1(struct sis_video_info *ivideo)
 {
-    bool mustwait = false;
-    u8  sr1F, cr17;
+       bool mustwait = false;
+       u8  sr1F, cr17;
 #ifdef CONFIG_FB_SIS_315
-    u8  cr63=0;
+       u8  cr63 = 0;
 #endif
-    u16 temp = 0xffff;
-    int i;
+       u16 temp = 0xffff;
+       int i;
+
+       sr1F = SiS_GetReg(SISSR, 0x1F);
+       SiS_SetRegOR(SISSR, 0x1F, 0x04);
+       SiS_SetRegAND(SISSR, 0x1F, 0x3F);
 
-    sr1F = SiS_GetReg(SISSR, 0x1F);
-    SiS_SetRegOR(SISSR, 0x1F, 0x04);
-    SiS_SetRegAND(SISSR, 0x1F, 0x3F);
-    if(sr1F & 0xc0) mustwait = true;
+       if (sr1F & 0xc0)
+               mustwait = true;
 
 #ifdef CONFIG_FB_SIS_315
-    if(ivideo->sisvga_engine == SIS_315_VGA) {
-       cr63 = SiS_GetReg(SISCR, ivideo->SiS_Pr.SiS_MyCR63);
-       cr63 &= 0x40;
-       SiS_SetRegAND(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xBF);
-    }
+       if (ivideo->sisvga_engine == SIS_315_VGA) {
+               cr63 = SiS_GetReg(SISCR, ivideo->SiS_Pr.SiS_MyCR63);
+               cr63 &= 0x40;
+               SiS_SetRegAND(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xBF);
+       }
 #endif
 
-    cr17 = SiS_GetReg(SISCR, 0x17);
-    cr17 &= 0x80;
-    if(!cr17) {
-       SiS_SetRegOR(SISCR, 0x17, 0x80);
-       mustwait = true;
-       SiS_SetReg(SISSR, 0x00, 0x01);
-       SiS_SetReg(SISSR, 0x00, 0x03);
-    }
+       cr17 = SiS_GetReg(SISCR, 0x17);
+       cr17 &= 0x80;
 
-    if(mustwait) {
-       for(i=0; i < 10; i++) sisfbwaitretracecrt1(ivideo);
-    }
+       if (!cr17) {
+               SiS_SetRegOR(SISCR, 0x17, 0x80);
+               mustwait = true;
+               SiS_SetReg(SISSR, 0x00, 0x01);
+               SiS_SetReg(SISSR, 0x00, 0x03);
+       }
 
+       if (mustwait) {
+               for (i = 0; i < 10; i++)
+                       sisfbwaitretracecrt1(ivideo);
+       }
 #ifdef CONFIG_FB_SIS_315
-    if(ivideo->chip >= SIS_330) {
-       SiS_SetRegAND(SISCR, 0x32, ~0x20);
-       if(ivideo->chip >= SIS_340) {
-          SiS_SetReg(SISCR, 0x57, 0x4a);
-       } else {
-          SiS_SetReg(SISCR, 0x57, 0x5f);
-       }
-       SiS_SetRegOR(SISCR, 0x53, 0x02);
-       while ((SiS_GetRegByte(SISINPSTAT)) & 0x01)    break;
-       while (!((SiS_GetRegByte(SISINPSTAT)) & 0x01)) break;
-       if ((SiS_GetRegByte(SISMISCW)) & 0x10) temp = 1;
-       SiS_SetRegAND(SISCR, 0x53, 0xfd);
-       SiS_SetRegAND(SISCR, 0x57, 0x00);
-    }
+       if (ivideo->chip >= SIS_330) {
+               SiS_SetRegAND(SISCR, 0x32, ~0x20);
+               if (ivideo->chip >= SIS_340)
+                       SiS_SetReg(SISCR, 0x57, 0x4a);
+               else
+                       SiS_SetReg(SISCR, 0x57, 0x5f);
+
+               SiS_SetRegOR(SISCR, 0x53, 0x02);
+               while ((SiS_GetRegByte(SISINPSTAT)) & 0x01)
+                       break;
+               while (!((SiS_GetRegByte(SISINPSTAT)) & 0x01))
+                       break;
+               if ((SiS_GetRegByte(SISMISCW)) & 0x10)
+                       temp = 1;
+
+               SiS_SetRegAND(SISCR, 0x53, 0xfd);
+               SiS_SetRegAND(SISCR, 0x57, 0x00);
+       }
 #endif
 
-    if(temp == 0xffff) {
-       i = 3;
-       do {
-         temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags,
-               ivideo->sisvga_engine, 0, 0, NULL, ivideo->vbflags2);
-       } while(((temp == 0) || (temp == 0xffff)) && i--);
+       if (temp == 0xffff) {
+               i = 3;
 
-       if((temp == 0) || (temp == 0xffff)) {
-          if(sisfb_test_DDC1(ivideo)) temp = 1;
-       }
-    }
+               do {
+                       temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags,
+                       ivideo->sisvga_engine, 0, 0, NULL, ivideo->vbflags2);
+               } while (((temp == 0) || (temp == 0xffff)) && i--);
 
-    if((temp) && (temp != 0xffff)) {
-       SiS_SetRegOR(SISCR, 0x32, 0x20);
-    }
+               if ((temp == 0) || (temp == 0xffff)) {
+                       if (sisfb_test_DDC1(ivideo))
+                               temp = 1;
+               }
+       }
+
+       if ((temp) && (temp != 0xffff))
+               SiS_SetRegOR(SISCR, 0x32, 0x20);
 
 #ifdef CONFIG_FB_SIS_315
-    if(ivideo->sisvga_engine == SIS_315_VGA) {
-       SiS_SetRegANDOR(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xBF, cr63);
-    }
+       if (ivideo->sisvga_engine == SIS_315_VGA)
+               SiS_SetRegANDOR(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xBF, cr63);
 #endif
 
-    SiS_SetRegANDOR(SISCR, 0x17, 0x7F, cr17);
-
-    SiS_SetReg(SISSR, 0x1F, sr1F);
+       SiS_SetRegANDOR(SISCR, 0x17, 0x7F, cr17);
+       SiS_SetReg(SISSR, 0x1F, sr1F);
 }
 
 /* Determine and detect attached devices on SiS30x */
@@ -2293,25 +2299,25 @@ static void SiS_SenseLCD(struct sis_video_info *ivideo)
        ivideo->SiS_Pr.PanelSelfDetected = false;
 
        /* LCD detection only for TMDS bridges */
-       if(!(ivideo->vbflags2 & VB2_SISTMDSBRIDGE))
+       if (!(ivideo->vbflags2 & VB2_SISTMDSBRIDGE))
                return;
-       if(ivideo->vbflags2 & VB2_30xBDH)
+       if (ivideo->vbflags2 & VB2_30xBDH)
                return;
 
        /* If LCD already set up by BIOS, skip it */
        reg = SiS_GetReg(SISCR, 0x32);
-       if(reg & 0x08)
+       if (reg & 0x08)
                return;
 
        realcrtno = 1;
-       if(ivideo->SiS_Pr.DDCPortMixup)
+       if (ivideo->SiS_Pr.DDCPortMixup)
                realcrtno = 0;
 
        /* Check DDC capabilities */
        temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine,
                                realcrtno, 0, &buffer[0], ivideo->vbflags2);
 
-       if((!temp) || (temp == 0xffff) || (!(temp & 0x02)))
+       if ((!temp) || (temp == 0xffff) || (!(temp & 0x02)))
                return;
 
        /* Read DDC data */
@@ -2320,17 +2326,17 @@ static void SiS_SenseLCD(struct sis_video_info *ivideo)
                temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags,
                                ivideo->sisvga_engine, realcrtno, 1,
                                &buffer[0], ivideo->vbflags2);
-       } while((temp) && i--);
+       } while ((temp) && i--);
 
-       if(temp)
+       if (temp)
                return;
 
        /* No digital device */
-       if(!(buffer[0x14] & 0x80))
+       if (!(buffer[0x14] & 0x80))
                return;
 
        /* First detailed timing preferred timing? */
-       if(!(buffer[0x18] & 0x02))
+       if (!(buffer[0x18] & 0x02))
                return;
 
        xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4);
@@ -2338,26 +2344,26 @@ static void SiS_SenseLCD(struct sis_video_info *ivideo)
 
        switch(xres) {
                case 1024:
-                       if(yres == 768)
+                       if (yres == 768)
                                paneltype = 0x02;
                        break;
                case 1280:
-                       if(yres == 1024)
+                       if (yres == 1024)
                                paneltype = 0x03;
                        break;
                case 1600:
-                       if((yres == 1200) && (ivideo->vbflags2 & VB2_30xC))
+                       if ((yres == 1200) && (ivideo->vbflags2 & VB2_30xC))
                                paneltype = 0x0b;
                        break;
        }
 
-       if(!paneltype)
+       if (!paneltype)
                return;
 
-       if(buffer[0x23])
+       if (buffer[0x23])
                cr37 |= 0x10;
 
-       if((buffer[0x47] & 0x18) == 0x18)
+       if ((buffer[0x47] & 0x18) == 0x18)
                cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20);
        else
                cr37 |= 0xc0;
@@ -2372,31 +2378,34 @@ static void SiS_SenseLCD(struct sis_video_info *ivideo)
 
 static int SISDoSense(struct sis_video_info *ivideo, u16 type, u16 test)
 {
-    int temp, mytest, result, i, j;
-
-    for(j = 0; j < 10; j++) {
-       result = 0;
-       for(i = 0; i < 3; i++) {
-          mytest = test;
-          SiS_SetReg(SISPART4, 0x11, (type & 0x00ff));
-          temp = (type >> 8) | (mytest & 0x00ff);
-         SiS_SetRegANDOR(SISPART4, 0x10, 0xe0, temp);
-          SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1500);
-          mytest >>= 8;
-          mytest &= 0x7f;
-          temp = SiS_GetReg(SISPART4, 0x03);
-          temp ^= 0x0e;
-          temp &= mytest;
-          if(temp == mytest) result++;
+       int temp, mytest, result, i, j;
+
+       for (j = 0; j < 10; j++) {
+               result = 0;
+               for (i = 0; i < 3; i++) {
+                       mytest = test;
+                       SiS_SetReg(SISPART4, 0x11, (type & 0x00ff));
+                       temp = (type >> 8) | (mytest & 0x00ff);
+                       SiS_SetRegANDOR(SISPART4, 0x10, 0xe0, temp);
+                       SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1500);
+                       mytest >>= 8;
+                       mytest &= 0x7f;
+                       temp = SiS_GetReg(SISPART4, 0x03);
+                       temp ^= 0x0e;
+                       temp &= mytest;
+                       if (temp == mytest)
+                               result++;
 #if 1
-         SiS_SetReg(SISPART4, 0x11, 0x00);
-         SiS_SetRegAND(SISPART4, 0x10, 0xe0);
-         SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1000);
+                       SiS_SetReg(SISPART4, 0x11, 0x00);
+                       SiS_SetRegAND(SISPART4, 0x10, 0xe0);
+                       SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1000);
 #endif
-       }
-       if((result == 0) || (result >= 2)) break;
-    }
-    return result;
+               }
+
+               if ((result == 0) || (result >= 2))
+                       break;
+       }
+       return result;
 }
 
 static void SiS_Sense30x(struct sis_video_info *ivideo)
@@ -4262,18 +4271,17 @@ static int sisfb_post_300_rwtest(struct sis_video_info *ivideo, int iteration,
        unsigned int k, RankCapacity, PageCapacity, BankNumHigh, BankNumMid;
        unsigned int PhysicalAdrOtherPage, PhysicalAdrHigh, PhysicalAdrHalfPage;
 
-        for(k = 0; k < ARRAY_SIZE(SiS_DRAMType); k++) {
-
+       for (k = 0; k < ARRAY_SIZE(SiS_DRAMType); k++) {
                RankCapacity = buswidth * SiS_DRAMType[k][3];
 
-               if(RankCapacity != PseudoRankCapacity)
+               if (RankCapacity != PseudoRankCapacity)
                        continue;
 
-               if((SiS_DRAMType[k][2] + SiS_DRAMType[k][0]) > PseudoAdrPinCount)
+               if ((SiS_DRAMType[k][2] + SiS_DRAMType[k][0]) > PseudoAdrPinCount)
                        continue;
 
                BankNumHigh = RankCapacity * 16 * iteration - 1;
-               if(iteration == 3) {             /* Rank No */
+               if (iteration == 3) {             /* Rank No */
                        BankNumMid  = RankCapacity * 16 - 1;
                } else {
                        BankNumMid  = RankCapacity * 16 * iteration / 2 - 1;
@@ -4287,18 +4295,22 @@ static int sisfb_post_300_rwtest(struct sis_video_info *ivideo, int iteration,
                SiS_SetRegAND(SISSR, 0x15, 0xFB); /* Test */
                SiS_SetRegOR(SISSR, 0x15, 0x04);  /* Test */
                sr14 = (SiS_DRAMType[k][3] * buswidth) - 1;
-               if(buswidth == 4)      sr14 |= 0x80;
-               else if(buswidth == 2) sr14 |= 0x40;
+
+               if (buswidth == 4)
+                       sr14 |= 0x80;
+               else if (buswidth == 2)
+                       sr14 |= 0x40;
+
                SiS_SetReg(SISSR, 0x13, SiS_DRAMType[k][4]);
                SiS_SetReg(SISSR, 0x14, sr14);
 
                BankNumHigh <<= 16;
                BankNumMid <<= 16;
 
-               if((BankNumHigh + PhysicalAdrHigh      >= mapsize) ||
-                  (BankNumMid  + PhysicalAdrHigh      >= mapsize) ||
-                  (BankNumHigh + PhysicalAdrHalfPage  >= mapsize) ||
-                  (BankNumHigh + PhysicalAdrOtherPage >= mapsize))
+               if ((BankNumHigh + PhysicalAdrHigh >= mapsize) ||
+                   (BankNumMid  + PhysicalAdrHigh >= mapsize) ||
+                   (BankNumHigh + PhysicalAdrHalfPage  >= mapsize) ||
+                   (BankNumHigh + PhysicalAdrOtherPage >= mapsize))
                        continue;
 
                /* Write data */
@@ -4312,7 +4324,7 @@ static int sisfb_post_300_rwtest(struct sis_video_info *ivideo, int iteration,
                                (FBAddr + BankNumHigh + PhysicalAdrOtherPage));
 
                /* Read data */
-               if(readw(FBAddr + BankNumHigh + PhysicalAdrHigh) == PhysicalAdrHigh)
+               if (readw(FBAddr + BankNumHigh + PhysicalAdrHigh) == PhysicalAdrHigh)
                        return 1;
        }
 
@@ -5867,7 +5879,7 @@ static int sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        ivideo->cardnumber++;
        }
 
-       strlcpy(ivideo->myid, chipinfo->chip_name, sizeof(ivideo->myid));
+       strscpy(ivideo->myid, chipinfo->chip_name, sizeof(ivideo->myid));
 
        ivideo->warncount = 0;
        ivideo->chip_id = pdev->device;
@@ -6150,24 +6162,20 @@ static int sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 #endif
 
 #ifdef CONFIG_FB_SIS_315
-               if(ivideo->sisvga_engine == SIS_315_VGA) {
+               if (ivideo->sisvga_engine == SIS_315_VGA) {
                        int result = 1;
-               /*      if((ivideo->chip == SIS_315H)   ||
-                          (ivideo->chip == SIS_315)    ||
-                          (ivideo->chip == SIS_315PRO) ||
-                          (ivideo->chip == SIS_330)) {
-                               sisfb_post_sis315330(pdev);
-                       } else */ if(ivideo->chip == XGI_20) {
+
+                       if (ivideo->chip == XGI_20) {
                                result = sisfb_post_xgi(pdev);
                                ivideo->sisfb_can_post = 1;
-                       } else if((ivideo->chip == XGI_40) && ivideo->haveXGIROM) {
+                       } else if ((ivideo->chip == XGI_40) && ivideo->haveXGIROM) {
                                result = sisfb_post_xgi(pdev);
                                ivideo->sisfb_can_post = 1;
                        } else {
                                printk(KERN_INFO "sisfb: Card is not "
                                        "POSTed and sisfb can't do this either.\n");
                        }
-                       if(!result) {
+                       if (!result) {
                                printk(KERN_ERR "sisfb: Failed to POST card\n");
                                ret = -ENODEV;
                                goto error_3;
index 6a52eba..fce6cfb 100644 (file)
@@ -1719,7 +1719,7 @@ static int sm501fb_init_fb(struct fb_info *fb, enum sm501_controller head,
                enable = 0;
        }
 
-       strlcpy(fb->fix.id, fbname, sizeof(fb->fix.id));
+       strscpy(fb->fix.id, fbname, sizeof(fb->fix.id));
 
        memcpy(&par->ops,
               (head == HEAD_CRT) ? &sm501fb_ops_crt : &sm501fb_ops_pnl,
index 5c76565..52e4ed9 100644 (file)
@@ -450,7 +450,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
        if (ret < 0)
                return ret;
 
-       /* Set Set Area Color Mode ON/OFF & Low Power Display Mode */
+       /* Set Area Color Mode ON/OFF & Low Power Display Mode */
        if (par->area_color_enable || par->low_power) {
                u32 mode;
 
index 27d4b0a..cd4d640 100644 (file)
@@ -1382,7 +1382,7 @@ static int sstfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                goto fail;
        }
        sst_get_memsize(info, &fix->smem_len);
-       strlcpy(fix->id, spec->name, sizeof(fix->id));
+       strscpy(fix->id, spec->name, sizeof(fix->id));
 
        printk(KERN_INFO "%s (revision %d) with %s dac\n",
                fix->id, par->revision, par->dac_sw.name);
index 15b0795..490bd9a 100644 (file)
@@ -80,7 +80,7 @@ static int gfb_set_fbinfo(struct gfb_info *gp)
        info->pseudo_palette = gp->pseudo_palette;
 
        /* Fill fix common fields */
-       strlcpy(info->fix.id, "gfb", sizeof(info->fix.id));
+       strscpy(info->fix.id, "gfb", sizeof(info->fix.id));
         info->fix.smem_start = gp->fb_base_phys;
         info->fix.smem_len = gp->fb_size;
         info->fix.type = FB_TYPE_PACKED_PIXELS;
index 1d3bacd..1279b02 100644 (file)
@@ -84,7 +84,7 @@ static int s3d_set_fbinfo(struct s3d_info *sp)
        info->pseudo_palette = sp->pseudo_palette;
 
        /* Fill fix common fields */
-       strlcpy(info->fix.id, "s3d", sizeof(info->fix.id));
+       strscpy(info->fix.id, "s3d", sizeof(info->fix.id));
         info->fix.smem_start = sp->fb_base_phys;
         info->fix.smem_len = sp->fb_size;
         info->fix.type = FB_TYPE_PACKED_PIXELS;
index 9daf17b..f7b4636 100644 (file)
@@ -207,7 +207,7 @@ static int e3d_set_fbinfo(struct e3d_info *ep)
        info->pseudo_palette = ep->pseudo_palette;
 
        /* Fill fix common fields */
-       strlcpy(info->fix.id, "e3d", sizeof(info->fix.id));
+       strscpy(info->fix.id, "e3d", sizeof(info->fix.id));
         info->fix.smem_start = ep->fb_base_phys;
         info->fix.smem_len = ep->fb_size;
         info->fix.type = FB_TYPE_PACKED_PIXELS;
index 1638a40..01d87f5 100644 (file)
@@ -333,7 +333,7 @@ tcx_init_fix(struct fb_info *info, int linebytes)
        else
                tcx_name = "TCX24";
 
-       strlcpy(info->fix.id, tcx_name, sizeof(info->fix.id));
+       strscpy(info->fix.id, tcx_name, sizeof(info->fix.id));
 
        info->fix.type = FB_TYPE_PACKED_PIXELS;
        info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
index 67e37a6..8a8122f 100644 (file)
@@ -1264,7 +1264,7 @@ static int tdfxfb_setup_ddc_bus(struct tdfxfb_i2c_chan *chan, const char *name,
 {
        int rc;
 
-       strlcpy(chan->adapter.name, name, sizeof(chan->adapter.name));
+       strscpy(chan->adapter.name, name, sizeof(chan->adapter.name));
        chan->adapter.owner             = THIS_MODULE;
        chan->adapter.class             = I2C_CLASS_DDC;
        chan->adapter.algo_data         = &chan->algo;
@@ -1293,7 +1293,7 @@ static int tdfxfb_setup_i2c_bus(struct tdfxfb_i2c_chan *chan, const char *name,
 {
        int rc;
 
-       strlcpy(chan->adapter.name, name, sizeof(chan->adapter.name));
+       strscpy(chan->adapter.name, name, sizeof(chan->adapter.name));
        chan->adapter.owner             = THIS_MODULE;
        chan->adapter.algo_data         = &chan->algo;
        chan->adapter.dev.parent        = dev;
index ae0cf55..1fff5fd 100644 (file)
@@ -1344,7 +1344,7 @@ tgafb_init_fix(struct fb_info *info)
                memory_size = 16777216;
        }
 
-       strlcpy(info->fix.id, tga_type_name, sizeof(info->fix.id));
+       strscpy(info->fix.id, tga_type_name, sizeof(info->fix.id));
 
        info->fix.type = FB_TYPE_PACKED_PIXELS;
        info->fix.type_aux = 0;
index 319131b..cda0954 100644 (file)
@@ -270,7 +270,7 @@ static int tridentfb_setup_ddc_bus(struct fb_info *info)
 {
        struct tridentfb_par *par = info->par;
 
-       strlcpy(par->ddc_adapter.name, info->fix.id,
+       strscpy(par->ddc_adapter.name, info->fix.id,
                sizeof(par->ddc_adapter.name));
        par->ddc_adapter.owner          = THIS_MODULE;
        par->ddc_adapter.class          = I2C_CLASS_DDC;
index 738029d..e1ec725 100644 (file)
@@ -1047,6 +1047,9 @@ int gnttab_dma_alloc_pages(struct gnttab_dma_alloc_args *args)
        size_t size;
        int i, ret;
 
+       if (args->nr_pages < 0 || args->nr_pages > (INT_MAX >> PAGE_SHIFT))
+               return -ENOMEM;
+
        size = args->nr_pages << PAGE_SHIFT;
        if (args->coherent)
                args->vaddr = dma_alloc_coherent(args->dev, size,
index 3369734..e88e8f6 100644 (file)
@@ -581,27 +581,30 @@ static int lock_pages(
        struct privcmd_dm_op_buf kbufs[], unsigned int num,
        struct page *pages[], unsigned int nr_pages, unsigned int *pinned)
 {
-       unsigned int i;
+       unsigned int i, off = 0;
 
-       for (i = 0; i < num; i++) {
+       for (i = 0; i < num; ) {
                unsigned int requested;
                int page_count;
 
                requested = DIV_ROUND_UP(
                        offset_in_page(kbufs[i].uptr) + kbufs[i].size,
-                       PAGE_SIZE);
+                       PAGE_SIZE) - off;
                if (requested > nr_pages)
                        return -ENOSPC;
 
                page_count = pin_user_pages_fast(
-                       (unsigned long) kbufs[i].uptr,
+                       (unsigned long)kbufs[i].uptr + off * PAGE_SIZE,
                        requested, FOLL_WRITE, pages);
-               if (page_count < 0)
-                       return page_count;
+               if (page_count <= 0)
+                       return page_count ? : -EFAULT;
 
                *pinned += page_count;
                nr_pages -= page_count;
                pages += page_count;
+
+               off = (requested == page_count) ? 0 : off + page_count;
+               i += !off;
        }
 
        return 0;
@@ -677,10 +680,8 @@ static long privcmd_ioctl_dm_op(struct file *file, void __user *udata)
        }
 
        rc = lock_pages(kbufs, kdata.num, pages, nr_pages, &pinned);
-       if (rc < 0) {
-               nr_pages = pinned;
+       if (rc < 0)
                goto out;
-       }
 
        for (i = 0; i < kdata.num; i++) {
                set_xen_guest_handle(xbufs[i].h, kbufs[i].uptr);
@@ -692,7 +693,7 @@ static long privcmd_ioctl_dm_op(struct file *file, void __user *udata)
        xen_preemptible_hcall_end();
 
 out:
-       unlock_pages(pages, nr_pages);
+       unlock_pages(pages, pinned);
        kfree(xbufs);
        kfree(pages);
        kfree(kbufs);
index 7a0c93a..d3dcda3 100644 (file)
@@ -1121,7 +1121,7 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
                                "%s: writing %s", __func__, state);
                return;
        }
-       strlcpy(phy, val, VSCSI_NAMELEN);
+       strscpy(phy, val, VSCSI_NAMELEN);
        kfree(val);
 
        /* virtual SCSI device */
index 07b010a..f44d5a6 100644 (file)
@@ -40,7 +40,7 @@ static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename)
                return -EINVAL;
        }
 
-       strlcpy(bus_id, nodename + 1, XEN_BUS_ID_SIZE);
+       strscpy(bus_id, nodename + 1, XEN_BUS_ID_SIZE);
        if (!strchr(bus_id, '/')) {
                pr_warn("bus_id %s no slash\n", bus_id);
                return -EINVAL;
index c4210a3..bbcc5af 100644 (file)
@@ -76,7 +76,7 @@ void afs_lock_op_done(struct afs_call *call)
        if (call->error == 0) {
                spin_lock(&vnode->lock);
                trace_afs_flock_ev(vnode, NULL, afs_flock_timestamp, 0);
-               vnode->locked_at = call->reply_time;
+               vnode->locked_at = call->issue_time;
                afs_schedule_lock_extension(vnode);
                spin_unlock(&vnode->lock);
        }
index 4943413..7d37f63 100644 (file)
@@ -131,7 +131,7 @@ bad:
 
 static time64_t xdr_decode_expiry(struct afs_call *call, u32 expiry)
 {
-       return ktime_divns(call->reply_time, NSEC_PER_SEC) + expiry;
+       return ktime_divns(call->issue_time, NSEC_PER_SEC) + expiry;
 }
 
 static void xdr_decode_AFSCallBack(const __be32 **_bp,
index 64ad554..723d162 100644 (file)
@@ -137,7 +137,6 @@ struct afs_call {
        bool                    need_attention; /* T if RxRPC poked us */
        bool                    async;          /* T if asynchronous */
        bool                    upgrade;        /* T to request service upgrade */
-       bool                    have_reply_time; /* T if have got reply_time */
        bool                    intr;           /* T if interruptible */
        bool                    unmarshalling_error; /* T if an unmarshalling error occurred */
        u16                     service_id;     /* Actual service ID (after upgrade) */
@@ -151,7 +150,7 @@ struct afs_call {
                } __attribute__((packed));
                __be64          tmp64;
        };
-       ktime_t                 reply_time;     /* Time of first reply packet */
+       ktime_t                 issue_time;     /* Time of issue of operation */
 };
 
 struct afs_call_type {
index 933e67f..805328c 100644 (file)
@@ -69,6 +69,7 @@ int afs_abort_to_error(u32 abort_code)
                /* Unified AFS error table */
        case UAEPERM:                   return -EPERM;
        case UAENOENT:                  return -ENOENT;
+       case UAEAGAIN:                  return -EAGAIN;
        case UAEACCES:                  return -EACCES;
        case UAEBUSY:                   return -EBUSY;
        case UAEEXIST:                  return -EEXIST;
index d5c4785..eccc3cd 100644 (file)
@@ -351,6 +351,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)
        if (call->max_lifespan)
                rxrpc_kernel_set_max_life(call->net->socket, rxcall,
                                          call->max_lifespan);
+       call->issue_time = ktime_get_real();
 
        /* send the request */
        iov[0].iov_base = call->request;
@@ -501,12 +502,6 @@ static void afs_deliver_to_call(struct afs_call *call)
                        return;
                }
 
-               if (!call->have_reply_time &&
-                   rxrpc_kernel_get_reply_time(call->net->socket,
-                                               call->rxcall,
-                                               &call->reply_time))
-                       call->have_reply_time = true;
-
                ret = call->type->deliver(call);
                state = READ_ONCE(call->state);
                if (ret == 0 && call->unmarshalling_error)
index fdc7d67..11571cc 100644 (file)
@@ -232,8 +232,7 @@ static void xdr_decode_YFSCallBack(const __be32 **_bp,
        struct afs_callback *cb = &scb->callback;
        ktime_t cb_expiry;
 
-       cb_expiry = call->reply_time;
-       cb_expiry = ktime_add(cb_expiry, xdr_to_u64(x->expiration_time) * 100);
+       cb_expiry = ktime_add(call->issue_time, xdr_to_u64(x->expiration_time) * 100);
        cb->expires_at  = ktime_divns(cb_expiry, NSEC_PER_SEC);
        scb->have_cb    = true;
        *_bp += xdr_size(x);
index 993aca2..e0375ba 100644 (file)
@@ -440,39 +440,26 @@ void btrfs_wait_block_group_cache_progress(struct btrfs_block_group *cache,
        btrfs_put_caching_control(caching_ctl);
 }
 
-int btrfs_wait_block_group_cache_done(struct btrfs_block_group *cache)
+static int btrfs_caching_ctl_wait_done(struct btrfs_block_group *cache,
+                                      struct btrfs_caching_control *caching_ctl)
+{
+       wait_event(caching_ctl->wait, btrfs_block_group_done(cache));
+       return cache->cached == BTRFS_CACHE_ERROR ? -EIO : 0;
+}
+
+static int btrfs_wait_block_group_cache_done(struct btrfs_block_group *cache)
 {
        struct btrfs_caching_control *caching_ctl;
-       int ret = 0;
+       int ret;
 
        caching_ctl = btrfs_get_caching_control(cache);
        if (!caching_ctl)
                return (cache->cached == BTRFS_CACHE_ERROR) ? -EIO : 0;
-
-       wait_event(caching_ctl->wait, btrfs_block_group_done(cache));
-       if (cache->cached == BTRFS_CACHE_ERROR)
-               ret = -EIO;
+       ret = btrfs_caching_ctl_wait_done(cache, caching_ctl);
        btrfs_put_caching_control(caching_ctl);
        return ret;
 }
 
-static bool space_cache_v1_done(struct btrfs_block_group *cache)
-{
-       bool ret;
-
-       spin_lock(&cache->lock);
-       ret = cache->cached != BTRFS_CACHE_FAST;
-       spin_unlock(&cache->lock);
-
-       return ret;
-}
-
-void btrfs_wait_space_cache_v1_finished(struct btrfs_block_group *cache,
-                               struct btrfs_caching_control *caching_ctl)
-{
-       wait_event(caching_ctl->wait, space_cache_v1_done(cache));
-}
-
 #ifdef CONFIG_BTRFS_DEBUG
 static void fragment_free_space(struct btrfs_block_group *block_group)
 {
@@ -750,9 +737,8 @@ done:
        btrfs_put_block_group(block_group);
 }
 
-int btrfs_cache_block_group(struct btrfs_block_group *cache, int load_cache_only)
+int btrfs_cache_block_group(struct btrfs_block_group *cache, bool wait)
 {
-       DEFINE_WAIT(wait);
        struct btrfs_fs_info *fs_info = cache->fs_info;
        struct btrfs_caching_control *caching_ctl = NULL;
        int ret = 0;
@@ -785,10 +771,7 @@ int btrfs_cache_block_group(struct btrfs_block_group *cache, int load_cache_only
        }
        WARN_ON(cache->caching_ctl);
        cache->caching_ctl = caching_ctl;
-       if (btrfs_test_opt(fs_info, SPACE_CACHE))
-               cache->cached = BTRFS_CACHE_FAST;
-       else
-               cache->cached = BTRFS_CACHE_STARTED;
+       cache->cached = BTRFS_CACHE_STARTED;
        cache->has_caching_ctl = 1;
        spin_unlock(&cache->lock);
 
@@ -801,8 +784,8 @@ int btrfs_cache_block_group(struct btrfs_block_group *cache, int load_cache_only
 
        btrfs_queue_work(fs_info->caching_workers, &caching_ctl->work);
 out:
-       if (load_cache_only && caching_ctl)
-               btrfs_wait_space_cache_v1_finished(cache, caching_ctl);
+       if (wait && caching_ctl)
+               ret = btrfs_caching_ctl_wait_done(cache, caching_ctl);
        if (caching_ctl)
                btrfs_put_caching_control(caching_ctl);
 
@@ -3312,7 +3295,7 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
                 * space back to the block group, otherwise we will leak space.
                 */
                if (!alloc && !btrfs_block_group_done(cache))
-                       btrfs_cache_block_group(cache, 1);
+                       btrfs_cache_block_group(cache, true);
 
                byte_in_group = bytenr - cache->start;
                WARN_ON(byte_in_group > cache->length);
index 35e0e86..6b3cdc4 100644 (file)
@@ -263,9 +263,7 @@ void btrfs_dec_nocow_writers(struct btrfs_block_group *bg);
 void btrfs_wait_nocow_writers(struct btrfs_block_group *bg);
 void btrfs_wait_block_group_cache_progress(struct btrfs_block_group *cache,
                                           u64 num_bytes);
-int btrfs_wait_block_group_cache_done(struct btrfs_block_group *cache);
-int btrfs_cache_block_group(struct btrfs_block_group *cache,
-                           int load_cache_only);
+int btrfs_cache_block_group(struct btrfs_block_group *cache, bool wait);
 void btrfs_put_caching_control(struct btrfs_caching_control *ctl);
 struct btrfs_caching_control *btrfs_get_caching_control(
                struct btrfs_block_group *cache);
index 4edb4bf..9ef162d 100644 (file)
@@ -505,7 +505,6 @@ struct btrfs_free_cluster {
 enum btrfs_caching_type {
        BTRFS_CACHE_NO,
        BTRFS_CACHE_STARTED,
-       BTRFS_CACHE_FAST,
        BTRFS_CACHE_FINISHED,
        BTRFS_CACHE_ERROR,
 };
index f43196a..41cddd3 100644 (file)
@@ -165,7 +165,7 @@ no_valid_dev_replace_entry_found:
                 */
                if (btrfs_find_device(fs_info->fs_devices, &args)) {
                        btrfs_err(fs_info,
-                       "replace devid present without an active replace item");
+"replace without active item, run 'device scan --forget' on the target device");
                        ret = -EUCLEAN;
                } else {
                        dev_replace->srcdev = NULL;
@@ -1129,8 +1129,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
                up_write(&dev_replace->rwsem);
 
                /* Scrub for replace must not be running in suspended state */
-               ret = btrfs_scrub_cancel(fs_info);
-               ASSERT(ret != -ENOTCONN);
+               btrfs_scrub_cancel(fs_info);
 
                trans = btrfs_start_transaction(root, 0);
                if (IS_ERR(trans)) {
index ab944d1..6914cd8 100644 (file)
@@ -2551,17 +2551,10 @@ int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
                return -EINVAL;
 
        /*
-        * pull in the free space cache (if any) so that our pin
-        * removes the free space from the cache.  We have load_only set
-        * to one because the slow code to read in the free extents does check
-        * the pinned extents.
+        * Fully cache the free space first so that our pin removes the free space
+        * from the cache.
         */
-       btrfs_cache_block_group(cache, 1);
-       /*
-        * Make sure we wait until the cache is completely built in case it is
-        * missing or is invalid and therefore needs to be rebuilt.
-        */
-       ret = btrfs_wait_block_group_cache_done(cache);
+       ret = btrfs_cache_block_group(cache, true);
        if (ret)
                goto out;
 
@@ -2584,12 +2577,7 @@ static int __exclude_logged_extent(struct btrfs_fs_info *fs_info,
        if (!block_group)
                return -EINVAL;
 
-       btrfs_cache_block_group(block_group, 1);
-       /*
-        * Make sure we wait until the cache is completely built in case it is
-        * missing or is invalid and therefore needs to be rebuilt.
-        */
-       ret = btrfs_wait_block_group_cache_done(block_group);
+       ret = btrfs_cache_block_group(block_group, true);
        if (ret)
                goto out;
 
@@ -4399,7 +4387,7 @@ have_block_group:
                ffe_ctl->cached = btrfs_block_group_done(block_group);
                if (unlikely(!ffe_ctl->cached)) {
                        ffe_ctl->have_caching_bg = true;
-                       ret = btrfs_cache_block_group(block_group, 0);
+                       ret = btrfs_cache_block_group(block_group, false);
 
                        /*
                         * If we get ENOMEM here or something else we want to
@@ -6169,13 +6157,7 @@ int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)
 
                if (end - start >= range->minlen) {
                        if (!btrfs_block_group_done(cache)) {
-                               ret = btrfs_cache_block_group(cache, 0);
-                               if (ret) {
-                                       bg_failed++;
-                                       bg_ret = ret;
-                                       continue;
-                               }
-                               ret = btrfs_wait_block_group_cache_done(cache);
+                               ret = btrfs_cache_block_group(cache, true);
                                if (ret) {
                                        bg_failed++;
                                        bg_ret = ret;
index eed81a7..cf4f19e 100644 (file)
@@ -3233,7 +3233,7 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl,
        u32 bio_size = bio->bi_iter.bi_size;
        u32 real_size;
        const sector_t sector = disk_bytenr >> SECTOR_SHIFT;
-       bool contig;
+       bool contig = false;
        int ret;
 
        ASSERT(bio);
@@ -3242,10 +3242,35 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl,
        if (bio_ctrl->compress_type != compress_type)
                return 0;
 
-       if (bio_ctrl->compress_type != BTRFS_COMPRESS_NONE)
+
+       if (bio->bi_iter.bi_size == 0) {
+               /* We can always add a page into an empty bio. */
+               contig = true;
+       } else if (bio_ctrl->compress_type == BTRFS_COMPRESS_NONE) {
+               struct bio_vec *bvec = bio_last_bvec_all(bio);
+
+               /*
+                * The contig check requires the following conditions to be met:
+                * 1) The pages are belonging to the same inode
+                *    This is implied by the call chain.
+                *
+                * 2) The range has adjacent logical bytenr
+                *
+                * 3) The range has adjacent file offset
+                *    This is required for the usage of btrfs_bio->file_offset.
+                */
+               if (bio_end_sector(bio) == sector &&
+                   page_offset(bvec->bv_page) + bvec->bv_offset +
+                   bvec->bv_len == page_offset(page) + pg_offset)
+                       contig = true;
+       } else {
+               /*
+                * For compression, all IO should have its logical bytenr
+                * set to the starting bytenr of the compressed extent.
+                */
                contig = bio->bi_iter.bi_sector == sector;
-       else
-               contig = bio_end_sector(bio) == sector;
+       }
+
        if (!contig)
                return 0;
 
index 66c8221..5a3f6e0 100644 (file)
@@ -2482,6 +2482,7 @@ static int fill_holes(struct btrfs_trans_handle *trans,
                btrfs_set_file_extent_num_bytes(leaf, fi, num_bytes);
                btrfs_set_file_extent_ram_bytes(leaf, fi, num_bytes);
                btrfs_set_file_extent_offset(leaf, fi, 0);
+               btrfs_set_file_extent_generation(leaf, fi, trans->transid);
                btrfs_mark_buffer_dirty(leaf);
                goto out;
        }
@@ -2498,6 +2499,7 @@ static int fill_holes(struct btrfs_trans_handle *trans,
                btrfs_set_file_extent_num_bytes(leaf, fi, num_bytes);
                btrfs_set_file_extent_ram_bytes(leaf, fi, num_bytes);
                btrfs_set_file_extent_offset(leaf, fi, 0);
+               btrfs_set_file_extent_generation(leaf, fi, trans->transid);
                btrfs_mark_buffer_dirty(leaf);
                goto out;
        }
index f0c97d2..ad25089 100644 (file)
@@ -7694,6 +7694,20 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
        bool unlock_extents = false;
 
        /*
+        * We could potentially fault if we have a buffer > PAGE_SIZE, and if
+        * we're NOWAIT we may submit a bio for a partial range and return
+        * EIOCBQUEUED, which would result in an errant short read.
+        *
+        * The best way to handle this would be to allow for partial completions
+        * of iocb's, so we could submit the partial bio, return and fault in
+        * the rest of the pages, and then submit the io for the rest of the
+        * range.  However we don't have that currently, so simply return
+        * -EAGAIN at this point so that the normal path is used.
+        */
+       if (!write && (flags & IOMAP_NOWAIT) && length > PAGE_SIZE)
+               return -EAGAIN;
+
+       /*
         * Cap the size of reads to that usually seen in buffered I/O as we need
         * to allocate a contiguous array for the checksums.
         */
index a64b26b..d647cb2 100644 (file)
@@ -349,9 +349,10 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
        key.offset = ref_id;
 again:
        ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1);
-       if (ret < 0)
+       if (ret < 0) {
+               err = ret;
                goto out;
-       if (ret == 0) {
+       } else if (ret == 0) {
                leaf = path->nodes[0];
                ref = btrfs_item_ptr(leaf, path->slots[0],
                                     struct btrfs_root_ref);
index 2729015..064ab2a 100644 (file)
@@ -2345,8 +2345,11 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info,
 
        ret = btrfs_get_bdev_and_sb(path, FMODE_READ, fs_info->bdev_holder, 0,
                                    &bdev, &disk_super);
-       if (ret)
+       if (ret) {
+               btrfs_put_dev_args_from_path(args);
                return ret;
+       }
+
        args->devid = btrfs_stack_device_id(&disk_super->dev_item);
        memcpy(args->uuid, disk_super->dev_item.uuid, BTRFS_UUID_SIZE);
        if (btrfs_fs_incompat(fs_info, METADATA_UUID))
index 7421abc..5bb8d8c 100644 (file)
@@ -371,6 +371,9 @@ static int btrfs_xattr_handler_set(const struct xattr_handler *handler,
                                   const char *name, const void *buffer,
                                   size_t size, int flags)
 {
+       if (btrfs_root_readonly(BTRFS_I(inode)->root))
+               return -EROFS;
+
        name = xattr_full_name(handler, name);
        return btrfs_setxattr_trans(inode, name, buffer, size, flags);
 }
index 6cba2c6..2ad58c4 100644 (file)
@@ -111,6 +111,7 @@ struct cachefiles_cache {
        char                            *tag;           /* cache binding tag */
        refcount_t                      unbind_pincount;/* refcount to do daemon unbind */
        struct xarray                   reqs;           /* xarray of pending on-demand requests */
+       unsigned long                   req_id_next;
        struct xarray                   ondemand_ids;   /* xarray for ondemand_id allocation */
        u32                             ondemand_id_next;
 };
index 1fee702..0254ed3 100644 (file)
@@ -158,9 +158,13 @@ int cachefiles_ondemand_copen(struct cachefiles_cache *cache, char *args)
 
        /* fail OPEN request if daemon reports an error */
        if (size < 0) {
-               if (!IS_ERR_VALUE(size))
-                       size = -EINVAL;
-               req->error = size;
+               if (!IS_ERR_VALUE(size)) {
+                       req->error = -EINVAL;
+                       ret = -EINVAL;
+               } else {
+                       req->error = size;
+                       ret = 0;
+               }
                goto out;
        }
 
@@ -238,14 +242,19 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
        unsigned long id = 0;
        size_t n;
        int ret = 0;
-       XA_STATE(xas, &cache->reqs, 0);
+       XA_STATE(xas, &cache->reqs, cache->req_id_next);
 
        /*
-        * Search for a request that has not ever been processed, to prevent
-        * requests from being processed repeatedly.
+        * Cyclically search for a request that has not ever been processed,
+        * to prevent requests from being processed repeatedly, and make
+        * request distribution fair.
         */
        xa_lock(&cache->reqs);
        req = xas_find_marked(&xas, UINT_MAX, CACHEFILES_REQ_NEW);
+       if (!req && cache->req_id_next > 0) {
+               xas_set(&xas, 0);
+               req = xas_find_marked(&xas, cache->req_id_next - 1, CACHEFILES_REQ_NEW);
+       }
        if (!req) {
                xa_unlock(&cache->reqs);
                return 0;
@@ -260,6 +269,7 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
        }
 
        xas_clear_mark(&xas, CACHEFILES_REQ_NEW);
+       cache->req_id_next = xas.xa_index + 1;
        xa_unlock(&cache->reqs);
 
        id = xas.xa_index;
index 8f7835c..46f5718 100644 (file)
@@ -32,10 +32,9 @@ int __cifs_calc_signature(struct smb_rqst *rqst,
        int rc;
        struct kvec *iov = rqst->rq_iov;
        int n_vec = rqst->rq_nvec;
-       int is_smb2 = server->vals->header_preamble_size == 0;
 
        /* iov[0] is actual data and not the rfc1002 length for SMB2+ */
-       if (is_smb2) {
+       if (!is_smb1(server)) {
                if (iov[0].iov_len <= 4)
                        return -EIO;
                i = 0;
index f54d8bf..8042d72 100644 (file)
@@ -1248,6 +1248,12 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
        lock_two_nondirectories(target_inode, src_inode);
 
        cifs_dbg(FYI, "about to flush pages\n");
+
+       rc = filemap_write_and_wait_range(src_inode->i_mapping, off,
+                                         off + len - 1);
+       if (rc)
+               goto out;
+
        /* should we flush first and last page first */
        truncate_inode_pages(&target_inode->i_data, 0);
 
index f15d7b0..ae7f571 100644 (file)
@@ -557,6 +557,8 @@ struct smb_version_values {
 
 #define HEADER_SIZE(server) (server->vals->header_size)
 #define MAX_HEADER_SIZE(server) (server->vals->max_header_size)
+#define HEADER_PREAMBLE_SIZE(server) (server->vals->header_preamble_size)
+#define MID_HEADER_SIZE(server) (HEADER_SIZE(server) - 1 - HEADER_PREAMBLE_SIZE(server))
 
 /**
  * CIFS superblock mount flags (mnt_cifs_flags) to consider when
@@ -750,6 +752,11 @@ struct TCP_Server_Info {
 #endif
 };
 
+static inline bool is_smb1(struct TCP_Server_Info *server)
+{
+       return HEADER_PREAMBLE_SIZE(server) != 0;
+}
+
 static inline void cifs_server_lock(struct TCP_Server_Info *server)
 {
        unsigned int nofs_flag = memalloc_nofs_save();
index 3da5da9..a0a06b6 100644 (file)
@@ -871,7 +871,7 @@ smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
        /*
         * SMB1 does not use credits.
         */
-       if (server->vals->header_preamble_size)
+       if (is_smb1(server))
                return 0;
 
        return le16_to_cpu(shdr->CreditRequest);
@@ -1050,7 +1050,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
 
        /* make sure this will fit in a large buffer */
        if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) -
-               server->vals->header_preamble_size) {
+           HEADER_PREAMBLE_SIZE(server)) {
                cifs_server_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
                cifs_reconnect(server, true);
                return -ECONNABORTED;
@@ -1065,8 +1065,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
 
        /* now read the rest */
        length = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1,
-                                      pdu_length - HEADER_SIZE(server) + 1
-                                      + server->vals->header_preamble_size);
+                                      pdu_length - MID_HEADER_SIZE(server));
 
        if (length < 0)
                return length;
@@ -1122,7 +1121,7 @@ smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
        /*
         * SMB1 does not use credits.
         */
-       if (server->vals->header_preamble_size)
+       if (is_smb1(server))
                return;
 
        if (shdr->CreditRequest) {
@@ -1180,10 +1179,10 @@ cifs_demultiplex_thread(void *p)
                if (length < 0)
                        continue;
 
-               if (server->vals->header_preamble_size == 0)
-                       server->total_read = 0;
-               else
+               if (is_smb1(server))
                        server->total_read = length;
+               else
+                       server->total_read = 0;
 
                /*
                 * The right amount was read from socket - 4 bytes,
@@ -1198,8 +1197,7 @@ next_pdu:
                server->pdu_size = pdu_length;
 
                /* make sure we have enough to get to the MID */
-               if (server->pdu_size < HEADER_SIZE(server) - 1 -
-                   server->vals->header_preamble_size) {
+               if (server->pdu_size < MID_HEADER_SIZE(server)) {
                        cifs_server_dbg(VFS, "SMB response too short (%u bytes)\n",
                                 server->pdu_size);
                        cifs_reconnect(server, true);
@@ -1208,9 +1206,8 @@ next_pdu:
 
                /* read down to the MID */
                length = cifs_read_from_socket(server,
-                            buf + server->vals->header_preamble_size,
-                            HEADER_SIZE(server) - 1
-                            - server->vals->header_preamble_size);
+                            buf + HEADER_PREAMBLE_SIZE(server),
+                            MID_HEADER_SIZE(server));
                if (length < 0)
                        continue;
                server->total_read += length;
index 96f3b05..421be43 100644 (file)
@@ -1600,17 +1600,8 @@ smb2_copychunk_range(const unsigned int xid,
        int chunks_copied = 0;
        bool chunk_sizes_updated = false;
        ssize_t bytes_written, total_bytes_written = 0;
-       struct inode *inode;
 
        pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL);
-
-       /*
-        * We need to flush all unwritten data before we can send the
-        * copychunk ioctl to the server.
-        */
-       inode = d_inode(trgtfile->dentry);
-       filemap_write_and_wait(inode->i_mapping);
-
        if (pcchunk == NULL)
                return -ENOMEM;
 
@@ -3307,26 +3298,43 @@ get_smb2_acl(struct cifs_sb_info *cifs_sb,
        return pntsd;
 }
 
+static long smb3_zero_data(struct file *file, struct cifs_tcon *tcon,
+                            loff_t offset, loff_t len, unsigned int xid)
+{
+       struct cifsFileInfo *cfile = file->private_data;
+       struct file_zero_data_information fsctl_buf;
+
+       cifs_dbg(FYI, "Offset %lld len %lld\n", offset, len);
+
+       fsctl_buf.FileOffset = cpu_to_le64(offset);
+       fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
+
+       return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
+                         cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
+                         (char *)&fsctl_buf,
+                         sizeof(struct file_zero_data_information),
+                         0, NULL, NULL);
+}
+
 static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
                            loff_t offset, loff_t len, bool keep_size)
 {
        struct cifs_ses *ses = tcon->ses;
-       struct inode *inode;
-       struct cifsInodeInfo *cifsi;
+       struct inode *inode = file_inode(file);
+       struct cifsInodeInfo *cifsi = CIFS_I(inode);
        struct cifsFileInfo *cfile = file->private_data;
-       struct file_zero_data_information fsctl_buf;
        long rc;
        unsigned int xid;
        __le64 eof;
 
        xid = get_xid();
 
-       inode = d_inode(cfile->dentry);
-       cifsi = CIFS_I(inode);
-
        trace_smb3_zero_enter(xid, cfile->fid.persistent_fid, tcon->tid,
                              ses->Suid, offset, len);
 
+       inode_lock(inode);
+       filemap_invalidate_lock(inode->i_mapping);
+
        /*
         * We zero the range through ioctl, so we need remove the page caches
         * first, otherwise the data may be inconsistent with the server.
@@ -3334,26 +3342,12 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
        truncate_pagecache_range(inode, offset, offset + len - 1);
 
        /* if file not oplocked can't be sure whether asking to extend size */
-       if (!CIFS_CACHE_READ(cifsi))
-               if (keep_size == false) {
-                       rc = -EOPNOTSUPP;
-                       trace_smb3_zero_err(xid, cfile->fid.persistent_fid,
-                               tcon->tid, ses->Suid, offset, len, rc);
-                       free_xid(xid);
-                       return rc;
-               }
-
-       cifs_dbg(FYI, "Offset %lld len %lld\n", offset, len);
-
-       fsctl_buf.FileOffset = cpu_to_le64(offset);
-       fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
+       rc = -EOPNOTSUPP;
+       if (keep_size == false && !CIFS_CACHE_READ(cifsi))
+               goto zero_range_exit;
 
-       rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
-                       cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
-                       (char *)&fsctl_buf,
-                       sizeof(struct file_zero_data_information),
-                       0, NULL, NULL);
-       if (rc)
+       rc = smb3_zero_data(file, tcon, offset, len, xid);
+       if (rc < 0)
                goto zero_range_exit;
 
        /*
@@ -3366,6 +3360,8 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
        }
 
  zero_range_exit:
+       filemap_invalidate_unlock(inode->i_mapping);
+       inode_unlock(inode);
        free_xid(xid);
        if (rc)
                trace_smb3_zero_err(xid, cfile->fid.persistent_fid, tcon->tid,
@@ -3379,7 +3375,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
 static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
                            loff_t offset, loff_t len)
 {
-       struct inode *inode;
+       struct inode *inode = file_inode(file);
        struct cifsFileInfo *cfile = file->private_data;
        struct file_zero_data_information fsctl_buf;
        long rc;
@@ -3388,14 +3384,12 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
 
        xid = get_xid();
 
-       inode = d_inode(cfile->dentry);
-
+       inode_lock(inode);
        /* Need to make file sparse, if not already, before freeing range. */
        /* Consider adding equivalent for compressed since it could also work */
        if (!smb2_set_sparse(xid, tcon, cfile, inode, set_sparse)) {
                rc = -EOPNOTSUPP;
-               free_xid(xid);
-               return rc;
+               goto out;
        }
 
        filemap_invalidate_lock(inode->i_mapping);
@@ -3415,8 +3409,10 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
                        (char *)&fsctl_buf,
                        sizeof(struct file_zero_data_information),
                        CIFSMaxBufSize, NULL, NULL);
-       free_xid(xid);
        filemap_invalidate_unlock(inode->i_mapping);
+out:
+       inode_unlock(inode);
+       free_xid(xid);
        return rc;
 }
 
@@ -3673,39 +3669,50 @@ static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon,
 {
        int rc;
        unsigned int xid;
-       struct inode *inode;
+       struct inode *inode = file_inode(file);
        struct cifsFileInfo *cfile = file->private_data;
-       struct cifsInodeInfo *cifsi;
+       struct cifsInodeInfo *cifsi = CIFS_I(inode);
        __le64 eof;
+       loff_t old_eof;
 
        xid = get_xid();
 
-       inode = d_inode(cfile->dentry);
-       cifsi = CIFS_I(inode);
+       inode_lock(inode);
 
-       if (off >= i_size_read(inode) ||
-           off + len >= i_size_read(inode)) {
+       old_eof = i_size_read(inode);
+       if ((off >= old_eof) ||
+           off + len >= old_eof) {
                rc = -EINVAL;
                goto out;
        }
 
+       filemap_invalidate_lock(inode->i_mapping);
+       rc = filemap_write_and_wait_range(inode->i_mapping, off, old_eof - 1);
+       if (rc < 0)
+               goto out_2;
+
+       truncate_pagecache_range(inode, off, old_eof);
+
        rc = smb2_copychunk_range(xid, cfile, cfile, off + len,
-                                 i_size_read(inode) - off - len, off);
+                                 old_eof - off - len, off);
        if (rc < 0)
-               goto out;
+               goto out_2;
 
-       eof = cpu_to_le64(i_size_read(inode) - len);
+       eof = cpu_to_le64(old_eof - len);
        rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
                          cfile->fid.volatile_fid, cfile->pid, &eof);
        if (rc < 0)
-               goto out;
+               goto out_2;
 
        rc = 0;
 
        cifsi->server_eof = i_size_read(inode) - len;
        truncate_setsize(inode, cifsi->server_eof);
        fscache_resize_cookie(cifs_inode_cookie(inode), cifsi->server_eof);
+out_2:
+       filemap_invalidate_unlock(inode->i_mapping);
  out:
+       inode_unlock(inode);
        free_xid(xid);
        return rc;
 }
@@ -3716,34 +3723,47 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon,
        int rc;
        unsigned int xid;
        struct cifsFileInfo *cfile = file->private_data;
+       struct inode *inode = file_inode(file);
        __le64 eof;
-       __u64  count;
+       __u64  count, old_eof;
 
        xid = get_xid();
 
-       if (off >= i_size_read(file->f_inode)) {
+       inode_lock(inode);
+
+       old_eof = i_size_read(inode);
+       if (off >= old_eof) {
                rc = -EINVAL;
                goto out;
        }
 
-       count = i_size_read(file->f_inode) - off;
-       eof = cpu_to_le64(i_size_read(file->f_inode) + len);
+       count = old_eof - off;
+       eof = cpu_to_le64(old_eof + len);
+
+       filemap_invalidate_lock(inode->i_mapping);
+       rc = filemap_write_and_wait_range(inode->i_mapping, off, old_eof + len - 1);
+       if (rc < 0)
+               goto out_2;
+       truncate_pagecache_range(inode, off, old_eof);
 
        rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
                          cfile->fid.volatile_fid, cfile->pid, &eof);
        if (rc < 0)
-               goto out;
+               goto out_2;
 
        rc = smb2_copychunk_range(xid, cfile, cfile, off, count, off + len);
        if (rc < 0)
-               goto out;
+               goto out_2;
 
-       rc = smb3_zero_range(file, tcon, off, len, 1);
+       rc = smb3_zero_data(file, tcon, off, len, xid);
        if (rc < 0)
-               goto out;
+               goto out_2;
 
        rc = 0;
+out_2:
+       filemap_invalidate_unlock(inode->i_mapping);
  out:
+       inode_unlock(inode);
        free_xid(xid);
        return rc;
 }
index 91cfc5b..6352ab3 100644 (file)
@@ -965,16 +965,17 @@ SMB2_negotiate(const unsigned int xid,
        } else if (rc != 0)
                goto neg_exit;
 
+       rc = -EIO;
        if (strcmp(server->vals->version_string,
                   SMB3ANY_VERSION_STRING) == 0) {
                if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
                        cifs_server_dbg(VFS,
                                "SMB2 dialect returned but not requested\n");
-                       return -EIO;
+                       goto neg_exit;
                } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
                        cifs_server_dbg(VFS,
                                "SMB2.1 dialect returned but not requested\n");
-                       return -EIO;
+                       goto neg_exit;
                } else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) {
                        /* ops set to 3.0 by default for default so update */
                        server->ops = &smb311_operations;
@@ -985,7 +986,7 @@ SMB2_negotiate(const unsigned int xid,
                if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
                        cifs_server_dbg(VFS,
                                "SMB2 dialect returned but not requested\n");
-                       return -EIO;
+                       goto neg_exit;
                } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
                        /* ops set to 3.0 by default for default so update */
                        server->ops = &smb21_operations;
@@ -999,7 +1000,7 @@ SMB2_negotiate(const unsigned int xid,
                /* if requested single dialect ensure returned dialect matched */
                cifs_server_dbg(VFS, "Invalid 0x%x dialect returned: not requested\n",
                                le16_to_cpu(rsp->DialectRevision));
-               return -EIO;
+               goto neg_exit;
        }
 
        cifs_dbg(FYI, "mode 0x%x\n", rsp->SecurityMode);
@@ -1017,9 +1018,10 @@ SMB2_negotiate(const unsigned int xid,
        else {
                cifs_server_dbg(VFS, "Invalid dialect returned by server 0x%x\n",
                                le16_to_cpu(rsp->DialectRevision));
-               rc = -EIO;
                goto neg_exit;
        }
+
+       rc = 0;
        server->dialect = le16_to_cpu(rsp->DialectRevision);
 
        /*
@@ -2572,19 +2574,15 @@ alloc_path_with_tree_prefix(__le16 **out_path, int *out_size, int *out_len,
 
        path_len = UniStrnlen((wchar_t *)path, PATH_MAX);
 
-       /*
-        * make room for one path separator between the treename and
-        * path
-        */
-       *out_len = treename_len + 1 + path_len;
+       /* make room for one path separator only if @path isn't empty */
+       *out_len = treename_len + (path[0] ? 1 : 0) + path_len;
 
        /*
-        * final path needs to be null-terminated UTF16 with a
-        * size aligned to 8
+        * final path needs to be 8-byte aligned as specified in
+        * MS-SMB2 2.2.13 SMB2 CREATE Request.
         */
-
-       *out_size = roundup((*out_len+1)*2, 8);
-       *out_path = kzalloc(*out_size, GFP_KERNEL);
+       *out_size = roundup(*out_len * sizeof(__le16), 8);
+       *out_path = kzalloc(*out_size + sizeof(__le16) /* null */, GFP_KERNEL);
        if (!*out_path)
                return -ENOMEM;
 
index de7aece..c2fe035 100644 (file)
@@ -261,8 +261,8 @@ smb_rqst_len(struct TCP_Server_Info *server, struct smb_rqst *rqst)
        int nvec;
        unsigned long buflen = 0;
 
-       if (server->vals->header_preamble_size == 0 &&
-           rqst->rq_nvec >= 2 && rqst->rq_iov[0].iov_len == 4) {
+       if (!is_smb1(server) && rqst->rq_nvec >= 2 &&
+           rqst->rq_iov[0].iov_len == 4) {
                iov = &rqst->rq_iov[1];
                nvec = rqst->rq_nvec - 1;
        } else {
@@ -346,7 +346,7 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
        sigprocmask(SIG_BLOCK, &mask, &oldmask);
 
        /* Generate a rfc1002 marker for SMB2+ */
-       if (server->vals->header_preamble_size == 0) {
+       if (!is_smb1(server)) {
                struct kvec hiov = {
                        .iov_base = &rfc1002_marker,
                        .iov_len  = 4
@@ -1238,7 +1238,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
                buf = (char *)midQ[i]->resp_buf;
                resp_iov[i].iov_base = buf;
                resp_iov[i].iov_len = midQ[i]->resp_buf_size +
-                       server->vals->header_preamble_size;
+                       HEADER_PREAMBLE_SIZE(server);
 
                if (midQ[i]->large_buf)
                        resp_buf_type[i] = CIFS_LARGE_BUFFER;
@@ -1643,7 +1643,7 @@ int
 cifs_discard_remaining_data(struct TCP_Server_Info *server)
 {
        unsigned int rfclen = server->pdu_size;
-       int remaining = rfclen + server->vals->header_preamble_size -
+       int remaining = rfclen + HEADER_PREAMBLE_SIZE(server) -
                server->total_read;
 
        while (remaining > 0) {
@@ -1689,8 +1689,7 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
        unsigned int data_offset, data_len;
        struct cifs_readdata *rdata = mid->callback_data;
        char *buf = server->smallbuf;
-       unsigned int buflen = server->pdu_size +
-               server->vals->header_preamble_size;
+       unsigned int buflen = server->pdu_size + HEADER_PREAMBLE_SIZE(server);
        bool use_rdma_mr = false;
 
        cifs_dbg(FYI, "%s: mid=%llu offset=%llu bytes=%u\n",
@@ -1724,10 +1723,10 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
 
        /* set up first two iov for signature check and to get credits */
        rdata->iov[0].iov_base = buf;
-       rdata->iov[0].iov_len = server->vals->header_preamble_size;
-       rdata->iov[1].iov_base = buf + server->vals->header_preamble_size;
+       rdata->iov[0].iov_len = HEADER_PREAMBLE_SIZE(server);
+       rdata->iov[1].iov_base = buf + HEADER_PREAMBLE_SIZE(server);
        rdata->iov[1].iov_len =
-               server->total_read - server->vals->header_preamble_size;
+               server->total_read - HEADER_PREAMBLE_SIZE(server);
        cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n",
                 rdata->iov[0].iov_base, rdata->iov[0].iov_len);
        cifs_dbg(FYI, "1: iov_base=%p iov_len=%zu\n",
@@ -1752,7 +1751,7 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
        }
 
        data_offset = server->ops->read_data_offset(buf) +
-               server->vals->header_preamble_size;
+               HEADER_PREAMBLE_SIZE(server);
        if (data_offset < server->total_read) {
                /*
                 * win2k8 sometimes sends an offset of 0 when the read
index 8e01d89..b5fd9d7 100644 (file)
@@ -222,8 +222,10 @@ static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
 
        rreq = erofs_fscache_alloc_request(folio_mapping(folio),
                                folio_pos(folio), folio_size(folio));
-       if (IS_ERR(rreq))
+       if (IS_ERR(rreq)) {
+               ret = PTR_ERR(rreq);
                goto out;
+       }
 
        return erofs_fscache_read_folios_async(mdev.m_fscache->cookie,
                                rreq, mdev.m_pa);
@@ -301,8 +303,10 @@ static int erofs_fscache_read_folio(struct file *file, struct folio *folio)
 
        rreq = erofs_fscache_alloc_request(folio_mapping(folio),
                                folio_pos(folio), folio_size(folio));
-       if (IS_ERR(rreq))
+       if (IS_ERR(rreq)) {
+               ret = PTR_ERR(rreq);
                goto out_unlock;
+       }
 
        pstart = mdev.m_pa + (pos - map.m_la);
        return erofs_fscache_read_folios_async(mdev.m_fscache->cookie,
index cfee49d..a01cc82 100644 (file)
@@ -195,7 +195,6 @@ struct erofs_workgroup {
        atomic_t refcount;
 };
 
-#if defined(CONFIG_SMP)
 static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp,
                                                 int val)
 {
@@ -224,34 +223,6 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
        return atomic_cond_read_relaxed(&grp->refcount,
                                        VAL != EROFS_LOCKED_MAGIC);
 }
-#else
-static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp,
-                                                int val)
-{
-       preempt_disable();
-       /* no need to spin on UP platforms, let's just disable preemption. */
-       if (val != atomic_read(&grp->refcount)) {
-               preempt_enable();
-               return false;
-       }
-       return true;
-}
-
-static inline void erofs_workgroup_unfreeze(struct erofs_workgroup *grp,
-                                           int orig_val)
-{
-       preempt_enable();
-}
-
-static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
-{
-       int v = atomic_read(&grp->refcount);
-
-       /* workgroup is never freezed on uniprocessor systems */
-       DBG_BUGON(v == EROFS_LOCKED_MAGIC);
-       return v;
-}
-#endif /* !CONFIG_SMP */
 #endif /* !CONFIG_EROFS_FS_ZIP */
 
 /* we strictly follow PAGE_SIZE and no buffer head yet */
index 572f0b8..d58549c 100644 (file)
@@ -141,7 +141,7 @@ struct z_erofs_maprecorder {
        u8  type, headtype;
        u16 clusterofs;
        u16 delta[2];
-       erofs_blk_t pblk, compressedlcs;
+       erofs_blk_t pblk, compressedblks;
        erofs_off_t nextpackoff;
 };
 
@@ -192,7 +192,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,
                                DBG_BUGON(1);
                                return -EFSCORRUPTED;
                        }
-                       m->compressedlcs = m->delta[0] &
+                       m->compressedblks = m->delta[0] &
                                ~Z_EROFS_VLE_DI_D0_CBLKCNT;
                        m->delta[0] = 1;
                }
@@ -293,7 +293,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
                                DBG_BUGON(1);
                                return -EFSCORRUPTED;
                        }
-                       m->compressedlcs = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT;
+                       m->compressedblks = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT;
                        m->delta[0] = 1;
                        return 0;
                } else if (i + 1 != (int)vcnt) {
@@ -497,7 +497,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
                return 0;
        }
        lcn = m->lcn + 1;
-       if (m->compressedlcs)
+       if (m->compressedblks)
                goto out;
 
        err = z_erofs_load_cluster_from_disk(m, lcn, false);
@@ -506,7 +506,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
 
        /*
         * If the 1st NONHEAD lcluster has already been handled initially w/o
-        * valid compressedlcs, which means at least it mustn't be CBLKCNT, or
+        * valid compressedblks, which means at least it mustn't be CBLKCNT, or
         * an internal implemenatation error is detected.
         *
         * The following code can also handle it properly anyway, but let's
@@ -523,12 +523,12 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
                 * if the 1st NONHEAD lcluster is actually PLAIN or HEAD type
                 * rather than CBLKCNT, it's a 1 lcluster-sized pcluster.
                 */
-               m->compressedlcs = 1;
+               m->compressedblks = 1 << (lclusterbits - LOG_BLOCK_SIZE);
                break;
        case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:
                if (m->delta[0] != 1)
                        goto err_bonus_cblkcnt;
-               if (m->compressedlcs)
+               if (m->compressedblks)
                        break;
                fallthrough;
        default:
@@ -539,7 +539,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
                return -EFSCORRUPTED;
        }
 out:
-       map->m_plen = (u64)m->compressedlcs << lclusterbits;
+       map->m_plen = (u64)m->compressedblks << LOG_BLOCK_SIZE;
        return 0;
 err_bonus_cblkcnt:
        erofs_err(m->inode->i_sb,
index 0522136..08a1993 100644 (file)
@@ -134,10 +134,10 @@ static bool inode_io_list_move_locked(struct inode *inode,
 
 static void wb_wakeup(struct bdi_writeback *wb)
 {
-       spin_lock_bh(&wb->work_lock);
+       spin_lock_irq(&wb->work_lock);
        if (test_bit(WB_registered, &wb->state))
                mod_delayed_work(bdi_wq, &wb->dwork, 0);
-       spin_unlock_bh(&wb->work_lock);
+       spin_unlock_irq(&wb->work_lock);
 }
 
 static void finish_writeback_work(struct bdi_writeback *wb,
@@ -164,7 +164,7 @@ static void wb_queue_work(struct bdi_writeback *wb,
        if (work->done)
                atomic_inc(&work->done->cnt);
 
-       spin_lock_bh(&wb->work_lock);
+       spin_lock_irq(&wb->work_lock);
 
        if (test_bit(WB_registered, &wb->state)) {
                list_add_tail(&work->list, &wb->work_list);
@@ -172,7 +172,7 @@ static void wb_queue_work(struct bdi_writeback *wb,
        } else
                finish_writeback_work(wb, work);
 
-       spin_unlock_bh(&wb->work_lock);
+       spin_unlock_irq(&wb->work_lock);
 }
 
 /**
@@ -2082,13 +2082,13 @@ static struct wb_writeback_work *get_next_work_item(struct bdi_writeback *wb)
 {
        struct wb_writeback_work *work = NULL;
 
-       spin_lock_bh(&wb->work_lock);
+       spin_lock_irq(&wb->work_lock);
        if (!list_empty(&wb->work_list)) {
                work = list_entry(wb->work_list.next,
                                  struct wb_writeback_work, list);
                list_del_init(&work->list);
        }
-       spin_unlock_bh(&wb->work_lock);
+       spin_unlock_irq(&wb->work_lock);
        return work;
 }
 
index 6462276..ba1de23 100644 (file)
@@ -2018,23 +2018,25 @@ static int __file_remove_privs(struct file *file, unsigned int flags)
 {
        struct dentry *dentry = file_dentry(file);
        struct inode *inode = file_inode(file);
-       int error;
+       int error = 0;
        int kill;
 
        if (IS_NOSEC(inode) || !S_ISREG(inode->i_mode))
                return 0;
 
        kill = dentry_needs_remove_privs(dentry);
-       if (kill <= 0)
+       if (kill < 0)
                return kill;
 
-       if (flags & IOCB_NOWAIT)
-               return -EAGAIN;
+       if (kill) {
+               if (flags & IOCB_NOWAIT)
+                       return -EAGAIN;
+
+               error = __remove_privs(file_mnt_user_ns(file), dentry, kill);
+       }
 
-       error = __remove_privs(file_mnt_user_ns(file), dentry, kill);
        if (!error)
                inode_has_no_xattr(inode);
-
        return error;
 }
 
index c266cfd..607f94a 100644 (file)
@@ -2129,6 +2129,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
        else
                error = locks_lock_file_wait(f.file, &fl);
 
+       locks_release_private(&fl);
  out_putf:
        fdput(f);
 
index 68789f8..df137ba 100644 (file)
@@ -4238,6 +4238,13 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize,
                err = -EPERM;
                goto out_fput;
        }
+
+       /* We're not controlling the target namespace. */
+       if (!ns_capable(mnt_userns, CAP_SYS_ADMIN)) {
+               err = -EPERM;
+               goto out_fput;
+       }
+
        kattr->mnt_userns = get_user_ns(mnt_userns);
 
 out_fput:
index dbab3ca..5d6c2dd 100644 (file)
@@ -2382,7 +2382,8 @@ static void nfs_dentry_remove_handle_error(struct inode *dir,
 {
        switch (error) {
        case -ENOENT:
-               d_delete(dentry);
+               if (d_really_is_positive(dentry))
+                       d_delete(dentry);
                nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
                break;
        case 0:
@@ -2484,8 +2485,10 @@ int nfs_unlink(struct inode *dir, struct dentry *dentry)
         */
        error = -ETXTBSY;
        if (WARN_ON(dentry->d_flags & DCACHE_NFSFS_RENAMED) ||
-           WARN_ON(dentry->d_fsdata == NFS_FSDATA_BLOCKED))
+           WARN_ON(dentry->d_fsdata == NFS_FSDATA_BLOCKED)) {
+               spin_unlock(&dentry->d_lock);
                goto out;
+       }
        if (dentry->d_fsdata)
                /* old devname */
                kfree(dentry->d_fsdata);
index d2bcd48..e032fe2 100644 (file)
@@ -221,8 +221,10 @@ nfs_file_fsync_commit(struct file *file, int datasync)
 int
 nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 {
-       struct nfs_open_context *ctx = nfs_file_open_context(file);
        struct inode *inode = file_inode(file);
+       struct nfs_inode *nfsi = NFS_I(inode);
+       long save_nredirtied = atomic_long_read(&nfsi->redirtied_pages);
+       long nredirtied;
        int ret;
 
        trace_nfs_fsync_enter(inode);
@@ -237,15 +239,10 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
                ret = pnfs_sync_inode(inode, !!datasync);
                if (ret != 0)
                        break;
-               if (!test_and_clear_bit(NFS_CONTEXT_RESEND_WRITES, &ctx->flags))
+               nredirtied = atomic_long_read(&nfsi->redirtied_pages);
+               if (nredirtied == save_nredirtied)
                        break;
-               /*
-                * If nfs_file_fsync_commit detected a server reboot, then
-                * resend all dirty pages that might have been covered by
-                * the NFS_CONTEXT_RESEND_WRITES flag
-                */
-               start = 0;
-               end = LLONG_MAX;
+               save_nredirtied = nredirtied;
        }
 
        trace_nfs_fsync_exit(inode, ret);
index b4e46b0..bea7c00 100644 (file)
@@ -426,6 +426,7 @@ nfs_ilookup(struct super_block *sb, struct nfs_fattr *fattr, struct nfs_fh *fh)
 static void nfs_inode_init_regular(struct nfs_inode *nfsi)
 {
        atomic_long_set(&nfsi->nrequests, 0);
+       atomic_long_set(&nfsi->redirtied_pages, 0);
        INIT_LIST_HEAD(&nfsi->commit_info.list);
        atomic_long_set(&nfsi->commit_info.ncommit, 0);
        atomic_set(&nfsi->commit_info.rpcs_out, 0);
index e88f6b1..9eb1812 100644 (file)
@@ -340,6 +340,11 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
                goto out;
        }
 
+       if (!S_ISREG(fattr->mode)) {
+               res = ERR_PTR(-EBADF);
+               goto out;
+       }
+
        res = ERR_PTR(-ENOMEM);
        len = strlen(SSC_READ_NAME_BODY) + 16;
        read_name = kzalloc(len, GFP_KERNEL);
@@ -357,6 +362,7 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
                                     r_ino->i_fop);
        if (IS_ERR(filep)) {
                res = ERR_CAST(filep);
+               iput(r_ino);
                goto out_free_name;
        }
 
index 41a9b6b..2613b7e 100644 (file)
@@ -2817,7 +2817,6 @@ int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *hdr)
        /* Resend all requests through the MDS */
        nfs_pageio_init_write(&pgio, hdr->inode, FLUSH_STABLE, true,
                              hdr->completion_ops);
-       set_bit(NFS_CONTEXT_RESEND_WRITES, &hdr->args.context->flags);
        return nfs_pageio_resend(&pgio, hdr);
 }
 EXPORT_SYMBOL_GPL(pnfs_write_done_resend_to_mds);
index 51a7e20..1843fa2 100644 (file)
@@ -1420,10 +1420,12 @@ static void nfs_initiate_write(struct nfs_pgio_header *hdr,
  */
 static void nfs_redirty_request(struct nfs_page *req)
 {
+       struct nfs_inode *nfsi = NFS_I(page_file_mapping(req->wb_page)->host);
+
        /* Bump the transmission count */
        req->wb_nio++;
        nfs_mark_request_dirty(req);
-       set_bit(NFS_CONTEXT_RESEND_WRITES, &nfs_req_openctx(req)->flags);
+       atomic_long_inc(&nfsi->redirtied_pages);
        nfs_end_page_writeback(req);
        nfs_release_request(req);
 }
@@ -1904,7 +1906,7 @@ static void nfs_commit_release_pages(struct nfs_commit_data *data)
                /* We have a mismatch. Write the page again */
                dprintk_cont(" mismatch\n");
                nfs_mark_request_dirty(req);
-               set_bit(NFS_CONTEXT_RESEND_WRITES, &nfs_req_openctx(req)->flags);
+               atomic_long_inc(&NFS_I(data->inode)->redirtied_pages);
        next:
                nfs_unlock_and_release_request(req);
                /* Latency breaker */
index 5bdff12..6ae1f56 100644 (file)
@@ -483,8 +483,7 @@ out:
 }
 
 #ifdef CONFIG_NTFS3_FS_POSIX_ACL
-static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
-                                        struct inode *inode, int type,
+static struct posix_acl *ntfs_get_acl_ex(struct inode *inode, int type,
                                         int locked)
 {
        struct ntfs_inode *ni = ntfs_i(inode);
@@ -519,7 +518,7 @@ static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
 
        /* Translate extended attribute to acl. */
        if (err >= 0) {
-               acl = posix_acl_from_xattr(mnt_userns, buf, err);
+               acl = posix_acl_from_xattr(&init_user_ns, buf, err);
        } else if (err == -ENODATA) {
                acl = NULL;
        } else {
@@ -542,8 +541,7 @@ struct posix_acl *ntfs_get_acl(struct inode *inode, int type, bool rcu)
        if (rcu)
                return ERR_PTR(-ECHILD);
 
-       /* TODO: init_user_ns? */
-       return ntfs_get_acl_ex(&init_user_ns, inode, type, 0);
+       return ntfs_get_acl_ex(inode, type, 0);
 }
 
 static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
@@ -595,7 +593,7 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
                value = kmalloc(size, GFP_NOFS);
                if (!value)
                        return -ENOMEM;
-               err = posix_acl_to_xattr(mnt_userns, acl, value, size);
+               err = posix_acl_to_xattr(&init_user_ns, acl, value, size);
                if (err < 0)
                        goto out;
                flags = 0;
@@ -646,7 +644,7 @@ static int ntfs_xattr_get_acl(struct user_namespace *mnt_userns,
        if (!acl)
                return -ENODATA;
 
-       err = posix_acl_to_xattr(mnt_userns, acl, buffer, size);
+       err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
        posix_acl_release(acl);
 
        return err;
@@ -670,12 +668,12 @@ static int ntfs_xattr_set_acl(struct user_namespace *mnt_userns,
        if (!value) {
                acl = NULL;
        } else {
-               acl = posix_acl_from_xattr(mnt_userns, value, size);
+               acl = posix_acl_from_xattr(&init_user_ns, value, size);
                if (IS_ERR(acl))
                        return PTR_ERR(acl);
 
                if (acl) {
-                       err = posix_acl_valid(mnt_userns, acl);
+                       err = posix_acl_valid(&init_user_ns, acl);
                        if (err)
                                goto release_and_out;
                }
index 801e60b..c28bc98 100644 (file)
@@ -3403,10 +3403,12 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
        ocfs2_lock_res_free(&osb->osb_nfs_sync_lockres);
        ocfs2_lock_res_free(&osb->osb_orphan_scan.os_lockres);
 
-       ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
-       osb->cconn = NULL;
+       if (osb->cconn) {
+               ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
+               osb->cconn = NULL;
 
-       ocfs2_dlm_shutdown_debug(osb);
+               ocfs2_dlm_shutdown_debug(osb);
+       }
 }
 
 static int ocfs2_drop_lock(struct ocfs2_super *osb,
index 013a727..e2cc9ee 100644 (file)
@@ -1914,8 +1914,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
            !ocfs2_is_hard_readonly(osb))
                hangup_needed = 1;
 
-       if (osb->cconn)
-               ocfs2_dlm_shutdown(osb, hangup_needed);
+       ocfs2_dlm_shutdown(osb, hangup_needed);
 
        ocfs2_blockcheck_stats_debugfs_remove(&osb->osb_ecc_stats);
        debugfs_remove_recursive(osb->osb_debug_root);
index b45fea6..0fbcb59 100644 (file)
@@ -460,9 +460,12 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
  * of the POSIX ACLs retrieved from the lower layer to this function to not
  * alter the POSIX ACLs for the underlying filesystem.
  */
-static void ovl_idmap_posix_acl(struct user_namespace *mnt_userns,
+static void ovl_idmap_posix_acl(struct inode *realinode,
+                               struct user_namespace *mnt_userns,
                                struct posix_acl *acl)
 {
+       struct user_namespace *fs_userns = i_user_ns(realinode);
+
        for (unsigned int i = 0; i < acl->a_count; i++) {
                vfsuid_t vfsuid;
                vfsgid_t vfsgid;
@@ -470,11 +473,11 @@ static void ovl_idmap_posix_acl(struct user_namespace *mnt_userns,
                struct posix_acl_entry *e = &acl->a_entries[i];
                switch (e->e_tag) {
                case ACL_USER:
-                       vfsuid = make_vfsuid(mnt_userns, &init_user_ns, e->e_uid);
+                       vfsuid = make_vfsuid(mnt_userns, fs_userns, e->e_uid);
                        e->e_uid = vfsuid_into_kuid(vfsuid);
                        break;
                case ACL_GROUP:
-                       vfsgid = make_vfsgid(mnt_userns, &init_user_ns, e->e_gid);
+                       vfsgid = make_vfsgid(mnt_userns, fs_userns, e->e_gid);
                        e->e_gid = vfsgid_into_kgid(vfsgid);
                        break;
                }
@@ -536,7 +539,7 @@ struct posix_acl *ovl_get_acl(struct inode *inode, int type, bool rcu)
        if (!clone)
                clone = ERR_PTR(-ENOMEM);
        else
-               ovl_idmap_posix_acl(mnt_user_ns(realpath.mnt), clone);
+               ovl_idmap_posix_acl(realinode, mnt_user_ns(realpath.mnt), clone);
        /*
         * Since we're not in RCU path walk we always need to release the
         * original ACLs.
index 1d17d7b..5af3380 100644 (file)
@@ -361,6 +361,7 @@ posix_acl_permission(struct user_namespace *mnt_userns, struct inode *inode,
                     const struct posix_acl *acl, int want)
 {
        const struct posix_acl_entry *pa, *pe, *mask_obj;
+       struct user_namespace *fs_userns = i_user_ns(inode);
        int found = 0;
        vfsuid_t vfsuid;
        vfsgid_t vfsgid;
@@ -376,7 +377,7 @@ posix_acl_permission(struct user_namespace *mnt_userns, struct inode *inode,
                                         goto check_perm;
                                 break;
                         case ACL_USER:
-                               vfsuid = make_vfsuid(mnt_userns, &init_user_ns,
+                               vfsuid = make_vfsuid(mnt_userns, fs_userns,
                                                     pa->e_uid);
                                if (vfsuid_eq_kuid(vfsuid, current_fsuid()))
                                         goto mask;
@@ -390,7 +391,7 @@ posix_acl_permission(struct user_namespace *mnt_userns, struct inode *inode,
                                 }
                                break;
                         case ACL_GROUP:
-                               vfsgid = make_vfsgid(mnt_userns, &init_user_ns,
+                               vfsgid = make_vfsgid(mnt_userns, fs_userns,
                                                     pa->e_gid);
                                if (vfsgid_in_group_p(vfsgid)) {
                                        found = 1;
@@ -736,6 +737,7 @@ void posix_acl_getxattr_idmapped_mnt(struct user_namespace *mnt_userns,
 {
        struct posix_acl_xattr_header *header = value;
        struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
+       struct user_namespace *fs_userns = i_user_ns(inode);
        int count;
        vfsuid_t vfsuid;
        vfsgid_t vfsgid;
@@ -753,13 +755,13 @@ void posix_acl_getxattr_idmapped_mnt(struct user_namespace *mnt_userns,
                switch (le16_to_cpu(entry->e_tag)) {
                case ACL_USER:
                        uid = make_kuid(&init_user_ns, le32_to_cpu(entry->e_id));
-                       vfsuid = make_vfsuid(mnt_userns, &init_user_ns, uid);
+                       vfsuid = make_vfsuid(mnt_userns, fs_userns, uid);
                        entry->e_id = cpu_to_le32(from_kuid(&init_user_ns,
                                                vfsuid_into_kuid(vfsuid)));
                        break;
                case ACL_GROUP:
                        gid = make_kgid(&init_user_ns, le32_to_cpu(entry->e_id));
-                       vfsgid = make_vfsgid(mnt_userns, &init_user_ns, gid);
+                       vfsgid = make_vfsgid(mnt_userns, fs_userns, gid);
                        entry->e_id = cpu_to_le32(from_kgid(&init_user_ns,
                                                vfsgid_into_kgid(vfsgid)));
                        break;
@@ -775,6 +777,7 @@ void posix_acl_setxattr_idmapped_mnt(struct user_namespace *mnt_userns,
 {
        struct posix_acl_xattr_header *header = value;
        struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
+       struct user_namespace *fs_userns = i_user_ns(inode);
        int count;
        vfsuid_t vfsuid;
        vfsgid_t vfsgid;
@@ -793,13 +796,13 @@ void posix_acl_setxattr_idmapped_mnt(struct user_namespace *mnt_userns,
                case ACL_USER:
                        uid = make_kuid(&init_user_ns, le32_to_cpu(entry->e_id));
                        vfsuid = VFSUIDT_INIT(uid);
-                       uid = from_vfsuid(mnt_userns, &init_user_ns, vfsuid);
+                       uid = from_vfsuid(mnt_userns, fs_userns, vfsuid);
                        entry->e_id = cpu_to_le32(from_kuid(&init_user_ns, uid));
                        break;
                case ACL_GROUP:
                        gid = make_kgid(&init_user_ns, le32_to_cpu(entry->e_id));
                        vfsgid = VFSGIDT_INIT(gid);
-                       gid = from_vfsgid(mnt_userns, &init_user_ns, vfsgid);
+                       gid = from_vfsgid(mnt_userns, fs_userns, vfsgid);
                        entry->e_id = cpu_to_le32(from_kgid(&init_user_ns, gid));
                        break;
                default:
index a3398d0..4e00236 100644 (file)
@@ -527,10 +527,12 @@ static void smaps_pte_entry(pte_t *pte, unsigned long addr,
        struct vm_area_struct *vma = walk->vma;
        bool locked = !!(vma->vm_flags & VM_LOCKED);
        struct page *page = NULL;
-       bool migration = false;
+       bool migration = false, young = false, dirty = false;
 
        if (pte_present(*pte)) {
                page = vm_normal_page(vma, addr, *pte);
+               young = pte_young(*pte);
+               dirty = pte_dirty(*pte);
        } else if (is_swap_pte(*pte)) {
                swp_entry_t swpent = pte_to_swp_entry(*pte);
 
@@ -560,8 +562,7 @@ static void smaps_pte_entry(pte_t *pte, unsigned long addr,
        if (!page)
                return;
 
-       smaps_account(mss, page, false, pte_young(*pte), pte_dirty(*pte),
-                     locked, migration);
+       smaps_account(mss, page, false, young, dirty, locked, migration);
 }
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
index 98e64fe..e565109 100644 (file)
@@ -593,7 +593,7 @@ static void squashfs_readahead(struct readahead_control *ractl)
 
                res = squashfs_read_data(inode->i_sb, block, bsize, NULL, actor);
 
-               kfree(actor);
+               squashfs_page_actor_free(actor);
 
                if (res == expected) {
                        int bytes;
index be4b12d..f1ccad5 100644 (file)
@@ -74,7 +74,7 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
        /* Decompress directly into the page cache buffers */
        res = squashfs_read_data(inode->i_sb, block, bsize, NULL, actor);
 
-       kfree(actor);
+       squashfs_page_actor_free(actor);
 
        if (res < 0)
                goto mark_errored;
index b23b780..54b93bf 100644 (file)
@@ -52,6 +52,7 @@ struct squashfs_page_actor *squashfs_page_actor_init(void **buffer,
        actor->buffer = buffer;
        actor->pages = pages;
        actor->next_page = 0;
+       actor->tmp_buffer = NULL;
        actor->squashfs_first_page = cache_first_page;
        actor->squashfs_next_page = cache_next_page;
        actor->squashfs_finish_page = cache_finish_page;
@@ -68,20 +69,9 @@ static void *handle_next_page(struct squashfs_page_actor *actor)
 
        if ((actor->next_page == actor->pages) ||
                        (actor->next_index != actor->page[actor->next_page]->index)) {
-               if (actor->alloc_buffer) {
-                       void *tmp_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
-
-                       if (tmp_buffer) {
-                               actor->tmp_buffer = tmp_buffer;
-                               actor->next_index++;
-                               actor->returned_pages++;
-                               return tmp_buffer;
-                       }
-               }
-
                actor->next_index++;
                actor->returned_pages++;
-               return ERR_PTR(-ENOMEM);
+               return actor->alloc_buffer ? actor->tmp_buffer : ERR_PTR(-ENOMEM);
        }
 
        actor->next_index++;
@@ -96,11 +86,10 @@ static void *direct_first_page(struct squashfs_page_actor *actor)
 
 static void *direct_next_page(struct squashfs_page_actor *actor)
 {
-       if (actor->pageaddr)
+       if (actor->pageaddr) {
                kunmap_local(actor->pageaddr);
-
-       kfree(actor->tmp_buffer);
-       actor->pageaddr = actor->tmp_buffer = NULL;
+               actor->pageaddr = NULL;
+       }
 
        return handle_next_page(actor);
 }
@@ -109,8 +98,6 @@ static void direct_finish_page(struct squashfs_page_actor *actor)
 {
        if (actor->pageaddr)
                kunmap_local(actor->pageaddr);
-
-       kfree(actor->tmp_buffer);
 }
 
 struct squashfs_page_actor *squashfs_page_actor_init_special(struct squashfs_sb_info *msblk,
@@ -121,6 +108,16 @@ struct squashfs_page_actor *squashfs_page_actor_init_special(struct squashfs_sb_
        if (actor == NULL)
                return NULL;
 
+       if (msblk->decompressor->alloc_buffer) {
+               actor->tmp_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
+
+               if (actor->tmp_buffer == NULL) {
+                       kfree(actor);
+                       return NULL;
+               }
+       } else
+               actor->tmp_buffer = NULL;
+
        actor->length = length ? : pages * PAGE_SIZE;
        actor->page = page;
        actor->pages = pages;
@@ -128,7 +125,6 @@ struct squashfs_page_actor *squashfs_page_actor_init_special(struct squashfs_sb_
        actor->returned_pages = 0;
        actor->next_index = page[0]->index & ~((1 << (msblk->block_log - PAGE_SHIFT)) - 1);
        actor->pageaddr = NULL;
-       actor->tmp_buffer = NULL;
        actor->alloc_buffer = msblk->decompressor->alloc_buffer;
        actor->squashfs_first_page = direct_first_page;
        actor->squashfs_next_page = direct_next_page;
index 24841d2..95ffbb5 100644 (file)
@@ -29,6 +29,11 @@ extern struct squashfs_page_actor *squashfs_page_actor_init(void **buffer,
 extern struct squashfs_page_actor *squashfs_page_actor_init_special(
                                struct squashfs_sb_info *msblk,
                                struct page **page, int pages, int length);
+static inline void squashfs_page_actor_free(struct squashfs_page_actor *actor)
+{
+       kfree(actor->tmp_buffer);
+       kfree(actor);
+}
 static inline void *squashfs_first_page(struct squashfs_page_actor *actor)
 {
        return actor->squashfs_first_page(actor);
index 81d26ab..da85b39 100644 (file)
@@ -141,6 +141,8 @@ struct tracefs_mount_opts {
        kuid_t uid;
        kgid_t gid;
        umode_t mode;
+       /* Opt_* bitfield. */
+       unsigned int opts;
 };
 
 enum {
@@ -241,6 +243,7 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
        kgid_t gid;
        char *p;
 
+       opts->opts = 0;
        opts->mode = TRACEFS_DEFAULT_MODE;
 
        while ((p = strsep(&data, ",")) != NULL) {
@@ -275,24 +278,36 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
                 * but traditionally tracefs has ignored all mount options
                 */
                }
+
+               opts->opts |= BIT(token);
        }
 
        return 0;
 }
 
-static int tracefs_apply_options(struct super_block *sb)
+static int tracefs_apply_options(struct super_block *sb, bool remount)
 {
        struct tracefs_fs_info *fsi = sb->s_fs_info;
        struct inode *inode = d_inode(sb->s_root);
        struct tracefs_mount_opts *opts = &fsi->mount_opts;
 
-       inode->i_mode &= ~S_IALLUGO;
-       inode->i_mode |= opts->mode;
+       /*
+        * On remount, only reset mode/uid/gid if they were provided as mount
+        * options.
+        */
+
+       if (!remount || opts->opts & BIT(Opt_mode)) {
+               inode->i_mode &= ~S_IALLUGO;
+               inode->i_mode |= opts->mode;
+       }
 
-       inode->i_uid = opts->uid;
+       if (!remount || opts->opts & BIT(Opt_uid))
+               inode->i_uid = opts->uid;
 
-       /* Set all the group ids to the mount option */
-       set_gid(sb->s_root, opts->gid);
+       if (!remount || opts->opts & BIT(Opt_gid)) {
+               /* Set all the group ids to the mount option */
+               set_gid(sb->s_root, opts->gid);
+       }
 
        return 0;
 }
@@ -307,7 +322,7 @@ static int tracefs_remount(struct super_block *sb, int *flags, char *data)
        if (err)
                goto fail;
 
-       tracefs_apply_options(sb);
+       tracefs_apply_options(sb, true);
 
 fail:
        return err;
@@ -359,7 +374,7 @@ static int trace_fill_super(struct super_block *sb, void *data, int silent)
 
        sb->s_op = &tracefs_super_operations;
 
-       tracefs_apply_options(sb);
+       tracefs_apply_options(sb, false);
 
        return 0;
 
index 1c44bf7..175de70 100644 (file)
@@ -1601,6 +1601,10 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
                        wake_userfault(vma->vm_userfaultfd_ctx.ctx, &range);
                }
 
+               /* Reset ptes for the whole vma range if wr-protected */
+               if (userfaultfd_wp(vma))
+                       uffd_wp_range(mm, vma, start, vma_end - start, false);
+
                new_flags = vma->vm_flags & ~__VM_UFFD_FLAGS;
                prev = vma_merge(mm, prev, start, vma_end, new_flags,
                                 vma->anon_vma, vma->vm_file, vma->vm_pgoff,
index 3d5ebd2..564a8c6 100644 (file)
@@ -4,6 +4,7 @@
 #define __ASM_GENERIC_BITOPS_GENERIC_NON_ATOMIC_H
 
 #include <linux/bits.h>
+#include <asm/barrier.h>
 
 #ifndef _LINUX_BITOPS_H
 #error only <linux/bitops.h> can be included directly
@@ -127,6 +128,18 @@ generic_test_bit(unsigned long nr, const volatile unsigned long *addr)
        return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
 }
 
+/**
+ * generic_test_bit_acquire - Determine, with acquire semantics, whether a bit is set
+ * @nr: bit number to test
+ * @addr: Address to start counting from
+ */
+static __always_inline bool
+generic_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr)
+{
+       unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+       return 1UL & (smp_load_acquire(p) >> (nr & (BITS_PER_LONG-1)));
+}
+
 /*
  * const_*() definitions provide good compile-time optimizations when
  * the passed arguments can be resolved at compile time.
@@ -137,6 +150,7 @@ generic_test_bit(unsigned long nr, const volatile unsigned long *addr)
 #define const___test_and_set_bit       generic___test_and_set_bit
 #define const___test_and_clear_bit     generic___test_and_clear_bit
 #define const___test_and_change_bit    generic___test_and_change_bit
+#define const_test_bit_acquire         generic_test_bit_acquire
 
 /**
  * const_test_bit - Determine whether a bit is set
index 988a3bb..2b238b1 100644 (file)
@@ -142,4 +142,16 @@ _test_bit(unsigned long nr, const volatile unsigned long *addr)
        return arch_test_bit(nr, addr);
 }
 
+/**
+ * _test_bit_acquire - Determine, with acquire semantics, whether a bit is set
+ * @nr: bit number to test
+ * @addr: Address to start counting from
+ */
+static __always_inline bool
+_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr)
+{
+       instrument_atomic_read(addr + BIT_WORD(nr), sizeof(long));
+       return arch_test_bit_acquire(nr, addr);
+}
+
 #endif /* _ASM_GENERIC_BITOPS_INSTRUMENTED_NON_ATOMIC_H */
index 5c37ced..71f8d54 100644 (file)
@@ -13,6 +13,7 @@
 #define arch___test_and_change_bit generic___test_and_change_bit
 
 #define arch_test_bit generic_test_bit
+#define arch_test_bit_acquire generic_test_bit_acquire
 
 #include <asm-generic/bitops/non-instrumented-non-atomic.h>
 
index bdb9b1f..0ddc78d 100644 (file)
@@ -12,5 +12,6 @@
 #define ___test_and_change_bit arch___test_and_change_bit
 
 #define _test_bit              arch_test_bit
+#define _test_bit_acquire      arch_test_bit_acquire
 
 #endif /* __ASM_GENERIC_BITOPS_NON_INSTRUMENTED_NON_ATOMIC_H */
index d0f7bdd..db13bb6 100644 (file)
@@ -97,7 +97,7 @@ static inline bool memory_contains(void *begin, void *end, void *virt,
 /**
  * memory_intersects - checks if the region occupied by an object intersects
  *                     with another memory region
- * @begin: virtual address of the beginning of the memory regien
+ * @begin: virtual address of the beginning of the memory region
  * @end: virtual address of the end of the memory region
  * @virt: virtual address of the memory object
  * @size: size of the memory object
@@ -110,7 +110,10 @@ static inline bool memory_intersects(void *begin, void *end, void *virt,
 {
        void *vend = virt + size;
 
-       return (virt >= begin && virt < end) || (vend >= begin && vend < end);
+       if (virt < end && vend > begin)
+               return true;
+
+       return false;
 }
 
 /**
index d3e2d81..2a67aed 100644 (file)
@@ -2,7 +2,7 @@
 #ifndef __ASM_GENERIC_SOFTIRQ_STACK_H
 #define __ASM_GENERIC_SOFTIRQ_STACK_H
 
-#if defined(CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK) && !defined(CONFIG_PREEMPT_RT)
+#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
 void do_softirq_own_stack(void);
 #else
 static inline void do_softirq_own_stack(void)
index e94cdf2..5001e14 100644 (file)
@@ -67,6 +67,7 @@ struct amba_device {
        struct clk              *pclk;
        struct device_dma_parameters dma_parms;
        unsigned int            periphid;
+       struct mutex            periphid_lock;
        unsigned int            cid;
        struct amba_cs_uci_id   uci;
        unsigned int            irq[AMBA_NR_IRQS];
index cf9bf65..3b89c64 100644 (file)
@@ -59,6 +59,7 @@ extern unsigned long __sw_hweight64(__u64 w);
 #define __test_and_clear_bit(nr, addr) bitop(___test_and_clear_bit, nr, addr)
 #define __test_and_change_bit(nr, addr)        bitop(___test_and_change_bit, nr, addr)
 #define test_bit(nr, addr)             bitop(_test_bit, nr, addr)
+#define test_bit_acquire(nr, addr)     bitop(_test_bit_acquire, nr, addr)
 
 /*
  * Include this here because some architectures need generic_ffs/fls in
index def8b8d..df518c4 100644 (file)
@@ -138,6 +138,17 @@ BUFFER_FNS(Defer_Completion, defer_completion)
 static __always_inline void set_buffer_uptodate(struct buffer_head *bh)
 {
        /*
+        * If somebody else already set this uptodate, they will
+        * have done the memory barrier, and a reader will thus
+        * see *some* valid buffer state.
+        *
+        * Any other serialization (with IO errors or whatever that
+        * might clear the bit) has to come from other state (eg BH_Lock).
+        */
+       if (test_bit(BH_Uptodate, &bh->b_state))
+               return;
+
+       /*
         * make it consistent with folio_mark_uptodate
         * pairs with smp_load_acquire in buffer_uptodate
         */
@@ -156,7 +167,7 @@ static __always_inline int buffer_uptodate(const struct buffer_head *bh)
         * make it consistent with folio_test_uptodate
         * pairs with smp_mb__before_atomic in set_buffer_uptodate
         */
-       return (smp_load_acquire(&bh->b_state) & (1UL << BH_Uptodate)) != 0;
+       return test_bit_acquire(BH_Uptodate, &bh->b_state);
 }
 
 #define bh_offset(bh)          ((unsigned long)(bh)->b_data & ~PAGE_MASK)
index ed53bfe..ac5d051 100644 (file)
@@ -734,11 +734,6 @@ static inline struct cgroup *cgroup_parent(struct cgroup *cgrp)
        return NULL;
 }
 
-static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
-{
-       return NULL;
-}
-
 static inline bool cgroup_psi_enabled(void)
 {
        return false;
index 01ce94b..7713d7b 100644 (file)
@@ -240,6 +240,12 @@ static inline void *offset_to_ptr(const int *off)
 #define __must_be_array(a)     BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
 
 /*
+ * Whether 'type' is a signed type or an unsigned type. Supports scalar types,
+ * bool and also pointer types.
+ */
+#define is_signed_type(type) (((type)(-1)) < (__force type)1)
+
+/*
  * This is needed in functions which generate the stack canary, see
  * arch/x86/kernel/smpboot.c::start_secondary() for an example.
  */
index 7acaabd..2114d65 100644 (file)
@@ -242,6 +242,7 @@ driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
 
 extern int driver_deferred_probe_timeout;
 void driver_deferred_probe_add(struct device *dev);
+int driver_deferred_probe_check_state(struct device *dev);
 void driver_init(void);
 
 /**
index 720874e..36e5dd8 100644 (file)
@@ -258,7 +258,7 @@ struct fscache_cookie *fscache_acquire_cookie(struct fscache_volume *volume,
 
 /**
  * fscache_use_cookie - Request usage of cookie attached to an object
- * @object: Object description
+ * @cookie: The cookie representing the cache object
  * @will_modify: If cache is expected to be modified locally
  *
  * Request usage of the cookie attached to an object.  The caller should tell
@@ -274,7 +274,7 @@ static inline void fscache_use_cookie(struct fscache_cookie *cookie,
 
 /**
  * fscache_unuse_cookie - Cease usage of cookie attached to an object
- * @object: Object description
+ * @cookie: The cookie representing the cache object
  * @aux_data: Updated auxiliary data (or NULL)
  * @object_size: Revised size of the object (or NULL)
  *
index 55e6f4a..b6e6d5b 100644 (file)
@@ -310,9 +310,11 @@ static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2)
 struct ieee80211_hdr {
        __le16 frame_control;
        __le16 duration_id;
-       u8 addr1[ETH_ALEN];
-       u8 addr2[ETH_ALEN];
-       u8 addr3[ETH_ALEN];
+       struct_group(addrs,
+               u8 addr1[ETH_ALEN];
+               u8 addr2[ETH_ALEN];
+               u8 addr3[ETH_ALEN];
+       );
        __le16 seq_ctrl;
        u8 addr4[ETH_ALEN];
 } __packed __aligned(2);
index 8064481..60fff13 100644 (file)
@@ -407,4 +407,5 @@ LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)
 #ifdef CONFIG_IO_URING
 LSM_HOOK(int, 0, uring_override_creds, const struct cred *new)
 LSM_HOOK(int, 0, uring_sqpoll, void)
+LSM_HOOK(int, 0, uring_cmd, struct io_uring_cmd *ioucmd)
 #endif /* CONFIG_IO_URING */
index 84a0d7e..3aa6030 100644 (file)
  *      Check whether the current task is allowed to spawn a io_uring polling
  *      thread (IORING_SETUP_SQPOLL).
  *
+ * @uring_cmd:
+ *      Check whether the file_operations uring_cmd is allowed to run.
+ *
  */
 union security_list_options {
        #define LSM_HOOK(RET, DEFAULT, NAME, ...) RET (*NAME)(__VA_ARGS__);
index 4d31ce5..6257867 100644 (file)
@@ -987,19 +987,30 @@ static inline void mod_memcg_page_state(struct page *page,
 
 static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx)
 {
-       return READ_ONCE(memcg->vmstats.state[idx]);
+       long x = READ_ONCE(memcg->vmstats.state[idx]);
+#ifdef CONFIG_SMP
+       if (x < 0)
+               x = 0;
+#endif
+       return x;
 }
 
 static inline unsigned long lruvec_page_state(struct lruvec *lruvec,
                                              enum node_stat_item idx)
 {
        struct mem_cgroup_per_node *pn;
+       long x;
 
        if (mem_cgroup_disabled())
                return node_page_state(lruvec_pgdat(lruvec), idx);
 
        pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec);
-       return READ_ONCE(pn->lruvec_stats.state[idx]);
+       x = READ_ONCE(pn->lruvec_stats.state[idx]);
+#ifdef CONFIG_SMP
+       if (x < 0)
+               x = 0;
+#endif
+       return x;
 }
 
 static inline unsigned long lruvec_page_state_local(struct lruvec *lruvec,
index 96b16fb..7b7ce60 100644 (file)
@@ -779,6 +779,7 @@ struct mlx5_core_dev {
        enum mlx5_device_state  state;
        /* sync interface state */
        struct mutex            intf_state_mutex;
+       struct lock_class_key   lock_key;
        unsigned long           intf_state;
        struct mlx5_priv        priv;
        struct mlx5_profile     profile;
index 3bedc44..21f8b27 100644 (file)
@@ -1544,9 +1544,16 @@ static inline bool is_longterm_pinnable_page(struct page *page)
        if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE)
                return false;
 #endif
-       return !(is_device_coherent_page(page) ||
-                is_zone_movable_page(page) ||
-                is_zero_pfn(page_to_pfn(page)));
+       /* The zero page may always be pinned */
+       if (is_zero_pfn(page_to_pfn(page)))
+               return true;
+
+       /* Coherent device memory must always allow eviction. */
+       if (is_device_coherent_page(page))
+               return false;
+
+       /* Otherwise, non-movable zone pages can be pinned. */
+       return !is_zone_movable_page(page);
 }
 #else
 static inline bool is_longterm_pinnable_page(struct page *page)
@@ -2885,7 +2892,6 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
 #define FOLL_MIGRATION 0x400   /* wait for page to replace migration entry */
 #define FOLL_TRIED     0x800   /* a retry, previous pass started an IO */
 #define FOLL_REMOTE    0x2000  /* we are working on non-current tsk/mm */
-#define FOLL_COW       0x4000  /* internal GUP flag */
 #define FOLL_ANON      0x8000  /* don't do file mappings */
 #define FOLL_LONGTERM  0x10000 /* mapping lifetime is indefinite: see below */
 #define FOLL_SPLIT_PMD 0x20000 /* split huge pmd before returning */
index 1a3cb93..05d6f3f 100644 (file)
@@ -640,9 +640,23 @@ extern int sysctl_devconf_inherit_init_net;
  */
 static inline bool net_has_fallback_tunnels(const struct net *net)
 {
-       return !IS_ENABLED(CONFIG_SYSCTL) ||
-              !sysctl_fb_tunnels_only_for_init_net ||
-              (net == &init_net && sysctl_fb_tunnels_only_for_init_net == 1);
+#if IS_ENABLED(CONFIG_SYSCTL)
+       int fb_tunnels_only_for_init_net = READ_ONCE(sysctl_fb_tunnels_only_for_init_net);
+
+       return !fb_tunnels_only_for_init_net ||
+               (net_eq(net, &init_net) && fb_tunnels_only_for_init_net == 1);
+#else
+       return true;
+#endif
+}
+
+static inline int net_inherit_devconf(void)
+{
+#if IS_ENABLED(CONFIG_SYSCTL)
+       return READ_ONCE(sysctl_devconf_inherit_init_net);
+#else
+       return 0;
+#endif
 }
 
 static inline int netdev_queue_numa_node_read(const struct netdev_queue *q)
index a13296d..fd53355 100644 (file)
@@ -94,10 +94,6 @@ struct ebt_table {
        struct ebt_replace_kernel *table;
        unsigned int valid_hooks;
        rwlock_t lock;
-       /* e.g. could be the table explicitly only allows certain
-        * matches, targets, ... 0 == let it in */
-       int (*check)(const struct ebt_table_info *info,
-          unsigned int valid_hooks);
        /* the data used by the kernel */
        struct ebt_table_info *private;
        struct nf_hook_ops *ops;
index b32ed68..7931fa4 100644 (file)
@@ -83,7 +83,6 @@ struct nfs_open_context {
        fmode_t mode;
 
        unsigned long flags;
-#define NFS_CONTEXT_RESEND_WRITES      (1)
 #define NFS_CONTEXT_BAD                        (2)
 #define NFS_CONTEXT_UNLOCK     (3)
 #define NFS_CONTEXT_FILE_OPEN          (4)
@@ -182,6 +181,7 @@ struct nfs_inode {
                /* Regular file */
                struct {
                        atomic_long_t   nrequests;
+                       atomic_long_t   redirtied_pages;
                        struct nfs_mds_commit_info commit_info;
                        struct mutex    commit_mutex;
                };
index f1221d1..0eb3b19 100644 (file)
@@ -30,7 +30,6 @@
  * https://mail-index.netbsd.org/tech-misc/2007/02/05/0000.html -
  * credit to Christian Biere.
  */
-#define is_signed_type(type)       (((type)(-1)) < (type)1)
 #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type)))
 #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))
 #define type_min(T) ((T)((T)-type_max(T)-(T)1))
index 3edfb6d..dd81f51 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef PMC_ATOM_H
 #define PMC_ATOM_H
 
+#include <linux/bits.h>
+
 /* ValleyView Power Control Unit PCI Device ID */
 #define        PCI_DEVICE_ID_VLV_PMC   0x0F1C
 /* CherryTrail Power Control Unit PCI Device ID */
 #define        ACPI_MMIO_REG_LEN       0x100
 
 #define        PM1_CNT                 0x4
-#define        SLEEP_TYPE_MASK         0xFFFFECFF
+#define        SLEEP_TYPE_MASK         GENMASK(12, 10)
 #define        SLEEP_TYPE_S5           0x1C00
-#define        SLEEP_ENABLE            0x2000
+#define        SLEEP_ENABLE            BIT(13)
 
 extern int pmc_atom_read(int offset, u32 *value);
 
index 8978476..dd74411 100644 (file)
@@ -27,7 +27,7 @@ void psi_memstall_leave(unsigned long *flags);
 
 int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);
 struct psi_trigger *psi_trigger_create(struct psi_group *group,
-                       char *buf, size_t nbytes, enum psi_res res);
+                       char *buf, enum psi_res res);
 void psi_trigger_destroy(struct psi_trigger *t);
 
 __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
index bf80adc..b89b4b8 100644 (file)
@@ -41,12 +41,15 @@ struct anon_vma {
        atomic_t refcount;
 
        /*
-        * Count of child anon_vmas and VMAs which points to this anon_vma.
+        * Count of child anon_vmas. Equals to the count of all anon_vmas that
+        * have ->parent pointing to this one, including itself.
         *
         * This counter is used for making decision about reusing anon_vma
         * instead of forking new one. See comments in function anon_vma_clone.
         */
-       unsigned degree;
+       unsigned long num_children;
+       /* Count of VMAs whose ->anon_vma pointer points to this object. */
+       unsigned long num_active_vmas;
 
        struct anon_vma *parent;        /* Parent of this anon_vma */
 
index 1bc362c..7bd0c49 100644 (file)
@@ -2060,6 +2060,7 @@ static inline int security_perf_event_write(struct perf_event *event)
 #ifdef CONFIG_SECURITY
 extern int security_uring_override_creds(const struct cred *new);
 extern int security_uring_sqpoll(void);
+extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
 #else
 static inline int security_uring_override_creds(const struct cred *new)
 {
@@ -2069,6 +2070,10 @@ static inline int security_uring_sqpoll(void)
 {
        return 0;
 }
+static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
+{
+       return 0;
+}
 #endif /* CONFIG_SECURITY */
 #endif /* CONFIG_IO_URING */
 
index aef3145..6e4f476 100644 (file)
@@ -141,6 +141,14 @@ struct gpio_desc;
  *     Locking: none.
  *     Interrupts: caller dependent.
  *
+ * @start_rx: ``void ()(struct uart_port *port)``
+ *
+ *     Start receiving characters.
+ *
+ *     Locking: @port->lock taken.
+ *     Interrupts: locally disabled.
+ *     This call must not sleep
+ *
  * @stop_rx: ``void ()(struct uart_port *port)``
  *
  *     Stop receiving characters; the @port is in the process of being closed.
index 1b6c401..ff0b990 100644 (file)
@@ -29,15 +29,10 @@ struct shmem_inode_info {
        struct inode            vfs_inode;
 };
 
-#define SHMEM_FL_USER_VISIBLE FS_FL_USER_VISIBLE
-#define SHMEM_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE
-#define SHMEM_FL_INHERITED FS_FL_USER_MODIFIABLE
-
-/* Flags that are appropriate for regular files (all but dir-specific ones). */
-#define SHMEM_REG_FLMASK (~(FS_DIRSYNC_FL | FS_TOPDIR_FL))
-
-/* Flags that are appropriate for non-directories/regular files. */
-#define SHMEM_OTHER_FLMASK (FS_NODUMP_FL | FS_NOATIME_FL)
+#define SHMEM_FL_USER_VISIBLE          FS_FL_USER_VISIBLE
+#define SHMEM_FL_USER_MODIFIABLE \
+       (FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL)
+#define SHMEM_FL_INHERITED             (FS_NODUMP_FL | FS_NOATIME_FL)
 
 struct shmem_sb_info {
        unsigned long max_blocks;   /* How many blocks are allowed */
index ca8afa3..18e163a 100644 (file)
@@ -2444,6 +2444,27 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
        skb_shinfo(skb)->nr_frags = i + 1;
 }
 
+/**
+ * skb_fill_page_desc_noacc - initialise a paged fragment in an skb
+ * @skb: buffer containing fragment to be initialised
+ * @i: paged fragment index to initialise
+ * @page: the page to use for this fragment
+ * @off: the offset to the data with @page
+ * @size: the length of the data
+ *
+ * Variant of skb_fill_page_desc() which does not deal with
+ * pfmemalloc, if page is not owned by us.
+ */
+static inline void skb_fill_page_desc_noacc(struct sk_buff *skb, int i,
+                                           struct page *page, int off,
+                                           int size)
+{
+       struct skb_shared_info *shinfo = skb_shinfo(skb);
+
+       __skb_fill_page_desc_noacc(shinfo, i, page, off, size);
+       shinfo->nr_frags = i + 1;
+}
+
 void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
                     int size, unsigned int truesize);
 
index e6c73d5..f089ee1 100644 (file)
@@ -469,6 +469,7 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch
  *     SPI_TRANS_FAIL_NO_START.
  * @queue_empty: signal green light for opportunistically skipping the queue
  *     for spi_sync transfers.
+ * @must_async: disable all fast paths in the core
  *
  * Each SPI controller can communicate with one or more @spi_device
  * children.  These make a small bus, sharing MOSI, MISO and SCK signals
@@ -690,6 +691,7 @@ struct spi_controller {
 
        /* Flag for enabling opportunistic skipping of the queue in spi_sync */
        bool                    queue_empty;
+       bool                    must_async;
 };
 
 static inline void *spi_controller_get_devdata(struct spi_controller *ctlr)
index b18759a..8401dec 100644 (file)
@@ -814,8 +814,6 @@ extern int trace_add_event_call(struct trace_event_call *call);
 extern int trace_remove_event_call(struct trace_event_call *call);
 extern int trace_event_get_offsets(struct trace_event_call *call);
 
-#define is_signed_type(type)   (((type)(-1)) < (type)1)
-
 int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
 int trace_set_clr_event(const char *system, const char *event, int set);
 int trace_array_set_clr_event(struct trace_array *tr, const char *system,
index 254a265..e96da41 100644 (file)
@@ -70,6 +70,7 @@ struct udp_sock {
         * For encapsulation sockets.
         */
        int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
+       void (*encap_err_rcv)(struct sock *sk, struct sk_buff *skb, unsigned int udp_offset);
        int (*encap_err_lookup)(struct sock *sk, struct sk_buff *skb);
        void (*encap_destroy)(struct sock *sk);
 
index f7a9914..9ff1ad4 100644 (file)
@@ -575,6 +575,7 @@ struct usb3_lpm_parameters {
  * @devaddr: device address, XHCI: assigned by HW, others: same as devnum
  * @can_submit: URBs may be submitted
  * @persist_enabled:  USB_PERSIST enabled for this device
+ * @reset_in_progress: the device is being reset
  * @have_langid: whether string_langid is valid
  * @authorized: policy has said we can use it;
  *     (user space) policy determines if we authorize this device to be
@@ -662,6 +663,7 @@ struct usb_device {
 
        unsigned can_submit:1;
        unsigned persist_enabled:1;
+       unsigned reset_in_progress:1;
        unsigned have_langid:1;
        unsigned authorized:1;
        unsigned authenticated:1;
index cfb916c..8d09c2f 100644 (file)
@@ -73,6 +73,11 @@ enum {
 #define DP_CAP_USB                     BIT(7)
 #define DP_CAP_DFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(15, 8)) >> 8)
 #define DP_CAP_UFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(23, 16)) >> 16)
+/* Get pin assignment taking plug & receptacle into consideration */
+#define DP_CAP_PIN_ASSIGN_UFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \
+                       DP_CAP_UFP_D_PIN_ASSIGN(_cap_) : DP_CAP_DFP_D_PIN_ASSIGN(_cap_))
+#define DP_CAP_PIN_ASSIGN_DFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \
+                       DP_CAP_DFP_D_PIN_ASSIGN(_cap_) : DP_CAP_UFP_D_PIN_ASSIGN(_cap_))
 
 /* DisplayPort Status Update VDO bits */
 #define DP_STATUS_CONNECTION(_status_) ((_status_) & 3)
index 732b522..e1b8a91 100644 (file)
@@ -73,6 +73,8 @@ extern ssize_t mcopy_continue(struct mm_struct *dst_mm, unsigned long dst_start,
 extern int mwriteprotect_range(struct mm_struct *dst_mm,
                               unsigned long start, unsigned long len,
                               bool enable_wp, atomic_t *mmap_changing);
+extern void uffd_wp_range(struct mm_struct *dst_mm, struct vm_area_struct *vma,
+                         unsigned long start, unsigned long len, bool enable_wp);
 
 /* mm helpers */
 static inline bool is_mergeable_vm_userfaultfd_ctx(struct vm_area_struct *vma,
index 4040244..f3fc36c 100644 (file)
 #define HIGHMEM_ZONE(xx)
 #endif
 
-#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL, HIGHMEM_ZONE(xx) xx##_MOVABLE
+#ifdef CONFIG_ZONE_DEVICE
+#define DEVICE_ZONE(xx) xx##_DEVICE,
+#else
+#define DEVICE_ZONE(xx)
+#endif
+
+#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL, \
+       HIGHMEM_ZONE(xx) xx##_MOVABLE, DEVICE_ZONE(xx)
 
 enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
-               FOR_ALL_ZONES(PGALLOC),
-               FOR_ALL_ZONES(ALLOCSTALL),
-               FOR_ALL_ZONES(PGSCAN_SKIP),
+               FOR_ALL_ZONES(PGALLOC)
+               FOR_ALL_ZONES(ALLOCSTALL)
+               FOR_ALL_ZONES(PGSCAN_SKIP)
                PGFREE, PGACTIVATE, PGDEACTIVATE, PGLAZYFREE,
                PGFAULT, PGMAJFAULT,
                PGLAZYFREED,
index 7dec36a..7725b75 100644 (file)
@@ -71,7 +71,7 @@ static inline int
 wait_on_bit(unsigned long *word, int bit, unsigned mode)
 {
        might_sleep();
-       if (!test_bit(bit, word))
+       if (!test_bit_acquire(bit, word))
                return 0;
        return out_of_line_wait_on_bit(word, bit,
                                       bit_wait,
@@ -96,7 +96,7 @@ static inline int
 wait_on_bit_io(unsigned long *word, int bit, unsigned mode)
 {
        might_sleep();
-       if (!test_bit(bit, word))
+       if (!test_bit_acquire(bit, word))
                return 0;
        return out_of_line_wait_on_bit(word, bit,
                                       bit_wait_io,
@@ -123,7 +123,7 @@ wait_on_bit_timeout(unsigned long *word, int bit, unsigned mode,
                    unsigned long timeout)
 {
        might_sleep();
-       if (!test_bit(bit, word))
+       if (!test_bit_acquire(bit, word))
                return 0;
        return out_of_line_wait_on_bit_timeout(word, bit,
                                               bit_wait_timeout,
@@ -151,7 +151,7 @@ wait_on_bit_action(unsigned long *word, int bit, wait_bit_action_f *action,
                   unsigned mode)
 {
        might_sleep();
-       if (!test_bit(bit, word))
+       if (!test_bit_acquire(bit, word))
                return 0;
        return out_of_line_wait_on_bit(word, bit, action, mode);
 }
index cee5f83..b69ca69 100644 (file)
@@ -66,8 +66,6 @@ int rxrpc_kernel_charge_accept(struct socket *, rxrpc_notify_rx_t,
 void rxrpc_kernel_set_tx_length(struct socket *, struct rxrpc_call *, s64);
 bool rxrpc_kernel_check_life(const struct socket *, const struct rxrpc_call *);
 u32 rxrpc_kernel_get_epoch(struct socket *, struct rxrpc_call *);
-bool rxrpc_kernel_get_reply_time(struct socket *, struct rxrpc_call *,
-                                ktime_t *);
 bool rxrpc_kernel_call_is_complete(struct rxrpc_call *);
 void rxrpc_kernel_set_max_life(struct socket *, struct rxrpc_call *,
                               unsigned long);
index 184105d..be2992e 100644 (file)
@@ -290,7 +290,7 @@ static inline const char *bond_3ad_churn_desc(churn_state_t state)
 }
 
 /* ========== AD Exported functions to the main bonding code ========== */
-void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution);
+void bond_3ad_initialize(struct bonding *bond);
 void bond_3ad_bind_slave(struct slave *slave);
 void bond_3ad_unbind_slave(struct slave *slave);
 void bond_3ad_state_machine_handler(struct work_struct *);
index c4898fc..f90f002 100644 (file)
@@ -33,7 +33,7 @@ extern unsigned int sysctl_net_busy_poll __read_mostly;
 
 static inline bool net_busy_loop_on(void)
 {
-       return sysctl_net_busy_poll;
+       return READ_ONCE(sysctl_net_busy_poll);
 }
 
 static inline bool sk_can_busy_loop(const struct sock *sk)
index fae9b40..c1cbcdb 100644 (file)
@@ -3,6 +3,73 @@
 #ifndef _LINUX_DROPREASON_H
 #define _LINUX_DROPREASON_H
 
+#define DEFINE_DROP_REASON(FN, FNe)    \
+       FN(NOT_SPECIFIED)               \
+       FN(NO_SOCKET)                   \
+       FN(PKT_TOO_SMALL)               \
+       FN(TCP_CSUM)                    \
+       FN(SOCKET_FILTER)               \
+       FN(UDP_CSUM)                    \
+       FN(NETFILTER_DROP)              \
+       FN(OTHERHOST)                   \
+       FN(IP_CSUM)                     \
+       FN(IP_INHDR)                    \
+       FN(IP_RPFILTER)                 \
+       FN(UNICAST_IN_L2_MULTICAST)     \
+       FN(XFRM_POLICY)                 \
+       FN(IP_NOPROTO)                  \
+       FN(SOCKET_RCVBUFF)              \
+       FN(PROTO_MEM)                   \
+       FN(TCP_MD5NOTFOUND)             \
+       FN(TCP_MD5UNEXPECTED)           \
+       FN(TCP_MD5FAILURE)              \
+       FN(SOCKET_BACKLOG)              \
+       FN(TCP_FLAGS)                   \
+       FN(TCP_ZEROWINDOW)              \
+       FN(TCP_OLD_DATA)                \
+       FN(TCP_OVERWINDOW)              \
+       FN(TCP_OFOMERGE)                \
+       FN(TCP_RFC7323_PAWS)            \
+       FN(TCP_INVALID_SEQUENCE)        \
+       FN(TCP_RESET)                   \
+       FN(TCP_INVALID_SYN)             \
+       FN(TCP_CLOSE)                   \
+       FN(TCP_FASTOPEN)                \
+       FN(TCP_OLD_ACK)                 \
+       FN(TCP_TOO_OLD_ACK)             \
+       FN(TCP_ACK_UNSENT_DATA)         \
+       FN(TCP_OFO_QUEUE_PRUNE)         \
+       FN(TCP_OFO_DROP)                \
+       FN(IP_OUTNOROUTES)              \
+       FN(BPF_CGROUP_EGRESS)           \
+       FN(IPV6DISABLED)                \
+       FN(NEIGH_CREATEFAIL)            \
+       FN(NEIGH_FAILED)                \
+       FN(NEIGH_QUEUEFULL)             \
+       FN(NEIGH_DEAD)                  \
+       FN(TC_EGRESS)                   \
+       FN(QDISC_DROP)                  \
+       FN(CPU_BACKLOG)                 \
+       FN(XDP)                         \
+       FN(TC_INGRESS)                  \
+       FN(UNHANDLED_PROTO)             \
+       FN(SKB_CSUM)                    \
+       FN(SKB_GSO_SEG)                 \
+       FN(SKB_UCOPY_FAULT)             \
+       FN(DEV_HDR)                     \
+       FN(DEV_READY)                   \
+       FN(FULL_RING)                   \
+       FN(NOMEM)                       \
+       FN(HDR_TRUNC)                   \
+       FN(TAP_FILTER)                  \
+       FN(TAP_TXFILTER)                \
+       FN(ICMP_CSUM)                   \
+       FN(INVALID_PROTO)               \
+       FN(IP_INADDRERRORS)             \
+       FN(IP_INNOROUTES)               \
+       FN(PKT_TOO_BIG)                 \
+       FNe(MAX)
+
 /**
  * enum skb_drop_reason - the reasons of skb drops
  *
index 867656b..24003de 100644 (file)
@@ -439,7 +439,7 @@ static inline void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb,
 {
        list_add_tail(&skb->list, &napi->rx_list);
        napi->rx_count += segs;
-       if (napi->rx_count >= gro_normal_batch)
+       if (napi->rx_count >= READ_ONCE(gro_normal_batch))
                gro_normal_list(napi);
 }
 
index 63fac94..ced80e2 100644 (file)
@@ -246,7 +246,8 @@ static inline void ip_tunnel_init_flow(struct flowi4 *fl4,
                                       __be32 daddr, __be32 saddr,
                                       __be32 key, __u8 tos,
                                       struct net *net, int oif,
-                                      __u32 mark, __u32 tun_inner_hash)
+                                      __u32 mark, __u32 tun_inner_hash,
+                                      __u8 flow_flags)
 {
        memset(fl4, 0, sizeof(*fl4));
 
@@ -263,6 +264,7 @@ static inline void ip_tunnel_init_flow(struct flowi4 *fl4,
        fl4->fl4_gre_key = key;
        fl4->flowi4_mark = mark;
        fl4->flowi4_multipath_hash = tun_inner_hash;
+       fl4->flowi4_flags = flow_flags;
 }
 
 int ip_tunnel_init(struct net_device *dev);
index a32be8a..6a2019a 100644 (file)
@@ -53,8 +53,6 @@ struct nf_conntrack_net {
        /* only used when new connection is allocated: */
        atomic_t count;
        unsigned int expect_count;
-       u8 sysctl_auto_assign_helper;
-       bool auto_assign_helper_warned;
 
        /* only used from work queues, configuration plane, and so on: */
        unsigned int users4;
index d5326c4..cd982f4 100644 (file)
@@ -270,6 +270,7 @@ void flow_offload_refresh(struct nf_flowtable *flow_table,
 
 struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_table,
                                                     struct flow_offload_tuple *tuple);
+void nf_flow_table_gc_run(struct nf_flowtable *flow_table);
 void nf_flow_table_gc_cleanup(struct nf_flowtable *flowtable,
                              struct net_device *dev);
 void nf_flow_table_cleanup(struct net_device *dev);
@@ -306,6 +307,8 @@ void nf_flow_offload_stats(struct nf_flowtable *flowtable,
                           struct flow_offload *flow);
 
 void nf_flow_table_offload_flush(struct nf_flowtable *flowtable);
+void nf_flow_table_offload_flush_cleanup(struct nf_flowtable *flowtable);
+
 int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
                                struct net_device *dev,
                                enum flow_block_command cmd);
index 99aae36..cdb7db9 100644 (file)
@@ -1652,6 +1652,7 @@ struct nftables_pernet {
        struct list_head        module_list;
        struct list_head        notify_list;
        struct mutex            commit_mutex;
+       u64                     table_handle;
        unsigned int            base_seq;
        u8                      validate_state;
 };
index c396a38..e1290c1 100644 (file)
@@ -101,7 +101,6 @@ struct netns_ct {
        u8                      sysctl_log_invalid; /* Log invalid packets */
        u8                      sysctl_events;
        u8                      sysctl_acct;
-       u8                      sysctl_auto_assign_helper;
        u8                      sysctl_tstamp;
        u8                      sysctl_checksum;
 
index c7320ef..6320a76 100644 (file)
@@ -179,6 +179,8 @@ struct netns_ipv4 {
        unsigned int sysctl_tcp_fastopen_blackhole_timeout;
        atomic_t tfo_active_disable_times;
        unsigned long tfo_active_disable_stamp;
+       u32 tcp_challenge_timestamp;
+       u32 tcp_challenge_count;
 
        int sysctl_udp_wmem_min;
        int sysctl_udp_rmem_min;
index afc7ce7..72394f4 100644 (file)
@@ -67,6 +67,9 @@ static inline int udp_sock_create(struct net *net,
 typedef int (*udp_tunnel_encap_rcv_t)(struct sock *sk, struct sk_buff *skb);
 typedef int (*udp_tunnel_encap_err_lookup_t)(struct sock *sk,
                                             struct sk_buff *skb);
+typedef void (*udp_tunnel_encap_err_rcv_t)(struct sock *sk,
+                                          struct sk_buff *skb,
+                                          unsigned int udp_offset);
 typedef void (*udp_tunnel_encap_destroy_t)(struct sock *sk);
 typedef struct sk_buff *(*udp_tunnel_gro_receive_t)(struct sock *sk,
                                                    struct list_head *head,
@@ -80,6 +83,7 @@ struct udp_tunnel_sock_cfg {
        __u8  encap_type;
        udp_tunnel_encap_rcv_t encap_rcv;
        udp_tunnel_encap_err_lookup_t encap_err_lookup;
+       udp_tunnel_encap_err_rcv_t encap_err_rcv;
        udp_tunnel_encap_destroy_t encap_destroy;
        udp_tunnel_gro_receive_t gro_receive;
        udp_tunnel_gro_complete_t gro_complete;
index 9e17247..6ce3bd2 100644 (file)
 #define                DDR3PHY_DSGCR_ODTPDD_ODT0       (1 << 20)       /* ODT[0] Power Down Driver */
 
 #define DDR3PHY_ZQ0SR0                         (0x188)         /* ZQ status register 0 */
+#define DDR3PHY_ZQ0SR0_PDO_OFF                 (0)             /* Pull-down output impedance select offset */
+#define DDR3PHY_ZQ0SR0_PUO_OFF                 (5)             /* Pull-up output impedance select offset */
+#define DDR3PHY_ZQ0SR0_PDODT_OFF               (10)            /* Pull-down on-die termination impedance select offset */
+#define DDR3PHY_ZQ0SRO_PUODT_OFF               (15)            /* Pull-up on-die termination impedance select offset */
+
+#define        DDR3PHY_DX0DLLCR                        (0x1CC)         /* DDR3PHY DATX8 DLL Control Register */
+#define        DDR3PHY_DX1DLLCR                        (0x20C)         /* DDR3PHY DATX8 DLL Control Register */
+#define                DDR3PHY_DXDLLCR_DLLDIS          (1 << 31)       /* DLL Disable */
 
 /* UDDRC */
 #define UDDRC_STAT                             (0x04)          /* UDDRC Operating Mode Status Register */
index 45264e4..50a974f 100644 (file)
@@ -9,6 +9,15 @@
 #include <linux/netdevice.h>
 #include <linux/tracepoint.h>
 
+#undef FN
+#define FN(reason)     TRACE_DEFINE_ENUM(SKB_DROP_REASON_##reason);
+DEFINE_DROP_REASON(FN, FN)
+
+#undef FN
+#undef FNe
+#define FN(reason)     { SKB_DROP_REASON_##reason, #reason },
+#define FNe(reason)    { SKB_DROP_REASON_##reason, #reason }
+
 /*
  * Tracepoint for free an sk_buff:
  */
@@ -35,9 +44,13 @@ TRACE_EVENT(kfree_skb,
 
        TP_printk("skbaddr=%p protocol=%u location=%p reason: %s",
                  __entry->skbaddr, __entry->protocol, __entry->location,
-                 drop_reasons[__entry->reason])
+                 __print_symbolic(__entry->reason,
+                                  DEFINE_DROP_REASON(FN, FNe)))
 );
 
+#undef FN
+#undef FNe
+
 TRACE_EVENT(consume_skb,
 
        TP_PROTO(struct sk_buff *skb),
index 7bf9ba1..59a217c 100644 (file)
@@ -79,7 +79,7 @@ struct bpf_insn {
 /* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
 struct bpf_lpm_trie_key {
        __u32   prefixlen;      /* up to 32 for AF_INET, 128 for AF_INET6 */
-       __u8    data[]; /* Arbitrary size */
+       __u8    data[0];        /* Arbitrary size */
 };
 
 struct bpf_cgroup_storage_key {
index 1463cfe..6b83177 100644 (file)
 #include <linux/types.h>
 #include <linux/time_types.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * IO submission data structure (Submission Queue Entry)
  */
@@ -67,8 +71,8 @@ struct io_uring_sqe {
                __s32   splice_fd_in;
                __u32   file_index;
                struct {
-                       __u16   notification_idx;
                        __u16   addr_len;
+                       __u16   __pad3[1];
                };
        };
        union {
@@ -174,8 +178,7 @@ enum io_uring_op {
        IORING_OP_FALLOCATE,
        IORING_OP_OPENAT,
        IORING_OP_CLOSE,
-       IORING_OP_RSRC_UPDATE,
-       IORING_OP_FILES_UPDATE = IORING_OP_RSRC_UPDATE,
+       IORING_OP_FILES_UPDATE,
        IORING_OP_STATX,
        IORING_OP_READ,
        IORING_OP_WRITE,
@@ -202,7 +205,7 @@ enum io_uring_op {
        IORING_OP_GETXATTR,
        IORING_OP_SOCKET,
        IORING_OP_URING_CMD,
-       IORING_OP_SENDZC_NOTIF,
+       IORING_OP_SEND_ZC,
 
        /* this goes last, obviously */
        IORING_OP_LAST,
@@ -224,7 +227,6 @@ enum io_uring_op {
 #define IORING_TIMEOUT_ETIME_SUCCESS   (1U << 5)
 #define IORING_TIMEOUT_CLOCK_MASK      (IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME)
 #define IORING_TIMEOUT_UPDATE_MASK     (IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE)
-
 /*
  * sqe->splice_flags
  * extends splice(2) flags
@@ -277,29 +279,16 @@ enum io_uring_op {
  *
  * IORING_RECVSEND_FIXED_BUF   Use registered buffers, the index is stored in
  *                             the buf_index field.
- *
- * IORING_RECVSEND_NOTIF_FLUSH Flush a notification after a successful
- *                             successful. Only for zerocopy sends.
  */
 #define IORING_RECVSEND_POLL_FIRST     (1U << 0)
 #define IORING_RECV_MULTISHOT          (1U << 1)
 #define IORING_RECVSEND_FIXED_BUF      (1U << 2)
-#define IORING_RECVSEND_NOTIF_FLUSH    (1U << 3)
 
 /*
  * accept flags stored in sqe->ioprio
  */
 #define IORING_ACCEPT_MULTISHOT        (1U << 0)
 
-
-/*
- * IORING_OP_RSRC_UPDATE flags
- */
-enum {
-       IORING_RSRC_UPDATE_FILES,
-       IORING_RSRC_UPDATE_NOTIF,
-};
-
 /*
  * IORING_OP_MSG_RING command types, stored in sqe->addr
  */
@@ -337,10 +326,13 @@ struct io_uring_cqe {
  * IORING_CQE_F_BUFFER If set, the upper 16 bits are the buffer ID
  * IORING_CQE_F_MORE   If set, parent SQE will generate more CQE entries
  * IORING_CQE_F_SOCK_NONEMPTY  If set, more data to read after socket recv
+ * IORING_CQE_F_NOTIF  Set for notification CQEs. Can be used to distinct
+ *                     them from sends.
  */
 #define IORING_CQE_F_BUFFER            (1U << 0)
 #define IORING_CQE_F_MORE              (1U << 1)
 #define IORING_CQE_F_SOCK_NONEMPTY     (1U << 2)
+#define IORING_CQE_F_NOTIF             (1U << 3)
 
 enum {
        IORING_CQE_BUFFER_SHIFT         = 16,
@@ -481,10 +473,6 @@ enum {
        /* register a range of fixed file slots for automatic slot allocation */
        IORING_REGISTER_FILE_ALLOC_RANGE        = 25,
 
-       /* zerocopy notification API */
-       IORING_REGISTER_NOTIFIERS               = 26,
-       IORING_UNREGISTER_NOTIFIERS             = 27,
-
        /* this goes last */
        IORING_REGISTER_LAST
 };
@@ -661,4 +649,8 @@ struct io_uring_recvmsg_out {
        __u32 flags;
 };
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 29ced55..6cb842e 100644 (file)
@@ -56,7 +56,7 @@
 #define VIRTIO_NET_F_MQ        22      /* Device supports Receive Flow
                                         * Steering */
 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23  /* Set MAC address */
-#define VIRTIO_NET_F_NOTF_COAL 53      /* Guest can handle notifications coalescing */
+#define VIRTIO_NET_F_NOTF_COAL 53      /* Device supports notifications coalescing */
 #define VIRTIO_NET_F_HASH_REPORT  57   /* Supports hash report */
 #define VIRTIO_NET_F_RSS         60    /* Supports RSS RX steering */
 #define VIRTIO_NET_F_RSC_EXT     61    /* extended coalescing info */
@@ -364,24 +364,24 @@ struct virtio_net_hash_config {
  */
 #define VIRTIO_NET_CTRL_NOTF_COAL              6
 /*
- * Set the tx-usecs/tx-max-packets patameters.
- * tx-usecs - Maximum number of usecs to delay a TX notification.
- * tx-max-packets - Maximum number of packets to send before a TX notification.
+ * Set the tx-usecs/tx-max-packets parameters.
  */
 struct virtio_net_ctrl_coal_tx {
+       /* Maximum number of packets to send before a TX notification */
        __le32 tx_max_packets;
+       /* Maximum number of usecs to delay a TX notification */
        __le32 tx_usecs;
 };
 
 #define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET               0
 
 /*
- * Set the rx-usecs/rx-max-packets patameters.
- * rx-usecs - Maximum number of usecs to delay a RX notification.
- * rx-max-frames - Maximum number of packets to receive before a RX notification.
+ * Set the rx-usecs/rx-max-packets parameters.
  */
 struct virtio_net_ctrl_coal_rx {
+       /* Maximum number of packets to receive before a RX notification */
        __le32 rx_max_packets;
+       /* Maximum number of usecs to delay a RX notification */
        __le32 rx_usecs;
 };
 
index b1f3e6a..4f84ea7 100644 (file)
@@ -296,7 +296,7 @@ enum xfrm_attr_type_t {
        XFRMA_ETIMER_THRESH,
        XFRMA_SRCADDR,          /* xfrm_address_t */
        XFRMA_COADDR,           /* xfrm_address_t */
-       XFRMA_LASTUSED,         /* unsigned long  */
+       XFRMA_LASTUSED,         /* __u64 */
        XFRMA_POLICY_TYPE,      /* struct xfrm_userpolicy_type */
        XFRMA_MIGRATE,
        XFRMA_ALG_AEAD,         /* struct xfrm_algo_aead */
index f81aa95..f525566 100644 (file)
@@ -135,11 +135,7 @@ static inline u32 ufshci_version(u32 major, u32 minor)
 
 #define UFSHCD_UIC_MASK                (UIC_COMMAND_COMPL | UFSHCD_UIC_PWR_MASK)
 
-#define UFSHCD_ERROR_MASK      (UIC_ERROR |\
-                               DEVICE_FATAL_ERROR |\
-                               CONTROLLER_FATAL_ERROR |\
-                               SYSTEM_BUS_FATAL_ERROR |\
-                               CRYPTO_ENGINE_FATAL_ERROR)
+#define UFSHCD_ERROR_MASK      (UIC_ERROR | INT_FATAL_ERRORS)
 
 #define INT_FATAL_ERRORS       (DEVICE_FATAL_ERROR |\
                                CONTROLLER_FATAL_ERROR |\
index 91642a4..1fe7942 100644 (file)
@@ -1446,13 +1446,25 @@ static noinline void __init kernel_init_freeable(void);
 
 #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)
 bool rodata_enabled __ro_after_init = true;
+
+#ifndef arch_parse_debug_rodata
+static inline bool arch_parse_debug_rodata(char *str) { return false; }
+#endif
+
 static int __init set_debug_rodata(char *str)
 {
-       if (strtobool(str, &rodata_enabled))
+       if (arch_parse_debug_rodata(str))
+               return 0;
+
+       if (str && !strcmp(str, "on"))
+               rodata_enabled = true;
+       else if (str && !strcmp(str, "off"))
+               rodata_enabled = false;
+       else
                pr_warn("Invalid option string for rodata: '%s'\n", str);
-       return 1;
+       return 0;
 }
-__setup("rodata=", set_debug_rodata);
+early_param("rodata", set_debug_rodata);
 #endif
 
 #ifdef CONFIG_STRICT_KERNEL_RWX
index e4e1dc0..5fc5d3e 100644 (file)
@@ -218,7 +218,7 @@ static int __io_sync_cancel(struct io_uring_task *tctx,
            (cd->flags & IORING_ASYNC_CANCEL_FD_FIXED)) {
                unsigned long file_ptr;
 
-               if (unlikely(fd > ctx->nr_user_files))
+               if (unlikely(fd >= ctx->nr_user_files))
                        return -EBADF;
                fd = array_index_nospec(fd, ctx->nr_user_files);
                file_ptr = io_fixed_file_slot(&ctx->file_table, fd)->file_ptr;
index ebfdb22..f9be9b7 100644 (file)
@@ -1450,9 +1450,10 @@ int io_req_prep_async(struct io_kiocb *req)
                return 0;
        if (WARN_ON_ONCE(req_has_async_data(req)))
                return -EFAULT;
-       if (io_alloc_async_data(req))
-               return -EAGAIN;
-
+       if (!io_op_defs[req->opcode].manual_alloc) {
+               if (io_alloc_async_data(req))
+                       return -EAGAIN;
+       }
        return def->prep_async(req);
 }
 
@@ -2639,7 +2640,6 @@ static __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
                io_unregister_personality(ctx, index);
        if (ctx->rings)
                io_poll_remove_all(ctx, NULL, true);
-       io_notif_unregister(ctx);
        mutex_unlock(&ctx->uring_lock);
 
        /* failed during ring init, it couldn't have issued any requests */
@@ -3838,15 +3838,6 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
                        break;
                ret = io_register_file_alloc_range(ctx, arg);
                break;
-       case IORING_REGISTER_NOTIFIERS:
-               ret = io_notif_register(ctx, arg, nr_args);
-               break;
-       case IORING_UNREGISTER_NOTIFIERS:
-               ret = -EINVAL;
-               if (arg || nr_args)
-                       break;
-               ret = io_notif_unregister(ctx);
-               break;
        default:
                ret = -EINVAL;
                break;
@@ -3932,8 +3923,8 @@ static int __init io_uring_init(void)
        BUILD_BUG_SQE_ELEM(42, __u16,  personality);
        BUILD_BUG_SQE_ELEM(44, __s32,  splice_fd_in);
        BUILD_BUG_SQE_ELEM(44, __u32,  file_index);
-       BUILD_BUG_SQE_ELEM(44, __u16,  notification_idx);
-       BUILD_BUG_SQE_ELEM(46, __u16,  addr_len);
+       BUILD_BUG_SQE_ELEM(44, __u16,  addr_len);
+       BUILD_BUG_SQE_ELEM(46, __u16,  __pad3[0]);
        BUILD_BUG_SQE_ELEM(48, __u64,  addr3);
        BUILD_BUG_SQE_ELEM_SIZE(48, 0, cmd);
        BUILD_BUG_SQE_ELEM(56, __u64,  __pad2);
index f8cdf1d..7047c13 100644 (file)
@@ -65,12 +65,12 @@ struct io_sendzc {
        struct file                     *file;
        void __user                     *buf;
        size_t                          len;
-       u16                             slot_idx;
        unsigned                        msg_flags;
        unsigned                        flags;
        unsigned                        addr_len;
        void __user                     *addr;
        size_t                          done_io;
+       struct io_kiocb                 *notif;
 };
 
 #define IO_APOLL_MULTI_POLLED (REQ_F_APOLL_MULTISHOT | REQ_F_POLLED)
@@ -182,6 +182,37 @@ static int io_sendmsg_copy_hdr(struct io_kiocb *req,
                                        &iomsg->free_iov);
 }
 
+int io_sendzc_prep_async(struct io_kiocb *req)
+{
+       struct io_sendzc *zc = io_kiocb_to_cmd(req, struct io_sendzc);
+       struct io_async_msghdr *io;
+       int ret;
+
+       if (!zc->addr || req_has_async_data(req))
+               return 0;
+       if (io_alloc_async_data(req))
+               return -ENOMEM;
+
+       io = req->async_data;
+       ret = move_addr_to_kernel(zc->addr, zc->addr_len, &io->addr);
+       return ret;
+}
+
+static int io_setup_async_addr(struct io_kiocb *req,
+                             struct sockaddr_storage *addr,
+                             unsigned int issue_flags)
+{
+       struct io_async_msghdr *io;
+
+       if (!addr || req_has_async_data(req))
+               return -EAGAIN;
+       if (io_alloc_async_data(req))
+               return -ENOMEM;
+       io = req->async_data;
+       memcpy(&io->addr, addr, sizeof(io->addr));
+       return -EAGAIN;
+}
+
 int io_sendmsg_prep_async(struct io_kiocb *req)
 {
        int ret;
@@ -848,17 +879,31 @@ out_free:
        return ret;
 }
 
+void io_sendzc_cleanup(struct io_kiocb *req)
+{
+       struct io_sendzc *zc = io_kiocb_to_cmd(req, struct io_sendzc);
+
+       zc->notif->flags |= REQ_F_CQE_SKIP;
+       io_notif_flush(zc->notif);
+       zc->notif = NULL;
+}
+
 int io_sendzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
        struct io_sendzc *zc = io_kiocb_to_cmd(req, struct io_sendzc);
        struct io_ring_ctx *ctx = req->ctx;
+       struct io_kiocb *notif;
 
-       if (READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3))
+       if (READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3) ||
+           READ_ONCE(sqe->__pad3[0]))
+               return -EINVAL;
+       /* we don't support IOSQE_CQE_SKIP_SUCCESS just yet */
+       if (req->flags & REQ_F_CQE_SKIP)
                return -EINVAL;
 
        zc->flags = READ_ONCE(sqe->ioprio);
        if (zc->flags & ~(IORING_RECVSEND_POLL_FIRST |
-                         IORING_RECVSEND_FIXED_BUF | IORING_RECVSEND_NOTIF_FLUSH))
+                         IORING_RECVSEND_FIXED_BUF))
                return -EINVAL;
        if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
                unsigned idx = READ_ONCE(sqe->buf_index);
@@ -869,11 +914,17 @@ int io_sendzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
                req->imu = READ_ONCE(ctx->user_bufs[idx]);
                io_req_set_rsrc_node(req, ctx, 0);
        }
+       notif = zc->notif = io_alloc_notif(ctx);
+       if (!notif)
+               return -ENOMEM;
+       notif->cqe.user_data = req->cqe.user_data;
+       notif->cqe.res = 0;
+       notif->cqe.flags = IORING_CQE_F_NOTIF;
+       req->flags |= REQ_F_NEED_CLEANUP;
 
        zc->buf = u64_to_user_ptr(READ_ONCE(sqe->addr));
        zc->len = READ_ONCE(sqe->len);
        zc->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL;
-       zc->slot_idx = READ_ONCE(sqe->notification_idx);
        if (zc->msg_flags & MSG_DONTWAIT)
                req->flags |= REQ_F_NOWAIT;
 
@@ -925,7 +976,7 @@ static int io_sg_from_iter(struct sock *sk, struct sk_buff *skb,
        shinfo->nr_frags = frag;
        from->bvec += bi.bi_idx;
        from->nr_segs -= bi.bi_idx;
-       from->count = bi.bi_size;
+       from->count -= copied;
        from->iov_offset = bi.bi_bvec_done;
 
        skb->data_len += copied;
@@ -944,44 +995,38 @@ static int io_sg_from_iter(struct sock *sk, struct sk_buff *skb,
 
 int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
 {
-       struct sockaddr_storage address;
-       struct io_ring_ctx *ctx = req->ctx;
+       struct sockaddr_storage __address, *addr = NULL;
        struct io_sendzc *zc = io_kiocb_to_cmd(req, struct io_sendzc);
-       struct io_notif_slot *notif_slot;
-       struct io_kiocb *notif;
        struct msghdr msg;
        struct iovec iov;
        struct socket *sock;
-       unsigned msg_flags;
+       unsigned msg_flags, cflags;
        int ret, min_ret = 0;
 
        if (!(req->flags & REQ_F_POLLED) &&
            (zc->flags & IORING_RECVSEND_POLL_FIRST))
                return -EAGAIN;
-
-       if (issue_flags & IO_URING_F_UNLOCKED)
-               return -EAGAIN;
        sock = sock_from_file(req->file);
        if (unlikely(!sock))
                return -ENOTSOCK;
 
-       notif_slot = io_get_notif_slot(ctx, zc->slot_idx);
-       if (!notif_slot)
-               return -EINVAL;
-       notif = io_get_notif(ctx, notif_slot);
-       if (!notif)
-               return -ENOMEM;
-
        msg.msg_name = NULL;
        msg.msg_control = NULL;
        msg.msg_controllen = 0;
        msg.msg_namelen = 0;
 
        if (zc->addr) {
-               ret = move_addr_to_kernel(zc->addr, zc->addr_len, &address);
-               if (unlikely(ret < 0))
-                       return ret;
-               msg.msg_name = (struct sockaddr *)&address;
+               if (req_has_async_data(req)) {
+                       struct io_async_msghdr *io = req->async_data;
+
+                       msg.msg_name = addr = &io->addr;
+               } else {
+                       ret = move_addr_to_kernel(zc->addr, zc->addr_len, &__address);
+                       if (unlikely(ret < 0))
+                               return ret;
+                       msg.msg_name = (struct sockaddr *)&__address;
+                       addr = &__address;
+               }
                msg.msg_namelen = zc->addr_len;
        }
 
@@ -989,13 +1034,13 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
                ret = io_import_fixed(WRITE, &msg.msg_iter, req->imu,
                                        (u64)(uintptr_t)zc->buf, zc->len);
                if (unlikely(ret))
-                               return ret;
+                       return ret;
        } else {
                ret = import_single_range(WRITE, zc->buf, zc->len, &iov,
                                          &msg.msg_iter);
                if (unlikely(ret))
                        return ret;
-               ret = io_notif_account_mem(notif, zc->len);
+               ret = io_notif_account_mem(zc->notif, zc->len);
                if (unlikely(ret))
                        return ret;
        }
@@ -1007,31 +1052,37 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
                min_ret = iov_iter_count(&msg.msg_iter);
 
        msg.msg_flags = msg_flags;
-       msg.msg_ubuf = &io_notif_to_data(notif)->uarg;
+       msg.msg_ubuf = &io_notif_to_data(zc->notif)->uarg;
        msg.sg_from_iter = io_sg_from_iter;
        ret = sock_sendmsg(sock, &msg);
 
        if (unlikely(ret < min_ret)) {
                if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))
-                       return -EAGAIN;
+                       return io_setup_async_addr(req, addr, issue_flags);
+
                if (ret > 0 && io_net_retry(sock, msg.msg_flags)) {
                        zc->len -= ret;
                        zc->buf += ret;
                        zc->done_io += ret;
                        req->flags |= REQ_F_PARTIAL_IO;
-                       return -EAGAIN;
+                       return io_setup_async_addr(req, addr, issue_flags);
                }
+               if (ret < 0 && !zc->done_io)
+                       zc->notif->flags |= REQ_F_CQE_SKIP;
                if (ret == -ERESTARTSYS)
                        ret = -EINTR;
-       } else if (zc->flags & IORING_RECVSEND_NOTIF_FLUSH) {
-               io_notif_slot_flush_submit(notif_slot, 0);
+               req_set_fail(req);
        }
 
        if (ret >= 0)
                ret += zc->done_io;
        else if (zc->done_io)
                ret = zc->done_io;
-       io_req_set_res(req, ret, 0);
+
+       io_notif_flush(zc->notif);
+       req->flags &= ~REQ_F_NEED_CLEANUP;
+       cflags = ret >= 0 ? IORING_CQE_F_MORE : 0;
+       io_req_set_res(req, ret, cflags);
        return IOU_OK;
 }
 
index 7c438d3..d744a0a 100644 (file)
@@ -31,6 +31,7 @@ struct io_async_connect {
 int io_shutdown_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
 int io_shutdown(struct io_kiocb *req, unsigned int issue_flags);
 
+int io_sendzc_prep_async(struct io_kiocb *req);
 int io_sendmsg_prep_async(struct io_kiocb *req);
 void io_sendmsg_recvmsg_cleanup(struct io_kiocb *req);
 int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
@@ -54,6 +55,7 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags);
 
 int io_sendzc(struct io_kiocb *req, unsigned int issue_flags);
 int io_sendzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
+void io_sendzc_cleanup(struct io_kiocb *req);
 
 void io_netmsg_cache_free(struct io_cache_entry *entry);
 #else
index 977736e..38d7716 100644 (file)
@@ -42,8 +42,7 @@ static void io_uring_tx_zerocopy_callback(struct sk_buff *skb,
        }
 }
 
-struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx,
-                               struct io_notif_slot *slot)
+struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx)
        __must_hold(&ctx->uring_lock)
 {
        struct io_kiocb *notif;
@@ -59,99 +58,23 @@ struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx,
        io_get_task_refs(1);
        notif->rsrc_node = NULL;
        io_req_set_rsrc_node(notif, ctx, 0);
-       notif->cqe.user_data = slot->tag;
-       notif->cqe.flags = slot->seq++;
-       notif->cqe.res = 0;
 
        nd = io_notif_to_data(notif);
        nd->account_pages = 0;
        nd->uarg.flags = SKBFL_ZEROCOPY_FRAG | SKBFL_DONT_ORPHAN;
        nd->uarg.callback = io_uring_tx_zerocopy_callback;
-       /* master ref owned by io_notif_slot, will be dropped on flush */
        refcount_set(&nd->uarg.refcnt, 1);
        return notif;
 }
 
-void io_notif_slot_flush(struct io_notif_slot *slot)
-       __must_hold(&ctx->uring_lock)
+void io_notif_flush(struct io_kiocb *notif)
+       __must_hold(&slot->notif->ctx->uring_lock)
 {
-       struct io_kiocb *notif = slot->notif;
        struct io_notif_data *nd = io_notif_to_data(notif);
 
-       slot->notif = NULL;
-
        /* drop slot's master ref */
-       if (refcount_dec_and_test(&nd->uarg.refcnt))
-               io_notif_complete(notif);
-}
-
-__cold int io_notif_unregister(struct io_ring_ctx *ctx)
-       __must_hold(&ctx->uring_lock)
-{
-       int i;
-
-       if (!ctx->notif_slots)
-               return -ENXIO;
-
-       for (i = 0; i < ctx->nr_notif_slots; i++) {
-               struct io_notif_slot *slot = &ctx->notif_slots[i];
-               struct io_kiocb *notif = slot->notif;
-               struct io_notif_data *nd;
-
-               if (!notif)
-                       continue;
-               nd = io_notif_to_data(notif);
-               slot->notif = NULL;
-               if (!refcount_dec_and_test(&nd->uarg.refcnt))
-                       continue;
+       if (refcount_dec_and_test(&nd->uarg.refcnt)) {
                notif->io_task_work.func = __io_notif_complete_tw;
                io_req_task_work_add(notif);
        }
-
-       kvfree(ctx->notif_slots);
-       ctx->notif_slots = NULL;
-       ctx->nr_notif_slots = 0;
-       return 0;
-}
-
-__cold int io_notif_register(struct io_ring_ctx *ctx,
-                            void __user *arg, unsigned int size)
-       __must_hold(&ctx->uring_lock)
-{
-       struct io_uring_notification_slot __user *slots;
-       struct io_uring_notification_slot slot;
-       struct io_uring_notification_register reg;
-       unsigned i;
-
-       if (ctx->nr_notif_slots)
-               return -EBUSY;
-       if (size != sizeof(reg))
-               return -EINVAL;
-       if (copy_from_user(&reg, arg, sizeof(reg)))
-               return -EFAULT;
-       if (!reg.nr_slots || reg.nr_slots > IORING_MAX_NOTIF_SLOTS)
-               return -EINVAL;
-       if (reg.resv || reg.resv2 || reg.resv3)
-               return -EINVAL;
-
-       slots = u64_to_user_ptr(reg.data);
-       ctx->notif_slots = kvcalloc(reg.nr_slots, sizeof(ctx->notif_slots[0]),
-                               GFP_KERNEL_ACCOUNT);
-       if (!ctx->notif_slots)
-               return -ENOMEM;
-
-       for (i = 0; i < reg.nr_slots; i++, ctx->nr_notif_slots++) {
-               struct io_notif_slot *notif_slot = &ctx->notif_slots[i];
-
-               if (copy_from_user(&slot, &slots[i], sizeof(slot))) {
-                       io_notif_unregister(ctx);
-                       return -EFAULT;
-               }
-               if (slot.resv[0] | slot.resv[1] | slot.resv[2]) {
-                       io_notif_unregister(ctx);
-                       return -EINVAL;
-               }
-               notif_slot->tag = slot.tag;
-       }
-       return 0;
 }
index 80f6445..5b4d710 100644 (file)
@@ -8,7 +8,6 @@
 #include "rsrc.h"
 
 #define IO_NOTIF_SPLICE_BATCH  32
-#define IORING_MAX_NOTIF_SLOTS (1U << 15)
 
 struct io_notif_data {
        struct file             *file;
@@ -16,63 +15,14 @@ struct io_notif_data {
        unsigned long           account_pages;
 };
 
-struct io_notif_slot {
-       /*
-        * Current/active notifier. A slot holds only one active notifier at a
-        * time and keeps one reference to it. Flush releases the reference and
-        * lazily replaces it with a new notifier.
-        */
-       struct io_kiocb         *notif;
-
-       /*
-        * Default ->user_data for this slot notifiers CQEs
-        */
-       u64                     tag;
-       /*
-        * Notifiers of a slot live in generations, we create a new notifier
-        * only after flushing the previous one. Track the sequential number
-        * for all notifiers and copy it into notifiers's cqe->cflags
-        */
-       u32                     seq;
-};
-
-int io_notif_register(struct io_ring_ctx *ctx,
-                     void __user *arg, unsigned int size);
-int io_notif_unregister(struct io_ring_ctx *ctx);
-
-void io_notif_slot_flush(struct io_notif_slot *slot);
-struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx,
-                               struct io_notif_slot *slot);
+void io_notif_flush(struct io_kiocb *notif);
+struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx);
 
 static inline struct io_notif_data *io_notif_to_data(struct io_kiocb *notif)
 {
        return io_kiocb_to_cmd(notif, struct io_notif_data);
 }
 
-static inline struct io_kiocb *io_get_notif(struct io_ring_ctx *ctx,
-                                           struct io_notif_slot *slot)
-{
-       if (!slot->notif)
-               slot->notif = io_alloc_notif(ctx, slot);
-       return slot->notif;
-}
-
-static inline struct io_notif_slot *io_get_notif_slot(struct io_ring_ctx *ctx,
-                                                     unsigned idx)
-       __must_hold(&ctx->uring_lock)
-{
-       if (idx >= ctx->nr_notif_slots)
-               return NULL;
-       idx = array_index_nospec(idx, ctx->nr_notif_slots);
-       return &ctx->notif_slots[idx];
-}
-
-static inline void io_notif_slot_flush_submit(struct io_notif_slot *slot,
-                                             unsigned int issue_flags)
-{
-       io_notif_slot_flush(slot);
-}
-
 static inline int io_notif_account_mem(struct io_kiocb *notif, unsigned len)
 {
        struct io_ring_ctx *ctx = notif->ctx;
index 72dd2b2..c61494e 100644 (file)
@@ -246,13 +246,12 @@ const struct io_op_def io_op_defs[] = {
                .prep                   = io_close_prep,
                .issue                  = io_close,
        },
-       [IORING_OP_RSRC_UPDATE] = {
+       [IORING_OP_FILES_UPDATE] = {
                .audit_skip             = 1,
                .iopoll                 = 1,
-               .name                   = "RSRC_UPDATE",
-               .prep                   = io_rsrc_update_prep,
-               .issue                  = io_rsrc_update,
-               .ioprio                 = 1,
+               .name                   = "FILES_UPDATE",
+               .prep                   = io_files_update_prep,
+               .issue                  = io_files_update,
        },
        [IORING_OP_STATX] = {
                .audit_skip             = 1,
@@ -471,20 +470,23 @@ const struct io_op_def io_op_defs[] = {
                .issue                  = io_uring_cmd,
                .prep_async             = io_uring_cmd_prep_async,
        },
-       [IORING_OP_SENDZC_NOTIF] = {
+       [IORING_OP_SEND_ZC] = {
                .name                   = "SENDZC_NOTIF",
                .needs_file             = 1,
                .unbound_nonreg_file    = 1,
                .pollout                = 1,
                .audit_skip             = 1,
                .ioprio                 = 1,
+               .manual_alloc           = 1,
 #if defined(CONFIG_NET)
+               .async_size             = sizeof(struct io_async_msghdr),
                .prep                   = io_sendzc_prep,
                .issue                  = io_sendzc,
+               .prep_async             = io_sendzc_prep_async,
+               .cleanup                = io_sendzc_cleanup,
 #else
                .prep                   = io_eopnotsupp_prep,
 #endif
-
        },
 };
 
index ece8ed4..763c6e5 100644 (file)
@@ -25,6 +25,8 @@ struct io_op_def {
        unsigned                ioprio : 1;
        /* supports iopoll */
        unsigned                iopoll : 1;
+       /* opcode specific path will handle ->async_data allocation if needed */
+       unsigned                manual_alloc : 1;
        /* size of async data needed, if any */
        unsigned short          async_size;
 
index 71359a4..cf32721 100644 (file)
 #include "io_uring.h"
 #include "openclose.h"
 #include "rsrc.h"
-#include "notif.h"
 
 struct io_rsrc_update {
        struct file                     *file;
        u64                             arg;
        u32                             nr_args;
        u32                             offset;
-       int                             type;
 };
 
 static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,
@@ -655,7 +653,7 @@ __cold int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg,
        return -EINVAL;
 }
 
-int io_rsrc_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
+int io_files_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
        struct io_rsrc_update *up = io_kiocb_to_cmd(req, struct io_rsrc_update);
 
@@ -669,7 +667,6 @@ int io_rsrc_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
        if (!up->nr_args)
                return -EINVAL;
        up->arg = READ_ONCE(sqe->addr);
-       up->type = READ_ONCE(sqe->ioprio);
        return 0;
 }
 
@@ -712,7 +709,7 @@ static int io_files_update_with_index_alloc(struct io_kiocb *req,
        return ret;
 }
 
-static int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
+int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
 {
        struct io_rsrc_update *up = io_kiocb_to_cmd(req, struct io_rsrc_update);
        struct io_ring_ctx *ctx = req->ctx;
@@ -741,54 +738,6 @@ static int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
        return IOU_OK;
 }
 
-static int io_notif_update(struct io_kiocb *req, unsigned int issue_flags)
-{
-       struct io_rsrc_update *up = io_kiocb_to_cmd(req, struct io_rsrc_update);
-       struct io_ring_ctx *ctx = req->ctx;
-       unsigned len = up->nr_args;
-       unsigned idx_end, idx = up->offset;
-       int ret = 0;
-
-       io_ring_submit_lock(ctx, issue_flags);
-       if (unlikely(check_add_overflow(idx, len, &idx_end))) {
-               ret = -EOVERFLOW;
-               goto out;
-       }
-       if (unlikely(idx_end > ctx->nr_notif_slots)) {
-               ret = -EINVAL;
-               goto out;
-       }
-
-       for (; idx < idx_end; idx++) {
-               struct io_notif_slot *slot = &ctx->notif_slots[idx];
-
-               if (!slot->notif)
-                       continue;
-               if (up->arg)
-                       slot->tag = up->arg;
-               io_notif_slot_flush_submit(slot, issue_flags);
-       }
-out:
-       io_ring_submit_unlock(ctx, issue_flags);
-       if (ret < 0)
-               req_set_fail(req);
-       io_req_set_res(req, ret, 0);
-       return IOU_OK;
-}
-
-int io_rsrc_update(struct io_kiocb *req, unsigned int issue_flags)
-{
-       struct io_rsrc_update *up = io_kiocb_to_cmd(req, struct io_rsrc_update);
-
-       switch (up->type) {
-       case IORING_RSRC_UPDATE_FILES:
-               return io_files_update(req, issue_flags);
-       case IORING_RSRC_UPDATE_NOTIF:
-               return io_notif_update(req, issue_flags);
-       }
-       return -EINVAL;
-}
-
 int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx,
                          struct io_rsrc_node *node, void *rsrc)
 {
index f3a9a17..9bce156 100644 (file)
@@ -167,8 +167,8 @@ static inline u64 *io_get_tag_slot(struct io_rsrc_data *data, unsigned int idx)
        return &data->tags[table_idx][off];
 }
 
-int io_rsrc_update(struct io_kiocb *req, unsigned int issue_flags);
-int io_rsrc_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
+int io_files_update(struct io_kiocb *req, unsigned int issue_flags);
+int io_files_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
 
 int __io_account_mem(struct user_struct *user, unsigned long nr_pages);
 
index 8e0cc2d..e78b6f9 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/errno.h>
 #include <linux/file.h>
 #include <linux/io_uring.h>
+#include <linux/security.h>
 
 #include <uapi/linux/io_uring.h>
 
@@ -88,6 +89,10 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
        if (!req->file->f_op->uring_cmd)
                return -EOPNOTSUPP;
 
+       ret = security_uring_cmd(ioucmd);
+       if (ret)
+               return ret;
+
        if (ctx->flags & IORING_SETUP_SQE128)
                issue_flags |= IO_URING_F_SQE128;
        if (ctx->flags & IORING_SETUP_CQE32)
@@ -112,7 +117,7 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
                if (ret < 0)
                        req_set_fail(req);
                io_req_set_res(req, ret, 0);
-               return IOU_OK;
+               return ret;
        }
 
        return IOU_ISSUE_SKIP_COMPLETE;
index 6432a37..c565fbf 100644 (file)
@@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
 
        ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
        if (ret < 0) {
+               audit_mark->path = NULL;
                fsnotify_put_mark(&audit_mark->mark);
                audit_mark = ERR_PTR(ret);
        }
index dd8d9ab..79a5da1 100644 (file)
@@ -1940,6 +1940,7 @@ void __audit_uring_exit(int success, long code)
                goto out;
        }
 
+       audit_return_fixup(ctx, success, code);
        if (ctx->context == AUDIT_CTX_SYSCALL) {
                /*
                 * NOTE: See the note in __audit_uring_entry() about the case
@@ -1981,7 +1982,6 @@ void __audit_uring_exit(int success, long code)
        audit_filter_inodes(current, ctx);
        if (ctx->current_state != AUDIT_STATE_RECORD)
                goto out;
-       audit_return_fixup(ctx, success, code);
        audit_log_exit();
 
 out:
@@ -2065,13 +2065,13 @@ void __audit_syscall_exit(int success, long return_code)
        if (!list_empty(&context->killed_trees))
                audit_kill_trees(context);
 
+       audit_return_fixup(context, success, return_code);
        /* run through both filters to ensure we set the filterkey properly */
        audit_filter_syscall(current, context);
        audit_filter_inodes(current, context);
        if (context->current_state < AUDIT_STATE_RECORD)
                goto out;
 
-       audit_return_fixup(context, success, return_code);
        audit_log_exit();
 
 out:
index 59b7eb6..4a400cd 100644 (file)
@@ -921,8 +921,10 @@ static void purge_effective_progs(struct cgroup *cgrp, struct bpf_prog *prog,
                                pos++;
                        }
                }
+
+               /* no link or prog match, skip the cgroup of this layer */
+               continue;
 found:
-               BUG_ON(!cg);
                progs = rcu_dereference_protected(
                                desc->bpf.effective[atype],
                                lockdep_is_held(&cgroup_mutex));
index c1e10d0..3d9eb3a 100644 (file)
@@ -971,7 +971,7 @@ pure_initcall(bpf_jit_charge_init);
 
 int bpf_jit_charge_modmem(u32 size)
 {
-       if (atomic_long_add_return(size, &bpf_jit_current) > bpf_jit_limit) {
+       if (atomic_long_add_return(size, &bpf_jit_current) > READ_ONCE(bpf_jit_limit)) {
                if (!bpf_capable()) {
                        atomic_long_sub(size, &bpf_jit_current);
                        return -EPERM;
index a4d40d9..2776062 100644 (file)
@@ -5197,7 +5197,7 @@ syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 {
        switch (func_id) {
        case BPF_FUNC_sys_bpf:
-               return &bpf_sys_bpf_proto;
+               return !perfmon_capable() ? NULL : &bpf_sys_bpf_proto;
        case BPF_FUNC_btf_find_by_name_kind:
                return &bpf_btf_find_by_name_kind_proto;
        case BPF_FUNC_sys_close:
index 096fdac..3eadb14 100644 (file)
@@ -6066,6 +6066,9 @@ skip_type_check:
                        return -EACCES;
                }
                meta->mem_size = reg->var_off.value;
+               err = mark_chain_precision(env, regno);
+               if (err)
+                       return err;
                break;
        case ARG_PTR_TO_INT:
        case ARG_PTR_TO_LONG:
@@ -7030,8 +7033,7 @@ record_func_key(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,
        struct bpf_insn_aux_data *aux = &env->insn_aux_data[insn_idx];
        struct bpf_reg_state *regs = cur_regs(env), *reg;
        struct bpf_map *map = meta->map_ptr;
-       struct tnum range;
-       u64 val;
+       u64 val, max;
        int err;
 
        if (func_id != BPF_FUNC_tail_call)
@@ -7041,10 +7043,11 @@ record_func_key(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,
                return -EINVAL;
        }
 
-       range = tnum_range(0, map->max_entries - 1);
        reg = &regs[BPF_REG_3];
+       val = reg->var_off.value;
+       max = map->max_entries;
 
-       if (!register_is_const(reg) || !tnum_in(range, reg->var_off)) {
+       if (!(register_is_const(reg) && val < max)) {
                bpf_map_key_store(aux, BPF_MAP_KEY_POISON);
                return 0;
        }
@@ -7052,8 +7055,6 @@ record_func_key(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,
        err = mark_chain_precision(env, BPF_REG_3);
        if (err)
                return err;
-
-       val = reg->var_off.value;
        if (bpf_map_key_unseen(aux))
                bpf_map_key_store(aux, val);
        else if (!bpf_map_key_poisoned(aux) &&
index 2ade21b..ff6a809 100644 (file)
@@ -59,6 +59,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
        int retval = 0;
 
        mutex_lock(&cgroup_mutex);
+       cpus_read_lock();
        percpu_down_write(&cgroup_threadgroup_rwsem);
        for_each_root(root) {
                struct cgroup *from_cgrp;
@@ -72,6 +73,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
                        break;
        }
        percpu_up_write(&cgroup_threadgroup_rwsem);
+       cpus_read_unlock();
        mutex_unlock(&cgroup_mutex);
 
        return retval;
index ffaccd6..e4bb5d5 100644 (file)
@@ -1820,6 +1820,7 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
 
                if (ss->css_rstat_flush) {
                        list_del_rcu(&css->rstat_css_node);
+                       synchronize_rcu();
                        list_add_rcu(&css->rstat_css_node,
                                     &dcgrp->rstat_css_list);
                }
@@ -2370,6 +2371,47 @@ int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen)
 EXPORT_SYMBOL_GPL(task_cgroup_path);
 
 /**
+ * cgroup_attach_lock - Lock for ->attach()
+ * @lock_threadgroup: whether to down_write cgroup_threadgroup_rwsem
+ *
+ * cgroup migration sometimes needs to stabilize threadgroups against forks and
+ * exits by write-locking cgroup_threadgroup_rwsem. However, some ->attach()
+ * implementations (e.g. cpuset), also need to disable CPU hotplug.
+ * Unfortunately, letting ->attach() operations acquire cpus_read_lock() can
+ * lead to deadlocks.
+ *
+ * Bringing up a CPU may involve creating and destroying tasks which requires
+ * read-locking threadgroup_rwsem, so threadgroup_rwsem nests inside
+ * cpus_read_lock(). If we call an ->attach() which acquires the cpus lock while
+ * write-locking threadgroup_rwsem, the locking order is reversed and we end up
+ * waiting for an on-going CPU hotplug operation which in turn is waiting for
+ * the threadgroup_rwsem to be released to create new tasks. For more details:
+ *
+ *   http://lkml.kernel.org/r/20220711174629.uehfmqegcwn2lqzu@wubuntu
+ *
+ * Resolve the situation by always acquiring cpus_read_lock() before optionally
+ * write-locking cgroup_threadgroup_rwsem. This allows ->attach() to assume that
+ * CPU hotplug is disabled on entry.
+ */
+static void cgroup_attach_lock(bool lock_threadgroup)
+{
+       cpus_read_lock();
+       if (lock_threadgroup)
+               percpu_down_write(&cgroup_threadgroup_rwsem);
+}
+
+/**
+ * cgroup_attach_unlock - Undo cgroup_attach_lock()
+ * @lock_threadgroup: whether to up_write cgroup_threadgroup_rwsem
+ */
+static void cgroup_attach_unlock(bool lock_threadgroup)
+{
+       if (lock_threadgroup)
+               percpu_up_write(&cgroup_threadgroup_rwsem);
+       cpus_read_unlock();
+}
+
+/**
  * cgroup_migrate_add_task - add a migration target task to a migration context
  * @task: target task
  * @mgctx: target migration context
@@ -2841,8 +2883,7 @@ int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader,
 }
 
 struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup,
-                                            bool *locked)
-       __acquires(&cgroup_threadgroup_rwsem)
+                                            bool *threadgroup_locked)
 {
        struct task_struct *tsk;
        pid_t pid;
@@ -2859,12 +2900,8 @@ struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup,
         * Therefore, we can skip the global lock.
         */
        lockdep_assert_held(&cgroup_mutex);
-       if (pid || threadgroup) {
-               percpu_down_write(&cgroup_threadgroup_rwsem);
-               *locked = true;
-       } else {
-               *locked = false;
-       }
+       *threadgroup_locked = pid || threadgroup;
+       cgroup_attach_lock(*threadgroup_locked);
 
        rcu_read_lock();
        if (pid) {
@@ -2895,17 +2932,14 @@ struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup,
        goto out_unlock_rcu;
 
 out_unlock_threadgroup:
-       if (*locked) {
-               percpu_up_write(&cgroup_threadgroup_rwsem);
-               *locked = false;
-       }
+       cgroup_attach_unlock(*threadgroup_locked);
+       *threadgroup_locked = false;
 out_unlock_rcu:
        rcu_read_unlock();
        return tsk;
 }
 
-void cgroup_procs_write_finish(struct task_struct *task, bool locked)
-       __releases(&cgroup_threadgroup_rwsem)
+void cgroup_procs_write_finish(struct task_struct *task, bool threadgroup_locked)
 {
        struct cgroup_subsys *ss;
        int ssid;
@@ -2913,8 +2947,8 @@ void cgroup_procs_write_finish(struct task_struct *task, bool locked)
        /* release reference from cgroup_procs_write_start() */
        put_task_struct(task);
 
-       if (locked)
-               percpu_up_write(&cgroup_threadgroup_rwsem);
+       cgroup_attach_unlock(threadgroup_locked);
+
        for_each_subsys(ss, ssid)
                if (ss->post_attach)
                        ss->post_attach();
@@ -3000,8 +3034,7 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp)
         * write-locking can be skipped safely.
         */
        has_tasks = !list_empty(&mgctx.preloaded_src_csets);
-       if (has_tasks)
-               percpu_down_write(&cgroup_threadgroup_rwsem);
+       cgroup_attach_lock(has_tasks);
 
        /* NULL dst indicates self on default hierarchy */
        ret = cgroup_migrate_prepare_dst(&mgctx);
@@ -3022,8 +3055,7 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp)
        ret = cgroup_migrate_execute(&mgctx);
 out_finish:
        cgroup_migrate_finish(&mgctx);
-       if (has_tasks)
-               percpu_up_write(&cgroup_threadgroup_rwsem);
+       cgroup_attach_unlock(has_tasks);
        return ret;
 }
 
@@ -3698,7 +3730,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf,
        }
 
        psi = cgroup_ino(cgrp) == 1 ? &psi_system : cgrp->psi;
-       new = psi_trigger_create(psi, buf, nbytes, res);
+       new = psi_trigger_create(psi, buf, res);
        if (IS_ERR(new)) {
                cgroup_put(cgrp);
                return PTR_ERR(new);
@@ -4971,13 +5003,13 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf,
        struct task_struct *task;
        const struct cred *saved_cred;
        ssize_t ret;
-       bool locked;
+       bool threadgroup_locked;
 
        dst_cgrp = cgroup_kn_lock_live(of->kn, false);
        if (!dst_cgrp)
                return -ENODEV;
 
-       task = cgroup_procs_write_start(buf, threadgroup, &locked);
+       task = cgroup_procs_write_start(buf, threadgroup, &threadgroup_locked);
        ret = PTR_ERR_OR_ZERO(task);
        if (ret)
                goto out_unlock;
@@ -5003,7 +5035,7 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf,
        ret = cgroup_attach_task(dst_cgrp, task, threadgroup);
 
 out_finish:
-       cgroup_procs_write_finish(task, locked);
+       cgroup_procs_write_finish(task, threadgroup_locked);
 out_unlock:
        cgroup_kn_unlock(of->kn);
 
index 58aadfd..1f3a552 100644 (file)
@@ -2289,7 +2289,7 @@ static void cpuset_attach(struct cgroup_taskset *tset)
        cgroup_taskset_first(tset, &css);
        cs = css_cs(css);
 
-       cpus_read_lock();
+       lockdep_assert_cpus_held();     /* see cgroup_attach_lock() */
        percpu_down_write(&cpuset_rwsem);
 
        guarantee_online_mems(cs, &cpuset_attach_nodemask_to);
@@ -2343,7 +2343,6 @@ static void cpuset_attach(struct cgroup_taskset *tset)
                wake_up(&cpuset_attach_wq);
 
        percpu_up_write(&cpuset_rwsem);
-       cpus_read_unlock();
 }
 
 /* The various types of files and directories in a cpuset file system */
index 07b26df..a0eb4d5 100644 (file)
@@ -494,6 +494,7 @@ static int __init crash_save_vmcoreinfo_init(void)
 
 #ifdef CONFIG_KALLSYMS
        VMCOREINFO_SYMBOL(kallsyms_names);
+       VMCOREINFO_SYMBOL(kallsyms_num_syms);
        VMCOREINFO_SYMBOL(kallsyms_token_table);
        VMCOREINFO_SYMBOL(kallsyms_token_index);
 #ifdef CONFIG_KALLSYMS_BASE_RELATIVE
index 80697e5..ca9d834 100644 (file)
@@ -1562,6 +1562,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
        /* Ensure it is not in reserved area nor out of text */
        if (!(core_kernel_text((unsigned long) p->addr) ||
            is_module_text_address((unsigned long) p->addr)) ||
+           in_gate_area_no_mm((unsigned long) p->addr) ||
            within_kprobe_blacklist((unsigned long) p->addr) ||
            jump_label_text_reserved(p->addr, p->addr) ||
            static_call_text_reserved(p->addr, p->addr) ||
@@ -1707,11 +1708,12 @@ static struct kprobe *__disable_kprobe(struct kprobe *p)
                /* Try to disarm and disable this/parent probe */
                if (p == orig_p || aggr_kprobe_disabled(orig_p)) {
                        /*
-                        * If 'kprobes_all_disarmed' is set, 'orig_p'
-                        * should have already been disarmed, so
-                        * skip unneed disarming process.
+                        * Don't be lazy here.  Even if 'kprobes_all_disarmed'
+                        * is false, 'orig_p' might not have been armed yet.
+                        * Note arm_all_kprobes() __tries__ to arm all kprobes
+                        * on the best effort basis.
                         */
-                       if (!kprobes_all_disarmed) {
+                       if (!kprobes_all_disarmed && !kprobe_disabled(orig_p)) {
                                ret = disarm_kprobe(orig_p, true);
                                if (ret) {
                                        p->flags &= ~KPROBE_FLAG_DISABLED;
index 6a477c6..a4e4d84 100644 (file)
@@ -2099,7 +2099,7 @@ static int find_module_sections(struct module *mod, struct load_info *info)
                                              sizeof(*mod->static_call_sites),
                                              &mod->num_static_call_sites);
 #endif
-#ifdef CONFIG_KUNIT
+#if IS_ENABLED(CONFIG_KUNIT)
        mod->kunit_suites = section_objs(info, ".kunit_test_suites",
                                              sizeof(*mod->kunit_suites),
                                              &mod->num_kunit_suites);
index ec66b40..ecb4b4f 100644 (file)
@@ -190,12 +190,8 @@ static void group_init(struct psi_group *group)
        /* Init trigger-related members */
        mutex_init(&group->trigger_lock);
        INIT_LIST_HEAD(&group->triggers);
-       memset(group->nr_triggers, 0, sizeof(group->nr_triggers));
-       group->poll_states = 0;
        group->poll_min_period = U32_MAX;
-       memset(group->polling_total, 0, sizeof(group->polling_total));
        group->polling_next_update = ULLONG_MAX;
-       group->polling_until = 0;
        init_waitqueue_head(&group->poll_wait);
        timer_setup(&group->poll_timer, poll_timer_fn, 0);
        rcu_assign_pointer(group->poll_task, NULL);
@@ -957,7 +953,7 @@ int psi_cgroup_alloc(struct cgroup *cgroup)
        if (static_branch_likely(&psi_disabled))
                return 0;
 
-       cgroup->psi = kmalloc(sizeof(struct psi_group), GFP_KERNEL);
+       cgroup->psi = kzalloc(sizeof(struct psi_group), GFP_KERNEL);
        if (!cgroup->psi)
                return -ENOMEM;
 
@@ -1091,7 +1087,7 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res)
 }
 
 struct psi_trigger *psi_trigger_create(struct psi_group *group,
-                       char *buf, size_t nbytes, enum psi_res res)
+                       char *buf, enum psi_res res)
 {
        struct psi_trigger *t;
        enum psi_states state;
@@ -1320,7 +1316,7 @@ static ssize_t psi_write(struct file *file, const char __user *user_buf,
                return -EBUSY;
        }
 
-       new = psi_trigger_create(&psi_system, buf, nbytes, res);
+       new = psi_trigger_create(&psi_system, buf, res);
        if (IS_ERR(new)) {
                mutex_unlock(&seq->lock);
                return PTR_ERR(new);
index d4788f8..0b1cd98 100644 (file)
@@ -47,7 +47,7 @@ __wait_on_bit(struct wait_queue_head *wq_head, struct wait_bit_queue_entry *wbq_
                prepare_to_wait(wq_head, &wbq_entry->wq_entry, mode);
                if (test_bit(wbq_entry->key.bit_nr, wbq_entry->key.flags))
                        ret = (*action)(&wbq_entry->key, mode);
-       } while (test_bit(wbq_entry->key.bit_nr, wbq_entry->key.flags) && !ret);
+       } while (test_bit_acquire(wbq_entry->key.bit_nr, wbq_entry->key.flags) && !ret);
 
        finish_wait(wq_head, &wbq_entry->wq_entry);
 
index a492f15..860b2dc 100644 (file)
@@ -277,6 +277,7 @@ COND_SYSCALL(landlock_restrict_self);
 
 /* mm/fadvise.c */
 COND_SYSCALL(fadvise64_64);
+COND_SYSCALL_COMPAT(fadvise64_64);
 
 /* mm/, CONFIG_MMU only */
 COND_SYSCALL(swapon);
index 126c769..439e2ab 100644 (file)
@@ -1861,8 +1861,6 @@ static void ftrace_hash_rec_enable_modify(struct ftrace_ops *ops,
        ftrace_hash_rec_update_modify(ops, filter_hash, 1);
 }
 
-static bool ops_references_ip(struct ftrace_ops *ops, unsigned long ip);
-
 /*
  * Try to update IPMODIFY flag on each ftrace_rec. Return 0 if it is OK
  * or no-needed to update, -EBUSY if it detects a conflict of the flag
@@ -3118,49 +3116,6 @@ static inline int ops_traces_mod(struct ftrace_ops *ops)
                ftrace_hash_empty(ops->func_hash->notrace_hash);
 }
 
-/*
- * Check if the current ops references the given ip.
- *
- * If the ops traces all functions, then it was already accounted for.
- * If the ops does not trace the current record function, skip it.
- * If the ops ignores the function via notrace filter, skip it.
- */
-static bool
-ops_references_ip(struct ftrace_ops *ops, unsigned long ip)
-{
-       /* If ops isn't enabled, ignore it */
-       if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
-               return false;
-
-       /* If ops traces all then it includes this function */
-       if (ops_traces_mod(ops))
-               return true;
-
-       /* The function must be in the filter */
-       if (!ftrace_hash_empty(ops->func_hash->filter_hash) &&
-           !__ftrace_lookup_ip(ops->func_hash->filter_hash, ip))
-               return false;
-
-       /* If in notrace hash, we ignore it too */
-       if (ftrace_lookup_ip(ops->func_hash->notrace_hash, ip))
-               return false;
-
-       return true;
-}
-
-/*
- * Check if the current ops references the record.
- *
- * If the ops traces all functions, then it was already accounted for.
- * If the ops does not trace the current record function, skip it.
- * If the ops ignores the function via notrace filter, skip it.
- */
-static bool
-ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
-{
-       return ops_references_ip(ops, rec->ip);
-}
-
 static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs)
 {
        bool init_nop = ftrace_need_init_nop();
@@ -6822,6 +6777,38 @@ static int ftrace_get_trampoline_kallsym(unsigned int symnum,
        return -ERANGE;
 }
 
+#if defined(CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS) || defined(CONFIG_MODULES)
+/*
+ * Check if the current ops references the given ip.
+ *
+ * If the ops traces all functions, then it was already accounted for.
+ * If the ops does not trace the current record function, skip it.
+ * If the ops ignores the function via notrace filter, skip it.
+ */
+static bool
+ops_references_ip(struct ftrace_ops *ops, unsigned long ip)
+{
+       /* If ops isn't enabled, ignore it */
+       if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
+               return false;
+
+       /* If ops traces all then it includes this function */
+       if (ops_traces_mod(ops))
+               return true;
+
+       /* The function must be in the filter */
+       if (!ftrace_hash_empty(ops->func_hash->filter_hash) &&
+           !__ftrace_lookup_ip(ops->func_hash->filter_hash, ip))
+               return false;
+
+       /* If in notrace hash, we ignore it too */
+       if (ftrace_lookup_ip(ops->func_hash->notrace_hash, ip))
+               return false;
+
+       return true;
+}
+#endif
+
 #ifdef CONFIG_MODULES
 
 #define next_to_ftrace_page(p) container_of(p, struct ftrace_page, next)
@@ -6834,7 +6821,7 @@ static int referenced_filters(struct dyn_ftrace *rec)
        int cnt = 0;
 
        for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
-               if (ops_references_rec(ops, rec)) {
+               if (ops_references_ip(ops, rec->ip)) {
                        if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_DIRECT))
                                continue;
                        if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_IPMODIFY))
index c1c47e2..dacc37b 100644 (file)
@@ -27,7 +27,7 @@ struct automaton_wip {
        bool final_states[state_max_wip];
 };
 
-struct automaton_wip automaton_wip = {
+static struct automaton_wip automaton_wip = {
        .state_names = {
                "preemptive",
                "non_preemptive"
index d1afe55..118e576 100644 (file)
@@ -27,7 +27,7 @@ struct automaton_wwnr {
        bool final_states[state_max_wwnr];
 };
 
-struct automaton_wwnr automaton_wwnr = {
+static struct automaton_wwnr automaton_wwnr = {
        .state_names = {
                "not_running",
                "running"
index b698d05..d65f6c2 100644 (file)
@@ -24,13 +24,13 @@ static struct rv_reactor rv_panic = {
        .react = rv_panic_reaction
 };
 
-static int register_react_panic(void)
+static int __init register_react_panic(void)
 {
        rv_register_reactor(&rv_panic);
        return 0;
 }
 
-static void unregister_react_panic(void)
+static void __exit unregister_react_panic(void)
 {
        rv_unregister_reactor(&rv_panic);
 }
index 31899f9..4b6b710 100644 (file)
@@ -23,13 +23,13 @@ static struct rv_reactor rv_printk = {
        .react = rv_printk_reaction
 };
 
-static int register_react_printk(void)
+static int __init register_react_printk(void)
 {
        rv_register_reactor(&rv_printk);
        return 0;
 }
 
-static void unregister_react_printk(void)
+static void __exit unregister_react_printk(void)
 {
        rv_unregister_reactor(&rv_printk);
 }
index cb866c3..918730d 100644 (file)
@@ -142,7 +142,8 @@ static bool check_user_trigger(struct trace_event_file *file)
 {
        struct event_trigger_data *data;
 
-       list_for_each_entry_rcu(data, &file->triggers, list) {
+       list_for_each_entry_rcu(data, &file->triggers, list,
+                               lockdep_is_held(&event_mutex)) {
                if (data->flags & EVENT_TRIGGER_FL_PROBE)
                        continue;
                return true;
index 95b58bd..1e130da 100644 (file)
@@ -95,14 +95,14 @@ __visible void trace_hardirqs_on_caller(unsigned long caller_addr)
        }
 
        lockdep_hardirqs_on_prepare();
-       lockdep_hardirqs_on(CALLER_ADDR0);
+       lockdep_hardirqs_on(caller_addr);
 }
 EXPORT_SYMBOL(trace_hardirqs_on_caller);
 NOKPROBE_SYMBOL(trace_hardirqs_on_caller);
 
 __visible void trace_hardirqs_off_caller(unsigned long caller_addr)
 {
-       lockdep_hardirqs_off(CALLER_ADDR0);
+       lockdep_hardirqs_off(caller_addr);
 
        if (!this_cpu_read(tracing_irq_cpu)) {
                this_cpu_write(tracing_irq_cpu, 1);
index 64ea283..ef42c1a 100644 (file)
@@ -571,7 +571,8 @@ static void for_each_tracepoint_range(
 bool trace_module_has_bad_taint(struct module *mod)
 {
        return mod->taints & ~((1 << TAINT_OOT_MODULE) | (1 << TAINT_CRAP) |
-                              (1 << TAINT_UNSIGNED_MODULE));
+                              (1 << TAINT_UNSIGNED_MODULE) |
+                              (1 << TAINT_TEST));
 }
 
 static BLOCKING_NOTIFIER_HEAD(tracepoint_notify_list);
@@ -647,7 +648,7 @@ static int tracepoint_module_coming(struct module *mod)
        /*
         * We skip modules that taint the kernel, especially those with different
         * module headers (for forced load), to make sure we don't cause a crash.
-        * Staging, out-of-tree, and unsigned GPL modules are fine.
+        * Staging, out-of-tree, unsigned GPL, and test modules are fine.
         */
        if (trace_module_has_bad_taint(mod))
                return 0;
index 072e4b2..bcbe60d 100644 (file)
@@ -2029,13 +2029,16 @@ config LKDTM
        Documentation on how to use the module can be found in
        Documentation/fault-injection/provoke-crashes.rst
 
-config TEST_CPUMASK
-       tristate "cpumask tests" if !KUNIT_ALL_TESTS
+config CPUMASK_KUNIT_TEST
+       tristate "KUnit test for cpumask" if !KUNIT_ALL_TESTS
        depends on KUNIT
        default KUNIT_ALL_TESTS
        help
          Enable to turn on cpumask tests, running at boot or module load time.
 
+         For more information on KUnit and unit tests in general, please refer
+         to the KUnit documentation in Documentation/dev-tools/kunit/.
+
          If unsure, say N.
 
 config TEST_LIST_SORT
index 5927d7f..ffabc30 100644 (file)
@@ -60,6 +60,7 @@ obj-$(CONFIG_TEST_BPF) += test_bpf.o
 obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o
 obj-$(CONFIG_TEST_BITOPS) += test_bitops.o
 CFLAGS_test_bitops.o += -Werror
+obj-$(CONFIG_CPUMASK_KUNIT_TEST) += cpumask_kunit.o
 obj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o
 obj-$(CONFIG_TEST_SIPHASH) += test_siphash.o
 obj-$(CONFIG_HASH_KUNIT_TEST) += test_hash.o
@@ -100,7 +101,6 @@ obj-$(CONFIG_TEST_HMM) += test_hmm.o
 obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o
 obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o
 obj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o
-obj-$(CONFIG_TEST_CPUMASK) += test_cpumask.o
 CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE)
 obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o
 #
similarity index 58%
rename from lib/test_cpumask.c
rename to lib/cpumask_kunit.c
index a31a162..ecbeec7 100644 (file)
@@ -9,6 +9,10 @@
 #include <linux/cpu.h>
 #include <linux/cpumask.h>
 
+#define MASK_MSG(m) \
+       "%s contains %sCPUs %*pbl", #m, (cpumask_weight(m) ? "" : "no "), \
+       nr_cpumask_bits, cpumask_bits(m)
+
 #define EXPECT_FOR_EACH_CPU_EQ(test, mask)                     \
        do {                                                    \
                const cpumask_t *m = (mask);                    \
@@ -16,7 +20,7 @@
                int cpu, iter = 0;                              \
                for_each_cpu(cpu, m)                            \
                        iter++;                                 \
-               KUNIT_EXPECT_EQ((test), mask_weight, iter);     \
+               KUNIT_EXPECT_EQ_MSG((test), mask_weight, iter, MASK_MSG(mask)); \
        } while (0)
 
 #define EXPECT_FOR_EACH_CPU_NOT_EQ(test, mask)                                 \
@@ -26,7 +30,7 @@
                int cpu, iter = 0;                                              \
                for_each_cpu_not(cpu, m)                                        \
                        iter++;                                                 \
-               KUNIT_EXPECT_EQ((test), nr_cpu_ids - mask_weight, iter);        \
+               KUNIT_EXPECT_EQ_MSG((test), nr_cpu_ids - mask_weight, iter, MASK_MSG(mask));    \
        } while (0)
 
 #define EXPECT_FOR_EACH_CPU_WRAP_EQ(test, mask)                        \
@@ -36,7 +40,7 @@
                int cpu, iter = 0;                              \
                for_each_cpu_wrap(cpu, m, nr_cpu_ids / 2)       \
                        iter++;                                 \
-               KUNIT_EXPECT_EQ((test), mask_weight, iter);     \
+               KUNIT_EXPECT_EQ_MSG((test), mask_weight, iter, MASK_MSG(mask)); \
        } while (0)
 
 #define EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, name)             \
@@ -45,7 +49,7 @@
                int cpu, iter = 0;                              \
                for_each_##name##_cpu(cpu)                      \
                        iter++;                                 \
-               KUNIT_EXPECT_EQ((test), mask_weight, iter);     \
+               KUNIT_EXPECT_EQ_MSG((test), mask_weight, iter, MASK_MSG(cpu_##name##_mask));    \
        } while (0)
 
 static cpumask_t mask_empty;
@@ -53,37 +57,43 @@ static cpumask_t mask_all;
 
 static void test_cpumask_weight(struct kunit *test)
 {
-       KUNIT_EXPECT_TRUE(test, cpumask_empty(&mask_empty));
-       KUNIT_EXPECT_TRUE(test, cpumask_full(cpu_possible_mask));
-       KUNIT_EXPECT_TRUE(test, cpumask_full(&mask_all));
+       KUNIT_EXPECT_TRUE_MSG(test, cpumask_empty(&mask_empty), MASK_MSG(&mask_empty));
+       KUNIT_EXPECT_TRUE_MSG(test, cpumask_full(&mask_all), MASK_MSG(&mask_all));
 
-       KUNIT_EXPECT_EQ(test, 0, cpumask_weight(&mask_empty));
-       KUNIT_EXPECT_EQ(test, nr_cpu_ids, cpumask_weight(cpu_possible_mask));
-       KUNIT_EXPECT_EQ(test, nr_cpumask_bits, cpumask_weight(&mask_all));
+       KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_weight(&mask_empty), MASK_MSG(&mask_empty));
+       KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids, cpumask_weight(cpu_possible_mask),
+                           MASK_MSG(cpu_possible_mask));
+       KUNIT_EXPECT_EQ_MSG(test, nr_cpumask_bits, cpumask_weight(&mask_all), MASK_MSG(&mask_all));
 }
 
 static void test_cpumask_first(struct kunit *test)
 {
-       KUNIT_EXPECT_LE(test, nr_cpu_ids, cpumask_first(&mask_empty));
-       KUNIT_EXPECT_EQ(test, 0, cpumask_first(cpu_possible_mask));
+       KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_first(&mask_empty), MASK_MSG(&mask_empty));
+       KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_first(cpu_possible_mask), MASK_MSG(cpu_possible_mask));
 
-       KUNIT_EXPECT_EQ(test, 0, cpumask_first_zero(&mask_empty));
-       KUNIT_EXPECT_LE(test, nr_cpu_ids, cpumask_first_zero(cpu_possible_mask));
+       KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_first_zero(&mask_empty), MASK_MSG(&mask_empty));
+       KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_first_zero(cpu_possible_mask),
+                           MASK_MSG(cpu_possible_mask));
 }
 
 static void test_cpumask_last(struct kunit *test)
 {
-       KUNIT_EXPECT_LE(test, nr_cpumask_bits, cpumask_last(&mask_empty));
-       KUNIT_EXPECT_EQ(test, nr_cpumask_bits - 1, cpumask_last(cpu_possible_mask));
+       KUNIT_EXPECT_LE_MSG(test, nr_cpumask_bits, cpumask_last(&mask_empty),
+                           MASK_MSG(&mask_empty));
+       KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids - 1, cpumask_last(cpu_possible_mask),
+                           MASK_MSG(cpu_possible_mask));
 }
 
 static void test_cpumask_next(struct kunit *test)
 {
-       KUNIT_EXPECT_EQ(test, 0, cpumask_next_zero(-1, &mask_empty));
-       KUNIT_EXPECT_LE(test, nr_cpu_ids, cpumask_next_zero(-1, cpu_possible_mask));
-
-       KUNIT_EXPECT_LE(test, nr_cpu_ids, cpumask_next(-1, &mask_empty));
-       KUNIT_EXPECT_EQ(test, 0, cpumask_next(-1, cpu_possible_mask));
+       KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_next_zero(-1, &mask_empty), MASK_MSG(&mask_empty));
+       KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_next_zero(-1, cpu_possible_mask),
+                           MASK_MSG(cpu_possible_mask));
+
+       KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_next(-1, &mask_empty),
+                           MASK_MSG(&mask_empty));
+       KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_next(-1, cpu_possible_mask),
+                           MASK_MSG(cpu_possible_mask));
 }
 
 static void test_cpumask_iterators(struct kunit *test)
index 9ff549f..47816af 100644 (file)
@@ -33,7 +33,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA
 
 config CRYPTO_LIB_CHACHA_GENERIC
        tristate
-       select XOR_BLOCKS
        help
          This symbol can be depended upon by arch implementations of the
          ChaCha library interface that require the generic code as a
index e01a93f..ce945c1 100644 (file)
  */
 int ___ratelimit(struct ratelimit_state *rs, const char *func)
 {
+       /* Paired with WRITE_ONCE() in .proc_handler().
+        * Changing two values seperately could be inconsistent
+        * and some message could be lost.  (See: net_ratelimit_state).
+        */
+       int interval = READ_ONCE(rs->interval);
+       int burst = READ_ONCE(rs->burst);
        unsigned long flags;
        int ret;
 
-       if (!rs->interval)
+       if (!interval)
                return 1;
 
        /*
@@ -44,7 +50,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
        if (!rs->begin)
                rs->begin = jiffies;
 
-       if (time_is_before_jiffies(rs->begin + rs->interval)) {
+       if (time_is_before_jiffies(rs->begin + interval)) {
                if (rs->missed) {
                        if (!(rs->flags & RATELIMIT_MSG_ON_RELEASE)) {
                                printk_deferred(KERN_WARNING
@@ -56,7 +62,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
                rs->begin   = jiffies;
                rs->printed = 0;
        }
-       if (rs->burst && rs->burst > rs->printed) {
+       if (burst && burst > rs->printed) {
                rs->printed++;
                ret = 1;
        } else {
index 95550b8..de65cb1 100644 (file)
@@ -260,10 +260,10 @@ void wb_wakeup_delayed(struct bdi_writeback *wb)
        unsigned long timeout;
 
        timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
-       spin_lock_bh(&wb->work_lock);
+       spin_lock_irq(&wb->work_lock);
        if (test_bit(WB_registered, &wb->state))
                queue_delayed_work(bdi_wq, &wb->dwork, timeout);
-       spin_unlock_bh(&wb->work_lock);
+       spin_unlock_irq(&wb->work_lock);
 }
 
 static void wb_update_bandwidth_workfn(struct work_struct *work)
@@ -334,12 +334,12 @@ static void cgwb_remove_from_bdi_list(struct bdi_writeback *wb);
 static void wb_shutdown(struct bdi_writeback *wb)
 {
        /* Make sure nobody queues further work */
-       spin_lock_bh(&wb->work_lock);
+       spin_lock_irq(&wb->work_lock);
        if (!test_and_clear_bit(WB_registered, &wb->state)) {
-               spin_unlock_bh(&wb->work_lock);
+               spin_unlock_irq(&wb->work_lock);
                return;
        }
-       spin_unlock_bh(&wb->work_lock);
+       spin_unlock_irq(&wb->work_lock);
 
        cgwb_remove_from_bdi_list(wb);
        /*
index f18a631..b1efebf 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/memblock.h>
 #include <linux/bootmem_info.h>
 #include <linux/memory_hotplug.h>
+#include <linux/kmemleak.h>
 
 void get_page_bootmem(unsigned long info, struct page *page, unsigned long type)
 {
@@ -33,6 +34,7 @@ void put_page_bootmem(struct page *page)
                ClearPagePrivate(page);
                set_page_private(page, 0);
                INIT_LIST_HEAD(&page->lru);
+               kmemleak_free_part(page_to_virt(page), PAGE_SIZE);
                free_reserved_page(page);
        }
 }
index cb8a7e9..cfdf631 100644 (file)
@@ -818,6 +818,9 @@ static int dbgfs_mk_context(char *name)
                return -ENOENT;
 
        new_dir = debugfs_create_dir(name, root);
+       /* Below check is required for a potential duplicated name case */
+       if (IS_ERR(new_dir))
+               return PTR_ERR(new_dir);
        dbgfs_dirs[dbgfs_nr_ctxs] = new_dir;
 
        new_ctx = dbgfs_new_ctx();
index 7328251..5abdaf4 100644 (file)
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -478,14 +478,42 @@ static int follow_pfn_pte(struct vm_area_struct *vma, unsigned long address,
        return -EEXIST;
 }
 
-/*
- * FOLL_FORCE can write to even unwritable pte's, but only
- * after we've gone through a COW cycle and they are dirty.
- */
-static inline bool can_follow_write_pte(pte_t pte, unsigned int flags)
+/* FOLL_FORCE can write to even unwritable PTEs in COW mappings. */
+static inline bool can_follow_write_pte(pte_t pte, struct page *page,
+                                       struct vm_area_struct *vma,
+                                       unsigned int flags)
 {
-       return pte_write(pte) ||
-               ((flags & FOLL_FORCE) && (flags & FOLL_COW) && pte_dirty(pte));
+       /* If the pte is writable, we can write to the page. */
+       if (pte_write(pte))
+               return true;
+
+       /* Maybe FOLL_FORCE is set to override it? */
+       if (!(flags & FOLL_FORCE))
+               return false;
+
+       /* But FOLL_FORCE has no effect on shared mappings */
+       if (vma->vm_flags & (VM_MAYSHARE | VM_SHARED))
+               return false;
+
+       /* ... or read-only private ones */
+       if (!(vma->vm_flags & VM_MAYWRITE))
+               return false;
+
+       /* ... or already writable ones that just need to take a write fault */
+       if (vma->vm_flags & VM_WRITE)
+               return false;
+
+       /*
+        * See can_change_pte_writable(): we broke COW and could map the page
+        * writable if we have an exclusive anonymous page ...
+        */
+       if (!page || !PageAnon(page) || !PageAnonExclusive(page))
+               return false;
+
+       /* ... and a write-fault isn't required for other reasons. */
+       if (vma_soft_dirty_enabled(vma) && !pte_soft_dirty(pte))
+               return false;
+       return !userfaultfd_pte_wp(vma, pte);
 }
 
 static struct page *follow_page_pte(struct vm_area_struct *vma,
@@ -528,12 +556,19 @@ retry:
        }
        if ((flags & FOLL_NUMA) && pte_protnone(pte))
                goto no_page;
-       if ((flags & FOLL_WRITE) && !can_follow_write_pte(pte, flags)) {
-               pte_unmap_unlock(ptep, ptl);
-               return NULL;
-       }
 
        page = vm_normal_page(vma, address, pte);
+
+       /*
+        * We only care about anon pages in can_follow_write_pte() and don't
+        * have to worry about pte_devmap() because they are never anon.
+        */
+       if ((flags & FOLL_WRITE) &&
+           !can_follow_write_pte(pte, page, vma, flags)) {
+               page = NULL;
+               goto out;
+       }
+
        if (!page && pte_devmap(pte) && (flags & (FOLL_GET | FOLL_PIN))) {
                /*
                 * Only return device mapping pages in the FOLL_GET or FOLL_PIN
@@ -986,17 +1021,6 @@ static int faultin_page(struct vm_area_struct *vma,
                return -EBUSY;
        }
 
-       /*
-        * The VM_FAULT_WRITE bit tells us that do_wp_page has broken COW when
-        * necessary, even if maybe_mkwrite decided not to set pte_write. We
-        * can thus safely do subsequent page lookups as if they were reads.
-        * But only do so when looping for pte_write is futile: in some cases
-        * userspace may also be wanting to write to the gotten user page,
-        * which a read fault here might prevent (a readonly page might get
-        * reCOWed by userspace write).
-        */
-       if ((ret & VM_FAULT_WRITE) && !(vma->vm_flags & VM_WRITE))
-               *flags |= FOLL_COW;
        return 0;
 }
 
index 8a7c1b3..e9414ee 100644 (file)
@@ -1040,12 +1040,6 @@ struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
 
        assert_spin_locked(pmd_lockptr(mm, pmd));
 
-       /*
-        * When we COW a devmap PMD entry, we split it into PTEs, so we should
-        * not be in this function with `flags & FOLL_COW` set.
-        */
-       WARN_ONCE(flags & FOLL_COW, "mm: In follow_devmap_pmd with FOLL_COW set");
-
        /* FOLL_GET and FOLL_PIN are mutually exclusive. */
        if (WARN_ON_ONCE((flags & (FOLL_PIN | FOLL_GET)) ==
                         (FOLL_PIN | FOLL_GET)))
@@ -1395,14 +1389,42 @@ fallback:
        return VM_FAULT_FALLBACK;
 }
 
-/*
- * FOLL_FORCE can write to even unwritable pmd's, but only
- * after we've gone through a COW cycle and they are dirty.
- */
-static inline bool can_follow_write_pmd(pmd_t pmd, unsigned int flags)
+/* FOLL_FORCE can write to even unwritable PMDs in COW mappings. */
+static inline bool can_follow_write_pmd(pmd_t pmd, struct page *page,
+                                       struct vm_area_struct *vma,
+                                       unsigned int flags)
 {
-       return pmd_write(pmd) ||
-              ((flags & FOLL_FORCE) && (flags & FOLL_COW) && pmd_dirty(pmd));
+       /* If the pmd is writable, we can write to the page. */
+       if (pmd_write(pmd))
+               return true;
+
+       /* Maybe FOLL_FORCE is set to override it? */
+       if (!(flags & FOLL_FORCE))
+               return false;
+
+       /* But FOLL_FORCE has no effect on shared mappings */
+       if (vma->vm_flags & (VM_MAYSHARE | VM_SHARED))
+               return false;
+
+       /* ... or read-only private ones */
+       if (!(vma->vm_flags & VM_MAYWRITE))
+               return false;
+
+       /* ... or already writable ones that just need to take a write fault */
+       if (vma->vm_flags & VM_WRITE)
+               return false;
+
+       /*
+        * See can_change_pte_writable(): we broke COW and could map the page
+        * writable if we have an exclusive anonymous page ...
+        */
+       if (!page || !PageAnon(page) || !PageAnonExclusive(page))
+               return false;
+
+       /* ... and a write-fault isn't required for other reasons. */
+       if (vma_soft_dirty_enabled(vma) && !pmd_soft_dirty(pmd))
+               return false;
+       return !userfaultfd_huge_pmd_wp(vma, pmd);
 }
 
 struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
@@ -1411,12 +1433,16 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
                                   unsigned int flags)
 {
        struct mm_struct *mm = vma->vm_mm;
-       struct page *page = NULL;
+       struct page *page;
 
        assert_spin_locked(pmd_lockptr(mm, pmd));
 
-       if (flags & FOLL_WRITE && !can_follow_write_pmd(*pmd, flags))
-               goto out;
+       page = pmd_page(*pmd);
+       VM_BUG_ON_PAGE(!PageHead(page) && !is_zone_device_page(page), page);
+
+       if ((flags & FOLL_WRITE) &&
+           !can_follow_write_pmd(*pmd, page, vma, flags))
+               return NULL;
 
        /* Avoid dumping huge zero page */
        if ((flags & FOLL_DUMP) && is_huge_zero_pmd(*pmd))
@@ -1424,10 +1450,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
 
        /* Full NUMA hinting faults to serialise migration in fault paths */
        if ((flags & FOLL_NUMA) && pmd_protnone(*pmd))
-               goto out;
-
-       page = pmd_page(*pmd);
-       VM_BUG_ON_PAGE(!PageHead(page) && !is_zone_device_page(page), page);
+               return NULL;
 
        if (!pmd_write(*pmd) && gup_must_unshare(flags, page))
                return ERR_PTR(-EMLINK);
@@ -1444,7 +1467,6 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
        page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT;
        VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), page);
 
-out:
        return page;
 }
 
index 0aee2f3..e070b85 100644 (file)
@@ -5241,6 +5241,21 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma,
        VM_BUG_ON(unshare && (flags & FOLL_WRITE));
        VM_BUG_ON(!unshare && !(flags & FOLL_WRITE));
 
+       /*
+        * hugetlb does not support FOLL_FORCE-style write faults that keep the
+        * PTE mapped R/O such as maybe_mkwrite() would do.
+        */
+       if (WARN_ON_ONCE(!unshare && !(vma->vm_flags & VM_WRITE)))
+               return VM_FAULT_SIGSEGV;
+
+       /* Let's take out MAP_SHARED mappings first. */
+       if (vma->vm_flags & VM_MAYSHARE) {
+               if (unlikely(unshare))
+                       return 0;
+               set_huge_ptep_writable(vma, haddr, ptep);
+               return 0;
+       }
+
        pte = huge_ptep_get(ptep);
        old_page = pte_page(pte);
 
@@ -5781,12 +5796,11 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
         * If we are going to COW/unshare the mapping later, we examine the
         * pending reservations for this page now. This will ensure that any
         * allocations necessary to record that reservation occur outside the
-        * spinlock. For private mappings, we also lookup the pagecache
-        * page now as it is used to determine if a reservation has been
-        * consumed.
+        * spinlock. Also lookup the pagecache page now as it is used to
+        * determine if a reservation has been consumed.
         */
        if ((flags & (FAULT_FLAG_WRITE|FAULT_FLAG_UNSHARE)) &&
-           !huge_pte_write(entry)) {
+           !(vma->vm_flags & VM_MAYSHARE) && !huge_pte_write(entry)) {
                if (vma_needs_reservation(h, vma, haddr) < 0) {
                        ret = VM_FAULT_OOM;
                        goto out_mutex;
@@ -5794,9 +5808,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
                /* Just decrements count, does not deallocate */
                vma_end_reservation(h, vma, haddr);
 
-               if (!(vma->vm_flags & VM_MAYSHARE))
-                       pagecache_page = hugetlbfs_pagecache_page(h,
-                                                               vma, haddr);
+               pagecache_page = hugetlbfs_pagecache_page(h, vma, haddr);
        }
 
        ptl = huge_pte_lock(h, mm, ptep);
@@ -6029,7 +6041,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
        if (!huge_pte_none_mostly(huge_ptep_get(dst_pte)))
                goto out_release_unlock;
 
-       if (vm_shared) {
+       if (page_in_pagecache) {
                page_dup_file_rmap(page, true);
        } else {
                ClearHPageRestoreReserve(page);
index c035020..9d780f4 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1646,8 +1646,11 @@ int vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot)
            pgprot_val(vm_pgprot_modify(vm_page_prot, vm_flags)))
                return 0;
 
-       /* Do we need to track softdirty? */
-       if (vma_soft_dirty_enabled(vma))
+       /*
+        * Do we need to track softdirty? hugetlb does not support softdirty
+        * tracking yet.
+        */
+       if (vma_soft_dirty_enabled(vma) && !is_vm_hugetlb_page(vma))
                return 1;
 
        /* Specialty mapping? */
index 3a23dde..bc6bddd 100644 (file)
@@ -196,10 +196,11 @@ static unsigned long change_pte_range(struct mmu_gather *tlb,
                        pages++;
                } else if (is_swap_pte(oldpte)) {
                        swp_entry_t entry = pte_to_swp_entry(oldpte);
-                       struct page *page = pfn_swap_entry_to_page(entry);
                        pte_t newpte;
 
                        if (is_writable_migration_entry(entry)) {
+                               struct page *page = pfn_swap_entry_to_page(entry);
+
                                /*
                                 * A protection check is difficult so
                                 * just be safe and disable write
index d0d466a..032a7bf 100644 (file)
@@ -2892,6 +2892,7 @@ static void wb_inode_writeback_start(struct bdi_writeback *wb)
 
 static void wb_inode_writeback_end(struct bdi_writeback *wb)
 {
+       unsigned long flags;
        atomic_dec(&wb->writeback_inodes);
        /*
         * Make sure estimate of writeback throughput gets updated after
@@ -2900,7 +2901,10 @@ static void wb_inode_writeback_end(struct bdi_writeback *wb)
         * that if multiple inodes end writeback at a similar time, they get
         * batched into one bandwidth update.
         */
-       queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL);
+       spin_lock_irqsave(&wb->work_lock, flags);
+       if (test_bit(WB_registered, &wb->state))
+               queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL);
+       spin_unlock_irqrestore(&wb->work_lock, flags);
 }
 
 bool __folio_end_writeback(struct folio *folio)
index 9b3db11..fa7a3d2 100644 (file)
@@ -110,7 +110,7 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
        do {
 again:
                next = pmd_addr_end(addr, end);
-               if (pmd_none(*pmd) || (!walk->vma && !walk->no_vma)) {
+               if (pmd_none(*pmd)) {
                        if (ops->pte_hole)
                                err = ops->pte_hole(addr, next, depth, walk);
                        if (err)
@@ -171,7 +171,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
        do {
  again:
                next = pud_addr_end(addr, end);
-               if (pud_none(*pud) || (!walk->vma && !walk->no_vma)) {
+               if (pud_none(*pud)) {
                        if (ops->pte_hole)
                                err = ops->pte_hole(addr, next, depth, walk);
                        if (err)
@@ -366,19 +366,19 @@ static int __walk_page_range(unsigned long start, unsigned long end,
        struct vm_area_struct *vma = walk->vma;
        const struct mm_walk_ops *ops = walk->ops;
 
-       if (vma && ops->pre_vma) {
+       if (ops->pre_vma) {
                err = ops->pre_vma(start, end, walk);
                if (err)
                        return err;
        }
 
-       if (vma && is_vm_hugetlb_page(vma)) {
+       if (is_vm_hugetlb_page(vma)) {
                if (ops->hugetlb_entry)
                        err = walk_hugetlb_range(start, end, walk);
        } else
                err = walk_pgd_range(start, end, walk);
 
-       if (vma && ops->post_vma)
+       if (ops->post_vma)
                ops->post_vma(walk);
 
        return err;
@@ -450,9 +450,13 @@ int walk_page_range(struct mm_struct *mm, unsigned long start,
                if (!vma) { /* after the last vma */
                        walk.vma = NULL;
                        next = end;
+                       if (ops->pte_hole)
+                               err = ops->pte_hole(start, next, -1, &walk);
                } else if (start < vma->vm_start) { /* outside vma */
                        walk.vma = NULL;
                        next = min(end, vma->vm_start);
+                       if (ops->pte_hole)
+                               err = ops->pte_hole(start, next, -1, &walk);
                } else { /* inside vma */
                        walk.vma = vma;
                        next = min(end, vma->vm_end);
@@ -470,9 +474,8 @@ int walk_page_range(struct mm_struct *mm, unsigned long start,
                        }
                        if (err < 0)
                                break;
-               }
-               if (walk.vma || walk.ops->pte_hole)
                        err = __walk_page_range(start, next, &walk);
+               }
                if (err)
                        break;
        } while (start = next, start < end);
@@ -501,9 +504,9 @@ int walk_page_range_novma(struct mm_struct *mm, unsigned long start,
        if (start >= end || !walk.mm)
                return -EINVAL;
 
-       mmap_assert_locked(walk.mm);
+       mmap_assert_write_locked(walk.mm);
 
-       return __walk_page_range(start, end, &walk);
+       return walk_pgd_range(start, end, &walk);
 }
 
 int walk_page_vma(struct vm_area_struct *vma, const struct mm_walk_ops *ops,
index eea3d28..8adab45 100644 (file)
@@ -152,13 +152,13 @@ void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, pgd_t *pgd)
 {
        const struct ptdump_range *range = st->range;
 
-       mmap_read_lock(mm);
+       mmap_write_lock(mm);
        while (range->start != range->end) {
                walk_page_range_novma(mm, range->start, range->end,
                                      &ptdump_ops, pgd, st);
                range++;
        }
-       mmap_read_unlock(mm);
+       mmap_write_unlock(mm);
 
        /* Flush out the last page */
        st->note_page(st, 0, -1, 0);
index edc06c5..93d5a6f 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -93,7 +93,8 @@ static inline struct anon_vma *anon_vma_alloc(void)
        anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
        if (anon_vma) {
                atomic_set(&anon_vma->refcount, 1);
-               anon_vma->degree = 1;   /* Reference for first vma */
+               anon_vma->num_children = 0;
+               anon_vma->num_active_vmas = 0;
                anon_vma->parent = anon_vma;
                /*
                 * Initialise the anon_vma root to point to itself. If called
@@ -201,6 +202,7 @@ int __anon_vma_prepare(struct vm_area_struct *vma)
                anon_vma = anon_vma_alloc();
                if (unlikely(!anon_vma))
                        goto out_enomem_free_avc;
+               anon_vma->num_children++; /* self-parent link for new root */
                allocated = anon_vma;
        }
 
@@ -210,8 +212,7 @@ int __anon_vma_prepare(struct vm_area_struct *vma)
        if (likely(!vma->anon_vma)) {
                vma->anon_vma = anon_vma;
                anon_vma_chain_link(vma, avc, anon_vma);
-               /* vma reference or self-parent link for new root */
-               anon_vma->degree++;
+               anon_vma->num_active_vmas++;
                allocated = NULL;
                avc = NULL;
        }
@@ -296,19 +297,19 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
                anon_vma_chain_link(dst, avc, anon_vma);
 
                /*
-                * Reuse existing anon_vma if its degree lower than two,
-                * that means it has no vma and only one anon_vma child.
+                * Reuse existing anon_vma if it has no vma and only one
+                * anon_vma child.
                 *
-                * Do not choose parent anon_vma, otherwise first child
-                * will always reuse it. Root anon_vma is never reused:
+                * Root anon_vma is never reused:
                 * it has self-parent reference and at least one child.
                 */
                if (!dst->anon_vma && src->anon_vma &&
-                   anon_vma != src->anon_vma && anon_vma->degree < 2)
+                   anon_vma->num_children < 2 &&
+                   anon_vma->num_active_vmas == 0)
                        dst->anon_vma = anon_vma;
        }
        if (dst->anon_vma)
-               dst->anon_vma->degree++;
+               dst->anon_vma->num_active_vmas++;
        unlock_anon_vma_root(root);
        return 0;
 
@@ -358,6 +359,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
        anon_vma = anon_vma_alloc();
        if (!anon_vma)
                goto out_error;
+       anon_vma->num_active_vmas++;
        avc = anon_vma_chain_alloc(GFP_KERNEL);
        if (!avc)
                goto out_error_free_anon_vma;
@@ -378,7 +380,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
        vma->anon_vma = anon_vma;
        anon_vma_lock_write(anon_vma);
        anon_vma_chain_link(vma, avc, anon_vma);
-       anon_vma->parent->degree++;
+       anon_vma->parent->num_children++;
        anon_vma_unlock_write(anon_vma);
 
        return 0;
@@ -410,7 +412,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma)
                 * to free them outside the lock.
                 */
                if (RB_EMPTY_ROOT(&anon_vma->rb_root.rb_root)) {
-                       anon_vma->parent->degree--;
+                       anon_vma->parent->num_children--;
                        continue;
                }
 
@@ -418,7 +420,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma)
                anon_vma_chain_free(avc);
        }
        if (vma->anon_vma) {
-               vma->anon_vma->degree--;
+               vma->anon_vma->num_active_vmas--;
 
                /*
                 * vma would still be needed after unlink, and anon_vma will be prepared
@@ -436,7 +438,8 @@ void unlink_anon_vmas(struct vm_area_struct *vma)
        list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) {
                struct anon_vma *anon_vma = avc->anon_vma;
 
-               VM_WARN_ON(anon_vma->degree);
+               VM_WARN_ON(anon_vma->num_children);
+               VM_WARN_ON(anon_vma->num_active_vmas);
                put_anon_vma(anon_vma);
 
                list_del(&avc->same_vma);
index 5783f11..42e5888 100644 (file)
@@ -1659,7 +1659,9 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp,
                new = page_folio(newpage);
                mem_cgroup_migrate(old, new);
                __inc_lruvec_page_state(newpage, NR_FILE_PAGES);
+               __inc_lruvec_page_state(newpage, NR_SHMEM);
                __dec_lruvec_page_state(oldpage, NR_FILE_PAGES);
+               __dec_lruvec_page_state(oldpage, NR_SHMEM);
        }
        xa_unlock_irq(&swap_mapping->i_pages);
 
@@ -1780,6 +1782,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
 
        if (shmem_should_replace_folio(folio, gfp)) {
                error = shmem_replace_page(&page, gfp, info, index);
+               folio = page_folio(page);
                if (error)
                        goto failed;
        }
@@ -2281,16 +2284,34 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
        return 0;
 }
 
-/* Mask out flags that are inappropriate for the given type of inode. */
-static unsigned shmem_mask_flags(umode_t mode, __u32 flags)
+#ifdef CONFIG_TMPFS_XATTR
+static int shmem_initxattrs(struct inode *, const struct xattr *, void *);
+
+/*
+ * chattr's fsflags are unrelated to extended attributes,
+ * but tmpfs has chosen to enable them under the same config option.
+ */
+static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags)
+{
+       unsigned int i_flags = 0;
+
+       if (fsflags & FS_NOATIME_FL)
+               i_flags |= S_NOATIME;
+       if (fsflags & FS_APPEND_FL)
+               i_flags |= S_APPEND;
+       if (fsflags & FS_IMMUTABLE_FL)
+               i_flags |= S_IMMUTABLE;
+       /*
+        * But FS_NODUMP_FL does not require any action in i_flags.
+        */
+       inode_set_flags(inode, i_flags, S_NOATIME | S_APPEND | S_IMMUTABLE);
+}
+#else
+static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags)
 {
-       if (S_ISDIR(mode))
-               return flags;
-       else if (S_ISREG(mode))
-               return flags & SHMEM_REG_FLMASK;
-       else
-               return flags & SHMEM_OTHER_FLMASK;
 }
+#define shmem_initxattrs NULL
+#endif
 
 static struct inode *shmem_get_inode(struct super_block *sb, struct inode *dir,
                                     umode_t mode, dev_t dev, unsigned long flags)
@@ -2319,7 +2340,8 @@ static struct inode *shmem_get_inode(struct super_block *sb, struct inode *dir,
                info->i_crtime = inode->i_mtime;
                info->fsflags = (dir == NULL) ? 0 :
                        SHMEM_I(dir)->fsflags & SHMEM_FL_INHERITED;
-               info->fsflags = shmem_mask_flags(mode, info->fsflags);
+               if (info->fsflags)
+                       shmem_set_inode_flags(inode, info->fsflags);
                INIT_LIST_HEAD(&info->shrinklist);
                INIT_LIST_HEAD(&info->swaplist);
                simple_xattrs_init(&info->xattrs);
@@ -2468,12 +2490,6 @@ out_unacct_blocks:
 static const struct inode_operations shmem_symlink_inode_operations;
 static const struct inode_operations shmem_short_symlink_operations;
 
-#ifdef CONFIG_TMPFS_XATTR
-static int shmem_initxattrs(struct inode *, const struct xattr *, void *);
-#else
-#define shmem_initxattrs NULL
-#endif
-
 static int
 shmem_write_begin(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len,
@@ -2826,12 +2842,13 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
 
        if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + len > inode->i_size)
                i_size_write(inode, offset + len);
-       inode->i_ctime = current_time(inode);
 undone:
        spin_lock(&inode->i_lock);
        inode->i_private = NULL;
        spin_unlock(&inode->i_lock);
 out:
+       if (!error)
+               file_modified(file);
        inode_unlock(inode);
        return error;
 }
@@ -3179,18 +3196,13 @@ static int shmem_fileattr_set(struct user_namespace *mnt_userns,
 
        if (fileattr_has_fsx(fa))
                return -EOPNOTSUPP;
+       if (fa->flags & ~SHMEM_FL_USER_MODIFIABLE)
+               return -EOPNOTSUPP;
 
        info->fsflags = (info->fsflags & ~SHMEM_FL_USER_MODIFIABLE) |
                (fa->flags & SHMEM_FL_USER_MODIFIABLE);
 
-       inode->i_flags &= ~(S_APPEND | S_IMMUTABLE | S_NOATIME);
-       if (info->fsflags & FS_APPEND_FL)
-               inode->i_flags |= S_APPEND;
-       if (info->fsflags & FS_IMMUTABLE_FL)
-               inode->i_flags |= S_IMMUTABLE;
-       if (info->fsflags & FS_NOATIME_FL)
-               inode->i_flags |= S_NOATIME;
-
+       shmem_set_inode_flags(inode, info->fsflags);
        inode->i_ctime = current_time(inode);
        return 0;
 }
index 1799664..07b9482 100644 (file)
@@ -392,6 +392,28 @@ kmem_cache_create(const char *name, unsigned int size, unsigned int align,
 }
 EXPORT_SYMBOL(kmem_cache_create);
 
+#ifdef SLAB_SUPPORTS_SYSFS
+/*
+ * For a given kmem_cache, kmem_cache_destroy() should only be called
+ * once or there will be a use-after-free problem. The actual deletion
+ * and release of the kobject does not need slab_mutex or cpu_hotplug_lock
+ * protection. So they are now done without holding those locks.
+ *
+ * Note that there will be a slight delay in the deletion of sysfs files
+ * if kmem_cache_release() is called indrectly from a work function.
+ */
+static void kmem_cache_release(struct kmem_cache *s)
+{
+       sysfs_slab_unlink(s);
+       sysfs_slab_release(s);
+}
+#else
+static void kmem_cache_release(struct kmem_cache *s)
+{
+       slab_kmem_cache_release(s);
+}
+#endif
+
 static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work)
 {
        LIST_HEAD(to_destroy);
@@ -418,11 +440,7 @@ static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work)
        list_for_each_entry_safe(s, s2, &to_destroy, list) {
                debugfs_slab_release(s);
                kfence_shutdown_cache(s);
-#ifdef SLAB_SUPPORTS_SYSFS
-               sysfs_slab_release(s);
-#else
-               slab_kmem_cache_release(s);
-#endif
+               kmem_cache_release(s);
        }
 }
 
@@ -437,20 +455,11 @@ static int shutdown_cache(struct kmem_cache *s)
        list_del(&s->list);
 
        if (s->flags & SLAB_TYPESAFE_BY_RCU) {
-#ifdef SLAB_SUPPORTS_SYSFS
-               sysfs_slab_unlink(s);
-#endif
                list_add_tail(&s->list, &slab_caches_to_rcu_destroy);
                schedule_work(&slab_caches_to_rcu_destroy_work);
        } else {
                kfence_shutdown_cache(s);
                debugfs_slab_release(s);
-#ifdef SLAB_SUPPORTS_SYSFS
-               sysfs_slab_unlink(s);
-               sysfs_slab_release(s);
-#else
-               slab_kmem_cache_release(s);
-#endif
        }
 
        return 0;
@@ -465,14 +474,16 @@ void slab_kmem_cache_release(struct kmem_cache *s)
 
 void kmem_cache_destroy(struct kmem_cache *s)
 {
+       int refcnt;
+
        if (unlikely(!s) || !kasan_check_byte(s))
                return;
 
        cpus_read_lock();
        mutex_lock(&slab_mutex);
 
-       s->refcount--;
-       if (s->refcount)
+       refcnt = --s->refcount;
+       if (refcnt)
                goto out_unlock;
 
        WARN(shutdown_cache(s),
@@ -481,6 +492,8 @@ void kmem_cache_destroy(struct kmem_cache *s)
 out_unlock:
        mutex_unlock(&slab_mutex);
        cpus_read_unlock();
+       if (!refcnt && !(s->flags & SLAB_TYPESAFE_BY_RCU))
+               kmem_cache_release(s);
 }
 EXPORT_SYMBOL(kmem_cache_destroy);
 
index 07d3bef..7327b25 100644 (file)
@@ -703,14 +703,29 @@ ssize_t mcopy_continue(struct mm_struct *dst_mm, unsigned long start,
                              mmap_changing, 0);
 }
 
+void uffd_wp_range(struct mm_struct *dst_mm, struct vm_area_struct *dst_vma,
+                  unsigned long start, unsigned long len, bool enable_wp)
+{
+       struct mmu_gather tlb;
+       pgprot_t newprot;
+
+       if (enable_wp)
+               newprot = vm_get_page_prot(dst_vma->vm_flags & ~(VM_WRITE));
+       else
+               newprot = vm_get_page_prot(dst_vma->vm_flags);
+
+       tlb_gather_mmu(&tlb, dst_mm);
+       change_protection(&tlb, dst_vma, start, start + len, newprot,
+                         enable_wp ? MM_CP_UFFD_WP : MM_CP_UFFD_WP_RESOLVE);
+       tlb_finish_mmu(&tlb);
+}
+
 int mwriteprotect_range(struct mm_struct *dst_mm, unsigned long start,
                        unsigned long len, bool enable_wp,
                        atomic_t *mmap_changing)
 {
        struct vm_area_struct *dst_vma;
        unsigned long page_mask;
-       struct mmu_gather tlb;
-       pgprot_t newprot;
        int err;
 
        /*
@@ -750,15 +765,7 @@ int mwriteprotect_range(struct mm_struct *dst_mm, unsigned long start,
                        goto out_unlock;
        }
 
-       if (enable_wp)
-               newprot = vm_get_page_prot(dst_vma->vm_flags & ~(VM_WRITE));
-       else
-               newprot = vm_get_page_prot(dst_vma->vm_flags);
-
-       tlb_gather_mmu(&tlb, dst_mm);
-       change_protection(&tlb, dst_vma, start, start + len, newprot,
-                         enable_wp ? MM_CP_UFFD_WP : MM_CP_UFFD_WP_RESOLVE);
-       tlb_finish_mmu(&tlb);
+       uffd_wp_range(dst_mm, dst_vma, start, len, enable_wp);
 
        err = 0;
 out_unlock:
index 373d273..90af9a8 100644 (file)
@@ -1168,8 +1168,15 @@ int fragmentation_index(struct zone *zone, unsigned int order)
 #define TEXT_FOR_HIGHMEM(xx)
 #endif
 
+#ifdef CONFIG_ZONE_DEVICE
+#define TEXT_FOR_DEVICE(xx) xx "_device",
+#else
+#define TEXT_FOR_DEVICE(xx)
+#endif
+
 #define TEXTS_FOR_ZONES(xx) TEXT_FOR_DMA(xx) TEXT_FOR_DMA32(xx) xx "_normal", \
-                                       TEXT_FOR_HIGHMEM(xx) xx "_movable",
+                                       TEXT_FOR_HIGHMEM(xx) xx "_movable", \
+                                       TEXT_FOR_DEVICE(xx)
 
 const char * const vmstat_text[] = {
        /* enum zone_stat_item counters */
index 34f784a..907c9b1 100644 (file)
@@ -1487,7 +1487,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle)
        struct size_class *class;
        enum fullness_group fullness;
 
-       if (unlikely(!handle))
+       if (IS_ERR_OR_NULL((void *)handle))
                return;
 
        /*
index 485c814..6643c9c 100644 (file)
@@ -4179,6 +4179,17 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, void *data,
                }
        }
 
+       if (i == ARRAY_SIZE(hci_cc_table)) {
+               /* Unknown opcode, assume byte 0 contains the status, so
+                * that e.g. __hci_cmd_sync() properly returns errors
+                * for vendor specific commands send by HCI drivers.
+                * If a vendor doesn't actually follow this convention we may
+                * need to introduce a vendor CC table in order to properly set
+                * the status.
+                */
+               *status = skb->data[0];
+       }
+
        handle_cmd_cnt_and_timer(hdev, ev->ncmd);
 
        hci_req_cmd_complete(hdev, *opcode, *status, req_complete,
@@ -5790,7 +5801,7 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
         */
        hci_dev_clear_flag(hdev, HCI_LE_ADV);
 
-       conn = hci_lookup_le_connect(hdev);
+       conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr);
        if (!conn) {
                /* In case of error status and there is no connection pending
                 * just unlock as there is nothing to cleanup.
index e6d804b..fbd5613 100644 (file)
@@ -3018,12 +3018,6 @@ static const struct hci_init_stage amp_init2[] = {
 /* Read Buffer Size (ACL mtu, max pkt, etc.) */
 static int hci_read_buffer_size_sync(struct hci_dev *hdev)
 {
-       /* Use Read LE Buffer Size V2 if supported */
-       if (hdev->commands[41] & 0x20)
-               return __hci_cmd_sync_status(hdev,
-                                            HCI_OP_LE_READ_BUFFER_SIZE_V2,
-                                            0, NULL, HCI_CMD_TIMEOUT);
-
        return __hci_cmd_sync_status(hdev, HCI_OP_READ_BUFFER_SIZE,
                                     0, NULL, HCI_CMD_TIMEOUT);
 }
@@ -3237,6 +3231,12 @@ static const struct hci_init_stage hci_init2[] = {
 /* Read LE Buffer Size */
 static int hci_le_read_buffer_size_sync(struct hci_dev *hdev)
 {
+       /* Use Read LE Buffer Size V2 if supported */
+       if (hdev->commands[41] & 0x20)
+               return __hci_cmd_sync_status(hdev,
+                                            HCI_OP_LE_READ_BUFFER_SIZE_V2,
+                                            0, NULL, HCI_CMD_TIMEOUT);
+
        return __hci_cmd_sync_status(hdev, HCI_OP_LE_READ_BUFFER_SIZE,
                                     0, NULL, HCI_CMD_TIMEOUT);
 }
@@ -4773,9 +4773,11 @@ int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason)
                /* Cleanup hci_conn object if it cannot be cancelled as it
                 * likelly means the controller and host stack are out of sync.
                 */
-               if (err)
+               if (err) {
+                       hci_dev_lock(hdev);
                        hci_conn_failed(conn, err);
-
+                       hci_dev_unlock(hdev);
+               }
                return err;
        case BT_CONNECT2:
                return hci_reject_conn_sync(hdev, conn, reason);
@@ -5288,17 +5290,21 @@ int hci_suspend_sync(struct hci_dev *hdev)
        /* Prevent disconnects from causing scanning to be re-enabled */
        hci_pause_scan_sync(hdev);
 
-       /* Soft disconnect everything (power off) */
-       err = hci_disconnect_all_sync(hdev, HCI_ERROR_REMOTE_POWER_OFF);
-       if (err) {
-               /* Set state to BT_RUNNING so resume doesn't notify */
-               hdev->suspend_state = BT_RUNNING;
-               hci_resume_sync(hdev);
-               return err;
-       }
+       if (hci_conn_count(hdev)) {
+               /* Soft disconnect everything (power off) */
+               err = hci_disconnect_all_sync(hdev, HCI_ERROR_REMOTE_POWER_OFF);
+               if (err) {
+                       /* Set state to BT_RUNNING so resume doesn't notify */
+                       hdev->suspend_state = BT_RUNNING;
+                       hci_resume_sync(hdev);
+                       return err;
+               }
 
-       /* Update event mask so only the allowed event can wakeup the host */
-       hci_set_event_mask_sync(hdev);
+               /* Update event mask so only the allowed event can wakeup the
+                * host.
+                */
+               hci_set_event_mask_sync(hdev);
+       }
 
        /* Only configure accept list if disconnect succeeded and wake
         * isn't being prevented.
index 5940744..cc20e70 100644 (file)
@@ -83,14 +83,14 @@ static void hidp_copy_session(struct hidp_session *session, struct hidp_conninfo
                ci->product = session->input->id.product;
                ci->version = session->input->id.version;
                if (session->input->name)
-                       strlcpy(ci->name, session->input->name, 128);
+                       strscpy(ci->name, session->input->name, 128);
                else
-                       strlcpy(ci->name, "HID Boot Device", 128);
+                       strscpy(ci->name, "HID Boot Device", 128);
        } else if (session->hid) {
                ci->vendor  = session->hid->vendor;
                ci->product = session->hid->product;
                ci->version = session->hid->version;
-               strlcpy(ci->name, session->hid->name, 128);
+               strscpy(ci->name, session->hid->name, 128);
        }
 }
 
index ced8ad4..613039b 100644 (file)
@@ -1309,7 +1309,7 @@ static int iso_sock_shutdown(struct socket *sock, int how)
        struct sock *sk = sock->sk;
        int err = 0;
 
-       BT_DBG("sock %p, sk %p", sock, sk);
+       BT_DBG("sock %p, sk %p, how %d", sock, sk, how);
 
        if (!sk)
                return 0;
@@ -1317,17 +1317,32 @@ static int iso_sock_shutdown(struct socket *sock, int how)
        sock_hold(sk);
        lock_sock(sk);
 
-       if (!sk->sk_shutdown) {
-               sk->sk_shutdown = SHUTDOWN_MASK;
-               iso_sock_clear_timer(sk);
-               __iso_sock_close(sk);
-
-               if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&
-                   !(current->flags & PF_EXITING))
-                       err = bt_sock_wait_state(sk, BT_CLOSED,
-                                                sk->sk_lingertime);
+       switch (how) {
+       case SHUT_RD:
+               if (sk->sk_shutdown & RCV_SHUTDOWN)
+                       goto unlock;
+               sk->sk_shutdown |= RCV_SHUTDOWN;
+               break;
+       case SHUT_WR:
+               if (sk->sk_shutdown & SEND_SHUTDOWN)
+                       goto unlock;
+               sk->sk_shutdown |= SEND_SHUTDOWN;
+               break;
+       case SHUT_RDWR:
+               if (sk->sk_shutdown & SHUTDOWN_MASK)
+                       goto unlock;
+               sk->sk_shutdown |= SHUTDOWN_MASK;
+               break;
        }
 
+       iso_sock_clear_timer(sk);
+       __iso_sock_close(sk);
+
+       if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&
+           !(current->flags & PF_EXITING))
+               err = bt_sock_wait_state(sk, BT_CLOSED, sk->sk_lingertime);
+
+unlock:
        release_sock(sk);
        sock_put(sk);
 
index cbe0cae..2c9de67 100644 (file)
@@ -1992,11 +1992,11 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
                        src_match = !bacmp(&c->src, src);
                        dst_match = !bacmp(&c->dst, dst);
                        if (src_match && dst_match) {
-                               c = l2cap_chan_hold_unless_zero(c);
-                               if (c) {
-                                       read_unlock(&chan_list_lock);
-                                       return c;
-                               }
+                               if (!l2cap_chan_hold_unless_zero(c))
+                                       continue;
+
+                               read_unlock(&chan_list_lock);
+                               return c;
                        }
 
                        /* Closest match */
index 6e31023..72e6595 100644 (file)
@@ -4547,6 +4547,22 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev,
                               MGMT_STATUS_NOT_SUPPORTED);
 }
 
+static u32 get_params_flags(struct hci_dev *hdev,
+                           struct hci_conn_params *params)
+{
+       u32 flags = hdev->conn_flags;
+
+       /* Devices using RPAs can only be programmed in the acceptlist if
+        * LL Privacy has been enable otherwise they cannot mark
+        * HCI_CONN_FLAG_REMOTE_WAKEUP.
+        */
+       if ((flags & HCI_CONN_FLAG_REMOTE_WAKEUP) && !use_ll_privacy(hdev) &&
+           hci_find_irk_by_addr(hdev, &params->addr, params->addr_type))
+               flags &= ~HCI_CONN_FLAG_REMOTE_WAKEUP;
+
+       return flags;
+}
+
 static int get_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
                            u16 data_len)
 {
@@ -4578,10 +4594,10 @@ static int get_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
        } else {
                params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
                                                le_addr_type(cp->addr.type));
-
                if (!params)
                        goto done;
 
+               supported_flags = get_params_flags(hdev, params);
                current_flags = params->flags;
        }
 
@@ -4649,38 +4665,35 @@ static int set_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
                        bt_dev_warn(hdev, "No such BR/EDR device %pMR (0x%x)",
                                    &cp->addr.bdaddr, cp->addr.type);
                }
-       } else {
-               params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
-                                               le_addr_type(cp->addr.type));
-               if (params) {
-                       /* Devices using RPAs can only be programmed in the
-                        * acceptlist LL Privacy has been enable otherwise they
-                        * cannot mark HCI_CONN_FLAG_REMOTE_WAKEUP.
-                        */
-                       if ((current_flags & HCI_CONN_FLAG_REMOTE_WAKEUP) &&
-                           !use_ll_privacy(hdev) &&
-                           hci_find_irk_by_addr(hdev, &params->addr,
-                                                params->addr_type)) {
-                               bt_dev_warn(hdev,
-                                           "Cannot set wakeable for RPA");
-                               goto unlock;
-                       }
 
-                       params->flags = current_flags;
-                       status = MGMT_STATUS_SUCCESS;
+               goto unlock;
+       }
 
-                       /* Update passive scan if HCI_CONN_FLAG_DEVICE_PRIVACY
-                        * has been set.
-                        */
-                       if (params->flags & HCI_CONN_FLAG_DEVICE_PRIVACY)
-                               hci_update_passive_scan(hdev);
-               } else {
-                       bt_dev_warn(hdev, "No such LE device %pMR (0x%x)",
-                                   &cp->addr.bdaddr,
-                                   le_addr_type(cp->addr.type));
-               }
+       params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
+                                       le_addr_type(cp->addr.type));
+       if (!params) {
+               bt_dev_warn(hdev, "No such LE device %pMR (0x%x)",
+                           &cp->addr.bdaddr, le_addr_type(cp->addr.type));
+               goto unlock;
        }
 
+       supported_flags = get_params_flags(hdev, params);
+
+       if ((supported_flags | current_flags) != supported_flags) {
+               bt_dev_warn(hdev, "Bad flag given (0x%x) vs supported (0x%0x)",
+                           current_flags, supported_flags);
+               goto unlock;
+       }
+
+       params->flags = current_flags;
+       status = MGMT_STATUS_SUCCESS;
+
+       /* Update passive scan if HCI_CONN_FLAG_DEVICE_PRIVACY
+        * has been set.
+        */
+       if (params->flags & HCI_CONN_FLAG_DEVICE_PRIVACY)
+               hci_update_passive_scan(hdev);
+
 unlock:
        hci_dev_unlock(hdev);
 
@@ -5054,7 +5067,6 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,
                else
                        status = MGMT_STATUS_FAILED;
 
-               mgmt_pending_remove(cmd);
                goto unlock;
        }
 
index ff47790..f20f437 100644 (file)
@@ -384,6 +384,7 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_
                                /* - Bridged-and-DNAT'ed traffic doesn't
                                 *   require ip_forwarding. */
                                if (rt->dst.dev == dev) {
+                                       skb_dst_drop(skb);
                                        skb_dst_set(skb, &rt->dst);
                                        goto bridged_dnat;
                                }
@@ -413,6 +414,7 @@ bridged_dnat:
                        kfree_skb(skb);
                        return 0;
                }
+               skb_dst_drop(skb);
                skb_dst_set_noref(skb, &rt->dst);
        }
 
index e4e0c83..6b07f30 100644 (file)
@@ -197,6 +197,7 @@ static int br_nf_pre_routing_finish_ipv6(struct net *net, struct sock *sk, struc
                        kfree_skb(skb);
                        return 0;
                }
+               skb_dst_drop(skb);
                skb_dst_set_noref(skb, &rt->dst);
        }
 
index 1a11064..8f19253 100644 (file)
@@ -36,18 +36,10 @@ static struct ebt_replace_kernel initial_table = {
        .entries        = (char *)&initial_chain,
 };
 
-static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
-{
-       if (valid_hooks & ~(1 << NF_BR_BROUTING))
-               return -EINVAL;
-       return 0;
-}
-
 static const struct ebt_table broute_table = {
        .name           = "broute",
        .table          = &initial_table,
        .valid_hooks    = 1 << NF_BR_BROUTING,
-       .check          = check,
        .me             = THIS_MODULE,
 };
 
index cb94943..278f324 100644 (file)
@@ -43,18 +43,10 @@ static struct ebt_replace_kernel initial_table = {
        .entries        = (char *)initial_chains,
 };
 
-static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
-{
-       if (valid_hooks & ~FILTER_VALID_HOOKS)
-               return -EINVAL;
-       return 0;
-}
-
 static const struct ebt_table frame_filter = {
        .name           = "filter",
        .table          = &initial_table,
        .valid_hooks    = FILTER_VALID_HOOKS,
-       .check          = check,
        .me             = THIS_MODULE,
 };
 
index 5ee0531..9066f7f 100644 (file)
@@ -43,18 +43,10 @@ static struct ebt_replace_kernel initial_table = {
        .entries        = (char *)initial_chains,
 };
 
-static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
-{
-       if (valid_hooks & ~NAT_VALID_HOOKS)
-               return -EINVAL;
-       return 0;
-}
-
 static const struct ebt_table frame_nat = {
        .name           = "nat",
        .table          = &initial_table,
        .valid_hooks    = NAT_VALID_HOOKS,
-       .check          = check,
        .me             = THIS_MODULE,
 };
 
index f2dbefb..9a0ae59 100644 (file)
@@ -1040,8 +1040,7 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
                goto free_iterate;
        }
 
-       /* the table doesn't like it */
-       if (t->check && (ret = t->check(newinfo, repl->valid_hooks)))
+       if (repl->valid_hooks != t->valid_hooks)
                goto free_unlock;
 
        if (repl->num_counters && repl->num_counters != t->private->nentries) {
@@ -1231,11 +1230,6 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
        if (ret != 0)
                goto free_chainstack;
 
-       if (table->check && table->check(newinfo, table->valid_hooks)) {
-               ret = -EINVAL;
-               goto free_chainstack;
-       }
-
        table->private = newinfo;
        rwlock_init(&table->lock);
        mutex_lock(&ebt_mutex);
diff --git a/net/core/.gitignore b/net/core/.gitignore
deleted file mode 100644 (file)
index df1e743..0000000
+++ /dev/null
@@ -1 +0,0 @@
-dropreason_str.c
index e8ce3bd..5857cec 100644 (file)
@@ -5,7 +5,7 @@
 
 obj-y := sock.o request_sock.o skbuff.o datagram.o stream.o scm.o \
         gen_stats.o gen_estimator.o net_namespace.o secure_seq.o \
-        flow_dissector.o dropreason_str.o
+        flow_dissector.o
 
 obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
 
@@ -40,23 +40,3 @@ obj-$(CONFIG_NET_SOCK_MSG) += skmsg.o
 obj-$(CONFIG_BPF_SYSCALL) += sock_map.o
 obj-$(CONFIG_BPF_SYSCALL) += bpf_sk_storage.o
 obj-$(CONFIG_OF)       += of_net.o
-
-clean-files := dropreason_str.c
-
-quiet_cmd_dropreason_str = GEN     $@
-cmd_dropreason_str = awk -F ',' 'BEGIN{ print "\#include <net/dropreason.h>\n"; \
-       print "const char * const drop_reasons[] = {" }\
-       /^enum skb_drop/ { dr=1; }\
-       /^\};/ { dr=0; }\
-       /^\tSKB_DROP_REASON_/ {\
-               if (dr) {\
-                       sub(/\tSKB_DROP_REASON_/, "", $$1);\
-                       printf "\t[SKB_DROP_REASON_%s] = \"%s\",\n", $$1, $$1;\
-               }\
-       }\
-       END{ print "};" }' $< > $@
-
-$(obj)/dropreason_str.c: $(srctree)/include/net/dropreason.h
-       $(call cmd,dropreason_str)
-
-$(obj)/dropreason_str.o: $(obj)/dropreason_str.c
index 1b7f385..94374d5 100644 (file)
@@ -310,11 +310,12 @@ BPF_CALL_2(bpf_sk_storage_delete, struct bpf_map *, map, struct sock *, sk)
 static int bpf_sk_storage_charge(struct bpf_local_storage_map *smap,
                                 void *owner, u32 size)
 {
+       int optmem_max = READ_ONCE(sysctl_optmem_max);
        struct sock *sk = (struct sock *)owner;
 
        /* same check as in sock_kmalloc() */
-       if (size <= sysctl_optmem_max &&
-           atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) {
+       if (size <= optmem_max &&
+           atomic_read(&sk->sk_omem_alloc) + size < optmem_max) {
                atomic_add(size, &sk->sk_omem_alloc);
                return 0;
        }
index 7255531..e4ff2db 100644 (file)
@@ -677,7 +677,7 @@ int __zerocopy_sg_from_iter(struct msghdr *msg, struct sock *sk,
                                page_ref_sub(last_head, refs);
                                refs = 0;
                        }
-                       skb_fill_page_desc(skb, frag++, head, start, size);
+                       skb_fill_page_desc_noacc(skb, frag++, head, start, size);
                }
                if (refs)
                        page_ref_sub(last_head, refs);
index 716df64..56c8b09 100644 (file)
@@ -4624,7 +4624,7 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen)
        struct softnet_data *sd;
        unsigned int old_flow, new_flow;
 
-       if (qlen < (netdev_max_backlog >> 1))
+       if (qlen < (READ_ONCE(netdev_max_backlog) >> 1))
                return false;
 
        sd = this_cpu_ptr(&softnet_data);
@@ -4672,7 +4672,7 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,
        if (!netif_running(skb->dev))
                goto drop;
        qlen = skb_queue_len(&sd->input_pkt_queue);
-       if (qlen <= netdev_max_backlog && !skb_flow_limit(skb, qlen)) {
+       if (qlen <= READ_ONCE(netdev_max_backlog) && !skb_flow_limit(skb, qlen)) {
                if (qlen) {
 enqueue:
                        __skb_queue_tail(&sd->input_pkt_queue, skb);
@@ -4928,7 +4928,7 @@ static int netif_rx_internal(struct sk_buff *skb)
 {
        int ret;
 
-       net_timestamp_check(netdev_tstamp_prequeue, skb);
+       net_timestamp_check(READ_ONCE(netdev_tstamp_prequeue), skb);
 
        trace_netif_rx(skb);
 
@@ -5281,7 +5281,7 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
        int ret = NET_RX_DROP;
        __be16 type;
 
-       net_timestamp_check(!netdev_tstamp_prequeue, skb);
+       net_timestamp_check(!READ_ONCE(netdev_tstamp_prequeue), skb);
 
        trace_netif_receive_skb(skb);
 
@@ -5664,7 +5664,7 @@ static int netif_receive_skb_internal(struct sk_buff *skb)
 {
        int ret;
 
-       net_timestamp_check(netdev_tstamp_prequeue, skb);
+       net_timestamp_check(READ_ONCE(netdev_tstamp_prequeue), skb);
 
        if (skb_defer_rx_timestamp(skb))
                return NET_RX_SUCCESS;
@@ -5694,7 +5694,7 @@ void netif_receive_skb_list_internal(struct list_head *head)
 
        INIT_LIST_HEAD(&sublist);
        list_for_each_entry_safe(skb, next, head, list) {
-               net_timestamp_check(netdev_tstamp_prequeue, skb);
+               net_timestamp_check(READ_ONCE(netdev_tstamp_prequeue), skb);
                skb_list_del_init(skb);
                if (!skb_defer_rx_timestamp(skb))
                        list_add_tail(&skb->list, &sublist);
@@ -5918,7 +5918,7 @@ static int process_backlog(struct napi_struct *napi, int quota)
                net_rps_action_and_irq_enable(sd);
        }
 
-       napi->weight = dev_rx_weight;
+       napi->weight = READ_ONCE(dev_rx_weight);
        while (again) {
                struct sk_buff *skb;
 
@@ -6665,8 +6665,8 @@ static __latent_entropy void net_rx_action(struct softirq_action *h)
 {
        struct softnet_data *sd = this_cpu_ptr(&softnet_data);
        unsigned long time_limit = jiffies +
-               usecs_to_jiffies(netdev_budget_usecs);
-       int budget = netdev_budget;
+               usecs_to_jiffies(READ_ONCE(netdev_budget_usecs));
+       int budget = READ_ONCE(netdev_budget);
        LIST_HEAD(list);
        LIST_HEAD(repoll);
 
@@ -10284,7 +10284,7 @@ static struct net_device *netdev_wait_allrefs_any(struct list_head *list)
                                return dev;
 
                if (time_after(jiffies, warning_time +
-                              netdev_unregister_timeout_secs * HZ)) {
+                              READ_ONCE(netdev_unregister_timeout_secs) * HZ)) {
                        list_for_each_entry(dev, list, todo_list) {
                                pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n",
                                         dev->name, netdev_refcnt_read(dev));
index e8508aa..c191db8 100644 (file)
@@ -1214,10 +1214,11 @@ void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
 static bool __sk_filter_charge(struct sock *sk, struct sk_filter *fp)
 {
        u32 filter_size = bpf_prog_size(fp->prog->len);
+       int optmem_max = READ_ONCE(sysctl_optmem_max);
 
        /* same check as in sock_kmalloc() */
-       if (filter_size <= sysctl_optmem_max &&
-           atomic_read(&sk->sk_omem_alloc) + filter_size < sysctl_optmem_max) {
+       if (filter_size <= optmem_max &&
+           atomic_read(&sk->sk_omem_alloc) + filter_size < optmem_max) {
                atomic_add(filter_size, &sk->sk_omem_alloc);
                return true;
        }
@@ -1548,7 +1549,7 @@ int sk_reuseport_attach_filter(struct sock_fprog *fprog, struct sock *sk)
        if (IS_ERR(prog))
                return PTR_ERR(prog);
 
-       if (bpf_prog_size(prog->len) > sysctl_optmem_max)
+       if (bpf_prog_size(prog->len) > READ_ONCE(sysctl_optmem_max))
                err = -ENOMEM;
        else
                err = reuseport_attach_prog(sk, prog);
@@ -1615,7 +1616,7 @@ int sk_reuseport_attach_bpf(u32 ufd, struct sock *sk)
                }
        } else {
                /* BPF_PROG_TYPE_SOCKET_FILTER */
-               if (bpf_prog_size(prog->len) > sysctl_optmem_max) {
+               if (bpf_prog_size(prog->len) > READ_ONCE(sysctl_optmem_max)) {
                        err = -ENOMEM;
                        goto err_prog_put;
                }
@@ -5034,14 +5035,14 @@ static int __bpf_setsockopt(struct sock *sk, int level, int optname,
                /* Only some socketops are supported */
                switch (optname) {
                case SO_RCVBUF:
-                       val = min_t(u32, val, sysctl_rmem_max);
+                       val = min_t(u32, val, READ_ONCE(sysctl_rmem_max));
                        val = min_t(int, val, INT_MAX / 2);
                        sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
                        WRITE_ONCE(sk->sk_rcvbuf,
                                   max_t(int, val * 2, SOCK_MIN_RCVBUF));
                        break;
                case SO_SNDBUF:
-                       val = min_t(u32, val, sysctl_wmem_max);
+                       val = min_t(u32, val, READ_ONCE(sysctl_wmem_max));
                        val = min_t(int, val, INT_MAX / 2);
                        sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
                        WRITE_ONCE(sk->sk_sndbuf,
index 541c7a7..21619c7 100644 (file)
@@ -26,7 +26,7 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
 
        cell = this_cpu_ptr(gcells->cells);
 
-       if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
+       if (skb_queue_len(&cell->napi_skbs) > READ_ONCE(netdev_max_backlog)) {
 drop:
                dev_core_stats_rx_dropped_inc(dev);
                kfree_skb(skb);
index 5b669eb..78cc8fb 100644 (file)
@@ -309,14 +309,17 @@ static int neigh_del_timer(struct neighbour *n)
 
 static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net)
 {
+       struct sk_buff_head tmp;
        unsigned long flags;
        struct sk_buff *skb;
 
+       skb_queue_head_init(&tmp);
        spin_lock_irqsave(&list->lock, flags);
        skb = skb_peek(list);
        while (skb != NULL) {
                struct sk_buff *skb_next = skb_peek_next(skb, list);
                struct net_device *dev = skb->dev;
+
                if (net == NULL || net_eq(dev_net(dev), net)) {
                        struct in_device *in_dev;
 
@@ -326,13 +329,16 @@ static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net)
                                in_dev->arp_parms->qlen--;
                        rcu_read_unlock();
                        __skb_unlink(skb, list);
-
-                       dev_put(dev);
-                       kfree_skb(skb);
+                       __skb_queue_tail(&tmp, skb);
                }
                skb = skb_next;
        }
        spin_unlock_irqrestore(&list->lock, flags);
+
+       while ((skb = __skb_dequeue(&tmp))) {
+               dev_put(skb->dev);
+               kfree_skb(skb);
+       }
 }
 
 static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev,
index 974bbbb..417463d 100644 (file)
@@ -91,7 +91,11 @@ static struct kmem_cache *skbuff_ext_cache __ro_after_init;
 int sysctl_max_skb_frags __read_mostly = MAX_SKB_FRAGS;
 EXPORT_SYMBOL(sysctl_max_skb_frags);
 
-/* The array 'drop_reasons' is auto-generated in dropreason_str.c */
+#undef FN
+#define FN(reason) [SKB_DROP_REASON_##reason] = #reason,
+const char * const drop_reasons[] = {
+       DEFINE_DROP_REASON(FN, FN)
+};
 EXPORT_SYMBOL(drop_reasons);
 
 /**
@@ -4205,9 +4209,8 @@ normal:
                                SKB_GSO_CB(nskb)->csum_start =
                                        skb_headroom(nskb) + doffset;
                        } else {
-                               skb_copy_bits(head_skb, offset,
-                                             skb_put(nskb, len),
-                                             len);
+                               if (skb_copy_bits(head_skb, offset, skb_put(nskb, len), len))
+                                       goto err;
                        }
                        continue;
                }
@@ -4798,7 +4801,7 @@ static bool skb_may_tx_timestamp(struct sock *sk, bool tsonly)
 {
        bool ret;
 
-       if (likely(sysctl_tstamp_allow_data || tsonly))
+       if (likely(READ_ONCE(sysctl_tstamp_allow_data) || tsonly))
                return true;
 
        read_lock_bh(&sk->sk_callback_lock);
index 59e75ff..188f855 100644 (file)
@@ -461,7 +461,7 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
 
                        if (copied == len)
                                break;
-               } while (!sg_is_last(sge));
+               } while ((i != msg_rx->sg.end) && !sg_is_last(sge));
 
                if (unlikely(peek)) {
                        msg_rx = sk_psock_next_msg(psock, msg_rx);
@@ -471,7 +471,7 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
                }
 
                msg_rx->sg.start = i;
-               if (!sge->length && sg_is_last(sge)) {
+               if (!sge->length && (i == msg_rx->sg.end || sg_is_last(sge))) {
                        msg_rx = sk_psock_dequeue_msg(psock);
                        kfree_sk_msg(msg_rx);
                }
index 4cb957d..788c137 100644 (file)
@@ -1101,7 +1101,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
                 * play 'guess the biggest size' games. RCVBUF/SNDBUF
                 * are treated in BSD as hints
                 */
-               val = min_t(u32, val, sysctl_wmem_max);
+               val = min_t(u32, val, READ_ONCE(sysctl_wmem_max));
 set_sndbuf:
                /* Ensure val * 2 fits into an int, to prevent max_t()
                 * from treating it as a negative value.
@@ -1133,7 +1133,7 @@ set_sndbuf:
                 * play 'guess the biggest size' games. RCVBUF/SNDBUF
                 * are treated in BSD as hints
                 */
-               __sock_set_rcvbuf(sk, min_t(u32, val, sysctl_rmem_max));
+               __sock_set_rcvbuf(sk, min_t(u32, val, READ_ONCE(sysctl_rmem_max)));
                break;
 
        case SO_RCVBUFFORCE:
@@ -2536,7 +2536,7 @@ struct sk_buff *sock_omalloc(struct sock *sk, unsigned long size,
 
        /* small safe race: SKB_TRUESIZE may differ from final skb->truesize */
        if (atomic_read(&sk->sk_omem_alloc) + SKB_TRUESIZE(size) >
-           sysctl_optmem_max)
+           READ_ONCE(sysctl_optmem_max))
                return NULL;
 
        skb = alloc_skb(size, priority);
@@ -2554,8 +2554,10 @@ struct sk_buff *sock_omalloc(struct sock *sk, unsigned long size,
  */
 void *sock_kmalloc(struct sock *sk, int size, gfp_t priority)
 {
-       if ((unsigned int)size <= sysctl_optmem_max &&
-           atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) {
+       int optmem_max = READ_ONCE(sysctl_optmem_max);
+
+       if ((unsigned int)size <= optmem_max &&
+           atomic_read(&sk->sk_omem_alloc) + size < optmem_max) {
                void *mem;
                /* First do the add, to avoid the race if kmalloc
                 * might sleep.
@@ -3309,8 +3311,8 @@ void sock_init_data(struct socket *sock, struct sock *sk)
        timer_setup(&sk->sk_timer, NULL, 0);
 
        sk->sk_allocation       =       GFP_KERNEL;
-       sk->sk_rcvbuf           =       sysctl_rmem_default;
-       sk->sk_sndbuf           =       sysctl_wmem_default;
+       sk->sk_rcvbuf           =       READ_ONCE(sysctl_rmem_default);
+       sk->sk_sndbuf           =       READ_ONCE(sysctl_wmem_default);
        sk->sk_state            =       TCP_CLOSE;
        sk_set_socket(sk, sock);
 
@@ -3365,7 +3367,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
 
 #ifdef CONFIG_NET_RX_BUSY_POLL
        sk->sk_napi_id          =       0;
-       sk->sk_ll_usec          =       sysctl_net_busy_read;
+       sk->sk_ll_usec          =       READ_ONCE(sysctl_net_busy_read);
 #endif
 
        sk->sk_max_pacing_rate = ~0UL;
index 71a1359..7258915 100644 (file)
@@ -234,14 +234,17 @@ static int set_default_qdisc(struct ctl_table *table, int write,
 static int proc_do_dev_weight(struct ctl_table *table, int write,
                           void *buffer, size_t *lenp, loff_t *ppos)
 {
-       int ret;
+       static DEFINE_MUTEX(dev_weight_mutex);
+       int ret, weight;
 
+       mutex_lock(&dev_weight_mutex);
        ret = proc_dointvec(table, write, buffer, lenp, ppos);
-       if (ret != 0)
-               return ret;
-
-       dev_rx_weight = weight_p * dev_weight_rx_bias;
-       dev_tx_weight = weight_p * dev_weight_tx_bias;
+       if (!ret && write) {
+               weight = READ_ONCE(weight_p);
+               WRITE_ONCE(dev_rx_weight, weight * dev_weight_rx_bias);
+               WRITE_ONCE(dev_tx_weight, weight * dev_weight_tx_bias);
+       }
+       mutex_unlock(&dev_weight_mutex);
 
        return ret;
 }
index ad6a666..1291c24 100644 (file)
@@ -2484,7 +2484,7 @@ static int dsa_slave_changeupper(struct net_device *dev,
                        if (!err)
                                dsa_bridge_mtu_normalization(dp);
                        if (err == -EOPNOTSUPP) {
-                               if (!extack->_msg)
+                               if (extack && !extack->_msg)
                                        NL_SET_ERR_MSG_MOD(extack,
                                                           "Offloading not supported");
                                err = 0;
index eb204ad..846588c 100644 (file)
@@ -45,7 +45,7 @@ static struct sk_buff *hellcreek_rcv(struct sk_buff *skb,
 
        skb->dev = dsa_master_find_slave(dev, 0, port);
        if (!skb->dev) {
-               netdev_warn(dev, "Failed to get source port: %d\n", port);
+               netdev_warn_once(dev, "Failed to get source port: %d\n", port);
                return NULL;
        }
 
index 92b778e..e8b9a92 100644 (file)
@@ -2682,23 +2682,27 @@ static __net_init int devinet_init_net(struct net *net)
 #endif
 
        if (!net_eq(net, &init_net)) {
-               if (IS_ENABLED(CONFIG_SYSCTL) &&
-                   sysctl_devconf_inherit_init_net == 3) {
+               switch (net_inherit_devconf()) {
+               case 3:
                        /* copy from the current netns */
                        memcpy(all, current->nsproxy->net_ns->ipv4.devconf_all,
                               sizeof(ipv4_devconf));
                        memcpy(dflt,
                               current->nsproxy->net_ns->ipv4.devconf_dflt,
                               sizeof(ipv4_devconf_dflt));
-               } else if (!IS_ENABLED(CONFIG_SYSCTL) ||
-                          sysctl_devconf_inherit_init_net != 2) {
-                       /* inherit == 0 or 1: copy from init_net */
+                       break;
+               case 0:
+               case 1:
+                       /* copy from init_net */
                        memcpy(all, init_net.ipv4.devconf_all,
                               sizeof(ipv4_devconf));
                        memcpy(dflt, init_net.ipv4.devconf_dflt,
                               sizeof(ipv4_devconf_dflt));
+                       break;
+               case 2:
+                       /* use compiled values */
+                       break;
                }
-               /* else inherit == 2: use compiled values */
        }
 
 #ifdef CONFIG_SYSCTL
index f361d3d..943edf4 100644 (file)
@@ -389,7 +389,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
        dev_match = dev_match || (res.type == RTN_LOCAL &&
                                  dev == net->loopback_dev);
        if (dev_match) {
-               ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_HOST;
+               ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_LINK;
                return ret;
        }
        if (no_addr)
@@ -401,7 +401,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
        ret = 0;
        if (fib_lookup(net, &fl4, &res, FIB_LOOKUP_IGNORE_LINKSTATE) == 0) {
                if (res.type == RTN_UNICAST)
-                       ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_HOST;
+                       ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_LINK;
        }
        return ret;
 
index 5c58e21..f866d62 100644 (file)
@@ -609,7 +609,7 @@ static int gre_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
        ip_tunnel_init_flow(&fl4, IPPROTO_GRE, key->u.ipv4.dst, key->u.ipv4.src,
                            tunnel_id_to_key32(key->tun_id),
                            key->tos & ~INET_ECN_MASK, dev_net(dev), 0,
-                           skb->mark, skb_get_hash(skb));
+                           skb->mark, skb_get_hash(skb), key->flow_flags);
        rt = ip_route_output_key(dev_net(dev), &fl4);
        if (IS_ERR(rt))
                return PTR_ERR(rt);
index d7bd1da..04e2034 100644 (file)
@@ -1730,7 +1730,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
 
        sk->sk_protocol = ip_hdr(skb)->protocol;
        sk->sk_bound_dev_if = arg->bound_dev_if;
-       sk->sk_sndbuf = sysctl_wmem_default;
+       sk->sk_sndbuf = READ_ONCE(sysctl_wmem_default);
        ipc.sockc.mark = fl4.flowi4_mark;
        err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base,
                             len, 0, &ipc, &rt, MSG_DONTWAIT);
index a8a323e..e49a61a 100644 (file)
@@ -772,7 +772,7 @@ static int ip_set_mcast_msfilter(struct sock *sk, sockptr_t optval, int optlen)
 
        if (optlen < GROUP_FILTER_SIZE(0))
                return -EINVAL;
-       if (optlen > sysctl_optmem_max)
+       if (optlen > READ_ONCE(sysctl_optmem_max))
                return -ENOBUFS;
 
        gsf = memdup_sockptr(optval, optlen);
@@ -808,7 +808,7 @@ static int compat_ip_set_mcast_msfilter(struct sock *sk, sockptr_t optval,
 
        if (optlen < size0)
                return -EINVAL;
-       if (optlen > sysctl_optmem_max - 4)
+       if (optlen > READ_ONCE(sysctl_optmem_max) - 4)
                return -ENOBUFS;
 
        p = kmalloc(optlen + 4, GFP_KERNEL);
@@ -1233,7 +1233,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, int optname,
 
                if (optlen < IP_MSFILTER_SIZE(0))
                        goto e_inval;
-               if (optlen > sysctl_optmem_max) {
+               if (optlen > READ_ONCE(sysctl_optmem_max)) {
                        err = -ENOBUFS;
                        break;
                }
index e65e948..019f3b0 100644 (file)
@@ -295,7 +295,7 @@ static int ip_tunnel_bind_dev(struct net_device *dev)
                ip_tunnel_init_flow(&fl4, iph->protocol, iph->daddr,
                                    iph->saddr, tunnel->parms.o_key,
                                    RT_TOS(iph->tos), dev_net(dev),
-                                   tunnel->parms.link, tunnel->fwmark, 0);
+                                   tunnel->parms.link, tunnel->fwmark, 0, 0);
                rt = ip_route_output_key(tunnel->net, &fl4);
 
                if (!IS_ERR(rt)) {
@@ -570,7 +570,8 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
        }
        ip_tunnel_init_flow(&fl4, proto, key->u.ipv4.dst, key->u.ipv4.src,
                            tunnel_id_to_key32(key->tun_id), RT_TOS(tos),
-                           dev_net(dev), 0, skb->mark, skb_get_hash(skb));
+                           dev_net(dev), 0, skb->mark, skb_get_hash(skb),
+                           key->flow_flags);
        if (tunnel->encap.type != TUNNEL_ENCAP_NONE)
                goto tx_error;
 
@@ -729,7 +730,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
        ip_tunnel_init_flow(&fl4, protocol, dst, tnl_params->saddr,
                            tunnel->parms.o_key, RT_TOS(tos),
                            dev_net(dev), tunnel->parms.link,
-                           tunnel->fwmark, skb_get_hash(skb));
+                           tunnel->fwmark, skb_get_hash(skb), 0);
 
        if (ip_tunnel_encap(skb, tunnel, &protocol, &fl4) < 0)
                goto tx_error;
index bbe2187..6cdfce6 100644 (file)
@@ -1000,7 +1000,7 @@ new_segment:
 
        i = skb_shinfo(skb)->nr_frags;
        can_coalesce = skb_can_coalesce(skb, i, page, offset);
-       if (!can_coalesce && i >= sysctl_max_skb_frags) {
+       if (!can_coalesce && i >= READ_ONCE(sysctl_max_skb_frags)) {
                tcp_mark_push(tp, skb);
                goto new_segment;
        }
@@ -1015,7 +1015,7 @@ new_segment:
                skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy);
        } else {
                get_page(page);
-               skb_fill_page_desc(skb, i, page, offset, copy);
+               skb_fill_page_desc_noacc(skb, i, page, offset, copy);
        }
 
        if (!(flags & MSG_NO_SHARED_FRAGS))
@@ -1354,7 +1354,7 @@ new_segment:
 
                        if (!skb_can_coalesce(skb, i, pfrag->page,
                                              pfrag->offset)) {
-                               if (i >= sysctl_max_skb_frags) {
+                               if (i >= READ_ONCE(sysctl_max_skb_frags)) {
                                        tcp_mark_push(tp, skb);
                                        goto new_segment;
                                }
index ab5f0ea..bc2ea12 100644 (file)
@@ -2513,6 +2513,21 @@ static inline bool tcp_may_undo(const struct tcp_sock *tp)
        return tp->undo_marker && (!tp->undo_retrans || tcp_packet_delayed(tp));
 }
 
+static bool tcp_is_non_sack_preventing_reopen(struct sock *sk)
+{
+       struct tcp_sock *tp = tcp_sk(sk);
+
+       if (tp->snd_una == tp->high_seq && tcp_is_reno(tp)) {
+               /* Hold old state until something *above* high_seq
+                * is ACKed. For Reno it is MUST to prevent false
+                * fast retransmits (RFC2582). SACK TCP is safe. */
+               if (!tcp_any_retrans_done(sk))
+                       tp->retrans_stamp = 0;
+               return true;
+       }
+       return false;
+}
+
 /* People celebrate: "We love our President!" */
 static bool tcp_try_undo_recovery(struct sock *sk)
 {
@@ -2535,14 +2550,8 @@ static bool tcp_try_undo_recovery(struct sock *sk)
        } else if (tp->rack.reo_wnd_persist) {
                tp->rack.reo_wnd_persist--;
        }
-       if (tp->snd_una == tp->high_seq && tcp_is_reno(tp)) {
-               /* Hold old state until something *above* high_seq
-                * is ACKed. For Reno it is MUST to prevent false
-                * fast retransmits (RFC2582). SACK TCP is safe. */
-               if (!tcp_any_retrans_done(sk))
-                       tp->retrans_stamp = 0;
+       if (tcp_is_non_sack_preventing_reopen(sk))
                return true;
-       }
        tcp_set_ca_state(sk, TCP_CA_Open);
        tp->is_sack_reneg = 0;
        return false;
@@ -2578,6 +2587,8 @@ static bool tcp_try_undo_loss(struct sock *sk, bool frto_undo)
                        NET_INC_STATS(sock_net(sk),
                                        LINUX_MIB_TCPSPURIOUSRTOS);
                inet_csk(sk)->icsk_retransmits = 0;
+               if (tcp_is_non_sack_preventing_reopen(sk))
+                       return true;
                if (frto_undo || tcp_is_sack(tp)) {
                        tcp_set_ca_state(sk, TCP_CA_Open);
                        tp->is_sack_reneg = 0;
@@ -3614,12 +3625,9 @@ bool tcp_oow_rate_limited(struct net *net, const struct sk_buff *skb,
 /* RFC 5961 7 [ACK Throttling] */
 static void tcp_send_challenge_ack(struct sock *sk)
 {
-       /* unprotected vars, we dont care of overwrites */
-       static u32 challenge_timestamp;
-       static unsigned int challenge_count;
        struct tcp_sock *tp = tcp_sk(sk);
        struct net *net = sock_net(sk);
-       u32 count, now;
+       u32 count, now, ack_limit;
 
        /* First check our per-socket dupack rate limit. */
        if (__tcp_oow_rate_limited(net,
@@ -3627,18 +3635,22 @@ static void tcp_send_challenge_ack(struct sock *sk)
                                   &tp->last_oow_ack_time))
                return;
 
+       ack_limit = READ_ONCE(net->ipv4.sysctl_tcp_challenge_ack_limit);
+       if (ack_limit == INT_MAX)
+               goto send_ack;
+
        /* Then check host-wide RFC 5961 rate limit. */
        now = jiffies / HZ;
-       if (now != challenge_timestamp) {
-               u32 ack_limit = READ_ONCE(net->ipv4.sysctl_tcp_challenge_ack_limit);
+       if (now != READ_ONCE(net->ipv4.tcp_challenge_timestamp)) {
                u32 half = (ack_limit + 1) >> 1;
 
-               challenge_timestamp = now;
-               WRITE_ONCE(challenge_count, half + prandom_u32_max(ack_limit));
+               WRITE_ONCE(net->ipv4.tcp_challenge_timestamp, now);
+               WRITE_ONCE(net->ipv4.tcp_challenge_count, half + prandom_u32_max(ack_limit));
        }
-       count = READ_ONCE(challenge_count);
+       count = READ_ONCE(net->ipv4.tcp_challenge_count);
        if (count > 0) {
-               WRITE_ONCE(challenge_count, count - 1);
+               WRITE_ONCE(net->ipv4.tcp_challenge_count, count - 1);
+send_ack:
                NET_INC_STATS(net, LINUX_MIB_TCPCHALLENGEACK);
                tcp_send_ack(sk);
        }
index 0c83780..5b019ba 100644 (file)
@@ -3139,8 +3139,10 @@ static int __net_init tcp_sk_init(struct net *net)
        net->ipv4.sysctl_tcp_tso_win_divisor = 3;
        /* Default TSQ limit of 16 TSO segments */
        net->ipv4.sysctl_tcp_limit_output_bytes = 16 * 65536;
-       /* rfc5961 challenge ack rate limiting */
-       net->ipv4.sysctl_tcp_challenge_ack_limit = 1000;
+
+       /* rfc5961 challenge ack rate limiting, per net-ns, disabled by default. */
+       net->ipv4.sysctl_tcp_challenge_ack_limit = INT_MAX;
+
        net->ipv4.sysctl_tcp_min_tso_segs = 2;
        net->ipv4.sysctl_tcp_tso_rtt_log = 9;  /* 2^9 = 512 usec */
        net->ipv4.sysctl_tcp_min_rtt_wlen = 300;
index 78b654f..290019d 100644 (file)
@@ -239,7 +239,7 @@ void tcp_select_initial_window(const struct sock *sk, int __space, __u32 mss,
        if (wscale_ok) {
                /* Set window scaling on max possible window */
                space = max_t(u32, space, READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rmem[2]));
-               space = max_t(u32, space, sysctl_rmem_max);
+               space = max_t(u32, space, READ_ONCE(sysctl_rmem_max));
                space = min_t(u32, space, *window_clamp);
                *rcv_wscale = clamp_t(int, ilog2(space) - 15,
                                      0, TCP_MAX_WSCALE);
index 34eda97..cd72158 100644 (file)
@@ -783,6 +783,8 @@ int __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable)
         */
        if (tunnel) {
                /* ...not for tunnels though: we don't have a sending socket */
+               if (udp_sk(sk)->encap_err_rcv)
+                       udp_sk(sk)->encap_err_rcv(sk, skb, iph->ihl << 2);
                goto out;
        }
        if (!inet->recverr) {
index 8efaf8c..8242c89 100644 (file)
@@ -72,6 +72,7 @@ void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
 
        udp_sk(sk)->encap_type = cfg->encap_type;
        udp_sk(sk)->encap_rcv = cfg->encap_rcv;
+       udp_sk(sk)->encap_err_rcv = cfg->encap_err_rcv;
        udp_sk(sk)->encap_err_lookup = cfg->encap_err_lookup;
        udp_sk(sk)->encap_destroy = cfg->encap_destroy;
        udp_sk(sk)->gro_receive = cfg->gro_receive;
index b624e3d..10ce86b 100644 (file)
@@ -3557,11 +3557,15 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
                fallthrough;
        case NETDEV_UP:
        case NETDEV_CHANGE:
-               if (dev->flags & IFF_SLAVE)
+               if (idev && idev->cnf.disable_ipv6)
                        break;
 
-               if (idev && idev->cnf.disable_ipv6)
+               if (dev->flags & IFF_SLAVE) {
+                       if (event == NETDEV_UP && !IS_ERR_OR_NULL(idev) &&
+                           dev->flags & IFF_UP && dev->flags & IFF_MULTICAST)
+                               ipv6_mc_up(idev);
                        break;
+               }
 
                if (event == NETDEV_UP) {
                        /* restore routes for permanent addresses */
@@ -7162,9 +7166,8 @@ static int __net_init addrconf_init_net(struct net *net)
        if (!dflt)
                goto err_alloc_dflt;
 
-       if (IS_ENABLED(CONFIG_SYSCTL) &&
-           !net_eq(net, &init_net)) {
-               switch (sysctl_devconf_inherit_init_net) {
+       if (!net_eq(net, &init_net)) {
+               switch (net_inherit_devconf()) {
                case 1:  /* copy from init_net */
                        memcpy(all, init_net.ipv6.devconf_all,
                               sizeof(ipv6_devconf));
index 222f6bf..e0dcc7a 100644 (file)
@@ -210,7 +210,7 @@ static int ipv6_set_mcast_msfilter(struct sock *sk, sockptr_t optval,
 
        if (optlen < GROUP_FILTER_SIZE(0))
                return -EINVAL;
-       if (optlen > sysctl_optmem_max)
+       if (optlen > READ_ONCE(sysctl_optmem_max))
                return -ENOBUFS;
 
        gsf = memdup_sockptr(optval, optlen);
@@ -244,7 +244,7 @@ static int compat_ipv6_set_mcast_msfilter(struct sock *sk, sockptr_t optval,
 
        if (optlen < size0)
                return -EINVAL;
-       if (optlen > sysctl_optmem_max - 4)
+       if (optlen > READ_ONCE(sysctl_optmem_max) - 4)
                return -ENOBUFS;
 
        p = kmalloc(optlen + 4, GFP_KERNEL);
index 7dd3629..38db006 100644 (file)
@@ -86,7 +86,6 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
        table[1].extra2 = &nf_frag->fqdir->high_thresh;
        table[2].data   = &nf_frag->fqdir->high_thresh;
        table[2].extra1 = &nf_frag->fqdir->low_thresh;
-       table[2].extra2 = &nf_frag->fqdir->high_thresh;
 
        hdr = register_net_sysctl(net, "net/netfilter", table);
        if (hdr == NULL)
index 73aaabf..0b0e34d 100644 (file)
@@ -191,6 +191,11 @@ static int seg6_genl_sethmac(struct sk_buff *skb, struct genl_info *info)
                goto out_unlock;
        }
 
+       if (slen > nla_len(info->attrs[SEG6_ATTR_SECRET])) {
+               err = -EINVAL;
+               goto out_unlock;
+       }
+
        if (hinfo) {
                err = seg6_hmac_info_del(net, hmackeyid);
                if (err)
index 16c176e..3366d6a 100644 (file)
@@ -616,8 +616,11 @@ int __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        }
 
        /* Tunnels don't have an application socket: don't pass errors back */
-       if (tunnel)
+       if (tunnel) {
+               if (udp_sk(sk)->encap_err_rcv)
+                       udp_sk(sk)->encap_err_rcv(sk, skb, offset);
                goto out;
+       }
 
        if (!np->recverr) {
                if (!harderr || sk->sk_state != TCP_ESTABLISHED)
index 71899e5..1215c86 100644 (file)
@@ -1412,12 +1412,6 @@ static int kcm_attach(struct socket *sock, struct socket *csock,
        psock->sk = csk;
        psock->bpf_prog = prog;
 
-       err = strp_init(&psock->strp, csk, &cb);
-       if (err) {
-               kmem_cache_free(kcm_psockp, psock);
-               goto out;
-       }
-
        write_lock_bh(&csk->sk_callback_lock);
 
        /* Check if sk_user_data is already by KCM or someone else.
@@ -1425,13 +1419,18 @@ static int kcm_attach(struct socket *sock, struct socket *csock,
         */
        if (csk->sk_user_data) {
                write_unlock_bh(&csk->sk_callback_lock);
-               strp_stop(&psock->strp);
-               strp_done(&psock->strp);
                kmem_cache_free(kcm_psockp, psock);
                err = -EALREADY;
                goto out;
        }
 
+       err = strp_init(&psock->strp, csk, &cb);
+       if (err) {
+               write_unlock_bh(&csk->sk_callback_lock);
+               kmem_cache_free(kcm_psockp, psock);
+               goto out;
+       }
+
        psock->save_data_ready = csk->sk_data_ready;
        psock->save_write_space = csk->sk_write_space;
        psock->save_state_change = csk->sk_state_change;
index fda2dcc..c85df5b 100644 (file)
@@ -1697,9 +1697,12 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sad
                pfk->registered |= (1<<hdr->sadb_msg_satype);
        }
 
+       mutex_lock(&pfkey_mutex);
        xfrm_probe_algs();
 
        supp_skb = compose_sadb_supported(hdr, GFP_KERNEL | __GFP_ZERO);
+       mutex_unlock(&pfkey_mutex);
+
        if (!supp_skb) {
                if (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC)
                        pfk->registered &= ~(1<<hdr->sadb_msg_satype);
index d56890e..9b283bb 100644 (file)
@@ -530,6 +530,10 @@ int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata)
 
        sdata_assert_lock(sdata);
 
+       /* When not connected/joined, sending CSA doesn't make sense. */
+       if (ifibss->state != IEEE80211_IBSS_MLME_JOINED)
+               return -ENOLINK;
+
        /* update cfg80211 bss information with the new channel */
        if (!is_zero_ether_addr(ifibss->bssid)) {
                cbss = cfg80211_get_bss(sdata->local->hw.wiphy,
index 3d4ab71..5265d2b 100644 (file)
@@ -3420,11 +3420,11 @@ static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata,
                ieee80211_link_info_change_notify(sdata, &sdata->deflink,
                                                  BSS_CHANGED_BSSID);
                sdata->u.mgd.flags = 0;
+
                mutex_lock(&sdata->local->mtx);
                ieee80211_link_release_channel(&sdata->deflink);
-               mutex_unlock(&sdata->local->mtx);
-
                ieee80211_vif_set_links(sdata, 0);
+               mutex_unlock(&sdata->local->mtx);
        }
 
        cfg80211_put_bss(sdata->local->hw.wiphy, auth_data->bss);
@@ -3462,10 +3462,6 @@ static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata,
                sdata->u.mgd.flags = 0;
                sdata->vif.bss_conf.mu_mimo_owner = false;
 
-               mutex_lock(&sdata->local->mtx);
-               ieee80211_link_release_channel(&sdata->deflink);
-               mutex_unlock(&sdata->local->mtx);
-
                if (status != ASSOC_REJECTED) {
                        struct cfg80211_assoc_failure data = {
                                .timeout = status == ASSOC_TIMEOUT,
@@ -3484,7 +3480,10 @@ static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata,
                        cfg80211_assoc_failure(sdata->dev, &data);
                }
 
+               mutex_lock(&sdata->local->mtx);
+               ieee80211_link_release_channel(&sdata->deflink);
                ieee80211_vif_set_links(sdata, 0);
+               mutex_unlock(&sdata->local->mtx);
        }
 
        kfree(assoc_data);
@@ -6509,6 +6508,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
        return 0;
 
 out_err:
+       ieee80211_link_release_channel(&sdata->deflink);
        ieee80211_vif_set_links(sdata, 0);
        return err;
 }
index 57df21e..45d7e71 100644 (file)
@@ -4074,6 +4074,7 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
                .link_id = -1,
        };
        struct tid_ampdu_rx *tid_agg_rx;
+       u8 link_id;
 
        tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
        if (!tid_agg_rx)
@@ -4093,6 +4094,9 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
                };
                drv_event_callback(rx.local, rx.sdata, &event);
        }
+       /* FIXME: statistics won't be right with this */
+       link_id = sta->sta.valid_links ? ffs(sta->sta.valid_links) - 1 : 0;
+       rx.link = rcu_dereference(sta->sdata->link[link_id]);
 
        ieee80211_rx_handlers(&rx, &frames);
 }
index fa8ddf5..c4f2aeb 100644 (file)
@@ -469,16 +469,19 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
        scan_req = rcu_dereference_protected(local->scan_req,
                                             lockdep_is_held(&local->mtx));
 
-       if (scan_req != local->int_scan_req) {
-               local->scan_info.aborted = aborted;
-               cfg80211_scan_done(scan_req, &local->scan_info);
-       }
        RCU_INIT_POINTER(local->scan_req, NULL);
        RCU_INIT_POINTER(local->scan_sdata, NULL);
 
        local->scanning = 0;
        local->scan_chandef.chan = NULL;
 
+       synchronize_rcu();
+
+       if (scan_req != local->int_scan_req) {
+               local->scan_info.aborted = aborted;
+               cfg80211_scan_done(scan_req, &local->scan_info);
+       }
+
        /* Set power back to normal operating levels. */
        ieee80211_hw_config(local, 0);
 
index cb23da9..58998d8 100644 (file)
@@ -494,7 +494,7 @@ __sta_info_alloc(struct ieee80211_sub_if_data *sdata,
        sta->sdata = sdata;
 
        if (sta_info_alloc_link(local, &sta->deflink, gfp))
-               return NULL;
+               goto free;
 
        if (link_id >= 0) {
                sta_info_add_link(sta, link_id, &sta->deflink,
@@ -2316,9 +2316,9 @@ static inline u64 sta_get_tidstats_msdu(struct ieee80211_sta_rx_stats *rxstats,
        u64 value;
 
        do {
-               start = u64_stats_fetch_begin(&rxstats->syncp);
+               start = u64_stats_fetch_begin_irq(&rxstats->syncp);
                value = rxstats->msdu[tid];
-       } while (u64_stats_fetch_retry(&rxstats->syncp, start));
+       } while (u64_stats_fetch_retry_irq(&rxstats->syncp, start));
 
        return value;
 }
@@ -2384,9 +2384,9 @@ static inline u64 sta_get_stats_bytes(struct ieee80211_sta_rx_stats *rxstats)
        u64 value;
 
        do {
-               start = u64_stats_fetch_begin(&rxstats->syncp);
+               start = u64_stats_fetch_begin_irq(&rxstats->syncp);
                value = rxstats->bytes;
-       } while (u64_stats_fetch_retry(&rxstats->syncp, start));
+       } while (u64_stats_fetch_retry_irq(&rxstats->syncp, start));
 
        return value;
 }
index 45df993..bf7fe6c 100644 (file)
@@ -5885,6 +5885,7 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,
        rcu_read_lock();
        err = ieee80211_lookup_ra_sta(sdata, skb, &sta);
        if (err) {
+               dev_kfree_skb(skb);
                rcu_read_unlock();
                return err;
        }
@@ -5899,7 +5900,7 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,
                 * for MLO STA, the SA should be the AP MLD address, but
                 * the link ID has been selected already
                 */
-               if (sta->sta.mlo)
+               if (sta && sta->sta.mlo)
                        memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN);
        }
        rcu_read_unlock();
index 93ec2f3..20f742b 100644 (file)
@@ -351,7 +351,7 @@ static u8 ccmp_gcmp_aad(struct sk_buff *skb, u8 *aad)
         * FC | A1 | A2 | A3 | SC | [A4] | [QC] */
        put_unaligned_be16(len_a, &aad[0]);
        put_unaligned(mask_fc, (__le16 *)&aad[2]);
-       memcpy(&aad[4], &hdr->addr1, 3 * ETH_ALEN);
+       memcpy(&aad[4], &hdr->addrs, 3 * ETH_ALEN);
 
        /* Mask Seq#, leave Frag# */
        aad[22] = *((u8 *) &hdr->seq_ctrl) & 0x0f;
@@ -792,7 +792,7 @@ static void bip_aad(struct sk_buff *skb, u8 *aad)
                                IEEE80211_FCTL_MOREDATA);
        put_unaligned(mask_fc, (__le16 *) &aad[0]);
        /* A1 || A2 || A3 */
-       memcpy(aad + 2, &hdr->addr1, 3 * ETH_ALEN);
+       memcpy(aad + 2, &hdr->addrs, 3 * ETH_ALEN);
 }
 
 
index b8ce846..c439125 100644 (file)
@@ -44,7 +44,7 @@ ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata,
 
        switch (mac_cb(skb)->dest.mode) {
        case IEEE802154_ADDR_NONE:
-               if (mac_cb(skb)->dest.mode != IEEE802154_ADDR_NONE)
+               if (hdr->source.mode != IEEE802154_ADDR_NONE)
                        /* FIXME: check if we are PAN coordinator */
                        skb->pkt_type = PACKET_OTHERHOST;
                else
index 35b5f80..b52afe3 100644 (file)
@@ -1079,9 +1079,9 @@ static void mpls_get_stats(struct mpls_dev *mdev,
 
                p = per_cpu_ptr(mdev->stats, i);
                do {
-                       start = u64_stats_fetch_begin(&p->syncp);
+                       start = u64_stats_fetch_begin_irq(&p->syncp);
                        local = p->stats;
-               } while (u64_stats_fetch_retry(&p->syncp, start));
+               } while (u64_stats_fetch_retry_irq(&p->syncp, start));
 
                stats->rx_packets       += local.rx_packets;
                stats->rx_bytes         += local.rx_bytes;
index da42575..d398f38 100644 (file)
@@ -1263,7 +1263,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 
                i = skb_shinfo(skb)->nr_frags;
                can_coalesce = skb_can_coalesce(skb, i, dfrag->page, offset);
-               if (!can_coalesce && i >= sysctl_max_skb_frags) {
+               if (!can_coalesce && i >= READ_ONCE(sysctl_max_skb_frags)) {
                        tcp_mark_push(tcp_sk(ssk), skb);
                        goto alloc_skb;
                }
index 9d43277..a56fd0b 100644 (file)
@@ -1280,12 +1280,12 @@ static void set_sock_size(struct sock *sk, int mode, int val)
        lock_sock(sk);
        if (mode) {
                val = clamp_t(int, val, (SOCK_MIN_SNDBUF + 1) / 2,
-                             sysctl_wmem_max);
+                             READ_ONCE(sysctl_wmem_max));
                sk->sk_sndbuf = val * 2;
                sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
        } else {
                val = clamp_t(int, val, (SOCK_MIN_RCVBUF + 1) / 2,
-                             sysctl_rmem_max);
+                             READ_ONCE(sysctl_rmem_max));
                sk->sk_rcvbuf = val * 2;
                sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
        }
index 71c2f4f..1357a27 100644 (file)
@@ -1782,7 +1782,7 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
                }
                spin_unlock_bh(&nf_conntrack_expect_lock);
        }
-       if (!exp)
+       if (!exp && tmpl)
                __nf_ct_try_assign_helper(ct, tmpl, GFP_ATOMIC);
 
        /* Other CPU might have obtained a pointer to this object before it was
@@ -2068,10 +2068,6 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
        ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply;
        if (ct->master || (help && !hlist_empty(&help->expectations)))
                return;
-
-       rcu_read_lock();
-       __nf_ct_try_assign_helper(ct, NULL, GFP_ATOMIC);
-       rcu_read_unlock();
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply);
 
@@ -2797,7 +2793,6 @@ int nf_conntrack_init_net(struct net *net)
        nf_conntrack_acct_pernet_init(net);
        nf_conntrack_tstamp_pernet_init(net);
        nf_conntrack_ecache_pernet_init(net);
-       nf_conntrack_helper_pernet_init(net);
        nf_conntrack_proto_pernet_init(net);
 
        return 0;
index e96b322..ff737a7 100644 (file)
@@ -35,11 +35,6 @@ unsigned int nf_ct_helper_hsize __read_mostly;
 EXPORT_SYMBOL_GPL(nf_ct_helper_hsize);
 static unsigned int nf_ct_helper_count __read_mostly;
 
-static bool nf_ct_auto_assign_helper __read_mostly = false;
-module_param_named(nf_conntrack_helper, nf_ct_auto_assign_helper, bool, 0644);
-MODULE_PARM_DESC(nf_conntrack_helper,
-                "Enable automatic conntrack helper assignment (default 0)");
-
 static DEFINE_MUTEX(nf_ct_nat_helpers_mutex);
 static struct list_head nf_ct_nat_helpers __read_mostly;
 
@@ -51,24 +46,6 @@ static unsigned int helper_hash(const struct nf_conntrack_tuple *tuple)
                (__force __u16)tuple->src.u.all) % nf_ct_helper_hsize;
 }
 
-static struct nf_conntrack_helper *
-__nf_ct_helper_find(const struct nf_conntrack_tuple *tuple)
-{
-       struct nf_conntrack_helper *helper;
-       struct nf_conntrack_tuple_mask mask = { .src.u.all = htons(0xFFFF) };
-       unsigned int h;
-
-       if (!nf_ct_helper_count)
-               return NULL;
-
-       h = helper_hash(tuple);
-       hlist_for_each_entry_rcu(helper, &nf_ct_helper_hash[h], hnode) {
-               if (nf_ct_tuple_src_mask_cmp(tuple, &helper->tuple, &mask))
-                       return helper;
-       }
-       return NULL;
-}
-
 struct nf_conntrack_helper *
 __nf_conntrack_helper_find(const char *name, u16 l3num, u8 protonum)
 {
@@ -209,33 +186,11 @@ nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp)
 }
 EXPORT_SYMBOL_GPL(nf_ct_helper_ext_add);
 
-static struct nf_conntrack_helper *
-nf_ct_lookup_helper(struct nf_conn *ct, struct net *net)
-{
-       struct nf_conntrack_net *cnet = nf_ct_pernet(net);
-
-       if (!cnet->sysctl_auto_assign_helper) {
-               if (cnet->auto_assign_helper_warned)
-                       return NULL;
-               if (!__nf_ct_helper_find(&ct->tuplehash[IP_CT_DIR_REPLY].tuple))
-                       return NULL;
-               pr_info("nf_conntrack: default automatic helper assignment "
-                       "has been turned off for security reasons and CT-based "
-                       "firewall rule not found. Use the iptables CT target "
-                       "to attach helpers instead.\n");
-               cnet->auto_assign_helper_warned = true;
-               return NULL;
-       }
-
-       return __nf_ct_helper_find(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
-}
-
 int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
                              gfp_t flags)
 {
        struct nf_conntrack_helper *helper = NULL;
        struct nf_conn_help *help;
-       struct net *net = nf_ct_net(ct);
 
        /* We already got a helper explicitly attached. The function
         * nf_conntrack_alter_reply - in case NAT is in use - asks for looking
@@ -246,23 +201,21 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
        if (test_bit(IPS_HELPER_BIT, &ct->status))
                return 0;
 
-       if (tmpl != NULL) {
-               help = nfct_help(tmpl);
-               if (help != NULL) {
-                       helper = rcu_dereference(help->helper);
-                       set_bit(IPS_HELPER_BIT, &ct->status);
-               }
+       if (WARN_ON_ONCE(!tmpl))
+               return 0;
+
+       help = nfct_help(tmpl);
+       if (help != NULL) {
+               helper = rcu_dereference(help->helper);
+               set_bit(IPS_HELPER_BIT, &ct->status);
        }
 
        help = nfct_help(ct);
 
        if (helper == NULL) {
-               helper = nf_ct_lookup_helper(ct, net);
-               if (helper == NULL) {
-                       if (help)
-                               RCU_INIT_POINTER(help->helper, NULL);
-                       return 0;
-               }
+               if (help)
+                       RCU_INIT_POINTER(help->helper, NULL);
+               return 0;
        }
 
        if (help == NULL) {
@@ -545,19 +498,6 @@ void nf_nat_helper_unregister(struct nf_conntrack_nat_helper *nat)
 }
 EXPORT_SYMBOL_GPL(nf_nat_helper_unregister);
 
-void nf_ct_set_auto_assign_helper_warned(struct net *net)
-{
-       nf_ct_pernet(net)->auto_assign_helper_warned = true;
-}
-EXPORT_SYMBOL_GPL(nf_ct_set_auto_assign_helper_warned);
-
-void nf_conntrack_helper_pernet_init(struct net *net)
-{
-       struct nf_conntrack_net *cnet = nf_ct_pernet(net);
-
-       cnet->sysctl_auto_assign_helper = nf_ct_auto_assign_helper;
-}
-
 int nf_conntrack_helper_init(void)
 {
        nf_ct_helper_hsize = 1; /* gets rounded up to use one page */
index 1796c45..992decb 100644 (file)
@@ -194,8 +194,9 @@ static int help(struct sk_buff *skb, unsigned int protoff,
 
                        /* dcc_ip can be the internal OR external (NAT'ed) IP */
                        tuple = &ct->tuplehash[dir].tuple;
-                       if (tuple->src.u3.ip != dcc_ip &&
-                           tuple->dst.u3.ip != dcc_ip) {
+                       if ((tuple->src.u3.ip != dcc_ip &&
+                            ct->tuplehash[!dir].tuple.dst.u3.ip != dcc_ip) ||
+                           dcc_port == 0) {
                                net_warn_ratelimited("Forged DCC command from %pI4: %pI4:%u\n",
                                                     &tuple->src.u3.ip,
                                                     &dcc_ip, dcc_port);
index 04169b5..7562b21 100644 (file)
@@ -2298,11 +2298,6 @@ ctnetlink_create_conntrack(struct net *net,
                        ct->status |= IPS_HELPER;
                        RCU_INIT_POINTER(help->helper, helper);
                }
-       } else {
-               /* try an implicit helper assignation */
-               err = __nf_ct_try_assign_helper(ct, NULL, GFP_ATOMIC);
-               if (err < 0)
-                       goto err2;
        }
 
        err = ctnetlink_setup_nat(ct, cda);
index a63b51d..a634c72 100644 (file)
@@ -655,6 +655,37 @@ static bool tcp_in_window(struct nf_conn *ct,
                    tn->tcp_be_liberal)
                        res = true;
                if (!res) {
+                       bool seq_ok = before(seq, sender->td_maxend + 1);
+
+                       if (!seq_ok) {
+                               u32 overshot = end - sender->td_maxend + 1;
+                               bool ack_ok;
+
+                               ack_ok = after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1);
+
+                               if (in_recv_win &&
+                                   ack_ok &&
+                                   overshot <= receiver->td_maxwin &&
+                                   before(sack, receiver->td_end + 1)) {
+                                       /* Work around TCPs that send more bytes than allowed by
+                                        * the receive window.
+                                        *
+                                        * If the (marked as invalid) packet is allowed to pass by
+                                        * the ruleset and the peer acks this data, then its possible
+                                        * all future packets will trigger 'ACK is over upper bound' check.
+                                        *
+                                        * Thus if only the sequence check fails then do update td_end so
+                                        * possible ACK for this data can update internal state.
+                                        */
+                                       sender->td_end = end;
+                                       sender->flags |= IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED;
+
+                                       nf_ct_l4proto_log_invalid(skb, ct, hook_state,
+                                                                 "%u bytes more than expected", overshot);
+                                       return res;
+                               }
+                       }
+
                        nf_ct_l4proto_log_invalid(skb, ct, hook_state,
                        "%s",
                        before(seq, sender->td_maxend + 1) ?
index 0589587..4ffe84c 100644 (file)
@@ -561,7 +561,6 @@ enum nf_ct_sysctl_index {
        NF_SYSCTL_CT_LOG_INVALID,
        NF_SYSCTL_CT_EXPECT_MAX,
        NF_SYSCTL_CT_ACCT,
-       NF_SYSCTL_CT_HELPER,
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
        NF_SYSCTL_CT_EVENTS,
 #endif
@@ -680,14 +679,6 @@ static struct ctl_table nf_ct_sysctl_table[] = {
                .extra1         = SYSCTL_ZERO,
                .extra2         = SYSCTL_ONE,
        },
-       [NF_SYSCTL_CT_HELPER] = {
-               .procname       = "nf_conntrack_helper",
-               .maxlen         = sizeof(u8),
-               .mode           = 0644,
-               .proc_handler   = proc_dou8vec_minmax,
-               .extra1         = SYSCTL_ZERO,
-               .extra2         = SYSCTL_ONE,
-       },
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
        [NF_SYSCTL_CT_EVENTS] = {
                .procname       = "nf_conntrack_events",
@@ -1100,7 +1091,6 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
        table[NF_SYSCTL_CT_CHECKSUM].data = &net->ct.sysctl_checksum;
        table[NF_SYSCTL_CT_LOG_INVALID].data = &net->ct.sysctl_log_invalid;
        table[NF_SYSCTL_CT_ACCT].data = &net->ct.sysctl_acct;
-       table[NF_SYSCTL_CT_HELPER].data = &cnet->sysctl_auto_assign_helper;
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
        table[NF_SYSCTL_CT_EVENTS].data = &net->ct.sysctl_events;
 #endif
index 765ac77..81c26a9 100644 (file)
@@ -437,12 +437,17 @@ static void nf_flow_offload_gc_step(struct nf_flowtable *flow_table,
        }
 }
 
+void nf_flow_table_gc_run(struct nf_flowtable *flow_table)
+{
+       nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step, NULL);
+}
+
 static void nf_flow_offload_work_gc(struct work_struct *work)
 {
        struct nf_flowtable *flow_table;
 
        flow_table = container_of(work, struct nf_flowtable, gc_work.work);
-       nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step, NULL);
+       nf_flow_table_gc_run(flow_table);
        queue_delayed_work(system_power_efficient_wq, &flow_table->gc_work, HZ);
 }
 
@@ -600,11 +605,11 @@ void nf_flow_table_free(struct nf_flowtable *flow_table)
        mutex_unlock(&flowtable_lock);
 
        cancel_delayed_work_sync(&flow_table->gc_work);
-       nf_flow_table_iterate(flow_table, nf_flow_table_do_cleanup, NULL);
-       nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step, NULL);
        nf_flow_table_offload_flush(flow_table);
-       if (nf_flowtable_hw_offload(flow_table))
-               nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step, NULL);
+       /* ... no more pending work after this stage ... */
+       nf_flow_table_iterate(flow_table, nf_flow_table_do_cleanup, NULL);
+       nf_flow_table_gc_run(flow_table);
+       nf_flow_table_offload_flush_cleanup(flow_table);
        rhashtable_destroy(&flow_table->rhashtable);
 }
 EXPORT_SYMBOL_GPL(nf_flow_table_free);
index 103b6cb..b04645c 100644 (file)
@@ -1074,6 +1074,14 @@ void nf_flow_offload_stats(struct nf_flowtable *flowtable,
        flow_offload_queue_work(offload);
 }
 
+void nf_flow_table_offload_flush_cleanup(struct nf_flowtable *flowtable)
+{
+       if (nf_flowtable_hw_offload(flowtable)) {
+               flush_workqueue(nf_flow_offload_del_wq);
+               nf_flow_table_gc_run(flowtable);
+       }
+}
+
 void nf_flow_table_offload_flush(struct nf_flowtable *flowtable)
 {
        if (nf_flowtable_hw_offload(flowtable)) {
index 62cfb0e..8160520 100644 (file)
@@ -32,7 +32,6 @@ static LIST_HEAD(nf_tables_objects);
 static LIST_HEAD(nf_tables_flowtables);
 static LIST_HEAD(nf_tables_destroy_list);
 static DEFINE_SPINLOCK(nf_tables_destroy_list_lock);
-static u64 table_handle;
 
 enum {
        NFT_VALIDATE_SKIP       = 0,
@@ -1235,7 +1234,7 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
        INIT_LIST_HEAD(&table->flowtables);
        table->family = family;
        table->flags = flags;
-       table->handle = ++table_handle;
+       table->handle = ++nft_net->table_handle;
        if (table->flags & NFT_TABLE_F_OWNER)
                table->nlpid = NETLINK_CB(skb).portid;
 
@@ -2167,8 +2166,10 @@ static int nft_basechain_init(struct nft_base_chain *basechain, u8 family,
        chain->flags |= NFT_CHAIN_BASE | flags;
        basechain->policy = NF_ACCEPT;
        if (chain->flags & NFT_CHAIN_HW_OFFLOAD &&
-           !nft_chain_offload_support(basechain))
+           !nft_chain_offload_support(basechain)) {
+               list_splice_init(&basechain->hook_list, &hook->list);
                return -EOPNOTSUPP;
+       }
 
        flow_block_init(&basechain->flow_block);
 
@@ -2196,9 +2197,9 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
                              struct netlink_ext_ack *extack)
 {
        const struct nlattr * const *nla = ctx->nla;
+       struct nft_stats __percpu *stats = NULL;
        struct nft_table *table = ctx->table;
        struct nft_base_chain *basechain;
-       struct nft_stats __percpu *stats;
        struct net *net = ctx->net;
        char name[NFT_NAME_MAXLEN];
        struct nft_rule_blob *blob;
@@ -2236,7 +2237,6 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
                                return PTR_ERR(stats);
                        }
                        rcu_assign_pointer(basechain->stats, stats);
-                       static_branch_inc(&nft_counters_enabled);
                }
 
                err = nft_basechain_init(basechain, family, &hook, flags);
@@ -2319,6 +2319,9 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
                goto err_unregister_hook;
        }
 
+       if (stats)
+               static_branch_inc(&nft_counters_enabled);
+
        table->use++;
 
        return 0;
@@ -2574,6 +2577,9 @@ static int nf_tables_newchain(struct sk_buff *skb, const struct nfnl_info *info,
        nft_ctx_init(&ctx, net, skb, info->nlh, family, table, chain, nla);
 
        if (chain != NULL) {
+               if (chain->flags & NFT_CHAIN_BINDING)
+                       return -EINVAL;
+
                if (info->nlh->nlmsg_flags & NLM_F_EXCL) {
                        NL_SET_BAD_ATTR(extack, attr);
                        return -EEXIST;
@@ -9707,6 +9713,8 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
                        return PTR_ERR(chain);
                if (nft_is_base_chain(chain))
                        return -EOPNOTSUPP;
+               if (nft_chain_is_bound(chain))
+                       return -EINVAL;
                if (desc->flags & NFT_DATA_DESC_SETELEM &&
                    chain->flags & NFT_CHAIN_BINDING)
                        return -EINVAL;
index b04995c..a3f01f2 100644 (file)
@@ -1089,9 +1089,6 @@ static int nft_ct_helper_obj_init(const struct nft_ctx *ctx,
        if (err < 0)
                goto err_put_helper;
 
-       /* Avoid the bogus warning, helper will be assigned after CT init */
-       nf_ct_set_auto_assign_helper_warned(ctx->net);
-
        return 0;
 
 err_put_helper:
index 0053a69..89342cc 100644 (file)
@@ -115,9 +115,21 @@ static int nft_osf_validate(const struct nft_ctx *ctx,
                            const struct nft_expr *expr,
                            const struct nft_data **data)
 {
-       return nft_chain_validate_hooks(ctx->chain, (1 << NF_INET_LOCAL_IN) |
-                                                   (1 << NF_INET_PRE_ROUTING) |
-                                                   (1 << NF_INET_FORWARD));
+       unsigned int hooks;
+
+       switch (ctx->family) {
+       case NFPROTO_IPV4:
+       case NFPROTO_IPV6:
+       case NFPROTO_INET:
+               hooks = (1 << NF_INET_LOCAL_IN) |
+                       (1 << NF_INET_PRE_ROUTING) |
+                       (1 << NF_INET_FORWARD);
+               break;
+       default:
+               return -EOPNOTSUPP;
+       }
+
+       return nft_chain_validate_hooks(ctx->chain, hooks);
 }
 
 static bool nft_osf_reduce(struct nft_regs_track *track,
index 2e7ac00..eb0e40c 100644 (file)
@@ -740,17 +740,23 @@ static int nft_payload_set_init(const struct nft_ctx *ctx,
                                const struct nlattr * const tb[])
 {
        struct nft_payload_set *priv = nft_expr_priv(expr);
+       u32 csum_offset, csum_type = NFT_PAYLOAD_CSUM_NONE;
+       int err;
 
        priv->base        = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_BASE]));
        priv->offset      = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_OFFSET]));
        priv->len         = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_LEN]));
 
        if (tb[NFTA_PAYLOAD_CSUM_TYPE])
-               priv->csum_type =
-                       ntohl(nla_get_be32(tb[NFTA_PAYLOAD_CSUM_TYPE]));
-       if (tb[NFTA_PAYLOAD_CSUM_OFFSET])
-               priv->csum_offset =
-                       ntohl(nla_get_be32(tb[NFTA_PAYLOAD_CSUM_OFFSET]));
+               csum_type = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_CSUM_TYPE]));
+       if (tb[NFTA_PAYLOAD_CSUM_OFFSET]) {
+               err = nft_parse_u32_check(tb[NFTA_PAYLOAD_CSUM_OFFSET], U8_MAX,
+                                         &csum_offset);
+               if (err < 0)
+                       return err;
+
+               priv->csum_offset = csum_offset;
+       }
        if (tb[NFTA_PAYLOAD_CSUM_FLAGS]) {
                u32 flags;
 
@@ -761,7 +767,7 @@ static int nft_payload_set_init(const struct nft_ctx *ctx,
                priv->csum_flags = flags;
        }
 
-       switch (priv->csum_type) {
+       switch (csum_type) {
        case NFT_PAYLOAD_CSUM_NONE:
        case NFT_PAYLOAD_CSUM_INET:
                break;
@@ -775,6 +781,7 @@ static int nft_payload_set_init(const struct nft_ctx *ctx,
        default:
                return -EOPNOTSUPP;
        }
+       priv->csum_type = csum_type;
 
        return nft_parse_register_load(tb[NFTA_PAYLOAD_SREG], &priv->sreg,
                                       priv->len);
@@ -833,6 +840,7 @@ nft_payload_select_ops(const struct nft_ctx *ctx,
 {
        enum nft_payload_bases base;
        unsigned int offset, len;
+       int err;
 
        if (tb[NFTA_PAYLOAD_BASE] == NULL ||
            tb[NFTA_PAYLOAD_OFFSET] == NULL ||
@@ -859,8 +867,13 @@ nft_payload_select_ops(const struct nft_ctx *ctx,
        if (tb[NFTA_PAYLOAD_DREG] == NULL)
                return ERR_PTR(-EINVAL);
 
-       offset = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_OFFSET]));
-       len    = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_LEN]));
+       err = nft_parse_u32_check(tb[NFTA_PAYLOAD_OFFSET], U8_MAX, &offset);
+       if (err < 0)
+               return ERR_PTR(err);
+
+       err = nft_parse_u32_check(tb[NFTA_PAYLOAD_LEN], U8_MAX, &len);
+       if (err < 0)
+               return ERR_PTR(err);
 
        if (len <= 4 && is_power_of_2(len) && IS_ALIGNED(offset, len) &&
            base != NFT_PAYLOAD_LL_HEADER && base != NFT_PAYLOAD_INNER_HEADER)
index 68b2eed..62da25a 100644 (file)
@@ -312,6 +312,13 @@ static int nft_tproxy_dump(struct sk_buff *skb,
        return 0;
 }
 
+static int nft_tproxy_validate(const struct nft_ctx *ctx,
+                              const struct nft_expr *expr,
+                              const struct nft_data **data)
+{
+       return nft_chain_validate_hooks(ctx->chain, 1 << NF_INET_PRE_ROUTING);
+}
+
 static struct nft_expr_type nft_tproxy_type;
 static const struct nft_expr_ops nft_tproxy_ops = {
        .type           = &nft_tproxy_type,
@@ -321,6 +328,7 @@ static const struct nft_expr_ops nft_tproxy_ops = {
        .destroy        = nft_tproxy_destroy,
        .dump           = nft_tproxy_dump,
        .reduce         = NFT_REDUCE_READONLY,
+       .validate       = nft_tproxy_validate,
 };
 
 static struct nft_expr_type nft_tproxy_type __read_mostly = {
index 5edaade..983ade4 100644 (file)
@@ -161,6 +161,7 @@ static const struct nft_expr_ops nft_tunnel_get_ops = {
 
 static struct nft_expr_type nft_tunnel_type __read_mostly = {
        .name           = "tunnel",
+       .family         = NFPROTO_NETDEV,
        .ops            = &nft_tunnel_get_ops,
        .policy         = nft_tunnel_policy,
        .maxattr        = NFTA_TUNNEL_MAX,
index 7e8a39a..6c9d153 100644 (file)
@@ -1802,7 +1802,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
                                ovs_dp_reset_user_features(skb, info);
                }
 
-               goto err_unlock_and_destroy_meters;
+               goto err_destroy_portids;
        }
 
        err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
@@ -1817,6 +1817,8 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
        ovs_notify(&dp_datapath_genl_family, reply, info);
        return 0;
 
+err_destroy_portids:
+       kfree(rcu_dereference_raw(dp->upcall_portids));
 err_unlock_and_destroy_meters:
        ovs_unlock();
        ovs_meters_exit(dp);
index 11c45c8..036d92c 100644 (file)
@@ -96,7 +96,8 @@ static void rose_loopback_timer(struct timer_list *unused)
                }
 
                if (frametype == ROSE_CALL_REQUEST) {
-                       if (!rose_loopback_neigh->dev) {
+                       if (!rose_loopback_neigh->dev &&
+                           !rose_loopback_neigh->loopback) {
                                kfree_skb(skb);
                                continue;
                        }
index 5714360..62c7070 100644 (file)
@@ -982,6 +982,7 @@ void rxrpc_send_keepalive(struct rxrpc_peer *);
 /*
  * peer_event.c
  */
+void rxrpc_encap_err_rcv(struct sock *sk, struct sk_buff *skb, unsigned int udp_offset);
 void rxrpc_error_report(struct sock *);
 void rxrpc_peer_keepalive_worker(struct work_struct *);
 
index f8ecad2..2a93e7b 100644 (file)
@@ -166,7 +166,7 @@ static void rxrpc_resend(struct rxrpc_call *call, unsigned long now_j)
        _enter("{%d,%d}", call->tx_hard_ack, call->tx_top);
 
        now = ktime_get_real();
-       max_age = ktime_sub(now, jiffies_to_usecs(call->peer->rto_j));
+       max_age = ktime_sub_us(now, jiffies_to_usecs(call->peer->rto_j));
 
        spin_lock_bh(&call->lock);
 
index 84d0a41..6401cdf 100644 (file)
@@ -285,8 +285,10 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,
        _enter("%p,%lx", rx, p->user_call_ID);
 
        limiter = rxrpc_get_call_slot(p, gfp);
-       if (!limiter)
+       if (!limiter) {
+               release_sock(&rx->sk);
                return ERR_PTR(-ERESTARTSYS);
+       }
 
        call = rxrpc_alloc_client_call(rx, srx, gfp, debug_id);
        if (IS_ERR(call)) {
index 96ecb73..38ea98f 100644 (file)
@@ -137,6 +137,7 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
 
        tuncfg.encap_type = UDP_ENCAP_RXRPC;
        tuncfg.encap_rcv = rxrpc_input_packet;
+       tuncfg.encap_err_rcv = rxrpc_encap_err_rcv;
        tuncfg.sk_user_data = local;
        setup_udp_tunnel_sock(net, local->socket, &tuncfg);
 
@@ -405,6 +406,9 @@ static void rxrpc_local_processor(struct work_struct *work)
                container_of(work, struct rxrpc_local, processor);
        bool again;
 
+       if (local->dead)
+               return;
+
        trace_rxrpc_local(local->debug_id, rxrpc_local_processing,
                          refcount_read(&local->ref), NULL);
 
index be03285..32561e9 100644 (file)
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
 #include <net/ip.h>
+#include <net/icmp.h>
 #include "ar-internal.h"
 
+static void rxrpc_adjust_mtu(struct rxrpc_peer *, unsigned int);
 static void rxrpc_store_error(struct rxrpc_peer *, struct sock_exterr_skb *);
 static void rxrpc_distribute_error(struct rxrpc_peer *, int,
                                   enum rxrpc_call_completion);
 
 /*
- * Find the peer associated with an ICMP packet.
+ * Find the peer associated with an ICMPv4 packet.
  */
 static struct rxrpc_peer *rxrpc_lookup_peer_icmp_rcu(struct rxrpc_local *local,
-                                                    const struct sk_buff *skb,
+                                                    struct sk_buff *skb,
+                                                    unsigned int udp_offset,
+                                                    unsigned int *info,
                                                     struct sockaddr_rxrpc *srx)
 {
-       struct sock_exterr_skb *serr = SKB_EXT_ERR(skb);
+       struct iphdr *ip, *ip0 = ip_hdr(skb);
+       struct icmphdr *icmp = icmp_hdr(skb);
+       struct udphdr *udp = (struct udphdr *)(skb->data + udp_offset);
 
-       _enter("");
+       _enter("%u,%u,%u", ip0->protocol, icmp->type, icmp->code);
+
+       switch (icmp->type) {
+       case ICMP_DEST_UNREACH:
+               *info = ntohs(icmp->un.frag.mtu);
+               fallthrough;
+       case ICMP_TIME_EXCEEDED:
+       case ICMP_PARAMETERPROB:
+               ip = (struct iphdr *)((void *)icmp + 8);
+               break;
+       default:
+               return NULL;
+       }
+
+       memset(srx, 0, sizeof(*srx));
+       srx->transport_type = local->srx.transport_type;
+       srx->transport_len = local->srx.transport_len;
+       srx->transport.family = local->srx.transport.family;
+
+       /* Can we see an ICMP4 packet on an ICMP6 listening socket?  and vice
+        * versa?
+        */
+       switch (srx->transport.family) {
+       case AF_INET:
+               srx->transport_len = sizeof(srx->transport.sin);
+               srx->transport.family = AF_INET;
+               srx->transport.sin.sin_port = udp->dest;
+               memcpy(&srx->transport.sin.sin_addr, &ip->daddr,
+                      sizeof(struct in_addr));
+               break;
+
+#ifdef CONFIG_AF_RXRPC_IPV6
+       case AF_INET6:
+               srx->transport_len = sizeof(srx->transport.sin);
+               srx->transport.family = AF_INET;
+               srx->transport.sin.sin_port = udp->dest;
+               memcpy(&srx->transport.sin.sin_addr, &ip->daddr,
+                      sizeof(struct in_addr));
+               break;
+#endif
+
+       default:
+               WARN_ON_ONCE(1);
+               return NULL;
+       }
+
+       _net("ICMP {%pISp}", &srx->transport);
+       return rxrpc_lookup_peer_rcu(local, srx);
+}
+
+#ifdef CONFIG_AF_RXRPC_IPV6
+/*
+ * Find the peer associated with an ICMPv6 packet.
+ */
+static struct rxrpc_peer *rxrpc_lookup_peer_icmp6_rcu(struct rxrpc_local *local,
+                                                     struct sk_buff *skb,
+                                                     unsigned int udp_offset,
+                                                     unsigned int *info,
+                                                     struct sockaddr_rxrpc *srx)
+{
+       struct icmp6hdr *icmp = icmp6_hdr(skb);
+       struct ipv6hdr *ip, *ip0 = ipv6_hdr(skb);
+       struct udphdr *udp = (struct udphdr *)(skb->data + udp_offset);
+
+       _enter("%u,%u,%u", ip0->nexthdr, icmp->icmp6_type, icmp->icmp6_code);
+
+       switch (icmp->icmp6_type) {
+       case ICMPV6_DEST_UNREACH:
+               *info = ntohl(icmp->icmp6_mtu);
+               fallthrough;
+       case ICMPV6_PKT_TOOBIG:
+       case ICMPV6_TIME_EXCEED:
+       case ICMPV6_PARAMPROB:
+               ip = (struct ipv6hdr *)((void *)icmp + 8);
+               break;
+       default:
+               return NULL;
+       }
 
        memset(srx, 0, sizeof(*srx));
        srx->transport_type = local->srx.transport_type;
@@ -43,6 +126,165 @@ static struct rxrpc_peer *rxrpc_lookup_peer_icmp_rcu(struct rxrpc_local *local,
         */
        switch (srx->transport.family) {
        case AF_INET:
+               _net("Rx ICMP6 on v4 sock");
+               srx->transport_len = sizeof(srx->transport.sin);
+               srx->transport.family = AF_INET;
+               srx->transport.sin.sin_port = udp->dest;
+               memcpy(&srx->transport.sin.sin_addr,
+                      &ip->daddr.s6_addr32[3], sizeof(struct in_addr));
+               break;
+       case AF_INET6:
+               _net("Rx ICMP6");
+               srx->transport.sin.sin_port = udp->dest;
+               memcpy(&srx->transport.sin6.sin6_addr, &ip->daddr,
+                      sizeof(struct in6_addr));
+               break;
+       default:
+               WARN_ON_ONCE(1);
+               return NULL;
+       }
+
+       _net("ICMP {%pISp}", &srx->transport);
+       return rxrpc_lookup_peer_rcu(local, srx);
+}
+#endif /* CONFIG_AF_RXRPC_IPV6 */
+
+/*
+ * Handle an error received on the local endpoint as a tunnel.
+ */
+void rxrpc_encap_err_rcv(struct sock *sk, struct sk_buff *skb,
+                        unsigned int udp_offset)
+{
+       struct sock_extended_err ee;
+       struct sockaddr_rxrpc srx;
+       struct rxrpc_local *local;
+       struct rxrpc_peer *peer;
+       unsigned int info = 0;
+       int err;
+       u8 version = ip_hdr(skb)->version;
+       u8 type = icmp_hdr(skb)->type;
+       u8 code = icmp_hdr(skb)->code;
+
+       rcu_read_lock();
+       local = rcu_dereference_sk_user_data(sk);
+       if (unlikely(!local)) {
+               rcu_read_unlock();
+               return;
+       }
+
+       rxrpc_new_skb(skb, rxrpc_skb_received);
+
+       switch (ip_hdr(skb)->version) {
+       case IPVERSION:
+               peer = rxrpc_lookup_peer_icmp_rcu(local, skb, udp_offset,
+                                                 &info, &srx);
+               break;
+#ifdef CONFIG_AF_RXRPC_IPV6
+       case 6:
+               peer = rxrpc_lookup_peer_icmp6_rcu(local, skb, udp_offset,
+                                                  &info, &srx);
+               break;
+#endif
+       default:
+               rcu_read_unlock();
+               return;
+       }
+
+       if (peer && !rxrpc_get_peer_maybe(peer))
+               peer = NULL;
+       if (!peer) {
+               rcu_read_unlock();
+               return;
+       }
+
+       memset(&ee, 0, sizeof(ee));
+
+       switch (version) {
+       case IPVERSION:
+               switch (type) {
+               case ICMP_DEST_UNREACH:
+                       switch (code) {
+                       case ICMP_FRAG_NEEDED:
+                               rxrpc_adjust_mtu(peer, info);
+                               rcu_read_unlock();
+                               rxrpc_put_peer(peer);
+                               return;
+                       default:
+                               break;
+                       }
+
+                       err = EHOSTUNREACH;
+                       if (code <= NR_ICMP_UNREACH) {
+                               /* Might want to do something different with
+                                * non-fatal errors
+                                */
+                               //harderr = icmp_err_convert[code].fatal;
+                               err = icmp_err_convert[code].errno;
+                       }
+                       break;
+
+               case ICMP_TIME_EXCEEDED:
+                       err = EHOSTUNREACH;
+                       break;
+               default:
+                       err = EPROTO;
+                       break;
+               }
+
+               ee.ee_origin = SO_EE_ORIGIN_ICMP;
+               ee.ee_type = type;
+               ee.ee_code = code;
+               ee.ee_errno = err;
+               break;
+
+#ifdef CONFIG_AF_RXRPC_IPV6
+       case 6:
+               switch (type) {
+               case ICMPV6_PKT_TOOBIG:
+                       rxrpc_adjust_mtu(peer, info);
+                       rcu_read_unlock();
+                       rxrpc_put_peer(peer);
+                       return;
+               }
+
+               icmpv6_err_convert(type, code, &err);
+
+               if (err == EACCES)
+                       err = EHOSTUNREACH;
+
+               ee.ee_origin = SO_EE_ORIGIN_ICMP6;
+               ee.ee_type = type;
+               ee.ee_code = code;
+               ee.ee_errno = err;
+               break;
+#endif
+       }
+
+       trace_rxrpc_rx_icmp(peer, &ee, &srx);
+
+       rxrpc_distribute_error(peer, err, RXRPC_CALL_NETWORK_ERROR);
+       rcu_read_unlock();
+       rxrpc_put_peer(peer);
+}
+
+/*
+ * Find the peer associated with a local error.
+ */
+static struct rxrpc_peer *rxrpc_lookup_peer_local_rcu(struct rxrpc_local *local,
+                                                     const struct sk_buff *skb,
+                                                     struct sockaddr_rxrpc *srx)
+{
+       struct sock_exterr_skb *serr = SKB_EXT_ERR(skb);
+
+       _enter("");
+
+       memset(srx, 0, sizeof(*srx));
+       srx->transport_type = local->srx.transport_type;
+       srx->transport_len = local->srx.transport_len;
+       srx->transport.family = local->srx.transport.family;
+
+       switch (srx->transport.family) {
+       case AF_INET:
                srx->transport_len = sizeof(srx->transport.sin);
                srx->transport.family = AF_INET;
                srx->transport.sin.sin_port = serr->port;
@@ -104,10 +346,8 @@ static struct rxrpc_peer *rxrpc_lookup_peer_icmp_rcu(struct rxrpc_local *local,
 /*
  * Handle an MTU/fragmentation problem.
  */
-static void rxrpc_adjust_mtu(struct rxrpc_peer *peer, struct sock_exterr_skb *serr)
+static void rxrpc_adjust_mtu(struct rxrpc_peer *peer, unsigned int mtu)
 {
-       u32 mtu = serr->ee.ee_info;
-
        _net("Rx ICMP Fragmentation Needed (%d)", mtu);
 
        /* wind down the local interface MTU */
@@ -148,7 +388,7 @@ void rxrpc_error_report(struct sock *sk)
        struct sock_exterr_skb *serr;
        struct sockaddr_rxrpc srx;
        struct rxrpc_local *local;
-       struct rxrpc_peer *peer;
+       struct rxrpc_peer *peer = NULL;
        struct sk_buff *skb;
 
        rcu_read_lock();
@@ -172,41 +412,20 @@ void rxrpc_error_report(struct sock *sk)
        }
        rxrpc_new_skb(skb, rxrpc_skb_received);
        serr = SKB_EXT_ERR(skb);
-       if (!skb->len && serr->ee.ee_origin == SO_EE_ORIGIN_TIMESTAMPING) {
-               _leave("UDP empty message");
-               rcu_read_unlock();
-               rxrpc_free_skb(skb, rxrpc_skb_freed);
-               return;
-       }
 
-       peer = rxrpc_lookup_peer_icmp_rcu(local, skb, &srx);
-       if (peer && !rxrpc_get_peer_maybe(peer))
-               peer = NULL;
-       if (!peer) {
-               rcu_read_unlock();
-               rxrpc_free_skb(skb, rxrpc_skb_freed);
-               _leave(" [no peer]");
-               return;
-       }
-
-       trace_rxrpc_rx_icmp(peer, &serr->ee, &srx);
-
-       if ((serr->ee.ee_origin == SO_EE_ORIGIN_ICMP &&
-            serr->ee.ee_type == ICMP_DEST_UNREACH &&
-            serr->ee.ee_code == ICMP_FRAG_NEEDED)) {
-               rxrpc_adjust_mtu(peer, serr);
-               rcu_read_unlock();
-               rxrpc_free_skb(skb, rxrpc_skb_freed);
-               rxrpc_put_peer(peer);
-               _leave(" [MTU update]");
-               return;
+       if (serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL) {
+               peer = rxrpc_lookup_peer_local_rcu(local, skb, &srx);
+               if (peer && !rxrpc_get_peer_maybe(peer))
+                       peer = NULL;
+               if (peer) {
+                       trace_rxrpc_rx_icmp(peer, &serr->ee, &srx);
+                       rxrpc_store_error(peer, serr);
+               }
        }
 
-       rxrpc_store_error(peer, serr);
        rcu_read_unlock();
        rxrpc_free_skb(skb, rxrpc_skb_freed);
        rxrpc_put_peer(peer);
-
        _leave("");
 }
 
index 250f23b..7e39c26 100644 (file)
@@ -771,46 +771,3 @@ call_complete:
        goto out;
 }
 EXPORT_SYMBOL(rxrpc_kernel_recv_data);
-
-/**
- * rxrpc_kernel_get_reply_time - Get timestamp on first reply packet
- * @sock: The socket that the call exists on
- * @call: The call to query
- * @_ts: Where to put the timestamp
- *
- * Retrieve the timestamp from the first DATA packet of the reply if it is
- * in the ring.  Returns true if successful, false if not.
- */
-bool rxrpc_kernel_get_reply_time(struct socket *sock, struct rxrpc_call *call,
-                                ktime_t *_ts)
-{
-       struct sk_buff *skb;
-       rxrpc_seq_t hard_ack, top, seq;
-       bool success = false;
-
-       mutex_lock(&call->user_mutex);
-
-       if (READ_ONCE(call->state) != RXRPC_CALL_CLIENT_RECV_REPLY)
-               goto out;
-
-       hard_ack = call->rx_hard_ack;
-       if (hard_ack != 0)
-               goto out;
-
-       seq = hard_ack + 1;
-       top = smp_load_acquire(&call->rx_top);
-       if (after(seq, top))
-               goto out;
-
-       skb = call->rxtx_buffer[seq & RXRPC_RXTX_BUFF_MASK];
-       if (!skb)
-               goto out;
-
-       *_ts = skb_get_ktime(skb);
-       success = true;
-
-out:
-       mutex_unlock(&call->user_mutex);
-       return success;
-}
-EXPORT_SYMBOL(rxrpc_kernel_get_reply_time);
index 258917a..78fa052 100644 (file)
@@ -540,7 +540,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,
         * directly into the target buffer.
         */
        sg = _sg;
-       nsg = skb_shinfo(skb)->nr_frags;
+       nsg = skb_shinfo(skb)->nr_frags + 1;
        if (nsg <= 4) {
                nsg = 4;
        } else {
index 1d38e27..3c3a626 100644 (file)
@@ -51,10 +51,7 @@ static int rxrpc_wait_for_tx_window_intr(struct rxrpc_sock *rx,
                        return sock_intr_errno(*timeo);
 
                trace_rxrpc_transmit(call, rxrpc_transmit_wait);
-               mutex_unlock(&call->user_mutex);
                *timeo = schedule_timeout(*timeo);
-               if (mutex_lock_interruptible(&call->user_mutex) < 0)
-                       return sock_intr_errno(*timeo);
        }
 }
 
@@ -290,37 +287,48 @@ out:
 static int rxrpc_send_data(struct rxrpc_sock *rx,
                           struct rxrpc_call *call,
                           struct msghdr *msg, size_t len,
-                          rxrpc_notify_end_tx_t notify_end_tx)
+                          rxrpc_notify_end_tx_t notify_end_tx,
+                          bool *_dropped_lock)
 {
        struct rxrpc_skb_priv *sp;
        struct sk_buff *skb;
        struct sock *sk = &rx->sk;
+       enum rxrpc_call_state state;
        long timeo;
-       bool more;
-       int ret, copied;
+       bool more = msg->msg_flags & MSG_MORE;
+       int ret, copied = 0;
 
        timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
 
        /* this should be in poll */
        sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
 
+reload:
+       ret = -EPIPE;
        if (sk->sk_shutdown & SEND_SHUTDOWN)
-               return -EPIPE;
-
-       more = msg->msg_flags & MSG_MORE;
-
+               goto maybe_error;
+       state = READ_ONCE(call->state);
+       ret = -ESHUTDOWN;
+       if (state >= RXRPC_CALL_COMPLETE)
+               goto maybe_error;
+       ret = -EPROTO;
+       if (state != RXRPC_CALL_CLIENT_SEND_REQUEST &&
+           state != RXRPC_CALL_SERVER_ACK_REQUEST &&
+           state != RXRPC_CALL_SERVER_SEND_REPLY)
+               goto maybe_error;
+
+       ret = -EMSGSIZE;
        if (call->tx_total_len != -1) {
-               if (len > call->tx_total_len)
-                       return -EMSGSIZE;
-               if (!more && len != call->tx_total_len)
-                       return -EMSGSIZE;
+               if (len - copied > call->tx_total_len)
+                       goto maybe_error;
+               if (!more && len - copied != call->tx_total_len)
+                       goto maybe_error;
        }
 
        skb = call->tx_pending;
        call->tx_pending = NULL;
        rxrpc_see_skb(skb, rxrpc_skb_seen);
 
-       copied = 0;
        do {
                /* Check to see if there's a ping ACK to reply to. */
                if (call->ackr_reason == RXRPC_ACK_PING_RESPONSE)
@@ -331,16 +339,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
 
                        _debug("alloc");
 
-                       if (!rxrpc_check_tx_space(call, NULL)) {
-                               ret = -EAGAIN;
-                               if (msg->msg_flags & MSG_DONTWAIT)
-                                       goto maybe_error;
-                               ret = rxrpc_wait_for_tx_window(rx, call,
-                                                              &timeo,
-                                                              msg->msg_flags & MSG_WAITALL);
-                               if (ret < 0)
-                                       goto maybe_error;
-                       }
+                       if (!rxrpc_check_tx_space(call, NULL))
+                               goto wait_for_space;
 
                        /* Work out the maximum size of a packet.  Assume that
                         * the security header is going to be in the padded
@@ -468,6 +468,27 @@ maybe_error:
 efault:
        ret = -EFAULT;
        goto out;
+
+wait_for_space:
+       ret = -EAGAIN;
+       if (msg->msg_flags & MSG_DONTWAIT)
+               goto maybe_error;
+       mutex_unlock(&call->user_mutex);
+       *_dropped_lock = true;
+       ret = rxrpc_wait_for_tx_window(rx, call, &timeo,
+                                      msg->msg_flags & MSG_WAITALL);
+       if (ret < 0)
+               goto maybe_error;
+       if (call->interruptibility == RXRPC_INTERRUPTIBLE) {
+               if (mutex_lock_interruptible(&call->user_mutex) < 0) {
+                       ret = sock_intr_errno(timeo);
+                       goto maybe_error;
+               }
+       } else {
+               mutex_lock(&call->user_mutex);
+       }
+       *_dropped_lock = false;
+       goto reload;
 }
 
 /*
@@ -629,6 +650,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
        enum rxrpc_call_state state;
        struct rxrpc_call *call;
        unsigned long now, j;
+       bool dropped_lock = false;
        int ret;
 
        struct rxrpc_send_params p = {
@@ -737,21 +759,13 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
                        ret = rxrpc_send_abort_packet(call);
        } else if (p.command != RXRPC_CMD_SEND_DATA) {
                ret = -EINVAL;
-       } else if (rxrpc_is_client_call(call) &&
-                  state != RXRPC_CALL_CLIENT_SEND_REQUEST) {
-               /* request phase complete for this client call */
-               ret = -EPROTO;
-       } else if (rxrpc_is_service_call(call) &&
-                  state != RXRPC_CALL_SERVER_ACK_REQUEST &&
-                  state != RXRPC_CALL_SERVER_SEND_REPLY) {
-               /* Reply phase not begun or not complete for service call. */
-               ret = -EPROTO;
        } else {
-               ret = rxrpc_send_data(rx, call, msg, len, NULL);
+               ret = rxrpc_send_data(rx, call, msg, len, NULL, &dropped_lock);
        }
 
 out_put_unlock:
-       mutex_unlock(&call->user_mutex);
+       if (!dropped_lock)
+               mutex_unlock(&call->user_mutex);
 error_put:
        rxrpc_put_call(call, rxrpc_call_put);
        _leave(" = %d", ret);
@@ -779,6 +793,7 @@ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
                           struct msghdr *msg, size_t len,
                           rxrpc_notify_end_tx_t notify_end_tx)
 {
+       bool dropped_lock = false;
        int ret;
 
        _enter("{%d,%s},", call->debug_id, rxrpc_call_states[call->state]);
@@ -796,7 +811,7 @@ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
        case RXRPC_CALL_SERVER_ACK_REQUEST:
        case RXRPC_CALL_SERVER_SEND_REPLY:
                ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len,
-                                     notify_end_tx);
+                                     notify_end_tx, &dropped_lock);
                break;
        case RXRPC_CALL_COMPLETE:
                read_lock_bh(&call->state_lock);
@@ -810,7 +825,8 @@ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
                break;
        }
 
-       mutex_unlock(&call->user_mutex);
+       if (!dropped_lock)
+               mutex_unlock(&call->user_mutex);
        _leave(" = %d", ret);
        return ret;
 }
index d47b968..7a8ea03 100644 (file)
@@ -409,7 +409,7 @@ static inline bool qdisc_restart(struct Qdisc *q, int *packets)
 
 void __qdisc_run(struct Qdisc *q)
 {
-       int quota = dev_tx_weight;
+       int quota = READ_ONCE(dev_tx_weight);
        int packets;
 
        while (qdisc_restart(q, &packets)) {
@@ -1122,6 +1122,21 @@ struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
 }
 EXPORT_SYMBOL(dev_graft_qdisc);
 
+static void shutdown_scheduler_queue(struct net_device *dev,
+                                    struct netdev_queue *dev_queue,
+                                    void *_qdisc_default)
+{
+       struct Qdisc *qdisc = dev_queue->qdisc_sleeping;
+       struct Qdisc *qdisc_default = _qdisc_default;
+
+       if (qdisc) {
+               rcu_assign_pointer(dev_queue->qdisc, qdisc_default);
+               dev_queue->qdisc_sleeping = qdisc_default;
+
+               qdisc_put(qdisc);
+       }
+}
+
 static void attach_one_default_qdisc(struct net_device *dev,
                                     struct netdev_queue *dev_queue,
                                     void *_unused)
@@ -1169,6 +1184,7 @@ static void attach_default_qdiscs(struct net_device *dev)
        if (qdisc == &noop_qdisc) {
                netdev_warn(dev, "default qdisc (%s) fail, fallback to %s\n",
                            default_qdisc_ops->id, noqueue_qdisc_ops.id);
+               netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc);
                dev->priv_flags |= IFF_NO_QUEUE;
                netdev_for_each_tx_queue(dev, attach_one_default_qdisc, NULL);
                qdisc = txq->qdisc_sleeping;
@@ -1447,21 +1463,6 @@ void dev_init_scheduler(struct net_device *dev)
        timer_setup(&dev->watchdog_timer, dev_watchdog, 0);
 }
 
-static void shutdown_scheduler_queue(struct net_device *dev,
-                                    struct netdev_queue *dev_queue,
-                                    void *_qdisc_default)
-{
-       struct Qdisc *qdisc = dev_queue->qdisc_sleeping;
-       struct Qdisc *qdisc_default = _qdisc_default;
-
-       if (qdisc) {
-               rcu_assign_pointer(dev_queue->qdisc, qdisc_default);
-               dev_queue->qdisc_sleeping = qdisc_default;
-
-               qdisc_put(qdisc);
-       }
-}
-
 void dev_shutdown(struct net_device *dev)
 {
        netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc);
index 3d061a1..2829455 100644 (file)
@@ -135,15 +135,15 @@ static void increment_one_qlen(u32 sfbhash, u32 slot, struct sfb_sched_data *q)
        }
 }
 
-static void increment_qlen(const struct sk_buff *skb, struct sfb_sched_data *q)
+static void increment_qlen(const struct sfb_skb_cb *cb, struct sfb_sched_data *q)
 {
        u32 sfbhash;
 
-       sfbhash = sfb_hash(skb, 0);
+       sfbhash = cb->hashes[0];
        if (sfbhash)
                increment_one_qlen(sfbhash, 0, q);
 
-       sfbhash = sfb_hash(skb, 1);
+       sfbhash = cb->hashes[1];
        if (sfbhash)
                increment_one_qlen(sfbhash, 1, q);
 }
@@ -281,8 +281,10 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 {
 
        struct sfb_sched_data *q = qdisc_priv(sch);
+       unsigned int len = qdisc_pkt_len(skb);
        struct Qdisc *child = q->qdisc;
        struct tcf_proto *fl;
+       struct sfb_skb_cb cb;
        int i;
        u32 p_min = ~0;
        u32 minqlen = ~0;
@@ -399,11 +401,12 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,
        }
 
 enqueue:
+       memcpy(&cb, sfb_skb_cb(skb), sizeof(cb));
        ret = qdisc_enqueue(skb, child, to_free);
        if (likely(ret == NET_XMIT_SUCCESS)) {
-               qdisc_qstats_backlog_inc(sch, skb);
+               sch->qstats.backlog += len;
                sch->q.qlen++;
-               increment_qlen(skb, q);
+               increment_qlen(&cb, q);
        } else if (net_xmit_drop_count(ret)) {
                q->stats.childdrop++;
                qdisc_qstats_drop(sch);
index 7210227..36079fd 100644 (file)
@@ -356,6 +356,7 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
        struct nlattr *tb[TCA_TBF_MAX + 1];
        struct tc_tbf_qopt *qopt;
        struct Qdisc *child = NULL;
+       struct Qdisc *old = NULL;
        struct psched_ratecfg rate;
        struct psched_ratecfg peak;
        u64 max_size;
@@ -447,7 +448,7 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
        sch_tree_lock(sch);
        if (child) {
                qdisc_tree_flush_backlog(q->qdisc);
-               qdisc_put(q->qdisc);
+               old = q->qdisc;
                q->qdisc = child;
        }
        q->limit = qopt->limit;
@@ -467,6 +468,7 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
        memcpy(&q->peak, &peak, sizeof(struct psched_ratecfg));
 
        sch_tree_unlock(sch);
+       qdisc_put(old);
        err = 0;
 
        tbf_offload_change(sch);
index 79c1318..0939cc3 100644 (file)
@@ -1855,7 +1855,6 @@ static void smc_listen_out_connected(struct smc_sock *new_smc)
 {
        struct sock *newsmcsk = &new_smc->sk;
 
-       sk_refcnt_debug_inc(newsmcsk);
        if (newsmcsk->sk_state == SMC_INIT)
                newsmcsk->sk_state = SMC_ACTIVE;
 
index ff49a11..ebf56cd 100644 (file)
@@ -757,6 +757,7 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk,
        lnk->lgr = lgr;
        smc_lgr_hold(lgr); /* lgr_put in smcr_link_clear() */
        lnk->link_idx = link_idx;
+       lnk->wr_rx_id_compl = 0;
        smc_ibdev_cnt_inc(lnk);
        smcr_copy_dev_info_to_link(lnk);
        atomic_set(&lnk->conn_cnt, 0);
index fe8b524..285f9bd 100644 (file)
@@ -115,8 +115,10 @@ struct smc_link {
        dma_addr_t              wr_rx_dma_addr; /* DMA address of wr_rx_bufs */
        dma_addr_t              wr_rx_v2_dma_addr; /* DMA address of v2 rx buf*/
        u64                     wr_rx_id;       /* seq # of last recv WR */
+       u64                     wr_rx_id_compl; /* seq # of last completed WR */
        u32                     wr_rx_cnt;      /* number of WR recv buffers */
        unsigned long           wr_rx_tstamp;   /* jiffies when last buf rx */
+       wait_queue_head_t       wr_rx_empty_wait; /* wait for RQ empty */
 
        struct ib_reg_wr        wr_reg;         /* WR register memory region */
        wait_queue_head_t       wr_reg_wait;    /* wait for wr_reg result */
index 26f8f24..b0678a4 100644 (file)
@@ -454,6 +454,7 @@ static inline void smc_wr_rx_process_cqes(struct ib_wc wc[], int num)
 
        for (i = 0; i < num; i++) {
                link = wc[i].qp->qp_context;
+               link->wr_rx_id_compl = wc[i].wr_id;
                if (wc[i].status == IB_WC_SUCCESS) {
                        link->wr_rx_tstamp = jiffies;
                        smc_wr_rx_demultiplex(&wc[i]);
@@ -465,6 +466,8 @@ static inline void smc_wr_rx_process_cqes(struct ib_wc wc[], int num)
                        case IB_WC_RNR_RETRY_EXC_ERR:
                        case IB_WC_WR_FLUSH_ERR:
                                smcr_link_down_cond_sched(link);
+                               if (link->wr_rx_id_compl == link->wr_rx_id)
+                                       wake_up(&link->wr_rx_empty_wait);
                                break;
                        default:
                                smc_wr_rx_post(link); /* refill WR RX */
@@ -639,6 +642,7 @@ void smc_wr_free_link(struct smc_link *lnk)
                return;
        ibdev = lnk->smcibdev->ibdev;
 
+       smc_wr_drain_cq(lnk);
        smc_wr_wakeup_reg_wait(lnk);
        smc_wr_wakeup_tx_wait(lnk);
 
@@ -889,6 +893,7 @@ int smc_wr_create_link(struct smc_link *lnk)
        atomic_set(&lnk->wr_tx_refcnt, 0);
        init_waitqueue_head(&lnk->wr_reg_wait);
        atomic_set(&lnk->wr_reg_refcnt, 0);
+       init_waitqueue_head(&lnk->wr_rx_empty_wait);
        return rc;
 
 dma_unmap:
index a54e90a..45e9b89 100644 (file)
@@ -73,6 +73,11 @@ static inline void smc_wr_tx_link_put(struct smc_link *link)
                wake_up_all(&link->wr_tx_wait);
 }
 
+static inline void smc_wr_drain_cq(struct smc_link *lnk)
+{
+       wait_event(lnk->wr_rx_empty_wait, lnk->wr_rx_id_compl == lnk->wr_rx_id);
+}
+
 static inline void smc_wr_wakeup_tx_wait(struct smc_link *lnk)
 {
        wake_up_all(&lnk->wr_tx_wait);
index 9b27c5e..7378375 100644 (file)
@@ -1801,7 +1801,7 @@ int __sys_listen(int fd, int backlog)
 
        sock = sockfd_lookup_light(fd, &err, &fput_needed);
        if (sock) {
-               somaxconn = sock_net(sock->sk)->core.sysctl_somaxconn;
+               somaxconn = READ_ONCE(sock_net(sock->sk)->core.sysctl_somaxconn);
                if ((unsigned int)backlog > somaxconn)
                        backlog = somaxconn;
 
index b098e70..7d268a2 100644 (file)
@@ -1902,7 +1902,7 @@ call_encode(struct rpc_task *task)
                        break;
                case -EKEYEXPIRED:
                        if (!task->tk_cred_retry) {
-                               rpc_exit(task, task->tk_status);
+                               rpc_call_rpcerror(task, task->tk_status);
                        } else {
                                task->tk_action = call_refresh;
                                task->tk_cred_retry--;
index 2f4d232..9618e44 100644 (file)
@@ -160,7 +160,7 @@ static void map_set(u64 *up_map, int i, unsigned int v)
 
 static int map_get(u64 up_map, int i)
 {
-       return (up_map & (1 << i)) >> i;
+       return (up_map & (1ULL << i)) >> i;
 }
 
 static struct tipc_peer *peer_prev(struct tipc_peer *peer)
index aab4346..0878b16 100644 (file)
@@ -65,9 +65,10 @@ static ssize_t ht40allow_map_read(struct file *file,
 {
        struct wiphy *wiphy = file->private_data;
        char *buf;
-       unsigned int offset = 0, buf_size = PAGE_SIZE, i, r;
+       unsigned int offset = 0, buf_size = PAGE_SIZE, i;
        enum nl80211_band band;
        struct ieee80211_supported_band *sband;
+       ssize_t r;
 
        buf = kzalloc(buf_size, GFP_KERNEL);
        if (!buf)
index 6a5f08f..cca5e1c 100644 (file)
@@ -136,7 +136,7 @@ static int ccmp_init_iv_and_aad(const struct ieee80211_hdr *hdr,
        pos = (u8 *) hdr;
        aad[0] = pos[0] & 0x8f;
        aad[1] = pos[1] & 0xc7;
-       memcpy(aad + 2, hdr->addr1, 3 * ETH_ALEN);
+       memcpy(aad + 2, &hdr->addrs, 3 * ETH_ALEN);
        pos = (u8 *) & hdr->seq_ctrl;
        aad[20] = pos[0] & 0x0f;
        aad[21] = 0;            /* all bits masked */
index f701121..a71a8c6 100644 (file)
@@ -379,6 +379,16 @@ static void xp_check_dma_contiguity(struct xsk_dma_map *dma_map)
 
 static int xp_init_dma_info(struct xsk_buff_pool *pool, struct xsk_dma_map *dma_map)
 {
+       if (!pool->unaligned) {
+               u32 i;
+
+               for (i = 0; i < pool->heads_cnt; i++) {
+                       struct xdp_buff_xsk *xskb = &pool->heads[i];
+
+                       xp_init_xskb_dma(xskb, pool, dma_map->dma_pages, xskb->orig_addr);
+               }
+       }
+
        pool->dma_pages = kvcalloc(dma_map->dma_pages_cnt, sizeof(*pool->dma_pages), GFP_KERNEL);
        if (!pool->dma_pages)
                return -ENOMEM;
@@ -428,12 +438,6 @@ int xp_dma_map(struct xsk_buff_pool *pool, struct device *dev,
 
        if (pool->unaligned)
                xp_check_dma_contiguity(dma_map);
-       else
-               for (i = 0; i < pool->heads_cnt; i++) {
-                       struct xdp_buff_xsk *xskb = &pool->heads[i];
-
-                       xp_init_xskb_dma(xskb, pool, dma_map->dma_pages, xskb->orig_addr);
-               }
 
        err = xp_init_dma_info(pool, dma_map);
        if (err) {
index 82d14ee..974eb97 100644 (file)
@@ -168,7 +168,7 @@ int espintcp_queue_out(struct sock *sk, struct sk_buff *skb)
 {
        struct espintcp_ctx *ctx = espintcp_getctx(sk);
 
-       if (skb_queue_len(&ctx->out_queue) >= netdev_max_backlog)
+       if (skb_queue_len(&ctx->out_queue) >= READ_ONCE(netdev_max_backlog))
                return -ENOBUFS;
 
        __skb_queue_tail(&ctx->out_queue, skb);
index 144238a..b2f4ec9 100644 (file)
@@ -669,7 +669,6 @@ resume:
 
                x->curlft.bytes += skb->len;
                x->curlft.packets++;
-               x->curlft.use_time = ktime_get_real_seconds();
 
                spin_unlock(&x->lock);
 
@@ -783,7 +782,7 @@ int xfrm_trans_queue_net(struct net *net, struct sk_buff *skb,
 
        trans = this_cpu_ptr(&xfrm_trans_tasklet);
 
-       if (skb_queue_len(&trans->queue) >= netdev_max_backlog)
+       if (skb_queue_len(&trans->queue) >= READ_ONCE(netdev_max_backlog))
                return -ENOBUFS;
 
        BUILD_BUG_ON(sizeof(struct xfrm_trans_cb) > sizeof(skb->cb));
index 555ab35..9a5e79a 100644 (file)
@@ -534,7 +534,6 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
 
                x->curlft.bytes += skb->len;
                x->curlft.packets++;
-               x->curlft.use_time = ktime_get_real_seconds();
 
                spin_unlock_bh(&x->lock);
 
index f1a0bab..cc6ab79 100644 (file)
@@ -3162,7 +3162,7 @@ ok:
        return dst;
 
 nopol:
-       if (!(dst_orig->dev->flags & IFF_LOOPBACK) &&
+       if ((!dst_orig->dev || !(dst_orig->dev->flags & IFF_LOOPBACK)) &&
            net->xfrm.policy_default[dir] == XFRM_USERPOLICY_BLOCK) {
                err = -EPERM;
                goto error;
@@ -3599,6 +3599,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
                if (pols[1]) {
                        if (IS_ERR(pols[1])) {
                                XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR);
+                               xfrm_pol_put(pols[0]);
                                return 0;
                        }
                        pols[1]->curlft.use_time = ktime_get_real_seconds();
index 52e60e6..91c32a3 100644 (file)
@@ -1592,6 +1592,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
        x->replay = orig->replay;
        x->preplay = orig->preplay;
        x->mapping_maxage = orig->mapping_maxage;
+       x->lastused = orig->lastused;
        x->new_mapping = 0;
        x->new_mapping_sport = 0;
 
index 0621c39..6ae4821 100644 (file)
@@ -47,7 +47,19 @@ else
 
 ifdef CONFIG_CC_IS_CLANG
 KBUILD_CFLAGS += -Wno-initializer-overrides
+# Clang before clang-16 would warn on default argument promotions.
+ifeq ($(shell [ $(CONFIG_CLANG_VERSION) -lt 160000 ] && echo y),y)
+# Disable -Wformat
 KBUILD_CFLAGS += -Wno-format
+# Then re-enable flags that were part of the -Wformat group that aren't
+# problematic.
+KBUILD_CFLAGS += -Wformat-extra-args -Wformat-invalid-specifier
+KBUILD_CFLAGS += -Wformat-zero-length -Wnonnull
+# Requires clang-12+.
+ifeq ($(shell [ $(CONFIG_CLANG_VERSION) -ge 120000 ] && echo y),y)
+KBUILD_CFLAGS += -Wformat-insufficient-args
+endif
+endif
 KBUILD_CFLAGS += -Wno-sign-compare
 KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
 KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
index ec5a624..a9dbd99 100644 (file)
@@ -150,6 +150,16 @@ retry:
 /* clang-format on */
 
 /*
+ * All access rights that are denied by default whether they are handled or not
+ * by a ruleset/layer.  This must be ORed with all ruleset->fs_access_masks[]
+ * entries when we need to get the absolute handled access masks.
+ */
+/* clang-format off */
+#define ACCESS_INITIALLY_DENIED ( \
+       LANDLOCK_ACCESS_FS_REFER)
+/* clang-format on */
+
+/*
  * @path: Should have been checked by get_path_from_fd().
  */
 int landlock_append_fs_rule(struct landlock_ruleset *const ruleset,
@@ -167,7 +177,9 @@ int landlock_append_fs_rule(struct landlock_ruleset *const ruleset,
                return -EINVAL;
 
        /* Transforms relative access rights to absolute ones. */
-       access_rights |= LANDLOCK_MASK_ACCESS_FS & ~ruleset->fs_access_masks[0];
+       access_rights |=
+               LANDLOCK_MASK_ACCESS_FS &
+               ~(ruleset->fs_access_masks[0] | ACCESS_INITIALLY_DENIED);
        object = get_inode_object(d_backing_inode(path->dentry));
        if (IS_ERR(object))
                return PTR_ERR(object);
@@ -277,23 +289,12 @@ static inline bool is_nouser_or_private(const struct dentry *dentry)
 static inline access_mask_t
 get_handled_accesses(const struct landlock_ruleset *const domain)
 {
-       access_mask_t access_dom = 0;
-       unsigned long access_bit;
-
-       for (access_bit = 0; access_bit < LANDLOCK_NUM_ACCESS_FS;
-            access_bit++) {
-               size_t layer_level;
+       access_mask_t access_dom = ACCESS_INITIALLY_DENIED;
+       size_t layer_level;
 
-               for (layer_level = 0; layer_level < domain->num_layers;
-                    layer_level++) {
-                       if (domain->fs_access_masks[layer_level] &
-                           BIT_ULL(access_bit)) {
-                               access_dom |= BIT_ULL(access_bit);
-                               break;
-                       }
-               }
-       }
-       return access_dom;
+       for (layer_level = 0; layer_level < domain->num_layers; layer_level++)
+               access_dom |= domain->fs_access_masks[layer_level];
+       return access_dom & LANDLOCK_MASK_ACCESS_FS;
 }
 
 static inline access_mask_t
@@ -316,8 +317,13 @@ init_layer_masks(const struct landlock_ruleset *const domain,
 
                for_each_set_bit(access_bit, &access_req,
                                 ARRAY_SIZE(*layer_masks)) {
-                       if (domain->fs_access_masks[layer_level] &
-                           BIT_ULL(access_bit)) {
+                       /*
+                        * Artificially handles all initially denied by default
+                        * access rights.
+                        */
+                       if (BIT_ULL(access_bit) &
+                           (domain->fs_access_masks[layer_level] |
+                            ACCESS_INITIALLY_DENIED)) {
                                (*layer_masks)[access_bit] |=
                                        BIT_ULL(layer_level);
                                handled_accesses |= BIT_ULL(access_bit);
@@ -857,10 +863,6 @@ static int current_check_refer_path(struct dentry *const old_dentry,
                                              NULL, NULL);
        }
 
-       /* Backward compatibility: no reparenting support. */
-       if (!(get_handled_accesses(dom) & LANDLOCK_ACCESS_FS_REFER))
-               return -EXDEV;
-
        access_request_parent1 |= LANDLOCK_ACCESS_FS_REFER;
        access_request_parent2 |= LANDLOCK_ACCESS_FS_REFER;
 
index 14d30fe..4b95de2 100644 (file)
@@ -2660,4 +2660,8 @@ int security_uring_sqpoll(void)
 {
        return call_int_hook(uring_sqpoll, 0);
 }
+int security_uring_cmd(struct io_uring_cmd *ioucmd)
+{
+       return call_int_hook(uring_cmd, 0, ioucmd);
+}
 #endif /* CONFIG_IO_URING */
index 7957350..03bca97 100644 (file)
@@ -91,6 +91,7 @@
 #include <uapi/linux/mount.h>
 #include <linux/fsnotify.h>
 #include <linux/fanotify.h>
+#include <linux/io_uring.h>
 
 #include "avc.h"
 #include "objsec.h"
@@ -6987,6 +6988,28 @@ static int selinux_uring_sqpoll(void)
        return avc_has_perm(&selinux_state, sid, sid,
                            SECCLASS_IO_URING, IO_URING__SQPOLL, NULL);
 }
+
+/**
+ * selinux_uring_cmd - check if IORING_OP_URING_CMD is allowed
+ * @ioucmd: the io_uring command structure
+ *
+ * Check to see if the current domain is allowed to execute an
+ * IORING_OP_URING_CMD against the device/file specified in @ioucmd.
+ *
+ */
+static int selinux_uring_cmd(struct io_uring_cmd *ioucmd)
+{
+       struct file *file = ioucmd->file;
+       struct inode *inode = file_inode(file);
+       struct inode_security_struct *isec = selinux_inode(inode);
+       struct common_audit_data ad;
+
+       ad.type = LSM_AUDIT_DATA_FILE;
+       ad.u.file = file;
+
+       return avc_has_perm(&selinux_state, current_sid(), isec->sid,
+                           SECCLASS_IO_URING, IO_URING__CMD, &ad);
+}
 #endif /* CONFIG_IO_URING */
 
 /*
@@ -7231,6 +7254,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
 #ifdef CONFIG_IO_URING
        LSM_HOOK_INIT(uring_override_creds, selinux_uring_override_creds),
        LSM_HOOK_INIT(uring_sqpoll, selinux_uring_sqpoll),
+       LSM_HOOK_INIT(uring_cmd, selinux_uring_cmd),
 #endif
 
        /*
index ff757ae..1c2f41f 100644 (file)
@@ -253,7 +253,7 @@ const struct security_class_mapping secclass_map[] = {
        { "anon_inode",
          { COMMON_FILE_PERMS, NULL } },
        { "io_uring",
-         { "override_creds", "sqpoll", NULL } },
+         { "override_creds", "sqpoll", "cmd", NULL } },
        { NULL }
   };
 
index 0018314..bffccdc 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/fs_context.h>
 #include <linux/fs_parser.h>
 #include <linux/watch_queue.h>
+#include <linux/io_uring.h>
 #include "smack.h"
 
 #define TRANS_TRUE     "TRUE"
@@ -4732,6 +4733,36 @@ static int smack_uring_sqpoll(void)
        return -EPERM;
 }
 
+/**
+ * smack_uring_cmd - check on file operations for io_uring
+ * @ioucmd: the command in question
+ *
+ * Make a best guess about whether a io_uring "command" should
+ * be allowed. Use the same logic used for determining if the
+ * file could be opened for read in the absence of better criteria.
+ */
+static int smack_uring_cmd(struct io_uring_cmd *ioucmd)
+{
+       struct file *file = ioucmd->file;
+       struct smk_audit_info ad;
+       struct task_smack *tsp;
+       struct inode *inode;
+       int rc;
+
+       if (!file)
+               return -EINVAL;
+
+       tsp = smack_cred(file->f_cred);
+       inode = file_inode(file);
+
+       smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
+       smk_ad_setfield_u_fs_path(&ad, file->f_path);
+       rc = smk_tskacc(tsp, smk_of_inode(inode), MAY_READ, &ad);
+       rc = smk_bu_credfile(file->f_cred, file, MAY_READ, rc);
+
+       return rc;
+}
+
 #endif /* CONFIG_IO_URING */
 
 struct lsm_blob_sizes smack_blob_sizes __lsm_ro_after_init = {
@@ -4889,6 +4920,7 @@ static struct security_hook_list smack_hooks[] __lsm_ro_after_init = {
 #ifdef CONFIG_IO_URING
        LSM_HOOK_INIT(uring_override_creds, smack_uring_override_creds),
        LSM_HOOK_INIT(uring_sqpoll, smack_uring_sqpoll),
+       LSM_HOOK_INIT(uring_cmd, smack_uring_cmd),
 #endif
 };
 
index 3bb1343..316917b 100644 (file)
@@ -75,9 +75,11 @@ struct kvm_regs {
 
 /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
 #define KVM_ARM_DEVICE_TYPE_SHIFT      0
-#define KVM_ARM_DEVICE_TYPE_MASK       (0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
+#define KVM_ARM_DEVICE_TYPE_MASK       GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \
+                                               KVM_ARM_DEVICE_TYPE_SHIFT)
 #define KVM_ARM_DEVICE_ID_SHIFT                16
-#define KVM_ARM_DEVICE_ID_MASK         (0xffff << KVM_ARM_DEVICE_ID_SHIFT)
+#define KVM_ARM_DEVICE_ID_MASK         GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
+                                               KVM_ARM_DEVICE_ID_SHIFT)
 
 /* Supported device IDs */
 #define KVM_ARM_DEVICE_VGIC_V2         0
index 24ae305..1bdd834 100644 (file)
@@ -36,4 +36,8 @@
 #include <linux/compiler-gcc.h>
 #endif
 
+#ifndef asm_volatile_goto
+#define asm_volatile_goto(x...) asm goto(x)
+#endif
+
 #endif /* __LINUX_COMPILER_TYPES_H */
index e6c98a6..6b1bafe 100644 (file)
@@ -486,6 +486,7 @@ mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
                        if (ops->idx)
                                ops->idx(evlist, evsel, mp, idx);
 
+                       pr_debug("idx %d: mmapping fd %d\n", idx, *output);
                        if (ops->mmap(map, mp, *output, evlist_cpu) < 0)
                                return -1;
 
@@ -494,6 +495,7 @@ mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
                        if (!idx)
                                perf_evlist__set_mmap_first(evlist, map, overwrite);
                } else {
+                       pr_debug("idx %d: set output fd %d -> %d\n", idx, fd, *output);
                        if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
                                return -1;
 
@@ -520,6 +522,48 @@ mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
 }
 
 static int
+mmap_per_thread(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
+               struct perf_mmap_param *mp)
+{
+       int nr_threads = perf_thread_map__nr(evlist->threads);
+       int nr_cpus    = perf_cpu_map__nr(evlist->all_cpus);
+       int cpu, thread, idx = 0;
+       int nr_mmaps = 0;
+
+       pr_debug("%s: nr cpu values (may include -1) %d nr threads %d\n",
+                __func__, nr_cpus, nr_threads);
+
+       /* per-thread mmaps */
+       for (thread = 0; thread < nr_threads; thread++, idx++) {
+               int output = -1;
+               int output_overwrite = -1;
+
+               if (mmap_per_evsel(evlist, ops, idx, mp, 0, thread, &output,
+                                  &output_overwrite, &nr_mmaps))
+                       goto out_unmap;
+       }
+
+       /* system-wide mmaps i.e. per-cpu */
+       for (cpu = 1; cpu < nr_cpus; cpu++, idx++) {
+               int output = -1;
+               int output_overwrite = -1;
+
+               if (mmap_per_evsel(evlist, ops, idx, mp, cpu, 0, &output,
+                                  &output_overwrite, &nr_mmaps))
+                       goto out_unmap;
+       }
+
+       if (nr_mmaps != evlist->nr_mmaps)
+               pr_err("Miscounted nr_mmaps %d vs %d\n", nr_mmaps, evlist->nr_mmaps);
+
+       return 0;
+
+out_unmap:
+       perf_evlist__munmap(evlist);
+       return -1;
+}
+
+static int
 mmap_per_cpu(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
             struct perf_mmap_param *mp)
 {
@@ -528,6 +572,8 @@ mmap_per_cpu(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
        int nr_mmaps = 0;
        int cpu, thread;
 
+       pr_debug("%s: nr cpu values %d nr threads %d\n", __func__, nr_cpus, nr_threads);
+
        for (cpu = 0; cpu < nr_cpus; cpu++) {
                int output = -1;
                int output_overwrite = -1;
@@ -569,6 +615,7 @@ int perf_evlist__mmap_ops(struct perf_evlist *evlist,
                          struct perf_evlist_mmap_ops *ops,
                          struct perf_mmap_param *mp)
 {
+       const struct perf_cpu_map *cpus = evlist->all_cpus;
        struct perf_evsel *evsel;
 
        if (!ops || !ops->get || !ops->mmap)
@@ -588,6 +635,9 @@ int perf_evlist__mmap_ops(struct perf_evlist *evlist,
        if (evlist->pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0)
                return -ENOMEM;
 
+       if (perf_cpu_map__empty(cpus))
+               return mmap_per_thread(evlist, ops, mp);
+
        return mmap_per_cpu(evlist, ops, mp);
 }
 
index 9167825..e55fdf9 100644 (file)
@@ -162,32 +162,34 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
 
        /*
         * Unfortunately these have to be hard coded because the noreturn
-        * attribute isn't provided in ELF data.
+        * attribute isn't provided in ELF data. Keep 'em sorted.
         */
        static const char * const global_noreturns[] = {
+               "__invalid_creds",
+               "__module_put_and_kthread_exit",
+               "__reiserfs_panic",
                "__stack_chk_fail",
-               "panic",
+               "__ubsan_handle_builtin_unreachable",
+               "cpu_bringup_and_idle",
+               "cpu_startup_entry",
                "do_exit",
+               "do_group_exit",
                "do_task_dead",
-               "kthread_exit",
-               "make_task_dead",
-               "__module_put_and_kthread_exit",
+               "ex_handler_msr_mce",
+               "fortify_panic",
                "kthread_complete_and_exit",
-               "__reiserfs_panic",
+               "kthread_exit",
+               "kunit_try_catch_throw",
                "lbug_with_loc",
-               "fortify_panic",
-               "usercopy_abort",
                "machine_real_restart",
+               "make_task_dead",
+               "panic",
                "rewind_stack_and_make_dead",
-               "kunit_try_catch_throw",
-               "xen_start_kernel",
-               "cpu_bringup_and_idle",
-               "do_group_exit",
+               "sev_es_terminate",
+               "snp_abort",
                "stop_this_cpu",
-               "__invalid_creds",
-               "cpu_startup_entry",
-               "__ubsan_handle_builtin_unreachable",
-               "ex_handler_msr_mce",
+               "usercopy_abort",
+               "xen_start_kernel",
        };
 
        if (!func)
index c930209..e7a776a 100644 (file)
@@ -21,11 +21,6 @@ cat /sys/devices/cpu_atom/cpus
 
 It indicates cpu0-cpu15 are core cpus and cpu16-cpu23 are atom cpus.
 
-Quickstart
-
-List hybrid event
------------------
-
 As before, use perf-list to list the symbolic event.
 
 perf list
@@ -40,7 +35,6 @@ the event is belong to. Same event name but with different pmu can
 be supported.
 
 Enable hybrid event with a specific pmu
----------------------------------------
 
 To enable a core only event or atom only event, following syntax is supported:
 
@@ -53,7 +47,6 @@ For example, count the 'cycles' event on core cpus.
        perf stat -e cpu_core/cycles/
 
 Create two events for one hardware event automatically
-------------------------------------------------------
 
 When creating one event and the event is available on both atom and core,
 two events are created automatically. One is for atom, the other is for
@@ -132,7 +125,6 @@ For perf-stat result, it displays two events:
 The first 'cycles' is core event, the second 'cycles' is atom event.
 
 Thread mode example:
---------------------
 
 perf-stat reports the scaled counts for hybrid event and with a percentage
 displayed. The percentage is the event's running time/enabling time.
@@ -176,14 +168,12 @@ perf_event_attr:
        604,097,080      cpu_atom/cycles/                                              (99.57%)
 
 perf-record:
-------------
 
 If there is no '-e' specified in perf record, on hybrid platform,
 it creates two default 'cycles' and adds them to event list. One
 is for core, the other is for atom.
 
 perf-stat:
-----------
 
 If there is no '-e' specified in perf stat, on hybrid platform,
 besides of software events, following events are created and
index 099817e..0228efc 100644 (file)
@@ -397,6 +397,9 @@ following filters are defined:
        - abort_tx: only when the target is a hardware transaction abort
        - cond: conditional branches
        - save_type: save branch type during sampling in case binary is not available later
+                    For the platforms with Intel Arch LBR support (12th-Gen+ client or
+                    4th-Gen Xeon+ server), the save branch type is unconditionally enabled
+                    when the taken branch stack sampling is enabled.
 
 +
 The option requires at least one branch type among any, any_call, any_ret, ind_call, cond.
@@ -757,8 +760,6 @@ events in data directory files. Option specified with no or empty value
 defaults to CPU layout. Masks defined or provided by the option value are
 filtered through the mask provided by -C option.
 
-include::intel-hybrid.txt[]
-
 --debuginfod[=URLs]::
        Specify debuginfod URL to be used when cacheing perf.data binaries,
        it follows the same syntax as the DEBUGINFOD_URLS variable, like:
@@ -778,6 +779,8 @@ include::intel-hybrid.txt[]
        only, as of now.  So the applications built without the frame
        pointer might see bogus addresses.
 
+include::intel-hybrid.txt[]
+
 SEE ALSO
 --------
 linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-intel-pt[1]
index 0661a1c..2171f02 100644 (file)
@@ -265,7 +265,7 @@ endif
 # defined. get-executable-or-default fails with an error if the first argument is supplied but
 # doesn't exist.
 override PYTHON_CONFIG := $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO))
-override PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_AUTO)))
+override PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_CONFIG)))
 
 grep-libs  = $(filter -l%,$(1))
 strip-libs  = $(filter-out -l%,$(1))
index e5921b3..bd94788 100644 (file)
@@ -954,11 +954,11 @@ ifndef NO_LIBBPF
        $(call QUIET_INSTALL, bpf-headers) \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'; \
-               $(INSTALL) include/bpf/*.h -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
-               $(INSTALL) include/bpf/linux/*.h -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'
+               $(INSTALL) include/bpf/*.h -m 644 -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
+               $(INSTALL) include/bpf/linux/*.h -m 644 -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'
        $(call QUIET_INSTALL, bpf-examples) \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'; \
-               $(INSTALL) examples/bpf/*.c -t '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
+               $(INSTALL) examples/bpf/*.c -m 644 -t '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
 endif
        $(call QUIET_INSTALL, perf-archive) \
                $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
@@ -967,13 +967,13 @@ endif
 ifndef NO_LIBAUDIT
        $(call QUIET_INSTALL, strace/groups) \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'; \
-               $(INSTALL) trace/strace/groups/* -t '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'
+               $(INSTALL) trace/strace/groups/* -m 644 -t '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'
 endif
 ifndef NO_LIBPERL
        $(call QUIET_INSTALL, perl-scripts) \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
-               $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
-               $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
+               $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
+               $(INSTALL) scripts/perl/*.pl -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
                $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
 endif
@@ -990,23 +990,23 @@ endif
                $(INSTALL) $(DLFILTERS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/dlfilters';
        $(call QUIET_INSTALL, perf_completion-script) \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
-               $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
+               $(INSTALL) perf-completion.sh -m 644 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
        $(call QUIET_INSTALL, perf-tip) \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
-               $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
+               $(INSTALL) Documentation/tips.txt -m 644 -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
 
 install-tests: all install-gtk
        $(call QUIET_INSTALL, tests) \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
-               $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
+               $(INSTALL) tests/attr.py -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
                $(INSTALL) tests/pe-file.exe* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
-               $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
+               $(INSTALL) tests/attr/* -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
                $(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
                $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
-               $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
-               $(INSTALL) tests/shell/lib/*.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
+               $(INSTALL) tests/shell/lib/*.sh -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
+               $(INSTALL) tests/shell/lib/*.py -m 644 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
 
 install-bin: install-tools install-tests install-traceevent-plugins
 
index 653e13b..438fc22 100644 (file)
@@ -146,15 +146,15 @@ static void *c2c_he_zalloc(size_t size)
 
        c2c_he->cpuset = bitmap_zalloc(c2c.cpus_cnt);
        if (!c2c_he->cpuset)
-               return NULL;
+               goto out_free;
 
        c2c_he->nodeset = bitmap_zalloc(c2c.nodes_cnt);
        if (!c2c_he->nodeset)
-               return NULL;
+               goto out_free;
 
        c2c_he->node_stats = zalloc(c2c.nodes_cnt * sizeof(*c2c_he->node_stats));
        if (!c2c_he->node_stats)
-               return NULL;
+               goto out_free;
 
        init_stats(&c2c_he->cstats.lcl_hitm);
        init_stats(&c2c_he->cstats.rmt_hitm);
@@ -163,6 +163,12 @@ static void *c2c_he_zalloc(size_t size)
        init_stats(&c2c_he->cstats.load);
 
        return &c2c_he->he;
+
+out_free:
+       free(c2c_he->nodeset);
+       free(c2c_he->cpuset);
+       free(c2c_he);
+       return NULL;
 }
 
 static void c2c_he_free(void *he)
index dd11d34..ea40ae5 100644 (file)
@@ -1874,8 +1874,7 @@ int cmd_lock(int argc, const char **argv)
                NULL
        };
        const char *const lock_subcommands[] = { "record", "report", "script",
-                                                "info", "contention",
-                                                "contention", NULL };
+                                                "info", "contention", NULL };
        const char *lock_usage[] = {
                NULL,
                NULL
index 4713f0f..f87ef43 100644 (file)
@@ -1906,14 +1906,18 @@ static int record__synthesize(struct record *rec, bool tail)
 
        err = perf_event__synthesize_bpf_events(session, process_synthesized_event,
                                                machine, opts);
-       if (err < 0)
+       if (err < 0) {
                pr_warning("Couldn't synthesize bpf events.\n");
+               err = 0;
+       }
 
        if (rec->opts.synth & PERF_SYNTH_CGROUP) {
                err = perf_event__synthesize_cgroups(tool, process_synthesized_event,
                                                     machine);
-               if (err < 0)
+               if (err < 0) {
                        pr_warning("Couldn't synthesize cgroup events.\n");
+                       err = 0;
+               }
        }
 
        if (rec->opts.nr_threads_synthesize > 1) {
@@ -3358,16 +3362,22 @@ static struct option __record_options[] = {
 
 struct option *record_options = __record_options;
 
-static void record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_cpu_map *cpus)
+static int record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_cpu_map *cpus)
 {
        struct perf_cpu cpu;
        int idx;
 
        if (cpu_map__is_dummy(cpus))
-               return;
+               return 0;
 
-       perf_cpu_map__for_each_cpu(cpu, idx, cpus)
+       perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
+               /* Return ENODEV is input cpu is greater than max cpu */
+               if ((unsigned long)cpu.cpu > mask->nbits)
+                       return -ENODEV;
                set_bit(cpu.cpu, mask->bits);
+       }
+
+       return 0;
 }
 
 static int record__mmap_cpu_mask_init_spec(struct mmap_cpu_mask *mask, const char *mask_spec)
@@ -3379,7 +3389,9 @@ static int record__mmap_cpu_mask_init_spec(struct mmap_cpu_mask *mask, const cha
                return -ENOMEM;
 
        bitmap_zero(mask->bits, mask->nbits);
-       record__mmap_cpu_mask_init(mask, cpus);
+       if (record__mmap_cpu_mask_init(mask, cpus))
+               return -ENODEV;
+
        perf_cpu_map__put(cpus);
 
        return 0;
@@ -3461,7 +3473,12 @@ static int record__init_thread_masks_spec(struct record *rec, struct perf_cpu_ma
                pr_err("Failed to allocate CPUs mask\n");
                return ret;
        }
-       record__mmap_cpu_mask_init(&cpus_mask, cpus);
+
+       ret = record__mmap_cpu_mask_init(&cpus_mask, cpus);
+       if (ret) {
+               pr_err("Failed to init cpu mask\n");
+               goto out_free_cpu_mask;
+       }
 
        ret = record__thread_mask_alloc(&full_mask, cpu__max_cpu().cpu);
        if (ret) {
@@ -3702,7 +3719,8 @@ static int record__init_thread_default_masks(struct record *rec, struct perf_cpu
        if (ret)
                return ret;
 
-       record__mmap_cpu_mask_init(&rec->thread_masks->maps, cpus);
+       if (record__mmap_cpu_mask_init(&rec->thread_masks->maps, cpus))
+               return -ENODEV;
 
        rec->nr_threads = 1;
 
index 2f6cd1b..a5cf243 100644 (file)
@@ -3355,7 +3355,8 @@ static bool schedstat_events_exposed(void)
 static int __cmd_record(int argc, const char **argv)
 {
        unsigned int rec_argc, i, j;
-       const char **rec_argv;
+       char **rec_argv;
+       const char **rec_argv_copy;
        const char * const record_args[] = {
                "record",
                "-a",
@@ -3384,6 +3385,7 @@ static int __cmd_record(int argc, const char **argv)
                ARRAY_SIZE(schedstat_args) : 0;
 
        struct tep_event *waking_event;
+       int ret;
 
        /*
         * +2 for either "-e", "sched:sched_wakeup" or
@@ -3391,14 +3393,18 @@ static int __cmd_record(int argc, const char **argv)
         */
        rec_argc = ARRAY_SIZE(record_args) + 2 + schedstat_argc + argc - 1;
        rec_argv = calloc(rec_argc + 1, sizeof(char *));
-
        if (rec_argv == NULL)
                return -ENOMEM;
+       rec_argv_copy = calloc(rec_argc + 1, sizeof(char *));
+       if (rec_argv_copy == NULL) {
+               free(rec_argv);
+               return -ENOMEM;
+       }
 
        for (i = 0; i < ARRAY_SIZE(record_args); i++)
                rec_argv[i] = strdup(record_args[i]);
 
-       rec_argv[i++] = "-e";
+       rec_argv[i++] = strdup("-e");
        waking_event = trace_event__tp_format("sched", "sched_waking");
        if (!IS_ERR(waking_event))
                rec_argv[i++] = strdup("sched:sched_waking");
@@ -3409,11 +3415,19 @@ static int __cmd_record(int argc, const char **argv)
                rec_argv[i++] = strdup(schedstat_args[j]);
 
        for (j = 1; j < (unsigned int)argc; j++, i++)
-               rec_argv[i] = argv[j];
+               rec_argv[i] = strdup(argv[j]);
 
        BUG_ON(i != rec_argc);
 
-       return cmd_record(i, rec_argv);
+       memcpy(rec_argv_copy, rec_argv, sizeof(char *) * rec_argc);
+       ret = cmd_record(rec_argc, rec_argv_copy);
+
+       for (i = 0; i < rec_argc; i++)
+               free(rec_argv[i]);
+       free(rec_argv);
+       free(rec_argv_copy);
+
+       return ret;
 }
 
 int cmd_sched(int argc, const char **argv)
index 13580a9..029b433 100644 (file)
@@ -445,6 +445,9 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
        struct perf_event_attr *attr = &evsel->core.attr;
        bool allow_user_set;
 
+       if (evsel__is_dummy_event(evsel))
+               return 0;
+
        if (perf_header__has_feat(&session->header, HEADER_STAT))
                return 0;
 
@@ -566,6 +569,8 @@ static struct evsel *find_first_output_type(struct evlist *evlist,
        struct evsel *evsel;
 
        evlist__for_each_entry(evlist, evsel) {
+               if (evsel__is_dummy_event(evsel))
+                       continue;
                if (output_type(evsel->core.attr.type) == (int)type)
                        return evsel;
        }
index 7fb81a4..0b4a62e 100644 (file)
@@ -826,6 +826,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
        }
 
        evlist__for_each_entry(evsel_list, counter) {
+               counter->reset_group = false;
                if (bpf_counter__load(counter, &target))
                        return -1;
                if (!evsel__is_bpf(counter))
@@ -1931,6 +1932,9 @@ setup_metrics:
                free(str);
        }
 
+       if (!stat_config.topdown_level)
+               stat_config.topdown_level = TOPDOWN_MAX_LEVEL;
+
        if (!evsel_list->core.nr_entries) {
                if (target__has_cpu(&target))
                        default_attrs0[0].config = PERF_COUNT_SW_CPU_CLOCK;
@@ -1947,8 +1951,6 @@ setup_metrics:
                }
                if (evlist__add_default_attrs(evsel_list, default_attrs1) < 0)
                        return -1;
-
-               stat_config.topdown_level = TOPDOWN_MAX_LEVEL;
                /* Platform specific attrs */
                if (evlist__add_default_attrs(evsel_list, default_null_attrs) < 0)
                        return -1;
index 9eccc97..6d47298 100644 (file)
@@ -98,9 +98,9 @@ int filter_event_early(void *data, const struct perf_dlfilter_sample *sample, vo
 static void print_vals(__u64 cycles, __u64 delta)
 {
        if (delta)
-               printf("%10llu %10llu ", cycles, delta);
+               printf("%10llu %10llu ", (unsigned long long)cycles, (unsigned long long)delta);
        else
-               printf("%10llu %10s ", cycles, "");
+               printf("%10llu %10s ", (unsigned long long)cycles, "");
 }
 
 int filter_event(void *data, const struct perf_dlfilter_sample *sample, void *ctx)
index 9313ef2..26a51b4 100755 (executable)
@@ -28,6 +28,24 @@ test_stat_record_report() {
   echo "stat record and report test [Success]"
 }
 
+test_stat_repeat_weak_groups() {
+  echo "stat repeat weak groups test"
+  if ! perf stat -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}' \
+     true 2>&1 | grep -q 'seconds time elapsed'
+  then
+    echo "stat repeat weak groups test [Skipped event parsing failed]"
+    return
+  fi
+  if ! perf stat -r2 -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}:W' \
+    true > /dev/null 2>&1
+  then
+    echo "stat repeat weak groups test [Failed]"
+    err=1
+    return
+  fi
+  echo "stat repeat weak groups test [Success]"
+}
+
 test_topdown_groups() {
   # Topdown events must be grouped with the slots event first. Test that
   # parse-events reorders this.
@@ -75,6 +93,7 @@ test_topdown_weak_groups() {
 
 test_default_stat
 test_stat_record_report
+test_stat_repeat_weak_groups
 test_topdown_groups
 test_topdown_weak_groups
 exit $err
index 4d216c0..4ee96b3 100644 (file)
@@ -49,8 +49,14 @@ void affinity__set(struct affinity *a, int cpu)
 {
        int cpu_set_size = get_cpu_set_size();
 
-       if (cpu == -1)
+       /*
+        * Return:
+        * - if cpu is -1
+        * - restrict out of bound access to sched_cpus
+        */
+       if (cpu == -1 || ((cpu >= (cpu_set_size * 8))))
                return;
+
        a->changed = true;
        set_bit(cpu, a->sched_cpus);
        /*
index 953338b..ed28a0d 100644 (file)
 
 #define BUILD_ID_URANDOM /* different uuid for each run */
 
-// FIXME, remove this and fix the deprecation warnings before its removed and
-// We'll break for good here...
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
 #ifdef HAVE_LIBCRYPTO_SUPPORT
 
 #define BUILD_ID_MD5
@@ -45,6 +41,7 @@
 #endif
 
 #ifdef BUILD_ID_MD5
+#include <openssl/evp.h>
 #include <openssl/md5.h>
 #endif
 #endif
@@ -142,15 +139,20 @@ gen_build_id(struct buildid_note *note,
 static void
 gen_build_id(struct buildid_note *note, unsigned long load_addr, const void *code, size_t csize)
 {
-       MD5_CTX context;
+       EVP_MD_CTX *mdctx;
 
        if (sizeof(note->build_id) < 16)
                errx(1, "build_id too small for MD5");
 
-       MD5_Init(&context);
-       MD5_Update(&context, &load_addr, sizeof(load_addr));
-       MD5_Update(&context, code, csize);
-       MD5_Final((unsigned char *)note->build_id, &context);
+       mdctx = EVP_MD_CTX_new();
+       if (!mdctx)
+               errx(2, "failed to create EVP_MD_CTX");
+
+       EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
+       EVP_DigestUpdate(mdctx, &load_addr, sizeof(load_addr));
+       EVP_DigestUpdate(mdctx, code, csize);
+       EVP_DigestFinal_ex(mdctx, (unsigned char *)note->build_id, NULL);
+       EVP_MD_CTX_free(mdctx);
 }
 #endif
 
index 464475f..c93bcaf 100644 (file)
@@ -1655,6 +1655,9 @@ int metricgroup__parse_groups(const struct option *opt,
        struct evlist *perf_evlist = *(struct evlist **)opt->value;
        const struct pmu_events_table *table = pmu_events_table__find();
 
+       if (!table)
+               return -EINVAL;
+
        return parse_groups(perf_evlist, str, metric_no_group,
                            metric_no_merge, NULL, metric_events, table);
 }
index 979c8cb..788ce5e 100644 (file)
@@ -1193,7 +1193,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
                                                  &rsd);
                if (retiring > 0.7)
                        color = PERF_COLOR_GREEN;
-               print_metric(config, ctxp, color, "%8.1f%%", "retiring",
+               print_metric(config, ctxp, color, "%8.1f%%", "Retiring",
                                retiring * 100.);
        } else if (perf_stat_evsel__is(evsel, TOPDOWN_FE_BOUND) &&
                   full_td(cpu_map_idx, st, &rsd)) {
@@ -1202,7 +1202,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
                                                  &rsd);
                if (fe_bound > 0.2)
                        color = PERF_COLOR_RED;
-               print_metric(config, ctxp, color, "%8.1f%%", "frontend bound",
+               print_metric(config, ctxp, color, "%8.1f%%", "Frontend Bound",
                                fe_bound * 100.);
        } else if (perf_stat_evsel__is(evsel, TOPDOWN_BE_BOUND) &&
                   full_td(cpu_map_idx, st, &rsd)) {
@@ -1211,7 +1211,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
                                                  &rsd);
                if (be_bound > 0.2)
                        color = PERF_COLOR_RED;
-               print_metric(config, ctxp, color, "%8.1f%%", "backend bound",
+               print_metric(config, ctxp, color, "%8.1f%%", "Backend Bound",
                                be_bound * 100.);
        } else if (perf_stat_evsel__is(evsel, TOPDOWN_BAD_SPEC) &&
                   full_td(cpu_map_idx, st, &rsd)) {
@@ -1220,7 +1220,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
                                                  &rsd);
                if (bad_spec > 0.1)
                        color = PERF_COLOR_RED;
-               print_metric(config, ctxp, color, "%8.1f%%", "bad speculation",
+               print_metric(config, ctxp, color, "%8.1f%%", "Bad Speculation",
                                bad_spec * 100.);
        } else if (perf_stat_evsel__is(evsel, TOPDOWN_HEAVY_OPS) &&
                        full_td(cpu_map_idx, st, &rsd) && (config->topdown_level > 1)) {
@@ -1234,13 +1234,13 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
 
                if (retiring > 0.7 && heavy_ops > 0.1)
                        color = PERF_COLOR_GREEN;
-               print_metric(config, ctxp, color, "%8.1f%%", "heavy operations",
+               print_metric(config, ctxp, color, "%8.1f%%", "Heavy Operations",
                                heavy_ops * 100.);
                if (retiring > 0.7 && light_ops > 0.6)
                        color = PERF_COLOR_GREEN;
                else
                        color = NULL;
-               print_metric(config, ctxp, color, "%8.1f%%", "light operations",
+               print_metric(config, ctxp, color, "%8.1f%%", "Light Operations",
                                light_ops * 100.);
        } else if (perf_stat_evsel__is(evsel, TOPDOWN_BR_MISPREDICT) &&
                        full_td(cpu_map_idx, st, &rsd) && (config->topdown_level > 1)) {
@@ -1254,13 +1254,13 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
 
                if (bad_spec > 0.1 && br_mis > 0.05)
                        color = PERF_COLOR_RED;
-               print_metric(config, ctxp, color, "%8.1f%%", "branch mispredict",
+               print_metric(config, ctxp, color, "%8.1f%%", "Branch Mispredict",
                                br_mis * 100.);
                if (bad_spec > 0.1 && m_clears > 0.05)
                        color = PERF_COLOR_RED;
                else
                        color = NULL;
-               print_metric(config, ctxp, color, "%8.1f%%", "machine clears",
+               print_metric(config, ctxp, color, "%8.1f%%", "Machine Clears",
                                m_clears * 100.);
        } else if (perf_stat_evsel__is(evsel, TOPDOWN_FETCH_LAT) &&
                        full_td(cpu_map_idx, st, &rsd) && (config->topdown_level > 1)) {
@@ -1274,13 +1274,13 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
 
                if (fe_bound > 0.2 && fetch_lat > 0.15)
                        color = PERF_COLOR_RED;
-               print_metric(config, ctxp, color, "%8.1f%%", "fetch latency",
+               print_metric(config, ctxp, color, "%8.1f%%", "Fetch Latency",
                                fetch_lat * 100.);
                if (fe_bound > 0.2 && fetch_bw > 0.1)
                        color = PERF_COLOR_RED;
                else
                        color = NULL;
-               print_metric(config, ctxp, color, "%8.1f%%", "fetch bandwidth",
+               print_metric(config, ctxp, color, "%8.1f%%", "Fetch Bandwidth",
                                fetch_bw * 100.);
        } else if (perf_stat_evsel__is(evsel, TOPDOWN_MEM_BOUND) &&
                        full_td(cpu_map_idx, st, &rsd) && (config->topdown_level > 1)) {
@@ -1294,13 +1294,13 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
 
                if (be_bound > 0.2 && mem_bound > 0.2)
                        color = PERF_COLOR_RED;
-               print_metric(config, ctxp, color, "%8.1f%%", "memory bound",
+               print_metric(config, ctxp, color, "%8.1f%%", "Memory Bound",
                                mem_bound * 100.);
                if (be_bound > 0.2 && core_bound > 0.1)
                        color = PERF_COLOR_RED;
                else
                        color = NULL;
-               print_metric(config, ctxp, color, "%8.1f%%", "Core bound",
+               print_metric(config, ctxp, color, "%8.1f%%", "Core Bound",
                                core_bound * 100.);
        } else if (evsel->metric_expr) {
                generic_metric(config, evsel->metric_expr, evsel->metric_events, NULL,
index 10b34bb..c2064a3 100644 (file)
@@ -12,6 +12,7 @@ TARGETS += cpu-hotplug
 TARGETS += damon
 TARGETS += drivers/dma-buf
 TARGETS += drivers/s390x/uvdevice
+TARGETS += drivers/net/bonding
 TARGETS += efivarfs
 TARGETS += exec
 TARGETS += filesystems
index e33cab3..db98106 100644 (file)
@@ -65,3 +65,4 @@ send_signal                              # intermittently fails to receive signa
 select_reuseport                         # intermittently fails on new s390x setup
 xdp_synproxy                             # JIT does not support calling kernel function                                (kfunc)
 unpriv_bpf_disabled                      # fentry
+lru_bug                                  # prog 'printk': failed to auto-attach: -524
index 9e75442..6c03a7d 100644 (file)
        .result = VERBOSE_ACCEPT,
        .retval = -1,
 },
+{
+       "precise: mark_chain_precision for ARG_CONST_ALLOC_SIZE_OR_ZERO",
+       .insns = {
+       BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_1, offsetof(struct xdp_md, ingress_ifindex)),
+       BPF_LD_MAP_FD(BPF_REG_6, 0),
+       BPF_MOV64_REG(BPF_REG_1, BPF_REG_6),
+       BPF_MOV64_IMM(BPF_REG_2, 1),
+       BPF_MOV64_IMM(BPF_REG_3, 0),
+       BPF_JMP_IMM(BPF_JEQ, BPF_REG_4, 0, 1),
+       BPF_MOV64_IMM(BPF_REG_2, 0x1000),
+       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_ringbuf_reserve),
+       BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
+       BPF_EXIT_INSN(),
+       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
+       BPF_LDX_MEM(BPF_DW, BPF_REG_2, BPF_REG_0, 42),
+       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_ringbuf_submit),
+       BPF_MOV64_IMM(BPF_REG_0, 0),
+       BPF_EXIT_INSN(),
+       },
+       .fixup_map_ringbuf = { 1 },
+       .prog_type = BPF_PROG_TYPE_XDP,
+       .flags = BPF_F_TEST_STATE_FREQ,
+       .errstr = "invalid access to memory, mem_size=1 off=42 size=8",
+       .result = REJECT,
+},
diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile
new file mode 100644 (file)
index 0000000..ab6c54b
--- /dev/null
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for net selftests
+
+TEST_PROGS := bond-break-lacpdu-tx.sh
+
+include ../../../lib.mk
diff --git a/tools/testing/selftests/drivers/net/bonding/bond-break-lacpdu-tx.sh b/tools/testing/selftests/drivers/net/bonding/bond-break-lacpdu-tx.sh
new file mode 100755 (executable)
index 0000000..47ab905
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+# Regression Test:
+#   Verify LACPDUs get transmitted after setting the MAC address of
+#   the bond.
+#
+# https://bugzilla.redhat.com/show_bug.cgi?id=2020773
+#
+#       +---------+
+#       | fab-br0 |
+#       +---------+
+#            |
+#       +---------+
+#       |  fbond  |
+#       +---------+
+#        |       |
+#    +------+ +------+
+#    |veth1 | |veth2 |
+#    +------+ +------+
+#
+# We use veths instead of physical interfaces
+
+set -e
+tmp=$(mktemp -q dump.XXXXXX)
+cleanup() {
+       ip link del fab-br0 >/dev/null 2>&1 || :
+       ip link del fbond  >/dev/null 2>&1 || :
+       ip link del veth1-bond  >/dev/null 2>&1 || :
+       ip link del veth2-bond  >/dev/null 2>&1 || :
+       modprobe -r bonding  >/dev/null 2>&1 || :
+       rm -f -- ${tmp}
+}
+
+trap cleanup 0 1 2
+cleanup
+sleep 1
+
+# create the bridge
+ip link add fab-br0 address 52:54:00:3B:7C:A6 mtu 1500 type bridge \
+       forward_delay 15
+
+# create the bond
+ip link add fbond type bond mode 4 miimon 200 xmit_hash_policy 1 \
+       ad_actor_sys_prio 65535 lacp_rate fast
+
+# set bond address
+ip link set fbond address 52:54:00:3B:7C:A6
+ip link set fbond up
+
+# set again bond sysfs parameters
+ip link set fbond type bond ad_actor_sys_prio 65535
+
+# create veths
+ip link add name veth1-bond type veth peer name veth1-end
+ip link add name veth2-bond type veth peer name veth2-end
+
+# add ports
+ip link set fbond master fab-br0
+ip link set veth1-bond down master fbond
+ip link set veth2-bond down master fbond
+
+# bring up
+ip link set veth1-end up
+ip link set veth2-end up
+ip link set fab-br0 up
+ip link set fbond up
+ip addr add dev fab-br0 10.0.0.3
+
+tcpdump -n -i veth1-end -e ether proto 0x8809 >${tmp} 2>&1 &
+sleep 15
+pkill tcpdump >/dev/null 2>&1
+rc=0
+num=$(grep "packets captured" ${tmp} | awk '{print $1}')
+if test "$num" -gt 0; then
+       echo "PASS, captured ${num}"
+else
+       echo "FAIL"
+       rc=1
+fi
+exit $rc
diff --git a/tools/testing/selftests/drivers/net/bonding/config b/tools/testing/selftests/drivers/net/bonding/config
new file mode 100644 (file)
index 0000000..dc1c22d
--- /dev/null
@@ -0,0 +1 @@
+CONFIG_BONDING=y
diff --git a/tools/testing/selftests/drivers/net/bonding/settings b/tools/testing/selftests/drivers/net/bonding/settings
new file mode 100644 (file)
index 0000000..867e118
--- /dev/null
@@ -0,0 +1 @@
+timeout=60
index 45edf45..0cbc71b 100644 (file)
@@ -754,7 +754,7 @@ void vm_install_exception_handler(struct kvm_vm *vm, int vector,
                        void (*handler)(struct ex_regs *));
 
 /* If a toddler were to say "abracadabra". */
-#define KVM_EXCEPTION_MAGIC 0xabacadabaull
+#define KVM_EXCEPTION_MAGIC 0xabacadabaULL
 
 /*
  * KVM selftest exception fixup uses registers to coordinate with the exception
@@ -786,7 +786,7 @@ void vm_install_exception_handler(struct kvm_vm *vm, int vector,
        "lea 1f(%%rip), %%r10\n\t"                              \
        "lea 2f(%%rip), %%r11\n\t"                              \
        "1: " insn "\n\t"                                       \
-       "mov $0, %[vector]\n\t"                                 \
+       "movb $0, %[vector]\n\t"                                \
        "jmp 3f\n\t"                                            \
        "2:\n\t"                                                \
        "mov  %%r9b, %[vector]\n\t"                             \
index 21a2ce8..45de42a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
  * Copyright © 2020 ANSSI
- * Copyright © 2020-2021 Microsoft Corporation
+ * Copyright © 2020-2022 Microsoft Corporation
  */
 
 #define _GNU_SOURCE
@@ -371,6 +371,13 @@ TEST_F_FORK(layout1, inval)
        ASSERT_EQ(EINVAL, errno);
        path_beneath.allowed_access &= ~LANDLOCK_ACCESS_FS_EXECUTE;
 
+       /* Tests with denied-by-default access right. */
+       path_beneath.allowed_access |= LANDLOCK_ACCESS_FS_REFER;
+       ASSERT_EQ(-1, landlock_add_rule(ruleset_fd, LANDLOCK_RULE_PATH_BENEATH,
+                                       &path_beneath, 0));
+       ASSERT_EQ(EINVAL, errno);
+       path_beneath.allowed_access &= ~LANDLOCK_ACCESS_FS_REFER;
+
        /* Test with unknown (64-bits) value. */
        path_beneath.allowed_access |= (1ULL << 60);
        ASSERT_EQ(-1, landlock_add_rule(ruleset_fd, LANDLOCK_RULE_PATH_BENEATH,
@@ -1826,6 +1833,20 @@ TEST_F_FORK(layout1, link)
        ASSERT_EQ(0, link(file1_s1d3, file2_s1d3));
 }
 
+static int test_rename(const char *const oldpath, const char *const newpath)
+{
+       if (rename(oldpath, newpath))
+               return errno;
+       return 0;
+}
+
+static int test_exchange(const char *const oldpath, const char *const newpath)
+{
+       if (renameat2(AT_FDCWD, oldpath, AT_FDCWD, newpath, RENAME_EXCHANGE))
+               return errno;
+       return 0;
+}
+
 TEST_F_FORK(layout1, rename_file)
 {
        const struct rule rules[] = {
@@ -1867,10 +1888,10 @@ TEST_F_FORK(layout1, rename_file)
         * to a different directory (which allows file removal).
         */
        ASSERT_EQ(-1, rename(file1_s2d1, file1_s1d3));
-       ASSERT_EQ(EXDEV, errno);
+       ASSERT_EQ(EACCES, errno);
        ASSERT_EQ(-1, renameat2(AT_FDCWD, file1_s2d1, AT_FDCWD, file1_s1d3,
                                RENAME_EXCHANGE));
-       ASSERT_EQ(EXDEV, errno);
+       ASSERT_EQ(EACCES, errno);
        ASSERT_EQ(-1, renameat2(AT_FDCWD, dir_s2d2, AT_FDCWD, file1_s1d3,
                                RENAME_EXCHANGE));
        ASSERT_EQ(EXDEV, errno);
@@ -1894,7 +1915,7 @@ TEST_F_FORK(layout1, rename_file)
        ASSERT_EQ(EXDEV, errno);
        ASSERT_EQ(0, unlink(file1_s1d3));
        ASSERT_EQ(-1, rename(file1_s2d1, file1_s1d3));
-       ASSERT_EQ(EXDEV, errno);
+       ASSERT_EQ(EACCES, errno);
 
        /* Exchanges and renames files with same parent. */
        ASSERT_EQ(0, renameat2(AT_FDCWD, file2_s2d3, AT_FDCWD, file1_s2d3,
@@ -2014,6 +2035,115 @@ TEST_F_FORK(layout1, reparent_refer)
        ASSERT_EQ(0, rename(dir_s1d3, dir_s2d3));
 }
 
+/* Checks renames beneath dir_s1d1. */
+static void refer_denied_by_default(struct __test_metadata *const _metadata,
+                                   const struct rule layer1[],
+                                   const int layer1_err,
+                                   const struct rule layer2[])
+{
+       int ruleset_fd;
+
+       ASSERT_EQ(0, unlink(file1_s1d2));
+
+       ruleset_fd = create_ruleset(_metadata, layer1[0].access, layer1);
+       ASSERT_LE(0, ruleset_fd);
+       enforce_ruleset(_metadata, ruleset_fd);
+       ASSERT_EQ(0, close(ruleset_fd));
+
+       /*
+        * If the first layer handles LANDLOCK_ACCESS_FS_REFER (according to
+        * layer1_err), then it allows some different-parent renames and links.
+        */
+       ASSERT_EQ(layer1_err, test_rename(file1_s1d1, file1_s1d2));
+       if (layer1_err == 0)
+               ASSERT_EQ(layer1_err, test_rename(file1_s1d2, file1_s1d1));
+       ASSERT_EQ(layer1_err, test_exchange(file2_s1d1, file2_s1d2));
+       ASSERT_EQ(layer1_err, test_exchange(file2_s1d2, file2_s1d1));
+
+       ruleset_fd = create_ruleset(_metadata, layer2[0].access, layer2);
+       ASSERT_LE(0, ruleset_fd);
+       enforce_ruleset(_metadata, ruleset_fd);
+       ASSERT_EQ(0, close(ruleset_fd));
+
+       /*
+        * Now, either the first or the second layer does not handle
+        * LANDLOCK_ACCESS_FS_REFER, which means that any different-parent
+        * renames and links are denied, thus making the layer handling
+        * LANDLOCK_ACCESS_FS_REFER null and void.
+        */
+       ASSERT_EQ(EXDEV, test_rename(file1_s1d1, file1_s1d2));
+       ASSERT_EQ(EXDEV, test_exchange(file2_s1d1, file2_s1d2));
+       ASSERT_EQ(EXDEV, test_exchange(file2_s1d2, file2_s1d1));
+}
+
+const struct rule layer_dir_s1d1_refer[] = {
+       {
+               .path = dir_s1d1,
+               .access = LANDLOCK_ACCESS_FS_REFER,
+       },
+       {},
+};
+
+const struct rule layer_dir_s1d1_execute[] = {
+       {
+               /* Matches a parent directory. */
+               .path = dir_s1d1,
+               .access = LANDLOCK_ACCESS_FS_EXECUTE,
+       },
+       {},
+};
+
+const struct rule layer_dir_s2d1_execute[] = {
+       {
+               /* Does not match a parent directory. */
+               .path = dir_s2d1,
+               .access = LANDLOCK_ACCESS_FS_EXECUTE,
+       },
+       {},
+};
+
+/*
+ * Tests precedence over renames: denied by default for different parent
+ * directories, *with* a rule matching a parent directory, but not directly
+ * denying access (with MAKE_REG nor REMOVE).
+ */
+TEST_F_FORK(layout1, refer_denied_by_default1)
+{
+       refer_denied_by_default(_metadata, layer_dir_s1d1_refer, 0,
+                               layer_dir_s1d1_execute);
+}
+
+/*
+ * Same test but this time turning around the ABI version order: the first
+ * layer does not handle LANDLOCK_ACCESS_FS_REFER.
+ */
+TEST_F_FORK(layout1, refer_denied_by_default2)
+{
+       refer_denied_by_default(_metadata, layer_dir_s1d1_execute, EXDEV,
+                               layer_dir_s1d1_refer);
+}
+
+/*
+ * Tests precedence over renames: denied by default for different parent
+ * directories, *without* a rule matching a parent directory, but not directly
+ * denying access (with MAKE_REG nor REMOVE).
+ */
+TEST_F_FORK(layout1, refer_denied_by_default3)
+{
+       refer_denied_by_default(_metadata, layer_dir_s1d1_refer, 0,
+                               layer_dir_s2d1_execute);
+}
+
+/*
+ * Same test but this time turning around the ABI version order: the first
+ * layer does not handle LANDLOCK_ACCESS_FS_REFER.
+ */
+TEST_F_FORK(layout1, refer_denied_by_default4)
+{
+       refer_denied_by_default(_metadata, layer_dir_s2d1_execute, EXDEV,
+                               layer_dir_s1d1_refer);
+}
+
 TEST_F_FORK(layout1, reparent_link)
 {
        const struct rule layer1[] = {
@@ -2336,11 +2466,12 @@ TEST_F_FORK(layout1, reparent_exdev_layers_rename1)
        ASSERT_EQ(EXDEV, errno);
 
        /*
-        * However, moving the file2_s1d3 file below dir_s2d3 is allowed
-        * because it cannot inherit MAKE_REG nor MAKE_DIR rights (which are
-        * dedicated to directories).
+        * Moving the file2_s1d3 file below dir_s2d3 is denied because the
+        * second layer does not handle REFER, which is always denied by
+        * default.
         */
-       ASSERT_EQ(0, rename(file2_s1d3, file1_s2d3));
+       ASSERT_EQ(-1, rename(file2_s1d3, file1_s2d3));
+       ASSERT_EQ(EXDEV, errno);
 }
 
 TEST_F_FORK(layout1, reparent_exdev_layers_rename2)
@@ -2373,8 +2504,12 @@ TEST_F_FORK(layout1, reparent_exdev_layers_rename2)
        ASSERT_EQ(EACCES, errno);
        ASSERT_EQ(-1, rename(file1_s1d1, file1_s2d3));
        ASSERT_EQ(EXDEV, errno);
-       /* Modify layout! */
-       ASSERT_EQ(0, rename(file2_s1d2, file1_s2d3));
+       /*
+        * Modifying the layout is now denied because the second layer does not
+        * handle REFER, which is always denied by default.
+        */
+       ASSERT_EQ(-1, rename(file2_s1d2, file1_s2d3));
+       ASSERT_EQ(EXDEV, errno);
 
        /* Without REFER source, EACCES wins over EXDEV. */
        ASSERT_EQ(-1, rename(dir_s1d1, file1_s2d2));
index 947fc72..d44c72b 100644 (file)
@@ -40,6 +40,7 @@ ifeq (0,$(MAKELEVEL))
     endif
 endif
 selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
+top_srcdir = $(selfdir)/../../..
 
 # The following are built by lib.mk common compile rules.
 # TEST_CUSTOM_PROGS should be used by tests that require
index 0e5751a..de7d5cc 100644 (file)
@@ -1,42 +1,42 @@
 # SPDX-License-Identifier: GPL-2.0-only
+cmsg_sender
+fin_ack_lat
+gro
+hwtstamp_config
+ioam6_parser
+ip_defrag
 ipsec
+ipv6_flowlabel
+ipv6_flowlabel_mgr
 msg_zerocopy
-socket
+nettest
 psock_fanout
 psock_snd
 psock_tpacket
-stress_reuseport_listen
+reuseaddr_conflict
+reuseaddr_ports_exhausted
 reuseport_addr_any
 reuseport_bpf
 reuseport_bpf_cpu
 reuseport_bpf_numa
 reuseport_dualstack
-reuseaddr_conflict
-tcp_mmap
-udpgso
-udpgso_bench_rx
-udpgso_bench_tx
-tcp_inq
-tls
-txring_overwrite
-ip_defrag
-ipv6_flowlabel
-ipv6_flowlabel_mgr
-so_txtime
-tcp_fastopen_backup_key
-nettest
-fin_ack_lat
-reuseaddr_ports_exhausted
-hwtstamp_config
 rxtimestamp
-timestamping
-txtimestamp
+socket
 so_netns_cookie
+so_txtime
+stress_reuseport_listen
+tap
+tcp_fastopen_backup_key
+tcp_inq
+tcp_mmap
 test_unix_oob
-gro
-ioam6_parser
+timestamping
+tls
 toeplitz
 tun
-cmsg_sender
+txring_overwrite
+txtimestamp
+udpgso
+udpgso_bench_rx
+udpgso_bench_tx
 unix_connect
-tap
\ No newline at end of file
index 9d64c56..8ce48ac 100644 (file)
@@ -47,7 +47,6 @@ enum {
        MODE_MIXED      = 3,
 };
 
-static bool cfg_flush          = false;
 static bool cfg_cork           = false;
 static int  cfg_mode           = MODE_ZC_FIXED;
 static int  cfg_nr_reqs                = 8;
@@ -166,21 +165,6 @@ static int io_uring_register_buffers(struct io_uring *ring,
        return (ret < 0) ? -errno : ret;
 }
 
-static int io_uring_register_notifications(struct io_uring *ring,
-                                          unsigned nr,
-                                          struct io_uring_notification_slot *slots)
-{
-       int ret;
-       struct io_uring_notification_register r = {
-               .nr_slots = nr,
-               .data = (unsigned long)slots,
-       };
-
-       ret = syscall(__NR_io_uring_register, ring->ring_fd,
-                     IORING_REGISTER_NOTIFIERS, &r, sizeof(r));
-       return (ret < 0) ? -errno : ret;
-}
-
 static int io_uring_mmap(int fd, struct io_uring_params *p,
                         struct io_uring_sq *sq, struct io_uring_cq *cq)
 {
@@ -297,11 +281,10 @@ static inline void io_uring_prep_send(struct io_uring_sqe *sqe, int sockfd,
 
 static inline void io_uring_prep_sendzc(struct io_uring_sqe *sqe, int sockfd,
                                        const void *buf, size_t len, int flags,
-                                       unsigned slot_idx, unsigned zc_flags)
+                                       unsigned zc_flags)
 {
        io_uring_prep_send(sqe, sockfd, buf, len, flags);
-       sqe->opcode = (__u8) IORING_OP_SENDZC_NOTIF;
-       sqe->notification_idx = slot_idx;
+       sqe->opcode = (__u8) IORING_OP_SEND_ZC;
        sqe->ioprio = zc_flags;
 }
 
@@ -374,7 +357,6 @@ static int do_setup_tx(int domain, int type, int protocol)
 
 static void do_tx(int domain, int type, int protocol)
 {
-       struct io_uring_notification_slot b[1] = {{.tag = NOTIF_TAG}};
        struct io_uring_sqe *sqe;
        struct io_uring_cqe *cqe;
        unsigned long packets = 0, bytes = 0;
@@ -390,10 +372,6 @@ static void do_tx(int domain, int type, int protocol)
        if (ret)
                error(1, ret, "io_uring: queue init");
 
-       ret = io_uring_register_notifications(&ring, 1, b);
-       if (ret)
-               error(1, ret, "io_uring: tx ctx registration");
-
        iov.iov_base = payload;
        iov.iov_len = cfg_payload_len;
 
@@ -409,9 +387,8 @@ static void do_tx(int domain, int type, int protocol)
                for (i = 0; i < cfg_nr_reqs; i++) {
                        unsigned zc_flags = 0;
                        unsigned buf_idx = 0;
-                       unsigned slot_idx = 0;
                        unsigned mode = cfg_mode;
-                       unsigned msg_flags = 0;
+                       unsigned msg_flags = MSG_WAITALL;
 
                        if (cfg_mode == MODE_MIXED)
                                mode = rand() % 3;
@@ -423,13 +400,10 @@ static void do_tx(int domain, int type, int protocol)
                                                   cfg_payload_len, msg_flags);
                                sqe->user_data = NONZC_TAG;
                        } else {
-                               if (cfg_flush) {
-                                       zc_flags |= IORING_RECVSEND_NOTIF_FLUSH;
-                                       compl_cqes++;
-                               }
+                               compl_cqes++;
                                io_uring_prep_sendzc(sqe, fd, payload,
                                                     cfg_payload_len,
-                                                    msg_flags, slot_idx, zc_flags);
+                                                    msg_flags, zc_flags);
                                if (mode == MODE_ZC_FIXED) {
                                        sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
                                        sqe->buf_index = buf_idx;
@@ -442,51 +416,57 @@ static void do_tx(int domain, int type, int protocol)
                if (ret != cfg_nr_reqs)
                        error(1, ret, "submit");
 
+               if (cfg_cork)
+                       do_setsockopt(fd, IPPROTO_UDP, UDP_CORK, 0);
                for (i = 0; i < cfg_nr_reqs; i++) {
                        ret = io_uring_wait_cqe(&ring, &cqe);
                        if (ret)
                                error(1, ret, "wait cqe");
 
-                       if (cqe->user_data == NOTIF_TAG) {
+                       if (cqe->user_data != NONZC_TAG &&
+                           cqe->user_data != ZC_TAG)
+                               error(1, -EINVAL, "invalid cqe->user_data");
+
+                       if (cqe->flags & IORING_CQE_F_NOTIF) {
+                               if (cqe->flags & IORING_CQE_F_MORE)
+                                       error(1, -EINVAL, "invalid notif flags");
                                compl_cqes--;
                                i--;
-                       } else if (cqe->user_data != NONZC_TAG &&
-                                  cqe->user_data != ZC_TAG) {
-                               error(1, cqe->res, "invalid user_data");
-                       } else if (cqe->res <= 0 && cqe->res != -EAGAIN) {
+                       } else if (cqe->res <= 0) {
+                               if (cqe->flags & IORING_CQE_F_MORE)
+                                       error(1, cqe->res, "more with a failed send");
                                error(1, cqe->res, "send failed");
                        } else {
-                               if (cqe->res > 0) {
-                                       packets++;
-                                       bytes += cqe->res;
-                               }
-                               /* failed requests don't flush */
-                               if (cfg_flush &&
-                                   cqe->res <= 0 &&
-                                   cqe->user_data == ZC_TAG)
-                                       compl_cqes--;
+                               if (cqe->user_data == ZC_TAG &&
+                                   !(cqe->flags & IORING_CQE_F_MORE))
+                                       error(1, cqe->res, "missing more flag");
+                               packets++;
+                               bytes += cqe->res;
                        }
                        io_uring_cqe_seen(&ring);
                }
-               if (cfg_cork)
-                       do_setsockopt(fd, IPPROTO_UDP, UDP_CORK, 0);
        } while (gettimeofday_ms() < tstop);
 
-       if (close(fd))
-               error(1, errno, "close");
-
-       fprintf(stderr, "tx=%lu (MB=%lu), tx/s=%lu (MB/s=%lu)\n",
-                       packets, bytes >> 20,
-                       packets / (cfg_runtime_ms / 1000),
-                       (bytes >> 20) / (cfg_runtime_ms / 1000));
-
        while (compl_cqes) {
                ret = io_uring_wait_cqe(&ring, &cqe);
                if (ret)
                        error(1, ret, "wait cqe");
+               if (cqe->flags & IORING_CQE_F_MORE)
+                       error(1, -EINVAL, "invalid notif flags");
+               if (!(cqe->flags & IORING_CQE_F_NOTIF))
+                       error(1, -EINVAL, "missing notif flag");
+
                io_uring_cqe_seen(&ring);
                compl_cqes--;
        }
+
+       fprintf(stderr, "tx=%lu (MB=%lu), tx/s=%lu (MB/s=%lu)\n",
+                       packets, bytes >> 20,
+                       packets / (cfg_runtime_ms / 1000),
+                       (bytes >> 20) / (cfg_runtime_ms / 1000));
+
+       if (close(fd))
+               error(1, errno, "close");
 }
 
 static void do_test(int domain, int type, int protocol)
@@ -500,8 +480,8 @@ static void do_test(int domain, int type, int protocol)
 
 static void usage(const char *filepath)
 {
-       error(1, 0, "Usage: %s [-f] [-n<N>] [-z0] [-s<payload size>] "
-                   "(-4|-6) [-t<time s>] -D<dst_ip> udp", filepath);
+       error(1, 0, "Usage: %s (-4|-6) (udp|tcp) -D<dst_ip> [-s<payload size>] "
+                   "[-t<time s>] [-n<batch>] [-p<port>] [-m<mode>]", filepath);
 }
 
 static void parse_opts(int argc, char **argv)
@@ -519,7 +499,7 @@ static void parse_opts(int argc, char **argv)
                usage(argv[0]);
        cfg_payload_len = max_payload_len;
 
-       while ((c = getopt(argc, argv, "46D:p:s:t:n:fc:m:")) != -1) {
+       while ((c = getopt(argc, argv, "46D:p:s:t:n:c:m:")) != -1) {
                switch (c) {
                case '4':
                        if (cfg_family != PF_UNSPEC)
@@ -548,9 +528,6 @@ static void parse_opts(int argc, char **argv)
                case 'n':
                        cfg_nr_reqs = strtoul(optarg, NULL, 0);
                        break;
-               case 'f':
-                       cfg_flush = 1;
-                       break;
                case 'c':
                        cfg_cork = strtol(optarg, NULL, 0);
                        break;
@@ -583,8 +560,6 @@ static void parse_opts(int argc, char **argv)
 
        if (cfg_payload_len > max_payload_len)
                error(1, 0, "-s: payload exceeds max (%d)", max_payload_len);
-       if (cfg_mode == MODE_NONZC && cfg_flush)
-               error(1, 0, "-f: only zerocopy modes support notifications");
        if (optind != argc - 1)
                usage(argv[0]);
 }
index 6a65e44..32aa6e9 100755 (executable)
@@ -25,15 +25,11 @@ readonly path_sysctl_mem="net.core.optmem_max"
 # No arguments: automated test
 if [[ "$#" -eq "0" ]]; then
        IPs=( "4" "6" )
-       protocols=( "tcp" "udp" )
 
        for IP in "${IPs[@]}"; do
-               for proto in "${protocols[@]}"; do
-                       for mode in $(seq 1 3); do
-                               $0 "$IP" "$proto" -m "$mode" -t 1 -n 32
-                               $0 "$IP" "$proto" -m "$mode" -t 1 -n 32 -f
-                               $0 "$IP" "$proto" -m "$mode" -t 1 -n 32 -c -f
-                       done
+               for mode in $(seq 1 3); do
+                       $0 "$IP" udp -m "$mode" -t 1 -n 32
+                       $0 "$IP" tcp -m "$mode" -t 1 -n 32
                done
        done
 
index bf6b962..faa7778 100755 (executable)
@@ -102,26 +102,42 @@ check_for_helper()
 
        ip netns exec ${netns} conntrack -L -f $family -p tcp --dport $port 2> /dev/null |grep -q 'helper=ftp'
        if [ $? -ne 0 ] ; then
-               echo "FAIL: ${netns} did not show attached helper $message" 1>&2
-               ret=1
+               if [ $autoassign -eq 0 ] ;then
+                       echo "FAIL: ${netns} did not show attached helper $message" 1>&2
+                       ret=1
+               else
+                       echo "PASS: ${netns} did not show attached helper $message" 1>&2
+               fi
+       else
+               if [ $autoassign -eq 0 ] ;then
+                       echo "PASS: ${netns} connection on port $port has ftp helper attached" 1>&2
+               else
+                       echo "FAIL: ${netns} connection on port $port has ftp helper attached" 1>&2
+                       ret=1
+               fi
        fi
 
-       echo "PASS: ${netns} connection on port $port has ftp helper attached" 1>&2
        return 0
 }
 
 test_helper()
 {
        local port=$1
-       local msg=$2
+       local autoassign=$2
+
+       if [ $autoassign -eq 0 ] ;then
+               msg="set via ruleset"
+       else
+               msg="auto-assign"
+       fi
 
        sleep 3 | ip netns exec ${ns2} nc -w 2 -l -p $port > /dev/null &
 
        sleep 1 | ip netns exec ${ns1} nc -w 2 10.0.1.2 $port > /dev/null &
        sleep 1
 
-       check_for_helper "$ns1" "ip $msg" $port
-       check_for_helper "$ns2" "ip $msg" $port
+       check_for_helper "$ns1" "ip $msg" $port $autoassign
+       check_for_helper "$ns2" "ip $msg" $port $autoassign
 
        wait
 
@@ -173,9 +189,9 @@ if [ $? -ne 0 ];then
        fi
 fi
 
-test_helper 2121 "set via ruleset"
-ip netns exec ${ns1} sysctl -q 'net.netfilter.nf_conntrack_helper=1'
-ip netns exec ${ns2} sysctl -q 'net.netfilter.nf_conntrack_helper=1'
-test_helper 21 "auto-assign"
+test_helper 2121 0
+ip netns exec ${ns1} sysctl -qe 'net.netfilter.nf_conntrack_helper=1'
+ip netns exec ${ns2} sysctl -qe 'net.netfilter.nf_conntrack_helper=1'
+test_helper 21 1
 
 exit $ret
index 50c5ab1..a07896a 100644 (file)
 #include "defines.h"
 #include "main.h"
 
+/*
+ * FIXME: OpenSSL 3.0 has deprecated some functions. For now just ignore
+ * the warnings.
+ */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 struct q1q2_ctx {
        BN_CTX *bn_ctx;
        BIGNUM *m;