History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Conflict resolution of af_smc.c from Stephen Rothwell.

David S. Miller committed 7 years ago

Commit 6b0a7f82 parents cea0aa9 fe5cdef350 files · +3831 −1901Browse files

Unified · Split

350 files
  1. .clang-format +24 −0
  2. Documentation/networking/rxrpc.txt +9 −7
  3. MAINTAINERS +15 −2
  4. Makefile +1 −1
  5. arch/arm64/include/asm/futex.h +8 −8
  6. arch/arm64/include/asm/module.h +5 −0
  7. arch/arm64/kernel/ftrace.c +1 −2
  8. arch/arm64/kernel/traps.c +9 −6
  9. arch/mips/configs/generic/board-ocelot.config +8 −0
  10. arch/mips/kernel/kgdb.c +2 −1
  11. arch/mips/sgi-ip27/ip27-irq.c +1 −2
  12. arch/powerpc/include/asm/mmu.h +1 −1
  13. arch/powerpc/kernel/exceptions-64s.S +12 −0
  14. arch/powerpc/kernel/head_32.S +0 −8
  15. arch/powerpc/kernel/vdso32/gettimeofday.S +1 −1
  16. arch/riscv/configs/rv32_defconfig +84 −0
  17. arch/riscv/mm/init.c +8 −0
  18. arch/sparc/kernel/pci_sun4v.c +11 −9
  19. arch/x86/events/amd/core.c +135 −5
  20. arch/x86/events/core.c +3 −10
  21. arch/x86/events/intel/core.c +7 −1
  22. arch/x86/include/asm/bitops.h +18 −23
  23. arch/x86/include/asm/kvm_emulate.h +3 −1
  24. arch/x86/include/asm/kvm_host.h +10 −7
  25. arch/x86/include/uapi/asm/vmx.h +1 −0
  26. arch/x86/kernel/cpu/resctrl/rdtgroup.c +3 −3
  27. arch/x86/kvm/emulate.c +102 −89
  28. arch/x86/kvm/lapic.c +3 −1
  29. arch/x86/kvm/mmu.c +7 −8
  30. arch/x86/kvm/mmu.h +1 −1
  31. arch/x86/kvm/pmu.c +4 −0
  32. arch/x86/kvm/svm.c +33 −24
  33. arch/x86/kvm/trace.h +2 −2
  34. arch/x86/kvm/vmx/nested.c +36 −11
  35. arch/x86/kvm/vmx/vmx.c +31 −4
  36. arch/x86/kvm/vmx/vmx.h +2 −0
  37. arch/x86/kvm/x86.c +31 −33
  38. arch/x86/kvm/x86.h +2 −0
  39. block/bfq-iosched.c +7 −8
  40. block/bfq-iosched.h +1 −1
  41. block/bfq-wf2q.c +15 −2
  42. block/bio.c +4 −1
  43. block/blk-mq.c +7 −0
  44. drivers/acpi/acpica/nsobject.c +4 −0
  45. drivers/acpi/nfit/core.c +6 −6
  46. drivers/acpi/nfit/intel.c +4 −6
  47. drivers/block/virtio_blk.c +2 −0
  48. drivers/bluetooth/btusb.c +1 −1
  49. drivers/char/ipmi/ipmi_dmi.c +0 −1
  50. drivers/char/ipmi/ipmi_msghandler.c +17 −2
  51. drivers/char/ipmi/ipmi_si_hardcode.c +2 −0
  52. drivers/clk/at91/clk-programmable.c +43 −14
  53. drivers/clk/at91/pmc.h +2 −0
  54. drivers/clk/at91/sama5d2.c +9 −1
  55. drivers/clk/imx/clk-pll14xx.c +1 −1
  56. drivers/clk/mediatek/clk-gate.c +1 −2
  57. drivers/clk/meson/clk-pll.c +1 −1
  58. drivers/clk/meson/g12a.c +3 −3
  59. drivers/clk/meson/gxbb.c +2 −0
  60. drivers/clk/meson/vid-pll-div.c +2 −2
  61. drivers/clk/x86/clk-pmc-atom.c +11 −3
  62. drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 −4
  63. drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +3 −0
  64. drivers/gpu/drm/amd/amdkfd/kfd_device.c +1 −0
  65. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 −0
  66. drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +2 −21
  67. drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +30 −4
  68. drivers/gpu/drm/drm_atomic_helper.c +2 −3
  69. drivers/gpu/drm/i915/gvt/dmabuf.c +6 −3
  70. drivers/gpu/drm/i915/gvt/gtt.c +9 −3
  71. drivers/gpu/drm/i915/gvt/kvmgt.c +3 −3
  72. drivers/gpu/drm/i915/icl_dsi.c +27 −21
  73. drivers/gpu/drm/i915/intel_ddi.c +11 −12
  74. drivers/gpu/drm/i915/intel_display.c +1 −5
  75. drivers/gpu/drm/i915/intel_dp.c +10 −59
  76. drivers/gpu/drm/i915/intel_drv.h +6 −4
  77. drivers/gpu/drm/i915/vlv_dsi.c +24 −0
  78. drivers/gpu/drm/mediatek/mtk_dpi.c +3 −5
  79. drivers/gpu/drm/mediatek/mtk_drm_drv.c +7 −0
  80. drivers/gpu/drm/mediatek/mtk_drm_gem.c +46 −0
  81. drivers/gpu/drm/mediatek/mtk_drm_gem.h +3 −0
  82. drivers/gpu/drm/mediatek/mtk_hdmi.c +1 −1
  83. drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +5 −30
  84. drivers/gpu/drm/mediatek/mtk_hdmi_phy.h +1 −4
  85. drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +43 −6
  86. drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c +23 −0
  87. drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c +19 −7
  88. drivers/gpu/drm/omapdrm/dss/hdmi4_core.c +1 −1
  89. drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +7 −2
  90. drivers/gpu/drm/sun4i/sun8i_tcon_top.c +3 −2
  91. drivers/gpu/drm/udl/udl_drv.c +1 −0
  92. drivers/gpu/drm/udl/udl_drv.h +1 −0
  93. drivers/gpu/drm/udl/udl_main.c +7 −1
  94. drivers/gpu/host1x/hw/channel_hw.c +1 −1
  95. drivers/infiniband/hw/hfi1/chip.c +19 −7
  96. drivers/infiniband/hw/hfi1/qp.c +3 −1
  97. drivers/infiniband/hw/hfi1/rc.c +2 −2
  98. drivers/infiniband/hw/hfi1/tid_rdma.c +8 −23
  99. drivers/infiniband/hw/hns/hns_roce_hem.c +4 −2
  100. drivers/infiniband/hw/hns/hns_roce_mr.c +2 −2
  101. drivers/infiniband/hw/hns/hns_roce_qp.c +0 −3
  102. drivers/infiniband/hw/mlx5/odp.c +2 −1
  103. drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +2 −0
  104. drivers/iommu/amd_iommu_init.c +1 −1
  105. drivers/irqchip/irq-ls1x.c +1 −0
  106. drivers/isdn/mISDN/socket.c +2 −2
  107. drivers/lightnvm/pblk-read.c +28 −22
  108. drivers/mmc/host/alcor.c +13 −21
  109. drivers/mmc/host/sdhci-omap.c +38 −0
  110. drivers/net/bonding/bond_main.c +5 −1
  111. drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +1 −1
  112. drivers/net/ethernet/cavium/thunder/nicvf_main.c +20 −2
  113. drivers/net/ethernet/freescale/fec_main.c +21 −9
  114. drivers/net/ethernet/ibm/ibmvnic.c +25 −7
  115. drivers/net/ethernet/mellanox/mlx5/core/en.h +1 −0
  116. drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +8 −3
  117. drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +4 −0
  118. drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +2 −1
  119. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +16 −5
  120. drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +75 −19
  121. drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +6 −0
  122. drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +4 −0
  123. drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c +24 −37
  124. drivers/net/ethernet/mellanox/mlxsw/core.c +3 −3
  125. drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c +11 −8
  126. drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1 −1
  127. drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1 −1
  128. drivers/net/ethernet/mscc/ocelot.c +15 −9
  129. drivers/net/ethernet/neterion/vxge/vxge-config.c +1 −0
  130. drivers/net/ethernet/qlogic/qed/qed.h +5 −2
  131. drivers/net/ethernet/qlogic/qed/qed_dev.c +34 −51
  132. drivers/net/ethernet/qlogic/qed/qed_int.c +63 −20
  133. drivers/net/ethernet/qlogic/qed/qed_int.h +2 −2
  134. drivers/net/ethernet/qlogic/qed/qed_main.c +1 −1
  135. drivers/net/ethernet/qlogic/qed/qed_sriov.c +1 −1
  136. drivers/net/ethernet/qlogic/qede/qede_ptp.c +3 −4
  137. drivers/net/team/team.c +26 −0
  138. drivers/net/wireless/ath/ath10k/htt_rx.c +1 −1
  139. drivers/net/wireless/ath/ath10k/mac.c +2 −2
  140. drivers/net/wireless/ath/ath9k/xmit.c +4 −1
  141. drivers/net/wireless/intel/iwlwifi/cfg/22000.c +22 −8
  142. drivers/net/wireless/intel/iwlwifi/fw/dbg.c +8 −26
  143. drivers/net/wireless/intel/iwlwifi/fw/init.c +0 −1
  144. drivers/net/wireless/intel/iwlwifi/iwl-config.h +2 −1
  145. drivers/net/wireless/intel/iwlwifi/iwl-csr.h +1 −0
  146. drivers/net/wireless/intel/iwlwifi/iwl-trans.h +6 −6
  147. drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +22 −49
  148. drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +0 −1
  149. drivers/net/wireless/intel/iwlwifi/mvm/sta.c +4 −39
  150. drivers/net/wireless/intel/iwlwifi/mvm/sta.h +2 −5
  151. drivers/net/wireless/intel/iwlwifi/pcie/drv.c +7 −6
  152. drivers/net/wireless/intel/iwlwifi/pcie/internal.h +1 −1
  153. drivers/net/wireless/intel/iwlwifi/pcie/trans.c +8 −3
  154. drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c +1 −1
  155. drivers/net/wireless/intel/iwlwifi/pcie/tx.c +1 −1
  156. drivers/net/wireless/mac80211_hwsim.c +15 −4
  157. drivers/net/wireless/mediatek/mt76/mt7603/init.c +2 −0
  158. drivers/net/wireless/mediatek/mt76/mt7603/mac.c +14 −39
  159. drivers/net/wireless/mediatek/mt76/mt7603/main.c +4 −4
  160. drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h +1 −1
  161. drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +8 −6
  162. drivers/net/wireless/ralink/rt2x00/rt2x00.h +0 −1
  163. drivers/net/wireless/ralink/rt2x00/rt2x00mac.c +0 −10
  164. drivers/net/wireless/ralink/rt2x00/rt2x00queue.c +9 −6
  165. drivers/nvdimm/btt_devs.c +13 −5
  166. drivers/nvdimm/namespace_devs.c +4 −1
  167. drivers/nvdimm/pmem.c +4 −4
  168. drivers/nvdimm/security.c +73 −45
  169. drivers/nvme/host/core.c +1 −1
  170. drivers/nvme/host/fc.c +15 −5
  171. drivers/nvme/target/admin-cmd.c +5 −0
  172. drivers/nvme/target/discovery.c +45 −23
  173. drivers/nvme/target/nvmet.h +1 −0
  174. drivers/pci/hotplug/pciehp_ctrl.c +4 −0
  175. drivers/pci/quirks.c +2 −0
  176. drivers/platform/x86/pmc_atom.c +21 −0
  177. drivers/scsi/csiostor/csio_scsi.c +4 −1
  178. drivers/scsi/virtio_scsi.c +1 −0
  179. drivers/vhost/vhost.c +5 −1
  180. drivers/virtio/virtio_pci_common.c +5 −3
  181. drivers/virtio/virtio_ring.c +2 −0
  182. fs/afs/rxrpc.c +17 −7
  183. fs/aio.c +2 −2
  184. fs/block_dev.c +4 −4
  185. fs/btrfs/ioctl.c +10 −0
  186. fs/btrfs/props.c +4 −4
  187. fs/dax.c +15 −0
  188. fs/fuse/dev.c +6 −6
  189. fs/io_uring.c +4 −0
  190. fs/nfs/nfs42proc.c +0 −3
  191. fs/nfs/nfs4file.c +3 −1
  192. fs/nfs/nfs4xdr.c +2 −2
  193. fs/nfs/super.c +2 −1
  194. fs/pipe.c +2 −2
  195. fs/splice.c +10 −2
  196. include/drm/drm_modeset_helper_vtables.h +4 −0
  197. include/dt-bindings/clock/sifive-fu540-prci.h +18 −0
  198. include/linux/bio.h +12 −8
  199. include/linux/blk-mq.h +1 −0
  200. include/linux/bvec.h +10 −4
  201. include/linux/kernel.h +2 −2
  202. include/linux/kvm_host.h +6 −4
  203. include/linux/mm.h +14 −1
  204. include/linux/netdevice.h +3 −0
  205. include/linux/nvme.h +7 −2
  206. include/linux/pipe_fs_i.h +6 −4
  207. include/linux/platform_data/x86/clk-pmc-atom.h +3 −0
  208. include/linux/sunrpc/sched.h +0 −8
  209. include/linux/virtio_ring.h +1 −1
  210. include/net/af_rxrpc.h +3 −1
  211. include/net/cfg80211.h +5 −0
  212. include/net/mac80211.h +34 −29
  213. include/net/netrom.h +1 −1
  214. include/net/sock.h +0 −6
  215. include/net/tls.h +3 −1
  216. include/sound/soc.h +9 −2
  217. include/uapi/sound/asound.h +1 −0
  218. kernel/dma/debug.c +1 −1
  219. kernel/events/core.c +43 −9
  220. kernel/events/ring_buffer.c +2 −2
  221. kernel/irq/chip.c +4 −0
  222. kernel/irq/irqdesc.c +1 −0
  223. kernel/locking/lockdep.c +12 −17
  224. kernel/sched/fair.c +3 −3
  225. kernel/time/alarmtimer.c +1 −1
  226. kernel/trace/trace.c +5 −1
  227. lib/iov_iter.c +4 −0
  228. mm/gup.c +36 −12
  229. mm/hugetlb.c +13 −0
  230. net/atm/lec.c +5 −1
  231. net/bluetooth/sco.c +2 −2
  232. net/bridge/br_input.c +14 −9
  233. net/bridge/br_multicast.c +3 −1
  234. net/bridge/br_netlink.c +1 −1
  235. net/core/dev.c +15 −1
  236. net/core/failover.c +3 −3
  237. net/core/filter.c +2 −0
  238. net/core/net-sysfs.c +5 −9
  239. net/core/ptp_classifier.c +4 −3
  240. net/core/rtnetlink.c +1 −1
  241. net/core/skbuff.c +9 −1
  242. net/core/sock.c +2 −2
  243. net/ipv4/fou.c +3 −1
  244. net/ipv4/route.c +15 −1
  245. net/ipv4/tcp_dctcp.c +17 −28
  246. net/ipv4/tcp_input.c +5 −5
  247. net/ipv6/route.c +4 −0
  248. net/ipv6/udp.c +2 −0
  249. net/llc/af_llc.c +1 −2
  250. net/mac80211/driver-ops.h +3 −0
  251. net/mac80211/key.c +4 −5
  252. net/mac80211/mesh_pathtbl.c +1 −1
  253. net/mac80211/rx.c +9 −1
  254. net/mac80211/trace_msg.h +6 −1
  255. net/mac80211/tx.c +23 −30
  256. net/netlink/af_netlink.c +2 −1
  257. net/netrom/af_netrom.c +54 −22
  258. net/netrom/nr_loopback.c +1 −1
  259. net/netrom/nr_route.c +1 −1
  260. net/netrom/sysctl_net_netrom.c +4 −1
  261. net/rds/af_rds.c +3 −0
  262. net/rds/bind.c +2 −0
  263. net/rxrpc/af_rxrpc.c +11 −6
  264. net/rxrpc/ar-internal.h +1 −0
  265. net/rxrpc/conn_event.c +7 −4
  266. net/rxrpc/input.c +12 −6
  267. net/rxrpc/peer_event.c +5 −0
  268. net/rxrpc/sendmsg.c +12 −9
  269. net/sctp/socket.c +2 −1
  270. net/smc/af_smc.c +39 −19
  271. net/smc/smc_close.c +21 −4
  272. net/smc/smc_close.h +1 −0
  273. net/smc/smc_ism.c +5 −0
  274. net/smc/smc_pnet.c +2 −1
  275. net/strparser/strparser.c +5 −7
  276. net/sunrpc/clnt.c +8 −37
  277. net/sunrpc/xprtrdma/verbs.c +1 −1
  278. net/tipc/link.c +2 −0
  279. net/tipc/name_table.c +2 −1
  280. net/tipc/sysctl.c +6 −2
  281. net/tls/tls_device.c +11 −1
  282. net/tls/tls_main.c +24 −0
  283. net/tls/tls_sw.c +1 −14
  284. net/wireless/nl80211.c +12 −6
  285. net/wireless/reg.c +39 −0
  286. net/wireless/scan.c +1 −2
  287. net/wireless/util.c +4 −2
  288. security/apparmor/lsm.c +48 −1
  289. sound/core/seq/seq_clientmgr.c +3 −3
  290. sound/hda/ext/hdac_ext_bus.c +0 −1
  291. sound/hda/hdac_bus.c +1 −0
  292. sound/hda/hdac_component.c +5 −1
  293. sound/pci/hda/hda_intel.c +4 −0
  294. sound/pci/hda/patch_realtek.c +51 −21
  295. sound/soc/codecs/Kconfig +1 −0
  296. sound/soc/codecs/ab8500-codec.c +1 −0
  297. sound/soc/codecs/cs35l35.c +11 −0
  298. sound/soc/codecs/cs4270.c +1 −0
  299. sound/soc/codecs/hdac_hda.c +39 −14
  300. sound/soc/codecs/hdac_hda.h +1 −0
  301. sound/soc/codecs/hdmi-codec.c +59 −62
  302. sound/soc/codecs/nau8810.c +2 −2
  303. sound/soc/codecs/nau8824.c +38 −8
  304. sound/soc/codecs/rt5682.c +25 −31
  305. sound/soc/codecs/tlv320aic32x4-i2c.c +2 −2
  306. sound/soc/codecs/tlv320aic32x4-spi.c +2 −2
  307. sound/soc/codecs/tlv320aic32x4.c +2 −0
  308. sound/soc/codecs/tlv320aic3x.c +3 −1
  309. sound/soc/codecs/wm_adsp.c +33 −7
  310. sound/soc/codecs/wm_adsp.h +1 −0
  311. sound/soc/fsl/fsl_asrc.c +14 −0
  312. sound/soc/fsl/fsl_esai.c +37 −10
  313. sound/soc/generic/audio-graph-card.c +8 −3
  314. sound/soc/generic/simple-card.c +9 −3
  315. sound/soc/intel/atom/sst-mfld-platform-pcm.c +8 −0
  316. sound/soc/intel/boards/cht_bsw_max98090_ti.c +41 −6
  317. sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +1 −1
  318. sound/soc/intel/skylake/skl-messages.c +1 −0
  319. sound/soc/intel/skylake/skl-pcm.c +22 −6
  320. sound/soc/mediatek/common/mtk-btcvsd.c +68 −1
  321. sound/soc/mediatek/mt8183/mt8183-afe-clk.c +4 −0
  322. sound/soc/rockchip/rockchip_pdm.c +3 −1
  323. sound/soc/samsung/i2s.c +6 −4
  324. sound/soc/samsung/odroid.c +2 −2
  325. sound/soc/sh/rcar/core.c +2 −0
  326. sound/soc/sh/rcar/rsnd.h +5 −0
  327. sound/soc/sh/rcar/src.c +7 −14
  328. sound/soc/soc-core.c +4 −2
  329. sound/soc/soc-dapm.c +11 −0
  330. sound/soc/soc-pcm.c +55 −11
  331. sound/soc/soc-topology.c +4 −3
  332. sound/soc/stm/stm32_adfsdm.c +34 −4
  333. sound/soc/stm/stm32_i2s.c +1 −2
  334. sound/soc/stm/stm32_sai.c +5 −3
  335. sound/soc/stm/stm32_sai_sub.c +86 −28
  336. sound/xen/xen_snd_front_alsa.c +1 −1
  337. tools/io_uring/io_uring-bench.c +4 −28
  338. tools/objtool/check.c +1 −0
  339. tools/testing/nvdimm/test/nfit.c +13 −4
  340. tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh +20 −0
  341. tools/testing/selftests/kvm/Makefile +8 −1
  342. tools/testing/selftests/kvm/include/x86_64/processor.h +27 −0
  343. tools/testing/selftests/kvm/lib/kvm_util.c +5 −0
  344. tools/testing/selftests/kvm/lib/x86_64/processor.c +14 −6
  345. tools/testing/selftests/kvm/x86_64/evmcs_test.c +3 −2
  346. tools/testing/selftests/kvm/x86_64/smm_test.c +157 −0
  347. tools/testing/selftests/kvm/x86_64/state_test.c +1 −14
  348. tools/testing/selftests/net/fib_tests.sh +40 −54
  349. virt/kvm/irqchip.c +3 −2
  350. virt/kvm/kvm_main.c +4 −2
.clang-format+24−0
@@ -78,6 +78,8 @@ ForEachMacros: · 77 unmodified lines
7878 - 'ata_qc_for_each_with_internal'
7979 - 'ax25_for_each'
8080 - 'ax25_uid_for_each'
81+ - '__bio_for_each_bvec'
82+ - 'bio_for_each_bvec'
8183 - 'bio_for_each_integrity_vec'
8284 - '__bio_for_each_segment'
8385 - 'bio_for_each_segment'
@@ -118,10 +120,12 @@ ForEachMacros: · 34 unmodified lines
118120 - 'drm_for_each_legacy_plane'
119121 - 'drm_for_each_plane'
120122 - 'drm_for_each_plane_mask'
123+ - 'drm_for_each_privobj'
121124 - 'drm_mm_for_each_hole'
122125 - 'drm_mm_for_each_node'
123126 - 'drm_mm_for_each_node_in_range'
124127 - 'drm_mm_for_each_node_safe'
128+ - 'flow_action_for_each'
125129 - 'for_each_active_drhd_unit'
126130 - 'for_each_active_iommu'
127131 - 'for_each_available_child_of_node'
@@ -158,6 +162,9 @@ ForEachMacros: · 30 unmodified lines
158162 - 'for_each_dss_dev'
159163 - 'for_each_efi_memory_desc'
160164 - 'for_each_efi_memory_desc_in_map'
165+ - 'for_each_element'
166+ - 'for_each_element_extid'
167+ - 'for_each_element_id'
161168 - 'for_each_endpoint_of_node'
162169 - 'for_each_evictable_lru'
163170 - 'for_each_fib6_node_rt_rcu'
@@ -195,6 +202,7 @@ ForEachMacros: · 31 unmodified lines
195202 - 'for_each_net_rcu'
196203 - 'for_each_new_connector_in_state'
197204 - 'for_each_new_crtc_in_state'
205+ - 'for_each_new_mst_mgr_in_state'
198206 - 'for_each_new_plane_in_state'
199207 - 'for_each_new_private_obj_in_state'
200208 - 'for_each_node'
@@ -210,8 +218,10 @@ ForEachMacros: · 9 unmodified lines
210218 - 'for_each_of_pci_range'
211219 - 'for_each_old_connector_in_state'
212220 - 'for_each_old_crtc_in_state'
221+ - 'for_each_old_mst_mgr_in_state'
213222 - 'for_each_oldnew_connector_in_state'
214223 - 'for_each_oldnew_crtc_in_state'
224+ - 'for_each_oldnew_mst_mgr_in_state'
215225 - 'for_each_oldnew_plane_in_state'
216226 - 'for_each_oldnew_plane_in_state_reverse'
217227 - 'for_each_oldnew_private_obj_in_state'
@@ -243,6 +253,9 @@ ForEachMacros: · 25 unmodified lines
243253 - 'for_each_sg_dma_page'
244254 - 'for_each_sg_page'
245255 - 'for_each_sibling_event'
256+ - 'for_each_subelement'
257+ - 'for_each_subelement_extid'
258+ - 'for_each_subelement_id'
246259 - '__for_each_thread'
247260 - 'for_each_thread'
248261 - 'for_each_zone'
@@ -252,6 +265,8 @@ ForEachMacros: · 3 unmodified lines
252265 - 'fwnode_for_each_child_node'
253266 - 'fwnode_graph_for_each_endpoint'
254267 - 'gadget_for_each_ep'
268+ - 'genradix_for_each'
269+ - 'genradix_for_each_from'
255270 - 'hash_for_each'
256271 - 'hash_for_each_possible'
257272 - 'hash_for_each_possible_rcu'
@@ -293,7 +308,11 @@ ForEachMacros: · 35 unmodified lines
293308 - 'key_for_each'
294309 - 'key_for_each_safe'
295310 - 'klp_for_each_func'
311+ - 'klp_for_each_func_safe'
312+ - 'klp_for_each_func_static'
296313 - 'klp_for_each_object'
314+ - 'klp_for_each_object_safe'
315+ - 'klp_for_each_object_static'
297316 - 'kvm_for_each_memslot'
298317 - 'kvm_for_each_vcpu'
299318 - 'list_for_each'
@@ -324,6 +343,8 @@ ForEachMacros: · 24 unmodified lines
324343 - 'media_device_for_each_intf'
325344 - 'media_device_for_each_link'
326345 - 'media_device_for_each_pad'
346+ - 'mp_bvec_for_each_page'
347+ - 'mp_bvec_for_each_segment'
327348 - 'nanddev_io_for_each_page'
328349 - 'netdev_for_each_lower_dev'
329350 - 'netdev_for_each_lower_private'
@@ -375,6 +396,7 @@ ForEachMacros: · 45 unmodified lines
375396 - 'rht_for_each_rcu'
376397 - 'rht_for_each_rcu_from'
377398 - '__rq_for_each_bio'
399+ - 'rq_for_each_bvec'
378400 - 'rq_for_each_segment'
379401 - 'scsi_for_each_prot_sg'
380402 - 'scsi_for_each_sg'
@@ -410,6 +432,8 @@ ForEachMacros: · 29 unmodified lines
410432 - 'v4l2_m2m_for_each_src_buf_safe'
411433 - 'virtio_device_for_each_vq'
412434 - 'xa_for_each'
435+ - 'xa_for_each_marked'
436+ - 'xa_for_each_start'
413437 - 'xas_for_each'
414438 - 'xas_for_each_conflict'
415439 - 'xas_for_each_marked'
Documentation/networking/rxrpc.txt+9−7
@@ -1009,16 +1009,18 @@ The kernel interface functions are as follows: · 1008 unmodified lines
10091009
10101010 (*) Check call still alive.
10111011
1012− u32 rxrpc_kernel_check_life(struct socket *sock,
1013− struct rxrpc_call *call);
1012+ bool rxrpc_kernel_check_life(struct socket *sock,
1013+ struct rxrpc_call *call,
1014+ u32 *_life);
10141015 void rxrpc_kernel_probe_life(struct socket *sock,
10151016 struct rxrpc_call *call);
10161017
1017− The first function returns a number that is updated when ACKs are received
1018− from the peer (notably including PING RESPONSE ACKs which we can elicit by
1019− sending PING ACKs to see if the call still exists on the server). The
1020− caller should compare the numbers of two calls to see if the call is still
1021− alive after waiting for a suitable interval.
1018+ The first function passes back in *_life a number that is updated when
1019+ ACKs are received from the peer (notably including PING RESPONSE ACKs
1020+ which we can elicit by sending PING ACKs to see if the call still exists
1021+ on the server). The caller should compare the numbers of two calls to see
1022+ if the call is still alive after waiting for a suitable interval. It also
1023+ returns true as long as the call hasn't yet reached the completed state.
10221024
10231025 This allows the caller to work out if the server is still contactable and
10241026 if the call is still alive on the server while waiting for the server to
MAINTAINERS+15−2
@@ -10139,7 +10139,7 @@ F: drivers/spi/spi-at91-usart.c · 10138 unmodified lines
1013910139 F: Documentation/devicetree/bindings/mfd/atmel-usart.txt
1014010140
1014110141 MICROCHIP KSZ SERIES ETHERNET SWITCH DRIVER
10142−M: Woojung Huh <Woojung.Huh@microchip.com>
10142+M: Woojung Huh <woojung.huh@microchip.com>
1014310143 M: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
1014410144 L: netdev@vger.kernel.org
1014510145 S: Maintained
@@ -16503,7 +16503,7 @@ F: drivers/char/virtio_console.c · 6357 unmodified lines
1650316503 F: include/linux/virtio_console.h
1650416504 F: include/uapi/linux/virtio_console.h
1650516505
16506−VIRTIO CORE, NET AND BLOCK DRIVERS
16506+VIRTIO CORE AND NET DRIVERS
1650716507 M: "Michael S. Tsirkin" <mst@redhat.com>
1650816508 M: Jason Wang <jasowang@redhat.com>
1650916509 L: virtualization@lists.linux-foundation.org
@@ -16518,6 +16518,19 @@ F: include/uapi/linux/virtio_*.h · 8 unmodified lines
1651816518 F: drivers/crypto/virtio/
1651916519 F: mm/balloon_compaction.c
1652016520
16521+VIRTIO BLOCK AND SCSI DRIVERS
16522+M: "Michael S. Tsirkin" <mst@redhat.com>
16523+M: Jason Wang <jasowang@redhat.com>
16524+R: Paolo Bonzini <pbonzini@redhat.com>
16525+R: Stefan Hajnoczi <stefanha@redhat.com>
16526+L: virtualization@lists.linux-foundation.org
16527+S: Maintained
16528+F: drivers/block/virtio_blk.c
16529+F: drivers/scsi/virtio_scsi.c
16530+F: include/uapi/linux/virtio_blk.h
16531+F: include/uapi/linux/virtio_scsi.h
16532+F: drivers/vhost/scsi.c
16533+
1652116534 VIRTIO CRYPTO DRIVER
1652216535 M: Gonglei <arei.gonglei@huawei.com>
1652316536 L: virtualization@lists.linux-foundation.org
Makefile+1−1
@@ -2,7 +2,7 @@ · 1 unmodified line
22 VERSION = 5
33 PATCHLEVEL = 1
44 SUBLEVEL = 0
5−EXTRAVERSION = -rc4
5+EXTRAVERSION = -rc5
66 NAME = Shy Crocodile
77
88 # *DOCUMENTATION*
arch/arm64/include/asm/futex.h+8−8
@@ -30,8 +30,8 @@ do { \ · 29 unmodified lines
3030 " prfm pstl1strm, %2\n" \
3131 "1: ldxr %w1, %2\n" \
3232 insn "\n" \
33−"2: stlxr %w3, %w0, %2\n" \
34−" cbnz %w3, 1b\n" \
33+"2: stlxr %w0, %w3, %2\n" \
34+" cbnz %w0, 1b\n" \
3535 " dmb ish\n" \
3636 "3:\n" \
3737 " .pushsection .fixup,\"ax\"\n" \
@@ -50,30 +50,30 @@ do { \ · 12 unmodified lines
5050 static inline int
5151 arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *_uaddr)
5252 {
53− int oldval = 0, ret, tmp;
53+ int oldval, ret, tmp;
5454 u32 __user *uaddr = __uaccess_mask_ptr(_uaddr);
5555
5656 pagefault_disable();
5757
5858 switch (op) {
5959 case FUTEX_OP_SET:
60− __futex_atomic_op("mov %w0, %w4",
60+ __futex_atomic_op("mov %w3, %w4",
6161 ret, oldval, uaddr, tmp, oparg);
6262 break;
6363 case FUTEX_OP_ADD:
64− __futex_atomic_op("add %w0, %w1, %w4",
64+ __futex_atomic_op("add %w3, %w1, %w4",
6565 ret, oldval, uaddr, tmp, oparg);
6666 break;
6767 case FUTEX_OP_OR:
68− __futex_atomic_op("orr %w0, %w1, %w4",
68+ __futex_atomic_op("orr %w3, %w1, %w4",
6969 ret, oldval, uaddr, tmp, oparg);
7070 break;
7171 case FUTEX_OP_ANDN:
72− __futex_atomic_op("and %w0, %w1, %w4",
72+ __futex_atomic_op("and %w3, %w1, %w4",
7373 ret, oldval, uaddr, tmp, ~oparg);
7474 break;
7575 case FUTEX_OP_XOR:
76− __futex_atomic_op("eor %w0, %w1, %w4",
76+ __futex_atomic_op("eor %w3, %w1, %w4",
7777 ret, oldval, uaddr, tmp, oparg);
7878 break;
7979 default:
arch/arm64/include/asm/module.h+5−0
@@ -73,4 +73,9 @@ static inline bool is_forbidden_offset_for_adrp(void *place) · 72 unmodified lines
7373 struct plt_entry get_plt_entry(u64 dst, void *pc);
7474 bool plt_entries_equal(const struct plt_entry *a, const struct plt_entry *b);
7575
76+static inline bool plt_entry_is_initialized(const struct plt_entry *e)
77+{
78+ return e->adrp || e->add || e->br;
79+}
80+
7681 #endif /* __ASM_MODULE_H */
arch/arm64/kernel/ftrace.c+1−2
@@ -107,8 +107,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) · 106 unmodified lines
107107 trampoline = get_plt_entry(addr, mod->arch.ftrace_trampoline);
108108 if (!plt_entries_equal(mod->arch.ftrace_trampoline,
109109 &trampoline)) {
110− if (!plt_entries_equal(mod->arch.ftrace_trampoline,
111− &(struct plt_entry){})) {
110+ if (plt_entry_is_initialized(mod->arch.ftrace_trampoline)) {
112111 pr_err("ftrace: far branches to multiple entry points unsupported inside a single module\n");
113112 return -EINVAL;
114113 }
arch/arm64/kernel/traps.c+9−6
@@ -102,10 +102,16 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) · 101 unmodified lines
102102 void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
103103 {
104104 struct stackframe frame;
105− int skip;
105+ int skip = 0;
106106
107107 pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
108108
109+ if (regs) {
110+ if (user_mode(regs))
111+ return;
112+ skip = 1;
113+ }
114+
109115 if (!tsk)
110116 tsk = current;
111117
@@ -126,7 +132,6 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) · 14 unmodified lines
126132 frame.graph = 0;
127133 #endif
128134
129− skip = !!regs;
130135 printk("Call trace:\n");
131136 do {
132137 /* skip until specified stack frame */
@@ -176,15 +181,13 @@ static int __die(const char *str, int err, struct pt_regs *regs) · 43 unmodified lines
176181 return ret;
177182
178183 print_modules();
179− __show_regs(regs);
180184 pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n",
181185 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk),
182186 end_of_stack(tsk));
187+ show_regs(regs);
183188
184− if (!user_mode(regs)) {
185− dump_backtrace(regs, tsk);
189+ if (!user_mode(regs))
186190 dump_instr(KERN_EMERG, regs);
187− }
188191
189192 return ret;
190193 }
arch/mips/configs/generic/board-ocelot.config+8−0
@@ -1,6 +1,10 @@
11 # require CONFIG_CPU_MIPS32_R2=y
22
33 CONFIG_LEGACY_BOARD_OCELOT=y
4+CONFIG_FIT_IMAGE_FDT_OCELOT=y
5+
6+CONFIG_BRIDGE=y
7+CONFIG_GENERIC_PHY=y
48
59 CONFIG_MTD=y
610 CONFIG_MTD_CMDLINE_PARTS=y
@@ -19,6 +23,8 @@ CONFIG_SERIAL_8250_CONSOLE=y · 12 unmodified lines
1923 CONFIG_SERIAL_OF_PLATFORM=y
2024
2125 CONFIG_NETDEVICES=y
26+CONFIG_NET_SWITCHDEV=y
27+CONFIG_NET_DSA=y
2228 CONFIG_MSCC_OCELOT_SWITCH=y
2329 CONFIG_MSCC_OCELOT_SWITCH_OCELOT=y
2430 CONFIG_MDIO_MSCC_MIIM=y
@@ -35,6 +41,8 @@ CONFIG_SPI_DESIGNWARE=y · 10 unmodified lines
3541 CONFIG_SPI_DW_MMIO=y
3642 CONFIG_SPI_SPIDEV=y
3743
44+CONFIG_PINCTRL_OCELOT=y
45+
3846 CONFIG_GPIO_SYSFS=y
3947
4048 CONFIG_POWER_RESET=y
arch/mips/kernel/kgdb.c+2−1
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333 #include <asm/processor.h>
3434 #include <asm/sigcontext.h>
3535 #include <linux/uaccess.h>
36+#include <asm/irq_regs.h>
3637
3738 static struct hard_trap_info {
3839 unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
@@ -214,7 +215,7 @@ void kgdb_call_nmi_hook(void *ignored) · 175 unmodified lines
214215 old_fs = get_fs();
215216 set_fs(KERNEL_DS);
216217
217− kgdb_nmicallback(raw_smp_processor_id(), NULL);
218+ kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
218219
219220 set_fs(old_fs);
220221 }
arch/mips/sgi-ip27/ip27-irq.c+1−2
@@ -118,7 +118,6 @@ static void shutdown_bridge_irq(struct irq_data *d) · 117 unmodified lines
118118 {
119119 struct hub_irq_data *hd = irq_data_get_irq_chip_data(d);
120120 struct bridge_controller *bc;
121− int pin = hd->pin;
122121
123122 if (!hd)
124123 return;
@@ -126,7 +125,7 @@ static void shutdown_bridge_irq(struct irq_data *d) · 1 unmodified line
126125 disable_hub_irq(d);
127126
128127 bc = hd->bc;
129− bridge_clr(bc, b_int_enable, (1 << pin));
128+ bridge_clr(bc, b_int_enable, (1 << hd->pin));
130129 bridge_read(bc, b_wid_tflush);
131130 }
132131
arch/powerpc/include/asm/mmu.h+1−1
@@ -352,7 +352,7 @@ static inline bool strict_kernel_rwx_enabled(void) · 351 unmodified lines
352352 #if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME) && \
353353 defined (CONFIG_PPC_64K_PAGES)
354354 #define MAX_PHYSMEM_BITS 51
355−#elif defined(CONFIG_SPARSEMEM)
355+#elif defined(CONFIG_PPC64)
356356 #define MAX_PHYSMEM_BITS 46
357357 #endif
358358
arch/powerpc/kernel/exceptions-64s.S+12−0
@@ -656,11 +656,17 @@ EXC_COMMON_BEGIN(data_access_slb_common) · 655 unmodified lines
656656 ld r4,PACA_EXSLB+EX_DAR(r13)
657657 std r4,_DAR(r1)
658658 addi r3,r1,STACK_FRAME_OVERHEAD
659+BEGIN_MMU_FTR_SECTION
660+ /* HPT case, do SLB fault */
659661 bl do_slb_fault
660662 cmpdi r3,0
661663 bne- 1f
662664 b fast_exception_return
663665 1: /* Error case */
666+MMU_FTR_SECTION_ELSE
667+ /* Radix case, access is outside page table range */
668+ li r3,-EFAULT
669+ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
664670 std r3,RESULT(r1)
665671 bl save_nvgprs
666672 RECONCILE_IRQ_STATE(r10, r11)
@@ -705,11 +711,17 @@ EXC_COMMON_BEGIN(instruction_access_slb_common) · 38 unmodified lines
705711 EXCEPTION_PROLOG_COMMON(0x480, PACA_EXSLB)
706712 ld r4,_NIP(r1)
707713 addi r3,r1,STACK_FRAME_OVERHEAD
714+BEGIN_MMU_FTR_SECTION
715+ /* HPT case, do SLB fault */
708716 bl do_slb_fault
709717 cmpdi r3,0
710718 bne- 1f
711719 b fast_exception_return
712720 1: /* Error case */
721+MMU_FTR_SECTION_ELSE
722+ /* Radix case, access is outside page table range */
723+ li r3,-EFAULT
724+ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
713725 std r3,RESULT(r1)
714726 bl save_nvgprs
715727 RECONCILE_IRQ_STATE(r10, r11)
arch/powerpc/kernel/head_32.S+0−8
@@ -851,10 +851,6 @@ __secondary_start: · 850 unmodified lines
851851 tophys(r4,r2)
852852 addi r4,r4,THREAD /* phys address of our thread_struct */
853853 mtspr SPRN_SPRG_THREAD,r4
854−#ifdef CONFIG_PPC_RTAS
855− li r3,0
856− stw r3, RTAS_SP(r4) /* 0 => not in RTAS */
857−#endif
858854 lis r4, (swapper_pg_dir - PAGE_OFFSET)@h
859855 ori r4, r4, (swapper_pg_dir - PAGE_OFFSET)@l
860856 mtspr SPRN_SPRG_PGDIR, r4
@@ -941,10 +937,6 @@ start_here: · 80 unmodified lines
941937 tophys(r4,r2)
942938 addi r4,r4,THREAD /* init task's THREAD */
943939 mtspr SPRN_SPRG_THREAD,r4
944−#ifdef CONFIG_PPC_RTAS
945− li r3,0
946− stw r3, RTAS_SP(r4) /* 0 => not in RTAS */
947−#endif
948940 lis r4, (swapper_pg_dir - PAGE_OFFSET)@h
949941 ori r4, r4, (swapper_pg_dir - PAGE_OFFSET)@l
950942 mtspr SPRN_SPRG_PGDIR, r4
arch/powerpc/kernel/vdso32/gettimeofday.S+1−1
@@ -98,7 +98,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime) · 97 unmodified lines
9898 * can be used, r7 contains NSEC_PER_SEC.
9999 */
100100
101− lwz r5,WTOM_CLOCK_SEC(r9)
101+ lwz r5,(WTOM_CLOCK_SEC+LOPART)(r9)
102102 lwz r6,WTOM_CLOCK_NSEC(r9)
103103
104104 /* We now have our offset in r5,r6. We create a fake dependency
arch/riscv/configs/rv32_defconfig+84−0
@@ -0,0 +1,84 @@
1+CONFIG_SYSVIPC=y
2+CONFIG_POSIX_MQUEUE=y
3+CONFIG_IKCONFIG=y
4+CONFIG_IKCONFIG_PROC=y
5+CONFIG_CGROUPS=y
6+CONFIG_CGROUP_SCHED=y
7+CONFIG_CFS_BANDWIDTH=y
8+CONFIG_CGROUP_BPF=y
9+CONFIG_NAMESPACES=y
10+CONFIG_USER_NS=y
11+CONFIG_CHECKPOINT_RESTORE=y
12+CONFIG_BLK_DEV_INITRD=y
13+CONFIG_EXPERT=y
14+CONFIG_BPF_SYSCALL=y
15+CONFIG_ARCH_RV32I=y
16+CONFIG_SMP=y
17+CONFIG_MODULES=y
18+CONFIG_MODULE_UNLOAD=y
19+CONFIG_NET=y
20+CONFIG_PACKET=y
21+CONFIG_UNIX=y
22+CONFIG_INET=y
23+CONFIG_IP_MULTICAST=y
24+CONFIG_IP_ADVANCED_ROUTER=y
25+CONFIG_IP_PNP=y
26+CONFIG_IP_PNP_DHCP=y
27+CONFIG_IP_PNP_BOOTP=y
28+CONFIG_IP_PNP_RARP=y
29+CONFIG_NETLINK_DIAG=y
30+CONFIG_PCI=y
31+CONFIG_PCIEPORTBUS=y
32+CONFIG_PCI_HOST_GENERIC=y
33+CONFIG_PCIE_XILINX=y
34+CONFIG_DEVTMPFS=y
35+CONFIG_BLK_DEV_LOOP=y
36+CONFIG_VIRTIO_BLK=y
37+CONFIG_BLK_DEV_SD=y
38+CONFIG_BLK_DEV_SR=y
39+CONFIG_ATA=y
40+CONFIG_SATA_AHCI=y
41+CONFIG_SATA_AHCI_PLATFORM=y
42+CONFIG_NETDEVICES=y
43+CONFIG_VIRTIO_NET=y
44+CONFIG_MACB=y
45+CONFIG_E1000E=y
46+CONFIG_R8169=y
47+CONFIG_MICROSEMI_PHY=y
48+CONFIG_INPUT_MOUSEDEV=y
49+CONFIG_SERIAL_8250=y
50+CONFIG_SERIAL_8250_CONSOLE=y
51+CONFIG_SERIAL_OF_PLATFORM=y
52+CONFIG_SERIAL_EARLYCON_RISCV_SBI=y
53+CONFIG_HVC_RISCV_SBI=y
54+# CONFIG_PTP_1588_CLOCK is not set
55+CONFIG_DRM=y
56+CONFIG_DRM_RADEON=y
57+CONFIG_FRAMEBUFFER_CONSOLE=y
58+CONFIG_USB=y
59+CONFIG_USB_XHCI_HCD=y
60+CONFIG_USB_XHCI_PLATFORM=y
61+CONFIG_USB_EHCI_HCD=y
62+CONFIG_USB_EHCI_HCD_PLATFORM=y
63+CONFIG_USB_OHCI_HCD=y
64+CONFIG_USB_OHCI_HCD_PLATFORM=y
65+CONFIG_USB_STORAGE=y
66+CONFIG_USB_UAS=y
67+CONFIG_VIRTIO_MMIO=y
68+CONFIG_SIFIVE_PLIC=y
69+CONFIG_EXT4_FS=y
70+CONFIG_EXT4_FS_POSIX_ACL=y
71+CONFIG_AUTOFS4_FS=y
72+CONFIG_MSDOS_FS=y
73+CONFIG_VFAT_FS=y
74+CONFIG_TMPFS=y
75+CONFIG_TMPFS_POSIX_ACL=y
76+CONFIG_NFS_FS=y
77+CONFIG_NFS_V4=y
78+CONFIG_NFS_V4_1=y
79+CONFIG_NFS_V4_2=y
80+CONFIG_ROOT_NFS=y
81+CONFIG_CRYPTO_USER_API_HASH=y
82+CONFIG_CRYPTO_DEV_VIRTIO=y
83+CONFIG_PRINTK_TIME=y
84+# CONFIG_RCU_TRACE is not set
arch/riscv/mm/init.c+8−0
@@ -121,6 +121,14 @@ void __init setup_bootmem(void) · 120 unmodified lines
121121 */
122122 memblock_reserve(reg->base, vmlinux_end - reg->base);
123123 mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
124+
125+ /*
126+ * Remove memblock from the end of usable area to the
127+ * end of region
128+ */
129+ if (reg->base + mem_size < end)
130+ memblock_remove(reg->base + mem_size,
131+ end - reg->base - mem_size);
124132 }
125133 }
126134 BUG_ON(mem_size == 0);
arch/sparc/kernel/pci_sun4v.c+11−9
@@ -73,6 +73,11 @@ static inline void iommu_batch_start(struct device *dev, unsigned long prot, uns · 72 unmodified lines
7373 p->npages = 0;
7474 }
7575
76+static inline bool iommu_use_atu(struct iommu *iommu, u64 mask)
77+{
78+ return iommu->atu && mask > DMA_BIT_MASK(32);
79+}
80+
7681 /* Interrupts must be disabled. */
7782 static long iommu_batch_flush(struct iommu_batch *p, u64 mask)
7883 {
@@ -92,7 +97,7 @@ static long iommu_batch_flush(struct iommu_batch *p, u64 mask) · 13 unmodified lines
9297 prot &= (HV_PCI_MAP_ATTR_READ | HV_PCI_MAP_ATTR_WRITE);
9398
9499 while (npages != 0) {
95− if (mask <= DMA_BIT_MASK(32) || !pbm->iommu->atu) {
100+ if (!iommu_use_atu(pbm->iommu, mask)) {
96101 num = pci_sun4v_iommu_map(devhandle,
97102 HV_PCI_TSBID(0, entry),
98103 npages,
@@ -179,7 +184,6 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size, · 80 unmodified lines
179184 unsigned long flags, order, first_page, npages, n;
180185 unsigned long prot = 0;
181186 struct iommu *iommu;
182− struct atu *atu;
183187 struct iommu_map_table *tbl;
184188 struct page *page;
185189 void *ret;
@@ -205,13 +209,11 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size, · 19 unmodified lines
205209 memset((char *)first_page, 0, PAGE_SIZE << order);
206210
207211 iommu = dev->archdata.iommu;
208− atu = iommu->atu;
209−
210212 mask = dev->coherent_dma_mask;
211− if (mask <= DMA_BIT_MASK(32) || !atu)
213+ if (!iommu_use_atu(iommu, mask))
212214 tbl = &iommu->tbl;
213215 else
214− tbl = &atu->tbl;
216+ tbl = &iommu->atu->tbl;
215217
216218 entry = iommu_tbl_range_alloc(dev, tbl, npages, NULL,
217219 (unsigned long)(-1), 0);
@@ -333,7 +335,7 @@ static void dma_4v_free_coherent(struct device *dev, size_t size, void *cpu, · 115 unmodified lines
333335 atu = iommu->atu;
334336 devhandle = pbm->devhandle;
335337
336− if (dvma <= DMA_BIT_MASK(32)) {
338+ if (!iommu_use_atu(iommu, dvma)) {
337339 tbl = &iommu->tbl;
338340 iotsb_num = 0; /* we don't care for legacy iommu */
339341 } else {
@@ -374,7 +376,7 @@ static dma_addr_t dma_4v_map_page(struct device *dev, struct page *page, · 34 unmodified lines
374376 npages >>= IO_PAGE_SHIFT;
375377
376378 mask = *dev->dma_mask;
377− if (mask <= DMA_BIT_MASK(32))
379+ if (!iommu_use_atu(iommu, mask))
378380 tbl = &iommu->tbl;
379381 else
380382 tbl = &atu->tbl;
@@ -510,7 +512,7 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist, · 129 unmodified lines
510512 IO_PAGE_SIZE) >> IO_PAGE_SHIFT;
511513
512514 mask = *dev->dma_mask;
513− if (mask <= DMA_BIT_MASK(32))
515+ if (!iommu_use_atu(iommu, mask))
514516 tbl = &iommu->tbl;
515517 else
516518 tbl = &atu->tbl;
arch/x86/events/amd/core.c+135−5
@@ -3,10 +3,14 @@ · 2 unmodified lines
33 #include <linux/types.h>
44 #include <linux/init.h>
55 #include <linux/slab.h>
6+#include <linux/delay.h>
67 #include <asm/apicdef.h>
8+#include <asm/nmi.h>
79
810 #include "../perf_event.h"
911
12+static DEFINE_PER_CPU(unsigned int, perf_nmi_counter);
13+
1014 static __initconst const u64 amd_hw_cache_event_ids
1115 [PERF_COUNT_HW_CACHE_MAX]
1216 [PERF_COUNT_HW_CACHE_OP_MAX]
@@ -429,6 +433,132 @@ static void amd_pmu_cpu_dead(int cpu) · 416 unmodified lines
429433 }
430434 }
431435
436+/*
437+ * When a PMC counter overflows, an NMI is used to process the event and
438+ * reset the counter. NMI latency can result in the counter being updated
439+ * before the NMI can run, which can result in what appear to be spurious
440+ * NMIs. This function is intended to wait for the NMI to run and reset
441+ * the counter to avoid possible unhandled NMI messages.
442+ */
443+#define OVERFLOW_WAIT_COUNT 50
444+
445+static void amd_pmu_wait_on_overflow(int idx)
446+{
447+ unsigned int i;
448+ u64 counter;
449+
450+ /*
451+ * Wait for the counter to be reset if it has overflowed. This loop
452+ * should exit very, very quickly, but just in case, don't wait
453+ * forever...
454+ */
455+ for (i = 0; i < OVERFLOW_WAIT_COUNT; i++) {
456+ rdmsrl(x86_pmu_event_addr(idx), counter);
457+ if (counter & (1ULL << (x86_pmu.cntval_bits - 1)))
458+ break;
459+
460+ /* Might be in IRQ context, so can't sleep */
461+ udelay(1);
462+ }
463+}
464+
465+static void amd_pmu_disable_all(void)
466+{
467+ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
468+ int idx;
469+
470+ x86_pmu_disable_all();
471+
472+ /*
473+ * This shouldn't be called from NMI context, but add a safeguard here
474+ * to return, since if we're in NMI context we can't wait for an NMI
475+ * to reset an overflowed counter value.
476+ */
477+ if (in_nmi())
478+ return;
479+
480+ /*
481+ * Check each counter for overflow and wait for it to be reset by the
482+ * NMI if it has overflowed. This relies on the fact that all active
483+ * counters are always enabled when this function is caled and
484+ * ARCH_PERFMON_EVENTSEL_INT is always set.
485+ */
486+ for (idx = 0; idx < x86_pmu.num_counters; idx++) {
487+ if (!test_bit(idx, cpuc->active_mask))
488+ continue;
489+
490+ amd_pmu_wait_on_overflow(idx);
491+ }
492+}
493+
494+static void amd_pmu_disable_event(struct perf_event *event)
495+{
496+ x86_pmu_disable_event(event);
497+
498+ /*
499+ * This can be called from NMI context (via x86_pmu_stop). The counter
500+ * may have overflowed, but either way, we'll never see it get reset
501+ * by the NMI if we're already in the NMI. And the NMI latency support
502+ * below will take care of any pending NMI that might have been
503+ * generated by the overflow.
504+ */
505+ if (in_nmi())
506+ return;
507+
508+ amd_pmu_wait_on_overflow(event->hw.idx);
509+}
510+
511+/*
512+ * Because of NMI latency, if multiple PMC counters are active or other sources
513+ * of NMIs are received, the perf NMI handler can handle one or more overflowed
514+ * PMC counters outside of the NMI associated with the PMC overflow. If the NMI
515+ * doesn't arrive at the LAPIC in time to become a pending NMI, then the kernel
516+ * back-to-back NMI support won't be active. This PMC handler needs to take into
517+ * account that this can occur, otherwise this could result in unknown NMI
518+ * messages being issued. Examples of this is PMC overflow while in the NMI
519+ * handler when multiple PMCs are active or PMC overflow while handling some
520+ * other source of an NMI.
521+ *
522+ * Attempt to mitigate this by using the number of active PMCs to determine
523+ * whether to return NMI_HANDLED if the perf NMI handler did not handle/reset
524+ * any PMCs. The per-CPU perf_nmi_counter variable is set to a minimum of the
525+ * number of active PMCs or 2. The value of 2 is used in case an NMI does not
526+ * arrive at the LAPIC in time to be collapsed into an already pending NMI.
527+ */
528+static int amd_pmu_handle_irq(struct pt_regs *regs)
529+{
530+ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
531+ int active, handled;
532+
533+ /*
534+ * Obtain the active count before calling x86_pmu_handle_irq() since
535+ * it is possible that x86_pmu_handle_irq() may make a counter
536+ * inactive (through x86_pmu_stop).
537+ */
538+ active = __bitmap_weight(cpuc->active_mask, X86_PMC_IDX_MAX);
539+
540+ /* Process any counter overflows */
541+ handled = x86_pmu_handle_irq(regs);
542+
543+ /*
544+ * If a counter was handled, record the number of possible remaining
545+ * NMIs that can occur.
546+ */
547+ if (handled) {
548+ this_cpu_write(perf_nmi_counter,
549+ min_t(unsigned int, 2, active));
550+
551+ return handled;
552+ }
553+
554+ if (!this_cpu_read(perf_nmi_counter))
555+ return NMI_DONE;
556+
557+ this_cpu_dec(perf_nmi_counter);
558+
559+ return NMI_HANDLED;
560+}
561+
432562 static struct event_constraint *
433563 amd_get_event_constraints(struct cpu_hw_events *cpuc, int idx,
434564 struct perf_event *event)
@@ -621,11 +751,11 @@ static ssize_t amd_event_sysfs_show(char *page, u64 config) · 186 unmodified lines
621751
622752 static __initconst const struct x86_pmu amd_pmu = {
623753 .name = "AMD",
624− .handle_irq = x86_pmu_handle_irq,
625− .disable_all = x86_pmu_disable_all,
754+ .handle_irq = amd_pmu_handle_irq,
755+ .disable_all = amd_pmu_disable_all,
626756 .enable_all = x86_pmu_enable_all,
627757 .enable = x86_pmu_enable_event,
628− .disable = x86_pmu_disable_event,
758+ .disable = amd_pmu_disable_event,
629759 .hw_config = amd_pmu_hw_config,
630760 .schedule_events = x86_schedule_events,
631761 .eventsel = MSR_K7_EVNTSEL0,
@@ -732,7 +862,7 @@ void amd_pmu_enable_virt(void) · 100 unmodified lines
732862 cpuc->perf_ctr_virt_mask = 0;
733863
734864 /* Reload all events */
735− x86_pmu_disable_all();
865+ amd_pmu_disable_all();
736866 x86_pmu_enable_all(0);
737867 }
738868 EXPORT_SYMBOL_GPL(amd_pmu_enable_virt);
@@ -750,7 +880,7 @@ void amd_pmu_disable_virt(void) · 11 unmodified lines
750880 cpuc->perf_ctr_virt_mask = AMD64_EVENTSEL_HOSTONLY;
751881
752882 /* Reload all events */
753− x86_pmu_disable_all();
883+ amd_pmu_disable_all();
754884 x86_pmu_enable_all(0);
755885 }
756886 EXPORT_SYMBOL_GPL(amd_pmu_disable_virt);
arch/x86/events/core.c+3−10
@@ -1349,8 +1349,9 @@ void x86_pmu_stop(struct perf_event *event, int flags) · 1348 unmodified lines
13491349 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
13501350 struct hw_perf_event *hwc = &event->hw;
13511351
1352− if (__test_and_clear_bit(hwc->idx, cpuc->active_mask)) {
1352+ if (test_bit(hwc->idx, cpuc->active_mask)) {
13531353 x86_pmu.disable(event);
1354+ __clear_bit(hwc->idx, cpuc->active_mask);
13541355 cpuc->events[hwc->idx] = NULL;
13551356 WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
13561357 hwc->state |= PERF_HES_STOPPED;
@@ -1447,16 +1448,8 @@ int x86_pmu_handle_irq(struct pt_regs *regs) · 90 unmodified lines
14471448 apic_write(APIC_LVTPC, APIC_DM_NMI);
14481449
14491450 for (idx = 0; idx < x86_pmu.num_counters; idx++) {
1450− if (!test_bit(idx, cpuc->active_mask)) {
1451− /*
1452− * Though we deactivated the counter some cpus
1453− * might still deliver spurious interrupts still
1454− * in flight. Catch them:
1455− */
1456− if (__test_and_clear_bit(idx, cpuc->running))
1457− handled++;
1451+ if (!test_bit(idx, cpuc->active_mask))
14581452 continue;
1459− }
14601453
14611454 event = cpuc->events[idx];
14621455
arch/x86/events/intel/core.c+7−1
@@ -3185,7 +3185,7 @@ static int intel_pmu_hw_config(struct perf_event *event) · 3184 unmodified lines
31853185 return ret;
31863186
31873187 if (event->attr.precise_ip) {
3188− if (!event->attr.freq) {
3188+ if (!(event->attr.freq || event->attr.wakeup_events)) {
31893189 event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD;
31903190 if (!(event->attr.sample_type &
31913191 ~intel_pmu_large_pebs_flags(event)))
@@ -3575,6 +3575,12 @@ static void intel_pmu_cpu_starting(int cpu) · 383 unmodified lines
35753575
35763576 cpuc->lbr_sel = NULL;
35773577
3578+ if (x86_pmu.flags & PMU_FL_TFA) {
3579+ WARN_ON_ONCE(cpuc->tfa_shadow);
3580+ cpuc->tfa_shadow = ~0ULL;
3581+ intel_set_tfa(cpuc, false);
3582+ }
3583+
35783584 if (x86_pmu.version > 1)
35793585 flip_smm_bit(&x86_pmu.attr_freeze_on_smi);
35803586
arch/x86/include/asm/bitops.h+18−23
@@ -36,16 +36,17 @@ · 35 unmodified lines
3636 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
3737 */
3838
39−#define BITOP_ADDR(x) "+m" (*(volatile long *) (x))
39+#define RLONG_ADDR(x) "m" (*(volatile long *) (x))
40+#define WBYTE_ADDR(x) "+m" (*(volatile char *) (x))
4041
41−#define ADDR BITOP_ADDR(addr)
42+#define ADDR RLONG_ADDR(addr)
4243
4344 /*
4445 * We do the locked ops that don't return the old value as
4546 * a mask operation on a byte.
4647 */
4748 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
48−#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
49+#define CONST_MASK_ADDR(nr, addr) WBYTE_ADDR((void *)(addr) + ((nr)>>3))
4950 #define CONST_MASK(nr) (1 << ((nr) & 7))
5051
5152 /**
@@ -73,7 +74,7 @@ set_bit(long nr, volatile unsigned long *addr) · 21 unmodified lines
7374 : "memory");
7475 } else {
7576 asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0"
76− : BITOP_ADDR(addr) : "Ir" (nr) : "memory");
77+ : : RLONG_ADDR(addr), "Ir" (nr) : "memory");
7778 }
7879 }
7980
@@ -88,7 +89,7 @@ set_bit(long nr, volatile unsigned long *addr) · 8 unmodified lines
8889 */
8990 static __always_inline void __set_bit(long nr, volatile unsigned long *addr)
9091 {
91− asm volatile(__ASM_SIZE(bts) " %1,%0" : ADDR : "Ir" (nr) : "memory");
92+ asm volatile(__ASM_SIZE(bts) " %1,%0" : : ADDR, "Ir" (nr) : "memory");
9293 }
9394
9495 /**
@@ -110,8 +111,7 @@ clear_bit(long nr, volatile unsigned long *addr) · 15 unmodified lines
110111 : "iq" ((u8)~CONST_MASK(nr)));
111112 } else {
112113 asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0"
113− : BITOP_ADDR(addr)
114− : "Ir" (nr));
114+ : : RLONG_ADDR(addr), "Ir" (nr) : "memory");
115115 }
116116 }
117117
@@ -131,7 +131,7 @@ static __always_inline void clear_bit_unlock(long nr, volatile unsigned long *ad · 13 unmodified lines
131131
132132 static __always_inline void __clear_bit(long nr, volatile unsigned long *addr)
133133 {
134− asm volatile(__ASM_SIZE(btr) " %1,%0" : ADDR : "Ir" (nr));
134+ asm volatile(__ASM_SIZE(btr) " %1,%0" : : ADDR, "Ir" (nr) : "memory");
135135 }
136136
137137 static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile unsigned long *addr)
@@ -139,7 +139,7 @@ static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile · 1 unmodified line
139139 bool negative;
140140 asm volatile(LOCK_PREFIX "andb %2,%1"
141141 CC_SET(s)
142− : CC_OUT(s) (negative), ADDR
142+ : CC_OUT(s) (negative), WBYTE_ADDR(addr)
143143 : "ir" ((char) ~(1 << nr)) : "memory");
144144 return negative;
145145 }
@@ -155,13 +155,9 @@ static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile · 9 unmodified lines
155155 * __clear_bit() is non-atomic and implies release semantics before the memory
156156 * operation. It can be used for an unlock if no other CPUs can concurrently
157157 * modify other bits in the word.
158− *
159− * No memory barrier is required here, because x86 cannot reorder stores past
160− * older loads. Same principle as spin_unlock.
161158 */
162159 static __always_inline void __clear_bit_unlock(long nr, volatile unsigned long *addr)
163160 {
164− barrier();
165161 __clear_bit(nr, addr);
166162 }
167163
@@ -176,7 +172,7 @@ static __always_inline void __clear_bit_unlock(long nr, volatile unsigned long * · 8 unmodified lines
176172 */
177173 static __always_inline void __change_bit(long nr, volatile unsigned long *addr)
178174 {
179− asm volatile(__ASM_SIZE(btc) " %1,%0" : ADDR : "Ir" (nr));
175+ asm volatile(__ASM_SIZE(btc) " %1,%0" : : ADDR, "Ir" (nr) : "memory");
180176 }
181177
182178 /**
@@ -196,8 +192,7 @@ static __always_inline void change_bit(long nr, volatile unsigned long *addr) · 13 unmodified lines
196192 : "iq" ((u8)CONST_MASK(nr)));
197193 } else {
198194 asm volatile(LOCK_PREFIX __ASM_SIZE(btc) " %1,%0"
199− : BITOP_ADDR(addr)
200− : "Ir" (nr));
195+ : : RLONG_ADDR(addr), "Ir" (nr) : "memory");
201196 }
202197 }
203198
@@ -242,8 +237,8 @@ static __always_inline bool __test_and_set_bit(long nr, volatile unsigned long * · 38 unmodified lines
242237
243238 asm(__ASM_SIZE(bts) " %2,%1"
244239 CC_SET(c)
245− : CC_OUT(c) (oldbit), ADDR
246− : "Ir" (nr));
240+ : CC_OUT(c) (oldbit)
241+ : ADDR, "Ir" (nr) : "memory");
247242 return oldbit;
248243 }
249244
@@ -282,8 +277,8 @@ static __always_inline bool __test_and_clear_bit(long nr, volatile unsigned long · 32 unmodified lines
282277
283278 asm volatile(__ASM_SIZE(btr) " %2,%1"
284279 CC_SET(c)
285− : CC_OUT(c) (oldbit), ADDR
286− : "Ir" (nr));
280+ : CC_OUT(c) (oldbit)
281+ : ADDR, "Ir" (nr) : "memory");
287282 return oldbit;
288283 }
289284
@@ -294,8 +289,8 @@ static __always_inline bool __test_and_change_bit(long nr, volatile unsigned lon · 4 unmodified lines
294289
295290 asm volatile(__ASM_SIZE(btc) " %2,%1"
296291 CC_SET(c)
297− : CC_OUT(c) (oldbit), ADDR
298− : "Ir" (nr) : "memory");
292+ : CC_OUT(c) (oldbit)
293+ : ADDR, "Ir" (nr) : "memory");
299294
300295 return oldbit;
301296 }
@@ -326,7 +321,7 @@ static __always_inline bool variable_test_bit(long nr, volatile const unsigned l · 24 unmodified lines
326321 asm volatile(__ASM_SIZE(bt) " %2,%1"
327322 CC_SET(c)
328323 : CC_OUT(c) (oldbit)
329− : "m" (*(unsigned long *)addr), "Ir" (nr));
324+ : "m" (*(unsigned long *)addr), "Ir" (nr) : "memory");
330325
331326 return oldbit;
332327 }
arch/x86/include/asm/kvm_emulate.h+3−1
@@ -226,7 +226,9 @@ struct x86_emulate_ops { · 225 unmodified lines
226226
227227 unsigned (*get_hflags)(struct x86_emulate_ctxt *ctxt);
228228 void (*set_hflags)(struct x86_emulate_ctxt *ctxt, unsigned hflags);
229− int (*pre_leave_smm)(struct x86_emulate_ctxt *ctxt, u64 smbase);
229+ int (*pre_leave_smm)(struct x86_emulate_ctxt *ctxt,
230+ const char *smstate);
231+ void (*post_leave_smm)(struct x86_emulate_ctxt *ctxt);
230232
231233 };
232234
arch/x86/include/asm/kvm_host.h+10−7
@@ -126,7 +126,7 @@ static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level) · 125 unmodified lines
126126 }
127127
128128 #define KVM_PERMILLE_MMU_PAGES 20
129−#define KVM_MIN_ALLOC_MMU_PAGES 64
129+#define KVM_MIN_ALLOC_MMU_PAGES 64UL
130130 #define KVM_MMU_HASH_SHIFT 12
131131 #define KVM_NUM_MMU_PAGES (1 << KVM_MMU_HASH_SHIFT)
132132 #define KVM_MIN_FREE_MMU_PAGES 5
@@ -844,9 +844,9 @@ enum kvm_irqchip_mode { · 711 unmodified lines
844844 };
845845
846846 struct kvm_arch {
847− unsigned int n_used_mmu_pages;
848− unsigned int n_requested_mmu_pages;
849− unsigned int n_max_mmu_pages;
847+ unsigned long n_used_mmu_pages;
848+ unsigned long n_requested_mmu_pages;
849+ unsigned long n_max_mmu_pages;
850850 unsigned int indirect_shadow_pages;
851851 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
852852 /*
@@ -1182,7 +1182,7 @@ struct kvm_x86_ops { · 329 unmodified lines
11821182
11831183 int (*smi_allowed)(struct kvm_vcpu *vcpu);
11841184 int (*pre_enter_smm)(struct kvm_vcpu *vcpu, char *smstate);
1185− int (*pre_leave_smm)(struct kvm_vcpu *vcpu, u64 smbase);
1185+ int (*pre_leave_smm)(struct kvm_vcpu *vcpu, const char *smstate);
11861186 int (*enable_smi_window)(struct kvm_vcpu *vcpu);
11871187
11881188 int (*mem_enc_op)(struct kvm *kvm, void __user *argp);
@@ -1256,8 +1256,8 @@ void kvm_mmu_clear_dirty_pt_masked(struct kvm *kvm, · 67 unmodified lines
12561256 gfn_t gfn_offset, unsigned long mask);
12571257 void kvm_mmu_zap_all(struct kvm *kvm);
12581258 void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen);
1259−unsigned int kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm);
1260−void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
1259+unsigned long kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm);
1260+void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned long kvm_nr_mmu_pages);
12611261
12621262 int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3);
12631263 bool pdptrs_changed(struct kvm_vcpu *vcpu);
@@ -1592,4 +1592,7 @@ static inline int kvm_cpu_get_apicid(int mps_cpu) · 328 unmodified lines
15921592 #define put_smstate(type, buf, offset, val) \
15931593 *(type *)((buf) + (offset) - 0x7e00) = val
15941594
1595+#define GET_SMSTATE(type, buf, offset) \
1596+ (*(type *)((buf) + (offset) - 0x7e00))
1597+
15951598 #endif /* _ASM_X86_KVM_HOST_H */
arch/x86/include/uapi/asm/vmx.h+1−0
@@ -146,6 +146,7 @@ · 145 unmodified lines
146146
147147 #define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
148148 #define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2
149+#define VMX_ABORT_VMCS_CORRUPTED 3
149150 #define VMX_ABORT_LOAD_HOST_MSR_FAIL 4
150151
151152 #endif /* _UAPIVMX_H */
arch/x86/kernel/cpu/resctrl/rdtgroup.c+3−3
@@ -2039,14 +2039,14 @@ out: · 2038 unmodified lines
20392039 enum rdt_param {
20402040 Opt_cdp,
20412041 Opt_cdpl2,
2042− Opt_mba_mpbs,
2042+ Opt_mba_mbps,
20432043 nr__rdt_params
20442044 };
20452045
20462046 static const struct fs_parameter_spec rdt_param_specs[] = {
20472047 fsparam_flag("cdp", Opt_cdp),
20482048 fsparam_flag("cdpl2", Opt_cdpl2),
2049− fsparam_flag("mba_mpbs", Opt_mba_mpbs),
2049+ fsparam_flag("mba_MBps", Opt_mba_mbps),
20502050 {}
20512051 };
20522052
@@ -2072,7 +2072,7 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param) · 19 unmodified lines
20722072 case Opt_cdpl2:
20732073 ctx->enable_cdpl2 = true;
20742074 return 0;
2075− case Opt_mba_mpbs:
2075+ case Opt_mba_mbps:
20762076 if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
20772077 return -EINVAL;
20782078 ctx->enable_mba_mbps = true;
arch/x86/kvm/emulate.c+102−89
@@ -2331,24 +2331,18 @@ static int em_lseg(struct x86_emulate_ctxt *ctxt) · 2330 unmodified lines
23312331
23322332 static int emulator_has_longmode(struct x86_emulate_ctxt *ctxt)
23332333 {
2334+#ifdef CONFIG_X86_64
23342335 u32 eax, ebx, ecx, edx;
23352336
23362337 eax = 0x80000001;
23372338 ecx = 0;
23382339 ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx, false);
23392340 return edx & bit(X86_FEATURE_LM);
2341+#else
2342+ return false;
2343+#endif
23402344 }
23412345
2342−#define GET_SMSTATE(type, smbase, offset) \
2343− ({ \
2344− type __val; \
2345− int r = ctxt->ops->read_phys(ctxt, smbase + offset, &__val, \
2346− sizeof(__val)); \
2347− if (r != X86EMUL_CONTINUE) \
2348− return X86EMUL_UNHANDLEABLE; \
2349− __val; \
2350− })
2351−
23522346 static void rsm_set_desc_flags(struct desc_struct *desc, u32 flags)
23532347 {
23542348 desc->g = (flags >> 23) & 1;
@@ -2361,27 +2355,30 @@ static void rsm_set_desc_flags(struct desc_struct *desc, u32 flags) · 6 unmodified lines
23612355 desc->type = (flags >> 8) & 15;
23622356 }
23632357
2364−static int rsm_load_seg_32(struct x86_emulate_ctxt *ctxt, u64 smbase, int n)
2358+static int rsm_load_seg_32(struct x86_emulate_ctxt *ctxt, const char *smstate,
2359+ int n)
23652360 {
23662361 struct desc_struct desc;
23672362 int offset;
23682363 u16 selector;
23692364
2370− selector = GET_SMSTATE(u32, smbase, 0x7fa8 + n * 4);
2365+ selector = GET_SMSTATE(u32, smstate, 0x7fa8 + n * 4);
23712366
23722367 if (n < 3)
23732368 offset = 0x7f84 + n * 12;
23742369 else
23752370 offset = 0x7f2c + (n - 3) * 12;
23762371
2377− set_desc_base(&desc, GET_SMSTATE(u32, smbase, offset + 8));
2378− set_desc_limit(&desc, GET_SMSTATE(u32, smbase, offset + 4));
2379− rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, offset));
2372+ set_desc_base(&desc, GET_SMSTATE(u32, smstate, offset + 8));
2373+ set_desc_limit(&desc, GET_SMSTATE(u32, smstate, offset + 4));
2374+ rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, offset));
23802375 ctxt->ops->set_segment(ctxt, selector, &desc, 0, n);
23812376 return X86EMUL_CONTINUE;
23822377 }
23832378
2384−static int rsm_load_seg_64(struct x86_emulate_ctxt *ctxt, u64 smbase, int n)
2379+#ifdef CONFIG_X86_64
2380+static int rsm_load_seg_64(struct x86_emulate_ctxt *ctxt, const char *smstate,
2381+ int n)
23852382 {
23862383 struct desc_struct desc;
23872384 int offset;
@@ -2390,15 +2387,16 @@ static int rsm_load_seg_64(struct x86_emulate_ctxt *ctxt, u64 smbase, int n) · 2 unmodified lines
23902387
23912388 offset = 0x7e00 + n * 16;
23922389
2393− selector = GET_SMSTATE(u16, smbase, offset);
2394− rsm_set_desc_flags(&desc, GET_SMSTATE(u16, smbase, offset + 2) << 8);
2395− set_desc_limit(&desc, GET_SMSTATE(u32, smbase, offset + 4));
2396− set_desc_base(&desc, GET_SMSTATE(u32, smbase, offset + 8));
2397− base3 = GET_SMSTATE(u32, smbase, offset + 12);
2390+ selector = GET_SMSTATE(u16, smstate, offset);
2391+ rsm_set_desc_flags(&desc, GET_SMSTATE(u16, smstate, offset + 2) << 8);
2392+ set_desc_limit(&desc, GET_SMSTATE(u32, smstate, offset + 4));
2393+ set_desc_base(&desc, GET_SMSTATE(u32, smstate, offset + 8));
2394+ base3 = GET_SMSTATE(u32, smstate, offset + 12);
23982395
23992396 ctxt->ops->set_segment(ctxt, selector, &desc, base3, n);
24002397 return X86EMUL_CONTINUE;
24012398 }
2399+#endif
24022400
24032401 static int rsm_enter_protected_mode(struct x86_emulate_ctxt *ctxt,
24042402 u64 cr0, u64 cr3, u64 cr4)
@@ -2445,7 +2443,8 @@ static int rsm_enter_protected_mode(struct x86_emulate_ctxt *ctxt, · 40 unmodified lines
24452443 return X86EMUL_CONTINUE;
24462444 }
24472445
2448−static int rsm_load_state_32(struct x86_emulate_ctxt *ctxt, u64 smbase)
2446+static int rsm_load_state_32(struct x86_emulate_ctxt *ctxt,
2447+ const char *smstate)
24492448 {
24502449 struct desc_struct desc;
24512450 struct desc_ptr dt;
@@ -2453,53 +2452,55 @@ static int rsm_load_state_32(struct x86_emulate_ctxt *ctxt, u64 smbase) · 1 unmodified line
24532452 u32 val, cr0, cr3, cr4;
24542453 int i;
24552454
2456− cr0 = GET_SMSTATE(u32, smbase, 0x7ffc);
2457− cr3 = GET_SMSTATE(u32, smbase, 0x7ff8);
2458− ctxt->eflags = GET_SMSTATE(u32, smbase, 0x7ff4) | X86_EFLAGS_FIXED;
2459− ctxt->_eip = GET_SMSTATE(u32, smbase, 0x7ff0);
2455+ cr0 = GET_SMSTATE(u32, smstate, 0x7ffc);
2456+ cr3 = GET_SMSTATE(u32, smstate, 0x7ff8);
2457+ ctxt->eflags = GET_SMSTATE(u32, smstate, 0x7ff4) | X86_EFLAGS_FIXED;
2458+ ctxt->_eip = GET_SMSTATE(u32, smstate, 0x7ff0);
24602459
24612460 for (i = 0; i < 8; i++)
2462− *reg_write(ctxt, i) = GET_SMSTATE(u32, smbase, 0x7fd0 + i * 4);
2461+ *reg_write(ctxt, i) = GET_SMSTATE(u32, smstate, 0x7fd0 + i * 4);
24632462
2464− val = GET_SMSTATE(u32, smbase, 0x7fcc);
2463+ val = GET_SMSTATE(u32, smstate, 0x7fcc);
24652464 ctxt->ops->set_dr(ctxt, 6, (val & DR6_VOLATILE) | DR6_FIXED_1);
2466− val = GET_SMSTATE(u32, smbase, 0x7fc8);
2465+ val = GET_SMSTATE(u32, smstate, 0x7fc8);
24672466 ctxt->ops->set_dr(ctxt, 7, (val & DR7_VOLATILE) | DR7_FIXED_1);
24682467
2469− selector = GET_SMSTATE(u32, smbase, 0x7fc4);
2470− set_desc_base(&desc, GET_SMSTATE(u32, smbase, 0x7f64));
2471− set_desc_limit(&desc, GET_SMSTATE(u32, smbase, 0x7f60));
2472− rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, 0x7f5c));
2468+ selector = GET_SMSTATE(u32, smstate, 0x7fc4);
2469+ set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7f64));
2470+ set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7f60));
2471+ rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7f5c));
24732472 ctxt->ops->set_segment(ctxt, selector, &desc, 0, VCPU_SREG_TR);
24742473
2475− selector = GET_SMSTATE(u32, smbase, 0x7fc0);
2476− set_desc_base(&desc, GET_SMSTATE(u32, smbase, 0x7f80));
2477− set_desc_limit(&desc, GET_SMSTATE(u32, smbase, 0x7f7c));
2478− rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, 0x7f78));
2474+ selector = GET_SMSTATE(u32, smstate, 0x7fc0);
2475+ set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7f80));
2476+ set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7f7c));
2477+ rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7f78));
24792478 ctxt->ops->set_segment(ctxt, selector, &desc, 0, VCPU_SREG_LDTR);
24802479
2481− dt.address = GET_SMSTATE(u32, smbase, 0x7f74);
2482− dt.size = GET_SMSTATE(u32, smbase, 0x7f70);
2480+ dt.address = GET_SMSTATE(u32, smstate, 0x7f74);
2481+ dt.size = GET_SMSTATE(u32, smstate, 0x7f70);
24832482 ctxt->ops->set_gdt(ctxt, &dt);
24842483
2485− dt.address = GET_SMSTATE(u32, smbase, 0x7f58);
2486− dt.size = GET_SMSTATE(u32, smbase, 0x7f54);
2484+ dt.address = GET_SMSTATE(u32, smstate, 0x7f58);
2485+ dt.size = GET_SMSTATE(u32, smstate, 0x7f54);
24872486 ctxt->ops->set_idt(ctxt, &dt);
24882487
24892488 for (i = 0; i < 6; i++) {
2490− int r = rsm_load_seg_32(ctxt, smbase, i);
2489+ int r = rsm_load_seg_32(ctxt, smstate, i);
24912490 if (r != X86EMUL_CONTINUE)
24922491 return r;
24932492 }
24942493
2495− cr4 = GET_SMSTATE(u32, smbase, 0x7f14);
2494+ cr4 = GET_SMSTATE(u32, smstate, 0x7f14);
24962495
2497− ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smbase, 0x7ef8));
2496+ ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smstate, 0x7ef8));
24982497
24992498 return rsm_enter_protected_mode(ctxt, cr0, cr3, cr4);
25002499 }
25012500
2502−static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt, u64 smbase)
2501+#ifdef CONFIG_X86_64
2502+static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt,
2503+ const char *smstate)
25032504 {
25042505 struct desc_struct desc;
25052506 struct desc_ptr dt;
@@ -2509,43 +2510,43 @@ static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt, u64 smbase) · 3 unmodified lines
25092510 int i, r;
25102511
25112512 for (i = 0; i < 16; i++)
2512− *reg_write(ctxt, i) = GET_SMSTATE(u64, smbase, 0x7ff8 - i * 8);
2513+ *reg_write(ctxt, i) = GET_SMSTATE(u64, smstate, 0x7ff8 - i * 8);
25132514
2514− ctxt->_eip = GET_SMSTATE(u64, smbase, 0x7f78);
2515− ctxt->eflags = GET_SMSTATE(u32, smbase, 0x7f70) | X86_EFLAGS_FIXED;
2515+ ctxt->_eip = GET_SMSTATE(u64, smstate, 0x7f78);
2516+ ctxt->eflags = GET_SMSTATE(u32, smstate, 0x7f70) | X86_EFLAGS_FIXED;
25162517
2517− val = GET_SMSTATE(u32, smbase, 0x7f68);
2518+ val = GET_SMSTATE(u32, smstate, 0x7f68);
25182519 ctxt->ops->set_dr(ctxt, 6, (val & DR6_VOLATILE) | DR6_FIXED_1);
2519− val = GET_SMSTATE(u32, smbase, 0x7f60);
2520+ val = GET_SMSTATE(u32, smstate, 0x7f60);
25202521 ctxt->ops->set_dr(ctxt, 7, (val & DR7_VOLATILE) | DR7_FIXED_1);
25212522
2522− cr0 = GET_SMSTATE(u64, smbase, 0x7f58);
2523− cr3 = GET_SMSTATE(u64, smbase, 0x7f50);
2524− cr4 = GET_SMSTATE(u64, smbase, 0x7f48);
2525− ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smbase, 0x7f00));
2526− val = GET_SMSTATE(u64, smbase, 0x7ed0);
2523+ cr0 = GET_SMSTATE(u64, smstate, 0x7f58);
2524+ cr3 = GET_SMSTATE(u64, smstate, 0x7f50);
2525+ cr4 = GET_SMSTATE(u64, smstate, 0x7f48);
2526+ ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smstate, 0x7f00));
2527+ val = GET_SMSTATE(u64, smstate, 0x7ed0);
25272528 ctxt->ops->set_msr(ctxt, MSR_EFER, val & ~EFER_LMA);
25282529
2529− selector = GET_SMSTATE(u32, smbase, 0x7e90);
2530− rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, 0x7e92) << 8);
2531− set_desc_limit(&desc, GET_SMSTATE(u32, smbase, 0x7e94));
2532− set_desc_base(&desc, GET_SMSTATE(u32, smbase, 0x7e98));
2533− base3 = GET_SMSTATE(u32, smbase, 0x7e9c);
2530+ selector = GET_SMSTATE(u32, smstate, 0x7e90);
2531+ rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7e92) << 8);
2532+ set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7e94));
2533+ set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7e98));
2534+ base3 = GET_SMSTATE(u32, smstate, 0x7e9c);
25342535 ctxt->ops->set_segment(ctxt, selector, &desc, base3, VCPU_SREG_TR);
25352536
2536− dt.size = GET_SMSTATE(u32, smbase, 0x7e84);
2537− dt.address = GET_SMSTATE(u64, smbase, 0x7e88);
2537+ dt.size = GET_SMSTATE(u32, smstate, 0x7e84);
2538+ dt.address = GET_SMSTATE(u64, smstate, 0x7e88);
25382539 ctxt->ops->set_idt(ctxt, &dt);
25392540
2540− selector = GET_SMSTATE(u32, smbase, 0x7e70);
2541− rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, 0x7e72) << 8);
2542− set_desc_limit(&desc, GET_SMSTATE(u32, smbase, 0x7e74));
2543− set_desc_base(&desc, GET_SMSTATE(u32, smbase, 0x7e78));
2544− base3 = GET_SMSTATE(u32, smbase, 0x7e7c);
2541+ selector = GET_SMSTATE(u32, smstate, 0x7e70);
2542+ rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7e72) << 8);
2543+ set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7e74));
2544+ set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7e78));
2545+ base3 = GET_SMSTATE(u32, smstate, 0x7e7c);
25452546 ctxt->ops->set_segment(ctxt, selector, &desc, base3, VCPU_SREG_LDTR);
25462547
2547− dt.size = GET_SMSTATE(u32, smbase, 0x7e64);
2548− dt.address = GET_SMSTATE(u64, smbase, 0x7e68);
2548+ dt.size = GET_SMSTATE(u32, smstate, 0x7e64);
2549+ dt.address = GET_SMSTATE(u64, smstate, 0x7e68);
25492550 ctxt->ops->set_gdt(ctxt, &dt);
25502551
25512552 r = rsm_enter_protected_mode(ctxt, cr0, cr3, cr4);
@@ -2553,37 +2554,49 @@ static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt, u64 smbase) · 1 unmodified line
25532554 return r;
25542555
25552556 for (i = 0; i < 6; i++) {
2556− r = rsm_load_seg_64(ctxt, smbase, i);
2557+ r = rsm_load_seg_64(ctxt, smstate, i);
25572558 if (r != X86EMUL_CONTINUE)
25582559 return r;
25592560 }
25602561
25612562 return X86EMUL_CONTINUE;
25622563 }
2564+#endif
25632565
25642566 static int em_rsm(struct x86_emulate_ctxt *ctxt)
25652567 {
25662568 unsigned long cr0, cr4, efer;
2569+ char buf[512];
25672570 u64 smbase;
25682571 int ret;
25692572
25702573 if ((ctxt->ops->get_hflags(ctxt) & X86EMUL_SMM_MASK) == 0)
25712574 return emulate_ud(ctxt);
25722575
2576+ smbase = ctxt->ops->get_smbase(ctxt);
2577+
2578+ ret = ctxt->ops->read_phys(ctxt, smbase + 0xfe00, buf, sizeof(buf));
2579+ if (ret != X86EMUL_CONTINUE)
2580+ return X86EMUL_UNHANDLEABLE;
2581+
2582+ if ((ctxt->ops->get_hflags(ctxt) & X86EMUL_SMM_INSIDE_NMI_MASK) == 0)
2583+ ctxt->ops->set_nmi_mask(ctxt, false);
2584+
2585+ ctxt->ops->set_hflags(ctxt, ctxt->ops->get_hflags(ctxt) &
2586+ ~(X86EMUL_SMM_INSIDE_NMI_MASK | X86EMUL_SMM_MASK));
2587+
25732588 /*
25742589 * Get back to real mode, to prepare a safe state in which to load
25752590 * CR0/CR3/CR4/EFER. It's all a bit more complicated if the vCPU
25762591 * supports long mode.
25772592 */
2578− cr4 = ctxt->ops->get_cr(ctxt, 4);
25792593 if (emulator_has_longmode(ctxt)) {
25802594 struct desc_struct cs_desc;
25812595
25822596 /* Zero CR4.PCIDE before CR0.PG. */
2583− if (cr4 & X86_CR4_PCIDE) {
2597+ cr4 = ctxt->ops->get_cr(ctxt, 4);
2598+ if (cr4 & X86_CR4_PCIDE)
25842599 ctxt->ops->set_cr(ctxt, 4, cr4 & ~X86_CR4_PCIDE);
2585− cr4 &= ~X86_CR4_PCIDE;
2586− }
25872600
25882601 /* A 32-bit code segment is required to clear EFER.LMA. */
25892602 memset(&cs_desc, 0, sizeof(cs_desc));
@@ -2597,39 +2610,39 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt) · 7 unmodified lines
25972610 if (cr0 & X86_CR0_PE)
25982611 ctxt->ops->set_cr(ctxt, 0, cr0 & ~(X86_CR0_PG | X86_CR0_PE));
25992612
2600− /* Now clear CR4.PAE (which must be done before clearing EFER.LME). */
2601− if (cr4 & X86_CR4_PAE)
2602− ctxt->ops->set_cr(ctxt, 4, cr4 & ~X86_CR4_PAE);
2603−
2604− /* And finally go back to 32-bit mode. */
2605− efer = 0;
2606− ctxt->ops->set_msr(ctxt, MSR_EFER, efer);
2613+ if (emulator_has_longmode(ctxt)) {
2614+ /* Clear CR4.PAE before clearing EFER.LME. */
2615+ cr4 = ctxt->ops->get_cr(ctxt, 4);
2616+ if (cr4 & X86_CR4_PAE)
2617+ ctxt->ops->set_cr(ctxt, 4, cr4 & ~X86_CR4_PAE);
26072618
2608− smbase = ctxt->ops->get_smbase(ctxt);
2619+ /* And finally go back to 32-bit mode. */
2620+ efer = 0;
2621+ ctxt->ops->set_msr(ctxt, MSR_EFER, efer);
2622+ }
26092623
26102624 /*
26112625 * Give pre_leave_smm() a chance to make ISA-specific changes to the
26122626 * vCPU state (e.g. enter guest mode) before loading state from the SMM
26132627 * state-save area.
26142628 */
2615− if (ctxt->ops->pre_leave_smm(ctxt, smbase))
2629+ if (ctxt->ops->pre_leave_smm(ctxt, buf))
26162630 return X86EMUL_UNHANDLEABLE;
26172631
2632+#ifdef CONFIG_X86_64
26182633 if (emulator_has_longmode(ctxt))
2619− ret = rsm_load_state_64(ctxt, smbase + 0x8000);
2634+ ret = rsm_load_state_64(ctxt, buf);
26202635 else
2621− ret = rsm_load_state_32(ctxt, smbase + 0x8000);
2636+#endif
2637+ ret = rsm_load_state_32(ctxt, buf);
26222638
26232639 if (ret != X86EMUL_CONTINUE) {
26242640 /* FIXME: should triple fault */
26252641 return X86EMUL_UNHANDLEABLE;
26262642 }
26272643
2628− if ((ctxt->ops->get_hflags(ctxt) & X86EMUL_SMM_INSIDE_NMI_MASK) == 0)
2629− ctxt->ops->set_nmi_mask(ctxt, false);
2644+ ctxt->ops->post_leave_smm(ctxt);
26302645
2631− ctxt->ops->set_hflags(ctxt, ctxt->ops->get_hflags(ctxt) &
2632− ~(X86EMUL_SMM_INSIDE_NMI_MASK | X86EMUL_SMM_MASK));
26332646 return X86EMUL_CONTINUE;
26342647 }
26352648
arch/x86/kvm/lapic.c+3−1
@@ -138,6 +138,7 @@ static inline bool kvm_apic_map_get_logical_dest(struct kvm_apic_map *map, · 137 unmodified lines
138138 if (offset <= max_apic_id) {
139139 u8 cluster_size = min(max_apic_id - offset + 1, 16U);
140140
141+ offset = array_index_nospec(offset, map->max_apic_id + 1);
141142 *cluster = &map->phys_map[offset];
142143 *mask = dest_id & (0xffff >> (16 - cluster_size));
143144 } else {
@@ -901,7 +902,8 @@ static inline bool kvm_apic_map_get_dest_lapic(struct kvm *kvm, · 757 unmodified lines
901902 if (irq->dest_id > map->max_apic_id) {
902903 *bitmap = 0;
903904 } else {
904− *dst = &map->phys_map[irq->dest_id];
905+ u32 dest_id = array_index_nospec(irq->dest_id, map->max_apic_id + 1);
906+ *dst = &map->phys_map[dest_id];
905907 *bitmap = 1;
906908 }
907909 return true;
arch/x86/kvm/mmu.c+7−8
@@ -2007,7 +2007,7 @@ static int is_empty_shadow_page(u64 *spt) · 2006 unmodified lines
20072007 * aggregate version in order to make the slab shrinker
20082008 * faster
20092009 */
2010−static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, int nr)
2010+static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, unsigned long nr)
20112011 {
20122012 kvm->arch.n_used_mmu_pages += nr;
20132013 percpu_counter_add(&kvm_total_used_mmu_pages, nr);
@@ -2238,7 +2238,7 @@ static bool kvm_mmu_remote_flush_or_zap(struct kvm *kvm, · 224 unmodified lines
22382238 struct list_head *invalid_list,
22392239 bool remote_flush)
22402240 {
2241− if (!remote_flush && !list_empty(invalid_list))
2241+ if (!remote_flush && list_empty(invalid_list))
22422242 return false;
22432243
22442244 if (!list_empty(invalid_list))
@@ -2763,7 +2763,7 @@ static bool prepare_zap_oldest_mmu_page(struct kvm *kvm, · 518 unmodified lines
27632763 * Changing the number of mmu pages allocated to the vm
27642764 * Note: if goal_nr_mmu_pages is too small, you will get dead lock
27652765 */
2766−void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int goal_nr_mmu_pages)
2766+void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned long goal_nr_mmu_pages)
27672767 {
27682768 LIST_HEAD(invalid_list);
27692769
@@ -6031,10 +6031,10 @@ out: · 3261 unmodified lines
60316031 /*
60326032 * Calculate mmu pages needed for kvm.
60336033 */
6034−unsigned int kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm)
6034+unsigned long kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm)
60356035 {
6036− unsigned int nr_mmu_pages;
6037− unsigned int nr_pages = 0;
6036+ unsigned long nr_mmu_pages;
6037+ unsigned long nr_pages = 0;
60386038 struct kvm_memslots *slots;
60396039 struct kvm_memory_slot *memslot;
60406040 int i;
@@ -6047,8 +6047,7 @@ unsigned int kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm) · 6 unmodified lines
60476047 }
60486048
60496049 nr_mmu_pages = nr_pages * KVM_PERMILLE_MMU_PAGES / 1000;
6050− nr_mmu_pages = max(nr_mmu_pages,
6051− (unsigned int) KVM_MIN_ALLOC_MMU_PAGES);
6050+ nr_mmu_pages = max(nr_mmu_pages, KVM_MIN_ALLOC_MMU_PAGES);
60526051
60536052 return nr_mmu_pages;
60546053 }
arch/x86/kvm/mmu.h+1−1
@@ -64,7 +64,7 @@ bool kvm_can_do_async_pf(struct kvm_vcpu *vcpu); · 63 unmodified lines
6464 int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code,
6565 u64 fault_address, char *insn, int insn_len);
6666
67−static inline unsigned int kvm_mmu_available_pages(struct kvm *kvm)
67+static inline unsigned long kvm_mmu_available_pages(struct kvm *kvm)
6868 {
6969 if (kvm->arch.n_max_mmu_pages > kvm->arch.n_used_mmu_pages)
7070 return kvm->arch.n_max_mmu_pages -
arch/x86/kvm/pmu.c+4−0
@@ -281,9 +281,13 @@ static int kvm_pmu_rdpmc_vmware(struct kvm_vcpu *vcpu, unsigned idx, u64 *data) · 280 unmodified lines
281281 int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned idx, u64 *data)
282282 {
283283 bool fast_mode = idx & (1u << 31);
284+ struct kvm_pmu *pmu = vcpu_to_pmu(vcpu);
284285 struct kvm_pmc *pmc;
285286 u64 ctr_val;
286287
288+ if (!pmu->version)
289+ return 1;
290+
287291 if (is_vmware_backdoor_pmc(idx))
288292 return kvm_pmu_rdpmc_vmware(vcpu, idx, data);
289293
arch/x86/kvm/svm.c+33−24
@@ -262,6 +262,7 @@ struct amd_svm_iommu_ir { · 261 unmodified lines
262262 };
263263
264264 #define AVIC_LOGICAL_ID_ENTRY_GUEST_PHYSICAL_ID_MASK (0xFF)
265+#define AVIC_LOGICAL_ID_ENTRY_VALID_BIT 31
265266 #define AVIC_LOGICAL_ID_ENTRY_VALID_MASK (1 << 31)
266267
267268 #define AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK (0xFFULL)
@@ -2692,6 +2693,7 @@ static int npf_interception(struct vcpu_svm *svm) · 2424 unmodified lines
26922693 static int db_interception(struct vcpu_svm *svm)
26932694 {
26942695 struct kvm_run *kvm_run = svm->vcpu.run;
2696+ struct kvm_vcpu *vcpu = &svm->vcpu;
26952697
26962698 if (!(svm->vcpu.guest_debug &
26972699 (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) &&
@@ -2702,6 +2704,8 @@ static int db_interception(struct vcpu_svm *svm) · 4 unmodified lines
27022704
27032705 if (svm->nmi_singlestep) {
27042706 disable_nmi_singlestep(svm);
2707+ /* Make sure we check for pending NMIs upon entry */
2708+ kvm_make_request(KVM_REQ_EVENT, vcpu);
27052709 }
27062710
27072711 if (svm->vcpu.guest_debug &
@@ -4517,14 +4521,25 @@ static int avic_incomplete_ipi_interception(struct vcpu_svm *svm) · 1809 unmodified lines
45174521 kvm_lapic_reg_write(apic, APIC_ICR, icrl);
45184522 break;
45194523 case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: {
4524+ int i;
4525+ struct kvm_vcpu *vcpu;
4526+ struct kvm *kvm = svm->vcpu.kvm;
45204527 struct kvm_lapic *apic = svm->vcpu.arch.apic;
45214528
45224529 /*
4523− * Update ICR high and low, then emulate sending IPI,
4524− * which is handled when writing APIC_ICR.
4530+ * At this point, we expect that the AVIC HW has already
4531+ * set the appropriate IRR bits on the valid target
4532+ * vcpus. So, we just need to kick the appropriate vcpu.
45254533 */
4526− kvm_lapic_reg_write(apic, APIC_ICR2, icrh);
4527− kvm_lapic_reg_write(apic, APIC_ICR, icrl);
4534+ kvm_for_each_vcpu(i, vcpu, kvm) {
4535+ bool m = kvm_apic_match_dest(vcpu, apic,
4536+ icrl & KVM_APIC_SHORT_MASK,
4537+ GET_APIC_DEST_FIELD(icrh),
4538+ icrl & KVM_APIC_DEST_MASK);
4539+
4540+ if (m && !avic_vcpu_is_running(vcpu))
4541+ kvm_vcpu_wake_up(vcpu);
4542+ }
45284543 break;
45294544 }
45304545 case AVIC_IPI_FAILURE_INVALID_TARGET:
@@ -4596,7 +4611,7 @@ static void avic_invalidate_logical_id_entry(struct kvm_vcpu *vcpu) · 65 unmodified lines
45964611 u32 *entry = avic_get_logical_id_entry(vcpu, svm->ldr_reg, flat);
45974612
45984613 if (entry)
4599− WRITE_ONCE(*entry, (u32) ~AVIC_LOGICAL_ID_ENTRY_VALID_MASK);
4614+ clear_bit(AVIC_LOGICAL_ID_ENTRY_VALID_BIT, (unsigned long *)entry);
46004615 }
46014616
46024617 static int avic_handle_ldr_update(struct kvm_vcpu *vcpu)
@@ -5621,6 +5636,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) · 1018 unmodified lines
56215636 svm->vmcb->save.cr2 = vcpu->arch.cr2;
56225637
56235638 clgi();
5639+ kvm_load_guest_xcr0(vcpu);
56245640
56255641 /*
56265642 * If this vCPU has touched SPEC_CTRL, restore the guest's value if
@@ -5766,6 +5782,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) · 139 unmodified lines
57665782 if (unlikely(svm->vmcb->control.exit_code == SVM_EXIT_NMI))
57675783 kvm_before_interrupt(&svm->vcpu);
57685784
5785+ kvm_put_guest_xcr0(vcpu);
57695786 stgi();
57705787
57715788 /* Any pending NMI will happen here */
@@ -6215,32 +6232,24 @@ static int svm_pre_enter_smm(struct kvm_vcpu *vcpu, char *smstate) · 443 unmodified lines
62156232 return 0;
62166233 }
62176234
6218−static int svm_pre_leave_smm(struct kvm_vcpu *vcpu, u64 smbase)
6235+static int svm_pre_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
62196236 {
62206237 struct vcpu_svm *svm = to_svm(vcpu);
62216238 struct vmcb *nested_vmcb;
62226239 struct page *page;
6223− struct {
6224− u64 guest;
6225− u64 vmcb;
6226− } svm_state_save;
6227− int ret;
6240+ u64 guest;
6241+ u64 vmcb;
62286242
6229− ret = kvm_vcpu_read_guest(vcpu, smbase + 0xfed8, &svm_state_save,
6230− sizeof(svm_state_save));
6231− if (ret)
6232− return ret;
6243+ guest = GET_SMSTATE(u64, smstate, 0x7ed8);
6244+ vmcb = GET_SMSTATE(u64, smstate, 0x7ee0);
62336245
6234− if (svm_state_save.guest) {
6235− vcpu->arch.hflags &= ~HF_SMM_MASK;
6236− nested_vmcb = nested_svm_map(svm, svm_state_save.vmcb, &page);
6237− if (nested_vmcb)
6238− enter_svm_guest_mode(svm, svm_state_save.vmcb, nested_vmcb, page);
6239− else
6240− ret = 1;
6241− vcpu->arch.hflags |= HF_SMM_MASK;
6246+ if (guest) {
6247+ nested_vmcb = nested_svm_map(svm, vmcb, &page);
6248+ if (!nested_vmcb)
6249+ return 1;
6250+ enter_svm_guest_mode(svm, vmcb, nested_vmcb, page);
62426251 }
6243− return ret;
6252+ return 0;
62446253 }
62456254
62466255 static int enable_smi_window(struct kvm_vcpu *vcpu)
arch/x86/kvm/trace.h+2−2
@@ -438,13 +438,13 @@ TRACE_EVENT(kvm_apic_ipi, · 437 unmodified lines
438438 );
439439
440440 TRACE_EVENT(kvm_apic_accept_irq,
441− TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec),
441+ TP_PROTO(__u32 apicid, __u16 dm, __u16 tm, __u8 vec),
442442 TP_ARGS(apicid, dm, tm, vec),
443443
444444 TP_STRUCT__entry(
445445 __field( __u32, apicid )
446446 __field( __u16, dm )
447− __field( __u8, tm )
447+ __field( __u16, tm )
448448 __field( __u8, vec )
449449 ),
450450
arch/x86/kvm/vmx/nested.c+36−11
@@ -2873,20 +2873,27 @@ static void nested_get_vmcs12_pages(struct kvm_vcpu *vcpu) · 2872 unmodified lines
28732873 /*
28742874 * If translation failed, VM entry will fail because
28752875 * prepare_vmcs02 set VIRTUAL_APIC_PAGE_ADDR to -1ull.
2876− * Failing the vm entry is _not_ what the processor
2877− * does but it's basically the only possibility we
2878− * have. We could still enter the guest if CR8 load
2879− * exits are enabled, CR8 store exits are enabled, and
2880− * virtualize APIC access is disabled; in this case
2881− * the processor would never use the TPR shadow and we
2882− * could simply clear the bit from the execution
2883− * control. But such a configuration is useless, so
2884− * let's keep the code simple.
28852876 */
28862877 if (!is_error_page(page)) {
28872878 vmx->nested.virtual_apic_page = page;
28882879 hpa = page_to_phys(vmx->nested.virtual_apic_page);
28892880 vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, hpa);
2881+ } else if (nested_cpu_has(vmcs12, CPU_BASED_CR8_LOAD_EXITING) &&
2882+ nested_cpu_has(vmcs12, CPU_BASED_CR8_STORE_EXITING) &&
2883+ !nested_cpu_has2(vmcs12, SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) {
2884+ /*
2885+ * The processor will never use the TPR shadow, simply
2886+ * clear the bit from the execution control. Such a
2887+ * configuration is useless, but it happens in tests.
2888+ * For any other configuration, failing the vm entry is
2889+ * _not_ what the processor does but it's basically the
2890+ * only possibility we have.
2891+ */
2892+ vmcs_clear_bits(CPU_BASED_VM_EXEC_CONTROL,
2893+ CPU_BASED_TPR_SHADOW);
2894+ } else {
2895+ printk("bad virtual-APIC page address\n");
2896+ dump_vmcs();
28902897 }
28912898 }
28922899
@@ -3789,8 +3796,18 @@ static void nested_vmx_restore_host_state(struct kvm_vcpu *vcpu) · 896 unmodified lines
37893796 vmx_set_cr4(vcpu, vmcs_readl(CR4_READ_SHADOW));
37903797
37913798 nested_ept_uninit_mmu_context(vcpu);
3792− vcpu->arch.cr3 = vmcs_readl(GUEST_CR3);
3793− __set_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail);
3799+
3800+ /*
3801+ * This is only valid if EPT is in use, otherwise the vmcs01 GUEST_CR3
3802+ * points to shadow pages! Fortunately we only get here after a WARN_ON
3803+ * if EPT is disabled, so a VMabort is perfectly fine.
3804+ */
3805+ if (enable_ept) {
3806+ vcpu->arch.cr3 = vmcs_readl(GUEST_CR3);
3807+ __set_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail);
3808+ } else {
3809+ nested_vmx_abort(vcpu, VMX_ABORT_VMCS_CORRUPTED);
3810+ }
37943811
37953812 /*
37963813 * Use ept_save_pdptrs(vcpu) to load the MMU's cached PDPTRs
@@ -5738,6 +5755,14 @@ __init int nested_vmx_hardware_setup(int (*exit_handlers[])(struct kvm_vcpu *)) · 1941 unmodified lines
57385755 {
57395756 int i;
57405757
5758+ /*
5759+ * Without EPT it is not possible to restore L1's CR3 and PDPTR on
5760+ * VMfail, because they are not available in vmcs01. Just always
5761+ * use hardware checks.
5762+ */
5763+ if (!enable_ept)
5764+ nested_early_check = 1;
5765+
57415766 if (!cpu_has_vmx_shadow_vmcs())
57425767 enable_shadow_vmcs = 0;
57435768 if (enable_shadow_vmcs) {
arch/x86/kvm/vmx/vmx.c+31−4
@@ -5603,7 +5603,7 @@ static void vmx_dump_dtsel(char *name, uint32_t limit) · 5602 unmodified lines
56035603 vmcs_readl(limit + GUEST_GDTR_BASE - GUEST_GDTR_LIMIT));
56045604 }
56055605
5606−static void dump_vmcs(void)
5606+void dump_vmcs(void)
56075607 {
56085608 u32 vmentry_ctl = vmcs_read32(VM_ENTRY_CONTROLS);
56095609 u32 vmexit_ctl = vmcs_read32(VM_EXIT_CONTROLS);
@@ -6410,6 +6410,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu) · 800 unmodified lines
64106410 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
64116411 vmx_set_interrupt_shadow(vcpu, 0);
64126412
6413+ kvm_load_guest_xcr0(vcpu);
6414+
64136415 if (static_cpu_has(X86_FEATURE_PKU) &&
64146416 kvm_read_cr4_bits(vcpu, X86_CR4_PKE) &&
64156417 vcpu->arch.pkru != vmx->host_pkru)
@@ -6506,6 +6508,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu) · 90 unmodified lines
65066508 __write_pkru(vmx->host_pkru);
65076509 }
65086510
6511+ kvm_put_guest_xcr0(vcpu);
6512+
65096513 vmx->nested.nested_run_pending = 0;
65106514 vmx->idt_vectoring_info = 0;
65116515
@@ -6852,6 +6856,30 @@ static void nested_vmx_entry_exit_ctls_update(struct kvm_vcpu *vcpu) · 340 unmodified lines
68526856 }
68536857 }
68546858
6859+static bool guest_cpuid_has_pmu(struct kvm_vcpu *vcpu)
6860+{
6861+ struct kvm_cpuid_entry2 *entry;
6862+ union cpuid10_eax eax;
6863+
6864+ entry = kvm_find_cpuid_entry(vcpu, 0xa, 0);
6865+ if (!entry)
6866+ return false;
6867+
6868+ eax.full = entry->eax;
6869+ return (eax.split.version_id > 0);
6870+}
6871+
6872+static void nested_vmx_procbased_ctls_update(struct kvm_vcpu *vcpu)
6873+{
6874+ struct vcpu_vmx *vmx = to_vmx(vcpu);
6875+ bool pmu_enabled = guest_cpuid_has_pmu(vcpu);
6876+
6877+ if (pmu_enabled)
6878+ vmx->nested.msrs.procbased_ctls_high |= CPU_BASED_RDPMC_EXITING;
6879+ else
6880+ vmx->nested.msrs.procbased_ctls_high &= ~CPU_BASED_RDPMC_EXITING;
6881+}
6882+
68556883 static void update_intel_pt_cfg(struct kvm_vcpu *vcpu)
68566884 {
68576885 struct vcpu_vmx *vmx = to_vmx(vcpu);
@@ -6940,6 +6968,7 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu) · 82 unmodified lines
69406968 if (nested_vmx_allowed(vcpu)) {
69416969 nested_vmx_cr_fixed1_bits_update(vcpu);
69426970 nested_vmx_entry_exit_ctls_update(vcpu);
6971+ nested_vmx_procbased_ctls_update(vcpu);
69436972 }
69446973
69456974 if (boot_cpu_has(X86_FEATURE_INTEL_PT) &&
@@ -7369,7 +7398,7 @@ static int vmx_pre_enter_smm(struct kvm_vcpu *vcpu, char *smstate) · 423 unmodified lines
73697398 return 0;
73707399 }
73717400
7372−static int vmx_pre_leave_smm(struct kvm_vcpu *vcpu, u64 smbase)
7401+static int vmx_pre_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
73737402 {
73747403 struct vcpu_vmx *vmx = to_vmx(vcpu);
73757404 int ret;
@@ -7380,9 +7409,7 @@ static int vmx_pre_leave_smm(struct kvm_vcpu *vcpu, u64 smbase) · 4 unmodified lines
73807409 }
73817410
73827411 if (vmx->nested.smm.guest_mode) {
7383− vcpu->arch.hflags &= ~HF_SMM_MASK;
73847412 ret = nested_vmx_enter_non_root_mode(vcpu, false);
7385− vcpu->arch.hflags |= HF_SMM_MASK;
73867413 if (ret)
73877414 return ret;
73887415
arch/x86/kvm/vmx/vmx.h+2−0
@@ -517,4 +517,6 @@ static inline void decache_tsc_multiplier(struct vcpu_vmx *vmx) · 516 unmodified lines
517517 vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio);
518518 }
519519
520+void dump_vmcs(void);
521+
520522 #endif /* __KVM_X86_VMX_H */
arch/x86/kvm/x86.c+31−33
@@ -800,7 +800,7 @@ void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw) · 799 unmodified lines
800800 }
801801 EXPORT_SYMBOL_GPL(kvm_lmsw);
802802
803−static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu)
803+void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu)
804804 {
805805 if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) &&
806806 !vcpu->guest_xcr0_loaded) {
@@ -810,8 +810,9 @@ static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu) · 3 unmodified lines
810810 vcpu->guest_xcr0_loaded = 1;
811811 }
812812 }
813+EXPORT_SYMBOL_GPL(kvm_load_guest_xcr0);
813814
814−static void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu)
815+void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu)
815816 {
816817 if (vcpu->guest_xcr0_loaded) {
817818 if (vcpu->arch.xcr0 != host_xcr0)
@@ -819,6 +820,7 @@ static void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu) · 1 unmodified line
819820 vcpu->guest_xcr0_loaded = 0;
820821 }
821822 }
823+EXPORT_SYMBOL_GPL(kvm_put_guest_xcr0);
822824
823825 static int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
824826 {
@@ -3093,7 +3095,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) · 2268 unmodified lines
30933095 break;
30943096 case KVM_CAP_NESTED_STATE:
30953097 r = kvm_x86_ops->get_nested_state ?
3096− kvm_x86_ops->get_nested_state(NULL, 0, 0) : 0;
3098+ kvm_x86_ops->get_nested_state(NULL, NULL, 0) : 0;
30973099 break;
30983100 default:
30993101 break;
@@ -3528,7 +3530,7 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu, · 428 unmodified lines
35283530 memset(&events->reserved, 0, sizeof(events->reserved));
35293531 }
35303532
3531−static void kvm_set_hflags(struct kvm_vcpu *vcpu, unsigned emul_flags);
3533+static void kvm_smm_changed(struct kvm_vcpu *vcpu);
35323534
35333535 static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
35343536 struct kvm_vcpu_events *events)
@@ -3588,12 +3590,13 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, · 53 unmodified lines
35883590 vcpu->arch.apic->sipi_vector = events->sipi_vector;
35893591
35903592 if (events->flags & KVM_VCPUEVENT_VALID_SMM) {
3591− u32 hflags = vcpu->arch.hflags;
3592− if (events->smi.smm)
3593− hflags |= HF_SMM_MASK;
3594− else
3595− hflags &= ~HF_SMM_MASK;
3596− kvm_set_hflags(vcpu, hflags);
3593+ if (!!(vcpu->arch.hflags & HF_SMM_MASK) != events->smi.smm) {
3594+ if (events->smi.smm)
3595+ vcpu->arch.hflags |= HF_SMM_MASK;
3596+ else
3597+ vcpu->arch.hflags &= ~HF_SMM_MASK;
3598+ kvm_smm_changed(vcpu);
3599+ }
35973600
35983601 vcpu->arch.smi_pending = events->smi.pending;
35993602
@@ -4270,7 +4273,7 @@ static int kvm_vm_ioctl_set_identity_map_addr(struct kvm *kvm, · 670 unmodified lines
42704273 }
42714274
42724275 static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm,
4273− u32 kvm_nr_mmu_pages)
4276+ unsigned long kvm_nr_mmu_pages)
42744277 {
42754278 if (kvm_nr_mmu_pages < KVM_MIN_ALLOC_MMU_PAGES)
42764279 return -EINVAL;
@@ -4284,7 +4287,7 @@ static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm, · 7 unmodified lines
42844287 return 0;
42854288 }
42864289
4287−static int kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm)
4290+static unsigned long kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm)
42884291 {
42894292 return kvm->arch.n_max_mmu_pages;
42904293 }
@@ -5958,12 +5961,18 @@ static unsigned emulator_get_hflags(struct x86_emulate_ctxt *ctxt) · 1667 unmodified lines
59585961
59595962 static void emulator_set_hflags(struct x86_emulate_ctxt *ctxt, unsigned emul_flags)
59605963 {
5961− kvm_set_hflags(emul_to_vcpu(ctxt), emul_flags);
5964+ emul_to_vcpu(ctxt)->arch.hflags = emul_flags;
5965+}
5966+
5967+static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt,
5968+ const char *smstate)
5969+{
5970+ return kvm_x86_ops->pre_leave_smm(emul_to_vcpu(ctxt), smstate);
59625971 }
59635972
5964−static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt, u64 smbase)
5973+static void emulator_post_leave_smm(struct x86_emulate_ctxt *ctxt)
59655974 {
5966− return kvm_x86_ops->pre_leave_smm(emul_to_vcpu(ctxt), smbase);
5975+ kvm_smm_changed(emul_to_vcpu(ctxt));
59675976 }
59685977
59695978 static const struct x86_emulate_ops emulate_ops = {
@@ -6006,6 +6015,7 @@ static const struct x86_emulate_ops emulate_ops = { · 36 unmodified lines
60066015 .get_hflags = emulator_get_hflags,
60076016 .set_hflags = emulator_set_hflags,
60086017 .pre_leave_smm = emulator_pre_leave_smm,
6018+ .post_leave_smm = emulator_post_leave_smm,
60096019 };
60106020
60116021 static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
@@ -6247,16 +6257,6 @@ static void kvm_smm_changed(struct kvm_vcpu *vcpu) · 235 unmodified lines
62476257 kvm_mmu_reset_context(vcpu);
62486258 }
62496259
6250−static void kvm_set_hflags(struct kvm_vcpu *vcpu, unsigned emul_flags)
6251−{
6252− unsigned changed = vcpu->arch.hflags ^ emul_flags;
6253−
6254− vcpu->arch.hflags = emul_flags;
6255−
6256− if (changed & HF_SMM_MASK)
6257− kvm_smm_changed(vcpu);
6258−}
6259−
62606260 static int kvm_vcpu_check_hw_bp(unsigned long addr, u32 type, u32 dr7,
62616261 unsigned long *db)
62626262 {
@@ -7441,9 +7441,9 @@ static void enter_smm_save_state_32(struct kvm_vcpu *vcpu, char *buf) · 1178 unmodified lines
74417441 put_smstate(u32, buf, 0x7ef8, vcpu->arch.smbase);
74427442 }
74437443
7444+#ifdef CONFIG_X86_64
74447445 static void enter_smm_save_state_64(struct kvm_vcpu *vcpu, char *buf)
74457446 {
7446−#ifdef CONFIG_X86_64
74477447 struct desc_ptr dt;
74487448 struct kvm_segment seg;
74497449 unsigned long val;
@@ -7493,10 +7493,8 @@ static void enter_smm_save_state_64(struct kvm_vcpu *vcpu, char *buf) · 43 unmodified lines
74937493
74947494 for (i = 0; i < 6; i++)
74957495 enter_smm_save_seg_64(vcpu, buf, i);
7496−#else
7497− WARN_ON_ONCE(1);
7498−#endif
74997496 }
7497+#endif
75007498
75017499 static void enter_smm(struct kvm_vcpu *vcpu)
75027500 {
@@ -7507,9 +7505,11 @@ static void enter_smm(struct kvm_vcpu *vcpu) · 4 unmodified lines
75077505
75087506 trace_kvm_enter_smm(vcpu->vcpu_id, vcpu->arch.smbase, true);
75097507 memset(buf, 0, 512);
7508+#ifdef CONFIG_X86_64
75107509 if (guest_cpuid_has(vcpu, X86_FEATURE_LM))
75117510 enter_smm_save_state_64(vcpu, buf);
75127511 else
7512+#endif
75137513 enter_smm_save_state_32(vcpu, buf);
75147514
75157515 /*
@@ -7567,8 +7567,10 @@ static void enter_smm(struct kvm_vcpu *vcpu) · 51 unmodified lines
75677567 kvm_set_segment(vcpu, &ds, VCPU_SREG_GS);
75687568 kvm_set_segment(vcpu, &ds, VCPU_SREG_SS);
75697569
7570+#ifdef CONFIG_X86_64
75707571 if (guest_cpuid_has(vcpu, X86_FEATURE_LM))
75717572 kvm_x86_ops->set_efer(vcpu, 0);
7573+#endif
75727574
75737575 kvm_update_cpuid(vcpu);
75747576 kvm_mmu_reset_context(vcpu);
@@ -7865,8 +7867,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) · 290 unmodified lines
78657867 goto cancel_injection;
78667868 }
78677869
7868− kvm_load_guest_xcr0(vcpu);
7869−
78707870 if (req_immediate_exit) {
78717871 kvm_make_request(KVM_REQ_EVENT, vcpu);
78727872 kvm_x86_ops->request_immediate_exit(vcpu);
@@ -7919,8 +7919,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) · 46 unmodified lines
79197919 vcpu->mode = OUTSIDE_GUEST_MODE;
79207920 smp_wmb();
79217921
7922− kvm_put_guest_xcr0(vcpu);
7923−
79247922 kvm_before_interrupt(vcpu);
79257923 kvm_x86_ops->handle_external_intr(vcpu);
79267924 kvm_after_interrupt(vcpu);
arch/x86/kvm/x86.h+2−0
@@ -347,4 +347,6 @@ static inline void kvm_after_interrupt(struct kvm_vcpu *vcpu) · 346 unmodified lines
347347 __this_cpu_write(current_vcpu, NULL);
348348 }
349349
350+void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu);
351+void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu);
350352 #endif
block/bfq-iosched.c+7−8
@@ -2822,7 +2822,7 @@ static void bfq_dispatch_remove(struct request_queue *q, struct request *rq) · 2821 unmodified lines
28222822 bfq_remove_request(q, rq);
28232823 }
28242824
2825−static void __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq)
2825+static bool __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq)
28262826 {
28272827 /*
28282828 * If this bfqq is shared between multiple processes, check
@@ -2855,9 +2855,11 @@ static void __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq) · 26 unmodified lines
28552855 /*
28562856 * All in-service entities must have been properly deactivated
28572857 * or requeued before executing the next function, which
2858− * resets all in-service entites as no more in service.
2858+ * resets all in-service entities as no more in service. This
2859+ * may cause bfqq to be freed. If this happens, the next
2860+ * function returns true.
28592861 */
2860− __bfq_bfqd_reset_in_service(bfqd);
2862+ return __bfq_bfqd_reset_in_service(bfqd);
28612863 }
28622864
28632865 /**
@@ -3262,7 +3264,6 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, · 398 unmodified lines
32623264 bool slow;
32633265 unsigned long delta = 0;
32643266 struct bfq_entity *entity = &bfqq->entity;
3265− int ref;
32663267
32673268 /*
32683269 * Check whether the process is slow (see bfq_bfqq_is_slow).
@@ -3347,10 +3348,8 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, · 78 unmodified lines
33473348 * reason.
33483349 */
33493350 __bfq_bfqq_recalc_budget(bfqd, bfqq, reason);
3350− ref = bfqq->ref;
3351− __bfq_bfqq_expire(bfqd, bfqq);
3352−
3353− if (ref == 1) /* bfqq is gone, no more actions on it */
3351+ if (__bfq_bfqq_expire(bfqd, bfqq))
3352+ /* bfqq is gone, no more actions on it */
33543353 return;
33553354
33563355 bfqq->injected_service = 0;
block/bfq-iosched.h+1−1
@@ -995,7 +995,7 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity, · 994 unmodified lines
995995 bool ins_into_idle_tree);
996996 bool next_queue_may_preempt(struct bfq_data *bfqd);
997997 struct bfq_queue *bfq_get_next_queue(struct bfq_data *bfqd);
998−void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd);
998+bool __bfq_bfqd_reset_in_service(struct bfq_data *bfqd);
999999 void bfq_deactivate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq,
10001000 bool ins_into_idle_tree, bool expiration);
10011001 void bfq_activate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq);
block/bfq-wf2q.c+15−2
@@ -1605,7 +1605,8 @@ struct bfq_queue *bfq_get_next_queue(struct bfq_data *bfqd) · 1604 unmodified lines
16051605 return bfqq;
16061606 }
16071607
1608−void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd)
1608+/* returns true if the in-service queue gets freed */
1609+bool __bfq_bfqd_reset_in_service(struct bfq_data *bfqd)
16091610 {
16101611 struct bfq_queue *in_serv_bfqq = bfqd->in_service_queue;
16111612 struct bfq_entity *in_serv_entity = &in_serv_bfqq->entity;
@@ -1629,8 +1630,20 @@ void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd) · 17 unmodified lines
16291630 * service tree either, then release the service reference to
16301631 * the queue it represents (taken with bfq_get_entity).
16311632 */
1632− if (!in_serv_entity->on_st)
1633+ if (!in_serv_entity->on_st) {
1634+ /*
1635+ * If no process is referencing in_serv_bfqq any
1636+ * longer, then the service reference may be the only
1637+ * reference to the queue. If this is the case, then
1638+ * bfqq gets freed here.
1639+ */
1640+ int ref = in_serv_bfqq->ref;
16331641 bfq_put_queue(in_serv_bfqq);
1642+ if (ref == 1)
1643+ return true;
1644+ }
1645+
1646+ return false;
16341647 }
16351648
16361649 void bfq_deactivate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq,
block/bio.c+4−1
@@ -1298,8 +1298,11 @@ struct bio *bio_copy_user_iov(struct request_queue *q, · 1297 unmodified lines
12981298 }
12991299 }
13001300
1301− if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes)
1301+ if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) {
1302+ if (!map_data)
1303+ __free_page(page);
13021304 break;
1305+ }
13031306
13041307 len -= bytes;
13051308 offset = 0;
block/blk-mq.c+7−0
@@ -654,6 +654,13 @@ bool blk_mq_complete_request(struct request *rq) · 653 unmodified lines
654654 }
655655 EXPORT_SYMBOL(blk_mq_complete_request);
656656
657+void blk_mq_complete_request_sync(struct request *rq)
658+{
659+ WRITE_ONCE(rq->state, MQ_RQ_COMPLETE);
660+ rq->q->mq_ops->complete(rq);
661+}
662+EXPORT_SYMBOL_GPL(blk_mq_complete_request_sync);
663+
657664 int blk_mq_request_started(struct request *rq)
658665 {
659666 return blk_mq_rq_state(rq) != MQ_RQ_IDLE;
drivers/acpi/acpica/nsobject.c+4−0
@@ -186,6 +186,10 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node) · 185 unmodified lines
186186 }
187187 }
188188
189+ if (obj_desc->common.type == ACPI_TYPE_REGION) {
190+ acpi_ut_remove_address_range(obj_desc->region.space_id, node);
191+ }
192+
189193 /* Clear the Node entry in all cases */
190194
191195 node->object = NULL;
drivers/acpi/nfit/core.c+6−6
@@ -567,6 +567,12 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, · 566 unmodified lines
567567 goto out;
568568 }
569569
570+ dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name,
571+ cmd_name, out_obj->buffer.length);
572+ print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4,
573+ out_obj->buffer.pointer,
574+ min_t(u32, 128, out_obj->buffer.length), true);
575+
570576 if (call_pkg) {
571577 call_pkg->nd_fw_size = out_obj->buffer.length;
572578 memcpy(call_pkg->nd_payload + call_pkg->nd_size_in,
@@ -585,12 +591,6 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, · 12 unmodified lines
585591 return 0;
586592 }
587593
588− dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name,
589− cmd_name, out_obj->buffer.length);
590− print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4,
591− out_obj->buffer.pointer,
592− min_t(u32, 128, out_obj->buffer.length), true);
593−
594594 for (i = 0, offset = 0; i < desc->out_num; i++) {
595595 u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i, buf,
596596 (u32 *) out_obj->buffer.pointer,
drivers/acpi/nfit/intel.c+4−6
@@ -122,9 +122,8 @@ static int intel_security_change_key(struct nvdimm *nvdimm, · 121 unmodified lines
122122 if (!test_bit(cmd, &nfit_mem->dsm_mask))
123123 return -ENOTTY;
124124
125− if (old_data)
126− memcpy(nd_cmd.cmd.old_pass, old_data->data,
127− sizeof(nd_cmd.cmd.old_pass));
125+ memcpy(nd_cmd.cmd.old_pass, old_data->data,
126+ sizeof(nd_cmd.cmd.old_pass));
128127 memcpy(nd_cmd.cmd.new_pass, new_data->data,
129128 sizeof(nd_cmd.cmd.new_pass));
130129 rc = nvdimm_ctl(nvdimm, ND_CMD_CALL, &nd_cmd, sizeof(nd_cmd), NULL);
@@ -336,9 +335,8 @@ static int __maybe_unused intel_security_overwrite(struct nvdimm *nvdimm, · 205 unmodified lines
336335
337336 /* flush all cache before we erase DIMM */
338337 nvdimm_invalidate_cache();
339− if (nkey)
340− memcpy(nd_cmd.cmd.passphrase, nkey->data,
341− sizeof(nd_cmd.cmd.passphrase));
338+ memcpy(nd_cmd.cmd.passphrase, nkey->data,
339+ sizeof(nd_cmd.cmd.passphrase));
342340 rc = nvdimm_ctl(nvdimm, ND_CMD_CALL, &nd_cmd, sizeof(nd_cmd), NULL);
343341 if (rc < 0)
344342 return rc;
drivers/block/virtio_blk.c+2−0
@@ -513,6 +513,8 @@ static int init_vq(struct virtio_blk *vblk) · 512 unmodified lines
513513 if (err)
514514 num_vqs = 1;
515515
516+ num_vqs = min_t(unsigned int, nr_cpu_ids, num_vqs);
517+
516518 vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL);
517519 if (!vblk->vqs)
518520 return -ENOMEM;
drivers/bluetooth/btusb.c+1−1
@@ -2942,6 +2942,7 @@ static int btusb_config_oob_wake(struct hci_dev *hdev) · 2941 unmodified lines
29422942 return 0;
29432943 }
29442944
2945+ irq_set_status_flags(irq, IRQ_NOAUTOEN);
29452946 ret = devm_request_irq(&hdev->dev, irq, btusb_oob_wake_handler,
29462947 0, "OOB Wake-on-BT", data);
29472948 if (ret) {
@@ -2956,7 +2957,6 @@ static int btusb_config_oob_wake(struct hci_dev *hdev) · 8 unmodified lines
29562957 }
29572958
29582959 data->oob_wake_irq = irq;
2959− disable_irq(irq);
29602960 bt_dev_info(hdev, "OOB Wake-on-BT configured at IRQ %u", irq);
29612961 return 0;
29622962 }
drivers/char/ipmi/ipmi_dmi.c+0−1
@@ -66,7 +66,6 @@ static void __init dmi_add_platform_ipmi(unsigned long base_addr, · 65 unmodified lines
6666 return;
6767 }
6868
69− memset(&p, 0, sizeof(p));
7069 p.addr = base_addr;
7170 p.space = space;
7271 p.regspacing = offset;
drivers/char/ipmi/ipmi_msghandler.c+17−2
@@ -214,6 +214,9 @@ struct ipmi_user { · 213 unmodified lines
214214
215215 /* Does this interface receive IPMI events? */
216216 bool gets_events;
217+
218+ /* Free must run in process context for RCU cleanup. */
219+ struct work_struct remove_work;
217220 };
218221
219222 static struct ipmi_user *acquire_ipmi_user(struct ipmi_user *user, int *index)
@@ -1157,6 +1160,15 @@ static int intf_err_seq(struct ipmi_smi *intf, · 937 unmodified lines
11571160 return rv;
11581161 }
11591162
1163+static void free_user_work(struct work_struct *work)
1164+{
1165+ struct ipmi_user *user = container_of(work, struct ipmi_user,
1166+ remove_work);
1167+
1168+ cleanup_srcu_struct(&user->release_barrier);
1169+ kfree(user);
1170+}
1171+
11601172 int ipmi_create_user(unsigned int if_num,
11611173 const struct ipmi_user_hndl *handler,
11621174 void *handler_data,
@@ -1200,6 +1212,8 @@ int ipmi_create_user(unsigned int if_num, · 37 unmodified lines
12001212 goto out_kfree;
12011213
12021214 found:
1215+ INIT_WORK(&new_user->remove_work, free_user_work);
1216+
12031217 rv = init_srcu_struct(&new_user->release_barrier);
12041218 if (rv)
12051219 goto out_kfree;
@@ -1260,8 +1274,9 @@ EXPORT_SYMBOL(ipmi_get_smi_info); · 54 unmodified lines
12601274 static void free_user(struct kref *ref)
12611275 {
12621276 struct ipmi_user *user = container_of(ref, struct ipmi_user, refcount);
1263− cleanup_srcu_struct(&user->release_barrier);
1264− kfree(user);
1277+
1278+ /* SRCU cleanup must happen in task context. */
1279+ schedule_work(&user->remove_work);
12651280 }
12661281
12671282 static void _ipmi_destroy_user(struct ipmi_user *user)
drivers/char/ipmi/ipmi_si_hardcode.c+2−0
@@ -118,6 +118,8 @@ void __init ipmi_hardcode_init(void) · 117 unmodified lines
118118 char *str;
119119 char *si_type[SI_MAX_PARMS];
120120
121+ memset(si_type, 0, sizeof(si_type));
122+
121123 /* Parse out the si_type string into its components. */
122124 str = si_type_str;
123125 if (*str != '\0') {
drivers/clk/at91/clk-programmable.c+43−14
@@ -20,8 +20,7 @@ · 19 unmodified lines
2020 #define PROG_ID_MAX 7
2121
2222 #define PROG_STATUS_MASK(id) (1 << ((id) + 8))
23−#define PROG_PRES_MASK 0x7
24−#define PROG_PRES(layout, pckr) ((pckr >> layout->pres_shift) & PROG_PRES_MASK)
23+#define PROG_PRES(layout, pckr) ((pckr >> layout->pres_shift) & layout->pres_mask)
2524 #define PROG_MAX_RM9200_CSS 3
2625
2726 struct clk_programmable {
@@ -37,20 +36,29 @@ static unsigned long clk_programmable_recalc_rate(struct clk_hw *hw, · 9 unmodified lines
3736 unsigned long parent_rate)
3837 {
3938 struct clk_programmable *prog = to_clk_programmable(hw);
39+ const struct clk_programmable_layout *layout = prog->layout;
4040 unsigned int pckr;
41+ unsigned long rate;
4142
4243 regmap_read(prog->regmap, AT91_PMC_PCKR(prog->id), &pckr);
4344
44− return parent_rate >> PROG_PRES(prog->layout, pckr);
45+ if (layout->is_pres_direct)
46+ rate = parent_rate / (PROG_PRES(layout, pckr) + 1);
47+ else
48+ rate = parent_rate >> PROG_PRES(layout, pckr);
49+
50+ return rate;
4551 }
4652
4753 static int clk_programmable_determine_rate(struct clk_hw *hw,
4854 struct clk_rate_request *req)
4955 {
56+ struct clk_programmable *prog = to_clk_programmable(hw);
57+ const struct clk_programmable_layout *layout = prog->layout;
5058 struct clk_hw *parent;
5159 long best_rate = -EINVAL;
5260 unsigned long parent_rate;
53− unsigned long tmp_rate;
61+ unsigned long tmp_rate = 0;
5462 int shift;
5563 int i;
5664
@@ -60,10 +68,18 @@ static int clk_programmable_determine_rate(struct clk_hw *hw, · 3 unmodified lines
6068 continue;
6169
6270 parent_rate = clk_hw_get_rate(parent);
63− for (shift = 0; shift < PROG_PRES_MASK; shift++) {
64− tmp_rate = parent_rate >> shift;
65− if (tmp_rate <= req->rate)
66− break;
71+ if (layout->is_pres_direct) {
72+ for (shift = 0; shift <= layout->pres_mask; shift++) {
73+ tmp_rate = parent_rate / (shift + 1);
74+ if (tmp_rate <= req->rate)
75+ break;
76+ }
77+ } else {
78+ for (shift = 0; shift < layout->pres_mask; shift++) {
79+ tmp_rate = parent_rate >> shift;
80+ if (tmp_rate <= req->rate)
81+ break;
82+ }
6783 }
6884
6985 if (tmp_rate > req->rate)
@@ -137,16 +153,23 @@ static int clk_programmable_set_rate(struct clk_hw *hw, unsigned long rate, · 67 unmodified lines
137153 if (!div)
138154 return -EINVAL;
139155
140− shift = fls(div) - 1;
156+ if (layout->is_pres_direct) {
157+ shift = div - 1;
141158
142− if (div != (1 << shift))
143− return -EINVAL;
159+ if (shift > layout->pres_mask)
160+ return -EINVAL;
161+ } else {
162+ shift = fls(div) - 1;
144163
145− if (shift >= PROG_PRES_MASK)
146− return -EINVAL;
164+ if (div != (1 << shift))
165+ return -EINVAL;
166+
167+ if (shift >= layout->pres_mask)
168+ return -EINVAL;
169+ }
147170
148171 regmap_update_bits(prog->regmap, AT91_PMC_PCKR(prog->id),
149− PROG_PRES_MASK << layout->pres_shift,
172+ layout->pres_mask << layout->pres_shift,
150173 shift << layout->pres_shift);
151174
152175 return 0;
@@ -202,19 +225,25 @@ at91_clk_register_programmable(struct regmap *regmap, · 49 unmodified lines
202225 }
203226
204227 const struct clk_programmable_layout at91rm9200_programmable_layout = {
228+ .pres_mask = 0x7,
205229 .pres_shift = 2,
206230 .css_mask = 0x3,
207231 .have_slck_mck = 0,
232+ .is_pres_direct = 0,
208233 };
209234
210235 const struct clk_programmable_layout at91sam9g45_programmable_layout = {
236+ .pres_mask = 0x7,
211237 .pres_shift = 2,
212238 .css_mask = 0x3,
213239 .have_slck_mck = 1,
240+ .is_pres_direct = 0,
214241 };
215242
216243 const struct clk_programmable_layout at91sam9x5_programmable_layout = {
244+ .pres_mask = 0x7,
217245 .pres_shift = 4,
218246 .css_mask = 0x7,
219247 .have_slck_mck = 0,
248+ .is_pres_direct = 0,
220249 };
drivers/clk/at91/pmc.h+2−0
@@ -71,9 +71,11 @@ struct clk_pll_characteristics { · 70 unmodified lines
7171 };
7272
7373 struct clk_programmable_layout {
74+ u8 pres_mask;
7475 u8 pres_shift;
7576 u8 css_mask;
7677 u8 have_slck_mck;
78+ u8 is_pres_direct;
7779 };
7880
7981 extern const struct clk_programmable_layout at91rm9200_programmable_layout;
drivers/clk/at91/sama5d2.c+9−1
@@ -125,6 +125,14 @@ static const struct { · 124 unmodified lines
125125 .pll = true },
126126 };
127127
128+static const struct clk_programmable_layout sama5d2_programmable_layout = {
129+ .pres_mask = 0xff,
130+ .pres_shift = 4,
131+ .css_mask = 0x7,
132+ .have_slck_mck = 0,
133+ .is_pres_direct = 1,
134+};
135+
128136 static void __init sama5d2_pmc_setup(struct device_node *np)
129137 {
130138 struct clk_range range = CLK_RANGE(0, 0);
@@ -249,7 +257,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np) · 118 unmodified lines
249257
250258 hw = at91_clk_register_programmable(regmap, name,
251259 parent_names, 6, i,
252− &at91sam9x5_programmable_layout);
260+ &sama5d2_programmable_layout);
253261 if (IS_ERR(hw))
254262 goto err_free;
255263 }
drivers/clk/imx/clk-pll14xx.c+1−1
@@ -362,7 +362,7 @@ struct clk *imx_clk_pll14xx(const char *name, const char *parent_name, · 361 unmodified lines
362362
363363 switch (pll_clk->type) {
364364 case PLL_1416X:
365− if (!pll->rate_table)
365+ if (!pll_clk->rate_table)
366366 init.ops = &clk_pll1416x_min_ops;
367367 else
368368 init.ops = &clk_pll1416x_ops;
drivers/clk/mediatek/clk-gate.c+1−2
@@ -169,11 +169,10 @@ struct clk *mtk_clk_register_gate( · 168 unmodified lines
169169 return ERR_PTR(-ENOMEM);
170170
171171 init.name = name;
172− init.flags = CLK_SET_RATE_PARENT;
172+ init.flags = flags | CLK_SET_RATE_PARENT;
173173 init.parent_names = parent_name ? &parent_name : NULL;
174174 init.num_parents = parent_name ? 1 : 0;
175175 init.ops = ops;
176− init.flags = flags;
177176
178177 cg->regmap = regmap;
179178 cg->set_ofs = set_ofs;
drivers/clk/meson/clk-pll.c+1−1
@@ -120,7 +120,7 @@ static bool meson_clk_pll_is_better(unsigned long rate, · 119 unmodified lines
120120 return true;
121121 } else {
122122 /* Round down */
123− if (now < rate && best < now)
123+ if (now <= rate && best < now)
124124 return true;
125125 }
126126
drivers/clk/meson/g12a.c+3−3
@@ -960,14 +960,14 @@ static struct clk_regmap g12a_sd_emmc_c_clk0 = { · 959 unmodified lines
960960 /* VPU Clock */
961961
962962 static const char * const g12a_vpu_parent_names[] = {
963− "fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7",
963+ "fclk_div3", "fclk_div4", "fclk_div5", "fclk_div7",
964964 "mpll1", "vid_pll", "hifi_pll", "gp0_pll",
965965 };
966966
967967 static struct clk_regmap g12a_vpu_0_sel = {
968968 .data = &(struct clk_regmap_mux_data){
969969 .offset = HHI_VPU_CLK_CNTL,
970− .mask = 0x3,
970+ .mask = 0x7,
971971 .shift = 9,
972972 },
973973 .hw.init = &(struct clk_init_data){
@@ -1011,7 +1011,7 @@ static struct clk_regmap g12a_vpu_0 = { · 37 unmodified lines
10111011 static struct clk_regmap g12a_vpu_1_sel = {
10121012 .data = &(struct clk_regmap_mux_data){
10131013 .offset = HHI_VPU_CLK_CNTL,
1014− .mask = 0x3,
1014+ .mask = 0x7,
10151015 .shift = 25,
10161016 },
10171017 .hw.init = &(struct clk_init_data){
drivers/clk/meson/gxbb.c+2−0
@@ -2216,6 +2216,7 @@ static struct clk_regmap gxbb_vdec_1_div = { · 2215 unmodified lines
22162216 .offset = HHI_VDEC_CLK_CNTL,
22172217 .shift = 0,
22182218 .width = 7,
2219+ .flags = CLK_DIVIDER_ROUND_CLOSEST,
22192220 },
22202221 .hw.init = &(struct clk_init_data){
22212222 .name = "vdec_1_div",
@@ -2261,6 +2262,7 @@ static struct clk_regmap gxbb_vdec_hevc_div = { · 39 unmodified lines
22612262 .offset = HHI_VDEC2_CLK_CNTL,
22622263 .shift = 16,
22632264 .width = 7,
2265+ .flags = CLK_DIVIDER_ROUND_CLOSEST,
22642266 },
22652267 .hw.init = &(struct clk_init_data){
22662268 .name = "vdec_hevc_div",
drivers/clk/meson/vid-pll-div.c+2−2
@@ -82,8 +82,8 @@ static unsigned long meson_vid_pll_div_recalc_rate(struct clk_hw *hw, · 81 unmodified lines
8282 div = _get_table_val(meson_parm_read(clk->map, &pll_div->val),
8383 meson_parm_read(clk->map, &pll_div->sel));
8484 if (!div || !div->divider) {
85− pr_info("%s: Invalid config value for vid_pll_div\n", __func__);
86− return parent_rate;
85+ pr_debug("%s: Invalid config value for vid_pll_div\n", __func__);
86+ return 0;
8787 }
8888
8989 return DIV_ROUND_UP_ULL(parent_rate * div->multiplier, div->divider);
drivers/clk/x86/clk-pmc-atom.c+11−3
@@ -165,7 +165,7 @@ static const struct clk_ops plt_clk_ops = { · 164 unmodified lines
165165 };
166166
167167 static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id,
168− void __iomem *base,
168+ const struct pmc_clk_data *pmc_data,
169169 const char **parent_names,
170170 int num_parents)
171171 {
@@ -184,9 +184,17 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id, · 12 unmodified lines
184184 init.num_parents = num_parents;
185185
186186 pclk->hw.init = &init;
187− pclk->reg = base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE;
187+ pclk->reg = pmc_data->base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE;
188188 spin_lock_init(&pclk->lock);
189189
190+ /*
191+ * On some systems, the pmc_plt_clocks already enabled by the
192+ * firmware are being marked as critical to avoid them being
193+ * gated by the clock framework.
194+ */
195+ if (pmc_data->critical && plt_clk_is_enabled(&pclk->hw))
196+ init.flags |= CLK_IS_CRITICAL;
197+
190198 ret = devm_clk_hw_register(&pdev->dev, &pclk->hw);
191199 if (ret) {
192200 pclk = ERR_PTR(ret);
@@ -332,7 +340,7 @@ static int plt_clk_probe(struct platform_device *pdev) · 139 unmodified lines
332340 return PTR_ERR(parent_names);
333341
334342 for (i = 0; i < PMC_CLK_NUM; i++) {
335− data->clks[i] = plt_clk_register(pdev, i, pmc_data->base,
343+ data->clks[i] = plt_clk_register(pdev, i, pmc_data,
336344 parent_names, data->nparents);
337345 if (IS_ERR(data->clks[i])) {
338346 err = PTR_ERR(data->clks[i]);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c+9−4
@@ -3173,11 +3173,16 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev) · 3172 unmodified lines
31733173 break;
31743174
31753175 if (fence) {
3176− r = dma_fence_wait_timeout(fence, false, tmo);
3176+ tmo = dma_fence_wait_timeout(fence, false, tmo);
31773177 dma_fence_put(fence);
31783178 fence = next;
3179− if (r <= 0)
3179+ if (tmo == 0) {
3180+ r = -ETIMEDOUT;
31803181 break;
3182+ } else if (tmo < 0) {
3183+ r = tmo;
3184+ break;
3185+ }
31813186 } else {
31823187 fence = next;
31833188 }
@@ -3188,8 +3193,8 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev) · 4 unmodified lines
31883193 tmo = dma_fence_wait_timeout(fence, false, tmo);
31893194 dma_fence_put(fence);
31903195
3191− if (r <= 0 || tmo <= 0) {
3192− DRM_ERROR("recover vram bo from shadow failed\n");
3196+ if (r < 0 || tmo <= 0) {
3197+ DRM_ERROR("recover vram bo from shadow failed, r is %ld, tmo is %ld\n", r, tmo);
31933198 return -EIO;
31943199 }
31953200
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c+3−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include "amdgpu_trace.h"
3636
3737 #define AMDGPU_IB_TEST_TIMEOUT msecs_to_jiffies(1000)
38+#define AMDGPU_IB_TEST_GFX_XGMI_TIMEOUT msecs_to_jiffies(2000)
3839
3940 /*
4041 * IB
@@ -344,6 +345,8 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev) · 303 unmodified lines
344345 * cost waiting for it coming back under RUNTIME only
345346 */
346347 tmo_gfx = 8 * AMDGPU_IB_TEST_TIMEOUT;
348+ } else if (adev->gmc.xgmi.hive_id) {
349+ tmo_gfx = AMDGPU_IB_TEST_GFX_XGMI_TIMEOUT;
347350 }
348351
349352 for (i = 0; i < adev->num_rings; ++i) {
drivers/gpu/drm/amd/amdkfd/kfd_device.c+1−0
@@ -320,6 +320,7 @@ static const struct kfd_deviceid supported_devices[] = { · 319 unmodified lines
320320 { 0x9876, &carrizo_device_info }, /* Carrizo */
321321 { 0x9877, &carrizo_device_info }, /* Carrizo */
322322 { 0x15DD, &raven_device_info }, /* Raven */
323+ { 0x15D8, &raven_device_info }, /* Raven */
323324 #endif
324325 { 0x67A0, &hawaii_device_info }, /* Hawaii */
325326 { 0x67A1, &hawaii_device_info }, /* Hawaii */
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c+1−0
@@ -4533,6 +4533,7 @@ static void handle_cursor_update(struct drm_plane *plane, · 4532 unmodified lines
45334533 amdgpu_crtc->cursor_width = plane->state->crtc_w;
45344534 amdgpu_crtc->cursor_height = plane->state->crtc_h;
45354535
4536+ memset(&attributes, 0, sizeof(attributes));
45364537 attributes.address.high_part = upper_32_bits(address);
45374538 attributes.address.low_part = lower_32_bits(address);
45384539 attributes.width = plane->state->crtc_w;
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c+2−21
@@ -1150,28 +1150,9 @@ void hubp1_cursor_set_position( · 1149 unmodified lines
11501150 REG_UPDATE(CURSOR_CONTROL,
11511151 CURSOR_ENABLE, cur_en);
11521152
1153− //account for cases where we see negative offset relative to overlay plane
1154− if (src_x_offset < 0 && src_y_offset < 0) {
1155− REG_SET_2(CURSOR_POSITION, 0,
1156− CURSOR_X_POSITION, 0,
1157− CURSOR_Y_POSITION, 0);
1158− x_hotspot -= src_x_offset;
1159− y_hotspot -= src_y_offset;
1160− } else if (src_x_offset < 0) {
1161− REG_SET_2(CURSOR_POSITION, 0,
1162− CURSOR_X_POSITION, 0,
1163− CURSOR_Y_POSITION, pos->y);
1164− x_hotspot -= src_x_offset;
1165− } else if (src_y_offset < 0) {
1166− REG_SET_2(CURSOR_POSITION, 0,
1153+ REG_SET_2(CURSOR_POSITION, 0,
11671154 CURSOR_X_POSITION, pos->x,
1168− CURSOR_Y_POSITION, 0);
1169− y_hotspot -= src_y_offset;
1170− } else {
1171− REG_SET_2(CURSOR_POSITION, 0,
1172− CURSOR_X_POSITION, pos->x,
1173− CURSOR_Y_POSITION, pos->y);
1174− }
1155+ CURSOR_Y_POSITION, pos->y);
11751156
11761157 REG_SET_2(CURSOR_HOT_SPOT, 0,
11771158 CURSOR_HOT_SPOT_X, x_hotspot,
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c+30−4
@@ -1037,6 +1037,31 @@ void dw_hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data, · 1036 unmodified lines
10371037 }
10381038 EXPORT_SYMBOL_GPL(dw_hdmi_phy_i2c_write);
10391039
1040+/* Filter out invalid setups to avoid configuring SCDC and scrambling */
1041+static bool dw_hdmi_support_scdc(struct dw_hdmi *hdmi)
1042+{
1043+ struct drm_display_info *display = &hdmi->connector.display_info;
1044+
1045+ /* Completely disable SCDC support for older controllers */
1046+ if (hdmi->version < 0x200a)
1047+ return false;
1048+
1049+ /* Disable if SCDC is not supported, or if an HF-VSDB block is absent */
1050+ if (!display->hdmi.scdc.supported ||
1051+ !display->hdmi.scdc.scrambling.supported)
1052+ return false;
1053+
1054+ /*
1055+ * Disable if display only support low TMDS rates and scrambling
1056+ * for low rates is not supported either
1057+ */
1058+ if (!display->hdmi.scdc.scrambling.low_rates &&
1059+ display->max_tmds_clock <= 340000)
1060+ return false;
1061+
1062+ return true;
1063+}
1064+
10401065 /*
10411066 * HDMI2.0 Specifies the following procedure for High TMDS Bit Rates:
10421067 * - The Source shall suspend transmission of the TMDS clock and data
@@ -1055,7 +1080,7 @@ void dw_hdmi_set_high_tmds_clock_ratio(struct dw_hdmi *hdmi) · 12 unmodified lines
10551080 unsigned long mtmdsclock = hdmi->hdmi_data.video_mode.mtmdsclock;
10561081
10571082 /* Control for TMDS Bit Period/TMDS Clock-Period Ratio */
1058− if (hdmi->connector.display_info.hdmi.scdc.supported) {
1083+ if (dw_hdmi_support_scdc(hdmi)) {
10591084 if (mtmdsclock > HDMI14_MAX_TMDSCLK)
10601085 drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 1);
10611086 else
@@ -1579,8 +1604,9 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi, · 517 unmodified lines
15791604
15801605 /* Set up HDMI_FC_INVIDCONF */
15811606 inv_val = (hdmi->hdmi_data.hdcp_enable ||
1582− vmode->mtmdsclock > HDMI14_MAX_TMDSCLK ||
1583− hdmi_info->scdc.scrambling.low_rates ?
1607+ (dw_hdmi_support_scdc(hdmi) &&
1608+ (vmode->mtmdsclock > HDMI14_MAX_TMDSCLK ||
1609+ hdmi_info->scdc.scrambling.low_rates)) ?
15841610 HDMI_FC_INVIDCONF_HDCP_KEEPOUT_ACTIVE :
15851611 HDMI_FC_INVIDCONF_HDCP_KEEPOUT_INACTIVE);
15861612
@@ -1646,7 +1672,7 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi, · 59 unmodified lines
16461672 }
16471673
16481674 /* Scrambling Control */
1649− if (hdmi_info->scdc.supported) {
1675+ if (dw_hdmi_support_scdc(hdmi)) {
16501676 if (vmode->mtmdsclock > HDMI14_MAX_TMDSCLK ||
16511677 hdmi_info->scdc.scrambling.low_rates) {
16521678 /*
drivers/gpu/drm/drm_atomic_helper.c+2−3
@@ -1034,7 +1034,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) · 1033 unmodified lines
10341034 funcs->atomic_disable(crtc, old_crtc_state);
10351035 else if (funcs->disable)
10361036 funcs->disable(crtc);
1037− else
1037+ else if (funcs->dpms)
10381038 funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
10391039
10401040 if (!(dev->irq_enabled && dev->num_crtcs))
@@ -1277,10 +1277,9 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, · 236 unmodified lines
12771277 if (new_crtc_state->enable) {
12781278 DRM_DEBUG_ATOMIC("enabling [CRTC:%d:%s]\n",
12791279 crtc->base.id, crtc->name);
1280−
12811280 if (funcs->atomic_enable)
12821281 funcs->atomic_enable(crtc, old_crtc_state);
1283− else
1282+ else if (funcs->commit)
12841283 funcs->commit(crtc);
12851284 }
12861285 }
drivers/gpu/drm/i915/gvt/dmabuf.c+6−3
@@ -209,7 +209,7 @@ static int vgpu_get_plane_info(struct drm_device *dev, · 208 unmodified lines
209209 struct drm_i915_private *dev_priv = to_i915(dev);
210210 struct intel_vgpu_primary_plane_format p;
211211 struct intel_vgpu_cursor_plane_format c;
212− int ret;
212+ int ret, tile_height = 1;
213213
214214 if (plane_id == DRM_PLANE_TYPE_PRIMARY) {
215215 ret = intel_vgpu_decode_primary_plane(vgpu, &p);
@@ -228,12 +228,15 @@ static int vgpu_get_plane_info(struct drm_device *dev, · 12 unmodified lines
228228 break;
229229 case PLANE_CTL_TILED_X:
230230 info->drm_format_mod = I915_FORMAT_MOD_X_TILED;
231+ tile_height = 8;
231232 break;
232233 case PLANE_CTL_TILED_Y:
233234 info->drm_format_mod = I915_FORMAT_MOD_Y_TILED;
235+ tile_height = 32;
234236 break;
235237 case PLANE_CTL_TILED_YF:
236238 info->drm_format_mod = I915_FORMAT_MOD_Yf_TILED;
239+ tile_height = 32;
237240 break;
238241 default:
239242 gvt_vgpu_err("invalid tiling mode: %x\n", p.tiled);
@@ -264,8 +267,8 @@ static int vgpu_get_plane_info(struct drm_device *dev, · 24 unmodified lines
264267 return -EINVAL;
265268 }
266269
267− info->size = (info->stride * info->height + PAGE_SIZE - 1)
268− >> PAGE_SHIFT;
270+ info->size = (info->stride * roundup(info->height, tile_height)
271+ + PAGE_SIZE - 1) >> PAGE_SHIFT;
269272 if (info->size == 0) {
270273 gvt_vgpu_err("fb size is zero\n");
271274 return -EINVAL;
drivers/gpu/drm/i915/gvt/gtt.c+9−3
@@ -750,14 +750,20 @@ static void ppgtt_free_spt(struct intel_vgpu_ppgtt_spt *spt) · 749 unmodified lines
750750
751751 static void ppgtt_free_all_spt(struct intel_vgpu *vgpu)
752752 {
753− struct intel_vgpu_ppgtt_spt *spt;
753+ struct intel_vgpu_ppgtt_spt *spt, *spn;
754754 struct radix_tree_iter iter;
755− void **slot;
755+ LIST_HEAD(all_spt);
756+ void __rcu **slot;
756757
758+ rcu_read_lock();
757759 radix_tree_for_each_slot(slot, &vgpu->gtt.spt_tree, &iter, 0) {
758760 spt = radix_tree_deref_slot(slot);
759− ppgtt_free_spt(spt);
761+ list_move(&spt->post_shadow_list, &all_spt);
760762 }
763+ rcu_read_unlock();
764+
765+ list_for_each_entry_safe(spt, spn, &all_spt, post_shadow_list)
766+ ppgtt_free_spt(spt);
761767 }
762768
763769 static int ppgtt_handle_guest_write_page_table_bytes(
drivers/gpu/drm/i915/gvt/kvmgt.c+3−3
@@ -905,7 +905,7 @@ static inline bool intel_vgpu_in_aperture(struct intel_vgpu *vgpu, u64 off) · 904 unmodified lines
905905 static int intel_vgpu_aperture_rw(struct intel_vgpu *vgpu, u64 off,
906906 void *buf, unsigned long count, bool is_write)
907907 {
908− void *aperture_va;
908+ void __iomem *aperture_va;
909909
910910 if (!intel_vgpu_in_aperture(vgpu, off) ||
911911 !intel_vgpu_in_aperture(vgpu, off + count)) {
@@ -920,9 +920,9 @@ static int intel_vgpu_aperture_rw(struct intel_vgpu *vgpu, u64 off, · 8 unmodified lines
920920 return -EIO;
921921
922922 if (is_write)
923− memcpy(aperture_va + offset_in_page(off), buf, count);
923+ memcpy_toio(aperture_va + offset_in_page(off), buf, count);
924924 else
925− memcpy(buf, aperture_va + offset_in_page(off), count);
925+ memcpy_fromio(buf, aperture_va + offset_in_page(off), count);
926926
927927 io_mapping_unmap(aperture_va);
928928
drivers/gpu/drm/i915/icl_dsi.c+27−21
@@ -323,6 +323,21 @@ static void gen11_dsi_program_esc_clk_div(struct intel_encoder *encoder) · 322 unmodified lines
323323 }
324324 }
325325
326+static void get_dsi_io_power_domains(struct drm_i915_private *dev_priv,
327+ struct intel_dsi *intel_dsi)
328+{
329+ enum port port;
330+
331+ for_each_dsi_port(port, intel_dsi->ports) {
332+ WARN_ON(intel_dsi->io_wakeref[port]);
333+ intel_dsi->io_wakeref[port] =
334+ intel_display_power_get(dev_priv,
335+ port == PORT_A ?
336+ POWER_DOMAIN_PORT_DDI_A_IO :
337+ POWER_DOMAIN_PORT_DDI_B_IO);
338+ }
339+}
340+
326341 static void gen11_dsi_enable_io_power(struct intel_encoder *encoder)
327342 {
328343 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
@@ -336,13 +351,7 @@ static void gen11_dsi_enable_io_power(struct intel_encoder *encoder) · 7 unmodified lines
336351 I915_WRITE(ICL_DSI_IO_MODECTL(port), tmp);
337352 }
338353
339− for_each_dsi_port(port, intel_dsi->ports) {
340− intel_dsi->io_wakeref[port] =
341− intel_display_power_get(dev_priv,
342− port == PORT_A ?
343− POWER_DOMAIN_PORT_DDI_A_IO :
344− POWER_DOMAIN_PORT_DDI_B_IO);
345− }
354+ get_dsi_io_power_domains(dev_priv, intel_dsi);
346355 }
347356
348357 static void gen11_dsi_power_up_lanes(struct intel_encoder *encoder)
@@ -589,6 +598,12 @@ static void gen11_dsi_map_pll(struct intel_encoder *encoder, · 240 unmodified lines
589598 val |= DPCLKA_CFGCR0_DDI_CLK_SEL(pll->info->id, port);
590599 }
591600 I915_WRITE(DPCLKA_CFGCR0_ICL, val);
601+
602+ for_each_dsi_port(port, intel_dsi->ports) {
603+ val &= ~DPCLKA_CFGCR0_DDI_CLK_OFF(port);
604+ }
605+ I915_WRITE(DPCLKA_CFGCR0_ICL, val);
606+
592607 POSTING_READ(DPCLKA_CFGCR0_ICL);
593608
594609 mutex_unlock(&dev_priv->dpll_lock);
@@ -1117,7 +1132,7 @@ static void gen11_dsi_disable_port(struct intel_encoder *encoder) · 522 unmodified lines
11171132 DRM_ERROR("DDI port:%c buffer not idle\n",
11181133 port_name(port));
11191134 }
1120− gen11_dsi_ungate_clocks(encoder);
1135+ gen11_dsi_gate_clocks(encoder);
11211136 }
11221137
11231138 static void gen11_dsi_disable_io_power(struct intel_encoder *encoder)
@@ -1218,20 +1233,11 @@ static int gen11_dsi_compute_config(struct intel_encoder *encoder, · 94 unmodified lines
12181233 return 0;
12191234 }
12201235
1221−static u64 gen11_dsi_get_power_domains(struct intel_encoder *encoder,
1222− struct intel_crtc_state *crtc_state)
1236+static void gen11_dsi_get_power_domains(struct intel_encoder *encoder,
1237+ struct intel_crtc_state *crtc_state)
12231238 {
1224− struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
1225− u64 domains = 0;
1226− enum port port;
1227−
1228− for_each_dsi_port(port, intel_dsi->ports)
1229− if (port == PORT_A)
1230− domains |= BIT_ULL(POWER_DOMAIN_PORT_DDI_A_IO);
1231− else
1232− domains |= BIT_ULL(POWER_DOMAIN_PORT_DDI_B_IO);
1233−
1234− return domains;
1239+ get_dsi_io_power_domains(to_i915(encoder->base.dev),
1240+ enc_to_intel_dsi(&encoder->base));
12351241 }
12361242
12371243 static bool gen11_dsi_get_hw_state(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_ddi.c+11−12
@@ -2075,12 +2075,11 @@ intel_ddi_main_link_aux_domain(struct intel_digital_port *dig_port) · 2074 unmodified lines
20752075 intel_aux_power_domain(dig_port);
20762076 }
20772077
2078−static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
2079− struct intel_crtc_state *crtc_state)
2078+static void intel_ddi_get_power_domains(struct intel_encoder *encoder,
2079+ struct intel_crtc_state *crtc_state)
20802080 {
20812081 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
20822082 struct intel_digital_port *dig_port;
2083− u64 domains;
20842083
20852084 /*
20862085 * TODO: Add support for MST encoders. Atm, the following should never
@@ -2088,10 +2087,10 @@ static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder, · 1 unmodified line
20882087 * hook.
20892088 */
20902089 if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
2091− return 0;
2090+ return;
20922091
20932092 dig_port = enc_to_dig_port(&encoder->base);
2094− domains = BIT_ULL(dig_port->ddi_io_power_domain);
2093+ intel_display_power_get(dev_priv, dig_port->ddi_io_power_domain);
20952094
20962095 /*
20972096 * AUX power is only needed for (e)DP mode, and for HDMI mode on TC
@@ -2099,15 +2098,15 @@ static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder, · 1 unmodified line
20992098 */
21002099 if (intel_crtc_has_dp_encoder(crtc_state) ||
21012100 intel_port_is_tc(dev_priv, encoder->port))
2102− domains |= BIT_ULL(intel_ddi_main_link_aux_domain(dig_port));
2101+ intel_display_power_get(dev_priv,
2102+ intel_ddi_main_link_aux_domain(dig_port));
21032103
21042104 /*
21052105 * VDSC power is needed when DSC is enabled
21062106 */
21072107 if (crtc_state->dsc_params.compression_enable)
2108− domains |= BIT_ULL(intel_dsc_power_domain(crtc_state));
2109−
2110− return domains;
2108+ intel_display_power_get(dev_priv,
2109+ intel_dsc_power_domain(crtc_state));
21112110 }
21122111
21132112 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state)
@@ -2825,10 +2824,10 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder) · 711 unmodified lines
28252824 return;
28262825 }
28272826 /*
2828− * DSI ports should have their DDI clock ungated when disabled
2829− * and gated when enabled.
2827+ * For DSI we keep the ddi clocks gated
2828+ * except during enable/disable sequence.
28302829 */
2831− ddi_clk_needed = !encoder->base.crtc;
2830+ ddi_clk_needed = false;
28322831 }
28332832
28342833 val = I915_READ(DPCLKA_CFGCR0_ICL);
drivers/gpu/drm/i915/intel_display.c+1−5
@@ -15986,8 +15986,6 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv) · 15985 unmodified lines
1598615986 struct intel_encoder *encoder;
1598715987
1598815988 for_each_intel_encoder(&dev_priv->drm, encoder) {
15989− u64 get_domains;
15990− enum intel_display_power_domain domain;
1599115989 struct intel_crtc_state *crtc_state;
1599215990
1599315991 if (!encoder->get_power_domains)
@@ -16001,9 +15999,7 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv) · 7 unmodified lines
1600115999 continue;
1600216000
1600316001 crtc_state = to_intel_crtc_state(encoder->base.crtc->state);
16004− get_domains = encoder->get_power_domains(encoder, crtc_state);
16005− for_each_power_domain(domain, get_domains)
16006− intel_display_power_get(dev_priv, domain);
16002+ encoder->get_power_domains(encoder, crtc_state);
1600716003 }
1600816004 }
1600916005
drivers/gpu/drm/i915/intel_dp.c+10−59
@@ -1859,42 +1859,6 @@ intel_dp_compute_link_config_wide(struct intel_dp *intel_dp, · 1858 unmodified lines
18591859 return -EINVAL;
18601860 }
18611861
1862−/* Optimize link config in order: max bpp, min lanes, min clock */
1863−static int
1864−intel_dp_compute_link_config_fast(struct intel_dp *intel_dp,
1865− struct intel_crtc_state *pipe_config,
1866− const struct link_config_limits *limits)
1867−{
1868− struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
1869− int bpp, clock, lane_count;
1870− int mode_rate, link_clock, link_avail;
1871−
1872− for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -= 2 * 3) {
1873− mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock,
1874− bpp);
1875−
1876− for (lane_count = limits->min_lane_count;
1877− lane_count <= limits->max_lane_count;
1878− lane_count <<= 1) {
1879− for (clock = limits->min_clock; clock <= limits->max_clock; clock++) {
1880− link_clock = intel_dp->common_rates[clock];
1881− link_avail = intel_dp_max_data_rate(link_clock,
1882− lane_count);
1883−
1884− if (mode_rate <= link_avail) {
1885− pipe_config->lane_count = lane_count;
1886− pipe_config->pipe_bpp = bpp;
1887− pipe_config->port_clock = link_clock;
1888−
1889− return 0;
1890− }
1891− }
1892− }
1893− }
1894−
1895− return -EINVAL;
1896−}
1897−
18981862 static int intel_dp_dsc_compute_bpp(struct intel_dp *intel_dp, u8 dsc_max_bpc)
18991863 {
19001864 int i, num_bpc;
@@ -2031,15 +1995,13 @@ intel_dp_compute_link_config(struct intel_encoder *encoder, · 130 unmodified lines
20311995 limits.min_bpp = 6 * 3;
20321996 limits.max_bpp = intel_dp_compute_bpp(intel_dp, pipe_config);
20331997
2034− if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] < DP_EDP_14) {
1998+ if (intel_dp_is_edp(intel_dp)) {
20351999 /*
20362000 * Use the maximum clock and number of lanes the eDP panel
2037− * advertizes being capable of. The eDP 1.3 and earlier panels
2038− * are generally designed to support only a single clock and
2039− * lane configuration, and typically these values correspond to
2040− * the native resolution of the panel. With eDP 1.4 rate select
2041− * and DSC, this is decreasingly the case, and we need to be
2042− * able to select less than maximum link config.
2001+ * advertizes being capable of. The panels are generally
2002+ * designed to support only a single clock and lane
2003+ * configuration, and typically these values correspond to the
2004+ * native resolution of the panel.
20432005 */
20442006 limits.min_lane_count = limits.max_lane_count;
20452007 limits.min_clock = limits.max_clock;
@@ -2053,22 +2015,11 @@ intel_dp_compute_link_config(struct intel_encoder *encoder, · 7 unmodified lines
20532015 intel_dp->common_rates[limits.max_clock],
20542016 limits.max_bpp, adjusted_mode->crtc_clock);
20552017
2056− if (intel_dp_is_edp(intel_dp))
2057− /*
2058− * Optimize for fast and narrow. eDP 1.3 section 3.3 and eDP 1.4
2059− * section A.1: "It is recommended that the minimum number of
2060− * lanes be used, using the minimum link rate allowed for that
2061− * lane configuration."
2062− *
2063− * Note that we use the max clock and lane count for eDP 1.3 and
2064− * earlier, and fast vs. wide is irrelevant.
2065− */
2066− ret = intel_dp_compute_link_config_fast(intel_dp, pipe_config,
2067− &limits);
2068− else
2069− /* Optimize for slow and wide. */
2070− ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config,
2071− &limits);
2018+ /*
2019+ * Optimize for slow and wide. This is the place to add alternative
2020+ * optimization policy.
2021+ */
2022+ ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config, &limits);
20722023
20732024 /* enable compression if the mode doesn't fit available BW */
20742025 DRM_DEBUG_KMS("Force DSC en = %d\n", intel_dp->force_dsc_en);
drivers/gpu/drm/i915/intel_drv.h+6−4
@@ -270,10 +270,12 @@ struct intel_encoder { · 269 unmodified lines
270270 * be set correctly before calling this function. */
271271 void (*get_config)(struct intel_encoder *,
272272 struct intel_crtc_state *pipe_config);
273− /* Returns a mask of power domains that need to be referenced as part
274− * of the hardware state readout code. */
275− u64 (*get_power_domains)(struct intel_encoder *encoder,
276− struct intel_crtc_state *crtc_state);
273+ /*
274+ * Acquires the power domains needed for an active encoder during
275+ * hardware state readout.
276+ */
277+ void (*get_power_domains)(struct intel_encoder *encoder,
278+ struct intel_crtc_state *crtc_state);
277279 /*
278280 * Called during system suspend after all pending requests for the
279281 * encoder are flushed (for example for DP AUX transactions) and
drivers/gpu/drm/i915/vlv_dsi.c+24−0
@@ -256,6 +256,28 @@ static void band_gap_reset(struct drm_i915_private *dev_priv) · 255 unmodified lines
256256 mutex_unlock(&dev_priv->sb_lock);
257257 }
258258
259+static int bdw_get_pipemisc_bpp(struct intel_crtc *crtc)
260+{
261+ struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
262+ u32 tmp;
263+
264+ tmp = I915_READ(PIPEMISC(crtc->pipe));
265+
266+ switch (tmp & PIPEMISC_DITHER_BPC_MASK) {
267+ case PIPEMISC_DITHER_6_BPC:
268+ return 18;
269+ case PIPEMISC_DITHER_8_BPC:
270+ return 24;
271+ case PIPEMISC_DITHER_10_BPC:
272+ return 30;
273+ case PIPEMISC_DITHER_12_BPC:
274+ return 36;
275+ default:
276+ MISSING_CASE(tmp);
277+ return 0;
278+ }
279+}
280+
259281 static int intel_dsi_compute_config(struct intel_encoder *encoder,
260282 struct intel_crtc_state *pipe_config,
261283 struct drm_connector_state *conn_state)
@@ -1071,6 +1093,8 @@ static void bxt_dsi_get_pipe_config(struct intel_encoder *encoder, · 809 unmodified lines
10711093 bpp = mipi_dsi_pixel_format_to_bpp(
10721094 pixel_format_from_register_bits(fmt));
10731095
1096+ pipe_config->pipe_bpp = bdw_get_pipemisc_bpp(crtc);
1097+
10741098 /* Enable Frame time stamo based scanline reporting */
10751099 adjusted_mode->private_flags |=
10761100 I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP;
drivers/gpu/drm/mediatek/mtk_dpi.c+3−5
@@ -662,13 +662,11 @@ static unsigned int mt8173_calculate_factor(int clock) · 661 unmodified lines
662662 static unsigned int mt2701_calculate_factor(int clock)
663663 {
664664 if (clock <= 64000)
665− return 16;
666− else if (clock <= 128000)
667− return 8;
668− else if (clock <= 256000)
669665 return 4;
670− else
666+ else if (clock <= 128000)
671667 return 2;
668+ else
669+ return 1;
672670 }
673671
674672 static const struct mtk_dpi_conf mt8173_conf = {
drivers/gpu/drm/mediatek/mtk_drm_drv.c+7−0
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <drm/drmP.h>
1616 #include <drm/drm_atomic.h>
1717 #include <drm/drm_atomic_helper.h>
18+#include <drm/drm_fb_helper.h>
1819 #include <drm/drm_gem.h>
1920 #include <drm/drm_gem_cma_helper.h>
2021 #include <drm/drm_of.h>
@@ -341,6 +342,8 @@ static struct drm_driver mtk_drm_driver = { · 320 unmodified lines
341342 .gem_prime_get_sg_table = mtk_gem_prime_get_sg_table,
342343 .gem_prime_import_sg_table = mtk_gem_prime_import_sg_table,
343344 .gem_prime_mmap = mtk_drm_gem_mmap_buf,
345+ .gem_prime_vmap = mtk_drm_gem_prime_vmap,
346+ .gem_prime_vunmap = mtk_drm_gem_prime_vunmap,
344347 .fops = &mtk_drm_fops,
345348
346349 .name = DRIVER_NAME,
@@ -376,6 +379,10 @@ static int mtk_drm_bind(struct device *dev) · 29 unmodified lines
376379 if (ret < 0)
377380 goto err_deinit;
378381
382+ ret = drm_fbdev_generic_setup(drm, 32);
383+ if (ret)
384+ DRM_ERROR("Failed to initialize fbdev: %d\n", ret);
385+
379386 return 0;
380387
381388 err_deinit:
drivers/gpu/drm/mediatek/mtk_drm_gem.c+46−0
@@ -241,3 +241,49 @@ err_gem_free: · 240 unmodified lines
241241 kfree(mtk_gem);
242242 return ERR_PTR(ret);
243243 }
244+
245+void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj)
246+{
247+ struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
248+ struct sg_table *sgt;
249+ struct sg_page_iter iter;
250+ unsigned int npages;
251+ unsigned int i = 0;
252+
253+ if (mtk_gem->kvaddr)
254+ return mtk_gem->kvaddr;
255+
256+ sgt = mtk_gem_prime_get_sg_table(obj);
257+ if (IS_ERR(sgt))
258+ return NULL;
259+
260+ npages = obj->size >> PAGE_SHIFT;
261+ mtk_gem->pages = kcalloc(npages, sizeof(*mtk_gem->pages), GFP_KERNEL);
262+ if (!mtk_gem->pages)
263+ goto out;
264+
265+ for_each_sg_page(sgt->sgl, &iter, sgt->orig_nents, 0) {
266+ mtk_gem->pages[i++] = sg_page_iter_page(&iter);
267+ if (i > npages)
268+ break;
269+ }
270+ mtk_gem->kvaddr = vmap(mtk_gem->pages, npages, VM_MAP,
271+ pgprot_writecombine(PAGE_KERNEL));
272+
273+out:
274+ kfree((void *)sgt);
275+
276+ return mtk_gem->kvaddr;
277+}
278+
279+void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
280+{
281+ struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
282+
283+ if (!mtk_gem->pages)
284+ return;
285+
286+ vunmap(vaddr);
287+ mtk_gem->kvaddr = 0;
288+ kfree((void *)mtk_gem->pages);
289+}
drivers/gpu/drm/mediatek/mtk_drm_gem.h+3−0
@@ -37,6 +37,7 @@ struct mtk_drm_gem_obj { · 36 unmodified lines
3737 dma_addr_t dma_addr;
3838 unsigned long dma_attrs;
3939 struct sg_table *sg;
40+ struct page **pages;
4041 };
4142
4243 #define to_mtk_gem_obj(x) container_of(x, struct mtk_drm_gem_obj, base)
@@ -52,5 +53,7 @@ int mtk_drm_gem_mmap_buf(struct drm_gem_object *obj, · 9 unmodified lines
5253 struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj);
5354 struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
5455 struct dma_buf_attachment *attach, struct sg_table *sg);
56+void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj);
57+void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
5558
5659 #endif
drivers/gpu/drm/mediatek/mtk_hdmi.c+1−1
@@ -1480,7 +1480,6 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, · 1479 unmodified lines
14801480 if (IS_ERR(regmap))
14811481 ret = PTR_ERR(regmap);
14821482 if (ret) {
1483− ret = PTR_ERR(regmap);
14841483 dev_err(dev,
14851484 "Failed to get system configuration registers: %d\n",
14861485 ret);
@@ -1516,6 +1515,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, · 29 unmodified lines
15161515 of_node_put(remote);
15171516
15181517 hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
1518+ of_node_put(i2c_np);
15191519 if (!hdmi->ddc_adpt) {
15201520 dev_err(dev, "Failed to get ddc i2c adapter by node\n");
15211521 return -EINVAL;
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c+5−30
@@ -15,28 +15,6 @@ static const struct phy_ops mtk_hdmi_phy_dev_ops = { · 14 unmodified lines
1515 .owner = THIS_MODULE,
1616 };
1717
18−long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
19− unsigned long *parent_rate)
20−{
21− struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw);
22−
23− hdmi_phy->pll_rate = rate;
24− if (rate <= 74250000)
25− *parent_rate = rate;
26− else
27− *parent_rate = rate / 2;
28−
29− return rate;
30−}
31−
32−unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw,
33− unsigned long parent_rate)
34−{
35− struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw);
36−
37− return hdmi_phy->pll_rate;
38−}
39−
4018 void mtk_hdmi_phy_clear_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,
4119 u32 bits)
4220 {
@@ -110,13 +88,11 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy) · 67 unmodified lines
11088 return NULL;
11189 }
11290
113−static void mtk_hdmi_phy_clk_get_ops(struct mtk_hdmi_phy *hdmi_phy,
114− const struct clk_ops **ops)
91+static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,
92+ struct clk_init_data *clk_init)
11593 {
116− if (hdmi_phy && hdmi_phy->conf && hdmi_phy->conf->hdmi_phy_clk_ops)
117− *ops = hdmi_phy->conf->hdmi_phy_clk_ops;
118− else
119− dev_err(hdmi_phy->dev, "Failed to get clk ops of phy\n");
94+ clk_init->flags = hdmi_phy->conf->flags;
95+ clk_init->ops = hdmi_phy->conf->hdmi_phy_clk_ops;
12096 }
12197
12298 static int mtk_hdmi_phy_probe(struct platform_device *pdev)
@@ -129,7 +105,6 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev) · 6 unmodified lines
129105 struct clk_init_data clk_init = {
130106 .num_parents = 1,
131107 .parent_names = (const char * const *)&ref_clk_name,
132− .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE,
133108 };
134109
135110 struct phy *phy;
@@ -167,7 +142,7 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev) · 31 unmodified lines
167142 hdmi_phy->dev = dev;
168143 hdmi_phy->conf =
169144 (struct mtk_hdmi_phy_conf *)of_device_get_match_data(dev);
170− mtk_hdmi_phy_clk_get_ops(hdmi_phy, &clk_init.ops);
145+ mtk_hdmi_phy_clk_get_data(hdmi_phy, &clk_init);
171146 hdmi_phy->pll_hw.init = &clk_init;
172147 hdmi_phy->pll = devm_clk_register(dev, &hdmi_phy->pll_hw);
173148 if (IS_ERR(hdmi_phy->pll)) {
drivers/gpu/drm/mediatek/mtk_hdmi_phy.h+1−4
@@ -21,6 +21,7 @@ struct mtk_hdmi_phy; · 20 unmodified lines
2121
2222 struct mtk_hdmi_phy_conf {
2323 bool tz_disabled;
24+ unsigned long flags;
2425 const struct clk_ops *hdmi_phy_clk_ops;
2526 void (*hdmi_phy_enable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
2627 void (*hdmi_phy_disable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
@@ -48,10 +49,6 @@ void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset, · 21 unmodified lines
4849 void mtk_hdmi_phy_mask(struct mtk_hdmi_phy *hdmi_phy, u32 offset,
4950 u32 val, u32 mask);
5051 struct mtk_hdmi_phy *to_mtk_hdmi_phy(struct clk_hw *hw);
51−long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
52− unsigned long *parent_rate);
53−unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw,
54− unsigned long parent_rate);
5552
5653 extern struct platform_driver mtk_hdmi_phy_driver;
5754 extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf;
drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c+43−6
@@ -79,7 +79,6 @@ static int mtk_hdmi_pll_prepare(struct clk_hw *hw) · 78 unmodified lines
7979 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK);
8080 usleep_range(80, 100);
8181 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN);
82− mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV);
8382 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK);
8483 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK);
8584 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK);
@@ -94,7 +93,6 @@ static void mtk_hdmi_pll_unprepare(struct clk_hw *hw) · 8 unmodified lines
9493 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK);
9594 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK);
9695 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK);
97− mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV);
9896 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN);
9997 usleep_range(80, 100);
10098 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK);
@@ -108,6 +106,12 @@ static void mtk_hdmi_pll_unprepare(struct clk_hw *hw) · 7 unmodified lines
108106 usleep_range(80, 100);
109107 }
110108
109+static long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
110+ unsigned long *parent_rate)
111+{
112+ return rate;
113+}
114+
111115 static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,
112116 unsigned long parent_rate)
113117 {
@@ -116,13 +120,14 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, · 2 unmodified lines
116120
117121 if (rate <= 64000000)
118122 pos_div = 3;
119− else if (rate <= 12800000)
120− pos_div = 1;
123+ else if (rate <= 128000000)
124+ pos_div = 2;
121125 else
122126 pos_div = 1;
123127
124128 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_PREDIV_MASK);
125129 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_POSDIV_MASK);
130+ mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV);
126131 mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IC),
127132 RG_HTPLL_IC_MASK);
128133 mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IR),
@@ -154,6 +159,39 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, · 25 unmodified lines
154159 return 0;
155160 }
156161
162+static unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw,
163+ unsigned long parent_rate)
164+{
165+ struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw);
166+ unsigned long out_rate, val;
167+
168+ val = (readl(hdmi_phy->regs + HDMI_CON6)
169+ & RG_HTPLL_PREDIV_MASK) >> RG_HTPLL_PREDIV;
170+ switch (val) {
171+ case 0x00:
172+ out_rate = parent_rate;
173+ break;
174+ case 0x01:
175+ out_rate = parent_rate / 2;
176+ break;
177+ default:
178+ out_rate = parent_rate / 4;
179+ break;
180+ }
181+
182+ val = (readl(hdmi_phy->regs + HDMI_CON6)
183+ & RG_HTPLL_FBKDIV_MASK) >> RG_HTPLL_FBKDIV;
184+ out_rate *= (val + 1) * 2;
185+ val = (readl(hdmi_phy->regs + HDMI_CON2)
186+ & RG_HDMITX_TX_POSDIV_MASK);
187+ out_rate >>= (val >> RG_HDMITX_TX_POSDIV);
188+
189+ if (readl(hdmi_phy->regs + HDMI_CON2) & RG_HDMITX_EN_TX_POSDIV)
190+ out_rate /= 5;
191+
192+ return out_rate;
193+}
194+
157195 static const struct clk_ops mtk_hdmi_phy_pll_ops = {
158196 .prepare = mtk_hdmi_pll_prepare,
159197 .unprepare = mtk_hdmi_pll_unprepare,
@@ -174,7 +212,6 @@ static void mtk_hdmi_phy_enable_tmds(struct mtk_hdmi_phy *hdmi_phy) · 14 unmodified lines
174212 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK);
175213 usleep_range(80, 100);
176214 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN);
177− mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV);
178215 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK);
179216 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK);
180217 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK);
@@ -186,7 +223,6 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy) · 5 unmodified lines
186223 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK);
187224 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK);
188225 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK);
189− mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV);
190226 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN);
191227 usleep_range(80, 100);
192228 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK);
@@ -202,6 +238,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy) · 9 unmodified lines
202238
203239 struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf = {
204240 .tz_disabled = true,
241+ .flags = CLK_SET_RATE_GATE,
205242 .hdmi_phy_clk_ops = &mtk_hdmi_phy_pll_ops,
206243 .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds,
207244 .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c+23−0
@@ -199,6 +199,20 @@ static void mtk_hdmi_pll_unprepare(struct clk_hw *hw) · 198 unmodified lines
199199 usleep_range(100, 150);
200200 }
201201
202+static long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
203+ unsigned long *parent_rate)
204+{
205+ struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw);
206+
207+ hdmi_phy->pll_rate = rate;
208+ if (rate <= 74250000)
209+ *parent_rate = rate;
210+ else
211+ *parent_rate = rate / 2;
212+
213+ return rate;
214+}
215+
202216 static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,
203217 unsigned long parent_rate)
204218 {
@@ -285,6 +299,14 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, · 80 unmodified lines
285299 return 0;
286300 }
287301
302+static unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw,
303+ unsigned long parent_rate)
304+{
305+ struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw);
306+
307+ return hdmi_phy->pll_rate;
308+}
309+
288310 static const struct clk_ops mtk_hdmi_phy_pll_ops = {
289311 .prepare = mtk_hdmi_pll_prepare,
290312 .unprepare = mtk_hdmi_pll_unprepare,
@@ -309,6 +331,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy) · 18 unmodified lines
309331 }
310332
311333 struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf = {
334+ .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE,
312335 .hdmi_phy_clk_ops = &mtk_hdmi_phy_pll_ops,
313336 .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds,
314337 .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c+19−7
@@ -175,6 +175,7 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) · 174 unmodified lines
175175 REG_FLD_MOD(core->base, HDMI_CORE_SYS_INTR_UNMASK4, 0, 3, 3);
176176 hdmi_wp_clear_irqenable(core->wp, HDMI_IRQ_CORE);
177177 hdmi_wp_set_irqstatus(core->wp, HDMI_IRQ_CORE);
178+ REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
178179 hdmi4_core_disable(core);
179180 return 0;
180181 }
@@ -182,16 +183,24 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) · 1 unmodified line
182183 if (err)
183184 return err;
184185
186+ /*
187+ * Initialize CEC clock divider: CEC needs 2MHz clock hence
188+ * set the divider to 24 to get 48/24=2MHz clock
189+ */
190+ REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);
191+
185192 /* Clear TX FIFO */
186193 if (!hdmi_cec_clear_tx_fifo(adap)) {
187194 pr_err("cec-%s: could not clear TX FIFO\n", adap->name);
188− return -EIO;
195+ err = -EIO;
196+ goto err_disable_clk;
189197 }
190198
191199 /* Clear RX FIFO */
192200 if (!hdmi_cec_clear_rx_fifo(adap)) {
193201 pr_err("cec-%s: could not clear RX FIFO\n", adap->name);
194− return -EIO;
202+ err = -EIO;
203+ goto err_disable_clk;
195204 }
196205
197206 /* Clear CEC interrupts */
@@ -236,6 +245,12 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) · 38 unmodified lines
236245 hdmi_write_reg(core->base, HDMI_CEC_INT_STATUS_1, temp);
237246 }
238247 return 0;
248+
249+err_disable_clk:
250+ REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
251+ hdmi4_core_disable(core);
252+
253+ return err;
239254 }
240255
241256 static int hdmi_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
@@ -333,11 +348,8 @@ int hdmi4_cec_init(struct platform_device *pdev, struct hdmi_core_data *core, · 91 unmodified lines
333348 return ret;
334349 core->wp = wp;
335350
336− /*
337− * Initialize CEC clock divider: CEC needs 2MHz clock hence
338− * set the devider to 24 to get 48/24=2MHz clock
339− */
340− REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);
351+ /* Disable clock initially, hdmi_cec_adap_enable() manages it */
352+ REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
341353
342354 ret = cec_register_adapter(core->adap, &pdev->dev);
343355 if (ret < 0) {
drivers/gpu/drm/omapdrm/dss/hdmi4_core.c+1−1
@@ -708,7 +708,7 @@ int hdmi4_audio_config(struct hdmi_core_data *core, struct hdmi_wp_data *wp, · 707 unmodified lines
708708 else
709709 acore.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_RIGHT;
710710 /*
711− * The I2S input word length is twice the lenght given in the IEC-60958
711+ * The I2S input word length is twice the length given in the IEC-60958
712712 * status word. If the word size is greater than
713713 * 20 bits, increment by one.
714714 */
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c+7−2
@@ -48,8 +48,13 @@ static enum drm_mode_status · 47 unmodified lines
4848 sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector,
4949 const struct drm_display_mode *mode)
5050 {
51− /* This is max for HDMI 2.0b (4K@60Hz) */
52− if (mode->clock > 594000)
51+ /*
52+ * Controller support maximum of 594 MHz, which correlates to
53+ * 4K@60Hz 4:4:4 or RGB. However, for frequencies greater than
54+ * 340 MHz scrambling has to be enabled. Because scrambling is
55+ * not yet implemented, just limit to 340 MHz for now.
56+ */
57+ if (mode->clock > 340000)
5358 return MODE_CLOCK_HIGH;
5459
5560 return MODE_OK;
drivers/gpu/drm/sun4i/sun8i_tcon_top.c+3−2
@@ -227,7 +227,7 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master, · 226 unmodified lines
227227
228228 err_unregister_gates:
229229 for (i = 0; i < CLK_NUM; i++)
230− if (clk_data->hws[i])
230+ if (!IS_ERR_OR_NULL(clk_data->hws[i]))
231231 clk_hw_unregister_gate(clk_data->hws[i]);
232232 clk_disable_unprepare(tcon_top->bus);
233233 err_assert_reset:
@@ -245,7 +245,8 @@ static void sun8i_tcon_top_unbind(struct device *dev, struct device *master, · 11 unmodified lines
245245
246246 of_clk_del_provider(dev->of_node);
247247 for (i = 0; i < CLK_NUM; i++)
248− clk_hw_unregister_gate(clk_data->hws[i]);
248+ if (clk_data->hws[i])
249+ clk_hw_unregister_gate(clk_data->hws[i]);
249250
250251 clk_disable_unprepare(tcon_top->bus);
251252 reset_control_assert(tcon_top->rst);
drivers/gpu/drm/udl/udl_drv.c+1−0
@@ -52,6 +52,7 @@ static struct drm_driver driver = { · 51 unmodified lines
5252 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
5353 .load = udl_driver_load,
5454 .unload = udl_driver_unload,
55+ .release = udl_driver_release,
5556
5657 /* gem hooks */
5758 .gem_free_object_unlocked = udl_gem_free_object,
drivers/gpu/drm/udl/udl_drv.h+1−0
@@ -104,6 +104,7 @@ void udl_urb_completion(struct urb *urb); · 103 unmodified lines
104104
105105 int udl_driver_load(struct drm_device *dev, unsigned long flags);
106106 void udl_driver_unload(struct drm_device *dev);
107+void udl_driver_release(struct drm_device *dev);
107108
108109 int udl_fbdev_init(struct drm_device *dev);
109110 void udl_fbdev_cleanup(struct drm_device *dev);
drivers/gpu/drm/udl/udl_main.c+7−1
@@ -379,6 +379,12 @@ void udl_driver_unload(struct drm_device *dev) · 378 unmodified lines
379379 udl_free_urb_list(dev);
380380
381381 udl_fbdev_cleanup(dev);
382− udl_modeset_cleanup(dev);
383382 kfree(udl);
384383 }
384+
385+void udl_driver_release(struct drm_device *dev)
386+{
387+ udl_modeset_cleanup(dev);
388+ drm_dev_fini(dev);
389+ kfree(dev);
390+}
drivers/gpu/host1x/hw/channel_hw.c+1−1
@@ -114,7 +114,7 @@ static inline void synchronize_syncpt_base(struct host1x_job *job) · 113 unmodified lines
114114
115115 static void host1x_channel_set_streamid(struct host1x_channel *channel)
116116 {
117−#if HOST1X_HW >= 6
117+#if IS_ENABLED(CONFIG_IOMMU_API) && HOST1X_HW >= 6
118118 struct iommu_fwspec *spec = dev_iommu_fwspec_get(channel->dev->parent);
119119 u32 sid = spec ? spec->ids[0] & 0xffff : 0x7f;
120120
drivers/infiniband/hw/hfi1/chip.c+19−7
@@ -13232,7 +13232,7 @@ static int set_up_context_variables(struct hfi1_devdata *dd) · 13231 unmodified lines
1323213232 int total_contexts;
1323313233 int ret;
1323413234 unsigned ngroups;
13235− int qos_rmt_count;
13235+ int rmt_count;
1323613236 int user_rmt_reduced;
1323713237 u32 n_usr_ctxts;
1323813238 u32 send_contexts = chip_send_contexts(dd);
@@ -13294,10 +13294,20 @@ static int set_up_context_variables(struct hfi1_devdata *dd) · 55 unmodified lines
1329413294 n_usr_ctxts = rcv_contexts - total_contexts;
1329513295 }
1329613296
13297− /* each user context requires an entry in the RMT */
13298− qos_rmt_count = qos_rmt_entries(dd, NULL, NULL);
13299− if (qos_rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
13300− user_rmt_reduced = NUM_MAP_ENTRIES - qos_rmt_count;
13297+ /*
13298+ * The RMT entries are currently allocated as shown below:
13299+ * 1. QOS (0 to 128 entries);
13300+ * 2. FECN for PSM (num_user_contexts + num_vnic_contexts);
13301+ * 3. VNIC (num_vnic_contexts).
13302+ * It should be noted that PSM FECN oversubscribe num_vnic_contexts
13303+ * entries of RMT because both VNIC and PSM could allocate any receive
13304+ * context between dd->first_dyn_alloc_text and dd->num_rcv_contexts,
13305+ * and PSM FECN must reserve an RMT entry for each possible PSM receive
13306+ * context.
13307+ */
13308+ rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_vnic_contexts * 2);
13309+ if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
13310+ user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count;
1330113311 dd_dev_err(dd,
1330213312 "RMT size is reducing the number of user receive contexts from %u to %d\n",
1330313313 n_usr_ctxts,
@@ -14285,9 +14295,11 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd, · 981 unmodified lines
1428514295 u64 reg;
1428614296 int i, idx, regoff, regidx;
1428714297 u8 offset;
14298+ u32 total_cnt;
1428814299
1428914300 /* there needs to be enough room in the map table */
14290− if (rmt->used + dd->num_user_contexts >= NUM_MAP_ENTRIES) {
14301+ total_cnt = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt;
14302+ if (rmt->used + total_cnt >= NUM_MAP_ENTRIES) {
1429114303 dd_dev_err(dd, "User FECN handling disabled - too many user contexts allocated\n");
1429214304 return;
1429314305 }
@@ -14341,7 +14353,7 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd, · 47 unmodified lines
1434114353 /* add rule 1 */
1434214354 add_rsm_rule(dd, RSM_INS_FECN, &rrd);
1434314355
14344− rmt->used += dd->num_user_contexts;
14356+ rmt->used += total_cnt;
1434514357 }
1434614358
1434714359 /* Initialize RSM for VNIC */
drivers/infiniband/hw/hfi1/qp.c+3−1
@@ -898,7 +898,9 @@ void notify_error_qp(struct rvt_qp *qp) · 897 unmodified lines
898898 if (!list_empty(&priv->s_iowait.list) &&
899899 !(qp->s_flags & RVT_S_BUSY) &&
900900 !(priv->s_flags & RVT_S_BUSY)) {
901− qp->s_flags &= ~RVT_S_ANY_WAIT_IO;
901+ qp->s_flags &= ~HFI1_S_ANY_WAIT_IO;
902+ iowait_clear_flag(&priv->s_iowait, IOWAIT_PENDING_IB);
903+ iowait_clear_flag(&priv->s_iowait, IOWAIT_PENDING_TID);
902904 list_del_init(&priv->s_iowait.list);
903905 priv->s_iowait.lock = NULL;
904906 rvt_put_qp(qp);
drivers/infiniband/hw/hfi1/rc.c+2−2
@@ -3088,7 +3088,7 @@ send_last: · 3087 unmodified lines
30883088 update_ack_queue(qp, next);
30893089 }
30903090 e = &qp->s_ack_queue[qp->r_head_ack_queue];
3091− if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
3091+ if (e->rdma_sge.mr) {
30923092 rvt_put_mr(e->rdma_sge.mr);
30933093 e->rdma_sge.mr = NULL;
30943094 }
@@ -3166,7 +3166,7 @@ send_last: · 71 unmodified lines
31663166 update_ack_queue(qp, next);
31673167 }
31683168 e = &qp->s_ack_queue[qp->r_head_ack_queue];
3169− if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
3169+ if (e->rdma_sge.mr) {
31703170 rvt_put_mr(e->rdma_sge.mr);
31713171 e->rdma_sge.mr = NULL;
31723172 }
drivers/infiniband/hw/hfi1/tid_rdma.c+8−23
@@ -5017,24 +5017,14 @@ int hfi1_make_tid_rdma_pkt(struct rvt_qp *qp, struct hfi1_pkt_state *ps) · 5016 unmodified lines
50175017 make_tid_rdma_ack(qp, ohdr, ps))
50185018 return 1;
50195019
5020− if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_SEND_OK)) {
5021− if (!(ib_rvt_state_ops[qp->state] & RVT_FLUSH_SEND))
5022− goto bail;
5023− /* We are in the error state, flush the work request. */
5024− if (qp->s_last == READ_ONCE(qp->s_head))
5025− goto bail;
5026− /* If DMAs are in progress, we can't flush immediately. */
5027− if (iowait_sdma_pending(&priv->s_iowait)) {
5028− qp->s_flags |= RVT_S_WAIT_DMA;
5029− goto bail;
5030− }
5031− clear_ahg(qp);
5032− wqe = rvt_get_swqe_ptr(qp, qp->s_last);
5033− hfi1_trdma_send_complete(qp, wqe, qp->s_last != qp->s_acked ?
5034− IB_WC_SUCCESS : IB_WC_WR_FLUSH_ERR);
5035− /* will get called again */
5036− goto done_free_tx;
5037− }
5020+ /*
5021+ * Bail out if we can't send data.
5022+ * Be reminded that this check must been done after the call to
5023+ * make_tid_rdma_ack() because the responding QP could be in
5024+ * RTR state where it can send TID RDMA ACK, not TID RDMA WRITE DATA.
5025+ */
5026+ if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_SEND_OK))
5027+ goto bail;
50385028
50395029 if (priv->s_flags & RVT_S_WAIT_ACK)
50405030 goto bail;
@@ -5144,11 +5134,6 @@ int hfi1_make_tid_rdma_pkt(struct rvt_qp *qp, struct hfi1_pkt_state *ps) · 103 unmodified lines
51445134 hfi1_make_ruc_header(qp, ohdr, (opcode << 24), bth1, bth2,
51455135 middle, ps);
51465136 return 1;
5147−done_free_tx:
5148− hfi1_put_txreq(ps->s_txreq);
5149− ps->s_txreq = NULL;
5150− return 1;
5151−
51525137 bail:
51535138 hfi1_put_txreq(ps->s_txreq);
51545139 bail_no_tx:
drivers/infiniband/hw/hns/hns_roce_hem.c+4−2
@@ -792,6 +792,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev, · 791 unmodified lines
792792 idx_offset = (obj & (table->num_obj - 1)) % obj_per_chunk;
793793 dma_offset = offset = idx_offset * table->obj_size;
794794 } else {
795+ u32 seg_size = 64; /* 8 bytes per BA and 8 BA per segment */
796+
795797 hns_roce_calc_hem_mhop(hr_dev, table, &mhop_obj, &mhop);
796798 /* mtt mhop */
797799 i = mhop.l0_idx;
@@ -803,8 +805,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev, · 5 unmodified lines
803805 hem_idx = i;
804806
805807 hem = table->hem[hem_idx];
806− dma_offset = offset = (obj & (table->num_obj - 1)) *
807− table->obj_size % mhop.bt_chunk_size;
808+ dma_offset = offset = (obj & (table->num_obj - 1)) * seg_size %
809+ mhop.bt_chunk_size;
808810 if (mhop.hop_num == 2)
809811 dma_offset = offset = 0;
810812 }
drivers/infiniband/hw/hns/hns_roce_mr.c+2−2
@@ -746,7 +746,6 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev *hr_dev, · 745 unmodified lines
746746 struct hns_roce_hem_table *table;
747747 dma_addr_t dma_handle;
748748 __le64 *mtts;
749− u32 s = start_index * sizeof(u64);
750749 u32 bt_page_size;
751750 u32 i;
752751
@@ -780,7 +779,8 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev *hr_dev, · 27 unmodified lines
780779 return -EINVAL;
781780
782781 mtts = hns_roce_table_find(hr_dev, table,
783− mtt->first_seg + s / hr_dev->caps.mtt_entry_sz,
782+ mtt->first_seg +
783+ start_index / HNS_ROCE_MTT_ENTRY_PER_SEG,
784784 &dma_handle);
785785 if (!mtts)
786786 return -ENOMEM;
drivers/infiniband/hw/hns/hns_roce_qp.c+0−3
@@ -274,9 +274,6 @@ void hns_roce_qp_free(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp) · 273 unmodified lines
274274 wait_for_completion(&hr_qp->free);
275275
276276 if ((hr_qp->ibqp.qp_type) != IB_QPT_GSI) {
277− if (hr_dev->caps.sccc_entry_sz)
278− hns_roce_table_put(hr_dev, &qp_table->sccc_table,
279− hr_qp->qpn);
280277 if (hr_dev->caps.trrl_entry_sz)
281278 hns_roce_table_put(hr_dev, &qp_table->trrl_table,
282279 hr_qp->qpn);
drivers/infiniband/hw/mlx5/odp.c+2−1
@@ -585,7 +585,7 @@ static int pagefault_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr, · 584 unmodified lines
585585 struct ib_umem_odp *odp_mr = to_ib_umem_odp(mr->umem);
586586 bool downgrade = flags & MLX5_PF_FLAGS_DOWNGRADE;
587587 bool prefetch = flags & MLX5_PF_FLAGS_PREFETCH;
588− u64 access_mask = ODP_READ_ALLOWED_BIT;
588+ u64 access_mask;
589589 u64 start_idx, page_mask;
590590 struct ib_umem_odp *odp;
591591 size_t size;
@@ -607,6 +607,7 @@ next_mr: · 15 unmodified lines
607607 page_shift = mr->umem->page_shift;
608608 page_mask = ~(BIT(page_shift) - 1);
609609 start_idx = (io_virt - (mr->mmkey.iova & page_mask)) >> page_shift;
610+ access_mask = ODP_READ_ALLOWED_BIT;
610611
611612 if (prefetch && !downgrade && !mr->umem->writable) {
612613 /* prefetch with write-access must
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c+2−0
@@ -1131,6 +1131,8 @@ static void pvrdma_pci_remove(struct pci_dev *pdev) · 1130 unmodified lines
11311131 pvrdma_page_dir_cleanup(dev, &dev->cq_pdir);
11321132 pvrdma_page_dir_cleanup(dev, &dev->async_pdir);
11331133 pvrdma_free_slots(dev);
1134+ dma_free_coherent(&pdev->dev, sizeof(*dev->dsr), dev->dsr,
1135+ dev->dsrbase);
11341136
11351137 iounmap(dev->regs);
11361138 kfree(dev->sgid_tbl);
drivers/iommu/amd_iommu_init.c+1−1
@@ -359,7 +359,7 @@ static void iommu_write_l2(struct amd_iommu *iommu, u8 address, u32 val) · 358 unmodified lines
359359 static void iommu_set_exclusion_range(struct amd_iommu *iommu)
360360 {
361361 u64 start = iommu->exclusion_start & PAGE_MASK;
362− u64 limit = (start + iommu->exclusion_length) & PAGE_MASK;
362+ u64 limit = (start + iommu->exclusion_length - 1) & PAGE_MASK;
363363 u64 entry;
364364
365365 if (!iommu->exclusion_start)
drivers/irqchip/irq-ls1x.c+1−0
@@ -130,6 +130,7 @@ static int __init ls1x_intc_of_init(struct device_node *node, · 129 unmodified lines
130130 NULL);
131131 if (!priv->domain) {
132132 pr_err("ls1x-irq: cannot add IRQ domain\n");
133+ err = -ENOMEM;
133134 goto out_iounmap;
134135 }
135136
drivers/isdn/mISDN/socket.c+2−2
@@ -710,10 +710,10 @@ base_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) · 709 unmodified lines
710710 struct sock *sk = sock->sk;
711711 int err = 0;
712712
713− if (!maddr || maddr->family != AF_ISDN)
713+ if (addr_len < sizeof(struct sockaddr_mISDN))
714714 return -EINVAL;
715715
716− if (addr_len < sizeof(struct sockaddr_mISDN))
716+ if (!maddr || maddr->family != AF_ISDN)
717717 return -EINVAL;
718718
719719 lock_sock(sk);
drivers/lightnvm/pblk-read.c+28−22
@@ -231,14 +231,14 @@ static void pblk_end_partial_read(struct nvm_rq *rqd) · 230 unmodified lines
231231 struct pblk_sec_meta *meta;
232232 struct bio *new_bio = rqd->bio;
233233 struct bio *bio = pr_ctx->orig_bio;
234− struct bio_vec src_bv, dst_bv;
235234 void *meta_list = rqd->meta_list;
236− int bio_init_idx = pr_ctx->bio_init_idx;
237235 unsigned long *read_bitmap = pr_ctx->bitmap;
236+ struct bvec_iter orig_iter = BVEC_ITER_ALL_INIT;
237+ struct bvec_iter new_iter = BVEC_ITER_ALL_INIT;
238238 int nr_secs = pr_ctx->orig_nr_secs;
239239 int nr_holes = nr_secs - bitmap_weight(read_bitmap, nr_secs);
240240 void *src_p, *dst_p;
241− int hole, i;
241+ int bit, i;
242242
243243 if (unlikely(nr_holes == 1)) {
244244 struct ppa_addr ppa;
@@ -257,33 +257,39 @@ static void pblk_end_partial_read(struct nvm_rq *rqd) · 12 unmodified lines
257257
258258 /* Fill the holes in the original bio */
259259 i = 0;
260− hole = find_first_zero_bit(read_bitmap, nr_secs);
261− do {
262− struct pblk_line *line;
260+ for (bit = 0; bit < nr_secs; bit++) {
261+ if (!test_bit(bit, read_bitmap)) {
262+ struct bio_vec dst_bv, src_bv;
263+ struct pblk_line *line;
263264
264− line = pblk_ppa_to_line(pblk, rqd->ppa_list[i]);
265− kref_put(&line->ref, pblk_line_put);
265+ line = pblk_ppa_to_line(pblk, rqd->ppa_list[i]);
266+ kref_put(&line->ref, pblk_line_put);
266267
267− meta = pblk_get_meta(pblk, meta_list, hole);
268− meta->lba = cpu_to_le64(pr_ctx->lba_list_media[i]);
268+ meta = pblk_get_meta(pblk, meta_list, bit);
269+ meta->lba = cpu_to_le64(pr_ctx->lba_list_media[i]);
269270
270− src_bv = new_bio->bi_io_vec[i++];
271− dst_bv = bio->bi_io_vec[bio_init_idx + hole];
271+ dst_bv = bio_iter_iovec(bio, orig_iter);
272+ src_bv = bio_iter_iovec(new_bio, new_iter);
272273
273− src_p = kmap_atomic(src_bv.bv_page);
274− dst_p = kmap_atomic(dst_bv.bv_page);
274+ src_p = kmap_atomic(src_bv.bv_page);
275+ dst_p = kmap_atomic(dst_bv.bv_page);
275276
276− memcpy(dst_p + dst_bv.bv_offset,
277− src_p + src_bv.bv_offset,
278− PBLK_EXPOSED_PAGE_SIZE);
277+ memcpy(dst_p + dst_bv.bv_offset,
278+ src_p + src_bv.bv_offset,
279+ PBLK_EXPOSED_PAGE_SIZE);
279280
280− kunmap_atomic(src_p);
281− kunmap_atomic(dst_p);
281+ kunmap_atomic(src_p);
282+ kunmap_atomic(dst_p);
282283
283− mempool_free(src_bv.bv_page, &pblk->page_bio_pool);
284+ flush_dcache_page(dst_bv.bv_page);
285+ mempool_free(src_bv.bv_page, &pblk->page_bio_pool);
284286
285− hole = find_next_zero_bit(read_bitmap, nr_secs, hole + 1);
286− } while (hole < nr_secs);
287+ bio_advance_iter(new_bio, &new_iter,
288+ PBLK_EXPOSED_PAGE_SIZE);
289+ i++;
290+ }
291+ bio_advance_iter(bio, &orig_iter, PBLK_EXPOSED_PAGE_SIZE);
292+ }
287293
288294 bio_put(new_bio);
289295 kfree(pr_ctx);
drivers/mmc/host/alcor.c+13−21
@@ -48,7 +48,6 @@ struct alcor_sdmmc_host { · 47 unmodified lines
4848 struct mmc_command *cmd;
4949 struct mmc_data *data;
5050 unsigned int dma_on:1;
51− unsigned int early_data:1;
5251
5352 struct mutex cmd_mutex;
5453
@@ -144,8 +143,7 @@ static void alcor_data_set_dma(struct alcor_sdmmc_host *host) · 89 unmodified lines
144143 host->sg_count--;
145144 }
146145
147−static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host,
148− bool early)
146+static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host)
149147 {
150148 struct alcor_pci_priv *priv = host->alcor_pci;
151149 struct mmc_data *data = host->data;
@@ -155,13 +153,6 @@ static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host, · 3 unmodified lines
155153 ctrl |= AU6601_DATA_WRITE;
156154
157155 if (data->host_cookie == COOKIE_MAPPED) {
158− if (host->early_data) {
159− host->early_data = false;
160− return;
161− }
162−
163− host->early_data = early;
164−
165156 alcor_data_set_dma(host);
166157 ctrl |= AU6601_DATA_DMA_MODE;
167158 host->dma_on = 1;
@@ -231,6 +222,7 @@ static void alcor_prepare_sg_miter(struct alcor_sdmmc_host *host) · 63 unmodified lines
231222 static void alcor_prepare_data(struct alcor_sdmmc_host *host,
232223 struct mmc_command *cmd)
233224 {
225+ struct alcor_pci_priv *priv = host->alcor_pci;
234226 struct mmc_data *data = cmd->data;
235227
236228 if (!data)
@@ -248,7 +240,7 @@ static void alcor_prepare_data(struct alcor_sdmmc_host *host, · 11 unmodified lines
248240 if (data->host_cookie != COOKIE_MAPPED)
249241 alcor_prepare_sg_miter(host);
250242
251− alcor_trigger_data_transfer(host, true);
243+ alcor_write8(priv, 0, AU6601_DATA_XFER_CTRL);
252244 }
253245
254246 static void alcor_send_cmd(struct alcor_sdmmc_host *host,
@@ -435,7 +427,7 @@ static int alcor_cmd_irq_done(struct alcor_sdmmc_host *host, u32 intmask) · 180 unmodified lines
435427 if (!host->data)
436428 return false;
437429
438− alcor_trigger_data_transfer(host, false);
430+ alcor_trigger_data_transfer(host);
439431 host->cmd = NULL;
440432 return true;
441433 }
@@ -456,7 +448,7 @@ static void alcor_cmd_irq_thread(struct alcor_sdmmc_host *host, u32 intmask) · 14 unmodified lines
456448 if (!host->data)
457449 alcor_request_complete(host, 1);
458450 else
459− alcor_trigger_data_transfer(host, false);
451+ alcor_trigger_data_transfer(host);
460452 host->cmd = NULL;
461453 }
462454
@@ -487,15 +479,9 @@ static int alcor_data_irq_done(struct alcor_sdmmc_host *host, u32 intmask) · 24 unmodified lines
487479 break;
488480 case AU6601_INT_READ_BUF_RDY:
489481 alcor_trf_block_pio(host, true);
490− if (!host->blocks)
491− break;
492− alcor_trigger_data_transfer(host, false);
493482 return 1;
494483 case AU6601_INT_WRITE_BUF_RDY:
495484 alcor_trf_block_pio(host, false);
496− if (!host->blocks)
497− break;
498− alcor_trigger_data_transfer(host, false);
499485 return 1;
500486 case AU6601_INT_DMA_END:
501487 if (!host->sg_count)
@@ -508,8 +494,14 @@ static int alcor_data_irq_done(struct alcor_sdmmc_host *host, u32 intmask) · 6 unmodified lines
508494 break;
509495 }
510496
511− if (intmask & AU6601_INT_DATA_END)
512− return 0;
497+ if (intmask & AU6601_INT_DATA_END) {
498+ if (!host->dma_on && host->blocks) {
499+ alcor_trigger_data_transfer(host);
500+ return 1;
501+ } else {
502+ return 0;
503+ }
504+ }
513505
514506 return 1;
515507 }
drivers/mmc/host/sdhci-omap.c+38−0
@@ -797,6 +797,43 @@ void sdhci_omap_reset(struct sdhci_host *host, u8 mask) · 796 unmodified lines
797797 sdhci_reset(host, mask);
798798 }
799799
800+#define CMD_ERR_MASK (SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX |\
801+ SDHCI_INT_TIMEOUT)
802+#define CMD_MASK (CMD_ERR_MASK | SDHCI_INT_RESPONSE)
803+
804+static u32 sdhci_omap_irq(struct sdhci_host *host, u32 intmask)
805+{
806+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
807+ struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
808+
809+ if (omap_host->is_tuning && host->cmd && !host->data_early &&
810+ (intmask & CMD_ERR_MASK)) {
811+
812+ /*
813+ * Since we are not resetting data lines during tuning
814+ * operation, data error or data complete interrupts
815+ * might still arrive. Mark this request as a failure
816+ * but still wait for the data interrupt
817+ */
818+ if (intmask & SDHCI_INT_TIMEOUT)
819+ host->cmd->error = -ETIMEDOUT;
820+ else
821+ host->cmd->error = -EILSEQ;
822+
823+ host->cmd = NULL;
824+
825+ /*
826+ * Sometimes command error interrupts and command complete
827+ * interrupt will arrive together. Clear all command related
828+ * interrupts here.
829+ */
830+ sdhci_writel(host, intmask & CMD_MASK, SDHCI_INT_STATUS);
831+ intmask &= ~CMD_MASK;
832+ }
833+
834+ return intmask;
835+}
836+
800837 static struct sdhci_ops sdhci_omap_ops = {
801838 .set_clock = sdhci_omap_set_clock,
802839 .set_power = sdhci_omap_set_power,
@@ -807,6 +844,7 @@ static struct sdhci_ops sdhci_omap_ops = { · 4 unmodified lines
807844 .platform_send_init_74_clocks = sdhci_omap_init_74_clocks,
808845 .reset = sdhci_omap_reset,
809846 .set_uhs_signaling = sdhci_omap_set_uhs_signaling,
847+ .irq = sdhci_omap_irq,
810848 };
811849
812850 static int sdhci_omap_set_capabilities(struct sdhci_omap_host *omap_host)
drivers/net/bonding/bond_main.c+5−1
@@ -3213,8 +3213,12 @@ static int bond_netdev_event(struct notifier_block *this, · 3212 unmodified lines
32133213 return NOTIFY_DONE;
32143214
32153215 if (event_dev->flags & IFF_MASTER) {
3216+ int ret;
3217+
32163218 netdev_dbg(event_dev, "IFF_MASTER\n");
3217− return bond_master_netdev_event(event, event_dev);
3219+ ret = bond_master_netdev_event(event, event_dev);
3220+ if (ret != NOTIFY_DONE)
3221+ return ret;
32183222 }
32193223
32203224 if (event_dev->flags & IFF_SLAVE) {
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c+1−1
@@ -957,7 +957,7 @@ int bnx2x_vfpf_update_vlan(struct bnx2x *bp, u16 vid, u8 vf_qid, bool add) · 956 unmodified lines
957957 bnx2x_sample_bulletin(bp);
958958
959959 if (bp->shadow_bulletin.content.valid_bitmap & 1 << VLAN_VALID) {
960− BNX2X_ERR("Hypervisor will dicline the request, avoiding\n");
960+ BNX2X_ERR("Hypervisor will decline the request, avoiding\n");
961961 rc = -EINVAL;
962962 goto out;
963963 }
drivers/net/ethernet/cavium/thunder/nicvf_main.c+20−2
@@ -32,6 +32,13 @@ · 31 unmodified lines
3232 #define DRV_NAME "nicvf"
3333 #define DRV_VERSION "1.0"
3434
35+/* NOTE: Packets bigger than 1530 are split across multiple pages and XDP needs
36+ * the buffer to be contiguous. Allow XDP to be set up only if we don't exceed
37+ * this value, keeping headroom for the 14 byte Ethernet header and two
38+ * VLAN tags (for QinQ)
39+ */
40+#define MAX_XDP_MTU (1530 - ETH_HLEN - VLAN_HLEN * 2)
41+
3542 /* Supported devices */
3643 static const struct pci_device_id nicvf_id_table[] = {
3744 { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM,
@@ -1582,6 +1589,15 @@ static int nicvf_change_mtu(struct net_device *netdev, int new_mtu) · 1544 unmodified lines
15821589 struct nicvf *nic = netdev_priv(netdev);
15831590 int orig_mtu = netdev->mtu;
15841591
1592+ /* For now just support only the usual MTU sized frames,
1593+ * plus some headroom for VLAN, QinQ.
1594+ */
1595+ if (nic->xdp_prog && new_mtu > MAX_XDP_MTU) {
1596+ netdev_warn(netdev, "Jumbo frames not yet supported with XDP, current MTU %d.\n",
1597+ netdev->mtu);
1598+ return -EINVAL;
1599+ }
1600+
15851601 netdev->mtu = new_mtu;
15861602
15871603 if (!netif_running(netdev))
@@ -1830,8 +1846,10 @@ static int nicvf_xdp_setup(struct nicvf *nic, struct bpf_prog *prog) · 242 unmodified lines
18301846 bool bpf_attached = false;
18311847 int ret = 0;
18321848
1833− /* For now just support only the usual MTU sized frames */
1834− if (prog && (dev->mtu > 1500)) {
1849+ /* For now just support only the usual MTU sized frames,
1850+ * plus some headroom for VLAN, QinQ.
1851+ */
1852+ if (prog && dev->mtu > MAX_XDP_MTU) {
18351853 netdev_warn(dev, "Jumbo frames not yet supported with XDP, current MTU %d.\n",
18361854 dev->mtu);
18371855 return -EOPNOTSUPP;
drivers/net/ethernet/freescale/fec_main.c+21−9
@@ -1840,13 +1840,9 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) · 1839 unmodified lines
18401840 int ret;
18411841
18421842 if (enable) {
1843− ret = clk_prepare_enable(fep->clk_ahb);
1844− if (ret)
1845− return ret;
1846−
18471843 ret = clk_prepare_enable(fep->clk_enet_out);
18481844 if (ret)
1849− goto failed_clk_enet_out;
1845+ return ret;
18501846
18511847 if (fep->clk_ptp) {
18521848 mutex_lock(&fep->ptp_clk_mutex);
@@ -1866,7 +1862,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) · 13 unmodified lines
18661862
18671863 phy_reset_after_clk_enable(ndev->phydev);
18681864 } else {
1869− clk_disable_unprepare(fep->clk_ahb);
18701865 clk_disable_unprepare(fep->clk_enet_out);
18711866 if (fep->clk_ptp) {
18721867 mutex_lock(&fep->ptp_clk_mutex);
@@ -1885,8 +1880,6 @@ failed_clk_ref: · 12 unmodified lines
18851880 failed_clk_ptp:
18861881 if (fep->clk_enet_out)
18871882 clk_disable_unprepare(fep->clk_enet_out);
1888−failed_clk_enet_out:
1889− clk_disable_unprepare(fep->clk_ahb);
18901883
18911884 return ret;
18921885 }
@@ -3470,6 +3463,9 @@ fec_probe(struct platform_device *pdev) · 1577 unmodified lines
34703463 ret = clk_prepare_enable(fep->clk_ipg);
34713464 if (ret)
34723465 goto failed_clk_ipg;
3466+ ret = clk_prepare_enable(fep->clk_ahb);
3467+ if (ret)
3468+ goto failed_clk_ahb;
34733469
34743470 fep->reg_phy = devm_regulator_get_optional(&pdev->dev, "phy");
34753471 if (!IS_ERR(fep->reg_phy)) {
@@ -3563,6 +3559,9 @@ failed_reset: · 87 unmodified lines
35633559 pm_runtime_put(&pdev->dev);
35643560 pm_runtime_disable(&pdev->dev);
35653561 failed_regulator:
3562+ clk_disable_unprepare(fep->clk_ahb);
3563+failed_clk_ahb:
3564+ clk_disable_unprepare(fep->clk_ipg);
35663565 failed_clk_ipg:
35673566 fec_enet_clk_enable(ndev, false);
35683567 failed_clk:
@@ -3686,6 +3685,7 @@ static int __maybe_unused fec_runtime_suspend(struct device *dev) · 117 unmodified lines
36863685 struct net_device *ndev = dev_get_drvdata(dev);
36873686 struct fec_enet_private *fep = netdev_priv(ndev);
36883687
3688+ clk_disable_unprepare(fep->clk_ahb);
36893689 clk_disable_unprepare(fep->clk_ipg);
36903690
36913691 return 0;
@@ -3695,8 +3695,20 @@ static int __maybe_unused fec_runtime_resume(struct device *dev) · 3 unmodified lines
36953695 {
36963696 struct net_device *ndev = dev_get_drvdata(dev);
36973697 struct fec_enet_private *fep = netdev_priv(ndev);
3698+ int ret;
36983699
3699− return clk_prepare_enable(fep->clk_ipg);
3700+ ret = clk_prepare_enable(fep->clk_ahb);
3701+ if (ret)
3702+ return ret;
3703+ ret = clk_prepare_enable(fep->clk_ipg);
3704+ if (ret)
3705+ goto failed_clk_ipg;
3706+
3707+ return 0;
3708+
3709+failed_clk_ipg:
3710+ clk_disable_unprepare(fep->clk_ahb);
3711+ return ret;
37003712 }
37013713
37023714 static const struct dev_pm_ops fec_pm_ops = {
drivers/net/ethernet/ibm/ibmvnic.c+25−7
@@ -3758,6 +3758,7 @@ static void handle_query_ip_offload_rsp(struct ibmvnic_adapter *adapter) · 3757 unmodified lines
37583758 {
37593759 struct device *dev = &adapter->vdev->dev;
37603760 struct ibmvnic_query_ip_offload_buffer *buf = &adapter->ip_offload_buf;
3761+ netdev_features_t old_hw_features = 0;
37613762 union ibmvnic_crq crq;
37623763 int i;
37633764
@@ -3833,24 +3834,41 @@ static void handle_query_ip_offload_rsp(struct ibmvnic_adapter *adapter) · 69 unmodified lines
38333834 adapter->ip_offload_ctrl.large_rx_ipv4 = 0;
38343835 adapter->ip_offload_ctrl.large_rx_ipv6 = 0;
38353836
3836− adapter->netdev->features = NETIF_F_SG | NETIF_F_GSO;
3837+ if (adapter->state != VNIC_PROBING) {
3838+ old_hw_features = adapter->netdev->hw_features;
3839+ adapter->netdev->hw_features = 0;
3840+ }
3841+
3842+ adapter->netdev->hw_features = NETIF_F_SG | NETIF_F_GSO | NETIF_F_GRO;
38373843
38383844 if (buf->tcp_ipv4_chksum || buf->udp_ipv4_chksum)
3839− adapter->netdev->features |= NETIF_F_IP_CSUM;
3845+ adapter->netdev->hw_features |= NETIF_F_IP_CSUM;
38403846
38413847 if (buf->tcp_ipv6_chksum || buf->udp_ipv6_chksum)
3842− adapter->netdev->features |= NETIF_F_IPV6_CSUM;
3848+ adapter->netdev->hw_features |= NETIF_F_IPV6_CSUM;
38433849
38443850 if ((adapter->netdev->features &
38453851 (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)))
3846− adapter->netdev->features |= NETIF_F_RXCSUM;
3852+ adapter->netdev->hw_features |= NETIF_F_RXCSUM;
38473853
38483854 if (buf->large_tx_ipv4)
3849− adapter->netdev->features |= NETIF_F_TSO;
3855+ adapter->netdev->hw_features |= NETIF_F_TSO;
38503856 if (buf->large_tx_ipv6)
3851− adapter->netdev->features |= NETIF_F_TSO6;
3857+ adapter->netdev->hw_features |= NETIF_F_TSO6;
38523858
3853− adapter->netdev->hw_features |= adapter->netdev->features;
3859+ if (adapter->state == VNIC_PROBING) {
3860+ adapter->netdev->features |= adapter->netdev->hw_features;
3861+ } else if (old_hw_features != adapter->netdev->hw_features) {
3862+ netdev_features_t tmp = 0;
3863+
3864+ /* disable features no longer supported */
3865+ adapter->netdev->features &= adapter->netdev->hw_features;
3866+ /* turn on features now supported if previously enabled */
3867+ tmp = (old_hw_features ^ adapter->netdev->hw_features) &
3868+ adapter->netdev->hw_features;
3869+ adapter->netdev->features |=
3870+ tmp & adapter->netdev->wanted_features;
3871+ }
38543872
38553873 memset(&crq, 0, sizeof(crq));
38563874 crq.control_ip_offload.first = IBMVNIC_CRQ_CMD;
drivers/net/ethernet/mellanox/mlx5/core/en.h+1−0
@@ -856,6 +856,7 @@ void mlx5e_close_channels(struct mlx5e_channels *chs); · 855 unmodified lines
856856 * switching channels
857857 */
858858 typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv);
859+int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv);
859860 int mlx5e_safe_switch_channels(struct mlx5e_priv *priv,
860861 struct mlx5e_channels *new_chs,
861862 mlx5e_fp_hw_modify hw_modify);
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c+8−3
@@ -186,12 +186,17 @@ static int mlx5e_tx_reporter_recover_from_ctx(struct mlx5e_tx_err_ctx *err_ctx) · 185 unmodified lines
186186
187187 static int mlx5e_tx_reporter_recover_all(struct mlx5e_priv *priv)
188188 {
189− int err;
189+ int err = 0;
190190
191191 rtnl_lock();
192192 mutex_lock(&priv->state_lock);
193− mlx5e_close_locked(priv->netdev);
194− err = mlx5e_open_locked(priv->netdev);
193+
194+ if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
195+ goto out;
196+
197+ err = mlx5e_safe_reopen_channels(priv);
198+
199+out:
195200 mutex_unlock(&priv->state_lock);
196201 rtnl_unlock();
197202
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c+4−0
@@ -39,6 +39,10 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv, · 38 unmodified lines
3939 return -EOPNOTSUPP;
4040 }
4141
42+ if (!(mlx5e_eswitch_rep(*out_dev) &&
43+ mlx5e_is_uplink_rep(netdev_priv(*out_dev))))
44+ return -EOPNOTSUPP;
45+
4246 return 0;
4347 }
4448
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c+2−1
@@ -1768,7 +1768,8 @@ static int set_pflag_rx_no_csum_complete(struct net_device *netdev, bool enable) · 1767 unmodified lines
17681768 struct mlx5e_channel *c;
17691769 int i;
17701770
1771− if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
1771+ if (!test_bit(MLX5E_STATE_OPENED, &priv->state) ||
1772+ priv->channels.params.xdp_prog)
17721773 return 0;
17731774
17741775 for (i = 0; i < channels->num; i++) {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+16−5
@@ -952,7 +952,11 @@ static int mlx5e_open_rq(struct mlx5e_channel *c, · 951 unmodified lines
952952 if (params->rx_dim_enabled)
953953 __set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);
954954
955− if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE))
955+ /* We disable csum_complete when XDP is enabled since
956+ * XDP programs might manipulate packets which will render
957+ * skb->checksum incorrect.
958+ */
959+ if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE) || c->xdp)
956960 __set_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &c->rq.state);
957961
958962 return 0;
@@ -2956,6 +2960,14 @@ int mlx5e_safe_switch_channels(struct mlx5e_priv *priv, · 1997 unmodified lines
29562960 return 0;
29572961 }
29582962
2963+int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv)
2964+{
2965+ struct mlx5e_channels new_channels = {};
2966+
2967+ new_channels.params = priv->channels.params;
2968+ return mlx5e_safe_switch_channels(priv, &new_channels, NULL);
2969+}
2970+
29592971 void mlx5e_timestamp_init(struct mlx5e_priv *priv)
29602972 {
29612973 priv->tstamp.tx_type = HWTSTAMP_TX_OFF;
@@ -4186,11 +4198,10 @@ static void mlx5e_tx_timeout_work(struct work_struct *work) · 1224 unmodified lines
41864198 if (!report_failed)
41874199 goto unlock;
41884200
4189− mlx5e_close_locked(priv->netdev);
4190− err = mlx5e_open_locked(priv->netdev);
4201+ err = mlx5e_safe_reopen_channels(priv);
41914202 if (err)
41924203 netdev_err(priv->netdev,
4193− "mlx5e_open_locked failed recovering from a tx_timeout, err(%d).\n",
4204+ "mlx5e_safe_reopen_channels failed recovering from a tx_timeout, err(%d).\n",
41944205 err);
41954206
41964207 unlock:
@@ -4578,7 +4589,7 @@ void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params, · 381 unmodified lines
45784589 {
45794590 enum mlx5e_traffic_types tt;
45804591
4581− rss_params->hfunc = ETH_RSS_HASH_XOR;
4592+ rss_params->hfunc = ETH_RSS_HASH_TOP;
45824593 netdev_rss_key_fill(rss_params->toeplitz_hash_key,
45834594 sizeof(rss_params->toeplitz_hash_key));
45844595 mlx5e_build_default_indir_rqt(rss_params->indirection_rqt,
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c+75−19
@@ -692,7 +692,14 @@ static inline bool is_last_ethertype_ip(struct sk_buff *skb, int *network_depth, · 691 unmodified lines
692692 {
693693 *proto = ((struct ethhdr *)skb->data)->h_proto;
694694 *proto = __vlan_get_protocol(skb, *proto, network_depth);
695− return (*proto == htons(ETH_P_IP) || *proto == htons(ETH_P_IPV6));
695+
696+ if (*proto == htons(ETH_P_IP))
697+ return pskb_may_pull(skb, *network_depth + sizeof(struct iphdr));
698+
699+ if (*proto == htons(ETH_P_IPV6))
700+ return pskb_may_pull(skb, *network_depth + sizeof(struct ipv6hdr));
701+
702+ return false;
696703 }
697704
698705 static inline void mlx5e_enable_ecn(struct mlx5e_rq *rq, struct sk_buff *skb)
@@ -712,17 +719,6 @@ static inline void mlx5e_enable_ecn(struct mlx5e_rq *rq, struct sk_buff *skb) · 13 unmodified lines
712719 rq->stats->ecn_mark += !!rc;
713720 }
714721
715−static u32 mlx5e_get_fcs(const struct sk_buff *skb)
716−{
717− const void *fcs_bytes;
718− u32 _fcs_bytes;
719−
720− fcs_bytes = skb_header_pointer(skb, skb->len - ETH_FCS_LEN,
721− ETH_FCS_LEN, &_fcs_bytes);
722−
723− return __get_unaligned_cpu32(fcs_bytes);
724−}
725−
726722 static u8 get_ip_proto(struct sk_buff *skb, int network_depth, __be16 proto)
727723 {
728724 void *ip_p = skb->data + network_depth;
@@ -733,6 +729,68 @@ static u8 get_ip_proto(struct sk_buff *skb, int network_depth, __be16 proto) · 4 unmodified lines
733729
734730 #define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN)
735731
732+#define MAX_PADDING 8
733+
734+static void
735+tail_padding_csum_slow(struct sk_buff *skb, int offset, int len,
736+ struct mlx5e_rq_stats *stats)
737+{
738+ stats->csum_complete_tail_slow++;
739+ skb->csum = csum_block_add(skb->csum,
740+ skb_checksum(skb, offset, len, 0),
741+ offset);
742+}
743+
744+static void
745+tail_padding_csum(struct sk_buff *skb, int offset,
746+ struct mlx5e_rq_stats *stats)
747+{
748+ u8 tail_padding[MAX_PADDING];
749+ int len = skb->len - offset;
750+ void *tail;
751+
752+ if (unlikely(len > MAX_PADDING)) {
753+ tail_padding_csum_slow(skb, offset, len, stats);
754+ return;
755+ }
756+
757+ tail = skb_header_pointer(skb, offset, len, tail_padding);
758+ if (unlikely(!tail)) {
759+ tail_padding_csum_slow(skb, offset, len, stats);
760+ return;
761+ }
762+
763+ stats->csum_complete_tail++;
764+ skb->csum = csum_block_add(skb->csum, csum_partial(tail, len, 0), offset);
765+}
766+
767+static void
768+mlx5e_skb_padding_csum(struct sk_buff *skb, int network_depth, __be16 proto,
769+ struct mlx5e_rq_stats *stats)
770+{
771+ struct ipv6hdr *ip6;
772+ struct iphdr *ip4;
773+ int pkt_len;
774+
775+ switch (proto) {
776+ case htons(ETH_P_IP):
777+ ip4 = (struct iphdr *)(skb->data + network_depth);
778+ pkt_len = network_depth + ntohs(ip4->tot_len);
779+ break;
780+ case htons(ETH_P_IPV6):
781+ ip6 = (struct ipv6hdr *)(skb->data + network_depth);
782+ pkt_len = network_depth + sizeof(*ip6) + ntohs(ip6->payload_len);
783+ break;
784+ default:
785+ return;
786+ }
787+
788+ if (likely(pkt_len >= skb->len))
789+ return;
790+
791+ tail_padding_csum(skb, pkt_len, stats);
792+}
793+
736794 static inline void mlx5e_handle_csum(struct net_device *netdev,
737795 struct mlx5_cqe64 *cqe,
738796 struct mlx5e_rq *rq,
@@ -752,7 +810,8 @@ static inline void mlx5e_handle_csum(struct net_device *netdev, · 13 unmodified lines
752810 return;
753811 }
754812
755− if (unlikely(test_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &rq->state)))
813+ /* True when explicitly set via priv flag, or XDP prog is loaded */
814+ if (test_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &rq->state))
756815 goto csum_unnecessary;
757816
758817 /* CQE csum doesn't cover padding octets in short ethernet
@@ -780,18 +839,15 @@ static inline void mlx5e_handle_csum(struct net_device *netdev, · 21 unmodified lines
780839 skb->csum = csum_partial(skb->data + ETH_HLEN,
781840 network_depth - ETH_HLEN,
782841 skb->csum);
783− if (unlikely(netdev->features & NETIF_F_RXFCS))
784− skb->csum = csum_block_add(skb->csum,
785− (__force __wsum)mlx5e_get_fcs(skb),
786− skb->len - ETH_FCS_LEN);
842+
843+ mlx5e_skb_padding_csum(skb, network_depth, proto, stats);
787844 stats->csum_complete++;
788845 return;
789846 }
790847
791848 csum_unnecessary:
792849 if (likely((cqe->hds_ip_ext & CQE_L3_OK) &&
793− ((cqe->hds_ip_ext & CQE_L4_OK) ||
794− (get_cqe_l4_hdr_type(cqe) == CQE_L4_HDR_TYPE_NONE)))) {
850+ (cqe->hds_ip_ext & CQE_L4_OK))) {
795851 skb->ip_summed = CHECKSUM_UNNECESSARY;
796852 if (cqe_is_tunneled(cqe)) {
797853 skb->csum_level = 1;
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c+6−0
@@ -59,6 +59,8 @@ static const struct counter_desc sw_stats_desc[] = { · 58 unmodified lines
5959 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary) },
6060 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_none) },
6161 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete) },
62+ { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete_tail) },
63+ { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete_tail_slow) },
6264 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary_inner) },
6365 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_drop) },
6466 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_redirect) },
@@ -151,6 +153,8 @@ static void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv) · 86 unmodified lines
151153 s->rx_removed_vlan_packets += rq_stats->removed_vlan_packets;
152154 s->rx_csum_none += rq_stats->csum_none;
153155 s->rx_csum_complete += rq_stats->csum_complete;
156+ s->rx_csum_complete_tail += rq_stats->csum_complete_tail;
157+ s->rx_csum_complete_tail_slow += rq_stats->csum_complete_tail_slow;
154158 s->rx_csum_unnecessary += rq_stats->csum_unnecessary;
155159 s->rx_csum_unnecessary_inner += rq_stats->csum_unnecessary_inner;
156160 s->rx_xdp_drop += rq_stats->xdp_drop;
@@ -1190,6 +1194,8 @@ static const struct counter_desc rq_stats_desc[] = { · 1033 unmodified lines
11901194 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) },
11911195 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) },
11921196 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) },
1197+ { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete_tail) },
1198+ { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete_tail_slow) },
11931199 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary) },
11941200 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) },
11951201 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) },
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h+4−0
@@ -71,6 +71,8 @@ struct mlx5e_sw_stats { · 70 unmodified lines
7171 u64 rx_csum_unnecessary;
7272 u64 rx_csum_none;
7373 u64 rx_csum_complete;
74+ u64 rx_csum_complete_tail;
75+ u64 rx_csum_complete_tail_slow;
7476 u64 rx_csum_unnecessary_inner;
7577 u64 rx_xdp_drop;
7678 u64 rx_xdp_redirect;
@@ -181,6 +183,8 @@ struct mlx5e_rq_stats { · 104 unmodified lines
181183 u64 packets;
182184 u64 bytes;
183185 u64 csum_complete;
186+ u64 csum_complete_tail;
187+ u64 csum_complete_tail_slow;
184188 u64 csum_unnecessary;
185189 u64 csum_unnecessary_inner;
186190 u64 csum_none;
drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c+24−37
@@ -148,14 +148,16 @@ static int mlx5_fpga_tls_alloc_swid(struct idr *idr, spinlock_t *idr_spinlock, · 147 unmodified lines
148148 return ret;
149149 }
150150
151−static void mlx5_fpga_tls_release_swid(struct idr *idr,
152− spinlock_t *idr_spinlock, u32 swid)
151+static void *mlx5_fpga_tls_release_swid(struct idr *idr,
152+ spinlock_t *idr_spinlock, u32 swid)
153153 {
154154 unsigned long flags;
155+ void *ptr;
155156
156157 spin_lock_irqsave(idr_spinlock, flags);
157− idr_remove(idr, swid);
158+ ptr = idr_remove(idr, swid);
158159 spin_unlock_irqrestore(idr_spinlock, flags);
160+ return ptr;
159161 }
160162
161163 static void mlx_tls_kfree_complete(struct mlx5_fpga_conn *conn,
@@ -165,20 +167,12 @@ static void mlx_tls_kfree_complete(struct mlx5_fpga_conn *conn, · 3 unmodified lines
165167 kfree(buf);
166168 }
167169
168−struct mlx5_teardown_stream_context {
169− struct mlx5_fpga_tls_command_context cmd;
170− u32 swid;
171−};
172−
173170 static void
174171 mlx5_fpga_tls_teardown_completion(struct mlx5_fpga_conn *conn,
175172 struct mlx5_fpga_device *fdev,
176173 struct mlx5_fpga_tls_command_context *cmd,
177174 struct mlx5_fpga_dma_buf *resp)
178175 {
179− struct mlx5_teardown_stream_context *ctx =
180− container_of(cmd, struct mlx5_teardown_stream_context, cmd);
181−
182176 if (resp) {
183177 u32 syndrome = MLX5_GET(tls_resp, resp->sg[0].data, syndrome);
184178
@@ -186,14 +180,6 @@ mlx5_fpga_tls_teardown_completion(struct mlx5_fpga_conn *conn, · 1 unmodified line
186180 mlx5_fpga_err(fdev,
187181 "Teardown stream failed with syndrome = %d",
188182 syndrome);
189− else if (MLX5_GET(tls_cmd, cmd->buf.sg[0].data, direction_sx))
190− mlx5_fpga_tls_release_swid(&fdev->tls->tx_idr,
191− &fdev->tls->tx_idr_spinlock,
192− ctx->swid);
193− else
194− mlx5_fpga_tls_release_swid(&fdev->tls->rx_idr,
195− &fdev->tls->rx_idr_spinlock,
196− ctx->swid);
197183 }
198184 mlx5_fpga_tls_put_command_ctx(cmd);
199185 }
@@ -217,22 +203,22 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq, · 17 unmodified lines
217203 void *cmd;
218204 int ret;
219205
220− rcu_read_lock();
221− flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle));
222− rcu_read_unlock();
223−
224− if (!flow) {
225− WARN_ONCE(1, "Received NULL pointer for handle\n");
226− return -EINVAL;
227− }
228−
229206 buf = kzalloc(size, GFP_ATOMIC);
230207 if (!buf)
231208 return -ENOMEM;
232209
233210 cmd = (buf + 1);
234211
212+ rcu_read_lock();
213+ flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle));
214+ if (unlikely(!flow)) {
215+ rcu_read_unlock();
216+ WARN_ONCE(1, "Received NULL pointer for handle\n");
217+ kfree(buf);
218+ return -EINVAL;
219+ }
235220 mlx5_fpga_tls_flow_to_cmd(flow, cmd);
221+ rcu_read_unlock();
236222
237223 MLX5_SET(tls_cmd, cmd, swid, ntohl(handle));
238224 MLX5_SET64(tls_cmd, cmd, tls_rcd_sn, be64_to_cpu(rcd_sn));
@@ -253,7 +239,7 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq, · 14 unmodified lines
253239 static void mlx5_fpga_tls_send_teardown_cmd(struct mlx5_core_dev *mdev,
254240 void *flow, u32 swid, gfp_t flags)
255241 {
256− struct mlx5_teardown_stream_context *ctx;
242+ struct mlx5_fpga_tls_command_context *ctx;
257243 struct mlx5_fpga_dma_buf *buf;
258244 void *cmd;
259245
@@ -261,7 +247,7 @@ static void mlx5_fpga_tls_send_teardown_cmd(struct mlx5_core_dev *mdev, · 1 unmodified line
261247 if (!ctx)
262248 return;
263249
264− buf = &ctx->cmd.buf;
250+ buf = &ctx->buf;
265251 cmd = (ctx + 1);
266252 MLX5_SET(tls_cmd, cmd, command_type, CMD_TEARDOWN_STREAM);
267253 MLX5_SET(tls_cmd, cmd, swid, swid);
@@ -272,8 +258,7 @@ static void mlx5_fpga_tls_send_teardown_cmd(struct mlx5_core_dev *mdev, · 4 unmodified lines
272258 buf->sg[0].data = cmd;
273259 buf->sg[0].size = MLX5_TLS_COMMAND_SIZE;
274260
275− ctx->swid = swid;
276− mlx5_fpga_tls_cmd_send(mdev->fpga, &ctx->cmd,
261+ mlx5_fpga_tls_cmd_send(mdev->fpga, ctx,
277262 mlx5_fpga_tls_teardown_completion);
278263 }
279264
@@ -283,13 +268,14 @@ void mlx5_fpga_tls_del_flow(struct mlx5_core_dev *mdev, u32 swid, · 3 unmodified lines
283268 struct mlx5_fpga_tls *tls = mdev->fpga->tls;
284269 void *flow;
285270
286− rcu_read_lock();
287271 if (direction_sx)
288− flow = idr_find(&tls->tx_idr, swid);
272+ flow = mlx5_fpga_tls_release_swid(&tls->tx_idr,
273+ &tls->tx_idr_spinlock,
274+ swid);
289275 else
290− flow = idr_find(&tls->rx_idr, swid);
291−
292− rcu_read_unlock();
276+ flow = mlx5_fpga_tls_release_swid(&tls->rx_idr,
277+ &tls->rx_idr_spinlock,
278+ swid);
293279
294280 if (!flow) {
295281 mlx5_fpga_err(mdev->fpga, "No flow information for swid %u\n",
@@ -297,6 +283,7 @@ void mlx5_fpga_tls_del_flow(struct mlx5_core_dev *mdev, u32 swid, · 1 unmodified line
297283 return;
298284 }
299285
286+ synchronize_rcu(); /* before kfree(flow) */
300287 mlx5_fpga_tls_send_teardown_cmd(mdev, flow, swid, flags);
301288 }
302289
drivers/net/ethernet/mellanox/mlxsw/core.c+3−3
@@ -568,7 +568,7 @@ static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core) · 567 unmodified lines
568568 if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
569569 return 0;
570570
571− emad_wq = alloc_workqueue("mlxsw_core_emad", WQ_MEM_RECLAIM, 0);
571+ emad_wq = alloc_workqueue("mlxsw_core_emad", 0, 0);
572572 if (!emad_wq)
573573 return -ENOMEM;
574574 mlxsw_core->emad_wq = emad_wq;
@@ -2004,10 +2004,10 @@ static int __init mlxsw_core_module_init(void) · 1429 unmodified lines
20042004 {
20052005 int err;
20062006
2007− mlxsw_wq = alloc_workqueue(mlxsw_core_driver_name, WQ_MEM_RECLAIM, 0);
2007+ mlxsw_wq = alloc_workqueue(mlxsw_core_driver_name, 0, 0);
20082008 if (!mlxsw_wq)
20092009 return -ENOMEM;
2010− mlxsw_owq = alloc_ordered_workqueue("%s_ordered", WQ_MEM_RECLAIM,
2010+ mlxsw_owq = alloc_ordered_workqueue("%s_ordered", 0,
20112011 mlxsw_core_driver_name);
20122012 if (!mlxsw_owq) {
20132013 err = -ENOMEM;
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c+11−8
@@ -70,6 +70,7 @@ static const struct mlxsw_sp_sb_pool_des mlxsw_sp2_sb_pool_dess[] = { · 69 unmodified lines
7070 {MLXSW_REG_SBXX_DIR_EGRESS, 1},
7171 {MLXSW_REG_SBXX_DIR_EGRESS, 2},
7272 {MLXSW_REG_SBXX_DIR_EGRESS, 3},
73+ {MLXSW_REG_SBXX_DIR_EGRESS, 15},
7374 };
7475
7576 #define MLXSW_SP_SB_ING_TC_COUNT 8
@@ -428,6 +429,7 @@ static const struct mlxsw_sp_sb_pr mlxsw_sp2_sb_prs[] = { · 352 unmodified lines
428429 MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
429430 MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
430431 MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
432+ MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, MLXSW_SP_SB_INFI),
431433 };
432434
433435 static int mlxsw_sp_sb_prs_init(struct mlxsw_sp *mlxsw_sp,
@@ -517,14 +519,14 @@ static const struct mlxsw_sp_sb_cm mlxsw_sp2_sb_cms_egress[] = { · 83 unmodified lines
517519 MLXSW_SP_SB_CM(0, 7, 4),
518520 MLXSW_SP_SB_CM(0, 7, 4),
519521 MLXSW_SP_SB_CM(0, 7, 4),
520− MLXSW_SP_SB_CM(0, 7, 4),
521− MLXSW_SP_SB_CM(0, 7, 4),
522− MLXSW_SP_SB_CM(0, 7, 4),
523− MLXSW_SP_SB_CM(0, 7, 4),
524− MLXSW_SP_SB_CM(0, 7, 4),
525− MLXSW_SP_SB_CM(0, 7, 4),
526− MLXSW_SP_SB_CM(0, 7, 4),
527− MLXSW_SP_SB_CM(0, 7, 4),
522+ MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8),
523+ MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8),
524+ MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8),
525+ MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8),
526+ MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8),
527+ MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8),
528+ MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8),
529+ MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8),
528530 MLXSW_SP_SB_CM(1, 0xff, 4),
529531 };
530532
@@ -671,6 +673,7 @@ static const struct mlxsw_sp_sb_pm mlxsw_sp2_sb_pms[] = { · 140 unmodified lines
671673 MLXSW_SP_SB_PM(0, 0),
672674 MLXSW_SP_SB_PM(0, 0),
673675 MLXSW_SP_SB_PM(0, 0),
676+ MLXSW_SP_SB_PM(10000, 90000),
674677 };
675678
676679 static int mlxsw_sp_port_sb_pms_init(struct mlxsw_sp_port *mlxsw_sp_port)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c+1−1
@@ -6804,7 +6804,7 @@ static int mlxsw_sp_router_port_check_rif_addr(struct mlxsw_sp *mlxsw_sp, · 6803 unmodified lines
68046804 /* A RIF is not created for macvlan netdevs. Their MAC is used to
68056805 * populate the FDB
68066806 */
6807− if (netif_is_macvlan(dev))
6807+ if (netif_is_macvlan(dev) || netif_is_l3_master(dev))
68086808 return 0;
68096809
68106810 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) {
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c+1−1
@@ -1630,7 +1630,7 @@ static int mlxsw_sp_port_mdb_add(struct mlxsw_sp_port *mlxsw_sp_port, · 1629 unmodified lines
16301630 u16 fid_index;
16311631 int err = 0;
16321632
1633− if (switchdev_trans_ph_prepare(trans))
1633+ if (switchdev_trans_ph_commit(trans))
16341634 return 0;
16351635
16361636 bridge_port = mlxsw_sp_bridge_port_find(mlxsw_sp->bridge, orig_dev);
drivers/net/ethernet/mscc/ocelot.c+15−9
@@ -613,7 +613,7 @@ static int ocelot_mact_mc_add(struct ocelot_port *port, · 612 unmodified lines
613613 struct netdev_hw_addr *hw_addr)
614614 {
615615 struct ocelot *ocelot = port->ocelot;
616− struct netdev_hw_addr *ha = kzalloc(sizeof(*ha), GFP_KERNEL);
616+ struct netdev_hw_addr *ha = kzalloc(sizeof(*ha), GFP_ATOMIC);
617617
618618 if (!ha)
619619 return -ENOMEM;
@@ -959,10 +959,8 @@ static void ocelot_get_strings(struct net_device *netdev, u32 sset, u8 *data) · 339 unmodified lines
959959 ETH_GSTRING_LEN);
960960 }
961961
962−static void ocelot_check_stats(struct work_struct *work)
962+static void ocelot_update_stats(struct ocelot *ocelot)
963963 {
964− struct delayed_work *del_work = to_delayed_work(work);
965− struct ocelot *ocelot = container_of(del_work, struct ocelot, stats_work);
966964 int i, j;
967965
968966 mutex_lock(&ocelot->stats_lock);
@@ -986,11 +984,19 @@ static void ocelot_check_stats(struct work_struct *work) · 17 unmodified lines
986984 }
987985 }
988986
989− cancel_delayed_work(&ocelot->stats_work);
987+ mutex_unlock(&ocelot->stats_lock);
988+}
989+
990+static void ocelot_check_stats_work(struct work_struct *work)
991+{
992+ struct delayed_work *del_work = to_delayed_work(work);
993+ struct ocelot *ocelot = container_of(del_work, struct ocelot,
994+ stats_work);
995+
996+ ocelot_update_stats(ocelot);
997+
990998 queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work,
991999 OCELOT_STATS_CHECK_DELAY);
992−
993− mutex_unlock(&ocelot->stats_lock);
9941000 }
9951001
9961002 static void ocelot_get_ethtool_stats(struct net_device *dev,
@@ -1001,7 +1007,7 @@ static void ocelot_get_ethtool_stats(struct net_device *dev, · 4 unmodified lines
10011007 int i;
10021008
10031009 /* check and update now */
1004− ocelot_check_stats(&ocelot->stats_work.work);
1010+ ocelot_update_stats(ocelot);
10051011
10061012 /* Copy all counters */
10071013 for (i = 0; i < ocelot->num_stats; i++)
@@ -1809,7 +1815,7 @@ int ocelot_init(struct ocelot *ocelot) · 801 unmodified lines
18091815 ANA_CPUQ_8021_CFG_CPUQ_BPDU_VAL(6),
18101816 ANA_CPUQ_8021_CFG, i);
18111817
1812− INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats);
1818+ INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats_work);
18131819 queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work,
18141820 OCELOT_STATS_CHECK_DELAY);
18151821 return 0;
drivers/net/ethernet/neterion/vxge/vxge-config.c+1−0
@@ -2366,6 +2366,7 @@ static void *__vxge_hw_blockpool_malloc(struct __vxge_hw_device *devh, u32 size, · 2365 unmodified lines
23662366 dma_object->addr))) {
23672367 vxge_os_dma_free(devh->pdev, memblock,
23682368 &dma_object->acc_handle);
2369+ memblock = NULL;
23692370 goto exit;
23702371 }
23712372
drivers/net/ethernet/qlogic/qed/qed.h+5−2
@@ -431,12 +431,16 @@ struct qed_qm_info { · 430 unmodified lines
431431 u8 num_pf_rls;
432432 };
433433
434+#define QED_OVERFLOW_BIT 1
435+
434436 struct qed_db_recovery_info {
435437 struct list_head list;
436438
437439 /* Lock to protect the doorbell recovery mechanism list */
438440 spinlock_t lock;
441+ bool dorq_attn;
439442 u32 db_recovery_counter;
443+ unsigned long overflow;
440444 };
441445
442446 struct storm_stats {
@@ -923,8 +927,7 @@ u16 qed_get_cm_pq_idx_llt_mtc(struct qed_hwfn *p_hwfn, u8 tc); · 480 unmodified lines
923927
924928 /* doorbell recovery mechanism */
925929 void qed_db_recovery_dp(struct qed_hwfn *p_hwfn);
926−void qed_db_recovery_execute(struct qed_hwfn *p_hwfn,
927− enum qed_db_rec_exec db_exec);
930+void qed_db_recovery_execute(struct qed_hwfn *p_hwfn);
928931 bool qed_edpm_enabled(struct qed_hwfn *p_hwfn);
929932
930933 /* Other Linux specific common definitions */
drivers/net/ethernet/qlogic/qed/qed_dev.c+34−51
@@ -102,11 +102,15 @@ static void qed_db_recovery_dp_entry(struct qed_hwfn *p_hwfn, · 101 unmodified lines
102102
103103 /* Doorbell address sanity (address within doorbell bar range) */
104104 static bool qed_db_rec_sanity(struct qed_dev *cdev,
105− void __iomem *db_addr, void *db_data)
105+ void __iomem *db_addr,
106+ enum qed_db_rec_width db_width,
107+ void *db_data)
106108 {
109+ u32 width = (db_width == DB_REC_WIDTH_32B) ? 32 : 64;
110+
107111 /* Make sure doorbell address is within the doorbell bar */
108112 if (db_addr < cdev->doorbells ||
109− (u8 __iomem *)db_addr >
113+ (u8 __iomem *)db_addr + width >
110114 (u8 __iomem *)cdev->doorbells + cdev->db_size) {
111115 WARN(true,
112116 "Illegal doorbell address: %p. Legal range for doorbell addresses is [%p..%p]\n",
@@ -159,7 +163,7 @@ int qed_db_recovery_add(struct qed_dev *cdev, · 46 unmodified lines
159163 }
160164
161165 /* Sanitize doorbell address */
162− if (!qed_db_rec_sanity(cdev, db_addr, db_data))
166+ if (!qed_db_rec_sanity(cdev, db_addr, db_width, db_data))
163167 return -EINVAL;
164168
165169 /* Obtain hwfn from doorbell address */
@@ -205,10 +209,6 @@ int qed_db_recovery_del(struct qed_dev *cdev, · 39 unmodified lines
205209 return 0;
206210 }
207211
208− /* Sanitize doorbell address */
209− if (!qed_db_rec_sanity(cdev, db_addr, db_data))
210− return -EINVAL;
211−
212212 /* Obtain hwfn from doorbell address */
213213 p_hwfn = qed_db_rec_find_hwfn(cdev, db_addr);
214214
@@ -300,31 +300,24 @@ void qed_db_recovery_dp(struct qed_hwfn *p_hwfn) · 85 unmodified lines
300300
301301 /* Ring the doorbell of a single doorbell recovery entry */
302302 static void qed_db_recovery_ring(struct qed_hwfn *p_hwfn,
303− struct qed_db_recovery_entry *db_entry,
304− enum qed_db_rec_exec db_exec)
305−{
306− if (db_exec != DB_REC_ONCE) {
307− /* Print according to width */
308− if (db_entry->db_width == DB_REC_WIDTH_32B) {
309− DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
310− "%s doorbell address %p data %x\n",
311− db_exec == DB_REC_DRY_RUN ?
312− "would have rung" : "ringing",
313− db_entry->db_addr,
314− *(u32 *)db_entry->db_data);
315− } else {
316− DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
317− "%s doorbell address %p data %llx\n",
318− db_exec == DB_REC_DRY_RUN ?
319− "would have rung" : "ringing",
320− db_entry->db_addr,
321− *(u64 *)(db_entry->db_data));
322− }
303+ struct qed_db_recovery_entry *db_entry)
304+{
305+ /* Print according to width */
306+ if (db_entry->db_width == DB_REC_WIDTH_32B) {
307+ DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
308+ "ringing doorbell address %p data %x\n",
309+ db_entry->db_addr,
310+ *(u32 *)db_entry->db_data);
311+ } else {
312+ DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
313+ "ringing doorbell address %p data %llx\n",
314+ db_entry->db_addr,
315+ *(u64 *)(db_entry->db_data));
323316 }
324317
325318 /* Sanity */
326319 if (!qed_db_rec_sanity(p_hwfn->cdev, db_entry->db_addr,
327− db_entry->db_data))
320+ db_entry->db_width, db_entry->db_data))
328321 return;
329322
330323 /* Flush the write combined buffer. Since there are multiple doorbelling
@@ -334,14 +327,12 @@ static void qed_db_recovery_ring(struct qed_hwfn *p_hwfn, · 3 unmodified lines
334327 wmb();
335328
336329 /* Ring the doorbell */
337− if (db_exec == DB_REC_REAL_DEAL || db_exec == DB_REC_ONCE) {
338− if (db_entry->db_width == DB_REC_WIDTH_32B)
339− DIRECT_REG_WR(db_entry->db_addr,
340− *(u32 *)(db_entry->db_data));
341− else
342− DIRECT_REG_WR64(db_entry->db_addr,
343− *(u64 *)(db_entry->db_data));
344− }
330+ if (db_entry->db_width == DB_REC_WIDTH_32B)
331+ DIRECT_REG_WR(db_entry->db_addr,
332+ *(u32 *)(db_entry->db_data));
333+ else
334+ DIRECT_REG_WR64(db_entry->db_addr,
335+ *(u64 *)(db_entry->db_data));
345336
346337 /* Flush the write combined buffer. Next doorbell may come from a
347338 * different entity to the same address...
@@ -350,29 +341,21 @@ static void qed_db_recovery_ring(struct qed_hwfn *p_hwfn, · 2 unmodified lines
350341 }
351342
352343 /* Traverse the doorbell recovery entry list and ring all the doorbells */
353−void qed_db_recovery_execute(struct qed_hwfn *p_hwfn,
354− enum qed_db_rec_exec db_exec)
344+void qed_db_recovery_execute(struct qed_hwfn *p_hwfn)
355345 {
356346 struct qed_db_recovery_entry *db_entry = NULL;
357347
358− if (db_exec != DB_REC_ONCE) {
359− DP_NOTICE(p_hwfn,
360− "Executing doorbell recovery. Counter was %d\n",
361− p_hwfn->db_recovery_info.db_recovery_counter);
348+ DP_NOTICE(p_hwfn, "Executing doorbell recovery. Counter was %d\n",
349+ p_hwfn->db_recovery_info.db_recovery_counter);
362350
363− /* Track amount of times recovery was executed */
364− p_hwfn->db_recovery_info.db_recovery_counter++;
365− }
351+ /* Track amount of times recovery was executed */
352+ p_hwfn->db_recovery_info.db_recovery_counter++;
366353
367354 /* Protect the list */
368355 spin_lock_bh(&p_hwfn->db_recovery_info.lock);
369356 list_for_each_entry(db_entry,
370− &p_hwfn->db_recovery_info.list, list_entry) {
371− qed_db_recovery_ring(p_hwfn, db_entry, db_exec);
372− if (db_exec == DB_REC_ONCE)
373− break;
374− }
375−
357+ &p_hwfn->db_recovery_info.list, list_entry)
358+ qed_db_recovery_ring(p_hwfn, db_entry);
376359 spin_unlock_bh(&p_hwfn->db_recovery_info.lock);
377360 }
378361
drivers/net/ethernet/qlogic/qed/qed_int.c+63−20
@@ -378,6 +378,9 @@ static int qed_db_rec_flush_queue(struct qed_hwfn *p_hwfn, · 377 unmodified lines
378378 u32 count = QED_DB_REC_COUNT;
379379 u32 usage = 1;
380380
381+ /* Flush any pending (e)dpms as they may never arrive */
382+ qed_wr(p_hwfn, p_ptt, DORQ_REG_DPM_FORCE_ABORT, 0x1);
383+
381384 /* wait for usage to zero or count to run out. This is necessary since
382385 * EDPM doorbell transactions can take multiple 64b cycles, and as such
383386 * can "split" over the pci. Possibly, the doorbell drop can happen with
@@ -406,51 +409,74 @@ static int qed_db_rec_flush_queue(struct qed_hwfn *p_hwfn, · 22 unmodified lines
406409
407410 int qed_db_rec_handler(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
408411 {
409− u32 overflow;
412+ u32 attn_ovfl, cur_ovfl;
410413 int rc;
411414
412− overflow = qed_rd(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY);
413− DP_NOTICE(p_hwfn, "PF Overflow sticky 0x%x\n", overflow);
414− if (!overflow) {
415− qed_db_recovery_execute(p_hwfn, DB_REC_ONCE);
415+ attn_ovfl = test_and_clear_bit(QED_OVERFLOW_BIT,
416+ &p_hwfn->db_recovery_info.overflow);
417+ cur_ovfl = qed_rd(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY);
418+ if (!cur_ovfl && !attn_ovfl)
416419 return 0;
417− }
418420
419− if (qed_edpm_enabled(p_hwfn)) {
421+ DP_NOTICE(p_hwfn, "PF Overflow sticky: attn %u current %u\n",
422+ attn_ovfl, cur_ovfl);
423+
424+ if (cur_ovfl && !p_hwfn->db_bar_no_edpm) {
420425 rc = qed_db_rec_flush_queue(p_hwfn, p_ptt);
421426 if (rc)
422427 return rc;
423428 }
424429
425− /* Flush any pending (e)dpm as they may never arrive */
426− qed_wr(p_hwfn, p_ptt, DORQ_REG_DPM_FORCE_ABORT, 0x1);
427−
428430 /* Release overflow sticky indication (stop silently dropping everything) */
429431 qed_wr(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY, 0x0);
430432
431433 /* Repeat all last doorbells (doorbell drop recovery) */
432− qed_db_recovery_execute(p_hwfn, DB_REC_REAL_DEAL);
434+ qed_db_recovery_execute(p_hwfn);
433435
434436 return 0;
435437 }
436438
437−static int qed_dorq_attn_cb(struct qed_hwfn *p_hwfn)
439+static void qed_dorq_attn_overflow(struct qed_hwfn *p_hwfn)
438440 {
439− u32 int_sts, first_drop_reason, details, address, all_drops_reason;
440441 struct qed_ptt *p_ptt = p_hwfn->p_dpc_ptt;
442+ u32 overflow;
441443 int rc;
442444
443− int_sts = qed_rd(p_hwfn, p_ptt, DORQ_REG_INT_STS);
444− DP_NOTICE(p_hwfn->cdev, "DORQ attention. int_sts was %x\n", int_sts);
445+ overflow = qed_rd(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY);
446+ if (!overflow)
447+ goto out;
448+
449+ /* Run PF doorbell recovery in next periodic handler */
450+ set_bit(QED_OVERFLOW_BIT, &p_hwfn->db_recovery_info.overflow);
451+
452+ if (!p_hwfn->db_bar_no_edpm) {
453+ rc = qed_db_rec_flush_queue(p_hwfn, p_ptt);
454+ if (rc)
455+ goto out;
456+ }
457+
458+ qed_wr(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY, 0x0);
459+out:
460+ /* Schedule the handler even if overflow was not detected */
461+ qed_periodic_db_rec_start(p_hwfn);
462+}
463+
464+static int qed_dorq_attn_int_sts(struct qed_hwfn *p_hwfn)
465+{
466+ u32 int_sts, first_drop_reason, details, address, all_drops_reason;
467+ struct qed_ptt *p_ptt = p_hwfn->p_dpc_ptt;
445468
446469 /* int_sts may be zero since all PFs were interrupted for doorbell
447470 * overflow but another one already handled it. Can abort here. If
448471 * This PF also requires overflow recovery we will be interrupted again.
449472 * The masked almost full indication may also be set. Ignoring.
450473 */
474+ int_sts = qed_rd(p_hwfn, p_ptt, DORQ_REG_INT_STS);
451475 if (!(int_sts & ~DORQ_REG_INT_STS_DORQ_FIFO_AFULL))
452476 return 0;
453477
478+ DP_NOTICE(p_hwfn->cdev, "DORQ attention. int_sts was %x\n", int_sts);
479+
454480 /* check if db_drop or overflow happened */
455481 if (int_sts & (DORQ_REG_INT_STS_DB_DROP |
456482 DORQ_REG_INT_STS_DORQ_FIFO_OVFL_ERR)) {
@@ -477,11 +503,6 @@ static int qed_dorq_attn_cb(struct qed_hwfn *p_hwfn) · 20 unmodified lines
477503 GET_FIELD(details, QED_DORQ_ATTENTION_SIZE) * 4,
478504 first_drop_reason, all_drops_reason);
479505
480− rc = qed_db_rec_handler(p_hwfn, p_ptt);
481− qed_periodic_db_rec_start(p_hwfn);
482− if (rc)
483− return rc;
484−
485506 /* Clear the doorbell drop details and prepare for next drop */
486507 qed_wr(p_hwfn, p_ptt, DORQ_REG_DB_DROP_DETAILS_REL, 0);
487508
@@ -507,6 +528,25 @@ static int qed_dorq_attn_cb(struct qed_hwfn *p_hwfn) · 19 unmodified lines
507528 return -EINVAL;
508529 }
509530
531+static int qed_dorq_attn_cb(struct qed_hwfn *p_hwfn)
532+{
533+ p_hwfn->db_recovery_info.dorq_attn = true;
534+ qed_dorq_attn_overflow(p_hwfn);
535+
536+ return qed_dorq_attn_int_sts(p_hwfn);
537+}
538+
539+static void qed_dorq_attn_handler(struct qed_hwfn *p_hwfn)
540+{
541+ if (p_hwfn->db_recovery_info.dorq_attn)
542+ goto out;
543+
544+ /* Call DORQ callback if the attention was missed */
545+ qed_dorq_attn_cb(p_hwfn);
546+out:
547+ p_hwfn->db_recovery_info.dorq_attn = false;
548+}
549+
510550 /* Instead of major changes to the data-structure, we have a some 'special'
511551 * identifiers for sources that changed meaning between adapters.
512552 */
@@ -1080,6 +1120,9 @@ static int qed_int_deassertion(struct qed_hwfn *p_hwfn, · 567 unmodified lines
10801120 }
10811121 }
10821122
1123+ /* Handle missed DORQ attention */
1124+ qed_dorq_attn_handler(p_hwfn);
1125+
10831126 /* Clear IGU indication for the deasserted bits */
10841127 DIRECT_REG_WR((u8 __iomem *)p_hwfn->regview +
10851128 GTT_BAR0_MAP_REG_IGU_CMD +
drivers/net/ethernet/qlogic/qed/qed_int.h+2−2
@@ -192,8 +192,8 @@ void qed_int_disable_post_isr_release(struct qed_dev *cdev); · 191 unmodified lines
192192
193193 /**
194194 * @brief - Doorbell Recovery handler.
195− * Run DB_REAL_DEAL doorbell recovery in case of PF overflow
196− * (and flush DORQ if needed), otherwise run DB_REC_ONCE.
195+ * Run doorbell recovery in case of PF overflow (and flush DORQ if
196+ * needed).
197197 *
198198 * @param p_hwfn
199199 * @param p_ptt
drivers/net/ethernet/qlogic/qed/qed_main.c+1−1
@@ -970,7 +970,7 @@ static void qed_update_pf_params(struct qed_dev *cdev, · 969 unmodified lines
970970 }
971971 }
972972
973−#define QED_PERIODIC_DB_REC_COUNT 100
973+#define QED_PERIODIC_DB_REC_COUNT 10
974974 #define QED_PERIODIC_DB_REC_INTERVAL_MS 100
975975 #define QED_PERIODIC_DB_REC_INTERVAL \
976976 msecs_to_jiffies(QED_PERIODIC_DB_REC_INTERVAL_MS)
drivers/net/ethernet/qlogic/qed/qed_sriov.c+1−1
@@ -1591,7 +1591,7 @@ static void qed_iov_vf_mbx_acquire(struct qed_hwfn *p_hwfn, · 1590 unmodified lines
15911591 p_vfdev->eth_fp_hsi_minor = ETH_HSI_VER_NO_PKT_LEN_TUNN;
15921592 } else {
15931593 DP_INFO(p_hwfn,
1594− "VF[%d] needs fastpath HSI %02x.%02x, which is incompatible with loaded FW's faspath HSI %02x.%02x\n",
1594+ "VF[%d] needs fastpath HSI %02x.%02x, which is incompatible with loaded FW's fastpath HSI %02x.%02x\n",
15951595 vf->abs_vf_id,
15961596 req->vfdev_info.eth_fp_hsi_major,
15971597 req->vfdev_info.eth_fp_hsi_minor,
drivers/net/ethernet/qlogic/qede/qede_ptp.c+3−4
@@ -490,18 +490,17 @@ int qede_ptp_enable(struct qede_dev *edev, bool init_tc) · 489 unmodified lines
490490
491491 ptp->clock = ptp_clock_register(&ptp->clock_info, &edev->pdev->dev);
492492 if (IS_ERR(ptp->clock)) {
493− rc = -EINVAL;
494493 DP_ERR(edev, "PTP clock registration failed\n");
494+ qede_ptp_disable(edev);
495+ rc = -EINVAL;
495496 goto err2;
496497 }
497498
498499 return 0;
499500
500−err2:
501− qede_ptp_disable(edev);
502− ptp->clock = NULL;
503501 err1:
504502 kfree(ptp);
503+err2:
505504 edev->ptp = NULL;
506505
507506 return rc;
drivers/net/team/team.c+26−0
@@ -1244,6 +1244,23 @@ static int team_port_add(struct team *team, struct net_device *port_dev, · 1243 unmodified lines
12441244 goto err_option_port_add;
12451245 }
12461246
1247+ /* set promiscuity level to new slave */
1248+ if (dev->flags & IFF_PROMISC) {
1249+ err = dev_set_promiscuity(port_dev, 1);
1250+ if (err)
1251+ goto err_set_slave_promisc;
1252+ }
1253+
1254+ /* set allmulti level to new slave */
1255+ if (dev->flags & IFF_ALLMULTI) {
1256+ err = dev_set_allmulti(port_dev, 1);
1257+ if (err) {
1258+ if (dev->flags & IFF_PROMISC)
1259+ dev_set_promiscuity(port_dev, -1);
1260+ goto err_set_slave_promisc;
1261+ }
1262+ }
1263+
12471264 netif_addr_lock_bh(dev);
12481265 dev_uc_sync_multiple(port_dev, dev);
12491266 dev_mc_sync_multiple(port_dev, dev);
@@ -1260,6 +1277,9 @@ static int team_port_add(struct team *team, struct net_device *port_dev, · 10 unmodified lines
12601277
12611278 return 0;
12621279
1280+err_set_slave_promisc:
1281+ __team_option_inst_del_port(team, port);
1282+
12631283 err_option_port_add:
12641284 team_upper_dev_unlink(team, port);
12651285
@@ -1305,6 +1325,12 @@ static int team_port_del(struct team *team, struct net_device *port_dev) · 39 unmodified lines
13051325
13061326 team_port_disable(team, port);
13071327 list_del_rcu(&port->list);
1328+
1329+ if (dev->flags & IFF_PROMISC)
1330+ dev_set_promiscuity(port_dev, -1);
1331+ if (dev->flags & IFF_ALLMULTI)
1332+ dev_set_allmulti(port_dev, -1);
1333+
13081334 team_upper_dev_unlink(team, port);
13091335 netdev_rx_handler_unregister(port_dev);
13101336 team_port_disable_netpoll(port);
drivers/net/wireless/ath/ath10k/htt_rx.c+1−1
@@ -2728,7 +2728,7 @@ static void ath10k_htt_rx_tx_fetch_ind(struct ath10k *ar, struct sk_buff *skb) · 2727 unmodified lines
27282728 num_msdus++;
27292729 num_bytes += ret;
27302730 }
2731− ieee80211_return_txq(hw, txq);
2731+ ieee80211_return_txq(hw, txq, false);
27322732 ieee80211_txq_schedule_end(hw, txq->ac);
27332733
27342734 record->num_msdus = cpu_to_le16(num_msdus);
drivers/net/wireless/ath/ath10k/mac.c+2−2
@@ -4089,7 +4089,7 @@ static int ath10k_mac_schedule_txq(struct ieee80211_hw *hw, u32 ac) · 4088 unmodified lines
40894089 if (ret < 0)
40904090 break;
40914091 }
4092− ieee80211_return_txq(hw, txq);
4092+ ieee80211_return_txq(hw, txq, false);
40934093 ath10k_htt_tx_txq_update(hw, txq);
40944094 if (ret == -EBUSY)
40954095 break;
@@ -4374,7 +4374,7 @@ static void ath10k_mac_op_wake_tx_queue(struct ieee80211_hw *hw, · 278 unmodified lines
43744374 if (ret < 0)
43754375 break;
43764376 }
4377− ieee80211_return_txq(hw, txq);
4377+ ieee80211_return_txq(hw, txq, false);
43784378 ath10k_htt_tx_txq_update(hw, txq);
43794379 out:
43804380 ieee80211_txq_schedule_end(hw, ac);
drivers/net/wireless/ath/ath9k/xmit.c+4−1
@@ -1938,12 +1938,15 @@ void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq) · 1937 unmodified lines
19381938 goto out;
19391939
19401940 while ((queue = ieee80211_next_txq(hw, txq->mac80211_qnum))) {
1941+ bool force;
1942+
19411943 tid = (struct ath_atx_tid *)queue->drv_priv;
19421944
19431945 ret = ath_tx_sched_aggr(sc, txq, tid);
19441946 ath_dbg(common, QUEUE, "ath_tx_sched_aggr returned %d\n", ret);
19451947
1946− ieee80211_return_txq(hw, queue);
1948+ force = !skb_queue_empty(&tid->retry_q);
1949+ ieee80211_return_txq(hw, queue, force);
19471950 }
19481951
19491952 out:
drivers/net/wireless/intel/iwlwifi/cfg/22000.c+22−8
@@ -82,6 +82,7 @@ · 81 unmodified lines
8282 #define IWL_22000_HR_A0_FW_PRE "iwlwifi-QuQnj-a0-hr-a0-"
8383 #define IWL_22000_SU_Z0_FW_PRE "iwlwifi-su-z0-"
8484 #define IWL_QU_B_JF_B_FW_PRE "iwlwifi-Qu-b0-jf-b0-"
85+#define IWL_QUZ_A_HR_B_FW_PRE "iwlwifi-QuZ-a0-hr-b0-"
8586 #define IWL_QNJ_B_JF_B_FW_PRE "iwlwifi-QuQnj-b0-jf-b0-"
8687 #define IWL_CC_A_FW_PRE "iwlwifi-cc-a0-"
8788 #define IWL_22000_SO_A_JF_B_FW_PRE "iwlwifi-so-a0-jf-b0-"
@@ -105,8 +106,8 @@ · 17 unmodified lines
105106 IWL_22000_HR_A0_FW_PRE __stringify(api) ".ucode"
106107 #define IWL_22000_SU_Z0_MODULE_FIRMWARE(api) \
107108 IWL_22000_SU_Z0_FW_PRE __stringify(api) ".ucode"
108−#define IWL_QU_B_JF_B_MODULE_FIRMWARE(api) \
109− IWL_QU_B_JF_B_FW_PRE __stringify(api) ".ucode"
109+#define IWL_QUZ_A_HR_B_MODULE_FIRMWARE(api) \
110+ IWL_QUZ_A_HR_B_FW_PRE __stringify(api) ".ucode"
110111 #define IWL_QU_B_JF_B_MODULE_FIRMWARE(api) \
111112 IWL_QU_B_JF_B_FW_PRE __stringify(api) ".ucode"
112113 #define IWL_QNJ_B_JF_B_MODULE_FIRMWARE(api) \
@@ -235,8 +236,20 @@ const struct iwl_cfg iwl_ax101_cfg_qu_hr = { · 122 unmodified lines
235236 .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT,
236237 };
237238
238−const struct iwl_cfg iwl22260_2ax_cfg = {
239− .name = "Intel(R) Wireless-AX 22260",
239+const struct iwl_cfg iwl_ax101_cfg_quz_hr = {
240+ .name = "Intel(R) Wi-Fi 6 AX101",
241+ .fw_name_pre = IWL_QUZ_A_HR_B_FW_PRE,
242+ IWL_DEVICE_22500,
243+ /*
244+ * This device doesn't support receiving BlockAck with a large bitmap
245+ * so we need to restrict the size of transmitted aggregation to the
246+ * HT size; mac80211 would otherwise pick the HE max (256) by default.
247+ */
248+ .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT,
249+};
250+
251+const struct iwl_cfg iwl_ax200_cfg_cc = {
252+ .name = "Intel(R) Wi-Fi 6 AX200 160MHz",
240253 .fw_name_pre = IWL_CC_A_FW_PRE,
241254 IWL_DEVICE_22500,
242255 /*
@@ -249,7 +262,7 @@ const struct iwl_cfg iwl22260_2ax_cfg = { · 6 unmodified lines
249262 };
250263
251264 const struct iwl_cfg killer1650x_2ax_cfg = {
252− .name = "Killer(R) Wireless-AX 1650x Wireless Network Adapter (200NGW)",
265+ .name = "Killer(R) Wi-Fi 6 AX1650x 160MHz Wireless Network Adapter (200NGW)",
253266 .fw_name_pre = IWL_CC_A_FW_PRE,
254267 IWL_DEVICE_22500,
255268 /*
@@ -262,7 +275,7 @@ const struct iwl_cfg killer1650x_2ax_cfg = { · 6 unmodified lines
262275 };
263276
264277 const struct iwl_cfg killer1650w_2ax_cfg = {
265− .name = "Killer(R) Wireless-AX 1650w Wireless Network Adapter (200D2W)",
278+ .name = "Killer(R) Wi-Fi 6 AX1650w 160MHz Wireless Network Adapter (200D2W)",
266279 .fw_name_pre = IWL_CC_A_FW_PRE,
267280 IWL_DEVICE_22500,
268281 /*
@@ -328,7 +341,7 @@ const struct iwl_cfg killer1550s_2ac_cfg_qu_b0_jf_b0 = { · 59 unmodified lines
328341 };
329342
330343 const struct iwl_cfg killer1650s_2ax_cfg_qu_b0_hr_b0 = {
331− .name = "Killer(R) Wireless-AX 1650i Wireless Network Adapter (22560NGW)",
344+ .name = "Killer(R) Wi-Fi 6 AX1650i 160MHz Wireless Network Adapter (201NGW)",
332345 .fw_name_pre = IWL_22000_QU_B_HR_B_FW_PRE,
333346 IWL_DEVICE_22500,
334347 /*
@@ -340,7 +353,7 @@ const struct iwl_cfg killer1650s_2ax_cfg_qu_b0_hr_b0 = { · 5 unmodified lines
340353 };
341354
342355 const struct iwl_cfg killer1650i_2ax_cfg_qu_b0_hr_b0 = {
343− .name = "Killer(R) Wireless-AX 1650s Wireless Network Adapter (22560D2W)",
356+ .name = "Killer(R) Wi-Fi 6 AX1650s 160MHz Wireless Network Adapter (201D2W)",
344357 .fw_name_pre = IWL_22000_QU_B_HR_B_FW_PRE,
345358 IWL_DEVICE_22500,
346359 /*
@@ -444,6 +457,7 @@ MODULE_FIRMWARE(IWL_22000_HR_B_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); · 97 unmodified lines
444457 MODULE_FIRMWARE(IWL_22000_HR_A0_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
445458 MODULE_FIRMWARE(IWL_22000_SU_Z0_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
446459 MODULE_FIRMWARE(IWL_QU_B_JF_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
460+MODULE_FIRMWARE(IWL_QUZ_A_HR_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
447461 MODULE_FIRMWARE(IWL_QNJ_B_JF_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
448462 MODULE_FIRMWARE(IWL_CC_A_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
449463 MODULE_FIRMWARE(IWL_22000_SO_A_JF_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
drivers/net/wireless/intel/iwlwifi/fw/dbg.c+8−26
@@ -1614,6 +1614,7 @@ iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt, · 1613 unmodified lines
16141614 if (!range) {
16151615 IWL_ERR(fwrt, "Failed to fill region header: id=%d, type=%d\n",
16161616 le32_to_cpu(reg->region_id), type);
1617+ memset(*data, 0, le32_to_cpu((*data)->len));
16171618 return;
16181619 }
16191620
@@ -1623,6 +1624,7 @@ iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt, · 3 unmodified lines
16231624 if (range_size < 0) {
16241625 IWL_ERR(fwrt, "Failed to dump region: id=%d, type=%d\n",
16251626 le32_to_cpu(reg->region_id), type);
1627+ memset(*data, 0, le32_to_cpu((*data)->len));
16261628 return;
16271629 }
16281630 range = range + range_size;
@@ -1807,12 +1809,12 @@ _iwl_fw_error_ini_dump(struct iwl_fw_runtime *fwrt, · 178 unmodified lines
18071809
18081810 trigger = fwrt->dump.active_trigs[id].trig;
18091811
1810− size = sizeof(*dump_file);
1811− size += iwl_fw_ini_get_trigger_len(fwrt, trigger);
1812−
1812+ size = iwl_fw_ini_get_trigger_len(fwrt, trigger);
18131813 if (!size)
18141814 return NULL;
18151815
1816+ size += sizeof(*dump_file);
1817+
18161818 dump_file = vzalloc(size);
18171819 if (!dump_file)
18181820 return NULL;
@@ -1942,14 +1944,10 @@ int iwl_fw_dbg_error_collect(struct iwl_fw_runtime *fwrt, · 123 unmodified lines
19421944 iwl_dump_error_desc->len = 0;
19431945
19441946 ret = iwl_fw_dbg_collect_desc(fwrt, iwl_dump_error_desc, false, 0);
1945− if (ret) {
1947+ if (ret)
19461948 kfree(iwl_dump_error_desc);
1947− } else {
1948− set_bit(STATUS_FW_WAIT_DUMP, &fwrt->trans->status);
1949−
1950− /* trigger nmi to halt the fw */
1951− iwl_force_nmi(fwrt->trans);
1952− }
1949+ else
1950+ iwl_trans_sync_nmi(fwrt->trans);
19531951
19541952 return ret;
19551953 }
@@ -2489,22 +2487,6 @@ IWL_EXPORT_SYMBOL(iwl_fw_dbg_apply_point); · 533 unmodified lines
24892487
24902488 void iwl_fwrt_stop_device(struct iwl_fw_runtime *fwrt)
24912489 {
2492− /* if the wait event timeout elapses instead of wake up then
2493− * the driver did not receive NMI interrupt and can not assume the FW
2494− * is halted
2495− */
2496− int ret = wait_event_timeout(fwrt->trans->fw_halt_waitq,
2497− !test_bit(STATUS_FW_WAIT_DUMP,
2498− &fwrt->trans->status),
2499− msecs_to_jiffies(2000));
2500− if (!ret) {
2501− /* failed to receive NMI interrupt, assuming the FW is stuck */
2502− set_bit(STATUS_FW_ERROR, &fwrt->trans->status);
2503−
2504− clear_bit(STATUS_FW_WAIT_DUMP, &fwrt->trans->status);
2505− }
2506−
2507− /* Assuming the op mode mutex is held at this point */
25082490 iwl_fw_dbg_collect_sync(fwrt);
25092491
25102492 iwl_trans_stop_device(fwrt->trans);
drivers/net/wireless/intel/iwlwifi/fw/init.c+0−1
@@ -76,7 +76,6 @@ void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans, · 75 unmodified lines
7676 fwrt->ops_ctx = ops_ctx;
7777 INIT_DELAYED_WORK(&fwrt->dump.wk, iwl_fw_error_dump_wk);
7878 iwl_fwrt_dbgfs_register(fwrt, dbgfs_dir);
79− init_waitqueue_head(&fwrt->trans->fw_halt_waitq);
8079 }
8180 IWL_EXPORT_SYMBOL(iwl_fw_runtime_init);
8281
drivers/net/wireless/intel/iwlwifi/iwl-config.h+2−1
@@ -549,8 +549,9 @@ extern const struct iwl_cfg iwl22000_2ac_cfg_hr; · 548 unmodified lines
549549 extern const struct iwl_cfg iwl22000_2ac_cfg_hr_cdb;
550550 extern const struct iwl_cfg iwl22000_2ac_cfg_jf;
551551 extern const struct iwl_cfg iwl_ax101_cfg_qu_hr;
552+extern const struct iwl_cfg iwl_ax101_cfg_quz_hr;
552553 extern const struct iwl_cfg iwl22000_2ax_cfg_hr;
553−extern const struct iwl_cfg iwl22260_2ax_cfg;
554+extern const struct iwl_cfg iwl_ax200_cfg_cc;
554555 extern const struct iwl_cfg killer1650s_2ax_cfg_qu_b0_hr_b0;
555556 extern const struct iwl_cfg killer1650i_2ax_cfg_qu_b0_hr_b0;
556557 extern const struct iwl_cfg killer1650x_2ax_cfg;
drivers/net/wireless/intel/iwlwifi/iwl-csr.h+1−0
@@ -327,6 +327,7 @@ enum { · 326 unmodified lines
327327 #define CSR_HW_REV_TYPE_NONE (0x00001F0)
328328 #define CSR_HW_REV_TYPE_QNJ (0x0000360)
329329 #define CSR_HW_REV_TYPE_QNJ_B0 (0x0000364)
330+#define CSR_HW_REV_TYPE_QUZ (0x0000354)
330331 #define CSR_HW_REV_TYPE_HR_CDB (0x0000340)
331332 #define CSR_HW_REV_TYPE_SO (0x0000370)
332333 #define CSR_HW_REV_TYPE_TY (0x0000420)
drivers/net/wireless/intel/iwlwifi/iwl-trans.h+6−6
@@ -338,7 +338,6 @@ enum iwl_d3_status { · 337 unmodified lines
338338 * are sent
339339 * @STATUS_TRANS_IDLE: the trans is idle - general commands are not to be sent
340340 * @STATUS_TRANS_DEAD: trans is dead - avoid any read/write operation
341− * @STATUS_FW_WAIT_DUMP: if set, wait until cleared before collecting dump
342341 */
343342 enum iwl_trans_status {
344343 STATUS_SYNC_HCMD_ACTIVE,
@@ -351,7 +350,6 @@ enum iwl_trans_status { · 6 unmodified lines
351350 STATUS_TRANS_GOING_IDLE,
352351 STATUS_TRANS_IDLE,
353352 STATUS_TRANS_DEAD,
354− STATUS_FW_WAIT_DUMP,
355353 };
356354
357355 static inline int
@@ -618,6 +616,7 @@ struct iwl_trans_ops { · 260 unmodified lines
618616 struct iwl_trans_dump_data *(*dump_data)(struct iwl_trans *trans,
619617 u32 dump_mask);
620618 void (*debugfs_cleanup)(struct iwl_trans *trans);
619+ void (*sync_nmi)(struct iwl_trans *trans);
621620 };
622621
623622 /**
@@ -831,7 +830,6 @@ struct iwl_trans { · 207 unmodified lines
831830 u32 lmac_error_event_table[2];
832831 u32 umac_error_event_table;
833832 unsigned int error_event_table_tlv_status;
834− wait_queue_head_t fw_halt_waitq;
835833
836834 /* pointer to trans specific struct */
837835 /*Ensure that this pointer will always be aligned to sizeof pointer */
@@ -1239,10 +1237,12 @@ static inline void iwl_trans_fw_error(struct iwl_trans *trans) · 401 unmodified lines
12391237 /* prevent double restarts due to the same erroneous FW */
12401238 if (!test_and_set_bit(STATUS_FW_ERROR, &trans->status))
12411239 iwl_op_mode_nic_error(trans->op_mode);
1240+}
12421241
1243− if (test_and_clear_bit(STATUS_FW_WAIT_DUMP, &trans->status))
1244− wake_up(&trans->fw_halt_waitq);
1245−
1242+static inline void iwl_trans_sync_nmi(struct iwl_trans *trans)
1243+{
1244+ if (trans->ops->sync_nmi)
1245+ trans->ops->sync_nmi(trans);
12461246 }
12471247
12481248 /*****************************************************
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c+22−49
@@ -2714,9 +2714,6 @@ static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, · 2713 unmodified lines
27142714
27152715 iwl_mvm_mac_ctxt_remove(mvm, vif);
27162716
2717− kfree(mvmvif->ap_wep_key);
2718− mvmvif->ap_wep_key = NULL;
2719−
27202717 mutex_unlock(&mvm->mutex);
27212718 }
27222719
@@ -3183,24 +3180,7 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, · 460 unmodified lines
31833180 ret = iwl_mvm_update_sta(mvm, vif, sta);
31843181 } else if (old_state == IEEE80211_STA_ASSOC &&
31853182 new_state == IEEE80211_STA_AUTHORIZED) {
3186− /* if wep is used, need to set the key for the station now */
3187− if (vif->type == NL80211_IFTYPE_AP && mvmvif->ap_wep_key) {
3188− mvm_sta->wep_key =
3189− kmemdup(mvmvif->ap_wep_key,
3190− sizeof(*mvmvif->ap_wep_key) +
3191− mvmvif->ap_wep_key->keylen,
3192− GFP_KERNEL);
3193− if (!mvm_sta->wep_key) {
3194− ret = -ENOMEM;
3195− goto out_unlock;
3196− }
3197−
3198− ret = iwl_mvm_set_sta_key(mvm, vif, sta,
3199− mvm_sta->wep_key,
3200− STA_KEY_IDX_INVALID);
3201− } else {
3202− ret = 0;
3203− }
3183+ ret = 0;
32043184
32053185 /* we don't support TDLS during DCM */
32063186 if (iwl_mvm_phy_ctx_count(mvm) > 1)
@@ -3242,17 +3222,6 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, · 35 unmodified lines
32423222 NL80211_TDLS_DISABLE_LINK);
32433223 }
32443224
3245− /* Remove STA key if this is an AP using WEP */
3246− if (vif->type == NL80211_IFTYPE_AP && mvmvif->ap_wep_key) {
3247− int rm_ret = iwl_mvm_remove_sta_key(mvm, vif, sta,
3248− mvm_sta->wep_key);
3249−
3250− if (!ret)
3251− ret = rm_ret;
3252− kfree(mvm_sta->wep_key);
3253− mvm_sta->wep_key = NULL;
3254− }
3255−
32563225 if (unlikely(ret &&
32573226 test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED,
32583227 &mvm->status)))
@@ -3289,6 +3258,13 @@ static void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, · 30 unmodified lines
32893258 struct ieee80211_sta *sta, u32 changed)
32903259 {
32913260 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3261+ struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
3262+
3263+ if (changed & (IEEE80211_RC_BW_CHANGED |
3264+ IEEE80211_RC_SUPP_RATES_CHANGED |
3265+ IEEE80211_RC_NSS_CHANGED))
3266+ iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band,
3267+ true);
32923268
32933269 if (vif->type == NL80211_IFTYPE_STATION &&
32943270 changed & IEEE80211_RC_NSS_CHANGED)
@@ -3439,20 +3415,12 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, · 144 unmodified lines
34393415 break;
34403416 case WLAN_CIPHER_SUITE_WEP40:
34413417 case WLAN_CIPHER_SUITE_WEP104:
3442− if (vif->type == NL80211_IFTYPE_AP) {
3443− struct iwl_mvm_vif *mvmvif =
3444− iwl_mvm_vif_from_mac80211(vif);
3445−
3446− mvmvif->ap_wep_key = kmemdup(key,
3447− sizeof(*key) + key->keylen,
3448− GFP_KERNEL);
3449− if (!mvmvif->ap_wep_key)
3450− return -ENOMEM;
3451− }
3452−
3453− if (vif->type != NL80211_IFTYPE_STATION)
3454− return 0;
3455− break;
3418+ if (vif->type == NL80211_IFTYPE_STATION)
3419+ break;
3420+ if (iwl_mvm_has_new_tx_api(mvm))
3421+ return -EOPNOTSUPP;
3422+ /* support HW crypto on TX */
3423+ return 0;
34563424 default:
34573425 /* currently FW supports only one optional cipher scheme */
34583426 if (hw->n_cipher_schemes &&
@@ -3540,12 +3508,17 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, · 81 unmodified lines
35403508 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, key_offset);
35413509 if (ret) {
35423510 IWL_WARN(mvm, "set key failed\n");
3511+ key->hw_key_idx = STA_KEY_IDX_INVALID;
35433512 /*
35443513 * can't add key for RX, but we don't need it
3545− * in the device for TX so still return 0
3514+ * in the device for TX so still return 0,
3515+ * unless we have new TX API where we cannot
3516+ * put key material into the TX_CMD
35463517 */
3547− key->hw_key_idx = STA_KEY_IDX_INVALID;
3548− ret = 0;
3518+ if (iwl_mvm_has_new_tx_api(mvm))
3519+ ret = -EOPNOTSUPP;
3520+ else
3521+ ret = 0;
35493522 }
35503523
35513524 break;
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h+0−1
@@ -498,7 +498,6 @@ struct iwl_mvm_vif { · 497 unmodified lines
498498 netdev_features_t features;
499499
500500 struct iwl_probe_resp_data __rcu *probe_resp_data;
501− struct ieee80211_key_conf *ap_wep_key;
502501 };
503502
504503 static inline struct iwl_mvm_vif *
drivers/net/wireless/intel/iwlwifi/mvm/sta.c+4−39
@@ -8,7 +8,7 @@ · 7 unmodified lines
88 * Copyright(c) 2012 - 2015 Intel Corporation. All rights reserved.
99 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
1010 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11− * Copyright(c) 2018 Intel Corporation
11+ * Copyright(c) 2018 - 2019 Intel Corporation
1212 *
1313 * This program is free software; you can redistribute it and/or modify
1414 * it under the terms of version 2 of the GNU General Public License as
@@ -31,7 +31,7 @@ · 16 unmodified lines
3131 * Copyright(c) 2012 - 2015 Intel Corporation. All rights reserved.
3232 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
3333 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34− * Copyright(c) 2018 Intel Corporation
34+ * Copyright(c) 2018 - 2019 Intel Corporation
3535 * All rights reserved.
3636 *
3737 * Redistribution and use in source and binary forms, with or without
@@ -1399,7 +1399,9 @@ void iwl_mvm_add_new_dqa_stream_wk(struct work_struct *wk) · 1361 unmodified lines
13991399
14001400 iwl_mvm_sta_alloc_queue(mvm, txq->sta, txq->ac, tid);
14011401 list_del_init(&mvmtxq->list);
1402+ local_bh_disable();
14021403 iwl_mvm_mac_itxq_xmit(mvm->hw, txq);
1404+ local_bh_enable();
14031405 }
14041406
14051407 mutex_unlock(&mvm->mutex);
@@ -2333,21 +2335,6 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) · 927 unmodified lines
23332335 iwl_mvm_enable_txq(mvm, NULL, mvmvif->cab_queue, 0, &cfg,
23342336 timeout);
23352337
2336− if (mvmvif->ap_wep_key) {
2337− u8 key_offset = iwl_mvm_set_fw_key_idx(mvm);
2338−
2339− __set_bit(key_offset, mvm->fw_key_table);
2340−
2341− if (key_offset == STA_KEY_IDX_INVALID)
2342− return -ENOSPC;
2343−
2344− ret = iwl_mvm_send_sta_key(mvm, mvmvif->mcast_sta.sta_id,
2345− mvmvif->ap_wep_key, true, 0, NULL, 0,
2346− key_offset, 0);
2347− if (ret)
2348− return ret;
2349− }
2350−
23512338 return 0;
23522339 }
23532340
@@ -2419,28 +2406,6 @@ int iwl_mvm_rm_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) · 65 unmodified lines
24192406
24202407 iwl_mvm_disable_txq(mvm, NULL, mvmvif->cab_queue, 0, 0);
24212408
2422− if (mvmvif->ap_wep_key) {
2423− int i;
2424−
2425− if (!__test_and_clear_bit(mvmvif->ap_wep_key->hw_key_idx,
2426− mvm->fw_key_table)) {
2427− IWL_ERR(mvm, "offset %d not used in fw key table.\n",
2428− mvmvif->ap_wep_key->hw_key_idx);
2429− return -ENOENT;
2430− }
2431−
2432− /* track which key was deleted last */
2433− for (i = 0; i < STA_KEY_MAX_NUM; i++) {
2434− if (mvm->fw_key_deleted[i] < U8_MAX)
2435− mvm->fw_key_deleted[i]++;
2436− }
2437− mvm->fw_key_deleted[mvmvif->ap_wep_key->hw_key_idx] = 0;
2438− ret = __iwl_mvm_remove_sta_key(mvm, mvmvif->mcast_sta.sta_id,
2439− mvmvif->ap_wep_key, true);
2440− if (ret)
2441− return ret;
2442− }
2443−
24442409 ret = iwl_mvm_rm_sta_common(mvm, mvmvif->mcast_sta.sta_id);
24452410 if (ret)
24462411 IWL_WARN(mvm, "Failed sending remove station\n");
drivers/net/wireless/intel/iwlwifi/mvm/sta.h+2−5
@@ -8,7 +8,7 @@ · 7 unmodified lines
88 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
99 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
1010 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
11− * Copyright(c) 2018 Intel Corporation
11+ * Copyright(c) 2018 - 2019 Intel Corporation
1212 *
1313 * This program is free software; you can redistribute it and/or modify
1414 * it under the terms of version 2 of the GNU General Public License as
@@ -31,7 +31,7 @@ · 16 unmodified lines
3131 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
3232 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
3333 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
34− * Copyright(c) 2018 Intel Corporation
34+ * Copyright(c) 2018 - 2019 Intel Corporation
3535 * All rights reserved.
3636 *
3737 * Redistribution and use in source and binary forms, with or without
@@ -394,7 +394,6 @@ struct iwl_mvm_rxq_dup_data { · 356 unmodified lines
394394 * the BA window. To be used for UAPSD only.
395395 * @ptk_pn: per-queue PTK PN data structures
396396 * @dup_data: per queue duplicate packet detection data
397− * @wep_key: used in AP mode. Is a duplicate of the WEP key.
398397 * @deferred_traffic_tid_map: indication bitmap of deferred traffic per-TID
399398 * @tx_ant: the index of the antenna to use for data tx to this station. Only
400399 * used during connection establishment (e.g. for the 4 way handshake
@@ -426,8 +425,6 @@ struct iwl_mvm_sta { · 25 unmodified lines
426425 struct iwl_mvm_key_pn __rcu *ptk_pn[4];
427426 struct iwl_mvm_rxq_dup_data *dup_data;
428427
429− struct ieee80211_key_conf *wep_key;
430−
431428 u8 reserved_queue;
432429
433430 /* Temporary, until the new TLC will control the Tx protection */
drivers/net/wireless/intel/iwlwifi/pcie/drv.c+7−6
@@ -953,14 +953,15 @@ static const struct pci_device_id iwl_hw_card_ids[] = { · 952 unmodified lines
953953 {IWL_PCI_DEVICE(0xA0F0, 0x1652, killer1650i_2ax_cfg_qu_b0_hr_b0)},
954954 {IWL_PCI_DEVICE(0xA0F0, 0x4070, iwl_ax101_cfg_qu_hr)},
955955
956− {IWL_PCI_DEVICE(0x2723, 0x0080, iwl22260_2ax_cfg)},
957− {IWL_PCI_DEVICE(0x2723, 0x0084, iwl22260_2ax_cfg)},
958− {IWL_PCI_DEVICE(0x2723, 0x0088, iwl22260_2ax_cfg)},
959− {IWL_PCI_DEVICE(0x2723, 0x008C, iwl22260_2ax_cfg)},
956+ {IWL_PCI_DEVICE(0x2723, 0x0080, iwl_ax200_cfg_cc)},
957+ {IWL_PCI_DEVICE(0x2723, 0x0084, iwl_ax200_cfg_cc)},
958+ {IWL_PCI_DEVICE(0x2723, 0x0088, iwl_ax200_cfg_cc)},
959+ {IWL_PCI_DEVICE(0x2723, 0x008C, iwl_ax200_cfg_cc)},
960960 {IWL_PCI_DEVICE(0x2723, 0x1653, killer1650w_2ax_cfg)},
961961 {IWL_PCI_DEVICE(0x2723, 0x1654, killer1650x_2ax_cfg)},
962− {IWL_PCI_DEVICE(0x2723, 0x4080, iwl22260_2ax_cfg)},
963− {IWL_PCI_DEVICE(0x2723, 0x4088, iwl22260_2ax_cfg)},
962+ {IWL_PCI_DEVICE(0x2723, 0x2080, iwl_ax200_cfg_cc)},
963+ {IWL_PCI_DEVICE(0x2723, 0x4080, iwl_ax200_cfg_cc)},
964+ {IWL_PCI_DEVICE(0x2723, 0x4088, iwl_ax200_cfg_cc)},
964965
965966 {IWL_PCI_DEVICE(0x1a56, 0x1653, killer1650w_2ax_cfg)},
966967 {IWL_PCI_DEVICE(0x1a56, 0x1654, killer1650x_2ax_cfg)},
drivers/net/wireless/intel/iwlwifi/pcie/internal.h+1−1
@@ -1043,7 +1043,7 @@ static inline bool iwl_pcie_dbg_on(struct iwl_trans *trans) · 1042 unmodified lines
10431043
10441044 void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state);
10451045 void iwl_trans_pcie_dump_regs(struct iwl_trans *trans);
1046−void iwl_trans_sync_nmi(struct iwl_trans *trans);
1046+void iwl_trans_pcie_sync_nmi(struct iwl_trans *trans);
10471047
10481048 #ifdef CONFIG_IWLWIFI_DEBUGFS
10491049 int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans);
drivers/net/wireless/intel/iwlwifi/pcie/trans.c+8−3
@@ -3318,7 +3318,8 @@ static void iwl_trans_pcie_resume(struct iwl_trans *trans) · 3317 unmodified lines
33183318 .unref = iwl_trans_pcie_unref, \
33193319 .dump_data = iwl_trans_pcie_dump_data, \
33203320 .d3_suspend = iwl_trans_pcie_d3_suspend, \
3321− .d3_resume = iwl_trans_pcie_d3_resume
3321+ .d3_resume = iwl_trans_pcie_d3_resume, \
3322+ .sync_nmi = iwl_trans_pcie_sync_nmi
33223323
33233324 #ifdef CONFIG_PM_SLEEP
33243325 #define IWL_TRANS_PM_OPS \
@@ -3542,6 +3543,10 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, · 217 unmodified lines
35423543 }
35433544 } else if (cfg == &iwl_ax101_cfg_qu_hr) {
35443545 if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
3546+ CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR) &&
3547+ trans->hw_rev == CSR_HW_REV_TYPE_QNJ_B0) {
3548+ trans->cfg = &iwl22000_2ax_cfg_qnj_hr_b0;
3549+ } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
35453550 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) {
35463551 trans->cfg = &iwl_ax101_cfg_qu_hr;
35473552 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
@@ -3560,7 +3565,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, · 12 unmodified lines
35603565 }
35613566 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
35623567 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR) &&
3563− (trans->cfg != &iwl22260_2ax_cfg ||
3568+ (trans->cfg != &iwl_ax200_cfg_cc ||
35643569 trans->hw_rev == CSR_HW_REV_TYPE_QNJ_B0)) {
35653570 u32 hw_status;
35663571
@@ -3637,7 +3642,7 @@ out_no_pci: · 70 unmodified lines
36373642 return ERR_PTR(ret);
36383643 }
36393644
3640−void iwl_trans_sync_nmi(struct iwl_trans *trans)
3645+void iwl_trans_pcie_sync_nmi(struct iwl_trans *trans)
36413646 {
36423647 unsigned long timeout = jiffies + IWL_TRANS_NMI_TIMEOUT;
36433648
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c+1−1
@@ -965,7 +965,7 @@ static int iwl_pcie_gen2_send_hcmd_sync(struct iwl_trans *trans, · 964 unmodified lines
965965 cmd_str);
966966 ret = -ETIMEDOUT;
967967
968− iwl_trans_sync_nmi(trans);
968+ iwl_trans_pcie_sync_nmi(trans);
969969 goto cancel;
970970 }
971971
drivers/net/wireless/intel/iwlwifi/pcie/tx.c+1−1
@@ -1960,7 +1960,7 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans, · 1959 unmodified lines
19601960 iwl_get_cmd_string(trans, cmd->id));
19611961 ret = -ETIMEDOUT;
19621962
1963− iwl_trans_sync_nmi(trans);
1963+ iwl_trans_pcie_sync_nmi(trans);
19641964 goto cancel;
19651965 }
19661966
drivers/net/wireless/mac80211_hwsim.c+15−4
@@ -2644,7 +2644,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info, · 2643 unmodified lines
26442644 enum nl80211_band band;
26452645 const struct ieee80211_ops *ops = &mac80211_hwsim_ops;
26462646 struct net *net;
2647− int idx;
2647+ int idx, i;
26482648 int n_limits = 0;
26492649
26502650 if (WARN_ON(param->channels > 1 && !param->use_chanctx))
@@ -2768,12 +2768,23 @@ static int mac80211_hwsim_new_radio(struct genl_info *info, · 117 unmodified lines
27682768 goto failed_hw;
27692769 }
27702770
2771+ data->if_combination.max_interfaces = 0;
2772+ for (i = 0; i < n_limits; i++)
2773+ data->if_combination.max_interfaces +=
2774+ data->if_limits[i].max;
2775+
27712776 data->if_combination.n_limits = n_limits;
2772− data->if_combination.max_interfaces = 2048;
27732777 data->if_combination.limits = data->if_limits;
27742778
2775− hw->wiphy->iface_combinations = &data->if_combination;
2776− hw->wiphy->n_iface_combinations = 1;
2779+ /*
2780+ * If we actually were asked to support combinations,
2781+ * advertise them - if there's only a single thing like
2782+ * only IBSS then don't advertise it as combinations.
2783+ */
2784+ if (data->if_combination.max_interfaces > 1) {
2785+ hw->wiphy->iface_combinations = &data->if_combination;
2786+ hw->wiphy->n_iface_combinations = 1;
2787+ }
27772788
27782789 if (param->ciphers) {
27792790 memcpy(data->ciphers, param->ciphers,
drivers/net/wireless/mediatek/mt76/mt7603/init.c+2−0
@@ -510,6 +510,8 @@ int mt7603_register_device(struct mt7603_dev *dev) · 509 unmodified lines
510510 bus_ops->rmw = mt7603_rmw;
511511 dev->mt76.bus = bus_ops;
512512
513+ spin_lock_init(&dev->ps_lock);
514+
513515 INIT_DELAYED_WORK(&dev->mac_work, mt7603_mac_work);
514516 tasklet_init(&dev->pre_tbtt_tasklet, mt7603_pre_tbtt_tasklet,
515517 (unsigned long)dev);
drivers/net/wireless/mediatek/mt76/mt7603/mac.c+14−39
@@ -343,7 +343,7 @@ void mt7603_mac_rx_ba_reset(struct mt7603_dev *dev, void *addr, u8 tid) · 342 unmodified lines
343343 MT_BA_CONTROL_1_RESET));
344344 }
345345
346−void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid, int ssn,
346+void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid,
347347 int ba_size)
348348 {
349349 u32 addr = mt7603_wtbl2_addr(wcid);
@@ -358,43 +358,6 @@ void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid, int ssn, · 8 unmodified lines
358358 mt76_clear(dev, addr + (15 * 4), tid_mask);
359359 return;
360360 }
361− mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000);
362−
363− mt7603_mac_stop(dev);
364− switch (tid) {
365− case 0:
366− mt76_rmw_field(dev, addr + (2 * 4), MT_WTBL2_W2_TID0_SN, ssn);
367− break;
368− case 1:
369− mt76_rmw_field(dev, addr + (2 * 4), MT_WTBL2_W2_TID1_SN, ssn);
370− break;
371− case 2:
372− mt76_rmw_field(dev, addr + (2 * 4), MT_WTBL2_W2_TID2_SN_LO,
373− ssn);
374− mt76_rmw_field(dev, addr + (3 * 4), MT_WTBL2_W3_TID2_SN_HI,
375− ssn >> 8);
376− break;
377− case 3:
378− mt76_rmw_field(dev, addr + (3 * 4), MT_WTBL2_W3_TID3_SN, ssn);
379− break;
380− case 4:
381− mt76_rmw_field(dev, addr + (3 * 4), MT_WTBL2_W3_TID4_SN, ssn);
382− break;
383− case 5:
384− mt76_rmw_field(dev, addr + (3 * 4), MT_WTBL2_W3_TID5_SN_LO,
385− ssn);
386− mt76_rmw_field(dev, addr + (4 * 4), MT_WTBL2_W4_TID5_SN_HI,
387− ssn >> 4);
388− break;
389− case 6:
390− mt76_rmw_field(dev, addr + (4 * 4), MT_WTBL2_W4_TID6_SN, ssn);
391− break;
392− case 7:
393− mt76_rmw_field(dev, addr + (4 * 4), MT_WTBL2_W4_TID7_SN, ssn);
394− break;
395− }
396− mt7603_wtbl_update(dev, wcid, MT_WTBL_UPDATE_WTBL2);
397− mt7603_mac_start(dev);
398361
399362 for (i = 7; i > 0; i--) {
400363 if (ba_size >= MT_AGG_SIZE_LIMIT(i))
@@ -827,6 +790,7 @@ mt7603_mac_write_txwi(struct mt7603_dev *dev, __le32 *txwi, · 426 unmodified lines
827790 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
828791 struct ieee80211_tx_rate *rate = &info->control.rates[0];
829792 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
793+ struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data;
830794 struct ieee80211_vif *vif = info->control.vif;
831795 struct mt7603_vif *mvif;
832796 int wlan_idx;
@@ -834,6 +798,7 @@ mt7603_mac_write_txwi(struct mt7603_dev *dev, __le32 *txwi, · 1 unmodified line
834798 int tx_count = 8;
835799 u8 frame_type, frame_subtype;
836800 u16 fc = le16_to_cpu(hdr->frame_control);
801+ u16 seqno = 0;
837802 u8 vif_idx = 0;
838803 u32 val;
839804 u8 bw;
@@ -919,7 +884,17 @@ mt7603_mac_write_txwi(struct mt7603_dev *dev, __le32 *txwi, · 79 unmodified lines
919884 tx_count = 0x1f;
920885
921886 val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, tx_count) |
922− FIELD_PREP(MT_TXD3_SEQ, le16_to_cpu(hdr->seq_ctrl));
887+ MT_TXD3_SN_VALID;
888+
889+ if (ieee80211_is_data_qos(hdr->frame_control))
890+ seqno = le16_to_cpu(hdr->seq_ctrl);
891+ else if (ieee80211_is_back_req(hdr->frame_control))
892+ seqno = le16_to_cpu(bar->start_seq_num);
893+ else
894+ val &= ~MT_TXD3_SN_VALID;
895+
896+ val |= FIELD_PREP(MT_TXD3_SEQ, seqno >> 4);
897+
923898 txwi[3] = cpu_to_le32(val);
924899
925900 if (key) {
drivers/net/wireless/mediatek/mt76/mt7603/main.c+4−4
@@ -372,7 +372,7 @@ mt7603_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps) · 371 unmodified lines
372372 struct mt7603_sta *msta = (struct mt7603_sta *)sta->drv_priv;
373373 struct sk_buff_head list;
374374
375− mt76_stop_tx_queues(&dev->mt76, sta, false);
375+ mt76_stop_tx_queues(&dev->mt76, sta, true);
376376 mt7603_wtbl_set_ps(dev, msta, ps);
377377 if (ps)
378378 return;
@@ -584,13 +584,13 @@ mt7603_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 205 unmodified lines
584584 case IEEE80211_AMPDU_TX_OPERATIONAL:
585585 mtxq->aggr = true;
586586 mtxq->send_bar = false;
587− mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, *ssn, ba_size);
587+ mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, ba_size);
588588 break;
589589 case IEEE80211_AMPDU_TX_STOP_FLUSH:
590590 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
591591 mtxq->aggr = false;
592592 ieee80211_send_bar(vif, sta->addr, tid, mtxq->agg_ssn);
593− mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, *ssn, -1);
593+ mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, -1);
594594 break;
595595 case IEEE80211_AMPDU_TX_START:
596596 mtxq->agg_ssn = *ssn << 4;
@@ -598,7 +598,7 @@ mt7603_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 1 unmodified line
598598 break;
599599 case IEEE80211_AMPDU_TX_STOP_CONT:
600600 mtxq->aggr = false;
601− mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, *ssn, -1);
601+ mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, -1);
602602 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
603603 break;
604604 }
drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h+1−1
@@ -200,7 +200,7 @@ void mt7603_beacon_set_timer(struct mt7603_dev *dev, int idx, int intval); · 199 unmodified lines
200200 int mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb);
201201 void mt7603_mac_add_txs(struct mt7603_dev *dev, void *data);
202202 void mt7603_mac_rx_ba_reset(struct mt7603_dev *dev, void *addr, u8 tid);
203−void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid, int ssn,
203+void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid,
204204 int ba_size);
205205
206206 void mt7603_pse_client_reset(struct mt7603_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c+8−6
@@ -466,7 +466,6 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev, · 465 unmodified lines
466466 return;
467467
468468 rcu_read_lock();
469− mt76_tx_status_lock(mdev, &list);
470469
471470 if (stat->wcid < ARRAY_SIZE(dev->mt76.wcid))
472471 wcid = rcu_dereference(dev->mt76.wcid[stat->wcid]);
@@ -479,6 +478,8 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev, · 6 unmodified lines
479478 drv_priv);
480479 }
481480
481+ mt76_tx_status_lock(mdev, &list);
482+
482483 if (wcid) {
483484 if (stat->pktid >= MT_PACKET_ID_FIRST)
484485 status.skb = mt76_tx_status_skb_get(mdev, wcid,
@@ -498,7 +499,9 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev, · 13 unmodified lines
498499 if (*update == 0 && stat_val == stat_cache &&
499500 stat->wcid == msta->status.wcid && msta->n_frames < 32) {
500501 msta->n_frames++;
501− goto out;
502+ mt76_tx_status_unlock(mdev, &list);
503+ rcu_read_unlock();
504+ return;
502505 }
503506
504507 mt76x02_mac_fill_tx_status(dev, status.info, &msta->status,
@@ -514,11 +517,10 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev, · 9 unmodified lines
514517
515518 if (status.skb)
516519 mt76_tx_status_skb_done(mdev, status.skb, &list);
517− else
518− ieee80211_tx_status_ext(mt76_hw(dev), &status);
519−
520−out:
521520 mt76_tx_status_unlock(mdev, &list);
521+
522+ if (!status.skb)
523+ ieee80211_tx_status_ext(mt76_hw(dev), &status);
522524 rcu_read_unlock();
523525 }
524526
drivers/net/wireless/ralink/rt2x00/rt2x00.h+0−1
@@ -673,7 +673,6 @@ enum rt2x00_state_flags { · 672 unmodified lines
673673 CONFIG_CHANNEL_HT40,
674674 CONFIG_POWERSAVING,
675675 CONFIG_HT_DISABLED,
676− CONFIG_QOS_DISABLED,
677676 CONFIG_MONITORING,
678677
679678 /*
drivers/net/wireless/ralink/rt2x00/rt2x00mac.c+0−10
@@ -642,18 +642,8 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw, · 641 unmodified lines
642642 rt2x00dev->intf_associated--;
643643
644644 rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated);
645−
646− clear_bit(CONFIG_QOS_DISABLED, &rt2x00dev->flags);
647645 }
648646
649− /*
650− * Check for access point which do not support 802.11e . We have to
651− * generate data frames sequence number in S/W for such AP, because
652− * of H/W bug.
653− */
654− if (changes & BSS_CHANGED_QOS && !bss_conf->qos)
655− set_bit(CONFIG_QOS_DISABLED, &rt2x00dev->flags);
656−
657647 /*
658648 * When the erp information has changed, we should perform
659649 * additional configuration steps. For all other changes we are done.
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c+9−6
@@ -201,15 +201,18 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev, · 200 unmodified lines
201201 if (!rt2x00_has_cap_flag(rt2x00dev, REQUIRE_SW_SEQNO)) {
202202 /*
203203 * rt2800 has a H/W (or F/W) bug, device incorrectly increase
204− * seqno on retransmited data (non-QOS) frames. To workaround
205− * the problem let's generate seqno in software if QOS is
206− * disabled.
204+ * seqno on retransmitted data (non-QOS) and management frames.
205+ * To workaround the problem let's generate seqno in software.
206+ * Except for beacons which are transmitted periodically by H/W
207+ * hence hardware has to assign seqno for them.
207208 */
208− if (test_bit(CONFIG_QOS_DISABLED, &rt2x00dev->flags))
209− __clear_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags);
210− else
209+ if (ieee80211_is_beacon(hdr->frame_control)) {
210+ __set_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags);
211211 /* H/W will generate sequence number */
212212 return;
213+ }
214+
215+ __clear_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags);
213216 }
214217
215218 /*
drivers/nvdimm/btt_devs.c+13−5
@@ -198,14 +198,15 @@ static struct device *__nd_btt_create(struct nd_region *nd_region, · 197 unmodified lines
198198 return NULL;
199199
200200 nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL);
201− if (nd_btt->id < 0) {
202− kfree(nd_btt);
203− return NULL;
204− }
201+ if (nd_btt->id < 0)
202+ goto out_nd_btt;
205203
206204 nd_btt->lbasize = lbasize;
207− if (uuid)
205+ if (uuid) {
208206 uuid = kmemdup(uuid, 16, GFP_KERNEL);
207+ if (!uuid)
208+ goto out_put_id;
209+ }
209210 nd_btt->uuid = uuid;
210211 dev = &nd_btt->dev;
211212 dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id);
@@ -220,6 +221,13 @@ static struct device *__nd_btt_create(struct nd_region *nd_region, · 8 unmodified lines
220221 return NULL;
221222 }
222223 return dev;
224+
225+out_put_id:
226+ ida_simple_remove(&nd_region->btt_ida, nd_btt->id);
227+
228+out_nd_btt:
229+ kfree(nd_btt);
230+ return NULL;
223231 }
224232
225233 struct device *nd_btt_create(struct nd_region *nd_region)
drivers/nvdimm/namespace_devs.c+4−1
@@ -2249,9 +2249,12 @@ static struct device *create_namespace_blk(struct nd_region *nd_region, · 2248 unmodified lines
22492249 if (!nsblk->uuid)
22502250 goto blk_err;
22512251 memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
2252− if (name[0])
2252+ if (name[0]) {
22532253 nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
22542254 GFP_KERNEL);
2255+ if (!nsblk->alt_name)
2256+ goto blk_err;
2257+ }
22552258 res = nsblk_add_resource(nd_region, ndd, nsblk,
22562259 __le64_to_cpu(nd_label->dpa));
22572260 if (!res)
drivers/nvdimm/pmem.c+4−4
@@ -113,13 +113,13 @@ static void write_pmem(void *pmem_addr, struct page *page, · 112 unmodified lines
113113
114114 while (len) {
115115 mem = kmap_atomic(page);
116− chunk = min_t(unsigned int, len, PAGE_SIZE);
116+ chunk = min_t(unsigned int, len, PAGE_SIZE - off);
117117 memcpy_flushcache(pmem_addr, mem + off, chunk);
118118 kunmap_atomic(mem);
119119 len -= chunk;
120120 off = 0;
121121 page++;
122− pmem_addr += PAGE_SIZE;
122+ pmem_addr += chunk;
123123 }
124124 }
125125
@@ -132,7 +132,7 @@ static blk_status_t read_pmem(struct page *page, unsigned int off, · 6 unmodified lines
132132
133133 while (len) {
134134 mem = kmap_atomic(page);
135− chunk = min_t(unsigned int, len, PAGE_SIZE);
135+ chunk = min_t(unsigned int, len, PAGE_SIZE - off);
136136 rem = memcpy_mcsafe(mem + off, pmem_addr, chunk);
137137 kunmap_atomic(mem);
138138 if (rem)
@@ -140,7 +140,7 @@ static blk_status_t read_pmem(struct page *page, unsigned int off, · 1 unmodified line
140140 len -= chunk;
141141 off = 0;
142142 page++;
143− pmem_addr += PAGE_SIZE;
143+ pmem_addr += chunk;
144144 }
145145 return BLK_STS_OK;
146146 }
drivers/nvdimm/security.c+73−45
@@ -22,6 +22,8 @@ static bool key_revalidate = true; · 21 unmodified lines
2222 module_param(key_revalidate, bool, 0444);
2323 MODULE_PARM_DESC(key_revalidate, "Require key validation at init.");
2424
25+static const char zero_key[NVDIMM_PASSPHRASE_LEN];
26+
2527 static void *key_data(struct key *key)
2628 {
2729 struct encrypted_key_payload *epayload = dereference_key_locked(key);
@@ -75,6 +77,16 @@ static struct key *nvdimm_request_key(struct nvdimm *nvdimm) · 47 unmodified lines
7577 return key;
7678 }
7779
80+static const void *nvdimm_get_key_payload(struct nvdimm *nvdimm,
81+ struct key **key)
82+{
83+ *key = nvdimm_request_key(nvdimm);
84+ if (!*key)
85+ return zero_key;
86+
87+ return key_data(*key);
88+}
89+
7890 static struct key *nvdimm_lookup_user_key(struct nvdimm *nvdimm,
7991 key_serial_t id, int subclass)
8092 {
@@ -105,36 +117,57 @@ static struct key *nvdimm_lookup_user_key(struct nvdimm *nvdimm, · 24 unmodified lines
105117 return key;
106118 }
107119
108−static struct key *nvdimm_key_revalidate(struct nvdimm *nvdimm)
120+static const void *nvdimm_get_user_key_payload(struct nvdimm *nvdimm,
121+ key_serial_t id, int subclass, struct key **key)
122+{
123+ *key = NULL;
124+ if (id == 0) {
125+ if (subclass == NVDIMM_BASE_KEY)
126+ return zero_key;
127+ else
128+ return NULL;
129+ }
130+
131+ *key = nvdimm_lookup_user_key(nvdimm, id, subclass);
132+ if (!*key)
133+ return NULL;
134+
135+ return key_data(*key);
136+}
137+
138+
139+static int nvdimm_key_revalidate(struct nvdimm *nvdimm)
109140 {
110141 struct key *key;
111142 int rc;
143+ const void *data;
112144
113145 if (!nvdimm->sec.ops->change_key)
114− return NULL;
146+ return -EOPNOTSUPP;
115147
116− key = nvdimm_request_key(nvdimm);
117− if (!key)
118− return NULL;
148+ data = nvdimm_get_key_payload(nvdimm, &key);
119149
120150 /*
121151 * Send the same key to the hardware as new and old key to
122152 * verify that the key is good.
123153 */
124− rc = nvdimm->sec.ops->change_key(nvdimm, key_data(key),
125− key_data(key), NVDIMM_USER);
154+ rc = nvdimm->sec.ops->change_key(nvdimm, data, data, NVDIMM_USER);
126155 if (rc < 0) {
127156 nvdimm_put_key(key);
128− key = NULL;
157+ return rc;
129158 }
130− return key;
159+
160+ nvdimm_put_key(key);
161+ nvdimm->sec.state = nvdimm_security_state(nvdimm, NVDIMM_USER);
162+ return 0;
131163 }
132164
133165 static int __nvdimm_security_unlock(struct nvdimm *nvdimm)
134166 {
135167 struct device *dev = &nvdimm->dev;
136168 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
137− struct key *key = NULL;
169+ struct key *key;
170+ const void *data;
138171 int rc;
139172
140173 /* The bus lock should be held at the top level of the call stack */
@@ -160,16 +193,11 @@ static int __nvdimm_security_unlock(struct nvdimm *nvdimm) · 19 unmodified lines
160193 if (!key_revalidate)
161194 return 0;
162195
163− key = nvdimm_key_revalidate(nvdimm);
164− if (!key)
165− return nvdimm_security_freeze(nvdimm);
196+ return nvdimm_key_revalidate(nvdimm);
166197 } else
167− key = nvdimm_request_key(nvdimm);
198+ data = nvdimm_get_key_payload(nvdimm, &key);
168199
169− if (!key)
170− return -ENOKEY;
171−
172− rc = nvdimm->sec.ops->unlock(nvdimm, key_data(key));
200+ rc = nvdimm->sec.ops->unlock(nvdimm, data);
173201 dev_dbg(dev, "key: %d unlock: %s\n", key_serial(key),
174202 rc == 0 ? "success" : "fail");
175203
@@ -195,6 +223,7 @@ int nvdimm_security_disable(struct nvdimm *nvdimm, unsigned int keyid) · 19 unmodified lines
195223 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
196224 struct key *key;
197225 int rc;
226+ const void *data;
198227
199228 /* The bus lock should be held at the top level of the call stack */
200229 lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
@@ -214,11 +243,12 @@ int nvdimm_security_disable(struct nvdimm *nvdimm, unsigned int keyid) · 13 unmodified lines
214243 return -EBUSY;
215244 }
216245
217− key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY);
218− if (!key)
246+ data = nvdimm_get_user_key_payload(nvdimm, keyid,
247+ NVDIMM_BASE_KEY, &key);
248+ if (!data)
219249 return -ENOKEY;
220250
221− rc = nvdimm->sec.ops->disable(nvdimm, key_data(key));
251+ rc = nvdimm->sec.ops->disable(nvdimm, data);
222252 dev_dbg(dev, "key: %d disable: %s\n", key_serial(key),
223253 rc == 0 ? "success" : "fail");
224254
@@ -235,6 +265,7 @@ int nvdimm_security_update(struct nvdimm *nvdimm, unsigned int keyid, · 10 unmodified lines
235265 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
236266 struct key *key, *newkey;
237267 int rc;
268+ const void *data, *newdata;
238269
239270 /* The bus lock should be held at the top level of the call stack */
240271 lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
@@ -249,22 +280,19 @@ int nvdimm_security_update(struct nvdimm *nvdimm, unsigned int keyid, · 8 unmodified lines
249280 return -EIO;
250281 }
251282
252− if (keyid == 0)
253− key = NULL;
254− else {
255− key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY);
256− if (!key)
257− return -ENOKEY;
258− }
283+ data = nvdimm_get_user_key_payload(nvdimm, keyid,
284+ NVDIMM_BASE_KEY, &key);
285+ if (!data)
286+ return -ENOKEY;
259287
260− newkey = nvdimm_lookup_user_key(nvdimm, new_keyid, NVDIMM_NEW_KEY);
261− if (!newkey) {
288+ newdata = nvdimm_get_user_key_payload(nvdimm, new_keyid,
289+ NVDIMM_NEW_KEY, &newkey);
290+ if (!newdata) {
262291 nvdimm_put_key(key);
263292 return -ENOKEY;
264293 }
265294
266− rc = nvdimm->sec.ops->change_key(nvdimm, key ? key_data(key) : NULL,
267− key_data(newkey), pass_type);
295+ rc = nvdimm->sec.ops->change_key(nvdimm, data, newdata, pass_type);
268296 dev_dbg(dev, "key: %d %d update%s: %s\n",
269297 key_serial(key), key_serial(newkey),
270298 pass_type == NVDIMM_MASTER ? "(master)" : "(user)",
@@ -286,8 +314,9 @@ int nvdimm_security_erase(struct nvdimm *nvdimm, unsigned int keyid, · 15 unmodified lines
286314 {
287315 struct device *dev = &nvdimm->dev;
288316 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
289− struct key *key;
317+ struct key *key = NULL;
290318 int rc;
319+ const void *data;
291320
292321 /* The bus lock should be held at the top level of the call stack */
293322 lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
@@ -319,11 +348,12 @@ int nvdimm_security_erase(struct nvdimm *nvdimm, unsigned int keyid, · 25 unmodified lines
319348 return -EOPNOTSUPP;
320349 }
321350
322− key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY);
323− if (!key)
351+ data = nvdimm_get_user_key_payload(nvdimm, keyid,
352+ NVDIMM_BASE_KEY, &key);
353+ if (!data)
324354 return -ENOKEY;
325355
326− rc = nvdimm->sec.ops->erase(nvdimm, key_data(key), pass_type);
356+ rc = nvdimm->sec.ops->erase(nvdimm, data, pass_type);
327357 dev_dbg(dev, "key: %d erase%s: %s\n", key_serial(key),
328358 pass_type == NVDIMM_MASTER ? "(master)" : "(user)",
329359 rc == 0 ? "success" : "fail");
@@ -337,8 +367,9 @@ int nvdimm_security_overwrite(struct nvdimm *nvdimm, unsigned int keyid) · 7 unmodified lines
337367 {
338368 struct device *dev = &nvdimm->dev;
339369 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
340− struct key *key;
370+ struct key *key = NULL;
341371 int rc;
372+ const void *data;
342373
343374 /* The bus lock should be held at the top level of the call stack */
344375 lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
@@ -368,15 +399,12 @@ int nvdimm_security_overwrite(struct nvdimm *nvdimm, unsigned int keyid) · 23 unmodified lines
368399 return -EBUSY;
369400 }
370401
371− if (keyid == 0)
372− key = NULL;
373− else {
374− key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY);
375− if (!key)
376− return -ENOKEY;
377− }
402+ data = nvdimm_get_user_key_payload(nvdimm, keyid,
403+ NVDIMM_BASE_KEY, &key);
404+ if (!data)
405+ return -ENOKEY;
378406
379− rc = nvdimm->sec.ops->overwrite(nvdimm, key ? key_data(key) : NULL);
407+ rc = nvdimm->sec.ops->overwrite(nvdimm, data);
380408 dev_dbg(dev, "key: %d overwrite submission: %s\n", key_serial(key),
381409 rc == 0 ? "success" : "fail");
382410
drivers/nvme/host/core.c+1−1
@@ -288,7 +288,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved) · 287 unmodified lines
288288 "Cancelling I/O %d", req->tag);
289289
290290 nvme_req(req)->status = NVME_SC_ABORT_REQ;
291− blk_mq_complete_request(req);
291+ blk_mq_complete_request_sync(req);
292292 return true;
293293 }
294294 EXPORT_SYMBOL_GPL(nvme_cancel_request);
drivers/nvme/host/fc.c+15−5
@@ -1845,7 +1845,7 @@ nvme_fc_init_queue(struct nvme_fc_ctrl *ctrl, int idx) · 1844 unmodified lines
18451845 memset(queue, 0, sizeof(*queue));
18461846 queue->ctrl = ctrl;
18471847 queue->qnum = idx;
1848− atomic_set(&queue->csn, 1);
1848+ atomic_set(&queue->csn, 0);
18491849 queue->dev = ctrl->dev;
18501850
18511851 if (idx > 0)
@@ -1887,7 +1887,7 @@ nvme_fc_free_queue(struct nvme_fc_queue *queue) · 35 unmodified lines
18871887 */
18881888
18891889 queue->connection_id = 0;
1890− atomic_set(&queue->csn, 1);
1890+ atomic_set(&queue->csn, 0);
18911891 }
18921892
18931893 static void
@@ -2183,7 +2183,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, · 289 unmodified lines
21832183 {
21842184 struct nvme_fc_cmd_iu *cmdiu = &op->cmd_iu;
21852185 struct nvme_command *sqe = &cmdiu->sqe;
2186− u32 csn;
21872186 int ret, opstate;
21882187
21892188 /*
@@ -2198,8 +2197,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, · 8 unmodified lines
21982197
21992198 /* format the FC-NVME CMD IU and fcp_req */
22002199 cmdiu->connection_id = cpu_to_be64(queue->connection_id);
2201− csn = atomic_inc_return(&queue->csn);
2202− cmdiu->csn = cpu_to_be32(csn);
22032200 cmdiu->data_len = cpu_to_be32(data_len);
22042201 switch (io_dir) {
22052202 case NVMEFC_FCP_WRITE:
@@ -2257,11 +2254,24 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, · 51 unmodified lines
22572254 if (!(op->flags & FCOP_FLAGS_AEN))
22582255 blk_mq_start_request(op->rq);
22592256
2257+ cmdiu->csn = cpu_to_be32(atomic_inc_return(&queue->csn));
22602258 ret = ctrl->lport->ops->fcp_io(&ctrl->lport->localport,
22612259 &ctrl->rport->remoteport,
22622260 queue->lldd_handle, &op->fcp_req);
22632261
22642262 if (ret) {
2263+ /*
2264+ * If the lld fails to send the command is there an issue with
2265+ * the csn value? If the command that fails is the Connect,
2266+ * no - as the connection won't be live. If it is a command
2267+ * post-connect, it's possible a gap in csn may be created.
2268+ * Does this matter? As Linux initiators don't send fused
2269+ * commands, no. The gap would exist, but as there's nothing
2270+ * that depends on csn order to be delivered on the target
2271+ * side, it shouldn't hurt. It would be difficult for a
2272+ * target to even detect the csn gap as it has no idea when the
2273+ * cmd with the csn was supposed to arrive.
2274+ */
22652275 opstate = atomic_xchg(&op->state, FCPOP_STATE_COMPLETE);
22662276 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate);
22672277
drivers/nvme/target/admin-cmd.c+5−0
@@ -24,6 +24,11 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd) · 23 unmodified lines
2424 return len;
2525 }
2626
27+u64 nvmet_get_log_page_offset(struct nvme_command *cmd)
28+{
29+ return le64_to_cpu(cmd->get_log_page.lpo);
30+}
31+
2732 static void nvmet_execute_get_log_page_noop(struct nvmet_req *req)
2833 {
2934 nvmet_req_complete(req, nvmet_zero_sgl(req, 0, req->data_len));
drivers/nvme/target/discovery.c+45−23
@@ -131,54 +131,76 @@ static void nvmet_set_disc_traddr(struct nvmet_req *req, struct nvmet_port *port · 130 unmodified lines
131131 memcpy(traddr, port->disc_addr.traddr, NVMF_TRADDR_SIZE);
132132 }
133133
134+static size_t discovery_log_entries(struct nvmet_req *req)
135+{
136+ struct nvmet_ctrl *ctrl = req->sq->ctrl;
137+ struct nvmet_subsys_link *p;
138+ struct nvmet_port *r;
139+ size_t entries = 0;
140+
141+ list_for_each_entry(p, &req->port->subsystems, entry) {
142+ if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
143+ continue;
144+ entries++;
145+ }
146+ list_for_each_entry(r, &req->port->referrals, entry)
147+ entries++;
148+ return entries;
149+}
150+
134151 static void nvmet_execute_get_disc_log_page(struct nvmet_req *req)
135152 {
136153 const int entry_size = sizeof(struct nvmf_disc_rsp_page_entry);
137154 struct nvmet_ctrl *ctrl = req->sq->ctrl;
138155 struct nvmf_disc_rsp_page_hdr *hdr;
156+ u64 offset = nvmet_get_log_page_offset(req->cmd);
139157 size_t data_len = nvmet_get_log_page_len(req->cmd);
140− size_t alloc_len = max(data_len, sizeof(*hdr));
141− int residual_len = data_len - sizeof(*hdr);
158+ size_t alloc_len;
142159 struct nvmet_subsys_link *p;
143160 struct nvmet_port *r;
144161 u32 numrec = 0;
145162 u16 status = 0;
163+ void *buffer;
164+
165+ /* Spec requires dword aligned offsets */
166+ if (offset & 0x3) {
167+ status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
168+ goto out;
169+ }
146170
147171 /*
148172 * Make sure we're passing at least a buffer of response header size.
149173 * If host provided data len is less than the header size, only the
150174 * number of bytes requested by host will be sent to host.
151175 */
152− hdr = kzalloc(alloc_len, GFP_KERNEL);
153− if (!hdr) {
176+ down_read(&nvmet_config_sem);
177+ alloc_len = sizeof(*hdr) + entry_size * discovery_log_entries(req);
178+ buffer = kzalloc(alloc_len, GFP_KERNEL);
179+ if (!buffer) {
180+ up_read(&nvmet_config_sem);
154181 status = NVME_SC_INTERNAL;
155182 goto out;
156183 }
157184
158− down_read(&nvmet_config_sem);
185+ hdr = buffer;
159186 list_for_each_entry(p, &req->port->subsystems, entry) {
187+ char traddr[NVMF_TRADDR_SIZE];
188+
160189 if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
161190 continue;
162− if (residual_len >= entry_size) {
163− char traddr[NVMF_TRADDR_SIZE];
164−
165− nvmet_set_disc_traddr(req, req->port, traddr);
166− nvmet_format_discovery_entry(hdr, req->port,
167− p->subsys->subsysnqn, traddr,
168− NVME_NQN_NVME, numrec);
169− residual_len -= entry_size;
170− }
191+
192+ nvmet_set_disc_traddr(req, req->port, traddr);
193+ nvmet_format_discovery_entry(hdr, req->port,
194+ p->subsys->subsysnqn, traddr,
195+ NVME_NQN_NVME, numrec);
171196 numrec++;
172197 }
173198
174199 list_for_each_entry(r, &req->port->referrals, entry) {
175− if (residual_len >= entry_size) {
176− nvmet_format_discovery_entry(hdr, r,
177− NVME_DISC_SUBSYS_NAME,
178− r->disc_addr.traddr,
179− NVME_NQN_DISC, numrec);
180− residual_len -= entry_size;
181− }
200+ nvmet_format_discovery_entry(hdr, r,
201+ NVME_DISC_SUBSYS_NAME,
202+ r->disc_addr.traddr,
203+ NVME_NQN_DISC, numrec);
182204 numrec++;
183205 }
184206
@@ -190,8 +212,8 @@ static void nvmet_execute_get_disc_log_page(struct nvmet_req *req) · 5 unmodified lines
190212
191213 up_read(&nvmet_config_sem);
192214
193− status = nvmet_copy_to_sgl(req, 0, hdr, data_len);
194− kfree(hdr);
215+ status = nvmet_copy_to_sgl(req, 0, buffer + offset, data_len);
216+ kfree(buffer);
195217 out:
196218 nvmet_req_complete(req, status);
197219 }
drivers/nvme/target/nvmet.h+1−0
@@ -428,6 +428,7 @@ u16 nvmet_copy_from_sgl(struct nvmet_req *req, off_t off, void *buf, · 427 unmodified lines
428428 u16 nvmet_zero_sgl(struct nvmet_req *req, off_t off, size_t len);
429429
430430 u32 nvmet_get_log_page_len(struct nvme_command *cmd);
431+u64 nvmet_get_log_page_offset(struct nvme_command *cmd);
431432
432433 extern struct list_head *nvmet_ports;
433434 void nvmet_port_disc_changed(struct nvmet_port *port,
drivers/pci/hotplug/pciehp_ctrl.c+4−0
@@ -115,6 +115,10 @@ static void remove_board(struct controller *ctrl, bool safe_removal) · 114 unmodified lines
115115 * removed from the slot/adapter.
116116 */
117117 msleep(1000);
118+
119+ /* Ignore link or presence changes caused by power off */
120+ atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC),
121+ &ctrl->pending_events);
118122 }
119123
120124 /* turn off Green LED */
drivers/pci/quirks.c+2−0
@@ -3877,6 +3877,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9128, · 3876 unmodified lines
38773877 /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */
38783878 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9130,
38793879 quirk_dma_func1_alias);
3880+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9170,
3881+ quirk_dma_func1_alias);
38803882 /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c47 + c57 */
38813883 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9172,
38823884 quirk_dma_func1_alias);
drivers/platform/x86/pmc_atom.c+21−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717
1818 #include <linux/debugfs.h>
1919 #include <linux/device.h>
20+#include <linux/dmi.h>
2021 #include <linux/init.h>
2122 #include <linux/io.h>
2223 #include <linux/platform_data/x86/clk-pmc-atom.h>
@@ -391,11 +392,27 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc) · 368 unmodified lines
391392 }
392393 #endif /* CONFIG_DEBUG_FS */
393394
395+/*
396+ * Some systems need one or more of their pmc_plt_clks to be
397+ * marked as critical.
398+ */
399+static const struct dmi_system_id critclk_systems[] = {
400+ {
401+ .ident = "MPL CEC1x",
402+ .matches = {
403+ DMI_MATCH(DMI_SYS_VENDOR, "MPL AG"),
404+ DMI_MATCH(DMI_PRODUCT_NAME, "CEC10 Family"),
405+ },
406+ },
407+ { /*sentinel*/ }
408+};
409+
394410 static int pmc_setup_clks(struct pci_dev *pdev, void __iomem *pmc_regmap,
395411 const struct pmc_data *pmc_data)
396412 {
397413 struct platform_device *clkdev;
398414 struct pmc_clk_data *clk_data;
415+ const struct dmi_system_id *d = dmi_first_match(critclk_systems);
399416
400417 clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
401418 if (!clk_data)
@@ -403,6 +420,10 @@ static int pmc_setup_clks(struct pci_dev *pdev, void __iomem *pmc_regmap, · 1 unmodified line
403420
404421 clk_data->base = pmc_regmap; /* offset is added by client */
405422 clk_data->clks = pmc_data->clks;
423+ if (d) {
424+ clk_data->critical = true;
425+ pr_info("%s critclks quirk enabled\n", d->ident);
426+ }
406427
407428 clkdev = platform_device_register_data(&pdev->dev, "clk-pmc-atom",
408429 PLATFORM_DEVID_NONE,
drivers/scsi/csiostor/csio_scsi.c+4−1
@@ -1713,8 +1713,11 @@ csio_scsi_err_handler(struct csio_hw *hw, struct csio_ioreq *req) · 1712 unmodified lines
17131713 }
17141714
17151715 out:
1716− if (req->nsge > 0)
1716+ if (req->nsge > 0) {
17171717 scsi_dma_unmap(cmnd);
1718+ if (req->dcopy && (host_status == DID_OK))
1719+ host_status = csio_scsi_copy_to_sgl(hw, req);
1720+ }
17181721
17191722 cmnd->result = (((host_status) << 16) | scsi_status);
17201723 cmnd->scsi_done(cmnd);
drivers/scsi/virtio_scsi.c+1−0
@@ -793,6 +793,7 @@ static int virtscsi_probe(struct virtio_device *vdev) · 792 unmodified lines
793793
794794 /* We need to know how many queues before we allocate. */
795795 num_queues = virtscsi_config_get(vdev, num_queues) ? : 1;
796+ num_queues = min_t(unsigned int, nr_cpu_ids, num_queues);
796797
797798 num_targets = virtscsi_config_get(vdev, max_target) + 1;
798799
drivers/vhost/vhost.c+5−1
@@ -911,8 +911,12 @@ static int vhost_new_umem_range(struct vhost_umem *umem, · 910 unmodified lines
911911 u64 start, u64 size, u64 end,
912912 u64 userspace_addr, int perm)
913913 {
914− struct vhost_umem_node *tmp, *node = kmalloc(sizeof(*node), GFP_ATOMIC);
914+ struct vhost_umem_node *tmp, *node;
915915
916+ if (!size)
917+ return -EFAULT;
918+
919+ node = kmalloc(sizeof(*node), GFP_ATOMIC);
916920 if (!node)
917921 return -ENOMEM;
918922
drivers/virtio/virtio_pci_common.c+5−3
@@ -255,9 +255,11 @@ void vp_del_vqs(struct virtio_device *vdev) · 254 unmodified lines
255255 for (i = 0; i < vp_dev->msix_used_vectors; ++i)
256256 free_irq(pci_irq_vector(vp_dev->pci_dev, i), vp_dev);
257257
258− for (i = 0; i < vp_dev->msix_vectors; i++)
259− if (vp_dev->msix_affinity_masks[i])
260− free_cpumask_var(vp_dev->msix_affinity_masks[i]);
258+ if (vp_dev->msix_affinity_masks) {
259+ for (i = 0; i < vp_dev->msix_vectors; i++)
260+ if (vp_dev->msix_affinity_masks[i])
261+ free_cpumask_var(vp_dev->msix_affinity_masks[i]);
262+ }
261263
262264 if (vp_dev->msix_enabled) {
263265 /* Disable the vector used for configuration */
drivers/virtio/virtio_ring.c+2−0
@@ -882,6 +882,8 @@ static struct virtqueue *vring_create_virtqueue_split( · 881 unmodified lines
882882 GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO);
883883 if (queue)
884884 break;
885+ if (!may_reduce_num)
886+ return NULL;
885887 }
886888
887889 if (!num)
fs/afs/rxrpc.c+17−7
@@ -610,6 +610,7 @@ static long afs_wait_for_call_to_complete(struct afs_call *call, · 609 unmodified lines
610610 bool stalled = false;
611611 u64 rtt;
612612 u32 life, last_life;
613+ bool rxrpc_complete = false;
613614
614615 DECLARE_WAITQUEUE(myself, current);
615616
@@ -621,7 +622,7 @@ static long afs_wait_for_call_to_complete(struct afs_call *call, · 5 unmodified lines
621622 rtt2 = 2;
622623
623624 timeout = rtt2;
624− last_life = rxrpc_kernel_check_life(call->net->socket, call->rxcall);
625+ rxrpc_kernel_check_life(call->net->socket, call->rxcall, &last_life);
625626
626627 add_wait_queue(&call->waitq, &myself);
627628 for (;;) {
@@ -639,7 +640,12 @@ static long afs_wait_for_call_to_complete(struct afs_call *call, · 11 unmodified lines
639640 if (afs_check_call_state(call, AFS_CALL_COMPLETE))
640641 break;
641642
642− life = rxrpc_kernel_check_life(call->net->socket, call->rxcall);
643+ if (!rxrpc_kernel_check_life(call->net->socket, call->rxcall, &life)) {
644+ /* rxrpc terminated the call. */
645+ rxrpc_complete = true;
646+ break;
647+ }
648+
643649 if (timeout == 0 &&
644650 life == last_life && signal_pending(current)) {
645651 if (stalled)
@@ -663,12 +669,16 @@ static long afs_wait_for_call_to_complete(struct afs_call *call, · 17 unmodified lines
663669 remove_wait_queue(&call->waitq, &myself);
664670 __set_current_state(TASK_RUNNING);
665671
666− /* Kill off the call if it's still live. */
667672 if (!afs_check_call_state(call, AFS_CALL_COMPLETE)) {
668− _debug("call interrupted");
669− if (rxrpc_kernel_abort_call(call->net->socket, call->rxcall,
670− RX_USER_ABORT, -EINTR, "KWI"))
671− afs_set_call_complete(call, -EINTR, 0);
673+ if (rxrpc_complete) {
674+ afs_set_call_complete(call, call->error, call->abort_code);
675+ } else {
676+ /* Kill off the call if it's still live. */
677+ _debug("call interrupted");
678+ if (rxrpc_kernel_abort_call(call->net->socket, call->rxcall,
679+ RX_USER_ABORT, -EINTR, "KWI"))
680+ afs_set_call_complete(call, -EINTR, 0);
681+ }
672682 }
673683
674684 spin_lock_bh(&call->state_lock);
fs/aio.c+2−2
@@ -1034,7 +1034,7 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) · 1033 unmodified lines
10341034 return NULL;
10351035
10361036 if (unlikely(!get_reqs_available(ctx))) {
1037− kfree(req);
1037+ kmem_cache_free(kiocb_cachep, req);
10381038 return NULL;
10391039 }
10401040
@@ -1794,7 +1794,7 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, · 753 unmodified lines
17941794 */
17951795 eventfd = eventfd_ctx_fdget(iocb->aio_resfd);
17961796 if (IS_ERR(eventfd))
1797− return PTR_ERR(req->ki_eventfd);
1797+ return PTR_ERR(eventfd);
17981798
17991799 req->ki_eventfd = eventfd;
18001800 }
fs/block_dev.c+4−4
@@ -307,10 +307,10 @@ static void blkdev_bio_end_io(struct bio *bio) · 306 unmodified lines
307307 struct blkdev_dio *dio = bio->bi_private;
308308 bool should_dirty = dio->should_dirty;
309309
310− if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) {
311− if (bio->bi_status && !dio->bio.bi_status)
312− dio->bio.bi_status = bio->bi_status;
313− } else {
310+ if (bio->bi_status && !dio->bio.bi_status)
311+ dio->bio.bi_status = bio->bi_status;
312+
313+ if (!dio->multi_bio || atomic_dec_and_test(&dio->ref)) {
314314 if (!dio->is_sync) {
315315 struct kiocb *iocb = dio->iocb;
316316 ssize_t ret;
fs/btrfs/ioctl.c+10−0
@@ -501,6 +501,16 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg) · 500 unmodified lines
501501 if (!capable(CAP_SYS_ADMIN))
502502 return -EPERM;
503503
504+ /*
505+ * If the fs is mounted with nologreplay, which requires it to be
506+ * mounted in RO mode as well, we can not allow discard on free space
507+ * inside block groups, because log trees refer to extents that are not
508+ * pinned in a block group's free space cache (pinning the extents is
509+ * precisely the first phase of replaying a log tree).
510+ */
511+ if (btrfs_test_opt(fs_info, NOLOGREPLAY))
512+ return -EROFS;
513+
504514 rcu_read_lock();
505515 list_for_each_entry_rcu(device, &fs_info->fs_devices->devices,
506516 dev_list) {
fs/btrfs/props.c+4−4
@@ -366,11 +366,11 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans, · 365 unmodified lines
366366
367367 static int prop_compression_validate(const char *value, size_t len)
368368 {
369− if (!strncmp("lzo", value, len))
369+ if (!strncmp("lzo", value, 3))
370370 return 0;
371− else if (!strncmp("zlib", value, len))
371+ else if (!strncmp("zlib", value, 4))
372372 return 0;
373− else if (!strncmp("zstd", value, len))
373+ else if (!strncmp("zstd", value, 4))
374374 return 0;
375375
376376 return -EINVAL;
@@ -396,7 +396,7 @@ static int prop_compression_apply(struct inode *inode, · 19 unmodified lines
396396 btrfs_set_fs_incompat(fs_info, COMPRESS_LZO);
397397 } else if (!strncmp("zlib", value, 4)) {
398398 type = BTRFS_COMPRESS_ZLIB;
399− } else if (!strncmp("zstd", value, len)) {
399+ } else if (!strncmp("zstd", value, 4)) {
400400 type = BTRFS_COMPRESS_ZSTD;
401401 btrfs_set_fs_incompat(fs_info, COMPRESS_ZSTD);
402402 } else {
fs/dax.c+15−0
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333 #include <linux/sizes.h>
3434 #include <linux/mmu_notifier.h>
3535 #include <linux/iomap.h>
36+#include <asm/pgalloc.h>
3637 #include "internal.h"
3738
3839 #define CREATE_TRACE_POINTS
@@ -1407,7 +1408,9 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, · 1368 unmodified lines
14071408 {
14081409 struct address_space *mapping = vmf->vma->vm_file->f_mapping;
14091410 unsigned long pmd_addr = vmf->address & PMD_MASK;
1411+ struct vm_area_struct *vma = vmf->vma;
14101412 struct inode *inode = mapping->host;
1413+ pgtable_t pgtable = NULL;
14111414 struct page *zero_page;
14121415 spinlock_t *ptl;
14131416 pmd_t pmd_entry;
@@ -1422,12 +1425,22 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, · 8 unmodified lines
14221425 *entry = dax_insert_entry(xas, mapping, vmf, *entry, pfn,
14231426 DAX_PMD | DAX_ZERO_PAGE, false);
14241427
1428+ if (arch_needs_pgtable_deposit()) {
1429+ pgtable = pte_alloc_one(vma->vm_mm);
1430+ if (!pgtable)
1431+ return VM_FAULT_OOM;
1432+ }
1433+
14251434 ptl = pmd_lock(vmf->vma->vm_mm, vmf->pmd);
14261435 if (!pmd_none(*(vmf->pmd))) {
14271436 spin_unlock(ptl);
14281437 goto fallback;
14291438 }
14301439
1440+ if (pgtable) {
1441+ pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable);
1442+ mm_inc_nr_ptes(vma->vm_mm);
1443+ }
14311444 pmd_entry = mk_pmd(zero_page, vmf->vma->vm_page_prot);
14321445 pmd_entry = pmd_mkhuge(pmd_entry);
14331446 set_pmd_at(vmf->vma->vm_mm, pmd_addr, vmf->pmd, pmd_entry);
@@ -1436,6 +1449,8 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, · 2 unmodified lines
14361449 return VM_FAULT_NOPAGE;
14371450
14381451 fallback:
1452+ if (pgtable)
1453+ pte_free(vma->vm_mm, pgtable);
14391454 trace_dax_pmd_load_hole_fallback(inode, vmf, zero_page, *entry);
14401455 return VM_FAULT_FALLBACK;
14411456 }
fs/fuse/dev.c+6−6
@@ -2056,10 +2056,8 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, · 2055 unmodified lines
20562056 rem += pipe->bufs[(pipe->curbuf + idx) & (pipe->buffers - 1)].len;
20572057
20582058 ret = -EINVAL;
2059− if (rem < len) {
2060− pipe_unlock(pipe);
2061− goto out;
2062− }
2059+ if (rem < len)
2060+ goto out_free;
20632061
20642062 rem = len;
20652063 while (rem) {
@@ -2077,7 +2075,9 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, · 11 unmodified lines
20772075 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
20782076 pipe->nrbufs--;
20792077 } else {
2080− pipe_buf_get(pipe, ibuf);
2078+ if (!pipe_buf_get(pipe, ibuf))
2079+ goto out_free;
2080+
20812081 *obuf = *ibuf;
20822082 obuf->flags &= ~PIPE_BUF_FLAG_GIFT;
20832083 obuf->len = rem;
@@ -2100,11 +2100,11 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, · 16 unmodified lines
21002100 ret = fuse_dev_do_write(fud, &cs, len);
21012101
21022102 pipe_lock(pipe);
2103+out_free:
21032104 for (idx = 0; idx < nbuf; idx++)
21042105 pipe_buf_release(pipe, &bufs[idx]);
21052106 pipe_unlock(pipe);
21062107
2107−out:
21082108 kvfree(bufs);
21092109 return ret;
21102110 }
fs/io_uring.c+4−0
@@ -2245,6 +2245,10 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx, · 2244 unmodified lines
22452245 goto err;
22462246
22472247 if (ctx->flags & IORING_SETUP_SQPOLL) {
2248+ ret = -EPERM;
2249+ if (!capable(CAP_SYS_ADMIN))
2250+ goto err;
2251+
22482252 if (p->flags & IORING_SETUP_SQ_AFF) {
22492253 int cpu;
22502254
fs/nfs/nfs42proc.c+0−3
@@ -329,9 +329,6 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, · 328 unmodified lines
329329 };
330330 ssize_t err, err2;
331331
332− if (!nfs_server_capable(file_inode(dst), NFS_CAP_COPY))
333− return -EOPNOTSUPP;
334−
335332 src_lock = nfs_get_lock_context(nfs_file_open_context(src));
336333 if (IS_ERR(src_lock))
337334 return PTR_ERR(src_lock);
fs/nfs/nfs4file.c+3−1
@@ -133,8 +133,10 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, · 132 unmodified lines
133133 struct file *file_out, loff_t pos_out,
134134 size_t count, unsigned int flags)
135135 {
136+ if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY))
137+ return -EOPNOTSUPP;
136138 if (file_inode(file_in) == file_inode(file_out))
137− return -EINVAL;
139+ return -EOPNOTSUPP;
138140 return nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count);
139141 }
140142
fs/nfs/nfs4xdr.c+2−2
@@ -2589,7 +2589,7 @@ static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, · 2588 unmodified lines
25892589 ARRAY_SIZE(nfs4_acl_bitmap), &hdr);
25902590
25912591 rpc_prepare_reply_pages(req, args->acl_pages, 0,
2592− args->acl_len, replen);
2592+ args->acl_len, replen + 1);
25932593 encode_nops(&hdr);
25942594 }
25952595
@@ -2811,7 +2811,7 @@ static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, · 215 unmodified lines
28112811 }
28122812
28132813 rpc_prepare_reply_pages(req, (struct page **)&args->page, 0,
2814− PAGE_SIZE, replen);
2814+ PAGE_SIZE, replen + 1);
28152815 encode_nops(&hdr);
28162816 }
28172817
fs/nfs/super.c+2−1
@@ -2041,7 +2041,8 @@ static int nfs23_validate_mount_data(void *options, · 2040 unmodified lines
20412041 memcpy(sap, &data->addr, sizeof(data->addr));
20422042 args->nfs_server.addrlen = sizeof(data->addr);
20432043 args->nfs_server.port = ntohs(data->addr.sin_port);
2044− if (!nfs_verify_server_address(sap))
2044+ if (sap->sa_family != AF_INET ||
2045+ !nfs_verify_server_address(sap))
20452046 goto out_no_address;
20462047
20472048 if (!(data->flags & NFS_MOUNT_TCP))
fs/pipe.c+2−2
@@ -188,9 +188,9 @@ EXPORT_SYMBOL(generic_pipe_buf_steal); · 187 unmodified lines
188188 * in the tee() system call, when we duplicate the buffers in one
189189 * pipe into another.
190190 */
191−void generic_pipe_buf_get(struct pipe_inode_info *pipe, struct pipe_buffer *buf)
191+bool generic_pipe_buf_get(struct pipe_inode_info *pipe, struct pipe_buffer *buf)
192192 {
193− get_page(buf->page);
193+ return try_get_page(buf->page);
194194 }
195195 EXPORT_SYMBOL(generic_pipe_buf_get);
196196
fs/splice.c+10−2
@@ -1593,7 +1593,11 @@ retry: · 1592 unmodified lines
15931593 * Get a reference to this pipe buffer,
15941594 * so we can copy the contents over.
15951595 */
1596− pipe_buf_get(ipipe, ibuf);
1596+ if (!pipe_buf_get(ipipe, ibuf)) {
1597+ if (ret == 0)
1598+ ret = -EFAULT;
1599+ break;
1600+ }
15971601 *obuf = *ibuf;
15981602
15991603 /*
@@ -1667,7 +1671,11 @@ static int link_pipe(struct pipe_inode_info *ipipe, · 67 unmodified lines
16671671 * Get a reference to this pipe buffer,
16681672 * so we can copy the contents over.
16691673 */
1670− pipe_buf_get(ipipe, ibuf);
1674+ if (!pipe_buf_get(ipipe, ibuf)) {
1675+ if (ret == 0)
1676+ ret = -EFAULT;
1677+ break;
1678+ }
16711679
16721680 obuf = opipe->bufs + nbuf;
16731681 *obuf = *ibuf;
include/drm/drm_modeset_helper_vtables.h+4−0
@@ -418,6 +418,8 @@ struct drm_crtc_helper_funcs { · 417 unmodified lines
418418 * Drivers can use the @old_crtc_state input parameter if the operations
419419 * needed to enable the CRTC don't depend solely on the new state but
420420 * also on the transition between the old state and the new state.
421+ *
422+ * This function is optional.
421423 */
422424 void (*atomic_enable)(struct drm_crtc *crtc,
423425 struct drm_crtc_state *old_crtc_state);
@@ -441,6 +443,8 @@ struct drm_crtc_helper_funcs { · 17 unmodified lines
441443 * parameter @old_crtc_state which could be used to access the old
442444 * state. Atomic drivers should consider to use this one instead
443445 * of @disable.
446+ *
447+ * This function is optional.
444448 */
445449 void (*atomic_disable)(struct drm_crtc *crtc,
446450 struct drm_crtc_state *old_crtc_state);
include/dt-bindings/clock/sifive-fu540-prci.h+18−0
@@ -0,0 +1,18 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+/*
3+ * Copyright (C) 2018-2019 SiFive, Inc.
4+ * Wesley Terpstra
5+ * Paul Walmsley
6+ */
7+
8+#ifndef __DT_BINDINGS_CLOCK_SIFIVE_FU540_PRCI_H
9+#define __DT_BINDINGS_CLOCK_SIFIVE_FU540_PRCI_H
10+
11+/* Clock indexes for use by Device Tree data and the PRCI driver */
12+
13+#define PRCI_CLK_COREPLL 0
14+#define PRCI_CLK_DDRPLL 1
15+#define PRCI_CLK_GEMGXLPLL 2
16+#define PRCI_CLK_TLCLK 3
17+
18+#endif
include/linux/bio.h+12−8
@@ -120,19 +120,23 @@ static inline bool bio_full(struct bio *bio) · 119 unmodified lines
120120 return bio->bi_vcnt >= bio->bi_max_vecs;
121121 }
122122
123−#define mp_bvec_for_each_segment(bv, bvl, i, iter_all) \
124− for (bv = bvec_init_iter_all(&iter_all); \
125− (iter_all.done < (bvl)->bv_len) && \
126− (mp_bvec_next_segment((bvl), &iter_all), 1); \
127− iter_all.done += bv->bv_len, i += 1)
123+static inline bool bio_next_segment(const struct bio *bio,
124+ struct bvec_iter_all *iter)
125+{
126+ if (iter->idx >= bio->bi_vcnt)
127+ return false;
128+
129+ bvec_advance(&bio->bi_io_vec[iter->idx], iter);
130+ return true;
131+}
128132
129133 /*
130134 * drivers should _never_ use the all version - the bio may have been split
131135 * before it got to the driver and the driver won't own all of it
132136 */
133−#define bio_for_each_segment_all(bvl, bio, i, iter_all) \
134− for (i = 0, iter_all.idx = 0; iter_all.idx < (bio)->bi_vcnt; iter_all.idx++) \
135− mp_bvec_for_each_segment(bvl, &((bio)->bi_io_vec[iter_all.idx]), i, iter_all)
137+#define bio_for_each_segment_all(bvl, bio, i, iter) \
138+ for (i = 0, bvl = bvec_init_iter_all(&iter); \
139+ bio_next_segment((bio), &iter); i++)
136140
137141 static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
138142 unsigned bytes)
include/linux/blk-mq.h+1−0
@@ -302,6 +302,7 @@ void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list); · 301 unmodified lines
302302 void blk_mq_kick_requeue_list(struct request_queue *q);
303303 void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs);
304304 bool blk_mq_complete_request(struct request *rq);
305+void blk_mq_complete_request_sync(struct request *rq);
305306 bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list,
306307 struct bio *bio);
307308 bool blk_mq_queue_stopped(struct request_queue *q);
include/linux/bvec.h+10−4
@@ -145,18 +145,18 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, · 144 unmodified lines
145145
146146 static inline struct bio_vec *bvec_init_iter_all(struct bvec_iter_all *iter_all)
147147 {
148− iter_all->bv.bv_page = NULL;
149148 iter_all->done = 0;
149+ iter_all->idx = 0;
150150
151151 return &iter_all->bv;
152152 }
153153
154−static inline void mp_bvec_next_segment(const struct bio_vec *bvec,
155− struct bvec_iter_all *iter_all)
154+static inline void bvec_advance(const struct bio_vec *bvec,
155+ struct bvec_iter_all *iter_all)
156156 {
157157 struct bio_vec *bv = &iter_all->bv;
158158
159− if (bv->bv_page) {
159+ if (iter_all->done) {
160160 bv->bv_page = nth_page(bv->bv_page, 1);
161161 bv->bv_offset = 0;
162162 } else {
@@ -165,6 +165,12 @@ static inline void mp_bvec_next_segment(const struct bio_vec *bvec, · 2 unmodified lines
165165 }
166166 bv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset,
167167 bvec->bv_len - iter_all->done);
168+ iter_all->done += bv->bv_len;
169+
170+ if (iter_all->done == bvec->bv_len) {
171+ iter_all->idx++;
172+ iter_all->done = 0;
173+ }
168174 }
169175
170176 /*
include/linux/kernel.h+2−2
@@ -47,8 +47,8 @@ · 46 unmodified lines
4747
4848 #define u64_to_user_ptr(x) ( \
4949 { \
50− typecheck(u64, x); \
51− (void __user *)(uintptr_t)x; \
50+ typecheck(u64, (x)); \
51+ (void __user *)(uintptr_t)(x); \
5252 } \
5353 )
5454
include/linux/kvm_host.h+6−4
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include <linux/irqbypass.h>
2929 #include <linux/swait.h>
3030 #include <linux/refcount.h>
31+#include <linux/nospec.h>
3132 #include <asm/signal.h>
3233
3334 #include <linux/kvm.h>
@@ -513,10 +514,10 @@ static inline struct kvm_io_bus *kvm_get_bus(struct kvm *kvm, enum kvm_bus idx) · 479 unmodified lines
513514
514515 static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
515516 {
516− /* Pairs with smp_wmb() in kvm_vm_ioctl_create_vcpu, in case
517− * the caller has read kvm->online_vcpus before (as is the case
518− * for kvm_for_each_vcpu, for example).
519− */
517+ int num_vcpus = atomic_read(&kvm->online_vcpus);
518+ i = array_index_nospec(i, num_vcpus);
519+
520+ /* Pairs with smp_wmb() in kvm_vm_ioctl_create_vcpu. */
520521 smp_rmb();
521522 return kvm->vcpus[i];
522523 }
@@ -600,6 +601,7 @@ void kvm_put_kvm(struct kvm *kvm); · 77 unmodified lines
600601
601602 static inline struct kvm_memslots *__kvm_memslots(struct kvm *kvm, int as_id)
602603 {
604+ as_id = array_index_nospec(as_id, KVM_ADDRESS_SPACE_NUM);
603605 return srcu_dereference_check(kvm->memslots[as_id], &kvm->srcu,
604606 lockdep_is_held(&kvm->slots_lock) ||
605607 !refcount_read(&kvm->users_count));
include/linux/mm.h+14−1
@@ -966,6 +966,10 @@ static inline bool is_pci_p2pdma_page(const struct page *page) · 965 unmodified lines
966966 }
967967 #endif /* CONFIG_DEV_PAGEMAP_OPS */
968968
969+/* 127: arbitrary random number, small enough to assemble well */
970+#define page_ref_zero_or_close_to_overflow(page) \
971+ ((unsigned int) page_ref_count(page) + 127u <= 127u)
972+
969973 static inline void get_page(struct page *page)
970974 {
971975 page = compound_head(page);
@@ -973,8 +977,17 @@ static inline void get_page(struct page *page) · 1 unmodified line
973977 * Getting a normal page or the head of a compound page
974978 * requires to already have an elevated page->_refcount.
975979 */
976− VM_BUG_ON_PAGE(page_ref_count(page) <= 0, page);
980+ VM_BUG_ON_PAGE(page_ref_zero_or_close_to_overflow(page), page);
981+ page_ref_inc(page);
982+}
983+
984+static inline __must_check bool try_get_page(struct page *page)
985+{
986+ page = compound_head(page);
987+ if (WARN_ON_ONCE(page_ref_count(page) <= 0))
988+ return false;
977989 page_ref_inc(page);
990+ return true;
978991 }
979992
980993 static inline void put_page(struct page *page)
include/linux/netdevice.h+3−0
@@ -1498,6 +1498,7 @@ struct net_device_ops { · 1497 unmodified lines
14981498 * @IFF_FAILOVER: device is a failover master device
14991499 * @IFF_FAILOVER_SLAVE: device is lower dev of a failover master device
15001500 * @IFF_L3MDEV_RX_HANDLER: only invoke the rx handler of L3 master device
1501+ * @IFF_LIVE_RENAME_OK: rename is allowed while device is up and running
15011502 */
15021503 enum netdev_priv_flags {
15031504 IFF_802_1Q_VLAN = 1<<0,
@@ -1530,6 +1531,7 @@ enum netdev_priv_flags { · 26 unmodified lines
15301531 IFF_FAILOVER = 1<<27,
15311532 IFF_FAILOVER_SLAVE = 1<<28,
15321533 IFF_L3MDEV_RX_HANDLER = 1<<29,
1534+ IFF_LIVE_RENAME_OK = 1<<30,
15331535 };
15341536
15351537 #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
@@ -1561,6 +1563,7 @@ enum netdev_priv_flags { · 25 unmodified lines
15611563 #define IFF_FAILOVER IFF_FAILOVER
15621564 #define IFF_FAILOVER_SLAVE IFF_FAILOVER_SLAVE
15631565 #define IFF_L3MDEV_RX_HANDLER IFF_L3MDEV_RX_HANDLER
1566+#define IFF_LIVE_RENAME_OK IFF_LIVE_RENAME_OK
15641567
15651568 /**
15661569 * struct net_device - The DEVICE structure.
include/linux/nvme.h+7−2
@@ -967,8 +967,13 @@ struct nvme_get_log_page_command { · 966 unmodified lines
967967 __le16 numdl;
968968 __le16 numdu;
969969 __u16 rsvd11;
970− __le32 lpol;
971− __le32 lpou;
970+ union {
971+ struct {
972+ __le32 lpol;
973+ __le32 lpou;
974+ };
975+ __le64 lpo;
976+ };
972977 __u32 rsvd14[2];
973978 };
974979
include/linux/pipe_fs_i.h+6−4
@@ -101,18 +101,20 @@ struct pipe_buf_operations { · 100 unmodified lines
101101 /*
102102 * Get a reference to the pipe buffer.
103103 */
104− void (*get)(struct pipe_inode_info *, struct pipe_buffer *);
104+ bool (*get)(struct pipe_inode_info *, struct pipe_buffer *);
105105 };
106106
107107 /**
108108 * pipe_buf_get - get a reference to a pipe_buffer
109109 * @pipe: the pipe that the buffer belongs to
110110 * @buf: the buffer to get a reference to
111+ *
112+ * Return: %true if the reference was successfully obtained.
111113 */
112−static inline void pipe_buf_get(struct pipe_inode_info *pipe,
114+static inline __must_check bool pipe_buf_get(struct pipe_inode_info *pipe,
113115 struct pipe_buffer *buf)
114116 {
115− buf->ops->get(pipe, buf);
117+ return buf->ops->get(pipe, buf);
116118 }
117119
118120 /**
@@ -171,7 +173,7 @@ struct pipe_inode_info *alloc_pipe_info(void); · 52 unmodified lines
171173 void free_pipe_info(struct pipe_inode_info *);
172174
173175 /* Generic pipe buffer ops functions */
174−void generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *);
176+bool generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *);
175177 int generic_pipe_buf_confirm(struct pipe_inode_info *, struct pipe_buffer *);
176178 int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *);
177179 void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *);
include/linux/platform_data/x86/clk-pmc-atom.h+3−0
@@ -35,10 +35,13 @@ struct pmc_clk { · 34 unmodified lines
3535 *
3636 * @base: PMC clock register base offset
3737 * @clks: pointer to set of registered clocks, typically 0..5
38+ * @critical: flag to indicate if firmware enabled pmc_plt_clks
39+ * should be marked as critial or not
3840 */
3941 struct pmc_clk_data {
4042 void __iomem *base;
4143 const struct pmc_clk *clks;
44+ bool critical;
4245 };
4346
4447 #endif /* __PLATFORM_DATA_X86_CLK_PMC_ATOM_H */
include/linux/sunrpc/sched.h+0−8
@@ -304,12 +304,4 @@ rpc_clnt_swap_deactivate(struct rpc_clnt *clnt) · 303 unmodified lines
304304 }
305305 #endif /* CONFIG_SUNRPC_SWAP */
306306
307−static inline bool
308−rpc_task_need_resched(const struct rpc_task *task)
309−{
310− if (RPC_IS_QUEUED(task) || task->tk_callback)
311− return true;
312− return false;
313−}
314−
315307 #endif /* _LINUX_SUNRPC_SCHED_H_ */
include/linux/virtio_ring.h+1−1
@@ -63,7 +63,7 @@ struct virtqueue; · 62 unmodified lines
6363 /*
6464 * Creates a virtqueue and allocates the descriptor ring. If
6565 * may_reduce_num is set, then this may allocate a smaller ring than
66− * expected. The caller should query virtqueue_get_ring_size to learn
66+ * expected. The caller should query virtqueue_get_vring_size to learn
6767 * the actual size of the ring.
6868 */
6969 struct virtqueue *vring_create_virtqueue(unsigned int index,
include/net/af_rxrpc.h+3−1
@@ -61,10 +61,12 @@ int rxrpc_kernel_charge_accept(struct socket *, rxrpc_notify_rx_t, · 60 unmodified lines
6161 rxrpc_user_attach_call_t, unsigned long, gfp_t,
6262 unsigned int);
6363 void rxrpc_kernel_set_tx_length(struct socket *, struct rxrpc_call *, s64);
64−u32 rxrpc_kernel_check_life(const struct socket *, const struct rxrpc_call *);
64+bool rxrpc_kernel_check_life(const struct socket *, const struct rxrpc_call *,
65+ u32 *);
6566 void rxrpc_kernel_probe_life(struct socket *, struct rxrpc_call *);
6667 u32 rxrpc_kernel_get_epoch(struct socket *, struct rxrpc_call *);
6768 bool rxrpc_kernel_get_reply_time(struct socket *, struct rxrpc_call *,
6869 ktime_t *);
70+bool rxrpc_kernel_call_is_complete(struct rxrpc_call *);
6971
7072 #endif /* _NET_RXRPC_H */
include/net/cfg80211.h+5−0
@@ -7183,6 +7183,11 @@ void cfg80211_pmsr_complete(struct wireless_dev *wdev, · 7182 unmodified lines
71837183 #define wiphy_info(wiphy, format, args...) \
71847184 dev_info(&(wiphy)->dev, format, ##args)
71857185
7186+#define wiphy_err_ratelimited(wiphy, format, args...) \
7187+ dev_err_ratelimited(&(wiphy)->dev, format, ##args)
7188+#define wiphy_warn_ratelimited(wiphy, format, args...) \
7189+ dev_warn_ratelimited(&(wiphy)->dev, format, ##args)
7190+
71867191 #define wiphy_debug(wiphy, format, args...) \
71877192 wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
71887193
include/net/mac80211.h+34−29
@@ -6231,8 +6231,6 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, · 6230 unmodified lines
62316231 * @hw: pointer as obtained from ieee80211_alloc_hw()
62326232 * @ac: AC number to return packets from.
62336233 *
6234− * Should only be called between calls to ieee80211_txq_schedule_start()
6235− * and ieee80211_txq_schedule_end().
62366234 * Returns the next txq if successful, %NULL if no queue is eligible. If a txq
62376235 * is returned, it should be returned with ieee80211_return_txq() after the
62386236 * driver has finished scheduling it.
@@ -6240,51 +6238,58 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, · 1 unmodified line
62406238 struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac);
62416239
62426240 /**
6243− * ieee80211_return_txq - return a TXQ previously acquired by ieee80211_next_txq()
6244− *
6245− * @hw: pointer as obtained from ieee80211_alloc_hw()
6246− * @txq: pointer obtained from station or virtual interface
6247− *
6248− * Should only be called between calls to ieee80211_txq_schedule_start()
6249− * and ieee80211_txq_schedule_end().
6250− */
6251−void ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
6252−
6253−/**
6254− * ieee80211_txq_schedule_start - acquire locks for safe scheduling of an AC
6241+ * ieee80211_txq_schedule_start - start new scheduling round for TXQs
62556242 *
62566243 * @hw: pointer as obtained from ieee80211_alloc_hw()
62576244 * @ac: AC number to acquire locks for
62586245 *
6259− * Acquire locks needed to schedule TXQs from the given AC. Should be called
6260− * before ieee80211_next_txq() or ieee80211_return_txq().
6246+ * Should be called before ieee80211_next_txq() or ieee80211_return_txq().
6247+ * The driver must not call multiple TXQ scheduling rounds concurrently.
62616248 */
6262−void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac)
6263− __acquires(txq_lock);
6249+void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac);
6250+
6251+/* (deprecated) */
6252+static inline void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac)
6253+{
6254+}
6255+
6256+void __ieee80211_schedule_txq(struct ieee80211_hw *hw,
6257+ struct ieee80211_txq *txq, bool force);
62646258
62656259 /**
6266− * ieee80211_txq_schedule_end - release locks for safe scheduling of an AC
6260+ * ieee80211_schedule_txq - schedule a TXQ for transmission
62676261 *
62686262 * @hw: pointer as obtained from ieee80211_alloc_hw()
6269− * @ac: AC number to acquire locks for
6263+ * @txq: pointer obtained from station or virtual interface
62706264 *
6271− * Release locks previously acquired by ieee80211_txq_schedule_end().
6265+ * Schedules a TXQ for transmission if it is not already scheduled,
6266+ * even if mac80211 does not have any packets buffered.
6267+ *
6268+ * The driver may call this function if it has buffered packets for
6269+ * this TXQ internally.
62726270 */
6273−void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac)
6274− __releases(txq_lock);
6271+static inline void
6272+ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
6273+{
6274+ __ieee80211_schedule_txq(hw, txq, true);
6275+}
62756276
62766277 /**
6277− * ieee80211_schedule_txq - schedule a TXQ for transmission
6278+ * ieee80211_return_txq - return a TXQ previously acquired by ieee80211_next_txq()
62786279 *
62796280 * @hw: pointer as obtained from ieee80211_alloc_hw()
62806281 * @txq: pointer obtained from station or virtual interface
6282+ * @force: schedule txq even if mac80211 does not have any buffered packets.
62816283 *
6282− * Schedules a TXQ for transmission if it is not already scheduled. Takes a
6283− * lock, which means it must *not* be called between
6284− * ieee80211_txq_schedule_start() and ieee80211_txq_schedule_end()
6284+ * The driver may set force=true if it has buffered packets for this TXQ
6285+ * internally.
62856286 */
6286−void ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
6287− __acquires(txq_lock) __releases(txq_lock);
6287+static inline void
6288+ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq,
6289+ bool force)
6290+{
6291+ __ieee80211_schedule_txq(hw, txq, force);
6292+}
62886293
62896294 /**
62906295 * ieee80211_txq_may_transmit - check whether TXQ is allowed to transmit
include/net/netrom.h+1−1
@@ -266,7 +266,7 @@ void nr_stop_idletimer(struct sock *); · 265 unmodified lines
266266 int nr_t1timer_running(struct sock *);
267267
268268 /* sysctl_net_netrom.c */
269−void nr_register_sysctl(void);
269+int nr_register_sysctl(void);
270270 void nr_unregister_sysctl(void);
271271
272272 #endif
include/net/sock.h+0−6
@@ -2091,12 +2091,6 @@ static inline bool skwq_has_sleeper(struct socket_wq *wq) · 2090 unmodified lines
20912091 * @p: poll_table
20922092 *
20932093 * See the comments in the wq_has_sleeper function.
2094− *
2095− * Do not derive sock from filp->private_data here. An SMC socket establishes
2096− * an internal TCP socket that is used in the fallback case. All socket
2097− * operations on the SMC socket are then forwarded to the TCP socket. In case of
2098− * poll, the filp->private_data pointer references the SMC socket because the
2099− * TCP socket has no file assigned.
21002094 */
21012095 static inline void sock_poll_wait(struct file *filp, struct socket *sock,
21022096 poll_table *p)
include/net/tls.h+3−1
@@ -318,6 +318,7 @@ int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size); · 317 unmodified lines
318318 int tls_device_sendpage(struct sock *sk, struct page *page,
319319 int offset, size_t size, int flags);
320320 void tls_device_sk_destruct(struct sock *sk);
321+void tls_device_free_resources_tx(struct sock *sk);
321322 void tls_device_init(void);
322323 void tls_device_cleanup(void);
323324 int tls_tx_records(struct sock *sk, int flags);
@@ -341,6 +342,7 @@ int tls_push_sg(struct sock *sk, struct tls_context *ctx, · 17 unmodified lines
341342 int flags);
342343 int tls_push_partial_record(struct sock *sk, struct tls_context *ctx,
343344 int flags);
345+bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx);
344346
345347 static inline struct tls_msg *tls_msg(struct sk_buff *skb)
346348 {
@@ -390,7 +392,7 @@ tls_validate_xmit_skb(struct sock *sk, struct net_device *dev, · 43 unmodified lines
390392 static inline bool tls_is_sk_tx_device_offloaded(struct sock *sk)
391393 {
392394 #ifdef CONFIG_SOCK_VALIDATE_XMIT
393− return sk_fullsock(sk) &
395+ return sk_fullsock(sk) &&
394396 (smp_load_acquire(&sk->sk_validate_xmit_skb) ==
395397 &tls_validate_xmit_skb);
396398 #else
include/sound/soc.h+9−2
@@ -802,8 +802,13 @@ struct snd_soc_component_driver { · 801 unmodified lines
802802 int probe_order;
803803 int remove_order;
804804
805− /* signal if the module handling the component cannot be removed */
806− unsigned int ignore_module_refcount:1;
805+ /*
806+ * signal if the module handling the component should not be removed
807+ * if a pcm is open. Setting this would prevent the module
808+ * refcount being incremented in probe() but allow it be incremented
809+ * when a pcm is opened and decremented when it is closed.
810+ */
811+ unsigned int module_get_upon_open:1;
807812
808813 /* bits */
809814 unsigned int idle_bias_on:1;
@@ -1083,6 +1088,8 @@ struct snd_soc_card { · 273 unmodified lines
10831088 struct mutex mutex;
10841089 struct mutex dapm_mutex;
10851090
1091+ spinlock_t dpcm_lock;
1092+
10861093 bool instantiated;
10871094 bool topology_shortname_created;
10881095
include/uapi/sound/asound.h+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232
3333 #ifndef __KERNEL__
3434 #include <stdlib.h>
35+#include <time.h>
3536 #endif
3637
3738 /*
kernel/dma/debug.c+1−1
@@ -706,7 +706,7 @@ static struct dma_debug_entry *dma_entry_alloc(void) · 705 unmodified lines
706706 #ifdef CONFIG_STACKTRACE
707707 entry->stacktrace.max_entries = DMA_DEBUG_STACKTRACE_ENTRIES;
708708 entry->stacktrace.entries = entry->st_entries;
709− entry->stacktrace.skip = 2;
709+ entry->stacktrace.skip = 1;
710710 save_stack_trace(&entry->stacktrace);
711711 #endif
712712
kernel/events/core.c+43−9
@@ -2009,8 +2009,8 @@ event_sched_out(struct perf_event *event, · 2008 unmodified lines
20092009 event->pmu->del(event, 0);
20102010 event->oncpu = -1;
20112011
2012− if (event->pending_disable) {
2013− event->pending_disable = 0;
2012+ if (READ_ONCE(event->pending_disable) >= 0) {
2013+ WRITE_ONCE(event->pending_disable, -1);
20142014 state = PERF_EVENT_STATE_OFF;
20152015 }
20162016 perf_event_set_state(event, state);
@@ -2198,7 +2198,8 @@ EXPORT_SYMBOL_GPL(perf_event_disable); · 181 unmodified lines
21982198
21992199 void perf_event_disable_inatomic(struct perf_event *event)
22002200 {
2201− event->pending_disable = 1;
2201+ WRITE_ONCE(event->pending_disable, smp_processor_id());
2202+ /* can fail, see perf_pending_event_disable() */
22022203 irq_work_queue(&event->pending);
22032204 }
22042205
@@ -5810,10 +5811,45 @@ void perf_event_wakeup(struct perf_event *event) · 3605 unmodified lines
58105811 }
58115812 }
58125813
5814+static void perf_pending_event_disable(struct perf_event *event)
5815+{
5816+ int cpu = READ_ONCE(event->pending_disable);
5817+
5818+ if (cpu < 0)
5819+ return;
5820+
5821+ if (cpu == smp_processor_id()) {
5822+ WRITE_ONCE(event->pending_disable, -1);
5823+ perf_event_disable_local(event);
5824+ return;
5825+ }
5826+
5827+ /*
5828+ * CPU-A CPU-B
5829+ *
5830+ * perf_event_disable_inatomic()
5831+ * @pending_disable = CPU-A;
5832+ * irq_work_queue();
5833+ *
5834+ * sched-out
5835+ * @pending_disable = -1;
5836+ *
5837+ * sched-in
5838+ * perf_event_disable_inatomic()
5839+ * @pending_disable = CPU-B;
5840+ * irq_work_queue(); // FAILS
5841+ *
5842+ * irq_work_run()
5843+ * perf_pending_event()
5844+ *
5845+ * But the event runs on CPU-B and wants disabling there.
5846+ */
5847+ irq_work_queue_on(&event->pending, cpu);
5848+}
5849+
58135850 static void perf_pending_event(struct irq_work *entry)
58145851 {
5815− struct perf_event *event = container_of(entry,
5816− struct perf_event, pending);
5852+ struct perf_event *event = container_of(entry, struct perf_event, pending);
58175853 int rctx;
58185854
58195855 rctx = perf_swevent_get_recursion_context();
@@ -5822,10 +5858,7 @@ static void perf_pending_event(struct irq_work *entry) · 2 unmodified lines
58225858 * and we won't recurse 'further'.
58235859 */
58245860
5825− if (event->pending_disable) {
5826− event->pending_disable = 0;
5827− perf_event_disable_local(event);
5828− }
5861+ perf_pending_event_disable(event);
58295862
58305863 if (event->pending_wakeup) {
58315864 event->pending_wakeup = 0;
@@ -10236,6 +10269,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, · 4404 unmodified lines
1023610269
1023710270
1023810271 init_waitqueue_head(&event->waitq);
10272+ event->pending_disable = -1;
1023910273 init_irq_work(&event->pending, perf_pending_event);
1024010274
1024110275 mutex_init(&event->mmap_mutex);
kernel/events/ring_buffer.c+2−2
@@ -392,7 +392,7 @@ void *perf_aux_output_begin(struct perf_output_handle *handle, · 391 unmodified lines
392392 * store that will be enabled on successful return
393393 */
394394 if (!handle->size) { /* A, matches D */
395− event->pending_disable = 1;
395+ event->pending_disable = smp_processor_id();
396396 perf_output_wakeup(handle);
397397 local_set(&rb->aux_nest, 0);
398398 goto err_put;
@@ -480,7 +480,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size) · 81 unmodified lines
480480
481481 if (wakeup) {
482482 if (handle->aux_flags & PERF_AUX_FLAG_TRUNCATED)
483− handle->event->pending_disable = 1;
483+ handle->event->pending_disable = smp_processor_id();
484484 perf_output_wakeup(handle);
485485 }
486486
kernel/irq/chip.c+4−0
@@ -1449,6 +1449,10 @@ int irq_chip_set_vcpu_affinity_parent(struct irq_data *data, void *vcpu_info) · 1448 unmodified lines
14491449 int irq_chip_set_wake_parent(struct irq_data *data, unsigned int on)
14501450 {
14511451 data = data->parent_data;
1452+
1453+ if (data->chip->flags & IRQCHIP_SKIP_SET_WAKE)
1454+ return 0;
1455+
14521456 if (data->chip->irq_set_wake)
14531457 return data->chip->irq_set_wake(data, on);
14541458
kernel/irq/irqdesc.c+1−0
@@ -558,6 +558,7 @@ int __init early_irq_init(void) · 557 unmodified lines
558558 alloc_masks(&desc[i], node);
559559 raw_spin_lock_init(&desc[i].lock);
560560 lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
561+ mutex_init(&desc[i].request_mutex);
561562 desc_set_defaults(i, &desc[i], node, NULL, NULL);
562563 }
563564 return arch_early_irq_init();
kernel/locking/lockdep.c+12−17
@@ -4689,8 +4689,8 @@ static void free_zapped_rcu(struct rcu_head *ch) · 4688 unmodified lines
46894689 return;
46904690
46914691 raw_local_irq_save(flags);
4692− if (!graph_lock())
4693− goto out_irq;
4692+ arch_spin_lock(&lockdep_lock);
4693+ current->lockdep_recursion = 1;
46944694
46954695 /* closed head */
46964696 pf = delayed_free.pf + (delayed_free.index ^ 1);
@@ -4702,8 +4702,8 @@ static void free_zapped_rcu(struct rcu_head *ch) · 5 unmodified lines
47024702 */
47034703 call_rcu_zapped(delayed_free.pf + delayed_free.index);
47044704
4705− graph_unlock();
4706−out_irq:
4705+ current->lockdep_recursion = 0;
4706+ arch_spin_unlock(&lockdep_lock);
47074707 raw_local_irq_restore(flags);
47084708 }
47094709
@@ -4744,21 +4744,17 @@ static void lockdep_free_key_range_reg(void *start, unsigned long size) · 34 unmodified lines
47444744 {
47454745 struct pending_free *pf;
47464746 unsigned long flags;
4747− int locked;
47484747
47494748 init_data_structures_once();
47504749
47514750 raw_local_irq_save(flags);
4752− locked = graph_lock();
4753− if (!locked)
4754− goto out_irq;
4755−
4751+ arch_spin_lock(&lockdep_lock);
4752+ current->lockdep_recursion = 1;
47564753 pf = get_pending_free();
47574754 __lockdep_free_key_range(pf, start, size);
47584755 call_rcu_zapped(pf);
4759−
4760− graph_unlock();
4761−out_irq:
4756+ current->lockdep_recursion = 0;
4757+ arch_spin_unlock(&lockdep_lock);
47624758 raw_local_irq_restore(flags);
47634759
47644760 /*
@@ -4911,9 +4907,8 @@ void lockdep_unregister_key(struct lock_class_key *key) · 146 unmodified lines
49114907 return;
49124908
49134909 raw_local_irq_save(flags);
4914− if (!graph_lock())
4915− goto out_irq;
4916−
4910+ arch_spin_lock(&lockdep_lock);
4911+ current->lockdep_recursion = 1;
49174912 pf = get_pending_free();
49184913 hlist_for_each_entry_rcu(k, hash_head, hash_entry) {
49194914 if (k == key) {
@@ -4925,8 +4920,8 @@ void lockdep_unregister_key(struct lock_class_key *key) · 5 unmodified lines
49254920 WARN_ON_ONCE(!found);
49264921 __lockdep_free_key_range(pf, key, 1);
49274922 call_rcu_zapped(pf);
4928− graph_unlock();
4929−out_irq:
4923+ current->lockdep_recursion = 0;
4924+ arch_spin_unlock(&lockdep_lock);
49304925 raw_local_irq_restore(flags);
49314926
49324927 /* Wait until is_dynamic_key() has finished accessing k->hash_entry. */
kernel/sched/fair.c+3−3
@@ -7784,10 +7784,10 @@ static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq) · 7783 unmodified lines
77847784 if (cfs_rq->last_h_load_update == now)
77857785 return;
77867786
7787− cfs_rq->h_load_next = NULL;
7787+ WRITE_ONCE(cfs_rq->h_load_next, NULL);
77887788 for_each_sched_entity(se) {
77897789 cfs_rq = cfs_rq_of(se);
7790− cfs_rq->h_load_next = se;
7790+ WRITE_ONCE(cfs_rq->h_load_next, se);
77917791 if (cfs_rq->last_h_load_update == now)
77927792 break;
77937793 }
@@ -7797,7 +7797,7 @@ static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq) · 3 unmodified lines
77977797 cfs_rq->last_h_load_update = now;
77987798 }
77997799
7800− while ((se = cfs_rq->h_load_next) != NULL) {
7800+ while ((se = READ_ONCE(cfs_rq->h_load_next)) != NULL) {
78017801 load = cfs_rq->h_load;
78027802 load = div64_ul(load * se->avg.load_avg,
78037803 cfs_rq_load_avg(cfs_rq) + 1);
kernel/time/alarmtimer.c+1−1
@@ -594,7 +594,7 @@ static ktime_t alarm_timer_remaining(struct k_itimer *timr, ktime_t now) · 593 unmodified lines
594594 {
595595 struct alarm *alarm = &timr->it.alarm.alarmtimer;
596596
597− return ktime_sub(now, alarm->node.expires);
597+ return ktime_sub(alarm->node.expires, now);
598598 }
599599
600600 /**
kernel/trace/trace.c+5−1
@@ -7041,12 +7041,16 @@ static void buffer_pipe_buf_release(struct pipe_inode_info *pipe, · 7040 unmodified lines
70417041 buf->private = 0;
70427042 }
70437043
7044−static void buffer_pipe_buf_get(struct pipe_inode_info *pipe,
7044+static bool buffer_pipe_buf_get(struct pipe_inode_info *pipe,
70457045 struct pipe_buffer *buf)
70467046 {
70477047 struct buffer_ref *ref = (struct buffer_ref *)buf->private;
70487048
7049+ if (ref->ref > INT_MAX/2)
7050+ return false;
7051+
70497052 ref->ref++;
7053+ return true;
70507054 }
70517055
70527056 /* Pipe buffer operations for a buffer. */
lib/iov_iter.c+4−0
@@ -1528,6 +1528,7 @@ EXPORT_SYMBOL(csum_and_copy_to_iter); · 1527 unmodified lines
15281528 size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
15291529 struct iov_iter *i)
15301530 {
1531+#ifdef CONFIG_CRYPTO
15311532 struct ahash_request *hash = hashp;
15321533 struct scatterlist sg;
15331534 size_t copied;
@@ -1537,6 +1538,9 @@ size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, · 3 unmodified lines
15371538 ahash_request_set_crypt(hash, &sg, NULL, copied);
15381539 crypto_ahash_update(hash);
15391540 return copied;
1541+#else
1542+ return 0;
1543+#endif
15401544 }
15411545 EXPORT_SYMBOL(hash_and_copy_to_iter);
15421546
mm/gup.c+36−12
@@ -160,8 +160,12 @@ retry: · 159 unmodified lines
160160 goto retry;
161161 }
162162
163− if (flags & FOLL_GET)
164− get_page(page);
163+ if (flags & FOLL_GET) {
164+ if (unlikely(!try_get_page(page))) {
165+ page = ERR_PTR(-ENOMEM);
166+ goto out;
167+ }
168+ }
165169 if (flags & FOLL_TOUCH) {
166170 if ((flags & FOLL_WRITE) &&
167171 !pte_dirty(pte) && !PageDirty(page))
@@ -298,7 +302,10 @@ retry_locked: · 130 unmodified lines
298302 if (pmd_trans_unstable(pmd))
299303 ret = -EBUSY;
300304 } else {
301− get_page(page);
305+ if (unlikely(!try_get_page(page))) {
306+ spin_unlock(ptl);
307+ return ERR_PTR(-ENOMEM);
308+ }
302309 spin_unlock(ptl);
303310 lock_page(page);
304311 ret = split_huge_page(page);
@@ -500,7 +507,10 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address, · 195 unmodified lines
500507 if (is_device_public_page(*page))
501508 goto unmap;
502509 }
503− get_page(*page);
510+ if (unlikely(!try_get_page(*page))) {
511+ ret = -ENOMEM;
512+ goto unmap;
513+ }
504514 out:
505515 ret = 0;
506516 unmap:
@@ -1545,6 +1555,20 @@ static void undo_dev_pagemap(int *nr, int nr_start, struct page **pages) · 1038 unmodified lines
15451555 }
15461556 }
15471557
1558+/*
1559+ * Return the compund head page with ref appropriately incremented,
1560+ * or NULL if that failed.
1561+ */
1562+static inline struct page *try_get_compound_head(struct page *page, int refs)
1563+{
1564+ struct page *head = compound_head(page);
1565+ if (WARN_ON_ONCE(page_ref_count(head) < 0))
1566+ return NULL;
1567+ if (unlikely(!page_cache_add_speculative(head, refs)))
1568+ return NULL;
1569+ return head;
1570+}
1571+
15481572 #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL
15491573 static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end,
15501574 int write, struct page **pages, int *nr)
@@ -1579,9 +1603,9 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, · 28 unmodified lines
15791603
15801604 VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
15811605 page = pte_page(pte);
1582− head = compound_head(page);
15831606
1584− if (!page_cache_get_speculative(head))
1607+ head = try_get_compound_head(page, 1);
1608+ if (!head)
15851609 goto pte_unmap;
15861610
15871611 if (unlikely(pte_val(pte) != pte_val(*ptep))) {
@@ -1720,8 +1744,8 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, · 132 unmodified lines
17201744 refs++;
17211745 } while (addr += PAGE_SIZE, addr != end);
17221746
1723− head = compound_head(pmd_page(orig));
1724− if (!page_cache_add_speculative(head, refs)) {
1747+ head = try_get_compound_head(pmd_page(orig), refs);
1748+ if (!head) {
17251749 *nr -= refs;
17261750 return 0;
17271751 }
@@ -1758,8 +1782,8 @@ static int gup_huge_pud(pud_t orig, pud_t *pudp, unsigned long addr, · 30 unmodified lines
17581782 refs++;
17591783 } while (addr += PAGE_SIZE, addr != end);
17601784
1761− head = compound_head(pud_page(orig));
1762− if (!page_cache_add_speculative(head, refs)) {
1785+ head = try_get_compound_head(pud_page(orig), refs);
1786+ if (!head) {
17631787 *nr -= refs;
17641788 return 0;
17651789 }
@@ -1795,8 +1819,8 @@ static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr, · 29 unmodified lines
17951819 refs++;
17961820 } while (addr += PAGE_SIZE, addr != end);
17971821
1798− head = compound_head(pgd_page(orig));
1799− if (!page_cache_add_speculative(head, refs)) {
1822+ head = try_get_compound_head(pgd_page(orig), refs);
1823+ if (!head) {
18001824 *nr -= refs;
18011825 return 0;
18021826 }
mm/hugetlb.c+13−0
@@ -4299,6 +4299,19 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, · 4298 unmodified lines
42994299
43004300 pfn_offset = (vaddr & ~huge_page_mask(h)) >> PAGE_SHIFT;
43014301 page = pte_page(huge_ptep_get(pte));
4302+
4303+ /*
4304+ * Instead of doing 'try_get_page()' below in the same_page
4305+ * loop, just check the count once here.
4306+ */
4307+ if (unlikely(page_count(page) <= 0)) {
4308+ if (pages) {
4309+ spin_unlock(ptl);
4310+ remainder = 0;
4311+ err = -ENOMEM;
4312+ break;
4313+ }
4314+ }
43024315 same_page:
43034316 if (pages) {
43044317 pages[i] = mem_map_offset(page, pfn_offset);
net/atm/lec.c+5−1
@@ -710,7 +710,10 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) · 709 unmodified lines
710710
711711 static int lec_mcast_attach(struct atm_vcc *vcc, int arg)
712712 {
713− if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg])
713+ if (arg < 0 || arg >= MAX_LEC_ITF)
714+ return -EINVAL;
715+ arg = array_index_nospec(arg, MAX_LEC_ITF);
716+ if (!dev_lec[arg])
714717 return -EINVAL;
715718 vcc->proto_data = dev_lec[arg];
716719 return lec_mcast_make(netdev_priv(dev_lec[arg]), vcc);
@@ -728,6 +731,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) · 11 unmodified lines
728731 i = arg;
729732 if (arg >= MAX_LEC_ITF)
730733 return -EINVAL;
734+ i = array_index_nospec(arg, MAX_LEC_ITF);
731735 if (!dev_lec[i]) {
732736 int size;
733737
net/bluetooth/sco.c+2−2
@@ -523,12 +523,12 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, · 522 unmodified lines
523523 struct sock *sk = sock->sk;
524524 int err = 0;
525525
526− BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr);
527−
528526 if (!addr || addr_len < sizeof(struct sockaddr_sco) ||
529527 addr->sa_family != AF_BLUETOOTH)
530528 return -EINVAL;
531529
530+ BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr);
531+
532532 lock_sock(sk);
533533
534534 if (sk->sk_state != BT_OPEN) {
net/bridge/br_input.c+14−9
@@ -196,13 +196,10 @@ static void __br_handle_local_finish(struct sk_buff *skb) · 195 unmodified lines
196196 /* note: already called with rcu_read_lock */
197197 static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
198198 {
199− struct net_bridge_port *p = br_port_get_rcu(skb->dev);
200−
201199 __br_handle_local_finish(skb);
202200
203− BR_INPUT_SKB_CB(skb)->brdev = p->br->dev;
204− br_pass_frame_up(skb);
205− return 0;
201+ /* return 1 to signal the okfn() was called so it's ok to use the skb */
202+ return 1;
206203 }
207204
208205 static int nf_hook_bridge_pre(struct sk_buff *skb, struct sk_buff **pskb)
@@ -333,10 +330,18 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb) · 124 unmodified lines
333330 goto forward;
334331 }
335332
336− /* Deliver packet to local host only */
337− NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, dev_net(skb->dev),
338− NULL, skb, skb->dev, NULL, br_handle_local_finish);
339− return RX_HANDLER_CONSUMED;
333+ /* The else clause should be hit when nf_hook():
334+ * - returns < 0 (drop/error)
335+ * - returns = 0 (stolen/nf_queue)
336+ * Thus return 1 from the okfn() to signal the skb is ok to pass
337+ */
338+ if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
339+ dev_net(skb->dev), NULL, skb, skb->dev, NULL,
340+ br_handle_local_finish) == 1) {
341+ return RX_HANDLER_PASS;
342+ } else {
343+ return RX_HANDLER_CONSUMED;
344+ }
340345 }
341346
342347 forward:
net/bridge/br_multicast.c+3−1
@@ -2013,7 +2013,8 @@ static void br_multicast_start_querier(struct net_bridge *br, · 2012 unmodified lines
20132013
20142014 __br_multicast_open(br, query);
20152015
2016− list_for_each_entry(port, &br->port_list, list) {
2016+ rcu_read_lock();
2017+ list_for_each_entry_rcu(port, &br->port_list, list) {
20172018 if (port->state == BR_STATE_DISABLED ||
20182019 port->state == BR_STATE_BLOCKING)
20192020 continue;
@@ -2025,6 +2026,7 @@ static void br_multicast_start_querier(struct net_bridge *br, · 5 unmodified lines
20252026 br_multicast_enable(&port->ip6_own_query);
20262027 #endif
20272028 }
2029+ rcu_read_unlock();
20282030 }
20292031
20302032 int br_multicast_toggle(struct net_bridge *br, unsigned long val)
net/bridge/br_netlink.c+1−1
@@ -1441,7 +1441,7 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev) · 1440 unmodified lines
14411441 nla_put_u8(skb, IFLA_BR_VLAN_STATS_ENABLED,
14421442 br_opt_get(br, BROPT_VLAN_STATS_ENABLED)) ||
14431443 nla_put_u8(skb, IFLA_BR_VLAN_STATS_PER_PORT,
1444− br_opt_get(br, IFLA_BR_VLAN_STATS_PER_PORT)))
1444+ br_opt_get(br, BROPT_VLAN_STATS_PER_PORT)))
14451445 return -EMSGSIZE;
14461446 #endif
14471447 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
net/core/dev.c+15−1
@@ -1184,7 +1184,21 @@ int dev_change_name(struct net_device *dev, const char *newname) · 1183 unmodified lines
11841184 BUG_ON(!dev_net(dev));
11851185
11861186 net = dev_net(dev);
1187− if (dev->flags & IFF_UP)
1187+
1188+ /* Some auto-enslaved devices e.g. failover slaves are
1189+ * special, as userspace might rename the device after
1190+ * the interface had been brought up and running since
1191+ * the point kernel initiated auto-enslavement. Allow
1192+ * live name change even when these slave devices are
1193+ * up and running.
1194+ *
1195+ * Typically, users of these auto-enslaving devices
1196+ * don't actually care about slave name change, as
1197+ * they are supposed to operate on master interface
1198+ * directly.
1199+ */
1200+ if (dev->flags & IFF_UP &&
1201+ likely(!(dev->priv_flags & IFF_LIVE_RENAME_OK)))
11881202 return -EBUSY;
11891203
11901204 write_seqcount_begin(&devnet_rename_seq);
net/core/failover.c+3−3
@@ -80,14 +80,14 @@ static int failover_slave_register(struct net_device *slave_dev) · 79 unmodified lines
8080 goto err_upper_link;
8181 }
8282
83− slave_dev->priv_flags |= IFF_FAILOVER_SLAVE;
83+ slave_dev->priv_flags |= (IFF_FAILOVER_SLAVE | IFF_LIVE_RENAME_OK);
8484
8585 if (fops && fops->slave_register &&
8686 !fops->slave_register(slave_dev, failover_dev))
8787 return NOTIFY_OK;
8888
8989 netdev_upper_dev_unlink(slave_dev, failover_dev);
90− slave_dev->priv_flags &= ~IFF_FAILOVER_SLAVE;
90+ slave_dev->priv_flags &= ~(IFF_FAILOVER_SLAVE | IFF_LIVE_RENAME_OK);
9191 err_upper_link:
9292 netdev_rx_handler_unregister(slave_dev);
9393 done:
@@ -121,7 +121,7 @@ int failover_slave_unregister(struct net_device *slave_dev) · 27 unmodified lines
121121
122122 netdev_rx_handler_unregister(slave_dev);
123123 netdev_upper_dev_unlink(slave_dev, failover_dev);
124− slave_dev->priv_flags &= ~IFF_FAILOVER_SLAVE;
124+ slave_dev->priv_flags &= ~(IFF_FAILOVER_SLAVE | IFF_LIVE_RENAME_OK);
125125
126126 if (fops && fops->slave_unregister &&
127127 !fops->slave_unregister(slave_dev, failover_dev))
net/core/filter.c+2−0
@@ -4462,6 +4462,8 @@ BPF_CALL_3(bpf_bind, struct bpf_sock_addr_kern *, ctx, struct sockaddr *, addr, · 4461 unmodified lines
44624462 * Only binding to IP is supported.
44634463 */
44644464 err = -EINVAL;
4465+ if (addr_len < offsetofend(struct sockaddr, sa_family))
4466+ return err;
44654467 if (addr->sa_family == AF_INET) {
44664468 if (addr_len < sizeof(struct sockaddr_in))
44674469 return err;
net/core/net-sysfs.c+5−9
@@ -1747,20 +1747,16 @@ int netdev_register_kobject(struct net_device *ndev) · 1746 unmodified lines
17471747
17481748 error = device_add(dev);
17491749 if (error)
1750− goto error_put_device;
1750+ return error;
17511751
17521752 error = register_queue_kobjects(ndev);
1753− if (error)
1754− goto error_device_del;
1753+ if (error) {
1754+ device_del(dev);
1755+ return error;
1756+ }
17551757
17561758 pm_runtime_set_memalloc_noio(dev, true);
17571759
1758− return 0;
1759−
1760−error_device_del:
1761− device_del(dev);
1762−error_put_device:
1763− put_device(dev);
17641760 return error;
17651761 }
17661762
net/core/ptp_classifier.c+4−3
@@ -185,9 +185,10 @@ void __init ptp_classifier_init(void) · 184 unmodified lines
185185 { 0x16, 0, 0, 0x00000000 },
186186 { 0x06, 0, 0, 0x00000000 },
187187 };
188− struct sock_fprog_kern ptp_prog = {
189− .len = ARRAY_SIZE(ptp_filter), .filter = ptp_filter,
190− };
188+ struct sock_fprog_kern ptp_prog;
189+
190+ ptp_prog.len = ARRAY_SIZE(ptp_filter);
191+ ptp_prog.filter = ptp_filter;
191192
192193 BUG_ON(bpf_prog_create(&ptp_insns, &ptp_prog));
193194 }
net/core/rtnetlink.c+1−1
@@ -4951,7 +4951,7 @@ static int rtnl_valid_stats_req(const struct nlmsghdr *nlh, bool strict_check, · 4950 unmodified lines
49514951 {
49524952 struct if_stats_msg *ifsm;
49534953
4954− if (nlh->nlmsg_len < sizeof(*ifsm)) {
4954+ if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifsm))) {
49554955 NL_SET_ERR_MSG(extack, "Invalid header for stats dump");
49564956 return -EINVAL;
49574957 }
net/core/skbuff.c+9−1
@@ -5082,7 +5082,8 @@ EXPORT_SYMBOL_GPL(skb_gso_validate_mac_len); · 5081 unmodified lines
50825082
50835083 static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb)
50845084 {
5085− int mac_len;
5085+ int mac_len, meta_len;
5086+ void *meta;
50865087
50875088 if (skb_cow(skb, skb_headroom(skb)) < 0) {
50885089 kfree_skb(skb);
@@ -5094,6 +5095,13 @@ static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb) · 5 unmodified lines
50945095 memmove(skb_mac_header(skb) + VLAN_HLEN, skb_mac_header(skb),
50955096 mac_len - VLAN_HLEN - ETH_TLEN);
50965097 }
5098+
5099+ meta_len = skb_metadata_len(skb);
5100+ if (meta_len) {
5101+ meta = skb_metadata_end(skb) - meta_len;
5102+ memmove(meta + VLAN_HLEN, meta, meta_len);
5103+ }
5104+
50975105 skb->mac_header += VLAN_HLEN;
50985106 return skb;
50995107 }
net/core/sock.c+2−2
@@ -348,7 +348,7 @@ static int sock_get_timeout(long timeo, void *optval, bool old_timeval) · 347 unmodified lines
348348 tv.tv_usec = ((timeo % HZ) * USEC_PER_SEC) / HZ;
349349 }
350350
351− if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
351+ if (old_timeval && in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
352352 struct old_timeval32 tv32 = { tv.tv_sec, tv.tv_usec };
353353 *(struct old_timeval32 *)optval = tv32;
354354 return sizeof(tv32);
@@ -372,7 +372,7 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool · 17 unmodified lines
372372 {
373373 struct __kernel_sock_timeval tv;
374374
375− if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
375+ if (old_timeval && in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
376376 struct old_timeval32 tv32;
377377
378378 if (optlen < sizeof(tv32))
net/ipv4/fou.c+3−1
@@ -121,6 +121,7 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb) · 120 unmodified lines
121121 struct guehdr *guehdr;
122122 void *data;
123123 u16 doffset = 0;
124+ u8 proto_ctype;
124125
125126 if (!fou)
126127 return 1;
@@ -210,13 +211,14 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb) · 83 unmodified lines
210211 if (unlikely(guehdr->control))
211212 return gue_control_message(skb, guehdr);
212213
214+ proto_ctype = guehdr->proto_ctype;
213215 __skb_pull(skb, sizeof(struct udphdr) + hdrlen);
214216 skb_reset_transport_header(skb);
215217
216218 if (iptunnel_pull_offloads(skb))
217219 goto drop;
218220
219− return -guehdr->proto_ctype;
221+ return -proto_ctype;
220222
221223 drop:
222224 kfree_skb(skb);
net/ipv4/route.c+15−1
@@ -1200,9 +1200,23 @@ static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie) · 1199 unmodified lines
12001200
12011201 static void ipv4_link_failure(struct sk_buff *skb)
12021202 {
1203+ struct ip_options opt;
12031204 struct rtable *rt;
1205+ int res;
12041206
1205− icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0);
1207+ /* Recompile ip options since IPCB may not be valid anymore.
1208+ */
1209+ memset(&opt, 0, sizeof(opt));
1210+ opt.optlen = ip_hdr(skb)->ihl*4 - sizeof(struct iphdr);
1211+
1212+ rcu_read_lock();
1213+ res = __ip_options_compile(dev_net(skb->dev), &opt, skb, NULL);
1214+ rcu_read_unlock();
1215+
1216+ if (res)
1217+ return;
1218+
1219+ __icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0, &opt);
12061220
12071221 rt = skb_rtable(skb);
12081222 if (rt)
net/ipv4/tcp_dctcp.c+17−28
@@ -49,9 +49,8 @@ · 48 unmodified lines
4949 #define DCTCP_MAX_ALPHA 1024U
5050
5151 struct dctcp {
52− u32 acked_bytes_ecn;
53− u32 acked_bytes_total;
54− u32 prior_snd_una;
52+ u32 old_delivered;
53+ u32 old_delivered_ce;
5554 u32 prior_rcv_nxt;
5655 u32 dctcp_alpha;
5756 u32 next_seq;
@@ -73,8 +72,8 @@ static void dctcp_reset(const struct tcp_sock *tp, struct dctcp *ca) · 15 unmodified lines
7372 {
7473 ca->next_seq = tp->snd_nxt;
7574
76− ca->acked_bytes_ecn = 0;
77− ca->acked_bytes_total = 0;
75+ ca->old_delivered = tp->delivered;
76+ ca->old_delivered_ce = tp->delivered_ce;
7877 }
7978
8079 static void dctcp_init(struct sock *sk)
@@ -86,7 +85,6 @@ static void dctcp_init(struct sock *sk) · 5 unmodified lines
8685 sk->sk_state == TCP_CLOSE)) {
8786 struct dctcp *ca = inet_csk_ca(sk);
8887
89− ca->prior_snd_una = tp->snd_una;
9088 ca->prior_rcv_nxt = tp->rcv_nxt;
9189
9290 ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA);
@@ -118,37 +116,25 @@ static void dctcp_update_alpha(struct sock *sk, u32 flags) · 25 unmodified lines
118116 {
119117 const struct tcp_sock *tp = tcp_sk(sk);
120118 struct dctcp *ca = inet_csk_ca(sk);
121− u32 acked_bytes = tp->snd_una - ca->prior_snd_una;
122−
123− /* If ack did not advance snd_una, count dupack as MSS size.
124− * If ack did update window, do not count it at all.
125− */
126− if (acked_bytes == 0 && !(flags & CA_ACK_WIN_UPDATE))
127− acked_bytes = inet_csk(sk)->icsk_ack.rcv_mss;
128− if (acked_bytes) {
129− ca->acked_bytes_total += acked_bytes;
130− ca->prior_snd_una = tp->snd_una;
131−
132− if (flags & CA_ACK_ECE)
133− ca->acked_bytes_ecn += acked_bytes;
134− }
135119
136120 /* Expired RTT */
137121 if (!before(tp->snd_una, ca->next_seq)) {
138− u64 bytes_ecn = ca->acked_bytes_ecn;
122+ u32 delivered_ce = tp->delivered_ce - ca->old_delivered_ce;
139123 u32 alpha = ca->dctcp_alpha;
140124
141125 /* alpha = (1 - g) * alpha + g * F */
142126
143127 alpha -= min_not_zero(alpha, alpha >> dctcp_shift_g);
144− if (bytes_ecn) {
128+ if (delivered_ce) {
129+ u32 delivered = tp->delivered - ca->old_delivered;
130+
145131 /* If dctcp_shift_g == 1, a 32bit value would overflow
146− * after 8 Mbytes.
132+ * after 8 M packets.
147133 */
148− bytes_ecn <<= (10 - dctcp_shift_g);
149− do_div(bytes_ecn, max(1U, ca->acked_bytes_total));
134+ delivered_ce <<= (10 - dctcp_shift_g);
135+ delivered_ce /= max(1U, delivered);
150136
151− alpha = min(alpha + (u32)bytes_ecn, DCTCP_MAX_ALPHA);
137+ alpha = min(alpha + delivered_ce, DCTCP_MAX_ALPHA);
152138 }
153139 /* dctcp_alpha can be read from dctcp_get_info() without
154140 * synchro, so we ask compiler to not use dctcp_alpha
@@ -200,6 +186,7 @@ static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr, · 45 unmodified lines
200186 union tcp_cc_info *info)
201187 {
202188 const struct dctcp *ca = inet_csk_ca(sk);
189+ const struct tcp_sock *tp = tcp_sk(sk);
203190
204191 /* Fill it also in case of VEGASINFO due to req struct limits.
205192 * We can still correctly retrieve it later.
@@ -211,8 +198,10 @@ static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr, · 5 unmodified lines
211198 info->dctcp.dctcp_enabled = 1;
212199 info->dctcp.dctcp_ce_state = (u16) ca->ce_state;
213200 info->dctcp.dctcp_alpha = ca->dctcp_alpha;
214− info->dctcp.dctcp_ab_ecn = ca->acked_bytes_ecn;
215− info->dctcp.dctcp_ab_tot = ca->acked_bytes_total;
201+ info->dctcp.dctcp_ab_ecn = tp->mss_cache *
202+ (tp->delivered_ce - ca->old_delivered_ce);
203+ info->dctcp.dctcp_ab_tot = tp->mss_cache *
204+ (tp->delivered - ca->old_delivered);
216205 }
217206
218207 *attr = INET_DIAG_DCTCPINFO;
net/ipv4/tcp_input.c+5−5
@@ -402,11 +402,12 @@ static int __tcp_grow_window(const struct sock *sk, const struct sk_buff *skb) · 401 unmodified lines
402402 static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb)
403403 {
404404 struct tcp_sock *tp = tcp_sk(sk);
405+ int room;
406+
407+ room = min_t(int, tp->window_clamp, tcp_space(sk)) - tp->rcv_ssthresh;
405408
406409 /* Check #1 */
407− if (tp->rcv_ssthresh < tp->window_clamp &&
408− (int)tp->rcv_ssthresh < tcp_space(sk) &&
409− !tcp_under_memory_pressure(sk)) {
410+ if (room > 0 && !tcp_under_memory_pressure(sk)) {
410411 int incr;
411412
412413 /* Check #2. Increase window, if skb with such overhead
@@ -419,8 +420,7 @@ static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb) · 6 unmodified lines
419420
420421 if (incr) {
421422 incr = max_t(int, incr, 2 * skb->len);
422− tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr,
423− tp->window_clamp);
423+ tp->rcv_ssthresh += min(room, incr);
424424 inet_csk(sk)->icsk_ack.quick |= 1;
425425 }
426426 }
net/ipv6/route.c+4−0
@@ -2331,6 +2331,10 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk, · 2330 unmodified lines
23312331
23322332 rcu_read_lock();
23332333 from = rcu_dereference(rt6->from);
2334+ if (!from) {
2335+ rcu_read_unlock();
2336+ return;
2337+ }
23342338 nrt6 = ip6_rt_cache_alloc(from, daddr, saddr);
23352339 if (nrt6) {
23362340 rt6_do_update_pmtu(nrt6, mtu);
net/ipv6/udp.c+2−0
@@ -1045,6 +1045,8 @@ static void udp_v6_flush_pending_frames(struct sock *sk) · 1044 unmodified lines
10451045 static int udpv6_pre_connect(struct sock *sk, struct sockaddr *uaddr,
10461046 int addr_len)
10471047 {
1048+ if (addr_len < offsetofend(struct sockaddr, sa_family))
1049+ return -EINVAL;
10481050 /* The following checks are replicated from __ip6_datagram_connect()
10491051 * and intended to prevent BPF program called below from accessing
10501052 * bytes that are out of the bound specified by user in addr_len.
net/llc/af_llc.c+1−2
@@ -320,14 +320,13 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) · 319 unmodified lines
320320 struct llc_sap *sap;
321321 int rc = -EINVAL;
322322
323− dprintk("%s: binding %02X\n", __func__, addr->sllc_sap);
324−
325323 lock_sock(sk);
326324 if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)))
327325 goto out;
328326 rc = -EAFNOSUPPORT;
329327 if (unlikely(addr->sllc_family != AF_LLC))
330328 goto out;
329+ dprintk("%s: binding %02X\n", __func__, addr->sllc_sap);
331330 rc = -ENODEV;
332331 rcu_read_lock();
333332 if (sk->sk_bound_dev_if) {
net/mac80211/driver-ops.h+3−0
@@ -1195,6 +1195,9 @@ static inline void drv_wake_tx_queue(struct ieee80211_local *local, · 1194 unmodified lines
11951195 {
11961196 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
11971197
1198+ if (local->in_reconfig)
1199+ return;
1200+
11981201 if (!check_sdata_in_driver(sdata))
11991202 return;
12001203
net/mac80211/key.c+4−5
@@ -167,8 +167,10 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) · 166 unmodified lines
167167 * The driver doesn't know anything about VLAN interfaces.
168168 * Hence, don't send GTKs for VLAN interfaces to the driver.
169169 */
170− if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE))
170+ if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
171+ ret = 1;
171172 goto out_unsupported;
173+ }
172174 }
173175
174176 ret = drv_set_key(key->local, SET_KEY, sdata,
@@ -213,11 +215,8 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) · 38 unmodified lines
213215 /* all of these we can do in software - if driver can */
214216 if (ret == 1)
215217 return 0;
216− if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL)) {
217− if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
218− return 0;
218+ if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL))
219219 return -EINVAL;
220− }
221220 return 0;
222221 default:
223222 return -EINVAL;
net/mac80211/mesh_pathtbl.c+1−1
@@ -23,7 +23,7 @@ static void mesh_path_free_rcu(struct mesh_table *tbl, struct mesh_path *mpath); · 22 unmodified lines
2323 static u32 mesh_table_hash(const void *addr, u32 len, u32 seed)
2424 {
2525 /* Use last four bytes of hw addr as hash index */
26− return jhash_1word(*(u32 *)(addr+2), seed);
26+ return jhash_1word(__get_unaligned_cpu32((u8 *)addr + 2), seed);
2727 }
2828
2929 static const struct rhashtable_params mesh_rht_params = {
net/mac80211/rx.c+9−1
@@ -1568,7 +1568,15 @@ static void sta_ps_start(struct sta_info *sta) · 1567 unmodified lines
15681568 return;
15691569
15701570 for (tid = 0; tid < IEEE80211_NUM_TIDS; tid++) {
1571− if (txq_has_queue(sta->sta.txq[tid]))
1571+ struct ieee80211_txq *txq = sta->sta.txq[tid];
1572+ struct txq_info *txqi = to_txq_info(txq);
1573+
1574+ spin_lock(&local->active_txq_lock[txq->ac]);
1575+ if (!list_empty(&txqi->schedule_order))
1576+ list_del_init(&txqi->schedule_order);
1577+ spin_unlock(&local->active_txq_lock[txq->ac]);
1578+
1579+ if (txq_has_queue(txq))
15721580 set_bit(tid, &sta->txq_buffered_tids);
15731581 else
15741582 clear_bit(tid, &sta->txq_buffered_tids);
net/mac80211/trace_msg.h+6−1
@@ -1,4 +1,9 @@
11 /* SPDX-License-Identifier: GPL-2.0 */
2+/*
3+ * Portions of this file
4+ * Copyright (C) 2019 Intel Corporation
5+ */
6+
27 #ifdef CONFIG_MAC80211_MESSAGE_TRACING
38
49 #if !defined(__MAC80211_MSG_DRIVER_TRACE) || defined(TRACE_HEADER_MULTI_READ)
@@ -11,7 +16,7 @@ · 6 unmodified lines
1116 #undef TRACE_SYSTEM
1217 #define TRACE_SYSTEM mac80211_msg
1318
14−#define MAX_MSG_LEN 100
19+#define MAX_MSG_LEN 120
1520
1621 DECLARE_EVENT_CLASS(mac80211_msg_event,
1722 TP_PROTO(struct va_format *vaf),
net/mac80211/tx.c+23−30
@@ -3221,6 +3221,7 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata, · 3220 unmodified lines
32213221 u8 max_subframes = sta->sta.max_amsdu_subframes;
32223222 int max_frags = local->hw.max_tx_fragments;
32233223 int max_amsdu_len = sta->sta.max_amsdu_len;
3224+ int orig_truesize;
32243225 __be16 len;
32253226 void *data;
32263227 bool ret = false;
@@ -3261,6 +3262,7 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata, · 34 unmodified lines
32613262 if (!head || skb_is_gso(head))
32623263 goto out;
32633264
3265+ orig_truesize = head->truesize;
32643266 orig_len = head->len;
32653267
32663268 if (skb->len + head->len > max_amsdu_len)
@@ -3318,6 +3320,7 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata, · 51 unmodified lines
33183320 *frag_tail = skb;
33193321
33203322 out_recalc:
3323+ fq->memory_usage += head->truesize - orig_truesize;
33213324 if (head->len != orig_len) {
33223325 flow->backlog += head->len - orig_len;
33233326 tin->backlog_bytes += head->len - orig_len;
@@ -3646,16 +3649,17 @@ EXPORT_SYMBOL(ieee80211_tx_dequeue); · 322 unmodified lines
36463649 struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)
36473650 {
36483651 struct ieee80211_local *local = hw_to_local(hw);
3652+ struct ieee80211_txq *ret = NULL;
36493653 struct txq_info *txqi = NULL;
36503654
3651− lockdep_assert_held(&local->active_txq_lock[ac]);
3655+ spin_lock_bh(&local->active_txq_lock[ac]);
36523656
36533657 begin:
36543658 txqi = list_first_entry_or_null(&local->active_txqs[ac],
36553659 struct txq_info,
36563660 schedule_order);
36573661 if (!txqi)
3658− return NULL;
3662+ goto out;
36593663
36603664 if (txqi->txq.sta) {
36613665 struct sta_info *sta = container_of(txqi->txq.sta,
@@ -3672,24 +3676,30 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac) · 10 unmodified lines
36723676
36733677
36743678 if (txqi->schedule_round == local->schedule_round[ac])
3675− return NULL;
3679+ goto out;
36763680
36773681 list_del_init(&txqi->schedule_order);
36783682 txqi->schedule_round = local->schedule_round[ac];
3679− return &txqi->txq;
3683+ ret = &txqi->txq;
3684+
3685+out:
3686+ spin_unlock_bh(&local->active_txq_lock[ac]);
3687+ return ret;
36803688 }
36813689 EXPORT_SYMBOL(ieee80211_next_txq);
36823690
3683−void ieee80211_return_txq(struct ieee80211_hw *hw,
3684− struct ieee80211_txq *txq)
3691+void __ieee80211_schedule_txq(struct ieee80211_hw *hw,
3692+ struct ieee80211_txq *txq,
3693+ bool force)
36853694 {
36863695 struct ieee80211_local *local = hw_to_local(hw);
36873696 struct txq_info *txqi = to_txq_info(txq);
36883697
3689− lockdep_assert_held(&local->active_txq_lock[txq->ac]);
3698+ spin_lock_bh(&local->active_txq_lock[txq->ac]);
36903699
36913700 if (list_empty(&txqi->schedule_order) &&
3692− (!skb_queue_empty(&txqi->frags) || txqi->tin.backlog_packets)) {
3701+ (force || !skb_queue_empty(&txqi->frags) ||
3702+ txqi->tin.backlog_packets)) {
36933703 /* If airtime accounting is active, always enqueue STAs at the
36943704 * head of the list to ensure that they only get moved to the
36953705 * back by the airtime DRR scheduler once they have a negative
@@ -3706,20 +3716,10 @@ void ieee80211_return_txq(struct ieee80211_hw *hw, · 10 unmodified lines
37063716 list_add_tail(&txqi->schedule_order,
37073717 &local->active_txqs[txq->ac]);
37083718 }
3709−}
3710−EXPORT_SYMBOL(ieee80211_return_txq);
37113719
3712−void ieee80211_schedule_txq(struct ieee80211_hw *hw,
3713− struct ieee80211_txq *txq)
3714− __acquires(txq_lock) __releases(txq_lock)
3715−{
3716− struct ieee80211_local *local = hw_to_local(hw);
3717−
3718− spin_lock_bh(&local->active_txq_lock[txq->ac]);
3719− ieee80211_return_txq(hw, txq);
37203720 spin_unlock_bh(&local->active_txq_lock[txq->ac]);
37213721 }
3722−EXPORT_SYMBOL(ieee80211_schedule_txq);
3722+EXPORT_SYMBOL(__ieee80211_schedule_txq);
37233723
37243724 bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw,
37253725 struct ieee80211_txq *txq)
@@ -3729,7 +3729,7 @@ bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw, · 3 unmodified lines
37293729 struct sta_info *sta;
37303730 u8 ac = txq->ac;
37313731
3732− lockdep_assert_held(&local->active_txq_lock[ac]);
3732+ spin_lock_bh(&local->active_txq_lock[ac]);
37333733
37343734 if (!txqi->txq.sta)
37353735 goto out;
@@ -3759,34 +3759,27 @@ bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw, · 23 unmodified lines
37593759
37603760 sta->airtime[ac].deficit += sta->airtime_weight;
37613761 list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]);
3762+ spin_unlock_bh(&local->active_txq_lock[ac]);
37623763
37633764 return false;
37643765 out:
37653766 if (!list_empty(&txqi->schedule_order))
37663767 list_del_init(&txqi->schedule_order);
3768+ spin_unlock_bh(&local->active_txq_lock[ac]);
37673769
37683770 return true;
37693771 }
37703772 EXPORT_SYMBOL(ieee80211_txq_may_transmit);
37713773
37723774 void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac)
3773− __acquires(txq_lock)
37743775 {
37753776 struct ieee80211_local *local = hw_to_local(hw);
37763777
37773778 spin_lock_bh(&local->active_txq_lock[ac]);
37783779 local->schedule_round[ac]++;
3779−}
3780−EXPORT_SYMBOL(ieee80211_txq_schedule_start);
3781−
3782−void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac)
3783− __releases(txq_lock)
3784−{
3785− struct ieee80211_local *local = hw_to_local(hw);
3786−
37873780 spin_unlock_bh(&local->active_txq_lock[ac]);
37883781 }
3789−EXPORT_SYMBOL(ieee80211_txq_schedule_end);
3782+EXPORT_SYMBOL(ieee80211_txq_schedule_start);
37903783
37913784 void __ieee80211_subif_start_xmit(struct sk_buff *skb,
37923785 struct net_device *dev,
net/netlink/af_netlink.c+2−1
@@ -988,7 +988,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, · 987 unmodified lines
988988 struct netlink_sock *nlk = nlk_sk(sk);
989989 struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
990990 int err = 0;
991− unsigned long groups = nladdr->nl_groups;
991+ unsigned long groups;
992992 bool bound;
993993
994994 if (addr_len < sizeof(struct sockaddr_nl))
@@ -996,6 +996,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, · 1 unmodified line
996996
997997 if (nladdr->nl_family != AF_NETLINK)
998998 return -EINVAL;
999+ groups = nladdr->nl_groups;
9991000
10001001 /* Only superuser is allowed to listen multicasts */
10011002 if (groups) {
net/netrom/af_netrom.c+54−22
@@ -1392,18 +1392,22 @@ static int __init nr_proto_init(void) · 1391 unmodified lines
13921392 int i;
13931393 int rc = proto_register(&nr_proto, 0);
13941394
1395− if (rc != 0)
1396− goto out;
1395+ if (rc)
1396+ return rc;
13971397
13981398 if (nr_ndevs > 0x7fffffff/sizeof(struct net_device *)) {
1399− printk(KERN_ERR "NET/ROM: nr_proto_init - nr_ndevs parameter to large\n");
1400− return -1;
1399+ pr_err("NET/ROM: %s - nr_ndevs parameter too large\n",
1400+ __func__);
1401+ rc = -EINVAL;
1402+ goto unregister_proto;
14011403 }
14021404
14031405 dev_nr = kcalloc(nr_ndevs, sizeof(struct net_device *), GFP_KERNEL);
1404− if (dev_nr == NULL) {
1405− printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device array\n");
1406− return -1;
1406+ if (!dev_nr) {
1407+ pr_err("NET/ROM: %s - unable to allocate device array\n",
1408+ __func__);
1409+ rc = -ENOMEM;
1410+ goto unregister_proto;
14071411 }
14081412
14091413 for (i = 0; i < nr_ndevs; i++) {
@@ -1413,13 +1417,13 @@ static int __init nr_proto_init(void) · 3 unmodified lines
14131417 sprintf(name, "nr%d", i);
14141418 dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, nr_setup);
14151419 if (!dev) {
1416− printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n");
1420+ rc = -ENOMEM;
14171421 goto fail;
14181422 }
14191423
14201424 dev->base_addr = i;
1421− if (register_netdev(dev)) {
1422− printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register network device\n");
1425+ rc = register_netdev(dev);
1426+ if (rc) {
14231427 free_netdev(dev);
14241428 goto fail;
14251429 }
@@ -1427,36 +1431,64 @@ static int __init nr_proto_init(void) · 1 unmodified line
14271431 dev_nr[i] = dev;
14281432 }
14291433
1430− if (sock_register(&nr_family_ops)) {
1431− printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register socket family\n");
1434+ rc = sock_register(&nr_family_ops);
1435+ if (rc)
14321436 goto fail;
1433− }
14341437
1435− register_netdevice_notifier(&nr_dev_notifier);
1438+ rc = register_netdevice_notifier(&nr_dev_notifier);
1439+ if (rc)
1440+ goto out_sock;
14361441
14371442 ax25_register_pid(&nr_pid);
14381443 ax25_linkfail_register(&nr_linkfail_notifier);
14391444
14401445 #ifdef CONFIG_SYSCTL
1441− nr_register_sysctl();
1446+ rc = nr_register_sysctl();
1447+ if (rc)
1448+ goto out_sysctl;
14421449 #endif
14431450
14441451 nr_loopback_init();
14451452
1446− proc_create_seq("nr", 0444, init_net.proc_net, &nr_info_seqops);
1447− proc_create_seq("nr_neigh", 0444, init_net.proc_net, &nr_neigh_seqops);
1448− proc_create_seq("nr_nodes", 0444, init_net.proc_net, &nr_node_seqops);
1449−out:
1450− return rc;
1453+ rc = -ENOMEM;
1454+ if (!proc_create_seq("nr", 0444, init_net.proc_net, &nr_info_seqops))
1455+ goto proc_remove1;
1456+ if (!proc_create_seq("nr_neigh", 0444, init_net.proc_net,
1457+ &nr_neigh_seqops))
1458+ goto proc_remove2;
1459+ if (!proc_create_seq("nr_nodes", 0444, init_net.proc_net,
1460+ &nr_node_seqops))
1461+ goto proc_remove3;
1462+
1463+ return 0;
1464+
1465+proc_remove3:
1466+ remove_proc_entry("nr_neigh", init_net.proc_net);
1467+proc_remove2:
1468+ remove_proc_entry("nr", init_net.proc_net);
1469+proc_remove1:
1470+
1471+ nr_loopback_clear();
1472+ nr_rt_free();
1473+
1474+#ifdef CONFIG_SYSCTL
1475+ nr_unregister_sysctl();
1476+out_sysctl:
1477+#endif
1478+ ax25_linkfail_release(&nr_linkfail_notifier);
1479+ ax25_protocol_release(AX25_P_NETROM);
1480+ unregister_netdevice_notifier(&nr_dev_notifier);
1481+out_sock:
1482+ sock_unregister(PF_NETROM);
14511483 fail:
14521484 while (--i >= 0) {
14531485 unregister_netdev(dev_nr[i]);
14541486 free_netdev(dev_nr[i]);
14551487 }
14561488 kfree(dev_nr);
1489+unregister_proto:
14571490 proto_unregister(&nr_proto);
1458− rc = -1;
1459− goto out;
1491+ return rc;
14601492 }
14611493
14621494 module_init(nr_proto_init);
net/netrom/nr_loopback.c+1−1
@@ -70,7 +70,7 @@ static void nr_loopback_timer(struct timer_list *unused) · 69 unmodified lines
7070 }
7171 }
7272
73−void __exit nr_loopback_clear(void)
73+void nr_loopback_clear(void)
7474 {
7575 del_timer_sync(&loopback_timer);
7676 skb_queue_purge(&loopback_queue);
net/netrom/nr_route.c+1−1
@@ -953,7 +953,7 @@ const struct seq_operations nr_neigh_seqops = { · 952 unmodified lines
953953 /*
954954 * Free all memory associated with the nodes and routes lists.
955955 */
956−void __exit nr_rt_free(void)
956+void nr_rt_free(void)
957957 {
958958 struct nr_neigh *s = NULL;
959959 struct nr_node *t = NULL;
net/netrom/sysctl_net_netrom.c+4−1
@@ -146,9 +146,12 @@ static struct ctl_table nr_table[] = { · 145 unmodified lines
146146 { }
147147 };
148148
149−void __init nr_register_sysctl(void)
149+int __init nr_register_sysctl(void)
150150 {
151151 nr_table_header = register_net_sysctl(&init_net, "net/netrom", nr_table);
152+ if (!nr_table_header)
153+ return -ENOMEM;
154+ return 0;
152155 }
153156
154157 void nr_unregister_sysctl(void)
net/rds/af_rds.c+3−0
@@ -543,6 +543,9 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr, · 542 unmodified lines
543543 struct rds_sock *rs = rds_sk_to_rs(sk);
544544 int ret = 0;
545545
546+ if (addr_len < offsetofend(struct sockaddr, sa_family))
547+ return -EINVAL;
548+
546549 lock_sock(sk);
547550
548551 switch (uaddr->sa_family) {
net/rds/bind.c+2−0
@@ -173,6 +173,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · 172 unmodified lines
173173 /* We allow an RDS socket to be bound to either IPv4 or IPv6
174174 * address.
175175 */
176+ if (addr_len < offsetofend(struct sockaddr, sa_family))
177+ return -EINVAL;
176178 if (uaddr->sa_family == AF_INET) {
177179 struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;
178180
net/rxrpc/af_rxrpc.c+11−6
@@ -135,7 +135,7 @@ static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len) · 134 unmodified lines
135135 struct sockaddr_rxrpc *srx = (struct sockaddr_rxrpc *)saddr;
136136 struct rxrpc_local *local;
137137 struct rxrpc_sock *rx = rxrpc_sk(sock->sk);
138− u16 service_id = srx->srx_service;
138+ u16 service_id;
139139 int ret;
140140
141141 _enter("%p,%p,%d", rx, saddr, len);
@@ -143,6 +143,7 @@ static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len) · 1 unmodified line
143143 ret = rxrpc_validate_address(rx, srx, len);
144144 if (ret < 0)
145145 goto error;
146+ service_id = srx->srx_service;
146147
147148 lock_sock(&rx->sk);
148149
@@ -370,18 +371,22 @@ EXPORT_SYMBOL(rxrpc_kernel_end_call); · 221 unmodified lines
370371 * rxrpc_kernel_check_life - Check to see whether a call is still alive
371372 * @sock: The socket the call is on
372373 * @call: The call to check
374+ * @_life: Where to store the life value
373375 *
374376 * Allow a kernel service to find out whether a call is still alive - ie. we're
375− * getting ACKs from the server. Returns a number representing the life state
376− * which can be compared to that returned by a previous call.
377+ * getting ACKs from the server. Passes back in *_life a number representing
378+ * the life state which can be compared to that returned by a previous call and
379+ * return true if the call is still alive.
377380 *
378381 * If the life state stalls, rxrpc_kernel_probe_life() should be called and
379382 * then 2RTT waited.
380383 */
381−u32 rxrpc_kernel_check_life(const struct socket *sock,
382− const struct rxrpc_call *call)
384+bool rxrpc_kernel_check_life(const struct socket *sock,
385+ const struct rxrpc_call *call,
386+ u32 *_life)
383387 {
384− return call->acks_latest;
388+ *_life = call->acks_latest;
389+ return call->state != RXRPC_CALL_COMPLETE;
385390 }
386391 EXPORT_SYMBOL(rxrpc_kernel_check_life);
387392
net/rxrpc/ar-internal.h+1−0
@@ -654,6 +654,7 @@ struct rxrpc_call { · 653 unmodified lines
654654 u8 ackr_reason; /* reason to ACK */
655655 u16 ackr_skew; /* skew on packet being ACK'd */
656656 rxrpc_serial_t ackr_serial; /* serial of packet being ACK'd */
657+ rxrpc_serial_t ackr_first_seq; /* first sequence number received */
657658 rxrpc_seq_t ackr_prev_seq; /* previous sequence number received */
658659 rxrpc_seq_t ackr_consumed; /* Highest packet shown consumed */
659660 rxrpc_seq_t ackr_seen; /* Highest packet shown seen */
net/rxrpc/conn_event.c+7−4
@@ -153,7 +153,8 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn, · 152 unmodified lines
153153 * pass a connection-level abort onto all calls on that connection
154154 */
155155 static void rxrpc_abort_calls(struct rxrpc_connection *conn,
156− enum rxrpc_call_completion compl)
156+ enum rxrpc_call_completion compl,
157+ rxrpc_serial_t serial)
157158 {
158159 struct rxrpc_call *call;
159160 int i;
@@ -173,6 +174,9 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn, · 13 unmodified lines
173174 call->call_id, 0,
174175 conn->abort_code,
175176 conn->error);
177+ else
178+ trace_rxrpc_rx_abort(call, serial,
179+ conn->abort_code);
176180 if (rxrpc_set_call_completion(call, compl,
177181 conn->abort_code,
178182 conn->error))
@@ -213,8 +217,6 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn, · 34 unmodified lines
213217 conn->state = RXRPC_CONN_LOCALLY_ABORTED;
214218 spin_unlock_bh(&conn->state_lock);
215219
216− rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED);
217−
218220 msg.msg_name = &conn->params.peer->srx.transport;
219221 msg.msg_namelen = conn->params.peer->srx.transport_len;
220222 msg.msg_control = NULL;
@@ -242,6 +244,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn, · 21 unmodified lines
242244 len = iov[0].iov_len + iov[1].iov_len;
243245
244246 serial = atomic_inc_return(&conn->serial);
247+ rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED, serial);
245248 whdr.serial = htonl(serial);
246249 _proto("Tx CONN ABORT %%%u { %d }", serial, conn->abort_code);
247250
@@ -321,7 +324,7 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, · 73 unmodified lines
321324 conn->error = -ECONNABORTED;
322325 conn->abort_code = abort_code;
323326 conn->state = RXRPC_CONN_REMOTELY_ABORTED;
324− rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED);
327+ rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED, sp->hdr.serial);
325328 return -ECONNABORTED;
326329
327330 case RXRPC_PACKET_TYPE_CHALLENGE:
net/rxrpc/input.c+12−6
@@ -837,7 +837,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb, · 836 unmodified lines
837837 u8 acks[RXRPC_MAXACKS];
838838 } buf;
839839 rxrpc_serial_t acked_serial;
840− rxrpc_seq_t first_soft_ack, hard_ack;
840+ rxrpc_seq_t first_soft_ack, hard_ack, prev_pkt;
841841 int nr_acks, offset, ioffset;
842842
843843 _enter("");
@@ -851,13 +851,14 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb, · 7 unmodified lines
851851
852852 acked_serial = ntohl(buf.ack.serial);
853853 first_soft_ack = ntohl(buf.ack.firstPacket);
854+ prev_pkt = ntohl(buf.ack.previousPacket);
854855 hard_ack = first_soft_ack - 1;
855856 nr_acks = buf.ack.nAcks;
856857 summary.ack_reason = (buf.ack.reason < RXRPC_ACK__INVALID ?
857858 buf.ack.reason : RXRPC_ACK__INVALID);
858859
859860 trace_rxrpc_rx_ack(call, sp->hdr.serial, acked_serial,
860− first_soft_ack, ntohl(buf.ack.previousPacket),
861+ first_soft_ack, prev_pkt,
861862 summary.ack_reason, nr_acks);
862863
863864 if (buf.ack.reason == RXRPC_ACK_PING_RESPONSE)
@@ -878,8 +879,9 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb, · 14 unmodified lines
878879 rxrpc_propose_ack_respond_to_ack);
879880 }
880881
881− /* Discard any out-of-order or duplicate ACKs. */
882− if (before_eq(sp->hdr.serial, call->acks_latest))
882+ /* Discard any out-of-order or duplicate ACKs (outside lock). */
883+ if (before(first_soft_ack, call->ackr_first_seq) ||
884+ before(prev_pkt, call->ackr_prev_seq))
883885 return;
884886
885887 buf.info.rxMTU = 0;
@@ -890,12 +892,16 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb, · 4 unmodified lines
890892
891893 spin_lock(&call->input_lock);
892894
893− /* Discard any out-of-order or duplicate ACKs. */
894− if (before_eq(sp->hdr.serial, call->acks_latest))
895+ /* Discard any out-of-order or duplicate ACKs (inside lock). */
896+ if (before(first_soft_ack, call->ackr_first_seq) ||
897+ before(prev_pkt, call->ackr_prev_seq))
895898 goto out;
896899 call->acks_latest_ts = skb->tstamp;
897900 call->acks_latest = sp->hdr.serial;
898901
902+ call->ackr_first_seq = first_soft_ack;
903+ call->ackr_prev_seq = prev_pkt;
904+
899905 /* Parse rwind and mtu sizes if provided. */
900906 if (buf.info.rxMTU)
901907 rxrpc_input_ackinfo(call, skb, &buf.info);
net/rxrpc/peer_event.c+5−0
@@ -157,6 +157,11 @@ void rxrpc_error_report(struct sock *sk) · 156 unmodified lines
157157
158158 _enter("%p{%d}", sk, local->debug_id);
159159
160+ /* Clear the outstanding error value on the socket so that it doesn't
161+ * cause kernel_sendmsg() to return it later.
162+ */
163+ sock_error(sk);
164+
160165 skb = sock_dequeue_err_skb(sk);
161166 if (!skb) {
162167 _leave("UDP socket errqueue empty");
net/rxrpc/sendmsg.c+12−9
@@ -152,12 +152,13 @@ static void rxrpc_notify_end_tx(struct rxrpc_sock *rx, struct rxrpc_call *call, · 151 unmodified lines
152152 }
153153
154154 /*
155− * Queue a DATA packet for transmission, set the resend timeout and send the
156− * packet immediately
155+ * Queue a DATA packet for transmission, set the resend timeout and send
156+ * the packet immediately. Returns the error from rxrpc_send_data_packet()
157+ * in case the caller wants to do something with it.
157158 */
158−static void rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
159− struct sk_buff *skb, bool last,
160− rxrpc_notify_end_tx_t notify_end_tx)
159+static int rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
160+ struct sk_buff *skb, bool last,
161+ rxrpc_notify_end_tx_t notify_end_tx)
161162 {
162163 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
163164 unsigned long now;
@@ -250,7 +251,8 @@ static void rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call, · 86 unmodified lines
250251
251252 out:
252253 rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
253− _leave("");
254+ _leave(" = %d", ret);
255+ return ret;
254256 }
255257
256258 /*
@@ -423,9 +425,10 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, · 166 unmodified lines
423425 if (ret < 0)
424426 goto out;
425427
426− rxrpc_queue_packet(rx, call, skb,
427− !msg_data_left(msg) && !more,
428− notify_end_tx);
428+ ret = rxrpc_queue_packet(rx, call, skb,
429+ !msg_data_left(msg) && !more,
430+ notify_end_tx);
431+ /* Should check for failure here */
429432 skb = NULL;
430433 }
431434 } while (msg_data_left(msg) > 0);
net/sctp/socket.c+2−1
@@ -4850,7 +4850,8 @@ static int sctp_connect(struct sock *sk, struct sockaddr *addr, · 4849 unmodified lines
48504850 }
48514851
48524852 /* Validate addr_len before calling common connect/connectx routine. */
4853− af = sctp_get_af_specific(addr->sa_family);
4853+ af = addr_len < offsetofend(struct sockaddr, sa_family) ? NULL :
4854+ sctp_get_af_specific(addr->sa_family);
48544855 if (!af || addr_len < af->sockaddr_len) {
48554856 err = -EINVAL;
48564857 } else {
net/smc/af_smc.c+39−19
@@ -165,10 +165,9 @@ static int smc_release(struct socket *sock) · 164 unmodified lines
165165
166166 if (sk->sk_state == SMC_CLOSED) {
167167 if (smc->clcsock) {
168− mutex_lock(&smc->clcsock_release_lock);
169− sock_release(smc->clcsock);
170− smc->clcsock = NULL;
171− mutex_unlock(&smc->clcsock_release_lock);
168+ release_sock(sk);
169+ smc_clcsock_release(smc);
170+ lock_sock(sk);
172171 }
173172 if (!smc->use_fallback)
174173 smc_conn_free(&smc->conn);
@@ -444,10 +443,19 @@ static void smc_link_save_peer_info(struct smc_link *link, · 269 unmodified lines
444443 link->peer_mtu = clc->qp_mtu;
445444 }
446445
446+static void smc_switch_to_fallback(struct smc_sock *smc)
447+{
448+ smc->use_fallback = true;
449+ if (smc->sk.sk_socket && smc->sk.sk_socket->file) {
450+ smc->clcsock->file = smc->sk.sk_socket->file;
451+ smc->clcsock->file->private_data = smc->clcsock;
452+ }
453+}
454+
447455 /* fall back during connect */
448456 static int smc_connect_fallback(struct smc_sock *smc, int reason_code)
449457 {
450− smc->use_fallback = true;
458+ smc_switch_to_fallback(smc);
451459 smc->fallback_rsn = reason_code;
452460 smc_copy_sock_settings_to_clc(smc);
453461 smc->connect_nonblock = 0;
@@ -780,10 +788,14 @@ static void smc_connect_work(struct work_struct *work) · 326 unmodified lines
780788 smc->sk.sk_err = -rc;
781789
782790 out:
783− if (smc->sk.sk_err)
784− smc->sk.sk_state_change(&smc->sk);
785− else
786− smc->sk.sk_write_space(&smc->sk);
791+ if (!sock_flag(&smc->sk, SOCK_DEAD)) {
792+ if (smc->sk.sk_err) {
793+ smc->sk.sk_state_change(&smc->sk);
794+ } else { /* allow polling before and after fallback decision */
795+ smc->clcsock->sk->sk_write_space(smc->clcsock->sk);
796+ smc->sk.sk_write_space(&smc->sk);
797+ }
798+ }
787799 release_sock(&smc->sk);
788800 }
789801
@@ -867,11 +879,11 @@ static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc) · 77 unmodified lines
867879 if (rc < 0)
868880 lsk->sk_err = -rc;
869881 if (rc < 0 || lsk->sk_state == SMC_CLOSED) {
882+ new_sk->sk_prot->unhash(new_sk);
870883 if (new_clcsock)
871884 sock_release(new_clcsock);
872885 new_sk->sk_state = SMC_CLOSED;
873886 sock_set_flag(new_sk, SOCK_DEAD);
874− new_sk->sk_prot->unhash(new_sk);
875887 sock_put(new_sk); /* final */
876888 *new_smc = NULL;
877889 goto out;
@@ -922,16 +934,21 @@ struct sock *smc_accept_dequeue(struct sock *parent, · 44 unmodified lines
922934
923935 smc_accept_unlink(new_sk);
924936 if (new_sk->sk_state == SMC_CLOSED) {
937+ new_sk->sk_prot->unhash(new_sk);
925938 if (isk->clcsock) {
926939 sock_release(isk->clcsock);
927940 isk->clcsock = NULL;
928941 }
929− new_sk->sk_prot->unhash(new_sk);
930942 sock_put(new_sk); /* final */
931943 continue;
932944 }
933− if (new_sock)
945+ if (new_sock) {
934946 sock_graft(new_sk, new_sock);
947+ if (isk->use_fallback) {
948+ smc_sk(new_sk)->clcsock->file = new_sock->file;
949+ isk->clcsock->file->private_data = isk->clcsock;
950+ }
951+ }
935952 return new_sk;
936953 }
937954 return NULL;
@@ -951,6 +968,7 @@ void smc_close_non_accepted(struct sock *sk) · 13 unmodified lines
951968 sock_set_flag(sk, SOCK_DEAD);
952969 sk->sk_shutdown |= SHUTDOWN_MASK;
953970 }
971+ sk->sk_prot->unhash(sk);
954972 if (smc->clcsock) {
955973 struct socket *tcp;
956974
@@ -966,7 +984,6 @@ void smc_close_non_accepted(struct sock *sk) · 9 unmodified lines
966984 smc_conn_free(&smc->conn);
967985 }
968986 release_sock(sk);
969− sk->sk_prot->unhash(sk);
970987 sock_put(sk); /* final sock_put */
971988 }
972989
@@ -1032,13 +1049,13 @@ static void smc_listen_out(struct smc_sock *new_smc) · 59 unmodified lines
10321049 struct smc_sock *lsmc = new_smc->listen_smc;
10331050 struct sock *newsmcsk = &new_smc->sk;
10341051
1035− lock_sock_nested(&lsmc->sk, SINGLE_DEPTH_NESTING);
10361052 if (lsmc->sk.sk_state == SMC_LISTEN) {
1053+ lock_sock_nested(&lsmc->sk, SINGLE_DEPTH_NESTING);
10371054 smc_accept_enqueue(&lsmc->sk, newsmcsk);
1055+ release_sock(&lsmc->sk);
10381056 } else { /* no longer listening */
10391057 smc_close_non_accepted(newsmcsk);
10401058 }
1041− release_sock(&lsmc->sk);
10421059
10431060 /* Wake up accept */
10441061 lsmc->sk.sk_data_ready(&lsmc->sk);
@@ -1082,7 +1099,7 @@ static void smc_listen_decline(struct smc_sock *new_smc, int reason_code, · 37 unmodified lines
10821099 return;
10831100 }
10841101 smc_conn_free(&new_smc->conn);
1085− new_smc->use_fallback = true;
1102+ smc_switch_to_fallback(new_smc);
10861103 new_smc->fallback_rsn = reason_code;
10871104 if (reason_code && reason_code != SMC_CLC_DECL_PEERDECL) {
10881105 if (smc_clc_send_decline(new_smc, reason_code) < 0) {
@@ -1220,6 +1237,9 @@ static void smc_listen_work(struct work_struct *work) · 131 unmodified lines
12201237 u8 buf[SMC_CLC_MAX_LEN];
12211238 int rc = 0;
12221239
1240+ if (new_smc->listen_smc->sk.sk_state != SMC_LISTEN)
1241+ return smc_listen_out_err(new_smc);
1242+
12231243 if (new_smc->use_fallback) {
12241244 smc_listen_out_connected(new_smc);
12251245 return;
@@ -1227,7 +1247,7 @@ static void smc_listen_work(struct work_struct *work) · 1 unmodified line
12271247
12281248 /* check if peer is smc capable */
12291249 if (!tcp_sk(newclcsock->sk)->syn_smc) {
1230− new_smc->use_fallback = true;
1250+ smc_switch_to_fallback(new_smc);
12311251 new_smc->fallback_rsn = SMC_CLC_DECL_PEERNOSMC;
12321252 smc_listen_out_connected(new_smc);
12331253 return;
@@ -1507,7 +1527,7 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) · 273 unmodified lines
15071527
15081528 if (msg->msg_flags & MSG_FASTOPEN) {
15091529 if (sk->sk_state == SMC_INIT) {
1510− smc->use_fallback = true;
1530+ smc_switch_to_fallback(smc);
15111531 smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP;
15121532 } else {
15131533 rc = -EINVAL;
@@ -1712,7 +1732,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, · 198 unmodified lines
17121732 case TCP_FASTOPEN_NO_COOKIE:
17131733 /* option not supported by SMC */
17141734 if (sk->sk_state == SMC_INIT) {
1715− smc->use_fallback = true;
1735+ smc_switch_to_fallback(smc);
17161736 smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP;
17171737 } else {
17181738 if (!smc->use_fallback)
net/smc/smc_close.c+21−4
@@ -21,6 +21,22 @@ · 20 unmodified lines
2121
2222 #define SMC_CLOSE_WAIT_LISTEN_CLCSOCK_TIME (5 * HZ)
2323
24+/* release the clcsock that is assigned to the smc_sock */
25+void smc_clcsock_release(struct smc_sock *smc)
26+{
27+ struct socket *tcp;
28+
29+ if (smc->listen_smc && current_work() != &smc->smc_listen_work)
30+ cancel_work_sync(&smc->smc_listen_work);
31+ mutex_lock(&smc->clcsock_release_lock);
32+ if (smc->clcsock) {
33+ tcp = smc->clcsock;
34+ smc->clcsock = NULL;
35+ sock_release(tcp);
36+ }
37+ mutex_unlock(&smc->clcsock_release_lock);
38+}
39+
2440 static void smc_close_cleanup_listen(struct sock *parent)
2541 {
2642 struct sock *sk;
@@ -321,6 +337,7 @@ static void smc_close_passive_work(struct work_struct *work) · 294 unmodified lines
321337 close_work);
322338 struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
323339 struct smc_cdc_conn_state_flags *rxflags;
340+ bool release_clcsock = false;
324341 struct sock *sk = &smc->sk;
325342 int old_state;
326343
@@ -400,13 +417,13 @@ wakeup: · 73 unmodified lines
400417 if ((sk->sk_state == SMC_CLOSED) &&
401418 (sock_flag(sk, SOCK_DEAD) || !sk->sk_socket)) {
402419 smc_conn_free(conn);
403− if (smc->clcsock) {
404− sock_release(smc->clcsock);
405− smc->clcsock = NULL;
406− }
420+ if (smc->clcsock)
421+ release_clcsock = true;
407422 }
408423 }
409424 release_sock(sk);
425+ if (release_clcsock)
426+ smc_clcsock_release(smc);
410427 sock_put(sk); /* sock_hold done by schedulers of close_work */
411428 }
412429
net/smc/smc_close.h+1−0
@@ -23,5 +23,6 @@ void smc_close_wake_tx_prepared(struct smc_sock *smc); · 22 unmodified lines
2323 int smc_close_active(struct smc_sock *smc);
2424 int smc_close_shutdown_write(struct smc_sock *smc);
2525 void smc_close_init(struct smc_sock *smc);
26+void smc_clcsock_release(struct smc_sock *smc);
2627
2728 #endif /* SMC_CLOSE_H */
net/smc/smc_ism.c+5−0
@@ -289,6 +289,11 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name, · 288 unmodified lines
289289 INIT_LIST_HEAD(&smcd->vlan);
290290 smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)",
291291 WQ_MEM_RECLAIM, name);
292+ if (!smcd->event_wq) {
293+ kfree(smcd->conn);
294+ kfree(smcd);
295+ return NULL;
296+ }
292297 return smcd;
293298 }
294299 EXPORT_SYMBOL_GPL(smcd_alloc_dev);
net/smc/smc_pnet.c+2−1
@@ -604,7 +604,8 @@ static int smc_pnet_flush(struct sk_buff *skb, struct genl_info *info) · 603 unmodified lines
604604 {
605605 struct net *net = genl_info_net(info);
606606
607− return smc_pnet_remove_by_pnetid(net, NULL);
607+ smc_pnet_remove_by_pnetid(net, NULL);
608+ return 0;
608609 }
609610
610611 /* SMC_PNETID generic netlink operation definition */
net/strparser/strparser.c+5−7
@@ -140,13 +140,11 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb, · 139 unmodified lines
140140 /* We are going to append to the frags_list of head.
141141 * Need to unshare the frag_list.
142142 */
143− if (skb_has_frag_list(head)) {
144− err = skb_unclone(head, GFP_ATOMIC);
145− if (err) {
146− STRP_STATS_INCR(strp->stats.mem_fail);
147− desc->error = err;
148− return 0;
149− }
143+ err = skb_unclone(head, GFP_ATOMIC);
144+ if (err) {
145+ STRP_STATS_INCR(strp->stats.mem_fail);
146+ desc->error = err;
147+ return 0;
150148 }
151149
152150 if (unlikely(skb_shinfo(head)->frag_list)) {
net/sunrpc/clnt.c+8−37
@@ -1540,7 +1540,6 @@ call_start(struct rpc_task *task) · 1539 unmodified lines
15401540 clnt->cl_stats->rpccnt++;
15411541 task->tk_action = call_reserve;
15421542 rpc_task_set_transport(task, clnt);
1543− call_reserve(task);
15441543 }
15451544
15461545 /*
@@ -1554,9 +1553,6 @@ call_reserve(struct rpc_task *task) · 7 unmodified lines
15541553 task->tk_status = 0;
15551554 task->tk_action = call_reserveresult;
15561555 xprt_reserve(task);
1557− if (rpc_task_need_resched(task))
1558− return;
1559− call_reserveresult(task);
15601556 }
15611557
15621558 static void call_retry_reserve(struct rpc_task *task);
@@ -1579,7 +1575,6 @@ call_reserveresult(struct rpc_task *task) · 16 unmodified lines
15791575 if (status >= 0) {
15801576 if (task->tk_rqstp) {
15811577 task->tk_action = call_refresh;
1582− call_refresh(task);
15831578 return;
15841579 }
15851580
@@ -1605,7 +1600,6 @@ call_reserveresult(struct rpc_task *task) · 19 unmodified lines
16051600 /* fall through */
16061601 case -EAGAIN: /* woken up; retry */
16071602 task->tk_action = call_retry_reserve;
1608− call_retry_reserve(task);
16091603 return;
16101604 case -EIO: /* probably a shutdown */
16111605 break;
@@ -1628,9 +1622,6 @@ call_retry_reserve(struct rpc_task *task) · 16 unmodified lines
16281622 task->tk_status = 0;
16291623 task->tk_action = call_reserveresult;
16301624 xprt_retry_reserve(task);
1631− if (rpc_task_need_resched(task))
1632− return;
1633− call_reserveresult(task);
16341625 }
16351626
16361627 /*
@@ -1645,9 +1636,6 @@ call_refresh(struct rpc_task *task) · 8 unmodified lines
16451636 task->tk_status = 0;
16461637 task->tk_client->cl_stats->rpcauthrefresh++;
16471638 rpcauth_refreshcred(task);
1648− if (rpc_task_need_resched(task))
1649− return;
1650− call_refreshresult(task);
16511639 }
16521640
16531641 /*
@@ -1666,7 +1654,6 @@ call_refreshresult(struct rpc_task *task) · 12 unmodified lines
16661654 case 0:
16671655 if (rpcauth_uptodatecred(task)) {
16681656 task->tk_action = call_allocate;
1669− call_allocate(task);
16701657 return;
16711658 }
16721659 /* Use rate-limiting and a max number of retries if refresh
@@ -1685,7 +1672,6 @@ call_refreshresult(struct rpc_task *task) · 12 unmodified lines
16851672 task->tk_cred_retry--;
16861673 dprintk("RPC: %5u %s: retry refresh creds\n",
16871674 task->tk_pid, __func__);
1688− call_refresh(task);
16891675 return;
16901676 }
16911677 dprintk("RPC: %5u %s: refresh creds failed with error %d\n",
@@ -1711,10 +1697,8 @@ call_allocate(struct rpc_task *task) · 19 unmodified lines
17111697 task->tk_status = 0;
17121698 task->tk_action = call_encode;
17131699
1714− if (req->rq_buffer) {
1715− call_encode(task);
1700+ if (req->rq_buffer)
17161701 return;
1717− }
17181702
17191703 if (proc->p_proc != 0) {
17201704 BUG_ON(proc->p_arglen == 0);
@@ -1740,12 +1724,8 @@ call_allocate(struct rpc_task *task) · 19 unmodified lines
17401724
17411725 status = xprt->ops->buf_alloc(task);
17421726 xprt_inject_disconnect(xprt);
1743− if (status == 0) {
1744− if (rpc_task_need_resched(task))
1745− return;
1746− call_encode(task);
1727+ if (status == 0)
17471728 return;
1748− }
17491729 if (status != -ENOMEM) {
17501730 rpc_exit(task, status);
17511731 return;
@@ -1828,8 +1808,12 @@ call_encode(struct rpc_task *task) · 76 unmodified lines
18281808 xprt_request_enqueue_receive(task);
18291809 xprt_request_enqueue_transmit(task);
18301810 out:
1831− task->tk_action = call_bind;
1832− call_bind(task);
1811+ task->tk_action = call_transmit;
1812+ /* Check that the connection is OK */
1813+ if (!xprt_bound(task->tk_xprt))
1814+ task->tk_action = call_bind;
1815+ else if (!xprt_connected(task->tk_xprt))
1816+ task->tk_action = call_connect;
18331817 }
18341818
18351819 /*
@@ -1847,7 +1831,6 @@ rpc_task_handle_transmitted(struct rpc_task *task) · 11 unmodified lines
18471831 {
18481832 xprt_end_transmit(task);
18491833 task->tk_action = call_transmit_status;
1850− call_transmit_status(task);
18511834 }
18521835
18531836 /*
@@ -1865,7 +1848,6 @@ call_bind(struct rpc_task *task) · 11 unmodified lines
18651848
18661849 if (xprt_bound(xprt)) {
18671850 task->tk_action = call_connect;
1868− call_connect(task);
18691851 return;
18701852 }
18711853
@@ -1896,7 +1878,6 @@ call_bind_status(struct rpc_task *task) · 24 unmodified lines
18961878 dprint_status(task);
18971879 task->tk_status = 0;
18981880 task->tk_action = call_connect;
1899− call_connect(task);
19001881 return;
19011882 }
19021883
@@ -1981,7 +1962,6 @@ call_connect(struct rpc_task *task) · 78 unmodified lines
19811962
19821963 if (xprt_connected(xprt)) {
19831964 task->tk_action = call_transmit;
1984− call_transmit(task);
19851965 return;
19861966 }
19871967
@@ -2051,7 +2031,6 @@ call_connect_status(struct rpc_task *task) · 63 unmodified lines
20512031 case 0:
20522032 clnt->cl_stats->netreconn++;
20532033 task->tk_action = call_transmit;
2054− call_transmit(task);
20552034 return;
20562035 }
20572036 rpc_exit(task, status);
@@ -2087,9 +2066,6 @@ call_transmit(struct rpc_task *task) · 29 unmodified lines
20872066 xprt_transmit(task);
20882067 }
20892068 xprt_end_transmit(task);
2090− if (rpc_task_need_resched(task))
2091− return;
2092− call_transmit_status(task);
20932069 }
20942070
20952071 /*
@@ -2107,9 +2083,6 @@ call_transmit_status(struct rpc_task *task) · 11 unmodified lines
21072083 if (rpc_task_transmitted(task)) {
21082084 if (task->tk_status == 0)
21092085 xprt_request_wait_receive(task);
2110− if (rpc_task_need_resched(task))
2111− return;
2112− call_status(task);
21132086 return;
21142087 }
21152088
@@ -2170,7 +2143,6 @@ call_bc_encode(struct rpc_task *task) · 54 unmodified lines
21702143 {
21712144 xprt_request_enqueue_transmit(task);
21722145 task->tk_action = call_bc_transmit;
2173− call_bc_transmit(task);
21742146 }
21752147
21762148 /*
@@ -2261,7 +2233,6 @@ call_status(struct rpc_task *task) · 84 unmodified lines
22612233 status = task->tk_status;
22622234 if (status >= 0) {
22632235 task->tk_action = call_decode;
2264− call_decode(task);
22652236 return;
22662237 }
22672238
net/sunrpc/xprtrdma/verbs.c+1−1
@@ -90,7 +90,7 @@ static void rpcrdma_xprt_drain(struct rpcrdma_xprt *r_xprt) · 89 unmodified lines
9090 /* Flush Receives, then wait for deferred Reply work
9191 * to complete.
9292 */
93− ib_drain_qp(ia->ri_id->qp);
93+ ib_drain_rq(ia->ri_id->qp);
9494 drain_workqueue(buf->rb_completion_wq);
9595
9696 /* Deferred Reply processing might have scheduled
net/tipc/link.c+2−0
@@ -876,6 +876,8 @@ void tipc_link_reset(struct tipc_link *l) · 875 unmodified lines
876876 __skb_queue_head_init(&list);
877877
878878 l->in_session = false;
879+ /* Force re-synch of peer session number before establishing */
880+ l->peer_session--;
879881 l->session++;
880882 l->mtu = l->advertised_mtu;
881883
net/tipc/name_table.c+2−1
@@ -909,7 +909,8 @@ static int tipc_nl_service_list(struct net *net, struct tipc_nl_msg *msg, · 908 unmodified lines
909909 for (; i < TIPC_NAMETBL_SIZE; i++) {
910910 head = &tn->nametbl->services[i];
911911
912− if (*last_type) {
912+ if (*last_type ||
913+ (!i && *last_key && (*last_lower == *last_key))) {
913914 service = tipc_service_find(net, *last_type);
914915 if (!service)
915916 return -EPIPE;
net/tipc/sysctl.c+6−2
@@ -38,6 +38,8 @@ · 37 unmodified lines
3838
3939 #include <linux/sysctl.h>
4040
41+static int zero;
42+static int one = 1;
4143 static struct ctl_table_header *tipc_ctl_hdr;
4244
4345 static struct ctl_table tipc_table[] = {
@@ -46,14 +48,16 @@ static struct ctl_table tipc_table[] = { · 2 unmodified lines
4648 .data = &sysctl_tipc_rmem,
4749 .maxlen = sizeof(sysctl_tipc_rmem),
4850 .mode = 0644,
49− .proc_handler = proc_dointvec,
51+ .proc_handler = proc_dointvec_minmax,
52+ .extra1 = &one,
5053 },
5154 {
5255 .procname = "named_timeout",
5356 .data = &sysctl_tipc_named_timeout,
5457 .maxlen = sizeof(sysctl_tipc_named_timeout),
5558 .mode = 0644,
56− .proc_handler = proc_dointvec,
59+ .proc_handler = proc_dointvec_minmax,
60+ .extra1 = &zero,
5761 },
5862 {
5963 .procname = "sk_filter",
net/tls/tls_device.c+11−1
@@ -52,8 +52,11 @@ static DEFINE_SPINLOCK(tls_device_lock); · 51 unmodified lines
5252
5353 static void tls_device_free_ctx(struct tls_context *ctx)
5454 {
55− if (ctx->tx_conf == TLS_HW)
55+ if (ctx->tx_conf == TLS_HW) {
5656 kfree(tls_offload_ctx_tx(ctx));
57+ kfree(ctx->tx.rec_seq);
58+ kfree(ctx->tx.iv);
59+ }
5760
5861 if (ctx->rx_conf == TLS_HW)
5962 kfree(tls_offload_ctx_rx(ctx));
@@ -216,6 +219,13 @@ void tls_device_sk_destruct(struct sock *sk) · 156 unmodified lines
216219 }
217220 EXPORT_SYMBOL(tls_device_sk_destruct);
218221
222+void tls_device_free_resources_tx(struct sock *sk)
223+{
224+ struct tls_context *tls_ctx = tls_get_ctx(sk);
225+
226+ tls_free_partial_record(sk, tls_ctx);
227+}
228+
219229 static void tls_append_frag(struct tls_record_info *record,
220230 struct page_frag *pfrag,
221231 int size)
net/tls/tls_main.c+24−0
@@ -208,6 +208,26 @@ int tls_push_partial_record(struct sock *sk, struct tls_context *ctx, · 207 unmodified lines
208208 return tls_push_sg(sk, ctx, sg, offset, flags);
209209 }
210210
211+bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx)
212+{
213+ struct scatterlist *sg;
214+
215+ sg = ctx->partially_sent_record;
216+ if (!sg)
217+ return false;
218+
219+ while (1) {
220+ put_page(sg_page(sg));
221+ sk_mem_uncharge(sk, sg->length);
222+
223+ if (sg_is_last(sg))
224+ break;
225+ sg++;
226+ }
227+ ctx->partially_sent_record = NULL;
228+ return true;
229+}
230+
211231 static void tls_write_space(struct sock *sk)
212232 {
213233 struct tls_context *ctx = tls_get_ctx(sk);
@@ -267,6 +287,10 @@ static void tls_sk_proto_close(struct sock *sk, long timeout) · 53 unmodified lines
267287 kfree(ctx->tx.rec_seq);
268288 kfree(ctx->tx.iv);
269289 tls_sw_free_resources_tx(sk);
290+#ifdef CONFIG_TLS_DEVICE
291+ } else if (ctx->tx_conf == TLS_HW) {
292+ tls_device_free_resources_tx(sk);
293+#endif
270294 }
271295
272296 if (ctx->rx_conf == TLS_SW) {
net/tls/tls_sw.c+1−14
@@ -2065,20 +2065,7 @@ void tls_sw_free_resources_tx(struct sock *sk) · 2064 unmodified lines
20652065 /* Free up un-sent records in tx_list. First, free
20662066 * the partially sent record if any at head of tx_list.
20672067 */
2068− if (tls_ctx->partially_sent_record) {
2069− struct scatterlist *sg = tls_ctx->partially_sent_record;
2070−
2071− while (1) {
2072− put_page(sg_page(sg));
2073− sk_mem_uncharge(sk, sg->length);
2074−
2075− if (sg_is_last(sg))
2076− break;
2077− sg++;
2078− }
2079−
2080− tls_ctx->partially_sent_record = NULL;
2081−
2068+ if (tls_free_partial_record(sk, tls_ctx)) {
20822069 rec = list_first_entry(&ctx->tx_list,
20832070 struct tls_rec, list);
20842071 list_del(&rec->list);
net/wireless/nl80211.c+12−6
@@ -13614,7 +13614,8 @@ static const struct genl_ops nl80211_ops[] = { · 13613 unmodified lines
1361413614 .doit = nl80211_associate,
1361513615 .flags = GENL_UNS_ADMIN_PERM,
1361613616 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
13617− NL80211_FLAG_NEED_RTNL,
13617+ NL80211_FLAG_NEED_RTNL |
13618+ NL80211_FLAG_CLEAR_SKB,
1361813619 },
1361913620 {
1362013621 .cmd = NL80211_CMD_DEAUTHENTICATE,
@@ -13659,14 +13660,16 @@ static const struct genl_ops nl80211_ops[] = { · 38 unmodified lines
1365913660 .doit = nl80211_connect,
1366013661 .flags = GENL_UNS_ADMIN_PERM,
1366113662 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
13662− NL80211_FLAG_NEED_RTNL,
13663+ NL80211_FLAG_NEED_RTNL |
13664+ NL80211_FLAG_CLEAR_SKB,
1366313665 },
1366413666 {
1366513667 .cmd = NL80211_CMD_UPDATE_CONNECT_PARAMS,
1366613668 .doit = nl80211_update_connect_params,
1366713669 .flags = GENL_ADMIN_PERM,
1366813670 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
13669− NL80211_FLAG_NEED_RTNL,
13671+ NL80211_FLAG_NEED_RTNL |
13672+ NL80211_FLAG_CLEAR_SKB,
1367013673 },
1367113674 {
1367213675 .cmd = NL80211_CMD_DISCONNECT,
@@ -13691,7 +13694,8 @@ static const struct genl_ops nl80211_ops[] = { · 18 unmodified lines
1369113694 .doit = nl80211_setdel_pmksa,
1369213695 .flags = GENL_UNS_ADMIN_PERM,
1369313696 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
13694− NL80211_FLAG_NEED_RTNL,
13697+ NL80211_FLAG_NEED_RTNL |
13698+ NL80211_FLAG_CLEAR_SKB,
1369513699 },
1369613700 {
1369713701 .cmd = NL80211_CMD_DEL_PMKSA,
@@ -13999,7 +14003,8 @@ static const struct genl_ops nl80211_ops[] = { · 301 unmodified lines
1399914003 .dumpit = nl80211_vendor_cmd_dump,
1400014004 .flags = GENL_UNS_ADMIN_PERM,
1400114005 .internal_flags = NL80211_FLAG_NEED_WIPHY |
14002− NL80211_FLAG_NEED_RTNL,
14006+ NL80211_FLAG_NEED_RTNL |
14007+ NL80211_FLAG_CLEAR_SKB,
1400314008 },
1400414009 {
1400514010 .cmd = NL80211_CMD_SET_QOS_MAP,
@@ -14047,7 +14052,8 @@ static const struct genl_ops nl80211_ops[] = { · 41 unmodified lines
1404714052 .cmd = NL80211_CMD_SET_PMK,
1404814053 .doit = nl80211_set_pmk,
1404914054 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
14050− NL80211_FLAG_NEED_RTNL,
14055+ NL80211_FLAG_NEED_RTNL |
14056+ NL80211_FLAG_CLEAR_SKB,
1405114057 },
1405214058 {
1405314059 .cmd = NL80211_CMD_DEL_PMK,
net/wireless/reg.c+39−0
@@ -1309,6 +1309,16 @@ reg_intersect_dfs_region(const enum nl80211_dfs_regions dfs_region1, · 1308 unmodified lines
13091309 return dfs_region1;
13101310 }
13111311
1312+static void reg_wmm_rules_intersect(const struct ieee80211_wmm_ac *wmm_ac1,
1313+ const struct ieee80211_wmm_ac *wmm_ac2,
1314+ struct ieee80211_wmm_ac *intersect)
1315+{
1316+ intersect->cw_min = max_t(u16, wmm_ac1->cw_min, wmm_ac2->cw_min);
1317+ intersect->cw_max = max_t(u16, wmm_ac1->cw_max, wmm_ac2->cw_max);
1318+ intersect->cot = min_t(u16, wmm_ac1->cot, wmm_ac2->cot);
1319+ intersect->aifsn = max_t(u8, wmm_ac1->aifsn, wmm_ac2->aifsn);
1320+}
1321+
13121322 /*
13131323 * Helper for regdom_intersect(), this does the real
13141324 * mathematical intersection fun
@@ -1323,6 +1333,8 @@ static int reg_rules_intersect(const struct ieee80211_regdomain *rd1, · 8 unmodified lines
13231333 struct ieee80211_freq_range *freq_range;
13241334 const struct ieee80211_power_rule *power_rule1, *power_rule2;
13251335 struct ieee80211_power_rule *power_rule;
1336+ const struct ieee80211_wmm_rule *wmm_rule1, *wmm_rule2;
1337+ struct ieee80211_wmm_rule *wmm_rule;
13261338 u32 freq_diff, max_bandwidth1, max_bandwidth2;
13271339
13281340 freq_range1 = &rule1->freq_range;
@@ -1333,6 +1345,10 @@ static int reg_rules_intersect(const struct ieee80211_regdomain *rd1, · 4 unmodified lines
13331345 power_rule2 = &rule2->power_rule;
13341346 power_rule = &intersected_rule->power_rule;
13351347
1348+ wmm_rule1 = &rule1->wmm_rule;
1349+ wmm_rule2 = &rule2->wmm_rule;
1350+ wmm_rule = &intersected_rule->wmm_rule;
1351+
13361352 freq_range->start_freq_khz = max(freq_range1->start_freq_khz,
13371353 freq_range2->start_freq_khz);
13381354 freq_range->end_freq_khz = min(freq_range1->end_freq_khz,
@@ -1376,6 +1392,29 @@ static int reg_rules_intersect(const struct ieee80211_regdomain *rd1, · 37 unmodified lines
13761392 intersected_rule->dfs_cac_ms = max(rule1->dfs_cac_ms,
13771393 rule2->dfs_cac_ms);
13781394
1395+ if (rule1->has_wmm && rule2->has_wmm) {
1396+ u8 ac;
1397+
1398+ for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
1399+ reg_wmm_rules_intersect(&wmm_rule1->client[ac],
1400+ &wmm_rule2->client[ac],
1401+ &wmm_rule->client[ac]);
1402+ reg_wmm_rules_intersect(&wmm_rule1->ap[ac],
1403+ &wmm_rule2->ap[ac],
1404+ &wmm_rule->ap[ac]);
1405+ }
1406+
1407+ intersected_rule->has_wmm = true;
1408+ } else if (rule1->has_wmm) {
1409+ *wmm_rule = *wmm_rule1;
1410+ intersected_rule->has_wmm = true;
1411+ } else if (rule2->has_wmm) {
1412+ *wmm_rule = *wmm_rule2;
1413+ intersected_rule->has_wmm = true;
1414+ } else {
1415+ intersected_rule->has_wmm = false;
1416+ }
1417+
13791418 if (!is_valid_reg_rule(intersected_rule))
13801419 return -EINVAL;
13811420
net/wireless/scan.c+1−2
@@ -190,10 +190,9 @@ static size_t cfg80211_gen_new_ie(const u8 *ie, size_t ielen, · 189 unmodified lines
190190 /* copy subelement as we need to change its content to
191191 * mark an ie after it is processed.
192192 */
193− sub_copy = kmalloc(subie_len, gfp);
193+ sub_copy = kmemdup(subelement, subie_len, gfp);
194194 if (!sub_copy)
195195 return 0;
196− memcpy(sub_copy, subelement, subie_len);
197196
198197 pos = &new_ie[0];
199198
net/wireless/util.c+4−2
@@ -1220,9 +1220,11 @@ static u32 cfg80211_calculate_bitrate_he(struct rate_info *rate) · 1219 unmodified lines
12201220 else if (rate->bw == RATE_INFO_BW_HE_RU &&
12211221 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_26)
12221222 result = rates_26[rate->he_gi];
1223− else if (WARN(1, "invalid HE MCS: bw:%d, ru:%d\n",
1224− rate->bw, rate->he_ru_alloc))
1223+ else {
1224+ WARN(1, "invalid HE MCS: bw:%d, ru:%d\n",
1225+ rate->bw, rate->he_ru_alloc);
12251226 return 0;
1227+ }
12261228
12271229 /* now scale to the appropriate MCS */
12281230 tmp = result;
security/apparmor/lsm.c+48−1
@@ -1336,9 +1336,16 @@ module_param_named(path_max, aa_g_path_max, aauint, S_IRUSR); · 1335 unmodified lines
13361336 bool aa_g_paranoid_load = true;
13371337 module_param_named(paranoid_load, aa_g_paranoid_load, aabool, S_IRUGO);
13381338
1339+static int param_get_aaintbool(char *buffer, const struct kernel_param *kp);
1340+static int param_set_aaintbool(const char *val, const struct kernel_param *kp);
1341+#define param_check_aaintbool param_check_int
1342+static const struct kernel_param_ops param_ops_aaintbool = {
1343+ .set = param_set_aaintbool,
1344+ .get = param_get_aaintbool
1345+};
13391346 /* Boot time disable flag */
13401347 static int apparmor_enabled __lsm_ro_after_init = 1;
1341−module_param_named(enabled, apparmor_enabled, int, 0444);
1348+module_param_named(enabled, apparmor_enabled, aaintbool, 0444);
13421349
13431350 static int __init apparmor_enabled_setup(char *str)
13441351 {
@@ -1413,6 +1420,46 @@ static int param_get_aauint(char *buffer, const struct kernel_param *kp) · 68 unmodified lines
14131420 return param_get_uint(buffer, kp);
14141421 }
14151422
1423+/* Can only be set before AppArmor is initialized (i.e. on boot cmdline). */
1424+static int param_set_aaintbool(const char *val, const struct kernel_param *kp)
1425+{
1426+ struct kernel_param kp_local;
1427+ bool value;
1428+ int error;
1429+
1430+ if (apparmor_initialized)
1431+ return -EPERM;
1432+
1433+ /* Create local copy, with arg pointing to bool type. */
1434+ value = !!*((int *)kp->arg);
1435+ memcpy(&kp_local, kp, sizeof(kp_local));
1436+ kp_local.arg = &value;
1437+
1438+ error = param_set_bool(val, &kp_local);
1439+ if (!error)
1440+ *((int *)kp->arg) = *((bool *)kp_local.arg);
1441+ return error;
1442+}
1443+
1444+/*
1445+ * To avoid changing /sys/module/apparmor/parameters/enabled from Y/N to
1446+ * 1/0, this converts the "int that is actually bool" back to bool for
1447+ * display in the /sys filesystem, while keeping it "int" for the LSM
1448+ * infrastructure.
1449+ */
1450+static int param_get_aaintbool(char *buffer, const struct kernel_param *kp)
1451+{
1452+ struct kernel_param kp_local;
1453+ bool value;
1454+
1455+ /* Create local copy, with arg pointing to bool type. */
1456+ value = !!*((int *)kp->arg);
1457+ memcpy(&kp_local, kp, sizeof(kp_local));
1458+ kp_local.arg = &value;
1459+
1460+ return param_get_bool(buffer, &kp_local);
1461+}
1462+
14161463 static int param_get_audit(char *buffer, const struct kernel_param *kp)
14171464 {
14181465 if (!apparmor_enabled)
sound/core/seq/seq_clientmgr.c+3−3
@@ -1252,7 +1252,7 @@ static int snd_seq_ioctl_set_client_info(struct snd_seq_client *client, · 1251 unmodified lines
12521252
12531253 /* fill the info fields */
12541254 if (client_info->name[0])
1255− strlcpy(client->name, client_info->name, sizeof(client->name));
1255+ strscpy(client->name, client_info->name, sizeof(client->name));
12561256
12571257 client->filter = client_info->filter;
12581258 client->event_lost = client_info->event_lost;
@@ -1530,7 +1530,7 @@ static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) · 271 unmodified lines
15301530 /* set queue name */
15311531 if (!info->name[0])
15321532 snprintf(info->name, sizeof(info->name), "Queue-%d", q->queue);
1533− strlcpy(q->name, info->name, sizeof(q->name));
1533+ strscpy(q->name, info->name, sizeof(q->name));
15341534 snd_use_lock_free(&q->use_lock);
15351535
15361536 return 0;
@@ -1592,7 +1592,7 @@ static int snd_seq_ioctl_set_queue_info(struct snd_seq_client *client, · 55 unmodified lines
15921592 queuefree(q);
15931593 return -EPERM;
15941594 }
1595− strlcpy(q->name, info->name, sizeof(q->name));
1595+ strscpy(q->name, info->name, sizeof(q->name));
15961596 queuefree(q);
15971597
15981598 return 0;
sound/hda/ext/hdac_ext_bus.c+0−1
@@ -107,7 +107,6 @@ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, · 106 unmodified lines
107107 INIT_LIST_HEAD(&bus->hlink_list);
108108 bus->idx = idx++;
109109
110− mutex_init(&bus->lock);
111110 bus->cmd_dma_state = true;
112111
113112 return 0;
sound/hda/hdac_bus.c+1−0
@@ -38,6 +38,7 @@ int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, · 37 unmodified lines
3838 INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events);
3939 spin_lock_init(&bus->reg_lock);
4040 mutex_init(&bus->cmd_mutex);
41+ mutex_init(&bus->lock);
4142 bus->irq = -1;
4243 return 0;
4344 }
sound/hda/hdac_component.c+5−1
@@ -69,13 +69,15 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable) · 68 unmodified lines
6969
7070 dev_dbg(bus->dev, "display power %s\n",
7171 enable ? "enable" : "disable");
72+
73+ mutex_lock(&bus->lock);
7274 if (enable)
7375 set_bit(idx, &bus->display_power_status);
7476 else
7577 clear_bit(idx, &bus->display_power_status);
7678
7779 if (!acomp || !acomp->ops)
78− return;
80+ goto unlock;
7981
8082 if (bus->display_power_status) {
8183 if (!bus->display_power_active) {
@@ -92,6 +94,8 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable) · 10 unmodified lines
9294 bus->display_power_active = false;
9395 }
9496 }
97+ unlock:
98+ mutex_unlock(&bus->lock);
9599 }
96100 EXPORT_SYMBOL_GPL(snd_hdac_display_power);
97101
sound/pci/hda/hda_intel.c+4−0
@@ -2142,6 +2142,8 @@ static struct snd_pci_quirk power_save_blacklist[] = { · 2141 unmodified lines
21422142 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
21432143 /* https://bugzilla.kernel.org/show_bug.cgi?id=199607 */
21442144 SND_PCI_QUIRK(0x8086, 0x2057, "Intel NUC5i7RYB", 0),
2145+ /* https://bugs.launchpad.net/bugs/1821663 */
2146+ SND_PCI_QUIRK(0x8086, 0x2064, "Intel SDP 8086:2064", 0),
21452147 /* https://bugzilla.redhat.com/show_bug.cgi?id=1520902 */
21462148 SND_PCI_QUIRK(0x8086, 0x2068, "Intel NUC7i3BNB", 0),
21472149 /* https://bugzilla.kernel.org/show_bug.cgi?id=198611 */
@@ -2150,6 +2152,8 @@ static struct snd_pci_quirk power_save_blacklist[] = { · 2 unmodified lines
21502152 SND_PCI_QUIRK(0x17aa, 0x367b, "Lenovo IdeaCentre B550", 0),
21512153 /* https://bugzilla.redhat.com/show_bug.cgi?id=1572975 */
21522154 SND_PCI_QUIRK(0x17aa, 0x36a7, "Lenovo C50 All in one", 0),
2155+ /* https://bugs.launchpad.net/bugs/1821663 */
2156+ SND_PCI_QUIRK(0x1631, 0xe017, "Packard Bell NEC IMEDIA 5204", 0),
21532157 {}
21542158 };
21552159 #endif /* CONFIG_PM */
sound/pci/hda/patch_realtek.c+51−21
@@ -1864,8 +1864,8 @@ enum { · 1863 unmodified lines
18641864 ALC887_FIXUP_BASS_CHMAP,
18651865 ALC1220_FIXUP_GB_DUAL_CODECS,
18661866 ALC1220_FIXUP_CLEVO_P950,
1867− ALC1220_FIXUP_SYSTEM76_ORYP5,
1868− ALC1220_FIXUP_SYSTEM76_ORYP5_PINS,
1867+ ALC1220_FIXUP_CLEVO_PB51ED,
1868+ ALC1220_FIXUP_CLEVO_PB51ED_PINS,
18691869 };
18701870
18711871 static void alc889_fixup_coef(struct hda_codec *codec,
@@ -2070,7 +2070,7 @@ static void alc1220_fixup_clevo_p950(struct hda_codec *codec, · 198 unmodified lines
20702070 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
20712071 const struct hda_fixup *fix, int action);
20722072
2073−static void alc1220_fixup_system76_oryp5(struct hda_codec *codec,
2073+static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
20742074 const struct hda_fixup *fix,
20752075 int action)
20762076 {
@@ -2322,18 +2322,18 @@ static const struct hda_fixup alc882_fixups[] = { · 245 unmodified lines
23222322 .type = HDA_FIXUP_FUNC,
23232323 .v.func = alc1220_fixup_clevo_p950,
23242324 },
2325− [ALC1220_FIXUP_SYSTEM76_ORYP5] = {
2325+ [ALC1220_FIXUP_CLEVO_PB51ED] = {
23262326 .type = HDA_FIXUP_FUNC,
2327− .v.func = alc1220_fixup_system76_oryp5,
2327+ .v.func = alc1220_fixup_clevo_pb51ed,
23282328 },
2329− [ALC1220_FIXUP_SYSTEM76_ORYP5_PINS] = {
2329+ [ALC1220_FIXUP_CLEVO_PB51ED_PINS] = {
23302330 .type = HDA_FIXUP_PINS,
23312331 .v.pins = (const struct hda_pintbl[]) {
23322332 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
23332333 {}
23342334 },
23352335 .chained = true,
2336− .chain_id = ALC1220_FIXUP_SYSTEM76_ORYP5,
2336+ .chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
23372337 },
23382338 };
23392339
@@ -2411,8 +2411,9 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { · 71 unmodified lines
24112411 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
24122412 SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
24132413 SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2414− SND_PCI_QUIRK(0x1558, 0x96e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_SYSTEM76_ORYP5_PINS),
2415− SND_PCI_QUIRK(0x1558, 0x97e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_SYSTEM76_ORYP5_PINS),
2414+ SND_PCI_QUIRK(0x1558, 0x96e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2415+ SND_PCI_QUIRK(0x1558, 0x97e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2416+ SND_PCI_QUIRK(0x1558, 0x65d1, "Tuxedo Book XC1509", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
24162417 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
24172418 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
24182419 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
@@ -5491,7 +5492,7 @@ static void alc_headset_btn_callback(struct hda_codec *codec, · 3072 unmodified lines
54915492 jack->jack->button_state = report;
54925493 }
54935494
5494−static void alc295_fixup_chromebook(struct hda_codec *codec,
5495+static void alc_fixup_headset_jack(struct hda_codec *codec,
54955496 const struct hda_fixup *fix, int action)
54965497 {
54975498
@@ -5501,16 +5502,6 @@ static void alc295_fixup_chromebook(struct hda_codec *codec, · 3 unmodified lines
55015502 alc_headset_btn_callback);
55025503 snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack", false,
55035504 SND_JACK_HEADSET, alc_headset_btn_keymap);
5504− switch (codec->core.vendor_id) {
5505− case 0x10ec0295:
5506− alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
5507− alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
5508− break;
5509− case 0x10ec0236:
5510− alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
5511− alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
5512− break;
5513− }
55145505 break;
55155506 case HDA_FIXUP_ACT_INIT:
55165507 switch (codec->core.vendor_id) {
@@ -5531,6 +5522,25 @@ static void alc295_fixup_chromebook(struct hda_codec *codec, · 14 unmodified lines
55315522 }
55325523 }
55335524
5525+static void alc295_fixup_chromebook(struct hda_codec *codec,
5526+ const struct hda_fixup *fix, int action)
5527+{
5528+ switch (action) {
5529+ case HDA_FIXUP_ACT_INIT:
5530+ switch (codec->core.vendor_id) {
5531+ case 0x10ec0295:
5532+ alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
5533+ alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
5534+ break;
5535+ case 0x10ec0236:
5536+ alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
5537+ alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
5538+ break;
5539+ }
5540+ break;
5541+ }
5542+}
5543+
55345544 static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
55355545 const struct hda_fixup *fix, int action)
55365546 {
@@ -5663,6 +5673,7 @@ enum { · 126 unmodified lines
56635673 ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
56645674 ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
56655675 ALC233_FIXUP_LENOVO_MULTI_CODECS,
5676+ ALC233_FIXUP_ACER_HEADSET_MIC,
56665677 ALC294_FIXUP_LENOVO_MIC_LOCATION,
56675678 ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
56685679 ALC700_FIXUP_INTEL_REFERENCE,
@@ -5684,6 +5695,7 @@ enum { · 15 unmodified lines
56845695 ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
56855696 ALC255_FIXUP_ACER_HEADSET_MIC,
56865697 ALC295_FIXUP_CHROME_BOOK,
5698+ ALC225_FIXUP_HEADSET_JACK,
56875699 ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
56885700 ALC225_FIXUP_WYSE_AUTO_MUTE,
56895701 ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
@@ -6490,6 +6502,16 @@ static const struct hda_fixup alc269_fixups[] = { · 800 unmodified lines
64906502 .type = HDA_FIXUP_FUNC,
64916503 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
64926504 },
6505+ [ALC233_FIXUP_ACER_HEADSET_MIC] = {
6506+ .type = HDA_FIXUP_VERBS,
6507+ .v.verbs = (const struct hda_verb[]) {
6508+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
6509+ { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
6510+ { }
6511+ },
6512+ .chained = true,
6513+ .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
6514+ },
64936515 [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
64946516 .type = HDA_FIXUP_PINS,
64956517 .v.pins = (const struct hda_pintbl[]) {
@@ -6635,6 +6657,12 @@ static const struct hda_fixup alc269_fixups[] = { · 139 unmodified lines
66356657 [ALC295_FIXUP_CHROME_BOOK] = {
66366658 .type = HDA_FIXUP_FUNC,
66376659 .v.func = alc295_fixup_chromebook,
6660+ .chained = true,
6661+ .chain_id = ALC225_FIXUP_HEADSET_JACK
6662+ },
6663+ [ALC225_FIXUP_HEADSET_JACK] = {
6664+ .type = HDA_FIXUP_FUNC,
6665+ .v.func = alc_fixup_headset_jack,
66386666 },
66396667 [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
66406668 .type = HDA_FIXUP_PINS,
@@ -6737,6 +6765,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 96 unmodified lines
67376765 SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
67386766 SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
67396767 SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
6768+ SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
67406769 SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
67416770 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
67426771 SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
@@ -7132,7 +7161,8 @@ static const struct hda_model_fixup alc269_fixup_models[] = { · 389 unmodified lines
71327161 {.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
71337162 {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
71347163 {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
7135− {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-sense-combo"},
7164+ {.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-headset-jack"},
7165+ {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-chrome-book"},
71367166 {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
71377167 {}
71387168 };
sound/soc/codecs/Kconfig+1−0
@@ -1151,6 +1151,7 @@ config SND_SOC_WCD9335 · 1150 unmodified lines
11511151 tristate "WCD9335 Codec"
11521152 depends on SLIMBUS
11531153 select REGMAP_SLIMBUS
1154+ select REGMAP_IRQ
11541155 help
11551156 The WCD9335 is a standalone Hi-Fi audio CODEC IC, supports
11561157 Qualcomm Technologies, Inc. (QTI) multimedia solutions,
sound/soc/codecs/ab8500-codec.c+1−0
@@ -2129,6 +2129,7 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) · 2128 unmodified lines
21292129 dev_err(dai->component->dev,
21302130 "%s: ERROR: The device is either a master or a slave.\n",
21312131 __func__);
2132+ /* fall through */
21322133 default:
21332134 dev_err(dai->component->dev,
21342135 "%s: ERROR: Unsupporter master mask 0x%x\n",
sound/soc/codecs/cs35l35.c+11−0
@@ -1635,6 +1635,16 @@ err: · 1634 unmodified lines
16351635 return ret;
16361636 }
16371637
1638+static int cs35l35_i2c_remove(struct i2c_client *i2c_client)
1639+{
1640+ struct cs35l35_private *cs35l35 = i2c_get_clientdata(i2c_client);
1641+
1642+ regulator_bulk_disable(cs35l35->num_supplies, cs35l35->supplies);
1643+ gpiod_set_value_cansleep(cs35l35->reset_gpio, 0);
1644+
1645+ return 0;
1646+}
1647+
16381648 static const struct of_device_id cs35l35_of_match[] = {
16391649 {.compatible = "cirrus,cs35l35"},
16401650 {},
@@ -1655,6 +1665,7 @@ static struct i2c_driver cs35l35_i2c_driver = { · 14 unmodified lines
16551665 },
16561666 .id_table = cs35l35_id,
16571667 .probe = cs35l35_i2c_probe,
1668+ .remove = cs35l35_i2c_remove,
16581669 };
16591670
16601671 module_i2c_driver(cs35l35_i2c_driver);
sound/soc/codecs/cs4270.c+1−0
@@ -642,6 +642,7 @@ static const struct regmap_config cs4270_regmap = { · 641 unmodified lines
642642 .reg_defaults = cs4270_reg_defaults,
643643 .num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults),
644644 .cache_type = REGCACHE_RBTREE,
645+ .write_flag_mask = CS4270_I2C_INCR,
645646
646647 .readable_reg = cs4270_reg_is_readable,
647648 .volatile_reg = cs4270_reg_is_volatile,
sound/soc/codecs/hdac_hda.c+39−14
@@ -38,6 +38,9 @@ static void hdac_hda_dai_close(struct snd_pcm_substream *substream, · 37 unmodified lines
3838 struct snd_soc_dai *dai);
3939 static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
4040 struct snd_soc_dai *dai);
41+static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
42+ struct snd_pcm_hw_params *params,
43+ struct snd_soc_dai *dai);
4144 static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
4245 struct snd_soc_dai *dai);
4346 static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
@@ -50,6 +53,7 @@ static const struct snd_soc_dai_ops hdac_hda_dai_ops = { · 6 unmodified lines
5053 .startup = hdac_hda_dai_open,
5154 .shutdown = hdac_hda_dai_close,
5255 .prepare = hdac_hda_dai_prepare,
56+ .hw_params = hdac_hda_dai_hw_params,
5357 .hw_free = hdac_hda_dai_hw_free,
5458 .set_tdm_slot = hdac_hda_dai_set_tdm_slot,
5559 };
@@ -139,6 +143,39 @@ static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai, · 83 unmodified lines
139143 return 0;
140144 }
141145
146+static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
147+ struct snd_pcm_hw_params *params,
148+ struct snd_soc_dai *dai)
149+{
150+ struct snd_soc_component *component = dai->component;
151+ struct hdac_hda_priv *hda_pvt;
152+ unsigned int format_val;
153+ unsigned int maxbps;
154+
155+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
156+ maxbps = dai->driver->playback.sig_bits;
157+ else
158+ maxbps = dai->driver->capture.sig_bits;
159+
160+ hda_pvt = snd_soc_component_get_drvdata(component);
161+ format_val = snd_hdac_calc_stream_format(params_rate(params),
162+ params_channels(params),
163+ params_format(params),
164+ maxbps,
165+ 0);
166+ if (!format_val) {
167+ dev_err(dai->dev,
168+ "invalid format_val, rate=%d, ch=%d, format=%d, maxbps=%d\n",
169+ params_rate(params), params_channels(params),
170+ params_format(params), maxbps);
171+
172+ return -EINVAL;
173+ }
174+
175+ hda_pvt->pcm[dai->id].format_val[substream->stream] = format_val;
176+ return 0;
177+}
178+
142179 static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
143180 struct snd_soc_dai *dai)
144181 {
@@ -162,10 +199,9 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream, · 17 unmodified lines
162199 struct snd_soc_dai *dai)
163200 {
164201 struct snd_soc_component *component = dai->component;
202+ struct hda_pcm_stream *hda_stream;
165203 struct hdac_hda_priv *hda_pvt;
166− struct snd_pcm_runtime *runtime = substream->runtime;
167204 struct hdac_device *hdev;
168− struct hda_pcm_stream *hda_stream;
169205 unsigned int format_val;
170206 struct hda_pcm *pcm;
171207 unsigned int stream;
@@ -179,19 +215,8 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream, · 7 unmodified lines
179215
180216 hda_stream = &pcm->stream[substream->stream];
181217
182− format_val = snd_hdac_calc_stream_format(runtime->rate,
183− runtime->channels,
184− runtime->format,
185− hda_stream->maxbps,
186− 0);
187− if (!format_val) {
188− dev_err(&hdev->dev,
189− "invalid format_val, rate=%d, ch=%d, format=%d\n",
190− runtime->rate, runtime->channels, runtime->format);
191− return -EINVAL;
192− }
193−
194218 stream = hda_pvt->pcm[dai->id].stream_tag[substream->stream];
219+ format_val = hda_pvt->pcm[dai->id].format_val[substream->stream];
195220
196221 ret = snd_hda_codec_prepare(&hda_pvt->codec, hda_stream,
197222 stream, format_val, substream);
sound/soc/codecs/hdac_hda.h+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88
99 struct hdac_hda_pcm {
1010 int stream_tag[2];
11+ unsigned int format_val[2];
1112 };
1213
1314 struct hdac_hda_priv {
sound/soc/codecs/hdmi-codec.c+59−62
@@ -484,9 +484,6 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, · 483 unmodified lines
484484 params_width(params), params_rate(params),
485485 params_channels(params));
486486
487− if (params_width(params) > 24)
488− params->msbits = 24;
489−
490487 ret = snd_pcm_create_iec958_consumer_hw_params(params, hp.iec.status,
491488 sizeof(hp.iec.status));
492489 if (ret < 0) {
@@ -529,73 +526,71 @@ static int hdmi_codec_set_fmt(struct snd_soc_dai *dai, · 36 unmodified lines
529526 {
530527 struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
531528 struct hdmi_codec_daifmt cf = { 0 };
532− int ret = 0;
533529
534530 dev_dbg(dai->dev, "%s()\n", __func__);
535531
536− if (dai->id == DAI_ID_SPDIF) {
537− cf.fmt = HDMI_SPDIF;
538− } else {
539− switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
540− case SND_SOC_DAIFMT_CBM_CFM:
541− cf.bit_clk_master = 1;
542− cf.frame_clk_master = 1;
543− break;
544− case SND_SOC_DAIFMT_CBS_CFM:
545− cf.frame_clk_master = 1;
546− break;
547− case SND_SOC_DAIFMT_CBM_CFS:
548− cf.bit_clk_master = 1;
549− break;
550− case SND_SOC_DAIFMT_CBS_CFS:
551− break;
552− default:
553− return -EINVAL;
554− }
532+ if (dai->id == DAI_ID_SPDIF)
533+ return 0;
534+
535+ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
536+ case SND_SOC_DAIFMT_CBM_CFM:
537+ cf.bit_clk_master = 1;
538+ cf.frame_clk_master = 1;
539+ break;
540+ case SND_SOC_DAIFMT_CBS_CFM:
541+ cf.frame_clk_master = 1;
542+ break;
543+ case SND_SOC_DAIFMT_CBM_CFS:
544+ cf.bit_clk_master = 1;
545+ break;
546+ case SND_SOC_DAIFMT_CBS_CFS:
547+ break;
548+ default:
549+ return -EINVAL;
550+ }
555551
556− switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
557− case SND_SOC_DAIFMT_NB_NF:
558− break;
559− case SND_SOC_DAIFMT_NB_IF:
560− cf.frame_clk_inv = 1;
561− break;
562− case SND_SOC_DAIFMT_IB_NF:
563− cf.bit_clk_inv = 1;
564− break;
565− case SND_SOC_DAIFMT_IB_IF:
566− cf.frame_clk_inv = 1;
567− cf.bit_clk_inv = 1;
568− break;
569− }
552+ switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
553+ case SND_SOC_DAIFMT_NB_NF:
554+ break;
555+ case SND_SOC_DAIFMT_NB_IF:
556+ cf.frame_clk_inv = 1;
557+ break;
558+ case SND_SOC_DAIFMT_IB_NF:
559+ cf.bit_clk_inv = 1;
560+ break;
561+ case SND_SOC_DAIFMT_IB_IF:
562+ cf.frame_clk_inv = 1;
563+ cf.bit_clk_inv = 1;
564+ break;
565+ }
570566
571− switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
572− case SND_SOC_DAIFMT_I2S:
573− cf.fmt = HDMI_I2S;
574− break;
575− case SND_SOC_DAIFMT_DSP_A:
576− cf.fmt = HDMI_DSP_A;
577− break;
578− case SND_SOC_DAIFMT_DSP_B:
579− cf.fmt = HDMI_DSP_B;
580− break;
581− case SND_SOC_DAIFMT_RIGHT_J:
582− cf.fmt = HDMI_RIGHT_J;
583− break;
584− case SND_SOC_DAIFMT_LEFT_J:
585− cf.fmt = HDMI_LEFT_J;
586− break;
587− case SND_SOC_DAIFMT_AC97:
588− cf.fmt = HDMI_AC97;
589− break;
590− default:
591− dev_err(dai->dev, "Invalid DAI interface format\n");
592− return -EINVAL;
593− }
567+ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
568+ case SND_SOC_DAIFMT_I2S:
569+ cf.fmt = HDMI_I2S;
570+ break;
571+ case SND_SOC_DAIFMT_DSP_A:
572+ cf.fmt = HDMI_DSP_A;
573+ break;
574+ case SND_SOC_DAIFMT_DSP_B:
575+ cf.fmt = HDMI_DSP_B;
576+ break;
577+ case SND_SOC_DAIFMT_RIGHT_J:
578+ cf.fmt = HDMI_RIGHT_J;
579+ break;
580+ case SND_SOC_DAIFMT_LEFT_J:
581+ cf.fmt = HDMI_LEFT_J;
582+ break;
583+ case SND_SOC_DAIFMT_AC97:
584+ cf.fmt = HDMI_AC97;
585+ break;
586+ default:
587+ dev_err(dai->dev, "Invalid DAI interface format\n");
588+ return -EINVAL;
594589 }
595590
596591 hcp->daifmt[dai->id] = cf;
597592
598− return ret;
593+ return 0;
599594 }
600595
601596 static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute)
@@ -792,8 +787,10 @@ static int hdmi_codec_probe(struct platform_device *pdev) · 190 unmodified lines
792787 i++;
793788 }
794789
795− if (hcd->spdif)
790+ if (hcd->spdif) {
796791 hcp->daidrv[i] = hdmi_spdif_dai;
792+ hcp->daifmt[DAI_ID_SPDIF].fmt = HDMI_SPDIF;
793+ }
797794
798795 dev_set_drvdata(dev, hcp);
799796
sound/soc/codecs/nau8810.c+2−2
@@ -411,9 +411,9 @@ static const struct snd_soc_dapm_widget nau8810_dapm_widgets[] = { · 410 unmodified lines
411411 SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3,
412412 NAU8810_MOUTMX_EN_SFT, 0, &nau8810_mono_mixer_controls[0],
413413 ARRAY_SIZE(nau8810_mono_mixer_controls)),
414− SND_SOC_DAPM_DAC("DAC", "HiFi Playback", NAU8810_REG_POWER3,
414+ SND_SOC_DAPM_DAC("DAC", "Playback", NAU8810_REG_POWER3,
415415 NAU8810_DAC_EN_SFT, 0),
416− SND_SOC_DAPM_ADC("ADC", "HiFi Capture", NAU8810_REG_POWER2,
416+ SND_SOC_DAPM_ADC("ADC", "Capture", NAU8810_REG_POWER2,
417417 NAU8810_ADC_EN_SFT, 0),
418418 SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3,
419419 NAU8810_NSPK_EN_SFT, 0, NULL, 0),
sound/soc/codecs/nau8824.c+38−8
@@ -681,8 +681,8 @@ static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = { · 680 unmodified lines
681681 SND_SOC_DAPM_ADC("ADCR", NULL, NAU8824_REG_ANALOG_ADC_2,
682682 NAU8824_ADCR_EN_SFT, 0),
683683
684− SND_SOC_DAPM_AIF_OUT("AIFTX", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
685− SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
684+ SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, SND_SOC_NOPM, 0, 0),
685+ SND_SOC_DAPM_AIF_IN("AIFRX", "Playback", 0, SND_SOC_NOPM, 0, 0),
686686
687687 SND_SOC_DAPM_DAC("DACL", NULL, NAU8824_REG_RDAC,
688688 NAU8824_DACL_EN_SFT, 0),
@@ -831,6 +831,36 @@ static void nau8824_int_status_clear_all(struct regmap *regmap) · 142 unmodified lines
831831 }
832832 }
833833
834+static void nau8824_dapm_disable_pin(struct nau8824 *nau8824, const char *pin)
835+{
836+ struct snd_soc_dapm_context *dapm = nau8824->dapm;
837+ const char *prefix = dapm->component->name_prefix;
838+ char prefixed_pin[80];
839+
840+ if (prefix) {
841+ snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
842+ prefix, pin);
843+ snd_soc_dapm_disable_pin(dapm, prefixed_pin);
844+ } else {
845+ snd_soc_dapm_disable_pin(dapm, pin);
846+ }
847+}
848+
849+static void nau8824_dapm_enable_pin(struct nau8824 *nau8824, const char *pin)
850+{
851+ struct snd_soc_dapm_context *dapm = nau8824->dapm;
852+ const char *prefix = dapm->component->name_prefix;
853+ char prefixed_pin[80];
854+
855+ if (prefix) {
856+ snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
857+ prefix, pin);
858+ snd_soc_dapm_force_enable_pin(dapm, prefixed_pin);
859+ } else {
860+ snd_soc_dapm_force_enable_pin(dapm, pin);
861+ }
862+}
863+
834864 static void nau8824_eject_jack(struct nau8824 *nau8824)
835865 {
836866 struct snd_soc_dapm_context *dapm = nau8824->dapm;
@@ -839,8 +869,8 @@ static void nau8824_eject_jack(struct nau8824 *nau8824) · 2 unmodified lines
839869 /* Clear all interruption status */
840870 nau8824_int_status_clear_all(regmap);
841871
842− snd_soc_dapm_disable_pin(dapm, "SAR");
843− snd_soc_dapm_disable_pin(dapm, "MICBIAS");
872+ nau8824_dapm_disable_pin(nau8824, "SAR");
873+ nau8824_dapm_disable_pin(nau8824, "MICBIAS");
844874 snd_soc_dapm_sync(dapm);
845875
846876 /* Enable the insertion interruption, disable the ejection
@@ -870,8 +900,8 @@ static void nau8824_jdet_work(struct work_struct *work) · 23 unmodified lines
870900 struct regmap *regmap = nau8824->regmap;
871901 int adc_value, event = 0, event_mask = 0;
872902
873− snd_soc_dapm_force_enable_pin(dapm, "MICBIAS");
874− snd_soc_dapm_force_enable_pin(dapm, "SAR");
903+ nau8824_dapm_enable_pin(nau8824, "MICBIAS");
904+ nau8824_dapm_enable_pin(nau8824, "SAR");
875905 snd_soc_dapm_sync(dapm);
876906
877907 msleep(100);
@@ -882,8 +912,8 @@ static void nau8824_jdet_work(struct work_struct *work) · 4 unmodified lines
882912 if (adc_value < HEADSET_SARADC_THD) {
883913 event |= SND_JACK_HEADPHONE;
884914
885− snd_soc_dapm_disable_pin(dapm, "SAR");
886− snd_soc_dapm_disable_pin(dapm, "MICBIAS");
915+ nau8824_dapm_disable_pin(nau8824, "SAR");
916+ nau8824_dapm_disable_pin(nau8824, "MICBIAS");
887917 snd_soc_dapm_sync(dapm);
888918 } else {
889919 event |= SND_JACK_HEADSET;
sound/soc/codecs/rt5682.c+25−31
@@ -910,13 +910,21 @@ static int rt5682_headset_detect(struct snd_soc_component *component, · 909 unmodified lines
910910 int jack_insert)
911911 {
912912 struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
913− struct snd_soc_dapm_context *dapm =
914− snd_soc_component_get_dapm(component);
915913 unsigned int val, count;
916914
917915 if (jack_insert) {
918− snd_soc_dapm_force_enable_pin(dapm, "CBJ Power");
919− snd_soc_dapm_sync(dapm);
916+
917+ snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
918+ RT5682_PWR_VREF2 | RT5682_PWR_MB,
919+ RT5682_PWR_VREF2 | RT5682_PWR_MB);
920+ snd_soc_component_update_bits(component,
921+ RT5682_PWR_ANLG_1, RT5682_PWR_FV2, 0);
922+ usleep_range(15000, 20000);
923+ snd_soc_component_update_bits(component,
924+ RT5682_PWR_ANLG_1, RT5682_PWR_FV2, RT5682_PWR_FV2);
925+ snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
926+ RT5682_PWR_CBJ, RT5682_PWR_CBJ);
927+
920928 snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
921929 RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_HIGH);
922930
@@ -944,8 +952,10 @@ static int rt5682_headset_detect(struct snd_soc_component *component, · 21 unmodified lines
944952 rt5682_enable_push_button_irq(component, false);
945953 snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
946954 RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW);
947− snd_soc_dapm_disable_pin(dapm, "CBJ Power");
948− snd_soc_dapm_sync(dapm);
955+ snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
956+ RT5682_PWR_VREF2 | RT5682_PWR_MB, 0);
957+ snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
958+ RT5682_PWR_CBJ, 0);
949959
950960 rt5682->jack_type = 0;
951961 }
@@ -1198,7 +1208,7 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w, · 246 unmodified lines
11981208 struct snd_soc_component *component =
11991209 snd_soc_dapm_to_component(w->dapm);
12001210 struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
1201− int ref, val, reg, sft, mask, idx = -EINVAL;
1211+ int ref, val, reg, idx = -EINVAL;
12021212 static const int div_f[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48};
12031213 static const int div_o[] = {1, 2, 4, 6, 8, 12, 16, 24, 32, 48};
12041214
@@ -1212,15 +1222,10 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w, · 7 unmodified lines
12121222
12131223 idx = rt5682_div_sel(rt5682, ref, div_f, ARRAY_SIZE(div_f));
12141224
1215− if (w->shift == RT5682_PWR_ADC_S1F_BIT) {
1225+ if (w->shift == RT5682_PWR_ADC_S1F_BIT)
12161226 reg = RT5682_PLL_TRACK_3;
1217− sft = RT5682_ADC_OSR_SFT;
1218− mask = RT5682_ADC_OSR_MASK;
1219− } else {
1227+ else
12201228 reg = RT5682_PLL_TRACK_2;
1221− sft = RT5682_DAC_OSR_SFT;
1222− mask = RT5682_DAC_OSR_MASK;
1223− }
12241229
12251230 snd_soc_component_update_bits(component, reg,
12261231 RT5682_FILTER_CLK_DIV_MASK, idx << RT5682_FILTER_CLK_DIV_SFT);
@@ -1232,7 +1237,8 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w, · 5 unmodified lines
12321237 }
12331238
12341239 snd_soc_component_update_bits(component, RT5682_ADDA_CLK_1,
1235− mask, idx << sft);
1240+ RT5682_ADC_OSR_MASK | RT5682_DAC_OSR_MASK,
1241+ (idx << RT5682_ADC_OSR_SFT) | (idx << RT5682_DAC_OSR_SFT));
12361242
12371243 return 0;
12381244 }
@@ -1591,8 +1597,6 @@ static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = { · 352 unmodified lines
15911597 0, NULL, 0),
15921598 SND_SOC_DAPM_SUPPLY("Vref1", RT5682_PWR_ANLG_1, RT5682_PWR_VREF1_BIT, 0,
15931599 rt5655_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
1594− SND_SOC_DAPM_SUPPLY("Vref2", RT5682_PWR_ANLG_1, RT5682_PWR_VREF2_BIT, 0,
1595− rt5655_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
15961600
15971601 /* ASRC */
15981602 SND_SOC_DAPM_SUPPLY_S("DAC STO1 ASRC", 1, RT5682_PLL_TRACK_1,
@@ -1627,9 +1631,6 @@ static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = { · 28 unmodified lines
16271631 SND_SOC_DAPM_PGA("BST1 CBJ", SND_SOC_NOPM,
16281632 0, 0, NULL, 0),
16291633
1630− SND_SOC_DAPM_SUPPLY("CBJ Power", RT5682_PWR_ANLG_3,
1631− RT5682_PWR_CBJ_BIT, 0, NULL, 0),
1632−
16331634 /* REC Mixer */
16341635 SND_SOC_DAPM_MIXER("RECMIX1L", SND_SOC_NOPM, 0, 0, rt5682_rec1_l_mix,
16351636 ARRAY_SIZE(rt5682_rec1_l_mix)),
@@ -1792,17 +1793,13 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = { · 156 unmodified lines
17921793
17931794 /*Vref*/
17941795 {"MICBIAS1", NULL, "Vref1"},
1795− {"MICBIAS1", NULL, "Vref2"},
17961796 {"MICBIAS2", NULL, "Vref1"},
1797− {"MICBIAS2", NULL, "Vref2"},
17981797
17991798 {"CLKDET SYS", NULL, "CLKDET"},
18001799
18011800 {"IN1P", NULL, "LDO2"},
18021801
18031802 {"BST1 CBJ", NULL, "IN1P"},
1804− {"BST1 CBJ", NULL, "CBJ Power"},
1805− {"CBJ Power", NULL, "Vref2"},
18061803
18071804 {"RECMIX1L", "CBJ Switch", "BST1 CBJ"},
18081805 {"RECMIX1L", NULL, "RECMIX1L Power"},
@@ -1912,9 +1909,7 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = { · 103 unmodified lines
19121909 {"HP Amp", NULL, "Capless"},
19131910 {"HP Amp", NULL, "Charge Pump"},
19141911 {"HP Amp", NULL, "CLKDET SYS"},
1915− {"HP Amp", NULL, "CBJ Power"},
19161912 {"HP Amp", NULL, "Vref1"},
1917− {"HP Amp", NULL, "Vref2"},
19181913 {"HPOL Playback", "Switch", "HP Amp"},
19191914 {"HPOR Playback", "Switch", "HP Amp"},
19201915 {"HPOL", NULL, "HPOL Playback"},
@@ -2303,16 +2298,13 @@ static int rt5682_set_bias_level(struct snd_soc_component *component, · 382 unmodified lines
23032298 switch (level) {
23042299 case SND_SOC_BIAS_PREPARE:
23052300 regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1,
2306− RT5682_PWR_MB | RT5682_PWR_BG,
2307− RT5682_PWR_MB | RT5682_PWR_BG);
2301+ RT5682_PWR_BG, RT5682_PWR_BG);
23082302 regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1,
23092303 RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO,
23102304 RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO);
23112305 break;
23122306
23132307 case SND_SOC_BIAS_STANDBY:
2314− regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1,
2315− RT5682_PWR_MB, RT5682_PWR_MB);
23162308 regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1,
23172309 RT5682_DIG_GATE_CTRL, RT5682_DIG_GATE_CTRL);
23182310 break;
@@ -2320,7 +2312,7 @@ static int rt5682_set_bias_level(struct snd_soc_component *component, · 1 unmodified line
23202312 regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1,
23212313 RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO, 0);
23222314 regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1,
2323− RT5682_PWR_MB | RT5682_PWR_BG, 0);
2315+ RT5682_PWR_BG, 0);
23242316 break;
23252317
23262318 default:
@@ -2363,6 +2355,8 @@ static int rt5682_resume(struct snd_soc_component *component) · 36 unmodified lines
23632355 regcache_cache_only(rt5682->regmap, false);
23642356 regcache_sync(rt5682->regmap);
23652357
2358+ rt5682_irq(0, rt5682);
2359+
23662360 return 0;
23672361 }
23682362 #else
sound/soc/codecs/tlv320aic32x4-i2c.c+2−2
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 *
44 * Copyright 2011 NW Digital Radio
55 *
6− * Author: Jeremy McDermond <nh6z@nh6z.net>
6+ * Author: Annaliese McDermond <nh6z@nh6z.net>
77 *
88 * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
99 *
@@ -72,5 +72,5 @@ static struct i2c_driver aic32x4_i2c_driver = { · 62 unmodified lines
7272 module_i2c_driver(aic32x4_i2c_driver);
7373
7474 MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver I2C");
75−MODULE_AUTHOR("Jeremy McDermond <nh6z@nh6z.net>");
75+MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>");
7676 MODULE_LICENSE("GPL");
sound/soc/codecs/tlv320aic32x4-spi.c+2−2
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 *
44 * Copyright 2011 NW Digital Radio
55 *
6− * Author: Jeremy McDermond <nh6z@nh6z.net>
6+ * Author: Annaliese McDermond <nh6z@nh6z.net>
77 *
88 * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
99 *
@@ -74,5 +74,5 @@ static struct spi_driver aic32x4_spi_driver = { · 64 unmodified lines
7474 module_spi_driver(aic32x4_spi_driver);
7575
7676 MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver SPI");
77−MODULE_AUTHOR("Jeremy McDermond <nh6z@nh6z.net>");
77+MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>");
7878 MODULE_LICENSE("GPL");
sound/soc/codecs/tlv320aic32x4.c+2−0
@@ -490,6 +490,8 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = { · 489 unmodified lines
490490 SND_SOC_DAPM_INPUT("IN2_R"),
491491 SND_SOC_DAPM_INPUT("IN3_L"),
492492 SND_SOC_DAPM_INPUT("IN3_R"),
493+ SND_SOC_DAPM_INPUT("CM_L"),
494+ SND_SOC_DAPM_INPUT("CM_R"),
493495 };
494496
495497 static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
sound/soc/codecs/tlv320aic3x.c+3−1
@@ -1609,7 +1609,6 @@ static int aic3x_probe(struct snd_soc_component *component) · 1608 unmodified lines
16091609 struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
16101610 int ret, i;
16111611
1612− INIT_LIST_HEAD(&aic3x->list);
16131612 aic3x->component = component;
16141613
16151614 for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) {
@@ -1873,6 +1872,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, · 257 unmodified lines
18731872 if (ret != 0)
18741873 goto err_gpio;
18751874
1875+ INIT_LIST_HEAD(&aic3x->list);
18761876 list_add(&aic3x->list, &reset_list);
18771877
18781878 return 0;
@@ -1889,6 +1889,8 @@ static int aic3x_i2c_remove(struct i2c_client *client) · 10 unmodified lines
18891889 {
18901890 struct aic3x_priv *aic3x = i2c_get_clientdata(client);
18911891
1892+ list_del(&aic3x->list);
1893+
18921894 if (gpio_is_valid(aic3x->gpio_reset) &&
18931895 !aic3x_is_shared_reset(aic3x)) {
18941896 gpio_set_value(aic3x->gpio_reset, 0);
sound/soc/codecs/wm_adsp.c+33−7
@@ -2905,6 +2905,8 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, · 2904 unmodified lines
29052905 if (wm_adsp_fw[dsp->fw].num_caps != 0)
29062906 wm_adsp_buffer_free(dsp);
29072907
2908+ dsp->fatal_error = false;
2909+
29082910 mutex_unlock(&dsp->pwr_lock);
29092911
29102912 adsp_dbg(dsp, "Execution stopped\n");
@@ -3000,6 +3002,9 @@ static int wm_adsp_compr_attach(struct wm_adsp_compr *compr) · 89 unmodified lines
30003002 {
30013003 struct wm_adsp_compr_buf *buf = NULL, *tmp;
30023004
3005+ if (compr->dsp->fatal_error)
3006+ return -EINVAL;
3007+
30033008 list_for_each_entry(tmp, &compr->dsp->buffer_list, list) {
30043009 if (!tmp->name || !strcmp(compr->name, tmp->name)) {
30053010 buf = tmp;
@@ -3535,11 +3540,11 @@ static int wm_adsp_buffer_get_error(struct wm_adsp_compr_buf *buf) · 529 unmodified lines
35353540
35363541 ret = wm_adsp_buffer_read(buf, HOST_BUFFER_FIELD(error), &buf->error);
35373542 if (ret < 0) {
3538− adsp_err(buf->dsp, "Failed to check buffer error: %d\n", ret);
3543+ compr_err(buf, "Failed to check buffer error: %d\n", ret);
35393544 return ret;
35403545 }
35413546 if (buf->error != 0) {
3542− adsp_err(buf->dsp, "Buffer error occurred: %d\n", buf->error);
3547+ compr_err(buf, "Buffer error occurred: %d\n", buf->error);
35433548 return -EIO;
35443549 }
35453550
@@ -3571,8 +3576,6 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd) · 25 unmodified lines
35713576 if (ret < 0)
35723577 break;
35733578
3574− wm_adsp_buffer_clear(compr->buf);
3575−
35763579 /* Trigger the IRQ at one fragment of data */
35773580 ret = wm_adsp_buffer_write(compr->buf,
35783581 HOST_BUFFER_FIELD(high_water_mark),
@@ -3584,6 +3587,8 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd) · 5 unmodified lines
35843587 }
35853588 break;
35863589 case SNDRV_PCM_TRIGGER_STOP:
3590+ if (wm_adsp_compr_attached(compr))
3591+ wm_adsp_buffer_clear(compr->buf);
35873592 break;
35883593 default:
35893594 ret = -EINVAL;
@@ -3917,22 +3922,40 @@ int wm_adsp2_lock(struct wm_adsp *dsp, unsigned int lock_regions) · 327 unmodified lines
39173922 }
39183923 EXPORT_SYMBOL_GPL(wm_adsp2_lock);
39193924
3925+static void wm_adsp_fatal_error(struct wm_adsp *dsp)
3926+{
3927+ struct wm_adsp_compr *compr;
3928+
3929+ dsp->fatal_error = true;
3930+
3931+ list_for_each_entry(compr, &dsp->compr_list, list) {
3932+ if (compr->stream) {
3933+ snd_compr_stop_error(compr->stream,
3934+ SNDRV_PCM_STATE_XRUN);
3935+ snd_compr_fragment_elapsed(compr->stream);
3936+ }
3937+ }
3938+}
3939+
39203940 irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
39213941 {
39223942 unsigned int val;
39233943 struct regmap *regmap = dsp->regmap;
39243944 int ret = 0;
39253945
3946+ mutex_lock(&dsp->pwr_lock);
3947+
39263948 ret = regmap_read(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, &val);
39273949 if (ret) {
39283950 adsp_err(dsp,
39293951 "Failed to read Region Lock Ctrl register: %d\n", ret);
3930− return IRQ_HANDLED;
3952+ goto error;
39313953 }
39323954
39333955 if (val & ADSP2_WDT_TIMEOUT_STS_MASK) {
39343956 adsp_err(dsp, "watchdog timeout error\n");
39353957 wm_adsp_stop_watchdog(dsp);
3958+ wm_adsp_fatal_error(dsp);
39363959 }
39373960
39383961 if (val & (ADSP2_SLAVE_ERR_MASK | ADSP2_REGION_LOCK_ERR_MASK)) {
@@ -3946,7 +3969,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp) · 7 unmodified lines
39463969 adsp_err(dsp,
39473970 "Failed to read Bus Err Addr register: %d\n",
39483971 ret);
3949− return IRQ_HANDLED;
3972+ goto error;
39503973 }
39513974
39523975 adsp_err(dsp, "bus error address = 0x%x\n",
@@ -3959,7 +3982,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp) · 6 unmodified lines
39593982 adsp_err(dsp,
39603983 "Failed to read Pmem Xmem Err Addr register: %d\n",
39613984 ret);
3962− return IRQ_HANDLED;
3985+ goto error;
39633986 }
39643987
39653988 adsp_err(dsp, "xmem error address = 0x%x\n",
@@ -3972,6 +3995,9 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp) · 6 unmodified lines
39723995 regmap_update_bits(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL,
39733996 ADSP2_CTRL_ERR_EINT, ADSP2_CTRL_ERR_EINT);
39743997
3998+error:
3999+ mutex_unlock(&dsp->pwr_lock);
4000+
39754001 return IRQ_HANDLED;
39764002 }
39774003 EXPORT_SYMBOL_GPL(wm_adsp2_bus_error);
sound/soc/codecs/wm_adsp.h+1−0
@@ -85,6 +85,7 @@ struct wm_adsp { · 84 unmodified lines
8585 bool preloaded;
8686 bool booted;
8787 bool running;
88+ bool fatal_error;
8889
8990 struct list_head ctl_list;
9091
sound/soc/fsl/fsl_asrc.c+14−0
@@ -445,6 +445,19 @@ struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair, bool dir) · 444 unmodified lines
445445 }
446446 EXPORT_SYMBOL_GPL(fsl_asrc_get_dma_channel);
447447
448+static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream,
449+ struct snd_soc_dai *dai)
450+{
451+ struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai);
452+
453+ /* Odd channel number is not valid for older ASRC (channel_bits==3) */
454+ if (asrc_priv->channel_bits == 3)
455+ snd_pcm_hw_constraint_step(substream->runtime, 0,
456+ SNDRV_PCM_HW_PARAM_CHANNELS, 2);
457+
458+ return 0;
459+}
460+
448461 static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream,
449462 struct snd_pcm_hw_params *params,
450463 struct snd_soc_dai *dai)
@@ -539,6 +552,7 @@ static int fsl_asrc_dai_trigger(struct snd_pcm_substream *substream, int cmd, · 88 unmodified lines
539552 }
540553
541554 static const struct snd_soc_dai_ops fsl_asrc_dai_ops = {
555+ .startup = fsl_asrc_dai_startup,
542556 .hw_params = fsl_asrc_dai_hw_params,
543557 .hw_free = fsl_asrc_dai_hw_free,
544558 .trigger = fsl_asrc_dai_trigger,
sound/soc/fsl/fsl_esai.c+37−10
@@ -54,6 +54,8 @@ struct fsl_esai { · 53 unmodified lines
5454 u32 fifo_depth;
5555 u32 slot_width;
5656 u32 slots;
57+ u32 tx_mask;
58+ u32 rx_mask;
5759 u32 hck_rate[2];
5860 u32 sck_rate[2];
5961 bool hck_dir[2];
@@ -361,21 +363,13 @@ static int fsl_esai_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask, · 301 unmodified lines
361363 regmap_update_bits(esai_priv->regmap, REG_ESAI_TCCR,
362364 ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots));
363365
364− regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMA,
365− ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(tx_mask));
366− regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMB,
367− ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(tx_mask));
368−
369366 regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR,
370367 ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots));
371368
372− regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMA,
373− ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(rx_mask));
374− regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMB,
375− ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(rx_mask));
376−
377369 esai_priv->slot_width = slot_width;
378370 esai_priv->slots = slots;
371+ esai_priv->tx_mask = tx_mask;
372+ esai_priv->rx_mask = rx_mask;
379373
380374 return 0;
381375 }
@@ -596,6 +590,7 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, · 214 unmodified lines
596590 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
597591 u8 i, channels = substream->runtime->channels;
598592 u32 pins = DIV_ROUND_UP(channels, esai_priv->slots);
593+ u32 mask;
599594
600595 switch (cmd) {
601596 case SNDRV_PCM_TRIGGER_START:
@@ -608,15 +603,38 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, · 6 unmodified lines
608603 for (i = 0; tx && i < channels; i++)
609604 regmap_write(esai_priv->regmap, REG_ESAI_ETDR, 0x0);
610605
606+ /*
607+ * When set the TE/RE in the end of enablement flow, there
608+ * will be channel swap issue for multi data line case.
609+ * In order to workaround this issue, we switch the bit
610+ * enablement sequence to below sequence
611+ * 1) clear the xSMB & xSMA: which is done in probe and
612+ * stop state.
613+ * 2) set TE/RE
614+ * 3) set xSMB
615+ * 4) set xSMA: xSMA is the last one in this flow, which
616+ * will trigger esai to start.
617+ */
611618 regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx),
612619 tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK,
613620 tx ? ESAI_xCR_TE(pins) : ESAI_xCR_RE(pins));
621+ mask = tx ? esai_priv->tx_mask : esai_priv->rx_mask;
622+
623+ regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx),
624+ ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(mask));
625+ regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx),
626+ ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(mask));
627+
614628 break;
615629 case SNDRV_PCM_TRIGGER_SUSPEND:
616630 case SNDRV_PCM_TRIGGER_STOP:
617631 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
618632 regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx),
619633 tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, 0);
634+ regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx),
635+ ESAI_xSMA_xS_MASK, 0);
636+ regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx),
637+ ESAI_xSMB_xS_MASK, 0);
620638
621639 /* Disable and reset FIFO */
622640 regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx),
@@ -906,6 +924,15 @@ static int fsl_esai_probe(struct platform_device *pdev) · 283 unmodified lines
906924 return ret;
907925 }
908926
927+ esai_priv->tx_mask = 0xFFFFFFFF;
928+ esai_priv->rx_mask = 0xFFFFFFFF;
929+
930+ /* Clear the TSMA, TSMB, RSMA, RSMB */
931+ regmap_write(esai_priv->regmap, REG_ESAI_TSMA, 0);
932+ regmap_write(esai_priv->regmap, REG_ESAI_TSMB, 0);
933+ regmap_write(esai_priv->regmap, REG_ESAI_RSMA, 0);
934+ regmap_write(esai_priv->regmap, REG_ESAI_RSMB, 0);
935+
909936 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_esai_component,
910937 &fsl_esai_dai, 1);
911938 if (ret) {
sound/soc/generic/audio-graph-card.c+8−3
@@ -20,6 +20,8 @@ · 19 unmodified lines
2020 #include <linux/string.h>
2121 #include <sound/simple_card_utils.h>
2222
23+#define DPCM_SELECTABLE 1
24+
2325 struct graph_priv {
2426 struct snd_soc_card snd_card;
2527 struct graph_dai_props {
@@ -440,6 +442,7 @@ static int graph_for_each_link(struct graph_priv *priv, · 414 unmodified lines
440442 struct device_node *codec_port;
441443 struct device_node *codec_port_old = NULL;
442444 struct asoc_simple_card_data adata;
445+ uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev);
443446 int rc, ret;
444447
445448 /* loop for all listed CPU port */
@@ -470,8 +473,9 @@ static int graph_for_each_link(struct graph_priv *priv, · 24 unmodified lines
470473 * if Codec port has many endpoints,
471474 * or has convert-xxx property
472475 */
473− if ((of_get_child_count(codec_port) > 1) ||
474− adata.convert_rate || adata.convert_channels)
476+ if (dpcm_selectable &&
477+ ((of_get_child_count(codec_port) > 1) ||
478+ adata.convert_rate || adata.convert_channels))
475479 ret = func_dpcm(priv, cpu_ep, codec_ep, li,
476480 (codec_port_old == codec_port));
477481 /* else normal sound */
@@ -732,7 +736,8 @@ static int graph_remove(struct platform_device *pdev) · 254 unmodified lines
732736
733737 static const struct of_device_id graph_of_match[] = {
734738 { .compatible = "audio-graph-card", },
735− { .compatible = "audio-graph-scu-card", },
739+ { .compatible = "audio-graph-scu-card",
740+ .data = (void *)DPCM_SELECTABLE },
736741 {},
737742 };
738743 MODULE_DEVICE_TABLE(of, graph_of_match);
sound/soc/generic/simple-card.c+9−3
@@ -9,12 +9,15 @@ · 8 unmodified lines
99 #include <linux/device.h>
1010 #include <linux/module.h>
1111 #include <linux/of.h>
12+#include <linux/of_device.h>
1213 #include <linux/platform_device.h>
1314 #include <linux/string.h>
1415 #include <sound/simple_card.h>
1516 #include <sound/soc-dai.h>
1617 #include <sound/soc.h>
1718
19+#define DPCM_SELECTABLE 1
20+
1821 struct simple_priv {
1922 struct snd_soc_card snd_card;
2023 struct simple_dai_props {
@@ -441,6 +444,7 @@ static int simple_for_each_link(struct simple_priv *priv, · 420 unmodified lines
441444 struct device *dev = simple_priv_to_dev(priv);
442445 struct device_node *top = dev->of_node;
443446 struct device_node *node;
447+ uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev);
444448 bool is_top = 0;
445449 int ret = 0;
446450
@@ -480,8 +484,9 @@ static int simple_for_each_link(struct simple_priv *priv, · 33 unmodified lines
480484 * if it has many CPUs,
481485 * or has convert-xxx property
482486 */
483− if (num > 2 ||
484− adata.convert_rate || adata.convert_channels)
487+ if (dpcm_selectable &&
488+ (num > 2 ||
489+ adata.convert_rate || adata.convert_channels))
485490 ret = func_dpcm(priv, np, codec, li, is_top);
486491 /* else normal sound */
487492 else
@@ -822,7 +827,8 @@ static int simple_remove(struct platform_device *pdev) · 334 unmodified lines
822827
823828 static const struct of_device_id simple_of_match[] = {
824829 { .compatible = "simple-audio-card", },
825− { .compatible = "simple-scu-audio-card", },
830+ { .compatible = "simple-scu-audio-card",
831+ .data = (void *)DPCM_SELECTABLE },
826832 {},
827833 };
828834 MODULE_DEVICE_TABLE(of, simple_of_match);
sound/soc/intel/atom/sst-mfld-platform-pcm.c+8−0
@@ -706,9 +706,17 @@ static int sst_soc_probe(struct snd_soc_component *component) · 705 unmodified lines
706706 return sst_dsp_init_v2_dpcm(component);
707707 }
708708
709+static void sst_soc_remove(struct snd_soc_component *component)
710+{
711+ struct sst_data *drv = dev_get_drvdata(component->dev);
712+
713+ drv->soc_card = NULL;
714+}
715+
709716 static const struct snd_soc_component_driver sst_soc_platform_drv = {
710717 .name = DRV_NAME,
711718 .probe = sst_soc_probe,
719+ .remove = sst_soc_remove,
712720 .ops = &sst_platform_ops,
713721 .compr_ops = &sst_platform_compr_ops,
714722 .pcm_new = sst_pcm_new,
sound/soc/intel/boards/cht_bsw_max98090_ti.c+41−6
@@ -43,6 +43,7 @@ struct cht_mc_private { · 42 unmodified lines
4343 struct clk *mclk;
4444 struct snd_soc_jack jack;
4545 bool ts3a227e_present;
46+ int quirks;
4647 };
4748
4849 static int platform_clock_control(struct snd_soc_dapm_widget *w,
@@ -54,6 +55,10 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, · 5 unmodified lines
5455 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
5556 int ret;
5657
58+ /* See the comment in snd_cht_mc_probe() */
59+ if (ctx->quirks & QUIRK_PMC_PLT_CLK_0)
60+ return 0;
61+
5762 codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI);
5863 if (!codec_dai) {
5964 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
@@ -223,6 +228,10 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) · 163 unmodified lines
223228 "jack detection gpios not added, error %d\n", ret);
224229 }
225230
231+ /* See the comment in snd_cht_mc_probe() */
232+ if (ctx->quirks & QUIRK_PMC_PLT_CLK_0)
233+ return 0;
234+
226235 /*
227236 * The firmware might enable the clock at
228237 * boot (this information may or may not
@@ -423,16 +432,15 @@ static int snd_cht_mc_probe(struct platform_device *pdev) · 194 unmodified lines
423432 const char *mclk_name;
424433 struct snd_soc_acpi_mach *mach;
425434 const char *platform_name;
426− int quirks = 0;
427−
428− dmi_id = dmi_first_match(cht_max98090_quirk_table);
429− if (dmi_id)
430− quirks = (unsigned long)dmi_id->driver_data;
431435
432436 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
433437 if (!drv)
434438 return -ENOMEM;
435439
440+ dmi_id = dmi_first_match(cht_max98090_quirk_table);
441+ if (dmi_id)
442+ drv->quirks = (unsigned long)dmi_id->driver_data;
443+
436444 drv->ts3a227e_present = acpi_dev_found("104C227E");
437445 if (!drv->ts3a227e_present) {
438446 /* no need probe TI jack detection chip */
@@ -458,7 +466,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev) · 19 unmodified lines
458466 snd_soc_card_cht.dev = &pdev->dev;
459467 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
460468
461− if (quirks & QUIRK_PMC_PLT_CLK_0)
469+ if (drv->quirks & QUIRK_PMC_PLT_CLK_0)
462470 mclk_name = "pmc_plt_clk_0";
463471 else
464472 mclk_name = "pmc_plt_clk_3";
@@ -471,6 +479,21 @@ static int snd_cht_mc_probe(struct platform_device *pdev) · 6 unmodified lines
471479 return PTR_ERR(drv->mclk);
472480 }
473481
482+ /*
483+ * Boards which have the MAX98090's clk connected to clk_0 do not seem
484+ * to like it if we muck with the clock. If we disable the clock when
485+ * it is unused we get "max98090 i2c-193C9890:00: PLL unlocked" errors
486+ * and the PLL never seems to lock again.
487+ * So for these boards we enable it here once and leave it at that.
488+ */
489+ if (drv->quirks & QUIRK_PMC_PLT_CLK_0) {
490+ ret_val = clk_prepare_enable(drv->mclk);
491+ if (ret_val < 0) {
492+ dev_err(&pdev->dev, "MCLK enable error: %d\n", ret_val);
493+ return ret_val;
494+ }
495+ }
496+
474497 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
475498 if (ret_val) {
476499 dev_err(&pdev->dev,
@@ -481,11 +504,23 @@ static int snd_cht_mc_probe(struct platform_device *pdev) · 4 unmodified lines
481504 return ret_val;
482505 }
483506
507+static int snd_cht_mc_remove(struct platform_device *pdev)
508+{
509+ struct snd_soc_card *card = platform_get_drvdata(pdev);
510+ struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
511+
512+ if (ctx->quirks & QUIRK_PMC_PLT_CLK_0)
513+ clk_disable_unprepare(ctx->mclk);
514+
515+ return 0;
516+}
517+
484518 static struct platform_driver snd_cht_mc_driver = {
485519 .driver = {
486520 .name = "cht-bsw-max98090",
487521 },
488522 .probe = snd_cht_mc_probe,
523+ .remove = snd_cht_mc_remove,
489524 };
490525
491526 module_platform_driver(snd_cht_mc_driver)
sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c+1−1
@@ -405,7 +405,7 @@ static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = { · 404 unmodified lines
405405 };
406406
407407 static const unsigned int dmic_2ch[] = {
408− 4,
408+ 2,
409409 };
410410
411411 static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
sound/soc/intel/skylake/skl-messages.c+1−0
@@ -483,6 +483,7 @@ static void skl_set_base_module_format(struct skl_sst *ctx, · 482 unmodified lines
483483 base_cfg->audio_fmt.bit_depth = format->bit_depth;
484484 base_cfg->audio_fmt.valid_bit_depth = format->valid_bit_depth;
485485 base_cfg->audio_fmt.ch_cfg = format->ch_cfg;
486+ base_cfg->audio_fmt.sample_type = format->sample_type;
486487
487488 dev_dbg(ctx->dev, "bit_depth=%x valid_bd=%x ch_config=%x\n",
488489 format->bit_depth, format->valid_bit_depth,
sound/soc/intel/skylake/skl-pcm.c+22−6
@@ -181,6 +181,7 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params) · 180 unmodified lines
181181 struct hdac_stream *hstream;
182182 struct hdac_ext_stream *stream;
183183 struct hdac_ext_link *link;
184+ unsigned char stream_tag;
184185
185186 hstream = snd_hdac_get_stream(bus, params->stream,
186187 params->link_dma_id + 1);
@@ -199,10 +200,13 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params) · 12 unmodified lines
199200
200201 snd_hdac_ext_link_stream_setup(stream, format_val);
201202
202− list_for_each_entry(link, &bus->hlink_list, list) {
203− if (link->index == params->link_index)
204− snd_hdac_ext_link_set_stream_id(link,
205− hstream->stream_tag);
203+ stream_tag = hstream->stream_tag;
204+ if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
205+ list_for_each_entry(link, &bus->hlink_list, list) {
206+ if (link->index == params->link_index)
207+ snd_hdac_ext_link_set_stream_id(link,
208+ stream_tag);
209+ }
206210 }
207211
208212 stream->link_prepared = 1;
@@ -645,6 +649,7 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream, · 436 unmodified lines
645649 struct hdac_ext_stream *link_dev =
646650 snd_soc_dai_get_dma_data(dai, substream);
647651 struct hdac_ext_link *link;
652+ unsigned char stream_tag;
648653
649654 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
650655
@@ -654,7 +659,11 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream, · 3 unmodified lines
654659 if (!link)
655660 return -EINVAL;
656661
657− snd_hdac_ext_link_clear_stream_id(link, hdac_stream(link_dev)->stream_tag);
662+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
663+ stream_tag = hdac_stream(link_dev)->stream_tag;
664+ snd_hdac_ext_link_clear_stream_id(link, stream_tag);
665+ }
666+
658667 snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
659668 return 0;
660669 }
@@ -1453,13 +1462,20 @@ static int skl_platform_soc_probe(struct snd_soc_component *component) · 792 unmodified lines
14531462 return 0;
14541463 }
14551464
1465+static void skl_pcm_remove(struct snd_soc_component *component)
1466+{
1467+ /* remove topology */
1468+ snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
1469+}
1470+
14561471 static const struct snd_soc_component_driver skl_component = {
14571472 .name = "pcm",
14581473 .probe = skl_platform_soc_probe,
1474+ .remove = skl_pcm_remove,
14591475 .ops = &skl_platform_ops,
14601476 .pcm_new = skl_pcm_new,
14611477 .pcm_free = skl_pcm_free,
1462− .ignore_module_refcount = 1, /* do not increase the refcount in core */
1478+ .module_get_upon_open = 1, /* increment refcount when a pcm is opened */
14631479 };
14641480
14651481 int skl_platform_register(struct device *dev)
sound/soc/mediatek/common/mtk-btcvsd.c+68−1
@@ -49,6 +49,7 @@ enum bt_sco_state { · 48 unmodified lines
4949 BT_SCO_STATE_IDLE,
5050 BT_SCO_STATE_RUNNING,
5151 BT_SCO_STATE_ENDING,
52+ BT_SCO_STATE_LOOPBACK,
5253 };
5354
5455 enum bt_sco_direct {
@@ -486,7 +487,8 @@ static irqreturn_t mtk_btcvsd_snd_irq_handler(int irq_id, void *dev) · 431 unmodified lines
486487 if (bt->rx->state != BT_SCO_STATE_RUNNING &&
487488 bt->rx->state != BT_SCO_STATE_ENDING &&
488489 bt->tx->state != BT_SCO_STATE_RUNNING &&
489− bt->tx->state != BT_SCO_STATE_ENDING) {
490+ bt->tx->state != BT_SCO_STATE_ENDING &&
491+ bt->tx->state != BT_SCO_STATE_LOOPBACK) {
490492 dev_warn(bt->dev, "%s(), in idle state: rx->state: %d, tx->state: %d\n",
491493 __func__, bt->rx->state, bt->tx->state);
492494 goto irq_handler_exit;
@@ -512,6 +514,42 @@ static irqreturn_t mtk_btcvsd_snd_irq_handler(int irq_id, void *dev) · 19 unmodified lines
512514 buf_cnt_tx = btsco_packet_info[packet_type][2];
513515 buf_cnt_rx = btsco_packet_info[packet_type][3];
514516
517+ if (bt->tx->state == BT_SCO_STATE_LOOPBACK) {
518+ u8 *src, *dst;
519+ unsigned long connsys_addr_rx, ap_addr_rx;
520+ unsigned long connsys_addr_tx, ap_addr_tx;
521+
522+ connsys_addr_rx = *bt->bt_reg_pkt_r;
523+ ap_addr_rx = (unsigned long)bt->bt_sram_bank2_base +
524+ (connsys_addr_rx & 0xFFFF);
525+
526+ connsys_addr_tx = *bt->bt_reg_pkt_w;
527+ ap_addr_tx = (unsigned long)bt->bt_sram_bank2_base +
528+ (connsys_addr_tx & 0xFFFF);
529+
530+ if (connsys_addr_tx == 0xdeadfeed ||
531+ connsys_addr_rx == 0xdeadfeed) {
532+ /* bt return 0xdeadfeed if read reg during bt sleep */
533+ dev_warn(bt->dev, "%s(), connsys_addr_tx == 0xdeadfeed\n",
534+ __func__);
535+ goto irq_handler_exit;
536+ }
537+
538+ src = (u8 *)ap_addr_rx;
539+ dst = (u8 *)ap_addr_tx;
540+
541+ mtk_btcvsd_snd_data_transfer(BT_SCO_DIRECT_BT2ARM, src,
542+ bt->tx->temp_packet_buf,
543+ packet_length,
544+ packet_num);
545+ mtk_btcvsd_snd_data_transfer(BT_SCO_DIRECT_ARM2BT,
546+ bt->tx->temp_packet_buf, dst,
547+ packet_length,
548+ packet_num);
549+ bt->rx->rw_cnt++;
550+ bt->tx->rw_cnt++;
551+ }
552+
515553 if (bt->rx->state == BT_SCO_STATE_RUNNING ||
516554 bt->rx->state == BT_SCO_STATE_ENDING) {
517555 if (bt->rx->xrun) {
@@ -1067,6 +1105,33 @@ static int btcvsd_band_set(struct snd_kcontrol *kcontrol, · 549 unmodified lines
10671105 return 0;
10681106 }
10691107
1108+static int btcvsd_loopback_get(struct snd_kcontrol *kcontrol,
1109+ struct snd_ctl_elem_value *ucontrol)
1110+{
1111+ struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
1112+ struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt);
1113+ bool lpbk_en = bt->tx->state == BT_SCO_STATE_LOOPBACK;
1114+
1115+ ucontrol->value.integer.value[0] = lpbk_en;
1116+ return 0;
1117+}
1118+
1119+static int btcvsd_loopback_set(struct snd_kcontrol *kcontrol,
1120+ struct snd_ctl_elem_value *ucontrol)
1121+{
1122+ struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
1123+ struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt);
1124+
1125+ if (ucontrol->value.integer.value[0]) {
1126+ mtk_btcvsd_snd_set_state(bt, bt->tx, BT_SCO_STATE_LOOPBACK);
1127+ mtk_btcvsd_snd_set_state(bt, bt->rx, BT_SCO_STATE_LOOPBACK);
1128+ } else {
1129+ mtk_btcvsd_snd_set_state(bt, bt->tx, BT_SCO_STATE_RUNNING);
1130+ mtk_btcvsd_snd_set_state(bt, bt->rx, BT_SCO_STATE_RUNNING);
1131+ }
1132+ return 0;
1133+}
1134+
10701135 static int btcvsd_tx_mute_get(struct snd_kcontrol *kcontrol,
10711136 struct snd_ctl_elem_value *ucontrol)
10721137 {
@@ -1202,6 +1267,8 @@ static int btcvsd_tx_timestamp_get(struct snd_kcontrol *kcontrol, · 129 unmodified lines
12021267 static const struct snd_kcontrol_new mtk_btcvsd_snd_controls[] = {
12031268 SOC_ENUM_EXT("BTCVSD Band", btcvsd_enum[0],
12041269 btcvsd_band_get, btcvsd_band_set),
1270+ SOC_SINGLE_BOOL_EXT("BTCVSD Loopback Switch", 0,
1271+ btcvsd_loopback_get, btcvsd_loopback_set),
12051272 SOC_SINGLE_BOOL_EXT("BTCVSD Tx Mute Switch", 0,
12061273 btcvsd_tx_mute_get, btcvsd_tx_mute_set),
12071274 SOC_SINGLE_BOOL_EXT("BTCVSD Tx Irq Received Switch", 0,
sound/soc/mediatek/mt8183/mt8183-afe-clk.c+4−0
@@ -605,6 +605,10 @@ void mt8183_mck_disable(struct mtk_base_afe *afe, int mck_id) · 604 unmodified lines
605605 int m_sel_id = mck_div[mck_id].m_sel_id;
606606 int div_clk_id = mck_div[mck_id].div_clk_id;
607607
608+ /* i2s5 mck not support */
609+ if (mck_id == MT8183_I2S5_MCK)
610+ return;
611+
608612 clk_disable_unprepare(afe_priv->clk[div_clk_id]);
609613 if (m_sel_id >= 0)
610614 clk_disable_unprepare(afe_priv->clk[m_sel_id]);
sound/soc/rockchip/rockchip_pdm.c+3−1
@@ -24,7 +24,7 @@ · 23 unmodified lines
2424
2525 #include "rockchip_pdm.h"
2626
27−#define PDM_DMA_BURST_SIZE (16) /* size * width: 16*4 = 64 bytes */
27+#define PDM_DMA_BURST_SIZE (8) /* size * width: 8*4 = 32 bytes */
2828
2929 struct rk_pdm_dev {
3030 struct device *dev;
@@ -208,7 +208,9 @@ static int rockchip_pdm_set_fmt(struct snd_soc_dai *cpu_dai, · 177 unmodified lines
208208 return -EINVAL;
209209 }
210210
211+ pm_runtime_get_sync(cpu_dai->dev);
211212 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, mask, val);
213+ pm_runtime_put(cpu_dai->dev);
212214
213215 return 0;
214216 }
sound/soc/samsung/i2s.c+6−4
@@ -1130,11 +1130,11 @@ static const struct snd_soc_dapm_widget samsung_i2s_widgets[] = { · 1129 unmodified lines
11301130 };
11311131
11321132 static const struct snd_soc_dapm_route samsung_i2s_dapm_routes[] = {
1133− { "Playback Mixer", NULL, "Primary" },
1134− { "Playback Mixer", NULL, "Secondary" },
1133+ { "Playback Mixer", NULL, "Primary Playback" },
1134+ { "Playback Mixer", NULL, "Secondary Playback" },
11351135
11361136 { "Mixer DAI TX", NULL, "Playback Mixer" },
1137− { "Playback Mixer", NULL, "Mixer DAI RX" },
1137+ { "Primary Capture", NULL, "Mixer DAI RX" },
11381138 };
11391139
11401140 static const struct snd_soc_component_driver samsung_i2s_component = {
@@ -1155,7 +1155,8 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv, · 14 unmodified lines
11551155 int num_dais)
11561156 {
11571157 static const char *dai_names[] = { "samsung-i2s", "samsung-i2s-sec" };
1158− static const char *stream_names[] = { "Primary", "Secondary" };
1158+ static const char *stream_names[] = { "Primary Playback",
1159+ "Secondary Playback" };
11591160 struct snd_soc_dai_driver *dai_drv;
11601161 struct i2s_dai *dai;
11611162 int i;
@@ -1201,6 +1202,7 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv, · 39 unmodified lines
12011202 dai_drv->capture.channels_max = 2;
12021203 dai_drv->capture.rates = i2s_dai_data->pcm_rates;
12031204 dai_drv->capture.formats = SAMSUNG_I2S_FMTS;
1205+ dai_drv->capture.stream_name = "Primary Capture";
12041206
12051207 return 0;
12061208 }
sound/soc/samsung/odroid.c+2−2
@@ -91,11 +91,11 @@ static int odroid_card_be_hw_params(struct snd_pcm_substream *substream, · 90 unmodified lines
9191 return ret;
9292
9393 /*
94− * We add 1 to the rclk_freq value in order to avoid too low clock
94+ * We add 2 to the rclk_freq value in order to avoid too low clock
9595 * frequency values due to the EPLL output frequency not being exact
9696 * multiple of the audio sampling rate.
9797 */
98− rclk_freq = params_rate(params) * rfs + 1;
98+ rclk_freq = params_rate(params) * rfs + 2;
9999
100100 ret = clk_set_rate(priv->sclk_i2s, rclk_freq);
101101 if (ret < 0)
sound/soc/sh/rcar/core.c+2−0
@@ -110,6 +110,8 @@ static const struct of_device_id rsnd_of_match[] = { · 109 unmodified lines
110110 { .compatible = "renesas,rcar_sound-gen1", .data = (void *)RSND_GEN1 },
111111 { .compatible = "renesas,rcar_sound-gen2", .data = (void *)RSND_GEN2 },
112112 { .compatible = "renesas,rcar_sound-gen3", .data = (void *)RSND_GEN3 },
113+ /* Special Handling */
114+ { .compatible = "renesas,rcar_sound-r8a77990", .data = (void *)(RSND_GEN3 | RSND_SOC_E) },
113115 {},
114116 };
115117 MODULE_DEVICE_TABLE(of, rsnd_of_match);
sound/soc/sh/rcar/rsnd.h+5−0
@@ -607,6 +607,8 @@ struct rsnd_priv { · 606 unmodified lines
607607 #define RSND_GEN1 (1 << 0)
608608 #define RSND_GEN2 (2 << 0)
609609 #define RSND_GEN3 (3 << 0)
610+#define RSND_SOC_MASK (0xFF << 4)
611+#define RSND_SOC_E (1 << 4) /* E1/E2/E3 */
610612
611613 /*
612614 * below value will be filled on rsnd_gen_probe()
@@ -679,6 +681,9 @@ struct rsnd_priv { · 66 unmodified lines
679681 #define rsnd_is_gen1(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN1)
680682 #define rsnd_is_gen2(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN2)
681683 #define rsnd_is_gen3(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN3)
684+#define rsnd_is_e3(priv) (((priv)->flags & \
685+ (RSND_GEN_MASK | RSND_SOC_MASK)) == \
686+ (RSND_GEN3 | RSND_SOC_E))
682687
683688 #define rsnd_flags_has(p, f) ((p)->flags & (f))
684689 #define rsnd_flags_set(p, f) ((p)->flags |= (f))
sound/soc/sh/rcar/src.c+7−14
@@ -14,7 +14,6 @@ · 13 unmodified lines
1414 */
1515
1616 #include "rsnd.h"
17−#include <linux/sys_soc.h>
1817
1918 #define SRC_NAME "src"
2019
@@ -135,7 +134,7 @@ unsigned int rsnd_src_get_rate(struct rsnd_priv *priv, · 114 unmodified lines
135134 return rate;
136135 }
137136
138−const static u32 bsdsr_table_pattern1[] = {
137+static const u32 bsdsr_table_pattern1[] = {
139138 0x01800000, /* 6 - 1/6 */
140139 0x01000000, /* 6 - 1/4 */
141140 0x00c00000, /* 6 - 1/3 */
@@ -144,7 +143,7 @@ const static u32 bsdsr_table_pattern1[] = { · 2 unmodified lines
144143 0x00400000, /* 6 - 1 */
145144 };
146145
147−const static u32 bsdsr_table_pattern2[] = {
146+static const u32 bsdsr_table_pattern2[] = {
148147 0x02400000, /* 6 - 1/6 */
149148 0x01800000, /* 6 - 1/4 */
150149 0x01200000, /* 6 - 1/3 */
@@ -153,7 +152,7 @@ const static u32 bsdsr_table_pattern2[] = { · 2 unmodified lines
153152 0x00600000, /* 6 - 1 */
154153 };
155154
156−const static u32 bsisr_table[] = {
155+static const u32 bsisr_table[] = {
157156 0x00100060, /* 6 - 1/6 */
158157 0x00100040, /* 6 - 1/4 */
159158 0x00100030, /* 6 - 1/3 */
@@ -162,7 +161,7 @@ const static u32 bsisr_table[] = { · 2 unmodified lines
162161 0x00100020, /* 6 - 1 */
163162 };
164163
165−const static u32 chan288888[] = {
164+static const u32 chan288888[] = {
166165 0x00000006, /* 1 to 2 */
167166 0x000001fe, /* 1 to 8 */
168167 0x000001fe, /* 1 to 8 */
@@ -171,7 +170,7 @@ const static u32 chan288888[] = { · 2 unmodified lines
171170 0x000001fe, /* 1 to 8 */
172171 };
173172
174−const static u32 chan244888[] = {
173+static const u32 chan244888[] = {
175174 0x00000006, /* 1 to 2 */
176175 0x0000001e, /* 1 to 4 */
177176 0x0000001e, /* 1 to 4 */
@@ -180,7 +179,7 @@ const static u32 chan244888[] = { · 2 unmodified lines
180179 0x000001fe, /* 1 to 8 */
181180 };
182181
183−const static u32 chan222222[] = {
182+static const u32 chan222222[] = {
184183 0x00000006, /* 1 to 2 */
185184 0x00000006, /* 1 to 2 */
186185 0x00000006, /* 1 to 2 */
@@ -189,18 +188,12 @@ const static u32 chan222222[] = { · 2 unmodified lines
189188 0x00000006, /* 1 to 2 */
190189 };
191190
192−static const struct soc_device_attribute ov_soc[] = {
193− { .soc_id = "r8a77990" }, /* E3 */
194− { /* sentinel */ }
195−};
196−
197191 static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io,
198192 struct rsnd_mod *mod)
199193 {
200194 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
201195 struct device *dev = rsnd_priv_to_dev(priv);
202196 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
203− const struct soc_device_attribute *soc = soc_device_match(ov_soc);
204197 int is_play = rsnd_io_is_play(io);
205198 int use_src = 0;
206199 u32 fin, fout;
@@ -307,7 +300,7 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, · 100 unmodified lines
307300 /*
308301 * E3 need to overwrite
309302 */
310− if (soc)
303+ if (rsnd_is_e3(priv))
311304 switch (rsnd_mod_id(mod)) {
312305 case 0:
313306 case 4:
sound/soc/soc-core.c+4−2
@@ -947,7 +947,7 @@ static void soc_cleanup_component(struct snd_soc_component *component) · 946 unmodified lines
947947 snd_soc_dapm_free(snd_soc_component_get_dapm(component));
948948 soc_cleanup_component_debugfs(component);
949949 component->card = NULL;
950− if (!component->driver->ignore_module_refcount)
950+ if (!component->driver->module_get_upon_open)
951951 module_put(component->dev->driver->owner);
952952 }
953953
@@ -1381,7 +1381,7 @@ static int soc_probe_component(struct snd_soc_card *card, · 427 unmodified lines
13811381 return 0;
13821382 }
13831383
1384− if (!component->driver->ignore_module_refcount &&
1384+ if (!component->driver->module_get_upon_open &&
13851385 !try_module_get(component->dev->driver->owner))
13861386 return -ENODEV;
13871387
@@ -2797,6 +2797,7 @@ int snd_soc_register_card(struct snd_soc_card *card) · 1409 unmodified lines
27972797
27982798 ret = soc_init_dai_link(card, link);
27992799 if (ret) {
2800+ soc_cleanup_platform(card);
28002801 dev_err(card->dev, "ASoC: failed to init link %s\n",
28012802 link->name);
28022803 mutex_unlock(&client_mutex);
@@ -2819,6 +2820,7 @@ int snd_soc_register_card(struct snd_soc_card *card) · 16 unmodified lines
28192820 card->instantiated = 0;
28202821 mutex_init(&card->mutex);
28212822 mutex_init(&card->dapm_mutex);
2823+ spin_lock_init(&card->dpcm_lock);
28222824
28232825 return snd_soc_bind_card(card);
28242826 }
sound/soc/soc-dapm.c+11−0
@@ -3650,6 +3650,13 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, · 3649 unmodified lines
36503650 case snd_soc_dapm_dac:
36513651 case snd_soc_dapm_aif_in:
36523652 case snd_soc_dapm_pga:
3653+ case snd_soc_dapm_buffer:
3654+ case snd_soc_dapm_scheduler:
3655+ case snd_soc_dapm_effect:
3656+ case snd_soc_dapm_src:
3657+ case snd_soc_dapm_asrc:
3658+ case snd_soc_dapm_encoder:
3659+ case snd_soc_dapm_decoder:
36533660 case snd_soc_dapm_out_drv:
36543661 case snd_soc_dapm_micbias:
36553662 case snd_soc_dapm_line:
@@ -3957,6 +3964,10 @@ snd_soc_dapm_free_kcontrol(struct snd_soc_card *card, · 301 unmodified lines
39573964 int count;
39583965
39593966 devm_kfree(card->dev, (void *)*private_value);
3967+
3968+ if (!w_param_text)
3969+ return;
3970+
39603971 for (count = 0 ; count < num_params; count++)
39613972 devm_kfree(card->dev, (void *)w_param_text[count]);
39623973 devm_kfree(card->dev, w_param_text);
sound/soc/soc-pcm.c+55−11
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <linux/delay.h>
1616 #include <linux/pinctrl/consumer.h>
1717 #include <linux/pm_runtime.h>
18+#include <linux/module.h>
1819 #include <linux/slab.h>
1920 #include <linux/workqueue.h>
2021 #include <linux/export.h>
@@ -463,6 +464,9 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream, · 442 unmodified lines
463464 continue;
464465
465466 component->driver->ops->close(substream);
467+
468+ if (component->driver->module_get_upon_open)
469+ module_put(component->dev->driver->owner);
466470 }
467471
468472 return 0;
@@ -513,6 +517,12 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) · 44 unmodified lines
513517 !component->driver->ops->open)
514518 continue;
515519
520+ if (component->driver->module_get_upon_open &&
521+ !try_module_get(component->dev->driver->owner)) {
522+ ret = -ENODEV;
523+ goto module_err;
524+ }
525+
516526 ret = component->driver->ops->open(substream);
517527 if (ret < 0) {
518528 dev_err(component->dev,
@@ -628,7 +638,7 @@ codec_dai_err: · 109 unmodified lines
628638
629639 component_err:
630640 soc_pcm_components_close(substream, component);
631−
641+module_err:
632642 if (cpu_dai->driver->ops->shutdown)
633643 cpu_dai->driver->ops->shutdown(substream, cpu_dai);
634644 out:
@@ -954,10 +964,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, · 319 unmodified lines
954964 codec_params = *params;
955965
956966 /* fixup params based on TDM slot masks */
957− if (codec_dai->tx_mask)
967+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
968+ codec_dai->tx_mask)
958969 soc_pcm_codec_params_fixup(&codec_params,
959970 codec_dai->tx_mask);
960− if (codec_dai->rx_mask)
971+
972+ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
973+ codec_dai->rx_mask)
961974 soc_pcm_codec_params_fixup(&codec_params,
962975 codec_dai->rx_mask);
963976
@@ -1213,6 +1226,7 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, · 249 unmodified lines
12131226 struct snd_soc_pcm_runtime *be, int stream)
12141227 {
12151228 struct snd_soc_dpcm *dpcm;
1229+ unsigned long flags;
12161230
12171231 /* only add new dpcms */
12181232 for_each_dpcm_be(fe, stream, dpcm) {
@@ -1228,8 +1242,10 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, · 9 unmodified lines
12281242 dpcm->fe = fe;
12291243 be->dpcm[stream].runtime = fe->dpcm[stream].runtime;
12301244 dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW;
1245+ spin_lock_irqsave(&fe->card->dpcm_lock, flags);
12311246 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients);
12321247 list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients);
1248+ spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
12331249
12341250 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n",
12351251 stream ? "capture" : "playback", fe->dai_link->name,
@@ -1275,6 +1291,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, · 39 unmodified lines
12751291 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
12761292 {
12771293 struct snd_soc_dpcm *dpcm, *d;
1294+ unsigned long flags;
12781295
12791296 for_each_dpcm_be_safe(fe, stream, dpcm, d) {
12801297 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n",
@@ -1294,8 +1311,10 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) · 13 unmodified lines
12941311 #ifdef CONFIG_DEBUG_FS
12951312 debugfs_remove(dpcm->debugfs_state);
12961313 #endif
1314+ spin_lock_irqsave(&fe->card->dpcm_lock, flags);
12971315 list_del(&dpcm->list_be);
12981316 list_del(&dpcm->list_fe);
1317+ spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
12991318 kfree(dpcm);
13001319 }
13011320 }
@@ -1547,10 +1566,13 @@ int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, · 245 unmodified lines
15471566 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream)
15481567 {
15491568 struct snd_soc_dpcm *dpcm;
1569+ unsigned long flags;
15501570
1571+ spin_lock_irqsave(&fe->card->dpcm_lock, flags);
15511572 for_each_dpcm_be(fe, stream, dpcm)
15521573 dpcm->be->dpcm[stream].runtime_update =
15531574 SND_SOC_DPCM_UPDATE_NO;
1575+ spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
15541576 }
15551577
15561578 static void dpcm_be_dai_startup_unwind(struct snd_soc_pcm_runtime *fe,
@@ -1899,10 +1921,15 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream, · 342 unmodified lines
18991921 struct snd_soc_pcm_runtime *be = dpcm->be;
19001922 struct snd_pcm_substream *be_substream =
19011923 snd_soc_dpcm_get_substream(be, stream);
1902− struct snd_soc_pcm_runtime *rtd = be_substream->private_data;
1924+ struct snd_soc_pcm_runtime *rtd;
19031925 struct snd_soc_dai *codec_dai;
19041926 int i;
19051927
1928+ /* A backend may not have the requested substream */
1929+ if (!be_substream)
1930+ continue;
1931+
1932+ rtd = be_substream->private_data;
19061933 if (rtd->dai_link->be_hw_params_fixup)
19071934 continue;
19081935
@@ -2571,6 +2598,7 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) · 662 unmodified lines
25712598 struct snd_soc_dpcm *dpcm;
25722599 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
25732600 int ret;
2601+ unsigned long flags;
25742602
25752603 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n",
25762604 stream ? "capture" : "playback", fe->dai_link->name);
@@ -2640,11 +2668,13 @@ close: · 63 unmodified lines
26402668 dpcm_be_dai_shutdown(fe, stream);
26412669 disconnect:
26422670 /* disconnect any non started BEs */
2671+ spin_lock_irqsave(&fe->card->dpcm_lock, flags);
26432672 for_each_dpcm_be(fe, stream, dpcm) {
26442673 struct snd_soc_pcm_runtime *be = dpcm->be;
26452674 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
26462675 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
26472676 }
2677+ spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
26482678
26492679 return ret;
26502680 }
@@ -3221,7 +3251,10 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, · 570 unmodified lines
32213251 {
32223252 struct snd_soc_dpcm *dpcm;
32233253 int state;
3254+ int ret = 1;
3255+ unsigned long flags;
32243256
3257+ spin_lock_irqsave(&fe->card->dpcm_lock, flags);
32253258 for_each_dpcm_fe(be, stream, dpcm) {
32263259
32273260 if (dpcm->fe == fe)
@@ -3230,12 +3263,15 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, · 2 unmodified lines
32303263 state = dpcm->fe->dpcm[stream].state;
32313264 if (state == SND_SOC_DPCM_STATE_START ||
32323265 state == SND_SOC_DPCM_STATE_PAUSED ||
3233− state == SND_SOC_DPCM_STATE_SUSPEND)
3234− return 0;
3266+ state == SND_SOC_DPCM_STATE_SUSPEND) {
3267+ ret = 0;
3268+ break;
3269+ }
32353270 }
3271+ spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
32363272
32373273 /* it's safe to free/stop this BE DAI */
3238− return 1;
3274+ return ret;
32393275 }
32403276 EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_free_stop);
32413277
@@ -3248,7 +3284,10 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, · 6 unmodified lines
32483284 {
32493285 struct snd_soc_dpcm *dpcm;
32503286 int state;
3287+ int ret = 1;
3288+ unsigned long flags;
32513289
3290+ spin_lock_irqsave(&fe->card->dpcm_lock, flags);
32523291 for_each_dpcm_fe(be, stream, dpcm) {
32533292
32543293 if (dpcm->fe == fe)
@@ -3258,12 +3297,15 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, · 3 unmodified lines
32583297 if (state == SND_SOC_DPCM_STATE_START ||
32593298 state == SND_SOC_DPCM_STATE_PAUSED ||
32603299 state == SND_SOC_DPCM_STATE_SUSPEND ||
3261− state == SND_SOC_DPCM_STATE_PREPARE)
3262− return 0;
3300+ state == SND_SOC_DPCM_STATE_PREPARE) {
3301+ ret = 0;
3302+ break;
3303+ }
32633304 }
3305+ spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
32643306
32653307 /* it's safe to change hw_params */
3266− return 1;
3308+ return ret;
32673309 }
32683310 EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params);
32693311
@@ -3302,6 +3344,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, · 32 unmodified lines
33023344 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params;
33033345 struct snd_soc_dpcm *dpcm;
33043346 ssize_t offset = 0;
3347+ unsigned long flags;
33053348
33063349 /* FE state */
33073350 offset += snprintf(buf + offset, size - offset,
@@ -3329,6 +3372,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, · 21 unmodified lines
33293372 goto out;
33303373 }
33313374
3375+ spin_lock_irqsave(&fe->card->dpcm_lock, flags);
33323376 for_each_dpcm_be(fe, stream, dpcm) {
33333377 struct snd_soc_pcm_runtime *be = dpcm->be;
33343378 params = &dpcm->hw_params;
@@ -3349,7 +3393,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, · 14 unmodified lines
33493393 params_channels(params),
33503394 params_rate(params));
33513395 }
3352−
3396+ spin_unlock_irqrestore(&fe->card->dpcm_lock, flags);
33533397 out:
33543398 return offset;
33553399 }
sound/soc/soc-topology.c+4−3
@@ -482,10 +482,11 @@ static void remove_widget(struct snd_soc_component *comp, · 481 unmodified lines
482482
483483 snd_ctl_remove(card, kcontrol);
484484
485− kfree(dobj->control.dvalues);
485+ /* free enum kcontrol's dvalues and dtexts */
486+ kfree(se->dobj.control.dvalues);
486487 for (j = 0; j < se->items; j++)
487− kfree(dobj->control.dtexts[j]);
488− kfree(dobj->control.dtexts);
488+ kfree(se->dobj.control.dtexts[j]);
489+ kfree(se->dobj.control.dtexts);
489490
490491 kfree(se);
491492 kfree(w->kcontrol_news[i].name);
sound/soc/stm/stm32_adfsdm.c+34−4
@@ -9,6 +9,7 @@ · 8 unmodified lines
99
1010 #include <linux/clk.h>
1111 #include <linux/module.h>
12+#include <linux/mutex.h>
1213 #include <linux/platform_device.h>
1314 #include <linux/slab.h>
1415
@@ -37,6 +38,8 @@ struct stm32_adfsdm_priv { · 22 unmodified lines
3738 /* PCM buffer */
3839 unsigned char *pcm_buff;
3940 unsigned int pos;
41+
42+ struct mutex lock; /* protect against race condition on iio state */
4043 };
4144
4245 static const struct snd_pcm_hardware stm32_adfsdm_pcm_hw = {
@@ -62,10 +65,12 @@ static void stm32_adfsdm_shutdown(struct snd_pcm_substream *substream, · 19 unmodified lines
6265 {
6366 struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai);
6467
68+ mutex_lock(&priv->lock);
6569 if (priv->iio_active) {
6670 iio_channel_stop_all_cb(priv->iio_cb);
6771 priv->iio_active = false;
6872 }
73+ mutex_unlock(&priv->lock);
6974 }
7075
7176 static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream,
@@ -74,13 +79,19 @@ static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream, · 2 unmodified lines
7479 struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai);
7580 int ret;
7681
82+ mutex_lock(&priv->lock);
83+ if (priv->iio_active) {
84+ iio_channel_stop_all_cb(priv->iio_cb);
85+ priv->iio_active = false;
86+ }
87+
7788 ret = iio_write_channel_attribute(priv->iio_ch,
7889 substream->runtime->rate, 0,
7990 IIO_CHAN_INFO_SAMP_FREQ);
8091 if (ret < 0) {
8192 dev_err(dai->dev, "%s: Failed to set %d sampling rate\n",
8293 __func__, substream->runtime->rate);
83− return ret;
94+ goto out;
8495 }
8596
8697 if (!priv->iio_active) {
@@ -92,6 +103,9 @@ static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream, · 5 unmodified lines
92103 __func__, ret);
93104 }
94105
106+out:
107+ mutex_unlock(&priv->lock);
108+
95109 return ret;
96110 }
97111
@@ -291,6 +305,7 @@ MODULE_DEVICE_TABLE(of, stm32_adfsdm_of_match); · 193 unmodified lines
291305 static int stm32_adfsdm_probe(struct platform_device *pdev)
292306 {
293307 struct stm32_adfsdm_priv *priv;
308+ struct snd_soc_component *component;
294309 int ret;
295310
296311 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -299,6 +314,7 @@ static int stm32_adfsdm_probe(struct platform_device *pdev) · 2 unmodified lines
299314
300315 priv->dev = &pdev->dev;
301316 priv->dai_drv = stm32_adfsdm_dai;
317+ mutex_init(&priv->lock);
302318
303319 dev_set_drvdata(&pdev->dev, priv);
304320
@@ -317,9 +333,15 @@ static int stm32_adfsdm_probe(struct platform_device *pdev) · 12 unmodified lines
317333 if (IS_ERR(priv->iio_cb))
318334 return PTR_ERR(priv->iio_cb);
319335
320− ret = devm_snd_soc_register_component(&pdev->dev,
321− &stm32_adfsdm_soc_platform,
322− NULL, 0);
336+ component = devm_kzalloc(&pdev->dev, sizeof(*component), GFP_KERNEL);
337+ if (!component)
338+ return -ENOMEM;
339+#ifdef CONFIG_DEBUG_FS
340+ component->debugfs_prefix = "pcm";
341+#endif
342+
343+ ret = snd_soc_add_component(&pdev->dev, component,
344+ &stm32_adfsdm_soc_platform, NULL, 0);
323345 if (ret < 0)
324346 dev_err(&pdev->dev, "%s: Failed to register PCM platform\n",
325347 __func__);
@@ -327,12 +349,20 @@ static int stm32_adfsdm_probe(struct platform_device *pdev) · 1 unmodified line
327349 return ret;
328350 }
329351
352+static int stm32_adfsdm_remove(struct platform_device *pdev)
353+{
354+ snd_soc_unregister_component(&pdev->dev);
355+
356+ return 0;
357+}
358+
330359 static struct platform_driver stm32_adfsdm_driver = {
331360 .driver = {
332361 .name = STM32_ADFSDM_DRV_NAME,
333362 .of_match_table = stm32_adfsdm_of_match,
334363 },
335364 .probe = stm32_adfsdm_probe,
365+ .remove = stm32_adfsdm_remove,
336366 };
337367
338368 module_platform_driver(stm32_adfsdm_driver);
sound/soc/stm/stm32_i2s.c+1−2
@@ -281,7 +281,6 @@ static bool stm32_i2s_readable_reg(struct device *dev, unsigned int reg) · 280 unmodified lines
281281 case STM32_I2S_CFG2_REG:
282282 case STM32_I2S_IER_REG:
283283 case STM32_I2S_SR_REG:
284− case STM32_I2S_TXDR_REG:
285284 case STM32_I2S_RXDR_REG:
286285 case STM32_I2S_CGFR_REG:
287286 return true;
@@ -293,7 +292,7 @@ static bool stm32_i2s_readable_reg(struct device *dev, unsigned int reg) · 5 unmodified lines
293292 static bool stm32_i2s_volatile_reg(struct device *dev, unsigned int reg)
294293 {
295294 switch (reg) {
296− case STM32_I2S_TXDR_REG:
295+ case STM32_I2S_SR_REG:
297296 case STM32_I2S_RXDR_REG:
298297 return true;
299298 default:
sound/soc/stm/stm32_sai.c+5−3
@@ -105,6 +105,7 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client, · 104 unmodified lines
105105 if (!pdev) {
106106 dev_err(&sai_client->pdev->dev,
107107 "Device not found for node %pOFn\n", np_provider);
108+ of_node_put(np_provider);
108109 return -ENODEV;
109110 }
110111
@@ -113,19 +114,20 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client, · 2 unmodified lines
113114 dev_err(&sai_client->pdev->dev,
114115 "SAI sync provider data not found\n");
115116 ret = -EINVAL;
116− goto out_put_dev;
117+ goto error;
117118 }
118119
119120 /* Configure sync client */
120121 ret = stm32_sai_sync_conf_client(sai_client, synci);
121122 if (ret < 0)
122− goto out_put_dev;
123+ goto error;
123124
124125 /* Configure sync provider */
125126 ret = stm32_sai_sync_conf_provider(sai_provider, synco);
126127
127−out_put_dev:
128+error:
128129 put_device(&pdev->dev);
130+ of_node_put(np_provider);
129131 return ret;
130132 }
131133
sound/soc/stm/stm32_sai_sub.c+86−28
@@ -70,6 +70,7 @@ · 69 unmodified lines
7070 #define SAI_IEC60958_STATUS_BYTES 24
7171
7272 #define SAI_MCLK_NAME_LEN 32
73+#define SAI_RATE_11K 11025
7374
7475 /**
7576 * struct stm32_sai_sub_data - private data of SAI sub block (block A or B)
@@ -100,8 +101,9 @@ · 24 unmodified lines
100101 * @slot_mask: rx or tx active slots mask. set at init or at runtime
101102 * @data_size: PCM data width. corresponds to PCM substream width.
102103 * @spdif_frm_cnt: S/PDIF playback frame counter
103− * @snd_aes_iec958: iec958 data
104+ * @iec958: iec958 data
104105 * @ctrl_lock: control lock
106+ * @irq_lock: prevent race condition with IRQ
105107 */
106108 struct stm32_sai_sub_data {
107109 struct platform_device *pdev;
@@ -133,6 +135,7 @@ struct stm32_sai_sub_data { · 25 unmodified lines
133135 unsigned int spdif_frm_cnt;
134136 struct snd_aes_iec958 iec958;
135137 struct mutex ctrl_lock; /* protect resources accessed by controls */
138+ spinlock_t irq_lock; /* used to prevent race condition with IRQ */
136139 };
137140
138141 enum stm32_sai_fifo_th {
@@ -307,6 +310,25 @@ static int stm32_sai_set_clk_div(struct stm32_sai_sub_data *sai, · 168 unmodified lines
307310 return ret;
308311 }
309312
313+static int stm32_sai_set_parent_clock(struct stm32_sai_sub_data *sai,
314+ unsigned int rate)
315+{
316+ struct platform_device *pdev = sai->pdev;
317+ struct clk *parent_clk = sai->pdata->clk_x8k;
318+ int ret;
319+
320+ if (!(rate % SAI_RATE_11K))
321+ parent_clk = sai->pdata->clk_x11k;
322+
323+ ret = clk_set_parent(sai->sai_ck, parent_clk);
324+ if (ret)
325+ dev_err(&pdev->dev, " Error %d setting sai_ck parent clock. %s",
326+ ret, ret == -EBUSY ?
327+ "Active stream rates conflict\n" : "\n");
328+
329+ return ret;
330+}
331+
310332 static long stm32_sai_mclk_round_rate(struct clk_hw *hw, unsigned long rate,
311333 unsigned long *prate)
312334 {
@@ -474,8 +496,10 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid) · 161 unmodified lines
474496 status = SNDRV_PCM_STATE_XRUN;
475497 }
476498
477− if (status != SNDRV_PCM_STATE_RUNNING)
499+ spin_lock(&sai->irq_lock);
500+ if (status != SNDRV_PCM_STATE_RUNNING && sai->substream)
478501 snd_pcm_stop_xrun(sai->substream);
502+ spin_unlock(&sai->irq_lock);
479503
480504 return IRQ_HANDLED;
481505 }
@@ -486,25 +510,29 @@ static int stm32_sai_set_sysclk(struct snd_soc_dai *cpu_dai, · 4 unmodified lines
486510 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
487511 int ret;
488512
489− if (dir == SND_SOC_CLOCK_OUT) {
513+ if (dir == SND_SOC_CLOCK_OUT && sai->sai_mclk) {
490514 ret = regmap_update_bits(sai->regmap, STM_SAI_CR1_REGX,
491515 SAI_XCR1_NODIV,
492516 (unsigned int)~SAI_XCR1_NODIV);
493517 if (ret < 0)
494518 return ret;
495519
496− dev_dbg(cpu_dai->dev, "SAI MCLK frequency is %uHz\n", freq);
497− sai->mclk_rate = freq;
520+ /* If master clock is used, set parent clock now */
521+ ret = stm32_sai_set_parent_clock(sai, freq);
522+ if (ret)
523+ return ret;
498524
499− if (sai->sai_mclk) {
500− ret = clk_set_rate_exclusive(sai->sai_mclk,
501− sai->mclk_rate);
502− if (ret) {
503− dev_err(cpu_dai->dev,
504− "Could not set mclk rate\n");
505− return ret;
506− }
525+ ret = clk_set_rate_exclusive(sai->sai_mclk, freq);
526+ if (ret) {
527+ dev_err(cpu_dai->dev,
528+ ret == -EBUSY ?
529+ "Active streams have incompatible rates" :
530+ "Could not set mclk rate\n");
531+ return ret;
507532 }
533+
534+ dev_dbg(cpu_dai->dev, "SAI MCLK frequency is %uHz\n", freq);
535+ sai->mclk_rate = freq;
508536 }
509537
510538 return 0;
@@ -679,8 +707,19 @@ static int stm32_sai_startup(struct snd_pcm_substream *substream, · 168 unmodified lines
679707 {
680708 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
681709 int imr, cr2, ret;
710+ unsigned long flags;
682711
712+ spin_lock_irqsave(&sai->irq_lock, flags);
683713 sai->substream = substream;
714+ spin_unlock_irqrestore(&sai->irq_lock, flags);
715+
716+ if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) {
717+ snd_pcm_hw_constraint_mask64(substream->runtime,
718+ SNDRV_PCM_HW_PARAM_FORMAT,
719+ SNDRV_PCM_FMTBIT_S32_LE);
720+ snd_pcm_hw_constraint_single(substream->runtime,
721+ SNDRV_PCM_HW_PARAM_CHANNELS, 2);
722+ }
684723
685724 ret = clk_prepare_enable(sai->sai_ck);
686725 if (ret < 0) {
@@ -898,14 +937,16 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai, · 211 unmodified lines
898937 struct snd_pcm_hw_params *params)
899938 {
900939 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
901− int div = 0;
940+ int div = 0, cr1 = 0;
902941 int sai_clk_rate, mclk_ratio, den;
903942 unsigned int rate = params_rate(params);
943+ int ret;
904944
905− if (!(rate % 11025))
906− clk_set_parent(sai->sai_ck, sai->pdata->clk_x11k);
907− else
908− clk_set_parent(sai->sai_ck, sai->pdata->clk_x8k);
945+ if (!sai->sai_mclk) {
946+ ret = stm32_sai_set_parent_clock(sai, rate);
947+ if (ret)
948+ return ret;
949+ }
909950 sai_clk_rate = clk_get_rate(sai->sai_ck);
910951
911952 if (STM_SAI_IS_F4(sai->pdata)) {
@@ -943,13 +984,19 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai, · 31 unmodified lines
943984 } else {
944985 if (sai->mclk_rate) {
945986 mclk_ratio = sai->mclk_rate / rate;
946− if ((mclk_ratio != 512) &&
947− (mclk_ratio != 256)) {
987+ if (mclk_ratio == 512) {
988+ cr1 = SAI_XCR1_OSR;
989+ } else if (mclk_ratio != 256) {
948990 dev_err(cpu_dai->dev,
949991 "Wrong mclk ratio %d\n",
950992 mclk_ratio);
951993 return -EINVAL;
952994 }
995+
996+ regmap_update_bits(sai->regmap,
997+ STM_SAI_CR1_REGX,
998+ SAI_XCR1_OSR, cr1);
999+
9531000 div = stm32_sai_get_clk_div(sai, sai_clk_rate,
9541001 sai->mclk_rate);
9551002 if (div < 0)
@@ -1051,28 +1098,36 @@ static void stm32_sai_shutdown(struct snd_pcm_substream *substream, · 95 unmodified lines
10511098 struct snd_soc_dai *cpu_dai)
10521099 {
10531100 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
1101+ unsigned long flags;
10541102
10551103 regmap_update_bits(sai->regmap, STM_SAI_IMR_REGX, SAI_XIMR_MASK, 0);
10561104
10571105 regmap_update_bits(sai->regmap, STM_SAI_CR1_REGX, SAI_XCR1_NODIV,
10581106 SAI_XCR1_NODIV);
10591107
1060− clk_disable_unprepare(sai->sai_ck);
1108+ /* Release mclk rate only if rate was actually set */
1109+ if (sai->mclk_rate) {
1110+ clk_rate_exclusive_put(sai->sai_mclk);
1111+ sai->mclk_rate = 0;
1112+ }
10611113
1062− clk_rate_exclusive_put(sai->sai_mclk);
1114+ clk_disable_unprepare(sai->sai_ck);
10631115
1116+ spin_lock_irqsave(&sai->irq_lock, flags);
10641117 sai->substream = NULL;
1118+ spin_unlock_irqrestore(&sai->irq_lock, flags);
10651119 }
10661120
10671121 static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd,
10681122 struct snd_soc_dai *cpu_dai)
10691123 {
10701124 struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev);
1125+ struct snd_kcontrol_new knew = iec958_ctls;
10711126
10721127 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) {
10731128 dev_dbg(&sai->pdev->dev, "%s: register iec controls", __func__);
1074− return snd_ctl_add(rtd->pcm->card,
1075− snd_ctl_new1(&iec958_ctls, sai));
1129+ knew.device = rtd->pcm->device;
1130+ return snd_ctl_add(rtd->pcm->card, snd_ctl_new1(&knew, sai));
10761131 }
10771132
10781133 return 0;
@@ -1081,7 +1136,7 @@ static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd, · 2 unmodified lines
10811136 static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai)
10821137 {
10831138 struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev);
1084− int cr1 = 0, cr1_mask;
1139+ int cr1 = 0, cr1_mask, ret;
10851140
10861141 sai->cpu_dai = cpu_dai;
10871142
@@ -1111,8 +1166,10 @@ static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai) · 23 unmodified lines
11111166 /* Configure synchronization */
11121167 if (sai->sync == SAI_SYNC_EXTERNAL) {
11131168 /* Configure synchro client and provider */
1114− sai->pdata->set_sync(sai->pdata, sai->np_sync_provider,
1115− sai->synco, sai->synci);
1169+ ret = sai->pdata->set_sync(sai->pdata, sai->np_sync_provider,
1170+ sai->synco, sai->synci);
1171+ if (ret)
1172+ return ret;
11161173 }
11171174
11181175 cr1_mask |= SAI_XCR1_SYNCEN_MASK;
@@ -1392,7 +1449,6 @@ static int stm32_sai_sub_dais_init(struct platform_device *pdev, · 273 unmodified lines
13921449 if (!sai->cpu_dai_drv)
13931450 return -ENOMEM;
13941451
1395− sai->cpu_dai_drv->name = dev_name(&pdev->dev);
13961452 if (STM_SAI_IS_PLAYBACK(sai)) {
13971453 memcpy(sai->cpu_dai_drv, &stm32_sai_playback_dai,
13981454 sizeof(stm32_sai_playback_dai));
@@ -1402,6 +1458,7 @@ static int stm32_sai_sub_dais_init(struct platform_device *pdev, · 3 unmodified lines
14021458 sizeof(stm32_sai_capture_dai));
14031459 sai->cpu_dai_drv->capture.stream_name = sai->cpu_dai_drv->name;
14041460 }
1461+ sai->cpu_dai_drv->name = dev_name(&pdev->dev);
14051462
14061463 return 0;
14071464 }
@@ -1424,6 +1481,7 @@ static int stm32_sai_sub_probe(struct platform_device *pdev) · 16 unmodified lines
14241481
14251482 sai->pdev = pdev;
14261483 mutex_init(&sai->ctrl_lock);
1484+ spin_lock_init(&sai->irq_lock);
14271485 platform_set_drvdata(pdev, sai);
14281486
14291487 sai->pdata = dev_get_drvdata(pdev->dev.parent);
sound/xen/xen_snd_front_alsa.c+1−1
@@ -441,7 +441,7 @@ static int shbuf_setup_backstore(struct xen_snd_front_pcm_stream_info *stream, · 440 unmodified lines
441441 {
442442 int i;
443443
444− stream->buffer = alloc_pages_exact(stream->buffer_sz, GFP_KERNEL);
444+ stream->buffer = alloc_pages_exact(buffer_sz, GFP_KERNEL);
445445 if (!stream->buffer)
446446 return -ENOMEM;
447447
tools/io_uring/io_uring-bench.c+4−28
@@ -32,10 +32,6 @@ · 31 unmodified lines
3232 #include "liburing.h"
3333 #include "barrier.h"
3434
35−#ifndef IOCQE_FLAG_CACHEHIT
36−#define IOCQE_FLAG_CACHEHIT (1U << 0)
37−#endif
38−
3935 #define min(a, b) ((a < b) ? (a) : (b))
4036
4137 struct io_sq_ring {
@@ -85,7 +81,6 @@ struct submitter { · 43 unmodified lines
8581 unsigned long reaps;
8682 unsigned long done;
8783 unsigned long calls;
88− unsigned long cachehit, cachemiss;
8984 volatile int finish;
9085
9186 __s32 *fds;
@@ -270,10 +265,6 @@ static int reap_events(struct submitter *s) · 178 unmodified lines
270265 return -1;
271266 }
272267 }
273− if (cqe->flags & IOCQE_FLAG_CACHEHIT)
274− s->cachehit++;
275− else
276− s->cachemiss++;
277268 reaped++;
278269 head++;
279270 } while (1);
@@ -489,7 +480,7 @@ static void file_depths(char *buf) · 209 unmodified lines
489480 int main(int argc, char *argv[])
490481 {
491482 struct submitter *s = &submitters[0];
492− unsigned long done, calls, reap, cache_hit, cache_miss;
483+ unsigned long done, calls, reap;
493484 int err, i, flags, fd;
494485 char *fdepths;
495486 void *ret;
@@ -569,44 +560,29 @@ int main(int argc, char *argv[]) · 73 unmodified lines
569560 pthread_create(&s->thread, NULL, submitter_fn, s);
570561
571562 fdepths = malloc(8 * s->nr_files);
572− cache_hit = cache_miss = reap = calls = done = 0;
563+ reap = calls = done = 0;
573564 do {
574565 unsigned long this_done = 0;
575566 unsigned long this_reap = 0;
576567 unsigned long this_call = 0;
577− unsigned long this_cache_hit = 0;
578− unsigned long this_cache_miss = 0;
579568 unsigned long rpc = 0, ipc = 0;
580− double hit = 0.0;
581569
582570 sleep(1);
583571 this_done += s->done;
584572 this_call += s->calls;
585573 this_reap += s->reaps;
586− this_cache_hit += s->cachehit;
587− this_cache_miss += s->cachemiss;
588− if (this_cache_hit && this_cache_miss) {
589− unsigned long hits, total;
590−
591− hits = this_cache_hit - cache_hit;
592− total = hits + this_cache_miss - cache_miss;
593− hit = (double) hits / (double) total;
594− hit *= 100.0;
595− }
596574 if (this_call - calls) {
597575 rpc = (this_done - done) / (this_call - calls);
598576 ipc = (this_reap - reap) / (this_call - calls);
599577 } else
600578 rpc = ipc = -1;
601579 file_depths(fdepths);
602− printf("IOPS=%lu, IOS/call=%ld/%ld, inflight=%u (%s), Cachehit=%0.2f%%\n",
580+ printf("IOPS=%lu, IOS/call=%ld/%ld, inflight=%u (%s)\n",
603581 this_done - done, rpc, ipc, s->inflight,
604− fdepths, hit);
582+ fdepths);
605583 done = this_done;
606584 calls = this_call;
607585 reap = this_reap;
608− cache_hit = s->cachehit;
609− cache_miss = s->cachemiss;
610586 } while (!finish);
611587
612588 pthread_join(s->thread, &ret);
tools/objtool/check.c+1−0
@@ -165,6 +165,7 @@ static int __dead_end_function(struct objtool_file *file, struct symbol *func, · 164 unmodified lines
165165 "fortify_panic",
166166 "usercopy_abort",
167167 "machine_real_restart",
168+ "rewind_stack_do_exit",
168169 };
169170
170171 if (func->bind == STB_WEAK)
tools/testing/nvdimm/test/nfit.c+13−4
@@ -146,6 +146,7 @@ static int dimm_fail_cmd_code[ARRAY_SIZE(handle)]; · 145 unmodified lines
146146 struct nfit_test_sec {
147147 u8 state;
148148 u8 ext_state;
149+ u8 old_state;
149150 u8 passphrase[32];
150151 u8 master_passphrase[32];
151152 u64 overwrite_end_time;
@@ -225,6 +226,8 @@ static struct workqueue_struct *nfit_wq; · 73 unmodified lines
225226
226227 static struct gen_pool *nfit_pool;
227228
229+static const char zero_key[NVDIMM_PASSPHRASE_LEN];
230+
228231 static struct nfit_test *to_nfit_test(struct device *dev)
229232 {
230233 struct platform_device *pdev = to_platform_device(dev);
@@ -1059,8 +1062,7 @@ static int nd_intel_test_cmd_secure_erase(struct nfit_test *t, · 828 unmodified lines
10591062 struct device *dev = &t->pdev.dev;
10601063 struct nfit_test_sec *sec = &dimm_sec_info[dimm];
10611064
1062− if (!(sec->state & ND_INTEL_SEC_STATE_ENABLED) ||
1063− (sec->state & ND_INTEL_SEC_STATE_FROZEN)) {
1065+ if (sec->state & ND_INTEL_SEC_STATE_FROZEN) {
10641066 nd_cmd->status = ND_INTEL_STATUS_INVALID_STATE;
10651067 dev_dbg(dev, "secure erase: wrong security state\n");
10661068 } else if (memcmp(nd_cmd->passphrase, sec->passphrase,
@@ -1068,6 +1070,12 @@ static int nd_intel_test_cmd_secure_erase(struct nfit_test *t, · 1 unmodified line
10681070 nd_cmd->status = ND_INTEL_STATUS_INVALID_PASS;
10691071 dev_dbg(dev, "secure erase: wrong passphrase\n");
10701072 } else {
1073+ if (!(sec->state & ND_INTEL_SEC_STATE_ENABLED)
1074+ && (memcmp(nd_cmd->passphrase, zero_key,
1075+ ND_INTEL_PASSPHRASE_SIZE) != 0)) {
1076+ dev_dbg(dev, "invalid zero key\n");
1077+ return 0;
1078+ }
10711079 memset(sec->passphrase, 0, ND_INTEL_PASSPHRASE_SIZE);
10721080 memset(sec->master_passphrase, 0, ND_INTEL_PASSPHRASE_SIZE);
10731081 sec->state = 0;
@@ -1093,7 +1101,7 @@ static int nd_intel_test_cmd_overwrite(struct nfit_test *t, · 19 unmodified lines
10931101 return 0;
10941102 }
10951103
1096− memset(sec->passphrase, 0, ND_INTEL_PASSPHRASE_SIZE);
1104+ sec->old_state = sec->state;
10971105 sec->state = ND_INTEL_SEC_STATE_OVERWRITE;
10981106 dev_dbg(dev, "overwrite progressing.\n");
10991107 sec->overwrite_end_time = get_jiffies_64() + 5 * HZ;
@@ -1115,7 +1123,8 @@ static int nd_intel_test_cmd_query_overwrite(struct nfit_test *t, · 15 unmodified lines
11151123
11161124 if (time_is_before_jiffies64(sec->overwrite_end_time)) {
11171125 sec->overwrite_end_time = 0;
1118− sec->state = 0;
1126+ sec->state = sec->old_state;
1127+ sec->old_state = 0;
11191128 sec->ext_state = ND_INTEL_SEC_ESTATE_ENABLED;
11201129 dev_dbg(dev, "overwrite is complete\n");
11211130 } else
tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh+20−0
@@ -11,6 +11,7 @@ lib_dir=$(dirname $0)/../../../net/forwarding · 10 unmodified lines
1111
1212 ALL_TESTS="
1313 rif_set_addr_test
14+ rif_vrf_set_addr_test
1415 rif_inherit_bridge_addr_test
1516 rif_non_inherit_bridge_addr_test
1617 vlan_interface_deletion_test
@@ -99,6 +100,25 @@ rif_set_addr_test() · 82 unmodified lines
99100 ip link set dev $swp1 addr $swp1_mac
100101 }
101102
103+rif_vrf_set_addr_test()
104+{
105+ # Test that it is possible to set an IP address on a VRF upper despite
106+ # its random MAC address.
107+ RET=0
108+
109+ ip link add name vrf-test type vrf table 10
110+ ip link set dev $swp1 master vrf-test
111+
112+ ip -4 address add 192.0.2.1/24 dev vrf-test
113+ check_err $? "failed to set IPv4 address on VRF"
114+ ip -6 address add 2001:db8:1::1/64 dev vrf-test
115+ check_err $? "failed to set IPv6 address on VRF"
116+
117+ log_test "RIF - setting IP address on VRF"
118+
119+ ip link del dev vrf-test
120+}
121+
102122 rif_inherit_bridge_addr_test()
103123 {
104124 RET=0
tools/testing/selftests/kvm/Makefile+8−1
@@ -1,3 +1,5 @@
1+include ../../../../scripts/Kbuild.include
2+
13 all:
24
35 top_srcdir = ../../../..
@@ -17,6 +19,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/state_test · 13 unmodified lines
1719 TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test
1820 TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid
1921 TEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test
22+TEST_GEN_PROGS_x86_64 += x86_64/smm_test
2023 TEST_GEN_PROGS_x86_64 += dirty_log_test
2124 TEST_GEN_PROGS_x86_64 += clear_dirty_log_test
2225
@@ -30,7 +33,11 @@ INSTALL_HDR_PATH = $(top_srcdir)/usr · 7 unmodified lines
3033 LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
3134 LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
3235 CFLAGS += -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I..
33−LDFLAGS += -pthread -no-pie
36+
37+no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
38+ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
39+
40+LDFLAGS += -pthread $(no-pie-option)
3441
3542 # After inclusion, $(OUTPUT) is defined and
3643 # $(TEST_GEN_PROGS) starts with $(OUTPUT)/
tools/testing/selftests/kvm/include/x86_64/processor.h+27−0
@@ -778,6 +778,33 @@ void vcpu_set_msr(struct kvm_vm *vm, uint32_t vcpuid, uint64_t msr_index, · 777 unmodified lines
778778 #define MSR_IA32_APICBASE_ENABLE (1<<11)
779779 #define MSR_IA32_APICBASE_BASE (0xfffff<<12)
780780
781+#define APIC_BASE_MSR 0x800
782+#define X2APIC_ENABLE (1UL << 10)
783+#define APIC_ICR 0x300
784+#define APIC_DEST_SELF 0x40000
785+#define APIC_DEST_ALLINC 0x80000
786+#define APIC_DEST_ALLBUT 0xC0000
787+#define APIC_ICR_RR_MASK 0x30000
788+#define APIC_ICR_RR_INVALID 0x00000
789+#define APIC_ICR_RR_INPROG 0x10000
790+#define APIC_ICR_RR_VALID 0x20000
791+#define APIC_INT_LEVELTRIG 0x08000
792+#define APIC_INT_ASSERT 0x04000
793+#define APIC_ICR_BUSY 0x01000
794+#define APIC_DEST_LOGICAL 0x00800
795+#define APIC_DEST_PHYSICAL 0x00000
796+#define APIC_DM_FIXED 0x00000
797+#define APIC_DM_FIXED_MASK 0x00700
798+#define APIC_DM_LOWEST 0x00100
799+#define APIC_DM_SMI 0x00200
800+#define APIC_DM_REMRD 0x00300
801+#define APIC_DM_NMI 0x00400
802+#define APIC_DM_INIT 0x00500
803+#define APIC_DM_STARTUP 0x00600
804+#define APIC_DM_EXTINT 0x00700
805+#define APIC_VECTOR_MASK 0x000FF
806+#define APIC_ICR2 0x310
807+
781808 #define MSR_IA32_TSCDEADLINE 0x000006e0
782809
783810 #define MSR_IA32_UCODE_WRITE 0x00000079
tools/testing/selftests/kvm/lib/kvm_util.c+5−0
@@ -91,6 +91,11 @@ static void vm_open(struct kvm_vm *vm, int perm, unsigned long type) · 90 unmodified lines
9191 if (vm->kvm_fd < 0)
9292 exit(KSFT_SKIP);
9393
94+ if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) {
95+ fprintf(stderr, "immediate_exit not available, skipping test\n");
96+ exit(KSFT_SKIP);
97+ }
98+
9499 vm->fd = ioctl(vm->kvm_fd, KVM_CREATE_VM, type);
95100 TEST_ASSERT(vm->fd >= 0, "KVM_CREATE_VM ioctl failed, "
96101 "rc: %i errno: %i", vm->fd, errno);
tools/testing/selftests/kvm/lib/x86_64/processor.c+14−6
@@ -1030,6 +1030,14 @@ struct kvm_x86_state *vcpu_save_state(struct kvm_vm *vm, uint32_t vcpuid) · 1029 unmodified lines
10301030 nested_size, sizeof(state->nested_));
10311031 }
10321032
1033+ /*
1034+ * When KVM exits to userspace with KVM_EXIT_IO, KVM guarantees
1035+ * guest state is consistent only after userspace re-enters the
1036+ * kernel with KVM_RUN. Complete IO prior to migrating state
1037+ * to a new VM.
1038+ */
1039+ vcpu_run_complete_io(vm, vcpuid);
1040+
10331041 nmsrs = kvm_get_num_msrs(vm);
10341042 list = malloc(sizeof(*list) + nmsrs * sizeof(list->indices[0]));
10351043 list->nmsrs = nmsrs;
@@ -1093,12 +1101,6 @@ void vcpu_load_state(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_x86_state *s · 57 unmodified lines
10931101 struct vcpu *vcpu = vcpu_find(vm, vcpuid);
10941102 int r;
10951103
1096− if (state->nested.size) {
1097− r = ioctl(vcpu->fd, KVM_SET_NESTED_STATE, &state->nested);
1098− TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_NESTED_STATE, r: %i",
1099− r);
1100− }
1101−
11021104 r = ioctl(vcpu->fd, KVM_SET_XSAVE, &state->xsave);
11031105 TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XSAVE, r: %i",
11041106 r);
@@ -1130,4 +1132,10 @@ void vcpu_load_state(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_x86_state *s · 25 unmodified lines
11301132 r = ioctl(vcpu->fd, KVM_SET_REGS, &state->regs);
11311133 TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_REGS, r: %i",
11321134 r);
1135+
1136+ if (state->nested.size) {
1137+ r = ioctl(vcpu->fd, KVM_SET_NESTED_STATE, &state->nested);
1138+ TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_NESTED_STATE, r: %i",
1139+ r);
1140+ }
11331141 }
tools/testing/selftests/kvm/x86_64/evmcs_test.c+3−2
@@ -123,8 +123,6 @@ int main(int argc, char *argv[]) · 122 unmodified lines
123123 stage, run->exit_reason,
124124 exit_reason_str(run->exit_reason));
125125
126− memset(&regs1, 0, sizeof(regs1));
127− vcpu_regs_get(vm, VCPU_ID, &regs1);
128126 switch (get_ucall(vm, VCPU_ID, &uc)) {
129127 case UCALL_ABORT:
130128 TEST_ASSERT(false, "%s at %s:%d", (const char *)uc.args[0],
@@ -144,6 +142,9 @@ int main(int argc, char *argv[]) · 13 unmodified lines
144142 stage, (ulong)uc.args[1]);
145143
146144 state = vcpu_save_state(vm, VCPU_ID);
145+ memset(&regs1, 0, sizeof(regs1));
146+ vcpu_regs_get(vm, VCPU_ID, &regs1);
147+
147148 kvm_vm_release(vm);
148149
149150 /* Restore state in a new VM. */
tools/testing/selftests/kvm/x86_64/smm_test.c+157−0
@@ -0,0 +1,157 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright (C) 2018, Red Hat, Inc.
4+ *
5+ * Tests for SMM.
6+ */
7+#define _GNU_SOURCE /* for program_invocation_short_name */
8+#include <fcntl.h>
9+#include <stdio.h>
10+#include <stdlib.h>
11+#include <stdint.h>
12+#include <string.h>
13+#include <sys/ioctl.h>
14+
15+#include "test_util.h"
16+
17+#include "kvm_util.h"
18+
19+#include "vmx.h"
20+
21+#define VCPU_ID 1
22+
23+#define PAGE_SIZE 4096
24+
25+#define SMRAM_SIZE 65536
26+#define SMRAM_MEMSLOT ((1 << 16) | 1)
27+#define SMRAM_PAGES (SMRAM_SIZE / PAGE_SIZE)
28+#define SMRAM_GPA 0x1000000
29+#define SMRAM_STAGE 0xfe
30+
31+#define STR(x) #x
32+#define XSTR(s) STR(s)
33+
34+#define SYNC_PORT 0xe
35+#define DONE 0xff
36+
37+/*
38+ * This is compiled as normal 64-bit code, however, SMI handler is executed
39+ * in real-address mode. To stay simple we're limiting ourselves to a mode
40+ * independent subset of asm here.
41+ * SMI handler always report back fixed stage SMRAM_STAGE.
42+ */
43+uint8_t smi_handler[] = {
44+ 0xb0, SMRAM_STAGE, /* mov $SMRAM_STAGE, %al */
45+ 0xe4, SYNC_PORT, /* in $SYNC_PORT, %al */
46+ 0x0f, 0xaa, /* rsm */
47+};
48+
49+void sync_with_host(uint64_t phase)
50+{
51+ asm volatile("in $" XSTR(SYNC_PORT)", %%al \n"
52+ : : "a" (phase));
53+}
54+
55+void self_smi(void)
56+{
57+ wrmsr(APIC_BASE_MSR + (APIC_ICR >> 4),
58+ APIC_DEST_SELF | APIC_INT_ASSERT | APIC_DM_SMI);
59+}
60+
61+void guest_code(struct vmx_pages *vmx_pages)
62+{
63+ uint64_t apicbase = rdmsr(MSR_IA32_APICBASE);
64+
65+ sync_with_host(1);
66+
67+ wrmsr(MSR_IA32_APICBASE, apicbase | X2APIC_ENABLE);
68+
69+ sync_with_host(2);
70+
71+ self_smi();
72+
73+ sync_with_host(4);
74+
75+ if (vmx_pages) {
76+ GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
77+
78+ sync_with_host(5);
79+
80+ self_smi();
81+
82+ sync_with_host(7);
83+ }
84+
85+ sync_with_host(DONE);
86+}
87+
88+int main(int argc, char *argv[])
89+{
90+ struct vmx_pages *vmx_pages = NULL;
91+ vm_vaddr_t vmx_pages_gva = 0;
92+
93+ struct kvm_regs regs;
94+ struct kvm_vm *vm;
95+ struct kvm_run *run;
96+ struct kvm_x86_state *state;
97+ int stage, stage_reported;
98+
99+ /* Create VM */
100+ vm = vm_create_default(VCPU_ID, 0, guest_code);
101+
102+ vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
103+
104+ run = vcpu_state(vm, VCPU_ID);
105+
106+ vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, SMRAM_GPA,
107+ SMRAM_MEMSLOT, SMRAM_PAGES, 0);
108+ TEST_ASSERT(vm_phy_pages_alloc(vm, SMRAM_PAGES, SMRAM_GPA, SMRAM_MEMSLOT)
109+ == SMRAM_GPA, "could not allocate guest physical addresses?");
110+
111+ memset(addr_gpa2hva(vm, SMRAM_GPA), 0x0, SMRAM_SIZE);
112+ memcpy(addr_gpa2hva(vm, SMRAM_GPA) + 0x8000, smi_handler,
113+ sizeof(smi_handler));
114+
115+ vcpu_set_msr(vm, VCPU_ID, MSR_IA32_SMBASE, SMRAM_GPA);
116+
117+ if (kvm_check_cap(KVM_CAP_NESTED_STATE)) {
118+ vmx_pages = vcpu_alloc_vmx(vm, &vmx_pages_gva);
119+ vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva);
120+ } else {
121+ printf("will skip SMM test with VMX enabled\n");
122+ vcpu_args_set(vm, VCPU_ID, 1, 0);
123+ }
124+
125+ for (stage = 1;; stage++) {
126+ _vcpu_run(vm, VCPU_ID);
127+ TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
128+ "Stage %d: unexpected exit reason: %u (%s),\n",
129+ stage, run->exit_reason,
130+ exit_reason_str(run->exit_reason));
131+
132+ memset(&regs, 0, sizeof(regs));
133+ vcpu_regs_get(vm, VCPU_ID, &regs);
134+
135+ stage_reported = regs.rax & 0xff;
136+
137+ if (stage_reported == DONE)
138+ goto done;
139+
140+ TEST_ASSERT(stage_reported == stage ||
141+ stage_reported == SMRAM_STAGE,
142+ "Unexpected stage: #%x, got %x",
143+ stage, stage_reported);
144+
145+ state = vcpu_save_state(vm, VCPU_ID);
146+ kvm_vm_release(vm);
147+ kvm_vm_restart(vm, O_RDWR);
148+ vm_vcpu_add(vm, VCPU_ID, 0, 0);
149+ vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
150+ vcpu_load_state(vm, VCPU_ID, state);
151+ run = vcpu_state(vm, VCPU_ID);
152+ free(state);
153+ }
154+
155+done:
156+ kvm_vm_free(vm);
157+}
tools/testing/selftests/kvm/x86_64/state_test.c+1−14
@@ -134,11 +134,6 @@ int main(int argc, char *argv[]) · 133 unmodified lines
134134
135135 struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);
136136
137− if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) {
138− fprintf(stderr, "immediate_exit not available, skipping test\n");
139− exit(KSFT_SKIP);
140− }
141−
142137 /* Create VM */
143138 vm = vm_create_default(VCPU_ID, 0, guest_code);
144139 vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
@@ -179,18 +174,10 @@ int main(int argc, char *argv[]) · 34 unmodified lines
179174 uc.args[1] == stage, "Unexpected register values vmexit #%lx, got %lx",
180175 stage, (ulong)uc.args[1]);
181176
182− /*
183− * When KVM exits to userspace with KVM_EXIT_IO, KVM guarantees
184− * guest state is consistent only after userspace re-enters the
185− * kernel with KVM_RUN. Complete IO prior to migrating state
186− * to a new VM.
187− */
188− vcpu_run_complete_io(vm, VCPU_ID);
189−
177+ state = vcpu_save_state(vm, VCPU_ID);
190178 memset(&regs1, 0, sizeof(regs1));
191179 vcpu_regs_get(vm, VCPU_ID, &regs1);
192180
193− state = vcpu_save_state(vm, VCPU_ID);
194181 kvm_vm_release(vm);
195182
196183 /* Restore state in a new VM. */
tools/testing/selftests/net/fib_tests.sh+40−54
@@ -607,6 +607,39 @@ run_cmd() · 606 unmodified lines
607607 return $rc
608608 }
609609
610+check_expected()
611+{
612+ local out="$1"
613+ local expected="$2"
614+ local rc=0
615+
616+ [ "${out}" = "${expected}" ] && return 0
617+
618+ if [ -z "${out}" ]; then
619+ if [ "$VERBOSE" = "1" ]; then
620+ printf "\nNo route entry found\n"
621+ printf "Expected:\n"
622+ printf " ${expected}\n"
623+ fi
624+ return 1
625+ fi
626+
627+ # tricky way to convert output to 1-line without ip's
628+ # messy '\'; this drops all extra white space
629+ out=$(echo ${out})
630+ if [ "${out}" != "${expected}" ]; then
631+ rc=1
632+ if [ "${VERBOSE}" = "1" ]; then
633+ printf " Unexpected route entry. Have:\n"
634+ printf " ${out}\n"
635+ printf " Expected:\n"
636+ printf " ${expected}\n\n"
637+ fi
638+ fi
639+
640+ return $rc
641+}
642+
610643 # add route for a prefix, flushing any existing routes first
611644 # expected to be the first step of a test
612645 add_route6()
@@ -654,31 +687,7 @@ check_route6() · 41 unmodified lines
654687 pfx=$1
655688
656689 out=$($IP -6 ro ls match ${pfx} | sed -e 's/ pref medium//')
657− [ "${out}" = "${expected}" ] && return 0
658−
659− if [ -z "${out}" ]; then
660− if [ "$VERBOSE" = "1" ]; then
661− printf "\nNo route entry found\n"
662− printf "Expected:\n"
663− printf " ${expected}\n"
664− fi
665− return 1
666− fi
667−
668− # tricky way to convert output to 1-line without ip's
669− # messy '\'; this drops all extra white space
670− out=$(echo ${out})
671− if [ "${out}" != "${expected}" ]; then
672− rc=1
673− if [ "${VERBOSE}" = "1" ]; then
674− printf " Unexpected route entry. Have:\n"
675− printf " ${out}\n"
676− printf " Expected:\n"
677− printf " ${expected}\n\n"
678− fi
679− fi
680−
681− return $rc
690+ check_expected "${out}" "${expected}"
682691 }
683692
684693 route_cleanup()
@@ -728,7 +737,7 @@ route_setup() · 43 unmodified lines
728737 ip -netns ns2 addr add 172.16.103.2/24 dev veth4
729738 ip -netns ns2 addr add 172.16.104.1/24 dev dummy1
730739
731− set +ex
740+ set +e
732741 }
733742
734743 # assumption is that basic add of a single path route works
@@ -963,7 +972,8 @@ ipv6_addr_metric_test() · 228 unmodified lines
963972 run_cmd "$IP li set dev dummy2 down"
964973 rc=$?
965974 if [ $rc -eq 0 ]; then
966− check_route6 ""
975+ out=$($IP -6 ro ls match 2001:db8:104::/64)
976+ check_expected "${out}" ""
967977 rc=$?
968978 fi
969979 log_test $rc 0 "Prefix route removed on link down"
@@ -1094,38 +1104,13 @@ check_route() · 124 unmodified lines
10941104 local pfx
10951105 local expected="$1"
10961106 local out
1097− local rc=0
10981107
10991108 set -- $expected
11001109 pfx=$1
11011110 [ "${pfx}" = "unreachable" ] && pfx=$2
11021111
11031112 out=$($IP ro ls match ${pfx})
1104− [ "${out}" = "${expected}" ] && return 0
1105−
1106− if [ -z "${out}" ]; then
1107− if [ "$VERBOSE" = "1" ]; then
1108− printf "\nNo route entry found\n"
1109− printf "Expected:\n"
1110− printf " ${expected}\n"
1111− fi
1112− return 1
1113− fi
1114−
1115− # tricky way to convert output to 1-line without ip's
1116− # messy '\'; this drops all extra white space
1117− out=$(echo ${out})
1118− if [ "${out}" != "${expected}" ]; then
1119− rc=1
1120− if [ "${VERBOSE}" = "1" ]; then
1121− printf " Unexpected route entry. Have:\n"
1122− printf " ${out}\n"
1123− printf " Expected:\n"
1124− printf " ${expected}\n\n"
1125− fi
1126− fi
1127−
1128− return $rc
1113+ check_expected "${out}" "${expected}"
11291114 }
11301115
11311116 # assumption is that basic add of a single path route works
@@ -1390,7 +1375,8 @@ ipv4_addr_metric_test() · 258 unmodified lines
13901375 run_cmd "$IP li set dev dummy2 down"
13911376 rc=$?
13921377 if [ $rc -eq 0 ]; then
1393− check_route ""
1378+ out=$($IP ro ls match 172.16.104.0/24)
1379+ check_expected "${out}" ""
13941380 rc=$?
13951381 fi
13961382 log_test $rc 0 "Prefix route removed on link down"
virt/kvm/irqchip.c+3−2
@@ -144,18 +144,19 @@ static int setup_routing_entry(struct kvm *kvm, · 143 unmodified lines
144144 {
145145 struct kvm_kernel_irq_routing_entry *ei;
146146 int r;
147+ u32 gsi = array_index_nospec(ue->gsi, KVM_MAX_IRQ_ROUTES);
147148
148149 /*
149150 * Do not allow GSI to be mapped to the same irqchip more than once.
150151 * Allow only one to one mapping between GSI and non-irqchip routing.
151152 */
152− hlist_for_each_entry(ei, &rt->map[ue->gsi], link)
153+ hlist_for_each_entry(ei, &rt->map[gsi], link)
153154 if (ei->type != KVM_IRQ_ROUTING_IRQCHIP ||
154155 ue->type != KVM_IRQ_ROUTING_IRQCHIP ||
155156 ue->u.irqchip.irqchip == ei->irqchip.irqchip)
156157 return -EINVAL;
157158
158− e->gsi = ue->gsi;
159+ e->gsi = gsi;
159160 e->type = ue->type;
160161 r = kvm_set_routing_entry(kvm, e, ue);
161162 if (r)
virt/kvm/kvm_main.c+4−2
@@ -2977,12 +2977,14 @@ static int kvm_ioctl_create_device(struct kvm *kvm, · 2976 unmodified lines
29772977 struct kvm_device_ops *ops = NULL;
29782978 struct kvm_device *dev;
29792979 bool test = cd->flags & KVM_CREATE_DEVICE_TEST;
2980+ int type;
29802981 int ret;
29812982
29822983 if (cd->type >= ARRAY_SIZE(kvm_device_ops_table))
29832984 return -ENODEV;
29842985
2985− ops = kvm_device_ops_table[cd->type];
2986+ type = array_index_nospec(cd->type, ARRAY_SIZE(kvm_device_ops_table));
2987+ ops = kvm_device_ops_table[type];
29862988 if (ops == NULL)
29872989 return -ENODEV;
29882990
@@ -2997,7 +2999,7 @@ static int kvm_ioctl_create_device(struct kvm *kvm, · 8 unmodified lines
29972999 dev->kvm = kvm;
29983000
29993001 mutex_lock(&kvm->lock);
3000− ret = ops->create(dev, cd->type);
3002+ ret = ops->create(dev, type);
30013003 if (ret < 0) {
30023004 mutex_unlock(&kvm->lock);
30033005 kfree(dev);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t