[openchrome-devel] drm-openchrome: Branch 'drm-next-5.16' - 368 commits - arch/arm64/boot arch/arm64/net arch/arm/boot arch/nds32/kernel arch/nios2/platform arch/powerpc/platforms arch/riscv/include arch/riscv/Kconfig arch/riscv/kernel arch/riscv/mm arch/riscv/net arch/s390/kvm arch/x86/crypto arch/x86/include arch/x86/kvm block/blk-mq.c block/blk-settings.c block/genhd.c Documentation/devicetree/bindings Documentation/gpu/todo.rst Documentation/userspace-api/ioctl drivers/base/regmap drivers/clk/clk-composite.c drivers/dma-buf/dma-buf.c drivers/dma-buf/dma-resv.c drivers/gpio/gpio-mlxbf2.c drivers/gpio/gpio-xgs-iproc.c drivers/gpu/drm drivers/infiniband/core drivers/infiniband/hw drivers/infiniband/sw drivers/mmc/host drivers/net/ethernet drivers/net/phy drivers/net/usb drivers/net/vmxnet3 drivers/net/xen-netfront.c drivers/nfc/port100.c drivers/nvdimm/pmem.c drivers/nvme/host drivers/nvme/target drivers/reset/Kconfig drivers/reset/reset-brcmstb-rescal.c drivers/reset/reset-socfpga.c drivers/ reset/tegra drivers/scsi/ibmvscsi drivers/scsi/mpt3sas drivers/scsi/ufs drivers/spi/spi-altera-dfl.c drivers/spi/spi-altera-platform.c drivers/spi/spi-pl022.c drivers/vdpa/vdpa_user drivers/video/fbdev drivers/virtio/virtio_ring.c drivers/watchdog/iTCO_wdt.c drivers/watchdog/ixp4xx_wdt.c drivers/watchdog/omap_wdt.c drivers/watchdog/sbsa_gwdt.c fs/btrfs/compression.c fs/btrfs/inode.c fs/btrfs/lzo.c fs/btrfs/zlib.c fs/btrfs/zstd.c fs/ocfs2/suballoc.c include/drm/drm_modeset_lock.h include/drm/ttm include/linux/bpf.h include/linux/bpf_types.h include/linux/dma-resv.h include/linux/fb.h include/linux/filter.h include/linux/page-flags.h include/linux/skmsg.h include/net/cfg80211.h include/net/mptcp.h include/net/sock.h include/net/tls.h include/net/udp.h kernel/bpf/arraymap.c kernel/bpf/core.c kernel/bpf/syscall.c kernel/cgroup/cgroup.c kernel/trace/ftrace.c kernel/trace/trace_eprobe.c MAINTAINERS Makefile mm/damon/core-test.h mm/huge_memory.c mm/khugepaged.c mm/memory.c mm/memory-failur e.c mm/oom_kill.c mm/page_alloc.c mm/secretmem.c mm/vmalloc.c net/batman-adv/bridge_loop_avoidance.c net/batman-adv/main.c net/batman-adv/network-coding.c net/batman-adv/translation-table.c net/core/dev.c net/core/net-sysfs.c net/core/skbuff.c net/core/skmsg.c net/core/sock_destructor.h net/core/sysctl_net_core.c net/ipv4/tcp_bpf.c net/ipv4/tcp.c net/ipv4/udp_bpf.c net/ipv4/udp.c net/mac80211/mesh.c net/mptcp/options.c net/sctp/sm_statefuns.c net/smc/af_smc.c net/smc/smc_llc.c net/tipc/crypto.c net/tls/tls_main.c net/tls/tls_sw.c net/unix/af_unix.c net/unix/unix_bpf.c net/wireless/core.c net/wireless/core.h net/wireless/mlme.c net/wireless/scan.c net/wireless/util.c tools/perf/arch tools/perf/builtin-script.c tools/perf/Makefile.perf tools/testing/selftests

Kevin Brace kevinbrace at kemper.freedesktop.org
Wed Jan 5 00:35:48 UTC 2022


 Documentation/devicetree/bindings/display/bridge/lvds-codec.yaml       |   33 
 Documentation/devicetree/bindings/display/bridge/ps8640.yaml           |   19 
 Documentation/devicetree/bindings/display/panel/panel-simple.yaml      |    5 
 Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml |   56 +
 Documentation/devicetree/bindings/vendor-prefixes.yaml                 |    2 
 Documentation/gpu/todo.rst                                             |   13 
 Documentation/userspace-api/ioctl/ioctl-number.rst                     |    1 
 MAINTAINERS                                                            |   17 
 Makefile                                                               |    4 
 arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts                        |    2 
 arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts                |    2 
 arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts               |    8 
 arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-som.dtsi            |    8 
 arch/arm64/boot/dts/qcom/sm8250.dtsi                                   |    3 
 arch/arm64/net/bpf_jit_comp.c                                          |    5 
 arch/nds32/kernel/ftrace.c                                             |    2 
 arch/nios2/platform/Kconfig.platform                                   |    1 
 arch/powerpc/platforms/pseries/iommu.c                                 |   27 
 arch/riscv/Kconfig                                                     |    6 
 arch/riscv/include/asm/kasan.h                                         |    3 
 arch/riscv/kernel/head.S                                               |    1 
 arch/riscv/mm/kasan_init.c                                             |   14 
 arch/riscv/net/bpf_jit_core.c                                          |    8 
 arch/s390/kvm/interrupt.c                                              |    5 
 arch/s390/kvm/kvm-s390.c                                               |    1 
 arch/x86/crypto/sm4-aesni-avx-asm_64.S                                 |    6 
 arch/x86/crypto/sm4-aesni-avx2-asm_64.S                                |    6 
 arch/x86/include/asm/kvm_host.h                                        |    2 
 arch/x86/kvm/svm/sev.c                                                 |   15 
 arch/x86/kvm/x86.c                                                     |   36 
 arch/x86/kvm/xen.c                                                     |   27 
 block/blk-mq.c                                                         |   13 
 block/blk-settings.c                                                   |   20 
 block/genhd.c                                                          |   22 
 drivers/base/regmap/regcache-rbtree.c                                  |    7 
 drivers/clk/clk-composite.c                                            |   10 
 drivers/dma-buf/dma-buf.c                                              |   81 -
 drivers/dma-buf/dma-resv.c                                             |   69 +
 drivers/gpio/gpio-mlxbf2.c                                             |    5 
 drivers/gpio/gpio-xgs-iproc.c                                          |    2 
 drivers/gpu/drm/Kconfig                                                |   20 
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h                             |    4 
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c                       |   25 
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c                             |   25 
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c                          |    4 
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c                                |    7 
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c                                |    9 
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c                             |    2 
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c                                |    1 
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c                               |    4 
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c                                 |   10 
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c                                  |    4 
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c                                  |    4 
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c                                  |    8 
 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c                               |    4 
 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c                               |   18 
 drivers/gpu/drm/amd/amdgpu/nv.c                                        |    1 
 drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c                                  |   24 
 drivers/gpu/drm/amd/amdkfd/kfd_device.c                                |    2 
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c                  |    2 
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c                           |    2 
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c                               |   50 
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h                                  |    2 
 drivers/gpu/drm/amd/amdkfd/kfd_process.c                               |    6 
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c                                   |   70 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c                      |   92 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c              |   10 
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c            |  150 ++
 drivers/gpu/drm/amd/display/dc/core/dc.c                               |   14 
 drivers/gpu/drm/amd/display/dc/core/dc_link.c                          |    4 
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c                       |    8 
 drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c                  |   22 
 drivers/gpu/drm/amd/display/dc/dc.h                                    |    3 
 drivers/gpu/drm/amd/display/dc/dc_dp_types.h                           |    3 
 drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h                         |    4 
 drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c            |    6 
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c              |    2 
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c                     |    3 
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c                       |    7 
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c                  |    7 
 drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c                     |   78 -
 drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.h                     |    1 
 drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c                      |    1 
 drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c                  |    6 
 drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c         |   13 
 drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c         |   14 
 drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h                            |    1 
 drivers/gpu/drm/amd/display/dc/inc/hw_sequencer_private.h              |    1 
 drivers/gpu/drm/amd/display/dmub/dmub_srv.h                            |    1 
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h                        |    4 
 drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c                      |    1 
 drivers/gpu/drm/amd/display/include/dal_asic_id.h                      |    2 
 drivers/gpu/drm/amd/pm/amdgpu_pm.c                                     |    4 
 drivers/gpu/drm/amd/pm/inc/smu_v13_0_1_ppsmc.h                         |    4 
 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c                       |   26 
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c                   |    8 
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c                    |   10 
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c                    |    2 
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.h                    |   13 
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c                  |   12 
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c                  |    4 
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c                  |   14 
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c                              |   13 
 drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c                   |   87 -
 drivers/gpu/drm/bridge/lontium-lt9611uxc.c                             |    9 
 drivers/gpu/drm/bridge/lvds-codec.c                                    |   76 +
 drivers/gpu/drm/bridge/nwl-dsi.c                                       |   35 
 drivers/gpu/drm/bridge/ti-sn65dsi83.c                                  |   17 
 drivers/gpu/drm/drm_connector.c                                        |   32 
 drivers/gpu/drm/drm_gem.c                                              |   26 
 drivers/gpu/drm/drm_modeset_lock.c                                     |   49 
 drivers/gpu/drm/drm_panel_orientation_quirks.c                         |   12 
 drivers/gpu/drm/drm_plane_helper.c                                     |    1 
 drivers/gpu/drm/drm_prime.c                                            |    6 
 drivers/gpu/drm/i915/display/g4x_hdmi.c                                |    1 
 drivers/gpu/drm/i915/display/intel_bios.c                              |  132 +-
 drivers/gpu/drm/i915/display/intel_cdclk.c                             |   44 
 drivers/gpu/drm/i915/display/intel_ddi.c                               |    1 
 drivers/gpu/drm/i915/display/intel_display.c                           |    9 
 drivers/gpu/drm/i915/display/intel_dp.c                                |   34 
 drivers/gpu/drm/i915/display/intel_fb.c                                |    4 
 drivers/gpu/drm/i915/display/intel_hdmi.c                              |   16 
 drivers/gpu/drm/i915/display/intel_hdmi.h                              |    1 
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c                             |    7 
 drivers/gpu/drm/i915/gt/intel_ggtt.c                                   |    3 
 drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c                      |    3 
 drivers/gpu/drm/i915/i915_request.c                                    |   34 
 drivers/gpu/drm/i915/i915_trace.h                                      |    7 
 drivers/gpu/drm/imx/imx-drm-core.c                                     |    2 
 drivers/gpu/drm/mxsfb/mxsfb_kms.c                                      |    8 
 drivers/gpu/drm/nouveau/nouveau_bo.c                                   |    4 
 drivers/gpu/drm/nouveau/nouveau_drm.c                                  |   42 
 drivers/gpu/drm/nouveau/nouveau_drv.h                                  |    5 
 drivers/gpu/drm/nouveau/nouveau_gem.c                                  |    4 
 drivers/gpu/drm/nouveau/nouveau_svm.c                                  |    4 
 drivers/gpu/drm/nouveau/nvkm/engine/ce/gt215.c                         |    2 
 drivers/gpu/drm/nouveau/nvkm/engine/device/base.c                      |    3 
 drivers/gpu/drm/nouveau/nvkm/engine/nvenc/base.c                       |    1 
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c                         |    2 
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c                     |    4 
 drivers/gpu/drm/panel/Kconfig                                          |   10 
 drivers/gpu/drm/panel/Makefile                                         |    1 
 drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c                       |    9 
 drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c                      |    3 
 drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c                      |    3 
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.c                          |    4 
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.h                          |    2 
 drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c                        |  333 ++++++
 drivers/gpu/drm/panel/panel-simple.c                                   |   35 
 drivers/gpu/drm/panel/panel-sitronix-st7703.c                          |    8 
 drivers/gpu/drm/radeon/radeon_gem.c                                    |    2 
 drivers/gpu/drm/scheduler/sched_main.c                                 |   26 
 drivers/gpu/drm/selftests/test-drm_damage_helper.c                     |    1 
 drivers/gpu/drm/ttm/ttm_bo.c                                           |   19 
 drivers/gpu/drm/ttm/ttm_bo_util.c                                      |    1 
 drivers/gpu/drm/ttm/ttm_bo_vm.c                                        |   94 -
 drivers/gpu/drm/udl/udl_connector.c                                    |    2 
 drivers/gpu/drm/v3d/v3d_gem.c                                          |   13 
 drivers/gpu/drm/virtio/virtgpu_display.c                               |    4 
 drivers/gpu/drm/virtio/virtgpu_drv.c                                   |    3 
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h                                    |    4 
 drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c                             |   72 -
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c                               |    3 
 drivers/infiniband/core/sa_query.c                                     |    5 
 drivers/infiniband/hw/hfi1/pio.c                                       |    9 
 drivers/infiniband/hw/irdma/uk.c                                       |    4 
 drivers/infiniband/hw/irdma/verbs.c                                    |    8 
 drivers/infiniband/hw/irdma/ws.c                                       |   13 
 drivers/infiniband/hw/mlx5/mr.c                                        |    2 
 drivers/infiniband/hw/mlx5/qp.c                                        |    2 
 drivers/infiniband/hw/qedr/qedr.h                                      |    1 
 drivers/infiniband/hw/qedr/qedr_iw_cm.c                                |    2 
 drivers/infiniband/hw/qedr/verbs.c                                     |    5 
 drivers/infiniband/hw/qib/qib_user_sdma.c                              |   33 
 drivers/infiniband/sw/rdmavt/qp.c                                      |    2 
 drivers/mmc/host/Kconfig                                               |    2 
 drivers/mmc/host/cqhci-core.c                                          |    3 
 drivers/mmc/host/dw_mmc-exynos.c                                       |   14 
 drivers/mmc/host/mtk-sd.c                                              |   38 
 drivers/mmc/host/sdhci-esdhc-imx.c                                     |   16 
 drivers/mmc/host/sdhci-pci-core.c                                      |   29 
 drivers/mmc/host/sdhci.c                                               |    6 
 drivers/mmc/host/tmio_mmc_core.c                                       |   17 
 drivers/mmc/host/vub300.c                                              |   18 
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c                     |   16 
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c             |   30 
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c                |   35 
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h                |    1 
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c              |    5 
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h              |    1 
 drivers/net/ethernet/intel/ice/ice_lag.c                               |   18 
 drivers/net/ethernet/intel/ice/ice_ptp.c                               |    3 
 drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c                |  148 ++
 drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c                    |    3 
 drivers/net/ethernet/mellanox/mlxsw/pci.c                              |   25 
 drivers/net/ethernet/microchip/lan743x_main.c                          |   35 
 drivers/net/ethernet/netronome/nfp/bpf/main.c                          |   16 
 drivers/net/ethernet/netronome/nfp/bpf/main.h                          |    2 
 drivers/net/ethernet/netronome/nfp/bpf/offload.c                       |   17 
 drivers/net/ethernet/nxp/lpc_eth.c                                     |    5 
 drivers/net/ethernet/realtek/r8169_main.c                              |    1 
 drivers/net/phy/phy.c                                                  |  140 +-
 drivers/net/usb/lan78xx.c                                              |    6 
 drivers/net/usb/usbnet.c                                               |    1 
 drivers/net/vmxnet3/vmxnet3_drv.c                                      |    1 
 drivers/net/xen-netfront.c                                             |    8 
 drivers/nfc/port100.c                                                  |    4 
 drivers/nvdimm/pmem.c                                                  |   33 
 drivers/nvme/host/tcp.c                                                |    9 
 drivers/nvme/target/tcp.c                                              |    7 
 drivers/reset/Kconfig                                                  |    4 
 drivers/reset/reset-brcmstb-rescal.c                                   |    2 
 drivers/reset/reset-socfpga.c                                          |   26 
 drivers/reset/tegra/reset-bpmp.c                                       |    9 
 drivers/scsi/ibmvscsi/ibmvfc.c                                         |    3 
 drivers/scsi/mpt3sas/mpt3sas_scsih.c                                   |    9 
 drivers/scsi/ufs/ufs-exynos.c                                          |    6 
 drivers/scsi/ufs/ufshcd.c                                              |    7 
 drivers/scsi/ufs/ufshpb.c                                              |  283 -----
 drivers/scsi/ufs/ufshpb.h                                              |    2 
 drivers/spi/spi-altera-dfl.c                                           |    2 
 drivers/spi/spi-altera-platform.c                                      |    2 
 drivers/spi/spi-pl022.c                                                |    5 
 drivers/vdpa/vdpa_user/vduse_dev.c                                     |   29 
 drivers/video/fbdev/core/bitblit.c                                     |   16 
 drivers/video/fbdev/core/fbcon.c                                       |  509 ----------
 drivers/video/fbdev/core/fbcon.h                                       |   59 -
 drivers/video/fbdev/core/fbcon_ccw.c                                   |   28 
 drivers/video/fbdev/core/fbcon_cw.c                                    |   28 
 drivers/video/fbdev/core/fbcon_rotate.h                                |    9 
 drivers/video/fbdev/core/fbcon_ud.c                                    |   37 
 drivers/video/fbdev/core/fbmem.c                                       |    5 
 drivers/video/fbdev/core/tileblit.c                                    |   16 
 drivers/video/fbdev/skeletonfb.c                                       |   12 
 drivers/virtio/virtio_ring.c                                           |    2 
 drivers/watchdog/iTCO_wdt.c                                            |   12 
 drivers/watchdog/ixp4xx_wdt.c                                          |    2 
 drivers/watchdog/omap_wdt.c                                            |    6 
 drivers/watchdog/sbsa_gwdt.c                                           |    5 
 fs/btrfs/compression.c                                                 |    3 
 fs/btrfs/inode.c                                                       |    3 
 fs/btrfs/lzo.c                                                         |   36 
 fs/btrfs/zlib.c                                                        |   36 
 fs/btrfs/zstd.c                                                        |   27 
 fs/ocfs2/suballoc.c                                                    |   22 
 include/drm/drm_modeset_lock.h                                         |    8 
 include/drm/ttm/ttm_bo_api.h                                           |    9 
 include/linux/bpf.h                                                    |    7 
 include/linux/bpf_types.h                                              |    8 
 include/linux/dma-resv.h                                               |   25 
 include/linux/fb.h                                                     |    2 
 include/linux/filter.h                                                 |    1 
 include/linux/page-flags.h                                             |   23 
 include/linux/skmsg.h                                                  |    1 
 include/net/cfg80211.h                                                 |    2 
 include/net/mptcp.h                                                    |    4 
 include/net/sock.h                                                     |    8 
 include/net/tls.h                                                      |   11 
 include/net/udp.h                                                      |    5 
 kernel/bpf/arraymap.c                                                  |    1 
 kernel/bpf/core.c                                                      |   24 
 kernel/bpf/syscall.c                                                   |   11 
 kernel/cgroup/cgroup.c                                                 |    4 
 kernel/trace/ftrace.c                                                  |   18 
 kernel/trace/trace_eprobe.c                                            |    4 
 mm/damon/core-test.h                                                   |    4 
 mm/huge_memory.c                                                       |    2 
 mm/khugepaged.c                                                        |   26 
 mm/memory-failure.c                                                    |   28 
 mm/memory.c                                                            |    9 
 mm/oom_kill.c                                                          |   23 
 mm/page_alloc.c                                                        |    8 
 mm/secretmem.c                                                         |    2 
 mm/vmalloc.c                                                           |   15 
 net/batman-adv/bridge_loop_avoidance.c                                 |    8 
 net/batman-adv/main.c                                                  |   56 -
 net/batman-adv/network-coding.c                                        |    4 
 net/batman-adv/translation-table.c                                     |    4 
 net/core/dev.c                                                         |    9 
 net/core/net-sysfs.c                                                   |    4 
 net/core/skbuff.c                                                      |   36 
 net/core/skmsg.c                                                       |   14 
 net/core/sock_destructor.h                                             |   12 
 net/core/sysctl_net_core.c                                             |    2 
 net/ipv4/tcp.c                                                         |    5 
 net/ipv4/tcp_bpf.c                                                     |   27 
 net/ipv4/udp.c                                                         |    3 
 net/ipv4/udp_bpf.c                                                     |    1 
 net/mac80211/mesh.c                                                    |    9 
 net/mptcp/options.c                                                    |   39 
 net/sctp/sm_statefuns.c                                                |  139 +-
 net/smc/af_smc.c                                                       |    2 
 net/smc/smc_llc.c                                                      |    2 
 net/tipc/crypto.c                                                      |   32 
 net/tls/tls_main.c                                                     |    4 
 net/tls/tls_sw.c                                                       |   21 
 net/unix/af_unix.c                                                     |    4 
 net/unix/unix_bpf.c                                                    |    2 
 net/wireless/core.c                                                    |    2 
 net/wireless/core.h                                                    |    2 
 net/wireless/mlme.c                                                    |   26 
 net/wireless/scan.c                                                    |    7 
 net/wireless/util.c                                                    |   14 
 tools/perf/Makefile.perf                                               |    2 
 tools/perf/arch/powerpc/util/skip-callchain-idx.c                      |    2 
 tools/perf/builtin-script.c                                            |   14 
 tools/testing/selftests/bpf/prog_tests/sockmap_listen.c                |   75 -
 tools/testing/selftests/net/fcnal-test.sh                              |    3 
 tools/testing/selftests/vm/split_huge_page_test.c                      |    2 
 309 files changed, 3186 insertions(+), 2578 deletions(-)

New commits:
commit 2a2de04da595ac652c68cbb25a4e5904d1a4e222
Merge: 0375fe0475e6 b6c24725249a
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Tue Jan 4 18:32:41 2022 -0600

    Merge tag 'drm-next-2021-11-12' of git://anongit.freedesktop.org/drm/drm into drm-next-5.16
    
    drm next/fixes for 5.16-rc1
    
    bridge:
    - HPD improvments for lt9611uxc
    - eDP aux-bus support for ps8640
    - LVDS data-mapping selection support
    
    ttm:
    - remove huge page functionality (needs reworking)
    - fix a race condition during BO eviction
    
    panels:
    - add some new panels
    
    fbdev:
    - fix double-free
    - remove unused scrolling acceleration
    - CONFIG_FB dep improvements
    
    locking:
    - improve contended locking logging
    - naming collision fix
    
    dma-buf:
    - add dma_resv_for_each_fence iterator
    - fix fence refcounting bug
    - name locking fixesA
    
    prime:
    - fix object references during mmap
    
    nouveau:
    - various code style changes
    - refcount fix
    - device removal fixes
    - protect client list with a mutex
    - fix CE0 address calculation
    
    i915:
    - DP rates related fixes
    - Revert disabling dual eDP that was causing state readout problems
    - put the cdclk vtables in const data
    - Fix DVO port type for older platforms
    - Fix blankscreen by turning DP++ TMDS output buffers on encoder->shutdown
    - CCS FBs related fixes
    - Fix recursive lock in GuC submission
    - Revert guc_id from i915_request tracepoint
    - Build fix around dmabuf
    
    amdgpu:
    - GPU reset fix
    - Aldebaran fix
    - Yellow Carp fixes
    - DCN2.1 DMCUB fix
    - IOMMU regression fix for Picasso
    - DSC display fixes
    - BPC display calculation fixes
    - Other misc display fixes
    - Don't allow partial copy from user for DC debugfs
    - SRIOV fixes
    - GFX9 CSB pin count fix
    - Various IP version check fixes
    - DP 2.0 fixes
    - Limit DCN1 MPO fix to DCN1
    
    amdkfd:
    - SVM fixes
    - Fix gfx version for renoir
    - Reset fixes
    
    udl:
    - timeout fix
    
    imx:
    - circular locking fix
    
    virtio:
    - NULL ptr deref fix

commit b6c24725249a6c1a889665d720cdff088f686f98
Merge: 447212bb4f8e 7120a447c7fe
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Nov 12 13:06:37 2021 +1000

    Merge tag 'drm-misc-fixes-2021-11-11' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
    
     * dma-buf: name_lock fixes
     * prime: Keep object ref during mmap
     * nouveau: Fix a refcount issue; Fix device removal; Protect client
       list with dedicated mutex; Fix address CE0 address calculation
     * ttm: Fix race condition during BO eviction
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    
    From: Thomas Zimmermann <tzimmermann at suse.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/YYzY6jeox9EeI15i@linux-uq9g.fritz.box

diff --cc drivers/dma-buf/dma-buf.c
index 35fe1cb5ad98,92492e314bd9..cc8f09bfa1a3
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@@ -1366,11 -1398,23 +1368,12 @@@ static int dma_buf_debug_show(struct se
  				buf_obj->exp_name,
  				file_inode(buf_obj->file)->i_ino,
  				buf_obj->name ?: "");
+ 		spin_unlock(&buf_obj->name_lock);
  
 -		robj = buf_obj->resv;
 -		fence = dma_resv_excl_fence(robj);
 -		if (fence)
 -			seq_printf(s, "\tExclusive fence: %s %s %ssignalled\n",
 -				   fence->ops->get_driver_name(fence),
 -				   fence->ops->get_timeline_name(fence),
 -				   dma_fence_is_signaled(fence) ? "" : "un");
 -
 -		fobj = rcu_dereference_protected(robj->fence,
 -						 dma_resv_held(robj));
 -		shared_count = fobj ? fobj->shared_count : 0;
 -		for (i = 0; i < shared_count; i++) {
 -			fence = rcu_dereference_protected(fobj->shared[i],
 -							  dma_resv_held(robj));
 -			seq_printf(s, "\tShared fence: %s %s %ssignalled\n",
 +		dma_resv_for_each_fence(&cursor, buf_obj->resv, true, fence) {
 +			seq_printf(s, "\t%s fence: %s %s %ssignalled\n",
 +				   dma_resv_iter_is_exclusive(&cursor) ?
 +					"Exclusive" : "Shared",
  				   fence->ops->get_driver_name(fence),
  				   fence->ops->get_timeline_name(fence),
  				   dma_fence_is_signaled(fence) ? "" : "un");
commit 447212bb4f8ebd7d95dd6e160cd82c69c9a23c4c
Merge: 951bad0bd9de 8bb7eca972ad
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Nov 12 09:22:28 2021 +1000

    BackMerge tag 'v5.15' into drm-next
    
    I got a drm-fixes which had some 5.15 stuff in it, so to avoid
    the mess just backmerge here.
    
    Linux 5.15
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --cc drivers/gpu/drm/drm_panel_orientation_quirks.c
index 62e8ccc7ab9c,e1b2ce4921ae..a9359878f4ed
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@@ -140,20 -134,12 +140,26 @@@ static const struct dmi_system_id orien
  		  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T103HAF"),
  		},
  		.driver_data = (void *)&lcd800x1280_rightside_up,
+ 	}, {	/* AYA NEO 2021 */
+ 		.matches = {
+ 		  DMI_EXACT_MATCH(DMI_SYS_VENDOR, "AYADEVICE"),
+ 		  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "AYA NEO 2021"),
+ 		},
+ 		.driver_data = (void *)&lcd800x1280_rightside_up,
 +	}, {	/* Chuwi HiBook (CWI514) */
 +		.matches = {
 +			DMI_MATCH(DMI_BOARD_VENDOR, "Hampoo"),
 +			DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
 +			/* Above matches are too generic, add bios-date match */
 +			DMI_MATCH(DMI_BIOS_DATE, "05/07/2016"),
 +		},
 +		.driver_data = (void *)&lcd1200x1920_rightside_up,
 +	}, {	/* Chuwi Hi10 Pro (CWI529) */
 +		.matches = {
 +		  DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Hampoo"),
 +		  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Hi10 pro tablet"),
 +		},
 +		.driver_data = (void *)&lcd1200x1920_rightside_up,
  	}, {	/* GPD MicroPC (generic strings, also match on bios date) */
  		.matches = {
  		  DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Default string"),
commit 7120a447c7fe37a123ab7a63afefdbf0787b9002
Author: xinhui pan <xinhui.pan at amd.com>
Date:   Wed Nov 10 12:31:49 2021 +0800

    drm/ttm: Double check mem_type of BO while eviction
    
    BO might sit in a wrong lru list as there is a small period of memory
    moving and lru list updating.
    
    Lets skip eviction if we hit such mismatch.
    
    Suggested-by: Christian König <christian.koenig at amd.com>
    Signed-off-by: xinhui pan <xinhui.pan at amd.com>
    Reviewed-by: Christian König <christian.koenig at amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211110043149.57554-2-xinhui.pan@amd.com
    Signed-off-by: Christian König <christian.koenig at amd.com>

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index bb9e02c31946..1ddf458aed71 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -617,7 +617,8 @@ static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
 			*busy = !ret;
 	}
 
-	if (ret && place && !bo->bdev->funcs->eviction_valuable(bo, place)) {
+	if (ret && place && (bo->resource->mem_type != place->mem_type ||
+		!bo->bdev->funcs->eviction_valuable(bo, place))) {
 		ret = false;
 		if (*locked) {
 			dma_resv_unlock(bo->base.resv);
commit 951bad0bd9de63b4c71bfd69f0dd5824b96a8ee9
Merge: f8ca7b74192b 4d395f938ae3
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Nov 11 10:14:44 2021 +1000

    Merge tag 'amd-drm-fixes-5.16-2021-11-10' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
    
    amd-drm-fixes-5.16-2021-11-10:
    
    amdgpu:
    - Don't allow partial copy from user for DC debugfs
    - SRIOV fixes
    - GFX9 CSB pin count fix
    - Various IP version check fixes
    - DP 2.0 fixes
    - Limit DCN1 MPO fix to DCN1
    
    amdkfd:
    - SVM fixes
    - Reset fixes
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    From: Alex Deucher <alexander.deucher at amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211110222536.7527-1-alexander.deucher@amd.com

commit f8ca7b74192b2e64bdfb89fb63c1d33b92bc899d
Merge: 917a6f0bdbc5 bcae3af286f4
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Nov 11 08:14:02 2021 +1000

    Merge tag 'drm-misc-next-fixes-2021-11-10' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
    
    Removed the TTM Huge Page functionnality to address a crash, a timeout
    fix for udl, CONFIG_FB dependency improvements, a fix for a circular
    locking depency in imx, a NULL pointer dereference fix for virtio, and a
    naming collision fix for drm/locking.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    
    From: Maxime Ripard <maxime at cerno.tech>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211110082114.vfpkpnecwdfg27lk@gilmour

commit 4d395f938ae3515f61d8128a0569bf48ca7e0edf
Author: Guchun Chen <guchun.chen at amd.com>
Date:   Wed Nov 10 13:13:55 2021 +0800

    drm/amdgpu: add missed support for UVD IP_VERSION(3, 0, 64)
    
    Fixes: 96b8dd4423e74d ("drm/amdgpu/amdgpu_vcn: convert to IP version checking")
    Signed-off-by: Flora Cui <flora.cui at amd.com>
    Signed-off-by: Guchun Chen <guchun.chen at amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index a20d21409c95..ff70bc233489 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -882,6 +882,7 @@ static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
 			break;
 		case IP_VERSION(3, 0, 0):
 		case IP_VERSION(3, 0, 16):
+		case IP_VERSION(3, 0, 64):
 		case IP_VERSION(3, 1, 1):
 		case IP_VERSION(3, 0, 2):
 			amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index 2658414c503d..4f7c70845785 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -134,6 +134,7 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
 			adev->vcn.indirect_sram = true;
 		break;
 	case IP_VERSION(3, 0, 0):
+	case IP_VERSION(3, 0, 64):
 		if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 0))
 			fw_name = FIRMWARE_SIENNA_CICHLID;
 		else
diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index febc903adf58..59eafa31c626 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -182,6 +182,7 @@ static int nv_query_video_codecs(struct amdgpu_device *adev, bool encode,
 {
 	switch (adev->ip_versions[UVD_HWIP][0]) {
 	case IP_VERSION(3, 0, 0):
+	case IP_VERSION(3, 0, 64):
 		if (amdgpu_sriov_vf(adev)) {
 			if (encode)
 				*codecs = &sriov_sc_video_codecs_encode;
commit b45a36032dc7e8b4da1a0479978ca6bb03ac632d
Author: Guchun Chen <guchun.chen at amd.com>
Date:   Wed Nov 10 10:07:41 2021 +0800

    drm/amdgpu: drop jpeg IP initialization in SRIOV case
    
    Fixes: b05b9c591f9ed6 ("drm/amdgpu: clean up set IP function")
    Signed-off-by: Guchun Chen <guchun.chen at amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index d7c8d9e3c203..a20d21409c95 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -867,7 +867,8 @@ static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
 		case IP_VERSION(2, 0, 2):
 		case IP_VERSION(2, 2, 0):
 			amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
-			amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
+			if (!amdgpu_sriov_vf(adev))
+				amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
 			break;
 		case IP_VERSION(2, 0, 3):
 			break;
commit 4375d6255d053472005d7003a74dbe6c70517a77
Author: Shirish S <shirish.s at amd.com>
Date:   Mon Nov 8 13:08:26 2021 +0530

    drm/amd/display: reject both non-zero src_x and src_y only for DCN1x
    
    [Why]
    Video plane gets rejected for non-zero src_y and src_x on DCN2.x.
    
    [How]
    Limit the rejection till DCN1.x and verified MPO, by dragging video
    playback beyond display's left (0, 0) co-ordinates.
    
    Fixes: d89f6048bdcb ("drm/amd/display: Reject non-zero src_y and src_x for video planes")
    Signed-off-by: Shirish S <shirish.s at amd.com>
    Reviewed-by: Harry Wentland <harry.wentland at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a7cf7df4d2f2..c911b30de658 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4582,7 +4582,8 @@ static void get_min_max_dc_plane_scaling(struct drm_device *dev,
 }
 
 
-static int fill_dc_scaling_info(const struct drm_plane_state *state,
+static int fill_dc_scaling_info(struct amdgpu_device *adev,
+				const struct drm_plane_state *state,
 				struct dc_scaling_info *scaling_info)
 {
 	int scale_w, scale_h, min_downscale, max_upscale;
@@ -4596,7 +4597,8 @@ static int fill_dc_scaling_info(const struct drm_plane_state *state,
 	/*
 	 * For reasons we don't (yet) fully understand a non-zero
 	 * src_y coordinate into an NV12 buffer can cause a
-	 * system hang. To avoid hangs (and maybe be overly cautious)
+	 * system hang on DCN1x.
+	 * To avoid hangs (and maybe be overly cautious)
 	 * let's reject both non-zero src_x and src_y.
 	 *
 	 * We currently know of only one use-case to reproduce a
@@ -4604,10 +4606,10 @@ static int fill_dc_scaling_info(const struct drm_plane_state *state,
 	 * is to gesture the YouTube Android app into full screen
 	 * on ChromeOS.
 	 */
-	if (state->fb &&
-	    state->fb->format->format == DRM_FORMAT_NV12 &&
-	    (scaling_info->src_rect.x != 0 ||
-	     scaling_info->src_rect.y != 0))
+	if (((adev->ip_versions[DCE_HWIP][0] == IP_VERSION(1, 0, 0)) ||
+	    (adev->ip_versions[DCE_HWIP][0] == IP_VERSION(1, 0, 1))) &&
+	    (state->fb && state->fb->format->format == DRM_FORMAT_NV12 &&
+	    (scaling_info->src_rect.x != 0 || scaling_info->src_rect.y != 0)))
 		return -EINVAL;
 
 	scaling_info->src_rect.width = state->src_w >> 16;
@@ -5513,7 +5515,7 @@ static int fill_dc_plane_attributes(struct amdgpu_device *adev,
 	int ret;
 	bool force_disable_dcc = false;
 
-	ret = fill_dc_scaling_info(plane_state, &scaling_info);
+	ret = fill_dc_scaling_info(adev, plane_state, &scaling_info);
 	if (ret)
 		return ret;
 
@@ -7576,7 +7578,7 @@ static int dm_plane_atomic_check(struct drm_plane *plane,
 	if (ret)
 		return ret;
 
-	ret = fill_dc_scaling_info(new_plane_state, &scaling_info);
+	ret = fill_dc_scaling_info(adev, new_plane_state, &scaling_info);
 	if (ret)
 		return ret;
 
@@ -9024,7 +9026,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 			bundle->surface_updates[planes_count].gamut_remap_matrix = &dc_plane->gamut_remap_matrix;
 		}
 
-		fill_dc_scaling_info(new_plane_state,
+		fill_dc_scaling_info(dm->adev, new_plane_state,
 				     &bundle->scaling_infos[planes_count]);
 
 		bundle->surface_updates[planes_count].scaling_info =
commit 917a6f0bdbc55c2e9770ab523768578db8e8ddb3
Merge: 4a390c2ee768 ade4a1fc5741
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Nov 10 13:09:39 2021 +1000

    Merge tag 'drm-intel-next-fixes-2021-11-09' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
    
    Couple Reverts, build fix, couple virtualization fixes,
    blank screen and other display rates fixes, and more.
    
    Four patches targeting stable in here.
    
    Display Fixes:
    - DP rates related fixes (Imre, Jani)
    - A Revert on disaling dual eDP that was causing state readout problems (Jani)
    - put the cdclk vtables in const data (Jani)
    - Fix DVO port type for moder platforms (Ville)
    - Fix blankscreen by turning DP++ TMDS output buffers on encoder->shutdown (Ville)
    - CCS FBs related fixes (Imre)
    
    GT fixes:
    - Fix recursive lock in GuC submission (Matt Brost)
    - Revert guc_id from i915_request tracepoint (Joonas)
    - Build fix around dmabuf (Matt Auld)
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    
    From: Rodrigo Vivi <rodrigo.vivi at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/YYsBif3HMi8GjLoU@intel.com

commit 4a390c2ee768fb27f96bbe078dc0cea3da040c3d
Merge: 806acd381960 ff2d23843f7f
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Nov 10 13:08:04 2021 +1000

    Merge tag 'drm-misc-next-fixes-2021-11-05' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
    
    A refcounting fix for outstanding fence callbacks.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    
    From: Maxime Ripard <maxime at cerno.tech>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211105074318.oy6rwjr5wcw6qpjj@gilmour

commit c40a09e56fa3d17a3d06cec9a24b04364bb18c8f
Author: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
Date:   Thu Nov 4 16:52:07 2021 -0400

    drm/amd/display: Add callbacks for DMUB HPD IRQ notifications
    
    [Why]
    We need HPD IRQ notifications (RX, short pulse) to properly handle
    DP MST for DPIA connections.
    
    [How]
    A null pointer exception currently occurs when these are received
    so add a check to validate that we have a handler installed for
    the notification.
    
    Extend the HPD handler to also handle HPD IRQ (RX) since the logic is
    the same.
    
    Fixes: e27c41d5b068 ("drm/amd/display: Support for DMUB HPD interrupt handling")
    
    Reviewed-by: Wayne Lin <Wayne.Lin at amd.com>
    Reviewed-by: Jude Shih <shenshih at amd.com>
    Acked-by: Anson Jacob <Anson.Jacob at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 6aafcc14b479..a7cf7df4d2f2 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -217,6 +217,7 @@ static const struct drm_format_info *
 amd_get_format_info(const struct drm_mode_fb_cmd2 *cmd);
 
 static void handle_hpd_irq_helper(struct amdgpu_dm_connector *aconnector);
+static void handle_hpd_rx_irq(void *param);
 
 static bool
 is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
@@ -683,8 +684,12 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
 	}
 	drm_connector_list_iter_end(&iter);
 
-	if (hpd_aconnector)
-		handle_hpd_irq_helper(hpd_aconnector);
+	if (hpd_aconnector) {
+		if (notify->type == DMUB_NOTIFICATION_HPD)
+			handle_hpd_irq_helper(hpd_aconnector);
+		else if (notify->type == DMUB_NOTIFICATION_HPD_IRQ)
+			handle_hpd_rx_irq(hpd_aconnector);
+	}
 }
 
 /**
@@ -760,6 +765,10 @@ static void dm_dmub_outbox1_low_irq(void *interrupt_params)
 				DRM_ERROR("DM: notify type %d invalid!", notify.type);
 				continue;
 			}
+			if (!dm->dmub_callback[notify.type]) {
+				DRM_DEBUG_DRIVER("DMUB notification skipped, no handler: type=%d\n", notify.type);
+				continue;
+			}
 			if (dm->dmub_thread_offload[notify.type] == true) {
 				dmub_hpd_wrk = kzalloc(sizeof(*dmub_hpd_wrk), GFP_ATOMIC);
 				if (!dmub_hpd_wrk) {
@@ -1560,6 +1569,10 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 			DRM_ERROR("amdgpu: fail to register dmub hpd callback");
 			goto error;
 		}
+		if (!register_dmub_notify_callback(adev, DMUB_NOTIFICATION_HPD_IRQ, dmub_hpd_callback, true)) {
+			DRM_ERROR("amdgpu: fail to register dmub hpd callback");
+			goto error;
+		}
 #endif /* CONFIG_DRM_AMD_DC_DCN */
 	}
 
commit d82b3266ef88dc10fe0e7031b2bd8ba7eedb7e59
Author: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
Date:   Thu Nov 4 16:52:06 2021 -0400

    drm/amd/display: Don't lock connection_mutex for DMUB HPD
    
    [Why]
    Per DRM spec we only need to hold that lock when touching
    connector->state - which we do not do in that handler.
    
    Taking this locking introduces unnecessary dependencies with other
    threads which is bad for performance and opens up the potential for
    a deadlock since there are multiple locks being held at once.
    
    [How]
    Remove the connection_mutex lock/unlock routine and just iterate over
    the drm connectors normally. The iter helpers implicitly lock the
    connection list so this is safe to do.
    
    DC link access also does not need to be guarded since the link
    table is static at creation - we don't dynamically add or remove links,
    just streams.
    
    Fixes: e27c41d5b068 ("drm/amd/display: Support for DMUB HPD interrupt handling")
    
    Reviewed-by: Jude Shih <shenshih at amd.com>
    Acked-by: Anson Jacob <Anson.Jacob at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index d0d38d3631dc..6aafcc14b479 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -669,10 +669,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
 		return;
 	}
 
-	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
-
 	link_index = notify->link_index;
-
 	link = adev->dm.dc->links[link_index];
 
 	drm_connector_list_iter_begin(dev, &iter);
@@ -685,7 +682,6 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
 		}
 	}
 	drm_connector_list_iter_end(&iter);
-	drm_modeset_unlock(&dev->mode_config.connection_mutex);
 
 	if (hpd_aconnector)
 		handle_hpd_irq_helper(hpd_aconnector);
commit 433e5dec418d026b373d291f97b3996369665f46
Author: Anson Jacob <Anson.Jacob at amd.com>
Date:   Thu Nov 4 16:51:57 2021 -0400

    drm/amd/display: Add comment where CONFIG_DRM_AMD_DC_DCN macro ends
    
    Trivial patch which adds a comment for macro
    endif's in amdgpu_dm.c
    
    Reviewed-by: Ariel Bernstein <Eric.Bernstein at amd.com>
    Reviewed-by: Harry Wentland <Harry.Wentland at amd.com>
    Acked-by: Anson Jacob <Anson.Jacob at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Anson Jacob <Anson.Jacob at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index c1bbed7339fe..d0d38d3631dc 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -619,7 +619,7 @@ static void dm_dcn_vertical_interrupt0_high_irq(void *interrupt_params)
 
 	amdgpu_dm_crtc_handle_crc_window_irq(&acrtc->base);
 }
-#endif
+#endif /* CONFIG_DRM_AMD_SECURE_DISPLAY */
 
 /**
  * dmub_aux_setconfig_reply_callback - Callback for AUX or SET_CONFIG command.
@@ -813,7 +813,7 @@ static void dm_dmub_outbox1_low_irq(void *interrupt_params)
 	if (count > DMUB_TRACE_MAX_READ)
 		DRM_DEBUG_DRIVER("Warning : count > DMUB_TRACE_MAX_READ");
 }
-#endif
+#endif /* CONFIG_DRM_AMD_DC_DCN */
 
 static int dm_set_clockgating_state(void *handle,
 		  enum amd_clockgating_state state)
@@ -1564,7 +1564,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 			DRM_ERROR("amdgpu: fail to register dmub hpd callback");
 			goto error;
 		}
-#endif
+#endif /* CONFIG_DRM_AMD_DC_DCN */
 	}
 
 	if (amdgpu_dm_initialize_drm_device(adev)) {
@@ -6078,7 +6078,7 @@ static void apply_dsc_policy_for_stream(struct amdgpu_dm_connector *aconnector,
 	if (stream->timing.flags.DSC && aconnector->dsc_settings.dsc_bits_per_pixel)
 		stream->timing.dsc_cfg.bits_per_pixel = aconnector->dsc_settings.dsc_bits_per_pixel;
 }
-#endif
+#endif /* CONFIG_DRM_AMD_DC_DCN */
 
 /**
  * DOC: FreeSync Video
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 398de46fb7e4..0ded4decee05 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1892,6 +1892,7 @@ static bool is_flip_pending_in_pipes(struct dc *dc, struct dc_state *context)
 	return false;
 }
 
+#ifdef CONFIG_DRM_AMD_DC_DCN
 /* Perform updates here which need to be deferred until next vupdate
  *
  * i.e. blnd lut, 3dlut, and shaper lut bypass regs are double buffered
@@ -1901,7 +1902,6 @@ static bool is_flip_pending_in_pipes(struct dc *dc, struct dc_state *context)
  */
 static void process_deferred_updates(struct dc *dc)
 {
-#ifdef CONFIG_DRM_AMD_DC_DCN
 	int i = 0;
 
 	if (dc->debug.enable_mem_low_power.bits.cm) {
@@ -1910,8 +1910,8 @@ static void process_deferred_updates(struct dc *dc)
 			if (dc->res_pool->dpps[i]->funcs->dpp_deferred_update)
 				dc->res_pool->dpps[i]->funcs->dpp_deferred_update(dc->res_pool->dpps[i]);
 	}
-#endif
 }
+#endif /* CONFIG_DRM_AMD_DC_DCN */
 
 void dc_post_update_surfaces_to_stream(struct dc *dc)
 {
@@ -1938,7 +1938,9 @@ void dc_post_update_surfaces_to_stream(struct dc *dc)
 			dc->hwss.disable_plane(dc, &context->res_ctx.pipe_ctx[i]);
 		}
 
+#ifdef CONFIG_DRM_AMD_DC_DCN
 	process_deferred_updates(dc);
+#endif
 
 	dc->hwss.optimize_bandwidth(dc, context);
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index f14f71dd1aa9..60544788e911 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -4770,7 +4770,7 @@ uint32_t dc_bandwidth_in_kbps_from_timing(
 				timing->dsc_cfg.bits_per_pixel,
 				timing->dsc_cfg.num_slices_h,
 				timing->dsc_cfg.is_dp);
-#endif
+#endif /* CONFIG_DRM_AMD_DC_DCN */
 
 	switch (timing->display_color_depth) {
 	case COLOR_DEPTH_666:
commit a44fe9ee051acac5f229809c7c08dd04f81d4a0d
Author: Felix Kuehling <Felix.Kuehling at amd.com>
Date:   Fri Nov 5 10:52:53 2021 -0400

    drm/amdkfd: Fix retry fault drain race conditions
    
    The check for whether to drain retry faults must be under the mmap write
    lock to serialize with munmap notifier callbacks.
    
    We were also missing checks on child ranges. To fix that, simplify the
    logic by using a flag rather than checking on each prange. That also
    allows draining less freqeuntly when many ranges are unmapped at once.
    
    Signed-off-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Tested-by: Philip Yang <Philip.Yang at amd.com>
    Tested-by: Alex Sierra <Alex.Sierra at amd.com>
    Reviewed-by: Philip Yang <Philip.Yang at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index 98f7503bc106..94e92c0812db 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -766,6 +766,7 @@ struct svm_range_list {
 	struct list_head		deferred_range_list;
 	spinlock_t			deferred_list_lock;
 	atomic_t			evicted_ranges;
+	bool				drain_pagefaults;
 	struct delayed_work		restore_work;
 	DECLARE_BITMAP(bitmap_supported, MAX_GPU_INSTANCE);
 	struct task_struct 		*faulting_task;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 381d8d27a55a..16137c4247bb 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -2002,20 +2002,28 @@ static void svm_range_deferred_list_work(struct work_struct *work)
 		pr_debug("prange 0x%p [0x%lx 0x%lx] op %d\n", prange,
 			 prange->start, prange->last, prange->work_item.op);
 
-		/* Make sure no stale retry fault coming after range is freed */
-		if (prange->work_item.op == SVM_OP_UNMAP_RANGE)
-			svm_range_drain_retry_fault(prange->svms);
-
 		mm = prange->work_item.mm;
+retry:
 		mmap_write_lock(mm);
 		mutex_lock(&svms->lock);
 
-		/* Remove from deferred_list must be inside mmap write lock,
+		/* Checking for the need to drain retry faults must be in
+		 * mmap write lock to serialize with munmap notifiers.
+		 *
+		 * Remove from deferred_list must be inside mmap write lock,
 		 * otherwise, svm_range_list_lock_and_flush_work may hold mmap
 		 * write lock, and continue because deferred_list is empty, then
 		 * deferred_list handle is blocked by mmap write lock.
 		 */
 		spin_lock(&svms->deferred_list_lock);
+		if (unlikely(svms->drain_pagefaults)) {
+			svms->drain_pagefaults = false;
+			spin_unlock(&svms->deferred_list_lock);
+			mutex_unlock(&svms->lock);
+			mmap_write_unlock(mm);
+			svm_range_drain_retry_fault(svms);
+			goto retry;
+		}
 		list_del_init(&prange->deferred_list);
 		spin_unlock(&svms->deferred_list_lock);
 
@@ -2048,6 +2056,12 @@ svm_range_add_list_work(struct svm_range_list *svms, struct svm_range *prange,
 			struct mm_struct *mm, enum svm_work_list_ops op)
 {
 	spin_lock(&svms->deferred_list_lock);
+	/* Make sure pending page faults are drained in the deferred worker
+	 * before the range is freed to avoid straggler interrupts on
+	 * unmapped memory causing "phantom faults".
+	 */
+	if (op == SVM_OP_UNMAP_RANGE)
+		svms->drain_pagefaults = true;
 	/* if prange is on the deferred list */
 	if (!list_empty(&prange->deferred_list)) {
 		pr_debug("update exist prange 0x%p work op %d\n", prange, op);
commit 3aac6aa6304f263641880e5769457ec998fb0d97
Author: Alex Sierra <alex.sierra at amd.com>
Date:   Wed Nov 3 21:06:31 2021 -0500

    drm/amdkfd: lower the VAs base offset to 8KB
    
    The low 16MB of virtual address space are currently reserved for kernel
    mode allocations mapped into user virtual address space. This causes
    conflicts with HMM/SVM mappings at low virtual addresses. We tried to
    move those kernel mode allocations to the upper half of the 64-bit
    virtual address space for GFX9, which is naturally reserved for kernel
    use. However, TBA (trap handler code) has problems to access addresses
    in the high virtual space. We have decided to set this to 8KB of the
    lower address space as a temporary fix, while investigate TBA address
    problem. It is very unlikely for user space to map memory at this low
    region.
    
    Signed-off-by: Alex Sierra <alex.sierra at amd.com>
    Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
index 2e86692def19..d1388896f9c1 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
@@ -308,7 +308,7 @@
  * 16MB are reserved for kernel use (CWSR trap handler and kernel IB
  * for now).
  */
-#define SVM_USER_BASE 0x1000000ull
+#define SVM_USER_BASE (u64)(KFD_CWSR_TBA_TMA_SIZE + 2*PAGE_SIZE)
 #define SVM_CWSR_BASE (SVM_USER_BASE - KFD_CWSR_TBA_TMA_SIZE)
 #define SVM_IB_BASE   (SVM_CWSR_BASE - PAGE_SIZE)
 
commit 706bc8c501405aa78e71a646f8cf1e70de1f9485
Author: Shirish S <shirish.s at amd.com>
Date:   Mon Nov 8 19:21:46 2021 +0530

    drm/amd/display: fix exit from amdgpu_dm_atomic_check() abruptly
    
    make action upon failure in "drm_atomic_add_affected_connectors()"
    consistent with the rest of failures in amdgpu_dm_atomic_check().
    
    Signed-off-by: Shirish S <shirish.s at amd.com>
    Reviewed-by: Harry Wentland <harry.wentland at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 94d225931d51..c1bbed7339fe 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -10802,7 +10802,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 
 		ret = drm_atomic_add_affected_connectors(state, crtc);
 		if (ret)
-			return ret;
+			goto fail;
 
 		ret = drm_atomic_add_affected_planes(state, crtc);
 		if (ret)
commit 9f4f2c1a35248f56b2a9c1c004e0aaff3609b15d
Author: shaoyunl <shaoyun.liu at amd.com>
Date:   Fri Nov 5 12:34:14 2021 -0400

    drm/amd/amdgpu: fix the kfd pre_reset sequence in sriov
    
    The KFD pre_reset should be called before reset been executed, it will
    hold the lock to prevent other rocm process to sent the packlage to hiq
    during host execute the real reset on the HW
    
    Signed-off-by: shaoyunl <shaoyun.liu at amd.com>
    Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b45f4751adf8..5625f7736e37 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4293,8 +4293,6 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
 	if (r)
 		return r;
 
-	amdgpu_amdkfd_pre_reset(adev);
-
 	/* Resume IP prior to SMC */
 	r = amdgpu_device_ip_reinit_early_sriov(adev);
 	if (r)
@@ -5030,8 +5028,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 
 		cancel_delayed_work_sync(&tmp_adev->delayed_init_work);
 
-		if (!amdgpu_sriov_vf(tmp_adev))
-			amdgpu_amdkfd_pre_reset(tmp_adev);
+		amdgpu_amdkfd_pre_reset(tmp_adev);
 
 		/*
 		 * Mark these ASICs to be reseted as untracked first
commit 4fc30ea780e0a5c1c019bc2e44f8523e1eed9051
Author: Evan Quan <evan.quan at amd.com>
Date:   Sat Oct 9 17:35:36 2021 +0800

    drm/amdgpu: fix uvd crash on Polaris12 during driver unloading
    
    There was a change(below) target for such issue:
    d82e2c249c8f ("drm/amdgpu: Fix crash on device remove/driver unload")
    But the fix for VI ASICs was missing there. This is a supplement for
    that.
    
    Fixes: d82e2c249c8f ("drm/amdgpu: Fix crash on device remove/driver unload")
    
    Signed-off-by: Evan Quan <evan.quan at amd.com>
    Acked-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index d5d023a24269..2d558c2f417d 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
@@ -534,6 +534,19 @@ static int uvd_v6_0_hw_fini(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	cancel_delayed_work_sync(&adev->uvd.idle_work);
+
+	if (RREG32(mmUVD_STATUS) != 0)
+		uvd_v6_0_stop(adev);
+
+	return 0;
+}
+
+static int uvd_v6_0_suspend(void *handle)
+{
+	int r;
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
 	/*
 	 * Proper cleanups before halting the HW engine:
 	 *   - cancel the delayed idle work
@@ -558,17 +571,6 @@ static int uvd_v6_0_hw_fini(void *handle)
 						       AMD_CG_STATE_GATE);
 	}
 
-	if (RREG32(mmUVD_STATUS) != 0)
-		uvd_v6_0_stop(adev);
-
-	return 0;
-}
-
-static int uvd_v6_0_suspend(void *handle)
-{
-	int r;
-	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
 	r = uvd_v6_0_hw_fini(adev);
 	if (r)
 		return r;
commit ade4a1fc5741a36b559dfbd4557dc3da1a4394af
Author: Imre Deak <imre.deak at intel.com>
Date:   Wed Oct 27 01:51:00 2021 +0300

    drm/i915/adlp/fb: Prevent the mapping of redundant trailing padding NULL pages
    
    So far the remapped view size in GTT/DPT was padded to the next aligned
    offset unnecessarily after the last color plane with an unaligned size.
    Remove the unnecessary padding.
    
    Cc: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
    Fixes: 3d1adc3d64cf ("drm/i915/adlp: Add support for remapping CCS FBs")
    Signed-off-by: Imre Deak <imre.deak at intel.com>
    Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211026225105.2783797-3-imre.deak@intel.com
    (cherry picked from commit 6b6636e17649d75b4d0cc55d3dff9e44511a442a)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index ff598b6cd953..ec403e46a328 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -848,9 +848,16 @@ unsigned int intel_remapped_info_size(const struct intel_remapped_info *rem_info
 	int i;
 
 	for (i = 0 ; i < ARRAY_SIZE(rem_info->plane); i++) {
+		unsigned int plane_size;
+
+		plane_size = rem_info->plane[i].dst_stride * rem_info->plane[i].height;
+		if (plane_size == 0)
+			continue;
+
 		if (rem_info->plane_alignment)
 			size = ALIGN(size, rem_info->plane_alignment);
-		size += rem_info->plane[i].dst_stride * rem_info->plane[i].height;
+
+		size += plane_size;
 	}
 
 	return size;
diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index f17383e76eb7..57c97554393b 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -1396,6 +1396,9 @@ remap_pages(struct drm_i915_gem_object *obj,
 {
 	unsigned int row;
 
+	if (!width || !height)
+		return sg;
+
 	if (alignment_pad) {
 		st->nents++;
 
commit 90ab96f3872eae816f4e07deaa77322a91237960
Author: Imre Deak <imre.deak at intel.com>
Date:   Wed Oct 27 01:50:59 2021 +0300

    drm/i915/fb: Fix rounding error in subsampled plane size calculation
    
    For NV12 FBs with odd main surface tile-row height the CCS surface
    height was incorrectly calculated 1 less than the actual value. Fix this
    by rounding up the result of divison. For consistency do the same for
    the CCS surface width calculation.
    
    Fixes: b3e57bccd68a ("drm/i915/tgl: Gen-12 render decompression")
    Signed-off-by: Imre Deak <imre.deak at intel.com>
    Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211026225105.2783797-2-imre.deak@intel.com
    (cherry picked from commit 2ee5ef9c934ad26376c9282171e731e6c0339815)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
index fa1f375e696b..cb511b2b7069 100644
--- a/drivers/gpu/drm/i915/display/intel_fb.c
+++ b/drivers/gpu/drm/i915/display/intel_fb.c
@@ -378,8 +378,8 @@ static void intel_fb_plane_dims(const struct intel_framebuffer *fb, int color_pl
 	intel_fb_plane_get_subsampling(&main_hsub, &main_vsub, &fb->base, main_plane);
 	intel_fb_plane_get_subsampling(&hsub, &vsub, &fb->base, color_plane);
 
-	*w = main_width / main_hsub / hsub;
-	*h = main_height / main_vsub / vsub;
+	*w = DIV_ROUND_UP(main_width, main_hsub * hsub);
+	*h = DIV_ROUND_UP(main_height, main_vsub * vsub);
 }
 
 static u32 intel_adjust_tile_offset(int *x, int *y,
commit cecbc0c7eba7983965cac94f88d2db00b913253b
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Fri Oct 29 22:18:02 2021 +0300

    drm/i915/hdmi: Turn DP++ TMDS output buffers back on in encoder->shutdown()
    
    Looks like our VBIOS/GOP generally fail to turn the DP dual mode adater
    TMDS output buffers back on after a reboot. This leads to a black screen
    after reboot if we turned the TMDS output buffers off prior to reboot.
    And if i915 decides to do a fastboot the black screen will persist even
    after i915 takes over.
    
    Apparently this has been a problem ever since commit b2ccb822d376 ("drm/i915:
    Enable/disable TMDS output buffers in DP++ adaptor as needed") if one
    rebooted while the display was turned off. And things became worse with
    commit fe0f1e3bfdfe ("drm/i915: Shut down displays gracefully on reboot")
    since now we always turn the display off before a reboot.
    
    This was reported on a RKL, but I confirmed the same behaviour on my
    SNB as well. So looks pretty universal.
    
    Let's fix this by explicitly turning the TMDS output buffers back on
    in the encoder->shutdown() hook. Note that this gets called after irqs
    have been disabled, so the i2c communication with the DP dual mode
    adapter has to be performed via polling (which the gmbus code is
    perfectly happy to do for us).
    
    We also need a bit of care in handling DDI encoders which may or may
    not be set up for HDMI output. Specifically ddc_pin will not be
    populated for a DP only DDI encoder, in which case we don't want to
    call intel_gmbus_get_adapter(). We can handle that by simply doing
    the dual mode adapter type check before calling
    intel_gmbus_get_adapter().
    
    Cc: <stable at vger.kernel.org> # v5.11+
    Fixes: fe0f1e3bfdfe ("drm/i915: Shut down displays gracefully on reboot")
    Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4371
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211029191802.18448-2-ville.syrjala@linux.intel.com
    Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy at intel.com>
    (cherry picked from commit 49c55f7b035b87371a6d3c53d9af9f92ddc962db)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/display/g4x_hdmi.c b/drivers/gpu/drm/i915/display/g4x_hdmi.c
index 88c427f3c346..f5b4dd5b4275 100644
--- a/drivers/gpu/drm/i915/display/g4x_hdmi.c
+++ b/drivers/gpu/drm/i915/display/g4x_hdmi.c
@@ -584,6 +584,7 @@ void g4x_hdmi_init(struct drm_i915_private *dev_priv,
 		else
 			intel_encoder->enable = g4x_enable_hdmi;
 	}
+	intel_encoder->shutdown = intel_hdmi_encoder_shutdown;
 
 	intel_encoder->type = INTEL_OUTPUT_HDMI;
 	intel_encoder->power_domain = intel_port_to_power_domain(port);
diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
index 1dcfe31e6c6f..cfb567df71b3 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -4361,6 +4361,7 @@ static void intel_ddi_encoder_shutdown(struct intel_encoder *encoder)
 	enum phy phy = intel_port_to_phy(i915, encoder->port);
 
 	intel_dp_encoder_shutdown(encoder);
+	intel_hdmi_encoder_shutdown(encoder);
 
 	if (!intel_phy_is_tc(i915, phy))
 		return;
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index d2e61f6c6e08..371736bdc01f 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -1246,12 +1246,13 @@ static void hsw_set_infoframes(struct intel_encoder *encoder,
 void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
 {
 	struct drm_i915_private *dev_priv = intel_hdmi_to_i915(hdmi);
-	struct i2c_adapter *adapter =
-		intel_gmbus_get_adapter(dev_priv, hdmi->ddc_bus);
+	struct i2c_adapter *adapter;
 
 	if (hdmi->dp_dual_mode.type < DRM_DP_DUAL_MODE_TYPE2_DVI)
 		return;
 
+	adapter = intel_gmbus_get_adapter(dev_priv, hdmi->ddc_bus);
+
 	drm_dbg_kms(&dev_priv->drm, "%s DP dual mode adaptor TMDS output\n",
 		    enable ? "Enabling" : "Disabling");
 
@@ -2258,6 +2259,17 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder,
 	return 0;
 }
 
+void intel_hdmi_encoder_shutdown(struct intel_encoder *encoder)
+{
+	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
+
+	/*
+	 * Give a hand to buggy BIOSen which forget to turn
+	 * the TMDS output buffers back on after a reboot.
+	 */
+	intel_dp_dual_mode_set_tmds_output(intel_hdmi, true);
+}
+
 static void
 intel_hdmi_unset_edid(struct drm_connector *connector)
 {
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.h b/drivers/gpu/drm/i915/display/intel_hdmi.h
index b43a180d007e..2bf440eb400a 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.h
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.h
@@ -28,6 +28,7 @@ void intel_hdmi_init_connector(struct intel_digital_port *dig_port,
 int intel_hdmi_compute_config(struct intel_encoder *encoder,
 			      struct intel_crtc_state *pipe_config,
 			      struct drm_connector_state *conn_state);
+void intel_hdmi_encoder_shutdown(struct intel_encoder *encoder);
 bool intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder,
 				       struct drm_connector *connector,
 				       bool high_tmds_clock_ratio,
commit bcae3af286f49bf4f6cda03f165fbe530f4a6bed
Author: Stephen Rothwell <sfr at canb.auug.org.au>
Date:   Mon Oct 18 11:51:13 2021 +0300

    drm/locking: fix __stack_depot_* name conflict
    
    Commit cd06ab2fd48f ("drm/locking: add backtrace for locking contended
    locks without backoff") added functions named __stack_depot_* in drm
    which conflict with stack depot. Rename to __drm_stack_depot_*.
    
    v2 by Jani:
    - Also rename __stack_depot_print
    
    References: https://lore.kernel.org/r/20211015202648.258445ef@canb.auug.org.au
    Fixes: cd06ab2fd48f ("drm/locking: add backtrace for locking contended locks without backoff")
    Cc: Daniel Vetter <daniel at ffwll.ch>
    Reviewed-by: Daniel Vetter <daniel at ffwll.ch>
    Signed-off-by: Stephen Rothwell <sfr at canb.auug.org.au>
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211018085113.27033-1-jani.nikula@intel.com
    (cherry picked from commit c4f08d7246a520da5f2b1068f635da0678485e33)

diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c
index 62f6fe482d25..83cf0bc64eb9 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -79,7 +79,7 @@
 static DEFINE_WW_CLASS(crtc_ww_class);
 
 #if IS_ENABLED(CONFIG_DRM_DEBUG_MODESET_LOCK)
-static noinline depot_stack_handle_t __stack_depot_save(void)
+static noinline depot_stack_handle_t __drm_stack_depot_save(void)
 {
 	unsigned long entries[8];
 	unsigned int n;
@@ -89,7 +89,7 @@ static noinline depot_stack_handle_t __stack_depot_save(void)
 	return stack_depot_save(entries, n, GFP_NOWAIT | __GFP_NOWARN);
 }
 
-static void __stack_depot_print(depot_stack_handle_t stack_depot)
+static void __drm_stack_depot_print(depot_stack_handle_t stack_depot)
 {
 	struct drm_printer p = drm_debug_printer("drm_modeset_lock");
 	unsigned long *entries;
@@ -108,11 +108,11 @@ static void __stack_depot_print(depot_stack_handle_t stack_depot)
 	kfree(buf);
 }
 #else /* CONFIG_DRM_DEBUG_MODESET_LOCK */
-static depot_stack_handle_t __stack_depot_save(void)
+static depot_stack_handle_t __drm_stack_depot_save(void)
 {
 	return 0;
 }
-static void __stack_depot_print(depot_stack_handle_t stack_depot)
+static void __drm_stack_depot_print(depot_stack_handle_t stack_depot)
 {
 }
 #endif /* CONFIG_DRM_DEBUG_MODESET_LOCK */
@@ -266,7 +266,7 @@ EXPORT_SYMBOL(drm_modeset_acquire_fini);
 void drm_modeset_drop_locks(struct drm_modeset_acquire_ctx *ctx)
 {
 	if (WARN_ON(ctx->contended))
-		__stack_depot_print(ctx->stack_depot);
+		__drm_stack_depot_print(ctx->stack_depot);
 
 	while (!list_empty(&ctx->locked)) {
 		struct drm_modeset_lock *lock;
@@ -286,7 +286,7 @@ static inline int modeset_lock(struct drm_modeset_lock *lock,
 	int ret;
 
 	if (WARN_ON(ctx->contended))
-		__stack_depot_print(ctx->stack_depot);
+		__drm_stack_depot_print(ctx->stack_depot);
 
 	if (ctx->trylock_only) {
 		lockdep_assert_held(&ctx->ww_ctx);
@@ -317,7 +317,7 @@ static inline int modeset_lock(struct drm_modeset_lock *lock,
 		ret = 0;
 	} else if (ret == -EDEADLK) {
 		ctx->contended = lock;
-		ctx->stack_depot = __stack_depot_save();
+		ctx->stack_depot = __drm_stack_depot_save();
 	}
 
 	return ret;
commit d89c0c8322ecdc9a2ec84b959b6f766be082da76
Author: Vivek Kasireddy <vivek.kasireddy at intel.com>
Date:   Thu Nov 4 14:42:49 2021 -0700

    drm/virtio: Fix NULL dereference error in virtio_gpu_poll
    
    When virgl is not enabled, vfpriv pointer would not be allocated.
    Therefore, check for a valid value before dereferencing.
    
    Reported-by: Christian Zigotzky <chzigotzky at xenosoft.de>
    Cc: Gurchetan Singh <gurchetansingh at chromium.org>
    Cc: Gerd Hoffmann <kraxel at redhat.com>
    Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
    Tested-by: Christian Zigotzky <chzigotzky at xenosoft.de>
    Link: http://patchwork.freedesktop.org/patch/msgid/20211104214249.1802789-1-vivek.kasireddy@intel.com
    Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>

diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
index 749db18dcfa2..d86e1ad4a972 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -163,10 +163,11 @@ static __poll_t virtio_gpu_poll(struct file *filp,
 	struct drm_file *drm_file = filp->private_data;
 	struct virtio_gpu_fpriv *vfpriv = drm_file->driver_priv;
 	struct drm_device *dev = drm_file->minor->dev;
+	struct virtio_gpu_device *vgdev = dev->dev_private;
 	struct drm_pending_event *e = NULL;
 	__poll_t mask = 0;
 
-	if (!vfpriv->ring_idx_mask)
+	if (!vgdev->has_virgl_3d || !vfpriv || !vfpriv->ring_idx_mask)
 		return drm_poll(filp, wait);
 
 	poll_wait(filp, &drm_file->event_wait, wait);
commit 2d32ffd6e9e5f28fab3f52ea4044e3c14418cfb7
Author: Alex Deucher <alexander.deucher at amd.com>
Date:   Wed Nov 3 23:17:50 2021 -0400

    drm/amdgpu: fix SI handling in amdgpu_device_asic_has_dc_support()
    
    Properly handle SI DC support when CONFIG_DRM_AMD_DC_SI is not
    set.
    
    Fixes: f7f12b25823c0d ("drm/amdgpu: default to true in amdgpu_device_asic_has_dc_support")
    Reviewed-by: Evan Quan <evan.quan at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 6c38dd9f41be..b45f4751adf8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3167,11 +3167,21 @@ bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
 {
 	switch (asic_type) {
 #if defined(CONFIG_DRM_AMD_DC)
-#if defined(CONFIG_DRM_AMD_DC_SI)
 	case CHIP_TAHITI:
 	case CHIP_PITCAIRN:
 	case CHIP_VERDE:
 	case CHIP_OLAND:
+		/*
+		 * We have systems in the wild with these ASICs that require
+		 * LVDS and VGA support which is not supported with DC.
+		 *
+		 * Fallback to the non-DC driver here by default so as not to
+		 * cause regressions.
+		 */
+#if defined(CONFIG_DRM_AMD_DC_SI)
+		return amdgpu_dc > 0;
+#else
+		return false;
 #endif
 	case CHIP_BONAIRE:
 	case CHIP_KAVERI:
commit 5702d052959f9d711698e2fc86a706db87e9d646
Author: Felix Kuehling <Felix.Kuehling at amd.com>
Date:   Thu Nov 4 15:11:04 2021 -0400

    drm/amdgpu: Fix dangling kfd_bo pointer for shared BOs
    
    If a kfd_bo was shared (e.g. a dmabuf export), the original kfd_bo may be
    freed when the amdgpu_bo still lives on. Free the kfd_bo struct in the
    release_notify callback then the amdgpu_bo is freed.
    
    Signed-off-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Reviewed-By: Ramesh Errabolu <Ramesh.Errabolu at amd.com>
    Reviewed-by: Christian König <christian.koenig at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
index 751557af09bb..a15a4787c7ee 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
@@ -297,7 +297,7 @@ void amdgpu_amdkfd_ras_poison_consumption_handler(struct kgd_dev *kgd);
 void amdgpu_amdkfd_gpuvm_init_mem_limits(void);
 void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
 				struct amdgpu_vm *vm);
-void amdgpu_amdkfd_unreserve_memory_limit(struct amdgpu_bo *bo);
+void amdgpu_amdkfd_release_notify(struct amdgpu_bo *bo);
 void amdgpu_amdkfd_reserve_system_mem(uint64_t size);
 #else
 static inline
@@ -312,7 +312,7 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
 }
 
 static inline
-void amdgpu_amdkfd_unreserve_memory_limit(struct amdgpu_bo *bo)
+void amdgpu_amdkfd_release_notify(struct amdgpu_bo *bo)
 {
 }
 #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index a00d8acdfb4b..71acd577803e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -207,7 +207,7 @@ static void unreserve_mem_limit(struct amdgpu_device *adev,
 	spin_unlock(&kfd_mem_limit.mem_limit_lock);
 }
 
-void amdgpu_amdkfd_unreserve_memory_limit(struct amdgpu_bo *bo)
+void amdgpu_amdkfd_release_notify(struct amdgpu_bo *bo)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
 	u32 domain = bo->preferred_domains;
@@ -219,6 +219,8 @@ void amdgpu_amdkfd_unreserve_memory_limit(struct amdgpu_bo *bo)
 	}
 
 	unreserve_mem_limit(adev, amdgpu_bo_size(bo), domain, sg);
+
+	kfree(bo->kfd_bo);
 }
 
 
@@ -1607,9 +1609,13 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
 	drm_vma_node_revoke(&mem->bo->tbo.base.vma_node, drm_priv);
 	if (mem->dmabuf)
 		dma_buf_put(mem->dmabuf);
-	drm_gem_object_put(&mem->bo->tbo.base);
 	mutex_destroy(&mem->lock);
-	kfree(mem);
+
+	/* If this releases the last reference, it will end up calling
+	 * amdgpu_amdkfd_release_notify and kfree the mem struct. That's why
+	 * this needs to be the last call here.
+	 */
+	drm_gem_object_put(&mem->bo->tbo.base);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index aeb92e5677ac..4fcfc2313b8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1274,7 +1274,7 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo)
 	abo = ttm_to_amdgpu_bo(bo);
 
 	if (abo->kfd_bo)
-		amdgpu_amdkfd_unreserve_memory_limit(abo);
+		amdgpu_amdkfd_release_notify(abo);
 
 	/* We only remove the fence if the resv has individualized. */
 	WARN_ON_ONCE(bo->type == ttm_bo_type_kernel
commit b8c20c74ab8c765b29fb253f6da4b0e59d9bdf3d
Author: shaoyunl <shaoyun.liu at amd.com>
Date:   Wed Nov 3 10:49:47 2021 -0400

    drm/amd/amdkfd: Don't sent command to HWS on kfd reset
    
    When kfd need to be reset, sent command to HWS might cause hang and get unnecessary timeout.
    This change try not to touch HW in pre_reset and keep queues to be in the evicted state
    when the reset is done, so they are not put back on the runlist. These queues will be destroied
    on process termination.
    
    Signed-off-by: shaoyunl <shaoyun.liu at amd.com>
    Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 533b27b35fc9..003ba6a373ff 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -1430,7 +1430,7 @@ static int unmap_queues_cpsch(struct device_queue_manager *dqm,
 
 	if (!dqm->sched_running)
 		return 0;
-	if (dqm->is_hws_hang)
+	if (dqm->is_hws_hang || dqm->is_resetting)
 		return -EIO;
 	if (!dqm->active_runlist)
 		return retval;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 457863861d6f..b993011cfa64 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -1715,7 +1715,11 @@ int kfd_process_evict_queues(struct kfd_process *p)
 
 		r = pdd->dev->dqm->ops.evict_process_queues(pdd->dev->dqm,
 							    &pdd->qpd);
-		if (r) {
+		/* evict return -EIO if HWS is hang or asic is resetting, in this case
+		 * we would like to set all the queues to be in evicted state to prevent
+		 * them been add back since they actually not be saved right now.
+		 */
+		if (r && r != -EIO) {
 			pr_err("Failed to evict process queues\n");
 			goto fail;
 		}
commit e6ef9b396b6354b33373c62f0f47edf8702f12e5
Author: Evan Quan <evan.quan at amd.com>
Date:   Thu Nov 4 11:11:26 2021 +0800

    drm/amdgpu: correctly toggle gfx on/off around RLC_SPM_* register access
    
    As part of the ib padding process, accessing the RLC_SPM_* register may
    trigger gfx hang. Since gfxoff may be already kicked during the whole period.
    To address that, we manually toggle gfx on/off around the RLC_SPM_*
    register access.
    
    This can resolve the gfx hang issue observed on running Talos with RDP launched
    in parallel.
    
    Signed-off-by: Evan Quan <evan.quan at amd.com>
    Acked-by: Guchun Chen <guchun.chen at amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index b53b36f5ae92..e7dfeb466a0e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -8249,6 +8249,9 @@ static int gfx_v10_0_update_gfx_clock_gating(struct amdgpu_device *adev,
 static void gfx_v10_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
 {
 	u32 reg, data;
+
+	amdgpu_gfx_off_ctrl(adev, false);
+
 	/* not for *_SOC15 */
 	reg = SOC15_REG_OFFSET(GC, 0, mmRLC_SPM_MC_CNTL);
 	if (amdgpu_sriov_is_pp_one_vf(adev))
@@ -8263,6 +8266,8 @@ static void gfx_v10_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
 		WREG32_SOC15_NO_KIQ(GC, 0, mmRLC_SPM_MC_CNTL, data);
 	else
 		WREG32_SOC15(GC, 0, mmRLC_SPM_MC_CNTL, data);
+
+	amdgpu_gfx_off_ctrl(adev, true);
 }
 
 static bool gfx_v10_0_check_rlcg_range(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
index 37b4a3db6360..d17a6f399347 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
@@ -3575,12 +3575,16 @@ static void gfx_v7_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
 {
 	u32 data;
 
+	amdgpu_gfx_off_ctrl(adev, false);
+
 	data = RREG32(mmRLC_SPM_VMID);
 
 	data &= ~RLC_SPM_VMID__RLC_SPM_VMID_MASK;
 	data |= (vmid & RLC_SPM_VMID__RLC_SPM_VMID_MASK) << RLC_SPM_VMID__RLC_SPM_VMID__SHIFT;
 
 	WREG32(mmRLC_SPM_VMID, data);
+
+	amdgpu_gfx_off_ctrl(adev, true);
 }
 
 static void gfx_v7_0_enable_cgcg(struct amdgpu_device *adev, bool enable)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index e0302c23e9a7..5f112efda634 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -5624,6 +5624,8 @@ static void gfx_v8_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
 {
 	u32 data;
 
+	amdgpu_gfx_off_ctrl(adev, false);
+
 	if (amdgpu_sriov_is_pp_one_vf(adev))
 		data = RREG32_NO_KIQ(mmRLC_SPM_VMID);
 	else
@@ -5636,6 +5638,8 @@ static void gfx_v8_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
 		WREG32_NO_KIQ(mmRLC_SPM_VMID, data);
 	else
 		WREG32(mmRLC_SPM_VMID, data);
+
+	amdgpu_gfx_off_ctrl(adev, true);
 }
 
 static const struct amdgpu_rlc_funcs iceland_rlc_funcs = {
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index be803ebd543c..b4b80f27b894 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -5104,6 +5104,8 @@ static void gfx_v9_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
 {
 	u32 reg, data;
 
+	amdgpu_gfx_off_ctrl(adev, false);
+
 	reg = SOC15_REG_OFFSET(GC, 0, mmRLC_SPM_MC_CNTL);
 	if (amdgpu_sriov_is_pp_one_vf(adev))
 		data = RREG32_NO_KIQ(reg);
@@ -5117,6 +5119,8 @@ static void gfx_v9_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
 		WREG32_SOC15_NO_KIQ(GC, 0, mmRLC_SPM_MC_CNTL, data);
 	else
 		WREG32_SOC15(GC, 0, mmRLC_SPM_MC_CNTL, data);
+
+	amdgpu_gfx_off_ctrl(adev, true);
 }
 
 static bool gfx_v9_0_check_rlcg_range(struct amdgpu_device *adev,
commit 7513c9ff44d9dfb035ec35b55f469244304806e6
Author: Tao Zhou <tao.zhou1 at amd.com>
Date:   Thu Nov 4 16:26:17 2021 +0800

    drm/amdgpu: correct xgmi ras error count reset
    
    The error count reset for xgmi3x16 pcs is missed.
    
    Signed-off-by: Tao Zhou <tao.zhou1 at amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 978ac927ac11..0fad2bf854ae 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -806,9 +806,9 @@ static void amdgpu_xgmi_reset_ras_error_count(struct amdgpu_device *adev)
 		for (i = 0; i < ARRAY_SIZE(xgmi23_pcs_err_status_reg_aldebaran); i++)
 			pcs_clear_status(adev,
 					 xgmi23_pcs_err_status_reg_aldebaran[i]);
-		for (i = 0; i < ARRAY_SIZE(xgmi23_pcs_err_status_reg_aldebaran); i++)
+		for (i = 0; i < ARRAY_SIZE(xgmi3x16_pcs_err_status_reg_aldebaran); i++)
 			pcs_clear_status(adev,
-					 xgmi23_pcs_err_status_reg_aldebaran[i]);
+					 xgmi3x16_pcs_err_status_reg_aldebaran[i]);
 		for (i = 0; i < ARRAY_SIZE(walf_pcs_err_status_reg_aldebaran); i++)
 			pcs_clear_status(adev,
 					 walf_pcs_err_status_reg_aldebaran[i]);
commit c451c979eafc3b7ffc1527c724058245ae41b01e
Author: Mario Limonciello <mario.limonciello at amd.com>
Date:   Thu Nov 4 10:44:50 2021 -0500

    drm/amd/pm: Correct DPMS disable IP version check
    
    Previously there was a check based on chip # for chips that aligned to
    >=CHIP_NAVI10 to have RLC stopped as part of DPMS check.  This was because
    of gfxclk being controlled by RLC in the newer designs.
    
    As part of IP version checking though, this got changed to match IP
    version for SMU.  Because Renoir designs also include smu11 that meant
    that even GFX9 started to stop RLC earlier.
    
    Adjust to match GFX IP version instead of SMU IP version to restore the
    previous behavior.
    
    Fixes: a8967967f6a5 ("drm/amdgpu/amdgpu_smu: convert to IP version checking")
    Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 821ae6e78703..01168b8955bf 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -1468,7 +1468,7 @@ static int smu_disable_dpms(struct smu_context *smu)
 			dev_err(adev->dev, "Failed to disable smu features.\n");
 	}
 
-	if (adev->ip_versions[MP1_HWIP][0] >= IP_VERSION(11, 0, 0) &&
+	if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0) &&
 	    adev->gfx.rlc.funcs->stop)
 		adev->gfx.rlc.funcs->stop(adev);
 
commit 6ddc0eb7a2e8b731991fe977eb52516fc56ac405
Author: YuBiao Wang <YuBiao.Wang at amd.com>
Date:   Thu Nov 4 17:32:30 2021 +0800

    drm/amd/amdgpu: Fix csb.bo pin_count leak on gfx 9
    
    [Why]
    csb bo is not unpinned in gfx 9. It will lead to pin_count leak on
    driver unload.
    
    [How]
    Call bo_free_kernel corresponding to bo_create_kernel in
    gfx_rlc_init_csb. This will also unify the code path with other gfx
    versions.
    
    Signed-off-by: YuBiao Wang <YuBiao.Wang at amd.com>
    Reviewed-by: Christian König <christian.koenig at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 7f944bb11298..be803ebd543c 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -2462,7 +2462,9 @@ static int gfx_v9_0_sw_fini(void *handle)
 	amdgpu_gfx_kiq_fini(adev);
 
 	gfx_v9_0_mec_fini(adev);
-	amdgpu_bo_unref(&adev->gfx.rlc.clear_state_obj);
+	amdgpu_bo_free_kernel(&adev->gfx.rlc.clear_state_obj,
+				&adev->gfx.rlc.clear_state_gpu_addr,
+				(void **)&adev->gfx.rlc.cs_ptr);
 	if (adev->flags & AMD_IS_APU) {
 		amdgpu_bo_free_kernel(&adev->gfx.rlc.cp_table_obj,
 				&adev->gfx.rlc.cp_table_gpu_addr,
commit c4fc13b5818f6e55ca86672dfddd9ea3a4fed470
Author: YuBiao Wang <YuBiao.Wang at amd.com>
Date:   Thu Nov 4 10:50:41 2021 +0800

    drm/amd/amdgpu: Avoid writing GMC registers under sriov in gmc9
    
    [Why]
    For Vega10, disabling gart of gfxhub could mess up KIQ and PSP
    under sriov mode, and lead to DMAR on host side.
    
    [How]
    Skip writing GMC registers under sriov.
    
    Signed-off-by: YuBiao Wang <YuBiao.Wang at amd.com>
    Acked-by: Christian König <christian.koenig at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
index bda1542ef1dd..480e41847d7c 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
@@ -348,6 +348,10 @@ static void gfxhub_v1_0_gart_disable(struct amdgpu_device *adev)
 		WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT0_CNTL,
 				    i * hub->ctx_distance, 0);
 
+	if (amdgpu_sriov_vf(adev))
+		/* Avoid write to GMC registers */
+		return;
+
 	/* Setup TLB control */
 	tmp = RREG32_SOC15(GC, 0, mmMC_VM_MX_L1_TLB_CNTL);
 	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0);
commit e9c76719c1e99caf95e70de74170291b9457bbc1
Author: Alex Deucher <alexander.deucher at amd.com>
Date:   Wed Nov 3 15:52:53 2021 -0400

    drm/amdgpu/powerplay: fix sysfs_emit/sysfs_emit_at handling
    
    sysfs_emit and sysfs_emit_at requrie a page boundary
    aligned buf address. Make them happy!
    
    v2: fix sysfs_emit -> sysfs_emit_at missed conversions
    
    Cc: Lang Yu <lang.yu at amd.com>
    Cc: Darren Powell <darren.powell at amd.com>
    Fixes: 6db0c87a0a8e ("amdgpu/pm: Replace hwmgr smu usage of sprintf with sysfs_emit")
    Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1774
    Reviewed-by: Lang Yu <lang.yu at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c
index 1de3ae77e03e..258c573acc97 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c
@@ -1024,6 +1024,8 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr,
 	uint32_t min_freq, max_freq = 0;
 	uint32_t ret = 0;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	switch (type) {
 	case PP_SCLK:
 		smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now);
@@ -1065,7 +1067,7 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr,
 			if (ret)
 				return ret;
 
-			size = sysfs_emit(buf, "%s:\n", "OD_SCLK");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_SCLK");
 			size += sysfs_emit_at(buf, size, "0: %10uMhz\n",
 			(data->gfx_actual_soft_min_freq > 0) ? data->gfx_actual_soft_min_freq : min_freq);
 			size += sysfs_emit_at(buf, size, "1: %10uMhz\n",
@@ -1081,7 +1083,7 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr,
 			if (ret)
 				return ret;
 
-			size = sysfs_emit(buf, "%s:\n", "OD_RANGE");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");
 			size += sysfs_emit_at(buf, size, "SCLK: %7uMHz %10uMHz\n",
 				min_freq, max_freq);
 		}
@@ -1456,6 +1458,8 @@ static int smu10_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
 	if (!buf)
 		return -EINVAL;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	size += sysfs_emit_at(buf, size, "%s %16s %s %s %s %s\n",title[0],
 			title[1], title[2], title[3], title[4], title[5]);
 
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
index e7803ce8f67a..aceebf584225 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
@@ -4914,6 +4914,8 @@ static int smu7_print_clock_levels(struct pp_hwmgr *hwmgr,
 	int size = 0;
 	uint32_t i, now, clock, pcie_speed;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	switch (type) {
 	case PP_SCLK:
 		smum_send_msg_to_smc(hwmgr, PPSMC_MSG_API_GetSclkFrequency, &clock);
@@ -4963,7 +4965,7 @@ static int smu7_print_clock_levels(struct pp_hwmgr *hwmgr,
 		break;
 	case OD_SCLK:
 		if (hwmgr->od_enabled) {
-			size = sysfs_emit(buf, "%s:\n", "OD_SCLK");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_SCLK");
 			for (i = 0; i < odn_sclk_table->num_of_pl; i++)
 				size += sysfs_emit_at(buf, size, "%d: %10uMHz %10umV\n",
 					i, odn_sclk_table->entries[i].clock/100,
@@ -4972,7 +4974,7 @@ static int smu7_print_clock_levels(struct pp_hwmgr *hwmgr,
 		break;
 	case OD_MCLK:
 		if (hwmgr->od_enabled) {
-			size = sysfs_emit(buf, "%s:\n", "OD_MCLK");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_MCLK");
 			for (i = 0; i < odn_mclk_table->num_of_pl; i++)
 				size += sysfs_emit_at(buf, size, "%d: %10uMHz %10umV\n",
 					i, odn_mclk_table->entries[i].clock/100,
@@ -4981,7 +4983,7 @@ static int smu7_print_clock_levels(struct pp_hwmgr *hwmgr,
 		break;
 	case OD_RANGE:
 		if (hwmgr->od_enabled) {
-			size = sysfs_emit(buf, "%s:\n", "OD_RANGE");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");
 			size += sysfs_emit_at(buf, size, "SCLK: %7uMHz %10uMHz\n",
 				data->golden_dpm_table.sclk_table.dpm_levels[0].value/100,
 				hwmgr->platform_descriptor.overdriveLimit.engineClock/100);
@@ -5518,6 +5520,8 @@ static int smu7_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
 	if (!buf)
 		return -EINVAL;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	size += sysfs_emit_at(buf, size, "%s %16s %16s %16s %16s %16s %16s %16s\n",
 			title[0], title[1], title[2], title[3],
 			title[4], title[5], title[6], title[7]);
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
index b94a77e4e714..8e28a8eecefc 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
@@ -1550,6 +1550,8 @@ static int smu8_print_clock_levels(struct pp_hwmgr *hwmgr,
 	uint32_t i, now;
 	int size = 0;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	switch (type) {
 	case PP_SCLK:
 		now = PHM_GET_FIELD(cgs_read_ind_register(hwmgr->device,
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.h b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.h
index ad33983a8064..2a75da1e9f03 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.h
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.h
@@ -109,6 +109,19 @@ int phm_irq_process(struct amdgpu_device *adev,
 			   struct amdgpu_irq_src *source,
 			   struct amdgpu_iv_entry *entry);
 
+/*
+ * Helper function to make sysfs_emit_at() happy. Align buf to
+ * the current page boundary and record the offset.
+ */
+static inline void phm_get_sysfs_buf(char **buf, int *offset)
+{
+	if (!*buf || !offset)
+		return;
+
+	*offset = offset_in_page(*buf);
+	*buf -= *offset;
+}
+
 int smu9_register_irq_handlers(struct pp_hwmgr *hwmgr);
 
 void *smu_atom_get_data_table(void *dev, uint32_t table, uint16_t *size,
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
index c152a61ddd2c..c981fc2882f0 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
@@ -4548,6 +4548,8 @@ static int vega10_get_ppfeature_status(struct pp_hwmgr *hwmgr, char *buf)
 	int ret = 0;
 	int size = 0;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	ret = vega10_get_enabled_smc_features(hwmgr, &features_enabled);
 	PP_ASSERT_WITH_CODE(!ret,
 			"[EnableAllSmuFeatures] Failed to get enabled smc features!",
@@ -4637,6 +4639,8 @@ static int vega10_print_clock_levels(struct pp_hwmgr *hwmgr,
 
 	int i, now, size = 0, count = 0;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	switch (type) {
 	case PP_SCLK:
 		if (data->registry_data.sclk_dpm_key_disabled)
@@ -4717,7 +4721,7 @@ static int vega10_print_clock_levels(struct pp_hwmgr *hwmgr,
 
 	case OD_SCLK:
 		if (hwmgr->od_enabled) {
-			size = sysfs_emit(buf, "%s:\n", "OD_SCLK");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_SCLK");
 			podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_sclk;
 			for (i = 0; i < podn_vdd_dep->count; i++)
 				size += sysfs_emit_at(buf, size, "%d: %10uMhz %10umV\n",
@@ -4727,7 +4731,7 @@ static int vega10_print_clock_levels(struct pp_hwmgr *hwmgr,
 		break;
 	case OD_MCLK:
 		if (hwmgr->od_enabled) {
-			size = sysfs_emit(buf, "%s:\n", "OD_MCLK");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_MCLK");
 			podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_mclk;
 			for (i = 0; i < podn_vdd_dep->count; i++)
 				size += sysfs_emit_at(buf, size, "%d: %10uMhz %10umV\n",
@@ -4737,7 +4741,7 @@ static int vega10_print_clock_levels(struct pp_hwmgr *hwmgr,
 		break;
 	case OD_RANGE:
 		if (hwmgr->od_enabled) {
-			size = sysfs_emit(buf, "%s:\n", "OD_RANGE");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");
 			size += sysfs_emit_at(buf, size, "SCLK: %7uMHz %10uMHz\n",
 				data->golden_dpm_table.gfx_table.dpm_levels[0].value/100,
 				hwmgr->platform_descriptor.overdriveLimit.engineClock/100);
@@ -5112,6 +5116,8 @@ static int vega10_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
 	if (!buf)
 		return -EINVAL;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	size += sysfs_emit_at(buf, size, "%s %16s %s %s %s %s\n",title[0],
 			title[1], title[2], title[3], title[4], title[5]);
 
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c
index 8558718e15a8..f7e783e1c888 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c
@@ -2141,6 +2141,8 @@ static int vega12_get_ppfeature_status(struct pp_hwmgr *hwmgr, char *buf)
 	int ret = 0;
 	int size = 0;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	ret = vega12_get_enabled_smc_features(hwmgr, &features_enabled);
 	PP_ASSERT_WITH_CODE(!ret,
 		"[EnableAllSmuFeatures] Failed to get enabled smc features!",
@@ -2244,6 +2246,8 @@ static int vega12_print_clock_levels(struct pp_hwmgr *hwmgr,
 	int i, now, size = 0;
 	struct pp_clock_levels_with_latency clocks;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	switch (type) {
 	case PP_SCLK:
 		PP_ASSERT_WITH_CODE(
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c
index 0cf39c1244b1..03e63be4ee27 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c
@@ -3238,6 +3238,8 @@ static int vega20_get_ppfeature_status(struct pp_hwmgr *hwmgr, char *buf)
 	int ret = 0;
 	int size = 0;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	ret = vega20_get_enabled_smc_features(hwmgr, &features_enabled);
 	PP_ASSERT_WITH_CODE(!ret,
 			"[EnableAllSmuFeatures] Failed to get enabled smc features!",
@@ -3364,6 +3366,8 @@ static int vega20_print_clock_levels(struct pp_hwmgr *hwmgr,
 	int ret = 0;
 	uint32_t gen_speed, lane_width, current_gen_speed, current_lane_width;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	switch (type) {
 	case PP_SCLK:
 		ret = vega20_get_current_clk_freq(hwmgr, PPCLK_GFXCLK, &now);
@@ -3479,7 +3483,7 @@ static int vega20_print_clock_levels(struct pp_hwmgr *hwmgr,
 	case OD_SCLK:
 		if (od8_settings[OD8_SETTING_GFXCLK_FMIN].feature_id &&
 		    od8_settings[OD8_SETTING_GFXCLK_FMAX].feature_id) {
-			size = sysfs_emit(buf, "%s:\n", "OD_SCLK");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_SCLK");
 			size += sysfs_emit_at(buf, size, "0: %10uMhz\n",
 				od_table->GfxclkFmin);
 			size += sysfs_emit_at(buf, size, "1: %10uMhz\n",
@@ -3489,7 +3493,7 @@ static int vega20_print_clock_levels(struct pp_hwmgr *hwmgr,
 
 	case OD_MCLK:
 		if (od8_settings[OD8_SETTING_UCLK_FMAX].feature_id) {
-			size = sysfs_emit(buf, "%s:\n", "OD_MCLK");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_MCLK");
 			size += sysfs_emit_at(buf, size, "1: %10uMhz\n",
 				od_table->UclkFmax);
 		}
@@ -3503,7 +3507,7 @@ static int vega20_print_clock_levels(struct pp_hwmgr *hwmgr,
 		    od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].feature_id &&
 		    od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].feature_id &&
 		    od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].feature_id) {
-			size = sysfs_emit(buf, "%s:\n", "OD_VDDC_CURVE");
+			size += sysfs_emit_at(buf, size, "%s:\n", "OD_VDDC_CURVE");
 			size += sysfs_emit_at(buf, size, "0: %10uMhz %10dmV\n",
 				od_table->GfxclkFreq1,
 				od_table->GfxclkVolt1 / VOLTAGE_SCALE);
@@ -3518,7 +3522,7 @@ static int vega20_print_clock_levels(struct pp_hwmgr *hwmgr,
 		break;
 
 	case OD_RANGE:
-		size = sysfs_emit(buf, "%s:\n", "OD_RANGE");
+		size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");
 
 		if (od8_settings[OD8_SETTING_GFXCLK_FMIN].feature_id &&
 		    od8_settings[OD8_SETTING_GFXCLK_FMAX].feature_id) {
@@ -4003,6 +4007,8 @@ static int vega20_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
 	if (!buf)
 		return -EINVAL;
 
+	phm_get_sysfs_buf(&buf, &size);
+
 	size += sysfs_emit_at(buf, size, "%16s %s %s %s %s %s %s %s %s %s %s\n",
 			title[0], title[1], title[2], title[3], title[4], title[5],
 			title[6], title[7], title[8], title[9], title[10]);
commit 7ef6b7f8441f5744ac3fa5e2067b25940ee1ff63
Author: Kent Russell <kent.russell at amd.com>
Date:   Fri Oct 29 13:28:57 2021 -0400

    drm/amdgpu: Make sure to reserve BOs before adding or removing
    
    BOs need to be reserved before they are added or removed, so ensure that
    they are reserved during kfd_mem_attach and kfd_mem_detach
    
    Signed-off-by: Kent Russell <kent.russell at amd.com>
    Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 0e9cfe99ae9e..a00d8acdfb4b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -734,14 +734,19 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,
 		}
 
 		/* Add BO to VM internal data structures */
+		ret = amdgpu_bo_reserve(bo[i], false);
+		if (ret) {
+			pr_debug("Unable to reserve BO during memory attach");
+			goto unwind;
+		}
 		attachment[i]->bo_va = amdgpu_vm_bo_add(adev, vm, bo[i]);
+		amdgpu_bo_unreserve(bo[i]);
 		if (unlikely(!attachment[i]->bo_va)) {
 			ret = -ENOMEM;
 			pr_err("Failed to add BO object to VM. ret == %d\n",
 			       ret);
 			goto unwind;
 		}
-
 		attachment[i]->va = va;
 		attachment[i]->pte_flags = get_pte_flags(adev, mem);
 		attachment[i]->adev = adev;
@@ -757,7 +762,9 @@ unwind:
 		if (!attachment[i])
 			continue;
 		if (attachment[i]->bo_va) {
+			amdgpu_bo_reserve(bo[i], true);
 			amdgpu_vm_bo_rmv(adev, attachment[i]->bo_va);
+			amdgpu_bo_unreserve(bo[i]);
 			list_del(&attachment[i]->list);
 		}
 		if (bo[i])
@@ -1568,12 +1575,12 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
 	pr_debug("Release VA 0x%llx - 0x%llx\n", mem->va,
 		mem->va + bo_size * (1 + mem->aql_queue));
 
-	ret = unreserve_bo_and_vms(&ctx, false, false);
-
 	/* Remove from VM internal data structures */
 	list_for_each_entry_safe(entry, tmp, &mem->attachments, list)
 		kfd_mem_detach(entry);
 
+	ret = unreserve_bo_and_vms(&ctx, false, false);
+
 	/* Free the sync object */
 	amdgpu_sync_free(&mem->sync);
 
commit a6283010e2907a5576f96b839e1a1c82659f137c
Author: Alex Sierra <alex.sierra at amd.com>
Date:   Fri Oct 29 13:30:40 2021 -0500

    drm/amdkfd: avoid recursive lock in migrations back to RAM
    
    [Why]:
    When we call hmm_range_fault to map memory after a migration, we don't
    expect memory to be migrated again as a result of hmm_range_fault. The
    driver ensures that all memory is in GPU-accessible locations so that
    no migration should be needed. However, there is one corner case where
    hmm_range_fault can unexpectedly cause a migration from DEVICE_PRIVATE
    back to system memory due to a write-fault when a system memory page in
    the same range was mapped read-only (e.g. COW). Ranges with individual
    pages in different locations are usually the result of failed page
    migrations (e.g. page lock contention). The unexpected migration back
    to system memory causes a deadlock from recursive locking in our
    driver.
    
    [How]:
    Creating a task reference new member under svm_range_list struct.
    Setting this with "current" reference, right before the hmm_range_fault
    is called. This member is checked against "current" reference at
    svm_migrate_to_ram callback function. If equal, the migration will be
    ignored.
    
    Signed-off-by: Alex Sierra <alex.sierra at amd.com>
    Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
index cc1525095937..aeade32ec298 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -861,6 +861,11 @@ static vm_fault_t svm_migrate_to_ram(struct vm_fault *vmf)
 		pr_debug("failed find process at fault address 0x%lx\n", addr);
 		return VM_FAULT_SIGBUS;
 	}
+	if (READ_ONCE(p->svms.faulting_task) == current) {
+		pr_debug("skipping ram migration\n");
+		kfd_unref_process(p);
+		return 0;
+	}
 	addr >>= PAGE_SHIFT;
 	pr_debug("CPU page fault svms 0x%p address 0x%lx\n", &p->svms, addr);
 
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index 4104b167e721..98f7503bc106 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -768,6 +768,7 @@ struct svm_range_list {
 	atomic_t			evicted_ranges;
 	struct delayed_work		restore_work;
 	DECLARE_BITMAP(bitmap_supported, MAX_GPU_INSTANCE);
+	struct task_struct 		*faulting_task;
 };
 
 /* Process data */
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index a2000a12bed4..381d8d27a55a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1496,9 +1496,11 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
 
 		next = min(vma->vm_end, end);
 		npages = (next - addr) >> PAGE_SHIFT;
+		WRITE_ONCE(p->svms.faulting_task, current);
 		r = amdgpu_hmm_range_get_pages(&prange->notifier, mm, NULL,
 					       addr, npages, &hmm_range,
 					       readonly, true, owner);
+		WRITE_ONCE(p->svms.faulting_task, NULL);
 		if (r) {
 			pr_debug("failed %d to get svm range pages\n", r);
 			goto unreserve_out;
commit 25a1a08fe79be6ef00e1393b1f5545f6ba62919f
Author: Harry Wentland <harry.wentland at amd.com>
Date:   Wed Oct 27 10:26:33 2021 -0400

    drm/amd/display: Don't allow partial copy_from_user
    
    There is no reason to allow for partial buffers from userspace in our
    debugfs. In this particular case callers will zero out the wr_buf but if
    callers in the future don't do that we might be looking at corrupt data.
    
    Linus puts it better than I can in
    https://lkml.org/lkml/2021/10/26/993
    
    Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>
    Signed-off-by: Harry Wentland <harry.wentland at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 3655663e079b..9d43ecb1f692 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -78,12 +78,10 @@ static int parse_write_buffer_into_params(char *wr_buf, uint32_t wr_buf_size,
 
 	wr_buf_ptr = wr_buf;
 
-	r = copy_from_user(wr_buf_ptr, buf, wr_buf_size);
-
-		/* r is bytes not be copied */
-	if (r >= wr_buf_size) {
-		DRM_DEBUG_DRIVER("user data not be read\n");
-		return -EINVAL;
+	/* r is bytes not be copied */
+	if (copy_from_user(wr_buf_ptr, buf, wr_buf_size)) {
+		DRM_DEBUG_DRIVER("user data could not be read successfully\n");
+		return -EFAULT;
 	}
 
 	/* check number of parameters. isspace could not differ space and \n */
commit 14d9a37c952588930d7226953359fea3ab956d39
Author: Fabio Estevam <festevam at gmail.com>
Date:   Wed Nov 3 21:11:12 2021 -0300

    Revert "drm/imx: Annotate dma-fence critical section in commit path"
    
    This reverts commit f4b34faa08428d813fc3629f882c503487f94a12.
    
    Since commit f4b34faa0842 ("drm/imx: Annotate dma-fence critical section in
    commit path") the following possible circular dependency is detected:
    
    [    5.001811] ======================================================
    [    5.001817] WARNING: possible circular locking dependency detected
    [    5.001824] 5.14.9-01225-g45da36cc6fcc-dirty #1 Tainted: G        W
    [    5.001833] ------------------------------------------------------
    [    5.001838] kworker/u8:0/7 is trying to acquire lock:
    [    5.001848] c1752080 (regulator_list_mutex){+.+.}-{3:3}, at: regulator_lock_dependent+0x40/0x294
    [    5.001903]
    [    5.001903] but task is already holding lock:
    [    5.001909] c176df78 (dma_fence_map){++++}-{0:0}, at: imx_drm_atomic_commit_tail+0x10/0x160
    [    5.001957]
    [    5.001957] which lock already depends on the new lock.
    ...
    
    Revert it for now.
    
    Tested on a imx6q-sabresd.
    
    Fixes: f4b34faa0842 ("drm/imx: Annotate dma-fence critical section in commit path")
    Signed-off-by: Fabio Estevam <festevam at gmail.com>
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211104001112.4035691-1-festevam@gmail.com

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 9558e9e1b431..cb685fe2039b 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -81,7 +81,6 @@ static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state)
 	struct drm_plane_state *old_plane_state, *new_plane_state;
 	bool plane_disabling = false;
 	int i;
-	bool fence_cookie = dma_fence_begin_signalling();
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
@@ -112,7 +111,6 @@ static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state)
 	}
 
 	drm_atomic_helper_commit_hw_done(state);
-	dma_fence_end_signalling(fence_cookie);
 }
 
 static const struct drm_mode_config_helper_funcs imx_drm_mode_config_helpers = {
commit 9d6366e743f37d36ef69347924ead7bcc596076e
Author: Arnd Bergmann <arnd at arndb.de>
Date:   Fri Oct 29 14:02:38 2021 +0200

    drm: fb_helper: improve CONFIG_FB dependency
    
    My previous patch correctly addressed the possible link failure, but as
    Jani points out, the dependency is now stricter than it needs to be.
    
    Change it again, to allow DRM_FBDEV_EMULATION to be used when
    DRM_KMS_HELPER and FB are both loadable modules and DRM is linked into
    the kernel.
    
    As a side-effect, the option is now only visible when at least one DRM
    driver makes use of DRM_KMS_HELPER. This is better, because the option
    has no effect otherwise.
    
    Fixes: 606b102876e3 ("drm: fb_helper: fix CONFIG_FB dependency")
    Suggested-by: Acked-by: Jani Nikula <jani.nikula at intel.com>
    Reviewed-by: Javier Martinez Canillas <javierm at redhat.com>
    Signed-off-by: Arnd Bergmann <arnd at arndb.de>
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211029120307.1407047-1-arnd@kernel.org

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index a4c020a9a0eb..0039df26854b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -117,9 +117,8 @@ config DRM_DEBUG_MODESET_LOCK
 
 config DRM_FBDEV_EMULATION
 	bool "Enable legacy fbdev support for your modesetting driver"
-	depends on DRM
-	depends on FB=y || FB=DRM
-	select DRM_KMS_HELPER
+	depends on DRM_KMS_HELPER
+	depends on FB=y || FB=DRM_KMS_HELPER
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
commit e0e6d1ea18c804de51b47fa65092c4cf2000604c
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Thu Oct 28 19:08:57 2021 +0200

    MAINTAINERS: dri-devel is for all of drivers/gpu
    
    Somehow we only have a list of subdirectories, which apparently made
    it harder for folks to find the gpu maintainers. Fix that.
    
    References: https://lore.kernel.org/dri-devel/YXrAAZlxxStNFG%2FK@phenom.ffwll.local/
    Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: David Airlie <airlied at linux.ie>
    Cc: Daniel Vetter <daniel at ffwll.ch>
    Cc: Steven Rostedt <rostedt at goodmis.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211028170857.4029606-1-daniel.vetter@ffwll.ch

diff --git a/MAINTAINERS b/MAINTAINERS
index a1bcf58c7a23..bfda0f80dbff 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6147,8 +6147,7 @@ T:	git git://anongit.freedesktop.org/drm/drm
 F:	Documentation/devicetree/bindings/display/
 F:	Documentation/devicetree/bindings/gpu/
 F:	Documentation/gpu/
-F:	drivers/gpu/drm/
-F:	drivers/gpu/vga/
+F:	drivers/gpu/
 F:	include/drm/
 F:	include/linux/vga*
 F:	include/uapi/drm/
commit 5591c8f79db1729d9c5ac7f5b4d3a5c26e262d93
Author: Johan Hovold <johan at kernel.org>
Date:   Mon Oct 25 13:53:53 2021 +0200

    drm/udl: fix control-message timeout
    
    USB control-message timeouts are specified in milliseconds and should
    specifically not vary with CONFIG_HZ.
    
    Fixes: 5320918b9a87 ("drm/udl: initial UDL driver (v4)")
    Cc: stable at vger.kernel.org      # 3.4
    Signed-off-by: Johan Hovold <johan at kernel.org>
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211025115353.5089-1-johan@kernel.org

diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
index 3750fd216131..930574ad2bca 100644
--- a/drivers/gpu/drm/udl/udl_connector.c
+++ b/drivers/gpu/drm/udl/udl_connector.c
@@ -30,7 +30,7 @@ static int udl_get_edid_block(void *data, u8 *buf, unsigned int block,
 		int bval = (i + block * EDID_LENGTH) << 8;
 		ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
 				      0x02, (0x80 | (0x02 << 5)), bval,
-				      0xA1, read_buff, 2, HZ);
+				      0xA1, read_buff, 2, 1000);
 		if (ret < 1) {
 			DRM_ERROR("Read EDID byte %d failed err %x\n", i, ret);
 			kfree(read_buff);
commit 0d979509539ed1df883a30d442177ca7be609565
Author: Jason Gunthorpe <jgg at nvidia.com>
Date:   Tue Oct 19 20:27:31 2021 -0300

    drm/ttm: remove ttm_bo_vm_insert_huge()
    
    The huge page functionality in TTM does not work safely because PUD and
    PMD entries do not have a special bit.
    
    get_user_pages_fast() considers any page that passed pmd_huge() as
    usable:
    
            if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) ||
                         pmd_devmap(pmd))) {
    
    And vmf_insert_pfn_pmd_prot() unconditionally sets
    
            entry = pmd_mkhuge(pfn_t_pmd(pfn, prot));
    
    eg on x86 the page will be _PAGE_PRESENT | PAGE_PSE.
    
    As such gup_huge_pmd() will try to deref a struct page:
    
            head = try_grab_compound_head(pmd_page(orig), refs, flags);
    
    and thus crash.
    
    Thomas further notices that the drivers are not expecting the struct page
    to be used by anything - in particular the refcount incr above will cause
    them to malfunction.
    
    Thus everything about this is not able to fully work correctly considering
    GUP_fast. Delete it entirely. It can return someday along with a proper
    PMD/PUD_SPECIAL bit in the page table itself to gate GUP_fast.
    
    Fixes: 314b6580adc5 ("drm/ttm, drm/vmwgfx: Support huge TTM pagefaults")
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>
    Reviewed-by: Thomas Hellström <thomas.helllstrom at linux.intel.com>
    Reviewed-by: Christian König <christian.koenig at amd.com>
    [danvet: Update subject per Thomas' &Christian's review]
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/0-v2-a44694790652+4ac-ttm_pmd_jgg@nvidia.com

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index d6aa032890ee..a1e63ba4c54a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -61,7 +61,7 @@ static vm_fault_t amdgpu_gem_fault(struct vm_fault *vmf)
 		}
 
 		 ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot,
-						TTM_BO_VM_NUM_PREFAULT, 1);
+						TTM_BO_VM_NUM_PREFAULT);
 
 		 drm_dev_exit(idx);
 	} else {
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index d476940ee97c..beeafb3bb266 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -56,7 +56,7 @@ static vm_fault_t nouveau_ttm_fault(struct vm_fault *vmf)
 
 	nouveau_bo_del_io_reserve_lru(bo);
 	prot = vm_get_page_prot(vma->vm_flags);
-	ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT, 1);
+	ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT);
 	nouveau_bo_add_io_reserve_lru(bo);
 	if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
 		return ret;
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index 458f92a70887..a36a4f2c76b0 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -61,7 +61,7 @@ static vm_fault_t radeon_gem_fault(struct vm_fault *vmf)
 		goto unlock_resv;
 
 	ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot,
-				       TTM_BO_VM_NUM_PREFAULT, 1);
+				       TTM_BO_VM_NUM_PREFAULT);
 	if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
 		goto unlock_mclk;
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 33680c94127c..08ba083a80d2 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -173,89 +173,6 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,
 }
 EXPORT_SYMBOL(ttm_bo_vm_reserve);
 
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
-/**
- * ttm_bo_vm_insert_huge - Insert a pfn for PUD or PMD faults
- * @vmf: Fault data
- * @bo: The buffer object
- * @page_offset: Page offset from bo start
- * @fault_page_size: The size of the fault in pages.
- * @pgprot: The page protections.
- * Does additional checking whether it's possible to insert a PUD or PMD
- * pfn and performs the insertion.
- *
- * Return: VM_FAULT_NOPAGE on successful insertion, VM_FAULT_FALLBACK if
- * a huge fault was not possible, or on insertion error.
- */
-static vm_fault_t ttm_bo_vm_insert_huge(struct vm_fault *vmf,
-					struct ttm_buffer_object *bo,
-					pgoff_t page_offset,
-					pgoff_t fault_page_size,
-					pgprot_t pgprot)
-{
-	pgoff_t i;
-	vm_fault_t ret;
-	unsigned long pfn;
-	pfn_t pfnt;
-	struct ttm_tt *ttm = bo->ttm;
-	bool write = vmf->flags & FAULT_FLAG_WRITE;
-
-	/* Fault should not cross bo boundary. */
-	page_offset &= ~(fault_page_size - 1);
-	if (page_offset + fault_page_size > bo->resource->num_pages)
-		goto out_fallback;
-
-	if (bo->resource->bus.is_iomem)
-		pfn = ttm_bo_io_mem_pfn(bo, page_offset);
-	else
-		pfn = page_to_pfn(ttm->pages[page_offset]);
-
-	/* pfn must be fault_page_size aligned. */
-	if ((pfn & (fault_page_size - 1)) != 0)
-		goto out_fallback;
-
-	/* Check that memory is contiguous. */
-	if (!bo->resource->bus.is_iomem) {
-		for (i = 1; i < fault_page_size; ++i) {
-			if (page_to_pfn(ttm->pages[page_offset + i]) != pfn + i)
-				goto out_fallback;
-		}
-	} else if (bo->bdev->funcs->io_mem_pfn) {
-		for (i = 1; i < fault_page_size; ++i) {
-			if (ttm_bo_io_mem_pfn(bo, page_offset + i) != pfn + i)
-				goto out_fallback;
-		}
-	}
-
-	pfnt = __pfn_to_pfn_t(pfn, PFN_DEV);
-	if (fault_page_size == (HPAGE_PMD_SIZE >> PAGE_SHIFT))
-		ret = vmf_insert_pfn_pmd_prot(vmf, pfnt, pgprot, write);
-#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
-	else if (fault_page_size == (HPAGE_PUD_SIZE >> PAGE_SHIFT))
-		ret = vmf_insert_pfn_pud_prot(vmf, pfnt, pgprot, write);
-#endif
-	else
-		WARN_ON_ONCE(ret = VM_FAULT_FALLBACK);
-
-	if (ret != VM_FAULT_NOPAGE)
-		goto out_fallback;
-
-	return VM_FAULT_NOPAGE;
-out_fallback:
-	count_vm_event(THP_FAULT_FALLBACK);
-	return VM_FAULT_FALLBACK;
-}
-#else
-static vm_fault_t ttm_bo_vm_insert_huge(struct vm_fault *vmf,
-					struct ttm_buffer_object *bo,
-					pgoff_t page_offset,
-					pgoff_t fault_page_size,
-					pgprot_t pgprot)
-{
-	return VM_FAULT_FALLBACK;
-}
-#endif
-
 /**
  * ttm_bo_vm_fault_reserved - TTM fault helper
  * @vmf: The struct vm_fault given as argument to the fault callback
@@ -263,7 +180,6 @@ static vm_fault_t ttm_bo_vm_insert_huge(struct vm_fault *vmf,
  * @num_prefault: Maximum number of prefault pages. The caller may want to
  * specify this based on madvice settings and the size of the GPU object
  * backed by the memory.
- * @fault_page_size: The size of the fault in pages.
  *
  * This function inserts one or more page table entries pointing to the
  * memory backing the buffer object, and then returns a return code
@@ -277,8 +193,7 @@ static vm_fault_t ttm_bo_vm_insert_huge(struct vm_fault *vmf,
  */
 vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 				    pgprot_t prot,
-				    pgoff_t num_prefault,
-				    pgoff_t fault_page_size)
+				    pgoff_t num_prefault)
 {
 	struct vm_area_struct *vma = vmf->vma;
 	struct ttm_buffer_object *bo = vma->vm_private_data;
@@ -329,11 +244,6 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 		prot = pgprot_decrypted(prot);
 	}
 
-	/* We don't prefault on huge faults. Yet. */
-	if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && fault_page_size != 1)
-		return ttm_bo_vm_insert_huge(vmf, bo, page_offset,
-					     fault_page_size, prot);
-
 	/*
 	 * Speculatively prefault a number of pages. Only error on
 	 * first page.
@@ -429,7 +339,7 @@ vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
 
 	prot = vma->vm_page_prot;
 	if (drm_dev_enter(ddev, &idx)) {
-		ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT, 1);
+		ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT);
 		drm_dev_exit(idx);
 	} else {
 		ret = ttm_bo_vm_dummy_page(vmf, prot);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index a833751099b5..858aff99a3fe 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1550,10 +1550,6 @@ void vmw_bo_dirty_unmap(struct vmw_buffer_object *vbo,
 			pgoff_t start, pgoff_t end);
 vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf);
 vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf);
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
-vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,
-				enum page_entry_size pe_size);
-#endif
 
 /* Transparent hugepage support - vmwgfx_thp.c */
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c b/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c
index e5a9a5cbd01a..922317d1acc8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c
@@ -477,7 +477,7 @@ vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf)
 	else
 		prot = vm_get_page_prot(vma->vm_flags);
 
-	ret = ttm_bo_vm_fault_reserved(vmf, prot, num_prefault, 1);
+	ret = ttm_bo_vm_fault_reserved(vmf, prot, num_prefault);
 	if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
 		return ret;
 
@@ -486,73 +486,3 @@ out_unlock:
 
 	return ret;
 }
-
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
-vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,
-				enum page_entry_size pe_size)
-{
-	struct vm_area_struct *vma = vmf->vma;
-	struct ttm_buffer_object *bo = (struct ttm_buffer_object *)
-	    vma->vm_private_data;
-	struct vmw_buffer_object *vbo =
-		container_of(bo, struct vmw_buffer_object, base);
-	pgprot_t prot;
-	vm_fault_t ret;
-	pgoff_t fault_page_size;
-	bool write = vmf->flags & FAULT_FLAG_WRITE;
-
-	switch (pe_size) {
-	case PE_SIZE_PMD:
-		fault_page_size = HPAGE_PMD_SIZE >> PAGE_SHIFT;
-		break;
-#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
-	case PE_SIZE_PUD:
-		fault_page_size = HPAGE_PUD_SIZE >> PAGE_SHIFT;
-		break;
-#endif
-	default:
-		WARN_ON_ONCE(1);
-		return VM_FAULT_FALLBACK;
-	}
-
-	/* Always do write dirty-tracking and COW on PTE level. */
-	if (write && (READ_ONCE(vbo->dirty) || is_cow_mapping(vma->vm_flags)))
-		return VM_FAULT_FALLBACK;
-
-	ret = ttm_bo_vm_reserve(bo, vmf);
-	if (ret)
-		return ret;
-
-	if (vbo->dirty) {
-		pgoff_t allowed_prefault;
-		unsigned long page_offset;
-
-		page_offset = vmf->pgoff -
-			drm_vma_node_start(&bo->base.vma_node);
-		if (page_offset >= bo->resource->num_pages ||
-		    vmw_resources_clean(vbo, page_offset,
-					page_offset + PAGE_SIZE,
-					&allowed_prefault)) {
-			ret = VM_FAULT_SIGBUS;
-			goto out_unlock;
-		}
-
-		/*
-		 * Write protect, so we get a new fault on write, and can
-		 * split.
-		 */
-		prot = vm_get_page_prot(vma->vm_flags & ~VM_SHARED);
-	} else {
-		prot = vm_get_page_prot(vma->vm_flags);
-	}
-
-	ret = ttm_bo_vm_fault_reserved(vmf, prot, 1, fault_page_size);
-	if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
-		return ret;
-
-out_unlock:
-	dma_resv_unlock(bo->base.resv);
-
-	return ret;
-}
-#endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
index e6b1f98ec99f..0a4c340252ec 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
@@ -61,9 +61,6 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
 		.fault = vmw_bo_vm_fault,
 		.open = ttm_bo_vm_open,
 		.close = ttm_bo_vm_close,
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
-		.huge_fault = vmw_bo_vm_huge_fault,
-#endif
 	};
 	struct drm_file *file_priv = filp->private_data;
 	struct vmw_private *dev_priv = vmw_priv(file_priv->minor->dev);
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 0551e2587f14..cd785cfa3123 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -584,8 +584,7 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,
 
 vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 				    pgprot_t prot,
-				    pgoff_t num_prefault,
-				    pgoff_t fault_page_size);
+				    pgoff_t num_prefault);
 
 vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf);
 
commit 806acd381960008700c15c3dc616d578e9558853
Merge: 5275a99e35e5 78469728809b
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Nov 5 15:14:17 2021 +1000

    Merge tag 'amd-drm-fixes-5.16-2021-11-03' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
    
    amd-drm-fixes-5.16-2021-11-03:
    
    amdgpu:
    - GPU reset fix
    - Aldebaran fix
    - Yellow Carp fixes
    - DCN2.1 DMCUB fix
    - IOMMU regression fix for Picasso
    - DSC display fixes
    - BPC display calculation fixes
    - Other misc display fixes
    
    amdkfd:
    - SVM fixes
    - Fix gfx version for renoir
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    From: Alex Deucher <alexander.deucher at amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211104024447.4535-1-alexander.deucher@amd.com

commit 5275a99e35e5a1d1f68038b0560d0e7eaf624e86
Merge: d9bd054177fb b3ec8cdf457e
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Nov 5 13:50:09 2021 +1000

    Merge tag 'drm-misc-next-2021-10-14' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
    
    drm-misc-next for 5.16:
    
    UAPI Changes:
    
    Cross-subsystem Changes:
    
    Core Changes:
      - fbdev: Fix double-free, Remove unused scrolling acceleration
      - locking: improve logging for contented locks without backoff
      - dma-buf: Add dma_resv_for_each_fence iterator, and conversion of
        users
    
    Driver Changes:
      - nouveau: Various code style improvements
      - bridge: HPD improvements for lt9611uxc, eDP aux-bus support for
        ps8640, lvds-codec data-mapping selection support
      - panels: Vivax TPC-9150, Innolux G070Y2-T02, LOGIC Technologies
        LTTD800480070-L2RT, Sharp LS060T1SX01,
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    
    From: Maxime Ripard <maxime at cerno.tech>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211014120452.2wicnt6hobu3kbwb@gilmour

commit f55aaf63bde0d0336c3823bb3713bd4a464abbcf
Author: Jeremy Cline <jcline at redhat.com>
Date:   Wed Nov 25 15:26:48 2020 -0500

    drm/nouveau: clean up all clients on device removal
    
    The postclose handler can run after the device has been removed (or the
    driver has been unbound) since userspace clients are free to hold the
    file open as long as they want. Because the device removal callback
    frees the entire nouveau_drm structure, any reference to it in the
    postclose handler will result in a use-after-free.
    
    To reproduce this, one must simply open the device file, unbind the
    driver (or physically remove the device), and then close the device
    file. This was found and can be reproduced easily with the IGT
    core_hotunplug tests.
    
    To avoid this, all clients are cleaned up in the device finalization
    rather than deferring it to the postclose handler, and the postclose
    handler is protected by a critical section which ensures the
    drm_dev_unplug() and the postclose handler won't race.
    
    This is not an ideal fix, since as I understand the proposed plan for
    the kernel<->userspace interface for hotplug support, destroying the
    client before the file is closed will cause problems. However, I believe
    to properly fix this issue, the lifetime of the nouveau_drm structure
    needs to be extended to match the drm_device, and this proved to be a
    rather invasive change. Thus, I've broken this out so the fix can be
    easily backported.
    
    This fixes with the two previous commits CVE-2020-27820 (Karol).
    
    Cc: stable at vger.kernel.org # 5.4+
    Signed-off-by: Jeremy Cline <jcline at redhat.com>
    Reviewed-by: Lyude Paul <lyude at redhat.com>
    Reviewed-by: Ben Skeggs <bskeggs at redhat.com>
    Tested-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20201125202648.5220-4-jcline@redhat.com
    Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/14

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 4c69ac2a8295..e7efd9ede8e4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -633,6 +633,7 @@ fail_alloc:
 static void
 nouveau_drm_device_fini(struct drm_device *dev)
 {
+	struct nouveau_cli *cli, *temp_cli;
 	struct nouveau_drm *drm = nouveau_drm(dev);
 
 	if (nouveau_pmops_runtime()) {
@@ -657,6 +658,24 @@ nouveau_drm_device_fini(struct drm_device *dev)
 	nouveau_ttm_fini(drm);
 	nouveau_vga_fini(drm);
 
+	/*
+	 * There may be existing clients from as-yet unclosed files. For now,
+	 * clean them up here rather than deferring until the file is closed,
+	 * but this likely not correct if we want to support hot-unplugging
+	 * properly.
+	 */
+	mutex_lock(&drm->clients_lock);
+	list_for_each_entry_safe(cli, temp_cli, &drm->clients, head) {
+		list_del(&cli->head);
+		mutex_lock(&cli->mutex);
+		if (cli->abi16)
+			nouveau_abi16_fini(cli->abi16);
+		mutex_unlock(&cli->mutex);
+		nouveau_cli_fini(cli);
+		kfree(cli);
+	}
+	mutex_unlock(&drm->clients_lock);
+
 	nouveau_cli_fini(&drm->client);
 	nouveau_cli_fini(&drm->master);
 	nvif_parent_dtor(&drm->parent);
@@ -1112,6 +1131,16 @@ nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
 {
 	struct nouveau_cli *cli = nouveau_cli(fpriv);
 	struct nouveau_drm *drm = nouveau_drm(dev);
+	int dev_index;
+
+	/*
+	 * The device is gone, and as it currently stands all clients are
+	 * cleaned up in the removal codepath. In the future this may change
+	 * so that we can support hot-unplugging, but for now we immediately
+	 * return to avoid a double-free situation.
+	 */
+	if (!drm_dev_enter(dev, &dev_index))
+		return;
 
 	pm_runtime_get_sync(dev->dev);
 
@@ -1128,6 +1157,7 @@ nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
 	kfree(cli);
 	pm_runtime_mark_last_busy(dev->dev);
 	pm_runtime_put_autosuspend(dev->dev);
+	drm_dev_exit(dev_index);
 }
 
 static const struct drm_ioctl_desc
commit abae9164a421bc4a41a3769f01ebcd1f9d955e0e
Author: Jeremy Cline <jcline at redhat.com>
Date:   Wed Nov 25 15:26:47 2020 -0500

    drm/nouveau: Add a dedicated mutex for the clients list
    
    Rather than protecting the nouveau_drm clients list with the lock within
    the "client" nouveau_cli, add a dedicated lock to serialize access to
    the list. This is both clearer and necessary to avoid lockdep being
    upset with us when we need to iterate through all the clients in the
    list and potentially lock their mutex, which is the same class as the
    lock protecting the entire list.
    
    Cc: stable at vger.kernel.org # 5.4+
    Signed-off-by: Jeremy Cline <jcline at redhat.com>
    Reviewed-by: Lyude Paul <lyude at redhat.com>
    Reviewed-by: Ben Skeggs <bskeggs at redhat.com>
    Tested-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20201125202648.5220-3-jcline@redhat.com
    Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/14

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 96490cc855cc..4c69ac2a8295 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -562,6 +562,7 @@ nouveau_drm_device_init(struct drm_device *dev)
 		nvkm_dbgopt(nouveau_debug, "DRM");
 
 	INIT_LIST_HEAD(&drm->clients);
+	mutex_init(&drm->clients_lock);
 	spin_lock_init(&drm->tile.lock);
 
 	/* workaround an odd issue on nvc1 by disabling the device's
@@ -659,6 +660,7 @@ nouveau_drm_device_fini(struct drm_device *dev)
 	nouveau_cli_fini(&drm->client);
 	nouveau_cli_fini(&drm->master);
 	nvif_parent_dtor(&drm->parent);
+	mutex_destroy(&drm->clients_lock);
 	kfree(drm);
 }
 
@@ -1090,9 +1092,9 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
 
 	fpriv->driver_priv = cli;
 
-	mutex_lock(&drm->client.mutex);
+	mutex_lock(&drm->clients_lock);
 	list_add(&cli->head, &drm->clients);
-	mutex_unlock(&drm->client.mutex);
+	mutex_unlock(&drm->clients_lock);
 
 done:
 	if (ret && cli) {
@@ -1118,9 +1120,9 @@ nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
 		nouveau_abi16_fini(cli->abi16);
 	mutex_unlock(&cli->mutex);
 
-	mutex_lock(&drm->client.mutex);
+	mutex_lock(&drm->clients_lock);
 	list_del(&cli->head);
-	mutex_unlock(&drm->client.mutex);
+	mutex_unlock(&drm->clients_lock);
 
 	nouveau_cli_fini(cli);
 	kfree(cli);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index ba65f136cf48..b2a970aa9bf4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -139,6 +139,11 @@ struct nouveau_drm {
 
 	struct list_head clients;
 
+	/**
+	 * @clients_lock: Protects access to the @clients list of &struct nouveau_cli.
+	 */
+	struct mutex clients_lock;
+
 	u8 old_pm_cap;
 
 	struct {
commit aff2299e0d81b26304ccc6a1ec0170e437f38efc
Author: Jeremy Cline <jcline at redhat.com>
Date:   Wed Nov 25 15:26:46 2020 -0500

    drm/nouveau: use drm_dev_unplug() during device removal
    
    Nouveau does not currently support hot-unplugging, but it still makes
    sense to switch from drm_dev_unregister() to drm_dev_unplug().
    drm_dev_unplug() calls drm_dev_unregister() after marking the device as
    unplugged, but only after any device critical sections are finished.
    
    Since nouveau isn't using drm_dev_enter() and drm_dev_exit(), there are
    no critical sections so this is nearly functionally equivalent. However,
    the DRM layer does check to see if the device is unplugged, and if it is
    returns appropriate error codes.
    
    In the future nouveau can add critical sections in order to truly
    support hot-unplugging.
    
    Cc: stable at vger.kernel.org # 5.4+
    Signed-off-by: Jeremy Cline <jcline at redhat.com>
    Reviewed-by: Lyude Paul <lyude at redhat.com>
    Reviewed-by: Ben Skeggs <bskeggs at redhat.com>
    Tested-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20201125202648.5220-2-jcline@redhat.com
    Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/14

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 6109cd9e3399..96490cc855cc 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -796,7 +796,7 @@ nouveau_drm_device_remove(struct drm_device *dev)
 	struct nvkm_client *client;
 	struct nvkm_device *device;
 
-	drm_dev_unregister(dev);
+	drm_dev_unplug(dev);
 
 	client = nvxx_client(&drm->client.base);
 	device = nvkm_device_find(client->device);
commit 6bb8c2d51811eb5e6504f49efe3b089d026009d2
Author: Chenyuan Mi <cymi20 at fudan.edu.cn>
Date:   Tue Sep 7 20:26:33 2021 +0800

    drm/nouveau/svm: Fix refcount leak bug and missing check against null bug
    
    The reference counting issue happens in one exception handling path of
    nouveau_svmm_bind(). When cli->svm.svmm is null, the function forgets
    to decrease the refcount of mm increased by get_task_mm(), causing a
    refcount leak.
    
    Fix this issue by using mmput() to decrease the refcount in the
    exception handling path.
    
    Also, the function forgets to do check against null when get mm
    by get_task_mm().
    
    Fix this issue by adding null check after get mm by get_task_mm().
    
    Signed-off-by: Chenyuan Mi <cymi20 at fudan.edu.cn>
    Signed-off-by: Xiyu Yang <xiyuyang19 at fudan.edu.cn>
    Signed-off-by: Xin Tan <tanxin.ctf at gmail.com>
    Fixes: 822cab6150d3 ("drm/nouveau/svm: check for SVM initialized before migrating")
    Reviewed-by: Lyude Paul <lyude at redhat.com>
    Reviewed-by: Ben Skeggs <bskeggs at redhat.com>
    Reviewed-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210907122633.16665-1-cymi20@fudan.edu.cn
    Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/14

diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index b0c3422cb01f..9985bfde015a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -162,10 +162,14 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
 	 */
 
 	mm = get_task_mm(current);
+	if (!mm) {
+		return -EINVAL;
+	}
 	mmap_read_lock(mm);
 
 	if (!cli->svm.svmm) {
 		mmap_read_unlock(mm);
+		mmput(mm);
 		return -EINVAL;
 	}
 
commit ff2d23843f7fb4f13055be5a4a9a20ddd04e6e9c
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Jul 23 09:58:57 2021 +0200

    dma-buf/poll: Get a file reference for outstanding fence callbacks
    
    This makes sure we don't hit the
    
            BUG_ON(dmabuf->cb_in.active || dmabuf->cb_out.active);
    
    in dma_buf_release, which could be triggered by user space closing the
    dma-buf file description while there are outstanding fence callbacks
    from dma_buf_poll.
    
    Cc: stable at vger.kernel.org
    Signed-off-by: Michel Dänzer <mdaenzer at redhat.com>
    Reviewed-by: Christian König <christian.koenig at amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210723075857.4065-1-michel@daenzer.net
    Signed-off-by: Christian König <christian.koenig at amd.com>

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index beb504a92d60..35fe1cb5ad98 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -67,12 +67,9 @@ static void dma_buf_release(struct dentry *dentry)
 	BUG_ON(dmabuf->vmapping_counter);
 
 	/*
-	 * Any fences that a dma-buf poll can wait on should be signaled
-	 * before releasing dma-buf. This is the responsibility of each
-	 * driver that uses the reservation objects.
-	 *
-	 * If you hit this BUG() it means someone dropped their ref to the
-	 * dma-buf while still having pending operation to the buffer.
+	 * If you hit this BUG() it could mean:
+	 * * There's a file reference imbalance in dma_buf_poll / dma_buf_poll_cb or somewhere else
+	 * * dmabuf->cb_in/out.active are non-0 despite no pending fence callback
 	 */
 	BUG_ON(dmabuf->cb_in.active || dmabuf->cb_out.active);
 
@@ -200,6 +197,7 @@ static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)
 static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
 {
 	struct dma_buf_poll_cb_t *dcb = (struct dma_buf_poll_cb_t *)cb;
+	struct dma_buf *dmabuf = container_of(dcb->poll, struct dma_buf, poll);
 	unsigned long flags;
 
 	spin_lock_irqsave(&dcb->poll->lock, flags);
@@ -207,6 +205,8 @@ static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
 	dcb->active = 0;
 	spin_unlock_irqrestore(&dcb->poll->lock, flags);
 	dma_fence_put(fence);
+	/* Paired with get_file in dma_buf_poll */
+	fput(dmabuf->file);
 }
 
 static bool dma_buf_poll_add_cb(struct dma_resv *resv, bool write,
@@ -259,6 +259,9 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
 		spin_unlock_irq(&dmabuf->poll.lock);
 
 		if (events & EPOLLOUT) {
+			/* Paired with fput in dma_buf_poll_cb */
+			get_file(dmabuf->file);
+
 			if (!dma_buf_poll_add_cb(resv, true, dcb))
 				/* No callback queued, wake up any other waiters */
 				dma_buf_poll_cb(NULL, &dcb->cb);
@@ -279,6 +282,9 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
 		spin_unlock_irq(&dmabuf->poll.lock);
 
 		if (events & EPOLLIN) {
+			/* Paired with fput in dma_buf_poll_cb */
+			get_file(dmabuf->file);
+
 			if (!dma_buf_poll_add_cb(resv, false, dcb))
 				/* No callback queued, wake up any other waiters */
 				dma_buf_poll_cb(NULL, &dcb->cb);
commit 93f43ed81abec8c805e1b77eb1d20dbc51a24dc4
Author: Ben Skeggs <bskeggs at redhat.com>
Date:   Wed Nov 3 11:10:57 2021 +1000

    ce/gf100: fix incorrect CE0 address calculation on some GPUs
    
    The code which constructs the modules for each engine present on the GPU
    passes -1 for 'instance' on non-instanced engines, which affects how the
    name for a sub-device is generated.  This is then stored as 'instance 0'
    in nvkm_subdev.inst, so code can potentially be shared with earlier GPUs
    that only had a single instance of an engine.
    
    However, GF100's CE constructor uses this value to calculate the address
    of its falcon before it's translated, resulting in CE0 getting the wrong
    address.
    
    This slightly modifies the approach, always passing a valid instance for
    engines that *can* have multiple copies, and having the code for earlier
    GPUs explicitly ask for non-instanced name generation.
    
    Bug: https://gitlab.freedesktop.org/drm/nouveau/-/issues/91
    
    Fixes: 50551b15c760 ("drm/nouveau/ce: switch to instanced constructor")
    Cc: <stable at vger.kernel.org> # v5.12+
    Signed-off-by: Ben Skeggs <bskeggs at redhat.com>
    Reviewed-by: Karol Herbst <kherbst at redhat.com>
    Tested-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211103011057.15344-1-skeggsb@gmail.com

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/ce/gt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/ce/gt215.c
index 704df0f2d1f1..09a112af2f89 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/ce/gt215.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/ce/gt215.c
@@ -78,6 +78,6 @@ int
 gt215_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
 	     struct nvkm_engine **pengine)
 {
-	return nvkm_falcon_new_(&gt215_ce, device, type, inst,
+	return nvkm_falcon_new_(&gt215_ce, device, type, -1,
 				(device->chipset != 0xaf), 0x104000, pengine);
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
index ca75c5f6ecaf..b51d690f375f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
@@ -3147,8 +3147,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 	WARN_ON(device->chip->ptr.inst & ~((1 << ARRAY_SIZE(device->ptr)) - 1));             \
 	for (j = 0; device->chip->ptr.inst && j < ARRAY_SIZE(device->ptr); j++) {            \
 		if ((device->chip->ptr.inst & BIT(j)) && (subdev_mask & BIT_ULL(type))) {    \
-			int inst = (device->chip->ptr.inst == 1) ? -1 : (j);                 \
-			ret = device->chip->ptr.ctor(device, (type), inst, &device->ptr[j]); \
+			ret = device->chip->ptr.ctor(device, (type), (j), &device->ptr[j]);  \
 			subdev = nvkm_device_subdev(device, (type), (j));                    \
 			if (ret) {                                                           \
 				nvkm_subdev_del(&subdev);                                    \
commit 78469728809b8604dc37ae4e6b12ae12decac5be
Author: Aric Cyr <aric.cyr at amd.com>
Date:   Sun Oct 24 16:57:45 2021 -0400

    drm/amd/display: 3.2.160
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Aric Cyr <aric.cyr at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index e9bac161fd25..3aac3f4a2852 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -47,7 +47,7 @@ struct aux_payload;
 struct set_config_cmd_payload;
 struct dmub_notification;
 
-#define DC_VER "3.2.159"
+#define DC_VER "3.2.160"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
commit 904b78298066707286c2e9517625f4e2ea74ee90
Author: Anthony Koo <Anthony.Koo at amd.com>
Date:   Sun Oct 24 11:20:03 2021 -0400

    drm/amd/display: [FW Promotion] Release 0.0.91
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Anthony Koo <Anthony.Koo at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index 0293c58f0701..c29a67ccef17 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -46,10 +46,10 @@
 
 /* Firmware versioning. */
 #ifdef DMUB_EXPOSE_VERSION
-#define DMUB_FW_VERSION_GIT_HASH 0x9525efb5
+#define DMUB_FW_VERSION_GIT_HASH 0x1d82d23e
 #define DMUB_FW_VERSION_MAJOR 0
 #define DMUB_FW_VERSION_MINOR 0
-#define DMUB_FW_VERSION_REVISION 90
+#define DMUB_FW_VERSION_REVISION 91
 #define DMUB_FW_VERSION_TEST 0
 #define DMUB_FW_VERSION_VBIOS 0
 #define DMUB_FW_VERSION_HOTFIX 0
commit a81ddb758c3956f74cc9901c4eeefb11ad84a515
Author: Aurabindo Pillai <aurabindo.pillai at amd.com>
Date:   Wed Oct 27 09:50:59 2021 -0400

    drm/amd/display: add condition check for dmub notification
    
    [Why & How]
    In order to have dc_enable_dmub_notifications() more precise, add
    one more condition to check if dc->debug.dpia_debug.bits.disable_dpia
    is false.
    
    Signed-off-by: Meenakshikumar Somasundaram <meenakshikumar.somasundaram at amd.com>
    Signed-off-by: Wayne Lin <Wayne.Lin at amd.com>
    Signed-off-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 11a00e4d9e81..398de46fb7e4 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -3608,7 +3608,8 @@ bool dc_enable_dmub_notifications(struct dc *dc)
 #if defined(CONFIG_DRM_AMD_DC_DCN)
 	/* YELLOW_CARP B0 USB4 DPIA needs dmub notifications for interrupts */
 	if (dc->ctx->asic_id.chip_family == FAMILY_YELLOW_CARP &&
-	    dc->ctx->asic_id.hw_internal_rev == YELLOW_CARP_B0)
+	    dc->ctx->asic_id.hw_internal_rev == YELLOW_CARP_B0 &&
+	    !dc->debug.dpia_debug.bits.disable_dpia)
 		return true;
 #endif
 	/* dmub aux needs dmub notifications to be enabled */
commit cd8cfbca6ecb74e9968c8e8613e0480bf090a394
Author: Jake Wang <haonan.wang2 at amd.com>
Date:   Thu Oct 7 14:04:33 2021 -0400

    drm/amd/display: Added new DMUB boot option for power optimization
    
    [Why]
    During Z10, root clock gating and memory low power registers needs to
    to be restored if optimization is enabled in driver.
    
    [How]
    Added new DMUB boot option for root clock gating and memory low power.
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Jake Wang <haonan.wang2 at amd.com>
    Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dmub/dmub_srv.h b/drivers/gpu/drm/amd/display/dmub/dmub_srv.h
index 717c0e572d2f..cd204eef073b 100644
--- a/drivers/gpu/drm/amd/display/dmub/dmub_srv.h
+++ b/drivers/gpu/drm/amd/display/dmub/dmub_srv.h
@@ -238,6 +238,7 @@ struct dmub_srv_hw_params {
 	bool load_inst_const;
 	bool skip_panel_power_sequence;
 	bool disable_z10;
+	bool power_optimization;
 	bool dpia_supported;
 	bool disable_dpia;
 };
diff --git a/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c b/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
index 10ebf20eaa41..fa0569174aec 100644
--- a/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
+++ b/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
@@ -340,6 +340,7 @@ void dmub_dcn31_enable_dmub_boot_options(struct dmub_srv *dmub, const struct dmu
 	boot_options.bits.z10_disable = params->disable_z10;
 	boot_options.bits.dpia_supported = params->dpia_supported;
 	boot_options.bits.enable_dpia = params->disable_dpia ? 0 : 1;
+	boot_options.bits.power_optimization = params->power_optimization;
 
 	boot_options.bits.sel_mux_phy_c_d_phy_f_g = (dmub->asic == DMUB_ASIC_DCN31B) ? 1 : 0;
 
commit 9959125a0aab6fe445b9c44573022c056eb1ba8c
Author: Jake Wang <haonan.wang2 at amd.com>
Date:   Wed Oct 13 14:39:41 2021 -0400

    drm/amd/display: Add MPC meory shutdown support
    
    [Why & How]
    The MPC memory clocks should be powered down when not in use.
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Jake Wang <haonan.wang2 at amd.com>
    Reviewed-by: Eric Yang <eric.yang2 at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c
index a82319f4d081..95149734378b 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c
@@ -1381,13 +1381,11 @@ int mpcc3_release_rmu(struct mpc *mpc, int mpcc_id)
 
 }
 
-static void mpc3_mpc_init(struct mpc *mpc)
+static void mpc3_set_mpc_mem_lp_mode(struct mpc *mpc)
 {
 	struct dcn30_mpc *mpc30 = TO_DCN30_MPC(mpc);
 	int mpcc_id;
 
-	mpc1_mpc_init(mpc);
-
 	if (mpc->ctx->dc->debug.enable_mem_low_power.bits.mpc) {
 		if (mpc30->mpc_mask->MPC_RMU0_MEM_LOW_PWR_MODE && mpc30->mpc_mask->MPC_RMU1_MEM_LOW_PWR_MODE) {
 			REG_UPDATE(MPC_RMU_MEM_PWR_CTRL, MPC_RMU0_MEM_LOW_PWR_MODE, 3);
@@ -1405,7 +1403,7 @@ const struct mpc_funcs dcn30_mpc_funcs = {
 	.read_mpcc_state = mpc1_read_mpcc_state,
 	.insert_plane = mpc1_insert_plane,
 	.remove_mpcc = mpc1_remove_mpcc,
-	.mpc_init = mpc3_mpc_init,
+	.mpc_init = mpc1_mpc_init,
 	.mpc_init_single_inst = mpc1_mpc_init_single_inst,
 	.update_blending = mpc2_update_blending,
 	.cursor_lock = mpc1_cursor_lock,
@@ -1432,6 +1430,7 @@ const struct mpc_funcs dcn30_mpc_funcs = {
 	.power_on_mpc_mem_pwr = mpc3_power_on_ogam_lut,
 	.get_mpc_out_mux = mpc1_get_mpc_out_mux,
 	.set_bg_color = mpc1_set_bg_color,
+	.set_mpc_mem_lp_mode = mpc3_set_mpc_mem_lp_mode,
 };
 
 void dcn30_mpc_construct(struct dcn30_mpc *mpc30,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
index 1b089893460a..5dd1ce9ddb53 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
@@ -66,6 +66,45 @@
 #define FN(reg_name, field_name) \
 	hws->shifts->field_name, hws->masks->field_name
 
+static void enable_memory_low_power(struct dc *dc)
+{
+	struct dce_hwseq *hws = dc->hwseq;
+	int i;
+
+	if (dc->debug.enable_mem_low_power.bits.dmcu) {
+		// Force ERAM to shutdown if DMCU is not enabled
+		if (dc->debug.disable_dmcu || dc->config.disable_dmcu) {
+			REG_UPDATE(DMU_MEM_PWR_CNTL, DMCU_ERAM_MEM_PWR_FORCE, 3);
+		}
+	}
+
+	// Set default OPTC memory power states
+	if (dc->debug.enable_mem_low_power.bits.optc) {
+		// Shutdown when unassigned and light sleep in VBLANK
+		REG_SET_2(ODM_MEM_PWR_CTRL3, 0, ODM_MEM_UNASSIGNED_PWR_MODE, 3, ODM_MEM_VBLANK_PWR_MODE, 1);
+	}
+
+	if (dc->debug.enable_mem_low_power.bits.vga) {
+		// Power down VGA memory
+		REG_UPDATE(MMHUBBUB_MEM_PWR_CNTL, VGA_MEM_PWR_FORCE, 1);
+	}
+
+	if (dc->debug.enable_mem_low_power.bits.mpc)
+		dc->res_pool->mpc->funcs->set_mpc_mem_lp_mode(dc->res_pool->mpc);
+
+
+	if (dc->debug.enable_mem_low_power.bits.vpg && dc->res_pool->stream_enc[0]->vpg->funcs->vpg_powerdown) {
+		// Power down VPGs
+		for (i = 0; i < dc->res_pool->stream_enc_count; i++)
+			dc->res_pool->stream_enc[i]->vpg->funcs->vpg_powerdown(dc->res_pool->stream_enc[i]->vpg);
+#if defined(CONFIG_DRM_AMD_DC_DCN)
+		for (i = 0; i < dc->res_pool->hpo_dp_stream_enc_count; i++)
+			dc->res_pool->hpo_dp_stream_enc[i]->vpg->funcs->vpg_powerdown(dc->res_pool->hpo_dp_stream_enc[i]->vpg);
+#endif
+	}
+
+}
+
 void dcn31_init_hw(struct dc *dc)
 {
 	struct abm **abms = dc->res_pool->multiple_abms;
@@ -108,35 +147,7 @@ void dcn31_init_hw(struct dc *dc)
 	if (res_pool->dccg->funcs->dccg_init)
 		res_pool->dccg->funcs->dccg_init(res_pool->dccg);
 
-	if (dc->debug.enable_mem_low_power.bits.dmcu) {
-		// Force ERAM to shutdown if DMCU is not enabled
-		if (dc->debug.disable_dmcu || dc->config.disable_dmcu) {
-			REG_UPDATE(DMU_MEM_PWR_CNTL, DMCU_ERAM_MEM_PWR_FORCE, 3);
-		}
-	}
-
-	// Set default OPTC memory power states
-	if (dc->debug.enable_mem_low_power.bits.optc) {
-		// Shutdown when unassigned and light sleep in VBLANK
-		REG_SET_2(ODM_MEM_PWR_CTRL3, 0, ODM_MEM_UNASSIGNED_PWR_MODE, 3, ODM_MEM_VBLANK_PWR_MODE, 1);
-	}
-
-	if (dc->debug.enable_mem_low_power.bits.vga) {
-		// Power down VGA memory
-		REG_UPDATE(MMHUBBUB_MEM_PWR_CNTL, VGA_MEM_PWR_FORCE, 1);
-	}
-
-#if defined(CONFIG_DRM_AMD_DC_DCN)
-	if (dc->debug.enable_mem_low_power.bits.vpg && dc->res_pool->stream_enc[0]->vpg->funcs->vpg_powerdown) {
-		// Power down VPGs
-		for (i = 0; i < dc->res_pool->stream_enc_count; i++)
-			dc->res_pool->stream_enc[i]->vpg->funcs->vpg_powerdown(dc->res_pool->stream_enc[i]->vpg);
-#if defined(CONFIG_DRM_AMD_DC_DP2_0)
-		for (i = 0; i < dc->res_pool->hpo_dp_stream_enc_count; i++)
-			dc->res_pool->hpo_dp_stream_enc[i]->vpg->funcs->vpg_powerdown(dc->res_pool->hpo_dp_stream_enc[i]->vpg);
-#endif
-	}
-#endif
+	enable_memory_low_power(dc);
 
 	if (dc->ctx->dc_bios->fw_info_valid) {
 		res_pool->ref_clocks.xtalin_clock_inKhz =
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h b/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h
index 04d6ec3f021f..f5fd2a067323 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h
@@ -367,6 +367,7 @@ struct mpc_funcs {
 	void (*set_bg_color)(struct mpc *mpc,
 			struct tg_color *bg_color,
 			int mpcc_id);
+	void (*set_mpc_mem_lp_mode)(struct mpc *mpc);
 };
 
 #endif
commit 0a068b683c87a85351a06017932fb0d4ec8d6b4b
Author: Jake Wang <haonan.wang2 at amd.com>
Date:   Thu Oct 21 19:10:17 2021 -0400

    drm/amd/display: Added HPO HW control shutdown support
    
    [Why]
    HPO is only used for DP2.0. HPO HW control should be
    disable when not being used to save power.
    
    [How]
    Shutdown HPO HW control during init hw.
    Shutdown HPO HW control during stream disable.
    Enable HPO HW control during stream enable if DP2.0.
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Jake Wang <haonan.wang2 at amd.com>
    Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index a5339796902a..e9bac161fd25 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -675,6 +675,7 @@ struct dc_debug_options {
 #endif
 	union mem_low_power_enable_options enable_mem_low_power;
 	union root_clock_optimization_options root_clock_optimization;
+	bool hpo_optimization;
 	bool force_vblank_alignment;
 
 	/* Enable dmub aux for legacy ddc */
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
index 989f5b6907e2..a3fee929cd12 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
@@ -671,6 +671,7 @@ struct dce_hwseq_registers {
 	uint32_t MC_VM_FB_LOCATION_BASE;
 	uint32_t MC_VM_FB_LOCATION_TOP;
 	uint32_t MC_VM_FB_OFFSET;
+	uint32_t HPO_TOP_HW_CONTROL;
 };
  /* set field name */
 #define HWS_SF(blk_name, reg_name, field_name, post_fix)\
@@ -1152,7 +1153,8 @@ struct dce_hwseq_registers {
 	type DOMAIN_PGFSM_PWR_STATUS;\
 	type HPO_HDMISTREAMCLK_G_GATE_DIS;\
 	type DISABLE_HOSTVM_FORCE_ALLOW_PSTATE;\
-	type I2C_LIGHT_SLEEP_FORCE;
+	type I2C_LIGHT_SLEEP_FORCE;\
+	type HPO_IO_EN;
 
 struct dce_hwseq_shift {
 	HWSEQ_REG_FIELD_LIST(uint8_t)
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
index af3e68d3e747..24e47df526f6 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
@@ -1244,6 +1244,12 @@ void dce110_disable_stream(struct pipe_ctx *pipe_ctx)
 #endif
 	if (dc_is_dp_signal(pipe_ctx->stream->signal))
 		dp_source_sequence_trace(link, DPCD_SOURCE_SEQ_AFTER_DISCONNECT_DIG_FE_BE);
+
+#if defined(CONFIG_DRM_AMD_DC_DCN)
+	if (dc->hwseq->funcs.setup_hpo_hw_control && is_dp_128b_132b_signal(pipe_ctx))
+		dc->hwseq->funcs.setup_hpo_hw_control(dc->hwseq, false);
+#endif
+
 }
 
 void dce110_unblank_stream(struct pipe_ctx *pipe_ctx,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
index cfee456c6c9a..4f88376a118f 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
@@ -2397,6 +2397,9 @@ void dcn20_enable_stream(struct pipe_ctx *pipe_ctx)
 	 * BY this, it is logic clean to separate stream and link
 	 */
 	if (is_dp_128b_132b_signal(pipe_ctx)) {
+		if (pipe_ctx->stream->ctx->dc->hwseq->funcs.setup_hpo_hw_control)
+			pipe_ctx->stream->ctx->dc->hwseq->funcs.setup_hpo_hw_control(
+				pipe_ctx->stream->ctx->dc->hwseq, true);
 		setup_dp_hpo_stream(pipe_ctx, true);
 		pipe_ctx->stream_res.hpo_dp_stream_enc->funcs->enable_stream(
 				pipe_ctx->stream_res.hpo_dp_stream_enc);
diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
index d24ad7754d71..1b089893460a 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
@@ -264,6 +264,9 @@ void dcn31_init_hw(struct dc *dc)
 	if (dc->debug.enable_mem_low_power.bits.i2c)
 		REG_UPDATE(DIO_MEM_PWR_CTRL, I2C_LIGHT_SLEEP_FORCE, 1);
 
+	if (hws->funcs.setup_hpo_hw_control)
+		hws->funcs.setup_hpo_hw_control(hws, false);
+
 	if (!dc->debug.disable_clock_gate) {
 		/* enable all DCN clock gating */
 		REG_WRITE(DCCG_GATE_DISABLE_CNTL, 0);
@@ -597,3 +600,9 @@ void dcn31_reset_hw_ctx_wrap(
 	/* New dc_state in the process of being applied to hardware. */
 	dc->current_state->res_ctx.link_enc_cfg_ctx.mode = LINK_ENC_CFG_TRANSIENT;
 }
+
+void dcn31_setup_hpo_hw_control(const struct dce_hwseq *hws, bool enable)
+{
+	if (hws->ctx->dc->debug.hpo_optimization)
+		REG_UPDATE(HPO_TOP_HW_CONTROL, HPO_IO_EN, !!enable);
+}
diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.h b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.h
index 7ae45dd202d9..edfc01d6ad73 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.h
@@ -54,5 +54,6 @@ void dcn31_reset_hw_ctx_wrap(
 bool dcn31_is_abm_supported(struct dc *dc,
 		struct dc_state *context, struct dc_stream_state *stream);
 void dcn31_init_pipes(struct dc *dc, struct dc_state *context);
+void dcn31_setup_hpo_hw_control(const struct dce_hwseq *hws, bool enable);
 
 #endif /* __DC_HWSS_DCN31_H__ */
diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c
index c6a737781ad1..05335a8c3c2d 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c
@@ -137,6 +137,7 @@ static const struct hwseq_private_funcs dcn31_private_funcs = {
 	.dccg_init = dcn20_dccg_init,
 	.set_blend_lut = dcn30_set_blend_lut,
 	.set_shaper_3dlut = dcn20_set_shaper_3dlut,
+	.setup_hpo_hw_control = dcn31_setup_hpo_hw_control,
 };
 
 void dcn31_hw_sequencer_construct(struct dc *dc)
diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
index 87b2c2428842..18896294ae12 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
@@ -860,7 +860,8 @@ static const struct dccg_mask dccg_mask = {
 	SR(D6VGA_CONTROL), \
 	SR(DC_IP_REQUEST_CNTL), \
 	SR(AZALIA_AUDIO_DTO), \
-	SR(AZALIA_CONTROLLER_CLOCK_GATING)
+	SR(AZALIA_CONTROLLER_CLOCK_GATING), \
+	SR(HPO_TOP_HW_CONTROL)
 
 static const struct dce_hwseq_registers hwseq_reg = {
 		HWSEQ_DCN31_REG_LIST()
@@ -898,7 +899,8 @@ static const struct dce_hwseq_registers hwseq_reg = {
 	HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_UNASSIGNED_PWR_MODE, mask_sh), \
 	HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_VBLANK_PWR_MODE, mask_sh), \
 	HWS_SF(, MMHUBBUB_MEM_PWR_CNTL, VGA_MEM_PWR_FORCE, mask_sh), \
-	HWS_SF(, DIO_MEM_PWR_CTRL, I2C_LIGHT_SLEEP_FORCE, mask_sh)
+	HWS_SF(, DIO_MEM_PWR_CTRL, I2C_LIGHT_SLEEP_FORCE, mask_sh), \
+	HWS_SF(, HPO_TOP_HW_CONTROL, HPO_IO_EN, mask_sh)
 
 static const struct dce_hwseq_shift hwseq_shift = {
 		HWSEQ_DCN31_MASK_SH_LIST(__SHIFT)
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer_private.h b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer_private.h
index f324285394be..c2008258c50a 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer_private.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer_private.h
@@ -143,6 +143,7 @@ struct hwseq_private_funcs {
 			const struct dc_plane_state *plane_state);
 	void (*PLAT_58856_wa)(struct dc_state *context,
 			struct pipe_ctx *pipe_ctx);
+	void (*setup_hpo_hw_control)(const struct dce_hwseq *hws, bool enable);
 };
 
 struct dce_hwseq {
commit edcf52caa985c010d0a6022190c8e3d3980a0223
Author: Wenjing Liu <wenjing.liu at amd.com>
Date:   Fri Oct 15 12:48:41 2021 -0400

    drm/amd/display: fix register write sequence for LINK_SQUARE_PATTERN
    
    [why&how]
    write LINK_SQUARE_PATTERN_num + 1 for square pulse pattern.
    Specs requirement to write this register prior to write LINK_QUAL_LANEX_SET.
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Wenjing Liu <wenjing.liu at amd.com>
    Reviewed-by: George Shen <george.shen at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index cc25ba0ec7db..cb7bf9148904 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -5329,6 +5329,14 @@ bool dc_link_dp_set_test_pattern(
 			return false;
 
 		if (link->dpcd_caps.dpcd_rev.raw >= DPCD_REV_12) {
+#if defined(CONFIG_DRM_AMD_DC_DCN)
+			if (test_pattern == DP_TEST_PATTERN_SQUARE_PULSE)
+				core_link_write_dpcd(link,
+						DP_LINK_SQUARE_PATTERN,
+						p_custom_pattern,
+						1);
+
+#endif
 			/* tell receiver that we are sending qualification
 			 * pattern DP 1.2 or later - DP receiver's link quality
 			 * pattern is set using DPCD LINK_QUAL_LANEx_SET
diff --git a/drivers/gpu/drm/amd/display/dc/dc_dp_types.h b/drivers/gpu/drm/amd/display/dc/dc_dp_types.h
index bc87ea0adf94..e68e9a86a4d9 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dp_types.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_dp_types.h
@@ -898,6 +898,9 @@ struct dpcd_usb4_dp_tunneling_info {
 #ifndef DP_DFP_CAPABILITY_EXTENSION_SUPPORT
 #define DP_DFP_CAPABILITY_EXTENSION_SUPPORT		0x0A3
 #endif
+#ifndef DP_LINK_SQUARE_PATTERN
+#define DP_LINK_SQUARE_PATTERN				0x10F
+#endif
 #ifndef DP_DSC_CONFIGURATION
 #define DP_DSC_CONFIGURATION				0x161
 #endif
commit 589bd2f03f87563d6dc4f480d47e5aabc09e4784
Author: Jimmy Kizito <Jimmy.Kizito at amd.com>
Date:   Wed Oct 20 12:29:22 2021 -0400

    drm/amd/display: Clear encoder assignments when state cleared.
    
    [Why]
    State can be cleared without removing individual streams (by
    calling dc_remove_stream_from_ctx()). This can leave the
    encoder assignment module in an incoherent state and cause
    future assignments to be incorrect.
    
    [How]
    Clear encoder assignments when committing 0 streams or
    re-initializing hardware.
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Jimmy Kizito <Jimmy.Kizito at amd.com>
    Reviewed-by: Jun Lei <Jun.Lei at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
index 72b0f8594b4a..25e48a8cbb78 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
@@ -236,6 +236,23 @@ static struct link_encoder *get_link_enc_used_by_link(
 
 	return link_enc;
 }
+/* Clear all link encoder assignments. */
+static void clear_enc_assignments(struct dc_state *state)
+{
+	int i;
+	enum engine_id eng_id;
+	struct dc_stream_state *stream;
+
+	for (i = 0; i < MAX_PIPES; i++) {
+		state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].valid = false;
+		eng_id = state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].eng_id;
+		stream = state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].stream;
+		if (eng_id != ENGINE_ID_UNKNOWN)
+			state->res_ctx.link_enc_cfg_ctx.link_enc_avail[eng_id - ENGINE_ID_DIGA] = eng_id;
+		if (stream)
+			stream->link_enc = NULL;
+	}
+}
 
 void link_enc_cfg_init(
 		struct dc *dc,
@@ -250,6 +267,8 @@ void link_enc_cfg_init(
 			state->res_ctx.link_enc_cfg_ctx.link_enc_avail[i] = ENGINE_ID_UNKNOWN;
 	}
 
+	clear_enc_assignments(state);
+
 	state->res_ctx.link_enc_cfg_ctx.mode = LINK_ENC_CFG_STEADY;
 }
 
@@ -265,6 +284,9 @@ void link_enc_cfg_link_encs_assign(
 
 	ASSERT(state->stream_count == stream_count);
 
+	if (stream_count == 0)
+		clear_enc_assignments(state);
+
 	/* Release DIG link encoder resources before running assignment algorithm. */
 	for (i = 0; i < stream_count; i++)
 		dc->res_pool->funcs->link_enc_unassign(state, streams[i]);
commit 0b55313cbdd3cf9095774dff8782a79a4a6b599f
Author: Roman Li <Roman.Li at amd.com>
Date:   Tue Oct 19 16:44:21 2021 -0400

    drm/amd/display: Force disable planes on any pipe split change
    
    [Why]
    In scenario when 1 display connected with pipe split (2 pipes in use)
    and 3 new displays simultaneously hotplugged via MST hub (4 pipes in use),
    mpcc may get reprogram to other vtg, remaining busy.
    In this case waiting for mpcc idle timeouts with error like this:
    [drm] REG_WAIT timeout 1us * 100000 tries - mpc2_assert_idle_mpcc
    RIP: 0010:mpc2_assert_mpcc_idle_before_connect
    Call Trace:
    dcn20_update_mpcc
    dcn20_program_front_end_for_ctx
    dc_commit_state
    amdgpu_dm_atomic_commit_tail
    ...
    
    [How]
    Add pipe split change condition to disable dangling plane.
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Roman Li <Roman.Li at amd.com>
    Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas at amd.com>
    Reviewed-by: Dmytro Laktyushkin <Dmytro.Laktyushkin at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 12e5470fa567..11a00e4d9e81 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1085,6 +1085,8 @@ static void disable_dangling_plane(struct dc *dc, struct dc_state *context)
 		struct dc_stream_state *old_stream =
 				dc->current_state->res_ctx.pipe_ctx[i].stream;
 		bool should_disable = true;
+		bool pipe_split_change =
+			context->res_ctx.pipe_ctx[i].top_pipe != dc->current_state->res_ctx.pipe_ctx[i].top_pipe;
 
 		for (j = 0; j < context->stream_count; j++) {
 			if (old_stream == context->streams[j]) {
@@ -1092,6 +1094,9 @@ static void disable_dangling_plane(struct dc *dc, struct dc_state *context)
 				break;
 			}
 		}
+		if (!should_disable && pipe_split_change)
+			should_disable = true;
+
 		if (should_disable && old_stream) {
 			dc_rem_all_planes_for_stream(dc, old_stream, dangling_context);
 			disable_all_writeback_pipes_for_stream(dc, old_stream, dangling_context);
commit 1fc31638eb79eff8b1fb0e1bfcd5f9dbddbf16e2
Author: Bing Guo <Bing.Guo at amd.com>
Date:   Mon Sep 27 18:39:11 2021 -0400

    drm/amd/display: Fix bpc calculation for specific encodings
    
    [Why]
    1. YCbCr 4:2:2 8bpc/10bpc modes are blocked for HDMI by policy
    2. A YCbCr 4:2:0 calculation error blocked some 4:2:0 timing modes
    
    [How]
    YCbCr 4:2:2 8bpc/10bpc modes are allowed for HDMI
    Fix YCbCr 4:2:0 calculation error
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Bing Guo <Bing.Guo at amd.com>
    Reviewed-by: Chris Park <chris.park at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c b/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
index e3d9f1decdfc..f47d82da115c 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
@@ -3576,16 +3576,9 @@ static double TruncToValidBPP(
 		MinDSCBPP = 8;
 		MaxDSCBPP = 3 * DSCInputBitPerComponent - 1.0 / 16;
 	} else {
-		if (Output == dm_hdmi) {
-			NonDSCBPP0 = 24;
-			NonDSCBPP1 = 24;
-			NonDSCBPP2 = 24;
-		}
-		else {
-			NonDSCBPP0 = 16;
-			NonDSCBPP1 = 20;
-			NonDSCBPP2 = 24;
-		}
+		NonDSCBPP0 = 16;
+		NonDSCBPP1 = 20;
+		NonDSCBPP2 = 24;
 
 		if (Format == dm_n422) {
 			MinDSCBPP = 7;
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c b/drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c
index d58925cff420..7e937bdcea00 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c
@@ -3892,15 +3892,11 @@ static double TruncToValidBPP(
 		MinDSCBPP = 8;
 		MaxDSCBPP = 3 * DSCInputBitPerComponent - 1.0 / 16;
 	} else {
-		if (Output == dm_hdmi) {
-			NonDSCBPP0 = 24;
-			NonDSCBPP1 = 24;
-			NonDSCBPP2 = 24;
-		} else {
-			NonDSCBPP0 = 16;
-			NonDSCBPP1 = 20;
-			NonDSCBPP2 = 24;
-		}
+
+		NonDSCBPP0 = 16;
+		NonDSCBPP1 = 20;
+		NonDSCBPP2 = 24;
+
 		if (Format == dm_n422) {
 			MinDSCBPP = 7;
 			MaxDSCBPP = 2 * DSCInputBitPerComponent - 1.0 / 16.0;
commit bca5bea4030d59b2d100c997b8044033247c1a99
Author: Yu-ting Shen <yu-tshen at amd.com>
Date:   Tue Oct 19 14:22:02 2021 +0800

    drm/amd/display: avoid link loss short pulse stuck the system
    
    [Why]
    MST monitor sends link loss short pulse continuous but sink is
    occupy by HDMI input to lead link training fail.
    
    [How]
    disable link once retraining fail.
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Yu-ting Shen <yu-tshen at amd.com>
    Reviewed-by: Wenjing Liu <Wenjing.Liu at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index 2796bdd17de1..f14f71dd1aa9 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -4279,6 +4279,8 @@ void core_link_enable_stream(
 			 */
 			if (status != DC_FAIL_DP_LINK_TRAINING ||
 					pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
+				if (false == stream->link->link_status.link_active)
+					disable_link(stream->link, pipe_ctx->stream->signal);
 				BREAK_TO_DEBUGGER();
 				return;
 			}
commit 670d2a6240536bb7a5dabbd7eb32ebec8c033301
Author: Felipe Clark <felclark at amd.com>
Date:   Mon Oct 18 16:50:10 2021 -0400

    drm/amd/display: Fix dummy p-state hang on monitors with extreme timing
    
    [WHY]
    It was found that the system would hang on a dummy pstate when playing
    4k60 videos on a 1080p 390Hz monitor.
    
    [HOW]
    Properly select the dummy_pstate_latency_ms when firmware assisted
    memory clock switching is enabled instead of assuming that the highest
    latency would work for every monitor timing.
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Felipe Clark <felclark at amd.com>
    Reviewed-by: Jun Lei <Jun.Lei at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
index e50c695e3c96..79a66e0c4303 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
@@ -2128,10 +2128,10 @@ static noinline void dcn30_calculate_wm_and_dlg_fp(
 		int pipe_cnt,
 		int vlevel)
 {
+	int maxMpcComb = context->bw_ctx.dml.vba.maxMpcComb;
 	int i, pipe_idx;
-	double dcfclk = context->bw_ctx.dml.vba.DCFCLKState[vlevel][context->bw_ctx.dml.vba.maxMpcComb];
-	bool pstate_en = context->bw_ctx.dml.vba.DRAMClockChangeSupport[vlevel][context->bw_ctx.dml.vba.maxMpcComb] !=
-			dm_dram_clock_change_unsupported;
+	double dcfclk = context->bw_ctx.dml.vba.DCFCLKState[vlevel][maxMpcComb];
+	bool pstate_en = context->bw_ctx.dml.vba.DRAMClockChangeSupport[vlevel][maxMpcComb] != dm_dram_clock_change_unsupported;
 
 	if (context->bw_ctx.dml.soc.min_dcfclk > dcfclk)
 		dcfclk = context->bw_ctx.dml.soc.min_dcfclk;
@@ -2207,6 +2207,7 @@ static noinline void dcn30_calculate_wm_and_dlg_fp(
 		context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].dml_input.sr_enter_plus_exit_time_us;
 		context->bw_ctx.dml.soc.sr_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].dml_input.sr_exit_time_us;
 	}
+
 	context->bw_ctx.bw.dcn.watermarks.c.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
 	context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
 	context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
commit 7c5b0f22364955ea7a7cbf9cefa4e8e9b99e9d88
Author: Anson Jacob <Anson.Jacob at amd.com>
Date:   Tue Oct 19 12:06:45 2021 -0400

    drm/amd/display: Fix dcn10_log_hubp_states printf format string
    
    Fix spacing issue for the format string.
    
    Addresses-Coverity-ID: 1446765: ("Invalid printf format string")
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Anson Jacob <Anson.Jacob at amd.com>
    Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
index a25732d07222..0b788d794fb3 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
@@ -231,7 +231,7 @@ static void dcn10_log_hubp_states(struct dc *dc, void *log_ctx)
 
 		if (!s->blank_en)
 			DTN_INFO("[%2d]:  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh"
-				"%  8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh"
+				"  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh"
 				"  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh  %8xh\n",
 				pool->hubps[i]->inst, dlg_regs->refcyc_h_blank_end, dlg_regs->dlg_vblank_end, dlg_regs->min_dst_y_next_start,
 				dlg_regs->refcyc_per_htotal, dlg_regs->refcyc_x_after_scaler, dlg_regs->dst_y_after_scaler,
commit a550bb165b3f9ed92d6c335e1ea191bf28bb4e0f
Author: Hersen Wu <hersenwu at amd.com>
Date:   Sun Oct 17 20:09:04 2021 -0400

    drm/amd/display: dsc engine not disabled after unplug dsc mst hub
    
    [WHY]
    If timing and bpp of displays on mst hub are not changed,
    pbn, slot_num for displays should not be changed. Linux
    user mode may initiate atomic_check with different display
    configuration after set mode finished. This will call to
    amdgpu_dm to re-compute payload, slot_num of displays and
    saved to dm_connect_state. stream->timing.flags.dsc, pbn,
    slot_num are updated to values which may be different from
    that were used for set mode. when dsc hub with 3 4k at 60hz dp
    connected, 3 dsc engines are enabled. timing.flags.dsc = 1.
    timing.flags.dsc are changed to 0 due to atomic check. when
    dsc hub is unplugged, amdgpu driver check timing.flags.dsc
    for last mode set and find out flags.dsc = 0, then does not
    disable dsc.
    
    [HOW]
    check status of  displays on dsc mst hubs. re-compute pbn,
    slot_num, timing.flags.dsc only if there is mode, connect
    or enable/disable change.
    
    Acked-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
    Signed-off-by: Hersen Wu <hersenwu at amd.com>
    Reviewed-by: Mikita Lipski <Mikita.Lipski at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index c3812f38ae56..94d225931d51 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -7249,8 +7249,8 @@ static int dm_update_mst_vcpi_slots_for_dsc(struct drm_atomic_state *state,
 	struct drm_connector_state *new_con_state;
 	struct amdgpu_dm_connector *aconnector;
 	struct dm_connector_state *dm_conn_state;
-	int i, j, clock;
-	int vcpi, pbn_div, pbn = 0;
+	int i, j;
+	int vcpi, pbn_div, pbn, slot_num = 0;
 
 	for_each_new_connector_in_state(state, connector, new_con_state, i) {
 
@@ -7278,17 +7278,7 @@ static int dm_update_mst_vcpi_slots_for_dsc(struct drm_atomic_state *state,
 		if (!stream)
 			continue;
 
-		if (stream->timing.flags.DSC != 1) {
-			drm_dp_mst_atomic_enable_dsc(state,
-						     aconnector->port,
-						     dm_conn_state->pbn,
-						     0,
-						     false);
-			continue;
-		}
-
 		pbn_div = dm_mst_get_pbn_divider(stream->link);
-		clock = stream->timing.pix_clk_100hz / 10;
 		/* pbn is calculated by compute_mst_dsc_configs_for_state*/
 		for (j = 0; j < dc_state->stream_count; j++) {
 			if (vars[j].aconnector == aconnector) {
@@ -7297,6 +7287,23 @@ static int dm_update_mst_vcpi_slots_for_dsc(struct drm_atomic_state *state,
 			}
 		}
 
+		if (j == dc_state->stream_count)
+			continue;
+
+		slot_num = DIV_ROUND_UP(pbn, pbn_div);
+
+		if (stream->timing.flags.DSC != 1) {
+			dm_conn_state->pbn = pbn;
+			dm_conn_state->vcpi_slots = slot_num;
+
+			drm_dp_mst_atomic_enable_dsc(state,
+						     aconnector->port,
+						     dm_conn_state->pbn,
+						     0,
+						     false);
+			continue;
+		}
+
 		vcpi = drm_dp_mst_atomic_enable_dsc(state,
 						    aconnector->port,
 						    pbn, pbn_div,
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
index 874a49b605c7..32a5ce09a62a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
@@ -534,13 +534,14 @@ static int kbps_to_peak_pbn(int kbps)
 
 static void set_dsc_configs_from_fairness_vars(struct dsc_mst_fairness_params *params,
 		struct dsc_mst_fairness_vars *vars,
-		int count)
+		int count,
+		int k)
 {
 	int i;
 
 	for (i = 0; i < count; i++) {
 		memset(&params[i].timing->dsc_cfg, 0, sizeof(params[i].timing->dsc_cfg));
-		if (vars[i].dsc_enabled && dc_dsc_compute_config(
+		if (vars[i + k].dsc_enabled && dc_dsc_compute_config(
 					params[i].sink->ctx->dc->res_pool->dscs[0],
 					&params[i].sink->dsc_caps.dsc_dec_caps,
 					params[i].sink->ctx->dc->debug.dsc_min_slice_height_override,
@@ -553,7 +554,7 @@ static void set_dsc_configs_from_fairness_vars(struct dsc_mst_fairness_params *p
 			if (params[i].bpp_overwrite)
 				params[i].timing->dsc_cfg.bits_per_pixel = params[i].bpp_overwrite;
 			else
-				params[i].timing->dsc_cfg.bits_per_pixel = vars[i].bpp_x16;
+				params[i].timing->dsc_cfg.bits_per_pixel = vars[i + k].bpp_x16;
 
 			if (params[i].num_slices_h)
 				params[i].timing->dsc_cfg.num_slices_h = params[i].num_slices_h;
@@ -586,7 +587,8 @@ static void increase_dsc_bpp(struct drm_atomic_state *state,
 			     struct dc_link *dc_link,
 			     struct dsc_mst_fairness_params *params,
 			     struct dsc_mst_fairness_vars *vars,
-			     int count)
+			     int count,
+			     int k)
 {
 	int i;
 	bool bpp_increased[MAX_PIPES];
@@ -601,8 +603,9 @@ static void increase_dsc_bpp(struct drm_atomic_state *state,
 	pbn_per_timeslot = dm_mst_get_pbn_divider(dc_link);
 
 	for (i = 0; i < count; i++) {
-		if (vars[i].dsc_enabled) {
-			initial_slack[i] = kbps_to_peak_pbn(params[i].bw_range.max_kbps) - vars[i].pbn;
+		if (vars[i + k].dsc_enabled) {
+			initial_slack[i] =
+			kbps_to_peak_pbn(params[i].bw_range.max_kbps) - vars[i + k].pbn;
 			bpp_increased[i] = false;
 			remaining_to_increase += 1;
 		} else {
@@ -629,7 +632,7 @@ static void increase_dsc_bpp(struct drm_atomic_state *state,
 		link_timeslots_used = 0;
 
 		for (i = 0; i < count; i++)
-			link_timeslots_used += DIV_ROUND_UP(vars[i].pbn, pbn_per_timeslot);
+			link_timeslots_used += DIV_ROUND_UP(vars[i + k].pbn, pbn_per_timeslot);
 
 		fair_pbn_alloc = (63 - link_timeslots_used) / remaining_to_increase * pbn_per_timeslot;
 
@@ -682,7 +685,8 @@ static void try_disable_dsc(struct drm_atomic_state *state,
 			    struct dc_link *dc_link,
 			    struct dsc_mst_fairness_params *params,
 			    struct dsc_mst_fairness_vars *vars,
-			    int count)
+			    int count,
+			    int k)
 {
 	int i;
 	bool tried[MAX_PIPES];
@@ -692,8 +696,8 @@ static void try_disable_dsc(struct drm_atomic_state *state,
 	int remaining_to_try = 0;
 
 	for (i = 0; i < count; i++) {
-		if (vars[i].dsc_enabled
-				&& vars[i].bpp_x16 == params[i].bw_range.max_target_bpp_x16
+		if (vars[i + k].dsc_enabled
+				&& vars[i + k].bpp_x16 == params[i].bw_range.max_target_bpp_x16
 				&& params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
 			kbps_increase[i] = params[i].bw_range.stream_kbps - params[i].bw_range.max_kbps;
 			tried[i] = false;
@@ -748,9 +752,10 @@ static void try_disable_dsc(struct drm_atomic_state *state,
 static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state,
 					     struct dc_state *dc_state,
 					     struct dc_link *dc_link,
-					     struct dsc_mst_fairness_vars *vars)
+					     struct dsc_mst_fairness_vars *vars,
+					     int *link_vars_start_index)
 {
-	int i;
+	int i, k;
 	struct dc_stream_state *stream;
 	struct dsc_mst_fairness_params params[MAX_PIPES];
 	struct amdgpu_dm_connector *aconnector;
@@ -768,11 +773,17 @@ static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state,
 		if (stream->link != dc_link)
 			continue;
 
+		aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
+		if (!aconnector)
+			continue;
+
+		if (!aconnector->port)
+			continue;
+
 		stream->timing.flags.DSC = 0;
 
 		params[count].timing = &stream->timing;
 		params[count].sink = stream->sink;
-		aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
 		params[count].aconnector = aconnector;
 		params[count].port = aconnector->port;
 		params[count].clock_force_enable = aconnector->dsc_settings.dsc_force_enable;
@@ -794,44 +805,55 @@ static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state,
 
 		count++;
 	}
+
+	if (count == 0) {
+		ASSERT(0);
+		return true;
+	}
+
+	/* k is start index of vars for current phy link used by mst hub */
+	k = *link_vars_start_index;
+	/* set vars start index for next mst hub phy link */
+	*link_vars_start_index += count;
+
 	/* Try no compression */
 	for (i = 0; i < count; i++) {
-		vars[i].aconnector = params[i].aconnector;
-		vars[i].pbn = kbps_to_peak_pbn(params[i].bw_range.stream_kbps);
-		vars[i].dsc_enabled = false;
-		vars[i].bpp_x16 = 0;
+		vars[i + k].aconnector = params[i].aconnector;
+		vars[i + k].pbn = kbps_to_peak_pbn(params[i].bw_range.stream_kbps);
+		vars[i + k].dsc_enabled = false;
+		vars[i + k].bpp_x16 = 0;
 		if (drm_dp_atomic_find_vcpi_slots(state,
 						 params[i].port->mgr,
 						 params[i].port,
-						 vars[i].pbn,
+						 vars[i + k].pbn,
 						 dm_mst_get_pbn_divider(dc_link)) < 0)
 			return false;
 	}
 	if (!drm_dp_mst_atomic_check(state) && !debugfs_overwrite) {
-		set_dsc_configs_from_fairness_vars(params, vars, count);
+		set_dsc_configs_from_fairness_vars(params, vars, count, k);
 		return true;
 	}
 
 	/* Try max compression */
 	for (i = 0; i < count; i++) {
 		if (params[i].compression_possible && params[i].clock_force_enable != DSC_CLK_FORCE_DISABLE) {
-			vars[i].pbn = kbps_to_peak_pbn(params[i].bw_range.min_kbps);
-			vars[i].dsc_enabled = true;
-			vars[i].bpp_x16 = params[i].bw_range.min_target_bpp_x16;
+			vars[i + k].pbn = kbps_to_peak_pbn(params[i].bw_range.min_kbps);
+			vars[i + k].dsc_enabled = true;
+			vars[i + k].bpp_x16 = params[i].bw_range.min_target_bpp_x16;
 			if (drm_dp_atomic_find_vcpi_slots(state,
 							  params[i].port->mgr,
 							  params[i].port,
-							  vars[i].pbn,
+							  vars[i + k].pbn,
 							  dm_mst_get_pbn_divider(dc_link)) < 0)
 				return false;
 		} else {
-			vars[i].pbn = kbps_to_peak_pbn(params[i].bw_range.stream_kbps);
-			vars[i].dsc_enabled = false;
-			vars[i].bpp_x16 = 0;
+			vars[i + k].pbn = kbps_to_peak_pbn(params[i].bw_range.stream_kbps);
+			vars[i + k].dsc_enabled = false;
+			vars[i + k].bpp_x16 = 0;
 			if (drm_dp_atomic_find_vcpi_slots(state,
 							  params[i].port->mgr,
 							  params[i].port,
-							  vars[i].pbn,
+							  vars[i + k].pbn,
 							  dm_mst_get_pbn_divider(dc_link)) < 0)
 				return false;
 		}
@@ -840,15 +862,76 @@ static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state,
 		return false;
 
 	/* Optimize degree of compression */
-	increase_dsc_bpp(state, dc_link, params, vars, count);
+	increase_dsc_bpp(state, dc_link, params, vars, count, k);
 
-	try_disable_dsc(state, dc_link, params, vars, count);
+	try_disable_dsc(state, dc_link, params, vars, count, k);
 
-	set_dsc_configs_from_fairness_vars(params, vars, count);
+	set_dsc_configs_from_fairness_vars(params, vars, count, k);
 
 	return true;
 }
 
+static bool is_dsc_need_re_compute(
+	struct drm_atomic_state *state,
+	struct dc_state *dc_state,
+	struct dc_link *dc_link)
+{
+	int i;
+	bool is_dsc_need_re_compute = false;
+
+	/* only check phy used by mst branch */
+	if (dc_link->type != dc_connection_mst_branch)
+		return false;
+
+	/* check if there is mode change in new request */
+	for (i = 0; i < dc_state->stream_count; i++) {
+		struct amdgpu_dm_connector *aconnector;
+		struct dc_stream_state *stream;
+		struct drm_crtc_state *new_crtc_state;
+		struct drm_connector_state *new_conn_state;
+
+		stream = dc_state->streams[i];
+
+		if (!stream)
+			continue;
+
+		/* check if stream using the same link for mst */
+		if (stream->link != dc_link)
+			continue;
+
+		aconnector = (struct amdgpu_dm_connector *) stream->dm_stream_context;
+		if (!aconnector)
+			continue;
+
+		new_conn_state = drm_atomic_get_new_connector_state(state, &aconnector->base);
+
+		if (!new_conn_state)
+			continue;
+
+		if (IS_ERR(new_conn_state))
+			continue;
+
+		if (!new_conn_state->crtc)
+			continue;
+
+		new_crtc_state = drm_atomic_get_new_crtc_state(state, new_conn_state->crtc);
+
+		if (!new_crtc_state)
+			continue;
+
+		if (IS_ERR(new_crtc_state))
+			continue;
+
+		if (new_crtc_state->enable && new_crtc_state->active) {
+			if (new_crtc_state->mode_changed || new_crtc_state->active_changed ||
+				new_crtc_state->connectors_changed)
+				is_dsc_need_re_compute = true;
+		}
+	}
+
+	return is_dsc_need_re_compute;
+}
+
 bool compute_mst_dsc_configs_for_state(struct drm_atomic_state *state,
 				       struct dc_state *dc_state,
 				       struct dsc_mst_fairness_vars *vars)
@@ -857,6 +940,7 @@ bool compute_mst_dsc_configs_for_state(struct drm_atomic_state *state,
 	struct dc_stream_state *stream;
 	bool computed_streams[MAX_PIPES];
 	struct amdgpu_dm_connector *aconnector;
+	int link_vars_start_index = 0;
 
 	for (i = 0; i < dc_state->stream_count; i++)
 		computed_streams[i] = false;
@@ -881,8 +965,12 @@ bool compute_mst_dsc_configs_for_state(struct drm_atomic_state *state,
 		if (dcn20_remove_stream_from_ctx(stream->ctx->dc, dc_state, stream) != DC_OK)
 			return false;
 
+		if (!is_dsc_need_re_compute(state, dc_state, stream->link))
+			continue;
+
 		mutex_lock(&aconnector->mst_mgr.lock);
-		if (!compute_mst_dsc_configs_for_link(state, dc_state, stream->link, vars)) {
+		if (!compute_mst_dsc_configs_for_link(state, dc_state, stream->link,
+			vars, &link_vars_start_index)) {
 			mutex_unlock(&aconnector->mst_mgr.lock);
 			return false;
 		}
commit 93cec184788b0cf3926bc1f7b47fed74ba87990c
Author: James Zhu <James.Zhu at amd.com>
Date:   Tue Nov 2 21:33:50 2021 -0400

    drm/amdgpu: remove duplicated kfd_resume_iommu
    
    Remove duplicated kfd_resume_iommu which already runs
    in mdgpu_amdkfd_device_init.
    
    Tested-By: Ken Moffat <zarniwhoop at ntlworld.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: James Zhu <James.Zhu at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 7c3f6ee14853..6c38dd9f41be 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2398,10 +2398,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 	if (!adev->gmc.xgmi.pending_reset)
 		amdgpu_amdkfd_device_init(adev);
 
-	r = amdgpu_amdkfd_resume_iommu(adev);
-	if (r)
-		goto init_failed;
-
 	amdgpu_fru_get_product_info(adev);
 
 init_failed:
commit e8a423c589a0a7848c019d70231e9da9784467ae
Author: Aaron Liu <aaron.liu at amd.com>
Date:   Tue Nov 2 16:45:09 2021 +0800

    drm/amdgpu: update RLC_PG_DELAY_3 Value to 200us for yellow carp
    
    For yellow carp, the desired CGPG hysteresis value is 0x4E20.
    
    Signed-off-by: Aaron Liu <aaron.liu at amd.com>
    Acked-by: Huang Rui <ray.huang at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 90a834dc4008..b53b36f5ae92 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -8316,11 +8316,8 @@ static void gfx_v10_cntl_power_gating(struct amdgpu_device *adev, bool enable)
 	if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)) {
 		switch (adev->ip_versions[GC_HWIP][0]) {
 		case IP_VERSION(10, 3, 1):
-			data = 0x4E20 & RLC_PG_DELAY_3__CGCG_ACTIVE_BEFORE_CGPG_MASK_Vangogh;
-			WREG32_SOC15(GC, 0, mmRLC_PG_DELAY_3, data);
-			break;
 		case IP_VERSION(10, 3, 3):
-			data = 0x1388 & RLC_PG_DELAY_3__CGCG_ACTIVE_BEFORE_CGPG_MASK_Vangogh;
+			data = 0x4E20 & RLC_PG_DELAY_3__CGCG_ACTIVE_BEFORE_CGPG_MASK_Vangogh;
 			WREG32_SOC15(GC, 0, mmRLC_PG_DELAY_3, data);
 			break;
 		default:
commit 91adec9e07097e538691daed5d934e7886dd1dc3
Author: Mario Limonciello <mario.limonciello at amd.com>
Date:   Tue Nov 2 10:04:37 2021 -0500

    drm/amd/display: Look at firmware version to determine using dmub on dcn21
    
    commit 652de07addd2 ("drm/amd/display: Fully switch to dmub for all dcn21
    asics") switched over to using dmub on Renoir to fix Gitlab 1735, but this
    implied a new dependency on newer firmware which might not be met on older
    kernel versions.
    
    Since sw_init runs before hw_init, there is an opportunity to determine
    whether or not the firmware version is new to adjust the behavior.
    
    Cc: Roman.Li at amd.com
    BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1772
    BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1735
    Fixes: 652de07addd2 ("drm/amd/display: Fully switch to dmub for all dcn21 asics")
    Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
    Acked-by: Alex Deucher <alexander.deucher at amd.com>
    Reviewed-by: Roman Li <Roman.Li at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 43e983e42c0f..c3812f38ae56 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1410,7 +1410,15 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 		switch (adev->ip_versions[DCE_HWIP][0]) {
 		case IP_VERSION(2, 1, 0):
 			init_data.flags.gpu_vm_support = true;
-			init_data.flags.disable_dmcu = true;
+			switch (adev->dm.dmcub_fw_version) {
+			case 0: /* development */
+			case 0x1: /* linux-firmware.git hash 6d9f399 */
+			case 0x01000000: /* linux-firmware.git hash 9a0b0f4 */
+				init_data.flags.disable_dmcu = false;
+				break;
+			default:
+				init_data.flags.disable_dmcu = true;
+			}
 			break;
 		case IP_VERSION(1, 0, 0):
 		case IP_VERSION(1, 0, 1):
commit a750559132c64f3fa40418876bc43881e169a8f0
Author: Mario Limonciello <mario.limonciello at amd.com>
Date:   Fri Oct 29 16:09:26 2021 -0500

    drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices
    
    For ASICs not supporting power profile mode, don't show the attribute.
    Verify that the function has been implemented by the subsystem.
    
    Suggested-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
    Reviewed-by: Lijo Lazar <lijo.lazar at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 49fe4155c374..41472ed99253 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -2094,6 +2094,10 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_
 	} else if (DEVICE_ATTR_IS(pp_dpm_dclk)) {
 		if (!(asic_type == CHIP_VANGOGH || asic_type == CHIP_SIENNA_CICHLID))
 			*states = ATTR_STATE_UNSUPPORTED;
+	} else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {
+		if (!adev->powerplay.pp_funcs->get_power_profile_mode ||
+		    amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)
+			*states = ATTR_STATE_UNSUPPORTED;
 	}
 
 	switch (asic_type) {
diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index 79e565121206..8d796ed3b7d1 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
@@ -877,16 +877,11 @@ static int pp_get_power_profile_mode(void *handle, char *buf)
 	struct pp_hwmgr *hwmgr = handle;
 	int ret;
 
-	if (!hwmgr || !hwmgr->pm_en)
+	if (!hwmgr || !hwmgr->pm_en || !hwmgr->hwmgr_func->get_power_profile_mode)
 		return -EOPNOTSUPP;
 	if (!buf)
 		return -EINVAL;
 
-	if (hwmgr->hwmgr_func->get_power_profile_mode == NULL) {
-		pr_info_ratelimited("%s was not implemented.\n", __func__);
-		return snprintf(buf, PAGE_SIZE, "\n");
-	}
-
 	mutex_lock(&hwmgr->smu_lock);
 	ret = hwmgr->hwmgr_func->get_power_profile_mode(hwmgr, buf);
 	mutex_unlock(&hwmgr->smu_lock);
@@ -898,13 +893,8 @@ static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
 	struct pp_hwmgr *hwmgr = handle;
 	int ret = -EOPNOTSUPP;
 
-	if (!hwmgr || !hwmgr->pm_en)
-		return ret;
-
-	if (hwmgr->hwmgr_func->set_power_profile_mode == NULL) {
-		pr_info_ratelimited("%s was not implemented.\n", __func__);
+	if (!hwmgr || !hwmgr->pm_en || !hwmgr->hwmgr_func->set_power_profile_mode)
 		return ret;
-	}
 
 	if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) {
 		pr_debug("power profile setting is for manual dpm mode only.\n");
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index b06c59dcc1b4..821ae6e78703 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -2534,13 +2534,15 @@ static int smu_get_power_profile_mode(void *handle, char *buf)
 	struct smu_context *smu = handle;
 	int ret = 0;
 
-	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
+	    !smu->ppt_funcs->get_power_profile_mode)
 		return -EOPNOTSUPP;
+	if (!buf)
+		return -EINVAL;
 
 	mutex_lock(&smu->mutex);
 
-	if (smu->ppt_funcs->get_power_profile_mode)
-		ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
+	ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
 
 	mutex_unlock(&smu->mutex);
 
@@ -2554,7 +2556,8 @@ static int smu_set_power_profile_mode(void *handle,
 	struct smu_context *smu = handle;
 	int ret = 0;
 
-	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled ||
+	    !smu->ppt_funcs->set_power_profile_mode)
 		return -EOPNOTSUPP;
 
 	mutex_lock(&smu->mutex);
commit a035be8a05bf7b9591cff1be4e9175bd5edab35a
Author: Mario Limonciello <mario.limonciello at amd.com>
Date:   Mon Nov 1 16:17:27 2021 -0500

    drm/amd/pm: Adjust returns when power_profile_mode is not supported
    
    This better aligns that the caller can make a mistake with the buffer
    and -EINVAL should be returned, but if the hardware doesn't support
    the feature it should be -EOPNOTSUPP.
    
    Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
    Reviewed-by: Lijo Lazar <lijo.lazar at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index 978007664e71..79e565121206 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
@@ -877,7 +877,9 @@ static int pp_get_power_profile_mode(void *handle, char *buf)
 	struct pp_hwmgr *hwmgr = handle;
 	int ret;
 
-	if (!hwmgr || !hwmgr->pm_en || !buf)
+	if (!hwmgr || !hwmgr->pm_en)
+		return -EOPNOTSUPP;
+	if (!buf)
 		return -EINVAL;
 
 	if (hwmgr->hwmgr_func->get_power_profile_mode == NULL) {
@@ -894,7 +896,7 @@ static int pp_get_power_profile_mode(void *handle, char *buf)
 static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
 {
 	struct pp_hwmgr *hwmgr = handle;
-	int ret = -EINVAL;
+	int ret = -EOPNOTSUPP;
 
 	if (!hwmgr || !hwmgr->pm_en)
 		return ret;
@@ -906,7 +908,7 @@ static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
 
 	if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) {
 		pr_debug("power profile setting is for manual dpm mode only.\n");
-		return ret;
+		return -EINVAL;
 	}
 
 	mutex_lock(&hwmgr->smu_lock);
commit 067558177be63c38935f2668cb270e42d37e6372
Author: Mario Limonciello <mario.limonciello at amd.com>
Date:   Mon Nov 1 16:15:33 2021 -0500

    drm/amd/pm: Add missing mutex for pp_get_power_profile_mode
    
    Prevent possible issues from set and get being called simultaneously.
    
    Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
    Reviewed-by: Lijo Lazar <lijo.lazar at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index 321215003643..978007664e71 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
@@ -875,6 +875,7 @@ pp_dpm_get_vce_clock_state(void *handle, unsigned idx)
 static int pp_get_power_profile_mode(void *handle, char *buf)
 {
 	struct pp_hwmgr *hwmgr = handle;
+	int ret;
 
 	if (!hwmgr || !hwmgr->pm_en || !buf)
 		return -EINVAL;
@@ -884,7 +885,10 @@ static int pp_get_power_profile_mode(void *handle, char *buf)
 		return snprintf(buf, PAGE_SIZE, "\n");
 	}
 
-	return hwmgr->hwmgr_func->get_power_profile_mode(hwmgr, buf);
+	mutex_lock(&hwmgr->smu_lock);
+	ret = hwmgr->hwmgr_func->get_power_profile_mode(hwmgr, buf);
+	mutex_unlock(&hwmgr->smu_lock);
+	return ret;
 }
 
 static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
commit 9a40d0448f0381dcff2c8f9e63d27ce79aebbdfb
Author: Mario Limonciello <mario.limonciello at amd.com>
Date:   Fri Oct 29 10:19:01 2021 -0500

    drm/amdgpu/pm: drop pp_power_profile_mode support for yellow carp
    
    This was added by commit bd8dcea93a7d ("drm/amd/pm: add callbacks to
    read/write sysfs file pp_power_profile_mode") but the feature was
    deprecated from PMFW.  Remove it from the driver.
    
    Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
    Acked-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v13_0_1_ppsmc.h b/drivers/gpu/drm/amd/pm/inc/smu_v13_0_1_ppsmc.h
index 1d3447991d0c..fc9198846e70 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu_v13_0_1_ppsmc.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu_v13_0_1_ppsmc.h
@@ -51,7 +51,7 @@
 #define PPSMC_MSG_PowerUpVcn                    0x07 ///< Power up VCN; VCN is power gated by default
 #define PPSMC_MSG_SetHardMinVcn                 0x08 ///< For wireless display
 #define PPSMC_MSG_SetSoftMinGfxclk              0x09 ///< Set SoftMin for GFXCLK, argument is frequency in MHz
-#define PPSMC_MSG_ActiveProcessNotify           0x0A ///< Set active work load type
+#define PPSMC_MSG_ActiveProcessNotify           0x0A ///< Deprecated (Not to be used)
 #define PPSMC_MSG_ForcePowerDownGfx             0x0B ///< Force power down GFX, i.e. enter GFXOFF
 #define PPSMC_MSG_PrepareMp1ForUnload           0x0C ///< Prepare PMFW for GFX driver unload
 #define PPSMC_MSG_SetDriverDramAddrHigh         0x0D ///< Set high 32 bits of DRAM address for Driver table transfer
@@ -63,7 +63,7 @@
 #define PPSMC_MSG_SetHardMinSocclkByFreq        0x13 ///< Set hard min for SOC CLK
 #define PPSMC_MSG_SetSoftMinFclk                0x14 ///< Set hard min for FCLK
 #define PPSMC_MSG_SetSoftMinVcn                 0x15 ///< Set soft min for VCN clocks (VCLK and DCLK)
-#define PPSMC_MSG_SPARE0                        0x16 ///< Spared
+#define PPSMC_MSG_SPARE                         0x16 ///< Spare
 #define PPSMC_MSG_GetGfxclkFrequency            0x17 ///< Get GFX clock frequency
 #define PPSMC_MSG_GetFclkFrequency              0x18 ///< Get FCLK frequency
 #define PPSMC_MSG_AllowGfxOff                   0x19 ///< Inform PMFW of allowing GFXOFF entry
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c
index a403657151ba..8215bbf5ed7c 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c
@@ -64,7 +64,6 @@ static struct cmn2asic_msg_mapping yellow_carp_message_map[SMU_MSG_MAX_COUNT] =
 	MSG_MAP(PowerDownVcn,                   PPSMC_MSG_PowerDownVcn,			1),
 	MSG_MAP(PowerUpVcn,                     PPSMC_MSG_PowerUpVcn,			1),
 	MSG_MAP(SetHardMinVcn,                  PPSMC_MSG_SetHardMinVcn,		1),
-	MSG_MAP(ActiveProcessNotify,            PPSMC_MSG_ActiveProcessNotify,		1),
 	MSG_MAP(PrepareMp1ForUnload,            PPSMC_MSG_PrepareMp1ForUnload,      1),
 	MSG_MAP(SetDriverDramAddrHigh,          PPSMC_MSG_SetDriverDramAddrHigh,	1),
 	MSG_MAP(SetDriverDramAddrLow,           PPSMC_MSG_SetDriverDramAddrLow,		1),
@@ -135,14 +134,6 @@ static struct cmn2asic_mapping yellow_carp_table_map[SMU_TABLE_COUNT] = {
 	TAB_MAP_VALID(CUSTOM_DPM),
 	TAB_MAP_VALID(DPMCLOCKS),
 };
-
-static struct cmn2asic_mapping yellow_carp_workload_map[PP_SMC_POWER_PROFILE_COUNT] = {
-	WORKLOAD_MAP(PP_SMC_POWER_PROFILE_FULLSCREEN3D,		WORKLOAD_PPLIB_FULL_SCREEN_3D_BIT),
-	WORKLOAD_MAP(PP_SMC_POWER_PROFILE_VIDEO,		WORKLOAD_PPLIB_VIDEO_BIT),
-	WORKLOAD_MAP(PP_SMC_POWER_PROFILE_VR,			WORKLOAD_PPLIB_VR_BIT),
-	WORKLOAD_MAP(PP_SMC_POWER_PROFILE_COMPUTE,		WORKLOAD_PPLIB_COMPUTE_BIT),
-	WORKLOAD_MAP(PP_SMC_POWER_PROFILE_CUSTOM,		WORKLOAD_PPLIB_CUSTOM_BIT),
-};
 	
 static int yellow_carp_init_smc_tables(struct smu_context *smu)
 {
@@ -543,81 +534,6 @@ static int yellow_carp_set_watermarks_table(struct smu_context *smu,
 	return 0;
 }
 
-static int yellow_carp_get_power_profile_mode(struct smu_context *smu,
-						char *buf)
-{
-	static const char *profile_name[] = {
-					"BOOTUP_DEFAULT",
-					"3D_FULL_SCREEN",
-					"POWER_SAVING",
-					"VIDEO",
-					"VR",
-					"COMPUTE",
-					"CUSTOM"};
-	uint32_t i, size = 0;
-	int16_t workload_type = 0;
-
-	if (!buf)
-		return -EINVAL;
-
-	for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) {
-		/*
-		 * Conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT.
-		 * Not all profile modes are supported on yellow carp.
-		 */
-		workload_type = smu_cmn_to_asic_specific_index(smu,
-							       CMN2ASIC_MAPPING_WORKLOAD,
-							       i);
-
-		if (workload_type < 0)
-			continue;
-
-		size += sysfs_emit_at(buf, size, "%2d %14s%s\n",
-			i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " ");
-	}
-
-	return size;
-}
-
-static int yellow_carp_set_power_profile_mode(struct smu_context *smu,
-						long *input, uint32_t size)
-{
-	int workload_type, ret;
-	uint32_t profile_mode = input[size];
-
-	if (profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) {
-		dev_err(smu->adev->dev, "Invalid power profile mode %d\n", profile_mode);
-		return -EINVAL;
-	}
-
-	if (profile_mode == PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ||
-			profile_mode == PP_SMC_POWER_PROFILE_POWERSAVING)
-		return 0;
-
-	/* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */
-	workload_type = smu_cmn_to_asic_specific_index(smu,
-						       CMN2ASIC_MAPPING_WORKLOAD,
-						       profile_mode);
-	if (workload_type < 0) {
-		dev_dbg(smu->adev->dev, "Unsupported power profile mode %d on YELLOWCARP\n",
-					profile_mode);
-		return -EINVAL;
-	}
-
-	ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_ActiveProcessNotify,
-				    1 << workload_type,
-				    NULL);
-	if (ret) {
-		dev_err_once(smu->adev->dev, "Fail to set workload type %d\n",
-					workload_type);
-		return ret;
-	}
-
-	smu->power_profile_mode = profile_mode;
-
-	return 0;
-}
-
 static ssize_t yellow_carp_get_gpu_metrics(struct smu_context *smu,
 						void **table)
 {
@@ -1238,8 +1154,6 @@ static const struct pptable_funcs yellow_carp_ppt_funcs = {
 	.read_sensor = yellow_carp_read_sensor,
 	.is_dpm_running = yellow_carp_is_dpm_running,
 	.set_watermarks_table = yellow_carp_set_watermarks_table,
-	.get_power_profile_mode = yellow_carp_get_power_profile_mode,
-	.set_power_profile_mode = yellow_carp_set_power_profile_mode,
 	.get_gpu_metrics = yellow_carp_get_gpu_metrics,
 	.get_enabled_mask = smu_cmn_get_enabled_32_bits_mask,
 	.get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
@@ -1261,6 +1175,5 @@ void yellow_carp_set_ppt_funcs(struct smu_context *smu)
 	smu->message_map = yellow_carp_message_map;
 	smu->feature_map = yellow_carp_feature_mask_map;
 	smu->table_map = yellow_carp_table_map;
-	smu->workload_map = yellow_carp_workload_map;
 	smu->is_apu = true;
 }
commit cc22b9276103c381e0c093123048c512d58998eb
Author: Graham Sider <Graham.Sider at amd.com>
Date:   Mon Nov 1 13:56:25 2021 -0400

    drm/amdkfd: update gfx target version for Renoir
    
    Previously Renoir compiler gfx target version was forced to Raven.
    Update driver side for completeness.
    
    Signed-off-by: Graham Sider <Graham.Sider at amd.com>
    Reviewed-by: Huang Rui <ray.huang at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
index 0fffaf859c59..3b119db16003 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
@@ -406,7 +406,7 @@ static const struct kfd_device_info aldebaran_device_info = {
 static const struct kfd_device_info renoir_device_info = {
 	.asic_family = CHIP_RENOIR,
 	.asic_name = "renoir",
-	.gfx_target_version = 90002,
+	.gfx_target_version = 90012,
 	.max_pasid_bits = 16,
 	.max_no_of_hqd  = 24,
 	.doorbell_size  = 8,
commit c92f909614867421f8caad1e3bfde3ee2e871179
Author: Mario Limonciello <mario.limonciello at amd.com>
Date:   Fri Jul 30 11:02:30 2021 -0500

    drm/amdgpu: Convert SMU version to decimal in debugfs
    
    This is more useful when talking to the SMU team to have the information
    in this format, save one less step to manually do it.
    
    Reviewed-by: Lijo Lazar <lijo.lazar at amd.com>
    Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index dfe667ea8b05..651c7abfde03 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -1423,6 +1423,8 @@ static int amdgpu_debugfs_firmware_info_show(struct seq_file *m, void *unused)
 	struct drm_amdgpu_info_firmware fw_info;
 	struct drm_amdgpu_query_fw query_fw;
 	struct atom_context *ctx = adev->mode_info.atom_context;
+	uint8_t smu_minor, smu_debug;
+	uint16_t smu_major;
 	int ret, i;
 
 	static const char *ta_fw_name[TA_FW_TYPE_MAX_INDEX] = {
@@ -1568,8 +1570,11 @@ static int amdgpu_debugfs_firmware_info_show(struct seq_file *m, void *unused)
 	ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
 	if (ret)
 		return ret;
-	seq_printf(m, "SMC feature version: %u, firmware version: 0x%08x\n",
-		   fw_info.feature, fw_info.ver);
+	smu_major = (fw_info.ver >> 16) & 0xffff;
+	smu_minor = (fw_info.ver >> 8) & 0xff;
+	smu_debug = (fw_info.ver >> 0) & 0xff;
+	seq_printf(m, "SMC feature version: %u, firmware version: 0x%08x (%d.%d.%d)\n",
+		   fw_info.feature, fw_info.ver, smu_major, smu_minor, smu_debug);
 
 	/* SDMA */
 	query_fw.fw_type = AMDGPU_INFO_FW_SDMA;
commit 740a451b0797bf91cd6adb1b6e86d4422e37a34a
Author: Felix Kuehling <Felix.Kuehling at amd.com>
Date:   Wed Oct 27 19:24:46 2021 -0400

    drm/amdkfd: Handle incomplete migration to system memory
    
    If some pages fail to migrate to system memory, don't update
    prange->actual_loc = 0. This prevents endless CPU page faults after
    partial migration failures due to contested page locks.
    
    Migration to RAM must be complete during migrations from VRAM to VRAM and
    during evictions. Implement retry and fail if the migration to RAM fails.
    
    Signed-off-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Reviewed-by: Philip Yang <Philip.Yang at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
index 6d8634e40b3b..cc1525095937 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -281,6 +281,19 @@ static unsigned long svm_migrate_successful_pages(struct migrate_vma *migrate)
 	return cpages;
 }
 
+static unsigned long svm_migrate_unsuccessful_pages(struct migrate_vma *migrate)
+{
+	unsigned long upages = 0;
+	unsigned long i;
+
+	for (i = 0; i < migrate->npages; i++) {
+		if (migrate->src[i] & MIGRATE_PFN_VALID &&
+		    !(migrate->src[i] & MIGRATE_PFN_MIGRATE))
+			upages++;
+	}
+	return upages;
+}
+
 static int
 svm_migrate_copy_to_vram(struct amdgpu_device *adev, struct svm_range *prange,
 			 struct migrate_vma *migrate, struct dma_fence **mfence,
@@ -634,10 +647,11 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
 		       struct vm_area_struct *vma, uint64_t start, uint64_t end)
 {
 	uint64_t npages = (end - start) >> PAGE_SHIFT;
+	unsigned long upages = npages;
+	unsigned long cpages = 0;
 	struct kfd_process_device *pdd;
 	struct dma_fence *mfence = NULL;
 	struct migrate_vma migrate;
-	unsigned long cpages = 0;
 	dma_addr_t *scratch;
 	size_t size;
 	void *buf;
@@ -671,6 +685,7 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
 	if (!cpages) {
 		pr_debug("failed collect migrate device pages [0x%lx 0x%lx]\n",
 			 prange->start, prange->last);
+		upages = svm_migrate_unsuccessful_pages(&migrate);
 		goto out_free;
 	}
 	if (cpages != npages)
@@ -683,8 +698,9 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
 				    scratch, npages);
 	migrate_vma_pages(&migrate);
 
-	pr_debug("successful/cpages/npages 0x%lx/0x%lx/0x%lx\n",
-		svm_migrate_successful_pages(&migrate), cpages, migrate.npages);
+	upages = svm_migrate_unsuccessful_pages(&migrate);
+	pr_debug("unsuccessful/cpages/npages 0x%lx/0x%lx/0x%lx\n",
+		 upages, cpages, migrate.npages);
 
 	svm_migrate_copy_done(adev, mfence);
 	migrate_vma_finalize(&migrate);
@@ -698,9 +714,9 @@ out:
 		if (pdd)
 			WRITE_ONCE(pdd->page_out, pdd->page_out + cpages);
 
-		return cpages;
+		return upages;
 	}
-	return r;
+	return r ? r : upages;
 }
 
 /**
@@ -720,7 +736,7 @@ int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm)
 	unsigned long addr;
 	unsigned long start;
 	unsigned long end;
-	unsigned long cpages = 0;
+	unsigned long upages = 0;
 	long r = 0;
 
 	if (!prange->actual_loc) {
@@ -756,12 +772,12 @@ int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm)
 			pr_debug("failed %ld to migrate\n", r);
 			break;
 		} else {
-			cpages += r;
+			upages += r;
 		}
 		addr = next;
 	}
 
-	if (cpages) {
+	if (!upages) {
 		svm_range_vram_node_free(prange);
 		prange->actual_loc = 0;
 	}
@@ -784,7 +800,7 @@ static int
 svm_migrate_vram_to_vram(struct svm_range *prange, uint32_t best_loc,
 			 struct mm_struct *mm)
 {
-	int r;
+	int r, retries = 3;
 
 	/*
 	 * TODO: for both devices with PCIe large bar or on same xgmi hive, skip
@@ -793,9 +809,14 @@ svm_migrate_vram_to_vram(struct svm_range *prange, uint32_t best_loc,
 
 	pr_debug("from gpu 0x%x to gpu 0x%x\n", prange->actual_loc, best_loc);
 
-	r = svm_migrate_vram_to_ram(prange, mm);
-	if (r)
-		return r;
+	do {
+		r = svm_migrate_vram_to_ram(prange, mm);
+		if (r)
+			return r;
+	} while (prange->actual_loc && --retries);
+
+	if (prange->actual_loc)
+		return -EDEADLK;
 
 	return svm_migrate_ram_to_vram(prange, best_loc, mm);
 }
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 5eaa39675690..a2000a12bed4 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -3096,6 +3096,8 @@ static void svm_range_evict_svm_bo_worker(struct work_struct *work)
 		struct svm_range *prange =
 				list_first_entry(&svm_bo->range_list,
 						struct svm_range, svm_bo_list);
+		int retries = 3;
+
 		list_del_init(&prange->svm_bo_list);
 		spin_unlock(&svm_bo->list_lock);
 
@@ -3103,7 +3105,11 @@ static void svm_range_evict_svm_bo_worker(struct work_struct *work)
 			 prange->start, prange->last);
 
 		mutex_lock(&prange->migrate_mutex);
-		svm_migrate_vram_to_ram(prange, svm_bo->eviction_fence->mm);
+		do {
+			svm_migrate_vram_to_ram(prange,
+						svm_bo->eviction_fence->mm);
+		} while (prange->actual_loc && --retries);
+		WARN(prange->actual_loc, "Migration failed during eviction");
 
 		mutex_lock(&prange->lock);
 		prange->svm_bo = NULL;
commit 12fcf0a7dacca7d84b100bd34a7b8bb1f3198552
Author: Felix Kuehling <Felix.Kuehling at amd.com>
Date:   Wed Oct 27 17:40:51 2021 -0400

    drm/amdkfd: Avoid thrashing of stack and heap
    
    Stack and heap pages tend to be shared by many small allocations.
    Concurrent access by CPU and GPU is therefore likely, which can lead to
    thrashing. Avoid this by setting the preferred location to system memory.
    
    Signed-off-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Signed-off-by: Philip Yang <Philip.Yang at amd.com>
    Reviewed-by: Philip Yang <Philip.Yang at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 5484f15b503b..5eaa39675690 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -2321,7 +2321,8 @@ svm_range_best_restore_location(struct svm_range *prange,
 
 static int
 svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr,
-				unsigned long *start, unsigned long *last)
+			       unsigned long *start, unsigned long *last,
+			       bool *is_heap_stack)
 {
 	struct vm_area_struct *vma;
 	struct interval_tree_node *node;
@@ -2332,6 +2333,12 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr,
 		pr_debug("VMA does not exist in address [0x%llx]\n", addr);
 		return -EFAULT;
 	}
+
+	*is_heap_stack = (vma->vm_start <= vma->vm_mm->brk &&
+			  vma->vm_end >= vma->vm_mm->start_brk) ||
+			 (vma->vm_start <= vma->vm_mm->start_stack &&
+			  vma->vm_end >= vma->vm_mm->start_stack);
+
 	start_limit = max(vma->vm_start >> PAGE_SHIFT,
 		      (unsigned long)ALIGN_DOWN(addr, 2UL << 8));
 	end_limit = min(vma->vm_end >> PAGE_SHIFT,
@@ -2361,9 +2368,9 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr,
 	*start = start_limit;
 	*last = end_limit - 1;
 
-	pr_debug("vma start: 0x%lx start: 0x%lx vma end: 0x%lx last: 0x%lx\n",
-		  vma->vm_start >> PAGE_SHIFT, *start,
-		  vma->vm_end >> PAGE_SHIFT, *last);
+	pr_debug("vma [0x%lx 0x%lx] range [0x%lx 0x%lx] is_heap_stack %d\n",
+		 vma->vm_start >> PAGE_SHIFT, vma->vm_end >> PAGE_SHIFT,
+		 *start, *last, *is_heap_stack);
 
 	return 0;
 }
@@ -2428,11 +2435,13 @@ svm_range *svm_range_create_unregistered_range(struct amdgpu_device *adev,
 	struct svm_range *prange = NULL;
 	unsigned long start, last;
 	uint32_t gpuid, gpuidx;
+	bool is_heap_stack;
 	uint64_t bo_s = 0;
 	uint64_t bo_l = 0;
 	int r;
 
-	if (svm_range_get_range_boundaries(p, addr, &start, &last))
+	if (svm_range_get_range_boundaries(p, addr, &start, &last,
+					   &is_heap_stack))
 		return NULL;
 
 	r = svm_range_check_vm(p, start, last, &bo_s, &bo_l);
@@ -2459,6 +2468,9 @@ svm_range *svm_range_create_unregistered_range(struct amdgpu_device *adev,
 		return NULL;
 	}
 
+	if (is_heap_stack)
+		prange->preferred_loc = KFD_IOCTL_SVM_LOCATION_SYSMEM;
+
 	svm_range_add_to_svms(prange);
 	svm_range_add_notifier_locked(mm, prange);
 
commit 297753a06a88d7e2b56489049f4adf0d1aac290f
Author: Felix Kuehling <Felix.Kuehling at amd.com>
Date:   Wed Oct 27 17:21:23 2021 -0400

    drm/amdkfd: Fix SVM_ATTR_PREFERRED_LOC
    
    The preferred location should be used as the migration destination
    whenever it is accessible by the faulting GPU. System memory is always
    accessible. Peer memory is accessible if it's in the same XGMI hive.
    
    Signed-off-by: Felix Kuehling <Felix.Kuehling at amd.com>
    Reviewed-by: Philip Yang <Philip.Yang at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index b691c8495d66..5484f15b503b 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -2261,7 +2261,7 @@ svm_range_from_addr(struct svm_range_list *svms, unsigned long addr,
  * migration if actual loc is not best location, then update GPU page table
  * mapping to the best location.
  *
- * If vm fault gpu is range preferred loc, the best_loc is preferred loc.
+ * If the preferred loc is accessible by faulting GPU, use preferred loc.
  * If vm fault gpu idx is on range ACCESSIBLE bitmap, best_loc is vm fault gpu
  * If vm fault gpu idx is on range ACCESSIBLE_IN_PLACE bitmap, then
  *    if range actual loc is cpu, best_loc is cpu
@@ -2278,7 +2278,7 @@ svm_range_best_restore_location(struct svm_range *prange,
 				struct amdgpu_device *adev,
 				int32_t *gpuidx)
 {
-	struct amdgpu_device *bo_adev;
+	struct amdgpu_device *bo_adev, *preferred_adev;
 	struct kfd_process *p;
 	uint32_t gpuid;
 	int r;
@@ -2291,8 +2291,16 @@ svm_range_best_restore_location(struct svm_range *prange,
 		return -1;
 	}
 
-	if (prange->preferred_loc == gpuid)
+	if (prange->preferred_loc == gpuid ||
+	    prange->preferred_loc == KFD_IOCTL_SVM_LOCATION_SYSMEM) {
 		return prange->preferred_loc;
+	} else if (prange->preferred_loc != KFD_IOCTL_SVM_LOCATION_UNDEFINED) {
+		preferred_adev = svm_range_get_adev_by_id(prange,
+							prange->preferred_loc);
+		if (amdgpu_xgmi_same_hive(adev, preferred_adev))
+			return prange->preferred_loc;
+		/* fall through */
+	}
 
 	if (test_bit(*gpuidx, prange->bitmap_access))
 		return gpuid;
commit 72c148d776b454a358a16993f11587dca237f259
Author: Oak Zeng <Oak.Zeng at amd.com>
Date:   Wed Jul 28 20:51:14 2021 -0500

    drm/amdgpu: use correct register mask to extract field
    
    Aldebaran has different register mask definitions for
    regiter MC_VM_XGMI_LFB_CNTL. Use the correct masks
    to interpret fields of this register.
    
    Signed-off-by: Oak Zeng <Oak.Zeng at amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c
index 497b86c376c6..90f0aefbdb39 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c
@@ -54,15 +54,17 @@ int gfxhub_v1_1_get_xgmi_info(struct amdgpu_device *adev)
 		seg_size = REG_GET_FIELD(
 			RREG32_SOC15(GC, 0, mmMC_VM_XGMI_LFB_SIZE_ALDE),
 			MC_VM_XGMI_LFB_SIZE, PF_LFB_SIZE) << 24;
+		max_region =
+			REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL_ALDE, PF_MAX_REGION);
 	} else {
 		xgmi_lfb_cntl = RREG32_SOC15(GC, 0, mmMC_VM_XGMI_LFB_CNTL);
 		seg_size = REG_GET_FIELD(
 			RREG32_SOC15(GC, 0, mmMC_VM_XGMI_LFB_SIZE),
 			MC_VM_XGMI_LFB_SIZE, PF_LFB_SIZE) << 24;
+		max_region =
+			REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL, PF_MAX_REGION);
 	}
 
-	max_region =
-		REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL, PF_MAX_REGION);
 
 
 	switch (adev->asic_type) {
@@ -89,9 +91,15 @@ int gfxhub_v1_1_get_xgmi_info(struct amdgpu_device *adev)
 		if (adev->gmc.xgmi.num_physical_nodes > max_num_physical_nodes)
 			return -EINVAL;
 
-		adev->gmc.xgmi.physical_node_id =
-		REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL,
-			      PF_LFB_REGION);
+		if (adev->asic_type == CHIP_ALDEBARAN) {
+			adev->gmc.xgmi.physical_node_id =
+				REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL_ALDE,
+						PF_LFB_REGION);
+		} else {
+			adev->gmc.xgmi.physical_node_id =
+				REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL,
+						PF_LFB_REGION);
+		}
 
 		if (adev->gmc.xgmi.physical_node_id > max_physical_node_id)
 			return -EINVAL;
commit 38d4e4638e85ae52bec2c33869b2131e24d49229
Author: Jingwen Chen <Jingwen.Chen2 at amd.com>
Date:   Fri Oct 22 11:30:01 2021 +0800

    drm/amd/amdgpu: fix bad job hw_fence use after free in advance tdr
    
    [Why]
    In advance tdr mode, the real bad job will be resubmitted twice, while
    in drm_sched_resubmit_jobs_ext, there's a dma_fence_put, so the bad job
    is put one more time than other jobs.
    
    [How]
    Adding dma_fence_get before resbumit job in
    amdgpu_device_recheck_guilty_jobs and put the fence for normal jobs
    
    Signed-off-by: Jingwen Chen <Jingwen.Chen2 at amd.com>
    Reviewed-by: Andrey Grodzovsky <andrey.grodzovsky at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 6e40cc1bc6dc..7c3f6ee14853 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4850,6 +4850,9 @@ static void amdgpu_device_recheck_guilty_jobs(
 
 		/* clear job's guilty and depend the folowing step to decide the real one */
 		drm_sched_reset_karma(s_job);
+		/* for the real bad job, it will be resubmitted twice, adding a dma_fence_get
+		 * to make sure fence is balanced */
+		dma_fence_get(s_job->s_fence->parent);
 		drm_sched_resubmit_jobs_ext(&ring->sched, 1);
 
 		ret = dma_fence_wait_timeout(s_job->s_fence->parent, false, ring->sched.timeout);
@@ -4885,6 +4888,7 @@ retry:
 
 		/* got the hw fence, signal finished fence */
 		atomic_dec(ring->sched.score);
+		dma_fence_put(s_job->s_fence->parent);
 		dma_fence_get(&s_job->s_fence->finished);
 		dma_fence_signal(&s_job->s_fence->finished);
 		dma_fence_put(&s_job->s_fence->finished);
commit 8244a3bc27b3efd057da154b8d7e414670d5044f
Author: Anand K Mistry <amistry at google.com>
Date:   Thu Sep 30 09:00:07 2021 +1000

    drm/prime: Fix use after free in mmap with drm_gem_ttm_mmap
    
    drm_gem_ttm_mmap() drops a reference to the gem object on success. If
    the gem object's refcount == 1 on entry to drm_gem_prime_mmap(), that
    drop will free the gem object, and the subsequent drm_gem_object_get()
    will be a UAF. Fix by grabbing a reference before calling the mmap
    helper.
    
    This issue was forseen when the reference dropping was adding in
    commit 9786b65bc61ac ("drm/ttm: fix mmap refcounting"):
      "For that to work properly the drm_gem_object_get() call in
      drm_gem_ttm_mmap() must be moved so it happens before calling
      obj->funcs->mmap(), otherwise the gem refcount would go down
      to zero."
    
    Signed-off-by: Anand K Mistry <amistry at google.com>
    Fixes: 9786b65bc61a ("drm/ttm: fix mmap refcounting")
    Cc: Gerd Hoffmann <kraxel at redhat.com>
    Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
    Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
    Cc: Maxime Ripard <mripard at kernel.org>
    Cc: Thomas Zimmermann <tzimmermann at suse.de>
    Cc: David Airlie <airlied at linux.ie>
    Cc: Daniel Vetter <daniel at ffwll.ch>
    Cc: dri-devel at lists.freedesktop.org
    Cc: <stable at vger.kernel.org> # v5.5+
    Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210930085932.1.I8043d61cc238e0168e2f4ca5f4783223434aa587@changeid

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index deb23dbec8b5..d6c7f4f9a7a2 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -719,11 +719,13 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 	if (obj->funcs && obj->funcs->mmap) {
 		vma->vm_ops = obj->funcs->vm_ops;
 
+		drm_gem_object_get(obj);
 		ret = obj->funcs->mmap(obj, vma);
-		if (ret)
+		if (ret) {
+			drm_gem_object_put(obj);
 			return ret;
+		}
 		vma->vm_private_data = obj;
-		drm_gem_object_get(obj);
 		return 0;
 	}
 
commit 1977e8eb40ed53f0cac7db1a78295726f4ac0b24
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Mon Oct 25 17:21:47 2021 +0300

    drm/i915: Fix type1 DVI DP dual mode adapter heuristic for modern platforms
    
    Looks like we never updated intel_bios_is_port_dp_dual_mode() when
    the VBT port mapping became erratic on modern platforms. This
    is causing us to look up the wrong child device and thus throwing
    the heuristic off (ie. we might end looking at a child device for
    a genuine DP++ port when we were supposed to look at one for a
    native HDMI port).
    
    Fix it up by not using the outdated port_mapping[] in
    intel_bios_is_port_dp_dual_mode() and rely on
    intel_bios_encoder_data_lookup() instead.
    
    Cc: stable at vger.kernel.org
    Tested-by: Randy Dunlap <rdunlap at infradead.org>
    Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4138
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211025142147.23897-1-ville.syrjala@linux.intel.com
    Reviewed-by: Jani Nikula <jani.nikula at intel.com>
    (cherry picked from commit 32c2bc89c7420fad2959ee23ef5b6be8b05d2bde)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index f9776ca85de3..2b1423a43437 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -1707,6 +1707,39 @@ static void sanitize_aux_ch(struct intel_bios_encoder_data *devdata,
 	child->aux_channel = 0;
 }
 
+static u8 dvo_port_type(u8 dvo_port)
+{
+	switch (dvo_port) {
+	case DVO_PORT_HDMIA:
+	case DVO_PORT_HDMIB:
+	case DVO_PORT_HDMIC:
+	case DVO_PORT_HDMID:
+	case DVO_PORT_HDMIE:
+	case DVO_PORT_HDMIF:
+	case DVO_PORT_HDMIG:
+	case DVO_PORT_HDMIH:
+	case DVO_PORT_HDMII:
+		return DVO_PORT_HDMIA;
+	case DVO_PORT_DPA:
+	case DVO_PORT_DPB:
+	case DVO_PORT_DPC:
+	case DVO_PORT_DPD:
+	case DVO_PORT_DPE:
+	case DVO_PORT_DPF:
+	case DVO_PORT_DPG:
+	case DVO_PORT_DPH:
+	case DVO_PORT_DPI:
+		return DVO_PORT_DPA;
+	case DVO_PORT_MIPIA:
+	case DVO_PORT_MIPIB:
+	case DVO_PORT_MIPIC:
+	case DVO_PORT_MIPID:
+		return DVO_PORT_MIPIA;
+	default:
+		return dvo_port;
+	}
+}
+
 static enum port __dvo_port_to_port(int n_ports, int n_dvo,
 				    const int port_mapping[][3], u8 dvo_port)
 {
@@ -2623,35 +2656,17 @@ bool intel_bios_is_port_edp(struct drm_i915_private *i915, enum port port)
 	return false;
 }
 
-static bool child_dev_is_dp_dual_mode(const struct child_device_config *child,
-				      enum port port)
+static bool child_dev_is_dp_dual_mode(const struct child_device_config *child)
 {
-	static const struct {
-		u16 dp, hdmi;
-	} port_mapping[] = {
-		/*
-		 * Buggy VBTs may declare DP ports as having
-		 * HDMI type dvo_port :( So let's check both.
-		 */
-		[PORT_B] = { DVO_PORT_DPB, DVO_PORT_HDMIB, },
-		[PORT_C] = { DVO_PORT_DPC, DVO_PORT_HDMIC, },
-		[PORT_D] = { DVO_PORT_DPD, DVO_PORT_HDMID, },
-		[PORT_E] = { DVO_PORT_DPE, DVO_PORT_HDMIE, },
-		[PORT_F] = { DVO_PORT_DPF, DVO_PORT_HDMIF, },
-	};
-
-	if (port == PORT_A || port >= ARRAY_SIZE(port_mapping))
-		return false;
-
 	if ((child->device_type & DEVICE_TYPE_DP_DUAL_MODE_BITS) !=
 	    (DEVICE_TYPE_DP_DUAL_MODE & DEVICE_TYPE_DP_DUAL_MODE_BITS))
 		return false;
 
-	if (child->dvo_port == port_mapping[port].dp)
+	if (dvo_port_type(child->dvo_port) == DVO_PORT_DPA)
 		return true;
 
 	/* Only accept a HDMI dvo_port as DP++ if it has an AUX channel */
-	if (child->dvo_port == port_mapping[port].hdmi &&
+	if (dvo_port_type(child->dvo_port) == DVO_PORT_HDMIA &&
 	    child->aux_channel != 0)
 		return true;
 
@@ -2661,10 +2676,36 @@ static bool child_dev_is_dp_dual_mode(const struct child_device_config *child,
 bool intel_bios_is_port_dp_dual_mode(struct drm_i915_private *i915,
 				     enum port port)
 {
+	static const struct {
+		u16 dp, hdmi;
+	} port_mapping[] = {
+		/*
+		 * Buggy VBTs may declare DP ports as having
+		 * HDMI type dvo_port :( So let's check both.
+		 */
+		[PORT_B] = { DVO_PORT_DPB, DVO_PORT_HDMIB, },
+		[PORT_C] = { DVO_PORT_DPC, DVO_PORT_HDMIC, },
+		[PORT_D] = { DVO_PORT_DPD, DVO_PORT_HDMID, },
+		[PORT_E] = { DVO_PORT_DPE, DVO_PORT_HDMIE, },
+		[PORT_F] = { DVO_PORT_DPF, DVO_PORT_HDMIF, },
+	};
 	const struct intel_bios_encoder_data *devdata;
 
+	if (HAS_DDI(i915)) {
+		const struct intel_bios_encoder_data *devdata;
+
+		devdata = intel_bios_encoder_data_lookup(i915, port);
+
+		return devdata && child_dev_is_dp_dual_mode(&devdata->child);
+	}
+
+	if (port == PORT_A || port >= ARRAY_SIZE(port_mapping))
+		return false;
+
 	list_for_each_entry(devdata, &i915->vbt.display_devices, node) {
-		if (child_dev_is_dp_dual_mode(&devdata->child, port))
+		if ((devdata->child.dvo_port == port_mapping[port].dp ||
+		     devdata->child.dvo_port == port_mapping[port].hdmi) &&
+		    child_dev_is_dp_dual_mode(&devdata->child))
 			return true;
 	}
 
commit 99bac3063e8e0f437b04897a399b9394919d1a79
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Thu Sep 30 22:09:42 2021 +0300

    drm/i915: Extend the async flip VT-d w/a to skl/bxt
    
    Looks like skl/bxt/derivatives also need the plane stride
    stretch w/a when using async flips and VT-d is enabled, or
    else we get corruption on screen. To my surprise this was
    even documented in bspec, but only as a note on the
    CHICHKEN_PIPESL register description rather than on the
    w/a list.
    
    So very much the same thing as on HSW/BDW, except the bits
    moved yet again.
    
    Cc: stable at vger.kernel.org
    Cc: Karthik B S <karthik.b.s at intel.com>
    Fixes: 55ea1cb178ef ("drm/i915: Enable async flips in i915")
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210930190943.17547-1-ville.syrjala@linux.intel.com
    Reviewed-by: Matt Roper <matthew.d.roper at intel.com>
    (cherry picked from commit d08df3b0bdb25546e86dc9a6c4e3ec0c43832299)
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>
    (cherry picked from commit b2d73debfdc16b742e64948dc4461876af3f8c10)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index f90fe39cf8ca..ecbb3d141632 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -77,6 +77,8 @@ struct intel_wm_config {
 
 static void gen9_init_clock_gating(struct drm_i915_private *dev_priv)
 {
+	enum pipe pipe;
+
 	if (HAS_LLC(dev_priv)) {
 		/*
 		 * WaCompressedResourceDisplayNewHashMode:skl,kbl
@@ -90,6 +92,16 @@ static void gen9_init_clock_gating(struct drm_i915_private *dev_priv)
 			   SKL_DE_COMPRESSED_HASH_MODE);
 	}
 
+	for_each_pipe(dev_priv, pipe) {
+		/*
+		 * "Plane N strech max must be programmed to 11b (x1)
+		 *  when Async flips are enabled on that plane."
+		 */
+		if (!IS_GEMINILAKE(dev_priv) && intel_vtd_active())
+			intel_uncore_rmw(&dev_priv->uncore, CHICKEN_PIPESL_1(pipe),
+					 SKL_PLANE1_STRETCH_MAX_MASK, SKL_PLANE1_STRETCH_MAX_X1);
+	}
+
 	/* See Bspec note for PSR2_CTL bit 31, Wa#828:skl,bxt,kbl,cfl */
 	intel_uncore_write(&dev_priv->uncore, CHICKEN_PAR1_1,
 		   intel_uncore_read(&dev_priv->uncore, CHICKEN_PAR1_1) | SKL_EDP_PSR_FIX_RDWRAP);
commit af6c83ae25a556376ff08291200716232b5a6efc
Author: Zhi A Wang <zhi.wang.linux2 at gmail.com>
Date:   Thu Aug 26 14:38:34 2021 +0000

    drm/i915/gvt: fix the usage of ww lock in gvt scheduler.
    
    As the APIs related to ww lock in i915 was changed recently, the usage of
    ww lock in GVT-g scheduler needs to be changed accrodingly. We noticed a
    deadlock when GVT-g scheduler submits the workload to i915. After some
    investigation, it seems the way of how to use ww lock APIs has been
    changed. Releasing a ww now requires a explicit i915_gem_ww_ctx_fini().
    
    Fixes: 67f1120381df ("drm/i915/gvt: Introduce per object locking in GVT scheduler.")
    Cc: Zhenyu Wang <zhenyuw at linux.intel.com>
    Signed-off-by: Zhi A Wang <zhi.a.wang at intel.com>
    Signed-off-by: Zhenyu Wang <zhenyuw at linux.intel.com>
    Link: http://patchwork.freedesktop.org/patch/msgid/20210826143834.25410-1-zhi.a.wang@intel.com
    Acked-by: Zhenyu Wang <zhenyuw at linux.intel.com>
    (cherry picked from commit d168cd797982db9db617113644c87b8f5f3cf27e)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index 0d18e13e3468..6c804102528b 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -576,7 +576,7 @@ retry:
 
 			/* No one is going to touch shadow bb from now on. */
 			i915_gem_object_flush_map(bb->obj);
-			i915_gem_object_unlock(bb->obj);
+			i915_gem_ww_ctx_fini(&ww);
 		}
 	}
 	return 0;
@@ -630,7 +630,7 @@ retry:
 		return ret;
 	}
 
-	i915_gem_object_unlock(wa_ctx->indirect_ctx.obj);
+	i915_gem_ww_ctx_fini(&ww);
 
 	/* FIXME: we are not tracking our pinned VMA leaving it
 	 * up to the core to fix up the stray pin_count upon
commit 8bb7eca972ad531c9b149c0a51ab43a417385813
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Sun Oct 31 13:53:10 2021 -0700

    Linux 5.15

diff --git a/Makefile b/Makefile
index 30c7c81d0437..ed6e7ec60eff 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,8 @@
 VERSION = 5
 PATCHLEVEL = 15
 SUBLEVEL = 0
-EXTRAVERSION = -rc7
-NAME = Opossums on Parade
+EXTRAVERSION =
+NAME = Trick or Treat
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
commit 75fcbd38608c3ce9f4dc784f2ac8916add64c9a8
Merge: ca5e83eddc8b 27730c8cd60d
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Sun Oct 31 11:24:06 2021 -0700

    Merge tag 'perf-tools-fixes-for-v5.15-2021-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
    
    Pull perf tools fixes from Arnaldo Carvalho de Melo:
    
     - Fix compilation of callchain related code on powerpc with gcc11+
    
     - Fix PERF_SAMPLE_WEIGHT_STRUCT support in 'perf script'
    
     - Check session->header.env.arch before using it, fixing a segmentation
       fault
    
     - Suppress 'rm dlfilter' build messages
    
    * tag 'perf-tools-fixes-for-v5.15-2021-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
      perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support
      perf callchain: Fix compilation on powerpc with gcc11+
      perf script: Check session->header.env.arch before using it
      perf build: Suppress 'rm dlfilter' build message

commit ca5e83eddc8bc85db5698ef702b610ee64243459
Merge: 180eca540ae0 f3d1436d4bf8
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Sun Oct 31 11:19:02 2021 -0700

    Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
    
    Pull kvm fixes from Paolo Bonzini:
    
     - Fixes for s390 interrupt delivery
    
     - Fixes for Xen emulator bugs showing up as debug kernel WARNs
    
     - Fix another issue with SEV/ES string I/O VMGEXITs
    
    * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
      KVM: x86: Take srcu lock in post_kvm_run_save()
      KVM: SEV-ES: fix another issue with string I/O VMGEXITs
      KVM: x86/xen: Fix kvm_xen_has_interrupt() sleeping in kvm_vcpu_block()
      KVM: x86: switch pvclock_gtod_sync_lock to a raw spinlock
      KVM: s390: preserve deliverable_mask in __airqs_kick_single_vcpu
      KVM: s390: clear kicked_mask before sleeping again

commit 27730c8cd60d1574d8337276e7a9d7d2ca92e0d1
Author: Kan Liang <kan.liang at linux.intel.com>
Date:   Wed Sep 29 08:38:13 2021 -0700

    perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support
    
    -F weight in perf script is broken.
    
      # ./perf mem record
      # ./perf script -F weight
      Samples for 'dummy:HG' event do not have WEIGHT attribute set. Cannot
    print 'weight' field.
    
    The sample type, PERF_SAMPLE_WEIGHT_STRUCT, is an alternative of the
    PERF_SAMPLE_WEIGHT sample type. They share the same space, weight. The
    lower 32 bits are exactly the same for both sample type. The higher 32
    bits may be different for different architecture. For a new kernel on
    x86, the PERF_SAMPLE_WEIGHT_STRUCT is used. For an old kernel or other
    ARCHs, the PERF_SAMPLE_WEIGHT is used.
    
    With -F weight, current perf script will only check the input string
    "weight" with the PERF_SAMPLE_WEIGHT sample type. Because the commit
    ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") didn't
    update the PERF_SAMPLE_WEIGHT_STRUCT sample type for perf script. For a
    new kernel on x86, the check fails.
    
    Use PERF_SAMPLE_WEIGHT_TYPE, which supports both sample types, to
    replace PERF_SAMPLE_WEIGHT
    
    Fixes: ea8d0ed6eae37b01 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT")
    Reported-by: Joe Mario <jmario at redhat.com>
    Reviewed-by: Kajol Jain <kjain at linux.ibm.com>
    Signed-off-by: Kan Liang <kan.liang at linux.intel.com>
    Tested-by: Jiri Olsa <jolsa at redhat.com>
    Tested-by: Joe Mario <jmario at redhat.com>
    Acked-by: Jiri Olsa <jolsa at redhat.com>
    Acked-by: Joe Mario <jmario at redhat.com>
    Cc: Andi Kleen <ak at linux.intel.com>
    Link: https://lore.kernel.org/r/1632929894-102778-1-git-send-email-kan.liang@linux.intel.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme at redhat.com>

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 42eb6bdf3c58..c32c2eb16d7d 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -459,7 +459,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
 		return -EINVAL;
 
 	if (PRINT_FIELD(WEIGHT) &&
-	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT, "WEIGHT", PERF_OUTPUT_WEIGHT))
+	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
 		return -EINVAL;
 
 	if (PRINT_FIELD(SYM) &&
commit 89ac61ff05a5c79545aa93f7b1da7e4dbc60fc9a
Author: Jiri Olsa <jolsa at redhat.com>
Date:   Tue Sep 28 21:52:53 2021 +0200

    perf callchain: Fix compilation on powerpc with gcc11+
    
    Got following build fail on powerpc:
    
        CC      arch/powerpc/util/skip-callchain-idx.o
      In function ‘check_return_reg’,
          inlined from ‘check_return_addr’ at arch/powerpc/util/skip-callchain-idx.c:213:7,
          inlined from ‘arch_skip_callchain_idx’ at arch/powerpc/util/skip-callchain-idx.c:265:7:
      arch/powerpc/util/skip-callchain-idx.c:54:18: error: ‘dwarf_frame_register’ accessing 96 bytes \
      in a region of size 64 [-Werror=stringop-overflow=]
         54 |         result = dwarf_frame_register(frame, ra_regno, ops_mem, &ops, &nops);
            |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      arch/powerpc/util/skip-callchain-idx.c: In function ‘arch_skip_callchain_idx’:
      arch/powerpc/util/skip-callchain-idx.c:54:18: note: referencing argument 3 of type ‘Dwarf_Op *’
      In file included from /usr/include/elfutils/libdwfl.h:32,
                       from arch/powerpc/util/skip-callchain-idx.c:10:
      /usr/include/elfutils/libdw.h:1069:12: note: in a call to function ‘dwarf_frame_register’
       1069 | extern int dwarf_frame_register (Dwarf_Frame *frame, int regno,
            |            ^~~~~~~~~~~~~~~~~~~~
      cc1: all warnings being treated as errors
    
    The dwarf_frame_register args changed with [1],
    Updating ops_mem accordingly.
    
    [1] https://sourceware.org/git/?p=elfutils.git;a=commit;h=5621fe5443da23112170235dd5cac161e5c75e65
    
    Reviewed-by: Kajol Jain <kjain at linux.ibm.com>
    Signed-off-by: Jiri Olsa <jolsa at redhat.com>
    Acked-by: Mark Wieelard <mjw at redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin at linux.intel.com>
    Cc: Ian Rogers <irogers at google.com>
    Cc: Ingo Molnar <mingo at kernel.org>
    Cc: Mark Rutland <mark.rutland at arm.com>
    Cc: Michael Petlan <mpetlan at redhat.com>
    Cc: Namhyung Kim <namhyung at kernel.org>
    Cc: Peter Zijlstra <a.p.zijlstra at chello.nl>
    Cc: Sukadev Bhattiprolu <sukadev at linux.vnet.ibm.com>
    Link: https://lore.kernel.org/r/20210928195253.1267023-1-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme at redhat.com>

diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
index 3018a054526a..20cd6244863b 100644
--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
+++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
@@ -45,7 +45,7 @@ static const Dwfl_Callbacks offline_callbacks = {
  */
 static int check_return_reg(int ra_regno, Dwarf_Frame *frame)
 {
-	Dwarf_Op ops_mem[2];
+	Dwarf_Op ops_mem[3];
 	Dwarf_Op dummy;
 	Dwarf_Op *ops = &dummy;
 	size_t nops;
commit 29c77550eef31b0d72a45b49eeab03b8963264e8
Author: Song Liu <songliubraving at fb.com>
Date:   Sun Oct 3 22:32:38 2021 -0700

    perf script: Check session->header.env.arch before using it
    
    When perf.data is not written cleanly, we would like to process existing
    data as much as possible (please see f_header.data.size == 0 condition
    in perf_session__read_header). However, perf.data with partial data may
    crash perf. Specifically, we see crash in 'perf script' for NULL
    session->header.env.arch.
    
    Fix this by checking session->header.env.arch before using it to determine
    native_arch. Also split the if condition so it is easier to read.
    
    Committer notes:
    
    If it is a pipe, we already assume is a native arch, so no need to check
    session->header.env.arch.
    
    Signed-off-by: Song Liu <songliubraving at fb.com>
    Cc: Peter Zijlstra <peterz at infradead.org>
    Cc: kernel-team at fb.com
    Cc: stable at vger.kernel.org
    Link: http://lore.kernel.org/lkml/20211004053238.514936-1-songliubraving@fb.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme at redhat.com>

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 6211d0b84b7a..42eb6bdf3c58 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -4039,11 +4039,15 @@ script_found:
 		goto out_delete;
 
 	uname(&uts);
-	if (data.is_pipe ||  /* assume pipe_mode indicates native_arch */
-	    !strcmp(uts.machine, session->header.env.arch) ||
-	    (!strcmp(uts.machine, "x86_64") &&
-	     !strcmp(session->header.env.arch, "i386")))
+	if (data.is_pipe) { /* Assume pipe_mode indicates native_arch */
 		native_arch = true;
+	} else if (session->header.env.arch) {
+		if (!strcmp(uts.machine, session->header.env.arch))
+			native_arch = true;
+		else if (!strcmp(uts.machine, "x86_64") &&
+			 !strcmp(session->header.env.arch, "i386"))
+			native_arch = true;
+	}
 
 	script.session = session;
 	script__setup_sample_type(&script);
commit 095729484efc4aa4604c474792b059bd940addce
Author: Adrian Hunter <adrian.hunter at intel.com>
Date:   Thu Sep 30 09:28:49 2021 +0300

    perf build: Suppress 'rm dlfilter' build message
    
    The following build message:
    
            rm dlfilters/dlfilter-test-api-v0.o
    
    is unwanted.
    
    The object file is being treated as an intermediate file and being
    automatically removed. Mark the object file as .SECONDARY to prevent
    removal and hence the message.
    
    Requested-by: Arnaldo Carvalho de Melo <acme at kernel.org>
    Signed-off-by: Adrian Hunter <adrian.hunter at intel.com>
    Cc: Jiri Olsa <jolsa at redhat.com>
    Link: http://lore.kernel.org/lkml/20210930062849.110416-1-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme at redhat.com>

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 5cd702062a04..b856afa6eb52 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -787,6 +787,8 @@ $(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h
 	$(Q)$(MKDIR) -p $(OUTPUT)dlfilters
 	$(QUIET_CC)$(CC) -c -Iinclude $(EXTRA_CFLAGS) -o $@ -fpic $<
 
+.SECONDARY: $(DLFILTERS:.so=.o)
+
 $(OUTPUT)dlfilters/%.so: $(OUTPUT)dlfilters/%.o
 	$(QUIET_LINK)$(CC) $(EXTRA_CFLAGS) -shared -o $@ $<
 
commit 180eca540ae06246d594bdd8d8213426a259cc8c
Merge: 3a4347d82efd 09d9e4d04187
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Sat Oct 30 15:56:38 2021 -0700

    Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
    
    Pull SCSI fixes from James Bottomley:
     "Three small fixes, all in drivers, and one sizeable update to the UFS
      driver to remove the HPB 2.0 feature that has been objected to by Jens
      and Christoph.
    
      Although the UFS patch is large and last minute, it's essentially the
      least intrusive way of resolving the objections in time for the 5.15
      release"
    
    * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
      scsi: ufs: ufshpb: Remove HPB2.0 flows
      scsi: mpt3sas: Fix reference tag handling for WRITE_INSERT
      scsi: ufs: ufs-exynos: Correct timeout value setting registers
      scsi: ibmvfc: Fix up duplicate response detection

commit 3a4347d82efdfcc5465b3ed37616426989182915
Merge: bf85ba018f92 675c496d0f92
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Sat Oct 30 09:55:46 2021 -0700

    Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
    
    Pull clk fix from Stephen Boyd:
     "One fix for the composite clk that broke when we changed this clk type
      to use the determine_rate instead of round_rate clk op by default.
      This caused lots of problems on Rockchip SoCs because they heavily use
      the composite clk code to model the clk tree"
    
    * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
      clk: composite: Also consider .determine_rate for rate + mux composites

commit bf85ba018f9229ce54765a62dba2dea60f7cdafb
Merge: 119c85055d86 54c5639d8f50
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Sat Oct 30 09:28:24 2021 -0700

    Merge tag 'riscv-for-linus-5.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
    
    Pull RISC-V fixes from Palmer Dabbelt:
     "These are pretty late, but they do fix concrete issues.
    
       - ensure the trap vector's address is aligned.
    
       - avoid re-populating the KASAN shadow memory.
    
       - allow kasan to build without warnings, which have recently become
         errors"
    
    * tag 'riscv-for-linus-5.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
      riscv: Fix asan-stack clang build
      riscv: Do not re-populate shadow memory with kasan_populate_early_shadow
      riscv: fix misalgned trap vector base address

commit 09d9e4d041876684d33f21d02bcdaea6586734f1
Author: Avri Altman <avri.altman at wdc.com>
Date:   Sat Oct 30 09:23:01 2021 +0300

    scsi: ufs: ufshpb: Remove HPB2.0 flows
    
    The Host Performance Buffer feature allows UFS read commands to carry the
    physical media addresses along with the LBAs, thus allowing less internal
    L2P-table switches in the device.  HPB1.0 allowed a single LBA, while
    HPB2.0 increases this capacity up to 255 blocks.
    
    Carrying more than a single record, the read operation is no longer purely
    of type "read" but a "hybrid" command: Writing the physical address to the
    device in one operation and reading back the required payload in another.
    
    The JEDEC HPB spec defines two commands for this operation:
    HPB-WRITE-BUFFER (0x2) to write the physical addresses to device, and
    HPB-READ to read the payload.
    
    With the current HPB design the UFS driver has no alternative but to divide
    the READ request into 2 separate commands: HPB-WRITE-BUFFER and HPB-READ.
    This causes a great deal of aggravation to the block layer guys who
    demanded that we completely revert the entire HPB driver regardless of the
    huge amount of corporate effort already invested in it.
    
    As a compromise, remove only the pieces that implement the 2.0
    specification. This is done as a matter of urgency for the final 5.15
    release.
    
    Link: https://lore.kernel.org/r/20211030062301.248-1-avri.altman@wdc.com
    Tested-by: Avri Altman <avri.altman at wdc.com>
    Tested-by: Bean Huo <beanhuo at micron.com>
    Reviewed-by: Bart Van Assche <bvanassche at acm.org>
    Reviewed-by: Bean Huo <beanhuo at micron.com>
    Co-developed-by: James Bottomley <James.Bottomley at HansenPartnership.com>
    Signed-off-by: James Bottomley <James.Bottomley at HansenPartnership.com>
    Signed-off-by: Avri Altman <avri.altman at wdc.com>
    Signed-off-by: Martin K. Petersen <martin.petersen at oracle.com>

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 95be7ecdfe10..41f2ff35f82b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2737,12 +2737,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 
 	lrbp->req_abort_skip = false;
 
-	err = ufshpb_prep(hba, lrbp);
-	if (err == -EAGAIN) {
-		lrbp->cmd = NULL;
-		ufshcd_release(hba);
-		goto out;
-	}
+	ufshpb_prep(hba, lrbp);
 
 	ufshcd_comp_scsi_upiu(hba, lrbp);
 
diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c
index 589af5f6b940..026a133149dc 100644
--- a/drivers/scsi/ufs/ufshpb.c
+++ b/drivers/scsi/ufs/ufshpb.c
@@ -84,16 +84,6 @@ static bool ufshpb_is_supported_chunk(struct ufshpb_lu *hpb, int transfer_len)
 	return transfer_len <= hpb->pre_req_max_tr_len;
 }
 
-/*
- * In this driver, WRITE_BUFFER CMD support 36KB (len=9) ~ 1MB (len=256) as
- * default. It is possible to change range of transfer_len through sysfs.
- */
-static inline bool ufshpb_is_required_wb(struct ufshpb_lu *hpb, int len)
-{
-	return len > hpb->pre_req_min_tr_len &&
-	       len <= hpb->pre_req_max_tr_len;
-}
-
 static bool ufshpb_is_general_lun(int lun)
 {
 	return lun < UFS_UPIU_MAX_UNIT_NUM_ID;
@@ -334,7 +324,7 @@ ufshpb_get_pos_from_lpn(struct ufshpb_lu *hpb, unsigned long lpn, int *rgn_idx,
 
 static void
 ufshpb_set_hpb_read_to_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
-			    __be64 ppn, u8 transfer_len, int read_id)
+			    __be64 ppn, u8 transfer_len)
 {
 	unsigned char *cdb = lrbp->cmd->cmnd;
 	__be64 ppn_tmp = ppn;
@@ -346,256 +336,11 @@ ufshpb_set_hpb_read_to_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
 	/* ppn value is stored as big-endian in the host memory */
 	memcpy(&cdb[6], &ppn_tmp, sizeof(__be64));
 	cdb[14] = transfer_len;
-	cdb[15] = read_id;
+	cdb[15] = 0;
 
 	lrbp->cmd->cmd_len = UFS_CDB_SIZE;
 }
 
-static inline void ufshpb_set_write_buf_cmd(unsigned char *cdb,
-					    unsigned long lpn, unsigned int len,
-					    int read_id)
-{
-	cdb[0] = UFSHPB_WRITE_BUFFER;
-	cdb[1] = UFSHPB_WRITE_BUFFER_PREFETCH_ID;
-
-	put_unaligned_be32(lpn, &cdb[2]);
-	cdb[6] = read_id;
-	put_unaligned_be16(len * HPB_ENTRY_SIZE, &cdb[7]);
-
-	cdb[9] = 0x00;	/* Control = 0x00 */
-}
-
-static struct ufshpb_req *ufshpb_get_pre_req(struct ufshpb_lu *hpb)
-{
-	struct ufshpb_req *pre_req;
-
-	if (hpb->num_inflight_pre_req >= hpb->throttle_pre_req) {
-		dev_info(&hpb->sdev_ufs_lu->sdev_dev,
-			 "pre_req throttle. inflight %d throttle %d",
-			 hpb->num_inflight_pre_req, hpb->throttle_pre_req);
-		return NULL;
-	}
-
-	pre_req = list_first_entry_or_null(&hpb->lh_pre_req_free,
-					   struct ufshpb_req, list_req);
-	if (!pre_req) {
-		dev_info(&hpb->sdev_ufs_lu->sdev_dev, "There is no pre_req");
-		return NULL;
-	}
-
-	list_del_init(&pre_req->list_req);
-	hpb->num_inflight_pre_req++;
-
-	return pre_req;
-}
-
-static inline void ufshpb_put_pre_req(struct ufshpb_lu *hpb,
-				      struct ufshpb_req *pre_req)
-{
-	pre_req->req = NULL;
-	bio_reset(pre_req->bio);
-	list_add_tail(&pre_req->list_req, &hpb->lh_pre_req_free);
-	hpb->num_inflight_pre_req--;
-}
-
-static void ufshpb_pre_req_compl_fn(struct request *req, blk_status_t error)
-{
-	struct ufshpb_req *pre_req = (struct ufshpb_req *)req->end_io_data;
-	struct ufshpb_lu *hpb = pre_req->hpb;
-	unsigned long flags;
-
-	if (error) {
-		struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
-		struct scsi_sense_hdr sshdr;
-
-		dev_err(&hpb->sdev_ufs_lu->sdev_dev, "block status %d", error);
-		scsi_command_normalize_sense(cmd, &sshdr);
-		dev_err(&hpb->sdev_ufs_lu->sdev_dev,
-			"code %x sense_key %x asc %x ascq %x",
-			sshdr.response_code,
-			sshdr.sense_key, sshdr.asc, sshdr.ascq);
-		dev_err(&hpb->sdev_ufs_lu->sdev_dev,
-			"byte4 %x byte5 %x byte6 %x additional_len %x",
-			sshdr.byte4, sshdr.byte5,
-			sshdr.byte6, sshdr.additional_length);
-	}
-
-	blk_mq_free_request(req);
-	spin_lock_irqsave(&hpb->rgn_state_lock, flags);
-	ufshpb_put_pre_req(pre_req->hpb, pre_req);
-	spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);
-}
-
-static int ufshpb_prep_entry(struct ufshpb_req *pre_req, struct page *page)
-{
-	struct ufshpb_lu *hpb = pre_req->hpb;
-	struct ufshpb_region *rgn;
-	struct ufshpb_subregion *srgn;
-	__be64 *addr;
-	int offset = 0;
-	int copied;
-	unsigned long lpn = pre_req->wb.lpn;
-	int rgn_idx, srgn_idx, srgn_offset;
-	unsigned long flags;
-
-	addr = page_address(page);
-	ufshpb_get_pos_from_lpn(hpb, lpn, &rgn_idx, &srgn_idx, &srgn_offset);
-
-	spin_lock_irqsave(&hpb->rgn_state_lock, flags);
-
-next_offset:
-	rgn = hpb->rgn_tbl + rgn_idx;
-	srgn = rgn->srgn_tbl + srgn_idx;
-
-	if (!ufshpb_is_valid_srgn(rgn, srgn))
-		goto mctx_error;
-
-	if (!srgn->mctx)
-		goto mctx_error;
-
-	copied = ufshpb_fill_ppn_from_page(hpb, srgn->mctx, srgn_offset,
-					   pre_req->wb.len - offset,
-					   &addr[offset]);
-
-	if (copied < 0)
-		goto mctx_error;
-
-	offset += copied;
-	srgn_offset += copied;
-
-	if (srgn_offset == hpb->entries_per_srgn) {
-		srgn_offset = 0;
-
-		if (++srgn_idx == hpb->srgns_per_rgn) {
-			srgn_idx = 0;
-			rgn_idx++;
-		}
-	}
-
-	if (offset < pre_req->wb.len)
-		goto next_offset;
-
-	spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);
-	return 0;
-mctx_error:
-	spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);
-	return -ENOMEM;
-}
-
-static int ufshpb_pre_req_add_bio_page(struct ufshpb_lu *hpb,
-				       struct request_queue *q,
-				       struct ufshpb_req *pre_req)
-{
-	struct page *page = pre_req->wb.m_page;
-	struct bio *bio = pre_req->bio;
-	int entries_bytes, ret;
-
-	if (!page)
-		return -ENOMEM;
-
-	if (ufshpb_prep_entry(pre_req, page))
-		return -ENOMEM;
-
-	entries_bytes = pre_req->wb.len * sizeof(__be64);
-
-	ret = bio_add_pc_page(q, bio, page, entries_bytes, 0);
-	if (ret != entries_bytes) {
-		dev_err(&hpb->sdev_ufs_lu->sdev_dev,
-			"bio_add_pc_page fail: %d", ret);
-		return -ENOMEM;
-	}
-	return 0;
-}
-
-static inline int ufshpb_get_read_id(struct ufshpb_lu *hpb)
-{
-	if (++hpb->cur_read_id >= MAX_HPB_READ_ID)
-		hpb->cur_read_id = 1;
-	return hpb->cur_read_id;
-}
-
-static int ufshpb_execute_pre_req(struct ufshpb_lu *hpb, struct scsi_cmnd *cmd,
-				  struct ufshpb_req *pre_req, int read_id)
-{
-	struct scsi_device *sdev = cmd->device;
-	struct request_queue *q = sdev->request_queue;
-	struct request *req;
-	struct scsi_request *rq;
-	struct bio *bio = pre_req->bio;
-
-	pre_req->hpb = hpb;
-	pre_req->wb.lpn = sectors_to_logical(cmd->device,
-					     blk_rq_pos(scsi_cmd_to_rq(cmd)));
-	pre_req->wb.len = sectors_to_logical(cmd->device,
-					     blk_rq_sectors(scsi_cmd_to_rq(cmd)));
-	if (ufshpb_pre_req_add_bio_page(hpb, q, pre_req))
-		return -ENOMEM;
-
-	req = pre_req->req;
-
-	/* 1. request setup */
-	blk_rq_append_bio(req, bio);
-	req->rq_disk = NULL;
-	req->end_io_data = (void *)pre_req;
-	req->end_io = ufshpb_pre_req_compl_fn;
-
-	/* 2. scsi_request setup */
-	rq = scsi_req(req);
-	rq->retries = 1;
-
-	ufshpb_set_write_buf_cmd(rq->cmd, pre_req->wb.lpn, pre_req->wb.len,
-				 read_id);
-	rq->cmd_len = scsi_command_size(rq->cmd);
-
-	if (blk_insert_cloned_request(q, req) != BLK_STS_OK)
-		return -EAGAIN;
-
-	hpb->stats.pre_req_cnt++;
-
-	return 0;
-}
-
-static int ufshpb_issue_pre_req(struct ufshpb_lu *hpb, struct scsi_cmnd *cmd,
-				int *read_id)
-{
-	struct ufshpb_req *pre_req;
-	struct request *req = NULL;
-	unsigned long flags;
-	int _read_id;
-	int ret = 0;
-
-	req = blk_get_request(cmd->device->request_queue,
-			      REQ_OP_DRV_OUT | REQ_SYNC, BLK_MQ_REQ_NOWAIT);
-	if (IS_ERR(req))
-		return -EAGAIN;
-
-	spin_lock_irqsave(&hpb->rgn_state_lock, flags);
-	pre_req = ufshpb_get_pre_req(hpb);
-	if (!pre_req) {
-		ret = -EAGAIN;
-		goto unlock_out;
-	}
-	_read_id = ufshpb_get_read_id(hpb);
-	spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);
-
-	pre_req->req = req;
-
-	ret = ufshpb_execute_pre_req(hpb, cmd, pre_req, _read_id);
-	if (ret)
-		goto free_pre_req;
-
-	*read_id = _read_id;
-
-	return ret;
-free_pre_req:
-	spin_lock_irqsave(&hpb->rgn_state_lock, flags);
-	ufshpb_put_pre_req(hpb, pre_req);
-unlock_out:
-	spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);
-	blk_put_request(req);
-	return ret;
-}
-
 /*
  * This function will set up HPB read command using host-side L2P map data.
  */
@@ -609,7 +354,6 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 	__be64 ppn;
 	unsigned long flags;
 	int transfer_len, rgn_idx, srgn_idx, srgn_offset;
-	int read_id = 0;
 	int err = 0;
 
 	hpb = ufshpb_get_hpb_data(cmd->device);
@@ -685,24 +429,8 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 		dev_err(hba->dev, "get ppn failed. err %d\n", err);
 		return err;
 	}
-	if (!ufshpb_is_legacy(hba) &&
-	    ufshpb_is_required_wb(hpb, transfer_len)) {
-		err = ufshpb_issue_pre_req(hpb, cmd, &read_id);
-		if (err) {
-			unsigned long timeout;
-
-			timeout = cmd->jiffies_at_alloc + msecs_to_jiffies(
-				  hpb->params.requeue_timeout_ms);
-
-			if (time_before(jiffies, timeout))
-				return -EAGAIN;
-
-			hpb->stats.miss_cnt++;
-			return 0;
-		}
-	}
 
-	ufshpb_set_hpb_read_to_upiu(hba, lrbp, ppn, transfer_len, read_id);
+	ufshpb_set_hpb_read_to_upiu(hba, lrbp, ppn, transfer_len);
 
 	hpb->stats.hit_cnt++;
 	return 0;
@@ -1841,16 +1569,11 @@ static void ufshpb_lu_parameter_init(struct ufs_hba *hba,
 	u32 entries_per_rgn;
 	u64 rgn_mem_size, tmp;
 
-	/* for pre_req */
-	hpb->pre_req_min_tr_len = hpb_dev_info->max_hpb_single_cmd + 1;
-
 	if (ufshpb_is_legacy(hba))
 		hpb->pre_req_max_tr_len = HPB_LEGACY_CHUNK_HIGH;
 	else
 		hpb->pre_req_max_tr_len = HPB_MULTI_CHUNK_HIGH;
 
-	hpb->cur_read_id = 0;
-
 	hpb->lu_pinned_start = hpb_lu_info->pinned_start;
 	hpb->lu_pinned_end = hpb_lu_info->num_pinned ?
 		(hpb_lu_info->pinned_start + hpb_lu_info->num_pinned - 1)
diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h
index a79e07398970..f15d8fdbce2e 100644
--- a/drivers/scsi/ufs/ufshpb.h
+++ b/drivers/scsi/ufs/ufshpb.h
@@ -241,8 +241,6 @@ struct ufshpb_lu {
 	spinlock_t param_lock;
 
 	struct list_head lh_pre_req_free;
-	int cur_read_id;
-	int pre_req_min_tr_len;
 	int pre_req_max_tr_len;
 
 	/* cached L2P map management worker */
commit 119c85055d867b9588263bca59794c872ef2a30e
Merge: db2398a56aec d853adc7adf6
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Fri Oct 29 17:35:56 2021 -0700

    Merge tag 'powerpc-5.15-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
    
    Pull powerpc fixes from Michael Ellerman:
     "Three commits fixing some issues introduced with the recent IOMMU
      changes we merged.
    
      Thanks to Alexey Kardashevskiy"
    
    * tag 'powerpc-5.15-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
      powerpc/pseries/iommu: Create huge DMA window if no MMIO32 is present
      powerpc/pseries/iommu: Check if the default window in use before removing it
      powerpc/pseries/iommu: Use correct vfree for it_map

commit db2398a56aecec058643d35828e8cca56a0ac0a3
Merge: a379fbbcb88b c0eee6fbfa2b
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Fri Oct 29 17:04:38 2021 -0700

    Merge tag 'gpio-fixes-for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
    
    Pull gpio fixes from Bartosz Golaszewski:
    
     - fix the return value check when parsing the ngpios property in
       gpio-xgs-iproc
    
     - check the return value of bgpio_init() in gpio-mlxbf2
    
    * tag 'gpio-fixes-for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
      gpio: mlxbf2.c: Add check for bgpio_init failure
      gpio: xgs-iproc: fix parsing of ngpios property

commit a379fbbcb88bcf43d886977c6fb91fb43f330b84
Merge: 17d50f89410c f4aaf1fa8b17
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Fri Oct 29 11:10:29 2021 -0700

    Merge tag 'block-5.15-2021-10-29' of git://git.kernel.dk/linux-block
    
    Pull block fixes from Jens Axboe:
    
     - NVMe pull request:
          - fix nvmet-tcp header digest verification (Amit Engel)
          - fix a memory leak in nvmet-tcp when releasing a queue (Maurizio
            Lombardi)
          - fix nvme-tcp H2CData PDU send accounting again (Sagi Grimberg)
          - fix digest pointer calculation in nvme-tcp and nvmet-tcp (Varun
            Prakash)
          - fix possible nvme-tcp req->offset corruption (Varun Prakash)
    
     - Queue drain ordering fix (Ming)
    
     - Partition check regression for zoned devices (Shin'ichiro)
    
     - Zone queue restart fix (Naohiro)
    
    * tag 'block-5.15-2021-10-29' of git://git.kernel.dk/linux-block:
      block: Fix partition check for host-aware zoned block devices
      nvmet-tcp: fix header digest verification
      nvmet-tcp: fix data digest pointer calculation
      nvme-tcp: fix data digest pointer calculation
      nvme-tcp: fix possible req->offset corruption
      block: schedule queue restart after BLK_STS_ZONE_RESOURCE
      block: drain queue after disk is removed from sysfs
      nvme-tcp: fix H2CData PDU send accounting (again)
      nvmet-tcp: fix a memory leak when releasing a queue

commit 61a9f252c1c026f84129a7bfa476e880b75e80eb
Author: Martin K. Petersen <martin.petersen at oracle.com>
Date:   Wed Oct 27 23:42:02 2021 -0400

    scsi: mpt3sas: Fix reference tag handling for WRITE_INSERT
    
    Testing revealed a problem with how the reference tag was handled for
    a WRITE_INSERT operation. The SCSI_PROT_REF_CHECK flag is not set when
    the controller is asked to generate the protection information
    (i.e. not DIX). And as a result the initial reference tag would not be
    set in the WRITE_INSERT case.
    
    Separate handling of the REF_CHECK and REF_INCREMENT flags to align
    with both the DIX spec and the MPI implementation.
    
    Link: https://lore.kernel.org/r/20211028034202.24225-1-martin.petersen@oracle.com
    Fixes: b3e2c72af1d5 ("scsi: mpt3sas: Use the proper SCSI midlayer interfaces for PI")
    Signed-off-by: Martin K. Petersen <martin.petersen at oracle.com>

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index d383d4a03436..ad1b6c2b37a7 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -5065,9 +5065,12 @@ _scsih_setup_eedp(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
 	if (scmd->prot_flags & SCSI_PROT_GUARD_CHECK)
 		eedp_flags |= MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD;
 
-	if (scmd->prot_flags & SCSI_PROT_REF_CHECK) {
-		eedp_flags |= MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG |
-			MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG;
+	if (scmd->prot_flags & SCSI_PROT_REF_CHECK)
+		eedp_flags |= MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG;
+
+	if (scmd->prot_flags & SCSI_PROT_REF_INCREMENT) {
+		eedp_flags |= MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG;
+
 		mpi_request->CDB.EEDP32.PrimaryReferenceTag =
 			cpu_to_be32(scsi_prot_ref_tag(scmd));
 	}
commit 17d50f89410c5f71142657d9a012cbabcaadb134
Merge: fd919bbd334f 90935eb303e0
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Fri Oct 29 10:54:44 2021 -0700

    Merge tag 'mmc-v5.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
    
    Pull MMC fixes from Ulf Hansson:
    
     - tmio: Re-enable card irqs after a reset
    
     - mtk-sd: Fixup probing of cqhci for crypto
    
     - cqhci: Fix support for suspend/resume
    
     - vub300: Fix control-message timeouts
    
     - dw_mmc-exynos: Fix support for tuning
    
     - winbond: Silences build errors on M68K
    
     - sdhci-esdhc-imx: Fix support for tuning
    
     - sdhci-pci: Read card detect from ACPI for Intel Merrifield
    
     - sdhci: Fix eMMC support for Thundercomm TurboX CM2290
    
    * tag 'mmc-v5.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
      mmc: tmio: reenable card irqs after the reset callback
      mmc: mediatek: Move cqhci init behind ungate clock
      mmc: cqhci: clear HALT state after CQE enable
      mmc: vub300: fix control-message timeouts
      mmc: dw_mmc: exynos: fix the finding clock sample value
      mmc: winbond: don't build on M68K
      mmc: sdhci-esdhc-imx: clear the buffer_read_ready to reset standard tuning circuit
      mmc: sdhci-pci: Read card detect from ACPI for Intel Merrifield
      mmc: sdhci: Map more voltage level to SDHCI_POWER_330

commit fd919bbd334f22486ee2e9c16ceefe833bb9e32f
Merge: 6f1152126731 ccaa66c8dd27
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Fri Oct 29 10:46:59 2021 -0700

    Merge tag 'for-5.15-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
    
    Pull btrfs fixes from David Sterba:
     "Last minute fixes for crash on 32bit architectures when compression is
      in use. It's a regression introduced in 5.15-rc and I'd really like
      not let this into the final release, fixes via stable trees would add
      unnecessary delay.
    
      The problem is on 32bit architectures with highmem enabled, the pages
      for compression may need to be kmapped, while the patches removed that
      as we don't use GFP_HIGHMEM allocations anymore. The pages that don't
      come from local allocation still may be from highmem. Despite being on
      32bit there's enough such ARM machines in use so it's not a marginal
      issue.
    
      I did full reverts of the patches one by one instead of a huge one.
      There's one exception for the "lzo" revert as there was an
      intermediate patch touching the same code to make it compatible with
      subpage. I can't revert that one too, so the revert in lzo.c is
      manual. Qu Wenruo has worked on that with me and verified the changes"
    
    * tag 'for-5.15-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
      Revert "btrfs: compression: drop kmap/kunmap from lzo"
      Revert "btrfs: compression: drop kmap/kunmap from zlib"
      Revert "btrfs: compression: drop kmap/kunmap from zstd"
      Revert "btrfs: compression: drop kmap/kunmap from generic helpers"

commit 6f11521267319659cceabe073112a0e35bcb7ff8
Merge: 75c7a6c1ca63 ddcf906fe5ed
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Fri Oct 29 10:41:07 2021 -0700

    Merge tag 'trace-v5.15-rc6-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
    
    Pull tracing comment fixes from Steven Rostedt:
    
     - Some bots have informed me that some of the ftrace functions
       kernel-doc has formatting issues.
    
     - Also, fix my snake instinct.
    
    * tag 'trace-v5.15-rc6-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
      tracing: Fix misspelling of "missing"
      ftrace: Fix kernel-doc formatting issues

commit 75c7a6c1ca63131875fe869cbfd404c94d0e1944
Merge: 2c04d67ec1eb f8690a4b5a1b
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Fri Oct 29 10:17:08 2021 -0700

    Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
    
    Pull crypto fix from Herbert Xu:
     "Fix a build-time warning in x86/sm4"
    
    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
      crypto: x86/sm4 - Fix invalid section entry size

commit 2c04d67ec1eb558c9d0f58d61e64554d8f39f120
Merge: f25a5481af12 9c7516d669e6
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Fri Oct 29 10:03:07 2021 -0700

    Merge branch 'akpm' (patches from Andrew)
    
    Merge misc fixes from Andrew Morton:
     "11 patches.
    
      Subsystems affected by this patch series: mm (memcg, memory-failure,
      oom-kill, secretmem, vmalloc, hugetlb, damon, and tools), and ocfs2"
    
    * emailed patches from Andrew Morton <akpm at linux-foundation.org>:
      tools/testing/selftests/vm/split_huge_page_test.c: fix application of sizeof to pointer
      mm/damon/core-test: fix wrong expectations for 'damon_split_regions_of()'
      mm: khugepaged: skip huge page collapse for special files
      mm, thp: bail out early in collapse_file for writeback page
      mm/vmalloc: fix numa spreading for large hash tables
      mm/secretmem: avoid letting secretmem_users drop to zero
      ocfs2: fix race between searching chunks and release journal_head from buffer_head
      mm/oom_kill.c: prevent a race between process_mrelease and exit_mmap
      mm: filemap: check if THP has hwpoisoned subpage for PMD page fault
      mm: hwpoison: remove the unnecessary THP check
      memcg: page_alloc: skip bulk allocator for __GFP_ACCOUNT

commit 54c5639d8f507ebefa814f574cb6f763033a72a5
Author: Alexandre Ghiti <alexandre.ghiti at canonical.com>
Date:   Fri Oct 29 06:59:27 2021 +0200

    riscv: Fix asan-stack clang build
    
    Nathan reported that because KASAN_SHADOW_OFFSET was not defined in
    Kconfig, it prevents asan-stack from getting disabled with clang even
    when CONFIG_KASAN_STACK is disabled: fix this by defining the
    corresponding config.
    
    Reported-by: Nathan Chancellor <nathan at kernel.org>
    Signed-off-by: Alexandre Ghiti <alexandre.ghiti at canonical.com>
    Fixes: 8ad8b72721d0 ("riscv: Add KASAN support")
    Cc: stable at vger.kernel.org
    Signed-off-by: Palmer Dabbelt <palmerdabbelt at google.com>

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index c3f3fd583e04..6d5b63bd4bd9 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -163,6 +163,12 @@ config PAGE_OFFSET
 	default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
 	default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB
 
+config KASAN_SHADOW_OFFSET
+	hex
+	depends on KASAN_GENERIC
+	default 0xdfffffc800000000 if 64BIT
+	default 0xffffffff if 32BIT
+
 config ARCH_FLATMEM_ENABLE
 	def_bool !NUMA
 
diff --git a/arch/riscv/include/asm/kasan.h b/arch/riscv/include/asm/kasan.h
index a2b3d9cdbc86..b00f503ec124 100644
--- a/arch/riscv/include/asm/kasan.h
+++ b/arch/riscv/include/asm/kasan.h
@@ -30,8 +30,7 @@
 #define KASAN_SHADOW_SIZE	(UL(1) << ((CONFIG_VA_BITS - 1) - KASAN_SHADOW_SCALE_SHIFT))
 #define KASAN_SHADOW_START	KERN_VIRT_START
 #define KASAN_SHADOW_END	(KASAN_SHADOW_START + KASAN_SHADOW_SIZE)
-#define KASAN_SHADOW_OFFSET	(KASAN_SHADOW_END - (1ULL << \
-					(64 - KASAN_SHADOW_SCALE_SHIFT)))
+#define KASAN_SHADOW_OFFSET	_AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
 
 void kasan_init(void);
 asmlinkage void kasan_early_init(void);
diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c
index 89a8376ce44e..54294f83513d 100644
--- a/arch/riscv/mm/kasan_init.c
+++ b/arch/riscv/mm/kasan_init.c
@@ -17,6 +17,9 @@ asmlinkage void __init kasan_early_init(void)
 	uintptr_t i;
 	pgd_t *pgd = early_pg_dir + pgd_index(KASAN_SHADOW_START);
 
+	BUILD_BUG_ON(KASAN_SHADOW_OFFSET !=
+		KASAN_SHADOW_END - (1UL << (64 - KASAN_SHADOW_SCALE_SHIFT)));
+
 	for (i = 0; i < PTRS_PER_PTE; ++i)
 		set_pte(kasan_early_shadow_pte + i,
 			mk_pte(virt_to_page(kasan_early_shadow_page),
commit cf11d01135ea1ff7fddb612033e3cb5cde279ff2
Author: Alexandre Ghiti <alexandre.ghiti at canonical.com>
Date:   Fri Oct 29 06:59:26 2021 +0200

    riscv: Do not re-populate shadow memory with kasan_populate_early_shadow
    
    When calling this function, all the shadow memory is already populated
    with kasan_early_shadow_pte which has PAGE_KERNEL protection.
    kasan_populate_early_shadow write-protects the mapping of the range
    of addresses passed in argument in zero_pte_populate, which actually
    write-protects all the shadow memory mapping since kasan_early_shadow_pte
    is used for all the shadow memory at this point. And then when using
    memblock API to populate the shadow memory, the first write access to the
    kernel stack triggers a trap. This becomes visible with the next commit
    that contains a fix for asan-stack.
    
    We already manually populate all the shadow memory in kasan_early_init
    and we write-protect kasan_early_shadow_pte at the end of kasan_init
    which makes the calls to kasan_populate_early_shadow superfluous so
    we can remove them.
    
    Signed-off-by: Alexandre Ghiti <alexandre.ghiti at canonical.com>
    Fixes: e178d670f251 ("riscv/kasan: add KASAN_VMALLOC support")
    Fixes: 8ad8b72721d0 ("riscv: Add KASAN support")
    Cc: stable at vger.kernel.org
    Signed-off-by: Palmer Dabbelt <palmerdabbelt at google.com>

diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c
index d7189c8714a9..89a8376ce44e 100644
--- a/arch/riscv/mm/kasan_init.c
+++ b/arch/riscv/mm/kasan_init.c
@@ -172,21 +172,10 @@ void __init kasan_init(void)
 	phys_addr_t p_start, p_end;
 	u64 i;
 
-	/*
-	 * Populate all kernel virtual address space with kasan_early_shadow_page
-	 * except for the linear mapping and the modules/kernel/BPF mapping.
-	 */
-	kasan_populate_early_shadow((void *)KASAN_SHADOW_START,
-				    (void *)kasan_mem_to_shadow((void *)
-								VMEMMAP_END));
 	if (IS_ENABLED(CONFIG_KASAN_VMALLOC))
 		kasan_shallow_populate(
 			(void *)kasan_mem_to_shadow((void *)VMALLOC_START),
 			(void *)kasan_mem_to_shadow((void *)VMALLOC_END));
-	else
-		kasan_populate_early_shadow(
-			(void *)kasan_mem_to_shadow((void *)VMALLOC_START),
-			(void *)kasan_mem_to_shadow((void *)VMALLOC_END));
 
 	/* Populate the linear mapping */
 	for_each_mem_range(i, &p_start, &p_end) {
commit ddcf906fe5ed842034b2d995064c1de1dcc7e812
Author: Steven Rostedt (VMware) <rostedt at goodmis.org>
Date:   Fri Oct 29 09:54:14 2021 -0400

    tracing: Fix misspelling of "missing"
    
    My snake instinct was on and I wrote "misssing" instead of "missing".
    
    Signed-off-by: Steven Rostedt (VMware) <rostedt at goodmis.org>

diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
index 5c5f208c15d3..928867f527e7 100644
--- a/kernel/trace/trace_eprobe.c
+++ b/kernel/trace/trace_eprobe.c
@@ -904,7 +904,7 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 
 	if (IS_ERR(ep)) {
 		ret = PTR_ERR(ep);
-		/* This must return -ENOMEM or misssing event, else there is a bug */
+		/* This must return -ENOMEM or missing event, else there is a bug */
 		WARN_ON_ONCE(ret != -ENOMEM && ret != -ENODEV);
 		ep = NULL;
 		goto error;
commit 6130722f1114cac4f3ec858763ad8995d5a2e586
Author: Steven Rostedt (VMware) <rostedt at goodmis.org>
Date:   Fri Oct 29 09:52:23 2021 -0400

    ftrace: Fix kernel-doc formatting issues
    
    Some functions had kernel-doc that used a comma instead of a hash to
    separate the function name from the one line description.
    
    Also, the "ftrace_is_dead()" had an incomplete description.
    
    Signed-off-by: Steven Rostedt (VMware) <rostedt at goodmis.org>

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 635fbdc9d589..feebf57c6458 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2208,7 +2208,7 @@ static int ftrace_check_record(struct dyn_ftrace *rec, bool enable, bool update)
 }
 
 /**
- * ftrace_update_record, set a record that now is tracing or not
+ * ftrace_update_record - set a record that now is tracing or not
  * @rec: the record to update
  * @enable: set to true if the record is tracing, false to force disable
  *
@@ -2221,7 +2221,7 @@ int ftrace_update_record(struct dyn_ftrace *rec, bool enable)
 }
 
 /**
- * ftrace_test_record, check if the record has been enabled or not
+ * ftrace_test_record - check if the record has been enabled or not
  * @rec: the record to test
  * @enable: set to true to check if enabled, false if it is disabled
  *
@@ -2574,7 +2574,7 @@ struct ftrace_rec_iter {
 };
 
 /**
- * ftrace_rec_iter_start, start up iterating over traced functions
+ * ftrace_rec_iter_start - start up iterating over traced functions
  *
  * Returns an iterator handle that is used to iterate over all
  * the records that represent address locations where functions
@@ -2605,7 +2605,7 @@ struct ftrace_rec_iter *ftrace_rec_iter_start(void)
 }
 
 /**
- * ftrace_rec_iter_next, get the next record to process.
+ * ftrace_rec_iter_next - get the next record to process.
  * @iter: The handle to the iterator.
  *
  * Returns the next iterator after the given iterator @iter.
@@ -2630,7 +2630,7 @@ struct ftrace_rec_iter *ftrace_rec_iter_next(struct ftrace_rec_iter *iter)
 }
 
 /**
- * ftrace_rec_iter_record, get the record at the iterator location
+ * ftrace_rec_iter_record - get the record at the iterator location
  * @iter: The current iterator location
  *
  * Returns the record that the current @iter is at.
@@ -2733,7 +2733,7 @@ static int __ftrace_modify_code(void *data)
 }
 
 /**
- * ftrace_run_stop_machine, go back to the stop machine method
+ * ftrace_run_stop_machine - go back to the stop machine method
  * @command: The command to tell ftrace what to do
  *
  * If an arch needs to fall back to the stop machine method, the
@@ -2745,7 +2745,7 @@ void ftrace_run_stop_machine(int command)
 }
 
 /**
- * arch_ftrace_update_code, modify the code to trace or not trace
+ * arch_ftrace_update_code - modify the code to trace or not trace
  * @command: The command that needs to be done
  *
  * Archs can override this function if it does not need to
@@ -7525,7 +7525,9 @@ void ftrace_kill(void)
 }
 
 /**
- * Test if ftrace is dead or not.
+ * ftrace_is_dead - Test if ftrace is dead or not.
+ *
+ * Returns 1 if ftrace is "dead", zero otherwise.
  */
 int ftrace_is_dead(void)
 {
commit ccaa66c8dd277ac02f96914168bb7177f7ea8117
Author: David Sterba <dsterba at suse.com>
Date:   Wed Oct 27 10:44:21 2021 +0200

    Revert "btrfs: compression: drop kmap/kunmap from lzo"
    
    This reverts commit 8c945d32e60427cbc0859cf7045bbe6196bb03d8.
    
    The kmaps in compression code are still needed and cause crashes on
    32bit machines (ARM, x86). Reproducible eg. by running fstest btrfs/004
    with enabled LZO or ZSTD compression.
    
    The revert does not apply cleanly due to changes in a6e66e6f8c1b
    ("btrfs: rework lzo_decompress_bio() to make it subpage compatible")
    that reworked the page iteration so the revert is done to be equivalent
    to the original code.
    
    Link: https://lore.kernel.org/all/CAJCQCtT+OuemovPO7GZk8Y8=qtOObr0XTDp8jh4OHD6y84AFxw@mail.gmail.com/
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=214839
    Tested-by: Qu Wenruo <wqu at suse.com>
    Signed-off-by: Qu Wenruo <wqu at suse.com>
    Signed-off-by: David Sterba <dsterba at suse.com>

diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index c25dfd1a8a54..3dbe6eb5fda7 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -141,7 +141,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 	*total_in = 0;
 
 	in_page = find_get_page(mapping, start >> PAGE_SHIFT);
-	data_in = page_address(in_page);
+	data_in = kmap(in_page);
 
 	/*
 	 * store the size of all chunks of compressed data in
@@ -152,7 +152,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 		ret = -ENOMEM;
 		goto out;
 	}
-	cpage_out = page_address(out_page);
+	cpage_out = kmap(out_page);
 	out_offset = LZO_LEN;
 	tot_out = LZO_LEN;
 	pages[0] = out_page;
@@ -210,6 +210,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 				if (out_len == 0 && tot_in >= len)
 					break;
 
+				kunmap(out_page);
 				if (nr_pages == nr_dest_pages) {
 					out_page = NULL;
 					ret = -E2BIG;
@@ -221,7 +222,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 					ret = -ENOMEM;
 					goto out;
 				}
-				cpage_out = page_address(out_page);
+				cpage_out = kmap(out_page);
 				pages[nr_pages++] = out_page;
 
 				pg_bytes_left = PAGE_SIZE;
@@ -243,11 +244,12 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 			break;
 
 		bytes_left = len - tot_in;
+		kunmap(in_page);
 		put_page(in_page);
 
 		start += PAGE_SIZE;
 		in_page = find_get_page(mapping, start >> PAGE_SHIFT);
-		data_in = page_address(in_page);
+		data_in = kmap(in_page);
 		in_len = min(bytes_left, PAGE_SIZE);
 	}
 
@@ -257,17 +259,22 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 	}
 
 	/* store the size of all chunks of compressed data */
-	sizes_ptr = page_address(pages[0]);
+	sizes_ptr = kmap_local_page(pages[0]);
 	write_compress_length(sizes_ptr, tot_out);
+	kunmap_local(sizes_ptr);
 
 	ret = 0;
 	*total_out = tot_out;
 	*total_in = tot_in;
 out:
 	*out_pages = nr_pages;
+	if (out_page)
+		kunmap(out_page);
 
-	if (in_page)
+	if (in_page) {
+		kunmap(in_page);
 		put_page(in_page);
+	}
 
 	return ret;
 }
@@ -283,6 +290,7 @@ static void copy_compressed_segment(struct compressed_bio *cb,
 	u32 orig_in = *cur_in;
 
 	while (*cur_in < orig_in + len) {
+		char *kaddr;
 		struct page *cur_page;
 		u32 copy_len = min_t(u32, PAGE_SIZE - offset_in_page(*cur_in),
 					  orig_in + len - *cur_in);
@@ -290,9 +298,11 @@ static void copy_compressed_segment(struct compressed_bio *cb,
 		ASSERT(copy_len);
 		cur_page = cb->compressed_pages[*cur_in / PAGE_SIZE];
 
+		kaddr = kmap(cur_page);
 		memcpy(dest + *cur_in - orig_in,
-			page_address(cur_page) + offset_in_page(*cur_in),
+			kaddr + offset_in_page(*cur_in),
 			copy_len);
+		kunmap(cur_page);
 
 		*cur_in += copy_len;
 	}
@@ -303,6 +313,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 	struct workspace *workspace = list_entry(ws, struct workspace, list);
 	const struct btrfs_fs_info *fs_info = btrfs_sb(cb->inode->i_sb);
 	const u32 sectorsize = fs_info->sectorsize;
+	char *kaddr;
 	int ret;
 	/* Compressed data length, can be unaligned */
 	u32 len_in;
@@ -311,7 +322,9 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 	/* Bytes decompressed so far */
 	u32 cur_out = 0;
 
-	len_in = read_compress_length(page_address(cb->compressed_pages[0]));
+	kaddr = kmap(cb->compressed_pages[0]);
+	len_in = read_compress_length(kaddr);
+	kunmap(cb->compressed_pages[0]);
 	cur_in += LZO_LEN;
 
 	/*
@@ -344,9 +357,9 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 		ASSERT(cur_in / sectorsize ==
 		       (cur_in + LZO_LEN - 1) / sectorsize);
 		cur_page = cb->compressed_pages[cur_in / PAGE_SIZE];
+		kaddr = kmap(cur_page);
 		ASSERT(cur_page);
-		seg_len = read_compress_length(page_address(cur_page) +
-					       offset_in_page(cur_in));
+		seg_len = read_compress_length(kaddr + offset_in_page(cur_in));
 		cur_in += LZO_LEN;
 
 		/* Copy the compressed segment payload into workspace */
@@ -431,7 +444,7 @@ int lzo_decompress(struct list_head *ws, unsigned char *data_in,
 	destlen = min_t(unsigned long, destlen, PAGE_SIZE);
 	bytes = min_t(unsigned long, destlen, out_len - start_byte);
 
-	kaddr = page_address(dest_page);
+	kaddr = kmap_local_page(dest_page);
 	memcpy(kaddr, workspace->buf + start_byte, bytes);
 
 	/*
@@ -441,6 +454,7 @@ int lzo_decompress(struct list_head *ws, unsigned char *data_in,
 	 */
 	if (bytes < destlen)
 		memset(kaddr+bytes, 0, destlen-bytes);
+	kunmap_local(kaddr);
 out:
 	return ret;
 }
commit 55276e14df4324ade34583adef110e11d249fb7b
Author: David Sterba <dsterba at suse.com>
Date:   Wed Oct 27 10:42:43 2021 +0200

    Revert "btrfs: compression: drop kmap/kunmap from zlib"
    
    This reverts commit 696ab562e6df9fbafd6052d8ce4aafcb2ed16069.
    
    The kmaps in compression code are still needed and cause crashes on
    32bit machines (ARM, x86). Reproducible eg. by running fstest btrfs/004
    with enabled LZO or ZSTD compression.
    
    Link: https://lore.kernel.org/all/CAJCQCtT+OuemovPO7GZk8Y8=qtOObr0XTDp8jh4OHD6y84AFxw@mail.gmail.com/
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=214839
    Signed-off-by: David Sterba <dsterba at suse.com>

diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index 8afa90074891..767a0c6c9694 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -126,7 +126,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 		ret = -ENOMEM;
 		goto out;
 	}
-	cpage_out = page_address(out_page);
+	cpage_out = kmap(out_page);
 	pages[0] = out_page;
 	nr_pages = 1;
 
@@ -148,22 +148,26 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 				int i;
 
 				for (i = 0; i < in_buf_pages; i++) {
-					if (in_page)
+					if (in_page) {
+						kunmap(in_page);
 						put_page(in_page);
+					}
 					in_page = find_get_page(mapping,
 								start >> PAGE_SHIFT);
-					data_in = page_address(in_page);
+					data_in = kmap(in_page);
 					memcpy(workspace->buf + i * PAGE_SIZE,
 					       data_in, PAGE_SIZE);
 					start += PAGE_SIZE;
 				}
 				workspace->strm.next_in = workspace->buf;
 			} else {
-				if (in_page)
+				if (in_page) {
+					kunmap(in_page);
 					put_page(in_page);
+				}
 				in_page = find_get_page(mapping,
 							start >> PAGE_SHIFT);
-				data_in = page_address(in_page);
+				data_in = kmap(in_page);
 				start += PAGE_SIZE;
 				workspace->strm.next_in = data_in;
 			}
@@ -192,6 +196,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 		 * the stream end if required
 		 */
 		if (workspace->strm.avail_out == 0) {
+			kunmap(out_page);
 			if (nr_pages == nr_dest_pages) {
 				out_page = NULL;
 				ret = -E2BIG;
@@ -202,7 +207,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 				ret = -ENOMEM;
 				goto out;
 			}
-			cpage_out = page_address(out_page);
+			cpage_out = kmap(out_page);
 			pages[nr_pages] = out_page;
 			nr_pages++;
 			workspace->strm.avail_out = PAGE_SIZE;
@@ -229,6 +234,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 			goto out;
 		} else if (workspace->strm.avail_out == 0) {
 			/* get another page for the stream end */
+			kunmap(out_page);
 			if (nr_pages == nr_dest_pages) {
 				out_page = NULL;
 				ret = -E2BIG;
@@ -239,7 +245,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 				ret = -ENOMEM;
 				goto out;
 			}
-			cpage_out = page_address(out_page);
+			cpage_out = kmap(out_page);
 			pages[nr_pages] = out_page;
 			nr_pages++;
 			workspace->strm.avail_out = PAGE_SIZE;
@@ -258,8 +264,13 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 	*total_in = workspace->strm.total_in;
 out:
 	*out_pages = nr_pages;
-	if (in_page)
+	if (out_page)
+		kunmap(out_page);
+
+	if (in_page) {
+		kunmap(in_page);
 		put_page(in_page);
+	}
 	return ret;
 }
 
@@ -276,7 +287,7 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 	unsigned long buf_start;
 	struct page **pages_in = cb->compressed_pages;
 
-	data_in = page_address(pages_in[page_in_index]);
+	data_in = kmap(pages_in[page_in_index]);
 	workspace->strm.next_in = data_in;
 	workspace->strm.avail_in = min_t(size_t, srclen, PAGE_SIZE);
 	workspace->strm.total_in = 0;
@@ -298,6 +309,7 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 
 	if (Z_OK != zlib_inflateInit2(&workspace->strm, wbits)) {
 		pr_warn("BTRFS: inflateInit failed\n");
+		kunmap(pages_in[page_in_index]);
 		return -EIO;
 	}
 	while (workspace->strm.total_in < srclen) {
@@ -324,13 +336,13 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 
 		if (workspace->strm.avail_in == 0) {
 			unsigned long tmp;
-
+			kunmap(pages_in[page_in_index]);
 			page_in_index++;
 			if (page_in_index >= total_pages_in) {
 				data_in = NULL;
 				break;
 			}
-			data_in = page_address(pages_in[page_in_index]);
+			data_in = kmap(pages_in[page_in_index]);
 			workspace->strm.next_in = data_in;
 			tmp = srclen - workspace->strm.total_in;
 			workspace->strm.avail_in = min(tmp, PAGE_SIZE);
@@ -342,6 +354,8 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 		ret = 0;
 done:
 	zlib_inflateEnd(&workspace->strm);
+	if (data_in)
+		kunmap(pages_in[page_in_index]);
 	if (!ret)
 		zero_fill_bio(cb->orig_bio);
 	return ret;
commit 56ee254d23c59fd48fb6f192d79858f60cfe2bf6
Author: David Sterba <dsterba at suse.com>
Date:   Wed Oct 27 10:42:27 2021 +0200

    Revert "btrfs: compression: drop kmap/kunmap from zstd"
    
    This reverts commit bbaf9715f3f5b5ff0de71da91fcc34ee9c198ed8.
    
    The kmaps in compression code are still needed and cause crashes on
    32bit machines (ARM, x86). Reproducible eg. by running fstest btrfs/004
    with enabled LZO or ZSTD compression.
    
    Example stacktrace with ZSTD on a 32bit ARM machine:
    
      Unable to handle kernel NULL pointer dereference at virtual address 00000000
      pgd = c4159ed3
      [00000000] *pgd=00000000
      Internal error: Oops: 5 [#1] PREEMPT SMP ARM
      Modules linked in:
      CPU: 0 PID: 210 Comm: kworker/u2:3 Not tainted 5.14.0-rc79+ #12
      Hardware name: Allwinner sun4i/sun5i Families
      Workqueue: btrfs-delalloc btrfs_work_helper
      PC is at mmiocpy+0x48/0x330
      LR is at ZSTD_compressStream_generic+0x15c/0x28c
    
      (mmiocpy) from [<c0629648>] (ZSTD_compressStream_generic+0x15c/0x28c)
      (ZSTD_compressStream_generic) from [<c06297dc>] (ZSTD_compressStream+0x64/0xa0)
      (ZSTD_compressStream) from [<c049444c>] (zstd_compress_pages+0x170/0x488)
      (zstd_compress_pages) from [<c0496798>] (btrfs_compress_pages+0x124/0x12c)
      (btrfs_compress_pages) from [<c043c068>] (compress_file_range+0x3c0/0x834)
      (compress_file_range) from [<c043c4ec>] (async_cow_start+0x10/0x28)
      (async_cow_start) from [<c0475c3c>] (btrfs_work_helper+0x100/0x230)
      (btrfs_work_helper) from [<c014ef68>] (process_one_work+0x1b4/0x418)
      (process_one_work) from [<c014f210>] (worker_thread+0x44/0x524)
      (worker_thread) from [<c0156aa4>] (kthread+0x180/0x1b0)
      (kthread) from [<c0100150>]
    
    Link: https://lore.kernel.org/all/CAJCQCtT+OuemovPO7GZk8Y8=qtOObr0XTDp8jh4OHD6y84AFxw@mail.gmail.com/
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=214839
    Signed-off-by: David Sterba <dsterba at suse.com>

diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
index 56dce9f00988..f06b68040352 100644
--- a/fs/btrfs/zstd.c
+++ b/fs/btrfs/zstd.c
@@ -399,7 +399,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 
 	/* map in the first page of input data */
 	in_page = find_get_page(mapping, start >> PAGE_SHIFT);
-	workspace->in_buf.src = page_address(in_page);
+	workspace->in_buf.src = kmap(in_page);
 	workspace->in_buf.pos = 0;
 	workspace->in_buf.size = min_t(size_t, len, PAGE_SIZE);
 
@@ -411,7 +411,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 		goto out;
 	}
 	pages[nr_pages++] = out_page;
-	workspace->out_buf.dst = page_address(out_page);
+	workspace->out_buf.dst = kmap(out_page);
 	workspace->out_buf.pos = 0;
 	workspace->out_buf.size = min_t(size_t, max_out, PAGE_SIZE);
 
@@ -446,6 +446,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 		if (workspace->out_buf.pos == workspace->out_buf.size) {
 			tot_out += PAGE_SIZE;
 			max_out -= PAGE_SIZE;
+			kunmap(out_page);
 			if (nr_pages == nr_dest_pages) {
 				out_page = NULL;
 				ret = -E2BIG;
@@ -457,7 +458,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 				goto out;
 			}
 			pages[nr_pages++] = out_page;
-			workspace->out_buf.dst = page_address(out_page);
+			workspace->out_buf.dst = kmap(out_page);
 			workspace->out_buf.pos = 0;
 			workspace->out_buf.size = min_t(size_t, max_out,
 							PAGE_SIZE);
@@ -472,12 +473,13 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 		/* Check if we need more input */
 		if (workspace->in_buf.pos == workspace->in_buf.size) {
 			tot_in += PAGE_SIZE;
+			kunmap(in_page);
 			put_page(in_page);
 
 			start += PAGE_SIZE;
 			len -= PAGE_SIZE;
 			in_page = find_get_page(mapping, start >> PAGE_SHIFT);
-			workspace->in_buf.src = page_address(in_page);
+			workspace->in_buf.src = kmap(in_page);
 			workspace->in_buf.pos = 0;
 			workspace->in_buf.size = min_t(size_t, len, PAGE_SIZE);
 		}
@@ -504,6 +506,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 
 		tot_out += PAGE_SIZE;
 		max_out -= PAGE_SIZE;
+		kunmap(out_page);
 		if (nr_pages == nr_dest_pages) {
 			out_page = NULL;
 			ret = -E2BIG;
@@ -515,7 +518,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 			goto out;
 		}
 		pages[nr_pages++] = out_page;
-		workspace->out_buf.dst = page_address(out_page);
+		workspace->out_buf.dst = kmap(out_page);
 		workspace->out_buf.pos = 0;
 		workspace->out_buf.size = min_t(size_t, max_out, PAGE_SIZE);
 	}
@@ -531,8 +534,12 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 out:
 	*out_pages = nr_pages;
 	/* Cleanup */
-	if (in_page)
+	if (in_page) {
+		kunmap(in_page);
 		put_page(in_page);
+	}
+	if (out_page)
+		kunmap(out_page);
 	return ret;
 }
 
@@ -556,7 +563,7 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 		goto done;
 	}
 
-	workspace->in_buf.src = page_address(pages_in[page_in_index]);
+	workspace->in_buf.src = kmap(pages_in[page_in_index]);
 	workspace->in_buf.pos = 0;
 	workspace->in_buf.size = min_t(size_t, srclen, PAGE_SIZE);
 
@@ -592,14 +599,14 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 			break;
 
 		if (workspace->in_buf.pos == workspace->in_buf.size) {
-			page_in_index++;
+			kunmap(pages_in[page_in_index++]);
 			if (page_in_index >= total_pages_in) {
 				workspace->in_buf.src = NULL;
 				ret = -EIO;
 				goto done;
 			}
 			srclen -= PAGE_SIZE;
-			workspace->in_buf.src = page_address(pages_in[page_in_index]);
+			workspace->in_buf.src = kmap(pages_in[page_in_index]);
 			workspace->in_buf.pos = 0;
 			workspace->in_buf.size = min_t(size_t, srclen, PAGE_SIZE);
 		}
@@ -607,6 +614,8 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 	ret = 0;
 	zero_fill_bio(cb->orig_bio);
 done:
+	if (workspace->in_buf.src)
+		kunmap(pages_in[page_in_index]);
 	return ret;
 }
 
commit 8c0fd126263730c35927cc8445727afb79219a19
Author: Guangming Cao <Guangming.Cao at mediatek.com>
Date:   Fri Oct 8 15:54:20 2021 +0800

    dma-buf: acquire name lock before read/write dma_buf.name
    
    Because dma-buf.name can be freed in func: "dma_buf_set_name",
    so, we need to acquire lock first before we read/write dma_buf.name
    to prevent Use After Free(UAF) issue.
    
    Signed-off-by: Guangming Cao <Guangming.Cao at mediatek.com>
    Reviewed-by: Christian König <christian.koenig at amd.com>
    Signed-off-by: Christian König <christian.koenig at amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211008075420.42874-1-guangming.cao@mediatek.com

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 63d32261b63f..92492e314bd9 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -1389,6 +1389,8 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
 		if (ret)
 			goto error_unlock;
 
+
+		spin_lock(&buf_obj->name_lock);
 		seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\t%08lu\t%s\n",
 				buf_obj->size,
 				buf_obj->file->f_flags, buf_obj->file->f_mode,
@@ -1396,6 +1398,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
 				buf_obj->exp_name,
 				file_inode(buf_obj->file)->i_ino,
 				buf_obj->name ?: "");
+		spin_unlock(&buf_obj->name_lock);
 
 		robj = buf_obj->resv;
 		fence = dma_resv_excl_fence(robj);
commit 9c7516d669e68e94e17203469a873ff5d1d3a41a
Author: David Yang <davidcomponentone at gmail.com>
Date:   Thu Oct 28 14:36:36 2021 -0700

    tools/testing/selftests/vm/split_huge_page_test.c: fix application of sizeof to pointer
    
    The coccinelle check report:
    
      ./tools/testing/selftests/vm/split_huge_page_test.c:344:36-42:
      ERROR: application of sizeof to pointer
    
    Use "strlen" to fix it.
    
    Link: https://lkml.kernel.org/r/20211012030116.184027-1-davidcomponentone@gmail.com
    Signed-off-by: David Yang <davidcomponentone at gmail.com>
    Reported-by: Zeal Robot <zealci at zte.com.cn>
    Cc: Zi Yan <ziy at nvidia.com>
    Cc: Shuah Khan <shuah at kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/tools/testing/selftests/vm/split_huge_page_test.c b/tools/testing/selftests/vm/split_huge_page_test.c
index 1af16d2c2a0a..52497b7b9f1d 100644
--- a/tools/testing/selftests/vm/split_huge_page_test.c
+++ b/tools/testing/selftests/vm/split_huge_page_test.c
@@ -341,7 +341,7 @@ void split_file_backed_thp(void)
 	}
 
 	/* write something to the file, so a file-backed THP can be allocated */
-	num_written = write(fd, tmpfs_loc, sizeof(tmpfs_loc));
+	num_written = write(fd, tmpfs_loc, strlen(tmpfs_loc) + 1);
 	close(fd);
 
 	if (num_written < 1) {
commit 2e014660b3e4b7bd0e75f845cdcf745c0f632889
Author: SeongJae Park <sj at kernel.org>
Date:   Thu Oct 28 14:36:33 2021 -0700

    mm/damon/core-test: fix wrong expectations for 'damon_split_regions_of()'
    
    Kunit test cases for 'damon_split_regions_of()' expects the number of
    regions after calling the function will be same to their request
    ('nr_sub').  However, the requested number is just an upper-limit,
    because the function randomly decides the size of each sub-region.
    
    This fixes the wrong expectation.
    
    Link: https://lkml.kernel.org/r/20211028090628.14948-1-sj@kernel.org
    Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests")
    Signed-off-by: SeongJae Park <sj at kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h
index c938a9c34e6c..7008c3735e99 100644
--- a/mm/damon/core-test.h
+++ b/mm/damon/core-test.h
@@ -219,14 +219,14 @@ static void damon_test_split_regions_of(struct kunit *test)
 	r = damon_new_region(0, 22);
 	damon_add_region(r, t);
 	damon_split_regions_of(c, t, 2);
-	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 2u);
+	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 2u);
 	damon_free_target(t);
 
 	t = damon_new_target(42);
 	r = damon_new_region(0, 220);
 	damon_add_region(r, t);
 	damon_split_regions_of(c, t, 4);
-	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 4u);
+	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
 	damon_free_target(t);
 	damon_destroy_ctx(c);
 }
commit a4aeaa06d45e90f9b279f0b09de84bd00006e733
Author: Yang Shi <shy828301 at gmail.com>
Date:   Thu Oct 28 14:36:30 2021 -0700

    mm: khugepaged: skip huge page collapse for special files
    
    The read-only THP for filesystems will collapse THP for files opened
    readonly and mapped with VM_EXEC.  The intended usecase is to avoid TLB
    misses for large text segments.  But it doesn't restrict the file types
    so a THP could be collapsed for a non-regular file, for example, block
    device, if it is opened readonly and mapped with EXEC permission.  This
    may cause bugs, like [1] and [2].
    
    This is definitely not the intended usecase, so just collapse THP for
    regular files in order to close the attack surface.
    
    [shy828301 at gmail.com: fix vm_file check [3]]
    
    Link: https://lore.kernel.org/lkml/CACkBjsYwLYLRmX8GpsDpMthagWOjWWrNxqY6ZLNQVr6yx+f5vA@mail.gmail.com/ [1]
    Link: https://lore.kernel.org/linux-mm/000000000000c6a82505ce284e4c@google.com/ [2]
    Link: https://lkml.kernel.org/r/CAHbLzkqTW9U3VvTu1Ki5v_cLRC9gHW+znBukg_ycergE0JWj-A@mail.gmail.com [3]
    Link: https://lkml.kernel.org/r/20211027195221.3825-1-shy828301@gmail.com
    Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
    Signed-off-by: Hugh Dickins <hughd at google.com>
    Signed-off-by: Yang Shi <shy828301 at gmail.com>
    Reported-by: Hao Sun <sunhao.th at gmail.com>
    Reported-by: syzbot+aae069be1de40fb11825 at syzkaller.appspotmail.com
    Cc: Matthew Wilcox <willy at infradead.org>
    Cc: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
    Cc: Song Liu <songliubraving at fb.com>
    Cc: Andrea Righi <andrea.righi at canonical.com>
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 48de4e1b0783..8a8b3aa92937 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -445,22 +445,25 @@ static bool hugepage_vma_check(struct vm_area_struct *vma,
 	if (!transhuge_vma_enabled(vma, vm_flags))
 		return false;
 
+	if (vma->vm_file && !IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) -
+				vma->vm_pgoff, HPAGE_PMD_NR))
+		return false;
+
 	/* Enabled via shmem mount options or sysfs settings. */
-	if (shmem_file(vma->vm_file) && shmem_huge_enabled(vma)) {
-		return IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
-				HPAGE_PMD_NR);
-	}
+	if (shmem_file(vma->vm_file))
+		return shmem_huge_enabled(vma);
 
 	/* THP settings require madvise. */
 	if (!(vm_flags & VM_HUGEPAGE) && !khugepaged_always())
 		return false;
 
-	/* Read-only file mappings need to be aligned for THP to work. */
+	/* Only regular file is valid */
 	if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && vma->vm_file &&
-	    !inode_is_open_for_write(vma->vm_file->f_inode) &&
 	    (vm_flags & VM_EXEC)) {
-		return IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
-				HPAGE_PMD_NR);
+		struct inode *inode = vma->vm_file->f_inode;
+
+		return !inode_is_open_for_write(inode) &&
+			S_ISREG(inode->i_mode);
 	}
 
 	if (!vma->anon_vma || vma->vm_ops)
commit 74c42e1baacf206338b1dd6b6199ac964512b5bb
Author: Rongwei Wang <rongwei.wang at linux.alibaba.com>
Date:   Thu Oct 28 14:36:27 2021 -0700

    mm, thp: bail out early in collapse_file for writeback page
    
    Currently collapse_file does not explicitly check PG_writeback, instead,
    page_has_private and try_to_release_page are used to filter writeback
    pages.  This does not work for xfs with blocksize equal to or larger
    than pagesize, because in such case xfs has no page->private.
    
    This makes collapse_file bail out early for writeback page.  Otherwise,
    xfs end_page_writeback will panic as follows.
    
      page:fffffe00201bcc80 refcount:0 mapcount:0 mapping:ffff0003f88c86a8 index:0x0 pfn:0x84ef32
      aops:xfs_address_space_operations [xfs] ino:30000b7 dentry name:"libtest.so"
      flags: 0x57fffe0000008027(locked|referenced|uptodate|active|writeback)
      raw: 57fffe0000008027 ffff80001b48bc28 ffff80001b48bc28 ffff0003f88c86a8
      raw: 0000000000000000 0000000000000000 00000000ffffffff ffff0000c3e9a000
      page dumped because: VM_BUG_ON_PAGE(((unsigned int) page_ref_count(page) + 127u <= 127u))
      page->mem_cgroup:ffff0000c3e9a000
      ------------[ cut here ]------------
      kernel BUG at include/linux/mm.h:1212!
      Internal error: Oops - BUG: 0 [#1] SMP
      Modules linked in:
      BUG: Bad page state in process khugepaged  pfn:84ef32
       xfs(E)
      page:fffffe00201bcc80 refcount:0 mapcount:0 mapping:0 index:0x0 pfn:0x84ef32
       libcrc32c(E) rfkill(E) aes_ce_blk(E) crypto_simd(E) ...
      CPU: 25 PID: 0 Comm: swapper/25 Kdump: loaded Tainted: ...
      pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--)
      Call trace:
        end_page_writeback+0x1c0/0x214
        iomap_finish_page_writeback+0x13c/0x204
        iomap_finish_ioend+0xe8/0x19c
        iomap_writepage_end_bio+0x38/0x50
        bio_endio+0x168/0x1ec
        blk_update_request+0x278/0x3f0
        blk_mq_end_request+0x34/0x15c
        virtblk_request_done+0x38/0x74 [virtio_blk]
        blk_done_softirq+0xc4/0x110
        __do_softirq+0x128/0x38c
        __irq_exit_rcu+0x118/0x150
        irq_exit+0x1c/0x30
        __handle_domain_irq+0x8c/0xf0
        gic_handle_irq+0x84/0x108
        el1_irq+0xcc/0x180
        arch_cpu_idle+0x18/0x40
        default_idle_call+0x4c/0x1a0
        cpuidle_idle_call+0x168/0x1e0
        do_idle+0xb4/0x104
        cpu_startup_entry+0x30/0x9c
        secondary_start_kernel+0x104/0x180
      Code: d4210000 b0006161 910c8021 94013f4d (d4210000)
      ---[ end trace 4a88c6a074082f8c ]---
      Kernel panic - not syncing: Oops - BUG: Fatal exception in interrupt
    
    Link: https://lkml.kernel.org/r/20211022023052.33114-1-rongwei.wang@linux.alibaba.com
    Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
    Signed-off-by: Rongwei Wang <rongwei.wang at linux.alibaba.com>
    Signed-off-by: Xu Yu <xuyu at linux.alibaba.com>
    Suggested-by: Yang Shi <shy828301 at gmail.com>
    Reviewed-by: Matthew Wilcox (Oracle) <willy at infradead.org>
    Reviewed-by: Yang Shi <shy828301 at gmail.com>
    Acked-by: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
    Cc: Song Liu <song at kernel.org>
    Cc: William Kucharski <william.kucharski at oracle.com>
    Cc: Hugh Dickins <hughd at google.com>
    Cc: Mike Kravetz <mike.kravetz at oracle.com>
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 045cc579f724..48de4e1b0783 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1763,6 +1763,10 @@ static void collapse_file(struct mm_struct *mm,
 				filemap_flush(mapping);
 				result = SCAN_FAIL;
 				goto xa_unlocked;
+			} else if (PageWriteback(page)) {
+				xas_unlock_irq(&xas);
+				result = SCAN_FAIL;
+				goto xa_unlocked;
 			} else if (trylock_page(page)) {
 				get_page(page);
 				xas_unlock_irq(&xas);
@@ -1798,7 +1802,8 @@ static void collapse_file(struct mm_struct *mm,
 			goto out_unlock;
 		}
 
-		if (!is_shmem && PageDirty(page)) {
+		if (!is_shmem && (PageDirty(page) ||
+				  PageWriteback(page))) {
 			/*
 			 * khugepaged only works on read-only fd, so this
 			 * page is dirty because it hasn't been flushed
commit ffb29b1c255ab48cb0062a3d11c101501e3e9b3f
Author: Chen Wandun <chenwandun at huawei.com>
Date:   Thu Oct 28 14:36:24 2021 -0700

    mm/vmalloc: fix numa spreading for large hash tables
    
    Eric Dumazet reported a strange numa spreading info in [1], and found
    commit 121e6f3258fe ("mm/vmalloc: hugepage vmalloc mappings") introduced
    this issue [2].
    
    Dig into the difference before and after this patch, page allocation has
    some difference:
    
    before:
      alloc_large_system_hash
        __vmalloc
          __vmalloc_node(..., NUMA_NO_NODE, ...)
            __vmalloc_node_range
              __vmalloc_area_node
                alloc_page /* because NUMA_NO_NODE, so choose alloc_page branch */
                  alloc_pages_current
                    alloc_page_interleave /* can be proved by print policy mode */
    
    after:
      alloc_large_system_hash
        __vmalloc
          __vmalloc_node(..., NUMA_NO_NODE, ...)
            __vmalloc_node_range
              __vmalloc_area_node
                alloc_pages_node /* choose nid by nuam_mem_id() */
                  __alloc_pages_node(nid, ....)
    
    So after commit 121e6f3258fe ("mm/vmalloc: hugepage vmalloc mappings"),
    it will allocate memory in current node instead of interleaving allocate
    memory.
    
    Link: https://lore.kernel.org/linux-mm/CANn89iL6AAyWhfxdHO+jaT075iOa3XcYn9k6JJc7JR2XYn6k_Q@mail.gmail.com/ [1]
    Link: https://lore.kernel.org/linux-mm/CANn89iLofTR=AK-QOZY87RdUZENCZUT4O6a0hvhu3_EwRMerOg@mail.gmail.com/ [2]
    Link: https://lkml.kernel.org/r/20211021080744.874701-2-chenwandun@huawei.com
    Fixes: 121e6f3258fe ("mm/vmalloc: hugepage vmalloc mappings")
    Signed-off-by: Chen Wandun <chenwandun at huawei.com>
    Reported-by: Eric Dumazet <edumazet at google.com>
    Cc: Shakeel Butt <shakeelb at google.com>
    Cc: Nicholas Piggin <npiggin at gmail.com>
    Cc: Kefeng Wang <wangkefeng.wang at huawei.com>
    Cc: Hanjun Guo <guohanjun at huawei.com>
    Cc: Uladzislau Rezki <urezki at gmail.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index d77830ff604c..e8a807c78110 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2816,6 +2816,8 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
 		unsigned int order, unsigned int nr_pages, struct page **pages)
 {
 	unsigned int nr_allocated = 0;
+	struct page *page;
+	int i;
 
 	/*
 	 * For order-0 pages we make use of bulk allocator, if
@@ -2823,7 +2825,7 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
 	 * to fails, fallback to a single page allocator that is
 	 * more permissive.
 	 */
-	if (!order) {
+	if (!order && nid != NUMA_NO_NODE) {
 		while (nr_allocated < nr_pages) {
 			unsigned int nr, nr_pages_request;
 
@@ -2848,7 +2850,7 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
 			if (nr != nr_pages_request)
 				break;
 		}
-	} else
+	} else if (order)
 		/*
 		 * Compound pages required for remap_vmalloc_page if
 		 * high-order pages.
@@ -2856,11 +2858,12 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
 		gfp |= __GFP_COMP;
 
 	/* High-order pages or fallback path if "bulk" fails. */
-	while (nr_allocated < nr_pages) {
-		struct page *page;
-		int i;
 
-		page = alloc_pages_node(nid, gfp, order);
+	while (nr_allocated < nr_pages) {
+		if (nid == NUMA_NO_NODE)
+			page = alloc_pages(gfp, order);
+		else
+			page = alloc_pages_node(nid, gfp, order);
 		if (unlikely(!page))
 			break;
 
commit 855d44434fa24d5344c1cb0edb38723f891cd415
Author: Kees Cook <keescook at chromium.org>
Date:   Thu Oct 28 14:36:21 2021 -0700

    mm/secretmem: avoid letting secretmem_users drop to zero
    
    Quoting Dmitry:
     "refcount_inc() needs to be done before fd_install(). After
      fd_install() finishes, the fd can be used by userspace and
      we can have secret data in memory before the refcount_inc().
    
      A straightforward misuse where a user will predict the returned
      fd in another thread before the syscall returns and will use it
      to store secret data is somewhat dubious because such a user just
      shoots themself in the foot.
    
      But a more interesting misuse would be to close the predicted fd
      and decrement the refcount before the corresponding refcount_inc,
      this way one can briefly drop the refcount to zero while there are
      other users of secretmem."
    
    Move fd_install() after refcount_inc().
    
    Link: https://lkml.kernel.org/r/20211021154046.880251-1-keescook@chromium.org
    Link: https://lore.kernel.org/lkml/CACT4Y+b1sW6-Hkn8HQYw_SsT7X3tp-CJNh2ci0wG3ZnQz9jjig@mail.gmail.com
    Fixes: 9a436f8ff631 ("PM: hibernate: disable when there are active secretmem users")
    Signed-off-by: Kees Cook <keescook at chromium.org>
    Reported-by: Dmitry Vyukov <dvyukov at google.com>
    Reviewed-by: Dmitry Vyukov <dvyukov at google.com>
    Reviewed-by: David Hildenbrand <david at redhat.com>
    Reviewed-by: Jordy Zomer <jordy at pwning.systems>
    Cc: Mike Rapoport <rppt at kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/mm/secretmem.c b/mm/secretmem.c
index c2dda408bb36..22b310adb53d 100644
--- a/mm/secretmem.c
+++ b/mm/secretmem.c
@@ -218,8 +218,8 @@ SYSCALL_DEFINE1(memfd_secret, unsigned int, flags)
 
 	file->f_flags |= O_LARGEFILE;
 
-	fd_install(fd, file);
 	atomic_inc(&secretmem_users);
+	fd_install(fd, file);
 	return fd;
 
 err_put_fd:
commit 6f1b228529ae49b0f85ab89bcdb6c365df401558
Author: Gautham Ananthakrishna <gautham.ananthakrishna at oracle.com>
Date:   Thu Oct 28 14:36:17 2021 -0700

    ocfs2: fix race between searching chunks and release journal_head from buffer_head
    
    Encountered a race between ocfs2_test_bg_bit_allocatable() and
    jbd2_journal_put_journal_head() resulting in the below vmcore.
    
      PID: 106879  TASK: ffff880244ba9c00  CPU: 2   COMMAND: "loop3"
      Call trace:
        panic
        oops_end
        no_context
        __bad_area_nosemaphore
        bad_area_nosemaphore
        __do_page_fault
        do_page_fault
        page_fault
          [exception RIP: ocfs2_block_group_find_clear_bits+316]
        ocfs2_block_group_find_clear_bits [ocfs2]
        ocfs2_cluster_group_search [ocfs2]
        ocfs2_search_chain [ocfs2]
        ocfs2_claim_suballoc_bits [ocfs2]
        __ocfs2_claim_clusters [ocfs2]
        ocfs2_claim_clusters [ocfs2]
        ocfs2_local_alloc_slide_window [ocfs2]
        ocfs2_reserve_local_alloc_bits [ocfs2]
        ocfs2_reserve_clusters_with_limit [ocfs2]
        ocfs2_reserve_clusters [ocfs2]
        ocfs2_lock_refcount_allocators [ocfs2]
        ocfs2_make_clusters_writable [ocfs2]
        ocfs2_replace_cow [ocfs2]
        ocfs2_refcount_cow [ocfs2]
        ocfs2_file_write_iter [ocfs2]
        lo_rw_aio
        loop_queue_work
        kthread_worker_fn
        kthread
        ret_from_fork
    
    When ocfs2_test_bg_bit_allocatable() called bh2jh(bg_bh), the
    bg_bh->b_private NULL as jbd2_journal_put_journal_head() raced and
    released the jounal head from the buffer head.  Needed to take bit lock
    for the bit 'BH_JournalHead' to fix this race.
    
    Link: https://lkml.kernel.org/r/1634820718-6043-1-git-send-email-gautham.ananthakrishna@oracle.com
    Signed-off-by: Gautham Ananthakrishna <gautham.ananthakrishna at oracle.com>
    Reviewed-by: Joseph Qi <joseph.qi at linux.alibaba.com>
    Cc: <rajesh.sivaramasubramaniom at oracle.com>
    Cc: Mark Fasheh <mark at fasheh.com>
    Cc: Joel Becker <jlbec at evilplan.org>
    Cc: Junxiao Bi <junxiao.bi at oracle.com>
    Cc: Changwei Ge <gechangwei at live.cn>
    Cc: Gang He <ghe at suse.com>
    Cc: Jun Piao <piaojun at huawei.com>
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 8521942f5af2..481017e1dac5 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -1251,7 +1251,7 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
 {
 	struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
 	struct journal_head *jh;
-	int ret;
+	int ret = 1;
 
 	if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap))
 		return 0;
@@ -1259,14 +1259,18 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
 	if (!buffer_jbd(bg_bh))
 		return 1;
 
-	jh = bh2jh(bg_bh);
-	spin_lock(&jh->b_state_lock);
-	bg = (struct ocfs2_group_desc *) jh->b_committed_data;
-	if (bg)
-		ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
-	else
-		ret = 1;
-	spin_unlock(&jh->b_state_lock);
+	jbd_lock_bh_journal_head(bg_bh);
+	if (buffer_jbd(bg_bh)) {
+		jh = bh2jh(bg_bh);
+		spin_lock(&jh->b_state_lock);
+		bg = (struct ocfs2_group_desc *) jh->b_committed_data;
+		if (bg)
+			ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
+		else
+			ret = 1;
+		spin_unlock(&jh->b_state_lock);
+	}
+	jbd_unlock_bh_journal_head(bg_bh);
 
 	return ret;
 }
commit 337546e83fc7e50917f44846beee936abb9c9f1f
Author: Suren Baghdasaryan <surenb at google.com>
Date:   Thu Oct 28 14:36:14 2021 -0700

    mm/oom_kill.c: prevent a race between process_mrelease and exit_mmap
    
    Race between process_mrelease and exit_mmap, where free_pgtables is
    called while __oom_reap_task_mm is in progress, leads to kernel crash
    during pte_offset_map_lock call.  oom-reaper avoids this race by setting
    MMF_OOM_VICTIM flag and causing exit_mmap to take and release
    mmap_write_lock, blocking it until oom-reaper releases mmap_read_lock.
    
    Reusing MMF_OOM_VICTIM for process_mrelease would be the simplest way to
    fix this race, however that would be considered a hack.  Fix this race
    by elevating mm->mm_users and preventing exit_mmap from executing until
    process_mrelease is finished.  Patch slightly refactors the code to
    adapt for a possible mmget_not_zero failure.
    
    This fix has considerable negative impact on process_mrelease
    performance and will likely need later optimization.
    
    Link: https://lkml.kernel.org/r/20211022014658.263508-1-surenb@google.com
    Fixes: 884a7e5964e0 ("mm: introduce process_mrelease system call")
    Signed-off-by: Suren Baghdasaryan <surenb at google.com>
    Acked-by: Michal Hocko <mhocko at suse.com>
    Cc: David Rientjes <rientjes at google.com>
    Cc: Matthew Wilcox (Oracle) <willy at infradead.org>
    Cc: Johannes Weiner <hannes at cmpxchg.org>
    Cc: Roman Gushchin <guro at fb.com>
    Cc: Rik van Riel <riel at surriel.com>
    Cc: Minchan Kim <minchan at kernel.org>
    Cc: Christian Brauner <christian at brauner.io>
    Cc: Christoph Hellwig <hch at infradead.org>
    Cc: Oleg Nesterov <oleg at redhat.com>
    Cc: David Hildenbrand <david at redhat.com>
    Cc: Jann Horn <jannh at google.com>
    Cc: Shakeel Butt <shakeelb at google.com>
    Cc: Andy Lutomirski <luto at kernel.org>
    Cc: Christian Brauner <christian.brauner at ubuntu.com>
    Cc: Florian Weimer <fweimer at redhat.com>
    Cc: Jan Engelhardt <jengelh at inai.de>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 831340e7ad8b..989f35a2bbb1 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -1150,7 +1150,7 @@ SYSCALL_DEFINE2(process_mrelease, int, pidfd, unsigned int, flags)
 	struct task_struct *task;
 	struct task_struct *p;
 	unsigned int f_flags;
-	bool reap = true;
+	bool reap = false;
 	struct pid *pid;
 	long ret = 0;
 
@@ -1177,15 +1177,15 @@ SYSCALL_DEFINE2(process_mrelease, int, pidfd, unsigned int, flags)
 		goto put_task;
 	}
 
-	mm = p->mm;
-	mmgrab(mm);
-
-	/* If the work has been done already, just exit with success */
-	if (test_bit(MMF_OOM_SKIP, &mm->flags))
-		reap = false;
-	else if (!task_will_free_mem(p)) {
-		reap = false;
-		ret = -EINVAL;
+	if (mmget_not_zero(p->mm)) {
+		mm = p->mm;
+		if (task_will_free_mem(p))
+			reap = true;
+		else {
+			/* Error only if the work has not been done already */
+			if (!test_bit(MMF_OOM_SKIP, &mm->flags))
+				ret = -EINVAL;
+		}
 	}
 	task_unlock(p);
 
@@ -1201,7 +1201,8 @@ SYSCALL_DEFINE2(process_mrelease, int, pidfd, unsigned int, flags)
 	mmap_read_unlock(mm);
 
 drop_mm:
-	mmdrop(mm);
+	if (mm)
+		mmput(mm);
 put_task:
 	put_task_struct(task);
 put_pid:
commit eac96c3efdb593df1a57bb5b95dbe037bfa9a522
Author: Yang Shi <shy828301 at gmail.com>
Date:   Thu Oct 28 14:36:11 2021 -0700

    mm: filemap: check if THP has hwpoisoned subpage for PMD page fault
    
    When handling shmem page fault the THP with corrupted subpage could be
    PMD mapped if certain conditions are satisfied.  But kernel is supposed
    to send SIGBUS when trying to map hwpoisoned page.
    
    There are two paths which may do PMD map: fault around and regular
    fault.
    
    Before commit f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault()
    codepaths") the thing was even worse in fault around path.  The THP
    could be PMD mapped as long as the VMA fits regardless what subpage is
    accessed and corrupted.  After this commit as long as head page is not
    corrupted the THP could be PMD mapped.
    
    In the regular fault path the THP could be PMD mapped as long as the
    corrupted page is not accessed and the VMA fits.
    
    This loophole could be fixed by iterating every subpage to check if any
    of them is hwpoisoned or not, but it is somewhat costly in page fault
    path.
    
    So introduce a new page flag called HasHWPoisoned on the first tail
    page.  It indicates the THP has hwpoisoned subpage(s).  It is set if any
    subpage of THP is found hwpoisoned by memory failure and after the
    refcount is bumped successfully, then cleared when the THP is freed or
    split.
    
    The soft offline path doesn't need this since soft offline handler just
    marks a subpage hwpoisoned when the subpage is migrated successfully.
    But shmem THP didn't get split then migrated at all.
    
    Link: https://lkml.kernel.org/r/20211020210755.23964-3-shy828301@gmail.com
    Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
    Signed-off-by: Yang Shi <shy828301 at gmail.com>
    Reviewed-by: Naoya Horiguchi <naoya.horiguchi at nec.com>
    Suggested-by: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
    Cc: Hugh Dickins <hughd at google.com>
    Cc: Matthew Wilcox <willy at infradead.org>
    Cc: Oscar Salvador <osalvador at suse.de>
    Cc: Peter Xu <peterx at redhat.com>
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index a558d67ee86f..fbfd3fad48f2 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -171,6 +171,15 @@ enum pageflags {
 	/* Compound pages. Stored in first tail page's flags */
 	PG_double_map = PG_workingset,
 
+#ifdef CONFIG_MEMORY_FAILURE
+	/*
+	 * Compound pages. Stored in first tail page's flags.
+	 * Indicates that at least one subpage is hwpoisoned in the
+	 * THP.
+	 */
+	PG_has_hwpoisoned = PG_mappedtodisk,
+#endif
+
 	/* non-lru isolated movable page */
 	PG_isolated = PG_reclaim,
 
@@ -668,6 +677,20 @@ PAGEFLAG_FALSE(DoubleMap)
 	TESTSCFLAG_FALSE(DoubleMap)
 #endif
 
+#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE)
+/*
+ * PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in the
+ * compound page.
+ *
+ * This flag is set by hwpoison handler.  Cleared by THP split or free page.
+ */
+PAGEFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND)
+	TESTSCFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND)
+#else
+PAGEFLAG_FALSE(HasHWPoisoned)
+	TESTSCFLAG_FALSE(HasHWPoisoned)
+#endif
+
 /*
  * Check if a page is currently marked HWPoisoned. Note that this check is
  * best effort only and inherently racy: there is no way to synchronize with
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 92192cb086c7..c5142d237e48 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2426,6 +2426,8 @@ static void __split_huge_page(struct page *page, struct list_head *list,
 	/* lock lru list/PageCompound, ref frozen by page_ref_freeze */
 	lruvec = lock_page_lruvec(head);
 
+	ClearPageHasHWPoisoned(head);
+
 	for (i = nr - 1; i >= 1; i--) {
 		__split_huge_page_tail(head, i, lruvec, list);
 		/* Some pages can be beyond EOF: drop them from page cache */
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 73f68699e7ab..bdbbb32211a5 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1694,6 +1694,20 @@ try_again:
 	}
 
 	if (PageTransHuge(hpage)) {
+		/*
+		 * The flag must be set after the refcount is bumped
+		 * otherwise it may race with THP split.
+		 * And the flag can't be set in get_hwpoison_page() since
+		 * it is called by soft offline too and it is just called
+		 * for !MF_COUNT_INCREASE.  So here seems to be the best
+		 * place.
+		 *
+		 * Don't need care about the above error handling paths for
+		 * get_hwpoison_page() since they handle either free page
+		 * or unhandlable page.  The refcount is bumped iff the
+		 * page is a valid handlable page.
+		 */
+		SetPageHasHWPoisoned(hpage);
 		if (try_to_split_thp_page(p, "Memory Failure") < 0) {
 			action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED);
 			res = -EBUSY;
diff --git a/mm/memory.c b/mm/memory.c
index adf9b9ef8277..c52be6d6b605 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3906,6 +3906,15 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
 	if (compound_order(page) != HPAGE_PMD_ORDER)
 		return ret;
 
+	/*
+	 * Just backoff if any subpage of a THP is corrupted otherwise
+	 * the corrupted page may mapped by PMD silently to escape the
+	 * check.  This kind of THP just can be PTE mapped.  Access to
+	 * the corrupted subpage should trigger SIGBUS as expected.
+	 */
+	if (unlikely(PageHasHWPoisoned(page)))
+		return ret;
+
 	/*
 	 * Archs like ppc64 need additional space to store information
 	 * related to pte entry. Use the preallocated table for that.
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3ec39552d00f..23d3339ac4e8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1312,8 +1312,10 @@ static __always_inline bool free_pages_prepare(struct page *page,
 
 		VM_BUG_ON_PAGE(compound && compound_order(page) != order, page);
 
-		if (compound)
+		if (compound) {
 			ClearPageDoubleMap(page);
+			ClearPageHasHWPoisoned(page);
+		}
 		for (i = 1; i < (1 << order); i++) {
 			if (compound)
 				bad += free_tail_pages_check(page, page + i);
commit c7cb42e94473aafe553c0f2a3d8ca904599399ed
Author: Yang Shi <shy828301 at gmail.com>
Date:   Thu Oct 28 14:36:07 2021 -0700

    mm: hwpoison: remove the unnecessary THP check
    
    When handling THP hwpoison checked if the THP is in allocation or free
    stage since hwpoison may mistreat it as hugetlb page.  After commit
    415c64c1453a ("mm/memory-failure: split thp earlier in memory error
    handling") the problem has been fixed, so this check is no longer
    needed.  Remove it.  The side effect of the removal is hwpoison may
    report unsplit THP instead of unknown error for shmem THP.  It seems not
    like a big deal.
    
    The following patch "mm: filemap: check if THP has hwpoisoned subpage
    for PMD page fault" depends on this, which fixes shmem THP with
    hwpoisoned subpage(s) are mapped PMD wrongly.  So this patch needs to be
    backported to -stable as well.
    
    Link: https://lkml.kernel.org/r/20211020210755.23964-2-shy828301@gmail.com
    Signed-off-by: Yang Shi <shy828301 at gmail.com>
    Suggested-by: Naoya Horiguchi <naoya.horiguchi at nec.com>
    Acked-by: Naoya Horiguchi <naoya.horiguchi at nec.com>
    Cc: Hugh Dickins <hughd at google.com>
    Cc: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
    Cc: Matthew Wilcox <willy at infradead.org>
    Cc: Oscar Salvador <osalvador at suse.de>
    Cc: Peter Xu <peterx at redhat.com>
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 3e6449f2102a..73f68699e7ab 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1147,20 +1147,6 @@ static int __get_hwpoison_page(struct page *page)
 	if (!HWPoisonHandlable(head))
 		return -EBUSY;
 
-	if (PageTransHuge(head)) {
-		/*
-		 * Non anonymous thp exists only in allocation/free time. We
-		 * can't handle such a case correctly, so let's give it up.
-		 * This should be better than triggering BUG_ON when kernel
-		 * tries to touch the "partially handled" page.
-		 */
-		if (!PageAnon(head)) {
-			pr_err("Memory failure: %#lx: non anonymous thp\n",
-				page_to_pfn(page));
-			return 0;
-		}
-	}
-
 	if (get_page_unless_zero(head)) {
 		if (head == compound_head(page))
 			return 1;
commit 8dcb3060d81dbfa8d954a2ec64ef7ca330f5bb4d
Author: Shakeel Butt <shakeelb at google.com>
Date:   Thu Oct 28 14:36:04 2021 -0700

    memcg: page_alloc: skip bulk allocator for __GFP_ACCOUNT
    
    Commit 5c1f4e690eec ("mm/vmalloc: switch to bulk allocator in
    __vmalloc_area_node()") switched to bulk page allocator for order 0
    allocation backing vmalloc.  However bulk page allocator does not
    support __GFP_ACCOUNT allocations and there are several users of
    kvmalloc(__GFP_ACCOUNT).
    
    For now make __GFP_ACCOUNT allocations bypass bulk page allocator.  In
    future if there is workload that can be significantly improved with the
    bulk page allocator with __GFP_ACCCOUNT support, we can revisit the
    decision.
    
    Link: https://lkml.kernel.org/r/20211014151607.2171970-1-shakeelb@google.com
    Fixes: 5c1f4e690eec ("mm/vmalloc: switch to bulk allocator in __vmalloc_area_node()")
    Signed-off-by: Shakeel Butt <shakeelb at google.com>
    Reported-by: Vasily Averin <vvs at virtuozzo.com>
    Tested-by: Vasily Averin <vvs at virtuozzo.com>
    Acked-by: David Hildenbrand <david at redhat.com>
    Acked-by: Michal Hocko <mhocko at suse.com>
    Acked-by: Roman Gushchin <guro at fb.com>
    Acked-by: Johannes Weiner <hannes at cmpxchg.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b37435c274cf..3ec39552d00f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5223,6 +5223,10 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid,
 	if (unlikely(page_array && nr_pages - nr_populated == 0))
 		goto out;
 
+	/* Bulk allocator does not support memcg accounting. */
+	if (memcg_kmem_enabled() && (gfp & __GFP_ACCOUNT))
+		goto failed;
+
 	/* Use the single page allocator for one page. */
 	if (nr_pages - nr_populated == 1)
 		goto failed;
commit f25a5481af12c2360710583b84537eb9e652d57d
Merge: f31531e55495 3dd60fb9d95d
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Thu Oct 28 16:50:25 2021 -0700

    Merge tag 'libnvdimm-fixes-5.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
    
    Pull libnvdimm fix from Dan Williams:
    
     - Fix a regression introduced in v5.15-rc6 that caused nvdimm namespace
       shutdown to hang due to reworks in the block layer q_usage_count.
    
    * tag 'libnvdimm-fixes-5.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
      nvdimm/pmem: stop using q_usage_count as external pgmap refcount

commit 90935eb303e0d12f3d3d0383262e65290321f5f6
Author: Wolfram Sang <wsa+renesas at sang-engineering.com>
Date:   Thu Oct 28 21:51:49 2021 +0200

    mmc: tmio: reenable card irqs after the reset callback
    
    The reset callback may clear the internal card detect interrupts, so
    make sure to reenable them if needed.
    
    Fixes: b4d86f37eacb ("mmc: renesas_sdhi: do hard reset if possible")
    Reported-by: Biju Das <biju.das.jz at bp.renesas.com>
    Signed-off-by: Wolfram Sang <wsa+renesas at sang-engineering.com>
    Cc: stable at vger.kernel.org
    Link: https://lore.kernel.org/r/20211028195149.8003-1-wsa+renesas@sang-engineering.com
    Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 7dfc26f48c18..e2affa52ef46 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -195,6 +195,10 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host)
 	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask_all);
 	host->sdcard_irq_mask = host->sdcard_irq_mask_all;
 
+	if (host->native_hotplug)
+		tmio_mmc_enable_mmc_irqs(host,
+				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
+
 	tmio_mmc_set_bus_width(host, host->mmc->ios.bus_width);
 
 	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
@@ -956,8 +960,15 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	case MMC_POWER_OFF:
 		tmio_mmc_power_off(host);
 		/* For R-Car Gen2+, we need to reset SDHI specific SCC */
-		if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
+		if (host->pdata->flags & TMIO_MMC_MIN_RCAR2) {
 			host->reset(host);
+
+			if (host->native_hotplug)
+				tmio_mmc_enable_mmc_irqs(host,
+						TMIO_STAT_CARD_REMOVE |
+						TMIO_STAT_CARD_INSERT);
+		}
+
 		host->set_clock(host, 0);
 		break;
 	case MMC_POWER_UP:
@@ -1185,10 +1196,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
 	_host->set_clock(_host, 0);
 	tmio_mmc_reset(_host);
 
-	if (_host->native_hotplug)
-		tmio_mmc_enable_mmc_irqs(_host,
-				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
-
 	spin_lock_init(&_host->lock);
 	mutex_init(&_host->ios_lock);
 
commit f31531e55495ca3746fb895ffdf73586be8259fa
Merge: 411a44c24a56 b112166a894d
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Thu Oct 28 12:17:01 2021 -0700

    Merge tag 'drm-fixes-2021-10-29' of git://anongit.freedesktop.org/drm/drm
    
    Pull drm fixes from Dave Airlie:
     "Quiet but not too quiet, I blame Halloween.
    
      The first set of amdgpu fixes missed last week, hence why this has a
      few more of them, it's mostly display fixes for new GPUs and some
      debugfs OOB stuff.
    
      The i915 patches have one to remove a tracepoint possible issue before
      it's a real problem, the others around cflush and display are cc'ed to
      stable as well.
    
      Otherwise it's just a few misc fixes.
    
      Summary:
    
      MAINTAINERS:
       - Fix the path pattern
    
      ttm:
       - Fix fence leak in ttm_transfered_destroy.
    
      core:
       - Add GPD Win3 rotation quirk
    
      i915:
       - Remove unconditional clflushes
       - Fix oops on boot due to sync state on disabled DP encoders
       - Revert backend specific data added to tracepoints
       - Remove useless and incorrect memory frequence calculation
    
      panel:
       - Add quirk for Aya Neo 2021
    
      seltest:
       - Reset property count for each drm damage selftest so full run will
         work correctly.
    
      amdgpu:
       - Fix two potential out of bounds writes in debugfs
       - Fix revision handling for Yellow Carp
       - Display fixes for Yellow Carp
       - Display fixes for DCN 3.1"
    
    * tag 'drm-fixes-2021-10-29' of git://anongit.freedesktop.org/drm/drm: (21 commits)
      MAINTAINERS: dri-devel is for all of drivers/gpu
      drm/i915: Revert 'guc_id' from i915_request tracepoint
      drm/amd/display: Fix deadlock when falling back to v2 from v3
      drm/amd/display: Fallback to clocks which meet requested voltage on DCN31
      drm/amdgpu: Fix even more out of bound writes from debugfs
      drm: panel-orientation-quirks: Add quirk for GPD Win3
      drm/i915/dp: Skip the HW readout of DPCD on disabled encoders
      drm/i915: Catch yet another unconditioal clflush
      drm/i915: Convert unconditional clflush to drm_clflush_virt_range()
      drm/i915/selftests: Properly reset mock object propers for each test
      drm: panel-orientation-quirks: Add quirk for Aya Neo 2021
      drm/ttm: fix memleak in ttm_transfered_destroy
      drm/amdgpu: support B0&B1 external revision id for yellow carp
      drm/amd/display: Moved dccg init to after bios golden init
      drm/amd/display: Increase watermark latencies for DCN3.1
      drm/amd/display: increase Z9 latency to workaround underflow in Z9
      drm/amd/display: Require immediate flip support for DCN3.1 planes
      drm/amd/display: Fix prefetch bandwidth calculation for DCN3.1
      drm/amd/display: Limit display scaling to up to true 4k for DCN 3.1
      drm/amdgpu: fix out of bounds write
      ...

commit b112166a894db446f47a8c31781b037f28ac1721
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Thu Oct 28 19:08:57 2021 +0200

    MAINTAINERS: dri-devel is for all of drivers/gpu
    
    Somehow we only have a list of subdirectories, which apparently made
    it harder for folks to find the gpu maintainers. Fix that.
    
    References: https://lore.kernel.org/dri-devel/YXrAAZlxxStNFG%2FK@phenom.ffwll.local/
    Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
    Cc: David Airlie <airlied at linux.ie>
    Cc: Daniel Vetter <daniel at ffwll.ch>
    Cc: Steven Rostedt <rostedt at goodmis.org>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211028170857.4029606-1-daniel.vetter@ffwll.ch

diff --git a/MAINTAINERS b/MAINTAINERS
index f26920f0fa65..c2fbfc53c749 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6147,8 +6147,7 @@ T:	git git://anongit.freedesktop.org/drm/drm
 F:	Documentation/devicetree/bindings/display/
 F:	Documentation/devicetree/bindings/gpu/
 F:	Documentation/gpu/
-F:	drivers/gpu/drm/
-F:	drivers/gpu/vga/
+F:	drivers/gpu/
 F:	include/drm/
 F:	include/linux/vga*
 F:	include/uapi/drm/
commit 946ca97e2ea3682e434ae1d0958a4565fa10b6bc
Merge: 79516af3497a 9a4aa3a2f160
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Oct 29 04:46:14 2021 +1000

    Merge tag 'drm-intel-fixes-2021-10-28' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes
    
    drm/i915 fixes for v5.15 final:
    - Remove unconditional clflushes
    - Fix oops on boot due to sync state on disabled DP encoders
    - Revert backend specific data added to tracepoints
    - Remove useless and incorrect memory frequence calculation
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    From: Jani Nikula <jani.nikula at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/8735olh27y.fsf@intel.com

commit 411a44c24a561e449b592ff631b7ae321f1eb559
Merge: 4fb7d85b2ebf 35392da51b1a
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Thu Oct 28 10:17:31 2021 -0700

    Merge tag 'net-5.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
    
    Pull networking fixes from Jakub Kicinski:
     "Including fixes from WiFi (mac80211), and BPF.
    
      Current release - regressions:
    
       - skb_expand_head: adjust skb->truesize to fix socket memory
         accounting
    
       - mptcp: fix corrupt receiver key in MPC + data + checksum
    
      Previous releases - regressions:
    
       - multicast: calculate csum of looped-back and forwarded packets
    
       - cgroup: fix memory leak caused by missing cgroup_bpf_offline
    
       - cfg80211: fix management registrations locking, prevent list
         corruption
    
       - cfg80211: correct false positive in bridge/4addr mode check
    
       - tcp_bpf: fix race in the tcp_bpf_send_verdict resulting in reusing
         previous verdict
    
      Previous releases - always broken:
    
       - sctp: enhancements for the verification tag, prevent attackers from
         killing SCTP sessions
    
       - tipc: fix size validations for the MSG_CRYPTO type
    
       - mac80211: mesh: fix HE operation element length check, prevent out
         of bound access
    
       - tls: fix sign of socket errors, prevent positive error codes being
         reported from read()/write()
    
       - cfg80211: scan: extend RCU protection in
         cfg80211_add_nontrans_list()
    
       - implement ->sock_is_readable() for UDP and AF_UNIX, fix poll() for
         sockets in a BPF sockmap
    
       - bpf: fix potential race in tail call compatibility check resulting
         in two operations which would make the map incompatible succeeding
    
       - bpf: prevent increasing bpf_jit_limit above max
    
       - bpf: fix error usage of map_fd and fdget() in generic batch update
    
       - phy: ethtool: lock the phy for consistency of results
    
       - prevent infinite while loop in skb_tx_hash() when Tx races with
         driver reconfiguring the queue <> traffic class mapping
    
       - usbnet: fixes for bad HW conjured by syzbot
    
       - xen: stop tx queues during live migration, prevent UAF
    
       - net-sysfs: initialize uid and gid before calling
         net_ns_get_ownership
    
       - mlxsw: prevent Rx stalls under memory pressure"
    
    * tag 'net-5.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (67 commits)
      Revert "net: hns3: fix pause config problem after autoneg disabled"
      mptcp: fix corrupt receiver key in MPC + data + checksum
      riscv, bpf: Fix potential NULL dereference
      octeontx2-af: Fix possible null pointer dereference.
      octeontx2-af: Display all enabled PF VF rsrc_alloc entries.
      octeontx2-af: Check whether ipolicers exists
      net: ethernet: microchip: lan743x: Fix skb allocation failure
      net/tls: Fix flipped sign in async_wait.err assignment
      net/tls: Fix flipped sign in tls_err_abort() calls
      net/smc: Correct spelling mistake to TCPF_SYN_RECV
      net/smc: Fix smc_link->llc_testlink_time overflow
      nfp: bpf: relax prog rejection for mtu check through max_pkt_offset
      vmxnet3: do not stop tx queues after netif_device_detach()
      r8169: Add device 10ec:8162 to driver r8169
      ptp: Document the PTP_CLK_MAGIC ioctl number
      usbnet: fix error return code in usbnet_probe()
      net: hns3: adjust string spaces of some parameters of tx bd info in debugfs
      net: hns3: expand buffer len for some debugfs command
      net: hns3: add more string spaces for dumping packets number of queue info in debugfs
      net: hns3: fix data endian problem of some functions of debugfs
      ...

commit 4fb7d85b2ebf0f06d6b47df2c9f2d45c6fec8b8c
Merge: 8685de2ed8c1 d81d0e41ed5f
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Thu Oct 28 10:04:39 2021 -0700

    Merge tag 'spi-fix-v5.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
    
    Pull spi fixes from Mark Brown:
     "A couple of final driver specific fixes for v5.15, one fixing
      potential ID collisions between two instances of the Altera driver and
      one making Microwire full duplex mode actually work on pl022"
    
    * tag 'spi-fix-v5.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
      spi: spl022: fix Microwire full duplex mode
      spi: altera: Change to dynamic allocation of spi id

commit 8685de2ed8c1b0e5cfb07d1986e6a38250a58e8a
Merge: eecd231a80a5 55e6d8037805
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Thu Oct 28 10:00:58 2021 -0700

    Merge tag 'regmap-fix-v5.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
    
    Pull regmap fix from Mark Brown:
     "This fixes a potential double free when handling an out of memory
      error inserting a node into an rbtree regcache"
    
    * tag 'regmap-fix-v5.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
      regmap: Fix possible double-free in regcache_rbtree_exit()

commit eecd231a80a5d54afc5eb350fc890ab15350408d
Merge: fc18cc89b980 cd004d8299f1
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Thu Oct 28 09:55:25 2021 -0700

    Merge tag 'linux-watchdog-5.15-rc7' of git://www.linux-watchdog.org/linux-watchdog
    
    Pull watchdog fixes from Wim Van Sebroeck:
     "I overlooked Guenters request to sent this upstream earlier, so it's a
      bit late in the release cycle.
    
      This contains:
    
       - Revert "watchdog: iTCO_wdt: Account for rebooting on second
         timeout"
    
       - sbsa: only use 32-bit accessors
    
       - sbsa: drop unneeded MODULE_ALIAS
    
       - ixp4xx_wdt: Fix address space warning
    
       - Fix OMAP watchdog early handling"
    
    * tag 'linux-watchdog-5.15-rc7' of git://www.linux-watchdog.org/linux-watchdog:
      watchdog: Fix OMAP watchdog early handling
      watchdog: ixp4xx_wdt: Fix address space warning
      watchdog: sbsa: drop unneeded MODULE_ALIAS
      watchdog: sbsa: only use 32-bit accessors
      Revert "watchdog: iTCO_wdt: Account for rebooting on second timeout"

commit fc18cc89b9802dbe710cbfb52d0b11b3197ead18
Merge: 9c5456773d79 7fa598f9706d
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Thu Oct 28 09:50:56 2021 -0700

    Merge tag 'trace-v5.15-rc6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
    
    Pull tracing fix from Steven Rostedt:
     "Do not WARN when attaching event probe to non-existent event
    
      If the user tries to attach an event probe (eprobe) to an event that
      does not exist, it will trigger a warning. There's an error check that
      only expects memory issues otherwise it is considered a bug. But
      changes in the code to move around the locking made it that it can
      error out if the user attempts to attach to an event that does not
      exist, returning an -ENODEV. As this path can be caused by user space
      putting in a bad value, do not trigger a WARN"
    
    * tag 'trace-v5.15-rc6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
      tracing: Do not warn when connecting eprobe to non existing event

commit 35392da51b1ab7ba0c63de0a553e2a93c2314266
Author: Guangbin Huang <huangguangbin2 at huawei.com>
Date:   Thu Oct 28 22:06:24 2021 +0800

    Revert "net: hns3: fix pause config problem after autoneg disabled"
    
    This reverts commit 3bda2e5df476417b6d08967e2d84234a59d57b1c.
    
    According to discussion with Andrew as follow:
    https://lore.kernel.org/netdev/09eda9fe-196b-006b-6f01-f54e75715961@huawei.com/
    
    HNS3 driver needs to separate pause autoneg from general autoneg, so revert
    this incorrect patch.
    
    Signed-off-by: Guangbin Huang <huangguangbin2 at huawei.com>
    Link: https://lore.kernel.org/r/20211028140624.53149-1-huangguangbin2@huawei.com
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index da3a593f6a56..d701451596c8 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -568,7 +568,6 @@ struct hnae3_ae_ops {
 			       u32 *auto_neg, u32 *rx_en, u32 *tx_en);
 	int (*set_pauseparam)(struct hnae3_handle *handle,
 			      u32 auto_neg, u32 rx_en, u32 tx_en);
-	int (*restore_pauseparam)(struct hnae3_handle *handle);
 
 	int (*set_autoneg)(struct hnae3_handle *handle, bool enable);
 	int (*get_autoneg)(struct hnae3_handle *handle);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 7d92dd273ed7..5ebd96f6833d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -824,26 +824,6 @@ static int hns3_check_ksettings_param(const struct net_device *netdev,
 	return 0;
 }
 
-static int hns3_set_phy_link_ksettings(struct net_device *netdev,
-				       const struct ethtool_link_ksettings *cmd)
-{
-	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
-	int ret;
-
-	if (cmd->base.speed == SPEED_1000 &&
-	    cmd->base.autoneg == AUTONEG_DISABLE)
-		return -EINVAL;
-
-	if (cmd->base.autoneg == AUTONEG_DISABLE && ops->restore_pauseparam) {
-		ret = ops->restore_pauseparam(handle);
-		if (ret)
-			return ret;
-	}
-
-	return phy_ethtool_ksettings_set(netdev->phydev, cmd);
-}
-
 static int hns3_set_link_ksettings(struct net_device *netdev,
 				   const struct ethtool_link_ksettings *cmd)
 {
@@ -862,11 +842,16 @@ static int hns3_set_link_ksettings(struct net_device *netdev,
 		  cmd->base.autoneg, cmd->base.speed, cmd->base.duplex);
 
 	/* Only support ksettings_set for netdev with phy attached for now */
-	if (netdev->phydev)
-		return hns3_set_phy_link_ksettings(netdev, cmd);
-	else if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) &&
-		 ops->set_phy_link_ksettings)
+	if (netdev->phydev) {
+		if (cmd->base.speed == SPEED_1000 &&
+		    cmd->base.autoneg == AUTONEG_DISABLE)
+			return -EINVAL;
+
+		return phy_ethtool_ksettings_set(netdev->phydev, cmd);
+	} else if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) &&
+		   ops->set_phy_link_ksettings) {
 		return ops->set_phy_link_ksettings(handle, cmd);
+	}
 
 	if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
 		return -EOPNOTSUPP;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 269e579762b2..d891390d492f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -10998,35 +10998,6 @@ static int hclge_set_pauseparam(struct hnae3_handle *handle, u32 auto_neg,
 	return -EOPNOTSUPP;
 }
 
-static int hclge_restore_pauseparam(struct hnae3_handle *handle)
-{
-	struct hclge_vport *vport = hclge_get_vport(handle);
-	struct hclge_dev *hdev = vport->back;
-	u32 auto_neg, rx_pause, tx_pause;
-	int ret;
-
-	hclge_get_pauseparam(handle, &auto_neg, &rx_pause, &tx_pause);
-	/* when autoneg is disabled, the pause setting of phy has no effect
-	 * unless the link goes down.
-	 */
-	ret = phy_suspend(hdev->hw.mac.phydev);
-	if (ret)
-		return ret;
-
-	phy_set_asym_pause(hdev->hw.mac.phydev, rx_pause, tx_pause);
-
-	ret = phy_resume(hdev->hw.mac.phydev);
-	if (ret)
-		return ret;
-
-	ret = hclge_mac_pause_setup_hw(hdev);
-	if (ret)
-		dev_err(&hdev->pdev->dev,
-			"restore pauseparam error, ret = %d.\n", ret);
-
-	return ret;
-}
-
 static void hclge_get_ksettings_an_result(struct hnae3_handle *handle,
 					  u8 *auto_neg, u32 *speed, u8 *duplex)
 {
@@ -12990,7 +12961,6 @@ static const struct hnae3_ae_ops hclge_ops = {
 	.halt_autoneg = hclge_halt_autoneg,
 	.get_pauseparam = hclge_get_pauseparam,
 	.set_pauseparam = hclge_set_pauseparam,
-	.restore_pauseparam = hclge_restore_pauseparam,
 	.set_mtu = hclge_set_mtu,
 	.reset_queue = hclge_reset_tqp,
 	.get_stats = hclge_get_stats,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
index 124791e4bfee..95074e91a846 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
@@ -1435,7 +1435,7 @@ static int hclge_bp_setup_hw(struct hclge_dev *hdev, u8 tc)
 	return 0;
 }
 
-int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
+static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
 {
 	bool tx_en, rx_en;
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
index 4b2c3a788980..2ee9b795f71d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
@@ -244,7 +244,6 @@ int hclge_tm_get_pri_weight(struct hclge_dev *hdev, u8 pri_id, u8 *weight);
 int hclge_tm_get_pri_shaper(struct hclge_dev *hdev, u8 pri_id,
 			    enum hclge_opcode_type cmd,
 			    struct hclge_tm_shaper_para *para);
-int hclge_mac_pause_setup_hw(struct hclge_dev *hdev);
 int hclge_tm_get_q_to_qs_map(struct hclge_dev *hdev, u16 q_id, u16 *qset_id);
 int hclge_tm_get_q_to_tc(struct hclge_dev *hdev, u16 q_id, u8 *tc_id);
 int hclge_tm_get_pg_to_pri_map(struct hclge_dev *hdev, u8 pg_id,
commit f7cc8890f30d3ddc785e2b2ddc647da5b4b3c3ec
Author: Davide Caratti <dcaratti at redhat.com>
Date:   Wed Oct 27 13:38:55 2021 -0700

    mptcp: fix corrupt receiver key in MPC + data + checksum
    
    using packetdrill it's possible to observe that the receiver key contains
    random values when clients transmit MP_CAPABLE with data and checksum (as
    specified in RFC8684 §3.1). Fix the layout of mptcp_out_options, to avoid
    using the skb extension copy when writing the MP_CAPABLE sub-option.
    
    Fixes: d7b269083786 ("mptcp: shrink mptcp_out_options struct")
    Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/233
    Reported-by: Poorva Sonparote <psonparo at redhat.com>
    Signed-off-by: Davide Caratti <dcaratti at redhat.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau at linux.intel.com>
    Link: https://lore.kernel.org/r/20211027203855.264600-1-mathew.j.martineau@linux.intel.com
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index 6026bbefbffd..3214848402ec 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -69,6 +69,10 @@ struct mptcp_out_options {
 		struct {
 			u64 sndr_key;
 			u64 rcvr_key;
+			u64 data_seq;
+			u32 subflow_seq;
+			u16 data_len;
+			__sum16 csum;
 		};
 		struct {
 			struct mptcp_addr_info addr;
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index c41273cefc51..f0f22eb4fd5f 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -485,11 +485,11 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb,
 		mpext = mptcp_get_ext(skb);
 		data_len = mpext ? mpext->data_len : 0;
 
-		/* we will check ext_copy.data_len in mptcp_write_options() to
+		/* we will check ops->data_len in mptcp_write_options() to
 		 * discriminate between TCPOLEN_MPTCP_MPC_ACK_DATA and
 		 * TCPOLEN_MPTCP_MPC_ACK
 		 */
-		opts->ext_copy.data_len = data_len;
+		opts->data_len = data_len;
 		opts->suboptions = OPTION_MPTCP_MPC_ACK;
 		opts->sndr_key = subflow->local_key;
 		opts->rcvr_key = subflow->remote_key;
@@ -505,9 +505,9 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb,
 			len = TCPOLEN_MPTCP_MPC_ACK_DATA;
 			if (opts->csum_reqd) {
 				/* we need to propagate more info to csum the pseudo hdr */
-				opts->ext_copy.data_seq = mpext->data_seq;
-				opts->ext_copy.subflow_seq = mpext->subflow_seq;
-				opts->ext_copy.csum = mpext->csum;
+				opts->data_seq = mpext->data_seq;
+				opts->subflow_seq = mpext->subflow_seq;
+				opts->csum = mpext->csum;
 				len += TCPOLEN_MPTCP_DSS_CHECKSUM;
 			}
 			*size = ALIGN(len, 4);
@@ -1227,7 +1227,7 @@ static void mptcp_set_rwin(const struct tcp_sock *tp)
 		WRITE_ONCE(msk->rcv_wnd_sent, ack_seq);
 }
 
-static u16 mptcp_make_csum(const struct mptcp_ext *mpext)
+static u16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __sum16 sum)
 {
 	struct csum_pseudo_header header;
 	__wsum csum;
@@ -1237,15 +1237,21 @@ static u16 mptcp_make_csum(const struct mptcp_ext *mpext)
 	 * always the 64-bit value, irrespective of what length is used in the
 	 * DSS option itself.
 	 */
-	header.data_seq = cpu_to_be64(mpext->data_seq);
-	header.subflow_seq = htonl(mpext->subflow_seq);
-	header.data_len = htons(mpext->data_len);
+	header.data_seq = cpu_to_be64(data_seq);
+	header.subflow_seq = htonl(subflow_seq);
+	header.data_len = htons(data_len);
 	header.csum = 0;
 
-	csum = csum_partial(&header, sizeof(header), ~csum_unfold(mpext->csum));
+	csum = csum_partial(&header, sizeof(header), ~csum_unfold(sum));
 	return (__force u16)csum_fold(csum);
 }
 
+static u16 mptcp_make_csum(const struct mptcp_ext *mpext)
+{
+	return __mptcp_make_csum(mpext->data_seq, mpext->subflow_seq, mpext->data_len,
+				 mpext->csum);
+}
+
 void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 			 struct mptcp_out_options *opts)
 {
@@ -1337,7 +1343,7 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 			len = TCPOLEN_MPTCP_MPC_SYN;
 		} else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions) {
 			len = TCPOLEN_MPTCP_MPC_SYNACK;
-		} else if (opts->ext_copy.data_len) {
+		} else if (opts->data_len) {
 			len = TCPOLEN_MPTCP_MPC_ACK_DATA;
 			if (opts->csum_reqd)
 				len += TCPOLEN_MPTCP_DSS_CHECKSUM;
@@ -1366,14 +1372,17 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 
 		put_unaligned_be64(opts->rcvr_key, ptr);
 		ptr += 2;
-		if (!opts->ext_copy.data_len)
+		if (!opts->data_len)
 			goto mp_capable_done;
 
 		if (opts->csum_reqd) {
-			put_unaligned_be32(opts->ext_copy.data_len << 16 |
-					   mptcp_make_csum(&opts->ext_copy), ptr);
+			put_unaligned_be32(opts->data_len << 16 |
+					   __mptcp_make_csum(opts->data_seq,
+							     opts->subflow_seq,
+							     opts->data_len,
+							     opts->csum), ptr);
 		} else {
-			put_unaligned_be32(opts->ext_copy.data_len << 16 |
+			put_unaligned_be32(opts->data_len << 16 |
 					   TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
 		}
 		ptr += 1;
commit 27de809a3d83a6199664479ebb19712533d6fd9b
Author: Björn Töpel <bjorn at kernel.org>
Date:   Thu Oct 28 14:51:15 2021 +0200

    riscv, bpf: Fix potential NULL dereference
    
    The bpf_jit_binary_free() function requires a non-NULL argument. When
    the RISC-V BPF JIT fails to converge in NR_JIT_ITERATIONS steps,
    jit_data->header will be NULL, which triggers a NULL
    dereference. Avoid this by checking the argument, prior calling the
    function.
    
    Fixes: ca6cb5447cec ("riscv, bpf: Factor common RISC-V JIT code")
    Signed-off-by: Björn Töpel <bjorn at kernel.org>
    Acked-by: Daniel Borkmann <daniel at iogearbox.net>
    Link: https://lore.kernel.org/r/20211028125115.514587-1-bjorn@kernel.org
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c
index 0fee2cbaaf53..753d85bdfad0 100644
--- a/arch/riscv/net/bpf_jit_core.c
+++ b/arch/riscv/net/bpf_jit_core.c
@@ -125,7 +125,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 
 	if (i == NR_JIT_ITERATIONS) {
 		pr_err("bpf-jit: image did not converge in <%d passes!\n", i);
-		bpf_jit_binary_free(jit_data->header);
+		if (jit_data->header)
+			bpf_jit_binary_free(jit_data->header);
 		prog = orig_prog;
 		goto out_offset;
 	}
commit f3d1436d4bf8ced1c9a62a045d193a65567e1fcc
Author: David Woodhouse <dwmw at amazon.co.uk>
Date:   Tue Oct 26 04:12:38 2021 +0100

    KVM: x86: Take srcu lock in post_kvm_run_save()
    
    The Xen interrupt injection for event channels relies on accessing the
    guest's vcpu_info structure in __kvm_xen_has_interrupt(), through a
    gfn_to_hva_cache.
    
    This requires the srcu lock to be held, which is mostly the case except
    for this code path:
    
    [   11.822877] WARNING: suspicious RCU usage
    [   11.822965] -----------------------------
    [   11.823013] include/linux/kvm_host.h:664 suspicious rcu_dereference_check() usage!
    [   11.823131]
    [   11.823131] other info that might help us debug this:
    [   11.823131]
    [   11.823196]
    [   11.823196] rcu_scheduler_active = 2, debug_locks = 1
    [   11.823253] 1 lock held by dom:0/90:
    [   11.823292]  #0: ffff998956ec8118 (&vcpu->mutex){+.+.}, at: kvm_vcpu_ioctl+0x85/0x680
    [   11.823379]
    [   11.823379] stack backtrace:
    [   11.823428] CPU: 2 PID: 90 Comm: dom:0 Kdump: loaded Not tainted 5.4.34+ #5
    [   11.823496] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
    [   11.823612] Call Trace:
    [   11.823645]  dump_stack+0x7a/0xa5
    [   11.823681]  lockdep_rcu_suspicious+0xc5/0x100
    [   11.823726]  __kvm_xen_has_interrupt+0x179/0x190
    [   11.823773]  kvm_cpu_has_extint+0x6d/0x90
    [   11.823813]  kvm_cpu_accept_dm_intr+0xd/0x40
    [   11.823853]  kvm_vcpu_ready_for_interrupt_injection+0x20/0x30
                  < post_kvm_run_save() inlined here >
    [   11.823906]  kvm_arch_vcpu_ioctl_run+0x135/0x6a0
    [   11.823947]  kvm_vcpu_ioctl+0x263/0x680
    
    Fixes: 40da8ccd724f ("KVM: x86/xen: Add event channel interrupt vector upcall")
    Signed-off-by: David Woodhouse <dwmw at amazon.co.uk>
    Cc: stable at vger.kernel.org
    Message-Id: <606aaaf29fca3850a63aa4499826104e77a72346.camel at infradead.org>
    Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 5c82eff19e4a..ffd9dd7d5d14 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8783,9 +8783,17 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu)
 
 	kvm_run->cr8 = kvm_get_cr8(vcpu);
 	kvm_run->apic_base = kvm_get_apic_base(vcpu);
+
+	/*
+	 * The call to kvm_ready_for_interrupt_injection() may end up in
+	 * kvm_xen_has_interrupt() which may require the srcu lock to be
+	 * held, to protect against changes in the vcpu_info address.
+	 */
+	vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
 	kvm_run->ready_for_interrupt_injection =
 		pic_in_kernel(vcpu->kvm) ||
 		kvm_vcpu_ready_for_interrupt_injection(vcpu);
+	srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
 
 	if (is_smm(vcpu))
 		kvm_run->flags |= KVM_RUN_X86_SMM;
commit f4aaf1fa8b17e74aa46bf0165c35a1575b239d4e
Merge: e0c60d0102a5 86aeda32b887
Author: Jens Axboe <axboe at kernel.dk>
Date:   Thu Oct 28 08:34:01 2021 -0600

    Merge tag 'nvme-5.15-2021-10-28' of git://git.infradead.org/nvme into block-5.15
    
    Pull NVMe fixes from Christoph:
    
    "nvme fixe for Linux 5.15
    
     - fix nvmet-tcp header digest verification (Amit Engel)
     - fix a memory leak in nvmet-tcp when releasing a queue
       (Maurizio Lombardi)
     - fix nvme-tcp H2CData PDU send accounting again (Sagi Grimberg)
     - fix digest pointer calculation in nvme-tcp and nvmet-tcp
       (Varun Prakash)
     - fix possible nvme-tcp req->offset corruption (Varun Prakash)"
    
    * tag 'nvme-5.15-2021-10-28' of git://git.infradead.org/nvme:
      nvmet-tcp: fix header digest verification
      nvmet-tcp: fix data digest pointer calculation
      nvme-tcp: fix data digest pointer calculation
      nvme-tcp: fix possible req->offset corruption
      nvme-tcp: fix H2CData PDU send accounting (again)
      nvmet-tcp: fix a memory leak when releasing a queue

commit 20af8864a3029fde67fd00999f58bc1ada632374
Merge: e8684db191e4 c2d4c543f74c
Author: David S. Miller <davem at davemloft.net>
Date:   Thu Oct 28 14:47:37 2021 +0100

    Merge branch 'octeontx2-debugfs-fixes'
    
    Rakesh Babu Saladi says:
    
    ====================
    RVU Debugfs fix updates.
    
    The following patch series consists of the patch fixes done over
    rvu_debugfs.c and rvu_nix.c files.
    
    Patch 1: Check and return if ipolicers do not exists.
    Patch 2: Fix rsrc_alloc to print all enabled PF/VF entries with list of LFs
    allocated for each functional block.
    Patch 3: Fix possible null pointer dereference.
    ====================
    
    Signed-off-by: David S. Miller <davem at davemloft.net>

commit c2d4c543f74c90f883e8ec62a31973ae8807d354
Author: Rakesh Babu Saladi <rsaladi2 at marvell.com>
Date:   Wed Oct 27 23:02:34 2021 +0530

    octeontx2-af: Fix possible null pointer dereference.
    
    This patch fixes possible null pointer dereference in files
    "rvu_debugfs.c" and "rvu_nix.c"
    
    Fixes: 8756828a8148 ("octeontx2-af: Add NPA aura and pool contexts to debugfs")
    Fixes: 9a946def264d ("octeontx2-af: Modify nix_vtag_cfg mailbox to support TX VTAG entries")
    Signed-off-by: Rakesh Babu Saladi <rsaladi2 at marvell.com>
    Signed-off-by: Subbaraya Sundeep <sbhatta at marvell.com>
    Signed-off-by: Sunil Goutham <sgoutham at marvell.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index c7e12464c243..49d822a98ada 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -578,7 +578,7 @@ static ssize_t rvu_dbg_qsize_write(struct file *filp,
 	if (cmd_buf)
 		ret = -EINVAL;
 
-	if (!strncmp(subtoken, "help", 4) || ret < 0) {
+	if (ret < 0 || !strncmp(subtoken, "help", 4)) {
 		dev_info(rvu->dev, "Use echo <%s-lf > qsize\n", blk_string);
 		goto qsize_write_done;
 	}
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 9ef4e942e31e..6970540dc470 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -2507,6 +2507,9 @@ static void nix_free_tx_vtag_entries(struct rvu *rvu, u16 pcifunc)
 		return;
 
 	nix_hw = get_nix_hw(rvu->hw, blkaddr);
+	if (!nix_hw)
+		return;
+
 	vlan = &nix_hw->txvlan;
 
 	mutex_lock(&vlan->rsrc_lock);
commit e77bcdd1f639809950c45234b08647ac6d3ffe7b
Author: Rakesh Babu <rsaladi2 at marvell.com>
Date:   Wed Oct 27 23:02:33 2021 +0530

    octeontx2-af: Display all enabled PF VF rsrc_alloc entries.
    
    Currently, we are using a fixed buffer size of length 2048 to display
    rsrc_alloc output. As a result a maximum of 2048 characters of
    rsrc_alloc output is displayed, which may lead sometimes to display only
    partial output. This patch fixes this dependency on max limit of buffer
    size and displays all PF VF entries.
    
    Each column of the debugfs entry "rsrc_alloc" uses a fixed width of 12
    characters to print the list of LFs of each block for a PF/VF. If the
    length of list of LFs of a block exceeds this fixed width then the list
    gets truncated and displays only a part of the list. This patch fixes
    this by using the maximum possible length of list of LFs among all
    blocks of all PFs and VFs entries as the width size.
    
    Fixes: f7884097141b ("octeontx2-af: Formatting debugfs entry rsrc_alloc.")
    Fixes: 23205e6d06d4 ("octeontx2-af: Dump current resource provisioning status")
    Signed-off-by: Rakesh Babu <rsaladi2 at marvell.com>
    Signed-off-by: Nithin Dabilpuram <ndabilpuram at marvell.com>
    Signed-off-by: Sunil Kovvuri Goutham <Sunil.Goutham at cavium.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index 6c589ca9b577..c7e12464c243 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -226,18 +226,85 @@ static const struct file_operations rvu_dbg_##name##_fops = { \
 
 static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf);
 
+static void get_lf_str_list(struct rvu_block block, int pcifunc,
+			    char *lfs)
+{
+	int lf = 0, seq = 0, len = 0, prev_lf = block.lf.max;
+
+	for_each_set_bit(lf, block.lf.bmap, block.lf.max) {
+		if (lf >= block.lf.max)
+			break;
+
+		if (block.fn_map[lf] != pcifunc)
+			continue;
+
+		if (lf == prev_lf + 1) {
+			prev_lf = lf;
+			seq = 1;
+			continue;
+		}
+
+		if (seq)
+			len += sprintf(lfs + len, "-%d,%d", prev_lf, lf);
+		else
+			len += (len ? sprintf(lfs + len, ",%d", lf) :
+				      sprintf(lfs + len, "%d", lf));
+
+		prev_lf = lf;
+		seq = 0;
+	}
+
+	if (seq)
+		len += sprintf(lfs + len, "-%d", prev_lf);
+
+	lfs[len] = '\0';
+}
+
+static int get_max_column_width(struct rvu *rvu)
+{
+	int index, pf, vf, lf_str_size = 12, buf_size = 256;
+	struct rvu_block block;
+	u16 pcifunc;
+	char *buf;
+
+	buf = kzalloc(buf_size, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
+		for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
+			pcifunc = pf << 10 | vf;
+			if (!pcifunc)
+				continue;
+
+			for (index = 0; index < BLK_COUNT; index++) {
+				block = rvu->hw->block[index];
+				if (!strlen(block.name))
+					continue;
+
+				get_lf_str_list(block, pcifunc, buf);
+				if (lf_str_size <= strlen(buf))
+					lf_str_size = strlen(buf) + 1;
+			}
+		}
+	}
+
+	kfree(buf);
+	return lf_str_size;
+}
+
 /* Dumps current provisioning status of all RVU block LFs */
 static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 					  char __user *buffer,
 					  size_t count, loff_t *ppos)
 {
-	int index, off = 0, flag = 0, go_back = 0, len = 0;
+	int index, off = 0, flag = 0, len = 0, i = 0;
 	struct rvu *rvu = filp->private_data;
-	int lf, pf, vf, pcifunc;
+	int bytes_not_copied = 0;
 	struct rvu_block block;
-	int bytes_not_copied;
-	int lf_str_size = 12;
+	int pf, vf, pcifunc;
 	int buf_size = 2048;
+	int lf_str_size;
 	char *lfs;
 	char *buf;
 
@@ -249,6 +316,9 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 	if (!buf)
 		return -ENOSPC;
 
+	/* Get the maximum width of a column */
+	lf_str_size = get_max_column_width(rvu);
+
 	lfs = kzalloc(lf_str_size, GFP_KERNEL);
 	if (!lfs) {
 		kfree(buf);
@@ -262,65 +332,69 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 					 "%-*s", lf_str_size,
 					 rvu->hw->block[index].name);
 		}
+
 	off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
+	bytes_not_copied = copy_to_user(buffer + (i * off), buf, off);
+	if (bytes_not_copied)
+		goto out;
+
+	i++;
+	*ppos += off;
 	for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
 		for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
+			off = 0;
+			flag = 0;
 			pcifunc = pf << 10 | vf;
 			if (!pcifunc)
 				continue;
 
 			if (vf) {
 				sprintf(lfs, "PF%d:VF%d", pf, vf - 1);
-				go_back = scnprintf(&buf[off],
-						    buf_size - 1 - off,
-						    "%-*s", lf_str_size, lfs);
+				off = scnprintf(&buf[off],
+						buf_size - 1 - off,
+						"%-*s", lf_str_size, lfs);
 			} else {
 				sprintf(lfs, "PF%d", pf);
-				go_back = scnprintf(&buf[off],
-						    buf_size - 1 - off,
-						    "%-*s", lf_str_size, lfs);
+				off = scnprintf(&buf[off],
+						buf_size - 1 - off,
+						"%-*s", lf_str_size, lfs);
 			}
 
-			off += go_back;
-			for (index = 0; index < BLKTYPE_MAX; index++) {
+			for (index = 0; index < BLK_COUNT; index++) {
 				block = rvu->hw->block[index];
 				if (!strlen(block.name))
 					continue;
 				len = 0;
 				lfs[len] = '\0';
-				for (lf = 0; lf < block.lf.max; lf++) {
-					if (block.fn_map[lf] != pcifunc)
-						continue;
+				get_lf_str_list(block, pcifunc, lfs);
+				if (strlen(lfs))
 					flag = 1;
-					len += sprintf(&lfs[len], "%d,", lf);
-				}
 
-				if (flag)
-					len--;
-				lfs[len] = '\0';
 				off += scnprintf(&buf[off], buf_size - 1 - off,
 						 "%-*s", lf_str_size, lfs);
-				if (!strlen(lfs))
-					go_back += lf_str_size;
 			}
-			if (!flag)
-				off -= go_back;
-			else
-				flag = 0;
-			off--;
-			off +=	scnprintf(&buf[off], buf_size - 1 - off, "\n");
+			if (flag) {
+				off +=	scnprintf(&buf[off],
+						  buf_size - 1 - off, "\n");
+				bytes_not_copied = copy_to_user(buffer +
+								(i * off),
+								buf, off);
+				if (bytes_not_copied)
+					goto out;
+
+				i++;
+				*ppos += off;
+			}
 		}
 	}
 
-	bytes_not_copied = copy_to_user(buffer, buf, off);
+out:
 	kfree(lfs);
 	kfree(buf);
-
 	if (bytes_not_copied)
 		return -EFAULT;
 
-	*ppos = off;
-	return off;
+	return *ppos;
 }
 
 RVU_DEBUG_FOPS(rsrc_status, rsrc_attach_status, NULL);
commit cc45b96e2de7ada26520f101dada0abafa4ba997
Author: Subbaraya Sundeep <sbhatta at marvell.com>
Date:   Wed Oct 27 23:02:32 2021 +0530

    octeontx2-af: Check whether ipolicers exists
    
    While displaying ingress policers information in
    debugfs check whether ingress policers exist in
    the hardware or not because some platforms(CN9XXX)
    do not have this feature.
    
    Fixes: e7d8971763f3 ("octeontx2-af: cn10k: Debugfs support for bandwidth")
    Signed-off-by: Subbaraya Sundeep <sbhatta at marvell.com>
    Signed-off-by: Rakesh Babu <rsaladi2 at marvell.com>
    Signed-off-by: Sunil Kovvuri Goutham <sgoutham at marvell.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index 9338765da048..6c589ca9b577 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -1719,6 +1719,10 @@ static int rvu_dbg_nix_band_prof_ctx_display(struct seq_file *m, void *unused)
 	u16 pcifunc;
 	char *str;
 
+	/* Ingress policers do not exist on all platforms */
+	if (!nix_hw->ipolicer)
+		return 0;
+
 	for (layer = 0; layer < BAND_PROF_NUM_LAYERS; layer++) {
 		if (layer == BAND_PROF_INVAL_LAYER)
 			continue;
@@ -1768,6 +1772,10 @@ static int rvu_dbg_nix_band_prof_rsrc_display(struct seq_file *m, void *unused)
 	int layer;
 	char *str;
 
+	/* Ingress policers do not exist on all platforms */
+	if (!nix_hw->ipolicer)
+		return 0;
+
 	seq_puts(m, "\nBandwidth profile resource free count\n");
 	seq_puts(m, "=====================================\n");
 	for (layer = 0; layer < BAND_PROF_NUM_LAYERS; layer++) {
commit e8684db191e4164f3f5f3ad7dec04a6734c25f1c
Author: Yuiko Oshino <yuiko.oshino at microchip.com>
Date:   Wed Oct 27 14:23:02 2021 -0400

    net: ethernet: microchip: lan743x: Fix skb allocation failure
    
    The driver allocates skb during ndo_open with GFP_ATOMIC which has high chance of failure when there are multiple instances.
    GFP_KERNEL is enough while open and use GFP_ATOMIC only from interrupt context.
    
    Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino at microchip.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index c4f32c7e0db1..4d5a5d6595b3 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -1944,7 +1944,8 @@ static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index)
 				  index);
 }
 
-static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index)
+static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index,
+					gfp_t gfp)
 {
 	struct net_device *netdev = rx->adapter->netdev;
 	struct device *dev = &rx->adapter->pdev->dev;
@@ -1958,7 +1959,7 @@ static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index)
 
 	descriptor = &rx->ring_cpu_ptr[index];
 	buffer_info = &rx->buffer_info[index];
-	skb = __netdev_alloc_skb(netdev, buffer_length, GFP_ATOMIC | GFP_DMA);
+	skb = __netdev_alloc_skb(netdev, buffer_length, gfp);
 	if (!skb)
 		return -ENOMEM;
 	dma_ptr = dma_map_single(dev, skb->data, buffer_length, DMA_FROM_DEVICE);
@@ -2120,7 +2121,8 @@ static int lan743x_rx_process_buffer(struct lan743x_rx *rx)
 
 	/* save existing skb, allocate new skb and map to dma */
 	skb = buffer_info->skb;
-	if (lan743x_rx_init_ring_element(rx, rx->last_head)) {
+	if (lan743x_rx_init_ring_element(rx, rx->last_head,
+					 GFP_ATOMIC | GFP_DMA)) {
 		/* failed to allocate next skb.
 		 * Memory is very low.
 		 * Drop this packet and reuse buffer.
@@ -2335,13 +2337,16 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
 
 	rx->last_head = 0;
 	for (index = 0; index < rx->ring_size; index++) {
-		ret = lan743x_rx_init_ring_element(rx, index);
+		ret = lan743x_rx_init_ring_element(rx, index, GFP_KERNEL);
 		if (ret)
 			goto cleanup;
 	}
 	return 0;
 
 cleanup:
+	netif_warn(rx->adapter, ifup, rx->adapter->netdev,
+		   "Error allocating memory for LAN743x\n");
+
 	lan743x_rx_ring_cleanup(rx);
 	return ret;
 }
commit 1d9d6fd21ad4a28b16ed9ee5432ae738b9dc58aa
Author: Daniel Jordan <daniel.m.jordan at oracle.com>
Date:   Wed Oct 27 17:59:21 2021 -0400

    net/tls: Fix flipped sign in async_wait.err assignment
    
    sk->sk_err contains a positive number, yet async_wait.err wants the
    opposite.  Fix the missed sign flip, which Jakub caught by inspection.
    
    Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of records for performance")
    Suggested-by: Jakub Kicinski <kuba at kernel.org>
    Signed-off-by: Daniel Jordan <daniel.m.jordan at oracle.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 1644f8baea19..1b08b877a890 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -459,7 +459,7 @@ static void tls_encrypt_done(struct crypto_async_request *req, int err)
 
 		/* If err is already set on socket, return the same code */
 		if (sk->sk_err) {
-			ctx->async_wait.err = sk->sk_err;
+			ctx->async_wait.err = -sk->sk_err;
 		} else {
 			ctx->async_wait.err = err;
 			tls_err_abort(sk, err);
commit da353fac65fede6b8b4cfe207f0d9408e3121105
Author: Daniel Jordan <daniel.m.jordan at oracle.com>
Date:   Wed Oct 27 17:59:20 2021 -0400

    net/tls: Fix flipped sign in tls_err_abort() calls
    
    sk->sk_err appears to expect a positive value, a convention that ktls
    doesn't always follow and that leads to memory corruption in other code.
    For instance,
    
        [kworker]
        tls_encrypt_done(..., err=<negative error from crypto request>)
          tls_err_abort(.., err)
            sk->sk_err = err;
    
        [task]
        splice_from_pipe_feed
          ...
            tls_sw_do_sendpage
              if (sk->sk_err) {
                ret = -sk->sk_err;  // ret is positive
    
        splice_from_pipe_feed (continued)
          ret = actor(...)  // ret is still positive and interpreted as bytes
                            // written, resulting in underflow of buf->len and
                            // sd->len, leading to huge buf->offset and bogus
                            // addresses computed in later calls to actor()
    
    Fix all tls_err_abort() callers to pass a negative error code
    consistently and centralize the error-prone sign flip there, throwing in
    a warning to catch future misuse and uninlining the function so it
    really does only warn once.
    
    Cc: stable at vger.kernel.org
    Fixes: c46234ebb4d1e ("tls: RX path for ktls")
    Reported-by: syzbot+b187b77c8474f9648fae at syzkaller.appspotmail.com
    Signed-off-by: Daniel Jordan <daniel.m.jordan at oracle.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/include/net/tls.h b/include/net/tls.h
index 01d2e3744393..1fffb206f09f 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -358,6 +358,7 @@ int tls_sk_query(struct sock *sk, int optname, char __user *optval,
 		int __user *optlen);
 int tls_sk_attach(struct sock *sk, int optname, char __user *optval,
 		  unsigned int optlen);
+void tls_err_abort(struct sock *sk, int err);
 
 int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx);
 void tls_sw_strparser_arm(struct sock *sk, struct tls_context *ctx);
@@ -466,12 +467,6 @@ static inline bool tls_is_sk_tx_device_offloaded(struct sock *sk)
 #endif
 }
 
-static inline void tls_err_abort(struct sock *sk, int err)
-{
-	sk->sk_err = err;
-	sk_error_report(sk);
-}
-
 static inline bool tls_bigint_increment(unsigned char *seq, int len)
 {
 	int i;
@@ -512,7 +507,7 @@ static inline void tls_advance_record_sn(struct sock *sk,
 					 struct cipher_context *ctx)
 {
 	if (tls_bigint_increment(ctx->rec_seq, prot->rec_seq_size))
-		tls_err_abort(sk, EBADMSG);
+		tls_err_abort(sk, -EBADMSG);
 
 	if (prot->version != TLS_1_3_VERSION &&
 	    prot->cipher_type != TLS_CIPHER_CHACHA20_POLY1305)
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index d5d09bd817b7..1644f8baea19 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -35,6 +35,7 @@
  * SOFTWARE.
  */
 
+#include <linux/bug.h>
 #include <linux/sched/signal.h>
 #include <linux/module.h>
 #include <linux/splice.h>
@@ -43,6 +44,14 @@
 #include <net/strparser.h>
 #include <net/tls.h>
 
+noinline void tls_err_abort(struct sock *sk, int err)
+{
+	WARN_ON_ONCE(err >= 0);
+	/* sk->sk_err should contain a positive error code. */
+	sk->sk_err = -err;
+	sk_error_report(sk);
+}
+
 static int __skb_nsg(struct sk_buff *skb, int offset, int len,
                      unsigned int recursion_level)
 {
@@ -419,7 +428,7 @@ int tls_tx_records(struct sock *sk, int flags)
 
 tx_err:
 	if (rc < 0 && rc != -EAGAIN)
-		tls_err_abort(sk, EBADMSG);
+		tls_err_abort(sk, -EBADMSG);
 
 	return rc;
 }
@@ -763,7 +772,7 @@ static int tls_push_record(struct sock *sk, int flags,
 			       msg_pl->sg.size + prot->tail_size, i);
 	if (rc < 0) {
 		if (rc != -EINPROGRESS) {
-			tls_err_abort(sk, EBADMSG);
+			tls_err_abort(sk, -EBADMSG);
 			if (split) {
 				tls_ctx->pending_open_record_frags = true;
 				tls_merge_open_record(sk, rec, tmp, orig_end);
@@ -1827,7 +1836,7 @@ int tls_sw_recvmsg(struct sock *sk,
 		err = decrypt_skb_update(sk, skb, &msg->msg_iter,
 					 &chunk, &zc, async_capable);
 		if (err < 0 && err != -EINPROGRESS) {
-			tls_err_abort(sk, EBADMSG);
+			tls_err_abort(sk, -EBADMSG);
 			goto recv_end;
 		}
 
@@ -2007,7 +2016,7 @@ ssize_t tls_sw_splice_read(struct socket *sock,  loff_t *ppos,
 		}
 
 		if (err < 0) {
-			tls_err_abort(sk, EBADMSG);
+			tls_err_abort(sk, -EBADMSG);
 			goto splice_read_end;
 		}
 		ctx->decrypted = 1;
commit a32f07d21102dd40496724e4416a7e97fc1755d8
Merge: 90a881fc352a f3a3a0fe0b64
Author: David S. Miller <davem at davemloft.net>
Date:   Thu Oct 28 13:04:29 2021 +0100

    Merge branch 'SMC-fixes'
    
    Tony Lu says:
    
    ====================
    Fixes for SMC
    
    There are some fixes for SMC.
    
    v1->v2:
    - fix wrong email address.
    ====================
    
    Signed-off-by: David S. Miller <davem at davemloft.net>

commit f3a3a0fe0b644582fa5d83dd94b398f99fc57914
Author: Wen Gu <guwen at linux.alibaba.com>
Date:   Thu Oct 28 15:13:47 2021 +0800

    net/smc: Correct spelling mistake to TCPF_SYN_RECV
    
    There should use TCPF_SYN_RECV instead of TCP_SYN_RECV.
    
    Signed-off-by: Wen Gu <guwen at linux.alibaba.com>
    Reviewed-by: Tony Lu <tonylu at linux.alibaba.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index c038efc23ce3..78b663dbfa1f 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1057,7 +1057,7 @@ static void smc_connect_work(struct work_struct *work)
 	if (smc->clcsock->sk->sk_err) {
 		smc->sk.sk_err = smc->clcsock->sk->sk_err;
 	} else if ((1 << smc->clcsock->sk->sk_state) &
-					(TCPF_SYN_SENT | TCP_SYN_RECV)) {
+					(TCPF_SYN_SENT | TCPF_SYN_RECV)) {
 		rc = sk_stream_wait_connect(smc->clcsock->sk, &timeo);
 		if ((rc == -EPIPE) &&
 		    ((1 << smc->clcsock->sk->sk_state) &
commit c4a146c7cf5e8ad76231523b174d161bf152c6e7
Author: Tony Lu <tonylu at linux.alibaba.com>
Date:   Thu Oct 28 15:13:45 2021 +0800

    net/smc: Fix smc_link->llc_testlink_time overflow
    
    The value of llc_testlink_time is set to the value stored in
    net->ipv4.sysctl_tcp_keepalive_time when linkgroup init. The value of
    sysctl_tcp_keepalive_time is already jiffies, so we don't need to
    multiply by HZ, which would cause smc_link->llc_testlink_time overflow,
    and test_link send flood.
    
    Signed-off-by: Tony Lu <tonylu at linux.alibaba.com>
    Reviewed-by: Xuan Zhuo <xuanzhuo at linux.alibaba.com>
    Reviewed-by: Wen Gu <guwen at linux.alibaba.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c
index 72f4b72eb175..f1d323439a2a 100644
--- a/net/smc/smc_llc.c
+++ b/net/smc/smc_llc.c
@@ -1822,7 +1822,7 @@ void smc_llc_link_active(struct smc_link *link)
 			    link->smcibdev->ibdev->name, link->ibport);
 	link->state = SMC_LNK_ACTIVE;
 	if (link->lgr->llc_testlink_time) {
-		link->llc_testlink_time = link->lgr->llc_testlink_time * HZ;
+		link->llc_testlink_time = link->lgr->llc_testlink_time;
 		schedule_delayed_work(&link->llc_testlink_wrk,
 				      link->llc_testlink_time);
 	}
commit 90a881fc352a953f1c8beb61977a2db0818157d4
Author: Yu Xiao <yu.xiao at corigine.com>
Date:   Thu Oct 28 12:00:36 2021 +0200

    nfp: bpf: relax prog rejection for mtu check through max_pkt_offset
    
    MTU change is refused whenever the value of new MTU is bigger than
    the max packet bytes that fits in NFP Cluster Target Memory (CTM).
    However, an eBPF program doesn't always need to access the whole
    packet data.
    
    The maximum direct packet access (DPA) offset has always been
    caculated by verifier and stored in the max_pkt_offset field of prog
    aux data.
    
    Signed-off-by: Yu Xiao <yu.xiao at corigine.com>
    Reviewed-by: Yinjun Zhang <yinjun.zhang at corigine.com>
    Reviewed-by: Niklas Soderlund <niklas.soderlund at corigine.com>
    Signed-off-by: Simon Horman <simon.horman at corigine.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.c b/drivers/net/ethernet/netronome/nfp/bpf/main.c
index 11c83a99b014..f469950c7265 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/main.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/main.c
@@ -182,15 +182,21 @@ static int
 nfp_bpf_check_mtu(struct nfp_app *app, struct net_device *netdev, int new_mtu)
 {
 	struct nfp_net *nn = netdev_priv(netdev);
-	unsigned int max_mtu;
+	struct nfp_bpf_vnic *bv;
+	struct bpf_prog *prog;
 
 	if (~nn->dp.ctrl & NFP_NET_CFG_CTRL_BPF)
 		return 0;
 
-	max_mtu = nn_readb(nn, NFP_NET_CFG_BPF_INL_MTU) * 64 - 32;
-	if (new_mtu > max_mtu) {
-		nn_info(nn, "BPF offload active, MTU over %u not supported\n",
-			max_mtu);
+	if (nn->xdp_hw.prog) {
+		prog = nn->xdp_hw.prog;
+	} else {
+		bv = nn->app_priv;
+		prog = bv->tc_prog;
+	}
+
+	if (nfp_bpf_offload_check_mtu(nn, prog, new_mtu)) {
+		nn_info(nn, "BPF offload active, potential packet access beyond hardware packet boundary");
 		return -EBUSY;
 	}
 	return 0;
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.h b/drivers/net/ethernet/netronome/nfp/bpf/main.h
index d0e17eebddd9..16841bb750b7 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/main.h
+++ b/drivers/net/ethernet/netronome/nfp/bpf/main.h
@@ -560,6 +560,8 @@ bool nfp_is_subprog_start(struct nfp_insn_meta *meta);
 void nfp_bpf_jit_prepare(struct nfp_prog *nfp_prog);
 int nfp_bpf_jit(struct nfp_prog *prog);
 bool nfp_bpf_supported_opcode(u8 code);
+bool nfp_bpf_offload_check_mtu(struct nfp_net *nn, struct bpf_prog *prog,
+			       unsigned int mtu);
 
 int nfp_verify_insn(struct bpf_verifier_env *env, int insn_idx,
 		    int prev_insn_idx);
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/offload.c b/drivers/net/ethernet/netronome/nfp/bpf/offload.c
index 53851853562c..9d97cd281f18 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/offload.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/offload.c
@@ -481,19 +481,28 @@ int nfp_bpf_event_output(struct nfp_app_bpf *bpf, const void *data,
 	return 0;
 }
 
+bool nfp_bpf_offload_check_mtu(struct nfp_net *nn, struct bpf_prog *prog,
+			       unsigned int mtu)
+{
+	unsigned int fw_mtu, pkt_off;
+
+	fw_mtu = nn_readb(nn, NFP_NET_CFG_BPF_INL_MTU) * 64 - 32;
+	pkt_off = min(prog->aux->max_pkt_offset, mtu);
+
+	return fw_mtu < pkt_off;
+}
+
 static int
 nfp_net_bpf_load(struct nfp_net *nn, struct bpf_prog *prog,
 		 struct netlink_ext_ack *extack)
 {
 	struct nfp_prog *nfp_prog = prog->aux->offload->dev_priv;
-	unsigned int fw_mtu, pkt_off, max_stack, max_prog_len;
+	unsigned int max_stack, max_prog_len;
 	dma_addr_t dma_addr;
 	void *img;
 	int err;
 
-	fw_mtu = nn_readb(nn, NFP_NET_CFG_BPF_INL_MTU) * 64 - 32;
-	pkt_off = min(prog->aux->max_pkt_offset, nn->dp.netdev->mtu);
-	if (fw_mtu < pkt_off) {
+	if (nfp_bpf_offload_check_mtu(nn, prog, nn->dp.netdev->mtu)) {
 		NL_SET_ERR_MSG_MOD(extack, "BPF offload not supported with potential packet access beyond HW packet split boundary");
 		return -EOPNOTSUPP;
 	}
commit 9159f102402a64ac85e676b75cc1f9c62c5b4b73
Author: Dongli Zhang <dongli.zhang at oracle.com>
Date:   Tue Oct 26 14:50:31 2021 -0700

    vmxnet3: do not stop tx queues after netif_device_detach()
    
    The netif_device_detach() conditionally stops all tx queues if the queues
    are running. There is no need to call netif_tx_stop_all_queues() again.
    
    Signed-off-by: Dongli Zhang <dongli.zhang at oracle.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 142f70670f5c..8799854bacb2 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3833,7 +3833,6 @@ vmxnet3_suspend(struct device *device)
 	vmxnet3_free_intr_resources(adapter);
 
 	netif_device_detach(netdev);
-	netif_tx_stop_all_queues(netdev);
 
 	/* Create wake-up filters. */
 	pmConf = adapter->pm_conf;
commit e8a1ff65927080278e6826f797b7c197fb2611a6
Author: Wenbin Mei <wenbin.mei at mediatek.com>
Date:   Thu Oct 28 10:20:49 2021 +0800

    mmc: mediatek: Move cqhci init behind ungate clock
    
    We must enable clock before cqhci init, because crypto needs read
    information from CQHCI registers, otherwise, it will hang in MediaTek mmc
    host controller.
    
    Signed-off-by: Wenbin Mei <wenbin.mei at mediatek.com>
    Fixes: 88bd652b3c74 ("mmc: mediatek: command queue support")
    Cc: stable at vger.kernel.org
    Acked-by: Chaotian Jing <chaotian.jing at mediatek.com>
    Link: https://lore.kernel.org/r/20211028022049.22129-1-wenbin.mei@mediatek.com
    Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>

diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 4dfc246c5f95..b06b4dcb7c78 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -2577,6 +2577,25 @@ static int msdc_drv_probe(struct platform_device *pdev)
 		host->dma_mask = DMA_BIT_MASK(32);
 	mmc_dev(mmc)->dma_mask = &host->dma_mask;
 
+	host->timeout_clks = 3 * 1048576;
+	host->dma.gpd = dma_alloc_coherent(&pdev->dev,
+				2 * sizeof(struct mt_gpdma_desc),
+				&host->dma.gpd_addr, GFP_KERNEL);
+	host->dma.bd = dma_alloc_coherent(&pdev->dev,
+				MAX_BD_NUM * sizeof(struct mt_bdma_desc),
+				&host->dma.bd_addr, GFP_KERNEL);
+	if (!host->dma.gpd || !host->dma.bd) {
+		ret = -ENOMEM;
+		goto release_mem;
+	}
+	msdc_init_gpd_bd(host, &host->dma);
+	INIT_DELAYED_WORK(&host->req_timeout, msdc_request_timeout);
+	spin_lock_init(&host->lock);
+
+	platform_set_drvdata(pdev, mmc);
+	msdc_ungate_clock(host);
+	msdc_init_hw(host);
+
 	if (mmc->caps2 & MMC_CAP2_CQE) {
 		host->cq_host = devm_kzalloc(mmc->parent,
 					     sizeof(*host->cq_host),
@@ -2597,25 +2616,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
 		mmc->max_seg_size = 64 * 1024;
 	}
 
-	host->timeout_clks = 3 * 1048576;
-	host->dma.gpd = dma_alloc_coherent(&pdev->dev,
-				2 * sizeof(struct mt_gpdma_desc),
-				&host->dma.gpd_addr, GFP_KERNEL);
-	host->dma.bd = dma_alloc_coherent(&pdev->dev,
-				MAX_BD_NUM * sizeof(struct mt_bdma_desc),
-				&host->dma.bd_addr, GFP_KERNEL);
-	if (!host->dma.gpd || !host->dma.bd) {
-		ret = -ENOMEM;
-		goto release_mem;
-	}
-	msdc_init_gpd_bd(host, &host->dma);
-	INIT_DELAYED_WORK(&host->req_timeout, msdc_request_timeout);
-	spin_lock_init(&host->lock);
-
-	platform_set_drvdata(pdev, mmc);
-	msdc_ungate_clock(host);
-	msdc_init_hw(host);
-
 	ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq,
 			       IRQF_TRIGGER_NONE, pdev->name, host);
 	if (ret)
commit 9a4aa3a2f1606a03c220b21049baa4a2b6169626
Author: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Date:   Wed Oct 27 12:32:55 2021 +0300

    drm/i915: Revert 'guc_id' from i915_request tracepoint
    
    Avoid adding backend specific data to the tracepoints outside of
    the LOW_LEVEL_TRACEPOINTS kernel config protection. These bits of
    information are bound to change depending on the selected submission
    method per platform and are not necessarily possible to maintain in
    the future.
    
    Fixes: dbf9da8d55ef ("drm/i915/guc: Add trace point for GuC submit")
    Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
    Cc: John Harrison <john.c.harrison at intel.com>
    Cc: Matthew Brost <matthew.brost at intel.com>
    Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
    Cc: Chris Wilson <chris at chris-wilson.co.uk>
    Cc: Matt Roper <matthew.d.roper at intel.com>
    Reviewed-by: Matthew Auld <matthew.auld at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211027093255.66489-1-joonas.lahtinen@linux.intel.com
    (cherry picked from commit 64512a66b67e6546e2db15192b3603cd6d58b75c)
    Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>

diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h
index 806ad688274b..63fec1c3c132 100644
--- a/drivers/gpu/drm/i915/i915_trace.h
+++ b/drivers/gpu/drm/i915/i915_trace.h
@@ -794,7 +794,6 @@ DECLARE_EVENT_CLASS(i915_request,
 	    TP_STRUCT__entry(
 			     __field(u32, dev)
 			     __field(u64, ctx)
-			     __field(u32, guc_id)
 			     __field(u16, class)
 			     __field(u16, instance)
 			     __field(u32, seqno)
@@ -805,16 +804,14 @@ DECLARE_EVENT_CLASS(i915_request,
 			   __entry->dev = rq->engine->i915->drm.primary->index;
 			   __entry->class = rq->engine->uabi_class;
 			   __entry->instance = rq->engine->uabi_instance;
-			   __entry->guc_id = rq->context->guc_id;
 			   __entry->ctx = rq->fence.context;
 			   __entry->seqno = rq->fence.seqno;
 			   __entry->tail = rq->tail;
 			   ),
 
-	    TP_printk("dev=%u, engine=%u:%u, guc_id=%u, ctx=%llu, seqno=%u, tail=%u",
+	    TP_printk("dev=%u, engine=%u:%u, ctx=%llu, seqno=%u, tail=%u",
 		      __entry->dev, __entry->class, __entry->instance,
-		      __entry->guc_id, __entry->ctx, __entry->seqno,
-		      __entry->tail)
+		      __entry->ctx, __entry->seqno, __entry->tail)
 );
 
 DEFINE_EVENT(i915_request, i915_request_add,
commit 79516af3497a5b89acb09f4a644f61d6c69e5f16
Merge: 19928833e8f8 61b1d445f3bf
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Oct 28 17:27:10 2021 +1000

    Merge tag 'drm-misc-fixes-2021-10-28' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
    
    One patch to fix the default screen orientation on the GPD Win3
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    
    From: Maxime Ripard <maxime at cerno.tech>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211028072300.b4gqexq6zfhby24g@gilmour

commit 19928833e8f8fa5ee687c451437ce674f19d6c09
Merge: 03424d380be7 ee71fb6c4d99
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Oct 28 15:22:14 2021 +1000

    Merge tag 'drm-misc-fixes-2021-10-26' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
    
    drm-misc-fixes for v5.15-rc8:
    - Fix fence leak in ttm_transfered_destroy.
    - Add quirk for Aya Neo 2021
    - Reset property count for each drm damage selftest so full run will work correctly.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    
    From: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/4a133970-ff4b-aa62-d346-b269b1b9236e@linux.intel.com

commit 03424d380be72dfe6f87eed02b4fef7979583af8
Merge: defbbcd99fa6 ad76744b041d
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Oct 28 15:21:50 2021 +1000

    Merge tag 'amd-drm-fixes-5.15-2021-10-27' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
    
    amd-drm-fixes-5.15-2021-10-27:
    
    amdgpu:
    - Display fixes for DCN 3.1
    - Fix potential out of bounds write in debugfs
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    From: Alex Deucher <alexander.deucher at amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211028023130.4528-1-alexander.deucher@amd.com

commit ad76744b041d8c87ef1c9adbb04fb7eaa20a179e
Author: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
Date:   Fri Oct 22 16:14:24 2021 -0400

    drm/amd/display: Fix deadlock when falling back to v2 from v3
    
    [Why]
    A deadlock in the kernel occurs when we fallback from the V3 to V2
    add_topology_to_display or remove_topology_to_display because they
    both try to acquire the dtm_mutex but recursive locking isn't
    supported on mutex_lock().
    
    [How]
    Make the mutex_lock/unlock more fine grained and move them up such that
    they're only required for the psp invocation itself.
    
    Fixes: bf62221e9d0e ("drm/amd/display: Add DCN3.1 HDCP support")
    
    Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
    Reviewed-by: Aric Cyr <aric.cyr at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
index e9bd84ec027d..be61975f1470 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
@@ -105,6 +105,7 @@ static enum mod_hdcp_status remove_display_from_topology_v3(
 	dtm_cmd->dtm_status = TA_DTM_STATUS__GENERIC_FAILURE;
 
 	psp_dtm_invoke(psp, dtm_cmd->cmd_id);
+	mutex_unlock(&psp->dtm_context.mutex);
 
 	if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) {
 		status = remove_display_from_topology_v2(hdcp, index);
@@ -115,8 +116,6 @@ static enum mod_hdcp_status remove_display_from_topology_v3(
 		HDCP_TOP_REMOVE_DISPLAY_TRACE(hdcp, display->index);
 	}
 
-	mutex_unlock(&psp->dtm_context.mutex);
-
 	return status;
 }
 
@@ -205,6 +204,7 @@ static enum mod_hdcp_status add_display_to_topology_v3(
 	dtm_cmd->dtm_in_message.topology_update_v3.link_hdcp_cap = link->hdcp_supported_informational;
 
 	psp_dtm_invoke(psp, dtm_cmd->cmd_id);
+	mutex_unlock(&psp->dtm_context.mutex);
 
 	if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) {
 		status = add_display_to_topology_v2(hdcp, display);
@@ -214,8 +214,6 @@ static enum mod_hdcp_status add_display_to_topology_v3(
 		HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, display->index);
 	}
 
-	mutex_unlock(&psp->dtm_context.mutex);
-
 	return status;
 }
 
commit 54149d13f369e1ab02f36b91feee02069184c1d8
Author: Michael Strauss <michael.strauss at amd.com>
Date:   Thu Oct 21 13:27:16 2021 -0400

    drm/amd/display: Fallback to clocks which meet requested voltage on DCN31
    
    [WHY]
    On certain configs, SMU clock table voltages don't match which cause parser
    to behave incorrectly by leaving dcfclk and socclk table entries unpopulated.
    
    [HOW]
    Currently the function that finds the corresponding clock for a given voltage
    only checks for exact voltage level matches. In the case that no match gets
    found, parser now falls back to searching for the max clock which meets the
    requested voltage (i.e. its corresponding voltage is below requested).
    
    Signed-off-by: Michael Strauss <michael.strauss at amd.com>
    Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
index 035ba0ef6369..377c4e53a2b3 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
@@ -518,14 +518,21 @@ static unsigned int find_clk_for_voltage(
 		unsigned int voltage)
 {
 	int i;
+	int max_voltage = 0;
+	int clock = 0;
 
 	for (i = 0; i < NUM_SOC_VOLTAGE_LEVELS; i++) {
-		if (clock_table->SocVoltage[i] == voltage)
+		if (clock_table->SocVoltage[i] == voltage) {
 			return clocks[i];
+		} else if (clock_table->SocVoltage[i] >= max_voltage &&
+				clock_table->SocVoltage[i] < voltage) {
+			max_voltage = clock_table->SocVoltage[i];
+			clock = clocks[i];
+		}
 	}
 
-	ASSERT(0);
-	return 0;
+	ASSERT(clock);
+	return clock;
 }
 
 void dcn31_clk_mgr_helper_populate_bw_params(
commit 3f4e54bd312d3dafb59daf2b97ffa08abebe60f5
Author: Patrik Jakobsson <patrik.r.jakobsson at gmail.com>
Date:   Wed Oct 27 16:27:30 2021 +0200

    drm/amdgpu: Fix even more out of bound writes from debugfs
    
    CVE-2021-42327 was fixed by:
    
    commit f23750b5b3d98653b31d4469592935ef6364ad67
    Author: Thelford Williams <tdwilliamsiv at gmail.com>
    Date:   Wed Oct 13 16:04:13 2021 -0400
    
        drm/amdgpu: fix out of bounds write
    
    but amdgpu_dm_debugfs.c contains more of the same issue so fix the
    remaining ones.
    
    v2:
            * Add missing fix in dp_max_bpc_write (Harry Wentland)
    
    Fixes: 918698d5c2b5 ("drm/amd/display: Return the number of bytes parsed than allocated")
    Signed-off-by: Patrik Jakobsson <pjakobsson at suse.de>
    Reviewed-by: Harry Wentland <harry.wentland at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 17f2756a64dc..8080bba5b7a7 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -487,7 +487,7 @@ static ssize_t dp_phy_settings_write(struct file *f, const char __user *buf,
 	if (!wr_buf)
 		return -ENOSPC;
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					   (long *)param, buf,
 					   max_param_num,
 					   &param_nums)) {
@@ -639,7 +639,7 @@ static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __us
 	if (!wr_buf)
 		return -ENOSPC;
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					   (long *)param, buf,
 					   max_param_num,
 					   &param_nums)) {
@@ -914,7 +914,7 @@ static ssize_t dp_dsc_passthrough_set(struct file *f, const char __user *buf,
 		return -ENOSPC;
 	}
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					   &param, buf,
 					   max_param_num,
 					   &param_nums)) {
@@ -1211,7 +1211,7 @@ static ssize_t trigger_hotplug(struct file *f, const char __user *buf,
 		return -ENOSPC;
 	}
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 						(long *)param, buf,
 						max_param_num,
 						&param_nums)) {
@@ -1396,7 +1396,7 @@ static ssize_t dp_dsc_clock_en_write(struct file *f, const char __user *buf,
 		return -ENOSPC;
 	}
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					    (long *)param, buf,
 					    max_param_num,
 					    &param_nums)) {
@@ -1581,7 +1581,7 @@ static ssize_t dp_dsc_slice_width_write(struct file *f, const char __user *buf,
 		return -ENOSPC;
 	}
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					    (long *)param, buf,
 					    max_param_num,
 					    &param_nums)) {
@@ -1766,7 +1766,7 @@ static ssize_t dp_dsc_slice_height_write(struct file *f, const char __user *buf,
 		return -ENOSPC;
 	}
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					    (long *)param, buf,
 					    max_param_num,
 					    &param_nums)) {
@@ -1944,7 +1944,7 @@ static ssize_t dp_dsc_bits_per_pixel_write(struct file *f, const char __user *bu
 		return -ENOSPC;
 	}
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					    (long *)param, buf,
 					    max_param_num,
 					    &param_nums)) {
@@ -2382,7 +2382,7 @@ static ssize_t dp_max_bpc_write(struct file *f, const char __user *buf,
 		return -ENOSPC;
 	}
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					   (long *)param, buf,
 					   max_param_num,
 					   &param_nums)) {
commit 7fa598f9706d40bd16f2ab286bdf5808e1393d35
Author: Steven Rostedt (VMware) <rostedt at goodmis.org>
Date:   Wed Oct 27 12:08:54 2021 -0400

    tracing: Do not warn when connecting eprobe to non existing event
    
    When the syscall trace points are not configured in, the kselftests for
    ftrace will try to attach an event probe (eprobe) to one of the system
    call trace points. This triggered a WARNING, because the failure only
    expects to see memory issues. But this is not the only failure. The user
    may attempt to attach to a non existent event, and the kernel must not
    warn about it.
    
    Link: https://lkml.kernel.org/r/20211027120854.0680aa0f@gandalf.local.home
    
    Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events")
    Signed-off-by: Steven Rostedt (VMware) <rostedt at goodmis.org>

diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
index c4a15aef36af..5c5f208c15d3 100644
--- a/kernel/trace/trace_eprobe.c
+++ b/kernel/trace/trace_eprobe.c
@@ -904,8 +904,8 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 
 	if (IS_ERR(ep)) {
 		ret = PTR_ERR(ep);
-		/* This must return -ENOMEM, else there is a bug */
-		WARN_ON_ONCE(ret != -ENOMEM);
+		/* This must return -ENOMEM or misssing event, else there is a bug */
+		WARN_ON_ONCE(ret != -ENOMEM && ret != -ENODEV);
 		ep = NULL;
 		goto error;
 	}
commit 5740211ea442dbfd143093f8eea39faba186042f
Author: Matthew Auld <matthew.auld at intel.com>
Date:   Thu Oct 21 13:53:31 2021 +0100

    drm/i915/dmabuf: fix broken build
    
    wbinvd_on_all_cpus() is only defined on x86 it seems, plus we need to
    include asm/smp.h here.
    
    Reported-by: kernel test robot <lkp at intel.com>
    Signed-off-by: Matthew Auld <matthew.auld at intel.com>
    Cc: Thomas Hellström <thomas.hellstrom at linux.intel.com>
    Reviewed-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211021125332.2455288-1-matthew.auld@intel.com
    (cherry picked from commit 777226dac058d119286b4081953cb5aa2cb7394b)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
index 1adcd8e02d29..a45d0ec2c5b6 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
@@ -12,6 +12,13 @@
 #include "i915_gem_object.h"
 #include "i915_scatterlist.h"
 
+#if defined(CONFIG_X86)
+#include <asm/smp.h>
+#else
+#define wbinvd_on_all_cpus() \
+	pr_warn(DRIVER_NAME ": Missing cache flush in %s\n", __func__)
+#endif
+
 I915_SELFTEST_DECLARE(static bool force_different_devices;)
 
 static struct drm_i915_gem_object *dma_buf_to_obj(struct dma_buf *buf)
commit ab0f0c79d1a6c5832d8464804e773103e3e12fea
Author: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Date:   Wed Oct 27 12:32:55 2021 +0300

    drm/i915: Revert 'guc_id' from i915_request tracepoint
    
    Avoid adding backend specific data to the tracepoints outside of
    the LOW_LEVEL_TRACEPOINTS kernel config protection. These bits of
    information are bound to change depending on the selected submission
    method per platform and are not necessarily possible to maintain in
    the future.
    
    Fixes: dbf9da8d55ef ("drm/i915/guc: Add trace point for GuC submit")
    Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
    Cc: John Harrison <john.c.harrison at intel.com>
    Cc: Matthew Brost <matthew.brost at intel.com>
    Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
    Cc: Chris Wilson <chris at chris-wilson.co.uk>
    Cc: Matt Roper <matthew.d.roper at intel.com>
    Reviewed-by: Matthew Auld <matthew.auld at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211027093255.66489-1-joonas.lahtinen@linux.intel.com
    (cherry picked from commit 64512a66b67e6546e2db15192b3603cd6d58b75c)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h
index 9795f456cccf..8104981a6604 100644
--- a/drivers/gpu/drm/i915/i915_trace.h
+++ b/drivers/gpu/drm/i915/i915_trace.h
@@ -794,7 +794,6 @@ DECLARE_EVENT_CLASS(i915_request,
 	    TP_STRUCT__entry(
 			     __field(u32, dev)
 			     __field(u64, ctx)
-			     __field(u32, guc_id)
 			     __field(u16, class)
 			     __field(u16, instance)
 			     __field(u32, seqno)
@@ -805,16 +804,14 @@ DECLARE_EVENT_CLASS(i915_request,
 			   __entry->dev = rq->engine->i915->drm.primary->index;
 			   __entry->class = rq->engine->uabi_class;
 			   __entry->instance = rq->engine->uabi_instance;
-			   __entry->guc_id = rq->context->guc_id.id;
 			   __entry->ctx = rq->fence.context;
 			   __entry->seqno = rq->fence.seqno;
 			   __entry->tail = rq->tail;
 			   ),
 
-	    TP_printk("dev=%u, engine=%u:%u, guc_id=%u, ctx=%llu, seqno=%u, tail=%u",
+	    TP_printk("dev=%u, engine=%u:%u, ctx=%llu, seqno=%u, tail=%u",
 		      __entry->dev, __entry->class, __entry->instance,
-		      __entry->guc_id, __entry->ctx, __entry->seqno,
-		      __entry->tail)
+		      __entry->ctx, __entry->seqno, __entry->tail)
 );
 
 DEFINE_EVENT(i915_request, i915_request_add,
commit 72f898ca0ab85fde6facf78b14d9f67a4a7b32d1
Author: Janghyub Seo <jhyub06 at gmail.com>
Date:   Tue Oct 26 07:12:42 2021 +0000

    r8169: Add device 10ec:8162 to driver r8169
    
    This patch makes the driver r8169 pick up device Realtek Semiconductor Co.
    , Ltd. Device [10ec:8162].
    
    Signed-off-by: Janghyub Seo <jhyub06 at gmail.com>
    Suggested-by: Rushab Shah <rushabshah32 at gmail.com>
    Link: https://lore.kernel.org/r/1635231849296.1489250046.441294000@gmail.com
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 46a6ff9a782d..2918947dd57c 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -157,6 +157,7 @@ static const struct pci_device_id rtl8169_pci_tbl[] = {
 	{ PCI_VDEVICE(REALTEK,	0x8129) },
 	{ PCI_VDEVICE(REALTEK,	0x8136), RTL_CFG_NO_GBIT },
 	{ PCI_VDEVICE(REALTEK,	0x8161) },
+	{ PCI_VDEVICE(REALTEK,	0x8162) },
 	{ PCI_VDEVICE(REALTEK,	0x8167) },
 	{ PCI_VDEVICE(REALTEK,	0x8168) },
 	{ PCI_VDEVICE(NCUBE,	0x8168) },
commit f82161516756be2827609ec4845e1e4316df0709
Author: Randy Dunlap <rdunlap at infradead.org>
Date:   Sun Oct 24 09:38:31 2021 -0700

    ptp: Document the PTP_CLK_MAGIC ioctl number
    
    Add PTP_CLK_MAGIC to the userspace-api/ioctl/ioctl-number.rst
    documentation file.
    
    Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.")
    Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
    Cc: Richard Cochran <richardcochran at gmail.com>
    Cc: John Stultz <john.stultz at linaro.org>
    Cc: Jonathan Corbet <corbet at lwn.net>
    Link: https://lore.kernel.org/r/20211024163831.10200-1-rdunlap@infradead.org
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst
index 2e8134059c87..6655d929a351 100644
--- a/Documentation/userspace-api/ioctl/ioctl-number.rst
+++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
@@ -104,6 +104,7 @@ Code  Seq#    Include File                                           Comments
 '8'   all                                                            SNP8023 advanced NIC card
                                                                      <mailto:mcr at solidum.com>
 ';'   64-7F  linux/vfio.h
+'='   00-3f  uapi/linux/ptp_clock.h                                  <mailto:richardcochran at gmail.com>
 '@'   00-0F  linux/radeonfb.h                                        conflict!
 '@'   00-0F  drivers/video/aty/aty128fb.c                            conflict!
 'A'   00-1F  linux/apm_bios.h                                        conflict!
commit 9c5456773d79b64cc6cebb06f668e29249636ba9
Merge: 1fc596a56b33 890d33561337
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Wed Oct 27 13:15:05 2021 -0700

    Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
    
    Pull virtio fixes from Michael Tsirkin:
     "A couple of fixes that seem important enough to pick at the last
      moment"
    
    * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
      virtio-ring: fix DMA metadata flags
      vduse: Fix race condition between resetting and irq injecting
      vduse: Disallow injecting interrupt before DRIVER_OK is set

commit 64a19591a2938b170aa736443d5d3bf4c51e1388
Author: Chen Lu <181250012 at smail.nju.edu.cn>
Date:   Mon Oct 18 13:22:38 2021 +0800

    riscv: fix misalgned trap vector base address
    
    The trap vector marked by label .Lsecondary_park must align on a
    4-byte boundary, as the {m,s}tvec is defined to require 4-byte
    alignment.
    
    Signed-off-by: Chen Lu <181250012 at smail.nju.edu.cn>
    Reviewed-by: Anup Patel <anup.patel at wdc.com>
    Fixes: e011995e826f ("RISC-V: Move relocate and few other functions out of __init")
    Cc: stable at vger.kernel.org
    Signed-off-by: Palmer Dabbelt <palmerdabbelt at google.com>

diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index fce5184b22c3..52c5ff9804c5 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -193,6 +193,7 @@ setup_trap_vector:
 	csrw CSR_SCRATCH, zero
 	ret
 
+.align 2
 .Lsecondary_park:
 	/* We lack SMP support or have too many harts, so park this hart */
 	wfi
commit 890d33561337ffeba0d8ba42517e71288cfee2b6
Author: Vincent Whitchurch <vincent.whitchurch at axis.com>
Date:   Tue Oct 26 15:31:00 2021 +0200

    virtio-ring: fix DMA metadata flags
    
    The flags are currently overwritten, leading to the wrong direction
    being passed to the DMA unmap functions.
    
    Fixes: 72b5e8958738aaa4 ("virtio-ring: store DMA metadata in desc_extra for split virtqueue")
    Signed-off-by: Vincent Whitchurch <vincent.whitchurch at axis.com>
    Link: https://lore.kernel.org/r/20211026133100.17541-1-vincent.whitchurch@axis.com
    Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
    Acked-by: Jason Wang <jasowang at redhat.com>

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index dd95dfd85e98..3035bb6f5458 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -576,7 +576,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
 	/* Last one doesn't continue. */
 	desc[prev].flags &= cpu_to_virtio16(_vq->vdev, ~VRING_DESC_F_NEXT);
 	if (!indirect && vq->use_dma_api)
-		vq->split.desc_extra[prev & (vq->split.vring.num - 1)].flags =
+		vq->split.desc_extra[prev & (vq->split.vring.num - 1)].flags &=
 			~VRING_DESC_F_NEXT;
 
 	if (indirect) {
commit 6f7c88691191e6c52ef2543d6f1da8d360b27a24
Author: Wang Hai <wanghai38 at huawei.com>
Date:   Tue Oct 26 20:40:15 2021 +0800

    usbnet: fix error return code in usbnet_probe()
    
    Return error code if usb_maxpacket() returns 0 in usbnet_probe()
    
    Fixes: 397430b50a36 ("usbnet: sanity check for maxpacket")
    Reported-by: Hulk Robot <hulkci at huawei.com>
    Signed-off-by: Wang Hai <wanghai38 at huawei.com>
    Reviewed-by: Johan Hovold <johan at kernel.org>
    Link: https://lore.kernel.org/r/20211026124015.3025136-1-wanghai38@huawei.com
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 80432ee0ce69..a33d7fb82a00 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1790,6 +1790,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 	dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
 	if (dev->maxpacket == 0) {
 		/* that is a broken device */
+		status = -ENODEV;
 		goto out4;
 	}
 
commit 1fc596a56b334f4d593a2b49e5ff55af6aaa0816
Merge: 646b0de5fe32 4e84dc47bb48
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Wed Oct 27 10:41:59 2021 -0700

    Merge tag 'trace-v5.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
    
    Pull nds32 tracing fix from Steven Rostedt:
     "Fix nds32le build when DYNAMIC_FTRACE is disabled
    
      A randconfig found that nds32le architecture fails to build due to a
      prototype mismatch between a ftrace function pointer and the function
      it was to be assigned to. That function pointer prototype missed being
      updated when all the ftrace callbacks were updated"
    
    * tag 'trace-v5.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
      ftrace/nds32: Update the proto for ftrace_trace_function to match ftrace_stub

commit 646b0de5fe32306eaf5399647adf2177d4417021
Merge: ab2aa486f48c 4a089e95b4d6
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Wed Oct 27 10:19:43 2021 -0700

    Merge tag 'nios2_fixes_for_v5.15_part3' of git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux
    
    Pull nios2 fix from Dinh Nguyen:
     "Fix a build error for allmodconfig"
    
    * tag 'nios2_fixes_for_v5.15_part3' of git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux:
      nios2: Make NIOS2_DTB_SOURCE_BOOL depend on !COMPILE_TEST

commit ab2aa486f48c79b0c9df77e3827922d29c60df0c
Merge: d25f27432f80 64733956ebba
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Wed Oct 27 10:01:17 2021 -0700

    Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
    
    Pull rdma fixes from Jason Gunthorpe:
     "Nothing very exciting here, it has been a quiet cycle overall. Usual
      collection of small bug fixes:
    
       - irdma issues with CQ entries, VLAN completions and a mutex deadlock
    
       - Incorrect DCT packets in mlx5
    
       - Userspace triggered overflows in qib
    
       - Locking error in hfi
    
       - Typo in errno value in qib/hfi1
    
       - Double free in qedr
    
       - Leak of random kernel memory to userspace with a netlink callback"
    
    * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
      RDMA/sa_query: Use strscpy_pad instead of memcpy to copy a string
      RDMA/irdma: Do not hold qos mutex twice on QP resume
      RDMA/irdma: Set VLAN in UD work completion correctly
      RDMA/mlx5: Initialize the ODP xarray when creating an ODP MR
      rdma/qedr: Fix crash due to redundant release of device's qp memory
      RDMA/rdmavt: Fix error code in rvt_create_qp()
      IB/hfi1: Fix abba locking issue with sc_disable()
      IB/qib: Protect from buffer overflow in struct qib_user_sdma_pkt fields
      RDMA/mlx5: Set user priority for DCT
      RDMA/irdma: Process extended CQ entries correctly

commit 4e84dc47bb48accbbeeba4e6bb3f31aa7895323c
Author: Steven Rostedt (VMware) <rostedt at goodmis.org>
Date:   Wed Oct 27 12:51:01 2021 -0400

    ftrace/nds32: Update the proto for ftrace_trace_function to match ftrace_stub
    
    The ftrace callback prototype was changed to pass a special ftrace_regs
    instead of pt_regs as the last parameter, but the static ftrace for nds32
    missed updating ftrace_trace_function and this caused a warning when
    compared to ftrace_stub:
    
    ../arch/nds32/kernel/ftrace.c: In function '_mcount':
    ../arch/nds32/kernel/ftrace.c:24:35: error: comparison of distinct pointer types lacks a cast [-Werror]
       24 |         if (ftrace_trace_function != ftrace_stub)
          |                                   ^~
    
    Link: https://lore.kernel.org/all/20211027055554.19372-1-rdunlap@infradead.org/
    Link: https://lkml.kernel.org/r/20211027125101.33449969@gandalf.local.home
    
    Cc: Ingo Molnar <mingo at kernel.org>
    Cc: Andrew Morton <akpm at linux-foundation.org>
    Cc: Nick Hu <nickhu at andestech.com>
    Cc: Greentime Hu <green.hu at gmail.com>
    Cc: Vincent Chen <deanbo422 at gmail.com>
    Cc: Masami Hiramatsu <mhiramat at kernel.org>
    Cc: Peter Zijlstra <peterz at infradead.org>
    Cc: stable at vger.kernel.org
    Fixes: d19ad0775dcd6 ("ftrace: Have the callbacks receive a struct ftrace_regs instead of pt_regs")
    Reported-by: Randy Dunlap <rdunlap at infradead.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt at goodmis.org>

diff --git a/arch/nds32/kernel/ftrace.c b/arch/nds32/kernel/ftrace.c
index 0e23e3a8df6b..d55b73b18149 100644
--- a/arch/nds32/kernel/ftrace.c
+++ b/arch/nds32/kernel/ftrace.c
@@ -6,7 +6,7 @@
 
 #ifndef CONFIG_DYNAMIC_FTRACE
 extern void (*ftrace_trace_function)(unsigned long, unsigned long,
-				     struct ftrace_ops*, struct pt_regs*);
+				     struct ftrace_ops*, struct ftrace_regs*);
 extern void ftrace_graph_caller(void);
 
 noinline void __naked ftrace_stub(unsigned long ip, unsigned long parent_ip,
commit afe8ca110cf4c99dee7b31473eacb56b72944df4
Merge: 424a4f52c5d4 689a0a9f505f
Author: Jakub Kicinski <kuba at kernel.org>
Date:   Wed Oct 27 08:12:25 2021 -0700

    Merge tag 'mac80211-for-net-2021-10-27' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211
    
    Johannes Berg says:
    
    ====================
    Two fixes:
     * bridge vs. 4-addr mode check was wrong
     * management frame registrations locking was
       wrong, causing list corruption/crashes
    ====================
    
    Link: https://lore.kernel.org/r/20211027143756.91711-1-johannes@sipsolutions.net
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

commit 9b0971ca7fc75daca80c0bb6c02e96059daea90a
Author: Paolo Bonzini <pbonzini at redhat.com>
Date:   Mon Oct 25 12:14:31 2021 -0400

    KVM: SEV-ES: fix another issue with string I/O VMGEXITs
    
    If the guest requests string I/O from the hypervisor via VMGEXIT,
    SW_EXITINFO2 will contain the REP count.  However, sev_es_string_io
    was incorrectly treating it as the size of the GHCB buffer in
    bytes.
    
    This fixes the "outsw" test in the experimental SEV tests of
    kvm-unit-tests.
    
    Cc: stable at vger.kernel.org
    Fixes: 7ed9abfe8e9f ("KVM: SVM: Support string IO operations for an SEV-ES guest")
    Reported-by: Marc Orr <marcorr at google.com>
    Tested-by: Marc Orr <marcorr at google.com>
    Reviewed-by: Marc Orr <marcorr at google.com>
    Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index e672493b5d8d..efd207fd335e 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -2579,11 +2579,20 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
 
 int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in)
 {
-	if (!setup_vmgexit_scratch(svm, in, svm->vmcb->control.exit_info_2))
+	int count;
+	int bytes;
+
+	if (svm->vmcb->control.exit_info_2 > INT_MAX)
+		return -EINVAL;
+
+	count = svm->vmcb->control.exit_info_2;
+	if (unlikely(check_mul_overflow(count, size, &bytes)))
+		return -EINVAL;
+
+	if (!setup_vmgexit_scratch(svm, in, bytes))
 		return -EINVAL;
 
-	return kvm_sev_es_string_io(&svm->vcpu, size, port,
-				    svm->ghcb_sa, svm->ghcb_sa_len / size, in);
+	return kvm_sev_es_string_io(&svm->vcpu, size, port, svm->ghcb_sa, count, in);
 }
 
 void sev_es_init_vmcb(struct vcpu_svm *svm)
commit 4a089e95b4d6bb625044d47aed0c442a8f7bd093
Author: Guenter Roeck <linux at roeck-us.net>
Date:   Wed Oct 20 12:11:16 2021 -0700

    nios2: Make NIOS2_DTB_SOURCE_BOOL depend on !COMPILE_TEST
    
    nios2:allmodconfig builds fail with
    
    make[1]: *** No rule to make target 'arch/nios2/boot/dts/""',
            needed by 'arch/nios2/boot/dts/built-in.a'.  Stop.
    make: [Makefile:1868: arch/nios2/boot/dts] Error 2 (ignored)
    
    This is seen with compile tests since those enable NIOS2_DTB_SOURCE_BOOL,
    which in turn enables NIOS2_DTB_SOURCE. This causes the build error
    because the default value for NIOS2_DTB_SOURCE is an empty string.
    Disable NIOS2_DTB_SOURCE_BOOL for compile tests to avoid the error.
    
    Fixes: 2fc8483fdcde ("nios2: Build infrastructure")
    Signed-off-by: Guenter Roeck <linux at roeck-us.net>
    Reviewed-by: Randy Dunlap <rdunlap at infradead.org>
    Signed-off-by: Dinh Nguyen <dinguyen at kernel.org>

diff --git a/arch/nios2/platform/Kconfig.platform b/arch/nios2/platform/Kconfig.platform
index 9e32fb7f3d4c..e849daff6fd1 100644
--- a/arch/nios2/platform/Kconfig.platform
+++ b/arch/nios2/platform/Kconfig.platform
@@ -37,6 +37,7 @@ config NIOS2_DTB_PHYS_ADDR
 
 config NIOS2_DTB_SOURCE_BOOL
 	bool "Compile and link device tree into kernel image"
+	depends on !COMPILE_TEST
 	help
 	  This allows you to specify a dts (device tree source) file
 	  which will be compiled and linked into the kernel image.
commit 424a4f52c5d4fe232ba55a4553eae4db2025121a
Merge: 440ffcdd9db4 630a6738da82
Author: David S. Miller <davem at davemloft.net>
Date:   Wed Oct 27 14:47:34 2021 +0100

    Merge branch 'hns3-fixes'
    
    Guangbin Huang says:
    
    ====================
    net: hns3: add some fixes for -net
    
    This series adds some fixes for the HNS3 ethernet driver.
    ====================
    
    Signed-off-by: David S. Miller <davem at davemloft.net>

commit 630a6738da82e2c29e1c38eafd6f8328e0a4963c
Author: Guangbin Huang <huangguangbin2 at huawei.com>
Date:   Wed Oct 27 20:11:49 2021 +0800

    net: hns3: adjust string spaces of some parameters of tx bd info in debugfs
    
    This patch adjusts the string spaces of some parameters of tx bd info in
    debugfs according to their maximum needs.
    
    Signed-off-by: Guangbin Huang <huangguangbin2 at huawei.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index f2ade0446208..e54f96251fea 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -790,13 +790,13 @@ static int hns3_dbg_rx_bd_info(struct hns3_dbg_data *d, char *buf, int len)
 }
 
 static const struct hns3_dbg_item tx_bd_info_items[] = {
-	{ "BD_IDX", 5 },
-	{ "ADDRESS", 2 },
+	{ "BD_IDX", 2 },
+	{ "ADDRESS", 13 },
 	{ "VLAN_TAG", 2 },
 	{ "SIZE", 2 },
 	{ "T_CS_VLAN_TSO", 2 },
 	{ "OT_VLAN_TAG", 3 },
-	{ "TV", 2 },
+	{ "TV", 5 },
 	{ "OLT_VLAN_LEN", 2 },
 	{ "PAYLEN_OL4CS", 2 },
 	{ "BD_FE_SC_VLD", 2 },
commit c7a6e3978ea952efb107ecf511c095c3bbb2945f
Author: Guangbin Huang <huangguangbin2 at huawei.com>
Date:   Wed Oct 27 20:11:48 2021 +0800

    net: hns3: expand buffer len for some debugfs command
    
    The specified buffer length for three debugfs files fd_tcam, uc and tqp
    is not enough for their maximum needs, so this patch fixes them.
    
    Fixes: b5a0b70d77b9 ("net: hns3: refactor dump fd tcam of debugfs")
    Fixes: 1556ea9120ff ("net: hns3: refactor dump mac list of debugfs")
    Fixes: d96b0e59468d ("net: hns3: refactor dump reg of debugfs")
    Signed-off-by: Guangbin Huang <huangguangbin2 at huawei.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 3aaad96d0176..f2ade0446208 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -137,7 +137,7 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
 		.name = "uc",
 		.cmd = HNAE3_DBG_CMD_MAC_UC,
 		.dentry = HNS3_DBG_DENTRY_MAC,
-		.buf_len = HNS3_DBG_READ_LEN,
+		.buf_len = HNS3_DBG_READ_LEN_128KB,
 		.init = hns3_dbg_common_file_init,
 	},
 	{
@@ -256,7 +256,7 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
 		.name = "tqp",
 		.cmd = HNAE3_DBG_CMD_REG_TQP,
 		.dentry = HNS3_DBG_DENTRY_REG,
-		.buf_len = HNS3_DBG_READ_LEN,
+		.buf_len = HNS3_DBG_READ_LEN_128KB,
 		.init = hns3_dbg_common_file_init,
 	},
 	{
@@ -298,7 +298,7 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
 		.name = "fd_tcam",
 		.cmd = HNAE3_DBG_CMD_FD_TCAM,
 		.dentry = HNS3_DBG_DENTRY_FD,
-		.buf_len = HNS3_DBG_READ_LEN,
+		.buf_len = HNS3_DBG_READ_LEN_1MB,
 		.init = hns3_dbg_common_file_init,
 	},
 	{
commit 6754614a787cbcbf87bae8a75619c24a33ea6791
Author: Jie Wang <wangjie125 at huawei.com>
Date:   Wed Oct 27 20:11:47 2021 +0800

    net: hns3: add more string spaces for dumping packets number of queue info in debugfs
    
    As the width of packets number registers is 32 bits, they needs at most
    10 characters for decimal data printing, but now the string spaces is not
    enough, so this patch fixes it.
    
    Fixes: e44c495d95e ("net: hns3: refactor queue info of debugfs")
    Signed-off-by: Jie Wang <wangjie125 at huawei.com>
    Signed-off-by: Guangbin Huang <huangguangbin2 at huawei.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 2b66c59f5eaf..3aaad96d0176 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -462,7 +462,7 @@ static const struct hns3_dbg_item rx_queue_info_items[] = {
 	{ "TAIL", 2 },
 	{ "HEAD", 2 },
 	{ "FBDNUM", 2 },
-	{ "PKTNUM", 2 },
+	{ "PKTNUM", 5 },
 	{ "COPYBREAK", 2 },
 	{ "RING_EN", 2 },
 	{ "RX_RING_EN", 2 },
@@ -565,7 +565,7 @@ static const struct hns3_dbg_item tx_queue_info_items[] = {
 	{ "HEAD", 2 },
 	{ "FBDNUM", 2 },
 	{ "OFFSET", 2 },
-	{ "PKTNUM", 2 },
+	{ "PKTNUM", 5 },
 	{ "RING_EN", 2 },
 	{ "TX_RING_EN", 2 },
 	{ "BASE_ADDR", 10 },
commit 2a21dab594a98c338c4bfbc31864cbca15888549
Author: Jie Wang <wangjie125 at huawei.com>
Date:   Wed Oct 27 20:11:46 2021 +0800

    net: hns3: fix data endian problem of some functions of debugfs
    
    The member data in struct hclge_desc is type of __le32, it needs endian
    conversion before using it, and some functions of debugfs didn't do that,
    so this patch fixes it.
    
    Fixes: c0ebebb9ccc1 ("net: hns3: Add "dcb register" status information query function")
    Signed-off-by: Jie Wang <wangjie125 at huawei.com>
    Signed-off-by: Guangbin Huang <huangguangbin2 at huawei.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index 32f62cd2dd99..9cda8b3562b8 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -391,7 +391,7 @@ static int hclge_dbg_dump_mac(struct hclge_dev *hdev, char *buf, int len)
 static int hclge_dbg_dump_dcb_qset(struct hclge_dev *hdev, char *buf, int len,
 				   int *pos)
 {
-	struct hclge_dbg_bitmap_cmd *bitmap;
+	struct hclge_dbg_bitmap_cmd req;
 	struct hclge_desc desc;
 	u16 qset_id, qset_num;
 	int ret;
@@ -408,12 +408,12 @@ static int hclge_dbg_dump_dcb_qset(struct hclge_dev *hdev, char *buf, int len,
 		if (ret)
 			return ret;
 
-		bitmap = (struct hclge_dbg_bitmap_cmd *)&desc.data[1];
+		req.bitmap = (u8)le32_to_cpu(desc.data[1]);
 
 		*pos += scnprintf(buf + *pos, len - *pos,
 				  "%04u           %#x            %#x             %#x               %#x\n",
-				  qset_id, bitmap->bit0, bitmap->bit1,
-				  bitmap->bit2, bitmap->bit3);
+				  qset_id, req.bit0, req.bit1, req.bit2,
+				  req.bit3);
 	}
 
 	return 0;
@@ -422,7 +422,7 @@ static int hclge_dbg_dump_dcb_qset(struct hclge_dev *hdev, char *buf, int len,
 static int hclge_dbg_dump_dcb_pri(struct hclge_dev *hdev, char *buf, int len,
 				  int *pos)
 {
-	struct hclge_dbg_bitmap_cmd *bitmap;
+	struct hclge_dbg_bitmap_cmd req;
 	struct hclge_desc desc;
 	u8 pri_id, pri_num;
 	int ret;
@@ -439,12 +439,11 @@ static int hclge_dbg_dump_dcb_pri(struct hclge_dev *hdev, char *buf, int len,
 		if (ret)
 			return ret;
 
-		bitmap = (struct hclge_dbg_bitmap_cmd *)&desc.data[1];
+		req.bitmap = (u8)le32_to_cpu(desc.data[1]);
 
 		*pos += scnprintf(buf + *pos, len - *pos,
 				  "%03u       %#x           %#x                %#x\n",
-				  pri_id, bitmap->bit0, bitmap->bit1,
-				  bitmap->bit2);
+				  pri_id, req.bit0, req.bit1, req.bit2);
 	}
 
 	return 0;
@@ -453,7 +452,7 @@ static int hclge_dbg_dump_dcb_pri(struct hclge_dev *hdev, char *buf, int len,
 static int hclge_dbg_dump_dcb_pg(struct hclge_dev *hdev, char *buf, int len,
 				 int *pos)
 {
-	struct hclge_dbg_bitmap_cmd *bitmap;
+	struct hclge_dbg_bitmap_cmd req;
 	struct hclge_desc desc;
 	u8 pg_id;
 	int ret;
@@ -466,12 +465,11 @@ static int hclge_dbg_dump_dcb_pg(struct hclge_dev *hdev, char *buf, int len,
 		if (ret)
 			return ret;
 
-		bitmap = (struct hclge_dbg_bitmap_cmd *)&desc.data[1];
+		req.bitmap = (u8)le32_to_cpu(desc.data[1]);
 
 		*pos += scnprintf(buf + *pos, len - *pos,
 				  "%03u      %#x           %#x               %#x\n",
-				  pg_id, bitmap->bit0, bitmap->bit1,
-				  bitmap->bit2);
+				  pg_id, req.bit0, req.bit1, req.bit2);
 	}
 
 	return 0;
@@ -511,7 +509,7 @@ static int hclge_dbg_dump_dcb_queue(struct hclge_dev *hdev, char *buf, int len,
 static int hclge_dbg_dump_dcb_port(struct hclge_dev *hdev, char *buf, int len,
 				   int *pos)
 {
-	struct hclge_dbg_bitmap_cmd *bitmap;
+	struct hclge_dbg_bitmap_cmd req;
 	struct hclge_desc desc;
 	u8 port_id = 0;
 	int ret;
@@ -521,12 +519,12 @@ static int hclge_dbg_dump_dcb_port(struct hclge_dev *hdev, char *buf, int len,
 	if (ret)
 		return ret;
 
-	bitmap = (struct hclge_dbg_bitmap_cmd *)&desc.data[1];
+	req.bitmap = (u8)le32_to_cpu(desc.data[1]);
 
 	*pos += scnprintf(buf + *pos, len - *pos, "port_mask: %#x\n",
-			 bitmap->bit0);
+			 req.bit0);
 	*pos += scnprintf(buf + *pos, len - *pos, "port_shaping_pass: %#x\n",
-			 bitmap->bit1);
+			 req.bit1);
 
 	return 0;
 }
commit 0251d196b0e1a19c870be882e5d4f496de8ab758
Author: Guangbin Huang <huangguangbin2 at huawei.com>
Date:   Wed Oct 27 20:11:45 2021 +0800

    net: hns3: ignore reset event before initialization process is done
    
    Currently, if there is a reset event triggered by RAS during device in
    initialization process, driver may run reset process concurrently with
    initialization process. In this case, it may cause problem. For example,
    the RSS indirection table may has not been alloc memory in initialization
    process yet, but it is used in reset process, it will cause a call trace
    like this:
    
    [61228.744836] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
    ...
    [61228.897677] Workqueue: hclgevf hclgevf_service_task [hclgevf]
    [61228.911390] pstate: 40400009 (nZcv daif +PAN -UAO -TCO BTYPE=--)
    [61228.918670] pc : hclgevf_set_rss_indir_table+0xb4/0x190 [hclgevf]
    [61228.927812] lr : hclgevf_set_rss_indir_table+0x90/0x190 [hclgevf]
    [61228.937248] sp : ffff8000162ebb50
    [61228.941087] x29: ffff8000162ebb50 x28: ffffb77add72dbc0 x27: ffff0820c7dc8080
    [61228.949516] x26: 0000000000000000 x25: ffff0820ad4fc880 x24: ffff0820c7dc8080
    [61228.958220] x23: ffff0820c7dc8090 x22: 00000000ffffffff x21: 0000000000000040
    [61228.966360] x20: ffffb77add72b9c0 x19: 0000000000000000 x18: 0000000000000030
    [61228.974646] x17: 0000000000000000 x16: ffffb77ae713feb0 x15: ffff0820ad4fcce8
    [61228.982808] x14: ffffffffffffffff x13: ffff8000962eb7f7 x12: 00003834ec70c960
    [61228.991990] x11: 00e0fafa8c206982 x10: 9670facc78a8f9a8 x9 : ffffb77add717530
    [61229.001123] x8 : ffff0820ad4fd6b8 x7 : 0000000000000000 x6 : 0000000000000011
    [61229.010249] x5 : 00000000000cb1b0 x4 : 0000000000002adb x3 : 0000000000000049
    [61229.018662] x2 : ffff8000162ebbb8 x1 : 0000000000000000 x0 : 0000000000000480
    [61229.027002] Call trace:
    [61229.030177]  hclgevf_set_rss_indir_table+0xb4/0x190 [hclgevf]
    [61229.039009]  hclgevf_rss_init_hw+0x128/0x1b4 [hclgevf]
    [61229.046809]  hclgevf_reset_rebuild+0x17c/0x69c [hclgevf]
    [61229.053862]  hclgevf_reset_service_task+0x4cc/0xa80 [hclgevf]
    [61229.061306]  hclgevf_service_task+0x6c/0x630 [hclgevf]
    [61229.068491]  process_one_work+0x1dc/0x48c
    [61229.074121]  worker_thread+0x15c/0x464
    [61229.078562]  kthread+0x168/0x16c
    [61229.082873]  ret_from_fork+0x10/0x18
    [61229.088221] Code: 7900e7f6 f904a683 d503201f 9101a3e2 (38616b43)
    [61229.095357] ---[ end trace 153661a538f6768c ]---
    
    To fix this problem, don't schedule reset task before initialization
    process is done.
    
    Signed-off-by: Guangbin Huang <huangguangbin2 at huawei.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 3dbde0496545..269e579762b2 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2853,6 +2853,7 @@ static void hclge_mbx_task_schedule(struct hclge_dev *hdev)
 static void hclge_reset_task_schedule(struct hclge_dev *hdev)
 {
 	if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
+	    test_bit(HCLGE_STATE_SERVICE_INITED, &hdev->state) &&
 	    !test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state))
 		mod_delayed_work(hclge_wq, &hdev->service_task, 0);
 }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 5efa5420297d..cf00ad7bb881 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -2232,6 +2232,7 @@ static void hclgevf_get_misc_vector(struct hclgevf_dev *hdev)
 void hclgevf_reset_task_schedule(struct hclgevf_dev *hdev)
 {
 	if (!test_bit(HCLGEVF_STATE_REMOVING, &hdev->state) &&
+	    test_bit(HCLGEVF_STATE_SERVICE_INITED, &hdev->state) &&
 	    !test_and_set_bit(HCLGEVF_STATE_RST_SERVICE_SCHED,
 			      &hdev->state))
 		mod_delayed_work(hclgevf_wq, &hdev->service_task, 0);
@@ -3449,6 +3450,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
 
 	hclgevf_init_rxd_adv_layout(hdev);
 
+	set_bit(HCLGEVF_STATE_SERVICE_INITED, &hdev->state);
+
 	hdev->last_reset_time = jiffies;
 	dev_info(&hdev->pdev->dev, "finished initializing %s driver\n",
 		 HCLGEVF_DRIVER_NAME);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
index 883130a9b48f..28288d7e3303 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
@@ -146,6 +146,7 @@ enum hclgevf_states {
 	HCLGEVF_STATE_REMOVING,
 	HCLGEVF_STATE_NIC_REGISTERED,
 	HCLGEVF_STATE_ROCE_REGISTERED,
+	HCLGEVF_STATE_SERVICE_INITED,
 	/* task states */
 	HCLGEVF_STATE_RST_SERVICE_SCHED,
 	HCLGEVF_STATE_RST_HANDLING,
commit f29da4088fb4eeba457219a931327d1d5f45196a
Author: Yufeng Mo <moyufeng at huawei.com>
Date:   Wed Oct 27 20:11:44 2021 +0800

    net: hns3: change hclge/hclgevf workqueue to WQ_UNBOUND mode
    
    Currently, the workqueue of hclge/hclgevf is executed on
    the CPU that initiates scheduling requests by default. In
    stress scenarios, the CPU may be busy and workqueue scheduling
    is completed after a long period of time. To avoid this
    situation and implement proper scheduling, use the WQ_UNBOUND
    mode instead. In this way, the workqueue can be performed on
    a relatively idle CPU.
    
    Signed-off-by: Yufeng Mo <moyufeng at huawei.com>
    Signed-off-by: Guangbin Huang <huangguangbin2 at huawei.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index c6b9806c75a5..3dbde0496545 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2847,33 +2847,28 @@ static void hclge_mbx_task_schedule(struct hclge_dev *hdev)
 {
 	if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
 	    !test_and_set_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state))
-		mod_delayed_work_on(cpumask_first(&hdev->affinity_mask),
-				    hclge_wq, &hdev->service_task, 0);
+		mod_delayed_work(hclge_wq, &hdev->service_task, 0);
 }
 
 static void hclge_reset_task_schedule(struct hclge_dev *hdev)
 {
 	if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
 	    !test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state))
-		mod_delayed_work_on(cpumask_first(&hdev->affinity_mask),
-				    hclge_wq, &hdev->service_task, 0);
+		mod_delayed_work(hclge_wq, &hdev->service_task, 0);
 }
 
 static void hclge_errhand_task_schedule(struct hclge_dev *hdev)
 {
 	if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
 	    !test_and_set_bit(HCLGE_STATE_ERR_SERVICE_SCHED, &hdev->state))
-		mod_delayed_work_on(cpumask_first(&hdev->affinity_mask),
-				    hclge_wq, &hdev->service_task, 0);
+		mod_delayed_work(hclge_wq, &hdev->service_task, 0);
 }
 
 void hclge_task_schedule(struct hclge_dev *hdev, unsigned long delay_time)
 {
 	if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
 	    !test_bit(HCLGE_STATE_RST_FAIL, &hdev->state))
-		mod_delayed_work_on(cpumask_first(&hdev->affinity_mask),
-				    hclge_wq, &hdev->service_task,
-				    delay_time);
+		mod_delayed_work(hclge_wq, &hdev->service_task, delay_time);
 }
 
 static int hclge_get_mac_link_status(struct hclge_dev *hdev, int *link_status)
@@ -3491,33 +3486,14 @@ static void hclge_get_misc_vector(struct hclge_dev *hdev)
 	hdev->num_msi_used += 1;
 }
 
-static void hclge_irq_affinity_notify(struct irq_affinity_notify *notify,
-				      const cpumask_t *mask)
-{
-	struct hclge_dev *hdev = container_of(notify, struct hclge_dev,
-					      affinity_notify);
-
-	cpumask_copy(&hdev->affinity_mask, mask);
-}
-
-static void hclge_irq_affinity_release(struct kref *ref)
-{
-}
-
 static void hclge_misc_affinity_setup(struct hclge_dev *hdev)
 {
 	irq_set_affinity_hint(hdev->misc_vector.vector_irq,
 			      &hdev->affinity_mask);
-
-	hdev->affinity_notify.notify = hclge_irq_affinity_notify;
-	hdev->affinity_notify.release = hclge_irq_affinity_release;
-	irq_set_affinity_notifier(hdev->misc_vector.vector_irq,
-				  &hdev->affinity_notify);
 }
 
 static void hclge_misc_affinity_teardown(struct hclge_dev *hdev)
 {
-	irq_set_affinity_notifier(hdev->misc_vector.vector_irq, NULL);
 	irq_set_affinity_hint(hdev->misc_vector.vector_irq, NULL);
 }
 
@@ -13082,7 +13058,7 @@ static int hclge_init(void)
 {
 	pr_info("%s is initializing\n", HCLGE_NAME);
 
-	hclge_wq = alloc_workqueue("%s", 0, 0, HCLGE_NAME);
+	hclge_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, HCLGE_NAME);
 	if (!hclge_wq) {
 		pr_err("%s: failed to create workqueue\n", HCLGE_NAME);
 		return -ENOMEM;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index de6afbcbfbac..69cd8f87b4c8 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -944,7 +944,6 @@ struct hclge_dev {
 
 	/* affinity mask and notify for misc interrupt */
 	cpumask_t affinity_mask;
-	struct irq_affinity_notify affinity_notify;
 	struct hclge_ptp *ptp;
 	struct devlink *devlink;
 };
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index bef6b98e2f50..5efa5420297d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -3899,7 +3899,7 @@ static int hclgevf_init(void)
 {
 	pr_info("%s is initializing\n", HCLGEVF_NAME);
 
-	hclgevf_wq = alloc_workqueue("%s", 0, 0, HCLGEVF_NAME);
+	hclgevf_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, HCLGEVF_NAME);
 	if (!hclgevf_wq) {
 		pr_err("%s: failed to create workqueue\n", HCLGEVF_NAME);
 		return -ENOMEM;
commit 3bda2e5df476417b6d08967e2d84234a59d57b1c
Author: Guangbin Huang <huangguangbin2 at huawei.com>
Date:   Wed Oct 27 20:11:43 2021 +0800

    net: hns3: fix pause config problem after autoneg disabled
    
    If a TP port is configured by follow steps:
    1.ethtool -s ethx autoneg off speed 100 duplex full
    2.ethtool -A ethx rx on tx on
    3.ethtool -s ethx autoneg on(rx&tx negotiated pause results are off)
    4.ethtool -s ethx autoneg off speed 100 duplex full
    
    In step 3, driver will set rx&tx pause parameters of hardware to off as
    pause parameters negotiated with link partner are off.
    
    After step 4, the "ethtool -a ethx" command shows both rx and tx pause
    parameters are on. However, pause parameters of hardware are still off
    and port has no flow control function actually.
    
    To fix this problem, if autoneg is disabled, driver uses its saved
    parameters to restore pause of hardware. If the speed is not changed in
    this case, there is no link state changed for phy, it will cause the pause
    parameter is not taken effect, so we need to force phy to go down and up.
    
    Fixes: aacbe27e82f0 ("net: hns3: modify how pause options is displayed")
    Signed-off-by: Guangbin Huang <huangguangbin2 at huawei.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index d701451596c8..da3a593f6a56 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -568,6 +568,7 @@ struct hnae3_ae_ops {
 			       u32 *auto_neg, u32 *rx_en, u32 *tx_en);
 	int (*set_pauseparam)(struct hnae3_handle *handle,
 			      u32 auto_neg, u32 rx_en, u32 tx_en);
+	int (*restore_pauseparam)(struct hnae3_handle *handle);
 
 	int (*set_autoneg)(struct hnae3_handle *handle, bool enable);
 	int (*get_autoneg)(struct hnae3_handle *handle);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 5ebd96f6833d..7d92dd273ed7 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -824,6 +824,26 @@ static int hns3_check_ksettings_param(const struct net_device *netdev,
 	return 0;
 }
 
+static int hns3_set_phy_link_ksettings(struct net_device *netdev,
+				       const struct ethtool_link_ksettings *cmd)
+{
+	struct hnae3_handle *handle = hns3_get_handle(netdev);
+	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	int ret;
+
+	if (cmd->base.speed == SPEED_1000 &&
+	    cmd->base.autoneg == AUTONEG_DISABLE)
+		return -EINVAL;
+
+	if (cmd->base.autoneg == AUTONEG_DISABLE && ops->restore_pauseparam) {
+		ret = ops->restore_pauseparam(handle);
+		if (ret)
+			return ret;
+	}
+
+	return phy_ethtool_ksettings_set(netdev->phydev, cmd);
+}
+
 static int hns3_set_link_ksettings(struct net_device *netdev,
 				   const struct ethtool_link_ksettings *cmd)
 {
@@ -842,16 +862,11 @@ static int hns3_set_link_ksettings(struct net_device *netdev,
 		  cmd->base.autoneg, cmd->base.speed, cmd->base.duplex);
 
 	/* Only support ksettings_set for netdev with phy attached for now */
-	if (netdev->phydev) {
-		if (cmd->base.speed == SPEED_1000 &&
-		    cmd->base.autoneg == AUTONEG_DISABLE)
-			return -EINVAL;
-
-		return phy_ethtool_ksettings_set(netdev->phydev, cmd);
-	} else if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) &&
-		   ops->set_phy_link_ksettings) {
+	if (netdev->phydev)
+		return hns3_set_phy_link_ksettings(netdev, cmd);
+	else if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) &&
+		 ops->set_phy_link_ksettings)
 		return ops->set_phy_link_ksettings(handle, cmd);
-	}
 
 	if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
 		return -EOPNOTSUPP;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index dcd40cc73082..c6b9806c75a5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -11021,6 +11021,35 @@ static int hclge_set_pauseparam(struct hnae3_handle *handle, u32 auto_neg,
 	return -EOPNOTSUPP;
 }
 
+static int hclge_restore_pauseparam(struct hnae3_handle *handle)
+{
+	struct hclge_vport *vport = hclge_get_vport(handle);
+	struct hclge_dev *hdev = vport->back;
+	u32 auto_neg, rx_pause, tx_pause;
+	int ret;
+
+	hclge_get_pauseparam(handle, &auto_neg, &rx_pause, &tx_pause);
+	/* when autoneg is disabled, the pause setting of phy has no effect
+	 * unless the link goes down.
+	 */
+	ret = phy_suspend(hdev->hw.mac.phydev);
+	if (ret)
+		return ret;
+
+	phy_set_asym_pause(hdev->hw.mac.phydev, rx_pause, tx_pause);
+
+	ret = phy_resume(hdev->hw.mac.phydev);
+	if (ret)
+		return ret;
+
+	ret = hclge_mac_pause_setup_hw(hdev);
+	if (ret)
+		dev_err(&hdev->pdev->dev,
+			"restore pauseparam error, ret = %d.\n", ret);
+
+	return ret;
+}
+
 static void hclge_get_ksettings_an_result(struct hnae3_handle *handle,
 					  u8 *auto_neg, u32 *speed, u8 *duplex)
 {
@@ -12984,6 +13013,7 @@ static const struct hnae3_ae_ops hclge_ops = {
 	.halt_autoneg = hclge_halt_autoneg,
 	.get_pauseparam = hclge_get_pauseparam,
 	.set_pauseparam = hclge_set_pauseparam,
+	.restore_pauseparam = hclge_restore_pauseparam,
 	.set_mtu = hclge_set_mtu,
 	.reset_queue = hclge_reset_tqp,
 	.get_stats = hclge_get_stats,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
index 95074e91a846..124791e4bfee 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
@@ -1435,7 +1435,7 @@ static int hclge_bp_setup_hw(struct hclge_dev *hdev, u8 tc)
 	return 0;
 }
 
-static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
+int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
 {
 	bool tx_en, rx_en;
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
index 2ee9b795f71d..4b2c3a788980 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
@@ -244,6 +244,7 @@ int hclge_tm_get_pri_weight(struct hclge_dev *hdev, u8 pri_id, u8 *weight);
 int hclge_tm_get_pri_shaper(struct hclge_dev *hdev, u8 pri_id,
 			    enum hclge_opcode_type cmd,
 			    struct hclge_tm_shaper_para *para);
+int hclge_mac_pause_setup_hw(struct hclge_dev *hdev);
 int hclge_tm_get_q_to_qs_map(struct hclge_dev *hdev, u16 q_id, u16 *qset_id);
 int hclge_tm_get_q_to_tc(struct hclge_dev *hdev, u16 q_id, u8 *tc_id);
 int hclge_tm_get_pg_to_pri_map(struct hclge_dev *hdev, u8 pg_id,
commit e0c60d0102a5ad3475401e1a2faa3d3623eefce4
Author: Shin'ichiro Kawasaki <shinichiro.kawasaki at wdc.com>
Date:   Tue Oct 26 15:01:15 2021 +0900

    block: Fix partition check for host-aware zoned block devices
    
    Commit a33df75c6328 ("block: use an xarray for disk->part_tbl") modified
    the method to check partition existence in host-aware zoned block
    devices from disk_has_partitions() helper function call to empty check
    of xarray disk->part_tbl. However, disk->part_tbl always has single
    entry for disk->part0 and never becomes empty. This resulted in the
    host-aware zoned devices always judged to have partitions, and it made
    the sysfs queue/zoned attribute to be "none" instead of "host-aware"
    regardless of partition existence in the devices.
    
    This also caused DEBUG_LOCKS_WARN_ON(lock->magic != lock) for
    sdkp->rev_mutex in scsi layer when the kernel detects host-aware zoned
    device. Since block layer handled the host-aware zoned devices as non-
    zoned devices, scsi layer did not have chance to initialize the mutex
    for zone revalidation. Therefore, the warning was triggered.
    
    To fix the issues, call the helper function disk_has_partitions() in
    place of disk->part_tbl empty check. Since the function was removed with
    the commit a33df75c6328, reimplement it to walk through entries in the
    xarray disk->part_tbl.
    
    Fixes: a33df75c6328 ("block: use an xarray for disk->part_tbl")
    Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki at wdc.com>
    Cc: stable at vger.kernel.org # v5.14+
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn at wdc.com>
    Reviewed-by: Christoph Hellwig <hch at lst.de>
    Link: https://lore.kernel.org/r/20211026060115.753746-1-shinichiro.kawasaki@wdc.com
    Signed-off-by: Jens Axboe <axboe at kernel.dk>

diff --git a/block/blk-settings.c b/block/blk-settings.c
index a7c857ad7d10..b880c70e22e4 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -842,6 +842,24 @@ bool blk_queue_can_use_dma_map_merging(struct request_queue *q,
 }
 EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging);
 
+static bool disk_has_partitions(struct gendisk *disk)
+{
+	unsigned long idx;
+	struct block_device *part;
+	bool ret = false;
+
+	rcu_read_lock();
+	xa_for_each(&disk->part_tbl, idx, part) {
+		if (bdev_is_partition(part)) {
+			ret = true;
+			break;
+		}
+	}
+	rcu_read_unlock();
+
+	return ret;
+}
+
 /**
  * blk_queue_set_zoned - configure a disk queue zoned model.
  * @disk:	the gendisk of the queue to configure
@@ -876,7 +894,7 @@ void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
 		 * we do nothing special as far as the block layer is concerned.
 		 */
 		if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED) ||
-		    !xa_empty(&disk->part_tbl))
+		    disk_has_partitions(disk))
 			model = BLK_ZONED_NONE;
 		break;
 	case BLK_ZONED_NONE:
commit 02295cf3897aa04072d4d25c7ae642eb86e2d63f
Author: Jani Nikula <jani.nikula at intel.com>
Date:   Tue Oct 26 12:34:07 2021 +0300

    drm/i915/dp: fix integer overflow in 128b/132b data rate calculation
    
    The intermediate value 1000000 * 10 * 9671 overflows 32 bits, so force
    promotion to a bigger type.
    
    From the logs:
    
    [drm:intel_dp_compute_config [i915]] DP link rate required 3657063 available -580783288
    
    v2: Use mul_u32_u32() (Ville)
    
    Fixes: 48efd014f0ea ("drm/i915/dp: add max data rate calculation for UHBR rates")
    Cc: Manasi Navare <manasi.d.navare at intel.com>
    Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211026093407.11381-1-jani.nikula@intel.com
    (cherry picked from commit bf0d608b55d9b7f426031dfd9f08d9df36c94728)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 0ddc24a37895..2a3521c6aae6 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -287,7 +287,7 @@ intel_dp_max_data_rate(int max_link_rate, int max_lanes)
 		 */
 		int max_link_rate_kbps = max_link_rate * 10;
 
-		max_link_rate_kbps = DIV_ROUND_CLOSEST_ULL(max_link_rate_kbps * 9671, 10000);
+		max_link_rate_kbps = DIV_ROUND_CLOSEST_ULL(mul_u32_u32(max_link_rate_kbps, 9671), 10000);
 		max_link_rate = max_link_rate_kbps / 8;
 	}
 
commit 9ca8bb7a1d201d62773a90bbab267f81f2ea427d
Author: Matthew Brost <matthew.brost at intel.com>
Date:   Wed Oct 20 12:21:47 2021 -0700

    drm/i915/guc: Fix recursive lock in GuC submission
    
    Use __release_guc_id (lock held) rather than release_guc_id (acquires
    lock), add lockdep annotations.
    
    213.280129] i915: Running i915_perf_live_selftests/live_noa_gpr
    [ 213.283459] ============================================
    [ 213.283462] WARNING: possible recursive locking detected
    {{[ 213.283466] 5.15.0-rc6+ #18 Tainted: G U W }}
    [ 213.283470] --------------------------------------------
    [ 213.283472] kworker/u24:0/8 is trying to acquire lock:
    [ 213.283475] ffff8ffc4f6cc1e8 (&guc->submission_state.lock){....}-{2:2}, at: destroyed_worker_func+0x2df/0x350 [i915]
    {{[ 213.283618] }}
    {{ but task is already holding lock:}}
    [ 213.283621] ffff8ffc4f6cc1e8 (&guc->submission_state.lock){....}-{2:2}, at: destroyed_worker_func+0x4f/0x350 [i915]
    {{[ 213.283720] }}
    {{ other info that might help us debug this:}}
    [ 213.283724] Possible unsafe locking scenario:[ 213.283727] CPU0
    [ 213.283728] ----
    [ 213.283730] lock(&guc->submission_state.lock);
    [ 213.283734] lock(&guc->submission_state.lock);
    {{[ 213.283737] }}
    {{ *** DEADLOCK ***}}[ 213.283740] May be due to missing lock nesting notation[ 213.283744] 3 locks held by kworker/u24:0/8:
    [ 213.283747] #0: ffff8ffb80059d38 ((wq_completion)events_unbound){..}-{0:0}, at: process_one_work+0x1f3/0x550
    [ 213.283757] #1: ffffb509000e3e78 ((work_completion)(&guc->submission_state.destroyed_worker)){..}-{0:0}, at: process_one_work+0x1f3/0x550
    [ 213.283766] #2: ffff8ffc4f6cc1e8 (&guc->submission_state.lock){....}-{2:2}, at: destroyed_worker_func+0x4f/0x350 [i915]
    {{[ 213.283860] }}
    {{ stack backtrace:}}
    [ 213.283863] CPU: 8 PID: 8 Comm: kworker/u24:0 Tainted: G U W 5.15.0-rc6+ #18
    [ 213.283868] Hardware name: ASUS System Product Name/PRIME B560M-A AC, BIOS 0403 01/26/2021
    [ 213.283873] Workqueue: events_unbound destroyed_worker_func [i915]
    [ 213.283957] Call Trace:
    [ 213.283960] dump_stack_lvl+0x57/0x72
    [ 213.283966] __lock_acquire.cold+0x191/0x2d3
    [ 213.283972] lock_acquire+0xb5/0x2b0
    [ 213.283978] ? destroyed_worker_func+0x2df/0x350 [i915]
    [ 213.284059] ? destroyed_worker_func+0x2d7/0x350 [i915]
    [ 213.284139] ? lock_release+0xb9/0x280
    [ 213.284143] _raw_spin_lock_irqsave+0x48/0x60
    [ 213.284148] ? destroyed_worker_func+0x2df/0x350 [i915]
    [ 213.284226] destroyed_worker_func+0x2df/0x350 [i915]
    [ 213.284310] process_one_work+0x270/0x550
    [ 213.284315] worker_thread+0x52/0x3b0
    [ 213.284319] ? process_one_work+0x550/0x550
    [ 213.284322] kthread+0x135/0x160
    [ 213.284326] ? set_kthread_struct+0x40/0x40
    [ 213.284331] ret_from_fork+0x1f/0x30
    
    and a bit later in the trace:
    
    {{ 227.499864] do_raw_spin_lock+0x94/0xa0}}
    [ 227.499868] _raw_spin_lock_irqsave+0x50/0x60
    [ 227.499871] ? guc_flush_destroyed_contexts+0x4f/0xf0 [i915]
    [ 227.499995] guc_flush_destroyed_contexts+0x4f/0xf0 [i915]
    [ 227.500104] intel_guc_submission_reset_prepare+0x99/0x4b0 [i915]
    [ 227.500209] ? mark_held_locks+0x49/0x70
    [ 227.500212] intel_uc_reset_prepare+0x46/0x50 [i915]
    [ 227.500320] reset_prepare+0x78/0x90 [i915]
    [ 227.500412] __intel_gt_set_wedged.part.0+0x13/0xe0 [i915]
    [ 227.500485] intel_gt_set_wedged.part.0+0x54/0x100 [i915]
    [ 227.500556] intel_gt_set_wedged_on_fini+0x1a/0x30 [i915]
    [ 227.500622] intel_gt_driver_unregister+0x1e/0x60 [i915]
    [ 227.500694] i915_driver_remove+0x4a/0xf0 [i915]
    [ 227.500767] i915_pci_probe+0x84/0x170 [i915]
    [ 227.500838] local_pci_probe+0x42/0x80
    [ 227.500842] pci_device_probe+0xd9/0x190
    [ 227.500844] really_probe+0x1f2/0x3f0
    [ 227.500847] __driver_probe_device+0xfe/0x180
    [ 227.500848] driver_probe_device+0x1e/0x90
    [ 227.500850] __driver_attach+0xc4/0x1d0
    [ 227.500851] ? __device_attach_driver+0xe0/0xe0
    [ 227.500853] ? __device_attach_driver+0xe0/0xe0
    [ 227.500854] bus_for_each_dev+0x64/0x90
    [ 227.500856] bus_add_driver+0x12e/0x1f0
    [ 227.500857] driver_register+0x8f/0xe0
    [ 227.500859] i915_init+0x1d/0x8f [i915]
    [ 227.500934] ? 0xffffffffc144a000
    [ 227.500936] do_one_initcall+0x58/0x2d0
    [ 227.500938] ? rcu_read_lock_sched_held+0x3f/0x80
    [ 227.500940] ? kmem_cache_alloc_trace+0x238/0x2d0
    [ 227.500944] do_init_module+0x5c/0x270
    [ 227.500946] __do_sys_finit_module+0x95/0xe0
    [ 227.500949] do_syscall_64+0x38/0x90
    [ 227.500951] entry_SYSCALL_64_after_hwframe+0x44/0xae
    [ 227.500953] RIP: 0033:0x7ffa59d2ae0d
    [ 227.500954] Code: c8 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 3b 80 0c 00 f7 d8 64 89 01 48
    [ 227.500955] RSP: 002b:00007fff320bbf48 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
    [ 227.500956] RAX: ffffffffffffffda RBX: 00000000022ea710 RCX: 00007ffa59d2ae0d
    [ 227.500957] RDX: 0000000000000000 RSI: 00000000022e1d90 RDI: 0000000000000004
    [ 227.500958] RBP: 0000000000000020 R08: 00007ffa59df3a60 R09: 0000000000000070
    [ 227.500958] R10: 00000000022e1d90 R11: 0000000000000246 R12: 00000000022e1d90
    [ 227.500959] R13: 00000000022e58e0 R14: 0000000000000043 R15: 00000000022e42c0
    
    v2:
     (CI build)
      - Fix build error
    
    Fixes: 1a52faed31311 ("drm/i915/guc: Take GT PM ref when deregistering context")
    Signed-off-by: Matthew Brost <matthew.brost at intel.com>
    Cc: stable at vger.kernel.org
    Reviewed-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
    Signed-off-by: John Harrison <John.C.Harrison at Intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211020192147.8048-1-matthew.brost@intel.com
    (cherry picked from commit 12a9917e9e84fef4efa73c09b32870df0b1ed795)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index d7710debcd47..38b47e73e35d 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -2373,6 +2373,7 @@ static inline void guc_lrc_desc_unpin(struct intel_context *ce)
 	unsigned long flags;
 	bool disabled;
 
+	lockdep_assert_held(&guc->submission_state.lock);
 	GEM_BUG_ON(!intel_gt_pm_is_awake(gt));
 	GEM_BUG_ON(!lrc_desc_registered(guc, ce->guc_id.id));
 	GEM_BUG_ON(ce != __get_context(guc, ce->guc_id.id));
@@ -2388,7 +2389,7 @@ static inline void guc_lrc_desc_unpin(struct intel_context *ce)
 	}
 	spin_unlock_irqrestore(&ce->guc_state.lock, flags);
 	if (unlikely(disabled)) {
-		release_guc_id(guc, ce);
+		__release_guc_id(guc, ce);
 		__guc_context_destroy(ce);
 		return;
 	}
commit 8a30b871b6f3804a72c523a2b086b72f1bf6146d
Author: Jani Nikula <jani.nikula at intel.com>
Date:   Thu Oct 21 16:34:08 2021 +0300

    drm/i915/cdclk: put the cdclk vtables in const data
    
    Add the const that was accidentally left out from the vtables.
    
    Fixes: 6b4cd9cba620 ("drm/i915: constify the cdclk vtable")
    Cc: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211021133408.32166-1-jani.nikula@intel.com
    (cherry picked from commit 877d074939a5f82b099da2db3bcccc6c418b9c39)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.c b/drivers/gpu/drm/i915/display/intel_cdclk.c
index 9e466d829019..868dd43a7542 100644
--- a/drivers/gpu/drm/i915/display/intel_cdclk.c
+++ b/drivers/gpu/drm/i915/display/intel_cdclk.c
@@ -2885,7 +2885,7 @@ u32 intel_read_rawclk(struct drm_i915_private *dev_priv)
 	return freq;
 }
 
-static struct intel_cdclk_funcs tgl_cdclk_funcs = {
+static const struct intel_cdclk_funcs tgl_cdclk_funcs = {
 	.get_cdclk = bxt_get_cdclk,
 	.set_cdclk = bxt_set_cdclk,
 	.bw_calc_min_cdclk = skl_bw_calc_min_cdclk,
@@ -2893,7 +2893,7 @@ static struct intel_cdclk_funcs tgl_cdclk_funcs = {
 	.calc_voltage_level = tgl_calc_voltage_level,
 };
 
-static struct intel_cdclk_funcs ehl_cdclk_funcs = {
+static const struct intel_cdclk_funcs ehl_cdclk_funcs = {
 	.get_cdclk = bxt_get_cdclk,
 	.set_cdclk = bxt_set_cdclk,
 	.bw_calc_min_cdclk = skl_bw_calc_min_cdclk,
@@ -2901,7 +2901,7 @@ static struct intel_cdclk_funcs ehl_cdclk_funcs = {
 	.calc_voltage_level = ehl_calc_voltage_level,
 };
 
-static struct intel_cdclk_funcs icl_cdclk_funcs = {
+static const struct intel_cdclk_funcs icl_cdclk_funcs = {
 	.get_cdclk = bxt_get_cdclk,
 	.set_cdclk = bxt_set_cdclk,
 	.bw_calc_min_cdclk = skl_bw_calc_min_cdclk,
@@ -2909,7 +2909,7 @@ static struct intel_cdclk_funcs icl_cdclk_funcs = {
 	.calc_voltage_level = icl_calc_voltage_level,
 };
 
-static struct intel_cdclk_funcs bxt_cdclk_funcs = {
+static const struct intel_cdclk_funcs bxt_cdclk_funcs = {
 	.get_cdclk = bxt_get_cdclk,
 	.set_cdclk = bxt_set_cdclk,
 	.bw_calc_min_cdclk = skl_bw_calc_min_cdclk,
@@ -2917,54 +2917,54 @@ static struct intel_cdclk_funcs bxt_cdclk_funcs = {
 	.calc_voltage_level = bxt_calc_voltage_level,
 };
 
-static struct intel_cdclk_funcs skl_cdclk_funcs = {
+static const struct intel_cdclk_funcs skl_cdclk_funcs = {
 	.get_cdclk = skl_get_cdclk,
 	.set_cdclk = skl_set_cdclk,
 	.bw_calc_min_cdclk = skl_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = skl_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs bdw_cdclk_funcs = {
+static const struct intel_cdclk_funcs bdw_cdclk_funcs = {
 	.get_cdclk = bdw_get_cdclk,
 	.set_cdclk = bdw_set_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = bdw_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs chv_cdclk_funcs = {
+static const struct intel_cdclk_funcs chv_cdclk_funcs = {
 	.get_cdclk = vlv_get_cdclk,
 	.set_cdclk = chv_set_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = vlv_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs vlv_cdclk_funcs = {
+static const struct intel_cdclk_funcs vlv_cdclk_funcs = {
 	.get_cdclk = vlv_get_cdclk,
 	.set_cdclk = vlv_set_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = vlv_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs hsw_cdclk_funcs = {
+static const struct intel_cdclk_funcs hsw_cdclk_funcs = {
 	.get_cdclk = hsw_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
 /* SNB, IVB, 965G, 945G */
-static struct intel_cdclk_funcs fixed_400mhz_cdclk_funcs = {
+static const struct intel_cdclk_funcs fixed_400mhz_cdclk_funcs = {
 	.get_cdclk = fixed_400mhz_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs ilk_cdclk_funcs = {
+static const struct intel_cdclk_funcs ilk_cdclk_funcs = {
 	.get_cdclk = fixed_450mhz_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs gm45_cdclk_funcs = {
+static const struct intel_cdclk_funcs gm45_cdclk_funcs = {
 	.get_cdclk = gm45_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
@@ -2972,7 +2972,7 @@ static struct intel_cdclk_funcs gm45_cdclk_funcs = {
 
 /* G45 uses G33 */
 
-static struct intel_cdclk_funcs i965gm_cdclk_funcs = {
+static const struct intel_cdclk_funcs i965gm_cdclk_funcs = {
 	.get_cdclk = i965gm_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
@@ -2980,19 +2980,19 @@ static struct intel_cdclk_funcs i965gm_cdclk_funcs = {
 
 /* i965G uses fixed 400 */
 
-static struct intel_cdclk_funcs pnv_cdclk_funcs = {
+static const struct intel_cdclk_funcs pnv_cdclk_funcs = {
 	.get_cdclk = pnv_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs g33_cdclk_funcs = {
+static const struct intel_cdclk_funcs g33_cdclk_funcs = {
 	.get_cdclk = g33_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs i945gm_cdclk_funcs = {
+static const struct intel_cdclk_funcs i945gm_cdclk_funcs = {
 	.get_cdclk = i945gm_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
@@ -3000,37 +3000,37 @@ static struct intel_cdclk_funcs i945gm_cdclk_funcs = {
 
 /* i945G uses fixed 400 */
 
-static struct intel_cdclk_funcs i915gm_cdclk_funcs = {
+static const struct intel_cdclk_funcs i915gm_cdclk_funcs = {
 	.get_cdclk = i915gm_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs i915g_cdclk_funcs = {
+static const struct intel_cdclk_funcs i915g_cdclk_funcs = {
 	.get_cdclk = fixed_333mhz_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs i865g_cdclk_funcs = {
+static const struct intel_cdclk_funcs i865g_cdclk_funcs = {
 	.get_cdclk = fixed_266mhz_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs i85x_cdclk_funcs = {
+static const struct intel_cdclk_funcs i85x_cdclk_funcs = {
 	.get_cdclk = i85x_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs i845g_cdclk_funcs = {
+static const struct intel_cdclk_funcs i845g_cdclk_funcs = {
 	.get_cdclk = fixed_200mhz_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
 };
 
-static struct intel_cdclk_funcs i830_cdclk_funcs = {
+static const struct intel_cdclk_funcs i830_cdclk_funcs = {
 	.get_cdclk = fixed_133mhz_get_cdclk,
 	.bw_calc_min_cdclk = intel_bw_calc_min_cdclk,
 	.modeset_calc_cdclk = fixed_modeset_calc_cdclk,
commit c4d6da21b2c6627d968d7c1410925ff4a8c199c4
Author: Jani Nikula <jani.nikula at intel.com>
Date:   Tue Oct 19 14:43:34 2021 +0300

    Revert "drm/i915/bios: gracefully disable dual eDP for now"
    
    This reverts commit 05734ca2a8f76c9eb3890b3c9dfc3467f03105c1.
    
    It's not graceful, instead it leads to boot time warning splats in the
    case it is supposed to handle gracefully. Apparently the BIOS/GOP
    enabling the port we end up skipping leads to state readout
    problems. Back to the drawing board.
    
    References: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21255/bat-adlp-4/boot0.txt
    Fixes: 05734ca2a8f7 ("drm/i915/bios: gracefully disable dual eDP for now")
    Cc: José Roberto de Souza <jose.souza at intel.com>
    Cc: Uma Shankar <uma.shankar at intel.com>
    Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Cc: Swati Sharma <swati2.sharma at intel.com>
    Reviewed-by: José Roberto de Souza <jose.souza at intel.com>
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211019114334.24643-1-jani.nikula@intel.com
    (cherry picked from commit 171c555c2c2664a250cd35680c34c31a6d233dc7)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index b99907c656bb..f9776ca85de3 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -1930,50 +1930,6 @@ static int _intel_bios_max_tmds_clock(const struct intel_bios_encoder_data *devd
 	}
 }
 
-static enum port get_edp_port(struct drm_i915_private *i915)
-{
-	const struct intel_bios_encoder_data *devdata;
-	enum port port;
-
-	for_each_port(port) {
-		devdata = i915->vbt.ports[port];
-
-		if (devdata && intel_bios_encoder_supports_edp(devdata))
-			return port;
-	}
-
-	return PORT_NONE;
-}
-
-/*
- * FIXME: The power sequencer and backlight code currently do not support more
- * than one set registers, at least not on anything other than VLV/CHV. It will
- * clobber the registers. As a temporary workaround, gracefully prevent more
- * than one eDP from being registered.
- */
-static void sanitize_dual_edp(struct intel_bios_encoder_data *devdata,
-			      enum port port)
-{
-	struct drm_i915_private *i915 = devdata->i915;
-	struct child_device_config *child = &devdata->child;
-	enum port p;
-
-	/* CHV might not clobber PPS registers. */
-	if (IS_CHERRYVIEW(i915))
-		return;
-
-	p = get_edp_port(i915);
-	if (p == PORT_NONE)
-		return;
-
-	drm_dbg_kms(&i915->drm, "both ports %c and %c configured as eDP, "
-		    "disabling port %c eDP\n", port_name(p), port_name(port),
-		    port_name(port));
-
-	child->device_type &= ~DEVICE_TYPE_DISPLAYPORT_OUTPUT;
-	child->device_type &= ~DEVICE_TYPE_INTERNAL_CONNECTOR;
-}
-
 static bool is_port_valid(struct drm_i915_private *i915, enum port port)
 {
 	/*
@@ -2031,9 +1987,6 @@ static void parse_ddi_port(struct drm_i915_private *i915,
 		    supports_typec_usb, supports_tbt,
 		    devdata->dsc != NULL);
 
-	if (is_edp)
-		sanitize_dual_edp(devdata, port);
-
 	if (is_dvi)
 		sanitize_ddc_pin(devdata, port);
 
commit cc99bc62ff6902688ee7bd3a7b25eefc620fbb6a
Author: Imre Deak <imre.deak at intel.com>
Date:   Mon Oct 18 12:41:51 2021 +0300

    drm/i915/dp: Ensure max link params are always valid
    
    Atm until the DPCD for a connector is read the max link rate and lane
    count params are invalid. If the connector is modeset, in
    intel_dp_compute_config(), intel_dp_common_len_rate_limit(max_link_rate)
    will return 0, leading to a intel_dp->common_rates[-1] access.
    
    Fix the above by making sure the max link params are always valid.
    
    The above access leads to an undefined behaviour by definition, though
    not causing a user visible problem to my best knowledge, see the previous
    patch why. Nevertheless it is an undefined behaviour and it triggers a
    BUG() in CONFIG_UBSAN builds, hence CC:stable.
    
    Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Imre Deak <imre.deak at intel.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Acked-by: Jani Nikula <jani.nikula at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211018094154.1407705-4-imre.deak@intel.com
    (cherry picked from commit 9ad87de4735620ffc555592e8c5f580478fa3ed0)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 9c898693f6c6..0ddc24a37895 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -1864,6 +1864,12 @@ void intel_dp_set_link_params(struct intel_dp *intel_dp,
 	intel_dp->lane_count = lane_count;
 }
 
+static void intel_dp_reset_max_link_params(struct intel_dp *intel_dp)
+{
+	intel_dp->max_link_lane_count = intel_dp_max_common_lane_count(intel_dp);
+	intel_dp->max_link_rate = intel_dp_max_common_rate(intel_dp);
+}
+
 /* Enable backlight PWM and backlight PP control. */
 void intel_edp_backlight_on(const struct intel_crtc_state *crtc_state,
 			    const struct drm_connector_state *conn_state)
@@ -2020,8 +2026,7 @@ void intel_dp_sync_state(struct intel_encoder *encoder,
 	if (intel_dp->dpcd[DP_DPCD_REV] == 0)
 		intel_dp_get_dpcd(intel_dp);
 
-	intel_dp->max_link_lane_count = intel_dp_max_common_lane_count(intel_dp);
-	intel_dp->max_link_rate = intel_dp_max_common_rate(intel_dp);
+	intel_dp_reset_max_link_params(intel_dp);
 }
 
 bool intel_dp_initial_fastset_check(struct intel_encoder *encoder,
@@ -2597,6 +2602,7 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp)
 		intel_dp_set_sink_rates(intel_dp);
 
 	intel_dp_set_common_rates(intel_dp);
+	intel_dp_reset_max_link_params(intel_dp);
 
 	/* Read the eDP DSC DPCD registers */
 	if (DISPLAY_VER(dev_priv) >= 10)
@@ -4338,12 +4344,7 @@ intel_dp_detect(struct drm_connector *connector,
 	 * supports link training fallback params.
 	 */
 	if (intel_dp->reset_link_params || intel_dp->is_mst) {
-		/* Initial max link lane count */
-		intel_dp->max_link_lane_count = intel_dp_max_common_lane_count(intel_dp);
-
-		/* Initial max link rate */
-		intel_dp->max_link_rate = intel_dp_max_common_rate(intel_dp);
-
+		intel_dp_reset_max_link_params(intel_dp);
 		intel_dp->reset_link_params = false;
 	}
 
@@ -5011,6 +5012,7 @@ intel_dp_init_connector(struct intel_digital_port *dig_port,
 	intel_dp_set_source_rates(intel_dp);
 	intel_dp_set_default_sink_rates(intel_dp);
 	intel_dp_set_common_rates(intel_dp);
+	intel_dp_reset_max_link_params(intel_dp);
 
 	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
 		intel_dp->pps.active_pipe = vlv_active_pipe(intel_dp);
commit 6c34bd4532a3f39952952ddc102737595729afc4
Author: Imre Deak <imre.deak at intel.com>
Date:   Mon Oct 18 17:34:17 2021 +0300

    drm/i915/dp: Ensure sink rate values are always valid
    
    Atm, there are no sink rate values set for DP (vs. eDP) sinks until the
    DPCD capabilities are successfully read from the sink. During this time
    intel_dp->num_common_rates is 0 which can lead to a
    
    intel_dp->common_rates[-1]    (*)
    
    access, which is an undefined behaviour, in the following cases:
    
    - In intel_dp_sync_state(), if the encoder is enabled without a sink
      connected to the encoder's connector (BIOS enabled a monitor, but the
      user unplugged the monitor until the driver loaded).
    - In intel_dp_sync_state() if the encoder is enabled with a sink
      connected, but for some reason the DPCD read has failed.
    - In intel_dp_compute_link_config() if modesetting a connector without
      a sink connected on it.
    - In intel_dp_compute_link_config() if modesetting a connector with a
      a sink connected on it, but before probing the connector first.
    
    To avoid the (*) access in all the above cases, make sure that the sink
    rate table - and hence the common rate table - is always valid, by
    setting a default minimum sink rate when registering the connector
    before anything could use it.
    
    I also considered setting all the DP link rates by default, so that
    modesetting with higher resolution modes also succeeds in the last two
    cases above. However in case a sink is not connected that would stop
    working after the first modeset, due to the LT fallback logic. So this
    would need more work, beyond the scope of this fix.
    
    As I mentioned in the previous patch, I don't think the issue this patch
    fixes is user visible, however it is an undefined behaviour by
    definition and triggers a BUG() in CONFIG_UBSAN builds, hence CC:stable.
    
    v2: Clear the default sink rates, before initializing these for eDP.
    
    Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4297
    References: https://gitlab.freedesktop.org/drm/intel/-/issues/4298
    Suggested-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Imre Deak <imre.deak at intel.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Acked-by: Jani Nikula <jani.nikula at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211018143417.1452632-1-imre.deak@intel.com
    (cherry picked from commit 3f61ef9777c0ab0f03f4af0ed6fd3e5250537a8d)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 9d8132dd4cc5..9c898693f6c6 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -120,6 +120,12 @@ bool intel_dp_is_uhbr(const struct intel_crtc_state *crtc_state)
 	return crtc_state->port_clock >= 1000000;
 }
 
+static void intel_dp_set_default_sink_rates(struct intel_dp *intel_dp)
+{
+	intel_dp->sink_rates[0] = 162000;
+	intel_dp->num_sink_rates = 1;
+}
+
 /* update sink rates from dpcd */
 static void intel_dp_set_sink_rates(struct intel_dp *intel_dp)
 {
@@ -2553,6 +2559,9 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp)
 	 */
 	intel_psr_init_dpcd(intel_dp);
 
+	/* Clear the default sink rates */
+	intel_dp->num_sink_rates = 0;
+
 	/* Read the eDP 1.4+ supported link rates. */
 	if (intel_dp->edp_dpcd[0] >= DP_EDP_14) {
 		__le16 sink_rates[DP_MAX_SUPPORTED_RATES];
@@ -5000,6 +5009,8 @@ intel_dp_init_connector(struct intel_digital_port *dig_port,
 	}
 
 	intel_dp_set_source_rates(intel_dp);
+	intel_dp_set_default_sink_rates(intel_dp);
+	intel_dp_set_common_rates(intel_dp);
 
 	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
 		intel_dp->pps.active_pipe = vlv_active_pipe(intel_dp);
commit 3a60f6537c9adf0828bf1dd868c59f659395257e
Author: David Sterba <dsterba at suse.com>
Date:   Wed Oct 27 10:39:03 2021 +0200

    Revert "btrfs: compression: drop kmap/kunmap from generic helpers"
    
    This reverts commit 4c2bf276b56d8d27ddbafcdf056ef3fc60ae50b0.
    
    The kmaps in compression code are still needed and cause crashes on
    32bit machines (ARM, x86). Reproducible eg. by running fstest btrfs/004
    with enabled LZO or ZSTD compression.
    
    Link: https://lore.kernel.org/all/CAJCQCtT+OuemovPO7GZk8Y8=qtOObr0XTDp8jh4OHD6y84AFxw@mail.gmail.com/
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=214839
    Signed-off-by: David Sterba <dsterba at suse.com>

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 7869ad12bc6e..0913ee50e6c3 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -172,9 +172,10 @@ static int check_compressed_csum(struct btrfs_inode *inode, struct bio *bio,
 		/* Hash through the page sector by sector */
 		for (pg_offset = 0; pg_offset < bytes_left;
 		     pg_offset += sectorsize) {
-			kaddr = page_address(page);
+			kaddr = kmap_atomic(page);
 			crypto_shash_digest(shash, kaddr + pg_offset,
 					    sectorsize, csum);
+			kunmap_atomic(kaddr);
 
 			if (memcmp(&csum, cb_sum, csum_size) != 0) {
 				btrfs_print_data_csum_error(inode, disk_start,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2aa9646bce56..e6772f55943e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -287,8 +287,9 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
 			cur_size = min_t(unsigned long, compressed_size,
 				       PAGE_SIZE);
 
-			kaddr = page_address(cpage);
+			kaddr = kmap_atomic(cpage);
 			write_extent_buffer(leaf, kaddr, ptr, cur_size);
+			kunmap_atomic(kaddr);
 
 			i++;
 			ptr += cur_size;
commit 86aeda32b887cdaeb0f4b7bfc9971e36377181c7
Author: Amit Engel <amit.engel at dell.com>
Date:   Wed Oct 27 09:49:27 2021 +0300

    nvmet-tcp: fix header digest verification
    
    Pass the correct length to nvmet_tcp_verify_hdgst, which is the pdu
    header length.  This fixes a wrong behaviour where header digest
    verification passes although the digest is wrong.
    
    Signed-off-by: Amit Engel <amit.engel at dell.com>
    Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
    Signed-off-by: Christoph Hellwig <hch at lst.de>

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 586ca20837e7..46c3b3be7e03 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -1096,7 +1096,7 @@ recv:
 	}
 
 	if (queue->hdr_digest &&
-	    nvmet_tcp_verify_hdgst(queue, &queue->pdu, queue->offset)) {
+	    nvmet_tcp_verify_hdgst(queue, &queue->pdu, hdr->hlen)) {
 		nvmet_tcp_fatal_error(queue); /* fatal */
 		return -EPROTO;
 	}
commit e790de54e94a7a15fb725b34724d41d41cbaa60c
Author: Varun Prakash <varun at chelsio.com>
Date:   Mon Oct 25 22:46:54 2021 +0530

    nvmet-tcp: fix data digest pointer calculation
    
    exp_ddgst is of type __le32, &cmd->exp_ddgst + cmd->offset increases
    &cmd->exp_ddgst by 4 * cmd->offset, fix this by type casting
    &cmd->exp_ddgst to u8 *.
    
    Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver")
    Signed-off-by: Varun Prakash <varun at chelsio.com>
    Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
    Signed-off-by: Christoph Hellwig <hch at lst.de>

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index c33a0464346f..586ca20837e7 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -702,7 +702,7 @@ static int nvmet_try_send_ddgst(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
 	struct nvmet_tcp_queue *queue = cmd->queue;
 	struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
 	struct kvec iov = {
-		.iov_base = &cmd->exp_ddgst + cmd->offset,
+		.iov_base = (u8 *)&cmd->exp_ddgst + cmd->offset,
 		.iov_len = NVME_TCP_DIGEST_LENGTH - cmd->offset
 	};
 	int ret;
commit d89b9f3bbb58e9e378881209756b0723694f22ff
Author: Varun Prakash <varun at chelsio.com>
Date:   Mon Oct 25 22:47:30 2021 +0530

    nvme-tcp: fix data digest pointer calculation
    
    ddgst is of type __le32, &req->ddgst + req->offset
    increases &req->ddgst by 4 * req->offset, fix this by
    type casting &req->ddgst to u8 *.
    
    Fixes: 3f2304f8c6d6 ("nvme-tcp: add NVMe over TCP host driver")
    Signed-off-by: Varun Prakash <varun at chelsio.com>
    Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
    Signed-off-by: Christoph Hellwig <hch at lst.de>

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 1a209f0d7181..4ae562d30d2b 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1054,7 +1054,7 @@ static int nvme_tcp_try_send_ddgst(struct nvme_tcp_request *req)
 	int ret;
 	struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
 	struct kvec iov = {
-		.iov_base = &req->ddgst + req->offset,
+		.iov_base = (u8 *)&req->ddgst + req->offset,
 		.iov_len = NVME_TCP_DIGEST_LENGTH - req->offset
 	};
 
commit ce7723e9cdae4eb3030da082876580f4b2dc0861
Author: Varun Prakash <varun at chelsio.com>
Date:   Tue Oct 26 19:01:55 2021 +0530

    nvme-tcp: fix possible req->offset corruption
    
    With commit db5ad6b7f8cd ("nvme-tcp: try to send request in queue_rq
    context") r2t and response PDU can get processed while send function
    is executing.
    
    Current data digest send code uses req->offset after kernel_sendmsg(),
    this creates a race condition where req->offset gets reset before it
    is used in send function.
    
    This can happen in two cases -
    1. Target sends r2t PDU which resets req->offset.
    2. Target send response PDU which completes the req and then req is
       used for a new command, nvme_tcp_setup_cmd_pdu() resets req->offset.
    
    Fix this by storing req->offset in a local variable and using
    this local variable after kernel_sendmsg().
    
    Fixes: db5ad6b7f8cd ("nvme-tcp: try to send request in queue_rq context")
    Signed-off-by: Varun Prakash <varun at chelsio.com>
    Reviewed-by: Keith Busch <kbusch at kernel.org>
    Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
    Signed-off-by: Christoph Hellwig <hch at lst.de>

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 0626d14e6d4c..1a209f0d7181 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1050,6 +1050,7 @@ static int nvme_tcp_try_send_data_pdu(struct nvme_tcp_request *req)
 static int nvme_tcp_try_send_ddgst(struct nvme_tcp_request *req)
 {
 	struct nvme_tcp_queue *queue = req->queue;
+	size_t offset = req->offset;
 	int ret;
 	struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
 	struct kvec iov = {
@@ -1066,7 +1067,7 @@ static int nvme_tcp_try_send_ddgst(struct nvme_tcp_request *req)
 	if (unlikely(ret <= 0))
 		return ret;
 
-	if (req->offset + ret == NVME_TCP_DIGEST_LENGTH) {
+	if (offset + ret == NVME_TCP_DIGEST_LENGTH) {
 		nvme_tcp_done_send_req(queue);
 		return 1;
 	}
commit defbbcd99fa68cb7feed453662048baa87e9a441
Merge: 3906fe9bb7f1 53c2ff8bcb06
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Oct 27 10:01:21 2021 +1000

    Merge tag 'amd-drm-fixes-5.15-2021-10-21' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
    
    amd-drm-fixes-5.15-2021-10-21:
    
    amdgpu:
    - Fix a potential out of bounds write in debugfs
    - Fix revision handling for Yellow Carp
    - Display fixes for Yellow Carp
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    From: Alex Deucher <alexander.deucher at amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211021203430.4578-1-alexander.deucher@amd.com

commit d25f27432f80a800a3592db128254c8140bd71bf
Merge: 3906fe9bb7f1 05d5da3cb11c
Author: Linus Torvalds <torvalds at linux-foundation.org>
Date:   Tue Oct 26 15:24:33 2021 -0700

    Merge tag 'arm-soc-fixes-5.15-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
    
    Pull ARM SoC fixes from Arnd Bergmann:
     "One last set of small fixes for the soc tree:
    
       - Incorrect ethernet phy settings found on i.mx and allwinner
         platforms
    
       - a revert for a Qualcomm DT change that caused a boot regression
    
       - four patches for incorrect settings in i.MX DT files
    
       - new MAINTAINER file entries for dhcom boards
    
       - a Kconfig fix for a reset driver that became unselectable
    
       - three more code changes for bugs in reset drivers"
    
    * tag 'arm-soc-fixes-5.15-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc:
      MAINTAINERS: Add maintainers for DHCOM i.MX6 and DHCOM/DHCOR STM32MP1
      Revert "arm64: dts: qcom: sm8250: remove bus clock from the mdss node for sm8250 target"
      arm64: dts: imx8mm-kontron: Fix connection type for VSC8531 RGMII PHY
      arm64: dts: imx8mm-kontron: Fix CAN SPI clock frequency
      arm64: dts: imx8mm-kontron: Fix polarity of reg_rst_eth2
      arm64: dts: imx8mm-kontron: Set lower limit of VDD_SNVS to 800 mV
      arm64: dts: imx8mm-kontron: Make sure SOC and DRAM supply voltages are correct
      reset: socfpga: add empty driver allowing consumers to probe
      reset: tegra-bpmp: Handle errors in BPMP response
      reset: pistachio: Re-enable driver selection
      reset: brcmstb-rescal: fix incorrect polarity of status bit
      ARM: dts: sun7i: A20-olinuxino-lime2: Fix ethernet phy-mode
      arm64: dts: allwinner: h5: NanoPI Neo 2: Fix ethernet node

commit 9586e67b911c95ba158fcc247b230e9c2d718623
Author: Naohiro Aota <naohiro.aota at wdc.com>
Date:   Wed Oct 27 01:51:27 2021 +0900

    block: schedule queue restart after BLK_STS_ZONE_RESOURCE
    
    When dispatching a zone append write request to a SCSI zoned block device,
    if the target zone of the request is already locked, the device driver will
    return BLK_STS_ZONE_RESOURCE and the request will be pushed back to the
    hctx dipatch queue. The queue will be marked as RESTART in
    dd_finish_request() and restarted in __blk_mq_free_request(). However, this
    restart applies to the hctx of the completed request. If the requeued
    request is on a different hctx, dispatch will no be retried until another
    request is submitted or the next periodic queue run triggers, leading to up
    to 30 seconds latency for the requeued request.
    
    Fix this problem by scheduling a queue restart similarly to the
    BLK_STS_RESOURCE case or when we cannot get the budget.
    
    Also, consolidate the checks into the "need_resource" variable to simplify
    the condition.
    
    Signed-off-by: Naohiro Aota <naohiro.aota at wdc.com>
    Reviewed-by: Christoph Hellwig <hch at lst.de>
    Cc: Niklas Cassel <Niklas.Cassel at wdc.com>
    Link: https://lore.kernel.org/r/20211026165127.4151055-1-naohiro.aota@wdc.com
    Signed-off-by: Jens Axboe <axboe at kernel.dk>

diff --git a/block/blk-mq.c b/block/blk-mq.c
index bc026372de43..652a31fc3bb3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1325,6 +1325,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
 	int errors, queued;
 	blk_status_t ret = BLK_STS_OK;
 	LIST_HEAD(zone_list);
+	bool needs_resource = false;
 
 	if (list_empty(list))
 		return false;
@@ -1370,6 +1371,8 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
 			queued++;
 			break;
 		case BLK_STS_RESOURCE:
+			needs_resource = true;
+			fallthrough;
 		case BLK_STS_DEV_RESOURCE:
 			blk_mq_handle_dev_resource(rq, list);
 			goto out;
@@ -1380,6 +1383,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
 			 * accept.
 			 */
 			blk_mq_handle_zone_resource(rq, &zone_list);
+			needs_resource = true;
 			break;
 		default:
 			errors++;
@@ -1406,7 +1410,6 @@ out:
 		/* For non-shared tags, the RESTART check will suffice */
 		bool no_tag = prep == PREP_DISPATCH_NO_TAG &&
 			(hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED);
-		bool no_budget_avail = prep == PREP_DISPATCH_NO_BUDGET;
 
 		if (nr_budgets)
 			blk_mq_release_budgets(q, list);
@@ -1447,14 +1450,16 @@ out:
 		 * If driver returns BLK_STS_RESOURCE and SCHED_RESTART
 		 * bit is set, run queue after a delay to avoid IO stalls
 		 * that could otherwise occur if the queue is idle.  We'll do
-		 * similar if we couldn't get budget and SCHED_RESTART is set.
+		 * similar if we couldn't get budget or couldn't lock a zone
+		 * and SCHED_RESTART is set.
 		 */
 		needs_restart = blk_mq_sched_needs_restart(hctx);
+		if (prep == PREP_DISPATCH_NO_BUDGET)
+			needs_resource = true;
 		if (!needs_restart ||
 		    (no_tag && list_empty_careful(&hctx->dispatch_wait.entry)))
 			blk_mq_run_hw_queue(hctx, true);
-		else if (needs_restart && (ret == BLK_STS_RESOURCE ||
-					   no_budget_avail))
+		else if (needs_restart && needs_resource)
 			blk_mq_delay_run_hw_queue(hctx, BLK_MQ_RESOURCE_DELAY);
 
 		blk_mq_update_dispatch_busy(hctx, true);
commit 440ffcdd9db4758f1503a25fb49a8e15ca83d6bc
Merge: 19fa0887c57d 54713c85f536
Author: Jakub Kicinski <kuba at kernel.org>
Date:   Tue Oct 26 14:38:54 2021 -0700

    Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
    
    Daniel Borkmann says:
    
    ====================
    pull-request: bpf 2021-10-26
    
    We've added 12 non-merge commits during the last 7 day(s) which contain
    a total of 23 files changed, 118 insertions(+), 98 deletions(-).
    
    The main changes are:
    
    1) Fix potential race window in BPF tail call compatibility check, from Toke Høiland-Jørgensen.
    
    2) Fix memory leak in cgroup fs due to missing cgroup_bpf_offline(), from Quanyang Wang.
    
    3) Fix file descriptor reference counting in generic_map_update_batch(), from Xu Kuohai.
    
    4) Fix bpf_jit_limit knob to the max supported limit by the arch's JIT, from Lorenz Bauer.
    
    5) Fix BPF sockmap ->poll callbacks for UDP and AF_UNIX sockets, from Cong Wang and Yucong Sun.
    
    6) Fix BPF sockmap concurrency issue in TCP on non-blocking sendmsg calls, from Liu Jian.
    
    7) Fix build failure of INODE_STORAGE and TASK_STORAGE maps on !CONFIG_NET, from Tejun Heo.
    
    * https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
      bpf: Fix potential race in tail call compatibility check
      bpf: Move BPF_MAP_TYPE for INODE_STORAGE and TASK_STORAGE outside of CONFIG_NET
      selftests/bpf: Use recv_timeout() instead of retries
      net: Implement ->sock_is_readable() for UDP and AF_UNIX
      skmsg: Extract and reuse sk_msg_is_readable()
      net: Rename ->stream_memory_read to ->sock_is_readable
      tcp_bpf: Fix one concurrency problem in the tcp_bpf_send_verdict function
      cgroup: Fix memory leak caused by missing cgroup_bpf_offline
      bpf: Fix error usage of map_fd and fdget() in generic_map_update_batch()
      bpf: Prevent increasing bpf_jit_limit above max
      bpf: Define bpf_jit_alloc_exec_limit for arm64 JIT
      bpf: Define bpf_jit_alloc_exec_limit for riscv JIT
    ====================
    
    Link: https://lore.kernel.org/r/20211026201920.11296-1-daniel@iogearbox.net
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

commit 54713c85f536048e685258f880bf298a74c3620d
Author: Toke Høiland-Jørgensen <toke at redhat.com>
Date:   Tue Oct 26 13:00:19 2021 +0200

    bpf: Fix potential race in tail call compatibility check
    
    Lorenzo noticed that the code testing for program type compatibility of
    tail call maps is potentially racy in that two threads could encounter a
    map with an unset type simultaneously and both return true even though they
    are inserting incompatible programs.
    
    The race window is quite small, but artificially enlarging it by adding a
    usleep_range() inside the check in bpf_prog_array_compatible() makes it
    trivial to trigger from userspace with a program that does, essentially:
    
            map_fd = bpf_create_map(BPF_MAP_TYPE_PROG_ARRAY, 4, 4, 2, 0);
            pid = fork();
            if (pid) {
                    key = 0;
                    value = xdp_fd;
            } else {
                    key = 1;
                    value = tc_fd;
            }
            err = bpf_map_update_elem(map_fd, &key, &value, 0);
    
    While the race window is small, it has potentially serious ramifications in
    that triggering it would allow a BPF program to tail call to a program of a
    different type. So let's get rid of it by protecting the update with a
    spinlock. The commit in the Fixes tag is the last commit that touches the
    code in question.
    
    v2:
    - Use a spinlock instead of an atomic variable and cmpxchg() (Alexei)
    v3:
    - Put lock and the members it protects into an embedded 'owner' struct (Daniel)
    
    Fixes: 3324b584b6f6 ("ebpf: misc core cleanup")
    Reported-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
    Signed-off-by: Toke Høiland-Jørgensen <toke at redhat.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Link: https://lore.kernel.org/bpf/20211026110019.363464-1-toke@redhat.com

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 020a7d5bf470..3db6f6c95489 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -929,8 +929,11 @@ struct bpf_array_aux {
 	 * stored in the map to make sure that all callers and callees have
 	 * the same prog type and JITed flag.
 	 */
-	enum bpf_prog_type type;
-	bool jited;
+	struct {
+		spinlock_t lock;
+		enum bpf_prog_type type;
+		bool jited;
+	} owner;
 	/* Programs with direct jumps into programs part of this array. */
 	struct list_head poke_progs;
 	struct bpf_map *map;
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index cebd4fb06d19..447def540544 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -1072,6 +1072,7 @@ static struct bpf_map *prog_array_map_alloc(union bpf_attr *attr)
 	INIT_WORK(&aux->work, prog_array_map_clear_deferred);
 	INIT_LIST_HEAD(&aux->poke_progs);
 	mutex_init(&aux->poke_mutex);
+	spin_lock_init(&aux->owner.lock);
 
 	map = array_map_alloc(attr);
 	if (IS_ERR(map)) {
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index c1e7eb3f1876..6e3ae90ad107 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1823,20 +1823,26 @@ static unsigned int __bpf_prog_ret0_warn(const void *ctx,
 bool bpf_prog_array_compatible(struct bpf_array *array,
 			       const struct bpf_prog *fp)
 {
+	bool ret;
+
 	if (fp->kprobe_override)
 		return false;
 
-	if (!array->aux->type) {
+	spin_lock(&array->aux->owner.lock);
+
+	if (!array->aux->owner.type) {
 		/* There's no owner yet where we could check for
 		 * compatibility.
 		 */
-		array->aux->type  = fp->type;
-		array->aux->jited = fp->jited;
-		return true;
+		array->aux->owner.type  = fp->type;
+		array->aux->owner.jited = fp->jited;
+		ret = true;
+	} else {
+		ret = array->aux->owner.type  == fp->type &&
+		      array->aux->owner.jited == fp->jited;
 	}
-
-	return array->aux->type  == fp->type &&
-	       array->aux->jited == fp->jited;
+	spin_unlock(&array->aux->owner.lock);
+	return ret;
 }
 
 static int bpf_check_tail_call(const struct bpf_prog *fp)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 9dab49d3f394..1cad6979a0d0 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -543,8 +543,10 @@ static void bpf_map_show_fdinfo(struct seq_file *m, struct file *filp)
 
 	if (map->map_type == BPF_MAP_TYPE_PROG_ARRAY) {
 		array = container_of(map, struct bpf_array, map);
-		type  = array->aux->type;
-		jited = array->aux->jited;
+		spin_lock(&array->aux->owner.lock);
+		type  = array->aux->owner.type;
+		jited = array->aux->owner.jited;
+		spin_unlock(&array->aux->owner.lock);
 	}
 
 	seq_printf(m,
commit 99d0a3831e3500d945162cdb2310e3a5fce90b60
Author: Tejun Heo <tj at kernel.org>
Date:   Thu Oct 21 08:46:10 2021 -1000

    bpf: Move BPF_MAP_TYPE for INODE_STORAGE and TASK_STORAGE outside of CONFIG_NET
    
    bpf_types.h has BPF_MAP_TYPE_INODE_STORAGE and BPF_MAP_TYPE_TASK_STORAGE
    declared inside #ifdef CONFIG_NET although they are built regardless of
    CONFIG_NET. So, when CONFIG_BPF_SYSCALL && !CONFIG_NET, they are built
    without the declarations leading to spurious build failures and not
    registered to bpf_map_types making them unavailable.
    
    Fix it by moving the BPF_MAP_TYPE for the two map types outside of
    CONFIG_NET.
    
    Reported-by: kernel test robot <lkp at intel.com>
    Fixes: a10787e6d58c ("bpf: Enable task local storage for tracing programs")
    Signed-off-by: Tejun Heo <tj at kernel.org>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Acked-by: Martin KaFai Lau <kafai at fb.com>
    Link: https://lore.kernel.org/bpf/YXG1cuuSJDqHQfRY@slm.duckdns.org

diff --git a/include/linux/bpf_types.h b/include/linux/bpf_types.h
index 9c81724e4b98..bbe1eefa4c8a 100644
--- a/include/linux/bpf_types.h
+++ b/include/linux/bpf_types.h
@@ -101,14 +101,14 @@ BPF_MAP_TYPE(BPF_MAP_TYPE_STACK_TRACE, stack_trace_map_ops)
 #endif
 BPF_MAP_TYPE(BPF_MAP_TYPE_ARRAY_OF_MAPS, array_of_maps_map_ops)
 BPF_MAP_TYPE(BPF_MAP_TYPE_HASH_OF_MAPS, htab_of_maps_map_ops)
-#ifdef CONFIG_NET
-BPF_MAP_TYPE(BPF_MAP_TYPE_DEVMAP, dev_map_ops)
-BPF_MAP_TYPE(BPF_MAP_TYPE_DEVMAP_HASH, dev_map_hash_ops)
-BPF_MAP_TYPE(BPF_MAP_TYPE_SK_STORAGE, sk_storage_map_ops)
 #ifdef CONFIG_BPF_LSM
 BPF_MAP_TYPE(BPF_MAP_TYPE_INODE_STORAGE, inode_storage_map_ops)
 #endif
 BPF_MAP_TYPE(BPF_MAP_TYPE_TASK_STORAGE, task_storage_map_ops)
+#ifdef CONFIG_NET
+BPF_MAP_TYPE(BPF_MAP_TYPE_DEVMAP, dev_map_ops)
+BPF_MAP_TYPE(BPF_MAP_TYPE_DEVMAP_HASH, dev_map_hash_ops)
+BPF_MAP_TYPE(BPF_MAP_TYPE_SK_STORAGE, sk_storage_map_ops)
 BPF_MAP_TYPE(BPF_MAP_TYPE_CPUMAP, cpu_map_ops)
 #if defined(CONFIG_XDP_SOCKETS)
 BPF_MAP_TYPE(BPF_MAP_TYPE_XSKMAP, xsk_map_ops)
commit a94b5aae2a40b164f1d67c37f466f06cb1398ef0
Merge: cd9733f5d75c 67b821502dbd
Author: Alexei Starovoitov <ast at kernel.org>
Date:   Tue Oct 26 12:29:33 2021 -0700

    Merge branch 'sock_map: fix ->poll() and update selftests'
    
    Cong Wang says:
    
    ====================
    This patchset fixes ->poll() for sockets in sockmap and updates
    selftests accordingly with select(). Please check each patch
    for more details.
    
    Fixes: c50524ec4e3a ("Merge branch 'sockmap: add sockmap support for unix datagram socket'")
    Fixes: 89d69c5d0fbc ("Merge branch 'sockmap: introduce BPF_SK_SKB_VERDICT and support UDP'")
    Acked-by: John Fastabend <john.fastabend at gmail.com>
    
    ---
    v4: add a comment in udp_poll()
    
    v3: drop sk_psock_get_checked()
        reuse tcp_bpf_sock_is_readable()
    
    v2: rename and reuse ->stream_memory_read()
        fix a compile error in sk_psock_get_checked()
    
    Cong Wang (3):
      net: rename ->stream_memory_read to ->sock_is_readable
      skmsg: extract and reuse sk_msg_is_readable()
      net: implement ->sock_is_readable() for UDP and AF_UNIX
    
    ====================
    
    Reviewed-by: Jakub Sitnicki <jakub at cloudflare.com>
    Acked-by: John Fastabend <john.fastabend at gmail.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>

commit 67b821502dbd6c9b23715da79cb9b37fa7d969dc
Author: Yucong Sun <sunyucong at gmail.com>
Date:   Fri Oct 8 13:33:06 2021 -0700

    selftests/bpf: Use recv_timeout() instead of retries
    
    We use non-blocking sockets in those tests, retrying for
    EAGAIN is ugly because there is no upper bound for the packet
    arrival time, at least in theory. After we fix poll() on
    sockmap sockets, now we can switch to select()+recv().
    
    Signed-off-by: Yucong Sun <sunyucong at gmail.com>
    Signed-off-by: Cong Wang <cong.wang at bytedance.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Link: https://lore.kernel.org/bpf/20211008203306.37525-5-xiyou.wangcong@gmail.com

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
index 5c5979046523..d88bb65b74cc 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
@@ -949,7 +949,6 @@ static void redir_to_connected(int family, int sotype, int sock_mapfd,
 	int err, n;
 	u32 key;
 	char b;
-	int retries = 100;
 
 	zero_verdict_count(verd_mapfd);
 
@@ -1002,17 +1001,11 @@ static void redir_to_connected(int family, int sotype, int sock_mapfd,
 		goto close_peer1;
 	if (pass != 1)
 		FAIL("%s: want pass count 1, have %d", log_prefix, pass);
-again:
-	n = read(c0, &b, 1);
-	if (n < 0) {
-		if (errno == EAGAIN && retries--) {
-			usleep(1000);
-			goto again;
-		}
-		FAIL_ERRNO("%s: read", log_prefix);
-	}
+	n = recv_timeout(c0, &b, 1, 0, IO_TIMEOUT_SEC);
+	if (n < 0)
+		FAIL_ERRNO("%s: recv_timeout", log_prefix);
 	if (n == 0)
-		FAIL("%s: incomplete read", log_prefix);
+		FAIL("%s: incomplete recv", log_prefix);
 
 close_peer1:
 	xclose(p1);
@@ -1571,7 +1564,6 @@ static void unix_redir_to_connected(int sotype, int sock_mapfd,
 	const char *log_prefix = redir_mode_str(mode);
 	int c0, c1, p0, p1;
 	unsigned int pass;
-	int retries = 100;
 	int err, n;
 	int sfd[2];
 	u32 key;
@@ -1606,17 +1598,11 @@ static void unix_redir_to_connected(int sotype, int sock_mapfd,
 	if (pass != 1)
 		FAIL("%s: want pass count 1, have %d", log_prefix, pass);
 
-again:
-	n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
-	if (n < 0) {
-		if (errno == EAGAIN && retries--) {
-			usleep(1000);
-			goto again;
-		}
-		FAIL_ERRNO("%s: read", log_prefix);
-	}
+	n = recv_timeout(mode == REDIR_INGRESS ? p0 : c0, &b, 1, 0, IO_TIMEOUT_SEC);
+	if (n < 0)
+		FAIL_ERRNO("%s: recv_timeout", log_prefix);
 	if (n == 0)
-		FAIL("%s: incomplete read", log_prefix);
+		FAIL("%s: incomplete recv", log_prefix);
 
 close:
 	xclose(c1);
@@ -1748,7 +1734,6 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd,
 	const char *log_prefix = redir_mode_str(mode);
 	int c0, c1, p0, p1;
 	unsigned int pass;
-	int retries = 100;
 	int err, n;
 	u32 key;
 	char b;
@@ -1781,17 +1766,11 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd,
 	if (pass != 1)
 		FAIL("%s: want pass count 1, have %d", log_prefix, pass);
 
-again:
-	n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
-	if (n < 0) {
-		if (errno == EAGAIN && retries--) {
-			usleep(1000);
-			goto again;
-		}
-		FAIL_ERRNO("%s: read", log_prefix);
-	}
+	n = recv_timeout(mode == REDIR_INGRESS ? p0 : c0, &b, 1, 0, IO_TIMEOUT_SEC);
+	if (n < 0)
+		FAIL_ERRNO("%s: recv_timeout", log_prefix);
 	if (n == 0)
-		FAIL("%s: incomplete read", log_prefix);
+		FAIL("%s: incomplete recv", log_prefix);
 
 close_cli1:
 	xclose(c1);
@@ -1841,7 +1820,6 @@ static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd,
 	const char *log_prefix = redir_mode_str(mode);
 	int c0, c1, p0, p1;
 	unsigned int pass;
-	int retries = 100;
 	int err, n;
 	int sfd[2];
 	u32 key;
@@ -1876,17 +1854,11 @@ static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd,
 	if (pass != 1)
 		FAIL("%s: want pass count 1, have %d", log_prefix, pass);
 
-again:
-	n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
-	if (n < 0) {
-		if (errno == EAGAIN && retries--) {
-			usleep(1000);
-			goto again;
-		}
-		FAIL_ERRNO("%s: read", log_prefix);
-	}
+	n = recv_timeout(mode == REDIR_INGRESS ? p0 : c0, &b, 1, 0, IO_TIMEOUT_SEC);
+	if (n < 0)
+		FAIL_ERRNO("%s: recv_timeout", log_prefix);
 	if (n == 0)
-		FAIL("%s: incomplete read", log_prefix);
+		FAIL("%s: incomplete recv", log_prefix);
 
 close_cli1:
 	xclose(c1);
@@ -1932,7 +1904,6 @@ static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd,
 	int sfd[2];
 	u32 key;
 	char b;
-	int retries = 100;
 
 	zero_verdict_count(verd_mapfd);
 
@@ -1963,17 +1934,11 @@ static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd,
 	if (pass != 1)
 		FAIL("%s: want pass count 1, have %d", log_prefix, pass);
 
-again:
-	n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1);
-	if (n < 0) {
-		if (errno == EAGAIN && retries--) {
-			usleep(1000);
-			goto again;
-		}
-		FAIL_ERRNO("%s: read", log_prefix);
-	}
+	n = recv_timeout(mode == REDIR_INGRESS ? p0 : c0, &b, 1, 0, IO_TIMEOUT_SEC);
+	if (n < 0)
+		FAIL_ERRNO("%s: recv_timeout", log_prefix);
 	if (n == 0)
-		FAIL("%s: incomplete read", log_prefix);
+		FAIL("%s: incomplete recv", log_prefix);
 
 close:
 	xclose(c1);
commit af493388950b6ea3a86f860cfaffab137e024fc8
Author: Cong Wang <cong.wang at bytedance.com>
Date:   Fri Oct 8 13:33:05 2021 -0700

    net: Implement ->sock_is_readable() for UDP and AF_UNIX
    
    Yucong noticed we can't poll() sockets in sockmap even
    when they are the destination sockets of redirections.
    This is because we never poll any psock queues in ->poll(),
    except for TCP. With ->sock_is_readable() now we can
    overwrite >sock_is_readable(), invoke and implement it for
    both UDP and AF_UNIX sockets.
    
    Reported-by: Yucong Sun <sunyucong at gmail.com>
    Signed-off-by: Cong Wang <cong.wang at bytedance.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Link: https://lore.kernel.org/bpf/20211008203306.37525-4-xiyou.wangcong@gmail.com

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 8536b2a7210b..2fffcf2b54f3 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2867,6 +2867,9 @@ __poll_t udp_poll(struct file *file, struct socket *sock, poll_table *wait)
 	    !(sk->sk_shutdown & RCV_SHUTDOWN) && first_packet_length(sk) == -1)
 		mask &= ~(EPOLLIN | EPOLLRDNORM);
 
+	/* psock ingress_msg queue should not contain any bad checksum frames */
+	if (sk_is_readable(sk))
+		mask |= EPOLLIN | EPOLLRDNORM;
 	return mask;
 
 }
diff --git a/net/ipv4/udp_bpf.c b/net/ipv4/udp_bpf.c
index 7a1d5f473878..bbe6569c9ad3 100644
--- a/net/ipv4/udp_bpf.c
+++ b/net/ipv4/udp_bpf.c
@@ -114,6 +114,7 @@ static void udp_bpf_rebuild_protos(struct proto *prot, const struct proto *base)
 	*prot        = *base;
 	prot->close  = sock_map_close;
 	prot->recvmsg = udp_bpf_recvmsg;
+	prot->sock_is_readable = sk_msg_is_readable;
 }
 
 static void udp_bpf_check_v6_needs_rebuild(struct proto *ops)
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 89f9e85ae970..78e08e82c08c 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -3052,6 +3052,8 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa
 	/* readable? */
 	if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
 		mask |= EPOLLIN | EPOLLRDNORM;
+	if (sk_is_readable(sk))
+		mask |= EPOLLIN | EPOLLRDNORM;
 
 	/* Connection-based need to check for termination and startup */
 	if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) &&
@@ -3091,6 +3093,8 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
 	/* readable? */
 	if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
 		mask |= EPOLLIN | EPOLLRDNORM;
+	if (sk_is_readable(sk))
+		mask |= EPOLLIN | EPOLLRDNORM;
 
 	/* Connection-based need to check for termination and startup */
 	if (sk->sk_type == SOCK_SEQPACKET) {
diff --git a/net/unix/unix_bpf.c b/net/unix/unix_bpf.c
index b927e2baae50..452376c6f419 100644
--- a/net/unix/unix_bpf.c
+++ b/net/unix/unix_bpf.c
@@ -102,6 +102,7 @@ static void unix_dgram_bpf_rebuild_protos(struct proto *prot, const struct proto
 	*prot        = *base;
 	prot->close  = sock_map_close;
 	prot->recvmsg = unix_bpf_recvmsg;
+	prot->sock_is_readable = sk_msg_is_readable;
 }
 
 static void unix_stream_bpf_rebuild_protos(struct proto *prot,
@@ -110,6 +111,7 @@ static void unix_stream_bpf_rebuild_protos(struct proto *prot,
 	*prot        = *base;
 	prot->close  = sock_map_close;
 	prot->recvmsg = unix_bpf_recvmsg;
+	prot->sock_is_readable = sk_msg_is_readable;
 	prot->unhash  = sock_map_unhash;
 }
 
commit fb4e0a5e73d4bb5ab69b7905abd2ec3b580e9b59
Author: Cong Wang <cong.wang at bytedance.com>
Date:   Fri Oct 8 13:33:04 2021 -0700

    skmsg: Extract and reuse sk_msg_is_readable()
    
    tcp_bpf_sock_is_readable() is pretty much generic,
    we can extract it and reuse it for non-TCP sockets.
    
    Signed-off-by: Cong Wang <cong.wang at bytedance.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Link: https://lore.kernel.org/bpf/20211008203306.37525-3-xiyou.wangcong@gmail.com

diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h
index 14ab0c0bc924..1ce9a9eb223b 100644
--- a/include/linux/skmsg.h
+++ b/include/linux/skmsg.h
@@ -128,6 +128,7 @@ int sk_msg_memcopy_from_iter(struct sock *sk, struct iov_iter *from,
 			     struct sk_msg *msg, u32 bytes);
 int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
 		   int len, int flags);
+bool sk_msg_is_readable(struct sock *sk);
 
 static inline void sk_msg_check_to_free(struct sk_msg *msg, u32 i, u32 bytes)
 {
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index 2d6249b28928..a86ef7e844f8 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -474,6 +474,20 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
 }
 EXPORT_SYMBOL_GPL(sk_msg_recvmsg);
 
+bool sk_msg_is_readable(struct sock *sk)
+{
+	struct sk_psock *psock;
+	bool empty = true;
+
+	rcu_read_lock();
+	psock = sk_psock(sk);
+	if (likely(psock))
+		empty = list_empty(&psock->ingress_msg);
+	rcu_read_unlock();
+	return !empty;
+}
+EXPORT_SYMBOL_GPL(sk_msg_is_readable);
+
 static struct sk_msg *sk_psock_create_ingress_msg(struct sock *sk,
 						  struct sk_buff *skb)
 {
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 7e71e9e278cb..5f4d6f45d87f 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -150,19 +150,6 @@ int tcp_bpf_sendmsg_redir(struct sock *sk, struct sk_msg *msg,
 EXPORT_SYMBOL_GPL(tcp_bpf_sendmsg_redir);
 
 #ifdef CONFIG_BPF_SYSCALL
-static bool tcp_bpf_sock_is_readable(struct sock *sk)
-{
-	struct sk_psock *psock;
-	bool empty = true;
-
-	rcu_read_lock();
-	psock = sk_psock(sk);
-	if (likely(psock))
-		empty = list_empty(&psock->ingress_msg);
-	rcu_read_unlock();
-	return !empty;
-}
-
 static int tcp_msg_wait_data(struct sock *sk, struct sk_psock *psock,
 			     long timeo)
 {
@@ -491,7 +478,7 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS],
 	prot[TCP_BPF_BASE].unhash		= sock_map_unhash;
 	prot[TCP_BPF_BASE].close		= sock_map_close;
 	prot[TCP_BPF_BASE].recvmsg		= tcp_bpf_recvmsg;
-	prot[TCP_BPF_BASE].sock_is_readable	= tcp_bpf_sock_is_readable;
+	prot[TCP_BPF_BASE].sock_is_readable	= sk_msg_is_readable;
 
 	prot[TCP_BPF_TX]			= prot[TCP_BPF_BASE];
 	prot[TCP_BPF_TX].sendmsg		= tcp_bpf_sendmsg;
commit 7b50ecfcc6cdfe87488576bc3ed443dc8d083b90
Author: Cong Wang <cong.wang at bytedance.com>
Date:   Fri Oct 8 13:33:03 2021 -0700

    net: Rename ->stream_memory_read to ->sock_is_readable
    
    The proto ops ->stream_memory_read() is currently only used
    by TCP to check whether psock queue is empty or not. We need
    to rename it before reusing it for non-TCP protocols, and
    adjust the exsiting users accordingly.
    
    Signed-off-by: Cong Wang <cong.wang at bytedance.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Link: https://lore.kernel.org/bpf/20211008203306.37525-2-xiyou.wangcong@gmail.com

diff --git a/include/net/sock.h b/include/net/sock.h
index ea6fbc88c8f9..463f390d90b3 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1208,7 +1208,7 @@ struct proto {
 #endif
 
 	bool			(*stream_memory_free)(const struct sock *sk, int wake);
-	bool			(*stream_memory_read)(const struct sock *sk);
+	bool			(*sock_is_readable)(struct sock *sk);
 	/* Memory pressure */
 	void			(*enter_memory_pressure)(struct sock *sk);
 	void			(*leave_memory_pressure)(struct sock *sk);
@@ -2820,4 +2820,10 @@ void sock_set_sndtimeo(struct sock *sk, s64 secs);
 
 int sock_bind_add(struct sock *sk, struct sockaddr *addr, int addr_len);
 
+static inline bool sk_is_readable(struct sock *sk)
+{
+	if (sk->sk_prot->sock_is_readable)
+		return sk->sk_prot->sock_is_readable(sk);
+	return false;
+}
 #endif	/* _SOCK_H */
diff --git a/include/net/tls.h b/include/net/tls.h
index be4b3e1cac46..01d2e3744393 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -375,7 +375,7 @@ void tls_sw_release_resources_rx(struct sock *sk);
 void tls_sw_free_ctx_rx(struct tls_context *tls_ctx);
 int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 		   int nonblock, int flags, int *addr_len);
-bool tls_sw_stream_read(const struct sock *sk);
+bool tls_sw_sock_is_readable(struct sock *sk);
 ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
 			   struct pipe_inode_info *pipe,
 			   size_t len, unsigned int flags);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e8b48df73c85..f5c336f8b0c8 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -486,10 +486,7 @@ static bool tcp_stream_is_readable(struct sock *sk, int target)
 {
 	if (tcp_epollin_ready(sk, target))
 		return true;
-
-	if (sk->sk_prot->stream_memory_read)
-		return sk->sk_prot->stream_memory_read(sk);
-	return false;
+	return sk_is_readable(sk);
 }
 
 /*
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 9d068153c316..7e71e9e278cb 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -150,7 +150,7 @@ int tcp_bpf_sendmsg_redir(struct sock *sk, struct sk_msg *msg,
 EXPORT_SYMBOL_GPL(tcp_bpf_sendmsg_redir);
 
 #ifdef CONFIG_BPF_SYSCALL
-static bool tcp_bpf_stream_read(const struct sock *sk)
+static bool tcp_bpf_sock_is_readable(struct sock *sk)
 {
 	struct sk_psock *psock;
 	bool empty = true;
@@ -491,7 +491,7 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS],
 	prot[TCP_BPF_BASE].unhash		= sock_map_unhash;
 	prot[TCP_BPF_BASE].close		= sock_map_close;
 	prot[TCP_BPF_BASE].recvmsg		= tcp_bpf_recvmsg;
-	prot[TCP_BPF_BASE].stream_memory_read	= tcp_bpf_stream_read;
+	prot[TCP_BPF_BASE].sock_is_readable	= tcp_bpf_sock_is_readable;
 
 	prot[TCP_BPF_TX]			= prot[TCP_BPF_BASE];
 	prot[TCP_BPF_TX].sendmsg		= tcp_bpf_sendmsg;
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index fde56ff49163..9ab81db8a654 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -681,12 +681,12 @@ static void build_protos(struct proto prot[TLS_NUM_CONFIG][TLS_NUM_CONFIG],
 
 	prot[TLS_BASE][TLS_SW] = prot[TLS_BASE][TLS_BASE];
 	prot[TLS_BASE][TLS_SW].recvmsg		  = tls_sw_recvmsg;
-	prot[TLS_BASE][TLS_SW].stream_memory_read = tls_sw_stream_read;
+	prot[TLS_BASE][TLS_SW].sock_is_readable   = tls_sw_sock_is_readable;
 	prot[TLS_BASE][TLS_SW].close		  = tls_sk_proto_close;
 
 	prot[TLS_SW][TLS_SW] = prot[TLS_SW][TLS_BASE];
 	prot[TLS_SW][TLS_SW].recvmsg		= tls_sw_recvmsg;
-	prot[TLS_SW][TLS_SW].stream_memory_read	= tls_sw_stream_read;
+	prot[TLS_SW][TLS_SW].sock_is_readable   = tls_sw_sock_is_readable;
 	prot[TLS_SW][TLS_SW].close		= tls_sk_proto_close;
 
 #ifdef CONFIG_TLS_DEVICE
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 4feb95e34b64..d5d09bd817b7 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -2026,7 +2026,7 @@ splice_read_end:
 	return copied ? : err;
 }
 
-bool tls_sw_stream_read(const struct sock *sk)
+bool tls_sw_sock_is_readable(struct sock *sk)
 {
 	struct tls_context *tls_ctx = tls_get_ctx(sk);
 	struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);
commit cd9733f5d75c94a32544d6ce5be47e14194cf137
Author: Liu Jian <liujian56 at huawei.com>
Date:   Tue Oct 12 13:20:19 2021 +0800

    tcp_bpf: Fix one concurrency problem in the tcp_bpf_send_verdict function
    
    With two Msgs, msgA and msgB and a user doing nonblocking sendmsg calls (or
    multiple cores) on a single socket 'sk' we could get the following flow.
    
     msgA, sk                               msgB, sk
     -----------                            ---------------
     tcp_bpf_sendmsg()
     lock(sk)
     psock = sk->psock
                                            tcp_bpf_sendmsg()
                                            lock(sk) ... blocking
    tcp_bpf_send_verdict
    if (psock->eval == NONE)
       psock->eval = sk_psock_msg_verdict
     ..
     < handle SK_REDIRECT case >
       release_sock(sk)                     < lock dropped so grab here >
       ret = tcp_bpf_sendmsg_redir
                                            psock = sk->psock
                                            tcp_bpf_send_verdict
     lock_sock(sk) ... blocking on B
                                            if (psock->eval == NONE) <- boom.
                                             psock->eval will have msgA state
    
    The problem here is we dropped the lock on msgA and grabbed it with msgB.
    Now we have old state in psock and importantly psock->eval has not been
    cleared. So msgB will run whatever action was done on A and the verdict
    program may never see it.
    
    Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface")
    Signed-off-by: Liu Jian <liujian56 at huawei.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Acked-by: John Fastabend <john.fastabend at gmail.com>
    Link: https://lore.kernel.org/bpf/20211012052019.184398-1-liujian56@huawei.com

diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index d3e9386b493e..9d068153c316 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -232,6 +232,7 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,
 	bool cork = false, enospc = sk_msg_full(msg);
 	struct sock *sk_redir;
 	u32 tosend, delta = 0;
+	u32 eval = __SK_NONE;
 	int ret;
 
 more_data:
@@ -275,13 +276,24 @@ more_data:
 	case __SK_REDIRECT:
 		sk_redir = psock->sk_redir;
 		sk_msg_apply_bytes(psock, tosend);
+		if (!psock->apply_bytes) {
+			/* Clean up before releasing the sock lock. */
+			eval = psock->eval;
+			psock->eval = __SK_NONE;
+			psock->sk_redir = NULL;
+		}
 		if (psock->cork) {
 			cork = true;
 			psock->cork = NULL;
 		}
 		sk_msg_return(sk, msg, tosend);
 		release_sock(sk);
+
 		ret = tcp_bpf_sendmsg_redir(sk_redir, msg, tosend, flags);
+
+		if (eval == __SK_REDIRECT)
+			sock_put(sk_redir);
+
 		lock_sock(sk);
 		if (unlikely(ret < 0)) {
 			int free = sk_msg_free_nocharge(sk, msg);
commit 61b1d445f3bfe4c3ba4335ceeb7e8ba688fd31e2
Author: Mario <awxkrnl at gmail.com>
Date:   Tue Oct 26 13:27:37 2021 +0200

    drm: panel-orientation-quirks: Add quirk for GPD Win3
    
    Fixes screen orientation for GPD Win 3 handheld gaming console.
    
    Signed-off-by: Mario Risoldi <awxkrnl at gmail.com>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211026112737.9181-1-awxkrnl@gmail.com

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 30c17a76f49a..e1b2ce4921ae 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -191,6 +191,12 @@ static const struct dmi_system_id orientation_data[] = {
 		  DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"),
 		},
 		.driver_data = (void *)&gpd_win2,
+	}, {	/* GPD Win 3 */
+		.matches = {
+		  DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"),
+		  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1618-03")
+		},
+		.driver_data = (void *)&lcd720x1280_rightside_up,
 	}, {	/* I.T.Works TW891 */
 		.matches = {
 		  DMI_EXACT_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."),
commit cd004d8299f1dc6cfa6a4eea8f94cb45eaedf070
Author: Walter Stoll <walter.stoll at duagon.com>
Date:   Thu Oct 14 12:22:29 2021 +0200

    watchdog: Fix OMAP watchdog early handling
    
    TI's implementation does not service the watchdog even if the kernel
    command line parameter omap_wdt.early_enable is set to 1. This patch
    fixes the issue.
    
    Signed-off-by: Walter Stoll <walter.stoll at duagon.com>
    Reviewed-by: Guenter Roeck <linux at roeck-us.net>
    Link: https://lore.kernel.org/r/88a8fe5229cd68fa0f1fd22f5d66666c1b7057a0.camel@duagon.com
    Signed-off-by: Guenter Roeck <linux at roeck-us.net>
    Signed-off-by: Wim Van Sebroeck <wim at linux-watchdog.org>

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 1616f93dfad7..74d785b2b478 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -268,8 +268,12 @@ static int omap_wdt_probe(struct platform_device *pdev)
 			wdev->wdog.bootstatus = WDIOF_CARDRESET;
 	}
 
-	if (!early_enable)
+	if (early_enable) {
+		omap_wdt_start(&wdev->wdog);
+		set_bit(WDOG_HW_RUNNING, &wdev->wdog.status);
+	} else {
 		omap_wdt_disable(wdev);
+	}
 
 	ret = watchdog_register_device(&wdev->wdog);
 	if (ret) {
commit abd1c6adc16d1b82109a29b570fc545b775049d5
Author: Guenter Roeck <linux at roeck-us.net>
Date:   Fri Sep 10 21:29:25 2021 -0700

    watchdog: ixp4xx_wdt: Fix address space warning
    
    sparse reports the following address space warning.
    
    drivers/watchdog/ixp4xx_wdt.c:122:20: sparse:
            incorrect type in assignment (different address spaces)
    drivers/watchdog/ixp4xx_wdt.c:122:20: sparse:
            expected void [noderef] __iomem *base
    drivers/watchdog/ixp4xx_wdt.c:122:20: sparse:
            got void *platform_data
    
    Add a typecast to solve the problem.
    
    Fixes: 21a0a29d16c6 ("watchdog: ixp4xx: Rewrite driver to use core")
    Cc: Linus Walleij <linus.walleij at linaro.org>
    Reviewed-by: Linus Walleij <linus.walleij at linaro.org>
    Signed-off-by: Guenter Roeck <linux at roeck-us.net>
    Link: https://lore.kernel.org/r/20210911042925.556889-1-linux@roeck-us.net
    Signed-off-by: Wim Van Sebroeck <wim at linux-watchdog.org>

diff --git a/drivers/watchdog/ixp4xx_wdt.c b/drivers/watchdog/ixp4xx_wdt.c
index 2693ffb24ac7..31b03fa71341 100644
--- a/drivers/watchdog/ixp4xx_wdt.c
+++ b/drivers/watchdog/ixp4xx_wdt.c
@@ -119,7 +119,7 @@ static int ixp4xx_wdt_probe(struct platform_device *pdev)
 	iwdt = devm_kzalloc(dev, sizeof(*iwdt), GFP_KERNEL);
 	if (!iwdt)
 		return -ENOMEM;
-	iwdt->base = dev->platform_data;
+	iwdt->base = (void __iomem *)dev->platform_data;
 
 	/*
 	 * Retrieve rate from a fixed clock from the device tree if
commit bcc3e704f1b73f7f8674364f0bda6593bbc9fd2b
Author: Krzysztof Kozlowski <krzysztof.kozlowski at canonical.com>
Date:   Fri Sep 17 11:20:23 2021 +0200

    watchdog: sbsa: drop unneeded MODULE_ALIAS
    
    The MODULE_DEVICE_TABLE already creates proper alias for platform
    driver.  Having another MODULE_ALIAS causes the alias to be duplicated.
    
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski at canonical.com>
    Reviewed-by: Guenter Roeck <linux at roeck-us.net>
    Link: https://lore.kernel.org/r/20210917092024.19323-1-krzysztof.kozlowski@canonical.com
    Signed-off-by: Guenter Roeck <linux at roeck-us.net>
    Signed-off-by: Wim Van Sebroeck <wim at linux-watchdog.org>

diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
index 6f4319bdbc50..9791c74aebd4 100644
--- a/drivers/watchdog/sbsa_gwdt.c
+++ b/drivers/watchdog/sbsa_gwdt.c
@@ -411,4 +411,3 @@ MODULE_AUTHOR("Suravee Suthikulpanit <Suravee.Suthikulpanit at amd.com>");
 MODULE_AUTHOR("Al Stone <al.stone at linaro.org>");
 MODULE_AUTHOR("Timur Tabi <timur at codeaurora.org>");
 MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:" DRV_NAME);
commit f31afb502c3151855df3ed40f5974c7884c10d14
Author: Jamie Iles <quic_jiles at quicinc.com>
Date:   Fri Sep 3 12:21:01 2021 +0100

    watchdog: sbsa: only use 32-bit accessors
    
    SBSA says of the generic watchdog:
    
      All registers are 32 bits in size and should be accessed using 32-bit
      reads and writes. If an access size other than 32 bits is used then
      the results are IMPLEMENTATION DEFINED.
    
    and for qemu, the implementation will only allow 32-bit accesses
    resulting in a synchronous external abort when configuring the watchdog.
    Use lo_hi_* accessors rather than a readq/writeq.
    
    Fixes: abd3ac7902fb ("watchdog: sbsa: Support architecture version 1")
    Signed-off-by: Jamie Iles <quic_jiles at quicinc.com>
    Reviewed-by: Guenter Roeck <linux at roeck-us.net>
    Reviewed-by: Shaokun Zhang <zhangshaokun at hisilicon.com>
    Link: https://lore.kernel.org/r/20210903112101.493552-1-quic_jiles@quicinc.com
    Signed-off-by: Guenter Roeck <linux at roeck-us.net>
    Signed-off-by: Wim Van Sebroeck <wim at linux-watchdog.org>

diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
index ee9ff38929eb..6f4319bdbc50 100644
--- a/drivers/watchdog/sbsa_gwdt.c
+++ b/drivers/watchdog/sbsa_gwdt.c
@@ -130,7 +130,7 @@ static u64 sbsa_gwdt_reg_read(struct sbsa_gwdt *gwdt)
 	if (gwdt->version == 0)
 		return readl(gwdt->control_base + SBSA_GWDT_WOR);
 	else
-		return readq(gwdt->control_base + SBSA_GWDT_WOR);
+		return lo_hi_readq(gwdt->control_base + SBSA_GWDT_WOR);
 }
 
 static void sbsa_gwdt_reg_write(u64 val, struct sbsa_gwdt *gwdt)
@@ -138,7 +138,7 @@ static void sbsa_gwdt_reg_write(u64 val, struct sbsa_gwdt *gwdt)
 	if (gwdt->version == 0)
 		writel((u32)val, gwdt->control_base + SBSA_GWDT_WOR);
 	else
-		writeq(val, gwdt->control_base + SBSA_GWDT_WOR);
+		lo_hi_writeq(val, gwdt->control_base + SBSA_GWDT_WOR);
 }
 
 /*
commit 6e7733ef0bb9372d5491168635f6ecba8ac3cb8a
Author: Guenter Roeck <linux at roeck-us.net>
Date:   Thu Oct 7 17:33:02 2021 -0700

    Revert "watchdog: iTCO_wdt: Account for rebooting on second timeout"
    
    This reverts commit cb011044e34c ("watchdog: iTCO_wdt: Account for
    rebooting on second timeout") and commit aec42642d91f ("watchdog: iTCO_wdt:
    Fix detection of SMI-off case") since those patches cause a regression
    on certain boards (https://bugzilla.kernel.org/show_bug.cgi?id=213809).
    
    While this revert may result in some boards to only reset after twice
    the configured timeout value, that is still better than a watchdog reset
    after half the configured value.
    
    Fixes: cb011044e34c ("watchdog: iTCO_wdt: Account for rebooting on second timeout")
    Fixes: aec42642d91f ("watchdog: iTCO_wdt: Fix detection of SMI-off case")
    Cc: Jan Kiszka <jan.kiszka at siemens.com>
    Cc: Mantas Mikulėnas <grawity at gmail.com>
    Reported-by: Javier S. Pedro <debbugs at javispedro.com>
    Signed-off-by: Guenter Roeck <linux at roeck-us.net>
    Link: https://lore.kernel.org/r/20211008003302.1461733-1-linux@roeck-us.net
    Signed-off-by: Wim Van Sebroeck <wim at linux-watchdog.org>

diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 643c6c2d0b72..ced2fc0deb8c 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -71,8 +71,6 @@
 #define TCOBASE(p)	((p)->tco_res->start)
 /* SMI Control and Enable Register */
 #define SMI_EN(p)	((p)->smi_res->start)
-#define TCO_EN		(1 << 13)
-#define GBL_SMI_EN	(1 << 0)
 
 #define TCO_RLD(p)	(TCOBASE(p) + 0x00) /* TCO Timer Reload/Curr. Value */
 #define TCOv1_TMR(p)	(TCOBASE(p) + 0x01) /* TCOv1 Timer Initial Value*/
@@ -357,12 +355,8 @@ static int iTCO_wdt_set_timeout(struct watchdog_device *wd_dev, unsigned int t)
 
 	tmrval = seconds_to_ticks(p, t);
 
-	/*
-	 * If TCO SMIs are off, the timer counts down twice before rebooting.
-	 * Otherwise, the BIOS generally reboots when the SMI triggers.
-	 */
-	if (p->smi_res &&
-	    (inl(SMI_EN(p)) & (TCO_EN | GBL_SMI_EN)) != (TCO_EN | GBL_SMI_EN))
+	/* For TCO v1 the timer counts down twice before rebooting */
+	if (p->iTCO_version == 1)
 		tmrval /= 2;
 
 	/* from the specs: */
@@ -527,7 +521,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
 		 * Disables TCO logic generating an SMI#
 		 */
 		val32 = inl(SMI_EN(p));
-		val32 &= ~TCO_EN;	/* Turn off SMI clearing watchdog */
+		val32 &= 0xffffdfff;	/* Turn off SMI clearing watchdog */
 		outl(val32, SMI_EN(p));
 	}
 
commit 92b18252b91de567cd875f2e84722b10ab34ee28
Author: Wenbin Mei <wenbin.mei at mediatek.com>
Date:   Tue Oct 26 15:08:12 2021 +0800

    mmc: cqhci: clear HALT state after CQE enable
    
    While mmc0 enter suspend state, we need halt CQE to send legacy cmd(flush
    cache) and disable cqe, for resume back, we enable CQE and not clear HALT
    state.
    In this case MediaTek mmc host controller will keep the value for HALT
    state after CQE disable/enable flow, so the next CQE transfer after resume
    will be timeout due to CQE is in HALT state, the log as below:
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: timeout for tag 2
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: ============ CQHCI REGISTER DUMP ===========
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Caps:      0x100020b6 | Version:  0x00000510
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Config:    0x00001103 | Control:  0x00000001
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int stat:  0x00000000 | Int enab: 0x00000006
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int sig:   0x00000006 | Int Coal: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: TDL base:  0xfd05f000 | TDL up32: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Doorbell:  0x8000203c | TCN:      0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Task clr:  0x00000000 | SSC1:     0x00001000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: SSC2:      0x00000001 | DCMD rsp: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: RED mask:  0xfdf9a080 | TERRI:    0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Resp idx:  0x00000000 | Resp arg: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQP:     0x00000000 | CRNQDUN:  0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQIS:    0x00000000 | CRNQIE:   0x00000000
    
    This change check HALT state after CQE enable, if CQE is in HALT state, we
    will clear it.
    
    Signed-off-by: Wenbin Mei <wenbin.mei at mediatek.com>
    Cc: stable at vger.kernel.org
    Acked-by: Adrian Hunter <adrian.hunter at intel.com>
    Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
    Link: https://lore.kernel.org/r/20211026070812.9359-1-wenbin.mei@mediatek.com
    Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>

diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
index 38559a956330..31f841231609 100644
--- a/drivers/mmc/host/cqhci-core.c
+++ b/drivers/mmc/host/cqhci-core.c
@@ -282,6 +282,9 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
 
 	cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
 
+	if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT)
+		cqhci_writel(cq_host, 0, CQHCI_CTL);
+
 	mmc->cqe_on = true;
 
 	if (cq_host->ops->enable)
commit 8c8171929116cc23f74743d99251eedadf62341a
Author: Johan Hovold <johan at kernel.org>
Date:   Mon Oct 25 13:56:08 2021 +0200

    mmc: vub300: fix control-message timeouts
    
    USB control-message timeouts are specified in milliseconds and should
    specifically not vary with CONFIG_HZ.
    
    Fixes: 88095e7b473a ("mmc: Add new VUB300 USB-to-SD/SDIO/MMC driver")
    Cc: stable at vger.kernel.org      # 3.0
    Signed-off-by: Johan Hovold <johan at kernel.org>
    Link: https://lore.kernel.org/r/20211025115608.5287-1-johan@kernel.org
    Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>

diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
index 4950d10d3a19..97beece62fec 100644
--- a/drivers/mmc/host/vub300.c
+++ b/drivers/mmc/host/vub300.c
@@ -576,7 +576,7 @@ static void check_vub300_port_status(struct vub300_mmc_host *vub300)
 				GET_SYSTEM_PORT_STATUS,
 				USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 				0x0000, 0x0000, &vub300->system_port_status,
-				sizeof(vub300->system_port_status), HZ);
+				sizeof(vub300->system_port_status), 1000);
 	if (sizeof(vub300->system_port_status) == retval)
 		new_system_port_status(vub300);
 }
@@ -1241,7 +1241,7 @@ static void __download_offload_pseudocode(struct vub300_mmc_host *vub300,
 						SET_INTERRUPT_PSEUDOCODE,
 						USB_DIR_OUT | USB_TYPE_VENDOR |
 						USB_RECIP_DEVICE, 0x0000, 0x0000,
-						xfer_buffer, xfer_length, HZ);
+						xfer_buffer, xfer_length, 1000);
 			kfree(xfer_buffer);
 			if (retval < 0)
 				goto copy_error_message;
@@ -1284,7 +1284,7 @@ static void __download_offload_pseudocode(struct vub300_mmc_host *vub300,
 						SET_TRANSFER_PSEUDOCODE,
 						USB_DIR_OUT | USB_TYPE_VENDOR |
 						USB_RECIP_DEVICE, 0x0000, 0x0000,
-						xfer_buffer, xfer_length, HZ);
+						xfer_buffer, xfer_length, 1000);
 			kfree(xfer_buffer);
 			if (retval < 0)
 				goto copy_error_message;
@@ -1991,7 +1991,7 @@ static void __set_clock_speed(struct vub300_mmc_host *vub300, u8 buf[8],
 		usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
 				SET_CLOCK_SPEED,
 				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-				0x00, 0x00, buf, buf_array_size, HZ);
+				0x00, 0x00, buf, buf_array_size, 1000);
 	if (retval != 8) {
 		dev_err(&vub300->udev->dev, "SET_CLOCK_SPEED"
 			" %dkHz failed with retval=%d\n", kHzClock, retval);
@@ -2013,14 +2013,14 @@ static void vub300_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
 				SET_SD_POWER,
 				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-				0x0000, 0x0000, NULL, 0, HZ);
+				0x0000, 0x0000, NULL, 0, 1000);
 		/* must wait for the VUB300 u-proc to boot up */
 		msleep(600);
 	} else if ((ios->power_mode == MMC_POWER_UP) && !vub300->card_powered) {
 		usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
 				SET_SD_POWER,
 				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-				0x0001, 0x0000, NULL, 0, HZ);
+				0x0001, 0x0000, NULL, 0, 1000);
 		msleep(600);
 		vub300->card_powered = 1;
 	} else if (ios->power_mode == MMC_POWER_ON) {
@@ -2275,14 +2275,14 @@ static int vub300_probe(struct usb_interface *interface,
 				GET_HC_INF0,
 				USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 				0x0000, 0x0000, &vub300->hc_info,
-				sizeof(vub300->hc_info), HZ);
+				sizeof(vub300->hc_info), 1000);
 	if (retval < 0)
 		goto error5;
 	retval =
 		usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
 				SET_ROM_WAIT_STATES,
 				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-				firmware_rom_wait_states, 0x0000, NULL, 0, HZ);
+				firmware_rom_wait_states, 0x0000, NULL, 0, 1000);
 	if (retval < 0)
 		goto error5;
 	dev_info(&vub300->udev->dev,
@@ -2297,7 +2297,7 @@ static int vub300_probe(struct usb_interface *interface,
 				GET_SYSTEM_PORT_STATUS,
 				USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 				0x0000, 0x0000, &vub300->system_port_status,
-				sizeof(vub300->system_port_status), HZ);
+				sizeof(vub300->system_port_status), 1000);
 	if (retval < 0) {
 		goto error4;
 	} else if (sizeof(vub300->system_port_status) == retval) {
commit 697542bceae51f7620af333b065dd09d213629fb
Author: Jaehoon Chung <jh80.chung at samsung.com>
Date:   Fri Oct 22 17:21:06 2021 +0900

    mmc: dw_mmc: exynos: fix the finding clock sample value
    
    Even though there are candiates value if can't find best value, it's
    returned -EIO. It's not proper behavior.
    If there is not best value, use a first candiate value to work eMMC.
    
    Signed-off-by: Jaehoon Chung <jh80.chung at samsung.com>
    Tested-by: Marek Szyprowski <m.szyprowski at samsung.com>
    Tested-by: Christian Hewitt <christianshewitt at gmail.com>
    Cc: stable at vger.kernel.org
    Fixes: c537a1c5ff63 ("mmc: dw_mmc: exynos: add variable delay tuning sequence")
    Link: https://lore.kernel.org/r/20211022082106.1557-1-jh80.chung@samsung.com
    Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>

diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index 0c75810812a0..1f8a3c0ddfe1 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -464,6 +464,18 @@ static s8 dw_mci_exynos_get_best_clksmpl(u8 candiates)
 		}
 	}
 
+	/*
+	 * If there is no cadiates value, then it needs to return -EIO.
+	 * If there are candiates values and don't find bset clk sample value,
+	 * then use a first candiates clock sample value.
+	 */
+	for (i = 0; i < iter; i++) {
+		__c = ror8(candiates, i);
+		if ((__c & 0x1) == 0x1) {
+			loc = i;
+			goto out;
+		}
+	}
 out:
 	return loc;
 }
@@ -494,6 +506,8 @@ static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode)
 		priv->tuned_sample = found;
 	} else {
 		ret = -EIO;
+		dev_warn(&mmc->class_dev,
+			"There is no candiates value about clksmpl!\n");
 	}
 
 	return ret;
commit 05d5da3cb11c91c39e607066d3313a6ce621796a
Author: Christoph Niedermaier <cniedermaier at dh-electronics.com>
Date:   Mon Oct 25 09:37:06 2021 +0200

    MAINTAINERS: Add maintainers for DHCOM i.MX6 and DHCOM/DHCOR STM32MP1
    
    Add maintainers for DH electronics DHCOM i.MX6
    and DHCOM/DHCOR STM32MP1 boards.
    
    Signed-off-by: Christoph Niedermaier <cniedermaier at dh-electronics.com>
    Cc: linux-arm-kernel at lists.infradead.org
    Cc: kernel at dh-electronics.com
    Cc: arnd at arndb.de
    Link: https://lore.kernel.org/r/20211025073706.2794-1-cniedermaier@dh-electronics.com'
    To: soc at kernel.org
    To: linux-kernel at vger.kernel.org
    Signed-off-by: Arnd Bergmann <arnd at arndb.de>

diff --git a/MAINTAINERS b/MAINTAINERS
index 8d118d7957d2..6fbcb632649f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5458,6 +5458,19 @@ F:	include/net/devlink.h
 F:	include/uapi/linux/devlink.h
 F:	net/core/devlink.c
 
+DH ELECTRONICS IMX6 DHCOM BOARD SUPPORT
+M:	Christoph Niedermaier <cniedermaier at dh-electronics.com>
+L:	kernel at dh-electronics.com
+S:	Maintained
+F:	arch/arm/boot/dts/imx6*-dhcom-*
+
+DH ELECTRONICS STM32MP1 DHCOM/DHCOR BOARD SUPPORT
+M:	Marek Vasut <marex at denx.de>
+L:	kernel at dh-electronics.com
+S:	Maintained
+F:	arch/arm/boot/dts/stm32mp1*-dhcom-*
+F:	arch/arm/boot/dts/stm32mp1*-dhcor-*
+
 DIALOG SEMICONDUCTOR DRIVERS
 M:	Support Opensource <support.opensource at diasemi.com>
 S:	Supported
commit d308ae0d299a6bb15be4efb91849582d19c23213
Author: Ming Lei <ming.lei at redhat.com>
Date:   Tue Oct 26 18:12:04 2021 +0800

    block: drain queue after disk is removed from sysfs
    
    Before removing disk from sysfs, userspace still may change queue via
    sysfs, such as switching elevator or setting wbt latency, both may
    reinitialize wbt, then the warning in blk_free_queue_stats() will be
    triggered since rq_qos_exit() is moved to del_gendisk().
    
    Fixes the issue by moving draining queue & tearing down after disk is
    removed from sysfs, at that time no one can come into queue's
    store()/show().
    
    Reported-by: Yi Zhang <yi.zhang at redhat.com>
    Tested-by: Yi Zhang <yi.zhang at redhat.com>
    Fixes: 8e141f9eb803 ("block: drain file system I/O on del_gendisk")
    Signed-off-by: Ming Lei <ming.lei at redhat.com>
    Link: https://lore.kernel.org/r/20211026101204.2897166-1-ming.lei@redhat.com
    Signed-off-by: Jens Axboe <axboe at kernel.dk>

diff --git a/block/genhd.c b/block/genhd.c
index b49858550fa6..ab12ae6e636e 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -588,16 +588,6 @@ void del_gendisk(struct gendisk *disk)
 	 * Prevent new I/O from crossing bio_queue_enter().
 	 */
 	blk_queue_start_drain(q);
-	blk_mq_freeze_queue_wait(q);
-
-	rq_qos_exit(q);
-	blk_sync_queue(q);
-	blk_flush_integrity();
-	/*
-	 * Allow using passthrough request again after the queue is torn down.
-	 */
-	blk_queue_flag_clear(QUEUE_FLAG_INIT_DONE, q);
-	__blk_mq_unfreeze_queue(q, true);
 
 	if (!(disk->flags & GENHD_FL_HIDDEN)) {
 		sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");
@@ -620,6 +610,18 @@ void del_gendisk(struct gendisk *disk)
 		sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
 	pm_runtime_set_memalloc_noio(disk_to_dev(disk), false);
 	device_del(disk_to_dev(disk));
+
+	blk_mq_freeze_queue_wait(q);
+
+	rq_qos_exit(q);
+	blk_sync_queue(q);
+	blk_flush_integrity();
+	/*
+	 * Allow using passthrough request again after the queue is torn down.
+	 */
+	blk_queue_flag_clear(QUEUE_FLAG_INIT_DONE, q);
+	__blk_mq_unfreeze_queue(q, true);
+
 }
 EXPORT_SYMBOL(del_gendisk);
 
commit f44e8f91b89d42af0dd26f3b299a0c055d5737e0
Merge: 36b6dcbc1245 e091b836a3ba
Author: Arnd Bergmann <arnd at arndb.de>
Date:   Tue Oct 26 16:20:49 2021 +0200

    Merge tag 'qcom-arm64-fixes-for-5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into arm/fixes
    
    Qualcomm ARM64 DTS one more fix for 5.15
    
    This reverts a clock change in the Qualcomm RB5 devicetree which in some
    combinations of firmware and configuration causes the device to crash
    during boot.
    
    Data on an adjacent platform indicates that this is probably not be the
    root cause of the problem, but this resolves the regression seen on RB5
    and will allow the SM8250 platform to boot v5.15.
    
    * tag 'qcom-arm64-fixes-for-5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux:
      Revert "arm64: dts: qcom: sm8250: remove bus clock from the mdss node for sm8250 target"
    
    Link: https://lore.kernel.org/r/20211025201213.1145348-1-bjorn.andersson@linaro.org
    Signed-off-by: Arnd Bergmann <arnd at arndb.de>

commit 19fa0887c57d35b57bfb895e6caf8e72d9601ec0
Author: Vadym Kochan <vkochan at marvell.com>
Date:   Tue Oct 26 15:19:07 2021 +0300

    MAINTAINERS: please remove myself from the Prestera driver
    
    Signed-off-by: Vadym Kochan <vkochan at marvell.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/MAINTAINERS b/MAINTAINERS
index 8d118d7957d2..086f5c89216b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11278,7 +11278,6 @@ F:	Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
 F:	drivers/net/ethernet/marvell/octeontx2/af/
 
 MARVELL PRESTERA ETHERNET SWITCH DRIVER
-M:	Vadym Kochan <vkochan at marvell.com>
 M:	Taras Chornyi <tchornyi at marvell.com>
 S:	Supported
 W:	https://github.com/Marvell-switching/switchdev-prestera
commit db6c3c064f5d55fa9969f33eafca3cdbefbb3541
Author: Johan Hovold <johan at kernel.org>
Date:   Tue Oct 26 12:36:17 2021 +0200

    net: lan78xx: fix division by zero in send path
    
    Add the missing endpoint max-packet sanity check to probe() to avoid
    division by zero in lan78xx_tx_bh() in case a malicious device has
    broken descriptors (or when doing descriptor fuzz testing).
    
    Note that USB core will reject URBs submitted for endpoints with zero
    wMaxPacketSize but that drivers doing packet-size calculations still
    need to handle this (cf. commit 2548288b4fb0 ("USB: Fix: Don't skip
    endpoint descriptors with maxpacket=0")).
    
    Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
    Cc: stable at vger.kernel.org      # 4.3
    Cc: Woojung.Huh at microchip.com <Woojung.Huh at microchip.com>
    Signed-off-by: Johan Hovold <johan at kernel.org>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 793f8fbe0069..63cd72c5f580 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -4122,6 +4122,12 @@ static int lan78xx_probe(struct usb_interface *intf,
 
 	dev->maxpacket = usb_maxpacket(dev->udev, dev->pipe_out, 1);
 
+	/* Reject broken descriptors. */
+	if (dev->maxpacket == 0) {
+		ret = -ENODEV;
+		goto out4;
+	}
+
 	/* driver requires remote-wakeup capability during autosuspend. */
 	intf->needs_remote_wakeup = 1;
 
commit 6f68cd634856f8ca93bafd623ba5357e0f648c68
Author: Pavel Skripkin <paskripkin at gmail.com>
Date:   Sun Oct 24 16:13:56 2021 +0300

    net: batman-adv: fix error handling
    
    Syzbot reported ODEBUG warning in batadv_nc_mesh_free(). The problem was
    in wrong error handling in batadv_mesh_init().
    
    Before this patch batadv_mesh_init() was calling batadv_mesh_free() in case
    of any batadv_*_init() calls failure. This approach may work well, when
    there is some kind of indicator, which can tell which parts of batadv are
    initialized; but there isn't any.
    
    All written above lead to cleaning up uninitialized fields. Even if we hide
    ODEBUG warning by initializing bat_priv->nc.work, syzbot was able to hit
    GPF in batadv_nc_purge_paths(), because hash pointer in still NULL. [1]
    
    To fix these bugs we can unwind batadv_*_init() calls one by one.
    It is good approach for 2 reasons: 1) It fixes bugs on error handling
    path 2) It improves the performance, since we won't call unneeded
    batadv_*_free() functions.
    
    So, this patch makes all batadv_*_init() clean up all allocated memory
    before returning with an error to no call correspoing batadv_*_free()
    and open-codes batadv_mesh_free() with proper order to avoid touching
    uninitialized fields.
    
    Link: https://lore.kernel.org/netdev/000000000000c87fbd05cef6bcb0@google.com/ [1]
    Reported-and-tested-by: syzbot+28b0702ada0bf7381f58 at syzkaller.appspotmail.com
    Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
    Signed-off-by: Pavel Skripkin <paskripkin at gmail.com>
    Acked-by: Sven Eckelmann <sven at narfation.org>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 1669744304c5..17687848daec 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1560,10 +1560,14 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
 		return 0;
 
 	bat_priv->bla.claim_hash = batadv_hash_new(128);
-	bat_priv->bla.backbone_hash = batadv_hash_new(32);
+	if (!bat_priv->bla.claim_hash)
+		return -ENOMEM;
 
-	if (!bat_priv->bla.claim_hash || !bat_priv->bla.backbone_hash)
+	bat_priv->bla.backbone_hash = batadv_hash_new(32);
+	if (!bat_priv->bla.backbone_hash) {
+		batadv_hash_destroy(bat_priv->bla.claim_hash);
 		return -ENOMEM;
+	}
 
 	batadv_hash_set_lock_class(bat_priv->bla.claim_hash,
 				   &batadv_claim_hash_lock_class_key);
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 3ddd66e4c29e..5207cd8d6ad8 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -190,29 +190,41 @@ int batadv_mesh_init(struct net_device *soft_iface)
 
 	bat_priv->gw.generation = 0;
 
-	ret = batadv_v_mesh_init(bat_priv);
-	if (ret < 0)
-		goto err;
-
 	ret = batadv_originator_init(bat_priv);
-	if (ret < 0)
-		goto err;
+	if (ret < 0) {
+		atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
+		goto err_orig;
+	}
 
 	ret = batadv_tt_init(bat_priv);
-	if (ret < 0)
-		goto err;
+	if (ret < 0) {
+		atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
+		goto err_tt;
+	}
+
+	ret = batadv_v_mesh_init(bat_priv);
+	if (ret < 0) {
+		atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
+		goto err_v;
+	}
 
 	ret = batadv_bla_init(bat_priv);
-	if (ret < 0)
-		goto err;
+	if (ret < 0) {
+		atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
+		goto err_bla;
+	}
 
 	ret = batadv_dat_init(bat_priv);
-	if (ret < 0)
-		goto err;
+	if (ret < 0) {
+		atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
+		goto err_dat;
+	}
 
 	ret = batadv_nc_mesh_init(bat_priv);
-	if (ret < 0)
-		goto err;
+	if (ret < 0) {
+		atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
+		goto err_nc;
+	}
 
 	batadv_gw_init(bat_priv);
 	batadv_mcast_init(bat_priv);
@@ -222,8 +234,20 @@ int batadv_mesh_init(struct net_device *soft_iface)
 
 	return 0;
 
-err:
-	batadv_mesh_free(soft_iface);
+err_nc:
+	batadv_dat_free(bat_priv);
+err_dat:
+	batadv_bla_free(bat_priv);
+err_bla:
+	batadv_v_mesh_free(bat_priv);
+err_v:
+	batadv_tt_free(bat_priv);
+err_tt:
+	batadv_originator_free(bat_priv);
+err_orig:
+	batadv_purge_outstanding_packets(bat_priv, NULL);
+	atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
+
 	return ret;
 }
 
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index 9f06132e007d..0a7f1d36a6a8 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -152,8 +152,10 @@ int batadv_nc_mesh_init(struct batadv_priv *bat_priv)
 				   &batadv_nc_coding_hash_lock_class_key);
 
 	bat_priv->nc.decoding_hash = batadv_hash_new(128);
-	if (!bat_priv->nc.decoding_hash)
+	if (!bat_priv->nc.decoding_hash) {
+		batadv_hash_destroy(bat_priv->nc.coding_hash);
 		goto err;
+	}
 
 	batadv_hash_set_lock_class(bat_priv->nc.decoding_hash,
 				   &batadv_nc_decoding_hash_lock_class_key);
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index e0b3dace2020..4b7ad6684bc4 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -4162,8 +4162,10 @@ int batadv_tt_init(struct batadv_priv *bat_priv)
 		return ret;
 
 	ret = batadv_tt_global_init(bat_priv);
-	if (ret < 0)
+	if (ret < 0) {
+		batadv_tt_local_table_free(bat_priv);
 		return ret;
+	}
 
 	batadv_tvlv_handler_register(bat_priv, batadv_tt_tvlv_ogm_handler_v1,
 				     batadv_tt_tvlv_unicast_handler_v1,
commit fa40d9734a57bcbfa79a280189799f76c88f7bb0
Author: Max VA <maxv at sentinelone.com>
Date:   Mon Oct 25 17:31:53 2021 +0200

    tipc: fix size validations for the MSG_CRYPTO type
    
    The function tipc_crypto_key_rcv is used to parse MSG_CRYPTO messages
    to receive keys from other nodes in the cluster in order to decrypt any
    further messages from them.
    This patch verifies that any supplied sizes in the message body are
    valid for the received message.
    
    Fixes: 1ef6f7c9390f ("tipc: add automatic session key exchange")
    Signed-off-by: Max VA <maxv at sentinelone.com>
    Acked-by: Ying Xue <ying.xue at windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
    Acked-by: Jon Maloy <jmaloy at redhat.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
index c9391d38de85..dc60c32bb70d 100644
--- a/net/tipc/crypto.c
+++ b/net/tipc/crypto.c
@@ -2285,43 +2285,53 @@ static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr)
 	u16 key_gen = msg_key_gen(hdr);
 	u16 size = msg_data_sz(hdr);
 	u8 *data = msg_data(hdr);
+	unsigned int keylen;
+
+	/* Verify whether the size can exist in the packet */
+	if (unlikely(size < sizeof(struct tipc_aead_key) + TIPC_AEAD_KEYLEN_MIN)) {
+		pr_debug("%s: message data size is too small\n", rx->name);
+		goto exit;
+	}
+
+	keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));
+
+	/* Verify the supplied size values */
+	if (unlikely(size != keylen + sizeof(struct tipc_aead_key) ||
+		     keylen > TIPC_AEAD_KEY_SIZE_MAX)) {
+		pr_debug("%s: invalid MSG_CRYPTO key size\n", rx->name);
+		goto exit;
+	}
 
 	spin_lock(&rx->lock);
 	if (unlikely(rx->skey || (key_gen == rx->key_gen && rx->key.keys))) {
 		pr_err("%s: key existed <%p>, gen %d vs %d\n", rx->name,
 		       rx->skey, key_gen, rx->key_gen);
-		goto exit;
+		goto exit_unlock;
 	}
 
 	/* Allocate memory for the key */
 	skey = kmalloc(size, GFP_ATOMIC);
 	if (unlikely(!skey)) {
 		pr_err("%s: unable to allocate memory for skey\n", rx->name);
-		goto exit;
+		goto exit_unlock;
 	}
 
 	/* Copy key from msg data */
-	skey->keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));
+	skey->keylen = keylen;
 	memcpy(skey->alg_name, data, TIPC_AEAD_ALG_NAME);
 	memcpy(skey->key, data + TIPC_AEAD_ALG_NAME + sizeof(__be32),
 	       skey->keylen);
 
-	/* Sanity check */
-	if (unlikely(size != tipc_aead_key_size(skey))) {
-		kfree(skey);
-		skey = NULL;
-		goto exit;
-	}
-
 	rx->key_gen = key_gen;
 	rx->skey_mode = msg_key_mode(hdr);
 	rx->skey = skey;
 	rx->nokey = 0;
 	mb(); /* for nokey flag */
 
-exit:
+exit_unlock:
 	spin_unlock(&rx->lock);
 
+exit:
 	/* Schedule the key attaching on this crypto */
 	if (likely(skey && queue_delayed_work(tx->wq, &rx->work, 0)))
 		return true;
commit 2195f2062e4cc93870da8e71c318ef98a1c51cef
Author: Krzysztof Kozlowski <krzysztof.kozlowski at canonical.com>
Date:   Mon Oct 25 16:49:36 2021 +0200

    nfc: port100: fix using -ERRNO as command type mask
    
    During probing, the driver tries to get a list (mask) of supported
    command types in port100_get_command_type_mask() function.  The value
    is u64 and 0 is treated as invalid mask (no commands supported).  The
    function however returns also -ERRNO as u64 which will be interpret as
    valid command mask.
    
    Return 0 on every error case of port100_get_command_type_mask(), so the
    probing will stop.
    
    Cc: <stable at vger.kernel.org>
    Fixes: 0347a6ab300a ("NFC: port100: Commands mechanism implementation")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski at canonical.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
index 517376c43b86..16ceb763594f 100644
--- a/drivers/nfc/port100.c
+++ b/drivers/nfc/port100.c
@@ -1006,11 +1006,11 @@ static u64 port100_get_command_type_mask(struct port100 *dev)
 
 	skb = port100_alloc_skb(dev, 0);
 	if (!skb)
-		return -ENOMEM;
+		return 0;
 
 	resp = port100_send_cmd_sync(dev, PORT100_CMD_GET_COMMAND_TYPE, skb);
 	if (IS_ERR(resp))
-		return PTR_ERR(resp);
+		return 0;
 
 	if (resp->len < 8)
 		mask = 0;
commit eacd68b7ceaa82a5d15a286f727000cef898c0b0
Merge: 9122a70a6333 fd1b5beb177a
Author: David S. Miller <davem at davemloft.net>
Date:   Tue Oct 26 13:26:09 2021 +0100

    Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
    
    Tony Nguyen says:
    
    ====================
    Intel Wired LAN Driver Updates 2021-10-25
    
    This series contains updates to ice driver only.
    
    Dave adds event handler for LAG NETDEV_UNREGISTER to unlink device from
    link aggregate.
    
    Yongxin Liu adds a check for PTP support during release which would
    cause a call trace on non-PTP supported devices.
    ====================
    
    Signed-off-by: David S. Miller <davem at davemloft.net>

commit 9122a70a6333705c0c35614ddc51c274ed1d3637
Author: Cyril Strejc <cyril.strejc at skoda.cz>
Date:   Sun Oct 24 22:14:25 2021 +0200

    net: multicast: calculate csum of looped-back and forwarded packets
    
    During a testing of an user-space application which transmits UDP
    multicast datagrams and utilizes multicast routing to send the UDP
    datagrams out of defined network interfaces, I've found a multicast
    router does not fill-in UDP checksum into locally produced, looped-back
    and forwarded UDP datagrams, if an original output NIC the datagrams
    are sent to has UDP TX checksum offload enabled.
    
    The datagrams are sent malformed out of the NIC the datagrams have been
    forwarded to.
    
    It is because:
    
    1. If TX checksum offload is enabled on the output NIC, UDP checksum
       is not calculated by kernel and is not filled into skb data.
    
    2. dev_loopback_xmit(), which is called solely by
       ip_mc_finish_output(), sets skb->ip_summed = CHECKSUM_UNNECESSARY
       unconditionally.
    
    3. Since 35fc92a9 ("[NET]: Allow forwarding of ip_summed except
       CHECKSUM_COMPLETE"), the ip_summed value is preserved during
       forwarding.
    
    4. If ip_summed != CHECKSUM_PARTIAL, checksum is not calculated during
       a packet egress.
    
    The minimum fix in dev_loopback_xmit():
    
    1. Preserves skb->ip_summed CHECKSUM_PARTIAL. This is the
       case when the original output NIC has TX checksum offload enabled.
       The effects are:
    
         a) If the forwarding destination interface supports TX checksum
            offloading, the NIC driver is responsible to fill-in the
            checksum.
    
         b) If the forwarding destination interface does NOT support TX
            checksum offloading, checksums are filled-in by kernel before
            skb is submitted to the NIC driver.
    
         c) For local delivery, checksum validation is skipped as in the
            case of CHECKSUM_UNNECESSARY, thanks to skb_csum_unnecessary().
    
    2. Translates ip_summed CHECKSUM_NONE to CHECKSUM_UNNECESSARY. It
       means, for CHECKSUM_NONE, the behavior is unmodified and is there
       to skip a looped-back packet local delivery checksum validation.
    
    Signed-off-by: Cyril Strejc <cyril.strejc at skoda.cz>
    Reviewed-by: Willem de Bruijn <willemb at google.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/include/net/udp.h b/include/net/udp.h
index 360df454356c..909ecf447e0f 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -494,8 +494,9 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,
 	 * CHECKSUM_NONE in __udp_gso_segment. UDP GRO indeed builds partial
 	 * packets in udp_gro_complete_segment. As does UDP GSO, verified by
 	 * udp_send_skb. But when those packets are looped in dev_loopback_xmit
-	 * their ip_summed is set to CHECKSUM_UNNECESSARY. Reset in this
-	 * specific case, where PARTIAL is both correct and required.
+	 * their ip_summed CHECKSUM_NONE is changed to CHECKSUM_UNNECESSARY.
+	 * Reset in this specific case, where PARTIAL is both correct and
+	 * required.
 	 */
 	if (skb->pkt_type == PACKET_LOOPBACK)
 		skb->ip_summed = CHECKSUM_PARTIAL;
diff --git a/net/core/dev.c b/net/core/dev.c
index ea2366497697..eb3a366bf212 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3912,7 +3912,8 @@ int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
 	skb_reset_mac_header(skb);
 	__skb_pull(skb, skb_network_offset(skb));
 	skb->pkt_type = PACKET_LOOPBACK;
-	skb->ip_summed = CHECKSUM_UNNECESSARY;
+	if (skb->ip_summed == CHECKSUM_NONE)
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
 	WARN_ON(!skb_dst(skb));
 	skb_dst_force(skb);
 	netif_rx_ni(skb);
commit d81d0e41ed5fe7229a2c9a29d13bad288c7cf2d2
Author: Thomas Perrot <thomas.perrot at bootlin.com>
Date:   Fri Oct 22 16:21:04 2021 +0200

    spi: spl022: fix Microwire full duplex mode
    
    There are missing braces in the function that verify controller parameters,
    then an error is always returned when the parameter to select Microwire
    frames operation is used on devices allowing it.
    
    Signed-off-by: Thomas Perrot <thomas.perrot at bootlin.com>
    Link: https://lore.kernel.org/r/20211022142104.1386379-1-thomas.perrot@bootlin.com
    Signed-off-by: Mark Brown <broonie at kernel.org>

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index feebda66f56e..e4484ace584e 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1716,12 +1716,13 @@ static int verify_controller_parameters(struct pl022 *pl022,
 				return -EINVAL;
 			}
 		} else {
-			if (chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX)
+			if (chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX) {
 				dev_err(&pl022->adev->dev,
 					"Microwire half duplex mode requested,"
 					" but this is only available in the"
 					" ST version of PL022\n");
-			return -EINVAL;
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
commit 25e1f67eda4a19c91dc05c84d6d413c53efb447b
Author: Sagi Grimberg <sagi at grimberg.me>
Date:   Sun Oct 24 10:43:31 2021 +0300

    nvme-tcp: fix H2CData PDU send accounting (again)
    
    We should not access request members after the last send, even to
    determine if indeed it was the last data payload send. The reason is
    that a completion could have arrived and trigger a new execution of the
    request which overridden these members. This was fixed by commit
    825619b09ad3 ("nvme-tcp: fix possible use-after-completion").
    
    Commit e371af033c56 broke that assumption again to address cases where
    multiple r2t pdus are sent per request. To fix it, we need to record the
    request data_sent and data_len and after the payload network send we
    reference these counters to determine weather we should advance the
    request iterator.
    
    Fixes: e371af033c56 ("nvme-tcp: fix incorrect h2cdata pdu offset accounting")
    Reported-by: Keith Busch <kbusch at kernel.org>
    Cc: stable at vger.kernel.org # 5.10+
    Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
    Reviewed-by: Keith Busch <kbusch at kernel.org>
    Signed-off-by: Christoph Hellwig <hch at lst.de>

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 3c1c29dd3020..0626d14e6d4c 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -926,12 +926,14 @@ static void nvme_tcp_fail_request(struct nvme_tcp_request *req)
 static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
 {
 	struct nvme_tcp_queue *queue = req->queue;
+	int req_data_len = req->data_len;
 
 	while (true) {
 		struct page *page = nvme_tcp_req_cur_page(req);
 		size_t offset = nvme_tcp_req_cur_offset(req);
 		size_t len = nvme_tcp_req_cur_length(req);
 		bool last = nvme_tcp_pdu_last_send(req, len);
+		int req_data_sent = req->data_sent;
 		int ret, flags = MSG_DONTWAIT;
 
 		if (last && !queue->data_digest && !nvme_tcp_queue_more(queue))
@@ -958,7 +960,7 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
 		 * in the request where we don't want to modify it as we may
 		 * compete with the RX path completing the request.
 		 */
-		if (req->data_sent + ret < req->data_len)
+		if (req_data_sent + ret < req_data_len)
 			nvme_tcp_advance_req(req, ret);
 
 		/* fully successful last send in current PDU */
commit 926245c7d22271307606c88b1fbb2539a8550e94
Author: Maurizio Lombardi <mlombard at redhat.com>
Date:   Fri Oct 15 10:26:34 2021 +0200

    nvmet-tcp: fix a memory leak when releasing a queue
    
    page_frag_free() won't completely release the memory
    allocated for the commands, the cache page must be explicitly
    freed by calling __page_frag_cache_drain().
    
    This bug can be easily reproduced by repeatedly
    executing the following command on the initiator:
    
    $echo 1 > /sys/devices/virtual/nvme-fabrics/ctl/nvme0/reset_controller
    
    Signed-off-by: Maurizio Lombardi <mlombard at redhat.com>
    Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
    Reviewed-by: John Meneghini <jmeneghi at redhat.com>
    Signed-off-by: Christoph Hellwig <hch at lst.de>

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 07ee347ea3f3..c33a0464346f 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -1428,6 +1428,7 @@ static void nvmet_tcp_uninit_data_in_cmds(struct nvmet_tcp_queue *queue)
 
 static void nvmet_tcp_release_queue_work(struct work_struct *w)
 {
+	struct page *page;
 	struct nvmet_tcp_queue *queue =
 		container_of(w, struct nvmet_tcp_queue, release_work);
 
@@ -1447,6 +1448,8 @@ static void nvmet_tcp_release_queue_work(struct work_struct *w)
 		nvmet_tcp_free_crypto(queue);
 	ida_simple_remove(&nvmet_tcp_queue_ida, queue->idx);
 
+	page = virt_to_head_page(queue->pf_cache.va);
+	__page_frag_cache_drain(page, queue->pf_cache.pagecnt_bias);
 	kfree(queue);
 }
 
commit 6e6f96630805874fa80b0067e1a57aafc06225f6
Author: Imre Deak <imre.deak at intel.com>
Date:   Mon Oct 18 12:41:49 2021 +0300

    drm/i915/dp: Skip the HW readout of DPCD on disabled encoders
    
    Reading out the DP encoders' DPCD during booting or resume is only
    required for enabled encoders: such encoders may be modesetted during
    the initial commit and the link training this involves depends on an
    initialized DPCD. For DDI encoders reading out the DPCD is skipped, do
    the same on pre-DDI platforms.
    
    Atm, the first DPCD readout without a sink connected - which is a likely
    scneario if the encoder is disabled - leaves intel_dp->num_common_rates
    at 0, which resulted in
    
    intel_dp_sync_state()->intel_dp_max_common_rate()
    
    in a
    
    intel_dp->common_rates[-1]
    
    access. This by definition results in an undefined behaviour, though to
    my best knowledge in all HW/compiler configurations it actually results
    in accessing the array item type value preceding the array. In this
    case the preceding value happens to be intel_dp->num_common_rates,
    which is 0, so this issue - by luck - didn't cause a user visible
    problem.
    
    Nevertheless it's still an undefined behaviour and in CONFIG_UBSAN
    builds leads to a kernel BUG() (which revealed this problem for us),
    hence CC:stable.
    
    A related problem in case the encoder is enabled but the sink is not
    connected or the DPCD readout fails is fixed by the next patch.
    
    v2: Amend the commit message describing the root cause of the
        CONFIG_UBSAN BUG().
    
    Fixes: a532cde31de3 ("drm/i915/tc: Fix TypeC port init/resume time sanitization")
    References: https://gitlab.freedesktop.org/drm/intel/-/issues/4297
    Reported-and-tested-by: Mat Jonczyk <mat.jonczyk at o2.pl>
    Cc: Mat Jonczyk <mat.jonczyk at o2.pl>
    Cc: José Roberto de Souza <jose.souza at intel.com>
    Cc: Jani Nikula <jani.nikula at intel.com>
    Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Imre Deak <imre.deak at intel.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Acked-by: Jani Nikula <jani.nikula at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211018094154.1407705-2-imre.deak@intel.com
    (cherry picked from commit 4ec5ffc341cecbea060739aea1d53398ac2ec3f8)
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index abe3d61b6243..5cf152be4487 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -1916,6 +1916,9 @@ void intel_dp_sync_state(struct intel_encoder *encoder,
 {
 	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
+	if (!crtc_state)
+		return;
+
 	/*
 	 * Don't clobber DPCD if it's been already read out during output
 	 * setup (eDP) or detect.
commit 9761ffb8f1090289b908590039e2c363cc35cf45
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Thu Oct 14 12:09:40 2021 +0300

    drm/i915: Catch yet another unconditioal clflush
    
    Replace the unconditional clflush() with drm_clflush_virt_range()
    which does the wbinvd() fallback when clflush is not available.
    
    This time no justification is given for the clflush in the
    offending commit.
    
    Cc: stable at vger.kernel.org
    Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
    Cc: Thomas Hellström <thomas.hellstrom at linux.intel.com>
    Fixes: 2c8ab3339e39 ("drm/i915: Pin timeline map after first timeline pin, v4.")
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211014090941.12159-4-ville.syrjala@linux.intel.com
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    (cherry picked from commit 9ced12182d0d8401d821e9602e56e276459900fc)
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>

diff --git a/drivers/gpu/drm/i915/gt/intel_timeline.c b/drivers/gpu/drm/i915/gt/intel_timeline.c
index 23d7328892ed..438bbc7b8147 100644
--- a/drivers/gpu/drm/i915/gt/intel_timeline.c
+++ b/drivers/gpu/drm/i915/gt/intel_timeline.c
@@ -64,7 +64,7 @@ intel_timeline_pin_map(struct intel_timeline *timeline)
 
 	timeline->hwsp_map = vaddr;
 	timeline->hwsp_seqno = memset(vaddr + ofs, 0, TIMELINE_SEQNO_BYTES);
-	clflush(vaddr + ofs);
+	drm_clflush_virt_range(vaddr + ofs, TIMELINE_SEQNO_BYTES);
 
 	return 0;
 }
commit fcf918ffd3b35e288097036c04af7446b2c6f2f1
Author: Ville Syrjälä <ville.syrjala at linux.intel.com>
Date:   Thu Oct 14 12:09:39 2021 +0300

    drm/i915: Convert unconditional clflush to drm_clflush_virt_range()
    
    This one is apparently a "clflush for good measure", so bit more
    justification (if you can call it that) than some of the others.
    Convert to drm_clflush_virt_range() again so that machines without
    clflush will survive the ordeal.
    
    Cc: stable at vger.kernel.org
    Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
    Cc: Thomas Hellström <thomas.hellstrom at intel.com> #v1
    Fixes: 12ca695d2c1e ("drm/i915: Do not share hwsp across contexts any more, v8.")
    Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211014090941.12159-3-ville.syrjala@linux.intel.com
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    (cherry picked from commit af7b6d234eefa30c461cc16912bafb32b9e6141c)
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>

diff --git a/drivers/gpu/drm/i915/gt/intel_timeline.c b/drivers/gpu/drm/i915/gt/intel_timeline.c
index 1257f4f11e66..23d7328892ed 100644
--- a/drivers/gpu/drm/i915/gt/intel_timeline.c
+++ b/drivers/gpu/drm/i915/gt/intel_timeline.c
@@ -225,7 +225,7 @@ void intel_timeline_reset_seqno(const struct intel_timeline *tl)
 
 	memset(hwsp_seqno + 1, 0, TIMELINE_SEQNO_BYTES - sizeof(*hwsp_seqno));
 	WRITE_ONCE(*hwsp_seqno, tl->seqno);
-	clflush(hwsp_seqno);
+	drm_clflush_virt_range(hwsp_seqno, TIMELINE_SEQNO_BYTES);
 }
 
 void intel_timeline_enter(struct intel_timeline *tl)
commit 759635760a804b0d8ad0cc677b650f1544cae22f
Author: Ido Schimmel <idosch at nvidia.com>
Date:   Sun Oct 24 09:40:14 2021 +0300

    mlxsw: pci: Recycle received packet upon allocation failure
    
    When the driver fails to allocate a new Rx buffer, it passes an empty Rx
    descriptor (contains zero address and size) to the device and marks it
    as invalid by setting the skb pointer in the descriptor's metadata to
    NULL.
    
    After processing enough Rx descriptors, the driver will try to process
    the invalid descriptor, but will return immediately seeing that the skb
    pointer is NULL. Since the driver no longer passes new Rx descriptors to
    the device, the Rx queue will eventually become full and the device will
    start to drop packets.
    
    Fix this by recycling the received packet if allocation of the new
    packet failed. This means that allocation is no longer performed at the
    end of the Rx routine, but at the start, before tearing down the DMA
    mapping of the received packet.
    
    Remove the comment about the descriptor being zeroed as it is no longer
    correct. This is OK because we either use the descriptor as-is (when
    recycling) or overwrite its address and size fields with that of the
    newly allocated Rx buffer.
    
    The issue was discovered when a process ("perf") consumed too much
    memory and put the system under memory pressure. It can be reproduced by
    injecting slab allocation failures [1]. After the fix, the Rx queue no
    longer comes to a halt.
    
    [1]
     # echo 10 > /sys/kernel/debug/failslab/times
     # echo 1000 > /sys/kernel/debug/failslab/interval
     # echo 100 > /sys/kernel/debug/failslab/probability
    
     FAULT_INJECTION: forcing a failure.
     name failslab, interval 1000, probability 100, space 0, times 8
     [...]
     Call Trace:
      <IRQ>
      dump_stack_lvl+0x34/0x44
      should_fail.cold+0x32/0x37
      should_failslab+0x5/0x10
      kmem_cache_alloc_node+0x23/0x190
      __alloc_skb+0x1f9/0x280
      __netdev_alloc_skb+0x3a/0x150
      mlxsw_pci_rdq_skb_alloc+0x24/0x90
      mlxsw_pci_cq_tasklet+0x3dc/0x1200
      tasklet_action_common.constprop.0+0x9f/0x100
      __do_softirq+0xb5/0x252
      irq_exit_rcu+0x7a/0xa0
      common_interrupt+0x83/0xa0
      </IRQ>
      asm_common_interrupt+0x1e/0x40
     RIP: 0010:cpuidle_enter_state+0xc8/0x340
     [...]
     mlxsw_spectrum2 0000:06:00.0: Failed to alloc skb for RDQ
    
    Fixes: eda6500a987a ("mlxsw: Add PCI bus implementation")
    Signed-off-by: Ido Schimmel <idosch at nvidia.com>
    Reviewed-by: Petr Machata <petrm at nvidia.com>
    Link: https://lore.kernel.org/r/20211024064014.1060919-1-idosch@idosch.org
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index 13b0259f7ea6..fcace73eae40 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -353,13 +353,10 @@ static int mlxsw_pci_rdq_skb_alloc(struct mlxsw_pci *mlxsw_pci,
 	struct sk_buff *skb;
 	int err;
 
-	elem_info->u.rdq.skb = NULL;
 	skb = netdev_alloc_skb_ip_align(NULL, buf_len);
 	if (!skb)
 		return -ENOMEM;
 
-	/* Assume that wqe was previously zeroed. */
-
 	err = mlxsw_pci_wqe_frag_map(mlxsw_pci, wqe, 0, skb->data,
 				     buf_len, DMA_FROM_DEVICE);
 	if (err)
@@ -597,21 +594,26 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
 	struct pci_dev *pdev = mlxsw_pci->pdev;
 	struct mlxsw_pci_queue_elem_info *elem_info;
 	struct mlxsw_rx_info rx_info = {};
-	char *wqe;
+	char wqe[MLXSW_PCI_WQE_SIZE];
 	struct sk_buff *skb;
 	u16 byte_count;
 	int err;
 
 	elem_info = mlxsw_pci_queue_elem_info_consumer_get(q);
-	skb = elem_info->u.sdq.skb;
-	if (!skb)
-		return;
-	wqe = elem_info->elem;
-	mlxsw_pci_wqe_frag_unmap(mlxsw_pci, wqe, 0, DMA_FROM_DEVICE);
+	skb = elem_info->u.rdq.skb;
+	memcpy(wqe, elem_info->elem, MLXSW_PCI_WQE_SIZE);
 
 	if (q->consumer_counter++ != consumer_counter_limit)
 		dev_dbg_ratelimited(&pdev->dev, "Consumer counter does not match limit in RDQ\n");
 
+	err = mlxsw_pci_rdq_skb_alloc(mlxsw_pci, elem_info);
+	if (err) {
+		dev_err_ratelimited(&pdev->dev, "Failed to alloc skb for RDQ\n");
+		goto out;
+	}
+
+	mlxsw_pci_wqe_frag_unmap(mlxsw_pci, wqe, 0, DMA_FROM_DEVICE);
+
 	if (mlxsw_pci_cqe_lag_get(cqe_v, cqe)) {
 		rx_info.is_lag = true;
 		rx_info.u.lag_id = mlxsw_pci_cqe_lag_id_get(cqe_v, cqe);
@@ -647,10 +649,7 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
 	skb_put(skb, byte_count);
 	mlxsw_core_skb_receive(mlxsw_pci->core, skb, &rx_info);
 
-	memset(wqe, 0, q->elem_size);
-	err = mlxsw_pci_rdq_skb_alloc(mlxsw_pci, elem_info);
-	if (err)
-		dev_dbg_ratelimited(&pdev->dev, "Failed to alloc skb for RDQ\n");
+out:
 	/* Everything is set up, ring doorbell to pass elem to HW */
 	q->producer_counter++;
 	mlxsw_pci_queue_doorbell_producer_ring(mlxsw_pci, q);
commit 3dd60fb9d95db9c78fec86ba4df20852a7b974ba
Author: Christoph Hellwig <hch at lst.de>
Date:   Tue Oct 19 09:36:40 2021 +0200

    nvdimm/pmem: stop using q_usage_count as external pgmap refcount
    
    Originally all DAX access when through block_device operations and thus
    needed a queue reference.  But since commit cccbce671582
    ("filesystem-dax: convert to dax_direct_access()") all this happens at
    the DAX device level which uses its own refcounting.  Having the external
    refcount thus wasn't needed but has otherwise been harmless for long
    time.
    
    But now that "block: drain file system I/O on del_gendisk" waits for
    q_usage_count to reach 0 in del_gendisk this whole scheme can't work
    anymore (and pmem is the only driver abusing q_usage_count like that).
    So switch to the internal reference and remove the unbalanced
    blk_freeze_queue_start that is taken care of by del_gendisk.
    
    Fixes: 8e141f9eb803 ("block: drain file system I/O on del_gendisk")
    Reported-by: Yi Zhang <yi.zhang at redhat.com>
    Signed-off-by: Christoph Hellwig <hch at lst.de>
    Link: https://lore.kernel.org/r/20211019073641.2323410-2-hch@lst.de
    Signed-off-by: Dan Williams <dan.j.williams at intel.com>

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index ef4950f80832..054154c22899 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -333,26 +333,6 @@ static const struct attribute_group *pmem_attribute_groups[] = {
 	NULL,
 };
 
-static void pmem_pagemap_cleanup(struct dev_pagemap *pgmap)
-{
-	struct pmem_device *pmem = pgmap->owner;
-
-	blk_cleanup_disk(pmem->disk);
-}
-
-static void pmem_release_queue(void *pgmap)
-{
-	pmem_pagemap_cleanup(pgmap);
-}
-
-static void pmem_pagemap_kill(struct dev_pagemap *pgmap)
-{
-	struct request_queue *q =
-		container_of(pgmap->ref, struct request_queue, q_usage_counter);
-
-	blk_freeze_queue_start(q);
-}
-
 static void pmem_release_disk(void *__pmem)
 {
 	struct pmem_device *pmem = __pmem;
@@ -360,12 +340,9 @@ static void pmem_release_disk(void *__pmem)
 	kill_dax(pmem->dax_dev);
 	put_dax(pmem->dax_dev);
 	del_gendisk(pmem->disk);
-}
 
-static const struct dev_pagemap_ops fsdax_pagemap_ops = {
-	.kill			= pmem_pagemap_kill,
-	.cleanup		= pmem_pagemap_cleanup,
-};
+	blk_cleanup_disk(pmem->disk);
+}
 
 static int pmem_attach_disk(struct device *dev,
 		struct nd_namespace_common *ndns)
@@ -427,10 +404,8 @@ static int pmem_attach_disk(struct device *dev,
 	pmem->disk = disk;
 	pmem->pgmap.owner = pmem;
 	pmem->pfn_flags = PFN_DEV;
-	pmem->pgmap.ref = &q->q_usage_counter;
 	if (is_nd_pfn(dev)) {
 		pmem->pgmap.type = MEMORY_DEVICE_FS_DAX;
-		pmem->pgmap.ops = &fsdax_pagemap_ops;
 		addr = devm_memremap_pages(dev, &pmem->pgmap);
 		pfn_sb = nd_pfn->pfn_sb;
 		pmem->data_offset = le64_to_cpu(pfn_sb->dataoff);
@@ -444,16 +419,12 @@ static int pmem_attach_disk(struct device *dev,
 		pmem->pgmap.range.end = res->end;
 		pmem->pgmap.nr_range = 1;
 		pmem->pgmap.type = MEMORY_DEVICE_FS_DAX;
-		pmem->pgmap.ops = &fsdax_pagemap_ops;
 		addr = devm_memremap_pages(dev, &pmem->pgmap);
 		pmem->pfn_flags |= PFN_MAP;
 		bb_range = pmem->pgmap.range;
 	} else {
 		addr = devm_memremap(dev, pmem->phys_addr,
 				pmem->size, ARCH_MEMREMAP_PMEM);
-		if (devm_add_action_or_reset(dev, pmem_release_queue,
-					&pmem->pgmap))
-			return -ENOMEM;
 		bb_range.start =  res->start;
 		bb_range.end = res->end;
 	}
commit fd1b5beb177a8372cea2a0d014835491e4886f77
Author: Yongxin Liu <yongxin.liu at windriver.com>
Date:   Mon Oct 11 15:02:16 2021 +0800

    ice: check whether PTP is initialized in ice_ptp_release()
    
    PTP is currently only supported on E810 devices, it is checked
    in ice_ptp_init(). However, there is no check in ice_ptp_release().
    For other E800 series devices, ice_ptp_release() will be wrongly executed.
    
    Fix the following calltrace.
    
      INFO: trying to register non-static key.
      The code is fine but needs lockdep annotation, or maybe
      you didn't initialize this object before use?
      turning off the locking correctness validator.
      Workqueue: ice ice_service_task [ice]
      Call Trace:
       dump_stack_lvl+0x5b/0x82
       dump_stack+0x10/0x12
       register_lock_class+0x495/0x4a0
       ? find_held_lock+0x3c/0xb0
       __lock_acquire+0x71/0x1830
       lock_acquire+0x1e6/0x330
       ? ice_ptp_release+0x3c/0x1e0 [ice]
       ? _raw_spin_lock+0x19/0x70
       ? ice_ptp_release+0x3c/0x1e0 [ice]
       _raw_spin_lock+0x38/0x70
       ? ice_ptp_release+0x3c/0x1e0 [ice]
       ice_ptp_release+0x3c/0x1e0 [ice]
       ice_prepare_for_reset+0xcb/0xe0 [ice]
       ice_do_reset+0x38/0x110 [ice]
       ice_service_task+0x138/0xf10 [ice]
       ? __this_cpu_preempt_check+0x13/0x20
       process_one_work+0x26a/0x650
       worker_thread+0x3f/0x3b0
       ? __kthread_parkme+0x51/0xb0
       ? process_one_work+0x650/0x650
       kthread+0x161/0x190
       ? set_kthread_struct+0x40/0x40
       ret_from_fork+0x1f/0x30
    
    Fixes: 4dd0d5c33c3e ("ice: add lock around Tx timestamp tracker flush")
    Signed-off-by: Yongxin Liu <yongxin.liu at windriver.com>
    Reviewed-by: Jacob Keller <jacob.e.keller at intel.com>
    Tested-by: Gurucharan G <gurucharanx.g at intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen at intel.com>

diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index 80380aed8882..d1ef3d48a4b0 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -1571,6 +1571,9 @@ err_kworker:
  */
 void ice_ptp_release(struct ice_pf *pf)
 {
+	if (!test_bit(ICE_FLAG_PTP, pf->flags))
+		return;
+
 	/* Disable timestamping for both Tx and Rx */
 	ice_ptp_cfg_timestamp(pf, false);
 
commit 6a8b357278f5f8b9817147277ab8f12879dce8a8
Author: Dave Ertman <david.m.ertman at intel.com>
Date:   Thu Oct 7 08:40:31 2021 -0700

    ice: Respond to a NETDEV_UNREGISTER event for LAG
    
    When the PF is a member of a link aggregate, and the driver
    is removed, the process will hang unless we respond to the
    NETDEV_UNREGISTER event that is sent to the event_handler
    for LAG.
    
    Add a case statement for the ice_lag_event_handler to unlink
    the PF from the link aggregate.
    
    Also remove code that was incorrectly applying a dev_hold to
    peer_netdevs that were associated with the ice driver.
    
    Fixes: df006dd4b1dc ("ice: Add initial support framework for LAG")
    Signed-off-by: Dave Ertman <david.m.ertman at intel.com>
    Tested-by: Tony Brelinski <tony.brelinski at intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen at intel.com>

diff --git a/drivers/net/ethernet/intel/ice/ice_lag.c b/drivers/net/ethernet/intel/ice/ice_lag.c
index 37c18c66b5c7..e375ac849aec 100644
--- a/drivers/net/ethernet/intel/ice/ice_lag.c
+++ b/drivers/net/ethernet/intel/ice/ice_lag.c
@@ -100,9 +100,9 @@ static void ice_display_lag_info(struct ice_lag *lag)
  */
 static void ice_lag_info_event(struct ice_lag *lag, void *ptr)
 {
-	struct net_device *event_netdev, *netdev_tmp;
 	struct netdev_notifier_bonding_info *info;
 	struct netdev_bonding_info *bonding_info;
+	struct net_device *event_netdev;
 	const char *lag_netdev_name;
 
 	event_netdev = netdev_notifier_info_to_dev(ptr);
@@ -123,19 +123,6 @@ static void ice_lag_info_event(struct ice_lag *lag, void *ptr)
 		goto lag_out;
 	}
 
-	rcu_read_lock();
-	for_each_netdev_in_bond_rcu(lag->upper_netdev, netdev_tmp) {
-		if (!netif_is_ice(netdev_tmp))
-			continue;
-
-		if (netdev_tmp && netdev_tmp != lag->netdev &&
-		    lag->peer_netdev != netdev_tmp) {
-			dev_hold(netdev_tmp);
-			lag->peer_netdev = netdev_tmp;
-		}
-	}
-	rcu_read_unlock();
-
 	if (bonding_info->slave.state)
 		ice_lag_set_backup(lag);
 	else
@@ -319,6 +306,9 @@ ice_lag_event_handler(struct notifier_block *notif_blk, unsigned long event,
 	case NETDEV_BONDING_INFO:
 		ice_lag_info_event(lag, ptr);
 		break;
+	case NETDEV_UNREGISTER:
+		ice_lag_unlink(lag, ptr);
+		break;
 	default:
 		break;
 	}
commit e091b836a3baee4c8b1423a969589196b88a9e06
Author: Amit Pundir <amit.pundir at linaro.org>
Date:   Thu Oct 14 16:54:10 2021 +0300

    Revert "arm64: dts: qcom: sm8250: remove bus clock from the mdss node for sm8250 target"
    
    This reverts commit 001ce9785c0674d913531345e86222c965fc8bf4.
    
    This upstream commit broke AOSP (post Android 12 merge) build
    on RB5. The device either silently crashes into USB crash mode
    after android boot animation or we see a blank blue screen
    with following dpu errors in dmesg:
    
    [  T444] hw recovery is not complete for ctl:3
    [  T444] [drm:dpu_encoder_phys_vid_prepare_for_kickoff:539] [dpu error]enc31 intf1 ctl 3 reset failure: -22
    [  T444] [drm:dpu_encoder_phys_vid_wait_for_commit_done:513] [dpu error]vblank timeout
    [  T444] [drm:dpu_kms_wait_for_commit_done:454] [dpu error]wait for commit done returned -110
    [    C7] [drm:dpu_encoder_frame_done_timeout:2127] [dpu error]enc31 frame done timeout
    [  T444] [drm:dpu_encoder_phys_vid_wait_for_commit_done:513] [dpu error]vblank timeout
    [  T444] [drm:dpu_kms_wait_for_commit_done:454] [dpu error]wait for commit done returned -110
    
    Fixes: 001ce9785c06 ("arm64: dts: qcom: sm8250: remove bus clock from the mdss node for sm8250 target")
    Signed-off-by: Amit Pundir <amit.pundir at linaro.org>
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
    Signed-off-by: Bjorn Andersson <bjorn.andersson at linaro.org>
    Link: https://lore.kernel.org/r/20211014135410.4136412-1-dmitry.baryshkov@linaro.org

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 8c15d9fed08f..d12e4cbfc852 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2590,9 +2590,10 @@
 			power-domains = <&dispcc MDSS_GDSC>;
 
 			clocks = <&dispcc DISP_CC_MDSS_AHB_CLK>,
+				 <&gcc GCC_DISP_HF_AXI_CLK>,
 				 <&gcc GCC_DISP_SF_AXI_CLK>,
 				 <&dispcc DISP_CC_MDSS_MDP_CLK>;
-			clock-names = "iface", "nrt_bus", "core";
+			clock-names = "iface", "bus", "nrt_bus", "core";
 
 			assigned-clocks = <&dispcc DISP_CC_MDSS_MDP_CLK>;
 			assigned-clock-rates = <460000000>;
commit f7a1e76d0f608961cc2fc681f867a834f2746bce
Author: Xin Long <lucien.xin at gmail.com>
Date:   Mon Oct 25 02:31:48 2021 -0400

    net-sysfs: initialize uid and gid before calling net_ns_get_ownership
    
    Currently in net_ns_get_ownership() it may not be able to set uid or gid
    if make_kuid or make_kgid returns an invalid value, and an uninit-value
    issue can be triggered by this.
    
    This patch is to fix it by initializing the uid and gid before calling
    net_ns_get_ownership(), as it does in kobject_get_ownership()
    
    Fixes: e6dee9f3893c ("net-sysfs: add netdev_change_owner()")
    Reported-by: Paolo Abeni <pabeni at redhat.com>
    Signed-off-by: Xin Long <lucien.xin at gmail.com>
    Acked-by: Christian Brauner <christian.brauner at ubuntu.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index f6197774048b..b2e49eb7001d 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1973,9 +1973,9 @@ int netdev_register_kobject(struct net_device *ndev)
 int netdev_change_owner(struct net_device *ndev, const struct net *net_old,
 			const struct net *net_new)
 {
+	kuid_t old_uid = GLOBAL_ROOT_UID, new_uid = GLOBAL_ROOT_UID;
+	kgid_t old_gid = GLOBAL_ROOT_GID, new_gid = GLOBAL_ROOT_GID;
 	struct device *dev = &ndev->dev;
-	kuid_t old_uid, new_uid;
-	kgid_t old_gid, new_gid;
 	int error;
 
 	net_ns_get_ownership(net_old, &old_uid, &old_gid);
commit 042b2046d0f05cf8124c26ff65dbb6148a4404fb
Author: Dongli Zhang <dongli.zhang at oracle.com>
Date:   Fri Oct 22 16:31:39 2021 -0700

    xen/netfront: stop tx queues during live migration
    
    The tx queues are not stopped during the live migration. As a result, the
    ndo_start_xmit() may access netfront_info->queues which is freed by
    talk_to_netback()->xennet_destroy_queues().
    
    This patch is to netif_device_detach() at the beginning of xen-netfront
    resuming, and netif_device_attach() at the end of resuming.
    
         CPU A                                CPU B
    
     talk_to_netback()
     -> if (info->queues)
            xennet_destroy_queues(info);
        to free netfront_info->queues
    
                                            xennet_start_xmit()
                                            to access netfront_info->queues
    
      -> err = xennet_create_queues(info, &num_queues);
    
    The idea is borrowed from virtio-net.
    
    Cc: Joe Jin <joe.jin at oracle.com>
    Signed-off-by: Dongli Zhang <dongli.zhang at oracle.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index e31b98403f31..fc41ba95f81d 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1730,6 +1730,10 @@ static int netfront_resume(struct xenbus_device *dev)
 
 	dev_dbg(&dev->dev, "%s\n", dev->nodename);
 
+	netif_tx_lock_bh(info->netdev);
+	netif_device_detach(info->netdev);
+	netif_tx_unlock_bh(info->netdev);
+
 	xennet_disconnect_backend(info);
 	return 0;
 }
@@ -2349,6 +2353,10 @@ static int xennet_connect(struct net_device *dev)
 	 * domain a kick because we've probably just requeued some
 	 * packets.
 	 */
+	netif_tx_lock_bh(np->netdev);
+	netif_device_attach(np->netdev);
+	netif_tx_unlock_bh(np->netdev);
+
 	netif_carrier_on(np->netdev);
 	for (j = 0; j < num_queues; ++j) {
 		queue = &np->queues[j];
commit 0c57eeecc559ca6bc18b8c4e2808bc78dbe769b0
Author: Michael Chan <michael.chan at broadcom.com>
Date:   Mon Oct 25 05:05:28 2021 -0400

    net: Prevent infinite while loop in skb_tx_hash()
    
    Drivers call netdev_set_num_tc() and then netdev_set_tc_queue()
    to set the queue count and offset for each TC.  So the queue count
    and offset for the TCs may be zero for a short period after dev->num_tc
    has been set.  If a TX packet is being transmitted at this time in the
    code path netdev_pick_tx() -> skb_tx_hash(), skb_tx_hash() may see
    nonzero dev->num_tc but zero qcount for the TC.  The while loop that
    keeps looping while hash >= qcount will not end.
    
    Fix it by checking the TC's qcount to be nonzero before using it.
    
    Fixes: eadec877ce9c ("net: Add support for subordinate traffic classes to netdev_pick_tx")
    Reviewed-by: Andy Gospodarek <gospo at broadcom.com>
    Signed-off-by: Michael Chan <michael.chan at broadcom.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/net/core/dev.c b/net/core/dev.c
index 7ee9fecd3aff..ea2366497697 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3163,6 +3163,12 @@ static u16 skb_tx_hash(const struct net_device *dev,
 
 		qoffset = sb_dev->tc_to_txq[tc].offset;
 		qcount = sb_dev->tc_to_txq[tc].count;
+		if (unlikely(!qcount)) {
+			net_warn_ratelimited("%s: invalid qcount, qoffset %u for tc %u\n",
+					     sb_dev->name, qoffset, tc);
+			qoffset = 0;
+			qcount = dev->real_num_tx_queues;
+		}
 	}
 
 	if (skb_rx_queue_recorded(skb)) {
commit 64733956ebba7cc629856f4a6ee35a52bc9c023f
Author: Mark Zhang <markzhang at nvidia.com>
Date:   Sun Oct 24 09:08:20 2021 +0300

    RDMA/sa_query: Use strscpy_pad instead of memcpy to copy a string
    
    When copying the device name, the length of the data memcpy copied exceeds
    the length of the source buffer, which cause the KASAN issue below.  Use
    strscpy_pad() instead.
    
     BUG: KASAN: slab-out-of-bounds in ib_nl_set_path_rec_attrs+0x136/0x320 [ib_core]
     Read of size 64 at addr ffff88811a10f5e0 by task rping/140263
     CPU: 3 PID: 140263 Comm: rping Not tainted 5.15.0-rc1+ #1
     Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
     Call Trace:
      dump_stack_lvl+0x57/0x7d
      print_address_description.constprop.0+0x1d/0xa0
      kasan_report+0xcb/0x110
      kasan_check_range+0x13d/0x180
      memcpy+0x20/0x60
      ib_nl_set_path_rec_attrs+0x136/0x320 [ib_core]
      ib_nl_make_request+0x1c6/0x380 [ib_core]
      send_mad+0x20a/0x220 [ib_core]
      ib_sa_path_rec_get+0x3e3/0x800 [ib_core]
      cma_query_ib_route+0x29b/0x390 [rdma_cm]
      rdma_resolve_route+0x308/0x3e0 [rdma_cm]
      ucma_resolve_route+0xe1/0x150 [rdma_ucm]
      ucma_write+0x17b/0x1f0 [rdma_ucm]
      vfs_write+0x142/0x4d0
      ksys_write+0x133/0x160
      do_syscall_64+0x43/0x90
      entry_SYSCALL_64_after_hwframe+0x44/0xae
     RIP: 0033:0x7f26499aa90f
     Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 29 fd ff ff 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 5c fd ff ff 48
     RSP: 002b:00007f26495f2dc0 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
     RAX: ffffffffffffffda RBX: 00000000000007d0 RCX: 00007f26499aa90f
     RDX: 0000000000000010 RSI: 00007f26495f2e00 RDI: 0000000000000003
     RBP: 00005632a8315440 R08: 0000000000000000 R09: 0000000000000001
     R10: 0000000000000000 R11: 0000000000000293 R12: 00007f26495f2e00
     R13: 00005632a83154e0 R14: 00005632a8315440 R15: 00005632a830a810
    
     Allocated by task 131419:
      kasan_save_stack+0x1b/0x40
      __kasan_kmalloc+0x7c/0x90
      proc_self_get_link+0x8b/0x100
      pick_link+0x4f1/0x5c0
      step_into+0x2eb/0x3d0
      walk_component+0xc8/0x2c0
      link_path_walk+0x3b8/0x580
      path_openat+0x101/0x230
      do_filp_open+0x12e/0x240
      do_sys_openat2+0x115/0x280
      __x64_sys_openat+0xce/0x140
      do_syscall_64+0x43/0x90
      entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    Fixes: 2ca546b92a02 ("IB/sa: Route SA pathrecord query through netlink")
    Link: https://lore.kernel.org/r/72ede0f6dab61f7f23df9ac7a70666e07ef314b0.1635055496.git.leonro@nvidia.com
    Signed-off-by: Mark Zhang <markzhang at nvidia.com>
    Reviewed-by: Mark Bloch <mbloch at nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro at nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index a20b8108e160..c00f8e28aab7 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -706,8 +706,9 @@ static void ib_nl_set_path_rec_attrs(struct sk_buff *skb,
 
 	/* Construct the family header first */
 	header = skb_put(skb, NLMSG_ALIGN(sizeof(*header)));
-	memcpy(header->device_name, dev_name(&query->port->agent->device->dev),
-	       LS_DEVICE_NAME_MAX);
+	strscpy_pad(header->device_name,
+		    dev_name(&query->port->agent->device->dev),
+		    LS_DEVICE_NAME_MAX);
 	header->port_num = query->port->port_num;
 
 	if ((comp_mask & IB_SA_PATH_REC_REVERSIBLE) &&
commit ace19b992436a257d9a793672e57abc28fe83e2e
Author: Trevor Woerner <twoerner at gmail.com>
Date:   Sun Oct 24 13:50:02 2021 -0400

    net: nxp: lpc_eth.c: avoid hang when bringing interface down
    
    A hard hang is observed whenever the ethernet interface is brought
    down. If the PHY is stopped before the LPC core block is reset,
    the SoC will hang. Comparing lpc_eth_close() and lpc_eth_open() I
    re-arranged the ordering of the functions calls in lpc_eth_close() to
    reset the hardware before stopping the PHY.
    Fixes: b7370112f519 ("lpc32xx: Added ethernet driver")
    Signed-off-by: Trevor Woerner <twoerner at gmail.com>
    Acked-by: Vladimir Zapolskiy <vz at mleia.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index d29fe562b3de..c910fa2f40a4 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1015,9 +1015,6 @@ static int lpc_eth_close(struct net_device *ndev)
 	napi_disable(&pldat->napi);
 	netif_stop_queue(ndev);
 
-	if (ndev->phydev)
-		phy_stop(ndev->phydev);
-
 	spin_lock_irqsave(&pldat->lock, flags);
 	__lpc_eth_reset(pldat);
 	netif_carrier_off(ndev);
@@ -1025,6 +1022,8 @@ static int lpc_eth_close(struct net_device *ndev)
 	writel(0, LPC_ENET_MAC2(pldat->net_base));
 	spin_unlock_irqrestore(&pldat->lock, flags);
 
+	if (ndev->phydev)
+		phy_stop(ndev->phydev);
 	clk_disable_unprepare(pldat->clk);
 
 	return 0;
commit 689a0a9f505f7bffdefe6f17fddb41c8ab6344f6
Author: Janusz Dziedzic <janusz.dziedzic at gmail.com>
Date:   Sun Oct 24 22:15:46 2021 +0200

    cfg80211: correct bridge/4addr mode check
    
    Without the patch we fail:
    
    $ sudo brctl addbr br0
    $ sudo brctl addif br0 wlp1s0
    $ sudo iw wlp1s0 set 4addr on
    command failed: Device or resource busy (-16)
    
    Last command failed but iface was already in 4addr mode.
    
    Fixes: ad4bb6f8883a ("cfg80211: disallow bridging managed/adhoc interfaces")
    Signed-off-by: Janusz Dziedzic <janusz.dziedzic at gmail.com>
    Link: https://lore.kernel.org/r/20211024201546.614379-1-janusz.dziedzic@gmail.com
    [add fixes tag, fix indentation, edit commit log]
    Signed-off-by: Johannes Berg <johannes.berg at intel.com>

diff --git a/net/wireless/util.c b/net/wireless/util.c
index 18dba3d7c638..a1a99a574984 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1028,14 +1028,14 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
 	    !(rdev->wiphy.interface_modes & (1 << ntype)))
 		return -EOPNOTSUPP;
 
-	/* if it's part of a bridge, reject changing type to station/ibss */
-	if (netif_is_bridge_port(dev) &&
-	    (ntype == NL80211_IFTYPE_ADHOC ||
-	     ntype == NL80211_IFTYPE_STATION ||
-	     ntype == NL80211_IFTYPE_P2P_CLIENT))
-		return -EBUSY;
-
 	if (ntype != otype) {
+		/* if it's part of a bridge, reject changing type to station/ibss */
+		if (netif_is_bridge_port(dev) &&
+		    (ntype == NL80211_IFTYPE_ADHOC ||
+		     ntype == NL80211_IFTYPE_STATION ||
+		     ntype == NL80211_IFTYPE_P2P_CLIENT))
+			return -EBUSY;
+
 		dev->ieee80211_ptr->use_4addr = false;
 		dev->ieee80211_ptr->mesh_id_up_len = 0;
 		wdev_lock(dev->ieee80211_ptr);
commit 09b1d5dc6ce1c9151777f6c4e128a59457704c97
Author: Johannes Berg <johannes.berg at intel.com>
Date:   Mon Oct 25 13:31:12 2021 +0200

    cfg80211: fix management registrations locking
    
    The management registrations locking was broken, the list was
    locked for each wdev, but cfg80211_mgmt_registrations_update()
    iterated it without holding all the correct spinlocks, causing
    list corruption.
    
    Rather than trying to fix it with fine-grained locking, just
    move the lock to the wiphy/rdev (still need the list on each
    wdev), we already need to hold the wdev lock to change it, so
    there's no contention on the lock in any case. This trivially
    fixes the bug since we hold one wdev's lock already, and now
    will hold the lock that protects all lists.
    
    Cc: stable at vger.kernel.org
    Reported-by: Jouni Malinen <j at w1.fi>
    Fixes: 6cd536fe62ef ("cfg80211: change internal management frame registration API")
    Link: https://lore.kernel.org/r/20211025133111.5cf733eab0f4.I7b0abb0494ab712f74e2efcd24bb31ac33f7eee9@changeid
    Signed-off-by: Johannes Berg <johannes.berg at intel.com>

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 62dd8422e0dc..27336fc70467 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5376,7 +5376,6 @@ static inline void wiphy_unlock(struct wiphy *wiphy)
  *	netdev and may otherwise be used by driver read-only, will be update
  *	by cfg80211 on change_interface
  * @mgmt_registrations: list of registrations for management frames
- * @mgmt_registrations_lock: lock for the list
  * @mgmt_registrations_need_update: mgmt registrations were updated,
  *	need to propagate the update to the driver
  * @mtx: mutex used to lock data in this struct, may be used by drivers
@@ -5423,7 +5422,6 @@ struct wireless_dev {
 	u32 identifier;
 
 	struct list_head mgmt_registrations;
-	spinlock_t mgmt_registrations_lock;
 	u8 mgmt_registrations_need_update:1;
 
 	struct mutex mtx;
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 03323121ca50..aaba847d79eb 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -524,6 +524,7 @@ use_default_name:
 	INIT_WORK(&rdev->propagate_cac_done_wk, cfg80211_propagate_cac_done_wk);
 	INIT_WORK(&rdev->mgmt_registrations_update_wk,
 		  cfg80211_mgmt_registrations_update_wk);
+	spin_lock_init(&rdev->mgmt_registrations_lock);
 
 #ifdef CONFIG_CFG80211_DEFAULT_PS
 	rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
@@ -1279,7 +1280,6 @@ void cfg80211_init_wdev(struct wireless_dev *wdev)
 	INIT_LIST_HEAD(&wdev->event_list);
 	spin_lock_init(&wdev->event_lock);
 	INIT_LIST_HEAD(&wdev->mgmt_registrations);
-	spin_lock_init(&wdev->mgmt_registrations_lock);
 	INIT_LIST_HEAD(&wdev->pmsr_list);
 	spin_lock_init(&wdev->pmsr_lock);
 	INIT_WORK(&wdev->pmsr_free_wk, cfg80211_pmsr_free_wk);
diff --git a/net/wireless/core.h b/net/wireless/core.h
index b35d0db12f1d..1720abf36f92 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -100,6 +100,8 @@ struct cfg80211_registered_device {
 	struct work_struct propagate_cac_done_wk;
 
 	struct work_struct mgmt_registrations_update_wk;
+	/* lock for all wdev lists */
+	spinlock_t mgmt_registrations_lock;
 
 	/* must be last because of the way we do wiphy_priv(),
 	 * and it should at least be aligned to NETDEV_ALIGN */
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 3aa69b375a10..783acd2c4211 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -452,9 +452,9 @@ static void cfg80211_mgmt_registrations_update(struct wireless_dev *wdev)
 
 	lockdep_assert_held(&rdev->wiphy.mtx);
 
-	spin_lock_bh(&wdev->mgmt_registrations_lock);
+	spin_lock_bh(&rdev->mgmt_registrations_lock);
 	if (!wdev->mgmt_registrations_need_update) {
-		spin_unlock_bh(&wdev->mgmt_registrations_lock);
+		spin_unlock_bh(&rdev->mgmt_registrations_lock);
 		return;
 	}
 
@@ -479,7 +479,7 @@ static void cfg80211_mgmt_registrations_update(struct wireless_dev *wdev)
 	rcu_read_unlock();
 
 	wdev->mgmt_registrations_need_update = 0;
-	spin_unlock_bh(&wdev->mgmt_registrations_lock);
+	spin_unlock_bh(&rdev->mgmt_registrations_lock);
 
 	rdev_update_mgmt_frame_registrations(rdev, wdev, &upd);
 }
@@ -503,6 +503,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
 				int match_len, bool multicast_rx,
 				struct netlink_ext_ack *extack)
 {
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
 	struct cfg80211_mgmt_registration *reg, *nreg;
 	int err = 0;
 	u16 mgmt_type;
@@ -548,7 +549,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
 	if (!nreg)
 		return -ENOMEM;
 
-	spin_lock_bh(&wdev->mgmt_registrations_lock);
+	spin_lock_bh(&rdev->mgmt_registrations_lock);
 
 	list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
 		int mlen = min(match_len, reg->match_len);
@@ -583,7 +584,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
 		list_add(&nreg->list, &wdev->mgmt_registrations);
 	}
 	wdev->mgmt_registrations_need_update = 1;
-	spin_unlock_bh(&wdev->mgmt_registrations_lock);
+	spin_unlock_bh(&rdev->mgmt_registrations_lock);
 
 	cfg80211_mgmt_registrations_update(wdev);
 
@@ -591,7 +592,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
 
  out:
 	kfree(nreg);
-	spin_unlock_bh(&wdev->mgmt_registrations_lock);
+	spin_unlock_bh(&rdev->mgmt_registrations_lock);
 
 	return err;
 }
@@ -602,7 +603,7 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
 	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
 	struct cfg80211_mgmt_registration *reg, *tmp;
 
-	spin_lock_bh(&wdev->mgmt_registrations_lock);
+	spin_lock_bh(&rdev->mgmt_registrations_lock);
 
 	list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
 		if (reg->nlportid != nlportid)
@@ -615,7 +616,7 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
 		schedule_work(&rdev->mgmt_registrations_update_wk);
 	}
 
-	spin_unlock_bh(&wdev->mgmt_registrations_lock);
+	spin_unlock_bh(&rdev->mgmt_registrations_lock);
 
 	if (nlportid && rdev->crit_proto_nlportid == nlportid) {
 		rdev->crit_proto_nlportid = 0;
@@ -628,15 +629,16 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
 
 void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev)
 {
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
 	struct cfg80211_mgmt_registration *reg, *tmp;
 
-	spin_lock_bh(&wdev->mgmt_registrations_lock);
+	spin_lock_bh(&rdev->mgmt_registrations_lock);
 	list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
 		list_del(&reg->list);
 		kfree(reg);
 	}
 	wdev->mgmt_registrations_need_update = 1;
-	spin_unlock_bh(&wdev->mgmt_registrations_lock);
+	spin_unlock_bh(&rdev->mgmt_registrations_lock);
 
 	cfg80211_mgmt_registrations_update(wdev);
 }
@@ -784,7 +786,7 @@ bool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq, int sig_dbm,
 	data = buf + ieee80211_hdrlen(mgmt->frame_control);
 	data_len = len - ieee80211_hdrlen(mgmt->frame_control);
 
-	spin_lock_bh(&wdev->mgmt_registrations_lock);
+	spin_lock_bh(&rdev->mgmt_registrations_lock);
 
 	list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
 		if (reg->frame_type != ftype)
@@ -808,7 +810,7 @@ bool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq, int sig_dbm,
 		break;
 	}
 
-	spin_unlock_bh(&wdev->mgmt_registrations_lock);
+	spin_unlock_bh(&rdev->mgmt_registrations_lock);
 
 	trace_cfg80211_return_bool(result);
 	return result;
commit 0985dba842eaa391858972cfe2724c3c174a2827
Author: David Woodhouse <dwmw at amazon.co.uk>
Date:   Sat Oct 23 20:47:19 2021 +0100

    KVM: x86/xen: Fix kvm_xen_has_interrupt() sleeping in kvm_vcpu_block()
    
    In kvm_vcpu_block, the current task is set to TASK_INTERRUPTIBLE before
    making a final check whether the vCPU should be woken from HLT by any
    incoming interrupt.
    
    This is a problem for the get_user() in __kvm_xen_has_interrupt(), which
    really shouldn't be sleeping when the task state has already been set.
    I think it's actually harmless as it would just manifest itself as a
    spurious wakeup, but it's causing a debug warning:
    
    [  230.963649] do not call blocking ops when !TASK_RUNNING; state=1 set at [<00000000b6bcdbc9>] prepare_to_swait_exclusive+0x30/0x80
    
    Fix the warning by turning it into an *explicit* spurious wakeup. When
    invoked with !task_is_running(current) (and we might as well add
    in_atomic() there while we're at it), just return 1 to indicate that
    an IRQ is pending, which will cause a wakeup and then something will
    call it again in a context that *can* sleep so it can fault the page
    back in.
    
    Cc: stable at vger.kernel.org
    Fixes: 40da8ccd724f ("KVM: x86/xen: Add event channel interrupt vector upcall")
    Signed-off-by: David Woodhouse <dwmw at amazon.co.uk>
    
    Message-Id: <168bf8c689561da904e48e2ff5ae4713eaef9e2d.camel at infradead.org>
    Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>

diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index 9ea9c3dabe37..8f62baebd028 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -190,6 +190,7 @@ void kvm_xen_update_runstate_guest(struct kvm_vcpu *v, int state)
 
 int __kvm_xen_has_interrupt(struct kvm_vcpu *v)
 {
+	int err;
 	u8 rc = 0;
 
 	/*
@@ -216,13 +217,29 @@ int __kvm_xen_has_interrupt(struct kvm_vcpu *v)
 	if (likely(slots->generation == ghc->generation &&
 		   !kvm_is_error_hva(ghc->hva) && ghc->memslot)) {
 		/* Fast path */
-		__get_user(rc, (u8 __user *)ghc->hva + offset);
-	} else {
-		/* Slow path */
-		kvm_read_guest_offset_cached(v->kvm, ghc, &rc, offset,
-					     sizeof(rc));
+		pagefault_disable();
+		err = __get_user(rc, (u8 __user *)ghc->hva + offset);
+		pagefault_enable();
+		if (!err)
+			return rc;
 	}
 
+	/* Slow path */
+
+	/*
+	 * This function gets called from kvm_vcpu_block() after setting the
+	 * task to TASK_INTERRUPTIBLE, to see if it needs to wake immediately
+	 * from a HLT. So we really mustn't sleep. If the page ended up absent
+	 * at that point, just return 1 in order to trigger an immediate wake,
+	 * and we'll end up getting called again from a context where we *can*
+	 * fault in the page and wait for it.
+	 */
+	if (in_atomic() || !task_is_running(current))
+		return 1;
+
+	kvm_read_guest_offset_cached(v->kvm, ghc, &rc, offset,
+				     sizeof(rc));
+
 	return rc;
 }
 
commit 4b2caef043dd89dd98da282cd6b90af2cbb60650
Merge: 8228c77d8b56 0e9ff65f455d
Author: Paolo Bonzini <pbonzini at redhat.com>
Date:   Mon Oct 25 09:08:56 2021 -0400

    Merge tag 'kvm-s390-master-5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
    
    KVM: s390: Fixes for interrupt delivery
    
    Two bugs that might result in CPUs not woken up when interrupts are
    pending.

commit b4ab21f90320969e5360719467153fc2bbc9435c
Merge: 95a359c95533 af1a02aa23c3
Author: David S. Miller <davem at davemloft.net>
Date:   Mon Oct 25 14:06:43 2021 +0100

    Merge branch 'ksettings-locking-fixes'
    
    Andrew Lunn says:
    
    ====================
    ksettings_{get|set} lock fixes
    
    Walter Stoll <Walter.Stoll at duagon.com> reported a race condition
    between "ethtool -s eth0 speed 100 duplex full autoneg off" and phylib
    reading the current status from the PHY. Both ksetting_get and
    ksetting_set fail the take the phydev mutex, and as a result, there is
    a small window of time where the phydev members are not self
    consistent.
    
    Patch 1 fixes phy_ethtool_ksettings_get by adding the needed lock.
    Patches 2 and 3 move code around and perform to refactoring, to allow
    patch 4 to fix phy_ethtool_ksettings_set by added the lock.
    
    Thanks go to Walter for the detailed origional report, suggested fix,
    and testing of the proposed patches.
    ====================
    
    Signed-off-by: David S. Miller <davem at davemloft.net>

commit af1a02aa23c37045e6adfcf074cf7dbac167a403
Author: Andrew Lunn <andrew at lunn.ch>
Date:   Sun Oct 24 21:48:05 2021 +0200

    phy: phy_ethtool_ksettings_set: Lock the PHY while changing settings
    
    There is a race condition where the PHY state machine can change
    members of the phydev structure at the same time userspace requests a
    change via ethtool. To prevent this, have phy_ethtool_ksettings_set
    take the PHY lock.
    
    Fixes: 2d55173e71b0 ("phy: add generic function to support ksetting support")
    Reported-by: Walter Stoll <Walter.Stoll at duagon.com>
    Suggested-by: Walter Stoll <Walter.Stoll at duagon.com>
    Tested-by: Walter Stoll <Walter.Stoll at duagon.com>
    Signed-off-by: Andrew Lunn <andrew at lunn.ch>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index d845afab1af7..a3bfb156c83d 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -798,6 +798,7 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,
 	      duplex != DUPLEX_FULL)))
 		return -EINVAL;
 
+	mutex_lock(&phydev->lock);
 	phydev->autoneg = autoneg;
 
 	if (autoneg == AUTONEG_DISABLE) {
@@ -814,8 +815,9 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,
 	phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
 
 	/* Restart the PHY */
-	phy_start_aneg(phydev);
+	_phy_start_aneg(phydev);
 
+	mutex_unlock(&phydev->lock);
 	return 0;
 }
 EXPORT_SYMBOL(phy_ethtool_ksettings_set);
commit 707293a56f95f8e7e0cfae008010c7933fb68973
Author: Andrew Lunn <andrew at lunn.ch>
Date:   Sun Oct 24 21:48:04 2021 +0200

    phy: phy_start_aneg: Add an unlocked version
    
    Split phy_start_aneg into a wrapper which takes the PHY lock, and a
    helper doing the real work. This will be needed when
    phy_ethtook_ksettings_set takes the lock.
    
    Fixes: 2d55173e71b0 ("phy: add generic function to support ksetting support")
    Signed-off-by: Andrew Lunn <andrew at lunn.ch>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index ee584fa8b76d..d845afab1af7 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -700,7 +700,7 @@ static int phy_check_link_status(struct phy_device *phydev)
 }
 
 /**
- * phy_start_aneg - start auto-negotiation for this PHY device
+ * _phy_start_aneg - start auto-negotiation for this PHY device
  * @phydev: the phy_device struct
  *
  * Description: Sanitizes the settings (if we're not autonegotiating
@@ -708,25 +708,43 @@ static int phy_check_link_status(struct phy_device *phydev)
  *   If the PHYCONTROL Layer is operating, we change the state to
  *   reflect the beginning of Auto-negotiation or forcing.
  */
-int phy_start_aneg(struct phy_device *phydev)
+static int _phy_start_aneg(struct phy_device *phydev)
 {
 	int err;
 
+	lockdep_assert_held(&phydev->lock);
+
 	if (!phydev->drv)
 		return -EIO;
 
-	mutex_lock(&phydev->lock);
-
 	if (AUTONEG_DISABLE == phydev->autoneg)
 		phy_sanitize_settings(phydev);
 
 	err = phy_config_aneg(phydev);
 	if (err < 0)
-		goto out_unlock;
+		return err;
 
 	if (phy_is_started(phydev))
 		err = phy_check_link_status(phydev);
-out_unlock:
+
+	return err;
+}
+
+/**
+ * phy_start_aneg - start auto-negotiation for this PHY device
+ * @phydev: the phy_device struct
+ *
+ * Description: Sanitizes the settings (if we're not autonegotiating
+ *   them), and then calls the driver's config_aneg function.
+ *   If the PHYCONTROL Layer is operating, we change the state to
+ *   reflect the beginning of Auto-negotiation or forcing.
+ */
+int phy_start_aneg(struct phy_device *phydev)
+{
+	int err;
+
+	mutex_lock(&phydev->lock);
+	err = _phy_start_aneg(phydev);
 	mutex_unlock(&phydev->lock);
 
 	return err;
commit 64cd92d5e8180c2ded3fdea76862de6f596ae2c9
Author: Andrew Lunn <andrew at lunn.ch>
Date:   Sun Oct 24 21:48:03 2021 +0200

    phy: phy_ethtool_ksettings_set: Move after phy_start_aneg
    
    This allows it to make use of a helper which assume the PHY is already
    locked.
    
    Fixes: 2d55173e71b0 ("phy: add generic function to support ksetting support")
    Signed-off-by: Andrew Lunn <andrew at lunn.ch>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 8457b829667e..ee584fa8b76d 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -243,59 +243,6 @@ static void phy_sanitize_settings(struct phy_device *phydev)
 	}
 }
 
-int phy_ethtool_ksettings_set(struct phy_device *phydev,
-			      const struct ethtool_link_ksettings *cmd)
-{
-	__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
-	u8 autoneg = cmd->base.autoneg;
-	u8 duplex = cmd->base.duplex;
-	u32 speed = cmd->base.speed;
-
-	if (cmd->base.phy_address != phydev->mdio.addr)
-		return -EINVAL;
-
-	linkmode_copy(advertising, cmd->link_modes.advertising);
-
-	/* We make sure that we don't pass unsupported values in to the PHY */
-	linkmode_and(advertising, advertising, phydev->supported);
-
-	/* Verify the settings we care about. */
-	if (autoneg != AUTONEG_ENABLE && autoneg != AUTONEG_DISABLE)
-		return -EINVAL;
-
-	if (autoneg == AUTONEG_ENABLE && linkmode_empty(advertising))
-		return -EINVAL;
-
-	if (autoneg == AUTONEG_DISABLE &&
-	    ((speed != SPEED_1000 &&
-	      speed != SPEED_100 &&
-	      speed != SPEED_10) ||
-	     (duplex != DUPLEX_HALF &&
-	      duplex != DUPLEX_FULL)))
-		return -EINVAL;
-
-	phydev->autoneg = autoneg;
-
-	if (autoneg == AUTONEG_DISABLE) {
-		phydev->speed = speed;
-		phydev->duplex = duplex;
-	}
-
-	linkmode_copy(phydev->advertising, advertising);
-
-	linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
-			 phydev->advertising, autoneg == AUTONEG_ENABLE);
-
-	phydev->master_slave_set = cmd->base.master_slave_cfg;
-	phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
-
-	/* Restart the PHY */
-	phy_start_aneg(phydev);
-
-	return 0;
-}
-EXPORT_SYMBOL(phy_ethtool_ksettings_set);
-
 void phy_ethtool_ksettings_get(struct phy_device *phydev,
 			       struct ethtool_link_ksettings *cmd)
 {
@@ -802,6 +749,59 @@ static int phy_poll_aneg_done(struct phy_device *phydev)
 	return ret < 0 ? ret : 0;
 }
 
+int phy_ethtool_ksettings_set(struct phy_device *phydev,
+			      const struct ethtool_link_ksettings *cmd)
+{
+	__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
+	u8 autoneg = cmd->base.autoneg;
+	u8 duplex = cmd->base.duplex;
+	u32 speed = cmd->base.speed;
+
+	if (cmd->base.phy_address != phydev->mdio.addr)
+		return -EINVAL;
+
+	linkmode_copy(advertising, cmd->link_modes.advertising);
+
+	/* We make sure that we don't pass unsupported values in to the PHY */
+	linkmode_and(advertising, advertising, phydev->supported);
+
+	/* Verify the settings we care about. */
+	if (autoneg != AUTONEG_ENABLE && autoneg != AUTONEG_DISABLE)
+		return -EINVAL;
+
+	if (autoneg == AUTONEG_ENABLE && linkmode_empty(advertising))
+		return -EINVAL;
+
+	if (autoneg == AUTONEG_DISABLE &&
+	    ((speed != SPEED_1000 &&
+	      speed != SPEED_100 &&
+	      speed != SPEED_10) ||
+	     (duplex != DUPLEX_HALF &&
+	      duplex != DUPLEX_FULL)))
+		return -EINVAL;
+
+	phydev->autoneg = autoneg;
+
+	if (autoneg == AUTONEG_DISABLE) {
+		phydev->speed = speed;
+		phydev->duplex = duplex;
+	}
+
+	linkmode_copy(phydev->advertising, advertising);
+
+	linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
+			 phydev->advertising, autoneg == AUTONEG_ENABLE);
+
+	phydev->master_slave_set = cmd->base.master_slave_cfg;
+	phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
+
+	/* Restart the PHY */
+	phy_start_aneg(phydev);
+
+	return 0;
+}
+EXPORT_SYMBOL(phy_ethtool_ksettings_set);
+
 /**
  * phy_speed_down - set speed to lowest speed supported by both link partners
  * @phydev: the phy_device struct
commit c10a485c3de5ccbf1fff65a382cebcb2730c6b06
Author: Andrew Lunn <andrew at lunn.ch>
Date:   Sun Oct 24 21:48:02 2021 +0200

    phy: phy_ethtool_ksettings_get: Lock the phy for consistency
    
    The PHY structure should be locked while copying information out if
    it, otherwise there is no guarantee of self consistency. Without the
    lock the PHY state machine could be updating the structure.
    
    Fixes: 2d55173e71b0 ("phy: add generic function to support ksetting support")
    Signed-off-by: Andrew Lunn <andrew at lunn.ch>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index f124a8a58bd4..8457b829667e 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -299,6 +299,7 @@ EXPORT_SYMBOL(phy_ethtool_ksettings_set);
 void phy_ethtool_ksettings_get(struct phy_device *phydev,
 			       struct ethtool_link_ksettings *cmd)
 {
+	mutex_lock(&phydev->lock);
 	linkmode_copy(cmd->link_modes.supported, phydev->supported);
 	linkmode_copy(cmd->link_modes.advertising, phydev->advertising);
 	linkmode_copy(cmd->link_modes.lp_advertising, phydev->lp_advertising);
@@ -317,6 +318,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
 	cmd->base.autoneg = phydev->autoneg;
 	cmd->base.eth_tp_mdix_ctrl = phydev->mdix_ctrl;
 	cmd->base.eth_tp_mdix = phydev->mdix;
+	mutex_unlock(&phydev->lock);
 }
 EXPORT_SYMBOL(phy_ethtool_ksettings_get);
 
commit 8228c77d8b56e3f735baf71fefb1b548c23691a7
Author: David Woodhouse <dwmw at amazon.co.uk>
Date:   Sat Oct 23 21:29:22 2021 +0100

    KVM: x86: switch pvclock_gtod_sync_lock to a raw spinlock
    
    On the preemption path when updating a Xen guest's runstate times, this
    lock is taken inside the scheduler rq->lock, which is a raw spinlock.
    This was shown in a lockdep warning:
    
    [   89.138354] =============================
    [   89.138356] [ BUG: Invalid wait context ]
    [   89.138358] 5.15.0-rc5+ #834 Tainted: G S        I E
    [   89.138360] -----------------------------
    [   89.138361] xen_shinfo_test/2575 is trying to lock:
    [   89.138363] ffffa34a0364efd8 (&kvm->arch.pvclock_gtod_sync_lock){....}-{3:3}, at: get_kvmclock_ns+0x1f/0x130 [kvm]
    [   89.138442] other info that might help us debug this:
    [   89.138444] context-{5:5}
    [   89.138445] 4 locks held by xen_shinfo_test/2575:
    [   89.138447]  #0: ffff972bdc3b8108 (&vcpu->mutex){+.+.}-{4:4}, at: kvm_vcpu_ioctl+0x77/0x6f0 [kvm]
    [   89.138483]  #1: ffffa34a03662e90 (&kvm->srcu){....}-{0:0}, at: kvm_arch_vcpu_ioctl_run+0xdc/0x8b0 [kvm]
    [   89.138526]  #2: ffff97331fdbac98 (&rq->__lock){-.-.}-{2:2}, at: __schedule+0xff/0xbd0
    [   89.138534]  #3: ffffa34a03662e90 (&kvm->srcu){....}-{0:0}, at: kvm_arch_vcpu_put+0x26/0x170 [kvm]
    ...
    [   89.138695]  get_kvmclock_ns+0x1f/0x130 [kvm]
    [   89.138734]  kvm_xen_update_runstate+0x14/0x90 [kvm]
    [   89.138783]  kvm_xen_update_runstate_guest+0x15/0xd0 [kvm]
    [   89.138830]  kvm_arch_vcpu_put+0xe6/0x170 [kvm]
    [   89.138870]  kvm_sched_out+0x2f/0x40 [kvm]
    [   89.138900]  __schedule+0x5de/0xbd0
    
    Cc: stable at vger.kernel.org
    Reported-by: syzbot+b282b65c2c68492df769 at syzkaller.appspotmail.com
    Fixes: 30b5c851af79 ("KVM: x86/xen: Add support for vCPU runstate information")
    Signed-off-by: David Woodhouse <dwmw at amazon.co.uk>
    Message-Id: <1b02a06421c17993df337493a68ba923f3bd5c0f.camel at infradead.org>
    Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index f8f48a7ec577..70771376e246 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1097,7 +1097,7 @@ struct kvm_arch {
 	u64 cur_tsc_generation;
 	int nr_vcpus_matched_tsc;
 
-	spinlock_t pvclock_gtod_sync_lock;
+	raw_spinlock_t pvclock_gtod_sync_lock;
 	bool use_master_clock;
 	u64 master_kernel_ns;
 	u64 master_cycle_now;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0c8b5129effd..5c82eff19e4a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2542,7 +2542,7 @@ static void kvm_synchronize_tsc(struct kvm_vcpu *vcpu, u64 data)
 	kvm_vcpu_write_tsc_offset(vcpu, offset);
 	raw_spin_unlock_irqrestore(&kvm->arch.tsc_write_lock, flags);
 
-	spin_lock_irqsave(&kvm->arch.pvclock_gtod_sync_lock, flags);
+	raw_spin_lock_irqsave(&kvm->arch.pvclock_gtod_sync_lock, flags);
 	if (!matched) {
 		kvm->arch.nr_vcpus_matched_tsc = 0;
 	} else if (!already_matched) {
@@ -2550,7 +2550,7 @@ static void kvm_synchronize_tsc(struct kvm_vcpu *vcpu, u64 data)
 	}
 
 	kvm_track_tsc_matching(vcpu);
-	spin_unlock_irqrestore(&kvm->arch.pvclock_gtod_sync_lock, flags);
+	raw_spin_unlock_irqrestore(&kvm->arch.pvclock_gtod_sync_lock, flags);
 }
 
 static inline void adjust_tsc_offset_guest(struct kvm_vcpu *vcpu,
@@ -2780,9 +2780,9 @@ static void kvm_gen_update_masterclock(struct kvm *kvm)
 	kvm_make_mclock_inprogress_request(kvm);
 
 	/* no guest entries from this point */
-	spin_lock_irqsave(&ka->pvclock_gtod_sync_lock, flags);
+	raw_spin_lock_irqsave(&ka->pvclock_gtod_sync_lock, flags);
 	pvclock_update_vm_gtod_copy(kvm);
-	spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
+	raw_spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
 
 	kvm_for_each_vcpu(i, vcpu, kvm)
 		kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
@@ -2800,15 +2800,15 @@ u64 get_kvmclock_ns(struct kvm *kvm)
 	unsigned long flags;
 	u64 ret;
 
-	spin_lock_irqsave(&ka->pvclock_gtod_sync_lock, flags);
+	raw_spin_lock_irqsave(&ka->pvclock_gtod_sync_lock, flags);
 	if (!ka->use_master_clock) {
-		spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
+		raw_spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
 		return get_kvmclock_base_ns() + ka->kvmclock_offset;
 	}
 
 	hv_clock.tsc_timestamp = ka->master_cycle_now;
 	hv_clock.system_time = ka->master_kernel_ns + ka->kvmclock_offset;
-	spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
+	raw_spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
 
 	/* both __this_cpu_read() and rdtsc() should be on the same cpu */
 	get_cpu();
@@ -2902,13 +2902,13 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
 	 * If the host uses TSC clock, then passthrough TSC as stable
 	 * to the guest.
 	 */
-	spin_lock_irqsave(&ka->pvclock_gtod_sync_lock, flags);
+	raw_spin_lock_irqsave(&ka->pvclock_gtod_sync_lock, flags);
 	use_master_clock = ka->use_master_clock;
 	if (use_master_clock) {
 		host_tsc = ka->master_cycle_now;
 		kernel_ns = ka->master_kernel_ns;
 	}
-	spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
+	raw_spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
 
 	/* Keep irq disabled to prevent changes to the clock */
 	local_irq_save(flags);
@@ -6100,13 +6100,13 @@ set_pit2_out:
 		 * is slightly ahead) here we risk going negative on unsigned
 		 * 'system_time' when 'user_ns.clock' is very small.
 		 */
-		spin_lock_irq(&ka->pvclock_gtod_sync_lock);
+		raw_spin_lock_irq(&ka->pvclock_gtod_sync_lock);
 		if (kvm->arch.use_master_clock)
 			now_ns = ka->master_kernel_ns;
 		else
 			now_ns = get_kvmclock_base_ns();
 		ka->kvmclock_offset = user_ns.clock - now_ns;
-		spin_unlock_irq(&ka->pvclock_gtod_sync_lock);
+		raw_spin_unlock_irq(&ka->pvclock_gtod_sync_lock);
 
 		kvm_make_all_cpus_request(kvm, KVM_REQ_CLOCK_UPDATE);
 		break;
@@ -8139,9 +8139,9 @@ static void kvm_hyperv_tsc_notifier(void)
 	list_for_each_entry(kvm, &vm_list, vm_list) {
 		struct kvm_arch *ka = &kvm->arch;
 
-		spin_lock_irqsave(&ka->pvclock_gtod_sync_lock, flags);
+		raw_spin_lock_irqsave(&ka->pvclock_gtod_sync_lock, flags);
 		pvclock_update_vm_gtod_copy(kvm);
-		spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
+		raw_spin_unlock_irqrestore(&ka->pvclock_gtod_sync_lock, flags);
 
 		kvm_for_each_vcpu(cpu, vcpu, kvm)
 			kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
@@ -11182,7 +11182,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
 	raw_spin_lock_init(&kvm->arch.tsc_write_lock);
 	mutex_init(&kvm->arch.apic_map_lock);
-	spin_lock_init(&kvm->arch.pvclock_gtod_sync_lock);
+	raw_spin_lock_init(&kvm->arch.pvclock_gtod_sync_lock);
 
 	kvm->arch.kvmclock_offset = -get_kvmclock_base_ns();
 	pvclock_update_vm_gtod_copy(kvm);
commit c0eee6fbfa2b3377f1efed10dad539abeb7312aa
Author: Asmaa Mnebhi <asmaa at nvidia.com>
Date:   Fri Oct 22 09:44:38 2021 -0400

    gpio: mlxbf2.c: Add check for bgpio_init failure
    
    Add a check if bgpio_init fails.
    
    Signed-off-by: Asmaa Mnebhi <asmaa at nvidia.com>
    Signed-off-by: Bartosz Golaszewski <brgl at bgdev.pl>

diff --git a/drivers/gpio/gpio-mlxbf2.c b/drivers/gpio/gpio-mlxbf2.c
index 177d03ef4529..40a052bc6784 100644
--- a/drivers/gpio/gpio-mlxbf2.c
+++ b/drivers/gpio/gpio-mlxbf2.c
@@ -256,6 +256,11 @@ mlxbf2_gpio_probe(struct platform_device *pdev)
 			NULL,
 			0);
 
+	if (ret) {
+		dev_err(dev, "bgpio_init failed\n");
+		return ret;
+	}
+
 	gc->direction_input = mlxbf2_gpio_direction_input;
 	gc->direction_output = mlxbf2_gpio_direction_output;
 	gc->ngpio = npins;
commit 85fe6415c146d5d42ce300c12f1ecf4d4af47d40
Author: Jonas Gorski <jonas.gorski at gmail.com>
Date:   Thu Oct 14 14:33:42 2021 +0200

    gpio: xgs-iproc: fix parsing of ngpios property
    
    of_property_read_u32 returns 0 on success, not true, so we need to
    invert the check to actually take over the provided ngpio value.
    
    Fixes: 6a41b6c5fc20 ("gpio: Add xgs-iproc driver")
    Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
    Reviewed-by: Chris Packham <chris.packham at alliedtelesis.co.nz>
    Reviewed-by: Florian Fainelli <f.fainelli at gmail.com>
    Reviewed-by: Linus Walleij <linus.walleij at linaro.org>
    Signed-off-by: Bartosz Golaszewski <brgl at bgdev.pl>

diff --git a/drivers/gpio/gpio-xgs-iproc.c b/drivers/gpio/gpio-xgs-iproc.c
index fa9b4d8c3ff5..43ca52fa6f9a 100644
--- a/drivers/gpio/gpio-xgs-iproc.c
+++ b/drivers/gpio/gpio-xgs-iproc.c
@@ -224,7 +224,7 @@ static int iproc_gpio_probe(struct platform_device *pdev)
 	}
 
 	chip->gc.label = dev_name(dev);
-	if (of_property_read_u32(dn, "ngpios", &num_gpios))
+	if (!of_property_read_u32(dn, "ngpios", &num_gpios))
 		chip->gc.ngpio = num_gpios;
 
 	irq = platform_get_irq(pdev, 0);
commit d853adc7adf601d7d6823afe3ed396065a3e08d1
Author: Alexey Kardashevskiy <aik at ozlabs.ru>
Date:   Thu Oct 21 00:23:15 2021 +1100

    powerpc/pseries/iommu: Create huge DMA window if no MMIO32 is present
    
    The iommu_init_table() helper takes an address range to reserve in
    the IOMMU table being initialized to exclude MMIO addresses, this is
    useful if the window stretches far beyond 4GB (although wastes some TCEs).
    At the moment the code searches for such MMIO32 range and fails if none
    found which is considered a problem while it really is not: it is actually
    better as this says there is no MMIO32 to reserve and we can use
    usually wasted TCEs. Furthermore PHYP never actually allows creating
    windows starting at busaddress=0 so this MMIO32 range is never useful.
    
    This removes error exit and initializes the table with zero range if
    no MMIO32 is detected.
    
    Fixes: 381ceda88c4c ("powerpc/pseries/iommu: Make use of DDW for indirect mapping")
    Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
    Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
    Link: https://lore.kernel.org/r/20211020132315.2287178-5-aik@ozlabs.ru

diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 8f921e38ce74..a52af8fbf571 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1411,18 +1411,19 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
 	} else {
 		struct iommu_table *newtbl;
 		int i;
+		unsigned long start = 0, end = 0;
 
 		for (i = 0; i < ARRAY_SIZE(pci->phb->mem_resources); i++) {
 			const unsigned long mask = IORESOURCE_MEM_64 | IORESOURCE_MEM;
 
 			/* Look for MMIO32 */
-			if ((pci->phb->mem_resources[i].flags & mask) == IORESOURCE_MEM)
+			if ((pci->phb->mem_resources[i].flags & mask) == IORESOURCE_MEM) {
+				start = pci->phb->mem_resources[i].start;
+				end = pci->phb->mem_resources[i].end;
 				break;
+			}
 		}
 
-		if (i == ARRAY_SIZE(pci->phb->mem_resources))
-			goto out_del_list;
-
 		/* New table for using DDW instead of the default DMA window */
 		newtbl = iommu_pseries_alloc_table(pci->phb->node);
 		if (!newtbl) {
@@ -1432,8 +1433,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
 
 		iommu_table_setparms_common(newtbl, pci->phb->bus->number, create.liobn, win_addr,
 					    1UL << len, page_shift, NULL, &iommu_table_lpar_multi_ops);
-		iommu_init_table(newtbl, pci->phb->node, pci->phb->mem_resources[i].start,
-				 pci->phb->mem_resources[i].end);
+		iommu_init_table(newtbl, pci->phb->node, start, end);
 
 		pci->table_group->tables[1] = newtbl;
 
commit 92fe01b7c655b9767724e7d62bdded0761d232ff
Author: Alexey Kardashevskiy <aik at ozlabs.ru>
Date:   Thu Oct 21 00:23:14 2021 +1100

    powerpc/pseries/iommu: Check if the default window in use before removing it
    
    At the moment this check is performed after we remove the default window
    which is late and disallows to revert whatever changes enable_ddw()
    has made to DMA windows.
    
    This moves the check and error exit before removing the window.
    
    This raised the message severity from "debug" to "warning" as this
    should not happen in practice and cannot be triggered by the userspace.
    
    Fixes: 381ceda88c4c ("powerpc/pseries/iommu: Make use of DDW for indirect mapping")
    Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
    Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
    Link: https://lore.kernel.org/r/20211020132315.2287178-4-aik@ozlabs.ru

diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index c003f698eedd..8f921e38ce74 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1302,6 +1302,12 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
 		struct property *default_win;
 		int reset_win_ext;
 
+		/* DDW + IOMMU on single window may fail if there is any allocation */
+		if (iommu_table_in_use(tbl)) {
+			dev_warn(&dev->dev, "current IOMMU table in use, can't be replaced.\n");
+			goto out_failed;
+		}
+
 		default_win = of_find_property(pdn, "ibm,dma-window", NULL);
 		if (!default_win)
 			goto out_failed;
@@ -1356,12 +1362,6 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
 			query.largest_available_block,
 			1ULL << page_shift);
 
-		/* DDW + IOMMU on single window may fail if there is any allocation */
-		if (default_win_removed && iommu_table_in_use(tbl)) {
-			dev_dbg(&dev->dev, "current IOMMU table in use, can't be replaced.\n");
-			goto out_failed;
-		}
-
 		len = order_base_2(query.largest_available_block << page_shift);
 		win_name = DMA64_PROPNAME;
 	} else {
commit 41ee7232fa5f3c034f22baa52bc287e494e2129a
Author: Alexey Kardashevskiy <aik at ozlabs.ru>
Date:   Thu Oct 21 00:23:13 2021 +1100

    powerpc/pseries/iommu: Use correct vfree for it_map
    
    The it_map array is vzalloc'ed so use vfree() for it when creating
    a huge DMA window failed for whatever reason.
    
    While at this, write zero to it_map.
    
    Fixes: 381ceda88c4c ("powerpc/pseries/iommu: Make use of DDW for indirect mapping")
    Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
    Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
    Link: https://lore.kernel.org/r/20211020132315.2287178-3-aik@ozlabs.ru

diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index dab5c56ffd0e..c003f698eedd 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1440,7 +1440,8 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
 		/* Keep default DMA window stuct if removed */
 		if (default_win_removed) {
 			tbl->it_size = 0;
-			kfree(tbl->it_map);
+			vfree(tbl->it_map);
+			tbl->it_map = NULL;
 		}
 
 		set_iommu_table_base(&dev->dev, newtbl);
commit 95a359c9553342d36d408d35331ff0bfce75272f
Author: Yuiko Oshino <yuiko.oshino at microchip.com>
Date:   Fri Oct 22 11:53:43 2021 -0400

    net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_and_coherent
    
    The dma failure was reported in the raspberry pi github (issue #4117).
    https://github.com/raspberrypi/linux/issues/4117
    The use of dma_set_mask_and_coherent fixes the issue.
    Tested on 32/64-bit raspberry pi CM4 and 64-bit ubuntu x86 PC with EVB-LAN7430.
    
    Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino at microchip.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index 3ac968b1c6ce..c4f32c7e0db1 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -1743,6 +1743,16 @@ static int lan743x_tx_ring_init(struct lan743x_tx *tx)
 		ret = -EINVAL;
 		goto cleanup;
 	}
+	if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
+				      DMA_BIT_MASK(64))) {
+		if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
+					      DMA_BIT_MASK(32))) {
+			dev_warn(&tx->adapter->pdev->dev,
+				 "lan743x_: No suitable DMA available\n");
+			ret = -ENOMEM;
+			goto cleanup;
+		}
+	}
 	ring_allocation_size = ALIGN(tx->ring_size *
 				     sizeof(struct lan743x_tx_descriptor),
 				     PAGE_SIZE);
@@ -2276,6 +2286,16 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
 		ret = -EINVAL;
 		goto cleanup;
 	}
+	if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
+				      DMA_BIT_MASK(64))) {
+		if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
+					      DMA_BIT_MASK(32))) {
+			dev_warn(&rx->adapter->pdev->dev,
+				 "lan743x_: No suitable DMA available\n");
+			ret = -ENOMEM;
+			goto cleanup;
+		}
+	}
 	ring_allocation_size = ALIGN(rx->ring_size *
 				     sizeof(struct lan743x_rx_descriptor),
 				     PAGE_SIZE);
commit d6423d2ec39cce2bfca418c81ef51792891576bc
Author: Yuiko Oshino <yuiko.oshino at microchip.com>
Date:   Fri Oct 22 11:13:53 2021 -0400

    net: ethernet: microchip: lan743x: Fix driver crash when lan743x_pm_resume fails
    
    The driver needs to clean up and return when the initialization fails on resume.
    
    Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino at microchip.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index 9e8561cdc32a..3ac968b1c6ce 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -3019,6 +3019,8 @@ static int lan743x_pm_resume(struct device *dev)
 	if (ret) {
 		netif_err(adapter, probe, adapter->netdev,
 			  "lan743x_hardware_init returned %d\n", ret);
+		lan743x_pci_cleanup(adapter);
+		return ret;
 	}
 
 	/* open netdev when netdev is at running state while resume.
commit 04f8ef5643bcd8bcde25dfdebef998aea480b2ba
Author: Quanyang Wang <quanyang.wang at windriver.com>
Date:   Mon Oct 18 15:56:23 2021 +0800

    cgroup: Fix memory leak caused by missing cgroup_bpf_offline
    
    When enabling CONFIG_CGROUP_BPF, kmemleak can be observed by running
    the command as below:
    
        $mount -t cgroup -o none,name=foo cgroup cgroup/
        $umount cgroup/
    
    unreferenced object 0xc3585c40 (size 64):
      comm "mount", pid 425, jiffies 4294959825 (age 31.990s)
      hex dump (first 32 bytes):
        01 00 00 80 84 8c 28 c0 00 00 00 00 00 00 00 00  ......(.........
        00 00 00 00 00 00 00 00 6c 43 a0 c3 00 00 00 00  ........lC......
      backtrace:
        [<e95a2f9e>] cgroup_bpf_inherit+0x44/0x24c
        [<1f03679c>] cgroup_setup_root+0x174/0x37c
        [<ed4b0ac5>] cgroup1_get_tree+0x2c0/0x4a0
        [<f85b12fd>] vfs_get_tree+0x24/0x108
        [<f55aec5c>] path_mount+0x384/0x988
        [<e2d5e9cd>] do_mount+0x64/0x9c
        [<208c9cfe>] sys_mount+0xfc/0x1f4
        [<06dd06e0>] ret_fast_syscall+0x0/0x48
        [<a8308cb3>] 0xbeb4daa8
    
    This is because that since the commit 2b0d3d3e4fcf ("percpu_ref: reduce
    memory footprint of percpu_ref in fast path") root_cgrp->bpf.refcnt.data
    is allocated by the function percpu_ref_init in cgroup_bpf_inherit which
    is called by cgroup_setup_root when mounting, but not freed along with
    root_cgrp when umounting. Adding cgroup_bpf_offline which calls
    percpu_ref_kill to cgroup_kill_sb can free root_cgrp->bpf.refcnt.data in
    umount path.
    
    This patch also fixes the commit 4bfc0bb2c60e ("bpf: decouple the lifetime
    of cgroup_bpf from cgroup itself"). A cgroup_bpf_offline is needed to do a
    cleanup that frees the resources which are allocated by cgroup_bpf_inherit
    in cgroup_setup_root.
    
    And inside cgroup_bpf_offline, cgroup_get() is at the beginning and
    cgroup_put is at the end of cgroup_bpf_release which is called by
    cgroup_bpf_offline. So cgroup_bpf_offline can keep the balance of
    cgroup's refcount.
    
    Fixes: 2b0d3d3e4fcf ("percpu_ref: reduce memory footprint of percpu_ref in fast path")
    Fixes: 4bfc0bb2c60e ("bpf: decouple the lifetime of cgroup_bpf from cgroup itself")
    Signed-off-by: Quanyang Wang <quanyang.wang at windriver.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Acked-by: Roman Gushchin <guro at fb.com>
    Acked-by: John Fastabend <john.fastabend at gmail.com>
    Link: https://lore.kernel.org/bpf/20211018075623.26884-1-quanyang.wang@windriver.com

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 570b0c97392a..ea08f01d0111 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -2187,8 +2187,10 @@ static void cgroup_kill_sb(struct super_block *sb)
 	 * And don't kill the default root.
 	 */
 	if (list_empty(&root->cgrp.self.children) && root != &cgrp_dfl_root &&
-	    !percpu_ref_is_dying(&root->cgrp.self.refcnt))
+	    !percpu_ref_is_dying(&root->cgrp.self.refcnt)) {
+		cgroup_bpf_offline(&root->cgrp);
 		percpu_ref_kill(&root->cgrp.self.refcnt);
+	}
 	cgroup_put(&root->cgrp);
 	kernfs_kill_sb(sb);
 }
commit fda7a38714f40b635f5502ec4855602c6b33dad2
Author: Xu Kuohai <xukuohai at huawei.com>
Date:   Tue Oct 19 03:29:34 2021 +0000

    bpf: Fix error usage of map_fd and fdget() in generic_map_update_batch()
    
    1. The ufd in generic_map_update_batch() should be read from batch.map_fd;
    2. A call to fdget() should be followed by a symmetric call to fdput().
    
    Fixes: aa2e93b8e58e ("bpf: Add generic support for update and delete batch ops")
    Signed-off-by: Xu Kuohai <xukuohai at huawei.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Link: https://lore.kernel.org/bpf/20211019032934.1210517-1-xukuohai@huawei.com

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 4e50c0bfdb7d..9dab49d3f394 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1337,12 +1337,11 @@ int generic_map_update_batch(struct bpf_map *map,
 	void __user *values = u64_to_user_ptr(attr->batch.values);
 	void __user *keys = u64_to_user_ptr(attr->batch.keys);
 	u32 value_size, cp, max_count;
-	int ufd = attr->map_fd;
+	int ufd = attr->batch.map_fd;
 	void *key, *value;
 	struct fd f;
 	int err = 0;
 
-	f = fdget(ufd);
 	if (attr->batch.elem_flags & ~BPF_F_LOCK)
 		return -EINVAL;
 
@@ -1367,6 +1366,7 @@ int generic_map_update_batch(struct bpf_map *map,
 		return -ENOMEM;
 	}
 
+	f = fdget(ufd); /* bpf_map_do_batch() guarantees ufd is valid */
 	for (cp = 0; cp < max_count; cp++) {
 		err = -EFAULT;
 		if (copy_from_user(key, keys + cp * map->key_size,
@@ -1386,6 +1386,7 @@ int generic_map_update_batch(struct bpf_map *map,
 
 	kvfree(value);
 	kvfree(key);
+	fdput(f);
 	return err;
 }
 
commit 22a127908e747c7ede8382d5f8d4cc6c9920004f
Merge: 4225fea1cb28 fadb7ff1a6c2
Author: Alexei Starovoitov <ast at kernel.org>
Date:   Wed Oct 20 18:19:02 2021 -0700

    Merge branch 'Fix up bpf_jit_limit some more'
    
    Lorenz Bauer says:
    
    ====================
    Fix some inconsistencies of bpf_jit_limit on non-x86 platforms.
    I've dropped exposing bpf_jit_current since we couldn't agree on
    file modes, correct names, etc.
    ====================
    
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>

commit fadb7ff1a6c2c565af56b4aacdd086b067eed440
Author: Lorenz Bauer <lmb at cloudflare.com>
Date:   Thu Oct 14 15:25:53 2021 +0100

    bpf: Prevent increasing bpf_jit_limit above max
    
    Restrict bpf_jit_limit to the maximum supported by the arch's JIT.
    
    Signed-off-by: Lorenz Bauer <lmb at cloudflare.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Link: https://lore.kernel.org/bpf/20211014142554.53120-4-lmb@cloudflare.com

diff --git a/include/linux/filter.h b/include/linux/filter.h
index 4a93c12543ee..ef03ff34234d 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1051,6 +1051,7 @@ extern int bpf_jit_enable;
 extern int bpf_jit_harden;
 extern int bpf_jit_kallsyms;
 extern long bpf_jit_limit;
+extern long bpf_jit_limit_max;
 
 typedef void (*bpf_jit_fill_hole_t)(void *area, unsigned int size);
 
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index d6b7dfdd8066..c1e7eb3f1876 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -524,6 +524,7 @@ int bpf_jit_enable   __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_DEFAULT_ON);
 int bpf_jit_kallsyms __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_DEFAULT_ON);
 int bpf_jit_harden   __read_mostly;
 long bpf_jit_limit   __read_mostly;
+long bpf_jit_limit_max __read_mostly;
 
 static void
 bpf_prog_ksym_set_addr(struct bpf_prog *prog)
@@ -817,7 +818,8 @@ u64 __weak bpf_jit_alloc_exec_limit(void)
 static int __init bpf_jit_charge_init(void)
 {
 	/* Only used as heuristic here to derive limit. */
-	bpf_jit_limit = min_t(u64, round_up(bpf_jit_alloc_exec_limit() >> 2,
+	bpf_jit_limit_max = bpf_jit_alloc_exec_limit();
+	bpf_jit_limit = min_t(u64, round_up(bpf_jit_limit_max >> 2,
 					    PAGE_SIZE), LONG_MAX);
 	return 0;
 }
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index c8496c1142c9..5f88526ad61c 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -419,7 +419,7 @@ static struct ctl_table net_core_table[] = {
 		.mode		= 0600,
 		.proc_handler	= proc_dolongvec_minmax_bpf_restricted,
 		.extra1		= &long_one,
-		.extra2		= &long_max,
+		.extra2		= &bpf_jit_limit_max,
 	},
 #endif
 	{
commit 5d63ae908242f028bd10860cba98450d11c079b8
Author: Lorenz Bauer <lmb at cloudflare.com>
Date:   Thu Oct 14 15:25:52 2021 +0100

    bpf: Define bpf_jit_alloc_exec_limit for arm64 JIT
    
    Expose the maximum amount of useable memory from the arm64 JIT.
    
    Signed-off-by: Lorenz Bauer <lmb at cloudflare.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Link: https://lore.kernel.org/bpf/20211014142554.53120-3-lmb@cloudflare.com

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 41c23f474ea6..803e7773fa86 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -1136,6 +1136,11 @@ out:
 	return prog;
 }
 
+u64 bpf_jit_alloc_exec_limit(void)
+{
+	return BPF_JIT_REGION_SIZE;
+}
+
 void *bpf_jit_alloc_exec(unsigned long size)
 {
 	return __vmalloc_node_range(size, PAGE_SIZE, BPF_JIT_REGION_START,
commit 8f04db78e4e36a5d4858ce841a3e9cc3d69bde36
Author: Lorenz Bauer <lmb at cloudflare.com>
Date:   Thu Oct 14 15:25:51 2021 +0100

    bpf: Define bpf_jit_alloc_exec_limit for riscv JIT
    
    Expose the maximum amount of useable memory from the riscv JIT.
    
    Signed-off-by: Lorenz Bauer <lmb at cloudflare.com>
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    Acked-by: Luke Nelson <luke.r.nels at gmail.com>
    Acked-by: Björn Töpel <bjorn at kernel.org>
    Link: https://lore.kernel.org/bpf/20211014142554.53120-2-lmb@cloudflare.com

diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c
index fed86f42dfbe..0fee2cbaaf53 100644
--- a/arch/riscv/net/bpf_jit_core.c
+++ b/arch/riscv/net/bpf_jit_core.c
@@ -166,6 +166,11 @@ out:
 	return prog;
 }
 
+u64 bpf_jit_alloc_exec_limit(void)
+{
+	return BPF_JIT_REGION_SIZE;
+}
+
 void *bpf_jit_alloc_exec(unsigned long size)
 {
 	return __vmalloc_node_range(size, PAGE_SIZE, BPF_JIT_REGION_START,
commit 1f83b835a3eaa5ae4bd825fb07182698bfc243ba
Author: Florian Westphal <fw at strlen.de>
Date:   Thu Oct 21 16:02:47 2021 +0200

    fcnal-test: kill hanging ping/nettest binaries on cleanup
    
    On my box I see a bunch of ping/nettest processes hanging
    around after fcntal-test.sh is done.
    
    Clean those up before netns deletion.
    
    Signed-off-by: Florian Westphal <fw at strlen.de>
    Acked-by: David Ahern <dsahern at kernel.org>
    Link: https://lore.kernel.org/r/20211021140247.29691-1-fw@strlen.de
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh
index 8e67a252b672..3313566ce906 100755
--- a/tools/testing/selftests/net/fcnal-test.sh
+++ b/tools/testing/selftests/net/fcnal-test.sh
@@ -445,10 +445,13 @@ cleanup()
 		ip -netns ${NSA} link set dev ${NSA_DEV} down
 		ip -netns ${NSA} link del dev ${NSA_DEV}
 
+		ip netns pids ${NSA} | xargs kill 2>/dev/null
 		ip netns del ${NSA}
 	fi
 
+	ip netns pids ${NSB} | xargs kill 2>/dev/null
 	ip netns del ${NSB}
+	ip netns pids ${NSC} | xargs kill 2>/dev/null
 	ip netns del ${NSC} >/dev/null 2>&1
 }
 
commit 32f8807a48ae55be0e76880cfe8607a18b5bb0df
Merge: 7f678def99d2 9d02831e517a
Author: Jakub Kicinski <kuba at kernel.org>
Date:   Fri Oct 22 12:36:47 2021 -0700

    Merge branch 'sctp-enhancements-for-the-verification-tag'
    
    Xin Long says:
    
    ====================
    sctp: enhancements for the verification tag
    
    This patchset is to address CVE-2021-3772:
    
      A flaw was found in the Linux SCTP stack. A blind attacker may be able to
      kill an existing SCTP association through invalid chunks if the attacker
      knows the IP-addresses and port numbers being used and the attacker can
      send packets with spoofed IP addresses.
    
    This is caused by the missing VTAG verification for the received chunks
    and the incorrect vtag for the ABORT used to reply to these invalid
    chunks.
    
    This patchset is to go over all processing functions for the received
    chunks and do:
    
    1. Make sure sctp_vtag_verify() is called firstly to verify the vtag from
       the received chunk and discard this chunk if it fails. With some
       exceptions:
    
       a. sctp_sf_do_5_1B_init()/5_2_2_dupinit()/9_2_reshutack(), processing
          INIT chunk, as sctphdr vtag is always 0 in INIT chunk.
    
       b. sctp_sf_do_5_2_4_dupcook(), processing dupicate COOKIE_ECHO chunk,
          as the vtag verification will be done by sctp_tietags_compare() and
          then it takes right actions according to the return.
    
       c. sctp_sf_shut_8_4_5(), processing SHUTDOWN_ACK chunk for cookie_wait
          and cookie_echoed state, as RFC demand sending a SHUTDOWN_COMPLETE
          even if the vtag verification failed.
    
       d. sctp_sf_ootb(), called in many types of chunks for closed state or
          no asoc, as the same reason to c.
    
    2. Always use the vtag from the received INIT chunk to make the response
       ABORT in sctp_ootb_pkt_new().
    
    3. Fix the order for some checks and add some missing checks for the
       received chunk.
    
    This patch series has been tested with SCTP TAHI testing to make sure no
    regression caused on protocol conformance.
    ====================
    
    Link: https://lore.kernel.org/r/cover.1634730082.git.lucien.xin@gmail.com
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

commit 9d02831e517aa36ee6bdb453a0eb47bd49923fe3
Author: Xin Long <lucien.xin at gmail.com>
Date:   Wed Oct 20 07:42:47 2021 -0400

    sctp: add vtag check in sctp_sf_ootb
    
    sctp_sf_ootb() is called when processing DATA chunk in closed state,
    and many other places are also using it.
    
    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.
    
    When fails to verify the vtag from the chunk, this patch sets asoc
    to NULL, so that the abort will be made with the vtag from the
    received chunk later.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin at gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index a3545498a038..fb3da4d8f4a3 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -3688,6 +3688,9 @@ enum sctp_disposition sctp_sf_ootb(struct net *net,
 
 	SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES);
 
+	if (asoc && !sctp_vtag_verify(chunk, asoc))
+		asoc = NULL;
+
 	ch = (struct sctp_chunkhdr *)chunk->chunk_hdr;
 	do {
 		/* Report violation if the chunk is less then minimal */
commit ef16b1734f0a176277b7bb9c71a6d977a6ef3998
Author: Xin Long <lucien.xin at gmail.com>
Date:   Wed Oct 20 07:42:46 2021 -0400

    sctp: add vtag check in sctp_sf_do_8_5_1_E_sa
    
    sctp_sf_do_8_5_1_E_sa() is called when processing SHUTDOWN_ACK chunk
    in cookie_wait and cookie_echoed state.
    
    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.
    
    Note that when fails to verify the vtag from SHUTDOWN-ACK chunk,
    SHUTDOWN COMPLETE message will still be sent back to peer, but
    with the vtag from SHUTDOWN-ACK chunk, as said in 5) of
    rfc4960#section-8.4.
    
    While at it, also remove the unnecessary chunk length check from
    sctp_sf_shut_8_4_5(), as it's already done in both places where
    it calls sctp_sf_shut_8_4_5().
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin at gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 36328ab88bdd..a3545498a038 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -3803,12 +3803,6 @@ static enum sctp_disposition sctp_sf_shut_8_4_5(
 
 	SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
 
-	/* If the chunk length is invalid, we don't want to process
-	 * the reset of the packet.
-	 */
-	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
-		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
-
 	/* We need to discard the rest of the packet to prevent
 	 * potential boomming attacks from additional bundled chunks.
 	 * This is documented in SCTP Threats ID.
@@ -3836,6 +3830,9 @@ enum sctp_disposition sctp_sf_do_8_5_1_E_sa(struct net *net,
 {
 	struct sctp_chunk *chunk = arg;
 
+	if (!sctp_vtag_verify(chunk, asoc))
+		asoc = NULL;
+
 	/* Make sure that the SHUTDOWN_ACK chunk has a valid length. */
 	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
 		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commit aa0f697e45286a6b5f0ceca9418acf54b9099d99
Author: Xin Long <lucien.xin at gmail.com>
Date:   Wed Oct 20 07:42:45 2021 -0400

    sctp: add vtag check in sctp_sf_violation
    
    sctp_sf_violation() is called when processing HEARTBEAT_ACK chunk
    in cookie_wait state, and some other places are also using it.
    
    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin at gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 96a069d725e9..36328ab88bdd 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -4669,6 +4669,9 @@ enum sctp_disposition sctp_sf_violation(struct net *net,
 {
 	struct sctp_chunk *chunk = arg;
 
+	if (!sctp_vtag_verify(chunk, asoc))
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+
 	/* Make sure that the chunk has a valid length. */
 	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
 		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commit a64b341b8695e1c744dd972b39868371b4f68f83
Author: Xin Long <lucien.xin at gmail.com>
Date:   Wed Oct 20 07:42:44 2021 -0400

    sctp: fix the processing for COOKIE_ECHO chunk
    
    1. In closed state: in sctp_sf_do_5_1D_ce():
    
      When asoc is NULL, making packet for abort will use chunk's vtag
      in sctp_ootb_pkt_new(). But when asoc exists, vtag from the chunk
      should be verified before using peer.i.init_tag to make packet
      for abort in sctp_ootb_pkt_new(), and just discard it if vtag is
      not correct.
    
    2. In the other states: in sctp_sf_do_5_2_4_dupcook():
    
      asoc always exists, but duplicate cookie_echo's vtag will be
      handled by sctp_tietags_compare() and then take actions, so before
      that we only verify the vtag for the abort sent for invalid chunk
      length.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin at gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 672e5308839b..96a069d725e9 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -710,6 +710,9 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
 	struct sock *sk;
 	int error = 0;
 
+	if (asoc && !sctp_vtag_verify(chunk, asoc))
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+
 	/* If the packet is an OOTB packet which is temporarily on the
 	 * control endpoint, respond with an ABORT.
 	 */
@@ -724,7 +727,8 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
 	 * in sctp_unpack_cookie().
 	 */
 	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
-		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
+						  commands);
 
 	/* If the endpoint is not listening or if the number of associations
 	 * on the TCP-style socket exceed the max backlog, respond with an
@@ -2204,9 +2208,11 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook(
 	 * enough for the chunk header.  Cookie length verification is
 	 * done later.
 	 */
-	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
-		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
-						  commands);
+	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) {
+		if (!sctp_vtag_verify(chunk, asoc))
+			asoc = NULL;
+		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, commands);
+	}
 
 	/* "Decode" the chunk.  We have no optional parameters so we
 	 * are in good shape.
commit 438b95a7c98f77d51cbf4db021f41b602d750a3f
Author: Xin Long <lucien.xin at gmail.com>
Date:   Wed Oct 20 07:42:43 2021 -0400

    sctp: fix the processing for INIT_ACK chunk
    
    Currently INIT_ACK chunk in non-cookie_echoed state is processed in
    sctp_sf_discard_chunk() to send an abort with the existent asoc's
    vtag if the chunk length is not valid. But the vtag in the chunk's
    sctphdr is not verified, which may be exploited by one to cook a
    malicious chunk to terminal a SCTP asoc.
    
    sctp_sf_discard_chunk() also is called in many other places to send
    an abort, and most of those have this problem. This patch is to fix
    it by sending abort with the existent asoc's vtag only if the vtag
    from the chunk's sctphdr is verified in sctp_sf_discard_chunk().
    
    Note on sctp_sf_do_9_1_abort() and sctp_sf_shutdown_pending_abort(),
    the chunk length has been verified before sctp_sf_discard_chunk(),
    so replace it with sctp_sf_discard(). On sctp_sf_do_asconf_ack() and
    sctp_sf_do_asconf(), move the sctp_chunk_length_valid check ahead of
    sctp_sf_discard_chunk(), then replace it with sctp_sf_discard().
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin at gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 9bfa8cca9974..672e5308839b 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -2343,7 +2343,7 @@ enum sctp_disposition sctp_sf_shutdown_pending_abort(
 	 */
 	if (SCTP_ADDR_DEL ==
 		    sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
-		return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 
 	if (!sctp_err_chunk_valid(chunk))
 		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
@@ -2389,7 +2389,7 @@ enum sctp_disposition sctp_sf_shutdown_sent_abort(
 	 */
 	if (SCTP_ADDR_DEL ==
 		    sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
-		return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 
 	if (!sctp_err_chunk_valid(chunk))
 		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
@@ -2659,7 +2659,7 @@ enum sctp_disposition sctp_sf_do_9_1_abort(
 	 */
 	if (SCTP_ADDR_DEL ==
 		    sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
-		return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 
 	if (!sctp_err_chunk_valid(chunk))
 		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
@@ -3865,6 +3865,11 @@ enum sctp_disposition sctp_sf_do_asconf(struct net *net,
 		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 	}
 
+	/* Make sure that the ASCONF ADDIP chunk has a valid length.  */
+	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_addip_chunk)))
+		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
+						  commands);
+
 	/* ADD-IP: Section 4.1.1
 	 * This chunk MUST be sent in an authenticated way by using
 	 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk
@@ -3873,13 +3878,7 @@ enum sctp_disposition sctp_sf_do_asconf(struct net *net,
 	 */
 	if (!asoc->peer.asconf_capable ||
 	    (!net->sctp.addip_noauth && !chunk->auth))
-		return sctp_sf_discard_chunk(net, ep, asoc, type, arg,
-					     commands);
-
-	/* Make sure that the ASCONF ADDIP chunk has a valid length.  */
-	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_addip_chunk)))
-		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
-						  commands);
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 
 	hdr = (struct sctp_addiphdr *)chunk->skb->data;
 	serial = ntohl(hdr->serial);
@@ -4008,6 +4007,12 @@ enum sctp_disposition sctp_sf_do_asconf_ack(struct net *net,
 		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 	}
 
+	/* Make sure that the ADDIP chunk has a valid length.  */
+	if (!sctp_chunk_length_valid(asconf_ack,
+				     sizeof(struct sctp_addip_chunk)))
+		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
+						  commands);
+
 	/* ADD-IP, Section 4.1.2:
 	 * This chunk MUST be sent in an authenticated way by using
 	 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk
@@ -4016,14 +4021,7 @@ enum sctp_disposition sctp_sf_do_asconf_ack(struct net *net,
 	 */
 	if (!asoc->peer.asconf_capable ||
 	    (!net->sctp.addip_noauth && !asconf_ack->auth))
-		return sctp_sf_discard_chunk(net, ep, asoc, type, arg,
-					     commands);
-
-	/* Make sure that the ADDIP chunk has a valid length.  */
-	if (!sctp_chunk_length_valid(asconf_ack,
-				     sizeof(struct sctp_addip_chunk)))
-		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
-						  commands);
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 
 	addip_hdr = (struct sctp_addiphdr *)asconf_ack->skb->data;
 	rcvd_serial = ntohl(addip_hdr->serial);
@@ -4595,6 +4593,9 @@ enum sctp_disposition sctp_sf_discard_chunk(struct net *net,
 {
 	struct sctp_chunk *chunk = arg;
 
+	if (asoc && !sctp_vtag_verify(chunk, asoc))
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+
 	/* Make sure that the chunk has a valid length.
 	 * Since we don't know the chunk type, we use a general
 	 * chunkhdr structure to make a comparison.
commit eae5783908042a762c24e1bd11876edb91d314b1
Author: Xin Long <lucien.xin at gmail.com>
Date:   Wed Oct 20 07:42:42 2021 -0400

    sctp: fix the processing for INIT chunk
    
    This patch fixes the problems below:
    
    1. In non-shutdown_ack_sent states: in sctp_sf_do_5_1B_init() and
       sctp_sf_do_5_2_2_dupinit():
    
      chunk length check should be done before any checks that may cause
      to send abort, as making packet for abort will access the init_tag
      from init_hdr in sctp_ootb_pkt_new().
    
    2. In shutdown_ack_sent state: in sctp_sf_do_9_2_reshutack():
    
      The same checks as does in sctp_sf_do_5_2_2_dupinit() is needed
      for sctp_sf_do_9_2_reshutack().
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin at gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 7f8306968c39..9bfa8cca9974 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -156,6 +156,12 @@ static enum sctp_disposition __sctp_sf_do_9_1_abort(
 					void *arg,
 					struct sctp_cmd_seq *commands);
 
+static enum sctp_disposition
+__sctp_sf_do_9_2_reshutack(struct net *net, const struct sctp_endpoint *ep,
+			   const struct sctp_association *asoc,
+			   const union sctp_subtype type, void *arg,
+			   struct sctp_cmd_seq *commands);
+
 /* Small helper function that checks if the chunk length
  * is of the appropriate length.  The 'required_length' argument
  * is set to be the size of a specific chunk we are testing.
@@ -337,6 +343,14 @@ enum sctp_disposition sctp_sf_do_5_1B_init(struct net *net,
 	if (!chunk->singleton)
 		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 
+	/* Make sure that the INIT chunk has a valid length.
+	 * Normally, this would cause an ABORT with a Protocol Violation
+	 * error, but since we don't have an association, we'll
+	 * just discard the packet.
+	 */
+	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_init_chunk)))
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+
 	/* If the packet is an OOTB packet which is temporarily on the
 	 * control endpoint, respond with an ABORT.
 	 */
@@ -351,14 +365,6 @@ enum sctp_disposition sctp_sf_do_5_1B_init(struct net *net,
 	if (chunk->sctp_hdr->vtag != 0)
 		return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands);
 
-	/* Make sure that the INIT chunk has a valid length.
-	 * Normally, this would cause an ABORT with a Protocol Violation
-	 * error, but since we don't have an association, we'll
-	 * just discard the packet.
-	 */
-	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_init_chunk)))
-		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
-
 	/* If the INIT is coming toward a closing socket, we'll send back
 	 * and ABORT.  Essentially, this catches the race of INIT being
 	 * backloged to the socket at the same time as the user issues close().
@@ -1524,20 +1530,16 @@ static enum sctp_disposition sctp_sf_do_unexpected_init(
 	if (!chunk->singleton)
 		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 
+	/* Make sure that the INIT chunk has a valid length. */
+	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_init_chunk)))
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+
 	/* 3.1 A packet containing an INIT chunk MUST have a zero Verification
 	 * Tag.
 	 */
 	if (chunk->sctp_hdr->vtag != 0)
 		return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands);
 
-	/* Make sure that the INIT chunk has a valid length.
-	 * In this case, we generate a protocol violation since we have
-	 * an association established.
-	 */
-	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_init_chunk)))
-		return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
-						  commands);
-
 	if (SCTP_INPUT_CB(chunk->skb)->encap_port != chunk->transport->encap_port)
 		return sctp_sf_new_encap_port(net, ep, asoc, type, arg, commands);
 
@@ -1882,9 +1884,9 @@ static enum sctp_disposition sctp_sf_do_dupcook_a(
 	 * its peer.
 	*/
 	if (sctp_state(asoc, SHUTDOWN_ACK_SENT)) {
-		disposition = sctp_sf_do_9_2_reshutack(net, ep, asoc,
-				SCTP_ST_CHUNK(chunk->chunk_hdr->type),
-				chunk, commands);
+		disposition = __sctp_sf_do_9_2_reshutack(net, ep, asoc,
+							 SCTP_ST_CHUNK(chunk->chunk_hdr->type),
+							 chunk, commands);
 		if (SCTP_DISPOSITION_NOMEM == disposition)
 			goto nomem;
 
@@ -2970,13 +2972,11 @@ enum sctp_disposition sctp_sf_do_9_2_shut_ctsn(
  * that belong to this association, it should discard the INIT chunk and
  * retransmit the SHUTDOWN ACK chunk.
  */
-enum sctp_disposition sctp_sf_do_9_2_reshutack(
-					struct net *net,
-					const struct sctp_endpoint *ep,
-					const struct sctp_association *asoc,
-					const union sctp_subtype type,
-					void *arg,
-					struct sctp_cmd_seq *commands)
+static enum sctp_disposition
+__sctp_sf_do_9_2_reshutack(struct net *net, const struct sctp_endpoint *ep,
+			   const struct sctp_association *asoc,
+			   const union sctp_subtype type, void *arg,
+			   struct sctp_cmd_seq *commands)
 {
 	struct sctp_chunk *chunk = arg;
 	struct sctp_chunk *reply;
@@ -3010,6 +3010,26 @@ nomem:
 	return SCTP_DISPOSITION_NOMEM;
 }
 
+enum sctp_disposition
+sctp_sf_do_9_2_reshutack(struct net *net, const struct sctp_endpoint *ep,
+			 const struct sctp_association *asoc,
+			 const union sctp_subtype type, void *arg,
+			 struct sctp_cmd_seq *commands)
+{
+	struct sctp_chunk *chunk = arg;
+
+	if (!chunk->singleton)
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+
+	if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_init_chunk)))
+		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+
+	if (chunk->sctp_hdr->vtag != 0)
+		return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands);
+
+	return __sctp_sf_do_9_2_reshutack(net, ep, asoc, type, arg, commands);
+}
+
 /*
  * sctp_sf_do_ecn_cwr
  *
commit 4f7019c7eb33967eb87766e0e4602b5576873680
Author: Xin Long <lucien.xin at gmail.com>
Date:   Wed Oct 20 07:42:41 2021 -0400

    sctp: use init_tag from inithdr for ABORT chunk
    
    Currently Linux SCTP uses the verification tag of the existing SCTP
    asoc when failing to process and sending the packet with the ABORT
    chunk. This will result in the peer accepting the ABORT chunk and
    removing the SCTP asoc. One could exploit this to terminate a SCTP
    asoc.
    
    This patch is to fix it by always using the initiate tag of the
    received INIT chunk for the ABORT chunk to be sent.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin at gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 32df65f68c12..7f8306968c39 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -6348,6 +6348,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(
 		 * yet.
 		 */
 		switch (chunk->chunk_hdr->type) {
+		case SCTP_CID_INIT:
 		case SCTP_CID_INIT_ACK:
 		{
 			struct sctp_initack_chunk *initack;
commit 7f678def99d29c520418607509bb19c7fc96a6db
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Fri Oct 22 13:28:37 2021 +0300

    skb_expand_head() adjust skb->truesize incorrectly
    
    Christoph Paasch reports [1] about incorrect skb->truesize
    after skb_expand_head() call in ip6_xmit.
    This may happen because of two reasons:
    - skb_set_owner_w() for newly cloned skb is called too early,
    before pskb_expand_head() where truesize is adjusted for (!skb-sk) case.
    - pskb_expand_head() does not adjust truesize in (skb->sk) case.
    In this case sk->sk_wmem_alloc should be adjusted too.
    
    [1] https://lkml.org/lkml/2021/8/20/1082
    
    Fixes: f1260ff15a71 ("skbuff: introduce skb_expand_head()")
    Fixes: 2d85a1b31dde ("ipv6: ip6_finish_output2: set sk into newly allocated nskb")
    Reported-by: Christoph Paasch <christoph.paasch at gmail.com>
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
    Reviewed-by: Eric Dumazet <edumazet at google.com>
    Link: https://lore.kernel.org/r/644330dd-477e-0462-83bf-9f514c41edd1@virtuozzo.com
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2170bea2c7de..fe9358437380 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -80,6 +80,7 @@
 #include <linux/indirect_call_wrapper.h>
 
 #include "datagram.h"
+#include "sock_destructor.h"
 
 struct kmem_cache *skbuff_head_cache __ro_after_init;
 static struct kmem_cache *skbuff_fclone_cache __ro_after_init;
@@ -1804,30 +1805,39 @@ EXPORT_SYMBOL(skb_realloc_headroom);
 struct sk_buff *skb_expand_head(struct sk_buff *skb, unsigned int headroom)
 {
 	int delta = headroom - skb_headroom(skb);
+	int osize = skb_end_offset(skb);
+	struct sock *sk = skb->sk;
 
 	if (WARN_ONCE(delta <= 0,
 		      "%s is expecting an increase in the headroom", __func__))
 		return skb;
 
-	/* pskb_expand_head() might crash, if skb is shared */
-	if (skb_shared(skb)) {
+	delta = SKB_DATA_ALIGN(delta);
+	/* pskb_expand_head() might crash, if skb is shared. */
+	if (skb_shared(skb) || !is_skb_wmem(skb)) {
 		struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
 
-		if (likely(nskb)) {
-			if (skb->sk)
-				skb_set_owner_w(nskb, skb->sk);
-			consume_skb(skb);
-		} else {
-			kfree_skb(skb);
-		}
+		if (unlikely(!nskb))
+			goto fail;
+
+		if (sk)
+			skb_set_owner_w(nskb, sk);
+		consume_skb(skb);
 		skb = nskb;
 	}
-	if (skb &&
-	    pskb_expand_head(skb, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) {
-		kfree_skb(skb);
-		skb = NULL;
+	if (pskb_expand_head(skb, delta, 0, GFP_ATOMIC))
+		goto fail;
+
+	if (sk && is_skb_wmem(skb)) {
+		delta = skb_end_offset(skb) - osize;
+		refcount_add(delta, &sk->sk_wmem_alloc);
+		skb->truesize += delta;
 	}
 	return skb;
+
+fail:
+	kfree_skb(skb);
+	return NULL;
 }
 EXPORT_SYMBOL(skb_expand_head);
 
diff --git a/net/core/sock_destructor.h b/net/core/sock_destructor.h
new file mode 100644
index 000000000000..2f396e6bfba5
--- /dev/null
+++ b/net/core/sock_destructor.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _NET_CORE_SOCK_DESTRUCTOR_H
+#define _NET_CORE_SOCK_DESTRUCTOR_H
+#include <net/tcp.h>
+
+static inline bool is_skb_wmem(const struct sk_buff *skb)
+{
+	return skb->destructor == sock_wfree ||
+	       skb->destructor == __sock_wfree ||
+	       (IS_ENABLED(CONFIG_INET) && skb->destructor == tcp_wfree);
+}
+#endif
commit 7fcb1c950e98e47918e86a5aa7b8fcc283ec6629
Merge: 64222515138e a2083eeb119f
Author: Jakub Kicinski <kuba at kernel.org>
Date:   Fri Oct 22 11:12:45 2021 -0700

    Merge tag 'mac80211-for-net-2021-10-21' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211
    
    Johannes Berg says:
    
    ====================
    Two small fixes:
     * RCU misuse in scan processing in cfg80211
     * missing size check for HE data in mac80211 mesh
    
    * tag 'mac80211-for-net-2021-10-21' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211:
      cfg80211: scan: fix RCU in cfg80211_add_nontrans_list()
      mac80211: mesh: fix HE operation element length check
    ====================
    
    Link: https://lore.kernel.org/r/20211021154351.134297-1-johannes@sipsolutions.net
    Signed-off-by: Jakub Kicinski <kuba at kernel.org>

commit f8690a4b5a1b64f74ae5c4f7c4ea880d8a8e1a0d
Author: Tianjia Zhang <tianjia.zhang at linux.alibaba.com>
Date:   Fri Oct 15 11:47:33 2021 +0800

    crypto: x86/sm4 - Fix invalid section entry size
    
    This fixes the following warning:
    
      vmlinux.o: warning: objtool: elf_update: invalid section entry size
    
    The size of the rodata section is 164 bytes, directly using the
    entry_size of 164 bytes will cause errors in some versions of the
    gcc compiler, while using 16 bytes directly will cause errors in
    the clang compiler. This patch correct it by filling the size of
    rodata to a 16-byte boundary.
    
    Fixes: a7ee22ee1445 ("crypto: x86/sm4 - add AES-NI/AVX/x86_64 implementation")
    Fixes: 5b2efa2bb865 ("crypto: x86/sm4 - add AES-NI/AVX2/x86_64 implementation")
    Reported-by: Peter Zijlstra <peterz at infradead.org>
    Reported-by: Abaci Robot <abaci at linux.alibaba.com>
    Signed-off-by: Tianjia Zhang <tianjia.zhang at linux.alibaba.com>
    Tested-by: Heyuan Shi <heyuan at linux.alibaba.com>
    Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>

diff --git a/arch/x86/crypto/sm4-aesni-avx-asm_64.S b/arch/x86/crypto/sm4-aesni-avx-asm_64.S
index 18d2f5199194..1cc72b4804fa 100644
--- a/arch/x86/crypto/sm4-aesni-avx-asm_64.S
+++ b/arch/x86/crypto/sm4-aesni-avx-asm_64.S
@@ -78,7 +78,7 @@
 	vpxor tmp0, x, x;
 
 
-.section	.rodata.cst164, "aM", @progbits, 164
+.section	.rodata.cst16, "aM", @progbits, 16
 .align 16
 
 /*
@@ -133,6 +133,10 @@
 .L0f0f0f0f:
 	.long 0x0f0f0f0f
 
+/* 12 bytes, only for padding */
+.Lpadding_deadbeef:
+	.long 0xdeadbeef, 0xdeadbeef, 0xdeadbeef
+
 
 .text
 .align 16
diff --git a/arch/x86/crypto/sm4-aesni-avx2-asm_64.S b/arch/x86/crypto/sm4-aesni-avx2-asm_64.S
index d2ffd7f76ee2..9c5d3f3ad45a 100644
--- a/arch/x86/crypto/sm4-aesni-avx2-asm_64.S
+++ b/arch/x86/crypto/sm4-aesni-avx2-asm_64.S
@@ -93,7 +93,7 @@
 	vpxor tmp0, x, x;
 
 
-.section	.rodata.cst164, "aM", @progbits, 164
+.section	.rodata.cst16, "aM", @progbits, 16
 .align 16
 
 /*
@@ -148,6 +148,10 @@
 .L0f0f0f0f:
 	.long 0x0f0f0f0f
 
+/* 12 bytes, only for padding */
+.Lpadding_deadbeef:
+	.long 0xdeadbeef, 0xdeadbeef, 0xdeadbeef
+
 .text
 .align 16
 
commit 0943aacf5ae10471b68a702c022b42c89e91ba9e
Author: Xie Yongji <xieyongji at bytedance.com>
Date:   Wed Sep 29 16:30:50 2021 +0800

    vduse: Fix race condition between resetting and irq injecting
    
    The interrupt might be triggered after a reset since there is
    no synchronization between resetting and irq injecting. And it
    might break something if the interrupt is delayed until a new
    round of device initialization.
    
    Fixes: c8a6153b6c59 ("vduse: Introduce VDUSE - vDPA Device in Userspace")
    Signed-off-by: Xie Yongji <xieyongji at bytedance.com>
    Link: https://lore.kernel.org/r/20210929083050.88-1-xieyongji@bytedance.com
    Signed-off-by: Michael S. Tsirkin <mst at redhat.com>

diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index cefb301b2ee4..841667a896dd 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -80,6 +80,7 @@ struct vduse_dev {
 	struct vdpa_callback config_cb;
 	struct work_struct inject;
 	spinlock_t irq_lock;
+	struct rw_semaphore rwsem;
 	int minor;
 	bool broken;
 	bool connected;
@@ -410,6 +411,8 @@ static void vduse_dev_reset(struct vduse_dev *dev)
 	if (domain->bounce_map)
 		vduse_domain_reset_bounce_map(domain);
 
+	down_write(&dev->rwsem);
+
 	dev->status = 0;
 	dev->driver_features = 0;
 	dev->generation++;
@@ -443,6 +446,8 @@ static void vduse_dev_reset(struct vduse_dev *dev)
 		flush_work(&vq->inject);
 		flush_work(&vq->kick);
 	}
+
+	up_write(&dev->rwsem);
 }
 
 static int vduse_vdpa_set_vq_address(struct vdpa_device *vdpa, u16 idx,
@@ -885,6 +890,23 @@ static void vduse_vq_irq_inject(struct work_struct *work)
 	spin_unlock_irq(&vq->irq_lock);
 }
 
+static int vduse_dev_queue_irq_work(struct vduse_dev *dev,
+				    struct work_struct *irq_work)
+{
+	int ret = -EINVAL;
+
+	down_read(&dev->rwsem);
+	if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
+		goto unlock;
+
+	ret = 0;
+	queue_work(vduse_irq_wq, irq_work);
+unlock:
+	up_read(&dev->rwsem);
+
+	return ret;
+}
+
 static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
 			    unsigned long arg)
 {
@@ -966,12 +988,7 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
 		break;
 	}
 	case VDUSE_DEV_INJECT_CONFIG_IRQ:
-		ret = -EINVAL;
-		if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
-			break;
-
-		ret = 0;
-		queue_work(vduse_irq_wq, &dev->inject);
+		ret = vduse_dev_queue_irq_work(dev, &dev->inject);
 		break;
 	case VDUSE_VQ_SETUP: {
 		struct vduse_vq_config config;
@@ -1049,10 +1066,6 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
 	case VDUSE_VQ_INJECT_IRQ: {
 		u32 index;
 
-		ret = -EINVAL;
-		if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
-			break;
-
 		ret = -EFAULT;
 		if (get_user(index, (u32 __user *)argp))
 			break;
@@ -1061,9 +1074,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
 		if (index >= dev->vq_num)
 			break;
 
-		ret = 0;
 		index = array_index_nospec(index, dev->vq_num);
-		queue_work(vduse_irq_wq, &dev->vqs[index].inject);
+		ret = vduse_dev_queue_irq_work(dev, &dev->vqs[index].inject);
 		break;
 	}
 	default:
@@ -1144,6 +1156,7 @@ static struct vduse_dev *vduse_dev_create(void)
 	INIT_LIST_HEAD(&dev->send_list);
 	INIT_LIST_HEAD(&dev->recv_list);
 	spin_lock_init(&dev->irq_lock);
+	init_rwsem(&dev->rwsem);
 
 	INIT_WORK(&dev->inject, vduse_dev_irq_inject);
 	init_waitqueue_head(&dev->waitq);
commit 1394103fd72ce9c67d20f882a93d59403c8da057
Author: Xie Yongji <xieyongji at bytedance.com>
Date:   Thu Sep 23 15:57:22 2021 +0800

    vduse: Disallow injecting interrupt before DRIVER_OK is set
    
    The interrupt callback should not be triggered before DRIVER_OK
    is set. Otherwise, it might break the virtio device driver.
    So let's add a check to avoid the unexpected behavior.
    
    Fixes: c8a6153b6c59 ("vduse: Introduce VDUSE - vDPA Device in Userspace")
    Signed-off-by: Xie Yongji <xieyongji at bytedance.com>
    Link: https://lore.kernel.org/r/20210923075722.98-1-xieyongji@bytedance.com
    Signed-off-by: Michael S. Tsirkin <mst at redhat.com>

diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 26e3d90d1e7c..cefb301b2ee4 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -966,6 +966,10 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
 		break;
 	}
 	case VDUSE_DEV_INJECT_CONFIG_IRQ:
+		ret = -EINVAL;
+		if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
+			break;
+
 		ret = 0;
 		queue_work(vduse_irq_wq, &dev->inject);
 		break;
@@ -1045,6 +1049,10 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
 	case VDUSE_VQ_INJECT_IRQ: {
 		u32 index;
 
+		ret = -EINVAL;
+		if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
+			break;
+
 		ret = -EFAULT;
 		if (get_user(index, (u32 __user *)argp))
 			break;
commit ee71fb6c4d99c51f2d82a32c503c872b7e40e7f7
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Thu Oct 21 22:20:48 2021 +0200

    drm/i915/selftests: Properly reset mock object propers for each test
    
    I forgot to do this properly in
    
    commit 6f11f37459d8f9f74ff1c299c0bedd50b458057a
    Author: Daniel Vetter <daniel.vetter at ffwll.ch>
    Date:   Fri Jul 23 10:34:55 2021 +0200
    
        drm/plane: remove drm_helper_get_plane_damage_clips
    
    intel-gfx CI didn't spot this because we run each selftest in each own
    invocations, which means reloading i915.ko. But if you just run all
    the selftests in one go at boot-up, then it falls apart and eventually
    we cross over the hardcoded limited of how many properties can be
    attached to a single object.
    
    Fix this by resetting the property count. Nothing else to clean up
    since it's all static storage anyway.
    
    Reported-and-tested-by: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
    Fixes: 6f11f37459d8 ("drm/plane: remove drm_helper_get_plane_damage_clips")
    Cc: José Roberto de Souza <jose.souza at intel.com>
    Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Cc: Gwan-gyeong Mun <gwan-gyeong.mun at intel.com>
    Cc: Hans de Goede <hdegoede at redhat.com>
    Cc: Daniel Vetter <daniel.vetter at intel.com>
    Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
    Cc: Maxime Ripard <mripard at kernel.org>
    Cc: Thomas Zimmermann <tzimmermann at suse.de>
    Acked-by: Thomas Zimmermann <tzimmermann at suse.de>
    Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211021202048.2638668-1-daniel.vetter@ffwll.ch

diff --git a/drivers/gpu/drm/selftests/test-drm_damage_helper.c b/drivers/gpu/drm/selftests/test-drm_damage_helper.c
index 1c19a5d3eefb..8d8d8e214c28 100644
--- a/drivers/gpu/drm/selftests/test-drm_damage_helper.c
+++ b/drivers/gpu/drm/selftests/test-drm_damage_helper.c
@@ -30,6 +30,7 @@ static void mock_setup(struct drm_plane_state *state)
 	mock_device.driver = &mock_driver;
 	mock_device.mode_config.prop_fb_damage_clips = &mock_prop;
 	mock_plane.dev = &mock_device;
+	mock_obj_props.count = 0;
 	mock_plane.base.properties = &mock_obj_props;
 	mock_prop.base.id = 1; /* 0 is an invalid id */
 	mock_prop.dev = &mock_device;
commit def0c3697287f6e85d5ac68b21302966c95474f9
Author: Bryant Mairs <bryant at mai.rs>
Date:   Tue Oct 19 09:24:33 2021 -0500

    drm: panel-orientation-quirks: Add quirk for Aya Neo 2021
    
    Fixes screen orientation for the Aya Neo 2021 handheld gaming console.
    
    Signed-off-by: Bryant Mairs <bryant at mai.rs>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211019142433.4295-1-bryant@mai.rs

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index f6bdec7fa925..30c17a76f49a 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -134,6 +134,12 @@ static const struct dmi_system_id orientation_data[] = {
 		  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T103HAF"),
 		},
 		.driver_data = (void *)&lcd800x1280_rightside_up,
+	}, {	/* AYA NEO 2021 */
+		.matches = {
+		  DMI_EXACT_MATCH(DMI_SYS_VENDOR, "AYADEVICE"),
+		  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "AYA NEO 2021"),
+		},
+		.driver_data = (void *)&lcd800x1280_rightside_up,
 	}, {	/* GPD MicroPC (generic strings, also match on bios date) */
 		.matches = {
 		  DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Default string"),
commit 0db55f9a1bafbe3dac750ea669de9134922389b5
Author: Christian König <christian.koenig at amd.com>
Date:   Wed Oct 20 19:19:46 2021 +0200

    drm/ttm: fix memleak in ttm_transfered_destroy
    
    We need to cleanup the fences for ghost objects as well.
    
    Signed-off-by: Christian König <christian.koenig at amd.com>
    Reported-by: Erhard F. <erhard_f at mailbox.org>
    Tested-by: Erhard F. <erhard_f at mailbox.org>
    Reviewed-by: Huang Rui <ray.huang at amd.com>
    Bug: https://bugzilla.kernel.org/show_bug.cgi?id=214029
    Bug: https://bugzilla.kernel.org/show_bug.cgi?id=214447
    CC: <stable at vger.kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211020173211.2247-1-christian.koenig@amd.com

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 1c5ffe2935af..abf2d7a4fdf1 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -190,6 +190,7 @@ static void ttm_transfered_destroy(struct ttm_buffer_object *bo)
 	struct ttm_transfer_obj *fbo;
 
 	fbo = container_of(bo, struct ttm_transfer_obj, base);
+	dma_resv_fini(&fbo->base.base._resv);
 	ttm_bo_put(fbo->bo);
 	kfree(fbo);
 }
commit 282da7cef078a87b6d5e8ceba8b17e428cf0e37c
Author: Chanho Park <chanho61.park at samsung.com>
Date:   Mon Oct 18 15:28:41 2021 +0900

    scsi: ufs: ufs-exynos: Correct timeout value setting registers
    
    PA_PWRMODEUSERDATA0 -> DL_FC0PROTTIMEOUTVAL
    PA_PWRMODEUSERDATA1 -> DL_TC0REPLAYTIMEOUTVAL
    PA_PWRMODEUSERDATA2 -> DL_AFC0REQTIMEOUTVAL
    
    Link: https://lore.kernel.org/r/20211018062841.18226-1-chanho61.park@samsung.com
    Fixes: a967ddb22d94 ("scsi: ufs: ufs-exynos: Apply vendor-specific values for three timeouts")
    Cc: Alim Akhtar <alim.akhtar at samsung.com>
    Cc: Kiwoong Kim <kwmad.kim at samsung.com>
    Cc: Krzysztof Kozlowski <krzysztof.kozlowski at canonical.com>
    Reviewed-by: Alim Akhtar <alim.akhtar at samsung.com>
    Reviewed-by: Avri Altman <avri.altman at wdc.com>
    Signed-off-by: Chanho Park <chanho61.park at samsung.com>
    Signed-off-by: Martin K. Petersen <martin.petersen at oracle.com>

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index a14dd8ce56d4..bb2dd79a1bcd 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -642,9 +642,9 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
 	}
 
 	/* setting for three timeout values for traffic class #0 */
-	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA0), 8064);
-	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA1), 28224);
-	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA2), 20160);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(DL_FC0PROTTIMEOUTVAL), 8064);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(DL_TC0REPLAYTIMEOUTVAL), 28224);
+	ufshcd_dme_set(hba, UIC_ARG_MIB(DL_AFC0REQTIMEOUTVAL), 20160);
 
 	return 0;
 out:
commit e20f80b9b163dc402dca115eed0affba6df5ebb5
Author: Brian King <brking at linux.vnet.ibm.com>
Date:   Tue Oct 19 10:21:29 2021 -0500

    scsi: ibmvfc: Fix up duplicate response detection
    
    Commit a264cf5e81c7 ("scsi: ibmvfc: Fix command state accounting and stale
    response detection") introduced a regression in detecting duplicate
    responses. This was observed in test where a command was sent to the VIOS
    and completed before ibmvfc_send_event() set the active flag to 1, which
    resulted in the atomic_dec_if_positive() call in ibmvfc_handle_crq()
    thinking this was a duplicate response, which resulted in scsi_done() not
    getting called, so we then hit a SCSI command timeout for this command once
    the timeout expires.  This simply ensures the active flag gets set prior to
    making the hcall to send the command to the VIOS, in order to close this
    window.
    
    Link: https://lore.kernel.org/r/20211019152129.16558-1-brking@linux.vnet.ibm.com
    Fixes: a264cf5e81c7 ("scsi: ibmvfc: Fix command state accounting and stale response detection")
    Cc: stable at vger.kernel.org
    Acked-by: Tyrel Datwyler <tyreld at linux.ibm.com>
    Signed-off-by: Brian King <brking at linux.vnet.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen at oracle.com>

diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 1f1586ad48fe..01f79991bf4a 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -1696,6 +1696,7 @@ static int ibmvfc_send_event(struct ibmvfc_event *evt,
 
 	spin_lock_irqsave(&evt->queue->l_lock, flags);
 	list_add_tail(&evt->queue_list, &evt->queue->sent);
+	atomic_set(&evt->active, 1);
 
 	mb();
 
@@ -1710,6 +1711,7 @@ static int ibmvfc_send_event(struct ibmvfc_event *evt,
 				     be64_to_cpu(crq_as_u64[1]));
 
 	if (rc) {
+		atomic_set(&evt->active, 0);
 		list_del(&evt->queue_list);
 		spin_unlock_irqrestore(&evt->queue->l_lock, flags);
 		del_timer(&evt->timer);
@@ -1737,7 +1739,6 @@ static int ibmvfc_send_event(struct ibmvfc_event *evt,
 
 		evt->done(evt);
 	} else {
-		atomic_set(&evt->active, 1);
 		spin_unlock_irqrestore(&evt->queue->l_lock, flags);
 		ibmvfc_trc_start(evt);
 	}
commit 53c2ff8bcb06acd07e24a62e7f5a0247bd7c6f67
Author: Aaron Liu <aaron.liu at amd.com>
Date:   Tue Oct 19 11:13:25 2021 +0800

    drm/amdgpu: support B0&B1 external revision id for yellow carp
    
    B0 internal rev_id is 0x01, B1 internal rev_id is 0x02.
    The external rev_id for B0 and B1 is 0x20.
    The original expression is not suitable for B1.
    
    v2: squash in fix for display code (Alex)
    
    Signed-off-by: Aaron Liu <aaron.liu at amd.com>
    Reviewed-by: Huang Rui <ray.huang at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index ff80786e3918..01efda4398e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -1257,7 +1257,7 @@ static int nv_common_early_init(void *handle)
 			AMD_PG_SUPPORT_VCN_DPG |
 			AMD_PG_SUPPORT_JPEG;
 		if (adev->pdev->device == 0x1681)
-			adev->external_rev_id = adev->rev_id + 0x19;
+			adev->external_rev_id = 0x20;
 		else
 			adev->external_rev_id = adev->rev_id + 0x01;
 		break;
diff --git a/drivers/gpu/drm/amd/display/include/dal_asic_id.h b/drivers/gpu/drm/amd/display/include/dal_asic_id.h
index 5adc471bef57..3d2f0817e40a 100644
--- a/drivers/gpu/drm/amd/display/include/dal_asic_id.h
+++ b/drivers/gpu/drm/amd/display/include/dal_asic_id.h
@@ -227,7 +227,7 @@ enum {
 #define FAMILY_YELLOW_CARP                     146
 
 #define YELLOW_CARP_A0 0x01
-#define YELLOW_CARP_B0 0x1A
+#define YELLOW_CARP_B0 0x20
 #define YELLOW_CARP_UNKNOWN 0xFF
 
 #ifndef ASICREV_IS_YELLOW_CARP
commit 2ef8ea23942f4c2569930c34e7689a0cb1b232cc
Author: Jake Wang <haonan.wang2 at amd.com>
Date:   Fri Oct 1 17:14:21 2021 -0400

    drm/amd/display: Moved dccg init to after bios golden init
    
    [Why]
    bios_golden_init will override dccg_init during init_hw.
    
    [How]
    Move dccg_init to after bios_golden_init.
    
    Reviewed-by: Aric Cyr <Aric.Cyr at amd.com>
    Reviewed-by: Eric Yang <eric.yang2 at amd.com>
    Acked-by: Agustin Gutierrez Sanchez <agustin.gutierrez at amd.com>
    Signed-off-by: Jake Wang <haonan.wang2 at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
index 3f2333ec67e2..3afa1159a5f7 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
@@ -76,10 +76,6 @@ void dcn31_init_hw(struct dc *dc)
 	if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks)
 		dc->clk_mgr->funcs->init_clocks(dc->clk_mgr);
 
-	// Initialize the dccg
-	if (res_pool->dccg->funcs->dccg_init)
-		res_pool->dccg->funcs->dccg_init(res_pool->dccg);
-
 	if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) {
 
 		REG_WRITE(REFCLK_CNTL, 0);
@@ -106,6 +102,9 @@ void dcn31_init_hw(struct dc *dc)
 		hws->funcs.bios_golden_init(dc);
 		hws->funcs.disable_vga(dc->hwseq);
 	}
+	// Initialize the dccg
+	if (res_pool->dccg->funcs->dccg_init)
+		res_pool->dccg->funcs->dccg_init(res_pool->dccg);
 
 	if (dc->debug.enable_mem_low_power.bits.dmcu) {
 		// Force ERAM to shutdown if DMCU is not enabled
commit dd8cb18906d97b2916fde42d32d915ae363c7e55
Author: Nikola Cornij <nikola.cornij at amd.com>
Date:   Fri Oct 1 13:26:05 2021 -0400

    drm/amd/display: Increase watermark latencies for DCN3.1
    
    [why]
    The original latencies were causing underflow in some modes
    
    [how]
    Replace with the up-to-date watermark values based on new measurments
    
    Reviewed-by: Ahmad Othman <ahmad.othman at amd.com>
    Acked-by: Agustin Gutierrez Sanchez <agustin.gutierrez at amd.com>
    Signed-off-by: Nikola Cornij <nikola.cornij at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
index 4a4894e9d9c9..035ba0ef6369 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
@@ -366,32 +366,32 @@ static struct wm_table lpddr5_wm_table = {
 			.wm_inst = WM_A,
 			.wm_type = WM_TYPE_PSTATE_CHG,
 			.pstate_latency_us = 11.65333,
-			.sr_exit_time_us = 5.32,
-			.sr_enter_plus_exit_time_us = 6.38,
+			.sr_exit_time_us = 11.5,
+			.sr_enter_plus_exit_time_us = 14.5,
 			.valid = true,
 		},
 		{
 			.wm_inst = WM_B,
 			.wm_type = WM_TYPE_PSTATE_CHG,
 			.pstate_latency_us = 11.65333,
-			.sr_exit_time_us = 9.82,
-			.sr_enter_plus_exit_time_us = 11.196,
+			.sr_exit_time_us = 11.5,
+			.sr_enter_plus_exit_time_us = 14.5,
 			.valid = true,
 		},
 		{
 			.wm_inst = WM_C,
 			.wm_type = WM_TYPE_PSTATE_CHG,
 			.pstate_latency_us = 11.65333,
-			.sr_exit_time_us = 9.89,
-			.sr_enter_plus_exit_time_us = 11.24,
+			.sr_exit_time_us = 11.5,
+			.sr_enter_plus_exit_time_us = 14.5,
 			.valid = true,
 		},
 		{
 			.wm_inst = WM_D,
 			.wm_type = WM_TYPE_PSTATE_CHG,
 			.pstate_latency_us = 11.65333,
-			.sr_exit_time_us = 9.748,
-			.sr_enter_plus_exit_time_us = 11.102,
+			.sr_exit_time_us = 11.5,
+			.sr_enter_plus_exit_time_us = 14.5,
 			.valid = true,
 		},
 	}
commit 4835ea6c173a8d8dfbfdbb21c4cd987d12681610
Author: Eric Yang <Eric.Yang2 at amd.com>
Date:   Thu Sep 30 13:46:45 2021 -0400

    drm/amd/display: increase Z9 latency to workaround underflow in Z9
    
    [Why]
    Z9 latency is higher than when we originally tuned the watermark
    parameters, causing underflow. Increasing the value until the latency
    issues is resolved.
    
    Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas at amd.com>
    Acked-by: Agustin Gutierrez Sanchez <agustin.gutierrez at amd.com>
    Signed-off-by: Eric Yang <Eric.Yang2 at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
index df6abe2b1f9e..79e92ecca96c 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
@@ -217,8 +217,8 @@ struct _vcs_dpi_soc_bounding_box_st dcn3_1_soc = {
 	.num_states = 5,
 	.sr_exit_time_us = 9.0,
 	.sr_enter_plus_exit_time_us = 11.0,
-	.sr_exit_z8_time_us = 402.0,
-	.sr_enter_plus_exit_z8_time_us = 520.0,
+	.sr_exit_z8_time_us = 442.0,
+	.sr_enter_plus_exit_z8_time_us = 560.0,
 	.writeback_latency_us = 12.0,
 	.dram_channel_width_bytes = 4,
 	.round_trip_ping_latency_dcfclk_cycles = 106,
commit 672437486ee9da3ed0e774937e6d0dd570921b39
Author: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
Date:   Wed Sep 29 16:22:53 2021 -0400

    drm/amd/display: Require immediate flip support for DCN3.1 planes
    
    [Why]
    Immediate flip can be enabled dynamically and has higher BW requirements
    when validating which voltage mode to use.
    
    If we validate when it's not set then potentially DCFCLK will be too low
    and we will underflow.
    
    [How]
    DM always requires support so always require it as part of DML input
    parameters.
    
    This can't be enabled unconditionally on older ASIC because it blocks
    some expected modes so only target DCN3.1 for now.
    
    Reviewed-by: Dmytro Laktyushkin <Dmytro.Laktyushkin at amd.com>
    Acked-by: Agustin Gutierrez Sanchez <agustin.gutierrez at amd.com>
    Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
index 1e3d50da1f93..df6abe2b1f9e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
@@ -1590,6 +1590,13 @@ static int dcn31_populate_dml_pipes_from_context(
 		pipe = &res_ctx->pipe_ctx[i];
 		timing = &pipe->stream->timing;
 
+		/*
+		 * Immediate flip can be set dynamically after enabling the plane.
+		 * We need to require support for immediate flip or underflow can be
+		 * intermittently experienced depending on peak b/w requirements.
+		 */
+		pipes[pipe_cnt].pipe.src.immediate_flip = true;
+
 		pipes[pipe_cnt].pipe.src.unbounded_req_mode = false;
 		pipes[pipe_cnt].pipe.src.gpuvm = true;
 		pipes[pipe_cnt].pipe.src.dcc_fraction_of_zs_req_luma = 0;
commit c938aed88f8259dc913b717a32319101c66e87a9
Author: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
Date:   Wed Sep 29 11:37:33 2021 -0400

    drm/amd/display: Fix prefetch bandwidth calculation for DCN3.1
    
    [Why]
    Prefetch BW calculated is lower than the DML reference because of a
    porting error that's excluding cursor and row bandwidth from the
    pixel data bandwidth.
    
    [How]
    Change the dml_max4 to dml_max3 and include cursor and row bandwidth
    in the same calculation as the rest of the pixel data during vactive.
    
    Reviewed-by: Dmytro Laktyushkin <Dmytro.Laktyushkin at amd.com>
    Acked-by: Agustin Gutierrez Sanchez <agustin.gutierrez at amd.com>
    Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c b/drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c
index ce55c9caf9a2..d58925cff420 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c
@@ -5398,9 +5398,9 @@ void dml31_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l
 
 					v->MaximumReadBandwidthWithPrefetch =
 							v->MaximumReadBandwidthWithPrefetch
-									+ dml_max4(
-											v->VActivePixelBandwidth[i][j][k],
-											v->VActiveCursorBandwidth[i][j][k]
+									+ dml_max3(
+											v->VActivePixelBandwidth[i][j][k]
+													+ v->VActiveCursorBandwidth[i][j][k]
 													+ v->NoOfDPP[i][j][k]
 															* (v->meta_row_bandwidth[i][j][k]
 																	+ v->dpte_row_bandwidth[i][j][k]),
commit c21b105380cf86e829c68586ca1315cfc253ad8c
Author: Nikola Cornij <nikola.cornij at amd.com>
Date:   Tue Sep 28 22:43:52 2021 -0400

    drm/amd/display: Limit display scaling to up to true 4k for DCN 3.1
    
    [why]
    The requirement is that image width up to 4096 shall be supported
    
    Reviewed-by: Aric Cyr <Aric.Cyr at amd.com>
    Acked-by: Agustin Gutierrez Sanchez <agustin.gutierrez at amd.com>
    Signed-off-by: Nikola Cornij <nikola.cornij at amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler at amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
index 0006bbac466c..1e3d50da1f93 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c
@@ -928,7 +928,7 @@ static const struct dc_debug_options debug_defaults_drv = {
 	.disable_dcc = DCC_ENABLE,
 	.vsr_support = true,
 	.performance_trace = false,
-	.max_downscale_src_width = 3840,/*upto 4K*/
+	.max_downscale_src_width = 4096,/*upto true 4K*/
 	.disable_pplib_wm_range = false,
 	.scl_reset_length10 = true,
 	.sanity_checks = false,
commit 5afa7898ab7a0ec9c28556a91df714bf3c2f725e
Author: Thelford Williams <tdwilliamsiv at gmail.com>
Date:   Wed Oct 13 16:04:13 2021 -0400

    drm/amdgpu: fix out of bounds write
    
    Size can be any value and is user controlled resulting in overwriting the
    40 byte array wr_buf with an arbitrary length of data from buf.
    
    Signed-off-by: Thelford Williams <tdwilliamsiv at gmail.com>
    Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
    Cc: stable at vger.kernel.org

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 87daa78a32b8..17f2756a64dc 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -263,7 +263,7 @@ static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
 	if (!wr_buf)
 		return -ENOSPC;
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					   (long *)param, buf,
 					   max_param_num,
 					   &param_nums)) {
commit 36b6dcbc1245a3b4dd6bc5cc6b0284c9f05cdddc
Merge: e23c7487f5a7 3ad60b4b3570
Author: Arnd Bergmann <arnd at arndb.de>
Date:   Wed Oct 20 16:42:19 2021 +0200

    Merge tag 'reset-fixes-for-v5.15' of git://git.pengutronix.de/pza/linux into arm/fixes
    
    Reset controller fixes for v5.15
    
    Fix the status bit polarity in the brcmstb-rescal driver, re-enable
    pistachio driver selection after MACH_PISTACHIO removal, add transfer
    error handling in the tegra-bpmp driver, and fix probing of the
    reset-socfpga driver after recent device link changes.
    
    * tag 'reset-fixes-for-v5.15' of git://git.pengutronix.de/pza/linux:
      reset: socfpga: add empty driver allowing consumers to probe
      reset: tegra-bpmp: Handle errors in BPMP response
      reset: pistachio: Re-enable driver selection
      reset: brcmstb-rescal: fix incorrect polarity of status bit
    
    Link: https://lore.kernel.org/r/b378f2aae54538db6a13c98561b4cbcacbef937c.camel@pengutronix.de
    Signed-off-by: Arnd Bergmann <arnd at arndb.de>

commit e23c7487f5a74f5cc9f7e1090f1d83c3e33ae315
Merge: 72cd4e3bde4e 55dd7e059098
Author: Arnd Bergmann <arnd at arndb.de>
Date:   Wed Oct 20 15:51:37 2021 +0200

    Merge tag 'sunxi-fixes-for-5.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux into arm/fixes
    
    Two patches to fix the GMAC PHY mode on some boards.
    
    * tag 'sunxi-fixes-for-5.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux:
      ARM: dts: sun7i: A20-olinuxino-lime2: Fix ethernet phy-mode
      arm64: dts: allwinner: h5: NanoPI Neo 2: Fix ethernet node
    
    Link: https://lore.kernel.org/r/d4c41c71-f1ff-4464-a26f-1bfd4b52fd78.lettre@localhost
    Signed-off-by: Arnd Bergmann <arnd at arndb.de>

commit 72cd4e3bde4e8ad178f9a698996275e20d235b63
Merge: 519d81956ee2 0b28c41e3c95
Author: Arnd Bergmann <arnd at arndb.de>
Date:   Wed Oct 20 15:49:36 2021 +0200

    Merge tag 'imx-fixes-5.15-4' of git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux into arm/fixes
    
    i.MX fixes for 5.15, round 4:
    
    - A series from Frieder Schrempf to fix i.MX8MM Kontron N801x board on
      various aspects, voltage settings, GPIO polarity, SPI clock frequency
      and Ethernet PHY type.
    
    * tag 'imx-fixes-5.15-4' of git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux:
      arm64: dts: imx8mm-kontron: Fix connection type for VSC8531 RGMII PHY
      arm64: dts: imx8mm-kontron: Fix CAN SPI clock frequency
      arm64: dts: imx8mm-kontron: Fix polarity of reg_rst_eth2
      arm64: dts: imx8mm-kontron: Set lower limit of VDD_SNVS to 800 mV
      arm64: dts: imx8mm-kontron: Make sure SOC and DRAM supply voltages are correct
    
    Link: https://lore.kernel.org/r/20211018000958.GC25810@dragon
    Signed-off-by: Arnd Bergmann <arnd at arndb.de>

commit 0e9ff65f455dfd0a8aea5e7843678ab6fe097e21
Author: Halil Pasic <pasic at linux.ibm.com>
Date:   Tue Oct 19 19:54:00 2021 +0200

    KVM: s390: preserve deliverable_mask in __airqs_kick_single_vcpu
    
    Changing the deliverable mask in __airqs_kick_single_vcpu() is a bug. If
    one idle vcpu can't take the interrupts we want to deliver, we should
    look for another vcpu that can, instead of saying that we don't want
    to deliver these interrupts by clearing the bits from the
    deliverable_mask.
    
    Fixes: 9f30f6216378 ("KVM: s390: add gib_alert_irq_handler()")
    Signed-off-by: Halil Pasic <pasic at linux.ibm.com>
    Reviewed-by: Christian Borntraeger <borntraeger at de.ibm.com>
    Reviewed-by: Michael Mueller <mimu at linux.ibm.com>
    Reviewed-by: Claudio Imbrenda <imbrenda at linux.ibm.com>
    Link: https://lore.kernel.org/r/20211019175401.3757927-3-pasic@linux.ibm.com
    Signed-off-by: Christian Borntraeger <borntraeger at de.ibm.com>

diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 10722455fd02..2245f4b8d362 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -3053,13 +3053,14 @@ static void __airqs_kick_single_vcpu(struct kvm *kvm, u8 deliverable_mask)
 	int vcpu_idx, online_vcpus = atomic_read(&kvm->online_vcpus);
 	struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int;
 	struct kvm_vcpu *vcpu;
+	u8 vcpu_isc_mask;
 
 	for_each_set_bit(vcpu_idx, kvm->arch.idle_mask, online_vcpus) {
 		vcpu = kvm_get_vcpu(kvm, vcpu_idx);
 		if (psw_ioint_disabled(vcpu))
 			continue;
-		deliverable_mask &= (u8)(vcpu->arch.sie_block->gcr[6] >> 24);
-		if (deliverable_mask) {
+		vcpu_isc_mask = (u8)(vcpu->arch.sie_block->gcr[6] >> 24);
+		if (deliverable_mask & vcpu_isc_mask) {
 			/* lately kicked but not yet running */
 			if (test_and_set_bit(vcpu_idx, gi->kicked_mask))
 				return;
commit 9b57e9d5010bbed7c0d9d445085840f7025e6f9a
Author: Halil Pasic <pasic at linux.ibm.com>
Date:   Tue Oct 19 19:53:59 2021 +0200

    KVM: s390: clear kicked_mask before sleeping again
    
    The idea behind kicked mask is that we should not re-kick a vcpu that
    is already in the "kick" process, i.e. that was kicked and is
    is about to be dispatched if certain conditions are met.
    
    The problem with the current implementation is, that it assumes the
    kicked vcpu is going to enter SIE shortly. But under certain
    circumstances, the vcpu we just kicked will be deemed non-runnable and
    will remain in wait state. This can happen, if the interrupt(s) this
    vcpu got kicked to deal with got already cleared (because the interrupts
    got delivered to another vcpu). In this case kvm_arch_vcpu_runnable()
    would return false, and the vcpu would remain in kvm_vcpu_block(),
    but this time with its kicked_mask bit set. So next time around we
    wouldn't kick the vcpu form __airqs_kick_single_vcpu(), but would assume
    that we just kicked it.
    
    Let us make sure the kicked_mask is cleared before we give up on
    re-dispatching the vcpu.
    
    Fixes: 9f30f6216378 ("KVM: s390: add gib_alert_irq_handler()")
    Reported-by: Matthew Rosato <mjrosato at linux.ibm.com>
    Signed-off-by: Halil Pasic <pasic at linux.ibm.com>
    Reviewed-by: Christian Borntraeger <borntraeger at de.ibm.com>
    Reviewed-by: Michael Mueller <mimu at linux.ibm.com>
    Reviewed-by: Claudio Imbrenda <imbrenda at linux.ibm.com>
    Link: https://lore.kernel.org/r/20211019175401.3757927-2-pasic@linux.ibm.com
    Signed-off-by: Christian Borntraeger <borntraeger at de.ibm.com>

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 6a6dd5e1daf6..1c97493d21e1 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -3363,6 +3363,7 @@ out_free_sie_block:
 
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
 {
+	clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.gisa_int.kicked_mask);
 	return kvm_s390_vcpu_has_irq(vcpu, 0);
 }
 
commit f09f6dfef8ce7b70a240cf83811e2b1909c3e47b
Author: Russ Weight <russell.h.weight at intel.com>
Date:   Mon Oct 18 17:24:01 2021 -0700

    spi: altera: Change to dynamic allocation of spi id
    
    The spi-altera driver has two flavors: platform and dfl. I'm seeing
    a case where I have both device types in the same machine, and they
    are conflicting on the SPI ID:
    
    ... kernel: couldn't get idr
    ... kernel: WARNING: CPU: 28 PID: 912 at drivers/spi/spi.c:2920 spi_register_controller.cold+0x84/0xc0a
    
    Both the platform and dfl drivers use the parent's driver ID as the SPI
    ID. In the error case, the parent devices are dfl_dev.4 and
    subdev_spi_altera.4.auto. When the second spi-master is created, the
    failure occurs because the SPI ID of 4 has already been allocated.
    
    Change the ID allocation to dynamic (by initializing bus_num to -1) to
    avoid duplicate SPI IDs.
    
    Signed-off-by: Russ Weight <russell.h.weight at intel.com>
    Link: https://lore.kernel.org/r/20211019002401.24041-1-russell.h.weight@intel.com
    Signed-off-by: Mark Brown <broonie at kernel.org>

diff --git a/drivers/spi/spi-altera-dfl.c b/drivers/spi/spi-altera-dfl.c
index 44fc9ee13fc7..ca40923258af 100644
--- a/drivers/spi/spi-altera-dfl.c
+++ b/drivers/spi/spi-altera-dfl.c
@@ -134,7 +134,7 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev)
 	if (!master)
 		return -ENOMEM;
 
-	master->bus_num = dfl_dev->id;
+	master->bus_num = -1;
 
 	hw = spi_master_get_devdata(master);
 
diff --git a/drivers/spi/spi-altera-platform.c b/drivers/spi/spi-altera-platform.c
index f7a7c14e3679..65147aae82a1 100644
--- a/drivers/spi/spi-altera-platform.c
+++ b/drivers/spi/spi-altera-platform.c
@@ -48,7 +48,7 @@ static int altera_spi_probe(struct platform_device *pdev)
 		return err;
 
 	/* setup the master state. */
-	master->bus_num = pdev->id;
+	master->bus_num = -1;
 
 	if (pdata) {
 		if (pdata->num_chipselect > ALTERA_SPI_MAX_CS) {
commit 2dace185caa580720c7cd67fec9efc5ee26108ac
Author: Mustafa Ismail <mustafa.ismail at intel.com>
Date:   Tue Oct 19 10:16:54 2021 -0500

    RDMA/irdma: Do not hold qos mutex twice on QP resume
    
    When irdma_ws_add fails, irdma_ws_remove is used to cleanup the leaf node.
    This lead to holding the qos mutex twice in the QP resume path. Fix this
    by avoiding the call to irdma_ws_remove and unwinding the error in
    irdma_ws_add. This skips the call to irdma_tc_in_use function which is not
    needed in the error unwind cases.
    
    Fixes: 3ae331c75128 ("RDMA/irdma: Add QoS definitions")
    Link: https://lore.kernel.org/r/20211019151654.1943-2-shiraz.saleem@intel.com
    Signed-off-by: Mustafa Ismail <mustafa.ismail at intel.com>
    Signed-off-by: Shiraz Saleem <shiraz.saleem at intel.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/hw/irdma/ws.c b/drivers/infiniband/hw/irdma/ws.c
index b68c575eb78e..b0d6ee0739f5 100644
--- a/drivers/infiniband/hw/irdma/ws.c
+++ b/drivers/infiniband/hw/irdma/ws.c
@@ -330,8 +330,10 @@ enum irdma_status_code irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri)
 
 		tc_node->enable = true;
 		ret = irdma_ws_cqp_cmd(vsi, tc_node, IRDMA_OP_WS_MODIFY_NODE);
-		if (ret)
+		if (ret) {
+			vsi->unregister_qset(vsi, tc_node);
 			goto reg_err;
+		}
 	}
 	ibdev_dbg(to_ibdev(vsi->dev),
 		  "WS: Using node %d which represents VSI %d TC %d\n",
@@ -350,6 +352,10 @@ enum irdma_status_code irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri)
 	}
 	goto exit;
 
+reg_err:
+	irdma_ws_cqp_cmd(vsi, tc_node, IRDMA_OP_WS_DELETE_NODE);
+	list_del(&tc_node->siblings);
+	irdma_free_node(vsi, tc_node);
 leaf_add_err:
 	if (list_empty(&vsi_node->child_list_head)) {
 		if (irdma_ws_cqp_cmd(vsi, vsi_node, IRDMA_OP_WS_DELETE_NODE))
@@ -369,11 +375,6 @@ vsi_add_err:
 exit:
 	mutex_unlock(&vsi->dev->ws_mutex);
 	return ret;
-
-reg_err:
-	mutex_unlock(&vsi->dev->ws_mutex);
-	irdma_ws_remove(vsi, user_pri);
-	return ret;
 }
 
 /**
commit cc07b73ef11d11d4359fb104d0199b22451dd3d8
Author: Mustafa Ismail <mustafa.ismail at intel.com>
Date:   Tue Oct 19 10:16:53 2021 -0500

    RDMA/irdma: Set VLAN in UD work completion correctly
    
    Currently VLAN is reported in UD work completion when VLAN id is zero,
    i.e. no VLAN case.
    
    Report VLAN in UD work completion only when VLAN id is non-zero.
    
    Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
    Link: https://lore.kernel.org/r/20211019151654.1943-1-shiraz.saleem@intel.com
    Signed-off-by: Mustafa Ismail <mustafa.ismail at intel.com>
    Signed-off-by: Shiraz Saleem <shiraz.saleem at intel.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index 7110ebf834f9..102dc9342f2a 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -3399,9 +3399,13 @@ static void irdma_process_cqe(struct ib_wc *entry,
 		}
 
 		if (cq_poll_info->ud_vlan_valid) {
-			entry->vlan_id = cq_poll_info->ud_vlan & VLAN_VID_MASK;
-			entry->wc_flags |= IB_WC_WITH_VLAN;
+			u16 vlan = cq_poll_info->ud_vlan & VLAN_VID_MASK;
+
 			entry->sl = cq_poll_info->ud_vlan >> VLAN_PRIO_SHIFT;
+			if (vlan) {
+				entry->vlan_id = vlan;
+				entry->wc_flags |= IB_WC_WITH_VLAN;
+			}
 		} else {
 			entry->sl = 0;
 		}
commit 5508546631a0f555d7088203dec2614e41b5106e
Author: Aharon Landau <aharonl at nvidia.com>
Date:   Tue Oct 19 14:30:10 2021 +0300

    RDMA/mlx5: Initialize the ODP xarray when creating an ODP MR
    
    Normally the zero fill would hide the missing initialization, but an
    errant set to desc_size in reg_create() causes a crash:
    
      BUG: unable to handle page fault for address: 0000000800000000
      PGD 0 P4D 0
      Oops: 0000 [#1] SMP PTI
      CPU: 5 PID: 890 Comm: ib_write_bw Not tainted 5.15.0-rc4+ #47
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
      RIP: 0010:mlx5_ib_dereg_mr+0x14/0x3b0 [mlx5_ib]
      Code: 48 63 cd 4c 89 f7 48 89 0c 24 e8 37 30 03 e1 48 8b 0c 24 eb a0 90 0f 1f 44 00 00 41 56 41 55 41 54 55 53 48 89 fb 48 83 ec 30 <48> 8b 2f 65 48 8b 04 25 28 00 00 00 48 89 44 24 28 31 c0 8b 87 c8
      RSP: 0018:ffff88811afa3a60 EFLAGS: 00010286
      RAX: 000000000000001c RBX: 0000000800000000 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000800000000
      RBP: 0000000800000000 R08: 0000000000000000 R09: c0000000fffff7ff
      R10: ffff88811afa38f8 R11: ffff88811afa38f0 R12: ffffffffa02c7ac0
      R13: 0000000000000000 R14: ffff88811afa3cd8 R15: ffff88810772fa00
      FS:  00007f47b9080740(0000) GS:ffff88852cd40000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000800000000 CR3: 000000010761e003 CR4: 0000000000370ea0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       mlx5_ib_free_odp_mr+0x95/0xc0 [mlx5_ib]
       mlx5_ib_dereg_mr+0x128/0x3b0 [mlx5_ib]
       ib_dereg_mr_user+0x45/0xb0 [ib_core]
       ? xas_load+0x8/0x80
       destroy_hw_idr_uobject+0x1a/0x50 [ib_uverbs]
       uverbs_destroy_uobject+0x2f/0x150 [ib_uverbs]
       uobj_destroy+0x3c/0x70 [ib_uverbs]
       ib_uverbs_cmd_verbs+0x467/0xb00 [ib_uverbs]
       ? uverbs_finalize_object+0x60/0x60 [ib_uverbs]
       ? ttwu_queue_wakelist+0xa9/0xe0
       ? pty_write+0x85/0x90
       ? file_tty_write.isra.33+0x214/0x330
       ? process_echoes+0x60/0x60
       ib_uverbs_ioctl+0xa7/0x110 [ib_uverbs]
       __x64_sys_ioctl+0x10d/0x8e0
       ? vfs_write+0x17f/0x260
       do_syscall_64+0x3c/0x80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    Add the missing xarray initialization and remove the desc_size set.
    
    Fixes: a639e66703ee ("RDMA/mlx5: Zero out ODP related items in the mlx5_ib_mr")
    Link: https://lore.kernel.org/r/a4846a11c9de834663e521770da895007f9f0d30.1634642730.git.leonro@nvidia.com
    Signed-off-by: Aharon Landau <aharonl at nvidia.com>
    Reviewed-by: Maor Gottlieb <maorg at nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro at nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 3be36ebbf67a..22e2f4d79743 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1339,7 +1339,6 @@ static struct mlx5_ib_mr *reg_create(struct ib_pd *pd, struct ib_umem *umem,
 		goto err_2;
 	}
 	mr->mmkey.type = MLX5_MKEY_MR;
-	mr->desc_size = sizeof(struct mlx5_mtt);
 	mr->umem = umem;
 	set_mr_fields(dev, mr, umem->length, access_flags);
 	kvfree(in);
@@ -1533,6 +1532,7 @@ static struct ib_mr *create_user_odp_mr(struct ib_pd *pd, u64 start, u64 length,
 		ib_umem_release(&odp->umem);
 		return ERR_CAST(mr);
 	}
+	xa_init(&mr->implicit_children);
 
 	odp->private = mr;
 	err = mlx5r_store_odp_mkey(dev, &mr->mmkey);
commit 60fab1076636493cfa2686e712446595fe43bc16
Author: Prabhakar Kushwaha <pkushwaha at marvell.com>
Date:   Tue Oct 19 11:22:12 2021 +0300

    rdma/qedr: Fix crash due to redundant release of device's qp memory
    
    Device's QP memory should only be allocated and released by IB layer.
    This patch removes the redundant release of the device's qp memory and
    uses completion APIs to make sure that .destroy_qp() only return, when qp
    reference becomes 0.
    
    Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
    Link: https://lore.kernel.org/r/20211019082212.7052-1-pkushwaha@marvell.com
    Acked-by: Michal Kalderon <michal.kalderon at marvell.com>
    Signed-off-by: Ariel Elior <aelior at marvell.com>
    Signed-off-by: Shai Malin <smalin at marvell.com>
    Signed-off-by: Alok Prasad <palok at marvell.com>
    Signed-off-by: Prabhakar Kushwaha <pkushwaha at marvell.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/hw/qedr/qedr.h b/drivers/infiniband/hw/qedr/qedr.h
index 3cb4febaad0f..8def88cfa300 100644
--- a/drivers/infiniband/hw/qedr/qedr.h
+++ b/drivers/infiniband/hw/qedr/qedr.h
@@ -455,6 +455,7 @@ struct qedr_qp {
 	/* synchronization objects used with iwarp ep */
 	struct kref refcnt;
 	struct completion iwarp_cm_comp;
+	struct completion qp_rel_comp;
 	unsigned long iwarp_cm_flags; /* enum iwarp_cm_flags */
 };
 
diff --git a/drivers/infiniband/hw/qedr/qedr_iw_cm.c b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
index 1715fbe0719d..a51fc6854984 100644
--- a/drivers/infiniband/hw/qedr/qedr_iw_cm.c
+++ b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
@@ -83,7 +83,7 @@ static void qedr_iw_free_qp(struct kref *ref)
 {
 	struct qedr_qp *qp = container_of(ref, struct qedr_qp, refcnt);
 
-	kfree(qp);
+	complete(&qp->qp_rel_comp);
 }
 
 static void
diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index 3fbf172dbbef..dcb3653db72d 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -1357,6 +1357,7 @@ static void qedr_set_common_qp_params(struct qedr_dev *dev,
 	if (rdma_protocol_iwarp(&dev->ibdev, 1)) {
 		kref_init(&qp->refcnt);
 		init_completion(&qp->iwarp_cm_comp);
+		init_completion(&qp->qp_rel_comp);
 	}
 
 	qp->pd = pd;
@@ -2857,8 +2858,10 @@ int qedr_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
 
 	qedr_free_qp_resources(dev, qp, udata);
 
-	if (rdma_protocol_iwarp(&dev->ibdev, 1))
+	if (rdma_protocol_iwarp(&dev->ibdev, 1)) {
 		qedr_iw_qp_rem_ref(&qp->ibqp);
+		wait_for_completion(&qp->qp_rel_comp);
+	}
 
 	return 0;
 }
commit 162079f2dccd02cb4b6654defd32ca387dd6d4d4
Author: Randy Dunlap <rdunlap at infradead.org>
Date:   Sun Oct 17 10:59:49 2021 -0700

    mmc: winbond: don't build on M68K
    
    The Winbond MMC driver fails to build on ARCH=m68k so prevent
    that build config. Silences these build errors:
    
    ../drivers/mmc/host/wbsd.c: In function 'wbsd_request_end':
    ../drivers/mmc/host/wbsd.c:212:28: error: implicit declaration of function 'claim_dma_lock' [-Werror=implicit-function-declaration]
      212 |                 dmaflags = claim_dma_lock();
    ../drivers/mmc/host/wbsd.c:215:17: error: implicit declaration of function 'release_dma_lock'; did you mean 'release_task'? [-Werror=implicit-function-declaration]
      215 |                 release_dma_lock(dmaflags);
    
    Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
    Cc: Pierre Ossman <pierre at ossman.eu>
    Cc: Geert Uytterhoeven <geert at linux-m68k.org>
    Cc: Arnd Bergmann <arnd at arndb.de>
    Link: https://lore.kernel.org/r/20211017175949.23838-1-rdunlap@infradead.org
    Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 95b3511b0560..ccc148cdb5ee 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -506,7 +506,7 @@ config MMC_OMAP_HS
 
 config MMC_WBSD
 	tristate "Winbond W83L51xD SD/MMC Card Interface support"
-	depends on ISA_DMA_API
+	depends on ISA_DMA_API && !M68K
 	help
 	  This selects the Winbond(R) W83L51xD Secure digital and
 	  Multimedia card Interface.
commit 9af372dc70e9fdcbb70939dac75365e7b88580b4
Author: Haibo Chen <haibo.chen at nxp.com>
Date:   Fri Oct 15 10:00:36 2021 +0800

    mmc: sdhci-esdhc-imx: clear the buffer_read_ready to reset standard tuning circuit
    
    To reset standard tuning circuit completely, after clear ESDHC_MIX_CTRL_EXE_TUNE,
    also need to clear bit buffer_read_ready, this operation will finally clear the
    USDHC IP internal logic flag execute_tuning_with_clr_buf, make sure the following
    normal data transfer will not be impacted by standard tuning logic used before.
    
    Find this issue when do quick SD card insert/remove stress test. During standard
    tuning prodedure, if remove SD card, USDHC standard tuning logic can't clear the
    internal flag execute_tuning_with_clr_buf. Next time when insert SD card, all
    data related commands can't get any data related interrupts, include data transfer
    complete interrupt, data timeout interrupt, data CRC interrupt, data end bit interrupt.
    Always trigger software timeout issue. Even reset the USDHC through bits in register
    SYS_CTRL (0x2C, bit28 reset tuning, bit26 reset data, bit 25 reset command, bit 24
    reset all) can't recover this. From the user's point of view, USDHC stuck, SD can't
    be recognized any more.
    
    Fixes: d9370424c948 ("mmc: sdhci-esdhc-imx: reset tuning circuit when power on mmc card")
    Signed-off-by: Haibo Chen <haibo.chen at nxp.com>
    Acked-by: Adrian Hunter <adrian.hunter at intel.com>
    Cc: stable at vger.kernel.org
    Link: https://lore.kernel.org/r/1634263236-6111-1-git-send-email-haibo.chen@nxp.com
    Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index f18d169bc8ff..e658f0174242 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1187,6 +1187,7 @@ static void esdhc_reset_tuning(struct sdhci_host *host)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
 	u32 ctrl;
+	int ret;
 
 	/* Reset the tuning circuit */
 	if (esdhc_is_usdhc(imx_data)) {
@@ -1199,7 +1200,22 @@ static void esdhc_reset_tuning(struct sdhci_host *host)
 		} else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
 			ctrl = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS);
 			ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
+			ctrl &= ~ESDHC_MIX_CTRL_EXE_TUNE;
 			writel(ctrl, host->ioaddr + SDHCI_AUTO_CMD_STATUS);
+			/* Make sure ESDHC_MIX_CTRL_EXE_TUNE cleared */
+			ret = readl_poll_timeout(host->ioaddr + SDHCI_AUTO_CMD_STATUS,
+				ctrl, !(ctrl & ESDHC_MIX_CTRL_EXE_TUNE), 1, 50);
+			if (ret == -ETIMEDOUT)
+				dev_warn(mmc_dev(host->mmc),
+				 "Warning! clear execute tuning bit failed\n");
+			/*
+			 * SDHCI_INT_DATA_AVAIL is W1C bit, set this bit will clear the
+			 * usdhc IP internal logic flag execute_tuning_with_clr_buf, which
+			 * will finally make sure the normal data transfer logic correct.
+			 */
+			ctrl = readl(host->ioaddr + SDHCI_INT_STATUS);
+			ctrl |= SDHCI_INT_DATA_AVAIL;
+			writel(ctrl, host->ioaddr + SDHCI_INT_STATUS);
 		}
 	}
 }
commit 59be177a909ac320e5f4b2a461ac09e20f35b2d8
Author: José Roberto de Souza <jose.souza at intel.com>
Date:   Tue Oct 12 18:00:46 2021 -0700

    drm/i915: Remove memory frequency calculation
    
    This memory frequency calculated is only used to check if it is zero,
    what is not useful as it will never actually be zero.
    
    Also the calculation is wrong, we should be checking other bit to
    select the appropriate frequency multiplier while this code is stuck
    with a fixed multiplier.
    
    So here dropping it as whole.
    
    v2:
    - Also remove memory frequency calculation for gen9 LP platforms
    
    Cc: Yakui Zhao <yakui.zhao at intel.com>
    Cc: Matt Roper <matthew.d.roper at intel.com>
    Fixes: 5d0c938ec9cc ("drm/i915/gen11+: Only load DRAM information from pcode")
    Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
    Reviewed-by: Matt Roper <matthew.d.roper at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211013010046.91858-1-jose.souza@intel.com
    (cherry picked from commit 83f52364b15265aec47d07e02b0fbf4093ab8554)
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 4037030f0984..9023d4ecf3b3 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -11048,12 +11048,6 @@ enum skl_power_gate {
 #define  DC_STATE_DEBUG_MASK_CORES	(1 << 0)
 #define  DC_STATE_DEBUG_MASK_MEMORY_UP	(1 << 1)
 
-#define BXT_P_CR_MC_BIOS_REQ_0_0_0	_MMIO(MCHBAR_MIRROR_BASE_SNB + 0x7114)
-#define  BXT_REQ_DATA_MASK			0x3F
-#define  BXT_DRAM_CHANNEL_ACTIVE_SHIFT		12
-#define  BXT_DRAM_CHANNEL_ACTIVE_MASK		(0xF << 12)
-#define  BXT_MEMORY_FREQ_MULTIPLIER_HZ		133333333
-
 #define BXT_D_CR_DRP0_DUNIT8			0x1000
 #define BXT_D_CR_DRP0_DUNIT9			0x1200
 #define  BXT_D_CR_DRP0_DUNIT_START		8
@@ -11084,9 +11078,7 @@ enum skl_power_gate {
 #define  BXT_DRAM_TYPE_LPDDR4			(0x2 << 22)
 #define  BXT_DRAM_TYPE_DDR4			(0x4 << 22)
 
-#define SKL_MEMORY_FREQ_MULTIPLIER_HZ		266666666
 #define SKL_MC_BIOS_DATA_0_0_0_MCHBAR_PCU	_MMIO(MCHBAR_MIRROR_BASE_SNB + 0x5E04)
-#define  SKL_REQ_DATA_MASK			(0xF << 0)
 #define  DG1_GEAR_TYPE				REG_BIT(16)
 
 #define SKL_MAD_INTER_CHANNEL_0_0_0_MCHBAR_MCMAIN _MMIO(MCHBAR_MIRROR_BASE_SNB + 0x5000)
diff --git a/drivers/gpu/drm/i915/intel_dram.c b/drivers/gpu/drm/i915/intel_dram.c
index 91866520c173..7acce64b0941 100644
--- a/drivers/gpu/drm/i915/intel_dram.c
+++ b/drivers/gpu/drm/i915/intel_dram.c
@@ -244,7 +244,6 @@ static int
 skl_get_dram_info(struct drm_i915_private *i915)
 {
 	struct dram_info *dram_info = &i915->dram_info;
-	u32 mem_freq_khz, val;
 	int ret;
 
 	dram_info->type = skl_get_dram_type(i915);
@@ -255,17 +254,6 @@ skl_get_dram_info(struct drm_i915_private *i915)
 	if (ret)
 		return ret;
 
-	val = intel_uncore_read(&i915->uncore,
-				SKL_MC_BIOS_DATA_0_0_0_MCHBAR_PCU);
-	mem_freq_khz = DIV_ROUND_UP((val & SKL_REQ_DATA_MASK) *
-				    SKL_MEMORY_FREQ_MULTIPLIER_HZ, 1000);
-
-	if (dram_info->num_channels * mem_freq_khz == 0) {
-		drm_info(&i915->drm,
-			 "Couldn't get system memory bandwidth\n");
-		return -EINVAL;
-	}
-
 	return 0;
 }
 
@@ -350,24 +338,10 @@ static void bxt_get_dimm_info(struct dram_dimm_info *dimm, u32 val)
 static int bxt_get_dram_info(struct drm_i915_private *i915)
 {
 	struct dram_info *dram_info = &i915->dram_info;
-	u32 dram_channels;
-	u32 mem_freq_khz, val;
-	u8 num_active_channels, valid_ranks = 0;
+	u32 val;
+	u8 valid_ranks = 0;
 	int i;
 
-	val = intel_uncore_read(&i915->uncore, BXT_P_CR_MC_BIOS_REQ_0_0_0);
-	mem_freq_khz = DIV_ROUND_UP((val & BXT_REQ_DATA_MASK) *
-				    BXT_MEMORY_FREQ_MULTIPLIER_HZ, 1000);
-
-	dram_channels = val & BXT_DRAM_CHANNEL_ACTIVE_MASK;
-	num_active_channels = hweight32(dram_channels);
-
-	if (mem_freq_khz * num_active_channels == 0) {
-		drm_info(&i915->drm,
-			 "Couldn't get system memory bandwidth\n");
-		return -EINVAL;
-	}
-
 	/*
 	 * Now read each DUNIT8/9/10/11 to check the rank of each dimms.
 	 */
commit 675c496d0f92b481ebe4abf4fb06eadad7789de6
Author: Martin Blumenstingl <martin.blumenstingl at googlemail.com>
Date:   Sat Oct 16 12:50:21 2021 +0200

    clk: composite: Also consider .determine_rate for rate + mux composites
    
    Commit 69a00fb3d69706 ("clk: divider: Implement and wire up
    .determine_rate by default") switches clk_divider_ops to implement
    .determine_rate by default. This breaks composite clocks with multiple
    parents because clk-composite.c does not use the special handling for
    mux + divider combinations anymore (that was restricted to rate clocks
    which only implement .round_rate, but not .determine_rate).
    
    Alex reports:
      This breaks lot of clocks for Rockchip which intensively uses
      composites,  i.e. those clocks will always stay at the initial parent,
      which in some cases  is the XTAL clock and I strongly guess it is the
      same for other platforms,  which use composite clocks having more than
      one parent (e.g. mediatek, ti ...)
    
      Example (RK3399)
      clk_sdio is set (initialized) with XTAL (24 MHz) as parent in u-boot.
      It will always stay at this parent, even if the mmc driver sets a rate
      of  200 MHz (fails, as the nature of things), which should switch it
      to   any of its possible parent PLLs defined in
      mux_pll_src_cpll_gpll_npll_ppll_upll_24m_p (see clk-rk3399.c)  - which
      never happens.
    
    Restore the original behavior by changing the priority of the conditions
    inside clk-composite.c. Now the special rate + mux case (with rate_ops
    having a .round_rate - which is still the case for the default
    clk_divider_ops) is preferred over rate_ops which have .determine_rate
    defined (and not further considering the mux).
    
    Fixes: 69a00fb3d69706 ("clk: divider: Implement and wire up .determine_rate by default")
    Reported-by: Alex Bee <knaerzche at gmail.com>
    Signed-off-by: Martin Blumenstingl <martin.blumenstingl at googlemail.com>
    Link: https://lore.kernel.org/r/20211016105022.303413-2-martin.blumenstingl@googlemail.com
    Tested-by: Alex Bee <knaerzche at gmail.com>
    Tested-by: Chen-Yu Tsai <wens at csie.org>
    Signed-off-by: Stephen Boyd <sboyd at kernel.org>

diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index 0506046a5f4b..510a9965633b 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -58,11 +58,8 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
 	long rate;
 	int i;
 
-	if (rate_hw && rate_ops && rate_ops->determine_rate) {
-		__clk_hw_set_clk(rate_hw, hw);
-		return rate_ops->determine_rate(rate_hw, req);
-	} else if (rate_hw && rate_ops && rate_ops->round_rate &&
-		   mux_hw && mux_ops && mux_ops->set_parent) {
+	if (rate_hw && rate_ops && rate_ops->round_rate &&
+	    mux_hw && mux_ops && mux_ops->set_parent) {
 		req->best_parent_hw = NULL;
 
 		if (clk_hw_get_flags(hw) & CLK_SET_RATE_NO_REPARENT) {
@@ -107,6 +104,9 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
 
 		req->rate = best_rate;
 		return 0;
+	} else if (rate_hw && rate_ops && rate_ops->determine_rate) {
+		__clk_hw_set_clk(rate_hw, hw);
+		return rate_ops->determine_rate(rate_hw, req);
 	} else if (mux_hw && mux_ops && mux_ops->determine_rate) {
 		__clk_hw_set_clk(mux_hw, hw);
 		return mux_ops->determine_rate(mux_hw, req);
commit 0b28c41e3c951ea3d4f012cfa9da5ebd6512cf6e
Author: Frieder Schrempf <frieder.schrempf at kontron.de>
Date:   Fri Oct 15 14:48:40 2021 +0200

    arm64: dts: imx8mm-kontron: Fix connection type for VSC8531 RGMII PHY
    
    Previously we falsely relied on the PHY driver to unconditionally
    enable the internal RX delay. Since the following fix for the PHY
    driver this is not the case anymore:
    
    commit 7b005a1742be ("net: phy: mscc: configure both RX and TX internal
    delays for RGMII")
    
    In order to enable the delay we need to set the connection type to
    "rgmii-rxid". Without the RX delay the ethernet is not functional at
    all.
    
    Fixes: 8668d8b2e67f ("arm64: dts: Add the Kontron i.MX8M Mini SoMs and baseboards")
    Cc: stable at vger.kernel.org
    Signed-off-by: Frieder Schrempf <frieder.schrempf at kontron.de>
    Signed-off-by: Shawn Guo <shawnguo at kernel.org>

diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts
index a52cdfb0920e..e99e7644ff39 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts
@@ -113,7 +113,7 @@
 &fec1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_enet>;
-	phy-connection-type = "rgmii";
+	phy-connection-type = "rgmii-rxid";
 	phy-handle = <&ethphy>;
 	status = "okay";
 
commit ca6f9d85d5944046a241b325700c1ca395651c28
Author: Frieder Schrempf <frieder.schrempf at kontron.de>
Date:   Fri Oct 15 14:48:39 2021 +0200

    arm64: dts: imx8mm-kontron: Fix CAN SPI clock frequency
    
    The MCP2515 can be used with an SPI clock of up to 10 MHz. Set the
    limit accordingly to prevent any performance issues caused by the
    really low clock speed of 100 kHz.
    
    This removes the arbitrarily low limit on the SPI frequency, that was
    caused by a typo in the original dts.
    
    Without this change, receiving CAN messages on the board beyond a
    certain bitrate will cause overrun errors (see 'ip -det -stat link show
    can0').
    
    With this fix, receiving messages on the bus works without any overrun
    errors for bitrates up to 1 MBit.
    
    Fixes: 8668d8b2e67f ("arm64: dts: Add the Kontron i.MX8M Mini SoMs and baseboards")
    Cc: stable at vger.kernel.org
    Signed-off-by: Frieder Schrempf <frieder.schrempf at kontron.de>
    Signed-off-by: Shawn Guo <shawnguo at kernel.org>

diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts
index 3912ac2446d7..a52cdfb0920e 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts
@@ -97,7 +97,7 @@
 		clocks = <&osc_can>;
 		interrupt-parent = <&gpio4>;
 		interrupts = <28 IRQ_TYPE_EDGE_FALLING>;
-		spi-max-frequency = <100000>;
+		spi-max-frequency = <10000000>;
 		vdd-supply = <&reg_vdd_3v3>;
 		xceiver-supply = <&reg_vdd_5v>;
 	};
commit 6562d6e350284307e33ea10c7f46a6661ff22770
Author: Frieder Schrempf <frieder.schrempf at kontron.de>
Date:   Fri Oct 15 14:48:38 2021 +0200

    arm64: dts: imx8mm-kontron: Fix polarity of reg_rst_eth2
    
    The regulator reg_rst_eth2 should keep the reset signal of the USB ethernet
    adapter deasserted anytime. Fix the polarity and mark it as always-on.
    
    Anyway, using the regulator is only a workaround for the missing support of
    specifying a reset GPIO for USB devices in a generic way. As we don't
    have a solution for this at the moment, at least fix the current
    workaround.
    
    Fixes: 8668d8b2e67f ("arm64: dts: Add the Kontron i.MX8M Mini SoMs and baseboards")
    Cc: stable at vger.kernel.org
    Signed-off-by: Frieder Schrempf <frieder.schrempf at kontron.de>
    Signed-off-by: Shawn Guo <shawnguo at kernel.org>

diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts
index d17abb515835..3912ac2446d7 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts
@@ -70,7 +70,9 @@
 		regulator-name = "rst-usb-eth2";
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_usb_eth2>;
-		gpio = <&gpio3 2 GPIO_ACTIVE_LOW>;
+		gpio = <&gpio3 2 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		regulator-always-on;
 	};
 
 	reg_vdd_5v: regulator-5v {
commit 256a24eba7f897c817fb0103dac73467d3789202
Author: Frieder Schrempf <frieder.schrempf at kontron.de>
Date:   Fri Oct 15 14:48:37 2021 +0200

    arm64: dts: imx8mm-kontron: Set lower limit of VDD_SNVS to 800 mV
    
    According to the datasheet the typical value for VDD_SNVS should be
    800 mV, so let's make sure that this is within the range of the
    regulator.
    
    Fixes: 8668d8b2e67f ("arm64: dts: Add the Kontron i.MX8M Mini SoMs and baseboards")
    Cc: stable at vger.kernel.org
    Signed-off-by: Frieder Schrempf <frieder.schrempf at kontron.de>
    Signed-off-by: Shawn Guo <shawnguo at kernel.org>

diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-som.dtsi b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-som.dtsi
index 7cf60c17c29b..42bbbb3f532b 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-som.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-som.dtsi
@@ -152,7 +152,7 @@
 
 			reg_vdd_snvs: LDO2 {
 				regulator-name = "ldo2";
-				regulator-min-microvolt = <850000>;
+				regulator-min-microvolt = <800000>;
 				regulator-max-microvolt = <900000>;
 				regulator-boot-on;
 				regulator-always-on;
commit 82a4f329b133ad0de66bee12c0be5c67bb8aa188
Author: Frieder Schrempf <frieder.schrempf at kontron.de>
Date:   Fri Oct 15 14:48:36 2021 +0200

    arm64: dts: imx8mm-kontron: Make sure SOC and DRAM supply voltages are correct
    
    It looks like the voltages for the SOC and DRAM supply weren't properly
    validated before. The datasheet and uboot-imx code tells us that VDD_SOC
    should be 800 mV in suspend and 850 mV in run mode. VDD_DRAM should be
    950 mV for DDR clock frequencies of up to 1.5 GHz.
    
    Let's fix these values to make sure the voltages are within the required
    range.
    
    Fixes: 8668d8b2e67f ("arm64: dts: Add the Kontron i.MX8M Mini SoMs and baseboards")
    Cc: stable at vger.kernel.org
    Signed-off-by: Frieder Schrempf <frieder.schrempf at kontron.de>
    Signed-off-by: Shawn Guo <shawnguo at kernel.org>

diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-som.dtsi b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-som.dtsi
index 9db9b90bf2bc..7cf60c17c29b 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-som.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-som.dtsi
@@ -91,10 +91,12 @@
 			reg_vdd_soc: BUCK1 {
 				regulator-name = "buck1";
 				regulator-min-microvolt = <800000>;
-				regulator-max-microvolt = <900000>;
+				regulator-max-microvolt = <850000>;
 				regulator-boot-on;
 				regulator-always-on;
 				regulator-ramp-delay = <3125>;
+				nxp,dvs-run-voltage = <850000>;
+				nxp,dvs-standby-voltage = <800000>;
 			};
 
 			reg_vdd_arm: BUCK2 {
@@ -111,7 +113,7 @@
 			reg_vdd_dram: BUCK3 {
 				regulator-name = "buck3";
 				regulator-min-microvolt = <850000>;
-				regulator-max-microvolt = <900000>;
+				regulator-max-microvolt = <950000>;
 				regulator-boot-on;
 				regulator-always-on;
 			};
commit 6ab4e2eb5e956a61e4d53cea3ab8c866ba79a830
Author: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
Date:   Wed Oct 13 23:17:18 2021 +0300

    mmc: sdhci-pci: Read card detect from ACPI for Intel Merrifield
    
    Intel Merrifield platform had been converted to use ACPI enumeration.
    However, the driver missed an update to retrieve card detect GPIO.
    Fix it here.
    
    Unfortunately we can't rely on CD GPIO state because there are two
    different PCB designs in the wild that are using the opposite card
    detection sense and there is no way to distinguish those platforms,
    that's why ignore CD GPIO completely and use it only as an event.
    
    Fixes: 4590d98f5a4f ("sfi: Remove framework for deprecated firmware")
    BugLink: https://github.com/edison-fw/meta-intel-edison/issues/135
    Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
    Acked-by: Adrian Hunter <adrian.hunter at intel.com>
    Cc: stable at vger.kernel.org
    Link: https://lore.kernel.org/r/20211013201723.52212-2-andriy.shevchenko@linux.intel.com
    Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index be19785227fe..d0f2edfe296c 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -616,16 +616,12 @@ static int intel_select_drive_strength(struct mmc_card *card,
 	return intel_host->drv_strength;
 }
 
-static int bxt_get_cd(struct mmc_host *mmc)
+static int sdhci_get_cd_nogpio(struct mmc_host *mmc)
 {
-	int gpio_cd = mmc_gpio_get_cd(mmc);
 	struct sdhci_host *host = mmc_priv(mmc);
 	unsigned long flags;
 	int ret = 0;
 
-	if (!gpio_cd)
-		return 0;
-
 	spin_lock_irqsave(&host->lock, flags);
 
 	if (host->flags & SDHCI_DEVICE_DEAD)
@@ -638,6 +634,21 @@ out:
 	return ret;
 }
 
+static int bxt_get_cd(struct mmc_host *mmc)
+{
+	int gpio_cd = mmc_gpio_get_cd(mmc);
+
+	if (!gpio_cd)
+		return 0;
+
+	return sdhci_get_cd_nogpio(mmc);
+}
+
+static int mrfld_get_cd(struct mmc_host *mmc)
+{
+	return sdhci_get_cd_nogpio(mmc);
+}
+
 #define SDHCI_INTEL_PWR_TIMEOUT_CNT	20
 #define SDHCI_INTEL_PWR_TIMEOUT_UDELAY	100
 
@@ -1341,6 +1352,14 @@ static int intel_mrfld_mmc_probe_slot(struct sdhci_pci_slot *slot)
 					 MMC_CAP_1_8V_DDR;
 		break;
 	case INTEL_MRFLD_SD:
+		slot->cd_idx = 0;
+		slot->cd_override_level = true;
+		/*
+		 * There are two PCB designs of SD card slot with the opposite
+		 * card detection sense. Quirk this out by ignoring GPIO state
+		 * completely in the custom ->get_cd() callback.
+		 */
+		slot->host->mmc_host_ops.get_cd = mrfld_get_cd;
 		slot->host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
 		break;
 	case INTEL_MRFLD_SDIO:
commit 663991f32857b3b63c94c97de9dbb0ec8600144f
Author: Dan Carpenter <dan.carpenter at oracle.com>
Date:   Wed Oct 13 11:06:45 2021 +0300

    RDMA/rdmavt: Fix error code in rvt_create_qp()
    
    Return negative -ENOMEM instead of positive ENOMEM.  Returning a postive
    value will cause an Oops because it becomes an ERR_PTR() in the
    create_qp() function.
    
    Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
    Link: https://lore.kernel.org/r/20211013080645.GD6010@kili
    Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
    Acked-by: Dennis Dalessandro <dennis.dalessandro at cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
index 49bdd78ac664..3305f2744bfa 100644
--- a/drivers/infiniband/sw/rdmavt/qp.c
+++ b/drivers/infiniband/sw/rdmavt/qp.c
@@ -1223,7 +1223,7 @@ int rvt_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
 	spin_lock(&rdi->n_qps_lock);
 	if (rdi->n_qps_allocated == rdi->dparms.props.max_qp) {
 		spin_unlock(&rdi->n_qps_lock);
-		ret = ENOMEM;
+		ret = -ENOMEM;
 		goto bail_ip;
 	}
 
commit 13bac861952a78664907a0f927d3e874e9a59034
Author: Mike Marciniszyn <mike.marciniszyn at cornelisnetworks.com>
Date:   Wed Oct 13 10:18:52 2021 -0400

    IB/hfi1: Fix abba locking issue with sc_disable()
    
    sc_disable() after having disabled the send context wakes up any waiters
    by calling hfi1_qp_wakeup() while holding the waitlock for the sc.
    
    This is contrary to the model for all other calls to hfi1_qp_wakeup()
    where the waitlock is dropped and a local is used to drive calls to
    hfi1_qp_wakeup().
    
    Fix by moving the sc->piowait into a local list and driving the wakeup
    calls from the list.
    
    Fixes: 099a884ba4c0 ("IB/hfi1: Handle wakeup of orphaned QPs for pio")
    Link: https://lore.kernel.org/r/20211013141852.128104.2682.stgit@awfm-01.cornelisnetworks.com
    Signed-off-by: Mike Marciniszyn <mike.marciniszyn at cornelisnetworks.com>
    Reported-by: TOTE Robot <oslab at tsinghua.edu.cn>
    Signed-off-by: Dennis Dalessandro <dennis.dalessandro at cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c
index 489b436f19bb..3d42bd2b36bd 100644
--- a/drivers/infiniband/hw/hfi1/pio.c
+++ b/drivers/infiniband/hw/hfi1/pio.c
@@ -878,6 +878,7 @@ void sc_disable(struct send_context *sc)
 {
 	u64 reg;
 	struct pio_buf *pbuf;
+	LIST_HEAD(wake_list);
 
 	if (!sc)
 		return;
@@ -912,19 +913,21 @@ void sc_disable(struct send_context *sc)
 	spin_unlock(&sc->release_lock);
 
 	write_seqlock(&sc->waitlock);
-	while (!list_empty(&sc->piowait)) {
+	if (!list_empty(&sc->piowait))
+		list_move(&sc->piowait, &wake_list);
+	write_sequnlock(&sc->waitlock);
+	while (!list_empty(&wake_list)) {
 		struct iowait *wait;
 		struct rvt_qp *qp;
 		struct hfi1_qp_priv *priv;
 
-		wait = list_first_entry(&sc->piowait, struct iowait, list);
+		wait = list_first_entry(&wake_list, struct iowait, list);
 		qp = iowait_to_qp(wait);
 		priv = qp->priv;
 		list_del_init(&priv->s_iowait.list);
 		priv->s_iowait.lock = NULL;
 		hfi1_qp_wakeup(qp, RVT_S_WAIT_PIO | HFI1_S_WAIT_PIO_DRAIN);
 	}
-	write_sequnlock(&sc->waitlock);
 
 	spin_unlock_irq(&sc->alloc_lock);
 }
commit d39bf40e55e666b5905fdbd46a0dced030ce87be
Author: Mike Marciniszyn <mike.marciniszyn at cornelisnetworks.com>
Date:   Tue Oct 12 13:55:19 2021 -0400

    IB/qib: Protect from buffer overflow in struct qib_user_sdma_pkt fields
    
    Overflowing either addrlimit or bytes_togo can allow userspace to trigger
    a buffer overflow of kernel memory. Check for overflows in all the places
    doing math on user controlled buffers.
    
    Fixes: f931551bafe1 ("IB/qib: Add new qib driver for QLogic PCIe InfiniBand adapters")
    Link: https://lore.kernel.org/r/20211012175519.7298.77738.stgit@awfm-01.cornelisnetworks.com
    Reported-by: Ilja Van Sprundel <ivansprundel at ioactive.com>
    Reviewed-by: Dennis Dalessandro <dennis.dalessandro at cornelisnetworks.com>
    Signed-off-by: Mike Marciniszyn <mike.marciniszyn at cornelisnetworks.com>
    Signed-off-by: Dennis Dalessandro <dennis.dalessandro at cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/hw/qib/qib_user_sdma.c b/drivers/infiniband/hw/qib/qib_user_sdma.c
index a67599b5a550..ac11943a5ddb 100644
--- a/drivers/infiniband/hw/qib/qib_user_sdma.c
+++ b/drivers/infiniband/hw/qib/qib_user_sdma.c
@@ -602,7 +602,7 @@ done:
 /*
  * How many pages in this iovec element?
  */
-static int qib_user_sdma_num_pages(const struct iovec *iov)
+static size_t qib_user_sdma_num_pages(const struct iovec *iov)
 {
 	const unsigned long addr  = (unsigned long) iov->iov_base;
 	const unsigned long  len  = iov->iov_len;
@@ -658,7 +658,7 @@ static void qib_user_sdma_free_pkt_frag(struct device *dev,
 static int qib_user_sdma_pin_pages(const struct qib_devdata *dd,
 				   struct qib_user_sdma_queue *pq,
 				   struct qib_user_sdma_pkt *pkt,
-				   unsigned long addr, int tlen, int npages)
+				   unsigned long addr, int tlen, size_t npages)
 {
 	struct page *pages[8];
 	int i, j;
@@ -722,7 +722,7 @@ static int qib_user_sdma_pin_pkt(const struct qib_devdata *dd,
 	unsigned long idx;
 
 	for (idx = 0; idx < niov; idx++) {
-		const int npages = qib_user_sdma_num_pages(iov + idx);
+		const size_t npages = qib_user_sdma_num_pages(iov + idx);
 		const unsigned long addr = (unsigned long) iov[idx].iov_base;
 
 		ret = qib_user_sdma_pin_pages(dd, pq, pkt, addr,
@@ -824,8 +824,8 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
 		unsigned pktnw;
 		unsigned pktnwc;
 		int nfrags = 0;
-		int npages = 0;
-		int bytes_togo = 0;
+		size_t npages = 0;
+		size_t bytes_togo = 0;
 		int tiddma = 0;
 		int cfur;
 
@@ -885,7 +885,11 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
 
 			npages += qib_user_sdma_num_pages(&iov[idx]);
 
-			bytes_togo += slen;
+			if (check_add_overflow(bytes_togo, slen, &bytes_togo) ||
+			    bytes_togo > type_max(typeof(pkt->bytes_togo))) {
+				ret = -EINVAL;
+				goto free_pbc;
+			}
 			pktnwc += slen >> 2;
 			idx++;
 			nfrags++;
@@ -904,8 +908,7 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
 		}
 
 		if (frag_size) {
-			int tidsmsize, n;
-			size_t pktsize;
+			size_t tidsmsize, n, pktsize, sz, addrlimit;
 
 			n = npages*((2*PAGE_SIZE/frag_size)+1);
 			pktsize = struct_size(pkt, addr, n);
@@ -923,14 +926,24 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
 			else
 				tidsmsize = 0;
 
-			pkt = kmalloc(pktsize+tidsmsize, GFP_KERNEL);
+			if (check_add_overflow(pktsize, tidsmsize, &sz)) {
+				ret = -EINVAL;
+				goto free_pbc;
+			}
+			pkt = kmalloc(sz, GFP_KERNEL);
 			if (!pkt) {
 				ret = -ENOMEM;
 				goto free_pbc;
 			}
 			pkt->largepkt = 1;
 			pkt->frag_size = frag_size;
-			pkt->addrlimit = n + ARRAY_SIZE(pkt->addr);
+			if (check_add_overflow(n, ARRAY_SIZE(pkt->addr),
+					       &addrlimit) ||
+			    addrlimit > type_max(typeof(pkt->addrlimit))) {
+				ret = -EINVAL;
+				goto free_pbc;
+			}
+			pkt->addrlimit = addrlimit;
 
 			if (tiddma) {
 				char *tidsm = (char *)pkt + pktsize;
commit b3ec8cdf457e5e63d396fe1346cc788cf7c1b578
Author: Claudio Suarez <cssk at net-c.es>
Date:   Thu Sep 30 17:10:26 2021 +0200

    fbdev: Garbage collect fbdev scrolling acceleration, part 1 (from TODO list)
    
    Scroll acceleration is disabled in fbcon by hard-wiring
    p->scrollmode = SCROLL_REDRAW. Remove the obsolete code in fbcon.c
    and fbdev/core/
    
    Signed-off-by: Claudio Suarez <cssk at net-c.es>
    Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/YVXTYqszZix9TxjJ@gineta.localdomain

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 6613543955e9..60d1d7ee0719 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -314,16 +314,19 @@ Level: Advanced
 Garbage collect fbdev scrolling acceleration
 --------------------------------------------
 
-Scroll acceleration is disabled in fbcon by hard-wiring p->scrollmode =
-SCROLL_REDRAW. There's a ton of code this will allow us to remove:
+Scroll acceleration has been disabled in fbcon. Now it works as the old
+SCROLL_REDRAW mode. A ton of code was removed in fbcon.c and the hook bmove was
+removed from fbcon_ops.
+Remaining tasks:
 
-- lots of code in fbcon.c
-
-- a bunch of the hooks in fbcon_ops, maybe the remaining hooks could be called
+- a bunch of the hooks in fbcon_ops could be removed or simplified by calling
   directly instead of the function table (with a switch on p->rotate)
 
 - fb_copyarea is unused after this, and can be deleted from all drivers
 
+- after that, fb_copyarea can be deleted from fb_ops in include/linux/fb.h as
+  well as cfb_copyarea
+
 Note that not all acceleration code can be deleted, since clearing and cursor
 support is still accelerated, which might be good candidates for further
 deletion projects.
diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c
index f98e8f298bc1..01fae2c96965 100644
--- a/drivers/video/fbdev/core/bitblit.c
+++ b/drivers/video/fbdev/core/bitblit.c
@@ -43,21 +43,6 @@ static void update_attr(u8 *dst, u8 *src, int attribute,
 	}
 }
 
-static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy,
-		      int sx, int dy, int dx, int height, int width)
-{
-	struct fb_copyarea area;
-
-	area.sx = sx * vc->vc_font.width;
-	area.sy = sy * vc->vc_font.height;
-	area.dx = dx * vc->vc_font.width;
-	area.dy = dy * vc->vc_font.height;
-	area.height = height * vc->vc_font.height;
-	area.width = width * vc->vc_font.width;
-
-	info->fbops->fb_copyarea(info, &area);
-}
-
 static void bit_clear(struct vc_data *vc, struct fb_info *info, int sy,
 		      int sx, int height, int width)
 {
@@ -393,7 +378,6 @@ static int bit_update_start(struct fb_info *info)
 
 void fbcon_set_bitops(struct fbcon_ops *ops)
 {
-	ops->bmove = bit_bmove;
 	ops->clear = bit_clear;
 	ops->putcs = bit_putcs;
 	ops->clear_margins = bit_clear_margins;
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 22bb3892f6bd..99ecd9a6d844 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -173,8 +173,6 @@ static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
 			int count, int ypos, int xpos);
 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only);
 static void fbcon_cursor(struct vc_data *vc, int mode);
-static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
-			int height, int width);
 static int fbcon_switch(struct vc_data *vc);
 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch);
 static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table);
@@ -182,16 +180,8 @@ static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table);
 /*
  *  Internal routines
  */
-static __inline__ void ywrap_up(struct vc_data *vc, int count);
-static __inline__ void ywrap_down(struct vc_data *vc, int count);
-static __inline__ void ypan_up(struct vc_data *vc, int count);
-static __inline__ void ypan_down(struct vc_data *vc, int count);
-static void fbcon_bmove_rec(struct vc_data *vc, struct fbcon_display *p, int sy, int sx,
-			    int dy, int dx, int height, int width, u_int y_break);
 static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
 			   int unit);
-static void fbcon_redraw_move(struct vc_data *vc, struct fbcon_display *p,
-			      int line, int count, int dy);
 static void fbcon_modechanged(struct fb_info *info);
 static void fbcon_set_all_vcs(struct fb_info *info);
 static void fbcon_start(void);
@@ -1135,14 +1125,6 @@ static void fbcon_init(struct vc_data *vc, int init)
 
 	ops->graphics = 0;
 
-	/*
-	 * No more hw acceleration for fbcon.
-	 *
-	 * FIXME: Garbage collect all the now dead code after sufficient time
-	 * has passed.
-	 */
-	p->scrollmode = SCROLL_REDRAW;
-
 	/*
 	 *  ++guenther: console.c:vc_allocate() relies on initializing
 	 *  vc_{cols,rows}, but we must not set those if we are only
@@ -1229,14 +1211,13 @@ finished:
  *  This system is now divided into two levels because of complications
  *  caused by hardware scrolling. Top level functions:
  *
- *	fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins()
+ *	fbcon_clear(), fbcon_putc(), fbcon_clear_margins()
  *
  *  handles y values in range [0, scr_height-1] that correspond to real
  *  screen positions. y_wrap shift means that first line of bitmap may be
  *  anywhere on this display. These functions convert lineoffsets to
  *  bitmap offsets and deal with the wrap-around case by splitting blits.
  *
- *	fbcon_bmove_physical_8()    -- These functions fast implementations
  *	fbcon_clear_physical_8()    -- of original fbcon_XXX fns.
  *	fbcon_putc_physical_8()	    -- (font width != 8) may be added later
  *
@@ -1409,224 +1390,6 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
 	}
 }
 
-static __inline__ void ywrap_up(struct vc_data *vc, int count)
-{
-	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
-	struct fbcon_ops *ops = info->fbcon_par;
-	struct fbcon_display *p = &fb_display[vc->vc_num];
-	
-	p->yscroll += count;
-	if (p->yscroll >= p->vrows)	/* Deal with wrap */
-		p->yscroll -= p->vrows;
-	ops->var.xoffset = 0;
-	ops->var.yoffset = p->yscroll * vc->vc_font.height;
-	ops->var.vmode |= FB_VMODE_YWRAP;
-	ops->update_start(info);
-	scrollback_max += count;
-	if (scrollback_max > scrollback_phys_max)
-		scrollback_max = scrollback_phys_max;
-	scrollback_current = 0;
-}
-
-static __inline__ void ywrap_down(struct vc_data *vc, int count)
-{
-	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
-	struct fbcon_ops *ops = info->fbcon_par;
-	struct fbcon_display *p = &fb_display[vc->vc_num];
-	
-	p->yscroll -= count;
-	if (p->yscroll < 0)	/* Deal with wrap */
-		p->yscroll += p->vrows;
-	ops->var.xoffset = 0;
-	ops->var.yoffset = p->yscroll * vc->vc_font.height;
-	ops->var.vmode |= FB_VMODE_YWRAP;
-	ops->update_start(info);
-	scrollback_max -= count;
-	if (scrollback_max < 0)
-		scrollback_max = 0;
-	scrollback_current = 0;
-}
-
-static __inline__ void ypan_up(struct vc_data *vc, int count)
-{
-	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
-	struct fbcon_display *p = &fb_display[vc->vc_num];
-	struct fbcon_ops *ops = info->fbcon_par;
-
-	p->yscroll += count;
-	if (p->yscroll > p->vrows - vc->vc_rows) {
-		ops->bmove(vc, info, p->vrows - vc->vc_rows,
-			    0, 0, 0, vc->vc_rows, vc->vc_cols);
-		p->yscroll -= p->vrows - vc->vc_rows;
-	}
-
-	ops->var.xoffset = 0;
-	ops->var.yoffset = p->yscroll * vc->vc_font.height;
-	ops->var.vmode &= ~FB_VMODE_YWRAP;
-	ops->update_start(info);
-	fbcon_clear_margins(vc, 1);
-	scrollback_max += count;
-	if (scrollback_max > scrollback_phys_max)
-		scrollback_max = scrollback_phys_max;
-	scrollback_current = 0;
-}
-
-static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count)
-{
-	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
-	struct fbcon_ops *ops = info->fbcon_par;
-	struct fbcon_display *p = &fb_display[vc->vc_num];
-
-	p->yscroll += count;
-
-	if (p->yscroll > p->vrows - vc->vc_rows) {
-		p->yscroll -= p->vrows - vc->vc_rows;
-		fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t);
-	}
-
-	ops->var.xoffset = 0;
-	ops->var.yoffset = p->yscroll * vc->vc_font.height;
-	ops->var.vmode &= ~FB_VMODE_YWRAP;
-	ops->update_start(info);
-	fbcon_clear_margins(vc, 1);
-	scrollback_max += count;
-	if (scrollback_max > scrollback_phys_max)
-		scrollback_max = scrollback_phys_max;
-	scrollback_current = 0;
-}
-
-static __inline__ void ypan_down(struct vc_data *vc, int count)
-{
-	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
-	struct fbcon_display *p = &fb_display[vc->vc_num];
-	struct fbcon_ops *ops = info->fbcon_par;
-	
-	p->yscroll -= count;
-	if (p->yscroll < 0) {
-		ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows,
-			    0, vc->vc_rows, vc->vc_cols);
-		p->yscroll += p->vrows - vc->vc_rows;
-	}
-
-	ops->var.xoffset = 0;
-	ops->var.yoffset = p->yscroll * vc->vc_font.height;
-	ops->var.vmode &= ~FB_VMODE_YWRAP;
-	ops->update_start(info);
-	fbcon_clear_margins(vc, 1);
-	scrollback_max -= count;
-	if (scrollback_max < 0)
-		scrollback_max = 0;
-	scrollback_current = 0;
-}
-
-static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count)
-{
-	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
-	struct fbcon_ops *ops = info->fbcon_par;
-	struct fbcon_display *p = &fb_display[vc->vc_num];
-
-	p->yscroll -= count;
-
-	if (p->yscroll < 0) {
-		p->yscroll += p->vrows - vc->vc_rows;
-		fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count);
-	}
-
-	ops->var.xoffset = 0;
-	ops->var.yoffset = p->yscroll * vc->vc_font.height;
-	ops->var.vmode &= ~FB_VMODE_YWRAP;
-	ops->update_start(info);
-	fbcon_clear_margins(vc, 1);
-	scrollback_max -= count;
-	if (scrollback_max < 0)
-		scrollback_max = 0;
-	scrollback_current = 0;
-}
-
-static void fbcon_redraw_move(struct vc_data *vc, struct fbcon_display *p,
-			      int line, int count, int dy)
-{
-	unsigned short *s = (unsigned short *)
-		(vc->vc_origin + vc->vc_size_row * line);
-
-	while (count--) {
-		unsigned short *start = s;
-		unsigned short *le = advance_row(s, 1);
-		unsigned short c;
-		int x = 0;
-		unsigned short attr = 1;
-
-		do {
-			c = scr_readw(s);
-			if (attr != (c & 0xff00)) {
-				attr = c & 0xff00;
-				if (s > start) {
-					fbcon_putcs(vc, start, s - start,
-						    dy, x);
-					x += s - start;
-					start = s;
-				}
-			}
-			console_conditional_schedule();
-			s++;
-		} while (s < le);
-		if (s > start)
-			fbcon_putcs(vc, start, s - start, dy, x);
-		console_conditional_schedule();
-		dy++;
-	}
-}
-
-static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info,
-			struct fbcon_display *p, int line, int count, int ycount)
-{
-	int offset = ycount * vc->vc_cols;
-	unsigned short *d = (unsigned short *)
-	    (vc->vc_origin + vc->vc_size_row * line);
-	unsigned short *s = d + offset;
-	struct fbcon_ops *ops = info->fbcon_par;
-
-	while (count--) {
-		unsigned short *start = s;
-		unsigned short *le = advance_row(s, 1);
-		unsigned short c;
-		int x = 0;
-
-		do {
-			c = scr_readw(s);
-
-			if (c == scr_readw(d)) {
-				if (s > start) {
-					ops->bmove(vc, info, line + ycount, x,
-						   line, x, 1, s-start);
-					x += s - start + 1;
-					start = s + 1;
-				} else {
-					x++;
-					start++;
-				}
-			}
-
-			scr_writew(c, d);
-			console_conditional_schedule();
-			s++;
-			d++;
-		} while (s < le);
-		if (s > start)
-			ops->bmove(vc, info, line + ycount, x, line, x, 1,
-				   s-start);
-		console_conditional_schedule();
-		if (ycount > 0)
-			line++;
-		else {
-			line--;
-			/* NOTE: We subtract two lines from these pointers */
-			s -= vc->vc_size_row;
-			d -= vc->vc_size_row;
-		}
-	}
-}
-
 static void fbcon_redraw(struct vc_data *vc, struct fbcon_display *p,
 			 int line, int count, int offset)
 {
@@ -1687,7 +1450,6 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 {
 	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct fbcon_display *p = &fb_display[vc->vc_num];
-	int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
 
 	if (fbcon_is_inactive(vc, info))
 		return true;
@@ -1704,249 +1466,32 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 	case SM_UP:
 		if (count > vc->vc_rows)	/* Maximum realistic size */
 			count = vc->vc_rows;
-		if (logo_shown >= 0)
-			goto redraw_up;
-		switch (p->scrollmode) {
-		case SCROLL_MOVE:
-			fbcon_redraw_blit(vc, info, p, t, b - t - count,
-				     count);
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
-			scr_memsetw((unsigned short *) (vc->vc_origin +
-							vc->vc_size_row *
-							(b - count)),
-				    vc->vc_video_erase_char,
-				    vc->vc_size_row * count);
-			return true;
-
-		case SCROLL_WRAP_MOVE:
-			if (b - t - count > 3 * vc->vc_rows >> 2) {
-				if (t > 0)
-					fbcon_bmove(vc, 0, 0, count, 0, t,
-						    vc->vc_cols);
-				ywrap_up(vc, count);
-				if (vc->vc_rows - b > 0)
-					fbcon_bmove(vc, b - count, 0, b, 0,
-						    vc->vc_rows - b,
-						    vc->vc_cols);
-			} else if (info->flags & FBINFO_READS_FAST)
-				fbcon_bmove(vc, t + count, 0, t, 0,
-					    b - t - count, vc->vc_cols);
-			else
-				goto redraw_up;
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
-			break;
-
-		case SCROLL_PAN_REDRAW:
-			if ((p->yscroll + count <=
-			     2 * (p->vrows - vc->vc_rows))
-			    && ((!scroll_partial && (b - t == vc->vc_rows))
-				|| (scroll_partial
-				    && (b - t - count >
-					3 * vc->vc_rows >> 2)))) {
-				if (t > 0)
-					fbcon_redraw_move(vc, p, 0, t, count);
-				ypan_up_redraw(vc, t, count);
-				if (vc->vc_rows - b > 0)
-					fbcon_redraw_move(vc, p, b,
-							  vc->vc_rows - b, b);
-			} else
-				fbcon_redraw_move(vc, p, t + count, b - t - count, t);
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
-			break;
-
-		case SCROLL_PAN_MOVE:
-			if ((p->yscroll + count <=
-			     2 * (p->vrows - vc->vc_rows))
-			    && ((!scroll_partial && (b - t == vc->vc_rows))
-				|| (scroll_partial
-				    && (b - t - count >
-					3 * vc->vc_rows >> 2)))) {
-				if (t > 0)
-					fbcon_bmove(vc, 0, 0, count, 0, t,
-						    vc->vc_cols);
-				ypan_up(vc, count);
-				if (vc->vc_rows - b > 0)
-					fbcon_bmove(vc, b - count, 0, b, 0,
-						    vc->vc_rows - b,
-						    vc->vc_cols);
-			} else if (info->flags & FBINFO_READS_FAST)
-				fbcon_bmove(vc, t + count, 0, t, 0,
-					    b - t - count, vc->vc_cols);
-			else
-				goto redraw_up;
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
-			break;
-
-		case SCROLL_REDRAW:
-		      redraw_up:
-			fbcon_redraw(vc, p, t, b - t - count,
-				     count * vc->vc_cols);
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
-			scr_memsetw((unsigned short *) (vc->vc_origin +
-							vc->vc_size_row *
-							(b - count)),
-				    vc->vc_video_erase_char,
-				    vc->vc_size_row * count);
-			return true;
-		}
-		break;
+		fbcon_redraw(vc, p, t, b - t - count,
+			     count * vc->vc_cols);
+		fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
+		scr_memsetw((unsigned short *) (vc->vc_origin +
+						vc->vc_size_row *
+						(b - count)),
+			    vc->vc_video_erase_char,
+			    vc->vc_size_row * count);
+		return true;
 
 	case SM_DOWN:
 		if (count > vc->vc_rows)	/* Maximum realistic size */
 			count = vc->vc_rows;
-		if (logo_shown >= 0)
-			goto redraw_down;
-		switch (p->scrollmode) {
-		case SCROLL_MOVE:
-			fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
-				     -count);
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
-			scr_memsetw((unsigned short *) (vc->vc_origin +
-							vc->vc_size_row *
-							t),
-				    vc->vc_video_erase_char,
-				    vc->vc_size_row * count);
-			return true;
-
-		case SCROLL_WRAP_MOVE:
-			if (b - t - count > 3 * vc->vc_rows >> 2) {
-				if (vc->vc_rows - b > 0)
-					fbcon_bmove(vc, b, 0, b - count, 0,
-						    vc->vc_rows - b,
-						    vc->vc_cols);
-				ywrap_down(vc, count);
-				if (t > 0)
-					fbcon_bmove(vc, count, 0, 0, 0, t,
-						    vc->vc_cols);
-			} else if (info->flags & FBINFO_READS_FAST)
-				fbcon_bmove(vc, t, 0, t + count, 0,
-					    b - t - count, vc->vc_cols);
-			else
-				goto redraw_down;
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
-			break;
-
-		case SCROLL_PAN_MOVE:
-			if ((count - p->yscroll <= p->vrows - vc->vc_rows)
-			    && ((!scroll_partial && (b - t == vc->vc_rows))
-				|| (scroll_partial
-				    && (b - t - count >
-					3 * vc->vc_rows >> 2)))) {
-				if (vc->vc_rows - b > 0)
-					fbcon_bmove(vc, b, 0, b - count, 0,
-						    vc->vc_rows - b,
-						    vc->vc_cols);
-				ypan_down(vc, count);
-				if (t > 0)
-					fbcon_bmove(vc, count, 0, 0, 0, t,
-						    vc->vc_cols);
-			} else if (info->flags & FBINFO_READS_FAST)
-				fbcon_bmove(vc, t, 0, t + count, 0,
-					    b - t - count, vc->vc_cols);
-			else
-				goto redraw_down;
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
-			break;
-
-		case SCROLL_PAN_REDRAW:
-			if ((count - p->yscroll <= p->vrows - vc->vc_rows)
-			    && ((!scroll_partial && (b - t == vc->vc_rows))
-				|| (scroll_partial
-				    && (b - t - count >
-					3 * vc->vc_rows >> 2)))) {
-				if (vc->vc_rows - b > 0)
-					fbcon_redraw_move(vc, p, b, vc->vc_rows - b,
-							  b - count);
-				ypan_down_redraw(vc, t, count);
-				if (t > 0)
-					fbcon_redraw_move(vc, p, count, t, 0);
-			} else
-				fbcon_redraw_move(vc, p, t, b - t - count, t + count);
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
-			break;
-
-		case SCROLL_REDRAW:
-		      redraw_down:
-			fbcon_redraw(vc, p, b - 1, b - t - count,
-				     -count * vc->vc_cols);
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
-			scr_memsetw((unsigned short *) (vc->vc_origin +
-							vc->vc_size_row *
-							t),
-				    vc->vc_video_erase_char,
-				    vc->vc_size_row * count);
-			return true;
-		}
+		fbcon_redraw(vc, p, b - 1, b - t - count,
+			     -count * vc->vc_cols);
+		fbcon_clear(vc, t, 0, count, vc->vc_cols);
+		scr_memsetw((unsigned short *) (vc->vc_origin +
+						vc->vc_size_row *
+						t),
+			    vc->vc_video_erase_char,
+			    vc->vc_size_row * count);
+		return true;
 	}
 	return false;
 }
 
-
-static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
-			int height, int width)
-{
-	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
-	struct fbcon_display *p = &fb_display[vc->vc_num];
-	
-	if (fbcon_is_inactive(vc, info))
-		return;
-
-	if (!width || !height)
-		return;
-
-	/*  Split blits that cross physical y_wrap case.
-	 *  Pathological case involves 4 blits, better to use recursive
-	 *  code rather than unrolled case
-	 *
-	 *  Recursive invocations don't need to erase the cursor over and
-	 *  over again, so we use fbcon_bmove_rec()
-	 */
-	fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width,
-			p->vrows - p->yscroll);
-}
-
-static void fbcon_bmove_rec(struct vc_data *vc, struct fbcon_display *p, int sy, int sx,
-			    int dy, int dx, int height, int width, u_int y_break)
-{
-	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
-	struct fbcon_ops *ops = info->fbcon_par;
-	u_int b;
-
-	if (sy < y_break && sy + height > y_break) {
-		b = y_break - sy;
-		if (dy < sy) {	/* Avoid trashing self */
-			fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
-					y_break);
-			fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
-					height - b, width, y_break);
-		} else {
-			fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
-					height - b, width, y_break);
-			fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
-					y_break);
-		}
-		return;
-	}
-
-	if (dy < y_break && dy + height > y_break) {
-		b = y_break - dy;
-		if (dy < sy) {	/* Avoid trashing self */
-			fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
-					y_break);
-			fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
-					height - b, width, y_break);
-		} else {
-			fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
-					height - b, width, y_break);
-			fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
-					y_break);
-		}
-		return;
-	}
-	ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
-		   height, width);
-}
-
 static void updatescrollmode(struct fbcon_display *p,
 					struct fb_info *info,
 					struct vc_data *vc)
@@ -2119,21 +1664,7 @@ static int fbcon_switch(struct vc_data *vc)
 
 	updatescrollmode(p, info, vc);
 
-	switch (p->scrollmode) {
-	case SCROLL_WRAP_MOVE:
-		scrollback_phys_max = p->vrows - vc->vc_rows;
-		break;
-	case SCROLL_PAN_MOVE:
-	case SCROLL_PAN_REDRAW:
-		scrollback_phys_max = p->vrows - 2 * vc->vc_rows;
-		if (scrollback_phys_max < 0)
-			scrollback_phys_max = 0;
-		break;
-	default:
-		scrollback_phys_max = 0;
-		break;
-	}
-
+	scrollback_phys_max = 0;
 	scrollback_max = 0;
 	scrollback_current = 0;
 
diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h
index 9315b360c898..a00603b4451a 100644
--- a/drivers/video/fbdev/core/fbcon.h
+++ b/drivers/video/fbdev/core/fbcon.h
@@ -29,7 +29,6 @@ struct fbcon_display {
     /* Filled in by the low-level console driver */
     const u_char *fontdata;
     int userfont;                   /* != 0 if fontdata kmalloc()ed */
-    u_short scrollmode;             /* Scroll Method */
     u_short inverse;                /* != 0 text black on white as default */
     short yscroll;                  /* Hardware scrolling */
     int vrows;                      /* number of virtual rows */
@@ -52,8 +51,6 @@ struct fbcon_display {
 };
 
 struct fbcon_ops {
-	void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,
-		      int sx, int dy, int dx, int height, int width);
 	void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
 		      int sx, int height, int width);
 	void (*putcs)(struct vc_data *vc, struct fb_info *info,
@@ -152,62 +149,6 @@ static inline int attr_col_ec(int shift, struct vc_data *vc,
 #define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0)
 #define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1)
 
-    /*
-     *  Scroll Method
-     */
-     
-/* There are several methods fbcon can use to move text around the screen:
- *
- *                     Operation   Pan    Wrap
- *---------------------------------------------
- * SCROLL_MOVE         copyarea    No     No
- * SCROLL_PAN_MOVE     copyarea    Yes    No
- * SCROLL_WRAP_MOVE    copyarea    No     Yes
- * SCROLL_REDRAW       imageblit   No     No
- * SCROLL_PAN_REDRAW   imageblit   Yes    No
- * SCROLL_WRAP_REDRAW  imageblit   No     Yes
- *
- * (SCROLL_WRAP_REDRAW is not implemented yet)
- *
- * In general, fbcon will choose the best scrolling
- * method based on the rule below:
- *
- * Pan/Wrap > accel imageblit > accel copyarea >
- * soft imageblit > (soft copyarea)
- *
- * Exception to the rule: Pan + accel copyarea is
- * preferred over Pan + accel imageblit.
- *
- * The above is typical for PCI/AGP cards. Unless
- * overridden, fbcon will never use soft copyarea.
- *
- * If you need to override the above rule, set the
- * appropriate flags in fb_info->flags.  For example,
- * to prefer copyarea over imageblit, set
- * FBINFO_READS_FAST.
- *
- * Other notes:
- * + use the hardware engine to move the text
- *    (hw-accelerated copyarea() and fillrect())
- * + use hardware-supported panning on a large virtual screen
- * + amifb can not only pan, but also wrap the display by N lines
- *    (i.e. visible line i = physical line (i+N) % yres).
- * + read what's already rendered on the screen and
- *     write it in a different place (this is cfb_copyarea())
- * + re-render the text to the screen
- *
- * Whether to use wrapping or panning can only be figured out at
- * runtime (when we know whether our font height is a multiple
- * of the pan/wrap step)
- *
- */
-
-#define SCROLL_MOVE	   0x001
-#define SCROLL_PAN_MOVE	   0x002
-#define SCROLL_WRAP_MOVE   0x003
-#define SCROLL_REDRAW	   0x004
-#define SCROLL_PAN_REDRAW  0x005
-
 #ifdef CONFIG_FB_TILEBLITTING
 extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info);
 #endif
diff --git a/drivers/video/fbdev/core/fbcon_ccw.c b/drivers/video/fbdev/core/fbcon_ccw.c
index 9cd2c4b05c32..ffa78936eaab 100644
--- a/drivers/video/fbdev/core/fbcon_ccw.c
+++ b/drivers/video/fbdev/core/fbcon_ccw.c
@@ -59,31 +59,12 @@ static void ccw_update_attr(u8 *dst, u8 *src, int attribute,
 	}
 }
 
-
-static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
-		     int sx, int dy, int dx, int height, int width)
-{
-	struct fbcon_ops *ops = info->fbcon_par;
-	struct fb_copyarea area;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
-
-	area.sx = sy * vc->vc_font.height;
-	area.sy = vyres - ((sx + width) * vc->vc_font.width);
-	area.dx = dy * vc->vc_font.height;
-	area.dy = vyres - ((dx + width) * vc->vc_font.width);
-	area.width = height * vc->vc_font.height;
-	area.height  = width * vc->vc_font.width;
-
-	info->fbops->fb_copyarea(info, &area);
-}
-
 static void ccw_clear(struct vc_data *vc, struct fb_info *info, int sy,
 		     int sx, int height, int width)
 {
-	struct fbcon_ops *ops = info->fbcon_par;
 	struct fb_fillrect region;
 	int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
+	u32 vyres = info->var.yres;
 
 	region.color = attr_bgcol_ec(bgshift,vc,info);
 	region.dx = sy * vc->vc_font.height;
@@ -140,7 +121,7 @@ static void ccw_putcs(struct vc_data *vc, struct fb_info *info,
 	u32 cnt, pitch, size;
 	u32 attribute = get_attribute(info, scr_readw(s));
 	u8 *dst, *buf = NULL;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
+	u32 vyres = info->var.yres;
 
 	if (!ops->fontbuffer)
 		return;
@@ -229,7 +210,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
 	int attribute, use_sw = vc->vc_cursor_type & CUR_SW;
 	int err = 1, dx, dy;
 	char *src;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
+	u32 vyres = info->var.yres;
 
 	if (!ops->fontbuffer)
 		return;
@@ -387,7 +368,7 @@ static int ccw_update_start(struct fb_info *info)
 {
 	struct fbcon_ops *ops = info->fbcon_par;
 	u32 yoffset;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
+	u32 vyres = info->var.yres;
 	int err;
 
 	yoffset = (vyres - info->var.yres) - ops->var.xoffset;
@@ -402,7 +383,6 @@ static int ccw_update_start(struct fb_info *info)
 
 void fbcon_rotate_ccw(struct fbcon_ops *ops)
 {
-	ops->bmove = ccw_bmove;
 	ops->clear = ccw_clear;
 	ops->putcs = ccw_putcs;
 	ops->clear_margins = ccw_clear_margins;
diff --git a/drivers/video/fbdev/core/fbcon_cw.c b/drivers/video/fbdev/core/fbcon_cw.c
index 88d89fad3f05..92e5b7fb51ee 100644
--- a/drivers/video/fbdev/core/fbcon_cw.c
+++ b/drivers/video/fbdev/core/fbcon_cw.c
@@ -44,31 +44,12 @@ static void cw_update_attr(u8 *dst, u8 *src, int attribute,
 	}
 }
 
-
-static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
-		     int sx, int dy, int dx, int height, int width)
-{
-	struct fbcon_ops *ops = info->fbcon_par;
-	struct fb_copyarea area;
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
-
-	area.sx = vxres - ((sy + height) * vc->vc_font.height);
-	area.sy = sx * vc->vc_font.width;
-	area.dx = vxres - ((dy + height) * vc->vc_font.height);
-	area.dy = dx * vc->vc_font.width;
-	area.width = height * vc->vc_font.height;
-	area.height  = width * vc->vc_font.width;
-
-	info->fbops->fb_copyarea(info, &area);
-}
-
 static void cw_clear(struct vc_data *vc, struct fb_info *info, int sy,
 		     int sx, int height, int width)
 {
-	struct fbcon_ops *ops = info->fbcon_par;
 	struct fb_fillrect region;
 	int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
+	u32 vxres = info->var.xres;
 
 	region.color = attr_bgcol_ec(bgshift,vc,info);
 	region.dx = vxres - ((sy + height) * vc->vc_font.height);
@@ -125,7 +106,7 @@ static void cw_putcs(struct vc_data *vc, struct fb_info *info,
 	u32 cnt, pitch, size;
 	u32 attribute = get_attribute(info, scr_readw(s));
 	u8 *dst, *buf = NULL;
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
+	u32 vxres = info->var.xres;
 
 	if (!ops->fontbuffer)
 		return;
@@ -212,7 +193,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
 	int attribute, use_sw = vc->vc_cursor_type & CUR_SW;
 	int err = 1, dx, dy;
 	char *src;
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
+	u32 vxres = info->var.xres;
 
 	if (!ops->fontbuffer)
 		return;
@@ -369,7 +350,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
 static int cw_update_start(struct fb_info *info)
 {
 	struct fbcon_ops *ops = info->fbcon_par;
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
+	u32 vxres = info->var.xres;
 	u32 xoffset;
 	int err;
 
@@ -385,7 +366,6 @@ static int cw_update_start(struct fb_info *info)
 
 void fbcon_rotate_cw(struct fbcon_ops *ops)
 {
-	ops->bmove = cw_bmove;
 	ops->clear = cw_clear;
 	ops->putcs = cw_putcs;
 	ops->clear_margins = cw_clear_margins;
diff --git a/drivers/video/fbdev/core/fbcon_rotate.h b/drivers/video/fbdev/core/fbcon_rotate.h
index e233444cda66..b528b2e54283 100644
--- a/drivers/video/fbdev/core/fbcon_rotate.h
+++ b/drivers/video/fbdev/core/fbcon_rotate.h
@@ -11,15 +11,6 @@
 #ifndef _FBCON_ROTATE_H
 #define _FBCON_ROTATE_H
 
-#define GETVYRES(s,i) ({                           \
-        (s == SCROLL_REDRAW || s == SCROLL_MOVE) ? \
-        (i)->var.yres : (i)->var.yres_virtual; })
-
-#define GETVXRES(s,i) ({                           \
-        (s == SCROLL_REDRAW || s == SCROLL_MOVE || !(i)->fix.xpanstep) ? \
-        (i)->var.xres : (i)->var.xres_virtual; })
-
-
 static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat)
 {
 	u32 tmp = (y * pitch) + x, index = tmp / 8,  bit = tmp % 8;
diff --git a/drivers/video/fbdev/core/fbcon_ud.c b/drivers/video/fbdev/core/fbcon_ud.c
index 8d5e66b1bdfb..09619bd8e021 100644
--- a/drivers/video/fbdev/core/fbcon_ud.c
+++ b/drivers/video/fbdev/core/fbcon_ud.c
@@ -44,33 +44,13 @@ static void ud_update_attr(u8 *dst, u8 *src, int attribute,
 	}
 }
 
-
-static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy,
-		     int sx, int dy, int dx, int height, int width)
-{
-	struct fbcon_ops *ops = info->fbcon_par;
-	struct fb_copyarea area;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
-
-	area.sy = vyres - ((sy + height) * vc->vc_font.height);
-	area.sx = vxres - ((sx + width) * vc->vc_font.width);
-	area.dy = vyres - ((dy + height) * vc->vc_font.height);
-	area.dx = vxres - ((dx + width) * vc->vc_font.width);
-	area.height = height * vc->vc_font.height;
-	area.width  = width * vc->vc_font.width;
-
-	info->fbops->fb_copyarea(info, &area);
-}
-
 static void ud_clear(struct vc_data *vc, struct fb_info *info, int sy,
 		     int sx, int height, int width)
 {
-	struct fbcon_ops *ops = info->fbcon_par;
 	struct fb_fillrect region;
 	int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
+	u32 vyres = info->var.yres;
+	u32 vxres = info->var.xres;
 
 	region.color = attr_bgcol_ec(bgshift,vc,info);
 	region.dy = vyres - ((sy + height) * vc->vc_font.height);
@@ -162,8 +142,8 @@ static void ud_putcs(struct vc_data *vc, struct fb_info *info,
 	u32 mod = vc->vc_font.width % 8, cnt, pitch, size;
 	u32 attribute = get_attribute(info, scr_readw(s));
 	u8 *dst, *buf = NULL;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
+	u32 vyres = info->var.yres;
+	u32 vxres = info->var.xres;
 
 	if (!ops->fontbuffer)
 		return;
@@ -259,8 +239,8 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode,
 	int attribute, use_sw = vc->vc_cursor_type & CUR_SW;
 	int err = 1, dx, dy;
 	char *src;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
+	u32 vyres = info->var.yres;
+	u32 vxres = info->var.xres;
 
 	if (!ops->fontbuffer)
 		return;
@@ -410,8 +390,8 @@ static int ud_update_start(struct fb_info *info)
 {
 	struct fbcon_ops *ops = info->fbcon_par;
 	int xoffset, yoffset;
-	u32 vyres = GETVYRES(ops->p->scrollmode, info);
-	u32 vxres = GETVXRES(ops->p->scrollmode, info);
+	u32 vyres = info->var.yres;
+	u32 vxres = info->var.xres;
 	int err;
 
 	xoffset = vxres - info->var.xres - ops->var.xoffset;
@@ -429,7 +409,6 @@ static int ud_update_start(struct fb_info *info)
 
 void fbcon_rotate_ud(struct fbcon_ops *ops)
 {
-	ops->bmove = ud_bmove;
 	ops->clear = ud_clear;
 	ops->putcs = ud_putcs;
 	ops->clear_margins = ud_clear_margins;
diff --git a/drivers/video/fbdev/core/tileblit.c b/drivers/video/fbdev/core/tileblit.c
index 2768eff247ba..72af95053bcb 100644
--- a/drivers/video/fbdev/core/tileblit.c
+++ b/drivers/video/fbdev/core/tileblit.c
@@ -16,21 +16,6 @@
 #include <asm/types.h>
 #include "fbcon.h"
 
-static void tile_bmove(struct vc_data *vc, struct fb_info *info, int sy,
-		       int sx, int dy, int dx, int height, int width)
-{
-	struct fb_tilearea area;
-
-	area.sx = sx;
-	area.sy = sy;
-	area.dx = dx;
-	area.dy = dy;
-	area.height = height;
-	area.width = width;
-
-	info->tileops->fb_tilecopy(info, &area);
-}
-
 static void tile_clear(struct vc_data *vc, struct fb_info *info, int sy,
 		       int sx, int height, int width)
 {
@@ -133,7 +118,6 @@ void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info)
 	struct fb_tilemap map;
 	struct fbcon_ops *ops = info->fbcon_par;
 
-	ops->bmove = tile_bmove;
 	ops->clear = tile_clear;
 	ops->putcs = tile_putcs;
 	ops->clear_margins = tile_clear_margins;
diff --git a/drivers/video/fbdev/skeletonfb.c b/drivers/video/fbdev/skeletonfb.c
index bcacfb6934fa..0fe922f726e9 100644
--- a/drivers/video/fbdev/skeletonfb.c
+++ b/drivers/video/fbdev/skeletonfb.c
@@ -505,15 +505,15 @@ void xxxfb_fillrect(struct fb_info *p, const struct fb_fillrect *region)
 }
 
 /**
- *      xxxfb_copyarea - REQUIRED function. Can use generic routines if
- *                       non acclerated hardware and packed pixel based.
+ *      xxxfb_copyarea - OBSOLETE function.
  *                       Copies one area of the screen to another area.
+ *                       Will be deleted in a future version
  *
  *      @info: frame buffer structure that represents a single frame buffer
  *      @area: Structure providing the data to copy the framebuffer contents
  *	       from one region to another.
  *
- *      This drawing operation copies a rectangular area from one area of the
+ *      This drawing operation copied a rectangular area from one area of the
  *	screen to another area.
  */
 void xxxfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) 
@@ -645,9 +645,9 @@ static const struct fb_ops xxxfb_ops = {
 	.fb_setcolreg	= xxxfb_setcolreg,
 	.fb_blank	= xxxfb_blank,
 	.fb_pan_display	= xxxfb_pan_display,
-	.fb_fillrect	= xxxfb_fillrect, 	/* Needed !!! */
-	.fb_copyarea	= xxxfb_copyarea,	/* Needed !!! */
-	.fb_imageblit	= xxxfb_imageblit,	/* Needed !!! */
+	.fb_fillrect	= xxxfb_fillrect,	/* Needed !!!   */
+	.fb_copyarea	= xxxfb_copyarea,	/* Obsolete     */
+	.fb_imageblit	= xxxfb_imageblit,	/* Needed !!!   */
 	.fb_cursor	= xxxfb_cursor,		/* Optional !!! */
 	.fb_sync	= xxxfb_sync,
 	.fb_ioctl	= xxxfb_ioctl,
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 5950f8f5dc74..6f3db99ab990 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -262,7 +262,7 @@ struct fb_ops {
 
 	/* Draws a rectangle */
 	void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);
-	/* Copy data from area to another */
+	/* Copy data from area to another. Obsolete. */
 	void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);
 	/* Draws a image to the display */
 	void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);
commit cd06ab2fd48f2c0243b06344a36056e811d263b8
Author: Jani Nikula <jani.nikula at intel.com>
Date:   Fri Oct 1 12:14:44 2021 +0300

    drm/locking: add backtrace for locking contended locks without backoff
    
    If drm_modeset_lock() returns -EDEADLK, the caller is supposed to drop
    all currently held locks using drm_modeset_backoff(). Failing to do so
    will result in warnings and backtraces on the paths trying to lock a
    contended lock. Add support for optionally printing the backtrace on the
    path that hit the deadlock and didn't gracefully handle the situation.
    
    For example, the patch [1] inadvertently dropped the return value check
    and error return on replacing calc_watermark_data() with
    intel_compute_global_watermarks(). The backtraces on the subsequent
    locking paths hitting WARN_ON(ctx->contended) were unhelpful, but adding
    the backtrace to the deadlock path produced this helpful printout:
    
    <7> [98.002465] drm_modeset_lock attempting to lock a contended lock without backoff:
       drm_modeset_lock+0x107/0x130
       drm_atomic_get_plane_state+0x76/0x150
       skl_compute_wm+0x251d/0x2b20 [i915]
       intel_atomic_check+0x1942/0x29e0 [i915]
       drm_atomic_check_only+0x554/0x910
       drm_atomic_nonblocking_commit+0xe/0x50
       drm_mode_atomic_ioctl+0x8c2/0xab0
       drm_ioctl_kernel+0xac/0x140
    
    Add new CONFIG_DRM_DEBUG_MODESET_LOCK to enable modeset lock debugging
    with stack depot and trace.
    
    [1] https://lore.kernel.org/r/20210924114741.15940-4-jani.nikula@intel.com
    
    v2:
    - default y if DEBUG_WW_MUTEX_SLOWPATH (Daniel)
    - depends on DEBUG_KERNEL
    
    Cc: Daniel Vetter <daniel at ffwll.ch>
    Cc: Dave Airlie <airlied at gmail.com>
    Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Signed-off-by: Jani Nikula <jani.nikula at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211001091444.8177-1-jani.nikula@intel.com

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 2a926d0de423..a4c020a9a0eb 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -100,6 +100,21 @@ config DRM_DEBUG_DP_MST_TOPOLOGY_REFS
           This has the potential to use a lot of memory and print some very
           large kernel messages. If in doubt, say "N".
 
+config DRM_DEBUG_MODESET_LOCK
+	bool "Enable backtrace history for lock contention"
+	depends on STACKTRACE_SUPPORT
+	depends on DEBUG_KERNEL
+	depends on EXPERT
+	select STACKDEPOT
+	default y if DEBUG_WW_MUTEX_SLOWPATH
+	help
+	  Enable debug tracing of failures to gracefully handle drm modeset lock
+	  contention. A history of each drm modeset lock path hitting -EDEADLK
+	  will be saved until gracefully handled, and the backtrace will be
+	  printed when attempting to lock a contended lock.
+
+	  If in doubt, say "N".
+
 config DRM_FBDEV_EMULATION
 	bool "Enable legacy fbdev support for your modesetting driver"
 	depends on DRM
diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c
index fcfe1a03c4a1..62f6fe482d25 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -25,6 +25,7 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_device.h>
 #include <drm/drm_modeset_lock.h>
+#include <drm/drm_print.h>
 
 /**
  * DOC: kms locking
@@ -77,6 +78,45 @@
 
 static DEFINE_WW_CLASS(crtc_ww_class);
 
+#if IS_ENABLED(CONFIG_DRM_DEBUG_MODESET_LOCK)
+static noinline depot_stack_handle_t __stack_depot_save(void)
+{
+	unsigned long entries[8];
+	unsigned int n;
+
+	n = stack_trace_save(entries, ARRAY_SIZE(entries), 1);
+
+	return stack_depot_save(entries, n, GFP_NOWAIT | __GFP_NOWARN);
+}
+
+static void __stack_depot_print(depot_stack_handle_t stack_depot)
+{
+	struct drm_printer p = drm_debug_printer("drm_modeset_lock");
+	unsigned long *entries;
+	unsigned int nr_entries;
+	char *buf;
+
+	buf = kmalloc(PAGE_SIZE, GFP_NOWAIT | __GFP_NOWARN);
+	if (!buf)
+		return;
+
+	nr_entries = stack_depot_fetch(stack_depot, &entries);
+	stack_trace_snprint(buf, PAGE_SIZE, entries, nr_entries, 2);
+
+	drm_printf(&p, "attempting to lock a contended lock without backoff:\n%s", buf);
+
+	kfree(buf);
+}
+#else /* CONFIG_DRM_DEBUG_MODESET_LOCK */
+static depot_stack_handle_t __stack_depot_save(void)
+{
+	return 0;
+}
+static void __stack_depot_print(depot_stack_handle_t stack_depot)
+{
+}
+#endif /* CONFIG_DRM_DEBUG_MODESET_LOCK */
+
 /**
  * drm_modeset_lock_all - take all modeset locks
  * @dev: DRM device
@@ -225,7 +265,9 @@ EXPORT_SYMBOL(drm_modeset_acquire_fini);
  */
 void drm_modeset_drop_locks(struct drm_modeset_acquire_ctx *ctx)
 {
-	WARN_ON(ctx->contended);
+	if (WARN_ON(ctx->contended))
+		__stack_depot_print(ctx->stack_depot);
+
 	while (!list_empty(&ctx->locked)) {
 		struct drm_modeset_lock *lock;
 
@@ -243,7 +285,8 @@ static inline int modeset_lock(struct drm_modeset_lock *lock,
 {
 	int ret;
 
-	WARN_ON(ctx->contended);
+	if (WARN_ON(ctx->contended))
+		__stack_depot_print(ctx->stack_depot);
 
 	if (ctx->trylock_only) {
 		lockdep_assert_held(&ctx->ww_ctx);
@@ -274,6 +317,7 @@ static inline int modeset_lock(struct drm_modeset_lock *lock,
 		ret = 0;
 	} else if (ret == -EDEADLK) {
 		ctx->contended = lock;
+		ctx->stack_depot = __stack_depot_save();
 	}
 
 	return ret;
@@ -296,6 +340,7 @@ int drm_modeset_backoff(struct drm_modeset_acquire_ctx *ctx)
 	struct drm_modeset_lock *contended = ctx->contended;
 
 	ctx->contended = NULL;
+	ctx->stack_depot = 0;
 
 	if (WARN_ON(!contended))
 		return 0;
diff --git a/include/drm/drm_modeset_lock.h b/include/drm/drm_modeset_lock.h
index aafd07388eb7..b84693fbd2b5 100644
--- a/include/drm/drm_modeset_lock.h
+++ b/include/drm/drm_modeset_lock.h
@@ -24,6 +24,8 @@
 #ifndef DRM_MODESET_LOCK_H_
 #define DRM_MODESET_LOCK_H_
 
+#include <linux/types.h> /* stackdepot.h is not self-contained */
+#include <linux/stackdepot.h>
 #include <linux/ww_mutex.h>
 
 struct drm_modeset_lock;
@@ -51,6 +53,12 @@ struct drm_modeset_acquire_ctx {
 	 */
 	struct drm_modeset_lock *contended;
 
+	/*
+	 * Stack depot for debugging when a contended lock was not backed off
+	 * from.
+	 */
+	depot_stack_handle_t stack_depot;
+
 	/*
 	 * list of held locks (drm_modeset_lock)
 	 */
commit 91302d6c1dfd438b53237831f1f78dfbfd8ce934
Author: Amos Kong <amos at sietium.com>
Date:   Wed Oct 6 03:35:56 2021 +0800

    drm/ttm_bo_api: update the description for @placement and @sg
    
    Correct the argument name of @placement and added @sg description for
    ttm_bo_init() and ttm_bo_init_reserved().
    
    Argument @flags was replaced to @placement by Jerome in commit
    09855acb1c2e3779f25317ec9a8ffe1b1784a4a8
    
    Argument @sg was added by Dave in commit
    129b78bfca591e736e56a294f0e357d73d938f7e
    
    Signed-off-by: Amos Kong <amos at sietium.com>
    Cc: Jerome Glisse <jglisse at redhat.com>
    Cc: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Christian König <christian.koenig at amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/38eac09bf2ddd6088cc8a126e6bc4792eaa2dc88.1633462176.git.amos@sietium.com
    Signed-off-by: Christian König <christian.koenig at amd.com>

diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 76d7c33884da..0551e2587f14 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -351,9 +351,10 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
  * @bo: Pointer to a ttm_buffer_object to be initialized.
  * @size: Requested size of buffer object.
  * @type: Requested type of buffer object.
- * @flags: Initial placement flags.
+ * @placement: Initial placement for buffer object.
  * @page_alignment: Data alignment in pages.
  * @ctx: TTM operation context for memory allocation.
+ * @sg: Scatter-gather table.
  * @resv: Pointer to a dma_resv, or NULL to let ttm allocate one.
  * @destroy: Destroy function. Use NULL for kfree().
  *
@@ -394,7 +395,7 @@ int ttm_bo_init_reserved(struct ttm_device *bdev,
  * @bo: Pointer to a ttm_buffer_object to be initialized.
  * @size: Requested size of buffer object.
  * @type: Requested type of buffer object.
- * @flags: Initial placement flags.
+ * @placement: Initial placement for buffer object.
  * @page_alignment: Data alignment in pages.
  * @interruptible: If needing to sleep to wait for GPU resources,
  * sleep interruptible.
@@ -402,6 +403,7 @@ int ttm_bo_init_reserved(struct ttm_device *bdev,
  * holds a pointer to a persistent shmem object. Typically, this would
  * point to the shmem object backing a GEM object if TTM is used to back a
  * GEM user interface.
+ * @sg: Scatter-gather table.
  * @resv: Pointer to a dma_resv, or NULL to let ttm allocate one.
  * @destroy: Destroy function. Use NULL for kfree().
  *
commit 381ba6a6baf104b572379c6b2deab884555104d4
Author: Karol Herbst <kherbst at redhat.com>
Date:   Tue Oct 12 15:33:34 2021 +0200

    drm/nouveau/mmu/gp100: remove unused variable
    
    Fixes a compilation issue introduced because I forgot to test with WERROR
    enabled.
    
    Cc: Stephen Rothwell <sfr at canb.auug.org.au>
    Cc: DRI <dri-devel at lists.freedesktop.org>
    Cc: nouveau at lists.freedesktop.org
    Fixes: 404046cf4805 ("drm/nouveau/mmu/gp100-: drop unneeded assignment in the if condition.")
    Acked-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Lyude Paul <lyude at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211012133334.1737918-1-kherbst@redhat.com

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
index 2b21f43069aa..17899fc95b2d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
@@ -488,7 +488,7 @@ gp100_vmm_fault_cancel(struct nvkm_vmm *vmm, void *argv, u32 argc)
 		struct gp100_vmm_fault_cancel_v0 v0;
 	} *args = argv;
 	int ret = -ENOSYS;
-	u32 inst, aper;
+	u32 aper;
 
 	if ((ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false)))
 		return ret;
commit 55e6d8037805b3400096d621091dfbf713f97e83
Author: Yang Yingliang <yangyingliang at huawei.com>
Date:   Tue Oct 12 10:37:35 2021 +0800

    regmap: Fix possible double-free in regcache_rbtree_exit()
    
    In regcache_rbtree_insert_to_block(), when 'present' realloc failed,
    the 'blk' which is supposed to assign to 'rbnode->block' will be freed,
    so 'rbnode->block' points a freed memory, in the error handling path of
    regcache_rbtree_init(), 'rbnode->block' will be freed again in
    regcache_rbtree_exit(), KASAN will report double-free as follows:
    
    BUG: KASAN: double-free or invalid-free in kfree+0xce/0x390
    Call Trace:
     slab_free_freelist_hook+0x10d/0x240
     kfree+0xce/0x390
     regcache_rbtree_exit+0x15d/0x1a0
     regcache_rbtree_init+0x224/0x2c0
     regcache_init+0x88d/0x1310
     __regmap_init+0x3151/0x4a80
     __devm_regmap_init+0x7d/0x100
     madera_spi_probe+0x10f/0x333 [madera_spi]
     spi_probe+0x183/0x210
     really_probe+0x285/0xc30
    
    To fix this, moving up the assignment of rbnode->block to immediately after
    the reallocation has succeeded so that the data structure stays valid even
    if the second reallocation fails.
    
    Reported-by: Hulk Robot <hulkci at huawei.com>
    Fixes: 3f4ff561bc88b ("regmap: rbtree: Make cache_present bitmap per node")
    Signed-off-by: Yang Yingliang <yangyingliang at huawei.com>
    Link: https://lore.kernel.org/r/20211012023735.1632786-1-yangyingliang@huawei.com
    Signed-off-by: Mark Brown <broonie at kernel.org>

diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index cfa29dc89bbf..fabf87058d80 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -281,14 +281,14 @@ static int regcache_rbtree_insert_to_block(struct regmap *map,
 	if (!blk)
 		return -ENOMEM;
 
+	rbnode->block = blk;
+
 	if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) {
 		present = krealloc(rbnode->cache_present,
 				   BITS_TO_LONGS(blklen) * sizeof(*present),
 				   GFP_KERNEL);
-		if (!present) {
-			kfree(blk);
+		if (!present)
 			return -ENOMEM;
-		}
 
 		memset(present + BITS_TO_LONGS(rbnode->blklen), 0,
 		       (BITS_TO_LONGS(blklen) - BITS_TO_LONGS(rbnode->blklen))
@@ -305,7 +305,6 @@ static int regcache_rbtree_insert_to_block(struct regmap *map,
 	}
 
 	/* update the rbnode block, its size and the base register */
-	rbnode->block = blk;
 	rbnode->blklen = blklen;
 	rbnode->base_reg = base_reg;
 	rbnode->cache_present = present;
commit 1db060509903b29d63fe2e39c14fd0f99c4a447e
Author: Guido Günther <agx at sigxcpu.org>
Date:   Mon Oct 11 15:41:27 2021 +0200

    drm: mxsfb: Set fallback bus format when the bridge doesn't provide one
    
    If a bridge doesn't do any bus format handling MEDIA_BUS_FMT_FIXED is
    returned. Fallback to a reasonable default (MEDIA_BUS_FMT_RGB888_1X24) in
    that case.
    
    This unbreaks e.g. using mxsfb with the nwl bridge and mipi dsi panels.
    
    Reported-by: Martin Kepplinger <martink at posteo.de>
    Signed-off-by: Guido Günther <agx at sigxcpu.org>
    Reviewed-by: Lucas Stach <l.stach at pengutronix.de>
    Reviewed-by: Sam Ravnborg <sam at ravnborg.org>
    Acked-by: Stefan Agner <stefan at agner.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/781f0352052cc50c823c199ef5f53c84902d0580.1633959458.git.agx@sigxcpu.org

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index d1cab1166ecf..0655582ae8ed 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -362,6 +362,12 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc,
 			drm_atomic_get_new_bridge_state(state,
 							mxsfb->bridge);
 		bus_format = bridge_state->input_bus_cfg.format;
+		if (bus_format == MEDIA_BUS_FMT_FIXED) {
+			dev_warn_once(drm->dev,
+				      "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"
+				      "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n");
+			bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+		}
 	}
 
 	/* If there is no bridge, use bus format from connector */
commit e2e0ee7e2c2b062e27ca0dd597793a56a5761865
Author: Guido Günther <agx at sigxcpu.org>
Date:   Mon Oct 11 15:41:26 2021 +0200

    drm: mxsfb: Print failed bus format in hex
    
    media-bus-formats.h has them in hexadecimal as well so matching with
    that file saves one conversion when debugging.
    
    Signed-off-by: Guido Günther <agx at sigxcpu.org>
    Reviewed-by: Lucas Stach <l.stach at pengutronix.de>
    Reviewed-by: Robert Foss <robert.foss at linaro.org>
    Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
    Reviewed-by: Sam Ravnborg <sam at ravnborg.org>
    Acked-by: Stefan Agner <stefan at agner.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/c84b34855abbb85cd25bbb5126db302f88327640.1633959458.git.agx@sigxcpu.org

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 89dd618d78f3..d1cab1166ecf 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -88,7 +88,7 @@ static void mxsfb_set_formats(struct mxsfb_drm_private *mxsfb,
 		ctrl |= CTRL_BUS_WIDTH_24;
 		break;
 	default:
-		dev_err(drm->dev, "Unknown media bus format %d\n", bus_format);
+		dev_err(drm->dev, "Unknown media bus format 0x%x\n", bus_format);
 		break;
 	}
 
commit 0c464eee746abadf0cc36a6a91ab05d90891578c
Author: Guido Günther <agx at sigxcpu.org>
Date:   Mon Oct 11 15:41:25 2021 +0200

    drm/panel: st7703: Add media bus format
    
    This allows the DSI bridge to detect the correct bus format.
    We currently only support MEDIA_BUS_FMT_RGB888_1X24.
    
    Signed-off-by: Guido Günther <agx at sigxcpu.org>
    Reviewed-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/d7ebeec861f4518c8497a5e07d09d5a9fd123d3d.1633959458.git.agx@sigxcpu.org

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index a2c303e5732c..73f69c929a75 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -453,6 +453,10 @@ disable_vcc:
 	return ret;
 }
 
+static const u32 mantix_bus_formats[] = {
+	MEDIA_BUS_FMT_RGB888_1X24,
+};
+
 static int st7703_get_modes(struct drm_panel *panel,
 			    struct drm_connector *connector)
 {
@@ -474,6 +478,10 @@ static int st7703_get_modes(struct drm_panel *panel,
 	connector->display_info.height_mm = mode->height_mm;
 	drm_mode_probed_add(connector, mode);
 
+	drm_display_info_set_bus_formats(&connector->display_info,
+					 mantix_bus_formats,
+					 ARRAY_SIZE(mantix_bus_formats));
+
 	return 1;
 }
 
commit 1311f3dfce7e2c9fe21edce2c3eefa744109a4ec
Author: Guido Günther <agx at sigxcpu.org>
Date:   Mon Oct 11 15:41:24 2021 +0200

    drm/panel: mantix: Add media bus format
    
    This allows the DSI bridge to detect the correct bus format.
    We currently only support MEDIA_BUS_FMT_RGB888_1X24.
    
    Signed-off-by: Guido Günther <agx at sigxcpu.org>
    Reviewed-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/75fbe7139a84fa133499afe242c204ba4516da98.1633959458.git.agx@sigxcpu.org

diff --git a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
index 30f28ad4df6b..31daae1da9c9 100644
--- a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
+++ b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
@@ -8,6 +8,7 @@
 #include <linux/backlight.h>
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
+#include <linux/media-bus-format.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/regulator/consumer.h>
@@ -220,6 +221,10 @@ static const struct drm_display_mode default_mode_ys = {
 	.height_mm   = 130,
 };
 
+static const u32 mantix_bus_formats[] = {
+	MEDIA_BUS_FMT_RGB888_1X24,
+};
+
 static int mantix_get_modes(struct drm_panel *panel,
 			    struct drm_connector *connector)
 {
@@ -241,6 +246,10 @@ static int mantix_get_modes(struct drm_panel *panel,
 	connector->display_info.height_mm = mode->height_mm;
 	drm_mode_probed_add(connector, mode);
 
+	drm_display_info_set_bus_formats(&connector->display_info,
+					 mantix_bus_formats,
+					 ARRAY_SIZE(mantix_bus_formats));
+
 	return 1;
 }
 
commit 2f1495fac8d38bfade18bd7e31fa787cd7815626
Author: Guido Günther <agx at sigxcpu.org>
Date:   Mon Oct 11 15:41:23 2021 +0200

    drm/bridge: nwl-dsi: Add atomic_get_input_bus_fmts
    
    Components further up in the chain might ask us for supported formats.
    
    Without this MEDIA_BUS_FMT_FIXED is assumed which then breaks display
    output with mxsfb since it can't determine a proper bus format.
    
    We handle the bus formats that correspond to the DSI formats the bridge
    can potentially output (see chapter 13.6 of the i.MX 8MQ reference
    manual) - which matches what xsfb can input.
    
    Fixes: b776b0f00f24 ("drm: mxsfb: Use bus_format from the nearest bridge if present")
    
    Signed-off-by: Guido Günther <agx at sigxcpu.org>
    Reviewed-by: Lucas Stach <l.stach at pengutronix.de>
    Reviewed-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/1712f2b952694fd4484dfd8576fbc5b4d7adf042.1633959458.git.agx@sigxcpu.org

diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
index ed8ac5059cd2..a7389a0facfb 100644
--- a/drivers/gpu/drm/bridge/nwl-dsi.c
+++ b/drivers/gpu/drm/bridge/nwl-dsi.c
@@ -939,6 +939,40 @@ static void nwl_dsi_bridge_detach(struct drm_bridge *bridge)
 	drm_of_panel_bridge_remove(dsi->dev->of_node, 1, 0);
 }
 
+static u32 *nwl_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
+						 struct drm_bridge_state *bridge_state,
+						 struct drm_crtc_state *crtc_state,
+						 struct drm_connector_state *conn_state,
+						 u32 output_fmt,
+						 unsigned int *num_input_fmts)
+{
+	u32 *input_fmts, input_fmt;
+
+	*num_input_fmts = 0;
+
+	switch (output_fmt) {
+	/* If MEDIA_BUS_FMT_FIXED is tested, return default bus format */
+	case MEDIA_BUS_FMT_FIXED:
+		input_fmt = MEDIA_BUS_FMT_RGB888_1X24;
+		break;
+	case MEDIA_BUS_FMT_RGB888_1X24:
+	case MEDIA_BUS_FMT_RGB666_1X18:
+	case MEDIA_BUS_FMT_RGB565_1X16:
+		input_fmt = output_fmt;
+		break;
+	default:
+		return NULL;
+	}
+
+	input_fmts = kcalloc(1, sizeof(*input_fmts), GFP_KERNEL);
+	if (!input_fmts)
+		return NULL;
+	input_fmts[0] = input_fmt;
+	*num_input_fmts = 1;
+
+	return input_fmts;
+}
+
 static const struct drm_bridge_funcs nwl_dsi_bridge_funcs = {
 	.atomic_duplicate_state	= drm_atomic_helper_bridge_duplicate_state,
 	.atomic_destroy_state	= drm_atomic_helper_bridge_destroy_state,
@@ -946,6 +980,7 @@ static const struct drm_bridge_funcs nwl_dsi_bridge_funcs = {
 	.atomic_check		= nwl_dsi_bridge_atomic_check,
 	.atomic_enable		= nwl_dsi_bridge_atomic_enable,
 	.atomic_disable		= nwl_dsi_bridge_atomic_disable,
+	.atomic_get_input_bus_fmts = nwl_bridge_atomic_get_input_bus_fmts,
 	.mode_set		= nwl_dsi_bridge_mode_set,
 	.mode_valid		= nwl_dsi_bridge_mode_valid,
 	.attach			= nwl_dsi_bridge_attach,
commit 4217d07b9fb328751f877d3bd9550122014860a2
Author: Shawn Guo <shawn.guo at linaro.org>
Date:   Mon Oct 4 10:49:35 2021 +0800

    mmc: sdhci: Map more voltage level to SDHCI_POWER_330
    
    On Thundercomm TurboX CM2290, the eMMC OCR reports vdd = 23 (3.5 ~ 3.6 V),
    which is being treated as an invalid value by sdhci_set_power_noreg().
    And thus eMMC is totally broken on the platform.
    
    [    1.436599] ------------[ cut here ]------------
    [    1.436606] mmc0: Invalid vdd 0x17
    [    1.436640] WARNING: CPU: 2 PID: 69 at drivers/mmc/host/sdhci.c:2048 sdhci_set_power_noreg+0x168/0x2b4
    [    1.436655] Modules linked in:
    [    1.436662] CPU: 2 PID: 69 Comm: kworker/u8:1 Tainted: G        W         5.15.0-rc1+ #137
    [    1.436669] Hardware name: Thundercomm TurboX CM2290 (DT)
    [    1.436674] Workqueue: events_unbound async_run_entry_fn
    [    1.436685] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [    1.436692] pc : sdhci_set_power_noreg+0x168/0x2b4
    [    1.436698] lr : sdhci_set_power_noreg+0x168/0x2b4
    [    1.436703] sp : ffff800010803a60
    [    1.436705] x29: ffff800010803a60 x28: ffff6a9102465f00 x27: ffff6a9101720a70
    [    1.436715] x26: ffff6a91014de1c0 x25: ffff6a91014de010 x24: ffff6a91016af280
    [    1.436724] x23: ffffaf7b1b276640 x22: 0000000000000000 x21: ffff6a9101720000
    [    1.436733] x20: ffff6a9101720370 x19: ffff6a9101720580 x18: 0000000000000020
    [    1.436743] x17: 0000000000000000 x16: 0000000000000004 x15: ffffffffffffffff
    [    1.436751] x14: 0000000000000000 x13: 00000000fffffffd x12: ffffaf7b1b84b0bc
    [    1.436760] x11: ffffaf7b1b720d10 x10: 000000000000000a x9 : ffff800010803a60
    [    1.436769] x8 : 000000000000000a x7 : 000000000000000f x6 : 00000000fffff159
    [    1.436778] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000ffffffff
    [    1.436787] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff6a9101718d80
    [    1.436797] Call trace:
    [    1.436800]  sdhci_set_power_noreg+0x168/0x2b4
    [    1.436805]  sdhci_set_ios+0xa0/0x7fc
    [    1.436811]  mmc_power_up.part.0+0xc4/0x164
    [    1.436818]  mmc_start_host+0xa0/0xb0
    [    1.436824]  mmc_add_host+0x60/0x90
    [    1.436830]  __sdhci_add_host+0x174/0x330
    [    1.436836]  sdhci_msm_probe+0x7c0/0x920
    [    1.436842]  platform_probe+0x68/0xe0
    [    1.436850]  really_probe.part.0+0x9c/0x31c
    [    1.436857]  __driver_probe_device+0x98/0x144
    [    1.436863]  driver_probe_device+0xc8/0x15c
    [    1.436869]  __device_attach_driver+0xb4/0x120
    [    1.436875]  bus_for_each_drv+0x78/0xd0
    [    1.436881]  __device_attach_async_helper+0xac/0xd0
    [    1.436888]  async_run_entry_fn+0x34/0x110
    [    1.436895]  process_one_work+0x1d0/0x354
    [    1.436903]  worker_thread+0x13c/0x470
    [    1.436910]  kthread+0x150/0x160
    [    1.436915]  ret_from_fork+0x10/0x20
    [    1.436923] ---[ end trace fcfac44cb045c3a8 ]---
    
    Fix the issue by mapping MMC_VDD_35_36 (and MMC_VDD_34_35) to
    SDHCI_POWER_330 as well.
    
    Signed-off-by: Shawn Guo <shawn.guo at linaro.org>
    Acked-by: Adrian Hunter <adrian.hunter at intel.com>
    Cc: stable at vger.kernel.org
    Link: https://lore.kernel.org/r/20211004024935.15326-1-shawn.guo@linaro.org
    Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 8eefa7d5fe85..2d80a04e11d8 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2042,6 +2042,12 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
 			break;
 		case MMC_VDD_32_33:
 		case MMC_VDD_33_34:
+		/*
+		 * 3.4 ~ 3.6V are valid only for those platforms where it's
+		 * known that the voltage range is supported by hardware.
+		 */
+		case MMC_VDD_34_35:
+		case MMC_VDD_35_36:
 			pwr = SDHCI_POWER_330;
 			break;
 		default:
commit ee30840ba3baa0bad0ce70905f89942b66d5e0f9
Author: Dan Carpenter <dan.carpenter at oracle.com>
Date:   Mon Oct 11 15:33:03 2021 +0300

    drm/v3d: fix copy_from_user() error codes
    
    The copy_to/from_user() function returns the number of bytes remaining
    to be copied, but we want to return -EFAULT on error.
    
    Fixes: e4165ae8304e ("drm/v3d: add multiple syncobjs support")
    Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
    Reviewed-by: Melissa Wen <mwen at igalia.com>
    Signed-off-by: Melissa Wen <melissa.srw at gmail.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211011123303.GA14314@kili

diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
index 6a000d77c568..e47ae40a865a 100644
--- a/drivers/gpu/drm/v3d/v3d_gem.c
+++ b/drivers/gpu/drm/v3d/v3d_gem.c
@@ -487,8 +487,8 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
 			for (i = 0; i < se->in_sync_count; i++) {
 				struct drm_v3d_sem in;
 
-				ret = copy_from_user(&in, handle++, sizeof(in));
-				if (ret) {
+				if (copy_from_user(&in, handle++, sizeof(in))) {
+					ret = -EFAULT;
 					DRM_DEBUG("Failed to copy wait dep handle.\n");
 					goto fail_deps;
 				}
@@ -609,8 +609,8 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv,
 	for (i = 0; i < count; i++) {
 		struct drm_v3d_sem out;
 
-		ret = copy_from_user(&out, post_deps++, sizeof(out));
-		if (ret) {
+		if (copy_from_user(&out, post_deps++, sizeof(out))) {
+			ret = -EFAULT;
 			DRM_DEBUG("Failed to copy post dep handles\n");
 			goto fail;
 		}
@@ -646,9 +646,8 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,
 	struct v3d_submit_ext *se = data;
 	int ret;
 
-	ret = copy_from_user(&multisync, ext, sizeof(multisync));
-	if (ret)
-		return ret;
+	if (copy_from_user(&multisync, ext, sizeof(multisync)))
+		return -EFAULT;
 
 	if (multisync.pad)
 		return -EINVAL;
commit f85d9e59f1b4f7e452f8bba6b75b666faef39676
Author: Randy Dunlap <rdunlap at infradead.org>
Date:   Sun Oct 10 15:44:59 2021 -0700

    drm/connector: fix all kernel-doc warnings
    
    Clean up all of the kernel-doc issues in drm_connector.c:
    
    drivers/gpu/drm/drm_connector.c:2611: warning: Excess function parameter 'connector' description in 'drm_connector_oob_hotplug_event'
    drivers/gpu/drm/drm_connector.c:2611: warning: Function parameter or member 'connector_fwnode' not described in 'drm_connector_oob_hotplug_event'
    
    drm_connector.c:630: warning: No description found for return value of 'drm_get_connector_status_name'
    drm_connector.c:715: warning: No description found for return value of 'drm_connector_list_iter_next'
    drm_connector.c:785: warning: No description found for return value of 'drm_get_subpixel_order_name'
    drm_connector.c:816: warning: No description found for return value of 'drm_display_info_set_bus_formats'
    drm_connector.c:1331: warning: No description found for return value of 'drm_mode_create_dvi_i_properties'
    drm_connector.c:1412: warning: No description found for return value of 'drm_connector_attach_content_type_property'
    drm_connector.c:1492: warning: No description found for return value of 'drm_mode_create_tv_margin_properties'
    drm_connector.c:1534: warning: No description found for return value of 'drm_mode_create_tv_properties'
    drm_connector.c:1627: warning: No description found for return value of 'drm_mode_create_scaling_mode_property'
    drm_connector.c:1944: warning: No description found for return value of 'drm_mode_create_suggested_offset_properties'
    
    drm_connector.c:2315: warning: missing initial short description on line:
     * drm_connector_set_panel_orientation_with_quirk -
    
    [The last warning listed is probably a quirk/bug in scripts/kernel-doc.]
    
    Fixes: 613051dac40d ("drm: locking&new iterators for connector_list")
    Fixes: 522171951761 ("drm: Extract drm_connector.[hc]")
    Fixes: b3c6c8bfe378 ("drm: document drm_display_info")
    Fixes: 50525c332b55 ("drm: content-type property for HDMI connector")
    Fixes: 6c4f52dca36f ("drm/connector: Allow creation of margin props alone")
    Fixes: 69654c632d80 ("drm/connector: Split out orientation quirk detection (v2)")
    Fixes: 72ad49682dde ("drm/connector: Add support for out-of-band hotplug notification (v3)")
    Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
    Cc: David Airlie <airlied at linux.ie>
    Cc: Daniel Vetter <daniel at ffwll.ch>
    Cc: dri-devel at lists.freedesktop.org
    Cc: Stanislav Lisovskiy <stanislav.lisovskiy at intel.com>
    Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Cc: Derek Basehore <dbasehore at chromium.org>
    Cc: Hans de Goede <hdegoede at redhat.com>
    Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
    Cc: Maxime Ripard <mripard at kernel.org>
    Cc: Thomas Zimmermann <tzimmermann at suse.de>
    Cc: Sam Ravnborg <sam at ravnborg.org>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211010224459.3603-1-rdunlap@infradead.org

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 79d8163686cd..52e20c68813b 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -625,6 +625,8 @@ int drm_connector_register_all(struct drm_device *dev)
  *
  * In contrast to the other drm_get_*_name functions this one here returns a
  * const pointer and hence is threadsafe.
+ *
+ * Returns: connector status string
  */
 const char *drm_get_connector_status_name(enum drm_connector_status status)
 {
@@ -707,7 +709,7 @@ __drm_connector_put_safe(struct drm_connector *conn)
  * drm_connector_list_iter_next - return next connector
  * @iter: connector_list iterator
  *
- * Returns the next connector for @iter, or NULL when the list walk has
+ * Returns: the next connector for @iter, or NULL when the list walk has
  * completed.
  */
 struct drm_connector *
@@ -780,6 +782,8 @@ static const struct drm_prop_enum_list drm_subpixel_enum_list[] = {
  *
  * Note you could abuse this and return something out of bounds, but that
  * would be a caller error.  No unscrubbed user data should make it here.
+ *
+ * Returns: string describing an enumerated subpixel property
  */
 const char *drm_get_subpixel_order_name(enum subpixel_order order)
 {
@@ -809,6 +813,9 @@ static const struct drm_prop_enum_list drm_link_status_enum_list[] = {
  * Store the supported bus formats in display info structure.
  * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for
  * a full list of available formats.
+ *
+ * Returns:
+ * 0 on success or a negative error code on failure.
  */
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
 				     const u32 *formats,
@@ -1326,6 +1333,8 @@ int drm_connector_create_standard_properties(struct drm_device *dev)
  * @dev: DRM device
  *
  * Called by a driver the first time a DVI-I connector is made.
+ *
+ * Returns: %0
  */
 int drm_mode_create_dvi_i_properties(struct drm_device *dev)
 {
@@ -1409,6 +1418,8 @@ EXPORT_SYMBOL(drm_connector_attach_dp_subconnector_property);
  * @connector: connector to attach content type property on.
  *
  * Called by a driver the first time a HDMI connector is made.
+ *
+ * Returns: %0
  */
 int drm_connector_attach_content_type_property(struct drm_connector *connector)
 {
@@ -1489,6 +1500,9 @@ EXPORT_SYMBOL(drm_connector_attach_tv_margin_properties);
  * creates the TV margin properties for a given device. No need to call this
  * function for an SDTV connector, it's already called from
  * drm_mode_create_tv_properties().
+ *
+ * Returns:
+ * 0 on success or a negative error code on failure.
  */
 int drm_mode_create_tv_margin_properties(struct drm_device *dev)
 {
@@ -1529,6 +1543,9 @@ EXPORT_SYMBOL(drm_mode_create_tv_margin_properties);
  * the TV specific connector properties for a given device.  Caller is
  * responsible for allocating a list of format names and passing them to
  * this routine.
+ *
+ * Returns:
+ * 0 on success or a negative error code on failure.
  */
 int drm_mode_create_tv_properties(struct drm_device *dev,
 				  unsigned int num_modes,
@@ -1624,6 +1641,8 @@ EXPORT_SYMBOL(drm_mode_create_tv_properties);
  * Atomic drivers should use drm_connector_attach_scaling_mode_property()
  * instead to correctly assign &drm_connector_state.scaling_mode
  * in the atomic state.
+ *
+ * Returns: %0
  */
 int drm_mode_create_scaling_mode_property(struct drm_device *dev)
 {
@@ -1941,6 +1960,9 @@ EXPORT_SYMBOL(drm_mode_create_content_type_property);
  * @dev: DRM device
  *
  * Create the suggested x/y offset property for connectors.
+ *
+ * Returns:
+ * 0 on success or a negative error code on failure.
  */
 int drm_mode_create_suggested_offset_properties(struct drm_device *dev)
 {
@@ -2314,8 +2336,8 @@ int drm_connector_set_panel_orientation(
 EXPORT_SYMBOL(drm_connector_set_panel_orientation);
 
 /**
- * drm_connector_set_panel_orientation_with_quirk -
- *	set the connector's panel_orientation after checking for quirks
+ * drm_connector_set_panel_orientation_with_quirk - set the
+ *	connector's panel_orientation after checking for quirks
  * @connector: connector for which to init the panel-orientation property.
  * @panel_orientation: drm_panel_orientation value to set
  * @width: width in pixels of the panel, used for panel quirk detection
@@ -2599,7 +2621,7 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode)
 
 /**
  * drm_connector_oob_hotplug_event - Report out-of-band hotplug event to connector
- * @connector: connector to report the event on
+ * @connector_fwnode: fwnode_handle to report the event on
  *
  * On some hardware a hotplug event notification may come from outside the display
  * driver / device. An example of this is some USB Type-C setups where the hardware
commit 90c45fc15aaf5719477a1e841caa000c6b2c1832
Author: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
Date:   Mon Oct 11 15:27:42 2021 +0200

    drm/panel: s6e63m0: Make s6e63m0_remove() return void
    
    Up to now s6e63m0_remove() returns zero unconditionally. Make it return
    void instead which makes it easier to see in the callers that there is
    no error to handle.
    
    Also the return value of spi remove callbacks is ignored anyway.
    
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211011132754.2479853-2-u.kleine-koenig@pengutronix.de

diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
index e0b1a7e354f3..e0f773678168 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c
@@ -116,7 +116,8 @@ static int s6e63m0_dsi_probe(struct mipi_dsi_device *dsi)
 static int s6e63m0_dsi_remove(struct mipi_dsi_device *dsi)
 {
 	mipi_dsi_detach(dsi);
-	return s6e63m0_remove(&dsi->dev);
+	s6e63m0_remove(&dsi->dev);
+	return 0;
 }
 
 static const struct of_device_id s6e63m0_dsi_of_match[] = {
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
index 3669cc3719ce..c178d962b0d5 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c
@@ -64,7 +64,8 @@ static int s6e63m0_spi_probe(struct spi_device *spi)
 
 static int s6e63m0_spi_remove(struct spi_device *spi)
 {
-	return s6e63m0_remove(&spi->dev);
+	s6e63m0_remove(&spi->dev);
+	return 0;
 }
 
 static const struct of_device_id s6e63m0_spi_of_match[] = {
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
index 35d72ac663d6..b34fa4d5de07 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c
@@ -749,13 +749,11 @@ int s6e63m0_probe(struct device *dev, void *trsp,
 }
 EXPORT_SYMBOL_GPL(s6e63m0_probe);
 
-int s6e63m0_remove(struct device *dev)
+void s6e63m0_remove(struct device *dev)
 {
 	struct s6e63m0 *ctx = dev_get_drvdata(dev);
 
 	drm_panel_remove(&ctx->panel);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(s6e63m0_remove);
 
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
index 306605ed1117..c926eca1c817 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h
@@ -35,6 +35,6 @@ int s6e63m0_probe(struct device *dev, void *trsp,
 				   const u8 *data,
 				   size_t len),
 		  bool dsi_mode);
-int s6e63m0_remove(struct device *dev);
+void s6e63m0_remove(struct device *dev);
 
 #endif /* _PANEL_SAMSUNG_S6E63M0_H */
commit 5e51cc0005c6ed1b793c228632f36269615f7c31
Author: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Date:   Fri Oct 8 10:50:07 2021 +0100

    dma-resv: Fix dma_resv_get_fences and dma_resv_copy_fences after conversion
    
    Cache the count of shared fences in the iterator to avoid dereferencing
    the dma_resv_object outside the RCU protection. Otherwise iterator and its
    users can observe an incosistent state which makes it impossible to use
    safely. Such as:
    
    <6> [187.517041] [IGT] gem_sync: executing
    <7> [187.536343] i915 0000:00:02.0: [drm:i915_gem_context_create_ioctl [i915]] HW context 1 created
    <7> [187.536793] i915 0000:00:02.0: [drm:i915_gem_context_create_ioctl [i915]] HW context 1 created
    <6> [187.551235] [IGT] gem_sync: starting subtest basic-many-each
    <1> [188.935462] BUG: kernel NULL pointer dereference, address: 0000000000000010
    <1> [188.935485] #PF: supervisor write access in kernel mode
    <1> [188.935495] #PF: error_code(0x0002) - not-present page
    <6> [188.935504] PGD 0 P4D 0
    <4> [188.935512] Oops: 0002 [#1] PREEMPT SMP NOPTI
    <4> [188.935521] CPU: 2 PID: 1467 Comm: gem_sync Not tainted 5.15.0-rc4-CI-Patchwork_21264+ #1
    <4> [188.935535] Hardware name:  /NUC6CAYB, BIOS AYAPLCEL.86A.0049.2018.0508.1356 05/08/2018
    <4> [188.935546] RIP: 0010:dma_resv_get_fences+0x116/0x2d0
    <4> [188.935560] Code: 10 85 c0 7f c9 be 03 00 00 00 e8 15 8b df ff eb bd e8 8e c6 ff ff eb b6 41 8b 04 24 49 8b 55 00 48 89 e7 8d 48 01 41 89 0c 24 <4c> 89 34 c2 e8 41 f2 ff ff 49 89 c6 48 85 c0 75 8c 48 8b 44 24 10
    <4> [188.935583] RSP: 0018:ffffc900011dbcc8 EFLAGS: 00010202
    <4> [188.935593] RAX: 0000000000000000 RBX: 00000000ffffffff RCX: 0000000000000001
    <4> [188.935603] RDX: 0000000000000010 RSI: ffffffff822e343c RDI: ffffc900011dbcc8
    <4> [188.935613] RBP: ffffc900011dbd48 R08: ffff88812d255bb8 R09: 00000000fffffffe
    <4> [188.935623] R10: 0000000000000001 R11: 0000000000000000 R12: ffffc900011dbd44
    <4> [188.935633] R13: ffffc900011dbd50 R14: ffff888113d29cc0 R15: 0000000000000000
    <4> [188.935643] FS:  00007f68d17e9700(0000) GS:ffff888277900000(0000) knlGS:0000000000000000
    <4> [188.935655] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    <4> [188.935665] CR2: 0000000000000010 CR3: 000000012d0a4000 CR4: 00000000003506e0
    <4> [188.935676] Call Trace:
    <4> [188.935685]  i915_gem_object_wait+0x1ff/0x410 [i915]
    <4> [188.935988]  i915_gem_wait_ioctl+0xf2/0x2a0 [i915]
    <4> [188.936272]  ? i915_gem_object_wait+0x410/0x410 [i915]
    <4> [188.936533]  drm_ioctl_kernel+0xae/0x140
    <4> [188.936546]  drm_ioctl+0x201/0x3d0
    <4> [188.936555]  ? i915_gem_object_wait+0x410/0x410 [i915]
    <4> [188.936820]  ? __fget_files+0xc2/0x1c0
    <4> [188.936830]  ? __fget_files+0xda/0x1c0
    <4> [188.936839]  __x64_sys_ioctl+0x6d/0xa0
    <4> [188.936848]  do_syscall_64+0x3a/0xb0
    <4> [188.936859]  entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    If the shared object has changed during the RCU unlocked period
    callers will correctly handle the restart on the next iteration.
    
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
    Fixes: 96601e8a4755 ("dma-buf: use new iterator in dma_resv_copy_fences")
    Fixes: d3c80698c9f5 ("dma-buf: use new iterator in dma_resv_get_fences v3")
    Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4274
    Cc: Christian König <christian.koenig at amd.com>
    Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
    Cc: Sumit Semwal <sumit.semwal at linaro.org>
    Cc: linux-media at vger.kernel.org
    Cc: dri-devel at lists.freedesktop.org
    Cc: linaro-mm-sig at lists.linaro.org
    Link: https://patchwork.freedesktop.org/patch/msgid/20211008095007.972693-1-tvrtko.ursulin@linux.intel.com
    Reviewed-by: Christian König <christian.koenig at amd.com>
    Signed-off-by: Christian König <christian.koenig at amd.com>

diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index 2f98caa68ae5..9eb2baa387d4 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -333,10 +333,14 @@ static void dma_resv_iter_restart_unlocked(struct dma_resv_iter *cursor)
 {
 	cursor->seq = read_seqcount_begin(&cursor->obj->seq);
 	cursor->index = -1;
-	if (cursor->all_fences)
+	cursor->shared_count = 0;
+	if (cursor->all_fences) {
 		cursor->fences = dma_resv_shared_list(cursor->obj);
-	else
+		if (cursor->fences)
+			cursor->shared_count = cursor->fences->shared_count;
+	} else {
 		cursor->fences = NULL;
+	}
 	cursor->is_restarted = true;
 }
 
@@ -363,7 +367,7 @@ static void dma_resv_iter_walk_unlocked(struct dma_resv_iter *cursor)
 				continue;
 
 		} else if (!cursor->fences ||
-			   cursor->index >= cursor->fences->shared_count) {
+			   cursor->index >= cursor->shared_count) {
 			cursor->fence = NULL;
 			break;
 
@@ -499,10 +503,8 @@ int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src)
 			dma_resv_list_free(list);
 			dma_fence_put(excl);
 
-			if (cursor.fences) {
-				unsigned int cnt = cursor.fences->shared_count;
-
-				list = dma_resv_list_alloc(cnt);
+			if (cursor.shared_count) {
+				list = dma_resv_list_alloc(cursor.shared_count);
 				if (!list) {
 					dma_resv_iter_end(&cursor);
 					return -ENOMEM;
@@ -573,7 +575,7 @@ int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **fence_excl,
 			if (fence_excl)
 				dma_fence_put(*fence_excl);
 
-			count = cursor.fences ? cursor.fences->shared_count : 0;
+			count = cursor.shared_count;
 			count += fence_excl ? 0 : 1;
 
 			/* Eventually re-allocate the array */
diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
index 491359cea54c..45f1d4812a37 100644
--- a/include/linux/dma-resv.h
+++ b/include/linux/dma-resv.h
@@ -170,9 +170,12 @@ struct dma_resv_iter {
 	/** @index: index into the shared fences */
 	unsigned int index;
 
-	/** @fences: the shared fences */
+	/** @fences: the shared fences; private, *MUST* not dereference  */
 	struct dma_resv_list *fences;
 
+	/** @shared_count: number of shared fences */
+	unsigned int shared_count;
+
 	/** @is_restarted: true if this is the first returned fence */
 	bool is_restarted;
 };
commit f30946db159feddf8c89bdeeb79ff893d949d480
Author: Lee Jones <lee.jones at linaro.org>
Date:   Fri Apr 16 15:36:52 2021 +0100

    drm/nouveau/nouveau_bo: Remove unused variables 'dev'
    
    Fixes the following W=1 kernel build warning(s):
    
     drivers/gpu/drm/nouveau/nouveau_bo.c: In function ‘nouveau_ttm_tt_populate’:
     drivers/gpu/drm/nouveau/nouveau_bo.c:1228:17: warning: variable ‘dev’ set but not used [-Wunused-but-set-variable]
     drivers/gpu/drm/nouveau/nouveau_bo.c: In function ‘nouveau_ttm_tt_unpopulate’:
     drivers/gpu/drm/nouveau/nouveau_bo.c:1252:17: warning: variable ‘dev’ set but not used [-Wunused-but-set-variable]
    
    Cc: Ben Skeggs <bskeggs at redhat.com>
    Cc: David Airlie <airlied at linux.ie>
    Cc: Daniel Vetter <daniel at ffwll.ch>
    Cc: Sumit Semwal <sumit.semwal at linaro.org>
    Cc: "Christian König" <christian.koenig at amd.com>
    Cc: Jeremy Kolb <jkolb at brandeis.edu>
    Cc: dri-devel at lists.freedesktop.org
    Cc: nouveau at lists.freedesktop.org
    Cc: linux-media at vger.kernel.org
    Cc: linaro-mm-sig at lists.linaro.org
    Signed-off-by: Lee Jones <lee.jones at linaro.org>
    Reviewed-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210416143725.2769053-8-lee.jones@linaro.org

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index b2c7e0802ac3..17a0a3ece485 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1248,7 +1248,6 @@ nouveau_ttm_tt_populate(struct ttm_device *bdev,
 {
 	struct ttm_tt *ttm_dma = (void *)ttm;
 	struct nouveau_drm *drm;
-	struct device *dev;
 	bool slave = !!(ttm->page_flags & TTM_TT_FLAG_EXTERNAL);
 
 	if (ttm_tt_is_populated(ttm))
@@ -1261,7 +1260,6 @@ nouveau_ttm_tt_populate(struct ttm_device *bdev,
 	}
 
 	drm = nouveau_bdev(bdev);
-	dev = drm->dev->dev;
 
 	return ttm_pool_alloc(&drm->ttm.bdev.pool, ttm, ctx);
 }
@@ -1271,7 +1269,6 @@ nouveau_ttm_tt_unpopulate(struct ttm_device *bdev,
 			  struct ttm_tt *ttm)
 {
 	struct nouveau_drm *drm;
-	struct device *dev;
 	bool slave = !!(ttm->page_flags & TTM_TT_FLAG_EXTERNAL);
 
 	if (slave)
@@ -1280,7 +1277,6 @@ nouveau_ttm_tt_unpopulate(struct ttm_device *bdev,
 	nouveau_ttm_tt_unbind(bdev, ttm);
 
 	drm = nouveau_bdev(bdev);
-	dev = drm->dev->dev;
 
 	return ttm_pool_free(&drm->ttm.bdev.pool, ttm);
 }
commit 1e39f430575fbd3000dfe153c82ce8a41fec496a
Author: Yang Yingliang <yangyingliang at huawei.com>
Date:   Thu Apr 1 22:17:31 2021 +0800

    drm/nouveau/gem: remove redundant semi-colon
    
    Signed-off-by: Yang Yingliang <yangyingliang at huawei.com>
    Reviewed-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210401141731.1684236-1-yangyingliang@huawei.com

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 5b27845075a1..d476940ee97c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -339,7 +339,7 @@ nouveau_gem_set_domain(struct drm_gem_object *gem, uint32_t read_domains,
 	struct ttm_buffer_object *bo = &nvbo->bo;
 	uint32_t domains = valid_domains & nvbo->valid_domains &
 		(write_domains ? write_domains : read_domains);
-	uint32_t pref_domains = 0;;
+	uint32_t pref_domains = 0;
 
 	if (!domains)
 		return -EINVAL;
commit 404046cf48050167bc068bd12fdd2cbce61022c3
Author: Luo penghao <luo.penghao at zte.com.cn>
Date:   Fri Aug 20 19:14:47 2021 -0700

    drm/nouveau/mmu/gp100-: drop unneeded assignment in the if condition.
    
    In order to keep the code style consistency of the whole file,
    the 'inst' assignments should be deleted.
    
    The clang_analyzer complains as follows:
    
    drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c:499:8: warning:
    Although the value storedto 'inst' is used in the enclosing expression,
    the value is never actually read from 'inst'.
    
    Karol: Removed unneeded brackets.
    
    Reported-by: Zeal Robot <zealci at zte.com.cn>
    Signed-off-by: Luo penghao <luo.penghao at zte.com.cn>
    Reviewed-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210821021447.27097-1-luo.penghao@zte.com.cn

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
index b5e733783b5b..2b21f43069aa 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
@@ -502,7 +502,7 @@ gp100_vmm_fault_cancel(struct nvkm_vmm *vmm, void *argv, u32 argc)
 	args->v0.inst |= 0x80000000;
 
 	if (!WARN_ON(nvkm_gr_ctxsw_pause(device))) {
-		if ((inst = nvkm_gr_ctxsw_inst(device)) == args->v0.inst) {
+		if (nvkm_gr_ctxsw_inst(device) == args->v0.inst) {
 			gf100_vmm_invalidate(vmm, 0x0000001b
 					     /* CANCEL_TARGETED. */ |
 					     (args->v0.hub    << 20) |
commit 6363185938106f462e293fe4ded485911a9eb08f
Author: Luo penghao <luo.penghao at zte.com.cn>
Date:   Fri Aug 20 19:11:06 2021 -0700

    drm/nouveau/mmu: drop unneeded assignment in the nvkm_uvmm_mthd_page()
    
    In order to keep the code style consistency of the whole file,
    the 'ret' assignments should be deleted.
    
    The clang_analyzer complains as follows:
    
    drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c:317:8:warning:
    Although the value storedto 'ret' is used in the enclosing expression,
    the value is never actually read from 'ret'.
    
    Reported-by: Zeal Robot <zealci at zte.com.cn>
    Signed-off-by: Luo penghao <luo.penghao at zte.com.cn>
    Reviewed-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210821021106.27010-1-luo.penghao@zte.com.cn

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index d6a1f8d04c09..186b4e63e559 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -299,7 +299,7 @@ nvkm_uvmm_mthd_page(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 	page = uvmm->vmm->func->page;
 	for (nr = 0; page[nr].shift; nr++);
 
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
+	if (!(nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
 		if ((index = args->v0.index) >= nr)
 			return -EINVAL;
 		type = page[index].type;
commit cacadb0633bbd8069d9c3b51b56adb926004fdd8
Author: yong yiran <yong.yiran at zte.com.cn>
Date:   Fri Aug 6 20:20:54 2021 -0700

    drm/nouveau/nvenc: remove duplicate include in base.c
    
    'priv.h' included in 'base.c' is duplicated.
    Remove all but the first include of priv.h from base.c.
    
    Reported-by: Zeal Robot <zealci at zte.com.cn>
    Signed-off-by: yong yiran <yong.yiran at zte.com.cn>
    Reviewed-by: Karol Herbst <kherbst at redhat.com>
    Signed-off-by: Karol Herbst <kherbst at redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210807032054.642867-1-yong.yiran@zte.com.cn

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/nvenc/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/nvenc/base.c
index c39e797dc7c9..cf5dcfda7b25 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/nvenc/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/nvenc/base.c
@@ -21,7 +21,6 @@
  */
 #include "priv.h"
 
-#include "priv.h"
 #include <core/firmware.h>
 
 static void *
commit a63f393dd7e1ebee707c9dee1d197fdc33d6486b
Author: Jing Xiangfeng <jingxiangfeng at huawei.com>
Date:   Sat Oct 9 17:09:20 2021 +0800

    drm/virtio: fix the missed drm_gem_object_put() in virtio_gpu_user_framebuffer_create()
    
    virtio_gpu_user_framebuffer_create() misses to call drm_gem_object_put()
    in an error path. Add the missed function call to fix it.
    
    Signed-off-by: Jing Xiangfeng <jingxiangfeng at huawei.com>
    Link: http://patchwork.freedesktop.org/patch/msgid/1633770560-11658-1-git-send-email-jingxiangfeng@huawei.com
    Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index a6caebd4a0dd..5b00310ac4cd 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -308,8 +308,10 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,
 		return ERR_PTR(-EINVAL);
 
 	virtio_gpu_fb = kzalloc(sizeof(*virtio_gpu_fb), GFP_KERNEL);
-	if (virtio_gpu_fb == NULL)
+	if (virtio_gpu_fb == NULL) {
+		drm_gem_object_put(obj);
 		return ERR_PTR(-ENOMEM);
+	}
 
 	ret = virtio_gpu_framebuffer_init(dev, virtio_gpu_fb, mode_cmd, obj);
 	if (ret) {
commit 914b6f290beb0cf056d75badffa78df6e3dfb058
Author: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
Date:   Sat Oct 9 23:38:06 2021 +0300

    drm/panel: Add support for Sharp LS060T1SX01 panel
    
    Add driver to support Sharp LS06T1SX01 FullHD panel. The panel uses
    nt35695 driver IC. For example this LCD module can be found in the
    kwaek.ca Dragonboard Display Adapter Bundle.
    
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211009203806.56821-3-dmitry.baryshkov@linaro.org

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 369cb76512fe..eb01549a6ccb 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -519,6 +519,16 @@ config DRM_PANEL_SHARP_LS043T1LE01
 	  Say Y here if you want to enable support for Sharp LS043T1LE01 qHD
 	  (540x960) DSI panel as found on the Qualcomm APQ8074 Dragonboard
 
+config DRM_PANEL_SHARP_LS060T1SX01
+	tristate "Sharp LS060T1SX01 FullHD video mode panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for Sharp LS060T1SX01 6.0"
+	  FullHD (1080x1920) DSI panel as found in Dragonboard Display Adapter
+	  Bundle.
+
 config DRM_PANEL_SITRONIX_ST7701
 	tristate "Sitronix ST7701 panel driver"
 	depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 6e30640b9099..bca4cc1f2715 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
+obj-$(CONFIG_DRM_PANEL_SHARP_LS060T1SX01) += panel-sharp-ls060t1sx01.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += panel-sitronix-st7701.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
diff --git a/drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c b/drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c
new file mode 100644
index 000000000000..e12570561629
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c
@@ -0,0 +1,333 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2021 Linaro Ltd.
+ * Generated with linux-mdss-dsi-panel-driver-generator from vendor device tree:
+ *   Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regulator/consumer.h>
+
+#include <video/mipi_display.h>
+
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+
+struct sharp_ls060 {
+	struct drm_panel panel;
+	struct mipi_dsi_device *dsi;
+	struct regulator *vddi_supply;
+	struct regulator *vddh_supply;
+	struct regulator *avdd_supply;
+	struct regulator *avee_supply;
+	struct gpio_desc *reset_gpio;
+	bool prepared;
+};
+
+static inline struct sharp_ls060 *to_sharp_ls060(struct drm_panel *panel)
+{
+	return container_of(panel, struct sharp_ls060, panel);
+}
+
+#define dsi_dcs_write_seq(dsi, seq...) ({				\
+		static const u8 d[] = { seq };				\
+									\
+		mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));	\
+	})
+
+static void sharp_ls060_reset(struct sharp_ls060 *ctx)
+{
+	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
+	usleep_range(10000, 11000);
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+	usleep_range(10000, 11000);
+	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
+	usleep_range(10000, 11000);
+}
+
+static int sharp_ls060_on(struct sharp_ls060 *ctx)
+{
+	struct mipi_dsi_device *dsi = ctx->dsi;
+	struct device *dev = &dsi->dev;
+	int ret;
+
+	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
+
+	ret = dsi_dcs_write_seq(dsi, 0xbb, 0x13);
+	if (ret < 0) {
+		dev_err(dev, "Failed to send command: %d\n", ret);
+		return ret;
+	}
+
+	ret = dsi_dcs_write_seq(dsi, MIPI_DCS_WRITE_MEMORY_START);
+	if (ret < 0) {
+		dev_err(dev, "Failed to send command: %d\n", ret);
+		return ret;
+	}
+
+	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to exit sleep mode: %d\n", ret);
+		return ret;
+	}
+	msleep(120);
+
+	ret = mipi_dsi_dcs_set_display_on(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to set display on: %d\n", ret);
+		return ret;
+	}
+	msleep(50);
+
+	return 0;
+}
+
+static int sharp_ls060_off(struct sharp_ls060 *ctx)
+{
+	struct mipi_dsi_device *dsi = ctx->dsi;
+	struct device *dev = &dsi->dev;
+	int ret;
+
+	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
+
+	ret = mipi_dsi_dcs_set_display_off(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to set display off: %d\n", ret);
+		return ret;
+	}
+	usleep_range(2000, 3000);
+
+	ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to enter sleep mode: %d\n", ret);
+		return ret;
+	}
+	msleep(121);
+
+	return 0;
+}
+
+static int sharp_ls060_prepare(struct drm_panel *panel)
+{
+	struct sharp_ls060 *ctx = to_sharp_ls060(panel);
+	struct device *dev = &ctx->dsi->dev;
+	int ret;
+
+	if (ctx->prepared)
+		return 0;
+
+	ret = regulator_enable(ctx->vddi_supply);
+	if (ret < 0)
+		return ret;
+
+	ret = regulator_enable(ctx->avdd_supply);
+	if (ret < 0)
+		goto err_avdd;
+
+	usleep_range(1000, 2000);
+
+	ret = regulator_enable(ctx->avee_supply);
+	if (ret < 0)
+		goto err_avee;
+
+	usleep_range(10000, 11000);
+
+	ret = regulator_enable(ctx->vddh_supply);
+	if (ret < 0)
+		goto err_vddh;
+
+	usleep_range(10000, 11000);
+
+	sharp_ls060_reset(ctx);
+
+	ret = sharp_ls060_on(ctx);
+	if (ret < 0) {
+		dev_err(dev, "Failed to initialize panel: %d\n", ret);
+		goto err_on;
+	}
+
+	ctx->prepared = true;
+
+	return 0;
+
+err_on:
+	regulator_disable(ctx->vddh_supply);
+
+	usleep_range(10000, 11000);
+
+err_vddh:
+	regulator_disable(ctx->avee_supply);
+
+err_avee:
+	regulator_disable(ctx->avdd_supply);
+
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+
+err_avdd:
+	regulator_disable(ctx->vddi_supply);
+
+	return ret;
+}
+
+static int sharp_ls060_unprepare(struct drm_panel *panel)
+{
+	struct sharp_ls060 *ctx = to_sharp_ls060(panel);
+	struct device *dev = &ctx->dsi->dev;
+	int ret;
+
+	if (!ctx->prepared)
+		return 0;
+
+	ret = sharp_ls060_off(ctx);
+	if (ret < 0)
+		dev_err(dev, "Failed to un-initialize panel: %d\n", ret);
+
+	regulator_disable(ctx->vddh_supply);
+
+	usleep_range(10000, 11000);
+
+	regulator_disable(ctx->avee_supply);
+	regulator_disable(ctx->avdd_supply);
+
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+
+	regulator_disable(ctx->vddi_supply);
+
+	ctx->prepared = false;
+	return 0;
+}
+
+static const struct drm_display_mode sharp_ls060_mode = {
+	.clock = (1080 + 96 + 16 + 64) * (1920 + 4 + 1 + 16) * 60 / 1000,
+	.hdisplay = 1080,
+	.hsync_start = 1080 + 96,
+	.hsync_end = 1080 + 96 + 16,
+	.htotal = 1080 + 96 + 16 + 64,
+	.vdisplay = 1920,
+	.vsync_start = 1920 + 4,
+	.vsync_end = 1920 + 4 + 1,
+	.vtotal = 1920 + 4 + 1 + 16,
+	.width_mm = 75,
+	.height_mm = 132,
+};
+
+static int sharp_ls060_get_modes(struct drm_panel *panel,
+				 struct drm_connector *connector)
+{
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, &sharp_ls060_mode);
+	if (!mode)
+		return -ENOMEM;
+
+	drm_mode_set_name(mode);
+
+	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+	connector->display_info.width_mm = mode->width_mm;
+	connector->display_info.height_mm = mode->height_mm;
+	drm_mode_probed_add(connector, mode);
+
+	return 1;
+}
+
+static const struct drm_panel_funcs sharp_ls060_panel_funcs = {
+	.prepare = sharp_ls060_prepare,
+	.unprepare = sharp_ls060_unprepare,
+	.get_modes = sharp_ls060_get_modes,
+};
+
+static int sharp_ls060_probe(struct mipi_dsi_device *dsi)
+{
+	struct device *dev = &dsi->dev;
+	struct sharp_ls060 *ctx;
+	int ret;
+
+	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	ctx->vddi_supply = devm_regulator_get(dev, "vddi");
+	if (IS_ERR(ctx->vddi_supply))
+		return PTR_ERR(ctx->vddi_supply);
+
+	ctx->vddh_supply = devm_regulator_get(dev, "vddh");
+	if (IS_ERR(ctx->vddh_supply))
+		return PTR_ERR(ctx->vddh_supply);
+
+	ctx->avdd_supply = devm_regulator_get(dev, "avdd");
+	if (IS_ERR(ctx->avdd_supply))
+		return PTR_ERR(ctx->avdd_supply);
+
+	ctx->avee_supply = devm_regulator_get(dev, "avee");
+	if (IS_ERR(ctx->avee_supply))
+		return PTR_ERR(ctx->avee_supply);
+
+	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(ctx->reset_gpio))
+		return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
+				     "Failed to get reset-gpios\n");
+
+	ctx->dsi = dsi;
+	mipi_dsi_set_drvdata(dsi, ctx);
+
+	dsi->lanes = 4;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
+			  MIPI_DSI_MODE_NO_EOT_PACKET |
+			  MIPI_DSI_CLOCK_NON_CONTINUOUS;
+
+	drm_panel_init(&ctx->panel, dev, &sharp_ls060_panel_funcs,
+		       DRM_MODE_CONNECTOR_DSI);
+
+	ret = drm_panel_of_backlight(&ctx->panel);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to get backlight\n");
+
+	drm_panel_add(&ctx->panel);
+
+	ret = mipi_dsi_attach(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to attach to DSI host: %d\n", ret);
+		drm_panel_remove(&ctx->panel);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int sharp_ls060_remove(struct mipi_dsi_device *dsi)
+{
+	struct sharp_ls060 *ctx = mipi_dsi_get_drvdata(dsi);
+	int ret;
+
+	ret = mipi_dsi_detach(dsi);
+	if (ret < 0)
+		dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret);
+
+	drm_panel_remove(&ctx->panel);
+
+	return 0;
+}
+
+static const struct of_device_id sharp_ls060t1sx01_of_match[] = {
+	{ .compatible = "sharp,ls060t1sx01" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, sharp_ls060t1sx01_of_match);
+
+static struct mipi_dsi_driver sharp_ls060_driver = {
+	.probe = sharp_ls060_probe,
+	.remove = sharp_ls060_remove,
+	.driver = {
+		.name = "panel-sharp-ls060t1sx01",
+		.of_match_table = sharp_ls060t1sx01_of_match,
+	},
+};
+module_mipi_dsi_driver(sharp_ls060_driver);
+
+MODULE_AUTHOR("Dmitry Baryshkov <dmitry.baryshkov at linaro.org>");
+MODULE_DESCRIPTION("DRM driver for Sharp LS060T1SX01 1080p video mode dsi panel");
+MODULE_LICENSE("GPL v2");
commit 2307d3a5a2df2d91563f9647dc6b526d6f8e8b58
Author: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
Date:   Sat Oct 9 23:38:05 2021 +0300

    dt-bindings: add bindings for the Sharp LS060T1SX01 panel
    
    Add devicetree bindings for the Sharp LS060T1SX01 6.0" FullHD panel
    using NT35695 driver. This panel can be found i.e. in the Dragonboard
    Display Adapter bundle.
    
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
    Reviewed-by: Rob Herring <robh at kernel.org>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211009203806.56821-2-dmitry.baryshkov@linaro.org

diff --git a/Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml b/Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml
new file mode 100644
index 000000000000..271c097cc9a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/sharp,ls060t1sx01.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sharp Microelectronics 6.0" FullHD TFT LCD panel
+
+maintainers:
+  - Dmitry Baryskov <dmitry.baryshkov at linaro.org>
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+    const: sharp,ls060t1sx01
+
+  reg: true
+  backlight: true
+  reset-gpios: true
+  port: true
+
+  avdd-supply:
+    description: handle of the regulator that provides the positive supply voltage
+  avee-supply:
+    description: handle of the regulator that provides the negative supply voltage
+  vddi-supply:
+    description: handle of the regulator that provides the I/O supply voltage
+  vddh-supply:
+    description: handle of the regulator that provides the analog supply voltage
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    dsi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        panel at 0 {
+            compatible = "sharp,ls060t1sx01";
+            reg = <0>;
+            avdd-supply = <&pm8941_l22>;
+            backlight = <&backlight>;
+            reset-gpios = <&pm8916_gpios 25 GPIO_ACTIVE_LOW>;
+        };
+    };
+
+...
commit 31f6207940a6c74d3446609441cd18a08e502d74
Author: Marek Vasut <marex at denx.de>
Date:   Sun Oct 10 16:49:19 2021 +0200

    drm/bridge: lvds-codec: Add support for LVDS data mapping select
    
    Decoder input LVDS format is a property of the decoder chip or even
    its strapping. Handle data-mapping the same way lvds-panel does. In
    case data-mapping is not present, do nothing, since there are still
    legacy bindings which do not specify this property.
    
    Signed-off-by: Marek Vasut <marex at denx.de>
    Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
    Reviewed-by: Sam Ravnborg <sam at ravnborg.org>
    To: dri-devel at lists.freedesktop.org
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211010144919.38392-2-marex@denx.de

diff --git a/drivers/gpu/drm/bridge/lvds-codec.c b/drivers/gpu/drm/bridge/lvds-codec.c
index dcf579a4cf83..ad460b96c0a3 100644
--- a/drivers/gpu/drm/bridge/lvds-codec.c
+++ b/drivers/gpu/drm/bridge/lvds-codec.c
@@ -12,6 +12,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
 #include <drm/drm_panel.h>
 
@@ -22,6 +23,7 @@ struct lvds_codec {
 	struct regulator *vcc;
 	struct gpio_desc *powerdown_gpio;
 	u32 connector_type;
+	unsigned int bus_format;
 };
 
 static inline struct lvds_codec *to_lvds_codec(struct drm_bridge *bridge)
@@ -74,12 +76,50 @@ static const struct drm_bridge_funcs funcs = {
 	.disable = lvds_codec_disable,
 };
 
+#define MAX_INPUT_SEL_FORMATS 1
+static u32 *
+lvds_codec_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
+				     struct drm_bridge_state *bridge_state,
+				     struct drm_crtc_state *crtc_state,
+				     struct drm_connector_state *conn_state,
+				     u32 output_fmt,
+				     unsigned int *num_input_fmts)
+{
+	struct lvds_codec *lvds_codec = to_lvds_codec(bridge);
+	u32 *input_fmts;
+
+	*num_input_fmts = 0;
+
+	input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts),
+			     GFP_KERNEL);
+	if (!input_fmts)
+		return NULL;
+
+	input_fmts[0] = lvds_codec->bus_format;
+	*num_input_fmts = MAX_INPUT_SEL_FORMATS;
+
+	return input_fmts;
+}
+
+static const struct drm_bridge_funcs funcs_decoder = {
+	.attach = lvds_codec_attach,
+	.enable = lvds_codec_enable,
+	.disable = lvds_codec_disable,
+	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+	.atomic_reset = drm_atomic_helper_bridge_reset,
+	.atomic_get_input_bus_fmts = lvds_codec_atomic_get_input_bus_fmts,
+};
+
 static int lvds_codec_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct device_node *panel_node;
+	struct device_node *bus_node;
 	struct drm_panel *panel;
 	struct lvds_codec *lvds_codec;
+	const char *mapping;
+	int ret;
 
 	lvds_codec = devm_kzalloc(dev, sizeof(*lvds_codec), GFP_KERNEL);
 	if (!lvds_codec)
@@ -119,13 +159,47 @@ static int lvds_codec_probe(struct platform_device *pdev)
 	if (IS_ERR(lvds_codec->panel_bridge))
 		return PTR_ERR(lvds_codec->panel_bridge);
 
+	lvds_codec->bridge.funcs = &funcs;
+
+	/*
+	 * Decoder input LVDS format is a property of the decoder chip or even
+	 * its strapping. Handle data-mapping the same way lvds-panel does. In
+	 * case data-mapping is not present, do nothing, since there are still
+	 * legacy bindings which do not specify this property.
+	 */
+	if (lvds_codec->connector_type != DRM_MODE_CONNECTOR_LVDS) {
+		bus_node = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0);
+		if (!bus_node) {
+			dev_dbg(dev, "bus DT node not found\n");
+			return -ENXIO;
+		}
+
+		ret = of_property_read_string(bus_node, "data-mapping",
+					      &mapping);
+		of_node_put(bus_node);
+		if (ret < 0) {
+			dev_warn(dev, "missing 'data-mapping' DT property\n");
+		} else {
+			if (!strcmp(mapping, "jeida-18")) {
+				lvds_codec->bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG;
+			} else if (!strcmp(mapping, "jeida-24")) {
+				lvds_codec->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
+			} else if (!strcmp(mapping, "vesa-24")) {
+				lvds_codec->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
+			} else {
+				dev_err(dev, "invalid 'data-mapping' DT property\n");
+				return -EINVAL;
+			}
+			lvds_codec->bridge.funcs = &funcs_decoder;
+		}
+	}
+
 	/*
 	 * The panel_bridge bridge is attached to the panel's of_node,
 	 * but we need a bridge attached to our of_node for our user
 	 * to look up.
 	 */
 	lvds_codec->bridge.of_node = dev->of_node;
-	lvds_codec->bridge.funcs = &funcs;
 	drm_bridge_add(&lvds_codec->bridge);
 
 	platform_set_drvdata(pdev, lvds_codec);
commit ba3e86789eaf820a2a5b1990f74ba279a4a3b990
Author: Marek Vasut <marex at denx.de>
Date:   Sun Oct 10 16:49:18 2021 +0200

    dt-bindings: display: bridge: lvds-codec: Document LVDS data mapping select
    
    Decoder input LVDS format is a property of the decoder chip or even
    its strapping. Add DT property data-mapping the same way lvds-panel
    does, to define the LVDS data mapping.
    
    Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
    Reviewed-by: Rob Herring <robh at kernel.org>
    Signed-off-by: Marek Vasut <marex at denx.de>
    Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
    Cc: Rob Herring <robh+dt at kernel.org>
    Cc: Sam Ravnborg <sam at ravnborg.org>
    Cc: devicetree at vger.kernel.org
    To: dri-devel at lists.freedesktop.org
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211010144919.38392-1-marex@denx.de

diff --git a/Documentation/devicetree/bindings/display/bridge/lvds-codec.yaml b/Documentation/devicetree/bindings/display/bridge/lvds-codec.yaml
index 304a1367faaa..1faae3e323a4 100644
--- a/Documentation/devicetree/bindings/display/bridge/lvds-codec.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/lvds-codec.yaml
@@ -49,11 +49,26 @@ properties:
 
     properties:
       port at 0:
-        $ref: /schemas/graph.yaml#/properties/port
+        $ref: /schemas/graph.yaml#/$defs/port-base
         description: |
           For LVDS encoders, port 0 is the parallel input
           For LVDS decoders, port 0 is the LVDS input
 
+        properties:
+          endpoint:
+            $ref: /schemas/media/video-interfaces.yaml#
+            unevaluatedProperties: false
+
+            properties:
+              data-mapping:
+                enum:
+                  - jeida-18
+                  - jeida-24
+                  - vesa-24
+                description: |
+                  The color signals mapping order. See details in
+                  Documentation/devicetree/bindings/display/panel/lvds.yaml
+
       port at 1:
         $ref: /schemas/graph.yaml#/properties/port
         description: |
@@ -71,6 +86,22 @@ properties:
 
   power-supply: true
 
+if:
+  not:
+    properties:
+      compatible:
+        contains:
+          const: lvds-decoder
+then:
+  properties:
+    ports:
+      properties:
+        port at 0:
+          properties:
+            endpoint:
+              properties:
+                data-mapping: false
+
 required:
   - compatible
   - ports
commit 2c0c19b681d5a331b53aab0d170f72a87c7bff12
Author: Zheyu Ma <zheyuma97 at gmail.com>
Date:   Sun Oct 10 06:42:28 2021 +0000

    fbdev: fbmem: Fix double free of 'fb_info->pixmap.addr'
    
    savagefb and some other drivers call kfree to free 'info->pixmap.addr'
    even after calling unregister_framebuffer, which may cause double free.
    
    Fix this by setting 'fb_info->pixmap.addr' to NULL after kfree in
    unregister_framebuffer.
    
    The following log reveals it:
    
    [   37.318872] BUG: KASAN: double-free or invalid-free in kfree+0x13e/0x290
    [   37.319369]
    [   37.320803] Call Trace:
    [   37.320992]  dump_stack_lvl+0xa8/0xd1
    [   37.321274]  print_address_description+0x87/0x3b0
    [   37.321632]  ? kfree+0x13e/0x290
    [   37.321879]  ? kfree+0x13e/0x290
    [   37.322126]  ? kfree+0x13e/0x290
    [   37.322374]  kasan_report_invalid_free+0x58/0x90
    [   37.322724]  ____kasan_slab_free+0x123/0x140
    [   37.323049]  __kasan_slab_free+0x11/0x20
    [   37.323347]  slab_free_freelist_hook+0x81/0x150
    [   37.323689]  ? savagefb_remove+0xa1/0xc0 [savagefb]
    [   37.324066]  kfree+0x13e/0x290
    [   37.324304]  savagefb_remove+0xa1/0xc0 [savagefb]
    [   37.324655]  pci_device_remove+0xa9/0x250
    [   37.324959]  ? pci_device_probe+0x7d0/0x7d0
    [   37.325273]  device_release_driver_internal+0x4f7/0x7a0
    [   37.325666]  driver_detach+0x1e8/0x2c0
    [   37.325952]  bus_remove_driver+0x134/0x290
    [   37.326262]  ? sysfs_remove_groups+0x97/0xb0
    [   37.326584]  driver_unregister+0x77/0xa0
    [   37.326883]  pci_unregister_driver+0x2c/0x1c0
    [   37.336124]
    [   37.336245] Allocated by task 5465:
    [   37.336507]  ____kasan_kmalloc+0xb5/0xe0
    [   37.336801]  __kasan_kmalloc+0x9/0x10
    [   37.337069]  kmem_cache_alloc_trace+0x12b/0x220
    [   37.337405]  register_framebuffer+0x3f3/0xa00
    [   37.337731]  foo_register_framebuffer+0x3b/0x50 [savagefb]
    [   37.338136]
    [   37.338255] Freed by task 5475:
    [   37.338492]  kasan_set_track+0x3d/0x70
    [   37.338774]  kasan_set_free_info+0x23/0x40
    [   37.339081]  ____kasan_slab_free+0x10b/0x140
    [   37.339399]  __kasan_slab_free+0x11/0x20
    [   37.339694]  slab_free_freelist_hook+0x81/0x150
    [   37.340034]  kfree+0x13e/0x290
    [   37.340267]  do_unregister_framebuffer+0x21c/0x3d0
    [   37.340624]  unregister_framebuffer+0x23/0x40
    [   37.340950]  savagefb_remove+0x45/0xc0 [savagefb]
    [   37.341302]  pci_device_remove+0xa9/0x250
    [   37.341603]  device_release_driver_internal+0x4f7/0x7a0
    [   37.341990]  driver_detach+0x1e8/0x2c0
    [   37.342272]  bus_remove_driver+0x134/0x290
    [   37.342577]  driver_unregister+0x77/0xa0
    [   37.342873]  pci_unregister_driver+0x2c/0x1c0
    [   37.343196]  cleanup_module+0x15/0x1c [savagefb]
    [   37.343543]  __se_sys_delete_module+0x398/0x490
    [   37.343881]  __x64_sys_delete_module+0x56/0x60
    [   37.344221]  do_syscall_64+0x4d/0xc0
    [   37.344492]  entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    Signed-off-by: Zheyu Ma <zheyuma97 at gmail.com>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/1633848148-29747-1-git-send-email-zheyuma97@gmail.com

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 7420d2c16e47..826175ad88a2 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1702,8 +1702,11 @@ static void do_unregister_framebuffer(struct fb_info *fb_info)
 {
 	unlink_framebuffer(fb_info);
 	if (fb_info->pixmap.addr &&
-	    (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
+	    (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT)) {
 		kfree(fb_info->pixmap.addr);
+		fb_info->pixmap.addr = NULL;
+	}
+
 	fb_destroy_modelist(&fb_info->modelist);
 	registered_fb[fb_info->node] = NULL;
 	num_registered_fb--;
commit 2620fddce4a9dee64876ee7f3f344ea558fc1ac3
Author: Sam Ravnborg <sam at ravnborg.org>
Date:   Sat Oct 9 19:34:19 2021 +0200

    Revert "dt-bindings: add bindings for the Sharp LS060T1SX01 panel"
    
    This reverts commit 230a6f0e6f49
    ("dt-bindings: add bindings for the Sharp LS060T1SX01 panel")
    
    It was pushed to drm-misc-next by accident.
    Added my own ack to expedit the revert.
    
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Acked-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210926001005.3442668-2-dmitry.baryshkov@linaro.org

diff --git a/Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml b/Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml
deleted file mode 100644
index 271c097cc9a4..000000000000
--- a/Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2
----
-$id: http://devicetree.org/schemas/display/panel/sharp,ls060t1sx01.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Sharp Microelectronics 6.0" FullHD TFT LCD panel
-
-maintainers:
-  - Dmitry Baryskov <dmitry.baryshkov at linaro.org>
-
-allOf:
-  - $ref: panel-common.yaml#
-
-properties:
-  compatible:
-    const: sharp,ls060t1sx01
-
-  reg: true
-  backlight: true
-  reset-gpios: true
-  port: true
-
-  avdd-supply:
-    description: handle of the regulator that provides the positive supply voltage
-  avee-supply:
-    description: handle of the regulator that provides the negative supply voltage
-  vddi-supply:
-    description: handle of the regulator that provides the I/O supply voltage
-  vddh-supply:
-    description: handle of the regulator that provides the analog supply voltage
-
-required:
-  - compatible
-  - reg
-
-additionalProperties: false
-
-examples:
-  - |
-    #include <dt-bindings/gpio/gpio.h>
-
-    dsi {
-        #address-cells = <1>;
-        #size-cells = <0>;
-
-        panel at 0 {
-            compatible = "sharp,ls060t1sx01";
-            reg = <0>;
-            avdd-supply = <&pm8941_l22>;
-            backlight = <&backlight>;
-            reset-gpios = <&pm8916_gpios 25 GPIO_ACTIVE_LOW>;
-        };
-    };
-
-...
commit 54d209e2fa942246c13557caabebc4228fb4d5d8
Author: Sam Ravnborg <sam at ravnborg.org>
Date:   Sat Oct 9 19:10:56 2021 +0200

    Revert "drm/panel: Add support for Sharp LS060T1SX01 panel"
    
    This reverts commit
    223cce88a926 ("drm/panel: Add support for Sharp LS060T1SX01 panel").
    
    It was pushed to drm-misc-next by accident.
    Added my own ack to expedit the revert.
    
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Acked-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210926001005.3442668-3-dmitry.baryshkov@linaro.org

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index eb01549a6ccb..369cb76512fe 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -519,16 +519,6 @@ config DRM_PANEL_SHARP_LS043T1LE01
 	  Say Y here if you want to enable support for Sharp LS043T1LE01 qHD
 	  (540x960) DSI panel as found on the Qualcomm APQ8074 Dragonboard
 
-config DRM_PANEL_SHARP_LS060T1SX01
-	tristate "Sharp LS060T1SX01 FullHD video mode panel"
-	depends on OF
-	depends on DRM_MIPI_DSI
-	depends on BACKLIGHT_CLASS_DEVICE
-	help
-	  Say Y here if you want to enable support for Sharp LS060T1SX01 6.0"
-	  FullHD (1080x1920) DSI panel as found in Dragonboard Display Adapter
-	  Bundle.
-
 config DRM_PANEL_SITRONIX_ST7701
 	tristate "Sitronix ST7701 panel driver"
 	depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index bca4cc1f2715..6e30640b9099 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -53,7 +53,6 @@ obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
-obj-$(CONFIG_DRM_PANEL_SHARP_LS060T1SX01) += panel-sharp-ls060t1sx01.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += panel-sitronix-st7701.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
diff --git a/drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c b/drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c
deleted file mode 100644
index 1049810d1f10..000000000000
--- a/drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c
+++ /dev/null
@@ -1,332 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-// Copyright (c) 2021 Linaro Ltd.
-// Generated with linux-mdss-dsi-panel-driver-generator from vendor device tree:
-//   Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
-
-#include <linux/delay.h>
-#include <linux/gpio/consumer.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/regulator/consumer.h>
-
-#include <video/mipi_display.h>
-
-#include <drm/drm_mipi_dsi.h>
-#include <drm/drm_modes.h>
-#include <drm/drm_panel.h>
-
-struct sharp_ls060 {
-	struct drm_panel panel;
-	struct mipi_dsi_device *dsi;
-	struct regulator *vddi_supply;
-	struct regulator *vddh_supply;
-	struct regulator *avdd_supply;
-	struct regulator *avee_supply;
-	struct gpio_desc *reset_gpio;
-	bool prepared;
-};
-
-static inline struct sharp_ls060 *to_sharp_ls060(struct drm_panel *panel)
-{
-	return container_of(panel, struct sharp_ls060, panel);
-}
-
-#define dsi_dcs_write_seq(dsi, seq...) ({				\
-		static const u8 d[] = { seq };				\
-									\
-		mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));	\
-	})
-
-static void sharp_ls060_reset(struct sharp_ls060 *ctx)
-{
-	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
-	usleep_range(10000, 11000);
-	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
-	usleep_range(10000, 11000);
-	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
-	usleep_range(10000, 11000);
-}
-
-static int sharp_ls060_on(struct sharp_ls060 *ctx)
-{
-	struct mipi_dsi_device *dsi = ctx->dsi;
-	struct device *dev = &dsi->dev;
-	int ret;
-
-	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
-
-	ret = dsi_dcs_write_seq(dsi, 0xbb, 0x13);
-	if (ret < 0) {
-		dev_err(dev, "Failed to send command: %d\n", ret);
-		return ret;
-	}
-
-	ret = dsi_dcs_write_seq(dsi, MIPI_DCS_WRITE_MEMORY_START);
-	if (ret < 0) {
-		dev_err(dev, "Failed to send command: %d\n", ret);
-		return ret;
-	}
-
-	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
-	if (ret < 0) {
-		dev_err(dev, "Failed to exit sleep mode: %d\n", ret);
-		return ret;
-	}
-	msleep(120);
-
-	ret = mipi_dsi_dcs_set_display_on(dsi);
-	if (ret < 0) {
-		dev_err(dev, "Failed to set display on: %d\n", ret);
-		return ret;
-	}
-	msleep(50);
-
-	return 0;
-}
-
-static int sharp_ls060_off(struct sharp_ls060 *ctx)
-{
-	struct mipi_dsi_device *dsi = ctx->dsi;
-	struct device *dev = &dsi->dev;
-	int ret;
-
-	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
-
-	ret = mipi_dsi_dcs_set_display_off(dsi);
-	if (ret < 0) {
-		dev_err(dev, "Failed to set display off: %d\n", ret);
-		return ret;
-	}
-	usleep_range(2000, 3000);
-
-	ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
-	if (ret < 0) {
-		dev_err(dev, "Failed to enter sleep mode: %d\n", ret);
-		return ret;
-	}
-	msleep(121);
-
-	return 0;
-}
-
-static int sharp_ls060_prepare(struct drm_panel *panel)
-{
-	struct sharp_ls060 *ctx = to_sharp_ls060(panel);
-	struct device *dev = &ctx->dsi->dev;
-	int ret;
-
-	if (ctx->prepared)
-		return 0;
-
-	ret = regulator_enable(ctx->vddi_supply);
-	if (ret < 0)
-		return ret;
-
-	ret = regulator_enable(ctx->avdd_supply);
-	if (ret < 0)
-		goto err_avdd;
-
-	msleep(1);
-
-	ret = regulator_enable(ctx->avee_supply);
-	if (ret < 0)
-		goto err_avee;
-
-	msleep(10);
-
-	ret = regulator_enable(ctx->vddh_supply);
-	if (ret < 0)
-		goto err_vddh;
-
-	msleep(10);
-
-	sharp_ls060_reset(ctx);
-
-	ret = sharp_ls060_on(ctx);
-	if (ret < 0) {
-		dev_err(dev, "Failed to initialize panel: %d\n", ret);
-		goto err_on;
-	}
-
-	ctx->prepared = true;
-
-	return 0;
-
-err_on:
-	regulator_disable(ctx->vddh_supply);
-
-	msleep(10);
-
-err_vddh:
-	regulator_disable(ctx->avee_supply);
-
-err_avee:
-	regulator_disable(ctx->avdd_supply);
-
-	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
-
-err_avdd:
-	regulator_disable(ctx->vddi_supply);
-
-	return ret;
-}
-
-static int sharp_ls060_unprepare(struct drm_panel *panel)
-{
-	struct sharp_ls060 *ctx = to_sharp_ls060(panel);
-	struct device *dev = &ctx->dsi->dev;
-	int ret;
-
-	if (!ctx->prepared)
-		return 0;
-
-	ret = sharp_ls060_off(ctx);
-	if (ret < 0)
-		dev_err(dev, "Failed to un-initialize panel: %d\n", ret);
-
-	regulator_disable(ctx->vddh_supply);
-
-	msleep(10);
-
-	regulator_disable(ctx->avee_supply);
-	regulator_disable(ctx->avdd_supply);
-
-	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
-
-	regulator_disable(ctx->vddi_supply);
-
-	ctx->prepared = false;
-	return 0;
-}
-
-static const struct drm_display_mode sharp_ls060_mode = {
-	.clock = (1080 + 96 + 16 + 64) * (1920 + 4 + 1 + 16) * 60 / 1000,
-	.hdisplay = 1080,
-	.hsync_start = 1080 + 96,
-	.hsync_end = 1080 + 96 + 16,
-	.htotal = 1080 + 96 + 16 + 64,
-	.vdisplay = 1920,
-	.vsync_start = 1920 + 4,
-	.vsync_end = 1920 + 4 + 1,
-	.vtotal = 1920 + 4 + 1 + 16,
-	.width_mm = 75,
-	.height_mm = 132,
-};
-
-static int sharp_ls060_get_modes(struct drm_panel *panel,
-				 struct drm_connector *connector)
-{
-	struct drm_display_mode *mode;
-
-	mode = drm_mode_duplicate(connector->dev, &sharp_ls060_mode);
-	if (!mode)
-		return -ENOMEM;
-
-	drm_mode_set_name(mode);
-
-	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
-	connector->display_info.width_mm = mode->width_mm;
-	connector->display_info.height_mm = mode->height_mm;
-	drm_mode_probed_add(connector, mode);
-
-	return 1;
-}
-
-static const struct drm_panel_funcs sharp_ls060_panel_funcs = {
-	.prepare = sharp_ls060_prepare,
-	.unprepare = sharp_ls060_unprepare,
-	.get_modes = sharp_ls060_get_modes,
-};
-
-static int sharp_ls060_probe(struct mipi_dsi_device *dsi)
-{
-	struct device *dev = &dsi->dev;
-	struct sharp_ls060 *ctx;
-	int ret;
-
-	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
-	if (!ctx)
-		return -ENOMEM;
-
-	ctx->vddi_supply = devm_regulator_get(dev, "vddi");
-	if (IS_ERR(ctx->vddi_supply))
-		return PTR_ERR(ctx->vddi_supply);
-
-	ctx->vddh_supply = devm_regulator_get(dev, "vddh");
-	if (IS_ERR(ctx->vddh_supply))
-		return PTR_ERR(ctx->vddh_supply);
-
-	ctx->avdd_supply = devm_regulator_get(dev, "avdd");
-	if (IS_ERR(ctx->avdd_supply))
-		return PTR_ERR(ctx->avdd_supply);
-
-	ctx->avee_supply = devm_regulator_get(dev, "avee");
-	if (IS_ERR(ctx->avee_supply))
-		return PTR_ERR(ctx->avee_supply);
-
-	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-	if (IS_ERR(ctx->reset_gpio))
-		return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
-				     "Failed to get reset-gpios\n");
-
-	ctx->dsi = dsi;
-	mipi_dsi_set_drvdata(dsi, ctx);
-
-	dsi->lanes = 4;
-	dsi->format = MIPI_DSI_FMT_RGB888;
-	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
-			  MIPI_DSI_MODE_EOT_PACKET |
-			  MIPI_DSI_CLOCK_NON_CONTINUOUS;
-
-	drm_panel_init(&ctx->panel, dev, &sharp_ls060_panel_funcs,
-		       DRM_MODE_CONNECTOR_DSI);
-
-	ret = drm_panel_of_backlight(&ctx->panel);
-	if (ret)
-		return dev_err_probe(dev, ret, "Failed to get backlight\n");
-
-	drm_panel_add(&ctx->panel);
-
-	ret = mipi_dsi_attach(dsi);
-	if (ret < 0) {
-		dev_err(dev, "Failed to attach to DSI host: %d\n", ret);
-		drm_panel_remove(&ctx->panel);
-		return ret;
-	}
-
-	return 0;
-}
-
-static int sharp_ls060_remove(struct mipi_dsi_device *dsi)
-{
-	struct sharp_ls060 *ctx = mipi_dsi_get_drvdata(dsi);
-	int ret;
-
-	ret = mipi_dsi_detach(dsi);
-	if (ret < 0)
-		dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret);
-
-	drm_panel_remove(&ctx->panel);
-
-	return 0;
-}
-
-static const struct of_device_id sharp_ls060t1sx01_of_match[] = {
-	{ .compatible = "sharp,ls060t1sx01" },
-	{ /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, sharp_ls060t1sx01_of_match);
-
-static struct mipi_dsi_driver sharp_ls060_driver = {
-	.probe = sharp_ls060_probe,
-	.remove = sharp_ls060_remove,
-	.driver = {
-		.name = "panel-sharp-ls060t1sx01",
-		.of_match_table = sharp_ls060t1sx01_of_match,
-	},
-};
-module_mipi_dsi_driver(sharp_ls060_driver);
-
-MODULE_AUTHOR("Dmitry Baryshkov <dmitry.baryshkov at linaro.org>");
-MODULE_DESCRIPTION("DRM driver for Sharp LS060T1SX01 1080p video mode dsi panel");
-MODULE_LICENSE("GPL v2");
commit 223cce88a926efbbd99d21fe2e540b1a9050410e
Author: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
Date:   Sun Sep 26 03:10:05 2021 +0300

    drm/panel: Add support for Sharp LS060T1SX01 panel
    
    Add driver to support Sharp LS06T1SX01 FullHD panel. The panel uses
    nt35695 driver IC. For example this LCD module can be found in the
    kwaek.ca Dragonboard Display Adapter Bundle.
    
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210926001005.3442668-3-dmitry.baryshkov@linaro.org

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 369cb76512fe..eb01549a6ccb 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -519,6 +519,16 @@ config DRM_PANEL_SHARP_LS043T1LE01
 	  Say Y here if you want to enable support for Sharp LS043T1LE01 qHD
 	  (540x960) DSI panel as found on the Qualcomm APQ8074 Dragonboard
 
+config DRM_PANEL_SHARP_LS060T1SX01
+	tristate "Sharp LS060T1SX01 FullHD video mode panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for Sharp LS060T1SX01 6.0"
+	  FullHD (1080x1920) DSI panel as found in Dragonboard Display Adapter
+	  Bundle.
+
 config DRM_PANEL_SITRONIX_ST7701
 	tristate "Sitronix ST7701 panel driver"
 	depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 6e30640b9099..bca4cc1f2715 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
+obj-$(CONFIG_DRM_PANEL_SHARP_LS060T1SX01) += panel-sharp-ls060t1sx01.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += panel-sitronix-st7701.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
diff --git a/drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c b/drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c
new file mode 100644
index 000000000000..1049810d1f10
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-sharp-ls060t1sx01.c
@@ -0,0 +1,332 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright (c) 2021 Linaro Ltd.
+// Generated with linux-mdss-dsi-panel-driver-generator from vendor device tree:
+//   Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regulator/consumer.h>
+
+#include <video/mipi_display.h>
+
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+
+struct sharp_ls060 {
+	struct drm_panel panel;
+	struct mipi_dsi_device *dsi;
+	struct regulator *vddi_supply;
+	struct regulator *vddh_supply;
+	struct regulator *avdd_supply;
+	struct regulator *avee_supply;
+	struct gpio_desc *reset_gpio;
+	bool prepared;
+};
+
+static inline struct sharp_ls060 *to_sharp_ls060(struct drm_panel *panel)
+{
+	return container_of(panel, struct sharp_ls060, panel);
+}
+
+#define dsi_dcs_write_seq(dsi, seq...) ({				\
+		static const u8 d[] = { seq };				\
+									\
+		mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));	\
+	})
+
+static void sharp_ls060_reset(struct sharp_ls060 *ctx)
+{
+	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
+	usleep_range(10000, 11000);
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+	usleep_range(10000, 11000);
+	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
+	usleep_range(10000, 11000);
+}
+
+static int sharp_ls060_on(struct sharp_ls060 *ctx)
+{
+	struct mipi_dsi_device *dsi = ctx->dsi;
+	struct device *dev = &dsi->dev;
+	int ret;
+
+	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
+
+	ret = dsi_dcs_write_seq(dsi, 0xbb, 0x13);
+	if (ret < 0) {
+		dev_err(dev, "Failed to send command: %d\n", ret);
+		return ret;
+	}
+
+	ret = dsi_dcs_write_seq(dsi, MIPI_DCS_WRITE_MEMORY_START);
+	if (ret < 0) {
+		dev_err(dev, "Failed to send command: %d\n", ret);
+		return ret;
+	}
+
+	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to exit sleep mode: %d\n", ret);
+		return ret;
+	}
+	msleep(120);
+
+	ret = mipi_dsi_dcs_set_display_on(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to set display on: %d\n", ret);
+		return ret;
+	}
+	msleep(50);
+
+	return 0;
+}
+
+static int sharp_ls060_off(struct sharp_ls060 *ctx)
+{
+	struct mipi_dsi_device *dsi = ctx->dsi;
+	struct device *dev = &dsi->dev;
+	int ret;
+
+	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
+
+	ret = mipi_dsi_dcs_set_display_off(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to set display off: %d\n", ret);
+		return ret;
+	}
+	usleep_range(2000, 3000);
+
+	ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to enter sleep mode: %d\n", ret);
+		return ret;
+	}
+	msleep(121);
+
+	return 0;
+}
+
+static int sharp_ls060_prepare(struct drm_panel *panel)
+{
+	struct sharp_ls060 *ctx = to_sharp_ls060(panel);
+	struct device *dev = &ctx->dsi->dev;
+	int ret;
+
+	if (ctx->prepared)
+		return 0;
+
+	ret = regulator_enable(ctx->vddi_supply);
+	if (ret < 0)
+		return ret;
+
+	ret = regulator_enable(ctx->avdd_supply);
+	if (ret < 0)
+		goto err_avdd;
+
+	msleep(1);
+
+	ret = regulator_enable(ctx->avee_supply);
+	if (ret < 0)
+		goto err_avee;
+
+	msleep(10);
+
+	ret = regulator_enable(ctx->vddh_supply);
+	if (ret < 0)
+		goto err_vddh;
+
+	msleep(10);
+
+	sharp_ls060_reset(ctx);
+
+	ret = sharp_ls060_on(ctx);
+	if (ret < 0) {
+		dev_err(dev, "Failed to initialize panel: %d\n", ret);
+		goto err_on;
+	}
+
+	ctx->prepared = true;
+
+	return 0;
+
+err_on:
+	regulator_disable(ctx->vddh_supply);
+
+	msleep(10);
+
+err_vddh:
+	regulator_disable(ctx->avee_supply);
+
+err_avee:
+	regulator_disable(ctx->avdd_supply);
+
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+
+err_avdd:
+	regulator_disable(ctx->vddi_supply);
+
+	return ret;
+}
+
+static int sharp_ls060_unprepare(struct drm_panel *panel)
+{
+	struct sharp_ls060 *ctx = to_sharp_ls060(panel);
+	struct device *dev = &ctx->dsi->dev;
+	int ret;
+
+	if (!ctx->prepared)
+		return 0;
+
+	ret = sharp_ls060_off(ctx);
+	if (ret < 0)
+		dev_err(dev, "Failed to un-initialize panel: %d\n", ret);
+
+	regulator_disable(ctx->vddh_supply);
+
+	msleep(10);
+
+	regulator_disable(ctx->avee_supply);
+	regulator_disable(ctx->avdd_supply);
+
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+
+	regulator_disable(ctx->vddi_supply);
+
+	ctx->prepared = false;
+	return 0;
+}
+
+static const struct drm_display_mode sharp_ls060_mode = {
+	.clock = (1080 + 96 + 16 + 64) * (1920 + 4 + 1 + 16) * 60 / 1000,
+	.hdisplay = 1080,
+	.hsync_start = 1080 + 96,
+	.hsync_end = 1080 + 96 + 16,
+	.htotal = 1080 + 96 + 16 + 64,
+	.vdisplay = 1920,
+	.vsync_start = 1920 + 4,
+	.vsync_end = 1920 + 4 + 1,
+	.vtotal = 1920 + 4 + 1 + 16,
+	.width_mm = 75,
+	.height_mm = 132,
+};
+
+static int sharp_ls060_get_modes(struct drm_panel *panel,
+				 struct drm_connector *connector)
+{
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, &sharp_ls060_mode);
+	if (!mode)
+		return -ENOMEM;
+
+	drm_mode_set_name(mode);
+
+	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+	connector->display_info.width_mm = mode->width_mm;
+	connector->display_info.height_mm = mode->height_mm;
+	drm_mode_probed_add(connector, mode);
+
+	return 1;
+}
+
+static const struct drm_panel_funcs sharp_ls060_panel_funcs = {
+	.prepare = sharp_ls060_prepare,
+	.unprepare = sharp_ls060_unprepare,
+	.get_modes = sharp_ls060_get_modes,
+};
+
+static int sharp_ls060_probe(struct mipi_dsi_device *dsi)
+{
+	struct device *dev = &dsi->dev;
+	struct sharp_ls060 *ctx;
+	int ret;
+
+	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	ctx->vddi_supply = devm_regulator_get(dev, "vddi");
+	if (IS_ERR(ctx->vddi_supply))
+		return PTR_ERR(ctx->vddi_supply);
+
+	ctx->vddh_supply = devm_regulator_get(dev, "vddh");
+	if (IS_ERR(ctx->vddh_supply))
+		return PTR_ERR(ctx->vddh_supply);
+
+	ctx->avdd_supply = devm_regulator_get(dev, "avdd");
+	if (IS_ERR(ctx->avdd_supply))
+		return PTR_ERR(ctx->avdd_supply);
+
+	ctx->avee_supply = devm_regulator_get(dev, "avee");
+	if (IS_ERR(ctx->avee_supply))
+		return PTR_ERR(ctx->avee_supply);
+
+	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(ctx->reset_gpio))
+		return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
+				     "Failed to get reset-gpios\n");
+
+	ctx->dsi = dsi;
+	mipi_dsi_set_drvdata(dsi, ctx);
+
+	dsi->lanes = 4;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
+			  MIPI_DSI_MODE_EOT_PACKET |
+			  MIPI_DSI_CLOCK_NON_CONTINUOUS;
+
+	drm_panel_init(&ctx->panel, dev, &sharp_ls060_panel_funcs,
+		       DRM_MODE_CONNECTOR_DSI);
+
+	ret = drm_panel_of_backlight(&ctx->panel);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to get backlight\n");
+
+	drm_panel_add(&ctx->panel);
+
+	ret = mipi_dsi_attach(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to attach to DSI host: %d\n", ret);
+		drm_panel_remove(&ctx->panel);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int sharp_ls060_remove(struct mipi_dsi_device *dsi)
+{
+	struct sharp_ls060 *ctx = mipi_dsi_get_drvdata(dsi);
+	int ret;
+
+	ret = mipi_dsi_detach(dsi);
+	if (ret < 0)
+		dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret);
+
+	drm_panel_remove(&ctx->panel);
+
+	return 0;
+}
+
+static const struct of_device_id sharp_ls060t1sx01_of_match[] = {
+	{ .compatible = "sharp,ls060t1sx01" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, sharp_ls060t1sx01_of_match);
+
+static struct mipi_dsi_driver sharp_ls060_driver = {
+	.probe = sharp_ls060_probe,
+	.remove = sharp_ls060_remove,
+	.driver = {
+		.name = "panel-sharp-ls060t1sx01",
+		.of_match_table = sharp_ls060t1sx01_of_match,
+	},
+};
+module_mipi_dsi_driver(sharp_ls060_driver);
+
+MODULE_AUTHOR("Dmitry Baryshkov <dmitry.baryshkov at linaro.org>");
+MODULE_DESCRIPTION("DRM driver for Sharp LS060T1SX01 1080p video mode dsi panel");
+MODULE_LICENSE("GPL v2");
commit 230a6f0e6f49d815f1e8d042929b53a16908f674
Author: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
Date:   Sun Sep 26 03:10:04 2021 +0300

    dt-bindings: add bindings for the Sharp LS060T1SX01 panel
    
    Add devicetree bindings for the Sharp LS060T1SX01 6.0" FullHD panel
    using NT35695 driver. This panel can be found i.e. in the Dragonboard
    Display Adapter bundle.
    
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210926001005.3442668-2-dmitry.baryshkov@linaro.org

diff --git a/Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml b/Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml
new file mode 100644
index 000000000000..271c097cc9a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/sharp,ls060t1sx01.yaml
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/sharp,ls060t1sx01.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sharp Microelectronics 6.0" FullHD TFT LCD panel
+
+maintainers:
+  - Dmitry Baryskov <dmitry.baryshkov at linaro.org>
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+    const: sharp,ls060t1sx01
+
+  reg: true
+  backlight: true
+  reset-gpios: true
+  port: true
+
+  avdd-supply:
+    description: handle of the regulator that provides the positive supply voltage
+  avee-supply:
+    description: handle of the regulator that provides the negative supply voltage
+  vddi-supply:
+    description: handle of the regulator that provides the I/O supply voltage
+  vddh-supply:
+    description: handle of the regulator that provides the analog supply voltage
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    dsi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        panel at 0 {
+            compatible = "sharp,ls060t1sx01";
+            reg = <0>;
+            avdd-supply = <&pm8941_l22>;
+            backlight = <&backlight>;
+            reset-gpios = <&pm8916_gpios 25 GPIO_ACTIVE_LOW>;
+        };
+    };
+
+...
commit c38171a5857402dfc26985fb59029926bda802fb
Author: David Heidelberg <david at ixit.cz>
Date:   Mon Sep 27 23:45:03 2021 +0200

    dt-bindings: display: simple: hardware can use ddc-i2c-bus
    
    Both hardware and driver can communicate DDC over i2c bus.
    
    Fixes warnings as:
    arch/arm/boot/dts/tegra20-paz00.dt.yaml: panel: 'ddc-i2c-bus' does not match any of the regexes: 'pinctrl-[0-9]+'
            From schema: /home/runner/work/linux/linux/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
    
    Signed-off-by: David Heidelberg <david at ixit.cz>
    Acked-by: Rob Herring <robh at kernel.org>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210927214503.36012-1-david@ixit.cz

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index f81e79bf56b4..f3c9395d23b6 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -321,6 +321,7 @@ properties:
       - yes-optoelectronics,ytc700tlag-05-201c
 
   backlight: true
+  ddc-i2c-bus: true
   enable-gpios: true
   port: true
   power-supply: true
commit 19f036eaaffa581449c907aa78b98b1f147af336
Author: Søren Andersen <san at skov.dk>
Date:   Thu Sep 30 12:05:01 2021 +0200

    drm/panel: panel-simple: add LOGIC Technologies LTTD800480070-L2RT panel
    
    Add support for the Logic Technologies LTTD800x480 L2RT 7" 800x480 TFT
    Resistive Touch Module.
    
    Signed-off-by: Søren Andersen <san at skov.dk>
    Signed-off-by: Oleksij Rempel <o.rempel at pengutronix.de>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210930100501.15690-3-o.rempel@pengutronix.de

diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
index 7f3e1b84b5f5..eb475a3a774b 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -2370,6 +2370,38 @@ static const struct panel_desc logictechno_lt170410_2whc = {
 	.connector_type = DRM_MODE_CONNECTOR_LVDS,
 };
 
+static const struct drm_display_mode logictechno_lttd800480070_l2rt_mode = {
+	.clock = 33000,
+	.hdisplay = 800,
+	.hsync_start = 800 + 112,
+	.hsync_end = 800 + 112 + 3,
+	.htotal = 800 + 112 + 3 + 85,
+	.vdisplay = 480,
+	.vsync_start = 480 + 38,
+	.vsync_end = 480 + 38 + 3,
+	.vtotal = 480 + 38 + 3 + 29,
+	.flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
+};
+
+static const struct panel_desc logictechno_lttd800480070_l2rt = {
+	.modes = &logictechno_lttd800480070_l2rt_mode,
+	.num_modes = 1,
+	.bpc = 8,
+	.size = {
+		.width = 154,
+		.height = 86,
+	},
+	.delay = {
+		.prepare = 45,
+		.enable = 100,
+		.disable = 100,
+		.unprepare = 45
+	},
+	.bus_format = MEDIA_BUS_FMT_RGB888_1X24,
+	.bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE,
+	.connector_type = DRM_MODE_CONNECTOR_DPI,
+};
+
 static const struct drm_display_mode logictechno_lttd800480070_l6wh_rt_mode = {
 	.clock = 33000,
 	.hdisplay = 800,
@@ -3750,6 +3782,9 @@ static const struct of_device_id platform_of_match[] = {
 	}, {
 		.compatible = "logictechno,lt170410-2whc",
 		.data = &logictechno_lt170410_2whc,
+	}, {
+		.compatible = "logictechno,lttd800480070-l2rt",
+		.data = &logictechno_lttd800480070_l2rt,
 	}, {
 		.compatible = "logictechno,lttd800480070-l6wh-rt",
 		.data = &logictechno_lttd800480070_l6wh_rt,
commit 76f7456838589dc51e22834c8469412689708e77
Author: Oleksij Rempel <o.rempel at pengutronix.de>
Date:   Thu Sep 30 12:04:59 2021 +0200

    dt-bindings: display: simple: add Innolux G070Y2-T02 panel
    
    Add binding for the Innolux G070Y2-T02 panel. It is 7" WVGA (800x480)
    TFT LCD panel with TTL interface and a backlight unit.
    
    Signed-off-by: Oleksij Rempel <o.rempel at pengutronix.de>
    Acked-by: Rob Herring <robh at kernel.org>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210930100501.15690-1-o.rempel@pengutronix.de

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index 1bea31fd9e2e..f81e79bf56b4 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -166,6 +166,8 @@ properties:
       - innolux,at070tn92
         # Innolux G070Y2-L01 7" WVGA (800x480) TFT LCD panel
       - innolux,g070y2-l01
+        # Innolux G070Y2-T02 7" WVGA (800x480) TFT LCD TTL panel
+      - innolux,g070y2-t02
         # Innolux Corporation 10.1" G101ICE-L01 WXGA (1280x800) LVDS panel
       - innolux,g101ice-l01
         # Innolux Corporation 12.1" WXGA (1280x800) TFT LCD panel
commit f474bb3000b6114b8beea3170d9cbed963593467
Author: Nikola Pavlica <pavlica.nikola at gmail.com>
Date:   Sat Oct 2 22:29:05 2021 +0200

    dt-bindings: display: simple: Add Vivax TPC-9150 panel
    
    This tablet display is unique and hence must be added to documentation.
    Unfortunately, it's real make and number is not known due to obscure and
    missing documentation and lack of writing on the display assembly
    itself.
    
    So the natural alternative that came to mind is to name the panel after
    the device that contained it (an Android tablet). Hopefully that isn't
    an issue.
    
    I can confirm that the parameters that I've obtained are correct since
    they came from a dump of the original Android OS.
    
    Signed-off-by: Nikola Pavlica <pavlica.nikola at gmail.com>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211002202905.509437-2-pavlica.nikola@gmail.com

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index 335776c45474..1bea31fd9e2e 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -309,6 +309,8 @@ properties:
       - urt,umsh-8596md-11t
       - urt,umsh-8596md-19t
       - urt,umsh-8596md-20t
+        # Vivax TPC-9150 tablet 9.0" WSVGA TFT LCD panel
+      - vivax,tpc9150-panel
         # VXT 800x480 color TFT LCD panel
       - vxt,vl050-8048nt-c01
         # Winstar Display Corporation 3.5" QVGA (320x240) TFT LCD panel
commit 97f921ff264e0edbfae65a8a14e864aefd76bc1f
Author: Nikola Pavlica <pavlica.nikola at gmail.com>
Date:   Sat Oct 2 22:29:04 2021 +0200

    dt-bindings: add vendor prefix for Vivax
    
    Add vendor prefix for the Vivax brand by M SAN Grupa d.o.o.
    
    Source (in Croatian): https://www.vivax.com/hr/o-nama.aspx
    
    Signed-off-by: Nikola Pavlica <pavlica.nikola at gmail.com>
    Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211002202905.509437-1-pavlica.nikola@gmail.com

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index a867f7102c35..1a7d9ca02c44 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1264,6 +1264,8 @@ patternProperties:
     description: Vitesse Semiconductor Corporation
   "^vivante,.*":
     description: Vivante Corporation
+  "^vivax,.*":
+    description: Vivax brand by M SAN Grupa d.o.o.
   "^vocore,.*":
     description: VoCore Studio
   "^voipac,.*":
commit e539a77e44c7bc4ca3822ed14fba01cf8936ee97
Author: Philip Chen <philipchen at chromium.org>
Date:   Wed Sep 29 17:34:57 2021 -0700

    dt-bindings: drm/bridge: ps8640: Add aux-bus child
    
    dp-aux-bus.yaml says we can list an eDP panel as a child of
    an eDP controller node to represent the fact that the panel
    is connected to the controller's DP AUX bus.
    
    Let's add it to the ps8640 bindings.
    
    Signed-off-by: Philip Chen <philipchen at chromium.org>
    Reviewed-by: Douglas Anderson <dianders at chromium.org>
    Reviewed-by: Stephen Boyd <swboyd at chromium.org>
    Reviewed-by: Rob Herring <robh at kernel.org>
    Signed-off-by: Douglas Anderson <dianders at chromium.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210929173343.v2.2.I6050ba184b24d887e92692a72ee3054d643d6091@changeid

diff --git a/Documentation/devicetree/bindings/display/bridge/ps8640.yaml b/Documentation/devicetree/bindings/display/bridge/ps8640.yaml
index fce82b605c8b..cdaf7a7a8f88 100644
--- a/Documentation/devicetree/bindings/display/bridge/ps8640.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/ps8640.yaml
@@ -40,6 +40,9 @@ properties:
   vdd33-supply:
     description: Regulator for 3.3V digital core power.
 
+  aux-bus:
+    $ref: /schemas/display/dp-aux-bus.yaml#
+
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
 
@@ -98,7 +101,21 @@ examples:
                     reg = <1>;
                     ps8640_out: endpoint {
                         remote-endpoint = <&panel_in>;
-                   };
+                    };
+                };
+            };
+
+            aux-bus {
+                panel {
+                    compatible = "boe,nv133fhm-n62";
+                    power-supply = <&pp3300_dx_edp>;
+                    backlight = <&backlight>;
+
+                    port {
+                        panel_in: endpoint {
+                            remote-endpoint = <&ps8640_out>;
+                        };
+                    };
                 };
             };
         };
commit 24417d5b0c006fd4208284f3462f4012ae79151c
Author: Marek Vasut <marex at denx.de>
Date:   Tue Sep 7 04:40:38 2021 +0200

    drm/bridge: ti-sn65dsi83: Implement .detach callback
    
    Move detach implementation from sn65dsi83_remove() to dedicated
    .detach callback. There is no functional change to the code, but
    that detach is now in the correct location.
    
    Signed-off-by: Marek Vasut <marex at denx.de>
    Cc: Jagan Teki <jagan at amarulasolutions.com>
    Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
    Cc: Linus Walleij <linus.walleij at linaro.org>
    Cc: Robert Foss <robert.foss at linaro.org>
    Cc: Sam Ravnborg <sam at ravnborg.org>
    Cc: dri-devel at lists.freedesktop.org
    Reviewed-by: Robert Foss <robert.foss at linaro.org>
    Signed-off-by: Robert Foss <robert.foss at linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210907024038.871299-1-marex@denx.de

diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
index a32f70bc68ea..ba1160ec6d6e 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
@@ -288,6 +288,19 @@ err_dsi_attach:
 	return ret;
 }
 
+static void sn65dsi83_detach(struct drm_bridge *bridge)
+{
+	struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge);
+
+	if (!ctx->dsi)
+		return;
+
+	mipi_dsi_detach(ctx->dsi);
+	mipi_dsi_device_unregister(ctx->dsi);
+	drm_bridge_remove(&ctx->bridge);
+	ctx->dsi = NULL;
+}
+
 static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
 					struct drm_bridge_state *old_bridge_state)
 {
@@ -583,6 +596,7 @@ sn65dsi83_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 
 static const struct drm_bridge_funcs sn65dsi83_funcs = {
 	.attach			= sn65dsi83_attach,
+	.detach			= sn65dsi83_detach,
 	.atomic_pre_enable	= sn65dsi83_atomic_pre_enable,
 	.atomic_enable		= sn65dsi83_atomic_enable,
 	.atomic_disable		= sn65dsi83_atomic_disable,
@@ -697,9 +711,6 @@ static int sn65dsi83_remove(struct i2c_client *client)
 {
 	struct sn65dsi83 *ctx = i2c_get_clientdata(client);
 
-	mipi_dsi_detach(ctx->dsi);
-	mipi_dsi_device_unregister(ctx->dsi);
-	drm_bridge_remove(&ctx->bridge);
 	of_node_put(ctx->host_node);
 
 	return 0;
commit 7cd80132aeab30e4699f04e80d909678d231a558
Author: Christian König <christian.koenig at amd.com>
Date:   Mon Sep 13 13:44:01 2021 +0200

    drm: use new iterator in drm_gem_fence_array_add_implicit v3
    
    Simplifying the code a bit.
    
    v2: add missing rcu_read_lock()/unlock()
    v3: switch to locked version
    
    Signed-off-by: Christian König <christian.koenig at amd.com>
    Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211005113742.1101-24-christian.koenig@amd.com

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 09c820045859..4dcdec6487bb 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1340,31 +1340,15 @@ int drm_gem_fence_array_add_implicit(struct xarray *fence_array,
 				     struct drm_gem_object *obj,
 				     bool write)
 {
-	int ret;
-	struct dma_fence **fences;
-	unsigned int i, fence_count;
-
-	if (!write) {
-		struct dma_fence *fence =
-			dma_resv_get_excl_unlocked(obj->resv);
-
-		return drm_gem_fence_array_add(fence_array, fence);
-	}
+	struct dma_resv_iter cursor;
+	struct dma_fence *fence;
+	int ret = 0;
 
-	ret = dma_resv_get_fences(obj->resv, NULL,
-						&fence_count, &fences);
-	if (ret || !fence_count)
-		return ret;
-
-	for (i = 0; i < fence_count; i++) {
-		ret = drm_gem_fence_array_add(fence_array, fences[i]);
+	dma_resv_for_each_fence(&cursor, obj->resv, write, fence) {
+		ret = drm_gem_fence_array_add(fence_array, fence);
 		if (ret)
 			break;
 	}
-
-	for (; i < fence_count; i++)
-		dma_fence_put(fences[i]);
-	kfree(fences);
 	return ret;
 }
 EXPORT_SYMBOL(drm_gem_fence_array_add_implicit);
commit a585070f268223766fcab4b9eb9eade28381eb48
Author: Christian König <christian.koenig at amd.com>
Date:   Mon Sep 13 12:36:42 2021 +0200

    drm/i915: use the new iterator in i915_request_await_object v2
    
    Simplifying the code a bit.
    
    v2: add missing rcu_read_lock()/rcu_read_unlock()
    v3: use dma_resv_for_each_fence instead
    
    Signed-off-by: Christian König <christian.koenig at amd.com>
    Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211005113742.1101-20-christian.koenig@amd.com

diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index ce446716d092..3839712ebd23 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -1509,38 +1509,14 @@ i915_request_await_object(struct i915_request *to,
 			  struct drm_i915_gem_object *obj,
 			  bool write)
 {
-	struct dma_fence *excl;
+	struct dma_resv_iter cursor;
+	struct dma_fence *fence;
 	int ret = 0;
 
-	if (write) {
-		struct dma_fence **shared;
-		unsigned int count, i;
-
-		ret = dma_resv_get_fences(obj->base.resv, &excl, &count,
-					  &shared);
+	dma_resv_for_each_fence(&cursor, obj->base.resv, write, fence) {
+		ret = i915_request_await_dma_fence(to, fence);
 		if (ret)
-			return ret;
-
-		for (i = 0; i < count; i++) {
-			ret = i915_request_await_dma_fence(to, shared[i]);
-			if (ret)
-				break;
-
-			dma_fence_put(shared[i]);
-		}
-
-		for (; i < count; i++)
-			dma_fence_put(shared[i]);
-		kfree(shared);
-	} else {
-		excl = dma_resv_get_excl_unlocked(obj->base.resv);
-	}
-
-	if (excl) {
-		if (ret == 0)
-			ret = i915_request_await_dma_fence(to, excl);
-
-		dma_fence_put(excl);
+			break;
 	}
 
 	return ret;
commit 9c2ba265352afc633a1e24d89c3ca499a9e429f4
Author: Christian König <christian.koenig at amd.com>
Date:   Mon Sep 13 11:28:19 2021 +0200

    drm/scheduler: use new iterator in drm_sched_job_add_implicit_dependencies v2
    
    Simplifying the code a bit.
    
    v2: use dma_resv_for_each_fence
    
    Signed-off-by: Christian König <christian.koenig at amd.com>
    Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211005113742.1101-17-christian.koenig@amd.com

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 042c16b5d54a..5bc5f775abe1 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -699,30 +699,16 @@ int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job,
 					    struct drm_gem_object *obj,
 					    bool write)
 {
+	struct dma_resv_iter cursor;
+	struct dma_fence *fence;
 	int ret;
-	struct dma_fence **fences;
-	unsigned int i, fence_count;
-
-	if (!write) {
-		struct dma_fence *fence = dma_resv_get_excl_unlocked(obj->resv);
-
-		return drm_sched_job_add_dependency(job, fence);
-	}
-
-	ret = dma_resv_get_fences(obj->resv, NULL, &fence_count, &fences);
-	if (ret || !fence_count)
-		return ret;
 
-	for (i = 0; i < fence_count; i++) {
-		ret = drm_sched_job_add_dependency(job, fences[i]);
+	dma_resv_for_each_fence(&cursor, obj->resv, write, fence) {
+		ret = drm_sched_job_add_dependency(job, fence);
 		if (ret)
-			break;
+			return ret;
 	}
-
-	for (; i < fence_count; i++)
-		dma_fence_put(fences[i]);
-	kfree(fences);
-	return ret;
+	return 0;
 }
 EXPORT_SYMBOL(drm_sched_job_add_implicit_dependencies);
 
commit dbcae3bfcbca771e73e562a59c3d23f76426e0f9
Author: Christian König <christian.koenig at amd.com>
Date:   Tue Jun 15 15:57:22 2021 +0200

    drm/ttm: use the new iterator in ttm_bo_flush_all_fences
    
    This is probably a fix since we didn't even grabed a reference to the
    fences.
    
    Signed-off-by: Christian König <christian.koenig at amd.com>
    Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211005113742.1101-11-christian.koenig@amd.com

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index d62b2013c367..3934ee225c78 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -269,23 +269,15 @@ static int ttm_bo_individualize_resv(struct ttm_buffer_object *bo)
 static void ttm_bo_flush_all_fences(struct ttm_buffer_object *bo)
 {
 	struct dma_resv *resv = &bo->base._resv;
-	struct dma_resv_list *fobj;
+	struct dma_resv_iter cursor;
 	struct dma_fence *fence;
-	int i;
-
-	rcu_read_lock();
-	fobj = dma_resv_shared_list(resv);
-	fence = dma_resv_excl_fence(resv);
-	if (fence && !fence->ops->signaled)
-		dma_fence_enable_sw_signaling(fence);
-
-	for (i = 0; fobj && i < fobj->shared_count; ++i) {
-		fence = rcu_dereference(fobj->shared[i]);
 
+	dma_resv_iter_begin(&cursor, resv, true);
+	dma_resv_for_each_fence_unlocked(&cursor, fence) {
 		if (!fence->ops->signaled)
 			dma_fence_enable_sw_signaling(fence);
 	}
-	rcu_read_unlock();
+	dma_resv_iter_end(&cursor);
 }
 
 /**
commit 0a42016d9319db24d15789574fe132d8159d7578
Author: Christian König <christian.koenig at amd.com>
Date:   Fri Sep 24 11:31:22 2021 +0200

    dma-buf: use the new iterator in dma_resv_poll
    
    Simplify the code a bit.
    
    Signed-off-by: Christian König <christian.koenig at amd.com>
    Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211005113742.1101-10-christian.koenig@amd.com

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 8242b5d9baeb..beb504a92d60 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -209,19 +209,14 @@ static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
 	dma_fence_put(fence);
 }
 
-static bool dma_buf_poll_shared(struct dma_resv *resv,
+static bool dma_buf_poll_add_cb(struct dma_resv *resv, bool write,
 				struct dma_buf_poll_cb_t *dcb)
 {
-	struct dma_resv_list *fobj = dma_resv_shared_list(resv);
+	struct dma_resv_iter cursor;
 	struct dma_fence *fence;
-	int i, r;
-
-	if (!fobj)
-		return false;
+	int r;
 
-	for (i = 0; i < fobj->shared_count; ++i) {
-		fence = rcu_dereference_protected(fobj->shared[i],
-						  dma_resv_held(resv));
+	dma_resv_for_each_fence(&cursor, resv, write, fence) {
 		dma_fence_get(fence);
 		r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb);
 		if (!r)
@@ -232,24 +227,6 @@ static bool dma_buf_poll_shared(struct dma_resv *resv,
 	return false;
 }
 
-static bool dma_buf_poll_excl(struct dma_resv *resv,
-			      struct dma_buf_poll_cb_t *dcb)
-{
-	struct dma_fence *fence = dma_resv_excl_fence(resv);
-	int r;
-
-	if (!fence)
-		return false;
-
-	dma_fence_get(fence);
-	r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb);
-	if (!r)
-		return true;
-	dma_fence_put(fence);
-
-	return false;
-}
-
 static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
 {
 	struct dma_buf *dmabuf;
@@ -282,8 +259,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
 		spin_unlock_irq(&dmabuf->poll.lock);
 
 		if (events & EPOLLOUT) {
-			if (!dma_buf_poll_shared(resv, dcb) &&
-			    !dma_buf_poll_excl(resv, dcb))
+			if (!dma_buf_poll_add_cb(resv, true, dcb))
 				/* No callback queued, wake up any other waiters */
 				dma_buf_poll_cb(NULL, &dcb->cb);
 			else
@@ -303,7 +279,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
 		spin_unlock_irq(&dmabuf->poll.lock);
 
 		if (events & EPOLLIN) {
-			if (!dma_buf_poll_excl(resv, dcb))
+			if (!dma_buf_poll_add_cb(resv, false, dcb))
 				/* No callback queued, wake up any other waiters */
 				dma_buf_poll_cb(NULL, &dcb->cb);
 			else
commit 63639d013a6ff202665f0fb7f4d810a5b6d46d79
Author: Christian König <christian.koenig at amd.com>
Date:   Thu Sep 23 10:28:42 2021 +0200

    dma-buf: use the new iterator in dma_buf_debug_show
    
    Simplifying the code a bit.
    
    Signed-off-by: Christian König <christian.koenig at amd.com>
    Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211005113742.1101-9-christian.koenig@amd.com

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 61e20ae7b08b..8242b5d9baeb 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -1356,10 +1356,9 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
 {
 	struct dma_buf *buf_obj;
 	struct dma_buf_attachment *attach_obj;
-	struct dma_resv *robj;
-	struct dma_resv_list *fobj;
+	struct dma_resv_iter cursor;
 	struct dma_fence *fence;
-	int count = 0, attach_count, shared_count, i;
+	int count = 0, attach_count;
 	size_t size = 0;
 	int ret;
 
@@ -1386,21 +1385,10 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
 				file_inode(buf_obj->file)->i_ino,
 				buf_obj->name ?: "");
 
-		robj = buf_obj->resv;
-		fence = dma_resv_excl_fence(robj);
-		if (fence)
-			seq_printf(s, "\tExclusive fence: %s %s %ssignalled\n",
-				   fence->ops->get_driver_name(fence),
-				   fence->ops->get_timeline_name(fence),
-				   dma_fence_is_signaled(fence) ? "" : "un");
-
-		fobj = rcu_dereference_protected(robj->fence,
-						 dma_resv_held(robj));
-		shared_count = fobj ? fobj->shared_count : 0;
-		for (i = 0; i < shared_count; i++) {
-			fence = rcu_dereference_protected(fobj->shared[i],
-							  dma_resv_held(robj));
-			seq_printf(s, "\tShared fence: %s %s %ssignalled\n",
+		dma_resv_for_each_fence(&cursor, buf_obj->resv, true, fence) {
+			seq_printf(s, "\t%s fence: %s %s %ssignalled\n",
+				   dma_resv_iter_is_exclusive(&cursor) ?
+					"Exclusive" : "Shared",
 				   fence->ops->get_driver_name(fence),
 				   fence->ops->get_timeline_name(fence),
 				   dma_fence_is_signaled(fence) ? "" : "un");
commit 5baaac3184ab896d74993825858f1b1a46c460ce
Author: Christian König <christian.koenig at amd.com>
Date:   Tue Jun 15 15:10:03 2021 +0200

    dma-buf: add dma_resv_for_each_fence v3
    
    A simpler version of the iterator to be used when the dma_resv object is
    locked.
    
    v2: fix index check here as well
    v3: minor coding improvement, some documentation cleanup
    
    Signed-off-by: Christian König <christian.koenig at amd.com>
    Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211006123609.2026-1-christian.koenig@amd.com

diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index a480af9581bd..2f98caa68ae5 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -423,6 +423,57 @@ struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor)
 }
 EXPORT_SYMBOL(dma_resv_iter_next_unlocked);
 
+/**
+ * dma_resv_iter_first - first fence from a locked dma_resv object
+ * @cursor: cursor to record the current position
+ *
+ * Return the first fence in the dma_resv object while holding the
+ * &dma_resv.lock.
+ */
+struct dma_fence *dma_resv_iter_first(struct dma_resv_iter *cursor)
+{
+	struct dma_fence *fence;
+
+	dma_resv_assert_held(cursor->obj);
+
+	cursor->index = 0;
+	if (cursor->all_fences)
+		cursor->fences = dma_resv_shared_list(cursor->obj);
+	else
+		cursor->fences = NULL;
+
+	fence = dma_resv_excl_fence(cursor->obj);
+	if (!fence)
+		fence = dma_resv_iter_next(cursor);
+
+	cursor->is_restarted = true;
+	return fence;
+}
+EXPORT_SYMBOL_GPL(dma_resv_iter_first);
+
+/**
+ * dma_resv_iter_next - next fence from a locked dma_resv object
+ * @cursor: cursor to record the current position
+ *
+ * Return the next fences from the dma_resv object while holding the
+ * &dma_resv.lock.
+ */
+struct dma_fence *dma_resv_iter_next(struct dma_resv_iter *cursor)
+{
+	unsigned int idx;
+
+	dma_resv_assert_held(cursor->obj);
+
+	cursor->is_restarted = false;
+	if (!cursor->fences || cursor->index >= cursor->fences->shared_count)
+		return NULL;
+
+	idx = cursor->index++;
+	return rcu_dereference_protected(cursor->fences->shared[idx],
+					 dma_resv_held(cursor->obj));
+}
+EXPORT_SYMBOL_GPL(dma_resv_iter_next);
+
 /**
  * dma_resv_copy_fences - Copy all fences from src to dst.
  * @dst: the destination reservation object
diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
index 764138ad8583..491359cea54c 100644
--- a/include/linux/dma-resv.h
+++ b/include/linux/dma-resv.h
@@ -179,6 +179,8 @@ struct dma_resv_iter {
 
 struct dma_fence *dma_resv_iter_first_unlocked(struct dma_resv_iter *cursor);
 struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor);
+struct dma_fence *dma_resv_iter_first(struct dma_resv_iter *cursor);
+struct dma_fence *dma_resv_iter_next(struct dma_resv_iter *cursor);
 
 /**
  * dma_resv_iter_begin - initialize a dma_resv_iter object
@@ -244,6 +246,24 @@ static inline bool dma_resv_iter_is_restarted(struct dma_resv_iter *cursor)
 	for (fence = dma_resv_iter_first_unlocked(cursor);		\
 	     fence; fence = dma_resv_iter_next_unlocked(cursor))
 
+/**
+ * dma_resv_for_each_fence - fence iterator
+ * @cursor: a struct dma_resv_iter pointer
+ * @obj: a dma_resv object pointer
+ * @all_fences: true if all fences should be returned
+ * @fence: the current fence
+ *
+ * Iterate over the fences in a struct dma_resv object while holding the
+ * &dma_resv.lock. @all_fences controls if the shared fences are returned as
+ * well. The cursor initialisation is part of the iterator and the fence stays
+ * valid as long as the lock is held and so no extra reference to the fence is
+ * taken.
+ */
+#define dma_resv_for_each_fence(cursor, obj, all_fences, fence)	\
+	for (dma_resv_iter_begin(cursor, obj, all_fences),	\
+	     fence = dma_resv_iter_first(cursor); fence;	\
+	     fence = dma_resv_iter_next(cursor))
+
 #define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base)
 #define dma_resv_assert_held(obj) lockdep_assert_held(&(obj)->lock.base)
 
commit a0a33067b957dfab876ae26b32695f09cdc2706d
Author: Simon Ser <contact at emersion.fr>
Date:   Mon Oct 4 09:12:50 2021 +0000

    drm/connector: refer to CTA-861-G in the "content type" prop docs
    
    The KMS documentation doesn't say much about the meaning of each
    content type. Add a reference to the specification defining them.
    
    Signed-off-by: Simon Ser <contact at emersion.fr>
    Cc: Emmanuel Gil Peyrot <linkmauve at linkmauve.fr>
    Cc: Daniel Vetter <daniel at ffwll.ch>
    Cc: Jani Nikula <jani.nikula at linux.intel.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
    Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211004091236.82010-1-contact@emersion.fr

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 3bc782b630b9..79d8163686cd 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1397,6 +1397,8 @@ EXPORT_SYMBOL(drm_connector_attach_dp_subconnector_property);
  *	Game:
  *		Content type is game
  *
+ *	The meaning of each content type is defined in CTA-861-G table 15.
+ *
  *	Drivers can set up this property by calling
  *	drm_connector_attach_content_type_property(). Decoding to
  *	infoframe values is done through drm_hdmi_avi_infoframe_content_type().
commit 7be28bd73f23e53d6e7f5fe891ba9503fc0c7210
Author: Alex Xu (Hello71) <alex_y_xu at yahoo.ca>
Date:   Thu Oct 7 02:37:06 2021 -0400

    drm/plane-helper: fix uninitialized variable reference
    
    drivers/gpu/drm/drm_plane_helper.c: In function 'drm_primary_helper_update':
    drivers/gpu/drm/drm_plane_helper.c:113:32: error: 'visible' is used uninitialized [-Werror=uninitialized]
      113 |         struct drm_plane_state plane_state = {
          |                                ^~~~~~~~~~~
    drivers/gpu/drm/drm_plane_helper.c:178:14: note: 'visible' was declared here
      178 |         bool visible;
          |              ^~~~~~~
    cc1: all warnings being treated as errors
    
    visible is an output, not an input. in practice this use might turn out
    OK but it's still UB.
    
    Fixes: df86af9133b4 ("drm/plane-helper: Add drm_plane_helper_check_state()")
    Reviewed-by: Simon Ser <contact at emersion.fr>
    Signed-off-by: Alex Xu (Hello71) <alex_y_xu at yahoo.ca>
    Signed-off-by: Simon Ser <contact at emersion.fr>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211007063706.305984-1-alex_y_xu@yahoo.ca

diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index 5b2d0ca03705..838b32b70bce 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -123,7 +123,6 @@ static int drm_plane_helper_check_update(struct drm_plane *plane,
 		.crtc_w = drm_rect_width(dst),
 		.crtc_h = drm_rect_height(dst),
 		.rotation = rotation,
-		.visible = *visible,
 	};
 	struct drm_crtc_state crtc_state = {
 		.crtc = crtc,
commit 1ab52ac1e9bc9391f592c9fa8340a6e3e9c36286
Author: Patrisious Haddad <phaddad at nvidia.com>
Date:   Wed Oct 6 12:31:53 2021 +0300

    RDMA/mlx5: Set user priority for DCT
    
    Currently, the driver doesn't set the PCP-based priority for DCT, hence
    DCT response packets are transmitted without user priority.
    
    Fix it by setting user provided priority in the eth_prio field in the DCT
    context, which in turn sets the value in the transmitted packet.
    
    Fixes: 776a3906b692 ("IB/mlx5: Add support for DC target QP")
    Link: https://lore.kernel.org/r/5fd2d94a13f5742d8803c218927322257d53205c.1633512672.git.leonro@nvidia.com
    Signed-off-by: Patrisious Haddad <phaddad at nvidia.com>
    Reviewed-by: Maor Gottlieb <maorg at nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro at nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index b2fca110346c..e5abbcfc1d57 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -4458,6 +4458,8 @@ static int mlx5_ib_modify_dct(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 		MLX5_SET(dctc, dctc, mtu, attr->path_mtu);
 		MLX5_SET(dctc, dctc, my_addr_index, attr->ah_attr.grh.sgid_index);
 		MLX5_SET(dctc, dctc, hop_limit, attr->ah_attr.grh.hop_limit);
+		if (attr->ah_attr.type == RDMA_AH_ATTR_TYPE_ROCE)
+			MLX5_SET(dctc, dctc, eth_prio, attr->ah_attr.sl & 0x7);
 
 		err = mlx5_core_create_dct(dev, &qp->dct.mdct, qp->dct.in,
 					   MLX5_ST_SZ_BYTES(create_dct_in), out,
commit e93c7d8e8c4cf80c6afe56e71c83c1cd31b4fce1
Author: Shiraz Saleem <shiraz.saleem at intel.com>
Date:   Tue Oct 5 13:23:02 2021 -0500

    RDMA/irdma: Process extended CQ entries correctly
    
    The valid bit for extended CQE's written by HW is retrieved from the
    incorrect quad-word. This leads to missed completions for any UD traffic
    particularly after a wrap-around.
    
    Get the valid bit for extended CQE's from the correct quad-word in the
    descriptor.
    
    Fixes: 551c46edc769 ("RDMA/irdma: Add user/kernel shared libraries")
    Link: https://lore.kernel.org/r/20211005182302.374-1-shiraz.saleem@intel.com
    Signed-off-by: Shiraz Saleem <shiraz.saleem at intel.com>
    Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

diff --git a/drivers/infiniband/hw/irdma/uk.c b/drivers/infiniband/hw/irdma/uk.c
index 5fb92de1f015..9b544a3b1288 100644
--- a/drivers/infiniband/hw/irdma/uk.c
+++ b/drivers/infiniband/hw/irdma/uk.c
@@ -1092,12 +1092,12 @@ irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, struct irdma_cq_poll_info *info)
 		if (cq->avoid_mem_cflct) {
 			ext_cqe = (__le64 *)((u8 *)cqe + 32);
 			get_64bit_val(ext_cqe, 24, &qword7);
-			polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword3);
+			polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword7);
 		} else {
 			peek_head = (cq->cq_ring.head + 1) % cq->cq_ring.size;
 			ext_cqe = cq->cq_base[peek_head].buf;
 			get_64bit_val(ext_cqe, 24, &qword7);
-			polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword3);
+			polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword7);
 			if (!peek_head)
 				polarity ^= 1;
 		}
commit 15184965783aab3ca7ee4f939e2598943b3f40f9
Author: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
Date:   Fri Jul 9 02:03:29 2021 +0300

    drm/bridge/lontium-lt9611uxc: fix provided connector suport
    
    - set DRM_CONNECTOR_POLL_HPD as the connector will generate hotplug
      events on its own
    
    - do not call drm_kms_helper_hotplug_event() unless mode_config.funcs
      pointer is not NULL to remove possible kernel oops.
    
    Fixes: bc6fa8676ebb ("drm/bridge/lontium-lt9611uxc: move HPD notification out of IRQ handler")
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
    Signed-off-by: Robert Foss <robert.foss at linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210708230329.395976-1-dmitry.baryshkov@linaro.org

diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
index 3cac16db970f..010657ea7af7 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
@@ -167,9 +167,10 @@ static void lt9611uxc_hpd_work(struct work_struct *work)
 	struct lt9611uxc *lt9611uxc = container_of(work, struct lt9611uxc, work);
 	bool connected;
 
-	if (lt9611uxc->connector.dev)
-		drm_kms_helper_hotplug_event(lt9611uxc->connector.dev);
-	else {
+	if (lt9611uxc->connector.dev) {
+		if (lt9611uxc->connector.dev->mode_config.funcs)
+			drm_kms_helper_hotplug_event(lt9611uxc->connector.dev);
+	} else {
 
 		mutex_lock(&lt9611uxc->ocm_lock);
 		connected = lt9611uxc->hdmi_connected;
@@ -339,6 +340,8 @@ static int lt9611uxc_connector_init(struct drm_bridge *bridge, struct lt9611uxc
 		return -ENODEV;
 	}
 
+	lt9611uxc->connector.polled = DRM_CONNECTOR_POLL_HPD;
+
 	drm_connector_helper_add(&lt9611uxc->connector,
 				 &lt9611uxc_bridge_connector_helper_funcs);
 	ret = drm_connector_init(bridge->dev, &lt9611uxc->connector,
commit 3ad60b4b3570937f3278509fe6797a5093ce53f8
Author: Paweł Anikiel <pan at semihalf.com>
Date:   Mon Sep 20 14:41:41 2021 +0200

    reset: socfpga: add empty driver allowing consumers to probe
    
    The early reset driver doesn't ever probe, which causes consuming
    devices to be unable to probe. Add an empty driver to set this device
    as available, allowing consumers to probe.
    
    Signed-off-by: Paweł Anikiel <pan at semihalf.com>
    Link: https://lore.kernel.org/r/20210920124141.1166544-4-pan@semihalf.com
    Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 2a72f861f798..8c6492e5693c 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -92,3 +92,29 @@ void __init socfpga_reset_init(void)
 	for_each_matching_node(np, socfpga_early_reset_dt_ids)
 		a10_reset_init(np);
 }
+
+/*
+ * The early driver is problematic, because it doesn't register
+ * itself as a driver. This causes certain device links to prevent
+ * consumer devices from probing. The hacky solution is to register
+ * an empty driver, whose only job is to attach itself to the reset
+ * manager and call probe.
+ */
+static const struct of_device_id socfpga_reset_dt_ids[] = {
+	{ .compatible = "altr,rst-mgr", },
+	{ /* sentinel */ },
+};
+
+static int reset_simple_probe(struct platform_device *pdev)
+{
+	return 0;
+}
+
+static struct platform_driver reset_socfpga_driver = {
+	.probe	= reset_simple_probe,
+	.driver = {
+		.name		= "socfpga-reset",
+		.of_match_table	= socfpga_reset_dt_ids,
+	},
+};
+builtin_platform_driver(reset_socfpga_driver);
commit c045ceb5a145d2a9a4bf33cbc55185ddf99f60ab
Author: Mikko Perttunen <mperttunen at nvidia.com>
Date:   Wed Sep 15 11:55:14 2021 +0300

    reset: tegra-bpmp: Handle errors in BPMP response
    
    The return value from tegra_bpmp_transfer indicates the success or
    failure of the IPC transaction with BPMP. If the transaction
    succeeded, we also need to check the actual command's result code.
    Add code to do this.
    
    Signed-off-by: Mikko Perttunen <mperttunen at nvidia.com>
    Link: https://lore.kernel.org/r/20210915085517.1669675-2-mperttunen@nvidia.com
    Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>

diff --git a/drivers/reset/tegra/reset-bpmp.c b/drivers/reset/tegra/reset-bpmp.c
index 24d3395964cc..4c5bba52b105 100644
--- a/drivers/reset/tegra/reset-bpmp.c
+++ b/drivers/reset/tegra/reset-bpmp.c
@@ -20,6 +20,7 @@ static int tegra_bpmp_reset_common(struct reset_controller_dev *rstc,
 	struct tegra_bpmp *bpmp = to_tegra_bpmp(rstc);
 	struct mrq_reset_request request;
 	struct tegra_bpmp_message msg;
+	int err;
 
 	memset(&request, 0, sizeof(request));
 	request.cmd = command;
@@ -30,7 +31,13 @@ static int tegra_bpmp_reset_common(struct reset_controller_dev *rstc,
 	msg.tx.data = &request;
 	msg.tx.size = sizeof(request);
 
-	return tegra_bpmp_transfer(bpmp, &msg);
+	err = tegra_bpmp_transfer(bpmp, &msg);
+	if (err)
+		return err;
+	if (msg.rx.ret)
+		return -EINVAL;
+
+	return 0;
 }
 
 static int tegra_bpmp_reset_module(struct reset_controller_dev *rstc,
commit 4af160707d7197d671a5b0ad9899383b6cb7c067
Author: Geert Uytterhoeven <geert+renesas at glider.be>
Date:   Tue Sep 14 11:15:59 2021 +0200

    reset: pistachio: Re-enable driver selection
    
    After the retirement of MACH_PISTACHIO, the Pistachio Reset Driver is no
    longer auto-enabled when building a kernel for Pistachio systems.
    Worse, the driver cannot be enabled by the user at all (unless
    compile-testing), as the config symbol is invisible.
    
    Fix this partially by making the symbol visible again when compiling for
    MIPS, and dropping the useless default.  The user still has to enable
    the driver manually when building a kernel for Pistachio systems,
    though.
    
    Fixes: 104f942b2832ab13 ("MIPS: Retire MACH_PISTACHIO")
    Signed-off-by: Geert Uytterhoeven <geert+renesas at glider.be>
    Reviewed-by: Rahul Bedarkar <rahulbedarkar89 at gmail.com>
    Reviewed-by: Jiaxun Yang <jiaxun.yang at flygoat.com>
    Link: https://lore.kernel.org/r/2c399e52540536df9c4006e46ef93fbccdde88db.1631610825.git.geert+renesas@glider.be
    Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>

diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index be799a5abf8a..b0056ae5d463 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -147,8 +147,8 @@ config RESET_OXNAS
 	bool
 
 config RESET_PISTACHIO
-	bool "Pistachio Reset Driver" if COMPILE_TEST
-	default MACH_PISTACHIO
+	bool "Pistachio Reset Driver"
+	depends on MIPS || COMPILE_TEST
 	help
 	  This enables the reset driver for ImgTec Pistachio SoCs.
 
commit f33eb7f29c16ba78db3221ee02346fd832274cdd
Author: Jim Quinlan <jim2101024 at gmail.com>
Date:   Tue Sep 14 15:11:21 2021 -0700

    reset: brcmstb-rescal: fix incorrect polarity of status bit
    
    The readl_poll_timeout() should complete when the status bit
    is a 1, not 0.
    
    Fixes: 4cf176e52397 ("reset: Add Broadcom STB RESCAL reset controller")
    Signed-off-by: Jim Quinlan <jim2101024 at gmail.com>
    Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
    Link: https://lore.kernel.org/r/20210914221122.62315-1-f.fainelli@gmail.com
    Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>

diff --git a/drivers/reset/reset-brcmstb-rescal.c b/drivers/reset/reset-brcmstb-rescal.c
index b6f074d6a65f..433fa0c40e47 100644
--- a/drivers/reset/reset-brcmstb-rescal.c
+++ b/drivers/reset/reset-brcmstb-rescal.c
@@ -38,7 +38,7 @@ static int brcm_rescal_reset_set(struct reset_controller_dev *rcdev,
 	}
 
 	ret = readl_poll_timeout(base + BRCM_RESCAL_STATUS, reg,
-				 !(reg & BRCM_RESCAL_STATUS_BIT), 100, 1000);
+				 (reg & BRCM_RESCAL_STATUS_BIT), 100, 1000);
 	if (ret) {
 		dev_err(data->dev, "time out on SATA/PCIe rescal\n");
 		return ret;
commit a2083eeb119fb9307258baea9b7c243ca9a2e0b6
Author: Johannes Berg <johannes.berg at intel.com>
Date:   Thu Sep 30 13:11:21 2021 +0200

    cfg80211: scan: fix RCU in cfg80211_add_nontrans_list()
    
    The SSID pointer is pointing to RCU protected data, so we
    need to have it under rcu_read_lock() for the entire use.
    Fix this.
    
    Cc: stable at vger.kernel.org
    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Link: https://lore.kernel.org/r/20210930131120.6ddfc603aa1d.I2137344c4e2426525b1a8e4ce5fca82f8ecbfe7e@changeid
    Signed-off-by: Johannes Berg <johannes.berg at intel.com>

diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 11c68b159324..adc0d14cfd86 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -418,14 +418,17 @@ cfg80211_add_nontrans_list(struct cfg80211_bss *trans_bss,
 	}
 	ssid_len = ssid[1];
 	ssid = ssid + 2;
-	rcu_read_unlock();
 
 	/* check if nontrans_bss is in the list */
 	list_for_each_entry(bss, &trans_bss->nontrans_list, nontrans_list) {
-		if (is_bss(bss, nontrans_bss->bssid, ssid, ssid_len))
+		if (is_bss(bss, nontrans_bss->bssid, ssid, ssid_len)) {
+			rcu_read_unlock();
 			return 0;
+		}
 	}
 
+	rcu_read_unlock();
+
 	/* add to the list */
 	list_add_tail(&nontrans_bss->nontrans_list, &trans_bss->nontrans_list);
 	return 0;
commit 636707e593120c9fa35f6a908c0d052f6154910d
Author: Johannes Berg <johannes.berg at intel.com>
Date:   Thu Sep 30 13:11:20 2021 +0200

    mac80211: mesh: fix HE operation element length check
    
    The length check here was bad, if the length doesn't at
    least include the length of the fixed part, we cannot
    call ieee80211_he_oper_size() to determine the total.
    Fix this, and convert to cfg80211_find_ext_elem() while
    at it.
    
    Cc: stable at vger.kernel.org
    Fixes: 70debba3ab7d ("mac80211: save HE oper info in BSS config for mesh")
    Link: https://lore.kernel.org/r/20210930131120.b0f940976c56.I954e1be55e9f87cc303165bff5c906afe1e54648@changeid
    Signed-off-by: Johannes Berg <johannes.berg at intel.com>

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 97095b7c9c64..5dcfd53a4ab6 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -672,7 +672,7 @@ ieee80211_mesh_update_bss_params(struct ieee80211_sub_if_data *sdata,
 				 u8 *ie, u8 ie_len)
 {
 	struct ieee80211_supported_band *sband;
-	const u8 *cap;
+	const struct element *cap;
 	const struct ieee80211_he_operation *he_oper = NULL;
 
 	sband = ieee80211_get_sband(sdata);
@@ -687,9 +687,10 @@ ieee80211_mesh_update_bss_params(struct ieee80211_sub_if_data *sdata,
 
 	sdata->vif.bss_conf.he_support = true;
 
-	cap = cfg80211_find_ext_ie(WLAN_EID_EXT_HE_OPERATION, ie, ie_len);
-	if (cap && cap[1] >= ieee80211_he_oper_size(&cap[3]))
-		he_oper = (void *)(cap + 3);
+	cap = cfg80211_find_ext_elem(WLAN_EID_EXT_HE_OPERATION, ie, ie_len);
+	if (cap && cap->datalen >= 1 + sizeof(*he_oper) &&
+	    cap->datalen >= 1 + ieee80211_he_oper_size(cap->data + 1))
+		he_oper = (void *)(cap->data + 1);
 
 	if (he_oper)
 		sdata->vif.bss_conf.he_oper.params =
commit 55dd7e059098ce4bd0a55c251cb78e74604abb57
Author: Bastien Roucariès <rouca at debian.org>
Date:   Thu Sep 16 08:17:21 2021 +0000

    ARM: dts: sun7i: A20-olinuxino-lime2: Fix ethernet phy-mode
    
    Commit bbc4d71d6354 ("net: phy: realtek: fix rtl8211e rx/tx delay
    config") sets the RX/TX delay according to the phy-mode property in the
    device tree. For the A20-olinuxino-lime2 board this is "rgmii", which is the
    wrong setting.
    
    Following the example of a900cac3750b ("ARM: dts: sun7i: a20: bananapro:
    Fix ethernet phy-mode") the phy-mode is changed to "rgmii-id" which gets
    the Ethernet working again on this board.
    
    Signed-off-by: Bastien Roucariès <rouca at debian.org>
    Signed-off-by: Maxime Ripard <maxime at cerno.tech>
    Link: https://lore.kernel.org/r/20210916081721.237137-1-rouca@debian.org

diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
index 8077f1716fbc..ecb91fb899ff 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
@@ -112,7 +112,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac_rgmii_pins>;
 	phy-handle = <&phy1>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	status = "okay";
 };
 
commit 0764e365dacd0b8f75c1736f9236be280649bd18
Author: Clément Bœsch <u at pkh.me>
Date:   Sun Sep 5 02:20:27 2021 +0200

    arm64: dts: allwinner: h5: NanoPI Neo 2: Fix ethernet node
    
    RX and TX delay are provided by ethernet PHY. Reflect that in ethernet
    node.
    
    Fixes: 44a94c7ef989 ("arm64: dts: allwinner: H5: Restore EMAC changes")
    Signed-off-by: Clément Bœsch <u at pkh.me>
    Reviewed-by: Jernej Skrabec <jernej.skrabec at gmail.com>
    Reviewed-by: Andrew Lunn <andrew at lunn.ch>
    Signed-off-by: Maxime Ripard <maxime at cerno.tech>
    Link: https://lore.kernel.org/r/20210905002027.171984-1-u@pkh.me

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts b/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts
index 02f8e72f0cad..05486cccee1c 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts
@@ -75,7 +75,7 @@
 	pinctrl-0 = <&emac_rgmii_pins>;
 	phy-supply = <&reg_gmac_3v3>;
 	phy-handle = <&ext_rgmii_phy>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	status = "okay";
 };
 


More information about the openchrome-devel mailing list