History

ASoC: Merge up fixes

Merge branch 'for-7.0' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-7.1 for both ASoC and general bug fixes to support testing.

Mark Brown committed 7 months ago

Commit 2a740dc2 parents 1e28cde 8ec017c403 files · +5213 −2083Browse files

Unified · Split

403 files
  1. .mailmap +2 −0
  2. Documentation/PCI/pcieaer-howto.rst +10 −0
  3. Documentation/core-api/dma-attributes.rst +30 −8
  4. Documentation/filesystems/overlayfs.rst +50 −0
  5. Documentation/hwmon/adm1177.rst +4 −4
  6. Documentation/hwmon/peci-cputemp.rst +6 −4
  7. Documentation/userspace-api/landlock.rst +19 −4
  8. MAINTAINERS +16 −7
  9. Makefile +2 −2
  10. arch/arm64/kvm/at.c +1 −1
  11. arch/arm64/kvm/reset.c +14 −0
  12. arch/loongarch/include/asm/linkage.h +36 −0
  13. arch/loongarch/include/asm/sigframe.h +9 −0
  14. arch/loongarch/kernel/asm-offsets.c +2 −0
  15. arch/loongarch/kernel/env.c +3 −4
  16. arch/loongarch/kernel/signal.c +1 −5
  17. arch/loongarch/kvm/intc/eiointc.c +8 −8
  18. arch/loongarch/kvm/vcpu.c +3 −0
  19. arch/loongarch/pci/pci.c +80 −0
  20. arch/loongarch/vdso/Makefile +2 −2
  21. arch/loongarch/vdso/sigreturn.S +3 −3
  22. arch/s390/include/asm/barrier.h +2 −2
  23. arch/s390/include/asm/kvm_host.h +3 −0
  24. arch/s390/include/asm/stacktrace.h +1 −1
  25. arch/s390/kernel/asm-offsets.c +1 −1
  26. arch/s390/kernel/entry.S +5 −2
  27. arch/s390/kernel/nmi.c +2 −2
  28. arch/s390/kernel/syscall.c +4 −1
  29. arch/s390/kvm/dat.c +15 −85
  30. arch/s390/kvm/dat.h +12 −11
  31. arch/s390/kvm/gaccess.c +55 −22
  32. arch/s390/kvm/gmap.c +114 −46
  33. arch/s390/kvm/gmap.h +21 −12
  34. arch/s390/kvm/interrupt.c +18 −0
  35. arch/s390/kvm/kvm-s390.c +23 −11
  36. arch/s390/kvm/vsie.c +8 −4
  37. arch/s390/mm/fault.c +9 −2
  38. arch/x86/coco/sev/noinstr.c +6 −0
  39. arch/x86/entry/entry_fred.c +14 −0
  40. arch/x86/kernel/cpu/common.c +26 −7
  41. arch/x86/kvm/mmu/mmu.c +10 −7
  42. arch/x86/platform/efi/quirks.c +1 −1
  43. drivers/accel/ivpu/ivpu_drv.h +1 −0
  44. drivers/accel/ivpu/ivpu_hw.c +4 −2
  45. drivers/acpi/ec.c +2 −0
  46. drivers/base/regmap/regmap.c +26 −4
  47. drivers/block/zram/zram_drv.c +14 −25
  48. drivers/bluetooth/btintel.c +8 −3
  49. drivers/bluetooth/btusb.c +4 −1
  50. drivers/bluetooth/hci_ll.c +2 −0
  51. drivers/cpufreq/cpufreq.c +3 −6
  52. drivers/cpufreq/cpufreq_conservative.c +12 −0
  53. drivers/cpufreq/cpufreq_governor.c +3 −0
  54. drivers/cpufreq/cpufreq_governor.h +1 −0
  55. drivers/cpufreq/freq_table.c +4 −0
  56. drivers/cxl/Kconfig +1 −0
  57. drivers/cxl/core/hdm.c +9 −16
  58. drivers/cxl/core/mbox.c +1 −1
  59. drivers/cxl/core/port.c +6 −2
  60. drivers/cxl/core/region.c +3 −1
  61. drivers/cxl/pmem.c +1 −1
  62. drivers/dma/dw-edma/dw-edma-core.c +6 −2
  63. drivers/dma/dw-edma/dw-hdma-v0-core.c +3 −3
  64. drivers/dma/fsl-edma-main.c +11 −15
  65. drivers/dma/idxd/cdev.c +4 −4
  66. drivers/dma/idxd/device.c +31 −14
  67. drivers/dma/idxd/dma.c +18 −0
  68. drivers/dma/idxd/idxd.h +1 −0
  69. drivers/dma/idxd/init.c +7 −7
  70. drivers/dma/idxd/irq.c +16 −0
  71. drivers/dma/idxd/submit.c +1 −1
  72. drivers/dma/idxd/sysfs.c +1 −0
  73. drivers/dma/sh/rz-dmac.c +36 −30
  74. drivers/dma/xilinx/xdma.c +2 −2
  75. drivers/dma/xilinx/xilinx_dma.c +30 −16
  76. drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 −2
  77. drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +11 −2
  78. drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +32 −13
  79. drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h +1 −0
  80. drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 −3
  81. drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +3 −3
  82. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 −2
  83. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +1 −0
  84. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +3 −1
  85. drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c +2 −4
  86. drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c +3 −2
  87. drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.c +3 −2
  88. drivers/gpu/drm/amd/display/dc/resource/dce120/dce120_resource.c +3 −2
  89. drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c +6 −8
  90. drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c +2 −4
  91. drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +32 −1
  92. drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +12 −9
  93. drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +32 −1
  94. drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c +32 −1
  95. drivers/gpu/drm/drm_gem_shmem_helper.c +28 −22
  96. drivers/gpu/drm/drm_syncobj.c +2 −2
  97. drivers/gpu/drm/i915/display/intel_display.c +7 −1
  98. drivers/gpu/drm/i915/display/intel_dp_tunnel.c +14 −6
  99. drivers/gpu/drm/i915/display/intel_dp_tunnel.h +7 −4
  100. drivers/gpu/drm/i915/display/intel_gmbus.c +3 −1
  101. drivers/gpu/drm/i915/display/intel_plane.c +9 −2
  102. drivers/gpu/drm/i915/i915_wait_util.h +1 −1
  103. drivers/gpu/drm/mediatek/mtk_dsi.c +5 −4
  104. drivers/gpu/drm/xe/regs/xe_gt_regs.h +1 −0
  105. drivers/gpu/drm/xe/xe_pt.c +6 −6
  106. drivers/gpu/drm/xe/xe_sriov_packet.c +2 −0
  107. drivers/gpu/drm/xe/xe_vm.c +18 −4
  108. drivers/gpu/drm/xe/xe_vm_types.h +4 −0
  109. drivers/gpu/drm/xe/xe_wa.c +2 −1
  110. drivers/hwmon/adm1177.c +31 −23
  111. drivers/hwmon/peci/cputemp.c +2 −2
  112. drivers/hwmon/pmbus/ina233.c +2 −1
  113. drivers/hwmon/pmbus/isl68137.c +18 −3
  114. drivers/hwmon/pmbus/pmbus_core.c +154 −38
  115. drivers/i2c/busses/i2c-designware-amdisp.c +5 −6
  116. drivers/i2c/busses/i2c-imx.c +32 −19
  117. drivers/infiniband/core/rw.c +27 −10
  118. drivers/infiniband/core/umem.c +3 −2
  119. drivers/infiniband/hw/bng_re/bng_dev.c +9 −5
  120. drivers/infiniband/hw/efa/efa_com.c +40 −48
  121. drivers/infiniband/hw/ionic/ionic_controlpath.c +3 −1
  122. drivers/infiniband/hw/irdma/cm.c +16 −13
  123. drivers/infiniband/hw/irdma/uk.c +22 −17
  124. drivers/infiniband/hw/irdma/utils.c +0 −2
  125. drivers/infiniband/hw/irdma/verbs.c +6 −4
  126. drivers/iommu/dma-iommu.c +17 −4
  127. drivers/irqchip/irq-qcom-mpm.c +3 −0
  128. drivers/irqchip/irq-renesas-rzv2h.c +1 −1
  129. drivers/media/i2c/ccs/ccs-core.c +0 −2
  130. drivers/media/mc/mc-request.c +5 −0
  131. drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c +4 −0
  132. drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c +27 −23
  133. drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2 −1
  134. drivers/media/platform/synopsys/Kconfig +1 −0
  135. drivers/media/platform/synopsys/dw-mipi-csi2rx.c +1 −1
  136. drivers/media/platform/verisilicon/imx8m_vpu_hw.c +1 −1
  137. drivers/media/usb/uvc/uvc_video.c +5 −4
  138. drivers/media/v4l2-core/v4l2-ioctl.c +3 −2
  139. drivers/net/can/dev/netlink.c +3 −1
  140. drivers/net/can/spi/mcp251x.c +24 −5
  141. drivers/net/ethernet/airoha/airoha_ppe.c +2 −0
  142. drivers/net/ethernet/broadcom/Kconfig +1 −1
  143. drivers/net/ethernet/broadcom/asp2/bcmasp.c +23 −18
  144. drivers/net/ethernet/cadence/macb_main.c +25 −16
  145. drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +2 −0
  146. drivers/net/ethernet/intel/iavf/iavf_ethtool.c +15 −16
  147. drivers/net/ethernet/intel/ice/ice.h +22 −0
  148. drivers/net/ethernet/intel/ice/ice_ethtool.c +11 −21
  149. drivers/net/ethernet/intel/ice/ice_main.c +2 −2
  150. drivers/net/ethernet/intel/ice/ice_repr.c +3 −2
  151. drivers/net/ethernet/intel/idpf/idpf.h +1 −1
  152. drivers/net/ethernet/intel/idpf/idpf_idc.c +4 −2
  153. drivers/net/ethernet/intel/idpf/idpf_txrx.c +1 −1
  154. drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +1 −1
  155. drivers/net/ethernet/microchip/lan743x_main.c +5 −0
  156. drivers/net/ethernet/microsoft/mana/mana_en.c +4 −2
  157. drivers/net/ethernet/pensando/ionic/ionic_lif.c +11 −6
  158. drivers/net/ethernet/ti/icssg/icssg_common.c +2 −2
  159. drivers/net/team/team_core.c +64 −1
  160. drivers/net/tun_vnet.h +1 −1
  161. drivers/net/virtio_net.c +6 −1
  162. drivers/pci/pwrctrl/core.c +3 −1
  163. drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c +0 −12
  164. drivers/pci/pwrctrl/slot.c +0 −1
  165. drivers/phy/Kconfig +2 −3
  166. drivers/phy/freescale/phy-fsl-lynx-28g.c +2 −0
  167. drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +1 −2
  168. drivers/phy/spacemit/phy-k1-usb2.c +14 −0
  169. drivers/phy/ti/phy-j721e-wiz.c +2 −0
  170. drivers/pinctrl/mediatek/pinctrl-mtk-common.c +6 −3
  171. drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +16 −0
  172. drivers/pinctrl/renesas/pinctrl-rza1.c +1 −1
  173. drivers/pinctrl/renesas/pinctrl-rzt2h.c +8 −7
  174. drivers/pinctrl/stm32/Kconfig +1 −0
  175. drivers/pinctrl/sunxi/pinctrl-sunxi.c +32 −11
  176. drivers/pinctrl/sunxi/pinctrl-sunxi.h +3 −1
  177. drivers/platform/olpc/olpc-xo175-ec.c +1 −1
  178. drivers/platform/x86/amd/hsmp/hsmp.c +1 −1
  179. drivers/platform/x86/asus-armoury.h +77 −0
  180. drivers/platform/x86/asus-nb-wmi.c +1 −1
  181. drivers/platform/x86/hp/hp-wmi.c +19 −0
  182. drivers/platform/x86/intel/hid.c +9 −1
  183. drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +4 −1
  184. drivers/platform/x86/lenovo/wmi-gamezone.c +0 −2
  185. drivers/scsi/ibmvscsi/ibmvfc.c +2 −1
  186. drivers/scsi/scsi_transport_sas.c +1 −1
  187. drivers/scsi/ses.c +1 −1
  188. drivers/spi/spi-fsl-lpspi.c +2 −1
  189. drivers/spi/spi-meson-spicc.c +0 −2
  190. drivers/spi/spi-sn-f-ospi.c +10 −32
  191. drivers/spi/spi.c +19 −13
  192. drivers/target/loopback/tcm_loop.c +46 −6
  193. drivers/target/target_core_file.c +1 −1
  194. drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c +7 −1
  195. drivers/vfio/pci/vfio_pci_dmabuf.c +2 −3
  196. drivers/virt/coco/tdx-guest/tdx-guest.c +10 −2
  197. drivers/virtio/virtio_ring.c +5 −5
  198. drivers/xen/privcmd.c +73 −3
  199. fs/btrfs/block-group.c +1 −1
  200. fs/btrfs/disk-io.c +2 −2
  201. fs/btrfs/tree-log.c +65 −33
  202. fs/btrfs/volumes.c +3 −2
  203. fs/btrfs/zlib.c +3 −1
  204. fs/erofs/Kconfig +30 −15
  205. fs/erofs/fileio.c +2 −4
  206. fs/erofs/ishare.c +13 −2
  207. fs/erofs/zdata.c +3 −0
  208. fs/ext4/Makefile +3 −2
  209. fs/ext4/crypto.c +8 −1
  210. fs/ext4/ext4.h +6 −0
  211. fs/ext4/ext4_extents.h +12 −0
  212. fs/ext4/extents-test.c +7 −5
  213. fs/ext4/extents.c +68 −12
  214. fs/ext4/fast_commit.c +10 −7
  215. fs/ext4/fsync.c +14 −2
  216. fs/ext4/ialloc.c +6 −0
  217. fs/ext4/inline.c +9 −1
  218. fs/ext4/inode.c +60 −15
  219. fs/ext4/mballoc-test.c +41 −40
  220. fs/ext4/mballoc.c +114 −18
  221. fs/ext4/mballoc.h +30 −0
  222. fs/ext4/page-io.c +8 −2
  223. fs/ext4/super.c +31 −6
  224. fs/ext4/sysfs.c +9 −1
  225. fs/fs-writeback.c +27 −9
  226. fs/fuse/file.c +1 −3
  227. fs/fuse/inode.c +1 −0
  228. fs/iomap/bio.c +50 −1
  229. fs/iomap/buffered-io.c +10 −5
  230. fs/jbd2/checkpoint.c +13 −2
  231. fs/namei.c +8 −2
  232. fs/netfs/buffered_read.c +1 −2
  233. fs/netfs/direct_read.c +1 −2
  234. fs/netfs/direct_write.c +11 −4
  235. fs/netfs/iterator.c +43 −0
  236. fs/netfs/read_collect.c +2 −2
  237. fs/netfs/read_retry.c +4 −1
  238. fs/netfs/read_single.c +0 −1
  239. fs/netfs/write_collect.c +2 −2
  240. fs/netfs/write_issue.c +1 −2
  241. fs/overlayfs/copy_up.c +3 −3
  242. fs/overlayfs/overlayfs.h +21 −0
  243. fs/overlayfs/ovl_entry.h +1 −6
  244. fs/overlayfs/params.c +28 −5
  245. fs/overlayfs/super.c +1 −1
  246. fs/overlayfs/util.c +4 −1
  247. fs/smb/client/Makefile +4 −3
  248. fs/smb/server/oplock.c +45 −27
  249. fs/smb/server/smb2pdu.c +52 −21
  250. fs/xfs/libxfs/xfs_attr.h +2 −1
  251. fs/xfs/libxfs/xfs_attr_leaf.c +22 −0
  252. fs/xfs/libxfs/xfs_attr_leaf.h +3 −0
  253. fs/xfs/libxfs/xfs_da_btree.c +42 −11
  254. fs/xfs/libxfs/xfs_da_btree.h +2 −0
  255. fs/xfs/scrub/quota.c +3 −1
  256. fs/xfs/scrub/trace.h +2 −10
  257. fs/xfs/xfs_attr_inactive.c +57 −38
  258. fs/xfs/xfs_attr_item.c +2 −49
  259. fs/xfs/xfs_dquot_item.c +7 −2
  260. fs/xfs/xfs_handle.c +1 −1
  261. fs/xfs/xfs_inode.c +2 −1
  262. fs/xfs/xfs_inode_item.c +7 −2
  263. fs/xfs/xfs_mount.c +4 −3
  264. fs/xfs/xfs_trace.h +34 −13
  265. fs/xfs/xfs_trans_ail.c +75 −52
  266. fs/xfs/xfs_verify_media.c +8 −10
  267. fs/xfs/xfs_xattr.c +1 −1
  268. include/linux/damon.h +6 −0
  269. include/linux/dma-mapping.h +13 −6
  270. include/linux/fs/super_types.h +1 −0
  271. include/linux/leafops.h +21 −11
  272. include/linux/mempolicy.h +1 −0
  273. include/linux/netfs.h +0 −1
  274. include/linux/pagemap.h +0 −11
  275. include/linux/security.h +1 −0
  276. include/linux/spi/spi.h +0 −5
  277. include/linux/srcutiny.h +4 −0
  278. include/linux/srcutree.h +5 −4
  279. include/linux/virtio_net.h +49 −4
  280. include/net/bluetooth/l2cap.h +1 −0
  281. include/net/codel_impl.h +1 −0
  282. include/net/inet_hashtables.h +14 −0
  283. include/net/ip6_fib.h +20 −1
  284. include/net/netfilter/nf_conntrack_core.h +5 −0
  285. include/net/netfilter/nf_conntrack_expect.h +18 −2
  286. include/net/netns/xfrm.h +1 −1
  287. include/sound/sdca_function.h +0 −5
  288. include/trace/events/btrfs.h +7 −4
  289. include/trace/events/dma.h +3 −1
  290. include/trace/events/netfs.h +4 −4
  291. include/uapi/linux/netfilter/nf_conntrack_common.h +4 −0
  292. init/Kconfig +1 −1
  293. io_uring/fdinfo.c +3 −1
  294. kernel/dma/debug.c +5 −4
  295. kernel/dma/direct.h +4 −3
  296. kernel/dma/mapping.c +6 −0
  297. kernel/dma/swiotlb.c +19 −2
  298. kernel/futex/core.c +1 −1
  299. kernel/futex/pi.c +2 −1
  300. kernel/futex/syscalls.c +8 −0
  301. kernel/power/main.c +1 −1
  302. kernel/power/snapshot.c +11 −0
  303. kernel/rcu/rcu.h +9 −0
  304. kernel/rcu/srcutiny.c +18 −1
  305. kernel/rcu/srcutree.c +102 −109
  306. kernel/sysctl.c +1 −1
  307. kernel/time/alarmtimer.c +1 −1
  308. kernel/trace/trace_events_trigger.c +66 −13
  309. kernel/trace/trace_osnoise.c +5 −5
  310. lib/bug.c +2 −5
  311. mm/damon/core.c +8 −0
  312. mm/damon/stat.c +50 −3
  313. mm/damon/sysfs.c +9 −1
  314. mm/hmm.c +2 −2
  315. mm/memory.c +15 −3
  316. mm/mempolicy.c +8 −2
  317. mm/mseal.c +1 −2
  318. mm/pagewalk.c +22 −3
  319. mm/rmap.c +7 −0
  320. mm/swap_state.c +4 −5
  321. mm/zswap.c +7 −1
  322. net/bluetooth/hci_conn.c +1 −1
  323. net/bluetooth/hci_core.c +1 −1
  324. net/bluetooth/hci_sync.c +10 −10
  325. net/bluetooth/l2cap_core.c +53 −18
  326. net/bluetooth/l2cap_sock.c +3 −0
  327. net/bluetooth/mgmt.c +1 −1
  328. net/bluetooth/sco.c +7 −3
  329. net/can/af_can.c +2 −2
  330. net/can/af_can.h +1 −1
  331. net/can/gw.c +3 −3
  332. net/can/isotp.c +18 −6
  333. net/can/proc.c +2 −1
  334. net/core/dev.c +17 −5
  335. net/core/rtnetlink.c +25 −3
  336. net/ipv4/esp4.c +6 −3
  337. net/ipv4/inet_connection_sock.c +3 −17
  338. net/ipv4/udp.c +1 −1
  339. net/ipv6/addrconf.c +2 −2
  340. net/ipv6/esp6.c +6 −3
  341. net/ipv6/ip6_fib.c +13 −2
  342. net/ipv6/netfilter/ip6t_rt.c +4 −0
  343. net/ipv6/route.c +1 −1
  344. net/key/af_key.c +12 −7
  345. net/netfilter/nf_conntrack_broadcast.c +6 −2
  346. net/netfilter/nf_conntrack_ecache.c +2 −0
  347. net/netfilter/nf_conntrack_expect.c +34 −5
  348. net/netfilter/nf_conntrack_h323_main.c +6 −6
  349. net/netfilter/nf_conntrack_helper.c +6 −5
  350. net/netfilter/nf_conntrack_netlink.c +40 −35
  351. net/netfilter/nf_conntrack_proto_tcp.c +3 −7
  352. net/netfilter/nf_conntrack_sip.c +12 −6
  353. net/netfilter/nfnetlink_log.c +2 −6
  354. net/netfilter/nft_set_pipapo_avx2.c +10 −10
  355. net/netfilter/nft_set_rbtree.c +75 −17
  356. net/nfc/nci/core.c +6 −4
  357. net/openvswitch/flow_netlink.c +2 −0
  358. net/openvswitch/vport-netdev.c +8 −3
  359. net/packet/af_packet.c +1 −0
  360. net/smc/smc_rx.c +8 −1
  361. net/tls/tls_sw.c +1 −1
  362. net/xfrm/xfrm_input.c +4 −1
  363. net/xfrm/xfrm_iptfs.c +14 −3
  364. net/xfrm/xfrm_nat_keepalive.c +1 −1
  365. net/xfrm/xfrm_policy.c +7 −5
  366. net/xfrm/xfrm_state.c +64 −52
  367. net/xfrm/xfrm_user.c +22 −10
  368. rust/kernel/regulator.rs +18 −15
  369. samples/landlock/sandboxer.c +3 −2
  370. scripts/coccinelle/api/kmalloc_objs.cocci +11 −0
  371. scripts/kconfig/merge_config.sh +10 −14
  372. security/landlock/domain.c +1 −2
  373. security/landlock/ruleset.c +4 −5
  374. security/landlock/tsync.c +73 −19
  375. security/security.c +1 −0
  376. sound/firewire/amdtp-stream.c +1 −1
  377. sound/hda/codecs/realtek/alc269.c +59 −7
  378. sound/hda/controllers/intel.c +0 −1
  379. sound/pci/asihpi/hpimsgx.c +4 −2
  380. sound/soc/amd/yc/acp6x-mach.c +14 −0
  381. sound/soc/codecs/adau1372.c +24 −10
  382. sound/soc/sdca/sdca_functions.c +10 −4
  383. sound/soc/sof/ipc4-topology.c +1 −1
  384. sound/usb/Kconfig +1 −0
  385. sound/usb/qcom/qc_audio_offload.c +1 −1
  386. sound/usb/quirks.c +4 −0
  387. tools/arch/x86/include/asm/msr-index.h +4 −1
  388. tools/arch/x86/include/uapi/asm/kvm.h +1 −0
  389. tools/include/linux/build_bug.h +3 −1
  390. tools/include/uapi/linux/kvm.h +8 −0
  391. tools/perf/check-headers.sh +0 −1
  392. tools/perf/util/kvm-stat-arch/kvm-stat-x86.c +3 −3
  393. tools/perf/util/metricgroup.c +3 −3
  394. tools/perf/util/parse-events.c +65 −17
  395. tools/testing/selftests/drivers/net/team/Makefile +1 −0
  396. tools/testing/selftests/drivers/net/team/config +2 −0
  397. tools/testing/selftests/drivers/net/team/non_ether_header_ops.sh +41 −0
  398. tools/testing/selftests/kvm/Makefile.kvm +1 −0
  399. tools/testing/selftests/kvm/s390/irq_routing.c +75 −0
  400. tools/testing/selftests/landlock/tsync_test.c +90 −1
  401. tools/testing/selftests/mount_setattr/mount_setattr_test.c +1 −1
  402. tools/testing/selftests/net/fib_tests.sh +58 −3
  403. tools/testing/selftests/net/netfilter/nft_concat_range.sh +69 −1
.mailmap+2−0
@@ -316,6 +316,7 @@ Hans Verkuil <hverkuil@kernel.org> <hverkuil-cisco@xs4all.nl> · 315 unmodified lines
316316 Hans Verkuil <hverkuil@kernel.org> <hansverk@cisco.com>
317317 Hao Ge <hao.ge@linux.dev> <gehao@kylinos.cn>
318318 Harry Yoo <harry.yoo@oracle.com> <42.hyeyoo@gmail.com>
319+Harry Yoo <harry@kernel.org> <harry.yoo@oracle.com>
319320 Heiko Carstens <hca@linux.ibm.com> <h.carstens@de.ibm.com>
320321 Heiko Carstens <hca@linux.ibm.com> <heiko.carstens@de.ibm.com>
321322 Heiko Stuebner <heiko@sntech.de> <heiko.stuebner@bqreaders.com>
@@ -587,6 +588,7 @@ Morten Welinder <terra@gnome.org> · 265 unmodified lines
587588 Morten Welinder <welinder@anemone.rentec.com>
588589 Morten Welinder <welinder@darter.rentec.com>
589590 Morten Welinder <welinder@troll.com>
591+Muhammad Usama Anjum <usama.anjum@arm.com> <usama.anjum@collabora.com>
590592 Mukesh Ojha <quic_mojha@quicinc.com> <mojha@codeaurora.org>
591593 Muna Sinada <quic_msinada@quicinc.com> <msinada@codeaurora.org>
592594 Murali Nalajala <quic_mnalajal@quicinc.com> <mnalajal@codeaurora.org>
Documentation/PCI/pcieaer-howto.rst+10−0
@@ -85,6 +85,16 @@ In the example, 'Requester ID' means the ID of the device that sent · 84 unmodified lines
8585 the error message to the Root Port. Please refer to PCIe specs for other
8686 fields.
8787
88+The 'TLP Header' is the prefix/header of the TLP that caused the error
89+in raw hex format. To decode the TLP Header into human-readable form
90+one may use tlp-tool:
91+
92+https://github.com/mmpg-x86/tlp-tool
93+
94+Example usage::
95+
96+ curl -L https://git.kernel.org/linus/2ca1c94ce0b6 | rtlp-tool --aer
97+
8898 AER Ratelimits
8999 --------------
90100
Documentation/core-api/dma-attributes.rst+30−8
@@ -149,11 +149,33 @@ For architectures that require cache flushing for DMA coherence · 148 unmodified lines
149149 DMA_ATTR_MMIO will not perform any cache flushing. The address
150150 provided must never be mapped cacheable into the CPU.
151151
152−DMA_ATTR_CPU_CACHE_CLEAN
153−------------------------
154−
155−This attribute indicates the CPU will not dirty any cacheline overlapping this
156−DMA_FROM_DEVICE/DMA_BIDIRECTIONAL buffer while it is mapped. This allows
157−multiple small buffers to safely share a cacheline without risk of data
158−corruption, suppressing DMA debug warnings about overlapping mappings.
159−All mappings sharing a cacheline should have this attribute.
152+DMA_ATTR_DEBUGGING_IGNORE_CACHELINES
153+------------------------------------
154+
155+This attribute indicates that CPU cache lines may overlap for buffers mapped
156+with DMA_FROM_DEVICE or DMA_BIDIRECTIONAL.
157+
158+Such overlap may occur when callers map multiple small buffers that reside
159+within the same cache line. In this case, callers must guarantee that the CPU
160+will not dirty these cache lines after the mappings are established. When this
161+condition is met, multiple buffers can safely share a cache line without risking
162+data corruption.
163+
164+All mappings that share a cache line must set this attribute to suppress DMA
165+debug warnings about overlapping mappings.
166+
167+DMA_ATTR_REQUIRE_COHERENT
168+-------------------------
169+
170+DMA mapping requests with the DMA_ATTR_REQUIRE_COHERENT fail on any
171+system where SWIOTLB or cache management is required. This should only
172+be used to support uAPI designs that require continuous HW DMA
173+coherence with userspace processes, for example RDMA and DRM. At a
174+minimum the memory being mapped must be userspace memory from
175+pin_user_pages() or similar.
176+
177+Drivers should consider using dma_mmap_pages() instead of this
178+interface when building their uAPIs, when possible.
179+
180+It must never be used in an in-kernel driver that only works with
181+kernel memory.
Documentation/filesystems/overlayfs.rst+50−0
@@ -783,6 +783,56 @@ controlled by the "uuid" mount option, which supports these values: · 782 unmodified lines
783783 mounted with "uuid=on".
784784
785785
786+Durability and copy up
787+----------------------
788+
789+The fsync(2) system call ensures that the data and metadata of a file
790+are safely written to the backing storage, which is expected to
791+guarantee the existence of the information post system crash.
792+
793+Without an fsync(2) call, there is no guarantee that the observed
794+data after a system crash will be either the old or the new data, but
795+in practice, the observed data after crash is often the old or new data
796+or a mix of both.
797+
798+When an overlayfs file is modified for the first time, copy up will
799+create a copy of the lower file and its parent directories in the upper
800+layer. Since the Linux filesystem API does not enforce any particular
801+ordering on storing changes without explicit fsync(2) calls, in case
802+of a system crash, the upper file could end up with no data at all
803+(i.e. zeros), which would be an unusual outcome. To avoid this
804+experience, overlayfs calls fsync(2) on the upper file before completing
805+data copy up with rename(2) or link(2) to make the copy up "atomic".
806+
807+By default, overlayfs does not explicitly call fsync(2) on copied up
808+directories or on metadata-only copy up, so it provides no guarantee to
809+persist the user's modification unless the user calls fsync(2).
810+The fsync during copy up only guarantees that if a copy up is observed
811+after a crash, the observed data is not zeroes or intermediate values
812+from the copy up staging area.
813+
814+On traditional local filesystems with a single journal (e.g. ext4, xfs),
815+fsync on a file also persists the parent directory changes, because they
816+are usually modified in the same transaction, so metadata durability during
817+data copy up effectively comes for free. Overlayfs further limits risk by
818+disallowing network filesystems as upper layer.
819+
820+Overlayfs can be tuned to prefer performance or durability when storing
821+to the underlying upper layer. This is controlled by the "fsync" mount
822+option, which supports these values:
823+
824+- "auto": (default)
825+ Call fsync(2) on upper file before completion of data copy up.
826+ No explicit fsync(2) on directory or metadata-only copy up.
827+- "strict":
828+ Call fsync(2) on upper file and directories before completion of any
829+ copy up.
830+- "volatile": [*]
831+ Prefer performance over durability (see `Volatile mount`_)
832+
833+[*] The mount option "volatile" is an alias to "fsync=volatile".
834+
835+
786836 Volatile mount
787837 --------------
788838
Documentation/hwmon/adm1177.rst+4−4
@@ -27,10 +27,10 @@ for details. · 26 unmodified lines
2727 Sysfs entries
2828 -------------
2929
30−The following attributes are supported. Current maxim attribute
30+The following attributes are supported. Current maximum attribute
3131 is read-write, all other attributes are read-only.
3232
33−in0_input Measured voltage in microvolts.
33+in0_input Measured voltage in millivolts.
3434
35−curr1_input Measured current in microamperes.
36−curr1_max_alarm Overcurrent alarm in microamperes.
35+curr1_input Measured current in milliamperes.
36+curr1_max Overcurrent shutdown threshold in milliamperes.
Documentation/hwmon/peci-cputemp.rst+6−4
@@ -51,8 +51,9 @@ temp1_max Provides thermal control temperature of the CPU package · 50 unmodified lines
5151 temp1_crit Provides shutdown temperature of the CPU package which
5252 is also known as the maximum processor junction
5353 temperature, Tjmax or Tprochot.
54−temp1_crit_hyst Provides the hysteresis value from Tcontrol to Tjmax of
55− the CPU package.
54+temp1_crit_hyst Provides the hysteresis temperature of the CPU
55+ package. Returns Tcontrol, the temperature at which
56+ the critical condition clears.
5657
5758 temp2_label "DTS"
5859 temp2_input Provides current temperature of the CPU package scaled
@@ -62,8 +63,9 @@ temp2_max Provides thermal control temperature of the CPU package · 3 unmodified lines
6263 temp2_crit Provides shutdown temperature of the CPU package which
6364 is also known as the maximum processor junction
6465 temperature, Tjmax or Tprochot.
65−temp2_crit_hyst Provides the hysteresis value from Tcontrol to Tjmax of
66− the CPU package.
66+temp2_crit_hyst Provides the hysteresis temperature of the CPU
67+ package. Returns Tcontrol, the temperature at which
68+ the critical condition clears.
6769
6870 temp3_label "Tcontrol"
6971 temp3_input Provides current Tcontrol temperature of the CPU
Documentation/userspace-api/landlock.rst+19−4
@@ -8,7 +8,7 @@ Landlock: unprivileged access control · 7 unmodified lines
88 =====================================
99
1010 :Author: Mickaël Salaün
11−:Date: January 2026
11+:Date: March 2026
1212
1313 The goal of Landlock is to enable restriction of ambient rights (e.g. global
1414 filesystem or network access) for a set of processes. Because Landlock
@@ -197,12 +197,27 @@ similar backwards compatibility check is needed for the restrict flags · 182 unmodified lines
197197
198198 .. code-block:: c
199199
200− __u32 restrict_flags = LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON;
201− if (abi < 7) {
202− /* Clear logging flags unsupported before ABI 7. */
200+ __u32 restrict_flags =
201+ LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON |
202+ LANDLOCK_RESTRICT_SELF_TSYNC;
203+ switch (abi) {
204+ case 1 ... 6:
205+ /* Removes logging flags for ABI < 7 */
203206 restrict_flags &= ~(LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF |
204207 LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON |
205208 LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF);
209+ __attribute__((fallthrough));
210+ case 7:
211+ /*
212+ * Removes multithreaded enforcement flag for ABI < 8
213+ *
214+ * WARNING: Without this flag, calling landlock_restrict_self(2) is
215+ * only equivalent if the calling process is single-threaded. Below
216+ * ABI v8 (and as of ABI v8, when not using this flag), a Landlock
217+ * policy would only be enforced for the calling thread and its
218+ * children (and not for all threads, including parents and siblings).
219+ */
220+ restrict_flags &= ~LANDLOCK_RESTRICT_SELF_TSYNC;
206221 }
207222
208223 The next step is to restrict the current thread from gaining more privileges
MAINTAINERS+16−7
@@ -3986,7 +3986,7 @@ F: drivers/hwmon/asus-ec-sensors.c · 3985 unmodified lines
39863986 ASUS NOTEBOOKS AND EEEPC ACPI/WMI EXTRAS DRIVERS
39873987 M: Corentin Chary <corentin.chary@gmail.com>
39883988 M: Luke D. Jones <luke@ljones.dev>
3989−M: Denis Benato <benato.denis96@gmail.com>
3989+M: Denis Benato <denis.benato@linux.dev>
39903990 L: platform-driver-x86@vger.kernel.org
39913991 S: Maintained
39923992 W: https://asus-linux.org/
@@ -8628,8 +8628,14 @@ F: drivers/gpu/drm/lima/ · 4635 unmodified lines
86288628 F: include/uapi/drm/lima_drm.h
86298629
86308630 DRM DRIVERS FOR LOONGSON
8631+M: Jianmin Lv <lvjianmin@loongson.cn>
8632+M: Qianhai Wu <wuqianhai@loongson.cn>
8633+R: Huacai Chen <chenhuacai@kernel.org>
8634+R: Mingcong Bai <jeffbai@aosc.io>
8635+R: Xi Ruoyao <xry111@xry111.site>
8636+R: Icenowy Zheng <zhengxingda@iscas.ac.cn>
86318637 L: dri-devel@lists.freedesktop.org
8632−S: Orphan
8638+S: Maintained
86338639 T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
86348640 F: drivers/gpu/drm/loongson/
86358641
@@ -9613,7 +9619,12 @@ F: include/linux/ext2* · 977 unmodified lines
96139619
96149620 EXT4 FILE SYSTEM
96159621 M: "Theodore Ts'o" <tytso@mit.edu>
9616−M: Andreas Dilger <adilger.kernel@dilger.ca>
9622+R: Andreas Dilger <adilger.kernel@dilger.ca>
9623+R: Baokun Li <libaokun@linux.alibaba.com>
9624+R: Jan Kara <jack@suse.cz>
9625+R: Ojaswin Mujoo <ojaswin@linux.ibm.com>
9626+R: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
9627+R: Zhang Yi <yi.zhang@huawei.com>
96179628 L: linux-ext4@vger.kernel.org
96189629 S: Maintained
96199630 W: http://ext4.wiki.kernel.org
@@ -12009,7 +12020,6 @@ I2C SUBSYSTEM · 2389 unmodified lines
1200912020 M: Wolfram Sang <wsa+renesas@sang-engineering.com>
1201012021 L: linux-i2c@vger.kernel.org
1201112022 S: Maintained
12012−W: https://i2c.wiki.kernel.org/
1201312023 Q: https://patchwork.ozlabs.org/project/linux-i2c/list/
1201412024 T: git git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git
1201512025 F: Documentation/i2c/
@@ -12035,7 +12045,6 @@ I2C SUBSYSTEM HOST DRIVERS · 19 unmodified lines
1203512045 M: Andi Shyti <andi.shyti@kernel.org>
1203612046 L: linux-i2c@vger.kernel.org
1203712047 S: Maintained
12038−W: https://i2c.wiki.kernel.org/
1203912048 Q: https://patchwork.ozlabs.org/project/linux-i2c/list/
1204012049 T: git git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git
1204112050 F: Documentation/devicetree/bindings/i2c/
@@ -16877,7 +16886,7 @@ M: Lorenzo Stoakes <ljs@kernel.org> · 4835 unmodified lines
1687716886 R: Rik van Riel <riel@surriel.com>
1687816887 R: Liam R. Howlett <Liam.Howlett@oracle.com>
1687916888 R: Vlastimil Babka <vbabka@kernel.org>
16880−R: Harry Yoo <harry.yoo@oracle.com>
16889+R: Harry Yoo <harry@kernel.org>
1688116890 R: Jann Horn <jannh@google.com>
1688216891 L: linux-mm@kvack.org
1688316892 S: Maintained
@@ -24343,7 +24352,7 @@ F: drivers/nvmem/layouts/sl28vpd.c · 7459 unmodified lines
2434324352
2434424353 SLAB ALLOCATOR
2434524354 M: Vlastimil Babka <vbabka@kernel.org>
24346−M: Harry Yoo <harry.yoo@oracle.com>
24355+M: Harry Yoo <harry@kernel.org>
2434724356 M: Andrew Morton <akpm@linux-foundation.org>
2434824357 R: Hao Li <hao.li@linux.dev>
2434924358 R: Christoph Lameter <cl@gentwo.org>
Makefile+2−2
@@ -2,7 +2,7 @@ · 1 unmodified line
22 VERSION = 7
33 PATCHLEVEL = 0
44 SUBLEVEL = 0
5−EXTRAVERSION = -rc5
5+EXTRAVERSION = -rc6
66 NAME = Baby Opossum Posse
77
88 # *DOCUMENTATION*
@@ -1654,7 +1654,7 @@ CLEAN_FILES += vmlinux.symvers modules-only.symvers \ · 1645 unmodified lines
16541654 modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \
16551655 compile_commands.json rust/test \
16561656 rust-project.json .vmlinux.objs .vmlinux.export.c \
1657− .builtin-dtbs-list .builtin-dtb.S
1657+ .builtin-dtbs-list .builtin-dtbs.S
16581658
16591659 # Directories & files removed with 'make mrproper'
16601660 MRPROPER_FILES += include/config include/generated \
arch/arm64/kvm/at.c+1−1
@@ -1753,7 +1753,7 @@ int __kvm_at_swap_desc(struct kvm *kvm, gpa_t ipa, u64 old, u64 new) · 1752 unmodified lines
17531753 if (!writable)
17541754 return -EPERM;
17551755
1756− ptep = (u64 __user *)hva + offset;
1756+ ptep = (void __user *)hva + offset;
17571757 if (cpus_have_final_cap(ARM64_HAS_LSE_ATOMICS))
17581758 r = __lse_swap_desc(ptep, old, new);
17591759 else
arch/arm64/kvm/reset.c+14−0
@@ -247,6 +247,20 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu) · 246 unmodified lines
247247 kvm_vcpu_set_be(vcpu);
248248
249249 *vcpu_pc(vcpu) = target_pc;
250+
251+ /*
252+ * We may come from a state where either a PC update was
253+ * pending (SMC call resulting in PC being increpented to
254+ * skip the SMC) or a pending exception. Make sure we get
255+ * rid of all that, as this cannot be valid out of reset.
256+ *
257+ * Note that clearing the exception mask also clears PC
258+ * updates, but that's an implementation detail, and we
259+ * really want to make it explicit.
260+ */
261+ vcpu_clear_flag(vcpu, PENDING_EXCEPTION);
262+ vcpu_clear_flag(vcpu, EXCEPT_MASK);
263+ vcpu_clear_flag(vcpu, INCREMENT_PC);
250264 vcpu_set_reg(vcpu, 0, reset_state.r0);
251265 }
252266
arch/loongarch/include/asm/linkage.h+36−0
@@ -41,4 +41,40 @@ · 40 unmodified lines
4141 .cfi_endproc; \
4242 SYM_END(name, SYM_T_NONE)
4343
44+/*
45+ * This is for the signal handler trampoline, which is used as the return
46+ * address of the signal handlers in userspace instead of called normally.
47+ * The long standing libgcc bug https://gcc.gnu.org/PR124050 requires a
48+ * nop between .cfi_startproc and the actual address of the trampoline, so
49+ * we cannot simply use SYM_FUNC_START.
50+ *
51+ * This wrapper also contains all the .cfi_* directives for recovering
52+ * the content of the GPRs and the "return address" (where the rt_sigreturn
53+ * syscall will jump to), assuming there is a struct rt_sigframe (where
54+ * a struct sigcontext containing those information we need to recover) at
55+ * $sp. The "DWARF for the LoongArch(TM) Architecture" manual states
56+ * column 0 is for $zero, but it does not make too much sense to
57+ * save/restore the hardware zero register. Repurpose this column here
58+ * for the return address (here it's not the content of $ra we cannot use
59+ * the default column 3).
60+ */
61+#define SYM_SIGFUNC_START(name) \
62+ .cfi_startproc; \
63+ .cfi_signal_frame; \
64+ .cfi_def_cfa 3, RT_SIGFRAME_SC; \
65+ .cfi_return_column 0; \
66+ .cfi_offset 0, SC_PC; \
67+ \
68+ .irp num, 1, 2, 3, 4, 5, 6, 7, 8, \
69+ 9, 10, 11, 12, 13, 14, 15, 16, \
70+ 17, 18, 19, 20, 21, 22, 23, 24, \
71+ 25, 26, 27, 28, 29, 30, 31; \
72+ .cfi_offset \num, SC_REGS + \num * SZREG; \
73+ .endr; \
74+ \
75+ nop; \
76+ SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
77+
78+#define SYM_SIGFUNC_END(name) SYM_FUNC_END(name)
79+
4480 #endif
arch/loongarch/include/asm/sigframe.h+9−0
@@ -0,0 +1,9 @@
1+/* SPDX-License-Identifier: GPL-2.0+ */
2+
3+#include <asm/siginfo.h>
4+#include <asm/ucontext.h>
5+
6+struct rt_sigframe {
7+ struct siginfo rs_info;
8+ struct ucontext rs_uctx;
9+};
arch/loongarch/kernel/asm-offsets.c+2−0
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <asm/ptrace.h>
1717 #include <asm/processor.h>
1818 #include <asm/ftrace.h>
19+#include <asm/sigframe.h>
1920 #include <vdso/datapage.h>
2021
2122 static void __used output_ptreg_defines(void)
@@ -220,6 +221,7 @@ static void __used output_sc_defines(void) · 198 unmodified lines
220221 COMMENT("Linux sigcontext offsets.");
221222 OFFSET(SC_REGS, sigcontext, sc_regs);
222223 OFFSET(SC_PC, sigcontext, sc_pc);
224+ OFFSET(RT_SIGFRAME_SC, rt_sigframe, rs_uctx.uc_mcontext);
223225 BLANK();
224226 }
225227
arch/loongarch/kernel/env.c+3−4
@@ -42,16 +42,15 @@ static int __init init_cpu_fullname(void) · 41 unmodified lines
4242 int cpu, ret;
4343 char *cpuname;
4444 const char *model;
45− struct device_node *root;
4645
4746 /* Parsing cpuname from DTS model property */
48− root = of_find_node_by_path("/");
49− ret = of_property_read_string(root, "model", &model);
47+ ret = of_property_read_string(of_root, "model", &model);
5048 if (ret == 0) {
5149 cpuname = kstrdup(model, GFP_KERNEL);
50+ if (!cpuname)
51+ return -ENOMEM;
5252 loongson_sysconf.cpuname = strsep(&cpuname, " ");
5353 }
54− of_node_put(root);
5554
5655 if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) {
5756 for (cpu = 0; cpu < NR_CPUS; cpu++)
arch/loongarch/kernel/signal.c+1−5
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include <asm/cpu-features.h>
3636 #include <asm/fpu.h>
3737 #include <asm/lbt.h>
38+#include <asm/sigframe.h>
3839 #include <asm/ucontext.h>
3940 #include <asm/vdso.h>
4041
@@ -51,11 +52,6 @@ · 10 unmodified lines
5152 #define lock_lbt_owner() ({ preempt_disable(); pagefault_disable(); })
5253 #define unlock_lbt_owner() ({ pagefault_enable(); preempt_enable(); })
5354
54−struct rt_sigframe {
55− struct siginfo rs_info;
56− struct ucontext rs_uctx;
57−};
58−
5955 struct _ctx_layout {
6056 struct sctx_info *addr;
6157 unsigned int size;
arch/loongarch/kvm/intc/eiointc.c+8−8
@@ -83,7 +83,7 @@ static inline void eiointc_update_sw_coremap(struct loongarch_eiointc *s, · 82 unmodified lines
8383
8484 if (!(s->status & BIT(EIOINTC_ENABLE_CPU_ENCODE))) {
8585 cpuid = ffs(cpuid) - 1;
86− cpuid = (cpuid >= 4) ? 0 : cpuid;
86+ cpuid = ((cpuid < 0) || (cpuid >= 4)) ? 0 : cpuid;
8787 }
8888
8989 vcpu = kvm_get_vcpu_by_cpuid(s->kvm, cpuid);
@@ -472,34 +472,34 @@ static int kvm_eiointc_regs_access(struct kvm_device *dev, · 382 unmodified lines
472472 switch (addr) {
473473 case EIOINTC_NODETYPE_START ... EIOINTC_NODETYPE_END:
474474 offset = (addr - EIOINTC_NODETYPE_START) / 4;
475− p = s->nodetype + offset * 4;
475+ p = (void *)s->nodetype + offset * 4;
476476 break;
477477 case EIOINTC_IPMAP_START ... EIOINTC_IPMAP_END:
478478 offset = (addr - EIOINTC_IPMAP_START) / 4;
479− p = &s->ipmap + offset * 4;
479+ p = (void *)&s->ipmap + offset * 4;
480480 break;
481481 case EIOINTC_ENABLE_START ... EIOINTC_ENABLE_END:
482482 offset = (addr - EIOINTC_ENABLE_START) / 4;
483− p = s->enable + offset * 4;
483+ p = (void *)s->enable + offset * 4;
484484 break;
485485 case EIOINTC_BOUNCE_START ... EIOINTC_BOUNCE_END:
486486 offset = (addr - EIOINTC_BOUNCE_START) / 4;
487− p = s->bounce + offset * 4;
487+ p = (void *)s->bounce + offset * 4;
488488 break;
489489 case EIOINTC_ISR_START ... EIOINTC_ISR_END:
490490 offset = (addr - EIOINTC_ISR_START) / 4;
491− p = s->isr + offset * 4;
491+ p = (void *)s->isr + offset * 4;
492492 break;
493493 case EIOINTC_COREISR_START ... EIOINTC_COREISR_END:
494494 if (cpu >= s->num_cpu)
495495 return -EINVAL;
496496
497497 offset = (addr - EIOINTC_COREISR_START) / 4;
498− p = s->coreisr[cpu] + offset * 4;
498+ p = (void *)s->coreisr[cpu] + offset * 4;
499499 break;
500500 case EIOINTC_COREMAP_START ... EIOINTC_COREMAP_END:
501501 offset = (addr - EIOINTC_COREMAP_START) / 4;
502− p = s->coremap + offset * 4;
502+ p = (void *)s->coremap + offset * 4;
503503 break;
504504 default:
505505 kvm_err("%s: unknown eiointc register, addr = %d\n", __func__, addr);
arch/loongarch/kvm/vcpu.c+3−0
@@ -588,6 +588,9 @@ struct kvm_vcpu *kvm_get_vcpu_by_cpuid(struct kvm *kvm, int cpuid) · 587 unmodified lines
588588 {
589589 struct kvm_phyid_map *map;
590590
591+ if (cpuid < 0)
592+ return NULL;
593+
591594 if (cpuid >= KVM_MAX_PHYID)
592595 return NULL;
593596
arch/loongarch/pci/pci.c+80−0
@@ -5,9 +5,11 @@ · 4 unmodified lines
55 #include <linux/kernel.h>
66 #include <linux/init.h>
77 #include <linux/acpi.h>
8+#include <linux/delay.h>
89 #include <linux/types.h>
910 #include <linux/pci.h>
1011 #include <linux/vgaarb.h>
12+#include <linux/io-64-nonatomic-lo-hi.h>
1113 #include <asm/cacheflush.h>
1214 #include <asm/loongson.h>
1315
@@ -15,6 +17,9 @@ · 1 unmodified line
1517 #define PCI_DEVICE_ID_LOONGSON_DC1 0x7a06
1618 #define PCI_DEVICE_ID_LOONGSON_DC2 0x7a36
1719 #define PCI_DEVICE_ID_LOONGSON_DC3 0x7a46
20+#define PCI_DEVICE_ID_LOONGSON_GPU1 0x7a15
21+#define PCI_DEVICE_ID_LOONGSON_GPU2 0x7a25
22+#define PCI_DEVICE_ID_LOONGSON_GPU3 0x7a35
1823
1924 int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
2025 int reg, int len, u32 *val)
@@ -99,3 +104,78 @@ static void pci_fixup_vgadev(struct pci_dev *pdev) · 78 unmodified lines
99104 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC1, pci_fixup_vgadev);
100105 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC2, pci_fixup_vgadev);
101106 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC3, pci_fixup_vgadev);
107+
108+#define CRTC_NUM_MAX 2
109+#define CRTC_OUTPUT_ENABLE 0x100
110+
111+static void loongson_gpu_fixup_dma_hang(struct pci_dev *pdev, bool on)
112+{
113+ u32 i, val, count, crtc_offset, device;
114+ void __iomem *crtc_reg, *base, *regbase;
115+ static u32 crtc_status[CRTC_NUM_MAX] = { 0 };
116+
117+ base = pdev->bus->ops->map_bus(pdev->bus, pdev->devfn + 1, 0);
118+ device = readw(base + PCI_DEVICE_ID);
119+
120+ regbase = ioremap(readq(base + PCI_BASE_ADDRESS_0) & ~0xffull, SZ_64K);
121+ if (!regbase) {
122+ pci_err(pdev, "Failed to ioremap()\n");
123+ return;
124+ }
125+
126+ switch (device) {
127+ case PCI_DEVICE_ID_LOONGSON_DC2:
128+ crtc_reg = regbase + 0x1240;
129+ crtc_offset = 0x10;
130+ break;
131+ case PCI_DEVICE_ID_LOONGSON_DC3:
132+ crtc_reg = regbase;
133+ crtc_offset = 0x400;
134+ break;
135+ }
136+
137+ for (i = 0; i < CRTC_NUM_MAX; i++, crtc_reg += crtc_offset) {
138+ val = readl(crtc_reg);
139+
140+ if (!on)
141+ crtc_status[i] = val;
142+
143+ /* No need to fixup if the status is off at startup. */
144+ if (!(crtc_status[i] & CRTC_OUTPUT_ENABLE))
145+ continue;
146+
147+ if (on)
148+ val |= CRTC_OUTPUT_ENABLE;
149+ else
150+ val &= ~CRTC_OUTPUT_ENABLE;
151+
152+ mb();
153+ writel(val, crtc_reg);
154+
155+ for (count = 0; count < 40; count++) {
156+ val = readl(crtc_reg) & CRTC_OUTPUT_ENABLE;
157+ if ((on && val) || (!on && !val))
158+ break;
159+ udelay(1000);
160+ }
161+
162+ pci_info(pdev, "DMA hang fixup at reg[0x%lx]: 0x%x\n",
163+ (unsigned long)crtc_reg & 0xffff, readl(crtc_reg));
164+ }
165+
166+ iounmap(regbase);
167+}
168+
169+static void pci_fixup_dma_hang_early(struct pci_dev *pdev)
170+{
171+ loongson_gpu_fixup_dma_hang(pdev, false);
172+}
173+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU2, pci_fixup_dma_hang_early);
174+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU3, pci_fixup_dma_hang_early);
175+
176+static void pci_fixup_dma_hang_final(struct pci_dev *pdev)
177+{
178+ loongson_gpu_fixup_dma_hang(pdev, true);
179+}
180+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU2, pci_fixup_dma_hang_final);
181+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU3, pci_fixup_dma_hang_final);
arch/loongarch/vdso/Makefile+2−2
@@ -26,7 +26,7 @@ cflags-vdso := $(ccflags-vdso) \ · 25 unmodified lines
2626 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
2727 -std=gnu11 -fms-extensions -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \
2828 -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
29− $(call cc-option, -fno-asynchronous-unwind-tables) \
29+ $(call cc-option, -fasynchronous-unwind-tables) \
3030 $(call cc-option, -fno-stack-protector)
3131 aflags-vdso := $(ccflags-vdso) \
3232 -D__ASSEMBLY__ -Wa,-gdwarf-2
@@ -41,7 +41,7 @@ endif · 8 unmodified lines
4141
4242 # VDSO linker flags.
4343 ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
44− $(filter -E%,$(KBUILD_CFLAGS)) -shared --build-id -T
44+ $(filter -E%,$(KBUILD_CFLAGS)) -shared --build-id --eh-frame-hdr -T
4545
4646 #
4747 # Shared build commands.
arch/loongarch/vdso/sigreturn.S+3−3
@@ -12,13 +12,13 @@ · 11 unmodified lines
1212
1313 #include <asm/regdef.h>
1414 #include <asm/asm.h>
15+#include <asm/asm-offsets.h>
1516
1617 .section .text
17− .cfi_sections .debug_frame
1818
19−SYM_FUNC_START(__vdso_rt_sigreturn)
19+SYM_SIGFUNC_START(__vdso_rt_sigreturn)
2020
2121 li.w a7, __NR_rt_sigreturn
2222 syscall 0
2323
24−SYM_FUNC_END(__vdso_rt_sigreturn)
24+SYM_SIGFUNC_END(__vdso_rt_sigreturn)
arch/s390/include/asm/barrier.h+2−2
@@ -62,8 +62,8 @@ do { \ · 61 unmodified lines
6262 * @size: number of elements in array
6363 */
6464 #define array_index_mask_nospec array_index_mask_nospec
65−static inline unsigned long array_index_mask_nospec(unsigned long index,
66− unsigned long size)
65+static __always_inline unsigned long array_index_mask_nospec(unsigned long index,
66+ unsigned long size)
6767 {
6868 unsigned long mask;
6969
arch/s390/include/asm/kvm_host.h+3−0
@@ -710,6 +710,9 @@ void kvm_arch_crypto_clear_masks(struct kvm *kvm); · 709 unmodified lines
710710 void kvm_arch_crypto_set_masks(struct kvm *kvm, unsigned long *apm,
711711 unsigned long *aqm, unsigned long *adm);
712712
713+#define SIE64_RETURN_NORMAL 0
714+#define SIE64_RETURN_MCCK 1
715+
713716 int __sie64a(phys_addr_t sie_block_phys, struct kvm_s390_sie_block *sie_block, u64 *rsa,
714717 unsigned long gasce);
715718
arch/s390/include/asm/stacktrace.h+1−1
@@ -62,7 +62,7 @@ struct stack_frame { · 61 unmodified lines
6262 struct {
6363 unsigned long sie_control_block;
6464 unsigned long sie_savearea;
65− unsigned long sie_reason;
65+ unsigned long sie_return;
6666 unsigned long sie_flags;
6767 unsigned long sie_control_block_phys;
6868 unsigned long sie_guest_asce;
arch/s390/kernel/asm-offsets.c+1−1
@@ -63,7 +63,7 @@ int main(void) · 62 unmodified lines
6363 OFFSET(__SF_EMPTY, stack_frame, empty[0]);
6464 OFFSET(__SF_SIE_CONTROL, stack_frame, sie_control_block);
6565 OFFSET(__SF_SIE_SAVEAREA, stack_frame, sie_savearea);
66− OFFSET(__SF_SIE_REASON, stack_frame, sie_reason);
66+ OFFSET(__SF_SIE_RETURN, stack_frame, sie_return);
6767 OFFSET(__SF_SIE_FLAGS, stack_frame, sie_flags);
6868 OFFSET(__SF_SIE_CONTROL_PHYS, stack_frame, sie_control_block_phys);
6969 OFFSET(__SF_SIE_GUEST_ASCE, stack_frame, sie_guest_asce);
arch/s390/kernel/entry.S+5−2
@@ -200,7 +200,7 @@ SYM_FUNC_START(__sie64a) · 199 unmodified lines
200200 stg %r3,__SF_SIE_CONTROL(%r15) # ...and virtual addresses
201201 stg %r4,__SF_SIE_SAVEAREA(%r15) # save guest register save area
202202 stg %r5,__SF_SIE_GUEST_ASCE(%r15) # save guest asce
203− xc __SF_SIE_REASON(8,%r15),__SF_SIE_REASON(%r15) # reason code = 0
203+ xc __SF_SIE_RETURN(8,%r15),__SF_SIE_RETURN(%r15) # return code = 0
204204 mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r14) # copy thread flags
205205 lmg %r0,%r13,0(%r4) # load guest gprs 0-13
206206 mvi __TI_sie(%r14),1
@@ -237,7 +237,7 @@ SYM_INNER_LABEL(sie_exit, SYM_L_GLOBAL) · 30 unmodified lines
237237 xgr %r4,%r4
238238 xgr %r5,%r5
239239 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
240− lg %r2,__SF_SIE_REASON(%r15) # return exit reason code
240+ lg %r2,__SF_SIE_RETURN(%r15) # return sie return code
241241 BR_EX %r14
242242 SYM_FUNC_END(__sie64a)
243243 EXPORT_SYMBOL(__sie64a)
@@ -271,6 +271,7 @@ SYM_CODE_START(system_call) · 27 unmodified lines
271271 xgr %r9,%r9
272272 xgr %r10,%r10
273273 xgr %r11,%r11
274+ xgr %r12,%r12
274275 la %r2,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
275276 mvc __PT_R8(64,%r2),__LC_SAVE_AREA(%r13)
276277 MBEAR %r2,%r13
@@ -407,6 +408,7 @@ SYM_CODE_START(\name) · 130 unmodified lines
407408 xgr %r6,%r6
408409 xgr %r7,%r7
409410 xgr %r10,%r10
411+ xgr %r12,%r12
410412 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
411413 mvc __PT_R8(64,%r11),__LC_SAVE_AREA(%r13)
412414 MBEAR %r11,%r13
@@ -496,6 +498,7 @@ SYM_CODE_START(mcck_int_handler) · 83 unmodified lines
496498 xgr %r6,%r6
497499 xgr %r7,%r7
498500 xgr %r10,%r10
501+ xgr %r12,%r12
499502 stmg %r8,%r9,__PT_PSW(%r11)
500503 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
501504 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
arch/s390/kernel/nmi.c+2−2
@@ -487,8 +487,8 @@ void notrace s390_do_machine_check(struct pt_regs *regs) · 486 unmodified lines
487487 mcck_dam_code = (mci.val & MCIC_SUBCLASS_MASK);
488488 if (test_cpu_flag(CIF_MCCK_GUEST) &&
489489 (mcck_dam_code & MCCK_CODE_NO_GUEST) != mcck_dam_code) {
490− /* Set exit reason code for host's later handling */
491− *((long *)(regs->gprs[15] + __SF_SIE_REASON)) = -EINTR;
490+ /* Set sie return code for host's later handling */
491+ ((struct stack_frame *)regs->gprs[15])->sie_return = SIE64_RETURN_MCCK;
492492 }
493493 clear_cpu_flag(CIF_MCCK_GUEST);
494494
arch/s390/kernel/syscall.c+4−1
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 */
1414
1515 #include <linux/cpufeature.h>
16+#include <linux/nospec.h>
1617 #include <linux/errno.h>
1718 #include <linux/sched.h>
1819 #include <linux/mm.h>
@@ -131,8 +132,10 @@ void noinstr __do_syscall(struct pt_regs *regs, int per_trap) · 112 unmodified lines
131132 if (unlikely(test_and_clear_pt_regs_flag(regs, PIF_SYSCALL_RET_SET)))
132133 goto out;
133134 regs->gprs[2] = -ENOSYS;
134− if (likely(nr < NR_syscalls))
135+ if (likely(nr < NR_syscalls)) {
136+ nr = array_index_nospec(nr, NR_syscalls);
135137 regs->gprs[2] = sys_call_table[nr](regs);
138+ }
136139 out:
137140 syscall_exit_to_user_mode(regs);
138141 }
arch/s390/kvm/dat.c+15−85
@@ -134,32 +134,6 @@ int dat_set_asce_limit(struct kvm_s390_mmu_cache *mc, union asce *asce, int newt · 133 unmodified lines
134134 return 0;
135135 }
136136
137−/**
138− * dat_crstep_xchg() - Exchange a gmap CRSTE with another.
139− * @crstep: Pointer to the CRST entry
140− * @new: Replacement entry.
141− * @gfn: The affected guest address.
142− * @asce: The ASCE of the address space.
143− *
144− * Context: This function is assumed to be called with kvm->mmu_lock held.
145− */
146−void dat_crstep_xchg(union crste *crstep, union crste new, gfn_t gfn, union asce asce)
147−{
148− if (crstep->h.i) {
149− WRITE_ONCE(*crstep, new);
150− return;
151− } else if (cpu_has_edat2()) {
152− crdte_crste(crstep, *crstep, new, gfn, asce);
153− return;
154− }
155−
156− if (machine_has_tlb_guest())
157− idte_crste(crstep, gfn, IDTE_GUEST_ASCE, asce, IDTE_GLOBAL);
158− else
159− idte_crste(crstep, gfn, 0, NULL_ASCE, IDTE_GLOBAL);
160− WRITE_ONCE(*crstep, new);
161−}
162−
163137 /**
164138 * dat_crstep_xchg_atomic() - Atomically exchange a gmap CRSTE with another.
165139 * @crstep: Pointer to the CRST entry.
@@ -175,8 +149,8 @@ void dat_crstep_xchg(union crste *crstep, union crste new, gfn_t gfn, union asce · 9 unmodified lines
175149 *
176150 * Return: %true if the exchange was successful.
177151 */
178−bool dat_crstep_xchg_atomic(union crste *crstep, union crste old, union crste new, gfn_t gfn,
179− union asce asce)
152+bool __must_check dat_crstep_xchg_atomic(union crste *crstep, union crste old, union crste new,
153+ gfn_t gfn, union asce asce)
180154 {
181155 if (old.h.i)
182156 return arch_try_cmpxchg((long *)crstep, &old.val, new.val);
@@ -292,6 +266,7 @@ static int dat_split_ste(struct kvm_s390_mmu_cache *mc, union pmd *pmdp, gfn_t g · 109 unmodified lines
292266 pt->ptes[i].val = init.val | i * PAGE_SIZE;
293267 /* No need to take locks as the page table is not installed yet. */
294268 pgste_init.prefix_notif = old.s.fc1.prefix_notif;
269+ pgste_init.vsie_notif = old.s.fc1.vsie_notif;
295270 pgste_init.pcl = uses_skeys && init.h.i;
296271 dat_init_pgstes(pt, pgste_init.val);
297272 } else {
@@ -893,7 +868,8 @@ static long _dat_slot_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct d · 595 unmodified lines
893868
894869 /* This table entry needs to be updated. */
895870 if (walk->start <= gfn && walk->end >= next) {
896− dat_crstep_xchg_atomic(crstep, crste, new_crste, gfn, walk->asce);
871+ if (!dat_crstep_xchg_atomic(crstep, crste, new_crste, gfn, walk->asce))
872+ return -EINVAL;
897873 /* A lower level table was present, needs to be freed. */
898874 if (!crste.h.fc && !crste.h.i) {
899875 if (is_pmd(crste))
@@ -1021,67 +997,21 @@ bool dat_test_age_gfn(union asce asce, gfn_t start, gfn_t end) · 121 unmodified lines
1021997 return _dat_walk_gfn_range(start, end, asce, &test_age_ops, 0, NULL) > 0;
1022998 }
1023999
1024−int dat_link(struct kvm_s390_mmu_cache *mc, union asce asce, int level,
1025− bool uses_skeys, struct guest_fault *f)
1026−{
1027− union crste oldval, newval;
1028− union pte newpte, oldpte;
1029− union pgste pgste;
1030− int rc = 0;
1031−
1032− rc = dat_entry_walk(mc, f->gfn, asce, DAT_WALK_ALLOC_CONTINUE, level, &f->crstep, &f->ptep);
1033− if (rc == -EINVAL || rc == -ENOMEM)
1034− return rc;
1035− if (rc)
1036− return -EAGAIN;
1037−
1038− if (WARN_ON_ONCE(unlikely(get_level(f->crstep, f->ptep) > level)))
1039− return -EINVAL;
1040−
1041− if (f->ptep) {
1042− pgste = pgste_get_lock(f->ptep);
1043− oldpte = *f->ptep;
1044− newpte = _pte(f->pfn, f->writable, f->write_attempt | oldpte.s.d, !f->page);
1045− newpte.s.sd = oldpte.s.sd;
1046− oldpte.s.sd = 0;
1047− if (oldpte.val == _PTE_EMPTY.val || oldpte.h.pfra == f->pfn) {
1048− pgste = __dat_ptep_xchg(f->ptep, pgste, newpte, f->gfn, asce, uses_skeys);
1049− if (f->callback)
1050− f->callback(f);
1051− } else {
1052− rc = -EAGAIN;
1053− }
1054− pgste_set_unlock(f->ptep, pgste);
1055− } else {
1056− oldval = READ_ONCE(*f->crstep);
1057− newval = _crste_fc1(f->pfn, oldval.h.tt, f->writable,
1058− f->write_attempt | oldval.s.fc1.d);
1059− newval.s.fc1.sd = oldval.s.fc1.sd;
1060− if (oldval.val != _CRSTE_EMPTY(oldval.h.tt).val &&
1061− crste_origin_large(oldval) != crste_origin_large(newval))
1062− return -EAGAIN;
1063− if (!dat_crstep_xchg_atomic(f->crstep, oldval, newval, f->gfn, asce))
1064− return -EAGAIN;
1065− if (f->callback)
1066− f->callback(f);
1067− }
1068−
1069− return rc;
1070−}
1071−
10721000 static long dat_set_pn_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
10731001 {
1074− union crste crste = READ_ONCE(*crstep);
1002+ union crste newcrste, oldcrste;
10751003 int *n = walk->priv;
10761004
1077− if (!crste.h.fc || crste.h.i || crste.h.p)
1078− return 0;
1079−
1005+ do {
1006+ oldcrste = READ_ONCE(*crstep);
1007+ if (!oldcrste.h.fc || oldcrste.h.i || oldcrste.h.p)
1008+ return 0;
1009+ if (oldcrste.s.fc1.prefix_notif)
1010+ break;
1011+ newcrste = oldcrste;
1012+ newcrste.s.fc1.prefix_notif = 1;
1013+ } while (!dat_crstep_xchg_atomic(crstep, oldcrste, newcrste, gfn, walk->asce));
10801014 *n = 2;
1081− if (crste.s.fc1.prefix_notif)
1082− return 0;
1083− crste.s.fc1.prefix_notif = 1;
1084− dat_crstep_xchg(crstep, crste, gfn, walk->asce);
10851015 return 0;
10861016 }
10871017
arch/s390/kvm/dat.h+12−11
@@ -160,14 +160,14 @@ union pmd { · 159 unmodified lines
160160 unsigned long :44; /* HW */
161161 unsigned long : 3; /* Unused */
162162 unsigned long : 1; /* HW */
163+ unsigned long s : 1; /* Special */
163164 unsigned long w : 1; /* Writable soft-bit */
164165 unsigned long r : 1; /* Readable soft-bit */
165166 unsigned long d : 1; /* Dirty */
166167 unsigned long y : 1; /* Young */
167− unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */
168168 unsigned long : 3; /* HW */
169+ unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */
169170 unsigned long vsie_notif : 1; /* Referenced in a shadow table */
170− unsigned long : 1; /* Unused */
171171 unsigned long : 4; /* HW */
172172 unsigned long sd : 1; /* Soft-Dirty */
173173 unsigned long pr : 1; /* Present */
@@ -183,14 +183,14 @@ union pud { · 9 unmodified lines
183183 unsigned long :33; /* HW */
184184 unsigned long :14; /* Unused */
185185 unsigned long : 1; /* HW */
186+ unsigned long s : 1; /* Special */
186187 unsigned long w : 1; /* Writable soft-bit */
187188 unsigned long r : 1; /* Readable soft-bit */
188189 unsigned long d : 1; /* Dirty */
189190 unsigned long y : 1; /* Young */
190− unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */
191191 unsigned long : 3; /* HW */
192+ unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */
192193 unsigned long vsie_notif : 1; /* Referenced in a shadow table */
193− unsigned long : 1; /* Unused */
194194 unsigned long : 4; /* HW */
195195 unsigned long sd : 1; /* Soft-Dirty */
196196 unsigned long pr : 1; /* Present */
@@ -254,14 +254,14 @@ union crste { · 57 unmodified lines
254254 struct {
255255 unsigned long :47;
256256 unsigned long : 1; /* HW (should be 0) */
257+ unsigned long s : 1; /* Special */
257258 unsigned long w : 1; /* Writable */
258259 unsigned long r : 1; /* Readable */
259260 unsigned long d : 1; /* Dirty */
260261 unsigned long y : 1; /* Young */
261− unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */
262262 unsigned long : 3; /* HW */
263+ unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */
263264 unsigned long vsie_notif : 1; /* Referenced in a shadow table */
264− unsigned long : 1;
265265 unsigned long : 4; /* HW */
266266 unsigned long sd : 1; /* Soft-Dirty */
267267 unsigned long pr : 1; /* Present */
@@ -540,8 +540,6 @@ int dat_set_slot(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t start, gf · 272 unmodified lines
540540 u16 type, u16 param);
541541 int dat_set_prefix_notif_bit(union asce asce, gfn_t gfn);
542542 bool dat_test_age_gfn(union asce asce, gfn_t start, gfn_t end);
543−int dat_link(struct kvm_s390_mmu_cache *mc, union asce asce, int level,
544− bool uses_skeys, struct guest_fault *f);
545543
546544 int dat_perform_essa(union asce asce, gfn_t gfn, int orc, union essa_state *state, bool *dirty);
547545 long dat_reset_cmma(union asce asce, gfn_t start_gfn);
@@ -938,11 +936,14 @@ static inline bool dat_pudp_xchg_atomic(union pud *pudp, union pud old, union pu · 390 unmodified lines
938936 return dat_crstep_xchg_atomic(_CRSTEP(pudp), _CRSTE(old), _CRSTE(new), gfn, asce);
939937 }
940938
941−static inline void dat_crstep_clear(union crste *crstep, gfn_t gfn, union asce asce)
939+static inline union crste dat_crstep_clear_atomic(union crste *crstep, gfn_t gfn, union asce asce)
942940 {
943− union crste newcrste = _CRSTE_EMPTY(crstep->h.tt);
941+ union crste oldcrste, empty = _CRSTE_EMPTY(crstep->h.tt);
944942
945− dat_crstep_xchg(crstep, newcrste, gfn, asce);
943+ do {
944+ oldcrste = READ_ONCE(*crstep);
945+ } while (!dat_crstep_xchg_atomic(crstep, oldcrste, empty, gfn, asce));
946+ return oldcrste;
946947 }
947948
948949 static inline int get_level(union crste *crstep, union pte *ptep)
arch/s390/kvm/gaccess.c+55−22
@@ -1434,17 +1434,27 @@ static int _do_shadow_pte(struct gmap *sg, gpa_t raddr, union pte *ptep_h, union · 1433 unmodified lines
14341434 if (rc)
14351435 return rc;
14361436
1437− pgste = pgste_get_lock(ptep_h);
1438− newpte = _pte(f->pfn, f->writable, !p, 0);
1439− newpte.s.d |= ptep->s.d;
1440− newpte.s.sd |= ptep->s.sd;
1441− newpte.h.p &= ptep->h.p;
1442− pgste = _gmap_ptep_xchg(sg->parent, ptep_h, newpte, pgste, f->gfn, false);
1443− pgste.vsie_notif = 1;
1437+ if (!pgste_get_trylock(ptep_h, &pgste))
1438+ return -EAGAIN;
1439+ newpte = _pte(f->pfn, f->writable, !p, ptep_h->s.s);
1440+ newpte.s.d |= ptep_h->s.d;
1441+ newpte.s.sd |= ptep_h->s.sd;
1442+ newpte.h.p &= ptep_h->h.p;
1443+ if (!newpte.h.p && !f->writable) {
1444+ rc = -EOPNOTSUPP;
1445+ } else {
1446+ pgste = _gmap_ptep_xchg(sg->parent, ptep_h, newpte, pgste, f->gfn, false);
1447+ pgste.vsie_notif = 1;
1448+ }
14441449 pgste_set_unlock(ptep_h, pgste);
1450+ if (rc)
1451+ return rc;
1452+ if (!sg->parent)
1453+ return -EAGAIN;
14451454
14461455 newpte = _pte(f->pfn, 0, !p, 0);
1447− pgste = pgste_get_lock(ptep);
1456+ if (!pgste_get_trylock(ptep, &pgste))
1457+ return -EAGAIN;
14481458 pgste = __dat_ptep_xchg(ptep, pgste, newpte, gpa_to_gfn(raddr), sg->asce, uses_skeys(sg));
14491459 pgste_set_unlock(ptep, pgste);
14501460
@@ -1454,7 +1464,7 @@ static int _do_shadow_pte(struct gmap *sg, gpa_t raddr, union pte *ptep_h, union · 3 unmodified lines
14541464 static int _do_shadow_crste(struct gmap *sg, gpa_t raddr, union crste *host, union crste *table,
14551465 struct guest_fault *f, bool p)
14561466 {
1457− union crste newcrste;
1467+ union crste newcrste, oldcrste;
14581468 gfn_t gfn;
14591469 int rc;
14601470
@@ -1467,16 +1477,28 @@ static int _do_shadow_crste(struct gmap *sg, gpa_t raddr, union crste *host, uni · 6 unmodified lines
14671477 if (rc)
14681478 return rc;
14691479
1470− newcrste = _crste_fc1(f->pfn, host->h.tt, f->writable, !p);
1471− newcrste.s.fc1.d |= host->s.fc1.d;
1472− newcrste.s.fc1.sd |= host->s.fc1.sd;
1473− newcrste.h.p &= host->h.p;
1474− newcrste.s.fc1.vsie_notif = 1;
1475− newcrste.s.fc1.prefix_notif = host->s.fc1.prefix_notif;
1476− _gmap_crstep_xchg(sg->parent, host, newcrste, f->gfn, false);
1480+ do {
1481+ /* _gmap_crstep_xchg_atomic() could have unshadowed this shadow gmap */
1482+ if (!sg->parent)
1483+ return -EAGAIN;
1484+ oldcrste = READ_ONCE(*host);
1485+ newcrste = _crste_fc1(f->pfn, oldcrste.h.tt, f->writable, !p);
1486+ newcrste.s.fc1.d |= oldcrste.s.fc1.d;
1487+ newcrste.s.fc1.sd |= oldcrste.s.fc1.sd;
1488+ newcrste.h.p &= oldcrste.h.p;
1489+ newcrste.s.fc1.vsie_notif = 1;
1490+ newcrste.s.fc1.prefix_notif = oldcrste.s.fc1.prefix_notif;
1491+ newcrste.s.fc1.s = oldcrste.s.fc1.s;
1492+ if (!newcrste.h.p && !f->writable)
1493+ return -EOPNOTSUPP;
1494+ } while (!_gmap_crstep_xchg_atomic(sg->parent, host, oldcrste, newcrste, f->gfn, false));
1495+ if (!sg->parent)
1496+ return -EAGAIN;
14771497
1478− newcrste = _crste_fc1(f->pfn, host->h.tt, 0, !p);
1479− dat_crstep_xchg(table, newcrste, gpa_to_gfn(raddr), sg->asce);
1498+ newcrste = _crste_fc1(f->pfn, oldcrste.h.tt, 0, !p);
1499+ gfn = gpa_to_gfn(raddr);
1500+ while (!dat_crstep_xchg_atomic(table, READ_ONCE(*table), newcrste, gfn, sg->asce))
1501+ ;
14801502 return 0;
14811503 }
14821504
@@ -1500,21 +1522,31 @@ static int _gaccess_do_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *sg, · 17 unmodified lines
15001522 if (rc)
15011523 return rc;
15021524
1503− /* A race occourred. The shadow mapping is already valid, nothing to do */
1504− if ((ptep && !ptep->h.i) || (!ptep && crste_leaf(*table)))
1525+ /* A race occurred. The shadow mapping is already valid, nothing to do */
1526+ if ((ptep && !ptep->h.i && ptep->h.p == w->p) ||
1527+ (!ptep && crste_leaf(*table) && !table->h.i && table->h.p == w->p))
15051528 return 0;
15061529
15071530 gl = get_level(table, ptep);
15081531
1532+ /* In case of a real address space */
1533+ if (w->level <= LEVEL_MEM) {
1534+ l = TABLE_TYPE_PAGE_TABLE;
1535+ hl = TABLE_TYPE_REGION1;
1536+ goto real_address_space;
1537+ }
1538+
15091539 /*
15101540 * Skip levels that are already protected. For each level, protect
15111541 * only the page containing the entry, not the whole table.
15121542 */
15131543 for (i = gl ; i >= w->level; i--) {
1514− rc = gmap_protect_rmap(mc, sg, entries[i - 1].gfn, gpa_to_gfn(saddr),
1515− entries[i - 1].pfn, i, entries[i - 1].writable);
1544+ rc = gmap_protect_rmap(mc, sg, entries[i].gfn, gpa_to_gfn(saddr),
1545+ entries[i].pfn, i + 1, entries[i].writable);
15161546 if (rc)
15171547 return rc;
1548+ if (!sg->parent)
1549+ return -EAGAIN;
15181550 }
15191551
15201552 rc = dat_entry_walk(NULL, entries[LEVEL_MEM].gfn, sg->parent->asce, DAT_WALK_LEAF,
@@ -1526,6 +1558,7 @@ static int _gaccess_do_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *sg, · 5 unmodified lines
15261558 /* Get the smallest granularity */
15271559 l = min3(gl, hl, w->level);
15281560
1561+real_address_space:
15291562 flags = DAT_WALK_SPLIT_ALLOC | (uses_skeys(sg->parent) ? DAT_WALK_USES_SKEYS : 0);
15301563 /* If necessary, create the shadow mapping */
15311564 if (l < gl) {
arch/s390/kvm/gmap.c+114−46
@@ -313,13 +313,16 @@ static long gmap_clear_young_crste(union crste *crstep, gfn_t gfn, gfn_t end, st · 312 unmodified lines
313313 struct clear_young_pte_priv *priv = walk->priv;
314314 union crste crste, new;
315315
316− crste = READ_ONCE(*crstep);
316+ do {
317+ crste = READ_ONCE(*crstep);
318+
319+ if (!crste.h.fc)
320+ return 0;
321+ if (!crste.s.fc1.y && crste.h.i)
322+ return 0;
323+ if (crste_prefix(crste) && !gmap_mkold_prefix(priv->gmap, gfn, end))
324+ break;
317325
318− if (!crste.h.fc)
319− return 0;
320− if (!crste.s.fc1.y && crste.h.i)
321− return 0;
322− if (!crste_prefix(crste) || gmap_mkold_prefix(priv->gmap, gfn, end)) {
323326 new = crste;
324327 new.h.i = 1;
325328 new.s.fc1.y = 0;
@@ -328,8 +331,8 @@ static long gmap_clear_young_crste(union crste *crstep, gfn_t gfn, gfn_t end, st · 2 unmodified lines
328331 folio_set_dirty(phys_to_folio(crste_origin_large(crste)));
329332 new.s.fc1.d = 0;
330333 new.h.p = 1;
331− dat_crstep_xchg(crstep, new, gfn, walk->asce);
332− }
334+ } while (!dat_crstep_xchg_atomic(crstep, crste, new, gfn, walk->asce));
335+
333336 priv->young = 1;
334337 return 0;
335338 }
@@ -391,14 +394,18 @@ static long _gmap_unmap_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct · 55 unmodified lines
391394 {
392395 struct gmap_unmap_priv *priv = walk->priv;
393396 struct folio *folio = NULL;
397+ union crste old = *crstep;
394398
395− if (crstep->h.fc) {
396− if (crstep->s.fc1.pr && test_bit(GMAP_FLAG_EXPORT_ON_UNMAP, &priv->gmap->flags))
397− folio = phys_to_folio(crste_origin_large(*crstep));
398− gmap_crstep_xchg(priv->gmap, crstep, _CRSTE_EMPTY(crstep->h.tt), gfn);
399− if (folio)
400− uv_convert_from_secure_folio(folio);
401− }
399+ if (!old.h.fc)
400+ return 0;
401+
402+ if (old.s.fc1.pr && test_bit(GMAP_FLAG_EXPORT_ON_UNMAP, &priv->gmap->flags))
403+ folio = phys_to_folio(crste_origin_large(old));
404+ /* No races should happen because kvm->mmu_lock is held in write mode */
405+ KVM_BUG_ON(!gmap_crstep_xchg_atomic(priv->gmap, crstep, old, _CRSTE_EMPTY(old.h.tt), gfn),
406+ priv->gmap->kvm);
407+ if (folio)
408+ uv_convert_from_secure_folio(folio);
402409
403410 return 0;
404411 }
@@ -474,23 +481,24 @@ static long _crste_test_and_clear_softdirty(union crste *table, gfn_t gfn, gfn_t · 69 unmodified lines
474481
475482 if (fatal_signal_pending(current))
476483 return 1;
477− crste = READ_ONCE(*table);
478− if (!crste.h.fc)
479− return 0;
480− if (crste.h.p && !crste.s.fc1.sd)
481− return 0;
484+ do {
485+ crste = READ_ONCE(*table);
486+ if (!crste.h.fc)
487+ return 0;
488+ if (crste.h.p && !crste.s.fc1.sd)
489+ return 0;
482490
483− /*
484− * If this large page contains one or more prefixes of vCPUs that are
485− * currently running, do not reset the protection, leave it marked as
486− * dirty.
487− */
488− if (!crste.s.fc1.prefix_notif || gmap_mkold_prefix(gmap, gfn, end)) {
491+ /*
492+ * If this large page contains one or more prefixes of vCPUs that are
493+ * currently running, do not reset the protection, leave it marked as
494+ * dirty.
495+ */
496+ if (crste.s.fc1.prefix_notif && !gmap_mkold_prefix(gmap, gfn, end))
497+ break;
489498 new = crste;
490499 new.h.p = 1;
491500 new.s.fc1.sd = 0;
492− gmap_crstep_xchg(gmap, table, new, gfn);
493− }
501+ } while (!gmap_crstep_xchg_atomic(gmap, table, crste, new, gfn));
494502
495503 for ( ; gfn < end; gfn++)
496504 mark_page_dirty(gmap->kvm, gfn);
@@ -511,7 +519,7 @@ void gmap_sync_dirty_log(struct gmap *gmap, gfn_t start, gfn_t end) · 14 unmodified lines
511519 _dat_walk_gfn_range(start, end, gmap->asce, &walk_ops, 0, gmap);
512520 }
513521
514−static int gmap_handle_minor_crste_fault(union asce asce, struct guest_fault *f)
522+static int gmap_handle_minor_crste_fault(struct gmap *gmap, struct guest_fault *f)
515523 {
516524 union crste newcrste, oldcrste = READ_ONCE(*f->crstep);
517525
@@ -536,10 +544,8 @@ static int gmap_handle_minor_crste_fault(union asce asce, struct guest_fault *f) · 18 unmodified lines
536544 newcrste.s.fc1.d = 1;
537545 newcrste.s.fc1.sd = 1;
538546 }
539− if (!oldcrste.s.fc1.d && newcrste.s.fc1.d)
540− SetPageDirty(phys_to_page(crste_origin_large(newcrste)));
541547 /* In case of races, let the slow path deal with it. */
542− return !dat_crstep_xchg_atomic(f->crstep, oldcrste, newcrste, f->gfn, asce);
548+ return !gmap_crstep_xchg_atomic(gmap, f->crstep, oldcrste, newcrste, f->gfn);
543549 }
544550 /* Trying to write on a read-only page, let the slow path deal with it. */
545551 return 1;
@@ -568,8 +574,6 @@ static int _gmap_handle_minor_pte_fault(struct gmap *gmap, union pgste *pgste, · 22 unmodified lines
568574 newpte.s.d = 1;
569575 newpte.s.sd = 1;
570576 }
571− if (!oldpte.s.d && newpte.s.d)
572− SetPageDirty(pfn_to_page(newpte.h.pfra));
573577 *pgste = gmap_ptep_xchg(gmap, f->ptep, newpte, *pgste, f->gfn);
574578
575579 return 0;
@@ -606,7 +610,7 @@ int gmap_try_fixup_minor(struct gmap *gmap, struct guest_fault *fault) · 30 unmodified lines
606610 fault->callback(fault);
607611 pgste_set_unlock(fault->ptep, pgste);
608612 } else {
609− rc = gmap_handle_minor_crste_fault(gmap->asce, fault);
613+ rc = gmap_handle_minor_crste_fault(gmap, fault);
610614 if (!rc && fault->callback)
611615 fault->callback(fault);
612616 }
@@ -623,10 +627,61 @@ static inline bool gmap_1m_allowed(struct gmap *gmap, gfn_t gfn) · 10 unmodified lines
623627 return test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &gmap->flags);
624628 }
625629
630+static int _gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, int level,
631+ struct guest_fault *f)
632+{
633+ union crste oldval, newval;
634+ union pte newpte, oldpte;
635+ union pgste pgste;
636+ int rc = 0;
637+
638+ rc = dat_entry_walk(mc, f->gfn, gmap->asce, DAT_WALK_ALLOC_CONTINUE, level,
639+ &f->crstep, &f->ptep);
640+ if (rc == -ENOMEM)
641+ return rc;
642+ if (KVM_BUG_ON(rc == -EINVAL, gmap->kvm))
643+ return rc;
644+ if (rc)
645+ return -EAGAIN;
646+ if (KVM_BUG_ON(get_level(f->crstep, f->ptep) > level, gmap->kvm))
647+ return -EINVAL;
648+
649+ if (f->ptep) {
650+ pgste = pgste_get_lock(f->ptep);
651+ oldpte = *f->ptep;
652+ newpte = _pte(f->pfn, f->writable, f->write_attempt | oldpte.s.d, !f->page);
653+ newpte.s.sd = oldpte.s.sd;
654+ oldpte.s.sd = 0;
655+ if (oldpte.val == _PTE_EMPTY.val || oldpte.h.pfra == f->pfn) {
656+ pgste = gmap_ptep_xchg(gmap, f->ptep, newpte, pgste, f->gfn);
657+ if (f->callback)
658+ f->callback(f);
659+ } else {
660+ rc = -EAGAIN;
661+ }
662+ pgste_set_unlock(f->ptep, pgste);
663+ } else {
664+ do {
665+ oldval = READ_ONCE(*f->crstep);
666+ newval = _crste_fc1(f->pfn, oldval.h.tt, f->writable,
667+ f->write_attempt | oldval.s.fc1.d);
668+ newval.s.fc1.s = !f->page;
669+ newval.s.fc1.sd = oldval.s.fc1.sd;
670+ if (oldval.val != _CRSTE_EMPTY(oldval.h.tt).val &&
671+ crste_origin_large(oldval) != crste_origin_large(newval))
672+ return -EAGAIN;
673+ } while (!gmap_crstep_xchg_atomic(gmap, f->crstep, oldval, newval, f->gfn));
674+ if (f->callback)
675+ f->callback(f);
676+ }
677+
678+ return rc;
679+}
680+
626681 int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fault *f)
627682 {
628683 unsigned int order;
629− int rc, level;
684+ int level;
630685
631686 lockdep_assert_held(&gmap->kvm->mmu_lock);
632687
@@ -638,16 +693,14 @@ int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fau · 5 unmodified lines
638693 else if (order >= get_order(_SEGMENT_SIZE) && gmap_1m_allowed(gmap, f->gfn))
639694 level = TABLE_TYPE_SEGMENT;
640695 }
641− rc = dat_link(mc, gmap->asce, level, uses_skeys(gmap), f);
642− KVM_BUG_ON(rc == -EINVAL, gmap->kvm);
643− return rc;
696+ return _gmap_link(mc, gmap, level, f);
644697 }
645698
646699 static int gmap_ucas_map_one(struct kvm_s390_mmu_cache *mc, struct gmap *gmap,
647700 gfn_t p_gfn, gfn_t c_gfn, bool force_alloc)
648701 {
702+ union crste newcrste, oldcrste;
649703 struct page_table *pt;
650− union crste newcrste;
651704 union crste *crstep;
652705 union pte *ptep;
653706 int rc;
@@ -673,7 +726,11 @@ static int gmap_ucas_map_one(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, · 19 unmodified lines
673726 &crstep, &ptep);
674727 if (rc)
675728 return rc;
676− dat_crstep_xchg(crstep, newcrste, c_gfn, gmap->asce);
729+ do {
730+ oldcrste = READ_ONCE(*crstep);
731+ if (oldcrste.val == newcrste.val)
732+ break;
733+ } while (!dat_crstep_xchg_atomic(crstep, oldcrste, newcrste, c_gfn, gmap->asce));
677734 return 0;
678735 }
679736
@@ -777,8 +834,10 @@ static void gmap_ucas_unmap_one(struct gmap *gmap, gfn_t c_gfn) · 97 unmodified lines
777834 int rc;
778835
779836 rc = dat_entry_walk(NULL, c_gfn, gmap->asce, 0, TABLE_TYPE_SEGMENT, &crstep, &ptep);
780− if (!rc)
781− dat_crstep_xchg(crstep, _PMD_EMPTY, c_gfn, gmap->asce);
837+ if (rc)
838+ return;
839+ while (!dat_crstep_xchg_atomic(crstep, READ_ONCE(*crstep), _PMD_EMPTY, c_gfn, gmap->asce))
840+ ;
782841 }
783842
784843 void gmap_ucas_unmap(struct gmap *gmap, gfn_t c_gfn, unsigned long count)
@@ -1017,8 +1076,8 @@ static void gmap_unshadow_level(struct gmap *sg, gfn_t r_gfn, int level) · 232 unmodified lines
10171076 dat_ptep_xchg(ptep, _PTE_EMPTY, r_gfn, sg->asce, uses_skeys(sg));
10181077 return;
10191078 }
1020− crste = READ_ONCE(*crstep);
1021− dat_crstep_clear(crstep, r_gfn, sg->asce);
1079+
1080+ crste = dat_crstep_clear_atomic(crstep, r_gfn, sg->asce);
10221081 if (crste_leaf(crste) || crste.h.i)
10231082 return;
10241083 if (is_pmd(crste))
@@ -1101,6 +1160,7 @@ struct gmap_protect_asce_top_level { · 76 unmodified lines
11011160 static inline int __gmap_protect_asce_top_level(struct kvm_s390_mmu_cache *mc, struct gmap *sg,
11021161 struct gmap_protect_asce_top_level *context)
11031162 {
1163+ struct gmap *parent;
11041164 int rc, i;
11051165
11061166 guard(write_lock)(&sg->kvm->mmu_lock);
@@ -1108,7 +1168,12 @@ static inline int __gmap_protect_asce_top_level(struct kvm_s390_mmu_cache *mc, s · 1 unmodified line
11081168 if (kvm_s390_array_needs_retry_safe(sg->kvm, context->seq, context->f))
11091169 return -EAGAIN;
11101170
1111− scoped_guard(spinlock, &sg->parent->children_lock) {
1171+ parent = READ_ONCE(sg->parent);
1172+ if (!parent)
1173+ return -EAGAIN;
1174+ scoped_guard(spinlock, &parent->children_lock) {
1175+ if (READ_ONCE(sg->parent) != parent)
1176+ return -EAGAIN;
11121177 for (i = 0; i < CRST_TABLE_PAGES; i++) {
11131178 if (!context->f[i].valid)
11141179 continue;
@@ -1191,6 +1256,9 @@ struct gmap *gmap_create_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *pare · 76 unmodified lines
11911256 struct gmap *sg, *new;
11921257 int rc;
11931258
1259+ if (WARN_ON(!parent))
1260+ return ERR_PTR(-EINVAL);
1261+
11941262 scoped_guard(spinlock, &parent->children_lock) {
11951263 sg = gmap_find_shadow(parent, asce, edat_level);
11961264 if (sg) {
arch/s390/kvm/gmap.h+21−12
@@ -185,6 +185,8 @@ static inline union pgste _gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, un · 184 unmodified lines
185185 else
186186 _gmap_handle_vsie_unshadow_event(gmap, gfn);
187187 }
188+ if (!ptep->s.d && newpte.s.d && !newpte.s.s)
189+ SetPageDirty(pfn_to_page(newpte.h.pfra));
188190 return __dat_ptep_xchg(ptep, pgste, newpte, gfn, gmap->asce, uses_skeys(gmap));
189191 }
190192
@@ -194,35 +196,42 @@ static inline union pgste gmap_ptep_xchg(struct gmap *gmap, union pte *ptep, uni · 3 unmodified lines
194196 return _gmap_ptep_xchg(gmap, ptep, newpte, pgste, gfn, true);
195197 }
196198
197−static inline void _gmap_crstep_xchg(struct gmap *gmap, union crste *crstep, union crste ne,
198− gfn_t gfn, bool needs_lock)
199+static inline bool __must_check _gmap_crstep_xchg_atomic(struct gmap *gmap, union crste *crstep,
200+ union crste oldcrste, union crste newcrste,
201+ gfn_t gfn, bool needs_lock)
199202 {
200− unsigned long align = 8 + (is_pmd(*crstep) ? 0 : 11);
203+ unsigned long align = is_pmd(newcrste) ? _PAGE_ENTRIES : _PAGE_ENTRIES * _CRST_ENTRIES;
204+
205+ if (KVM_BUG_ON(crstep->h.tt != oldcrste.h.tt || newcrste.h.tt != oldcrste.h.tt, gmap->kvm))
206+ return true;
201207
202208 lockdep_assert_held(&gmap->kvm->mmu_lock);
203209 if (!needs_lock)
204210 lockdep_assert_held(&gmap->children_lock);
205211
206212 gfn = ALIGN_DOWN(gfn, align);
207− if (crste_prefix(*crstep) && (ne.h.p || ne.h.i || !crste_prefix(ne))) {
208− ne.s.fc1.prefix_notif = 0;
213+ if (crste_prefix(oldcrste) && (newcrste.h.p || newcrste.h.i || !crste_prefix(newcrste))) {
214+ newcrste.s.fc1.prefix_notif = 0;
209215 gmap_unmap_prefix(gmap, gfn, gfn + align);
210216 }
211− if (crste_leaf(*crstep) && crstep->s.fc1.vsie_notif &&
212− (ne.h.p || ne.h.i || !ne.s.fc1.vsie_notif)) {
213− ne.s.fc1.vsie_notif = 0;
217+ if (crste_leaf(oldcrste) && oldcrste.s.fc1.vsie_notif &&
218+ (newcrste.h.p || newcrste.h.i || !newcrste.s.fc1.vsie_notif)) {
219+ newcrste.s.fc1.vsie_notif = 0;
214220 if (needs_lock)
215221 gmap_handle_vsie_unshadow_event(gmap, gfn);
216222 else
217223 _gmap_handle_vsie_unshadow_event(gmap, gfn);
218224 }
219− dat_crstep_xchg(crstep, ne, gfn, gmap->asce);
225+ if (!oldcrste.s.fc1.d && newcrste.s.fc1.d && !newcrste.s.fc1.s)
226+ SetPageDirty(phys_to_page(crste_origin_large(newcrste)));
227+ return dat_crstep_xchg_atomic(crstep, oldcrste, newcrste, gfn, gmap->asce);
220228 }
221229
222−static inline void gmap_crstep_xchg(struct gmap *gmap, union crste *crstep, union crste ne,
223− gfn_t gfn)
230+static inline bool __must_check gmap_crstep_xchg_atomic(struct gmap *gmap, union crste *crstep,
231+ union crste oldcrste, union crste newcrste,
232+ gfn_t gfn)
224233 {
225− return _gmap_crstep_xchg(gmap, crstep, ne, gfn, true);
234+ return _gmap_crstep_xchg_atomic(gmap, crstep, oldcrste, newcrste, gfn, true);
226235 }
227236
228237 /**
arch/s390/kvm/interrupt.c+18−0
@@ -2724,6 +2724,9 @@ static unsigned long get_ind_bit(__u64 addr, unsigned long bit_nr, bool swap) · 2723 unmodified lines
27242724
27252725 bit = bit_nr + (addr % PAGE_SIZE) * 8;
27262726
2727+ /* kvm_set_routing_entry() should never allow this to happen */
2728+ WARN_ON_ONCE(bit > (PAGE_SIZE * BITS_PER_BYTE - 1));
2729+
27272730 return swap ? (bit ^ (BITS_PER_LONG - 1)) : bit;
27282731 }
27292732
@@ -2824,6 +2827,12 @@ void kvm_s390_reinject_machine_check(struct kvm_vcpu *vcpu, · 94 unmodified lines
28242827 int rc;
28252828
28262829 mci.val = mcck_info->mcic;
2830+
2831+ /* log machine checks being reinjected on all debugs */
2832+ VCPU_EVENT(vcpu, 2, "guest machine check %lx", mci.val);
2833+ KVM_EVENT(2, "guest machine check %lx", mci.val);
2834+ pr_info("guest machine check pid %d: %lx", current->pid, mci.val);
2835+
28272836 if (mci.sr)
28282837 cr14 |= CR14_RECOVERY_SUBMASK;
28292838 if (mci.dg)
@@ -2852,6 +2861,7 @@ int kvm_set_routing_entry(struct kvm *kvm, · 22 unmodified lines
28522861 struct kvm_kernel_irq_routing_entry *e,
28532862 const struct kvm_irq_routing_entry *ue)
28542863 {
2864+ const struct kvm_irq_routing_s390_adapter *adapter;
28552865 u64 uaddr_s, uaddr_i;
28562866 int idx;
28572867
@@ -2862,6 +2872,14 @@ int kvm_set_routing_entry(struct kvm *kvm, · 4 unmodified lines
28622872 return -EINVAL;
28632873 e->set = set_adapter_int;
28642874
2875+ adapter = &ue->u.adapter;
2876+ if (adapter->summary_addr + (adapter->summary_offset / 8) >=
2877+ (adapter->summary_addr & PAGE_MASK) + PAGE_SIZE)
2878+ return -EINVAL;
2879+ if (adapter->ind_addr + (adapter->ind_offset / 8) >=
2880+ (adapter->ind_addr & PAGE_MASK) + PAGE_SIZE)
2881+ return -EINVAL;
2882+
28652883 idx = srcu_read_lock(&kvm->srcu);
28662884 uaddr_s = gpa_to_hva(kvm, ue->u.adapter.summary_addr);
28672885 uaddr_i = gpa_to_hva(kvm, ue->u.adapter.ind_addr);
arch/s390/kvm/kvm-s390.c+23−11
@@ -4617,7 +4617,7 @@ static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu) · 4616 unmodified lines
46174617 return 0;
46184618 }
46194619
4620−static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason)
4620+static int vcpu_post_run(struct kvm_vcpu *vcpu, int sie_return)
46214621 {
46224622 struct mcck_volatile_info *mcck_info;
46234623 struct sie_page *sie_page;
@@ -4633,14 +4633,14 @@ static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason) · 9 unmodified lines
46334633 vcpu->run->s.regs.gprs[14] = vcpu->arch.sie_block->gg14;
46344634 vcpu->run->s.regs.gprs[15] = vcpu->arch.sie_block->gg15;
46354635
4636− if (exit_reason == -EINTR) {
4637− VCPU_EVENT(vcpu, 3, "%s", "machine check");
4636+ if (sie_return == SIE64_RETURN_MCCK) {
46384637 sie_page = container_of(vcpu->arch.sie_block,
46394638 struct sie_page, sie_block);
46404639 mcck_info = &sie_page->mcck_info;
46414640 kvm_s390_reinject_machine_check(vcpu, mcck_info);
46424641 return 0;
46434642 }
4643+ WARN_ON_ONCE(sie_return != SIE64_RETURN_NORMAL);
46444644
46454645 if (vcpu->arch.sie_block->icptcode > 0) {
46464646 rc = kvm_handle_sie_intercept(vcpu);
@@ -4679,7 +4679,7 @@ int noinstr kvm_s390_enter_exit_sie(struct kvm_s390_sie_block *scb, · 32 unmodified lines
46794679 #define PSW_INT_MASK (PSW_MASK_EXT | PSW_MASK_IO | PSW_MASK_MCHECK)
46804680 static int __vcpu_run(struct kvm_vcpu *vcpu)
46814681 {
4682− int rc, exit_reason;
4682+ int rc, sie_return;
46834683 struct sie_page *sie_page = (struct sie_page *)vcpu->arch.sie_block;
46844684
46854685 /*
@@ -4719,9 +4719,9 @@ xfer_to_guest_mode_check: · 33 unmodified lines
47194719 guest_timing_enter_irqoff();
47204720 __disable_cpu_timer_accounting(vcpu);
47214721
4722− exit_reason = kvm_s390_enter_exit_sie(vcpu->arch.sie_block,
4723− vcpu->run->s.regs.gprs,
4724− vcpu->arch.gmap->asce.val);
4722+ sie_return = kvm_s390_enter_exit_sie(vcpu->arch.sie_block,
4723+ vcpu->run->s.regs.gprs,
4724+ vcpu->arch.gmap->asce.val);
47254725
47264726 __enable_cpu_timer_accounting(vcpu);
47274727 guest_timing_exit_irqoff();
@@ -4744,7 +4744,7 @@ xfer_to_guest_mode_check: · 16 unmodified lines
47444744 }
47454745 kvm_vcpu_srcu_read_lock(vcpu);
47464746
4747− rc = vcpu_post_run(vcpu, exit_reason);
4747+ rc = vcpu_post_run(vcpu, sie_return);
47484748 if (rc || guestdbg_exit_pending(vcpu)) {
47494749 kvm_vcpu_srcu_read_unlock(vcpu);
47504750 break;
@@ -5520,9 +5520,21 @@ long kvm_arch_vcpu_ioctl(struct file *filp, · 769 unmodified lines
55205520 }
55215521 #endif
55225522 case KVM_S390_VCPU_FAULT: {
5523− idx = srcu_read_lock(&vcpu->kvm->srcu);
5524− r = vcpu_dat_fault_handler(vcpu, arg, 0);
5525− srcu_read_unlock(&vcpu->kvm->srcu, idx);
5523+ gpa_t gaddr = arg;
5524+
5525+ scoped_guard(srcu, &vcpu->kvm->srcu) {
5526+ r = vcpu_ucontrol_translate(vcpu, &gaddr);
5527+ if (r)
5528+ break;
5529+
5530+ r = kvm_s390_faultin_gfn_simple(vcpu, NULL, gpa_to_gfn(gaddr), false);
5531+ if (r == PGM_ADDRESSING)
5532+ r = -EFAULT;
5533+ if (r <= 0)
5534+ break;
5535+ r = -EIO;
5536+ KVM_BUG_ON(r, vcpu->kvm);
5537+ }
55265538 break;
55275539 }
55285540 case KVM_ENABLE_CAP:
arch/s390/kvm/vsie.c+8−4
@@ -1122,6 +1122,7 @@ static int do_vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page, struc · 1121 unmodified lines
11221122 {
11231123 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
11241124 struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
1125+ unsigned long sie_return = SIE64_RETURN_NORMAL;
11251126 int guest_bp_isolation;
11261127 int rc = 0;
11271128
@@ -1163,7 +1164,7 @@ xfer_to_guest_mode_check: · 35 unmodified lines
11631164 goto xfer_to_guest_mode_check;
11641165 }
11651166 guest_timing_enter_irqoff();
1166− rc = kvm_s390_enter_exit_sie(scb_s, vcpu->run->s.regs.gprs, sg->asce.val);
1167+ sie_return = kvm_s390_enter_exit_sie(scb_s, vcpu->run->s.regs.gprs, sg->asce.val);
11671168 guest_timing_exit_irqoff();
11681169 local_irq_enable();
11691170 }
@@ -1178,12 +1179,13 @@ skip_sie: · 8 unmodified lines
11781179
11791180 kvm_vcpu_srcu_read_lock(vcpu);
11801181
1181− if (rc == -EINTR) {
1182− VCPU_EVENT(vcpu, 3, "%s", "machine check");
1182+ if (sie_return == SIE64_RETURN_MCCK) {
11831183 kvm_s390_reinject_machine_check(vcpu, &vsie_page->mcck_info);
11841184 return 0;
11851185 }
11861186
1187+ WARN_ON_ONCE(sie_return != SIE64_RETURN_NORMAL);
1188+
11871189 if (rc > 0)
11881190 rc = 0; /* we could still have an icpt */
11891191 else if (current->thread.gmap_int_code)
@@ -1326,7 +1328,7 @@ static void unregister_shadow_scb(struct kvm_vcpu *vcpu) · 136 unmodified lines
13261328 static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
13271329 {
13281330 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
1329− struct gmap *sg;
1331+ struct gmap *sg = NULL;
13301332 int rc = 0;
13311333
13321334 while (1) {
@@ -1366,6 +1368,8 @@ static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) · 33 unmodified lines
13661368 sg = gmap_put(sg);
13671369 cond_resched();
13681370 }
1371+ if (sg)
1372+ sg = gmap_put(sg);
13691373
13701374 if (rc == -EFAULT) {
13711375 /*
arch/s390/mm/fault.c+9−2
@@ -441,10 +441,17 @@ void do_secure_storage_access(struct pt_regs *regs) · 440 unmodified lines
441441 folio = phys_to_folio(addr);
442442 if (unlikely(!folio_try_get(folio)))
443443 return;
444− rc = arch_make_folio_accessible(folio);
444+ rc = uv_convert_from_secure(folio_to_phys(folio));
445+ if (!rc)
446+ clear_bit(PG_arch_1, &folio->flags.f);
445447 folio_put(folio);
448+ /*
449+ * There are some valid fixup types for kernel
450+ * accesses to donated secure memory. zeropad is one
451+ * of them.
452+ */
446453 if (rc)
447− BUG();
454+ return handle_fault_error_nolock(regs, 0);
448455 } else {
449456 if (faulthandler_disabled())
450457 return handle_fault_error_nolock(regs, 0);
arch/x86/coco/sev/noinstr.c+6−0
@@ -121,6 +121,9 @@ noinstr struct ghcb *__sev_get_ghcb(struct ghcb_state *state) · 120 unmodified lines
121121
122122 WARN_ON(!irqs_disabled());
123123
124+ if (!sev_cfg.ghcbs_initialized)
125+ return boot_ghcb;
126+
124127 data = this_cpu_read(runtime_data);
125128 ghcb = &data->ghcb_page;
126129
@@ -164,6 +167,9 @@ noinstr void __sev_put_ghcb(struct ghcb_state *state) · 37 unmodified lines
164167
165168 WARN_ON(!irqs_disabled());
166169
170+ if (!sev_cfg.ghcbs_initialized)
171+ return;
172+
167173 data = this_cpu_read(runtime_data);
168174 ghcb = &data->ghcb_page;
169175
arch/x86/entry/entry_fred.c+14−0
@@ -177,6 +177,16 @@ static noinstr void fred_extint(struct pt_regs *regs) · 176 unmodified lines
177177 }
178178 }
179179
180+#ifdef CONFIG_AMD_MEM_ENCRYPT
181+noinstr void exc_vmm_communication(struct pt_regs *regs, unsigned long error_code)
182+{
183+ if (user_mode(regs))
184+ return user_exc_vmm_communication(regs, error_code);
185+ else
186+ return kernel_exc_vmm_communication(regs, error_code);
187+}
188+#endif
189+
180190 static noinstr void fred_hwexc(struct pt_regs *regs, unsigned long error_code)
181191 {
182192 /* Optimize for #PF. That's the only exception which matters performance wise */
@@ -207,6 +217,10 @@ static noinstr void fred_hwexc(struct pt_regs *regs, unsigned long error_code) · 24 unmodified lines
207217 #ifdef CONFIG_X86_CET
208218 case X86_TRAP_CP: return exc_control_protection(regs, error_code);
209219 #endif
220+#ifdef CONFIG_AMD_MEM_ENCRYPT
221+ case X86_TRAP_VC: return exc_vmm_communication(regs, error_code);
222+#endif
223+
210224 default: return fred_bad_type(regs, error_code);
211225 }
212226
arch/x86/kernel/cpu/common.c+26−7
@@ -433,7 +433,20 @@ static __always_inline void setup_lass(struct cpuinfo_x86 *c) · 432 unmodified lines
433433
434434 /* These bits should not change their value after CPU init is finished. */
435435 static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP |
436− X86_CR4_FSGSBASE | X86_CR4_CET | X86_CR4_FRED;
436+ X86_CR4_FSGSBASE | X86_CR4_CET;
437+
438+/*
439+ * The CR pinning protects against ROP on the 'mov %reg, %CRn' instruction(s).
440+ * Since you can ROP directly to these instructions (barring shadow stack),
441+ * any protection must follow immediately and unconditionally after that.
442+ *
443+ * Specifically, the CR[04] write functions below will have the value
444+ * validation controlled by the @cr_pinning static_branch which is
445+ * __ro_after_init, just like the cr4_pinned_bits value.
446+ *
447+ * Once set, an attacker will have to defeat page-tables to get around these
448+ * restrictions. Which is a much bigger ask than 'simple' ROP.
449+ */
437450 static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning);
438451 static unsigned long cr4_pinned_bits __ro_after_init;
439452
@@ -2050,12 +2063,6 @@ static void identify_cpu(struct cpuinfo_x86 *c) · 1610 unmodified lines
20502063 setup_umip(c);
20512064 setup_lass(c);
20522065
2053− /* Enable FSGSBASE instructions if available. */
2054− if (cpu_has(c, X86_FEATURE_FSGSBASE)) {
2055− cr4_set_bits(X86_CR4_FSGSBASE);
2056− elf_hwcap2 |= HWCAP2_FSGSBASE;
2057− }
2058−
20592066 /*
20602067 * The vendor-specific functions might have changed features.
20612068 * Now we do "generic changes."
@@ -2416,6 +2423,18 @@ void cpu_init_exception_handling(bool boot_cpu) · 354 unmodified lines
24162423 /* GHCB needs to be setup to handle #VC. */
24172424 setup_ghcb();
24182425
2426+ /*
2427+ * On CPUs with FSGSBASE support, paranoid_entry() uses
2428+ * ALTERNATIVE-patched RDGSBASE/WRGSBASE instructions. Secondary CPUs
2429+ * boot after alternatives are patched globally, so early exceptions
2430+ * execute patched code that depends on FSGSBASE. Enable the feature
2431+ * before any exceptions occur.
2432+ */
2433+ if (cpu_feature_enabled(X86_FEATURE_FSGSBASE)) {
2434+ cr4_set_bits(X86_CR4_FSGSBASE);
2435+ elf_hwcap2 |= HWCAP2_FSGSBASE;
2436+ }
2437+
24192438 if (cpu_feature_enabled(X86_FEATURE_FRED)) {
24202439 /* The boot CPU has enabled FRED during early boot */
24212440 if (!boot_cpu)
arch/x86/kvm/mmu/mmu.c+10−7
@@ -3044,12 +3044,6 @@ static int mmu_set_spte(struct kvm_vcpu *vcpu, struct kvm_memory_slot *slot, · 3043 unmodified lines
30443044 bool prefetch = !fault || fault->prefetch;
30453045 bool write_fault = fault && fault->write;
30463046
3047− if (unlikely(is_noslot_pfn(pfn))) {
3048− vcpu->stat.pf_mmio_spte_created++;
3049− mark_mmio_spte(vcpu, sptep, gfn, pte_access);
3050− return RET_PF_EMULATE;
3051− }
3052−
30533047 if (is_shadow_present_pte(*sptep)) {
30543048 if (prefetch && is_last_spte(*sptep, level) &&
30553049 pfn == spte_to_pfn(*sptep))
@@ -3066,13 +3060,22 @@ static int mmu_set_spte(struct kvm_vcpu *vcpu, struct kvm_memory_slot *slot, · 10 unmodified lines
30663060 child = spte_to_child_sp(pte);
30673061 drop_parent_pte(vcpu->kvm, child, sptep);
30683062 flush = true;
3069− } else if (WARN_ON_ONCE(pfn != spte_to_pfn(*sptep))) {
3063+ } else if (pfn != spte_to_pfn(*sptep)) {
3064+ WARN_ON_ONCE(vcpu->arch.mmu->root_role.direct);
30703065 drop_spte(vcpu->kvm, sptep);
30713066 flush = true;
30723067 } else
30733068 was_rmapped = 1;
30743069 }
30753070
3071+ if (unlikely(is_noslot_pfn(pfn))) {
3072+ vcpu->stat.pf_mmio_spte_created++;
3073+ mark_mmio_spte(vcpu, sptep, gfn, pte_access);
3074+ if (flush)
3075+ kvm_flush_remote_tlbs_gfn(vcpu->kvm, gfn, level);
3076+ return RET_PF_EMULATE;
3077+ }
3078+
30763079 wrprot = make_spte(vcpu, sp, slot, pte_access, gfn, pfn, *sptep, prefetch,
30773080 false, host_writable, &spte);
30783081
arch/x86/platform/efi/quirks.c+1−1
@@ -424,7 +424,7 @@ void __init efi_unmap_boot_services(void) · 423 unmodified lines
424424 if (efi_enabled(EFI_DBG))
425425 return;
426426
427− sz = sizeof(*ranges_to_free) * efi.memmap.nr_map + 1;
427+ sz = sizeof(*ranges_to_free) * (efi.memmap.nr_map + 1);
428428 ranges_to_free = kzalloc(sz, GFP_KERNEL);
429429 if (!ranges_to_free) {
430430 pr_err("Failed to allocate storage for freeable EFI regions\n");
drivers/accel/ivpu/ivpu_drv.h+1−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #define IVPU_HW_IP_60XX 60
3636
3737 #define IVPU_HW_IP_REV_LNL_B0 4
38+#define IVPU_HW_IP_REV_NVL_A0 0
3839
3940 #define IVPU_HW_BTRS_MTL 1
4041 #define IVPU_HW_BTRS_LNL 2
drivers/accel/ivpu/ivpu_hw.c+4−2
@@ -70,8 +70,10 @@ static void wa_init(struct ivpu_device *vdev) · 69 unmodified lines
7070 if (ivpu_hw_btrs_gen(vdev) == IVPU_HW_BTRS_MTL)
7171 vdev->wa.interrupt_clear_with_0 = ivpu_hw_btrs_irqs_clear_with_0_mtl(vdev);
7272
73− if (ivpu_device_id(vdev) == PCI_DEVICE_ID_LNL &&
74− ivpu_revision(vdev) < IVPU_HW_IP_REV_LNL_B0)
73+ if ((ivpu_device_id(vdev) == PCI_DEVICE_ID_LNL &&
74+ ivpu_revision(vdev) < IVPU_HW_IP_REV_LNL_B0) ||
75+ (ivpu_device_id(vdev) == PCI_DEVICE_ID_NVL &&
76+ ivpu_revision(vdev) == IVPU_HW_IP_REV_NVL_A0))
7577 vdev->wa.disable_clock_relinquish = true;
7678
7779 if (ivpu_test_mode & IVPU_TEST_MODE_CLK_RELINQ_ENABLE)
drivers/acpi/ec.c+2−0
@@ -1656,6 +1656,8 @@ static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device, bool ca · 1655 unmodified lines
16561656
16571657 ret = ec_install_handlers(ec, device, call_reg);
16581658 if (ret) {
1659+ ec_remove_handlers(ec);
1660+
16591661 if (ec == first_ec)
16601662 first_ec = NULL;
16611663
drivers/base/regmap/regmap.c+26−4
@@ -1545,6 +1545,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg, · 1544 unmodified lines
15451545 unsigned int val_num)
15461546 {
15471547 void *orig_work_buf;
1548+ unsigned int selector_reg;
15481549 unsigned int win_offset;
15491550 unsigned int win_page;
15501551 bool page_chg;
@@ -1563,10 +1564,31 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg, · 12 unmodified lines
15631564 return -EINVAL;
15641565 }
15651566
1566− /* It is possible to have selector register inside data window.
1567− In that case, selector register is located on every page and
1568− it needs no page switching, when accessed alone. */
1567+ /*
1568+ * Calculate the address of the selector register in the corresponding
1569+ * data window if it is located on every page.
1570+ */
1571+ page_chg = in_range(range->selector_reg, range->window_start, range->window_len);
1572+ if (page_chg)
1573+ selector_reg = range->range_min + win_page * range->window_len +
1574+ range->selector_reg - range->window_start;
1575+
1576+ /*
1577+ * It is possible to have selector register inside data window.
1578+ * In that case, selector register is located on every page and it
1579+ * needs no page switching, when accessed alone.
1580+ *
1581+ * Nevertheless we should synchronize the cache values for it.
1582+ * This can't be properly achieved if the selector register is
1583+ * the first and the only one to be read inside the data window.
1584+ * That's why we update it in that case as well.
1585+ *
1586+ * However, we specifically avoid updating it for the default page,
1587+ * when it's overlapped with the real data window, to prevent from
1588+ * infinite looping.
1589+ */
15691590 if (val_num > 1 ||
1591+ (page_chg && selector_reg != range->selector_reg) ||
15701592 range->window_start + win_offset != range->selector_reg) {
15711593 /* Use separate work_buf during page switching */
15721594 orig_work_buf = map->work_buf;
@@ -1575,7 +1597,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg, · 2 unmodified lines
15751597 ret = _regmap_update_bits(map, range->selector_reg,
15761598 range->selector_mask,
15771599 win_page << range->selector_shift,
1578− &page_chg, false);
1600+ NULL, false);
15791601
15801602 map->work_buf = orig_work_buf;
15811603
drivers/block/zram/zram_drv.c+14−25
@@ -917,9 +917,8 @@ static void zram_account_writeback_submit(struct zram *zram) · 916 unmodified lines
917917
918918 static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req)
919919 {
920− u32 size, index = req->pps->index;
921− int err, prio;
922− bool huge;
920+ u32 index = req->pps->index;
921+ int err;
923922
924923 err = blk_status_to_errno(req->bio.bi_status);
925924 if (err) {
@@ -946,28 +945,13 @@ static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req) · 20 unmodified lines
946945 goto out;
947946 }
948947
949− if (zram->compressed_wb) {
950− /*
951− * ZRAM_WB slots get freed, we need to preserve data required
952− * for read decompression.
953− */
954− size = get_slot_size(zram, index);
955− prio = get_slot_comp_priority(zram, index);
956− huge = test_slot_flag(zram, index, ZRAM_HUGE);
957− }
958−
959− slot_free(zram, index);
960− set_slot_flag(zram, index, ZRAM_WB);
948+ clear_slot_flag(zram, index, ZRAM_IDLE);
949+ if (test_slot_flag(zram, index, ZRAM_HUGE))
950+ atomic64_dec(&zram->stats.huge_pages);
951+ atomic64_sub(get_slot_size(zram, index), &zram->stats.compr_data_size);
952+ zs_free(zram->mem_pool, get_slot_handle(zram, index));
961953 set_slot_handle(zram, index, req->blk_idx);
962−
963− if (zram->compressed_wb) {
964− if (huge)
965− set_slot_flag(zram, index, ZRAM_HUGE);
966− set_slot_size(zram, index, size);
967− set_slot_comp_priority(zram, index, prio);
968− }
969−
970− atomic64_inc(&zram->stats.pages_stored);
954+ set_slot_flag(zram, index, ZRAM_WB);
971955
972956 out:
973957 slot_unlock(zram, index);
@@ -2010,8 +1994,13 @@ static void slot_free(struct zram *zram, u32 index) · 1036 unmodified lines
20101994 set_slot_comp_priority(zram, index, 0);
20111995
20121996 if (test_slot_flag(zram, index, ZRAM_HUGE)) {
1997+ /*
1998+ * Writeback completion decrements ->huge_pages but keeps
1999+ * ZRAM_HUGE flag for deferred decompression path.
2000+ */
2001+ if (!test_slot_flag(zram, index, ZRAM_WB))
2002+ atomic64_dec(&zram->stats.huge_pages);
20132003 clear_slot_flag(zram, index, ZRAM_HUGE);
2014− atomic64_dec(&zram->stats.huge_pages);
20152004 }
20162005
20172006 if (test_slot_flag(zram, index, ZRAM_WB)) {
drivers/bluetooth/btintel.c+8−3
@@ -251,11 +251,13 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code) · 250 unmodified lines
251251
252252 bt_dev_err(hdev, "Hardware error 0x%2.2x", code);
253253
254+ hci_req_sync_lock(hdev);
255+
254256 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
255257 if (IS_ERR(skb)) {
256258 bt_dev_err(hdev, "Reset after hardware error failed (%ld)",
257259 PTR_ERR(skb));
258− return;
260+ goto unlock;
259261 }
260262 kfree_skb(skb);
261263
@@ -263,18 +265,21 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code) · 1 unmodified line
263265 if (IS_ERR(skb)) {
264266 bt_dev_err(hdev, "Retrieving Intel exception info failed (%ld)",
265267 PTR_ERR(skb));
266− return;
268+ goto unlock;
267269 }
268270
269271 if (skb->len != 13) {
270272 bt_dev_err(hdev, "Exception info size mismatch");
271273 kfree_skb(skb);
272− return;
274+ goto unlock;
273275 }
274276
275277 bt_dev_err(hdev, "Exception info %s", (char *)(skb->data + 1));
276278
277279 kfree_skb(skb);
280+
281+unlock:
282+ hci_req_sync_unlock(hdev);
278283 }
279284 EXPORT_SYMBOL_GPL(btintel_hw_error);
280285
drivers/bluetooth/btusb.c+4−1
@@ -2376,8 +2376,11 @@ static void btusb_work(struct work_struct *work) · 2375 unmodified lines
23762376 if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_CVSD) {
23772377 if (hdev->voice_setting & 0x0020) {
23782378 static const int alts[3] = { 2, 4, 5 };
2379+ unsigned int sco_idx;
23792380
2380− new_alts = alts[data->sco_num - 1];
2381+ sco_idx = min_t(unsigned int, data->sco_num - 1,
2382+ ARRAY_SIZE(alts) - 1);
2383+ new_alts = alts[sco_idx];
23812384 } else {
23822385 new_alts = data->sco_num;
23832386 }
drivers/bluetooth/hci_ll.c+2−0
@@ -541,6 +541,8 @@ static int download_firmware(struct ll_device *lldev) · 540 unmodified lines
541541 if (err || !fw->data || !fw->size) {
542542 bt_dev_err(lldev->hu.hdev, "request_firmware failed(errno %d) for %s",
543543 err, bts_scr_name);
544+ if (!err)
545+ release_firmware(fw);
544546 return -EINVAL;
545547 }
546548 ptr = (void *)fw->data;
drivers/cpufreq/cpufreq.c+3−6
@@ -1427,12 +1427,9 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy, · 1426 unmodified lines
14271427 * If there is a problem with its frequency table, take it
14281428 * offline and drop it.
14291429 */
1430− if (policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_ASCENDING &&
1431− policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_DESCENDING) {
1432− ret = cpufreq_table_validate_and_sort(policy);
1433− if (ret)
1434− goto out_offline_policy;
1435− }
1430+ ret = cpufreq_table_validate_and_sort(policy);
1431+ if (ret)
1432+ goto out_offline_policy;
14361433
14371434 /* related_cpus should at least include policy->cpus. */
14381435 cpumask_copy(policy->related_cpus, policy->cpus);
drivers/cpufreq/cpufreq_conservative.c+12−0
@@ -313,6 +313,17 @@ static void cs_start(struct cpufreq_policy *policy) · 312 unmodified lines
313313 dbs_info->requested_freq = policy->cur;
314314 }
315315
316+static void cs_limits(struct cpufreq_policy *policy)
317+{
318+ struct cs_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data);
319+
320+ /*
321+ * The limits have changed, so may have the current frequency. Reset
322+ * requested_freq to avoid any unintended outcomes due to the mismatch.
323+ */
324+ dbs_info->requested_freq = policy->cur;
325+}
326+
316327 static struct dbs_governor cs_governor = {
317328 .gov = CPUFREQ_DBS_GOVERNOR_INITIALIZER("conservative"),
318329 .kobj_type = { .default_groups = cs_groups },
@@ -322,6 +333,7 @@ static struct dbs_governor cs_governor = { · 3 unmodified lines
322333 .init = cs_init,
323334 .exit = cs_exit,
324335 .start = cs_start,
336+ .limits = cs_limits,
325337 };
326338
327339 #define CPU_FREQ_GOV_CONSERVATIVE (cs_governor.gov)
drivers/cpufreq/cpufreq_governor.c+3−0
@@ -563,6 +563,7 @@ EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_stop); · 562 unmodified lines
563563
564564 void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy)
565565 {
566+ struct dbs_governor *gov = dbs_governor_of(policy);
566567 struct policy_dbs_info *policy_dbs;
567568
568569 /* Protect gov->gdbs_data against cpufreq_dbs_governor_exit() */
@@ -574,6 +575,8 @@ void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy) · 5 unmodified lines
574575 mutex_lock(&policy_dbs->update_mutex);
575576 cpufreq_policy_apply_limits(policy);
576577 gov_update_sample_delay(policy_dbs, 0);
578+ if (gov->limits)
579+ gov->limits(policy);
577580 mutex_unlock(&policy_dbs->update_mutex);
578581
579582 out:
drivers/cpufreq/cpufreq_governor.h+1−0
@@ -138,6 +138,7 @@ struct dbs_governor { · 137 unmodified lines
138138 int (*init)(struct dbs_data *dbs_data);
139139 void (*exit)(struct dbs_data *dbs_data);
140140 void (*start)(struct cpufreq_policy *policy);
141+ void (*limits)(struct cpufreq_policy *policy);
141142 };
142143
143144 static inline struct dbs_governor *dbs_governor_of(struct cpufreq_policy *policy)
drivers/cpufreq/freq_table.c+4−0
@@ -360,6 +360,10 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy) · 359 unmodified lines
360360 if (policy_has_boost_freq(policy))
361361 policy->boost_supported = true;
362362
363+ if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING ||
364+ policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_DESCENDING)
365+ return 0;
366+
363367 return set_freq_table_sorted(policy);
364368 }
365369
drivers/cxl/Kconfig+1−0
@@ -59,6 +59,7 @@ config CXL_ACPI · 58 unmodified lines
5959 tristate "CXL ACPI: Platform Support"
6060 depends on ACPI
6161 depends on ACPI_NUMA
62+ depends on CXL_PMEM || !CXL_PMEM
6263 default CXL_BUS
6364 select ACPI_TABLE_LIB
6465 select ACPI_HMAT
drivers/cxl/core/hdm.c+9−16
@@ -94,7 +94,6 @@ static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) · 93 unmodified lines
9494 struct cxl_hdm *cxlhdm;
9595 void __iomem *hdm;
9696 u32 ctrl;
97− int i;
9897
9998 if (!info)
10099 return false;
@@ -113,22 +112,16 @@ static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) · 12 unmodified lines
113112 return false;
114113
115114 /*
116− * If any decoders are committed already, there should not be any
117− * emulated DVSEC decoders.
115+ * If HDM decoders are globally enabled, do not fall back to DVSEC
116+ * range emulation. Zeroed decoder registers after region teardown
117+ * do not imply absence of HDM capability.
118+ *
119+ * Falling back to DVSEC here would treat the decoder as AUTO and
120+ * may incorrectly latch default interleave settings.
118121 */
119− for (i = 0; i < cxlhdm->decoder_count; i++) {
120− ctrl = readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(i));
121− dev_dbg(&info->port->dev,
122− "decoder%d.%d: committed: %ld base: %#x_%.8x size: %#x_%.8x\n",
123− info->port->id, i,
124− FIELD_GET(CXL_HDM_DECODER0_CTRL_COMMITTED, ctrl),
125− readl(hdm + CXL_HDM_DECODER0_BASE_HIGH_OFFSET(i)),
126− readl(hdm + CXL_HDM_DECODER0_BASE_LOW_OFFSET(i)),
127− readl(hdm + CXL_HDM_DECODER0_SIZE_HIGH_OFFSET(i)),
128− readl(hdm + CXL_HDM_DECODER0_SIZE_LOW_OFFSET(i)));
129− if (FIELD_GET(CXL_HDM_DECODER0_CTRL_COMMITTED, ctrl))
130− return false;
131− }
122+ ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET);
123+ if (ctrl & CXL_HDM_DECODER_ENABLE)
124+ return false;
132125
133126 return true;
134127 }
drivers/cxl/core/mbox.c+1−1
@@ -1301,7 +1301,7 @@ int cxl_mem_sanitize(struct cxl_memdev *cxlmd, u16 cmd) · 1300 unmodified lines
13011301 * Require an endpoint to be safe otherwise the driver can not
13021302 * be sure that the device is unmapped.
13031303 */
1304− if (endpoint && cxl_num_decoders_committed(endpoint) == 0)
1304+ if (cxlmd->dev.driver && cxl_num_decoders_committed(endpoint) == 0)
13051305 return __cxl_mem_sanitize(mds, cmd);
13061306
13071307 return -EBUSY;
drivers/cxl/core/port.c+6−2
@@ -552,10 +552,13 @@ static void cxl_port_release(struct device *dev) · 551 unmodified lines
552552 xa_destroy(&port->dports);
553553 xa_destroy(&port->regions);
554554 ida_free(&cxl_port_ida, port->id);
555− if (is_cxl_root(port))
555+
556+ if (is_cxl_root(port)) {
556557 kfree(to_cxl_root(port));
557− else
558+ } else {
559+ put_device(dev->parent);
558560 kfree(port);
561+ }
559562 }
560563
561564 static ssize_t decoders_committed_show(struct device *dev,
@@ -707,6 +710,7 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev, · 145 unmodified lines
707710 struct cxl_port *iter;
708711
709712 dev->parent = &parent_port->dev;
713+ get_device(dev->parent);
710714 port->depth = parent_port->depth + 1;
711715 port->parent_dport = parent_dport;
712716
drivers/cxl/core/region.c+3−1
@@ -3854,8 +3854,10 @@ static int __construct_region(struct cxl_region *cxlr, · 3853 unmodified lines
38543854 }
38553855
38563856 rc = sysfs_update_group(&cxlr->dev.kobj, &cxl_region_group);
3857− if (rc)
3857+ if (rc) {
3858+ kfree(res);
38583859 return rc;
3860+ }
38593861
38603862 rc = insert_resource(cxlrd->res, res);
38613863 if (rc) {
drivers/cxl/pmem.c+1−1
@@ -554,7 +554,7 @@ static __exit void cxl_pmem_exit(void) · 553 unmodified lines
554554
555555 MODULE_DESCRIPTION("CXL PMEM: Persistent Memory Support");
556556 MODULE_LICENSE("GPL v2");
557−module_init(cxl_pmem_init);
557+subsys_initcall(cxl_pmem_init);
558558 module_exit(cxl_pmem_exit);
559559 MODULE_IMPORT_NS("CXL");
560560 MODULE_ALIAS_CXL(CXL_DEVICE_NVDIMM_BRIDGE);
drivers/dma/dw-edma/dw-edma-core.c+6−2
@@ -844,6 +844,7 @@ static int dw_edma_irq_request(struct dw_edma *dw, · 843 unmodified lines
844844 {
845845 struct dw_edma_chip *chip = dw->chip;
846846 struct device *dev = dw->chip->dev;
847+ struct msi_desc *msi_desc;
847848 u32 wr_mask = 1;
848849 u32 rd_mask = 1;
849850 int i, err = 0;
@@ -895,9 +896,12 @@ static int dw_edma_irq_request(struct dw_edma *dw, · 45 unmodified lines
895896 &dw->irq[i]);
896897 if (err)
897898 goto err_irq_free;
898−
899− if (irq_get_msi_desc(irq))
899+ msi_desc = irq_get_msi_desc(irq);
900+ if (msi_desc) {
900901 get_cached_msi_msg(irq, &dw->irq[i].msi);
902+ if (!msi_desc->pci.msi_attrib.is_msix)
903+ dw->irq[i].msi.data = dw->irq[0].msi.data + i;
904+ }
901905 }
902906
903907 dw->nr_irqs = i;
drivers/dma/dw-edma/dw-hdma-v0-core.c+3−3
@@ -252,10 +252,10 @@ static void dw_hdma_v0_core_start(struct dw_edma_chunk *chunk, bool first) · 251 unmodified lines
252252 lower_32_bits(chunk->ll_region.paddr));
253253 SET_CH_32(dw, chan->dir, chan->id, llp.msb,
254254 upper_32_bits(chunk->ll_region.paddr));
255+ /* Set consumer cycle */
256+ SET_CH_32(dw, chan->dir, chan->id, cycle_sync,
257+ HDMA_V0_CONSUMER_CYCLE_STAT | HDMA_V0_CONSUMER_CYCLE_BIT);
255258 }
256− /* Set consumer cycle */
257− SET_CH_32(dw, chan->dir, chan->id, cycle_sync,
258− HDMA_V0_CONSUMER_CYCLE_STAT | HDMA_V0_CONSUMER_CYCLE_BIT);
259259
260260 dw_hdma_v0_sync_ll_data(chunk);
261261
drivers/dma/fsl-edma-main.c+11−15
@@ -317,10 +317,8 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec, · 316 unmodified lines
317317 return NULL;
318318 i = fsl_chan - fsl_edma->chans;
319319
320− fsl_chan->priority = dma_spec->args[1];
321− fsl_chan->is_rxchan = dma_spec->args[2] & FSL_EDMA_RX;
322− fsl_chan->is_remote = dma_spec->args[2] & FSL_EDMA_REMOTE;
323− fsl_chan->is_multi_fifo = dma_spec->args[2] & FSL_EDMA_MULTI_FIFO;
320+ if (!b_chmux && i != dma_spec->args[0])
321+ continue;
324322
325323 if ((dma_spec->args[2] & FSL_EDMA_EVEN_CH) && (i & 0x1))
326324 continue;
@@ -328,17 +326,15 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec, · 1 unmodified line
328326 if ((dma_spec->args[2] & FSL_EDMA_ODD_CH) && !(i & 0x1))
329327 continue;
330328
331− if (!b_chmux && i == dma_spec->args[0]) {
332− chan = dma_get_slave_channel(chan);
333− chan->device->privatecnt++;
334− return chan;
335− } else if (b_chmux && !fsl_chan->srcid) {
336− /* if controller support channel mux, choose a free channel */
337− chan = dma_get_slave_channel(chan);
338− chan->device->privatecnt++;
339− fsl_chan->srcid = dma_spec->args[0];
340− return chan;
341− }
329+ fsl_chan->srcid = dma_spec->args[0];
330+ fsl_chan->priority = dma_spec->args[1];
331+ fsl_chan->is_rxchan = dma_spec->args[2] & FSL_EDMA_RX;
332+ fsl_chan->is_remote = dma_spec->args[2] & FSL_EDMA_REMOTE;
333+ fsl_chan->is_multi_fifo = dma_spec->args[2] & FSL_EDMA_MULTI_FIFO;
334+
335+ chan = dma_get_slave_channel(chan);
336+ chan->device->privatecnt++;
337+ return chan;
342338 }
343339 return NULL;
344340 }
drivers/dma/idxd/cdev.c+4−4
@@ -158,11 +158,7 @@ static const struct device_type idxd_cdev_file_type = { · 157 unmodified lines
158158 static void idxd_cdev_dev_release(struct device *dev)
159159 {
160160 struct idxd_cdev *idxd_cdev = dev_to_cdev(dev);
161− struct idxd_cdev_context *cdev_ctx;
162− struct idxd_wq *wq = idxd_cdev->wq;
163161
164− cdev_ctx = &ictx[wq->idxd->data->type];
165− ida_free(&cdev_ctx->minor_ida, idxd_cdev->minor);
166162 kfree(idxd_cdev);
167163 }
168164
@@ -582,11 +578,15 @@ int idxd_wq_add_cdev(struct idxd_wq *wq) · 413 unmodified lines
582578
583579 void idxd_wq_del_cdev(struct idxd_wq *wq)
584580 {
581+ struct idxd_cdev_context *cdev_ctx;
585582 struct idxd_cdev *idxd_cdev;
586583
587584 idxd_cdev = wq->idxd_cdev;
588585 wq->idxd_cdev = NULL;
589586 cdev_device_del(&idxd_cdev->cdev, cdev_dev(idxd_cdev));
587+
588+ cdev_ctx = &ictx[wq->idxd->data->type];
589+ ida_free(&cdev_ctx->minor_ida, idxd_cdev->minor);
590590 put_device(cdev_dev(idxd_cdev));
591591 }
592592
drivers/dma/idxd/device.c+31−14
@@ -175,6 +175,7 @@ void idxd_wq_free_resources(struct idxd_wq *wq) · 174 unmodified lines
175175 free_descs(wq);
176176 dma_free_coherent(dev, wq->compls_size, wq->compls, wq->compls_addr);
177177 sbitmap_queue_free(&wq->sbq);
178+ wq->type = IDXD_WQT_NONE;
178179 }
179180 EXPORT_SYMBOL_NS_GPL(idxd_wq_free_resources, "IDXD");
180181
@@ -382,7 +383,6 @@ static void idxd_wq_disable_cleanup(struct idxd_wq *wq) · 201 unmodified lines
382383 lockdep_assert_held(&wq->wq_lock);
383384 wq->state = IDXD_WQ_DISABLED;
384385 memset(wq->wqcfg, 0, idxd->wqcfg_size);
385− wq->type = IDXD_WQT_NONE;
386386 wq->threshold = 0;
387387 wq->priority = 0;
388388 wq->enqcmds_retries = IDXD_ENQCMDS_RETRIES;
@@ -831,8 +831,7 @@ static void idxd_device_evl_free(struct idxd_device *idxd) · 442 unmodified lines
831831 struct device *dev = &idxd->pdev->dev;
832832 struct idxd_evl *evl = idxd->evl;
833833
834− gencfg.bits = ioread32(idxd->reg_base + IDXD_GENCFG_OFFSET);
835− if (!gencfg.evl_en)
834+ if (!evl)
836835 return;
837836
838837 mutex_lock(&evl->lock);
@@ -1125,7 +1124,11 @@ int idxd_device_config(struct idxd_device *idxd) · 286 unmodified lines
11251124 {
11261125 int rc;
11271126
1128− lockdep_assert_held(&idxd->dev_lock);
1127+ guard(spinlock)(&idxd->dev_lock);
1128+
1129+ if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
1130+ return 0;
1131+
11291132 rc = idxd_wqs_setup(idxd);
11301133 if (rc < 0)
11311134 return rc;
@@ -1332,6 +1335,11 @@ void idxd_wq_free_irq(struct idxd_wq *wq) · 200 unmodified lines
13321335
13331336 free_irq(ie->vector, ie);
13341337 idxd_flush_pending_descs(ie);
1338+
1339+ /* The interrupt might have been already released by FLR */
1340+ if (ie->int_handle == INVALID_INT_HANDLE)
1341+ return;
1342+
13351343 if (idxd->request_int_handles)
13361344 idxd_device_release_int_handle(idxd, ie->int_handle, IDXD_IRQ_MSIX);
13371345 idxd_device_clear_perm_entry(idxd, ie);
@@ -1340,6 +1348,23 @@ void idxd_wq_free_irq(struct idxd_wq *wq) · 2 unmodified lines
13401348 ie->pasid = IOMMU_PASID_INVALID;
13411349 }
13421350
1351+void idxd_wq_flush_descs(struct idxd_wq *wq)
1352+{
1353+ struct idxd_irq_entry *ie = &wq->ie;
1354+ struct idxd_device *idxd = wq->idxd;
1355+
1356+ guard(mutex)(&wq->wq_lock);
1357+
1358+ if (wq->state != IDXD_WQ_ENABLED || wq->type != IDXD_WQT_KERNEL)
1359+ return;
1360+
1361+ idxd_flush_pending_descs(ie);
1362+ if (idxd->request_int_handles)
1363+ idxd_device_release_int_handle(idxd, ie->int_handle, IDXD_IRQ_MSIX);
1364+ idxd_device_clear_perm_entry(idxd, ie);
1365+ ie->int_handle = INVALID_INT_HANDLE;
1366+}
1367+
13431368 int idxd_wq_request_irq(struct idxd_wq *wq)
13441369 {
13451370 struct idxd_device *idxd = wq->idxd;
@@ -1454,11 +1479,7 @@ int idxd_drv_enable_wq(struct idxd_wq *wq) · 108 unmodified lines
14541479 }
14551480 }
14561481
1457− rc = 0;
1458− spin_lock(&idxd->dev_lock);
1459− if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
1460− rc = idxd_device_config(idxd);
1461− spin_unlock(&idxd->dev_lock);
1482+ rc = idxd_device_config(idxd);
14621483 if (rc < 0) {
14631484 dev_dbg(dev, "Writing wq %d config failed: %d\n", wq->id, rc);
14641485 goto err;
@@ -1533,7 +1554,6 @@ void idxd_drv_disable_wq(struct idxd_wq *wq) · 68 unmodified lines
15331554 idxd_wq_reset(wq);
15341555 idxd_wq_free_resources(wq);
15351556 percpu_ref_exit(&wq->wq_active);
1536− wq->type = IDXD_WQT_NONE;
15371557 wq->client_count = 0;
15381558 }
15391559 EXPORT_SYMBOL_NS_GPL(idxd_drv_disable_wq, "IDXD");
@@ -1554,10 +1574,7 @@ int idxd_device_drv_probe(struct idxd_dev *idxd_dev) · 14 unmodified lines
15541574 }
15551575
15561576 /* Device configuration */
1557− spin_lock(&idxd->dev_lock);
1558− if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
1559− rc = idxd_device_config(idxd);
1560− spin_unlock(&idxd->dev_lock);
1577+ rc = idxd_device_config(idxd);
15611578 if (rc < 0)
15621579 return -ENXIO;
15631580
drivers/dma/idxd/dma.c+18−0
@@ -194,6 +194,22 @@ static void idxd_dma_release(struct dma_device *device) · 193 unmodified lines
194194 kfree(idxd_dma);
195195 }
196196
197+static int idxd_dma_terminate_all(struct dma_chan *c)
198+{
199+ struct idxd_wq *wq = to_idxd_wq(c);
200+
201+ idxd_wq_flush_descs(wq);
202+
203+ return 0;
204+}
205+
206+static void idxd_dma_synchronize(struct dma_chan *c)
207+{
208+ struct idxd_wq *wq = to_idxd_wq(c);
209+
210+ idxd_wq_drain(wq);
211+}
212+
197213 int idxd_register_dma_device(struct idxd_device *idxd)
198214 {
199215 struct idxd_dma_dev *idxd_dma;
@@ -224,6 +240,8 @@ int idxd_register_dma_device(struct idxd_device *idxd) · 24 unmodified lines
224240 dma->device_issue_pending = idxd_dma_issue_pending;
225241 dma->device_alloc_chan_resources = idxd_dma_alloc_chan_resources;
226242 dma->device_free_chan_resources = idxd_dma_free_chan_resources;
243+ dma->device_terminate_all = idxd_dma_terminate_all;
244+ dma->device_synchronize = idxd_dma_synchronize;
227245
228246 rc = dma_async_device_register(dma);
229247 if (rc < 0) {
drivers/dma/idxd/idxd.h+1−0
@@ -803,6 +803,7 @@ void idxd_wq_quiesce(struct idxd_wq *wq); · 802 unmodified lines
803803 int idxd_wq_init_percpu_ref(struct idxd_wq *wq);
804804 void idxd_wq_free_irq(struct idxd_wq *wq);
805805 int idxd_wq_request_irq(struct idxd_wq *wq);
806+void idxd_wq_flush_descs(struct idxd_wq *wq);
806807
807808 /* submission */
808809 int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc);
drivers/dma/idxd/init.c+7−7
@@ -973,7 +973,8 @@ static void idxd_device_config_restore(struct idxd_device *idxd, · 972 unmodified lines
973973
974974 idxd->rdbuf_limit = idxd_saved->saved_idxd.rdbuf_limit;
975975
976− idxd->evl->size = saved_evl->size;
976+ if (idxd->evl)
977+ idxd->evl->size = saved_evl->size;
977978
978979 for (i = 0; i < idxd->max_groups; i++) {
979980 struct idxd_group *saved_group, *group;
@@ -1104,12 +1105,10 @@ static void idxd_reset_done(struct pci_dev *pdev) · 124 unmodified lines
11041105 idxd_device_config_restore(idxd, idxd->idxd_saved);
11051106
11061107 /* Re-configure IDXD device if allowed. */
1107− if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) {
1108− rc = idxd_device_config(idxd);
1109− if (rc < 0) {
1110− dev_err(dev, "HALT: %s config fails\n", idxd_name);
1111− goto out;
1112− }
1108+ rc = idxd_device_config(idxd);
1109+ if (rc < 0) {
1110+ dev_err(dev, "HALT: %s config fails\n", idxd_name);
1111+ goto out;
11131112 }
11141113
11151114 /* Bind IDXD device to driver. */
@@ -1147,6 +1146,7 @@ static void idxd_reset_done(struct pci_dev *pdev) · 31 unmodified lines
11471146 }
11481147 out:
11491148 kfree(idxd->idxd_saved);
1149+ idxd->idxd_saved = NULL;
11501150 }
11511151
11521152 static const struct pci_error_handlers idxd_error_handler = {
drivers/dma/idxd/irq.c+16−0
@@ -397,6 +397,17 @@ static void idxd_device_flr(struct work_struct *work) · 396 unmodified lines
397397 dev_err(&idxd->pdev->dev, "FLR failed\n");
398398 }
399399
400+static void idxd_wqs_flush_descs(struct idxd_device *idxd)
401+{
402+ int i;
403+
404+ for (i = 0; i < idxd->max_wqs; i++) {
405+ struct idxd_wq *wq = idxd->wqs[i];
406+
407+ idxd_wq_flush_descs(wq);
408+ }
409+}
410+
400411 static irqreturn_t idxd_halt(struct idxd_device *idxd)
401412 {
402413 union gensts_reg gensts;
@@ -415,6 +426,11 @@ static irqreturn_t idxd_halt(struct idxd_device *idxd) · 12 unmodified lines
415426 } else if (gensts.reset_type == IDXD_DEVICE_RESET_FLR) {
416427 idxd->state = IDXD_DEV_HALTED;
417428 idxd_mask_error_interrupts(idxd);
429+ /* Flush all pending descriptors, and disable
430+ * interrupts, they will be re-enabled when FLR
431+ * concludes.
432+ */
433+ idxd_wqs_flush_descs(idxd);
418434 dev_dbg(&idxd->pdev->dev,
419435 "idxd halted, doing FLR. After FLR, configs are restored\n");
420436 INIT_WORK(&idxd->work, idxd_device_flr);
drivers/dma/idxd/submit.c+1−1
@@ -138,7 +138,7 @@ static void llist_abort_desc(struct idxd_wq *wq, struct idxd_irq_entry *ie, · 137 unmodified lines
138138 */
139139 list_for_each_entry_safe(d, t, &flist, list) {
140140 list_del_init(&d->list);
141− idxd_dma_complete_txd(found, IDXD_COMPLETE_ABORT, true,
141+ idxd_dma_complete_txd(d, IDXD_COMPLETE_ABORT, true,
142142 NULL, NULL);
143143 }
144144 }
drivers/dma/idxd/sysfs.c+1−0
@@ -1836,6 +1836,7 @@ static void idxd_conf_device_release(struct device *dev) · 1835 unmodified lines
18361836 {
18371837 struct idxd_device *idxd = confdev_to_idxd(dev);
18381838
1839+ destroy_workqueue(idxd->wq);
18391840 kfree(idxd->groups);
18401841 bitmap_free(idxd->wq_enable_map);
18411842 kfree(idxd->wqs);
drivers/dma/sh/rz-dmac.c+36−30
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 */
1111
1212 #include <linux/bitfield.h>
13+#include <linux/cleanup.h>
1314 #include <linux/dma-mapping.h>
1415 #include <linux/dmaengine.h>
1516 #include <linux/interrupt.h>
@@ -296,13 +297,10 @@ static void rz_dmac_disable_hw(struct rz_dmac_chan *channel) · 280 unmodified lines
296297 {
297298 struct dma_chan *chan = &channel->vc.chan;
298299 struct rz_dmac *dmac = to_rz_dmac(chan->device);
299− unsigned long flags;
300300
301301 dev_dbg(dmac->dev, "%s channel %d\n", __func__, channel->index);
302302
303− local_irq_save(flags);
304303 rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1);
305− local_irq_restore(flags);
306304 }
307305
308306 static void rz_dmac_set_dmars_register(struct rz_dmac *dmac, int nr, u32 dmars)
@@ -447,6 +445,7 @@ static int rz_dmac_alloc_chan_resources(struct dma_chan *chan) · 138 unmodified lines
447445 if (!desc)
448446 break;
449447
448+ /* No need to lock. This is called only for the 1st client. */
450449 list_add_tail(&desc->node, &channel->ld_free);
451450 channel->descs_allocated++;
452451 }
@@ -502,18 +501,21 @@ rz_dmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, · 49 unmodified lines
502501 dev_dbg(dmac->dev, "%s channel: %d src=0x%pad dst=0x%pad len=%zu\n",
503502 __func__, channel->index, &src, &dest, len);
504503
505− if (list_empty(&channel->ld_free))
506− return NULL;
504+ scoped_guard(spinlock_irqsave, &channel->vc.lock) {
505+ if (list_empty(&channel->ld_free))
506+ return NULL;
507507
508− desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node);
508+ desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node);
509509
510− desc->type = RZ_DMAC_DESC_MEMCPY;
511− desc->src = src;
512− desc->dest = dest;
513− desc->len = len;
514− desc->direction = DMA_MEM_TO_MEM;
510+ desc->type = RZ_DMAC_DESC_MEMCPY;
511+ desc->src = src;
512+ desc->dest = dest;
513+ desc->len = len;
514+ desc->direction = DMA_MEM_TO_MEM;
515+
516+ list_move_tail(channel->ld_free.next, &channel->ld_queue);
517+ }
515518
516− list_move_tail(channel->ld_free.next, &channel->ld_queue);
517519 return vchan_tx_prep(&channel->vc, &desc->vd, flags);
518520 }
519521
@@ -529,27 +531,29 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, · 9 unmodified lines
529531 int dma_length = 0;
530532 int i = 0;
531533
532− if (list_empty(&channel->ld_free))
533− return NULL;
534+ scoped_guard(spinlock_irqsave, &channel->vc.lock) {
535+ if (list_empty(&channel->ld_free))
536+ return NULL;
534537
535− desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node);
538+ desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node);
536539
537− for_each_sg(sgl, sg, sg_len, i) {
538− dma_length += sg_dma_len(sg);
539− }
540+ for_each_sg(sgl, sg, sg_len, i)
541+ dma_length += sg_dma_len(sg);
540542
541− desc->type = RZ_DMAC_DESC_SLAVE_SG;
542− desc->sg = sgl;
543− desc->sgcount = sg_len;
544− desc->len = dma_length;
545− desc->direction = direction;
543+ desc->type = RZ_DMAC_DESC_SLAVE_SG;
544+ desc->sg = sgl;
545+ desc->sgcount = sg_len;
546+ desc->len = dma_length;
547+ desc->direction = direction;
546548
547− if (direction == DMA_DEV_TO_MEM)
548− desc->src = channel->src_per_address;
549− else
550− desc->dest = channel->dst_per_address;
549+ if (direction == DMA_DEV_TO_MEM)
550+ desc->src = channel->src_per_address;
551+ else
552+ desc->dest = channel->dst_per_address;
553+
554+ list_move_tail(channel->ld_free.next, &channel->ld_queue);
555+ }
551556
552− list_move_tail(channel->ld_free.next, &channel->ld_queue);
553557 return vchan_tx_prep(&channel->vc, &desc->vd, flags);
554558 }
555559
@@ -561,8 +565,8 @@ static int rz_dmac_terminate_all(struct dma_chan *chan) · 5 unmodified lines
561565 unsigned int i;
562566 LIST_HEAD(head);
563567
564− rz_dmac_disable_hw(channel);
565568 spin_lock_irqsave(&channel->vc.lock, flags);
569+ rz_dmac_disable_hw(channel);
566570 for (i = 0; i < DMAC_NR_LMDESC; i++)
567571 lmdesc[i].header = 0;
568572
@@ -699,7 +703,9 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_chan *channel) · 130 unmodified lines
699703 if (chstat & CHSTAT_ER) {
700704 dev_err(dmac->dev, "DMAC err CHSTAT_%d = %08X\n",
701705 channel->index, chstat);
702− rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1);
706+
707+ scoped_guard(spinlock_irqsave, &channel->vc.lock)
708+ rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1);
703709 goto done;
704710 }
705711
drivers/dma/xilinx/xdma.c+2−2
@@ -1234,8 +1234,8 @@ static int xdma_probe(struct platform_device *pdev) · 1233 unmodified lines
12341234
12351235 xdev->rmap = devm_regmap_init_mmio(&pdev->dev, reg_base,
12361236 &xdma_regmap_config);
1237− if (!xdev->rmap) {
1238− xdma_err(xdev, "config regmap failed: %d", ret);
1237+ if (IS_ERR(xdev->rmap)) {
1238+ xdma_err(xdev, "config regmap failed: %pe", xdev->rmap);
12391239 goto failed;
12401240 }
12411241 INIT_LIST_HEAD(&xdev->dma_dev.channels);
drivers/dma/xilinx/xilinx_dma.c+30−16
@@ -997,16 +997,16 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan, · 996 unmodified lines
997997 struct xilinx_cdma_tx_segment,
998998 node);
999999 cdma_hw = &cdma_seg->hw;
1000− residue += (cdma_hw->control - cdma_hw->status) &
1001− chan->xdev->max_buffer_len;
1000+ residue += (cdma_hw->control & chan->xdev->max_buffer_len) -
1001+ (cdma_hw->status & chan->xdev->max_buffer_len);
10021002 } else if (chan->xdev->dma_config->dmatype ==
10031003 XDMA_TYPE_AXIDMA) {
10041004 axidma_seg = list_entry(entry,
10051005 struct xilinx_axidma_tx_segment,
10061006 node);
10071007 axidma_hw = &axidma_seg->hw;
1008− residue += (axidma_hw->control - axidma_hw->status) &
1009− chan->xdev->max_buffer_len;
1008+ residue += (axidma_hw->control & chan->xdev->max_buffer_len) -
1009+ (axidma_hw->status & chan->xdev->max_buffer_len);
10101010 } else {
10111011 aximcdma_seg =
10121012 list_entry(entry,
@@ -1014,8 +1014,8 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan, · 1 unmodified line
10141014 node);
10151015 aximcdma_hw = &aximcdma_seg->hw;
10161016 residue +=
1017− (aximcdma_hw->control - aximcdma_hw->status) &
1018− chan->xdev->max_buffer_len;
1017+ (aximcdma_hw->control & chan->xdev->max_buffer_len) -
1018+ (aximcdma_hw->status & chan->xdev->max_buffer_len);
10191019 }
10201020 }
10211021
@@ -1235,14 +1235,6 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan) · 213 unmodified lines
12351235
12361236 dma_cookie_init(dchan);
12371237
1238− if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {
1239− /* For AXI DMA resetting once channel will reset the
1240− * other channel as well so enable the interrupts here.
1241− */
1242− dma_ctrl_set(chan, XILINX_DMA_REG_DMACR,
1243− XILINX_DMA_DMAXR_ALL_IRQ_MASK);
1244− }
1245−
12461238 if ((chan->xdev->dma_config->dmatype == XDMA_TYPE_CDMA) && chan->has_sg)
12471239 dma_ctrl_set(chan, XILINX_DMA_REG_DMACR,
12481240 XILINX_CDMA_CR_SGMODE);
@@ -1564,8 +1556,29 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan) · 315 unmodified lines
15641556 if (chan->err)
15651557 return;
15661558
1567− if (list_empty(&chan->pending_list))
1559+ if (list_empty(&chan->pending_list)) {
1560+ if (chan->cyclic) {
1561+ struct xilinx_dma_tx_descriptor *desc;
1562+ struct list_head *entry;
1563+
1564+ desc = list_last_entry(&chan->done_list,
1565+ struct xilinx_dma_tx_descriptor, node);
1566+ list_for_each(entry, &desc->segments) {
1567+ struct xilinx_axidma_tx_segment *axidma_seg;
1568+ struct xilinx_axidma_desc_hw *axidma_hw;
1569+ axidma_seg = list_entry(entry,
1570+ struct xilinx_axidma_tx_segment,
1571+ node);
1572+ axidma_hw = &axidma_seg->hw;
1573+ axidma_hw->status = 0;
1574+ }
1575+
1576+ list_splice_tail_init(&chan->done_list, &chan->active_list);
1577+ chan->desc_pendingcount = 0;
1578+ chan->idle = false;
1579+ }
15681580 return;
1581+ }
15691582
15701583 if (!chan->idle)
15711584 return;
@@ -1591,6 +1604,7 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan) · 19 unmodified lines
15911604 head_desc->async_tx.phys);
15921605 reg &= ~XILINX_DMA_CR_DELAY_MAX;
15931606 reg |= chan->irq_delay << XILINX_DMA_CR_DELAY_SHIFT;
1607+ reg |= XILINX_DMA_DMAXR_ALL_IRQ_MASK;
15941608 dma_ctrl_write(chan, XILINX_DMA_REG_DMACR, reg);
15951609
15961610 xilinx_dma_start(chan);
@@ -3024,7 +3038,7 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev, · 1427 unmodified lines
30243038 return -EINVAL;
30253039 }
30263040
3027− xdev->common.directions |= chan->direction;
3041+ xdev->common.directions |= BIT(chan->direction);
30283042
30293043 /* Request the interrupt */
30303044 chan->irq = of_irq_get(node, chan->tdest);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c+2−2
@@ -692,9 +692,9 @@ int amdgpu_amdkfd_submit_ib(struct amdgpu_device *adev, · 691 unmodified lines
692692 goto err_ib_sched;
693693 }
694694
695− /* Drop the initial kref_init count (see drm_sched_main as example) */
696− dma_fence_put(f);
697695 ret = dma_fence_wait(f, false);
696+ /* Drop the returned fence reference after the wait completes */
697+ dma_fence_put(f);
698698
699699 err_ib_sched:
700700 amdgpu_job_free(job);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c+11−2
@@ -4207,7 +4207,8 @@ fail: · 4206 unmodified lines
42074207
42084208 static int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev)
42094209 {
4210− char *input = amdgpu_lockup_timeout;
4210+ char buf[AMDGPU_MAX_TIMEOUT_PARAM_LENGTH];
4211+ char *input = buf;
42114212 char *timeout_setting = NULL;
42124213 int index = 0;
42134214 long timeout;
@@ -4217,9 +4218,17 @@ static int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev) · 3 unmodified lines
42174218 adev->gfx_timeout = adev->compute_timeout = adev->sdma_timeout =
42184219 adev->video_timeout = msecs_to_jiffies(2000);
42194220
4220− if (!strnlen(input, AMDGPU_MAX_TIMEOUT_PARAM_LENGTH))
4221+ if (!strnlen(amdgpu_lockup_timeout, AMDGPU_MAX_TIMEOUT_PARAM_LENGTH))
42214222 return 0;
42224223
4224+ /*
4225+ * strsep() destructively modifies its input by replacing delimiters
4226+ * with '\0'. Use a stack copy so the global module parameter buffer
4227+ * remains intact for multi-GPU systems where this function is called
4228+ * once per device.
4229+ */
4230+ strscpy(buf, amdgpu_lockup_timeout, sizeof(buf));
4231+
42234232 while ((timeout_setting = strsep(&input, ",")) &&
42244233 strnlen(timeout_setting, AMDGPU_MAX_TIMEOUT_PARAM_LENGTH)) {
42254234 ret = kstrtol(timeout_setting, 0, &timeout);
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c+32−13
@@ -35,10 +35,13 @@ · 34 unmodified lines
3535 * PASIDs are global address space identifiers that can be shared
3636 * between the GPU, an IOMMU and the driver. VMs on different devices
3737 * may use the same PASID if they share the same address
38− * space. Therefore PASIDs are allocated using a global IDA. VMs are
39− * looked up from the PASID per amdgpu_device.
38+ * space. Therefore PASIDs are allocated using IDR cyclic allocator
39+ * (similar to kernel PID allocation) which naturally delays reuse.
40+ * VMs are looked up from the PASID per amdgpu_device.
4041 */
41−static DEFINE_IDA(amdgpu_pasid_ida);
42+
43+static DEFINE_IDR(amdgpu_pasid_idr);
44+static DEFINE_SPINLOCK(amdgpu_pasid_idr_lock);
4245
4346 /* Helper to free pasid from a fence callback */
4447 struct amdgpu_pasid_cb {
@@ -50,8 +53,8 @@ struct amdgpu_pasid_cb { · 5 unmodified lines
5053 * amdgpu_pasid_alloc - Allocate a PASID
5154 * @bits: Maximum width of the PASID in bits, must be at least 1
5255 *
53− * Allocates a PASID of the given width while keeping smaller PASIDs
54− * available if possible.
56+ * Uses kernel's IDR cyclic allocator (same as PID allocation).
57+ * Allocates sequentially with automatic wrap-around.
5558 *
5659 * Returns a positive integer on success. Returns %-EINVAL if bits==0.
5760 * Returns %-ENOSPC if no PASID was available. Returns %-ENOMEM on
@@ -59,14 +62,15 @@ struct amdgpu_pasid_cb { · 1 unmodified line
5962 */
6063 int amdgpu_pasid_alloc(unsigned int bits)
6164 {
62− int pasid = -EINVAL;
65+ int pasid;
6366
64− for (bits = min(bits, 31U); bits > 0; bits--) {
65− pasid = ida_alloc_range(&amdgpu_pasid_ida, 1U << (bits - 1),
66− (1U << bits) - 1, GFP_KERNEL);
67− if (pasid != -ENOSPC)
68− break;
69− }
67+ if (bits == 0)
68+ return -EINVAL;
69+
70+ spin_lock(&amdgpu_pasid_idr_lock);
71+ pasid = idr_alloc_cyclic(&amdgpu_pasid_idr, NULL, 1,
72+ 1U << bits, GFP_KERNEL);
73+ spin_unlock(&amdgpu_pasid_idr_lock);
7074
7175 if (pasid >= 0)
7276 trace_amdgpu_pasid_allocated(pasid);
@@ -81,7 +85,10 @@ int amdgpu_pasid_alloc(unsigned int bits) · 8 unmodified lines
8185 void amdgpu_pasid_free(u32 pasid)
8286 {
8387 trace_amdgpu_pasid_freed(pasid);
84− ida_free(&amdgpu_pasid_ida, pasid);
88+
89+ spin_lock(&amdgpu_pasid_idr_lock);
90+ idr_remove(&amdgpu_pasid_idr, pasid);
91+ spin_unlock(&amdgpu_pasid_idr_lock);
8592 }
8693
8794 static void amdgpu_pasid_free_cb(struct dma_fence *fence,
@@ -616,3 +623,15 @@ void amdgpu_vmid_mgr_fini(struct amdgpu_device *adev) · 528 unmodified lines
616623 }
617624 }
618625 }
626+
627+/**
628+ * amdgpu_pasid_mgr_cleanup - cleanup PASID manager
629+ *
630+ * Cleanup the IDR allocator.
631+ */
632+void amdgpu_pasid_mgr_cleanup(void)
633+{
634+ spin_lock(&amdgpu_pasid_idr_lock);
635+ idr_destroy(&amdgpu_pasid_idr);
636+ spin_unlock(&amdgpu_pasid_idr_lock);
637+}
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h+1−0
@@ -74,6 +74,7 @@ int amdgpu_pasid_alloc(unsigned int bits); · 73 unmodified lines
7474 void amdgpu_pasid_free(u32 pasid);
7575 void amdgpu_pasid_free_delayed(struct dma_resv *resv,
7676 u32 pasid);
77+void amdgpu_pasid_mgr_cleanup(void);
7778
7879 bool amdgpu_vmid_had_gpu_reset(struct amdgpu_device *adev,
7980 struct amdgpu_vmid *id);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c+4−3
@@ -2898,6 +2898,7 @@ void amdgpu_vm_manager_fini(struct amdgpu_device *adev) · 2897 unmodified lines
28982898 xa_destroy(&adev->vm_manager.pasids);
28992899
29002900 amdgpu_vmid_mgr_fini(adev);
2901+ amdgpu_pasid_mgr_cleanup();
29012902 }
29022903
29032904 /**
@@ -2973,14 +2974,14 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid, · 69 unmodified lines
29732974 if (!root)
29742975 return false;
29752976
2976− addr /= AMDGPU_GPU_PAGE_SIZE;
2977−
29782977 if (is_compute_context && !svm_range_restore_pages(adev, pasid, vmid,
2979− node_id, addr, ts, write_fault)) {
2978+ node_id, addr >> PAGE_SHIFT, ts, write_fault)) {
29802979 amdgpu_bo_unref(&root);
29812980 return true;
29822981 }
29832982
2983+ addr /= AMDGPU_GPU_PAGE_SIZE;
2984+
29842985 r = amdgpu_bo_reserve(root, true);
29852986 if (r)
29862987 goto error_unref;
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c+3−3
@@ -3170,11 +3170,11 @@ static int kfd_ioctl_create_process(struct file *filep, struct kfd_process *p, v · 3169 unmodified lines
31703170 struct kfd_process *process;
31713171 int ret;
31723172
3173− /* Each FD owns only one kfd_process */
3174− if (p->context_id != KFD_CONTEXT_ID_PRIMARY)
3173+ if (!filep->private_data || !p)
31753174 return -EINVAL;
31763175
3177− if (!filep->private_data || !p)
3176+ /* Each FD owns only one kfd_process */
3177+ if (p->context_id != KFD_CONTEXT_ID_PRIMARY)
31783178 return -EINVAL;
31793179
31803180 mutex_lock(&kfd_processes_mutex);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c+8−2
@@ -3909,8 +3909,9 @@ void amdgpu_dm_update_connector_after_detect( · 3908 unmodified lines
39093909
39103910 aconnector->dc_sink = sink;
39113911 dc_sink_retain(aconnector->dc_sink);
3912+ drm_edid_free(aconnector->drm_edid);
3913+ aconnector->drm_edid = NULL;
39123914 if (sink->dc_edid.length == 0) {
3913− aconnector->drm_edid = NULL;
39143915 hdmi_cec_unset_edid(aconnector);
39153916 if (aconnector->dc_link->aux_mode) {
39163917 drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
@@ -5422,7 +5423,7 @@ static void setup_backlight_device(struct amdgpu_display_manager *dm, · 1505 unmodified lines
54225423 caps = &dm->backlight_caps[aconnector->bl_idx];
54235424
54245425 /* Only offer ABM property when non-OLED and user didn't turn off by module parameter */
5425− if (!caps->ext_caps->bits.oled && amdgpu_dm_abm_level < 0)
5426+ if (caps->ext_caps && !caps->ext_caps->bits.oled && amdgpu_dm_abm_level < 0)
54265427 drm_object_attach_property(&aconnector->base.base,
54275428 dm->adev->mode_info.abm_level_property,
54285429 ABM_SYSFS_CONTROL);
@@ -12523,6 +12524,11 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, · 7094 unmodified lines
1252312524 }
1252412525
1252512526 if (dc_resource_is_dsc_encoding_supported(dc)) {
12527+ for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
12528+ dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
12529+ dm_new_crtc_state->mode_changed_independent_from_dsc = new_crtc_state->mode_changed;
12530+ }
12531+
1252612532 for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
1252712533 if (drm_atomic_crtc_needs_modeset(new_crtc_state)) {
1252812534 ret = add_affected_mst_dsc_crtcs(state, crtc);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h+1−0
@@ -984,6 +984,7 @@ struct dm_crtc_state { · 983 unmodified lines
984984
985985 bool freesync_vrr_info_changed;
986986
987+ bool mode_changed_independent_from_dsc;
987988 bool dsc_force_changed;
988989 bool vrr_supported;
989990 struct mod_freesync_config freesync_config;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c+3−1
@@ -1744,9 +1744,11 @@ int pre_validate_dsc(struct drm_atomic_state *state, · 1743 unmodified lines
17441744 int ind = find_crtc_index_in_state_by_stream(state, stream);
17451745
17461746 if (ind >= 0) {
1747+ struct dm_crtc_state *dm_new_crtc_state = to_dm_crtc_state(state->crtcs[ind].new_state);
1748+
17471749 DRM_INFO_ONCE("%s:%d MST_DSC no mode changed for stream 0x%p\n",
17481750 __func__, __LINE__, stream);
1749− state->crtcs[ind].new_state->mode_changed = 0;
1751+ dm_new_crtc_state->base.mode_changed = dm_new_crtc_state->mode_changed_independent_from_dsc;
17501752 }
17511753 }
17521754 }
drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c+2−4
@@ -650,9 +650,6 @@ static struct link_encoder *dce100_link_encoder_create( · 649 unmodified lines
650650 return &enc110->base;
651651 }
652652
653− if (enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
654− return NULL;
655−
656653 link_regs_id =
657654 map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
658655
@@ -661,7 +658,8 @@ static struct link_encoder *dce100_link_encoder_create( · 2 unmodified lines
661658 &link_enc_feature,
662659 &link_enc_regs[link_regs_id],
663660 &link_enc_aux_regs[enc_init_data->channel - 1],
664− &link_enc_hpd_regs[enc_init_data->hpd_source]);
661+ enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ?
662+ NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]);
665663 return &enc110->base;
666664 }
667665
drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c+3−2
@@ -671,7 +671,7 @@ static struct link_encoder *dce110_link_encoder_create( · 670 unmodified lines
671671 kzalloc_obj(struct dce110_link_encoder);
672672 int link_regs_id;
673673
674− if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
674+ if (!enc110)
675675 return NULL;
676676
677677 link_regs_id =
@@ -682,7 +682,8 @@ static struct link_encoder *dce110_link_encoder_create( · 4 unmodified lines
682682 &link_enc_feature,
683683 &link_enc_regs[link_regs_id],
684684 &link_enc_aux_regs[enc_init_data->channel - 1],
685− &link_enc_hpd_regs[enc_init_data->hpd_source]);
685+ enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ?
686+ NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]);
686687 return &enc110->base;
687688 }
688689
drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.c+3−2
@@ -632,7 +632,7 @@ static struct link_encoder *dce112_link_encoder_create( · 631 unmodified lines
632632 kzalloc_obj(struct dce110_link_encoder);
633633 int link_regs_id;
634634
635− if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
635+ if (!enc110)
636636 return NULL;
637637
638638 link_regs_id =
@@ -643,7 +643,8 @@ static struct link_encoder *dce112_link_encoder_create( · 4 unmodified lines
643643 &link_enc_feature,
644644 &link_enc_regs[link_regs_id],
645645 &link_enc_aux_regs[enc_init_data->channel - 1],
646− &link_enc_hpd_regs[enc_init_data->hpd_source]);
646+ enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ?
647+ NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]);
647648 return &enc110->base;
648649 }
649650
drivers/gpu/drm/amd/display/dc/resource/dce120/dce120_resource.c+3−2
@@ -716,7 +716,7 @@ static struct link_encoder *dce120_link_encoder_create( · 715 unmodified lines
716716 kzalloc_obj(struct dce110_link_encoder);
717717 int link_regs_id;
718718
719− if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
719+ if (!enc110)
720720 return NULL;
721721
722722 link_regs_id =
@@ -727,7 +727,8 @@ static struct link_encoder *dce120_link_encoder_create( · 4 unmodified lines
727727 &link_enc_feature,
728728 &link_enc_regs[link_regs_id],
729729 &link_enc_aux_regs[enc_init_data->channel - 1],
730− &link_enc_hpd_regs[enc_init_data->hpd_source]);
730+ enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ?
731+ NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]);
731732
732733 return &enc110->base;
733734 }
drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c+6−8
@@ -746,18 +746,16 @@ static struct link_encoder *dce60_link_encoder_create( · 745 unmodified lines
746746 return &enc110->base;
747747 }
748748
749− if (enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
750− return NULL;
751−
752749 link_regs_id =
753750 map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
754751
755752 dce60_link_encoder_construct(enc110,
756− enc_init_data,
757− &link_enc_feature,
758− &link_enc_regs[link_regs_id],
759− &link_enc_aux_regs[enc_init_data->channel - 1],
760− &link_enc_hpd_regs[enc_init_data->hpd_source]);
753+ enc_init_data,
754+ &link_enc_feature,
755+ &link_enc_regs[link_regs_id],
756+ &link_enc_aux_regs[enc_init_data->channel - 1],
757+ enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ?
758+ NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]);
761759 return &enc110->base;
762760 }
763761
drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c+2−4
@@ -752,9 +752,6 @@ static struct link_encoder *dce80_link_encoder_create( · 751 unmodified lines
752752 return &enc110->base;
753753 }
754754
755− if (enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
756− return NULL;
757−
758755 link_regs_id =
759756 map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
760757
@@ -763,7 +760,8 @@ static struct link_encoder *dce80_link_encoder_create( · 2 unmodified lines
763760 &link_enc_feature,
764761 &link_enc_regs[link_regs_id],
765762 &link_enc_aux_regs[enc_init_data->channel - 1],
766− &link_enc_hpd_regs[enc_init_data->hpd_source]);
763+ enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ?
764+ NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]);
767765 return &enc110->base;
768766 }
769767
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c+32−1
@@ -59,6 +59,10 @@ · 58 unmodified lines
5959
6060 #define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c))
6161
62+static void smu_v13_0_0_get_od_setting_limits(struct smu_context *smu,
63+ int od_feature_bit,
64+ int32_t *min, int32_t *max);
65+
6266 static const struct smu_feature_bits smu_v13_0_0_dpm_features = {
6367 .bits = {
6468 SMU_FEATURE_BIT_INIT(FEATURE_DPM_GFXCLK_BIT),
@@ -1043,8 +1047,35 @@ static bool smu_v13_0_0_is_od_feature_supported(struct smu_context *smu, · 978 unmodified lines
10431047 PPTable_t *pptable = smu->smu_table.driver_pptable;
10441048 const OverDriveLimits_t * const overdrive_upperlimits =
10451049 &pptable->SkuTable.OverDriveLimitsBasicMax;
1050+ int32_t min_value, max_value;
1051+ bool feature_enabled;
10461052
1047− return overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit);
1053+ switch (od_feature_bit) {
1054+ case PP_OD_FEATURE_FAN_CURVE_BIT:
1055+ feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
1056+ if (feature_enabled) {
1057+ smu_v13_0_0_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_TEMP,
1058+ &min_value, &max_value);
1059+ if (!min_value && !max_value) {
1060+ feature_enabled = false;
1061+ goto out;
1062+ }
1063+
1064+ smu_v13_0_0_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_PWM,
1065+ &min_value, &max_value);
1066+ if (!min_value && !max_value) {
1067+ feature_enabled = false;
1068+ goto out;
1069+ }
1070+ }
1071+ break;
1072+ default:
1073+ feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
1074+ break;
1075+ }
1076+
1077+out:
1078+ return feature_enabled;
10481079 }
10491080
10501081 static void smu_v13_0_0_get_od_setting_limits(struct smu_context *smu,
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c+12−9
@@ -1391,7 +1391,7 @@ static int smu_v13_0_6_emit_clk_levels(struct smu_context *smu, · 1390 unmodified lines
13911391 break;
13921392 case SMU_OD_MCLK:
13931393 if (!smu_v13_0_6_cap_supported(smu, SMU_CAP(SET_UCLK_MAX)))
1394− return 0;
1394+ return -EOPNOTSUPP;
13951395
13961396 size += sysfs_emit_at(buf, size, "%s:\n", "OD_MCLK");
13971397 size += sysfs_emit_at(buf, size, "0: %uMhz\n1: %uMhz\n",
@@ -2122,6 +2122,7 @@ static int smu_v13_0_6_usr_edit_dpm_table(struct smu_context *smu, · 724 unmodified lines
21222122 {
21232123 struct smu_dpm_context *smu_dpm = &(smu->smu_dpm);
21242124 struct smu_13_0_dpm_context *dpm_context = smu_dpm->dpm_context;
2125+ struct smu_dpm_table *uclk_table = &dpm_context->dpm_tables.uclk_table;
21252126 struct smu_umd_pstate_table *pstate_table = &smu->pstate_table;
21262127 uint32_t min_clk;
21272128 uint32_t max_clk;
@@ -2221,14 +2222,16 @@ static int smu_v13_0_6_usr_edit_dpm_table(struct smu_context *smu, · 93 unmodified lines
22212222 if (ret)
22222223 return ret;
22232224
2224− min_clk = SMU_DPM_TABLE_MIN(
2225− &dpm_context->dpm_tables.uclk_table);
2226− max_clk = SMU_DPM_TABLE_MAX(
2227− &dpm_context->dpm_tables.uclk_table);
2228− ret = smu_v13_0_6_set_soft_freq_limited_range(
2229− smu, SMU_UCLK, min_clk, max_clk, false);
2230− if (ret)
2231− return ret;
2225+ if (SMU_DPM_TABLE_MAX(uclk_table) !=
2226+ pstate_table->uclk_pstate.curr.max) {
2227+ min_clk = SMU_DPM_TABLE_MIN(&dpm_context->dpm_tables.uclk_table);
2228+ max_clk = SMU_DPM_TABLE_MAX(&dpm_context->dpm_tables.uclk_table);
2229+ ret = smu_v13_0_6_set_soft_freq_limited_range(smu,
2230+ SMU_UCLK, min_clk,
2231+ max_clk, false);
2232+ if (ret)
2233+ return ret;
2234+ }
22322235 smu_v13_0_reset_custom_level(smu);
22332236 }
22342237 break;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c+32−1
@@ -59,6 +59,10 @@ · 58 unmodified lines
5959
6060 #define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c))
6161
62+static void smu_v13_0_7_get_od_setting_limits(struct smu_context *smu,
63+ int od_feature_bit,
64+ int32_t *min, int32_t *max);
65+
6266 static const struct smu_feature_bits smu_v13_0_7_dpm_features = {
6367 .bits = {
6468 SMU_FEATURE_BIT_INIT(FEATURE_DPM_GFXCLK_BIT),
@@ -1053,8 +1057,35 @@ static bool smu_v13_0_7_is_od_feature_supported(struct smu_context *smu, · 988 unmodified lines
10531057 PPTable_t *pptable = smu->smu_table.driver_pptable;
10541058 const OverDriveLimits_t * const overdrive_upperlimits =
10551059 &pptable->SkuTable.OverDriveLimitsBasicMax;
1060+ int32_t min_value, max_value;
1061+ bool feature_enabled;
10561062
1057− return overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit);
1063+ switch (od_feature_bit) {
1064+ case PP_OD_FEATURE_FAN_CURVE_BIT:
1065+ feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
1066+ if (feature_enabled) {
1067+ smu_v13_0_7_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_TEMP,
1068+ &min_value, &max_value);
1069+ if (!min_value && !max_value) {
1070+ feature_enabled = false;
1071+ goto out;
1072+ }
1073+
1074+ smu_v13_0_7_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_PWM,
1075+ &min_value, &max_value);
1076+ if (!min_value && !max_value) {
1077+ feature_enabled = false;
1078+ goto out;
1079+ }
1080+ }
1081+ break;
1082+ default:
1083+ feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
1084+ break;
1085+ }
1086+
1087+out:
1088+ return feature_enabled;
10581089 }
10591090
10601091 static void smu_v13_0_7_get_od_setting_limits(struct smu_context *smu,
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c+32−1
@@ -56,6 +56,10 @@ · 55 unmodified lines
5656
5757 #define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c))
5858
59+static void smu_v14_0_2_get_od_setting_limits(struct smu_context *smu,
60+ int od_feature_bit,
61+ int32_t *min, int32_t *max);
62+
5963 static const struct smu_feature_bits smu_v14_0_2_dpm_features = {
6064 .bits = { SMU_FEATURE_BIT_INIT(FEATURE_DPM_GFXCLK_BIT),
6165 SMU_FEATURE_BIT_INIT(FEATURE_DPM_UCLK_BIT),
@@ -922,8 +926,35 @@ static bool smu_v14_0_2_is_od_feature_supported(struct smu_context *smu, · 860 unmodified lines
922926 PPTable_t *pptable = smu->smu_table.driver_pptable;
923927 const OverDriveLimits_t * const overdrive_upperlimits =
924928 &pptable->SkuTable.OverDriveLimitsBasicMax;
929+ int32_t min_value, max_value;
930+ bool feature_enabled;
925931
926− return overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit);
932+ switch (od_feature_bit) {
933+ case PP_OD_FEATURE_FAN_CURVE_BIT:
934+ feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
935+ if (feature_enabled) {
936+ smu_v14_0_2_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_TEMP,
937+ &min_value, &max_value);
938+ if (!min_value && !max_value) {
939+ feature_enabled = false;
940+ goto out;
941+ }
942+
943+ smu_v14_0_2_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_PWM,
944+ &min_value, &max_value);
945+ if (!min_value && !max_value) {
946+ feature_enabled = false;
947+ goto out;
948+ }
949+ }
950+ break;
951+ default:
952+ feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
953+ break;
954+ }
955+
956+out:
957+ return feature_enabled;
927958 }
928959
929960 static void smu_v14_0_2_get_od_setting_limits(struct smu_context *smu,
drivers/gpu/drm/drm_gem_shmem_helper.c+28−22
@@ -550,27 +550,27 @@ int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev, · 549 unmodified lines
550550 }
551551 EXPORT_SYMBOL_GPL(drm_gem_shmem_dumb_create);
552552
553−static bool drm_gem_shmem_try_map_pmd(struct vm_fault *vmf, unsigned long addr,
554− struct page *page)
553+static vm_fault_t try_insert_pfn(struct vm_fault *vmf, unsigned int order,
554+ unsigned long pfn)
555555 {
556+ if (!order) {
557+ return vmf_insert_pfn(vmf->vma, vmf->address, pfn);
556558 #ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
557− unsigned long pfn = page_to_pfn(page);
558− unsigned long paddr = pfn << PAGE_SHIFT;
559− bool aligned = (addr & ~PMD_MASK) == (paddr & ~PMD_MASK);
560−
561− if (aligned &&
562− pmd_none(*vmf->pmd) &&
563− folio_test_pmd_mappable(page_folio(page))) {
564− pfn &= PMD_MASK >> PAGE_SHIFT;
565− if (vmf_insert_pfn_pmd(vmf, pfn, false) == VM_FAULT_NOPAGE)
566− return true;
567− }
559+ } else if (order == PMD_ORDER) {
560+ unsigned long paddr = pfn << PAGE_SHIFT;
561+ bool aligned = (vmf->address & ~PMD_MASK) == (paddr & ~PMD_MASK);
562+
563+ if (aligned &&
564+ folio_test_pmd_mappable(page_folio(pfn_to_page(pfn)))) {
565+ pfn &= PMD_MASK >> PAGE_SHIFT;
566+ return vmf_insert_pfn_pmd(vmf, pfn, false);
567+ }
568568 #endif
569−
570− return false;
569+ }
570+ return VM_FAULT_FALLBACK;
571571 }
572572
573−static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf)
573+static vm_fault_t drm_gem_shmem_any_fault(struct vm_fault *vmf, unsigned int order)
574574 {
575575 struct vm_area_struct *vma = vmf->vma;
576576 struct drm_gem_object *obj = vma->vm_private_data;
@@ -581,6 +581,9 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) · 4 unmodified lines
581581 pgoff_t page_offset;
582582 unsigned long pfn;
583583
584+ if (order && order != PMD_ORDER)
585+ return VM_FAULT_FALLBACK;
586+
584587 /* Offset to faulty address in the VMA. */
585588 page_offset = vmf->pgoff - vma->vm_pgoff;
586589
@@ -593,13 +596,8 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) · 6 unmodified lines
593596 goto out;
594597 }
595598
596− if (drm_gem_shmem_try_map_pmd(vmf, vmf->address, pages[page_offset])) {
597− ret = VM_FAULT_NOPAGE;
598− goto out;
599− }
600−
601599 pfn = page_to_pfn(pages[page_offset]);
602− ret = vmf_insert_pfn(vma, vmf->address, pfn);
600+ ret = try_insert_pfn(vmf, order, pfn);
603601
604602 out:
605603 dma_resv_unlock(shmem->base.resv);
@@ -607,6 +605,11 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) · 1 unmodified line
607605 return ret;
608606 }
609607
608+static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf)
609+{
610+ return drm_gem_shmem_any_fault(vmf, 0);
611+}
612+
610613 static void drm_gem_shmem_vm_open(struct vm_area_struct *vma)
611614 {
612615 struct drm_gem_object *obj = vma->vm_private_data;
@@ -643,6 +646,9 @@ static void drm_gem_shmem_vm_close(struct vm_area_struct *vma) · 30 unmodified lines
643646
644647 const struct vm_operations_struct drm_gem_shmem_vm_ops = {
645648 .fault = drm_gem_shmem_fault,
649+#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
650+ .huge_fault = drm_gem_shmem_any_fault,
651+#endif
646652 .open = drm_gem_shmem_vm_open,
647653 .close = drm_gem_shmem_vm_close,
648654 };
drivers/gpu/drm/drm_syncobj.c+2−2
@@ -602,7 +602,7 @@ int drm_syncobj_get_handle(struct drm_file *file_private, · 601 unmodified lines
602602 drm_syncobj_get(syncobj);
603603
604604 ret = xa_alloc(&file_private->syncobj_xa, handle, syncobj, xa_limit_32b,
605− GFP_NOWAIT);
605+ GFP_KERNEL);
606606 if (ret)
607607 drm_syncobj_put(syncobj);
608608
@@ -716,7 +716,7 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private, · 107 unmodified lines
716716 drm_syncobj_get(syncobj);
717717
718718 ret = xa_alloc(&file_private->syncobj_xa, handle, syncobj, xa_limit_32b,
719− GFP_NOWAIT);
719+ GFP_KERNEL);
720720 if (ret)
721721 drm_syncobj_put(syncobj);
722722
drivers/gpu/drm/i915/display/intel_display.c+7−1
@@ -4602,6 +4602,7 @@ intel_crtc_prepare_cleared_state(struct intel_atomic_state *state, · 4601 unmodified lines
46024602 struct intel_crtc_state *crtc_state =
46034603 intel_atomic_get_new_crtc_state(state, crtc);
46044604 struct intel_crtc_state *saved_state;
4605+ int err;
46054606
46064607 saved_state = intel_crtc_state_alloc(crtc);
46074608 if (!saved_state)
@@ -4610,7 +4611,12 @@ intel_crtc_prepare_cleared_state(struct intel_atomic_state *state, · 2 unmodified lines
46104611 /* free the old crtc_state->hw members */
46114612 intel_crtc_free_hw_state(crtc_state);
46124613
4613− intel_dp_tunnel_atomic_clear_stream_bw(state, crtc_state);
4614+ err = intel_dp_tunnel_atomic_clear_stream_bw(state, crtc_state);
4615+ if (err) {
4616+ kfree(saved_state);
4617+
4618+ return err;
4619+ }
46144620
46154621 /* FIXME: before the switch to atomic started, a new pipe_config was
46164622 * kzalloc'd. Code that depends on any field being zero should be
drivers/gpu/drm/i915/display/intel_dp_tunnel.c+14−6
@@ -621,19 +621,27 @@ int intel_dp_tunnel_atomic_compute_stream_bw(struct intel_atomic_state *state, · 620 unmodified lines
621621 *
622622 * Clear any DP tunnel stream BW requirement set by
623623 * intel_dp_tunnel_atomic_compute_stream_bw().
624+ *
625+ * Returns 0 in case of success, a negative error code otherwise.
624626 */
625−void intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state,
626− struct intel_crtc_state *crtc_state)
627+int intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state,
628+ struct intel_crtc_state *crtc_state)
627629 {
628630 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
631+ int err;
629632
630633 if (!crtc_state->dp_tunnel_ref.tunnel)
631− return;
634+ return 0;
635+
636+ err = drm_dp_tunnel_atomic_set_stream_bw(&state->base,
637+ crtc_state->dp_tunnel_ref.tunnel,
638+ crtc->pipe, 0);
639+ if (err)
640+ return err;
632641
633− drm_dp_tunnel_atomic_set_stream_bw(&state->base,
634− crtc_state->dp_tunnel_ref.tunnel,
635− crtc->pipe, 0);
636642 drm_dp_tunnel_ref_put(&crtc_state->dp_tunnel_ref);
643+
644+ return 0;
637645 }
638646
639647 /**
drivers/gpu/drm/i915/display/intel_dp_tunnel.h+7−4
@@ -40,8 +40,8 @@ int intel_dp_tunnel_atomic_compute_stream_bw(struct intel_atomic_state *state, · 39 unmodified lines
4040 struct intel_dp *intel_dp,
4141 const struct intel_connector *connector,
4242 struct intel_crtc_state *crtc_state);
43−void intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state,
44− struct intel_crtc_state *crtc_state);
43+int intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state,
44+ struct intel_crtc_state *crtc_state);
4545
4646 int intel_dp_tunnel_atomic_add_state_for_crtc(struct intel_atomic_state *state,
4747 struct intel_crtc *crtc);
@@ -88,9 +88,12 @@ intel_dp_tunnel_atomic_compute_stream_bw(struct intel_atomic_state *state, · 40 unmodified lines
8888 return 0;
8989 }
9090
91−static inline void
91+static inline int
9292 intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state,
93− struct intel_crtc_state *crtc_state) {}
93+ struct intel_crtc_state *crtc_state)
94+{
95+ return 0;
96+}
9497
9598 static inline int
9699 intel_dp_tunnel_atomic_add_state_for_crtc(struct intel_atomic_state *state,
drivers/gpu/drm/i915/display/intel_gmbus.c+3−1
@@ -496,8 +496,10 @@ gmbus_xfer_read_chunk(struct intel_display *display, · 495 unmodified lines
496496
497497 val = intel_de_read_fw(display, GMBUS3(display));
498498 do {
499− if (extra_byte_added && len == 1)
499+ if (extra_byte_added && len == 1) {
500+ len--;
500501 break;
502+ }
501503
502504 *buf++ = val & 0xff;
503505 val >>= 8;
drivers/gpu/drm/i915/display/intel_plane.c+9−2
@@ -436,11 +436,16 @@ void intel_plane_copy_hw_state(struct intel_plane_state *plane_state, · 435 unmodified lines
436436 drm_framebuffer_get(plane_state->hw.fb);
437437 }
438438
439+static void unlink_nv12_plane(struct intel_crtc_state *crtc_state,
440+ struct intel_plane_state *plane_state);
441+
439442 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
440443 struct intel_plane_state *plane_state)
441444 {
442445 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
443446
447+ unlink_nv12_plane(crtc_state, plane_state);
448+
444449 crtc_state->active_planes &= ~BIT(plane->id);
445450 crtc_state->scaled_planes &= ~BIT(plane->id);
446451 crtc_state->nv12_planes &= ~BIT(plane->id);
@@ -1513,6 +1518,9 @@ static void unlink_nv12_plane(struct intel_crtc_state *crtc_state, · 1066 unmodified lines
15131518 struct intel_display *display = to_intel_display(plane_state);
15141519 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
15151520
1521+ if (!plane_state->planar_linked_plane)
1522+ return;
1523+
15161524 plane_state->planar_linked_plane = NULL;
15171525
15181526 if (!plane_state->is_y_plane)
@@ -1550,8 +1558,7 @@ static int icl_check_nv12_planes(struct intel_atomic_state *state, · 31 unmodified lines
15501558 if (plane->pipe != crtc->pipe)
15511559 continue;
15521560
1553− if (plane_state->planar_linked_plane)
1554− unlink_nv12_plane(crtc_state, plane_state);
1561+ unlink_nv12_plane(crtc_state, plane_state);
15551562 }
15561563
15571564 if (!crtc_state->nv12_planes)
drivers/gpu/drm/i915/i915_wait_util.h+1−1
@@ -25,9 +25,9 @@ · 24 unmodified lines
2525 might_sleep(); \
2626 for (;;) { \
2727 const bool expired__ = ktime_after(ktime_get_raw(), end__); \
28− OP; \
2928 /* Guarantee COND check prior to timeout */ \
3029 barrier(); \
30+ OP; \
3131 if (COND) { \
3232 ret__ = 0; \
3333 break; \
drivers/gpu/drm/mediatek/mtk_dsi.c+5−4
@@ -1236,6 +1236,11 @@ static int mtk_dsi_probe(struct platform_device *pdev) · 1235 unmodified lines
12361236
12371237 dsi->host.ops = &mtk_dsi_ops;
12381238 dsi->host.dev = dev;
1239+
1240+ init_waitqueue_head(&dsi->irq_wait_queue);
1241+
1242+ platform_set_drvdata(pdev, dsi);
1243+
12391244 ret = mipi_dsi_host_register(&dsi->host);
12401245 if (ret < 0)
12411246 return dev_err_probe(dev, ret, "Failed to register DSI host\n");
@@ -1247,10 +1252,6 @@ static int mtk_dsi_probe(struct platform_device *pdev) · 5 unmodified lines
12471252 return dev_err_probe(&pdev->dev, ret, "Failed to request DSI irq\n");
12481253 }
12491254
1250− init_waitqueue_head(&dsi->irq_wait_queue);
1251−
1252− platform_set_drvdata(pdev, dsi);
1253−
12541255 dsi->bridge.of_node = dev->of_node;
12551256 dsi->bridge.type = DRM_MODE_CONNECTOR_DSI;
12561257
drivers/gpu/drm/xe/regs/xe_gt_regs.h+1−0
@@ -553,6 +553,7 @@ · 552 unmodified lines
553553 #define ENABLE_SMP_LD_RENDER_SURFACE_CONTROL REG_BIT(44 - 32)
554554 #define FORCE_SLM_FENCE_SCOPE_TO_TILE REG_BIT(42 - 32)
555555 #define FORCE_UGM_FENCE_SCOPE_TO_TILE REG_BIT(41 - 32)
556+#define L3_128B_256B_WRT_DIS REG_BIT(40 - 32)
556557 #define MAXREQS_PER_BANK REG_GENMASK(39 - 32, 37 - 32)
557558 #define DISABLE_128B_EVICTION_COMMAND_UDW REG_BIT(36 - 32)
558559
drivers/gpu/drm/xe/xe_pt.c+6−6
@@ -1442,9 +1442,9 @@ static int op_check_svm_userptr(struct xe_vm *vm, struct xe_vma_op *op, · 1441 unmodified lines
14421442 err = vma_check_userptr(vm, op->map.vma, pt_update);
14431443 break;
14441444 case DRM_GPUVA_OP_REMAP:
1445− if (op->remap.prev)
1445+ if (op->remap.prev && !op->remap.skip_prev)
14461446 err = vma_check_userptr(vm, op->remap.prev, pt_update);
1447− if (!err && op->remap.next)
1447+ if (!err && op->remap.next && !op->remap.skip_next)
14481448 err = vma_check_userptr(vm, op->remap.next, pt_update);
14491449 break;
14501450 case DRM_GPUVA_OP_UNMAP:
@@ -2198,12 +2198,12 @@ static int op_prepare(struct xe_vm *vm, · 747 unmodified lines
21982198
21992199 err = unbind_op_prepare(tile, pt_update_ops, old);
22002200
2201− if (!err && op->remap.prev) {
2201+ if (!err && op->remap.prev && !op->remap.skip_prev) {
22022202 err = bind_op_prepare(vm, tile, pt_update_ops,
22032203 op->remap.prev, false);
22042204 pt_update_ops->wait_vm_bookkeep = true;
22052205 }
2206− if (!err && op->remap.next) {
2206+ if (!err && op->remap.next && !op->remap.skip_next) {
22072207 err = bind_op_prepare(vm, tile, pt_update_ops,
22082208 op->remap.next, false);
22092209 pt_update_ops->wait_vm_bookkeep = true;
@@ -2428,10 +2428,10 @@ static void op_commit(struct xe_vm *vm, · 218 unmodified lines
24282428
24292429 unbind_op_commit(vm, tile, pt_update_ops, old, fence, fence2);
24302430
2431− if (op->remap.prev)
2431+ if (op->remap.prev && !op->remap.skip_prev)
24322432 bind_op_commit(vm, tile, pt_update_ops, op->remap.prev,
24332433 fence, fence2, false);
2434− if (op->remap.next)
2434+ if (op->remap.next && !op->remap.skip_next)
24352435 bind_op_commit(vm, tile, pt_update_ops, op->remap.next,
24362436 fence, fence2, false);
24372437 break;
drivers/gpu/drm/xe/xe_sriov_packet.c+2−0
@@ -341,6 +341,8 @@ ssize_t xe_sriov_packet_write_single(struct xe_device *xe, unsigned int vfid, · 340 unmodified lines
341341 ret = xe_sriov_pf_migration_restore_produce(xe, vfid, *data);
342342 if (ret) {
343343 xe_sriov_packet_free(*data);
344+ *data = NULL;
345+
344346 return ret;
345347 }
346348
drivers/gpu/drm/xe/xe_vm.c+18−4
@@ -2554,7 +2554,6 @@ static int xe_vma_op_commit(struct xe_vm *vm, struct xe_vma_op *op) · 2553 unmodified lines
25542554 if (!err && op->remap.skip_prev) {
25552555 op->remap.prev->tile_present =
25562556 tile_present;
2557− op->remap.prev = NULL;
25582557 }
25592558 }
25602559 if (op->remap.next) {
@@ -2564,11 +2563,13 @@ static int xe_vma_op_commit(struct xe_vm *vm, struct xe_vma_op *op) · 3 unmodified lines
25642563 if (!err && op->remap.skip_next) {
25652564 op->remap.next->tile_present =
25662565 tile_present;
2567− op->remap.next = NULL;
25682566 }
25692567 }
25702568
2571− /* Adjust for partial unbind after removing VMA from VM */
2569+ /*
2570+ * Adjust for partial unbind after removing VMA from VM. In case
2571+ * of unwind we might need to undo this later.
2572+ */
25722573 if (!err) {
25732574 op->base.remap.unmap->va->va.addr = op->remap.start;
25742575 op->base.remap.unmap->va->va.range = op->remap.range;
@@ -2687,6 +2688,8 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops, · 112 unmodified lines
26872688
26882689 op->remap.start = xe_vma_start(old);
26892690 op->remap.range = xe_vma_size(old);
2691+ op->remap.old_start = op->remap.start;
2692+ op->remap.old_range = op->remap.range;
26902693
26912694 flags |= op->base.remap.unmap->va->flags & XE_VMA_CREATE_MASK;
26922695 if (op->base.remap.prev) {
@@ -2835,8 +2838,19 @@ static void xe_vma_op_unwind(struct xe_vm *vm, struct xe_vma_op *op, · 142 unmodified lines
28352838 xe_svm_notifier_lock(vm);
28362839 vma->gpuva.flags &= ~XE_VMA_DESTROYED;
28372840 xe_svm_notifier_unlock(vm);
2838− if (post_commit)
2841+ if (post_commit) {
2842+ /*
2843+ * Restore the old va range, in case of the
2844+ * prev/next skip optimisation. Otherwise what
2845+ * we re-insert here could be smaller than the
2846+ * original range.
2847+ */
2848+ op->base.remap.unmap->va->va.addr =
2849+ op->remap.old_start;
2850+ op->base.remap.unmap->va->va.range =
2851+ op->remap.old_range;
28392852 xe_vm_insert_vma(vm, vma);
2853+ }
28402854 }
28412855 break;
28422856 }
drivers/gpu/drm/xe/xe_vm_types.h+4−0
@@ -373,6 +373,10 @@ struct xe_vma_op_remap { · 372 unmodified lines
373373 u64 start;
374374 /** @range: range of the VMA unmap */
375375 u64 range;
376+ /** @old_start: Original start of the VMA we unmap */
377+ u64 old_start;
378+ /** @old_range: Original range of the VMA we unmap */
379+ u64 old_range;
376380 /** @skip_prev: skip prev rebind */
377381 bool skip_prev;
378382 /** @skip_next: skip next rebind */
drivers/gpu/drm/xe/xe_wa.c+2−1
@@ -247,7 +247,8 @@ static const struct xe_rtp_entry_sr gt_was[] = { · 246 unmodified lines
247247 LSN_DIM_Z_WGT_MASK,
248248 LSN_LNI_WGT(1) | LSN_LNE_WGT(1) |
249249 LSN_DIM_X_WGT(1) | LSN_DIM_Y_WGT(1) |
250− LSN_DIM_Z_WGT(1)))
250+ LSN_DIM_Z_WGT(1)),
251+ SET(LSC_CHICKEN_BIT_0_UDW, L3_128B_256B_WRT_DIS))
251252 },
252253
253254 /* Xe2_HPM */
drivers/hwmon/adm1177.c+31−23
@@ -10,6 +10,8 @@ · 9 unmodified lines
1010 #include <linux/hwmon.h>
1111 #include <linux/i2c.h>
1212 #include <linux/init.h>
13+#include <linux/math64.h>
14+#include <linux/minmax.h>
1315 #include <linux/module.h>
1416 #include <linux/regulator/consumer.h>
1517
@@ -33,7 +35,7 @@ · 17 unmodified lines
3335 struct adm1177_state {
3436 struct i2c_client *client;
3537 u32 r_sense_uohm;
36− u32 alert_threshold_ua;
38+ u64 alert_threshold_ua;
3739 bool vrange_high;
3840 };
3941
@@ -48,7 +50,7 @@ static int adm1177_write_cmd(struct adm1177_state *st, u8 cmd) · 8 unmodified lines
4850 }
4951
5052 static int adm1177_write_alert_thr(struct adm1177_state *st,
51− u32 alert_threshold_ua)
53+ u64 alert_threshold_ua)
5254 {
5355 u64 val;
5456 int ret;
@@ -91,8 +93,8 @@ static int adm1177_read(struct device *dev, enum hwmon_sensor_types type, · 36 unmodified lines
9193 *val = div_u64((105840000ull * dummy),
9294 4096 * st->r_sense_uohm);
9395 return 0;
94− case hwmon_curr_max_alarm:
95− *val = st->alert_threshold_ua;
96+ case hwmon_curr_max:
97+ *val = div_u64(st->alert_threshold_ua, 1000);
9698 return 0;
9799 default:
98100 return -EOPNOTSUPP;
@@ -126,9 +128,10 @@ static int adm1177_write(struct device *dev, enum hwmon_sensor_types type, · 27 unmodified lines
126128 switch (type) {
127129 case hwmon_curr:
128130 switch (attr) {
129− case hwmon_curr_max_alarm:
130− adm1177_write_alert_thr(st, val);
131− return 0;
131+ case hwmon_curr_max:
132+ val = clamp_val(val, 0,
133+ div_u64(105840000ULL, st->r_sense_uohm));
134+ return adm1177_write_alert_thr(st, (u64)val * 1000);
132135 default:
133136 return -EOPNOTSUPP;
134137 }
@@ -156,7 +159,7 @@ static umode_t adm1177_is_visible(const void *data, · 21 unmodified lines
156159 if (st->r_sense_uohm)
157160 return 0444;
158161 return 0;
159− case hwmon_curr_max_alarm:
162+ case hwmon_curr_max:
160163 if (st->r_sense_uohm)
161164 return 0644;
162165 return 0;
@@ -170,7 +173,7 @@ static umode_t adm1177_is_visible(const void *data, · 7 unmodified lines
170173
171174 static const struct hwmon_channel_info * const adm1177_info[] = {
172175 HWMON_CHANNEL_INFO(curr,
173− HWMON_C_INPUT | HWMON_C_MAX_ALARM),
176+ HWMON_C_INPUT | HWMON_C_MAX),
174177 HWMON_CHANNEL_INFO(in,
175178 HWMON_I_INPUT),
176179 NULL
@@ -192,7 +195,8 @@ static int adm1177_probe(struct i2c_client *client) · 15 unmodified lines
192195 struct device *dev = &client->dev;
193196 struct device *hwmon_dev;
194197 struct adm1177_state *st;
195− u32 alert_threshold_ua;
198+ u64 alert_threshold_ua;
199+ u32 prop;
196200 int ret;
197201
198202 st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL);
@@ -208,22 +212,26 @@ static int adm1177_probe(struct i2c_client *client) · 9 unmodified lines
208212 if (device_property_read_u32(dev, "shunt-resistor-micro-ohms",
209213 &st->r_sense_uohm))
210214 st->r_sense_uohm = 0;
211− if (device_property_read_u32(dev, "adi,shutdown-threshold-microamp",
212− &alert_threshold_ua)) {
213− if (st->r_sense_uohm)
214− /*
215− * set maximum default value from datasheet based on
216− * shunt-resistor
217− */
218− alert_threshold_ua = div_u64(105840000000,
219− st->r_sense_uohm);
220− else
221− alert_threshold_ua = 0;
215+ if (!device_property_read_u32(dev, "adi,shutdown-threshold-microamp",
216+ &prop)) {
217+ alert_threshold_ua = prop;
218+ } else if (st->r_sense_uohm) {
219+ /*
220+ * set maximum default value from datasheet based on
221+ * shunt-resistor
222+ */
223+ alert_threshold_ua = div_u64(105840000000ULL,
224+ st->r_sense_uohm);
225+ } else {
226+ alert_threshold_ua = 0;
222227 }
223228 st->vrange_high = device_property_read_bool(dev,
224229 "adi,vrange-high-enable");
225− if (alert_threshold_ua && st->r_sense_uohm)
226− adm1177_write_alert_thr(st, alert_threshold_ua);
230+ if (alert_threshold_ua && st->r_sense_uohm) {
231+ ret = adm1177_write_alert_thr(st, alert_threshold_ua);
232+ if (ret)
233+ return ret;
234+ }
227235
228236 ret = adm1177_write_cmd(st, ADM1177_CMD_V_CONT |
229237 ADM1177_CMD_I_CONT |
drivers/hwmon/peci/cputemp.c+2−2
@@ -131,7 +131,7 @@ static int get_temp_target(struct peci_cputemp *priv, enum peci_temp_target_type · 130 unmodified lines
131131 *val = priv->temp.target.tjmax;
132132 break;
133133 case crit_hyst_type:
134− *val = priv->temp.target.tjmax - priv->temp.target.tcontrol;
134+ *val = priv->temp.target.tcontrol;
135135 break;
136136 default:
137137 ret = -EOPNOTSUPP;
@@ -319,7 +319,7 @@ static umode_t cputemp_is_visible(const void *data, enum hwmon_sensor_types type · 181 unmodified lines
319319 {
320320 const struct peci_cputemp *priv = data;
321321
322− if (channel > CPUTEMP_CHANNEL_NUMS)
322+ if (channel >= CPUTEMP_CHANNEL_NUMS)
323323 return 0;
324324
325325 if (channel < channel_core)
drivers/hwmon/pmbus/ina233.c+2−1
@@ -72,7 +72,8 @@ static int ina233_read_word_data(struct i2c_client *client, int page, · 71 unmodified lines
7272
7373 /* Adjust returned value to match VIN coefficients */
7474 /* VIN: 1.25 mV VSHUNT: 2.5 uV LSB */
75− ret = DIV_ROUND_CLOSEST(ret * 25, 12500);
75+ ret = clamp_val(DIV_ROUND_CLOSEST((s16)ret * 25, 12500),
76+ S16_MIN, S16_MAX) & 0xffff;
7677 break;
7778 default:
7879 ret = -ENODATA;
drivers/hwmon/pmbus/isl68137.c+18−3
@@ -96,7 +96,15 @@ static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client, · 95 unmodified lines
9696 int page,
9797 char *buf)
9898 {
99− int val = pmbus_read_byte_data(client, page, PMBUS_OPERATION);
99+ int val;
100+
101+ val = pmbus_lock_interruptible(client);
102+ if (val)
103+ return val;
104+
105+ val = pmbus_read_byte_data(client, page, PMBUS_OPERATION);
106+
107+ pmbus_unlock(client);
100108
101109 if (val < 0)
102110 return val;
@@ -118,6 +126,10 @@ static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client, · 15 unmodified lines
118126
119127 op_val = result ? ISL68137_VOUT_AVS : 0;
120128
129+ rc = pmbus_lock_interruptible(client);
130+ if (rc)
131+ return rc;
132+
121133 /*
122134 * Writes to VOUT setpoint over AVSBus will persist after the VRM is
123135 * switched to PMBus control. Switching back to AVSBus control
@@ -129,17 +141,20 @@ static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client, · 5 unmodified lines
129141 rc = pmbus_read_word_data(client, page, 0xff,
130142 PMBUS_VOUT_COMMAND);
131143 if (rc < 0)
132− return rc;
144+ goto unlock;
133145
134146 rc = pmbus_write_word_data(client, page, PMBUS_VOUT_COMMAND,
135147 rc);
136148 if (rc < 0)
137− return rc;
149+ goto unlock;
138150 }
139151
140152 rc = pmbus_update_byte_data(client, page, PMBUS_OPERATION,
141153 ISL68137_VOUT_AVS, op_val);
142154
155+unlock:
156+ pmbus_unlock(client);
157+
143158 return (rc < 0) ? rc : count;
144159 }
145160
drivers/hwmon/pmbus/pmbus_core.c+154−38
@@ -6,6 +6,7 @@ · 5 unmodified lines
66 * Copyright (c) 2012 Guenter Roeck
77 */
88
9+#include <linux/atomic.h>
910 #include <linux/debugfs.h>
1011 #include <linux/delay.h>
1112 #include <linux/dcache.h>
@@ -21,8 +22,8 @@ · 9 unmodified lines
2122 #include <linux/pmbus.h>
2223 #include <linux/regulator/driver.h>
2324 #include <linux/regulator/machine.h>
24−#include <linux/of.h>
2525 #include <linux/thermal.h>
26+#include <linux/workqueue.h>
2627 #include "pmbus.h"
2728
2829 /*
@@ -112,6 +113,11 @@ struct pmbus_data { · 83 unmodified lines
112113
113114 struct mutex update_lock;
114115
116+#if IS_ENABLED(CONFIG_REGULATOR)
117+ atomic_t regulator_events[PMBUS_PAGES];
118+ struct work_struct regulator_notify_work;
119+#endif
120+
115121 bool has_status_word; /* device uses STATUS_WORD register */
116122 int (*read_status)(struct i2c_client *client, int page);
117123
@@ -1209,6 +1215,12 @@ static ssize_t pmbus_show_boolean(struct device *dev, · 1091 unmodified lines
12091215 return sysfs_emit(buf, "%d\n", val);
12101216 }
12111217
1218+static ssize_t pmbus_show_zero(struct device *dev,
1219+ struct device_attribute *devattr, char *buf)
1220+{
1221+ return sysfs_emit(buf, "0\n");
1222+}
1223+
12121224 static ssize_t pmbus_show_sensor(struct device *dev,
12131225 struct device_attribute *devattr, char *buf)
12141226 {
@@ -1407,7 +1419,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data, · 192 unmodified lines
14071419 int reg,
14081420 enum pmbus_sensor_classes class,
14091421 bool update, bool readonly,
1410− bool convert)
1422+ bool writeonly, bool convert)
14111423 {
14121424 struct pmbus_sensor *sensor;
14131425 struct device_attribute *a;
@@ -1436,7 +1448,8 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data, · 22 unmodified lines
14361448 sensor->data = -ENODATA;
14371449 pmbus_dev_attr_init(a, sensor->name,
14381450 readonly ? 0444 : 0644,
1439− pmbus_show_sensor, pmbus_set_sensor);
1451+ writeonly ? pmbus_show_zero : pmbus_show_sensor,
1452+ pmbus_set_sensor);
14401453
14411454 if (pmbus_add_attribute(data, &a->attr))
14421455 return NULL;
@@ -1495,8 +1508,10 @@ static int pmbus_add_label(struct pmbus_data *data, · 52 unmodified lines
14951508 struct pmbus_limit_attr {
14961509 u16 reg; /* Limit register */
14971510 u16 sbit; /* Alarm attribute status bit */
1498− bool update; /* True if register needs updates */
1499− bool low; /* True if low limit; for limits with compare functions only */
1511+ bool readonly:1; /* True if the attribute is read-only */
1512+ bool writeonly:1; /* True if the attribute is write-only */
1513+ bool update:1; /* True if register needs updates */
1514+ bool low:1; /* True if low limit; for limits with compare functions only */
15001515 const char *attr; /* Attribute name */
15011516 const char *alarm; /* Alarm attribute name */
15021517 };
@@ -1511,9 +1526,9 @@ struct pmbus_sensor_attr { · 8 unmodified lines
15111526 u8 nlimit; /* # of limit registers */
15121527 enum pmbus_sensor_classes class;/* sensor class */
15131528 const char *label; /* sensor label */
1514− bool paged; /* true if paged sensor */
1515− bool update; /* true if update needed */
1516− bool compare; /* true if compare function needed */
1529+ bool paged:1; /* true if paged sensor */
1530+ bool update:1; /* true if update needed */
1531+ bool compare:1; /* true if compare function needed */
15171532 u32 func; /* sensor mask */
15181533 u32 sfunc; /* sensor status mask */
15191534 int sreg; /* status register */
@@ -1544,7 +1559,7 @@ static int pmbus_add_limit_attrs(struct i2c_client *client, · 24 unmodified lines
15441559 curr = pmbus_add_sensor(data, name, l->attr, index,
15451560 page, 0xff, l->reg, attr->class,
15461561 attr->update || l->update,
1547− false, true);
1562+ l->readonly, l->writeonly, true);
15481563 if (!curr)
15491564 return -ENOMEM;
15501565 if (l->sbit && (info->func[page] & attr->sfunc)) {
@@ -1584,7 +1599,7 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client, · 33 unmodified lines
15841599 return ret;
15851600 }
15861601 base = pmbus_add_sensor(data, name, "input", index, page, phase,
1587− attr->reg, attr->class, true, true, true);
1602+ attr->reg, attr->class, true, true, false, true);
15881603 if (!base)
15891604 return -ENOMEM;
15901605 /* No limit and alarm attributes for phase specific sensors */
@@ -1707,23 +1722,29 @@ static const struct pmbus_limit_attr vin_limit_attrs[] = { · 116 unmodified lines
17071722 }, {
17081723 .reg = PMBUS_VIRT_READ_VIN_AVG,
17091724 .update = true,
1725+ .readonly = true,
17101726 .attr = "average",
17111727 }, {
17121728 .reg = PMBUS_VIRT_READ_VIN_MIN,
17131729 .update = true,
1730+ .readonly = true,
17141731 .attr = "lowest",
17151732 }, {
17161733 .reg = PMBUS_VIRT_READ_VIN_MAX,
17171734 .update = true,
1735+ .readonly = true,
17181736 .attr = "highest",
17191737 }, {
17201738 .reg = PMBUS_VIRT_RESET_VIN_HISTORY,
1739+ .writeonly = true,
17211740 .attr = "reset_history",
17221741 }, {
17231742 .reg = PMBUS_MFR_VIN_MIN,
1743+ .readonly = true,
17241744 .attr = "rated_min",
17251745 }, {
17261746 .reg = PMBUS_MFR_VIN_MAX,
1747+ .readonly = true,
17271748 .attr = "rated_max",
17281749 },
17291750 };
@@ -1776,23 +1797,29 @@ static const struct pmbus_limit_attr vout_limit_attrs[] = { · 46 unmodified lines
17761797 }, {
17771798 .reg = PMBUS_VIRT_READ_VOUT_AVG,
17781799 .update = true,
1800+ .readonly = true,
17791801 .attr = "average",
17801802 }, {
17811803 .reg = PMBUS_VIRT_READ_VOUT_MIN,
17821804 .update = true,
1805+ .readonly = true,
17831806 .attr = "lowest",
17841807 }, {
17851808 .reg = PMBUS_VIRT_READ_VOUT_MAX,
17861809 .update = true,
1810+ .readonly = true,
17871811 .attr = "highest",
17881812 }, {
17891813 .reg = PMBUS_VIRT_RESET_VOUT_HISTORY,
1814+ .writeonly = true,
17901815 .attr = "reset_history",
17911816 }, {
17921817 .reg = PMBUS_MFR_VOUT_MIN,
1818+ .readonly = true,
17931819 .attr = "rated_min",
17941820 }, {
17951821 .reg = PMBUS_MFR_VOUT_MAX,
1822+ .readonly = true,
17961823 .attr = "rated_max",
17971824 },
17981825 };
@@ -1852,20 +1879,25 @@ static const struct pmbus_limit_attr iin_limit_attrs[] = { · 53 unmodified lines
18521879 }, {
18531880 .reg = PMBUS_VIRT_READ_IIN_AVG,
18541881 .update = true,
1882+ .readonly = true,
18551883 .attr = "average",
18561884 }, {
18571885 .reg = PMBUS_VIRT_READ_IIN_MIN,
18581886 .update = true,
1887+ .readonly = true,
18591888 .attr = "lowest",
18601889 }, {
18611890 .reg = PMBUS_VIRT_READ_IIN_MAX,
18621891 .update = true,
1892+ .readonly = true,
18631893 .attr = "highest",
18641894 }, {
18651895 .reg = PMBUS_VIRT_RESET_IIN_HISTORY,
1896+ .writeonly = true,
18661897 .attr = "reset_history",
18671898 }, {
18681899 .reg = PMBUS_MFR_IIN_MAX,
1900+ .readonly = true,
18691901 .attr = "rated_max",
18701902 },
18711903 };
@@ -1889,20 +1921,25 @@ static const struct pmbus_limit_attr iout_limit_attrs[] = { · 17 unmodified lines
18891921 }, {
18901922 .reg = PMBUS_VIRT_READ_IOUT_AVG,
18911923 .update = true,
1924+ .readonly = true,
18921925 .attr = "average",
18931926 }, {
18941927 .reg = PMBUS_VIRT_READ_IOUT_MIN,
18951928 .update = true,
1929+ .readonly = true,
18961930 .attr = "lowest",
18971931 }, {
18981932 .reg = PMBUS_VIRT_READ_IOUT_MAX,
18991933 .update = true,
1934+ .readonly = true,
19001935 .attr = "highest",
19011936 }, {
19021937 .reg = PMBUS_VIRT_RESET_IOUT_HISTORY,
1938+ .writeonly = true,
19031939 .attr = "reset_history",
19041940 }, {
19051941 .reg = PMBUS_MFR_IOUT_MAX,
1942+ .readonly = true,
19061943 .attr = "rated_max",
19071944 },
19081945 };
@@ -1943,20 +1980,25 @@ static const struct pmbus_limit_attr pin_limit_attrs[] = { · 34 unmodified lines
19431980 }, {
19441981 .reg = PMBUS_VIRT_READ_PIN_AVG,
19451982 .update = true,
1983+ .readonly = true,
19461984 .attr = "average",
19471985 }, {
19481986 .reg = PMBUS_VIRT_READ_PIN_MIN,
19491987 .update = true,
1988+ .readonly = true,
19501989 .attr = "input_lowest",
19511990 }, {
19521991 .reg = PMBUS_VIRT_READ_PIN_MAX,
19531992 .update = true,
1993+ .readonly = true,
19541994 .attr = "input_highest",
19551995 }, {
19561996 .reg = PMBUS_VIRT_RESET_PIN_HISTORY,
1997+ .writeonly = true,
19571998 .attr = "reset_history",
19581999 }, {
19592000 .reg = PMBUS_MFR_PIN_MAX,
2001+ .readonly = true,
19602002 .attr = "rated_max",
19612003 },
19622004 };
@@ -1980,20 +2022,25 @@ static const struct pmbus_limit_attr pout_limit_attrs[] = { · 17 unmodified lines
19802022 }, {
19812023 .reg = PMBUS_VIRT_READ_POUT_AVG,
19822024 .update = true,
2025+ .readonly = true,
19832026 .attr = "average",
19842027 }, {
19852028 .reg = PMBUS_VIRT_READ_POUT_MIN,
19862029 .update = true,
2030+ .readonly = true,
19872031 .attr = "input_lowest",
19882032 }, {
19892033 .reg = PMBUS_VIRT_READ_POUT_MAX,
19902034 .update = true,
2035+ .readonly = true,
19912036 .attr = "input_highest",
19922037 }, {
19932038 .reg = PMBUS_VIRT_RESET_POUT_HISTORY,
2039+ .writeonly = true,
19942040 .attr = "reset_history",
19952041 }, {
19962042 .reg = PMBUS_MFR_POUT_MAX,
2043+ .readonly = true,
19972044 .attr = "rated_max",
19982045 },
19992046 };
@@ -2049,18 +2096,23 @@ static const struct pmbus_limit_attr temp_limit_attrs[] = { · 49 unmodified lines
20492096 .sbit = PB_TEMP_OT_FAULT,
20502097 }, {
20512098 .reg = PMBUS_VIRT_READ_TEMP_MIN,
2099+ .readonly = true,
20522100 .attr = "lowest",
20532101 }, {
20542102 .reg = PMBUS_VIRT_READ_TEMP_AVG,
2103+ .readonly = true,
20552104 .attr = "average",
20562105 }, {
20572106 .reg = PMBUS_VIRT_READ_TEMP_MAX,
2107+ .readonly = true,
20582108 .attr = "highest",
20592109 }, {
20602110 .reg = PMBUS_VIRT_RESET_TEMP_HISTORY,
2111+ .writeonly = true,
20612112 .attr = "reset_history",
20622113 }, {
20632114 .reg = PMBUS_MFR_MAX_TEMP_1,
2115+ .readonly = true,
20642116 .attr = "rated_max",
20652117 },
20662118 };
@@ -2090,18 +2142,23 @@ static const struct pmbus_limit_attr temp_limit_attrs2[] = { · 23 unmodified lines
20902142 .sbit = PB_TEMP_OT_FAULT,
20912143 }, {
20922144 .reg = PMBUS_VIRT_READ_TEMP2_MIN,
2145+ .readonly = true,
20932146 .attr = "lowest",
20942147 }, {
20952148 .reg = PMBUS_VIRT_READ_TEMP2_AVG,
2149+ .readonly = true,
20962150 .attr = "average",
20972151 }, {
20982152 .reg = PMBUS_VIRT_READ_TEMP2_MAX,
2153+ .readonly = true,
20992154 .attr = "highest",
21002155 }, {
21012156 .reg = PMBUS_VIRT_RESET_TEMP2_HISTORY,
2157+ .writeonly = true,
21022158 .attr = "reset_history",
21032159 }, {
21042160 .reg = PMBUS_MFR_MAX_TEMP_2,
2161+ .readonly = true,
21052162 .attr = "rated_max",
21062163 },
21072164 };
@@ -2131,6 +2188,7 @@ static const struct pmbus_limit_attr temp_limit_attrs3[] = { · 23 unmodified lines
21312188 .sbit = PB_TEMP_OT_FAULT,
21322189 }, {
21332190 .reg = PMBUS_MFR_MAX_TEMP_3,
2191+ .readonly = true,
21342192 .attr = "rated_max",
21352193 },
21362194 };
@@ -2214,7 +2272,7 @@ static int pmbus_add_fan_ctrl(struct i2c_client *client, · 77 unmodified lines
22142272
22152273 sensor = pmbus_add_sensor(data, "fan", "target", index, page,
22162274 0xff, PMBUS_VIRT_FAN_TARGET_1 + id, PSC_FAN,
2217− false, false, true);
2275+ false, false, false, true);
22182276
22192277 if (!sensor)
22202278 return -ENOMEM;
@@ -2225,14 +2283,14 @@ static int pmbus_add_fan_ctrl(struct i2c_client *client, · 4 unmodified lines
22252283
22262284 sensor = pmbus_add_sensor(data, "pwm", NULL, index, page,
22272285 0xff, PMBUS_VIRT_PWM_1 + id, PSC_PWM,
2228− false, false, true);
2286+ false, false, false, true);
22292287
22302288 if (!sensor)
22312289 return -ENOMEM;
22322290
22332291 sensor = pmbus_add_sensor(data, "pwm", "enable", index, page,
22342292 0xff, PMBUS_VIRT_PWM_ENABLE_1 + id, PSC_PWM,
2235− true, false, false);
2293+ true, false, false, false);
22362294
22372295 if (!sensor)
22382296 return -ENOMEM;
@@ -2274,7 +2332,7 @@ static int pmbus_add_fan_attributes(struct i2c_client *client, · 35 unmodified lines
22742332
22752333 if (pmbus_add_sensor(data, "fan", "input", index,
22762334 page, 0xff, pmbus_fan_registers[f],
2277− PSC_FAN, true, true, true) == NULL)
2335+ PSC_FAN, true, true, false, true) == NULL)
22782336 return -ENOMEM;
22792337
22802338 /* Fan control */
@@ -3176,12 +3234,19 @@ static int pmbus_regulator_get_voltage(struct regulator_dev *rdev) · 895 unmodified lines
31763234 .class = PSC_VOLTAGE_OUT,
31773235 .convert = true,
31783236 };
3237+ int ret;
31793238
3239+ mutex_lock(&data->update_lock);
31803240 s.data = _pmbus_read_word_data(client, s.page, 0xff, PMBUS_READ_VOUT);
3181− if (s.data < 0)
3182− return s.data;
3241+ if (s.data < 0) {
3242+ ret = s.data;
3243+ goto unlock;
3244+ }
31833245
3184− return (int)pmbus_reg2data(data, &s) * 1000; /* unit is uV */
3246+ ret = (int)pmbus_reg2data(data, &s) * 1000; /* unit is uV */
3247+unlock:
3248+ mutex_unlock(&data->update_lock);
3249+ return ret;
31853250 }
31863251
31873252 static int pmbus_regulator_set_voltage(struct regulator_dev *rdev, int min_uv,
@@ -3198,16 +3263,22 @@ static int pmbus_regulator_set_voltage(struct regulator_dev *rdev, int min_uv, · 10 unmodified lines
31983263 };
31993264 int val = DIV_ROUND_CLOSEST(min_uv, 1000); /* convert to mV */
32003265 int low, high;
3266+ int ret;
32013267
32023268 *selector = 0;
32033269
3270+ mutex_lock(&data->update_lock);
32043271 low = pmbus_regulator_get_low_margin(client, s.page);
3205− if (low < 0)
3206− return low;
3272+ if (low < 0) {
3273+ ret = low;
3274+ goto unlock;
3275+ }
32073276
32083277 high = pmbus_regulator_get_high_margin(client, s.page);
3209− if (high < 0)
3210− return high;
3278+ if (high < 0) {
3279+ ret = high;
3280+ goto unlock;
3281+ }
32113282
32123283 /* Make sure we are within margins */
32133284 if (low > val)
@@ -3217,7 +3288,10 @@ static int pmbus_regulator_set_voltage(struct regulator_dev *rdev, int min_uv, · 3 unmodified lines
32173288
32183289 val = pmbus_data2reg(data, &s, val);
32193290
3220− return _pmbus_write_word_data(client, s.page, PMBUS_VOUT_COMMAND, (u16)val);
3291+ ret = _pmbus_write_word_data(client, s.page, PMBUS_VOUT_COMMAND, (u16)val);
3292+unlock:
3293+ mutex_unlock(&data->update_lock);
3294+ return ret;
32213295 }
32223296
32233297 static int pmbus_regulator_list_voltage(struct regulator_dev *rdev,
@@ -3227,6 +3301,7 @@ static int pmbus_regulator_list_voltage(struct regulator_dev *rdev, · 3 unmodified lines
32273301 struct i2c_client *client = to_i2c_client(dev->parent);
32283302 struct pmbus_data *data = i2c_get_clientdata(client);
32293303 int val, low, high;
3304+ int ret;
32303305
32313306 if (data->flags & PMBUS_VOUT_PROTECTED)
32323307 return 0;
@@ -3239,18 +3314,29 @@ static int pmbus_regulator_list_voltage(struct regulator_dev *rdev, · 6 unmodified lines
32393314 val = DIV_ROUND_CLOSEST(rdev->desc->min_uV +
32403315 (rdev->desc->uV_step * selector), 1000); /* convert to mV */
32413316
3317+ mutex_lock(&data->update_lock);
3318+
32423319 low = pmbus_regulator_get_low_margin(client, rdev_get_id(rdev));
3243− if (low < 0)
3244− return low;
3320+ if (low < 0) {
3321+ ret = low;
3322+ goto unlock;
3323+ }
32453324
32463325 high = pmbus_regulator_get_high_margin(client, rdev_get_id(rdev));
3247− if (high < 0)
3248− return high;
3326+ if (high < 0) {
3327+ ret = high;
3328+ goto unlock;
3329+ }
32493330
3250− if (val >= low && val <= high)
3251− return val * 1000; /* unit is uV */
3331+ if (val >= low && val <= high) {
3332+ ret = val * 1000; /* unit is uV */
3333+ goto unlock;
3334+ }
32523335
3253− return 0;
3336+ ret = 0;
3337+unlock:
3338+ mutex_unlock(&data->update_lock);
3339+ return ret;
32543340 }
32553341
32563342 const struct regulator_ops pmbus_regulator_ops = {
@@ -3281,12 +3367,42 @@ int pmbus_regulator_init_cb(struct regulator_dev *rdev, · 24 unmodified lines
32813367 }
32823368 EXPORT_SYMBOL_NS_GPL(pmbus_regulator_init_cb, "PMBUS");
32833369
3370+static void pmbus_regulator_notify_work_cancel(void *data)
3371+{
3372+ struct pmbus_data *pdata = data;
3373+
3374+ cancel_work_sync(&pdata->regulator_notify_work);
3375+}
3376+
3377+static void pmbus_regulator_notify_worker(struct work_struct *work)
3378+{
3379+ struct pmbus_data *data =
3380+ container_of(work, struct pmbus_data, regulator_notify_work);
3381+ int i, j;
3382+
3383+ for (i = 0; i < data->info->pages; i++) {
3384+ int event;
3385+
3386+ event = atomic_xchg(&data->regulator_events[i], 0);
3387+ if (!event)
3388+ continue;
3389+
3390+ for (j = 0; j < data->info->num_regulators; j++) {
3391+ if (i == rdev_get_id(data->rdevs[j])) {
3392+ regulator_notifier_call_chain(data->rdevs[j],
3393+ event, NULL);
3394+ break;
3395+ }
3396+ }
3397+ }
3398+}
3399+
32843400 static int pmbus_regulator_register(struct pmbus_data *data)
32853401 {
32863402 struct device *dev = data->dev;
32873403 const struct pmbus_driver_info *info = data->info;
32883404 const struct pmbus_platform_data *pdata = dev_get_platdata(dev);
3289− int i;
3405+ int i, ret;
32903406
32913407 data->rdevs = devm_kzalloc(dev, sizeof(struct regulator_dev *) * info->num_regulators,
32923408 GFP_KERNEL);
@@ -3310,19 +3426,19 @@ static int pmbus_regulator_register(struct pmbus_data *data) · 17 unmodified lines
33103426 info->reg_desc[i].name);
33113427 }
33123428
3429+ INIT_WORK(&data->regulator_notify_work, pmbus_regulator_notify_worker);
3430+
3431+ ret = devm_add_action_or_reset(dev, pmbus_regulator_notify_work_cancel, data);
3432+ if (ret)
3433+ return ret;
3434+
33133435 return 0;
33143436 }
33153437
33163438 static void pmbus_regulator_notify(struct pmbus_data *data, int page, int event)
33173439 {
3318− int j;
3319−
3320− for (j = 0; j < data->info->num_regulators; j++) {
3321− if (page == rdev_get_id(data->rdevs[j])) {
3322− regulator_notifier_call_chain(data->rdevs[j], event, NULL);
3323− break;
3324− }
3325− }
3440+ atomic_or(event, &data->regulator_events[page]);
3441+ schedule_work(&data->regulator_notify_work);
33263442 }
33273443 #else
33283444 static int pmbus_regulator_register(struct pmbus_data *data)
drivers/i2c/busses/i2c-designware-amdisp.c+5−6
@@ -7,6 +7,7 @@ · 6 unmodified lines
77
88 #include <linux/module.h>
99 #include <linux/platform_device.h>
10+#include <linux/pm_domain.h>
1011 #include <linux/pm_runtime.h>
1112 #include <linux/soc/amd/isp4_misc.h>
1213
@@ -76,22 +77,20 @@ static int amd_isp_dw_i2c_plat_probe(struct platform_device *pdev) · 63 unmodified lines
7677
7778 device_enable_async_suspend(&pdev->dev);
7879
79− pm_runtime_enable(&pdev->dev);
80− pm_runtime_get_sync(&pdev->dev);
81−
80+ dev_pm_genpd_resume(&pdev->dev);
8281 ret = i2c_dw_probe(isp_i2c_dev);
8382 if (ret) {
8483 dev_err_probe(&pdev->dev, ret, "i2c_dw_probe failed\n");
8584 goto error_release_rpm;
8685 }
87−
88− pm_runtime_put_sync(&pdev->dev);
86+ dev_pm_genpd_suspend(&pdev->dev);
87+ pm_runtime_set_suspended(&pdev->dev);
88+ pm_runtime_enable(&pdev->dev);
8989
9090 return 0;
9191
9292 error_release_rpm:
9393 amd_isp_dw_i2c_plat_pm_cleanup(isp_i2c_dev);
94− pm_runtime_put_sync(&pdev->dev);
9594 return ret;
9695 }
9796
drivers/i2c/busses/i2c-imx.c+32−19
@@ -1018,8 +1018,9 @@ static inline int i2c_imx_isr_read(struct imx_i2c_struct *i2c_imx) · 1017 unmodified lines
10181018 return 0;
10191019 }
10201020
1021−static inline void i2c_imx_isr_read_continue(struct imx_i2c_struct *i2c_imx)
1021+static inline enum imx_i2c_state i2c_imx_isr_read_continue(struct imx_i2c_struct *i2c_imx)
10221022 {
1023+ enum imx_i2c_state next_state = IMX_I2C_STATE_READ_CONTINUE;
10231024 unsigned int temp;
10241025
10251026 if ((i2c_imx->msg->len - 1) == i2c_imx->msg_buf_idx) {
@@ -1033,18 +1034,20 @@ static inline void i2c_imx_isr_read_continue(struct imx_i2c_struct *i2c_imx) · 7 unmodified lines
10331034 i2c_imx->stopped = 1;
10341035 temp &= ~(I2CR_MSTA | I2CR_MTX);
10351036 imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
1036− } else {
1037− /*
1038− * For i2c master receiver repeat restart operation like:
1039− * read -> repeat MSTA -> read/write
1040− * The controller must set MTX before read the last byte in
1041− * the first read operation, otherwise the first read cost
1042− * one extra clock cycle.
1043− */
1044− temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
1045− temp |= I2CR_MTX;
1046− imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
1037+
1038+ return IMX_I2C_STATE_DONE;
10471039 }
1040+ /*
1041+ * For i2c master receiver repeat restart operation like:
1042+ * read -> repeat MSTA -> read/write
1043+ * The controller must set MTX before read the last byte in
1044+ * the first read operation, otherwise the first read cost
1045+ * one extra clock cycle.
1046+ */
1047+ temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
1048+ temp |= I2CR_MTX;
1049+ imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
1050+ next_state = IMX_I2C_STATE_DONE;
10481051 } else if (i2c_imx->msg_buf_idx == (i2c_imx->msg->len - 2)) {
10491052 temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
10501053 temp |= I2CR_TXAK;
@@ -1052,6 +1055,7 @@ static inline void i2c_imx_isr_read_continue(struct imx_i2c_struct *i2c_imx) · 1 unmodified line
10521055 }
10531056
10541057 i2c_imx->msg->buf[i2c_imx->msg_buf_idx++] = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR);
1058+ return next_state;
10551059 }
10561060
10571061 static inline void i2c_imx_isr_read_block_data_len(struct imx_i2c_struct *i2c_imx)
@@ -1088,11 +1092,9 @@ static irqreturn_t i2c_imx_master_isr(struct imx_i2c_struct *i2c_imx, unsigned i · 30 unmodified lines
10881092 break;
10891093
10901094 case IMX_I2C_STATE_READ_CONTINUE:
1091− i2c_imx_isr_read_continue(i2c_imx);
1092− if (i2c_imx->msg_buf_idx == i2c_imx->msg->len) {
1093− i2c_imx->state = IMX_I2C_STATE_DONE;
1095+ i2c_imx->state = i2c_imx_isr_read_continue(i2c_imx);
1096+ if (i2c_imx->state == IMX_I2C_STATE_DONE)
10941097 wake_up(&i2c_imx->queue);
1095− }
10961098 break;
10971099
10981100 case IMX_I2C_STATE_READ_BLOCK_DATA:
@@ -1490,6 +1492,7 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, · 391 unmodified lines
14901492 bool is_lastmsg)
14911493 {
14921494 int block_data = msgs->flags & I2C_M_RECV_LEN;
1495+ int ret = 0;
14931496
14941497 dev_dbg(&i2c_imx->adapter.dev,
14951498 "<%s> write slave address: addr=0x%x\n",
@@ -1522,10 +1525,20 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, · 26 unmodified lines
15221525 dev_err(&i2c_imx->adapter.dev, "<%s> read timedout\n", __func__);
15231526 return -ETIMEDOUT;
15241527 }
1525− if (!i2c_imx->stopped)
1526− return i2c_imx_bus_busy(i2c_imx, 0, false);
1528+ if (i2c_imx->is_lastmsg) {
1529+ if (!i2c_imx->stopped)
1530+ ret = i2c_imx_bus_busy(i2c_imx, 0, false);
1531+ /*
1532+ * Only read the last byte of the last message after the bus is
1533+ * not busy. Else the controller generates another clock which
1534+ * might confuse devices.
1535+ */
1536+ if (!ret)
1537+ i2c_imx->msg->buf[i2c_imx->msg_buf_idx++] = imx_i2c_read_reg(i2c_imx,
1538+ IMX_I2C_I2DR);
1539+ }
15271540
1528− return 0;
1541+ return ret;
15291542 }
15301543
15311544 static int i2c_imx_xfer_common(struct i2c_adapter *adapter,
drivers/infiniband/core/rw.c+27−10
@@ -608,14 +608,29 @@ int rdma_rw_ctx_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num, · 607 unmodified lines
608608 if (rdma_rw_io_needs_mr(qp->device, port_num, dir, sg_cnt)) {
609609 ret = rdma_rw_init_mr_wrs(ctx, qp, port_num, sg, sg_cnt,
610610 sg_offset, remote_addr, rkey, dir);
611− } else if (sg_cnt > 1) {
611+ /*
612+ * If MR init succeeded or failed for a reason other
613+ * than pool exhaustion, that result is final.
614+ *
615+ * Pool exhaustion (-EAGAIN) from the max_sgl_rd
616+ * optimization is recoverable: fall back to
617+ * direct SGE posting. iWARP and force_mr require
618+ * MRs unconditionally, so -EAGAIN is terminal.
619+ */
620+ if (ret != -EAGAIN ||
621+ rdma_protocol_iwarp(qp->device, port_num) ||
622+ unlikely(rdma_rw_force_mr))
623+ goto out;
624+ }
625+
626+ if (sg_cnt > 1)
612627 ret = rdma_rw_init_map_wrs(ctx, qp, sg, sg_cnt, sg_offset,
613628 remote_addr, rkey, dir);
614− } else {
629+ else
615630 ret = rdma_rw_init_single_wr(ctx, qp, sg, sg_offset,
616631 remote_addr, rkey, dir);
617− }
618632
633+out:
619634 if (ret < 0)
620635 goto out_unmap_sg;
621636 return ret;
@@ -686,14 +701,16 @@ int rdma_rw_ctx_init_bvec(struct rdma_rw_ctx *ctx, struct ib_qp *qp, · 64 unmodified lines
686701 return ret;
687702
688703 /*
689− * IOVA mapping not available. Check if MR registration provides
690− * better performance than multiple SGE entries.
704+ * IOVA not available; fall back to the map_wrs path, which maps
705+ * each bvec as a direct SGE. This is always correct: the MR path
706+ * is a throughput optimization, not a correctness requirement.
707+ * (iWARP, which does require MRs, is handled by the check above.)
708+ *
709+ * The rdma_rw_io_needs_mr() gate is not used here because nr_bvec
710+ * is a raw page count that overstates DMA entry demand -- the bvec
711+ * caller has no post-DMA-coalescing segment count, and feeding the
712+ * inflated count into the MR path exhausts the pool on RDMA READs.
691713 */
692− if (rdma_rw_io_needs_mr(dev, port_num, dir, nr_bvec))
693− return rdma_rw_init_mr_wrs_bvec(ctx, qp, port_num, bvecs,
694− nr_bvec, &iter, remote_addr,
695− rkey, dir);
696−
697714 return rdma_rw_init_map_wrs_bvec(ctx, qp, bvecs, nr_bvec, &iter,
698715 remote_addr, rkey, dir);
699716 }
drivers/infiniband/core/umem.c+3−2
@@ -55,7 +55,8 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d · 54 unmodified lines
5555
5656 if (dirty)
5757 ib_dma_unmap_sgtable_attrs(dev, &umem->sgt_append.sgt,
58− DMA_BIDIRECTIONAL, 0);
58+ DMA_BIDIRECTIONAL,
59+ DMA_ATTR_REQUIRE_COHERENT);
5960
6061 for_each_sgtable_sg(&umem->sgt_append.sgt, sg, i) {
6162 unpin_user_page_range_dirty_lock(sg_page(sg),
@@ -169,7 +170,7 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, · 107 unmodified lines
169170 unsigned long lock_limit;
170171 unsigned long new_pinned;
171172 unsigned long cur_base;
172− unsigned long dma_attr = 0;
173+ unsigned long dma_attr = DMA_ATTR_REQUIRE_COHERENT;
173174 struct mm_struct *mm;
174175 unsigned long npages;
175176 int pinned, ret;
drivers/infiniband/hw/bng_re/bng_dev.c+9−5
@@ -210,7 +210,7 @@ static int bng_re_stats_ctx_alloc(struct bng_re_dev *rdev) · 209 unmodified lines
210210 return rc;
211211 }
212212
213−static void bng_re_query_hwrm_version(struct bng_re_dev *rdev)
213+static int bng_re_query_hwrm_version(struct bng_re_dev *rdev)
214214 {
215215 struct bnge_auxr_dev *aux_dev = rdev->aux_dev;
216216 struct hwrm_ver_get_output ver_get_resp = {};
@@ -230,7 +230,7 @@ static void bng_re_query_hwrm_version(struct bng_re_dev *rdev) · 13 unmodified lines
230230 if (rc) {
231231 ibdev_err(&rdev->ibdev, "Failed to query HW version, rc = 0x%x",
232232 rc);
233− return;
233+ return rc;
234234 }
235235
236236 cctx = rdev->chip_ctx;
@@ -244,6 +244,8 @@ static void bng_re_query_hwrm_version(struct bng_re_dev *rdev) · 7 unmodified lines
244244
245245 if (!cctx->hwrm_cmd_max_timeout)
246246 cctx->hwrm_cmd_max_timeout = BNG_ROCE_FW_MAX_TIMEOUT;
247+
248+ return 0;
247249 }
248250
249251 static void bng_re_dev_uninit(struct bng_re_dev *rdev)
@@ -306,13 +308,15 @@ static int bng_re_dev_init(struct bng_re_dev *rdev) · 56 unmodified lines
306308 goto msix_ctx_fail;
307309 }
308310
309− bng_re_query_hwrm_version(rdev);
311+ rc = bng_re_query_hwrm_version(rdev);
312+ if (rc)
313+ goto destroy_chip_ctx;
310314
311315 rc = bng_re_alloc_fw_channel(&rdev->bng_res, &rdev->rcfw);
312316 if (rc) {
313317 ibdev_err(&rdev->ibdev,
314318 "Failed to allocate RCFW Channel: %#x\n", rc);
315− goto alloc_fw_chl_fail;
319+ goto destroy_chip_ctx;
316320 }
317321
318322 /* Allocate nq record memory */
@@ -391,7 +395,7 @@ free_rcfw: · 72 unmodified lines
391395 kfree(rdev->nqr);
392396 nq_alloc_fail:
393397 bng_re_free_rcfw_channel(&rdev->rcfw);
394−alloc_fw_chl_fail:
398+destroy_chip_ctx:
395399 bng_re_destroy_chip_ctx(rdev);
396400 msix_ctx_fail:
397401 bnge_unregister_dev(rdev->aux_dev);
drivers/infiniband/hw/efa/efa_com.c+40−48
@@ -1,6 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
22 /*
3− * Copyright 2018-2025 Amazon.com, Inc. or its affiliates. All rights reserved.
3+ * Copyright 2018-2026 Amazon.com, Inc. or its affiliates. All rights reserved.
44 */
55
66 #include <linux/log2.h>
@@ -310,23 +310,19 @@ static inline struct efa_comp_ctx *efa_com_get_comp_ctx_by_cmd_id(struct efa_com · 303 unmodified lines
310310 return &aq->comp_ctx[ctx_id];
311311 }
312312
313−static struct efa_comp_ctx *__efa_com_submit_admin_cmd(struct efa_com_admin_queue *aq,
314− struct efa_admin_aq_entry *cmd,
315− size_t cmd_size_in_bytes,
316− struct efa_admin_acq_entry *comp,
317− size_t comp_size_in_bytes)
313+static void __efa_com_submit_admin_cmd(struct efa_com_admin_queue *aq,
314+ struct efa_comp_ctx *comp_ctx,
315+ struct efa_admin_aq_entry *cmd,
316+ size_t cmd_size_in_bytes,
317+ struct efa_admin_acq_entry *comp,
318+ size_t comp_size_in_bytes)
318319 {
319320 struct efa_admin_aq_entry *aqe;
320− struct efa_comp_ctx *comp_ctx;
321321 u16 queue_size_mask;
322322 u16 cmd_id;
323323 u16 ctx_id;
324324 u16 pi;
325325
326− comp_ctx = efa_com_alloc_comp_ctx(aq);
327− if (!comp_ctx)
328− return ERR_PTR(-EINVAL);
329−
330326 queue_size_mask = aq->depth - 1;
331327 pi = aq->sq.pc & queue_size_mask;
332328 ctx_id = efa_com_get_comp_ctx_id(aq, comp_ctx);
@@ -360,8 +356,6 @@ static struct efa_comp_ctx *__efa_com_submit_admin_cmd(struct efa_com_admin_queu · 27 unmodified lines
360356
361357 /* barrier not needed in case of writel */
362358 writel(aq->sq.pc, aq->sq.db_addr);
363−
364− return comp_ctx;
365359 }
366360
367361 static inline int efa_com_init_comp_ctxt(struct efa_com_admin_queue *aq)
@@ -394,28 +388,25 @@ static inline int efa_com_init_comp_ctxt(struct efa_com_admin_queue *aq) · 26 unmodified lines
394388 return 0;
395389 }
396390
397−static struct efa_comp_ctx *efa_com_submit_admin_cmd(struct efa_com_admin_queue *aq,
398− struct efa_admin_aq_entry *cmd,
399− size_t cmd_size_in_bytes,
400− struct efa_admin_acq_entry *comp,
401− size_t comp_size_in_bytes)
391+static int efa_com_submit_admin_cmd(struct efa_com_admin_queue *aq,
392+ struct efa_comp_ctx *comp_ctx,
393+ struct efa_admin_aq_entry *cmd,
394+ size_t cmd_size_in_bytes,
395+ struct efa_admin_acq_entry *comp,
396+ size_t comp_size_in_bytes)
402397 {
403− struct efa_comp_ctx *comp_ctx;
404−
405398 spin_lock(&aq->sq.lock);
406399 if (!test_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state)) {
407400 ibdev_err_ratelimited(aq->efa_dev, "Admin queue is closed\n");
408401 spin_unlock(&aq->sq.lock);
409− return ERR_PTR(-ENODEV);
402+ return -ENODEV;
410403 }
411404
412− comp_ctx = __efa_com_submit_admin_cmd(aq, cmd, cmd_size_in_bytes, comp,
413− comp_size_in_bytes);
405+ __efa_com_submit_admin_cmd(aq, comp_ctx, cmd, cmd_size_in_bytes, comp,
406+ comp_size_in_bytes);
414407 spin_unlock(&aq->sq.lock);
415− if (IS_ERR(comp_ctx))
416− clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state);
417408
418− return comp_ctx;
409+ return 0;
419410 }
420411
421412 static int efa_com_handle_single_admin_completion(struct efa_com_admin_queue *aq,
@@ -512,7 +503,6 @@ static int efa_com_wait_and_process_admin_cq_polling(struct efa_comp_ctx *comp_c · 90 unmodified lines
512503 {
513504 unsigned long timeout;
514505 unsigned long flags;
515− int err;
516506
517507 timeout = jiffies + usecs_to_jiffies(aq->completion_timeout);
518508
@@ -532,24 +522,20 @@ static int efa_com_wait_and_process_admin_cq_polling(struct efa_comp_ctx *comp_c · 13 unmodified lines
532522 atomic64_inc(&aq->stats.no_completion);
533523
534524 clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state);
535− err = -ETIME;
536− goto out;
525+ return -ETIME;
537526 }
538527
539528 msleep(aq->poll_interval);
540529 }
541530
542− err = efa_com_comp_status_to_errno(comp_ctx->user_cqe->acq_common_descriptor.status);
543−out:
544− efa_com_dealloc_comp_ctx(aq, comp_ctx);
545− return err;
531+ return efa_com_comp_status_to_errno(
532+ comp_ctx->user_cqe->acq_common_descriptor.status);
546533 }
547534
548535 static int efa_com_wait_and_process_admin_cq_interrupts(struct efa_comp_ctx *comp_ctx,
549536 struct efa_com_admin_queue *aq)
550537 {
551538 unsigned long flags;
552− int err;
553539
554540 wait_for_completion_timeout(&comp_ctx->wait_event,
555541 usecs_to_jiffies(aq->completion_timeout));
@@ -585,14 +571,11 @@ static int efa_com_wait_and_process_admin_cq_interrupts(struct efa_comp_ctx *com · 29 unmodified lines
585571 aq->cq.cc);
586572
587573 clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state);
588− err = -ETIME;
589− goto out;
574+ return -ETIME;
590575 }
591576
592− err = efa_com_comp_status_to_errno(comp_ctx->user_cqe->acq_common_descriptor.status);
593−out:
594− efa_com_dealloc_comp_ctx(aq, comp_ctx);
595− return err;
577+ return efa_com_comp_status_to_errno(
578+ comp_ctx->user_cqe->acq_common_descriptor.status);
596579 }
597580
598581 /*
@@ -642,30 +625,39 @@ int efa_com_cmd_exec(struct efa_com_admin_queue *aq, · 43 unmodified lines
642625 ibdev_dbg(aq->efa_dev, "%s (opcode %d)\n",
643626 efa_com_cmd_str(cmd->aq_common_descriptor.opcode),
644627 cmd->aq_common_descriptor.opcode);
645− comp_ctx = efa_com_submit_admin_cmd(aq, cmd, cmd_size, comp, comp_size);
646− if (IS_ERR(comp_ctx)) {
628+
629+ comp_ctx = efa_com_alloc_comp_ctx(aq);
630+ if (!comp_ctx) {
631+ clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state);
632+ up(&aq->avail_cmds);
633+ return -EINVAL;
634+ }
635+
636+ err = efa_com_submit_admin_cmd(aq, comp_ctx, cmd, cmd_size, comp, comp_size);
637+ if (err) {
647638 ibdev_err_ratelimited(
648639 aq->efa_dev,
649− "Failed to submit command %s (opcode %u) err %pe\n",
640+ "Failed to submit command %s (opcode %u) err %d\n",
650641 efa_com_cmd_str(cmd->aq_common_descriptor.opcode),
651− cmd->aq_common_descriptor.opcode, comp_ctx);
642+ cmd->aq_common_descriptor.opcode, err);
652643
644+ efa_com_dealloc_comp_ctx(aq, comp_ctx);
653645 up(&aq->avail_cmds);
654646 atomic64_inc(&aq->stats.cmd_err);
655− return PTR_ERR(comp_ctx);
647+ return err;
656648 }
657649
658650 err = efa_com_wait_and_process_admin_cq(comp_ctx, aq);
659651 if (err) {
660652 ibdev_err_ratelimited(
661653 aq->efa_dev,
662− "Failed to process command %s (opcode %u) comp_status %d err %d\n",
654+ "Failed to process command %s (opcode %u) err %d\n",
663655 efa_com_cmd_str(cmd->aq_common_descriptor.opcode),
664− cmd->aq_common_descriptor.opcode,
665− comp_ctx->user_cqe->acq_common_descriptor.status, err);
656+ cmd->aq_common_descriptor.opcode, err);
666657 atomic64_inc(&aq->stats.cmd_err);
667658 }
668659
660+ efa_com_dealloc_comp_ctx(aq, comp_ctx);
669661 up(&aq->avail_cmds);
670662
671663 return err;
drivers/infiniband/hw/ionic/ionic_controlpath.c+3−1
@@ -508,6 +508,7 @@ static int ionic_build_hdr(struct ionic_ibdev *dev, · 507 unmodified lines
508508 {
509509 const struct ib_global_route *grh;
510510 enum rdma_network_type net;
511+ u8 smac[ETH_ALEN];
511512 u16 vlan;
512513 int rc;
513514
@@ -518,7 +519,7 @@ static int ionic_build_hdr(struct ionic_ibdev *dev, · 4 unmodified lines
518519
519520 grh = rdma_ah_read_grh(attr);
520521
521− rc = rdma_read_gid_l2_fields(grh->sgid_attr, &vlan, &hdr->eth.smac_h[0]);
522+ rc = rdma_read_gid_l2_fields(grh->sgid_attr, &vlan, smac);
522523 if (rc)
523524 return rc;
524525
@@ -536,6 +537,7 @@ static int ionic_build_hdr(struct ionic_ibdev *dev, · 11 unmodified lines
536537 if (rc)
537538 return rc;
538539
540+ ether_addr_copy(hdr->eth.smac_h, smac);
539541 ether_addr_copy(hdr->eth.dmac_h, attr->roce.dmac);
540542
541543 if (net == RDMA_NETWORK_IPV4) {
drivers/infiniband/hw/irdma/cm.c+16−13
@@ -2241,11 +2241,12 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev, · 2240 unmodified lines
22412241 int oldarpindex;
22422242 int arpindex;
22432243 struct net_device *netdev = iwdev->netdev;
2244+ int ret;
22442245
22452246 /* create an hte and cm_node for this instance */
22462247 cm_node = kzalloc_obj(*cm_node, GFP_ATOMIC);
22472248 if (!cm_node)
2248− return NULL;
2249+ return ERR_PTR(-ENOMEM);
22492250
22502251 /* set our node specific transport info */
22512252 cm_node->ipv4 = cm_info->ipv4;
@@ -2348,8 +2349,10 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev, · 96 unmodified lines
23482349 arpindex = -EINVAL;
23492350 }
23502351
2351− if (arpindex < 0)
2352+ if (arpindex < 0) {
2353+ ret = -EINVAL;
23522354 goto err;
2355+ }
23532356
23542357 ether_addr_copy(cm_node->rem_mac,
23552358 iwdev->rf->arp_table[arpindex].mac_addr);
@@ -2360,7 +2363,7 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev, · 4 unmodified lines
23602363 err:
23612364 kfree(cm_node);
23622365
2363− return NULL;
2366+ return ERR_PTR(ret);
23642367 }
23652368
23662369 static void irdma_destroy_connection(struct irdma_cm_node *cm_node)
@@ -3021,8 +3024,8 @@ static int irdma_create_cm_node(struct irdma_cm_core *cm_core, · 654 unmodified lines
30213024
30223025 /* create a CM connection node */
30233026 cm_node = irdma_make_cm_node(cm_core, iwdev, cm_info, NULL);
3024− if (!cm_node)
3025− return -ENOMEM;
3027+ if (IS_ERR(cm_node))
3028+ return PTR_ERR(cm_node);
30263029
30273030 /* set our node side to client (active) side */
30283031 cm_node->tcp_cntxt.client = 1;
@@ -3219,9 +3222,9 @@ void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf) · 190 unmodified lines
32193222 cm_info.cm_id = listener->cm_id;
32203223 cm_node = irdma_make_cm_node(cm_core, iwdev, &cm_info,
32213224 listener);
3222− if (!cm_node) {
3225+ if (IS_ERR(cm_node)) {
32233226 ibdev_dbg(&cm_core->iwdev->ibdev,
3224− "CM: allocate node failed\n");
3227+ "CM: allocate node failed ret=%ld\n", PTR_ERR(cm_node));
32253228 refcount_dec(&listener->refcnt);
32263229 return;
32273230 }
@@ -4239,21 +4242,21 @@ static void irdma_cm_event_handler(struct work_struct *work) · 1011 unmodified lines
42394242 irdma_cm_event_reset(event);
42404243 break;
42414244 case IRDMA_CM_EVENT_CONNECTED:
4242− if (!event->cm_node->cm_id ||
4243− event->cm_node->state != IRDMA_CM_STATE_OFFLOADED)
4245+ if (!cm_node->cm_id ||
4246+ cm_node->state != IRDMA_CM_STATE_OFFLOADED)
42444247 break;
42454248 irdma_cm_event_connected(event);
42464249 break;
42474250 case IRDMA_CM_EVENT_MPA_REJECT:
4248− if (!event->cm_node->cm_id ||
4251+ if (!cm_node->cm_id ||
42494252 cm_node->state == IRDMA_CM_STATE_OFFLOADED)
42504253 break;
42514254 irdma_send_cm_event(cm_node, cm_node->cm_id,
42524255 IW_CM_EVENT_CONNECT_REPLY, -ECONNREFUSED);
42534256 break;
42544257 case IRDMA_CM_EVENT_ABORTED:
4255− if (!event->cm_node->cm_id ||
4256− event->cm_node->state == IRDMA_CM_STATE_OFFLOADED)
4258+ if (!cm_node->cm_id ||
4259+ cm_node->state == IRDMA_CM_STATE_OFFLOADED)
42574260 break;
42584261 irdma_event_connect_error(event);
42594262 break;
@@ -4263,7 +4266,7 @@ static void irdma_cm_event_handler(struct work_struct *work) · 3 unmodified lines
42634266 break;
42644267 }
42654268
4266− irdma_rem_ref_cm_node(event->cm_node);
4269+ irdma_rem_ref_cm_node(cm_node);
42674270 kfree(event);
42684271 }
42694272
drivers/infiniband/hw/irdma/uk.c+22−17
@@ -1438,7 +1438,7 @@ exit: · 1437 unmodified lines
14381438 * irdma_round_up_wq - return round up qp wq depth
14391439 * @wqdepth: wq depth in quanta to round up
14401440 */
1441−static int irdma_round_up_wq(u32 wqdepth)
1441+static u64 irdma_round_up_wq(u64 wqdepth)
14421442 {
14431443 int scount = 1;
14441444
@@ -1491,15 +1491,16 @@ void irdma_get_wqe_shift(struct irdma_uk_attrs *uk_attrs, u32 sge, · 46 unmodified lines
14911491 int irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, u32 sq_size, u8 shift,
14921492 u32 *sqdepth)
14931493 {
1494− u32 min_size = (u32)uk_attrs->min_hw_wq_size << shift;
1494+ u32 min_hw_quanta = (u32)uk_attrs->min_hw_wq_size << shift;
1495+ u64 hw_quanta =
1496+ irdma_round_up_wq(((u64)sq_size << shift) + IRDMA_SQ_RSVD);
14951497
1496− *sqdepth = irdma_round_up_wq((sq_size << shift) + IRDMA_SQ_RSVD);
1497−
1498− if (*sqdepth < min_size)
1499− *sqdepth = min_size;
1500− else if (*sqdepth > uk_attrs->max_hw_wq_quanta)
1498+ if (hw_quanta < min_hw_quanta)
1499+ hw_quanta = min_hw_quanta;
1500+ else if (hw_quanta > uk_attrs->max_hw_wq_quanta)
15011501 return -EINVAL;
15021502
1503+ *sqdepth = hw_quanta;
15031504 return 0;
15041505 }
15051506
@@ -1513,15 +1514,16 @@ int irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, u32 sq_size, u8 shift, · 7 unmodified lines
15131514 int irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, u32 rq_size, u8 shift,
15141515 u32 *rqdepth)
15151516 {
1516− u32 min_size = (u32)uk_attrs->min_hw_wq_size << shift;
1517−
1518− *rqdepth = irdma_round_up_wq((rq_size << shift) + IRDMA_RQ_RSVD);
1517+ u32 min_hw_quanta = (u32)uk_attrs->min_hw_wq_size << shift;
1518+ u64 hw_quanta =
1519+ irdma_round_up_wq(((u64)rq_size << shift) + IRDMA_RQ_RSVD);
15191520
1520− if (*rqdepth < min_size)
1521− *rqdepth = min_size;
1522− else if (*rqdepth > uk_attrs->max_hw_rq_quanta)
1521+ if (hw_quanta < min_hw_quanta)
1522+ hw_quanta = min_hw_quanta;
1523+ else if (hw_quanta > uk_attrs->max_hw_rq_quanta)
15231524 return -EINVAL;
15241525
1526+ *rqdepth = hw_quanta;
15251527 return 0;
15261528 }
15271529
@@ -1535,13 +1537,16 @@ int irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, u32 rq_size, u8 shift, · 7 unmodified lines
15351537 int irdma_get_srqdepth(struct irdma_uk_attrs *uk_attrs, u32 srq_size, u8 shift,
15361538 u32 *srqdepth)
15371539 {
1538− *srqdepth = irdma_round_up_wq((srq_size << shift) + IRDMA_RQ_RSVD);
1540+ u32 min_hw_quanta = (u32)uk_attrs->min_hw_wq_size << shift;
1541+ u64 hw_quanta =
1542+ irdma_round_up_wq(((u64)srq_size << shift) + IRDMA_RQ_RSVD);
15391543
1540− if (*srqdepth < ((u32)uk_attrs->min_hw_wq_size << shift))
1541− *srqdepth = uk_attrs->min_hw_wq_size << shift;
1542− else if (*srqdepth > uk_attrs->max_hw_srq_quanta)
1544+ if (hw_quanta < min_hw_quanta)
1545+ hw_quanta = min_hw_quanta;
1546+ else if (hw_quanta > uk_attrs->max_hw_srq_quanta)
15431547 return -EINVAL;
15441548
1549+ *srqdepth = hw_quanta;
15451550 return 0;
15461551 }
15471552
drivers/infiniband/hw/irdma/utils.c+0−2
@@ -2322,8 +2322,6 @@ void irdma_modify_qp_to_err(struct irdma_sc_qp *sc_qp) · 2321 unmodified lines
23222322 struct irdma_qp *qp = sc_qp->qp_uk.back_qp;
23232323 struct ib_qp_attr attr;
23242324
2325− if (qp->iwdev->rf->reset)
2326− return;
23272325 attr.qp_state = IB_QPS_ERR;
23282326
23292327 if (rdma_protocol_roce(qp->ibqp.device, 1))
drivers/infiniband/hw/irdma/verbs.c+6−4
@@ -558,7 +558,8 @@ static int irdma_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) · 557 unmodified lines
558558 }
559559
560560 irdma_qp_rem_ref(&iwqp->ibqp);
561− wait_for_completion(&iwqp->free_qp);
561+ if (!iwdev->rf->reset)
562+ wait_for_completion(&iwqp->free_qp);
562563 irdma_free_lsmm_rsrc(iwqp);
563564 irdma_cqp_qp_destroy_cmd(&iwdev->rf->sc_dev, &iwqp->sc_qp);
564565
@@ -1105,6 +1106,7 @@ static int irdma_create_qp(struct ib_qp *ibqp, · 540 unmodified lines
11051106 spin_lock_init(&iwqp->sc_qp.pfpdu.lock);
11061107 iwqp->sig_all = init_attr->sq_sig_type == IB_SIGNAL_ALL_WR;
11071108 rf->qp_table[qp_num] = iwqp;
1109+ init_completion(&iwqp->free_qp);
11081110
11091111 if (udata) {
11101112 /* GEN_1 legacy support with libi40iw does not have expanded uresp struct */
@@ -1129,7 +1131,6 @@ static int irdma_create_qp(struct ib_qp *ibqp, · 18 unmodified lines
11291131 }
11301132 }
11311133
1132− init_completion(&iwqp->free_qp);
11331134 return 0;
11341135
11351136 error:
@@ -1462,8 +1463,6 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr, · 326 unmodified lines
14621463 ctx_info->remote_atomics_en = true;
14631464 }
14641465
1465− wait_event(iwqp->mod_qp_waitq, !atomic_read(&iwqp->hw_mod_qp_pend));
1466−
14671466 ibdev_dbg(&iwdev->ibdev,
14681467 "VERBS: caller: %pS qp_id=%d to_ibqpstate=%d ibqpstate=%d irdma_qpstate=%d attr_mask=0x%x\n",
14691468 __builtin_return_address(0), ibqp->qp_num, attr->qp_state,
@@ -1540,6 +1539,7 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr, · 70 unmodified lines
15401539 case IB_QPS_ERR:
15411540 case IB_QPS_RESET:
15421541 if (iwqp->iwarp_state == IRDMA_QP_STATE_ERROR) {
1542+ iwqp->ibqp_state = attr->qp_state;
15431543 spin_unlock_irqrestore(&iwqp->lock, flags);
15441544 if (udata && udata->inlen) {
15451545 if (ib_copy_from_udata(&ureq, udata,
@@ -1745,6 +1745,7 @@ int irdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, · 199 unmodified lines
17451745 case IB_QPS_ERR:
17461746 case IB_QPS_RESET:
17471747 if (iwqp->iwarp_state == IRDMA_QP_STATE_ERROR) {
1748+ iwqp->ibqp_state = attr->qp_state;
17481749 spin_unlock_irqrestore(&iwqp->lock, flags);
17491750 if (udata && udata->inlen) {
17501751 if (ib_copy_from_udata(&ureq, udata,
@@ -3723,6 +3724,7 @@ static int irdma_rereg_mr_trans(struct irdma_mr *iwmr, u64 start, u64 len, · 1972 unmodified lines
37233724
37243725 err:
37253726 ib_umem_release(region);
3727+ iwmr->region = NULL;
37263728 return err;
37273729 }
37283730
drivers/iommu/dma-iommu.c+17−4
@@ -1211,7 +1211,7 @@ dma_addr_t iommu_dma_map_phys(struct device *dev, phys_addr_t phys, size_t size, · 1210 unmodified lines
12111211 */
12121212 if (dev_use_swiotlb(dev, size, dir) &&
12131213 iova_unaligned(iovad, phys, size)) {
1214− if (attrs & DMA_ATTR_MMIO)
1214+ if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))
12151215 return DMA_MAPPING_ERROR;
12161216
12171217 phys = iommu_dma_map_swiotlb(dev, phys, size, dir, attrs);
@@ -1223,7 +1223,8 @@ dma_addr_t iommu_dma_map_phys(struct device *dev, phys_addr_t phys, size_t size, · 5 unmodified lines
12231223 arch_sync_dma_for_device(phys, size, dir);
12241224
12251225 iova = __iommu_dma_map(dev, phys, size, prot, dma_mask);
1226− if (iova == DMA_MAPPING_ERROR && !(attrs & DMA_ATTR_MMIO))
1226+ if (iova == DMA_MAPPING_ERROR &&
1227+ !(attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT)))
12271228 swiotlb_tbl_unmap_single(dev, phys, size, dir, attrs);
12281229 return iova;
12291230 }
@@ -1233,7 +1234,7 @@ void iommu_dma_unmap_phys(struct device *dev, dma_addr_t dma_handle, · 3 unmodified lines
12331234 {
12341235 phys_addr_t phys;
12351236
1236− if (attrs & DMA_ATTR_MMIO) {
1237+ if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT)) {
12371238 __iommu_dma_unmap(dev, dma_handle, size);
12381239 return;
12391240 }
@@ -1945,9 +1946,21 @@ int dma_iova_link(struct device *dev, struct dma_iova_state *state, · 705 unmodified lines
19451946 if (WARN_ON_ONCE(iova_start_pad && offset > 0))
19461947 return -EIO;
19471948
1949+ /*
1950+ * DMA_IOVA_USE_SWIOTLB is set on state after some entry
1951+ * took SWIOTLB path, which we were supposed to prevent
1952+ * for DMA_ATTR_REQUIRE_COHERENT attribute.
1953+ */
1954+ if (WARN_ON_ONCE((state->__size & DMA_IOVA_USE_SWIOTLB) &&
1955+ (attrs & DMA_ATTR_REQUIRE_COHERENT)))
1956+ return -EOPNOTSUPP;
1957+
1958+ if (!dev_is_dma_coherent(dev) && (attrs & DMA_ATTR_REQUIRE_COHERENT))
1959+ return -EOPNOTSUPP;
1960+
19481961 if (dev_use_swiotlb(dev, size, dir) &&
19491962 iova_unaligned(iovad, phys, size)) {
1950− if (attrs & DMA_ATTR_MMIO)
1963+ if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))
19511964 return -EPERM;
19521965
19531966 return iommu_dma_iova_link_swiotlb(dev, state, phys, offset,
drivers/irqchip/irq-qcom-mpm.c+3−0
@@ -306,6 +306,8 @@ static int mpm_pd_power_off(struct generic_pm_domain *genpd) · 305 unmodified lines
306306 if (ret < 0)
307307 return ret;
308308
309+ mbox_client_txdone(priv->mbox_chan, 0);
310+
309311 return 0;
310312 }
311313
@@ -434,6 +436,7 @@ static int qcom_mpm_probe(struct platform_device *pdev, struct device_node *pare · 122 unmodified lines
434436 }
435437
436438 priv->mbox_client.dev = dev;
439+ priv->mbox_client.knows_txdone = true;
437440 priv->mbox_chan = mbox_request_channel(&priv->mbox_client, 0);
438441 if (IS_ERR(priv->mbox_chan)) {
439442 ret = PTR_ERR(priv->mbox_chan);
drivers/irqchip/irq-renesas-rzv2h.c+1−1
@@ -621,7 +621,7 @@ static int rzv2h_icu_probe_common(struct platform_device *pdev, struct device_no · 620 unmodified lines
621621 return 0;
622622
623623 pm_put:
624− pm_runtime_put(&pdev->dev);
624+ pm_runtime_put_sync(&pdev->dev);
625625
626626 return ret;
627627 }
drivers/media/i2c/ccs/ccs-core.c+0−2
@@ -3080,8 +3080,6 @@ static int ccs_init_state(struct v4l2_subdev *sd, · 3079 unmodified lines
30803080 struct v4l2_rect *crop =
30813081 v4l2_subdev_state_get_crop(sd_state, pad);
30823082
3083− guard(mutex)(&sensor->mutex);
3084−
30853083 ccs_get_native_size(ssd, crop);
30863084
30873085 fmt->width = crop->width;
drivers/media/mc/mc-request.c+5−0
@@ -192,6 +192,8 @@ static long media_request_ioctl_reinit(struct media_request *req) · 191 unmodified lines
192192 struct media_device *mdev = req->mdev;
193193 unsigned long flags;
194194
195+ mutex_lock(&mdev->req_queue_mutex);
196+
195197 spin_lock_irqsave(&req->lock, flags);
196198 if (req->state != MEDIA_REQUEST_STATE_IDLE &&
197199 req->state != MEDIA_REQUEST_STATE_COMPLETE) {
@@ -199,6 +201,7 @@ static long media_request_ioctl_reinit(struct media_request *req) · 1 unmodified line
199201 "request: %s not in idle or complete state, cannot reinit\n",
200202 req->debug_str);
201203 spin_unlock_irqrestore(&req->lock, flags);
204+ mutex_unlock(&mdev->req_queue_mutex);
202205 return -EBUSY;
203206 }
204207 if (req->access_count) {
@@ -206,6 +209,7 @@ static long media_request_ioctl_reinit(struct media_request *req) · 1 unmodified line
206209 "request: %s is being accessed, cannot reinit\n",
207210 req->debug_str);
208211 spin_unlock_irqrestore(&req->lock, flags);
212+ mutex_unlock(&mdev->req_queue_mutex);
209213 return -EBUSY;
210214 }
211215 req->state = MEDIA_REQUEST_STATE_CLEANING;
@@ -216,6 +220,7 @@ static long media_request_ioctl_reinit(struct media_request *req) · 4 unmodified lines
216220 spin_lock_irqsave(&req->lock, flags);
217221 req->state = MEDIA_REQUEST_STATE_IDLE;
218222 spin_unlock_irqrestore(&req->lock, flags);
223+ mutex_unlock(&mdev->req_queue_mutex);
219224
220225 return 0;
221226 }
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c+4−0
@@ -500,11 +500,15 @@ void rkvdec_hevc_run_preamble(struct rkvdec_ctx *ctx, · 499 unmodified lines
500500 ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
501501 V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS);
502502 run->ext_sps_st_rps = ctrl ? ctrl->p_cur.p : NULL;
503+ } else {
504+ run->ext_sps_st_rps = NULL;
503505 }
504506 if (ctx->has_sps_lt_rps) {
505507 ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
506508 V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS);
507509 run->ext_sps_lt_rps = ctrl ? ctrl->p_cur.p : NULL;
510+ } else {
511+ run->ext_sps_lt_rps = NULL;
508512 }
509513
510514 rkvdec_run_preamble(ctx, &run->base);
drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c+27−23
@@ -130,7 +130,7 @@ struct rkvdec_h264_ctx { · 129 unmodified lines
130130 struct vdpu383_regs_h26x regs;
131131 };
132132
133−static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
133+static noinline_for_stack void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
134134 {
135135 pps->top_field_order_cnt0 = dpb[0].top_field_order_cnt;
136136 pps->bot_field_order_cnt0 = dpb[0].bottom_field_order_cnt;
@@ -166,6 +166,31 @@ static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_d · 29 unmodified lines
166166 pps->bot_field_order_cnt15 = dpb[15].bottom_field_order_cnt;
167167 }
168168
169+static noinline_for_stack void set_dec_params(struct rkvdec_pps *pps, const struct v4l2_ctrl_h264_decode_params *dec_params)
170+{
171+ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
172+
173+ for (int i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
174+ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
175+ pps->is_longterm |= (1 << i);
176+ pps->ref_field_flags |=
177+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
178+ pps->ref_colmv_use_flag |=
179+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
180+ pps->ref_topfield_used |=
181+ (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
182+ pps->ref_botfield_used |=
183+ (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
184+ }
185+ pps->pic_field_flag =
186+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
187+ pps->pic_associated_flag =
188+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
189+
190+ pps->cur_top_field = dec_params->top_field_order_cnt;
191+ pps->cur_bot_field = dec_params->bottom_field_order_cnt;
192+}
193+
169194 static void assemble_hw_pps(struct rkvdec_ctx *ctx,
170195 struct rkvdec_h264_run *run)
171196 {
@@ -177,7 +202,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, · 5 unmodified lines
177202 struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
178203 struct rkvdec_sps_pps *hw_ps;
179204 u32 pic_width, pic_height;
180− u32 i;
181205
182206 /*
183207 * HW read the SPS/PPS information from PPS packet index by PPS id.
@@ -261,28 +285,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, · 77 unmodified lines
261285 !!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT);
262286
263287 set_field_order_cnt(&hw_ps->pps, dpb);
288+ set_dec_params(&hw_ps->pps, dec_params);
264289
265− for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
266− if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
267− hw_ps->pps.is_longterm |= (1 << i);
268−
269− hw_ps->pps.ref_field_flags |=
270− (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
271− hw_ps->pps.ref_colmv_use_flag |=
272− (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
273− hw_ps->pps.ref_topfield_used |=
274− (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
275− hw_ps->pps.ref_botfield_used |=
276− (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
277− }
278−
279− hw_ps->pps.pic_field_flag =
280− !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
281− hw_ps->pps.pic_associated_flag =
282− !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
283−
284− hw_ps->pps.cur_top_field = dec_params->top_field_order_cnt;
285− hw_ps->pps.cur_bot_field = dec_params->bottom_field_order_cnt;
286290 }
287291
288292 static void rkvdec_write_regs(struct rkvdec_ctx *ctx)
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c+2−1
@@ -893,7 +893,8 @@ out_update_last: · 892 unmodified lines
893893 update_ctx_last_info(vp9_ctx);
894894 }
895895
896−static void rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx)
896+static noinline_for_stack void
897+rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx)
897898 {
898899 struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv;
899900 struct rkvdec_vp9_intra_frame_symbol_counts *intra_cnts = vp9_ctx->count_tbl.cpu;
drivers/media/platform/synopsys/Kconfig+1−0
@@ -7,6 +7,7 @@ config VIDEO_DW_MIPI_CSI2RX · 6 unmodified lines
77 depends on VIDEO_DEV
88 depends on V4L_PLATFORM_DRIVERS
99 depends on PM && COMMON_CLK
10+ select GENERIC_PHY_MIPI_DPHY
1011 select MEDIA_CONTROLLER
1112 select V4L2_FWNODE
1213 select VIDEO_V4L2_SUBDEV_API
drivers/media/platform/synopsys/dw-mipi-csi2rx.c+1−1
@@ -301,7 +301,7 @@ dw_mipi_csi2rx_enum_mbus_code(struct v4l2_subdev *sd, · 300 unmodified lines
301301
302302 return 0;
303303 case DW_MIPI_CSI2RX_PAD_SINK:
304− if (code->index > csi2->formats_num)
304+ if (code->index >= csi2->formats_num)
305305 return -EINVAL;
306306
307307 code->code = csi2->formats[code->index].code;
drivers/media/platform/verisilicon/imx8m_vpu_hw.c+1−1
@@ -343,7 +343,7 @@ const struct hantro_variant imx8mq_vpu_variant = { · 342 unmodified lines
343343 .num_regs = ARRAY_SIZE(imx8mq_reg_names)
344344 };
345345
346−static const struct of_device_id imx8mq_vpu_shared_resources[] __initconst = {
346+static const struct of_device_id imx8mq_vpu_shared_resources[] = {
347347 { .compatible = "nxp,imx8mq-vpu-g1", },
348348 { .compatible = "nxp,imx8mq-vpu-g2", },
349349 { /* sentinel */ }
drivers/media/usb/uvc/uvc_video.c+5−4
@@ -1751,7 +1751,8 @@ static void uvc_video_complete(struct urb *urb) · 1750 unmodified lines
17511751 /*
17521752 * Free transfer buffers.
17531753 */
1754−static void uvc_free_urb_buffers(struct uvc_streaming *stream)
1754+static void uvc_free_urb_buffers(struct uvc_streaming *stream,
1755+ unsigned int size)
17551756 {
17561757 struct usb_device *udev = stream->dev->udev;
17571758 struct uvc_urb *uvc_urb;
@@ -1760,7 +1761,7 @@ static void uvc_free_urb_buffers(struct uvc_streaming *stream) · 2 unmodified lines
17601761 if (!uvc_urb->buffer)
17611762 continue;
17621763
1763− usb_free_noncoherent(udev, stream->urb_size, uvc_urb->buffer,
1764+ usb_free_noncoherent(udev, size, uvc_urb->buffer,
17641765 uvc_stream_dir(stream), uvc_urb->sgt);
17651766 uvc_urb->buffer = NULL;
17661767 uvc_urb->sgt = NULL;
@@ -1820,7 +1821,7 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream, · 53 unmodified lines
18201821
18211822 if (!uvc_alloc_urb_buffer(stream, uvc_urb, urb_size,
18221823 gfp_flags)) {
1823− uvc_free_urb_buffers(stream);
1824+ uvc_free_urb_buffers(stream, urb_size);
18241825 break;
18251826 }
18261827
@@ -1868,7 +1869,7 @@ static void uvc_video_stop_transfer(struct uvc_streaming *stream, · 41 unmodified lines
18681869 }
18691870
18701871 if (free_buffers)
1871− uvc_free_urb_buffers(stream);
1872+ uvc_free_urb_buffers(stream, stream->urb_size);
18721873 }
18731874
18741875 /*
drivers/media/v4l2-core/v4l2-ioctl.c+3−2
@@ -3082,13 +3082,14 @@ static long __video_do_ioctl(struct file *file, · 3081 unmodified lines
30823082 }
30833083
30843084 /*
3085− * We need to serialize streamon/off with queueing new requests.
3085+ * We need to serialize streamon/off/reqbufs with queueing new requests.
30863086 * These ioctls may trigger the cancellation of a streaming
30873087 * operation, and that should not be mixed with queueing a new
30883088 * request at the same time.
30893089 */
30903090 if (v4l2_device_supports_requests(vfd->v4l2_dev) &&
3091− (cmd == VIDIOC_STREAMON || cmd == VIDIOC_STREAMOFF)) {
3091+ (cmd == VIDIOC_STREAMON || cmd == VIDIOC_STREAMOFF ||
3092+ cmd == VIDIOC_REQBUFS)) {
30923093 req_queue_lock = &vfd->v4l2_dev->mdev->req_queue_mutex;
30933094
30943095 if (mutex_lock_interruptible(req_queue_lock))
drivers/net/can/dev/netlink.c+3−1
@@ -601,7 +601,9 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[], · 600 unmodified lines
601601 /* We need synchronization with dev->stop() */
602602 ASSERT_RTNL();
603603
604− can_ctrlmode_changelink(dev, data, extack);
604+ err = can_ctrlmode_changelink(dev, data, extack);
605+ if (err)
606+ return err;
605607
606608 if (data[IFLA_CAN_BITTIMING]) {
607609 struct can_bittiming bt;
drivers/net/can/spi/mcp251x.c+24−5
@@ -1225,7 +1225,11 @@ static int mcp251x_open(struct net_device *net) · 1224 unmodified lines
12251225 }
12261226
12271227 mutex_lock(&priv->mcp_lock);
1228− mcp251x_power_enable(priv->transceiver, 1);
1228+ ret = mcp251x_power_enable(priv->transceiver, 1);
1229+ if (ret) {
1230+ dev_err(&spi->dev, "failed to enable transceiver power: %pe\n", ERR_PTR(ret));
1231+ goto out_close_candev;
1232+ }
12291233
12301234 priv->force_quit = 0;
12311235 priv->tx_skb = NULL;
@@ -1272,6 +1276,7 @@ out_free_irq: · 40 unmodified lines
12721276 mcp251x_hw_sleep(spi);
12731277 out_close:
12741278 mcp251x_power_enable(priv->transceiver, 0);
1279+out_close_candev:
12751280 close_candev(net);
12761281 mutex_unlock(&priv->mcp_lock);
12771282 if (release_irq)
@@ -1516,11 +1521,25 @@ static int __maybe_unused mcp251x_can_resume(struct device *dev) · 238 unmodified lines
15161521 {
15171522 struct spi_device *spi = to_spi_device(dev);
15181523 struct mcp251x_priv *priv = spi_get_drvdata(spi);
1524+ int ret = 0;
15191525
1520− if (priv->after_suspend & AFTER_SUSPEND_POWER)
1521− mcp251x_power_enable(priv->power, 1);
1522− if (priv->after_suspend & AFTER_SUSPEND_UP)
1523− mcp251x_power_enable(priv->transceiver, 1);
1526+ if (priv->after_suspend & AFTER_SUSPEND_POWER) {
1527+ ret = mcp251x_power_enable(priv->power, 1);
1528+ if (ret) {
1529+ dev_err(dev, "failed to restore power: %pe\n", ERR_PTR(ret));
1530+ return ret;
1531+ }
1532+ }
1533+
1534+ if (priv->after_suspend & AFTER_SUSPEND_UP) {
1535+ ret = mcp251x_power_enable(priv->transceiver, 1);
1536+ if (ret) {
1537+ dev_err(dev, "failed to restore transceiver power: %pe\n", ERR_PTR(ret));
1538+ if (priv->after_suspend & AFTER_SUSPEND_POWER)
1539+ mcp251x_power_enable(priv->power, 0);
1540+ return ret;
1541+ }
1542+ }
15241543
15251544 if (priv->after_suspend & (AFTER_SUSPEND_POWER | AFTER_SUSPEND_UP))
15261545 queue_work(priv->wq, &priv->restart_work);
drivers/net/ethernet/airoha/airoha_ppe.c+2−0
@@ -227,7 +227,9 @@ static int airoha_ppe_get_wdma_info(struct net_device *dev, const u8 *addr, · 226 unmodified lines
227227 if (!dev)
228228 return -ENODEV;
229229
230+ rcu_read_lock();
230231 err = dev_fill_forward_path(dev, addr, &stack);
232+ rcu_read_unlock();
231233 if (err)
232234 return err;
233235
drivers/net/ethernet/broadcom/Kconfig+1−1
@@ -25,7 +25,7 @@ config B44 · 24 unmodified lines
2525 select SSB
2626 select MII
2727 select PHYLIB
28− select FIXED_PHY if BCM47XX
28+ select FIXED_PHY
2929 help
3030 If you have a network (Ethernet) controller of this type, say Y
3131 or M here.
drivers/net/ethernet/broadcom/asp2/bcmasp.c+23−18
@@ -1152,12 +1152,6 @@ void bcmasp_enable_wol(struct bcmasp_intf *intf, bool en) · 1151 unmodified lines
11521152 }
11531153 }
11541154
1155−static void bcmasp_wol_irq_destroy(struct bcmasp_priv *priv)
1156−{
1157− if (priv->wol_irq > 0)
1158− free_irq(priv->wol_irq, priv);
1159−}
1160−
11611155 static void bcmasp_eee_fixup(struct bcmasp_intf *intf, bool en)
11621156 {
11631157 u32 reg, phy_lpi_overwrite;
@@ -1255,7 +1249,7 @@ static int bcmasp_probe(struct platform_device *pdev) · 91 unmodified lines
12551249 if (priv->irq <= 0)
12561250 return -EINVAL;
12571251
1258− priv->clk = devm_clk_get_optional_enabled(dev, "sw_asp");
1252+ priv->clk = devm_clk_get_optional(dev, "sw_asp");
12591253 if (IS_ERR(priv->clk))
12601254 return dev_err_probe(dev, PTR_ERR(priv->clk),
12611255 "failed to request clock\n");
@@ -1283,6 +1277,10 @@ static int bcmasp_probe(struct platform_device *pdev) · 21 unmodified lines
12831277
12841278 bcmasp_set_pdata(priv, pdata);
12851279
1280+ ret = clk_prepare_enable(priv->clk);
1281+ if (ret)
1282+ return dev_err_probe(dev, ret, "failed to start clock\n");
1283+
12861284 /* Enable all clocks to ensure successful probing */
12871285 bcmasp_core_clock_set(priv, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE, 0);
12881286
@@ -1294,8 +1292,10 @@ static int bcmasp_probe(struct platform_device *pdev) · 5 unmodified lines
12941292
12951293 ret = devm_request_irq(&pdev->dev, priv->irq, bcmasp_isr, 0,
12961294 pdev->name, priv);
1297− if (ret)
1298− return dev_err_probe(dev, ret, "failed to request ASP interrupt: %d", ret);
1295+ if (ret) {
1296+ dev_err(dev, "Failed to request ASP interrupt: %d", ret);
1297+ goto err_clock_disable;
1298+ }
12991299
13001300 /* Register mdio child nodes */
13011301 of_platform_populate(dev->of_node, bcmasp_mdio_of_match, NULL, dev);
@@ -1307,13 +1307,17 @@ static int bcmasp_probe(struct platform_device *pdev) · 5 unmodified lines
13071307
13081308 priv->mda_filters = devm_kcalloc(dev, priv->num_mda_filters,
13091309 sizeof(*priv->mda_filters), GFP_KERNEL);
1310− if (!priv->mda_filters)
1311− return -ENOMEM;
1310+ if (!priv->mda_filters) {
1311+ ret = -ENOMEM;
1312+ goto err_clock_disable;
1313+ }
13121314
13131315 priv->net_filters = devm_kcalloc(dev, priv->num_net_filters,
13141316 sizeof(*priv->net_filters), GFP_KERNEL);
1315− if (!priv->net_filters)
1316− return -ENOMEM;
1317+ if (!priv->net_filters) {
1318+ ret = -ENOMEM;
1319+ goto err_clock_disable;
1320+ }
13171321
13181322 bcmasp_core_init_filters(priv);
13191323
@@ -1322,7 +1326,8 @@ static int bcmasp_probe(struct platform_device *pdev) · 2 unmodified lines
13221326 ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");
13231327 if (!ports_node) {
13241328 dev_warn(dev, "No ports found\n");
1325− return -EINVAL;
1329+ ret = -EINVAL;
1330+ goto err_clock_disable;
13261331 }
13271332
13281333 i = 0;
@@ -1344,8 +1349,6 @@ static int bcmasp_probe(struct platform_device *pdev) · 15 unmodified lines
13441349 */
13451350 bcmasp_core_clock_set(priv, 0, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE);
13461351
1347− clk_disable_unprepare(priv->clk);
1348−
13491352 /* Now do the registration of the network ports which will take care
13501353 * of managing the clock properly.
13511354 */
@@ -1358,13 +1361,16 @@ static int bcmasp_probe(struct platform_device *pdev) · 6 unmodified lines
13581361 count++;
13591362 }
13601363
1364+ clk_disable_unprepare(priv->clk);
1365+
13611366 dev_info(dev, "Initialized %d port(s)\n", count);
13621367
13631368 return ret;
13641369
13651370 err_cleanup:
1366− bcmasp_wol_irq_destroy(priv);
13671371 bcmasp_remove_intfs(priv);
1372+err_clock_disable:
1373+ clk_disable_unprepare(priv->clk);
13681374
13691375 return ret;
13701376 }
@@ -1376,7 +1382,6 @@ static void bcmasp_remove(struct platform_device *pdev) · 5 unmodified lines
13761382 if (!priv)
13771383 return;
13781384
1379− bcmasp_wol_irq_destroy(priv);
13801385 bcmasp_remove_intfs(priv);
13811386 }
13821387
drivers/net/ethernet/cadence/macb_main.c+25−16
@@ -1071,7 +1071,7 @@ static void macb_tx_unmap(struct macb *bp, struct macb_tx_skb *tx_skb, int budge · 1070 unmodified lines
10711071 }
10721072
10731073 if (tx_skb->skb) {
1074− napi_consume_skb(tx_skb->skb, budget);
1074+ dev_consume_skb_any(tx_skb->skb);
10751075 tx_skb->skb = NULL;
10761076 }
10771077 }
@@ -3224,7 +3224,7 @@ static void gem_get_ethtool_stats(struct net_device *dev, · 2146 unmodified lines
32243224 spin_lock_irq(&bp->stats_lock);
32253225 gem_update_stats(bp);
32263226 memcpy(data, &bp->ethtool_stats, sizeof(u64)
3227− * (GEM_STATS_LEN + QUEUE_STATS_LEN * MACB_MAX_QUEUES));
3227+ * (GEM_STATS_LEN + QUEUE_STATS_LEN * bp->num_queues));
32283228 spin_unlock_irq(&bp->stats_lock);
32293229 }
32303230
@@ -5776,9 +5776,9 @@ static int __maybe_unused macb_suspend(struct device *dev) · 2545 unmodified lines
57765776 struct macb_queue *queue;
57775777 struct in_device *idev;
57785778 unsigned long flags;
5779+ u32 tmp, ifa_local;
57795780 unsigned int q;
57805781 int err;
5781− u32 tmp;
57825782
57835783 if (!device_may_wakeup(&bp->dev->dev))
57845784 phy_exit(bp->phy);
@@ -5787,14 +5787,21 @@ static int __maybe_unused macb_suspend(struct device *dev) · 2 unmodified lines
57875787 return 0;
57885788
57895789 if (bp->wol & MACB_WOL_ENABLED) {
5790− /* Check for IP address in WOL ARP mode */
5791− idev = __in_dev_get_rcu(bp->dev);
5792− if (idev)
5793− ifa = rcu_dereference(idev->ifa_list);
5794− if ((bp->wolopts & WAKE_ARP) && !ifa) {
5795− netdev_err(netdev, "IP address not assigned as required by WoL walk ARP\n");
5796− return -EOPNOTSUPP;
5790+ if (bp->wolopts & WAKE_ARP) {
5791+ /* Check for IP address in WOL ARP mode */
5792+ rcu_read_lock();
5793+ idev = __in_dev_get_rcu(bp->dev);
5794+ if (idev)
5795+ ifa = rcu_dereference(idev->ifa_list);
5796+ if (!ifa) {
5797+ rcu_read_unlock();
5798+ netdev_err(netdev, "IP address not assigned as required by WoL walk ARP\n");
5799+ return -EOPNOTSUPP;
5800+ }
5801+ ifa_local = be32_to_cpu(ifa->ifa_local);
5802+ rcu_read_unlock();
57975803 }
5804+
57985805 spin_lock_irqsave(&bp->lock, flags);
57995806
58005807 /* Disable Tx and Rx engines before disabling the queues,
@@ -5833,8 +5840,9 @@ static int __maybe_unused macb_suspend(struct device *dev) · 32 unmodified lines
58335840 if (bp->wolopts & WAKE_ARP) {
58345841 tmp |= MACB_BIT(ARP);
58355842 /* write IP address into register */
5836− tmp |= MACB_BFEXT(IP, be32_to_cpu(ifa->ifa_local));
5843+ tmp |= MACB_BFEXT(IP, ifa_local);
58375844 }
5845+ spin_unlock_irqrestore(&bp->lock, flags);
58385846
58395847 /* Change interrupt handler and
58405848 * Enable WoL IRQ on queue 0
@@ -5847,11 +5855,12 @@ static int __maybe_unused macb_suspend(struct device *dev) · 6 unmodified lines
58475855 dev_err(dev,
58485856 "Unable to request IRQ %d (error %d)\n",
58495857 bp->queues[0].irq, err);
5850− spin_unlock_irqrestore(&bp->lock, flags);
58515858 return err;
58525859 }
5860+ spin_lock_irqsave(&bp->lock, flags);
58535861 queue_writel(bp->queues, IER, GEM_BIT(WOL));
58545862 gem_writel(bp, WOL, tmp);
5863+ spin_unlock_irqrestore(&bp->lock, flags);
58555864 } else {
58565865 err = devm_request_irq(dev, bp->queues[0].irq, macb_wol_interrupt,
58575866 IRQF_SHARED, netdev->name, bp->queues);
@@ -5859,13 +5868,13 @@ static int __maybe_unused macb_suspend(struct device *dev) · 1 unmodified line
58595868 dev_err(dev,
58605869 "Unable to request IRQ %d (error %d)\n",
58615870 bp->queues[0].irq, err);
5862− spin_unlock_irqrestore(&bp->lock, flags);
58635871 return err;
58645872 }
5873+ spin_lock_irqsave(&bp->lock, flags);
58655874 queue_writel(bp->queues, IER, MACB_BIT(WOL));
58665875 macb_writel(bp, WOL, tmp);
5876+ spin_unlock_irqrestore(&bp->lock, flags);
58675877 }
5868− spin_unlock_irqrestore(&bp->lock, flags);
58695878
58705879 enable_irq_wake(bp->queues[0].irq);
58715880 }
@@ -5932,6 +5941,8 @@ static int __maybe_unused macb_resume(struct device *dev) · 60 unmodified lines
59325941 queue_readl(bp->queues, ISR);
59335942 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
59345943 queue_writel(bp->queues, ISR, -1);
5944+ spin_unlock_irqrestore(&bp->lock, flags);
5945+
59355946 /* Replace interrupt handler on queue 0 */
59365947 devm_free_irq(dev, bp->queues[0].irq, bp->queues);
59375948 err = devm_request_irq(dev, bp->queues[0].irq, macb_interrupt,
@@ -5940,10 +5951,8 @@ static int __maybe_unused macb_resume(struct device *dev) · 2 unmodified lines
59405951 dev_err(dev,
59415952 "Unable to request IRQ %d (error %d)\n",
59425953 bp->queues[0].irq, err);
5943− spin_unlock_irqrestore(&bp->lock, flags);
59445954 return err;
59455955 }
5946− spin_unlock_irqrestore(&bp->lock, flags);
59475956
59485957 disable_irq_wake(bp->queues[0].irq);
59495958
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c+2−0
@@ -813,6 +813,8 @@ static void enetc_get_ringparam(struct net_device *ndev, · 812 unmodified lines
813813 {
814814 struct enetc_ndev_priv *priv = netdev_priv(ndev);
815815
816+ ring->rx_max_pending = priv->rx_bd_count;
817+ ring->tx_max_pending = priv->tx_bd_count;
816818 ring->rx_pending = priv->rx_bd_count;
817819 ring->tx_pending = priv->tx_bd_count;
818820
drivers/net/ethernet/intel/iavf/iavf_ethtool.c+15−16
@@ -313,14 +313,13 @@ static int iavf_get_sset_count(struct net_device *netdev, int sset) · 312 unmodified lines
313313 {
314314 /* Report the maximum number queues, even if not every queue is
315315 * currently configured. Since allocation of queues is in pairs,
316− * use netdev->real_num_tx_queues * 2. The real_num_tx_queues is set
317− * at device creation and never changes.
316+ * use netdev->num_tx_queues * 2. The num_tx_queues is set at
317+ * device creation and never changes.
318318 */
319319
320320 if (sset == ETH_SS_STATS)
321321 return IAVF_STATS_LEN +
322− (IAVF_QUEUE_STATS_LEN * 2 *
323− netdev->real_num_tx_queues);
322+ (IAVF_QUEUE_STATS_LEN * 2 * netdev->num_tx_queues);
324323 else
325324 return -EINVAL;
326325 }
@@ -345,19 +344,19 @@ static void iavf_get_ethtool_stats(struct net_device *netdev, · 18 unmodified lines
345344 iavf_add_ethtool_stats(&data, adapter, iavf_gstrings_stats);
346345
347346 rcu_read_lock();
348− /* As num_active_queues describe both tx and rx queues, we can use
349− * it to iterate over rings' stats.
347+ /* Use num_tx_queues to report stats for the maximum number of queues.
348+ * Queues beyond num_active_queues will report zero.
350349 */
351− for (i = 0; i < adapter->num_active_queues; i++) {
352− struct iavf_ring *ring;
350+ for (i = 0; i < netdev->num_tx_queues; i++) {
351+ struct iavf_ring *tx_ring = NULL, *rx_ring = NULL;
353352
354− /* Tx rings stats */
355− ring = &adapter->tx_rings[i];
356− iavf_add_queue_stats(&data, ring);
353+ if (i < adapter->num_active_queues) {
354+ tx_ring = &adapter->tx_rings[i];
355+ rx_ring = &adapter->rx_rings[i];
356+ }
357357
358− /* Rx rings stats */
359− ring = &adapter->rx_rings[i];
360− iavf_add_queue_stats(&data, ring);
358+ iavf_add_queue_stats(&data, tx_ring);
359+ iavf_add_queue_stats(&data, rx_ring);
361360 }
362361 rcu_read_unlock();
363362 }
@@ -376,9 +375,9 @@ static void iavf_get_stat_strings(struct net_device *netdev, u8 *data) · 12 unmodified lines
376375 iavf_add_stat_strings(&data, iavf_gstrings_stats);
377376
378377 /* Queues are always allocated in pairs, so we just use
379− * real_num_tx_queues for both Tx and Rx queues.
378+ * num_tx_queues for both Tx and Rx queues.
380379 */
381− for (i = 0; i < netdev->real_num_tx_queues; i++) {
380+ for (i = 0; i < netdev->num_tx_queues; i++) {
382381 iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,
383382 "tx", i);
384383 iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,
drivers/net/ethernet/intel/ice/ice.h+22−0
@@ -839,6 +839,28 @@ static inline void ice_tx_xsk_pool(struct ice_vsi *vsi, u16 qid) · 838 unmodified lines
839839 WRITE_ONCE(ring->xsk_pool, ice_get_xp_from_qid(vsi, qid));
840840 }
841841
842+/**
843+ * ice_get_max_txq - return the maximum number of Tx queues for in a PF
844+ * @pf: PF structure
845+ *
846+ * Return: maximum number of Tx queues
847+ */
848+static inline int ice_get_max_txq(struct ice_pf *pf)
849+{
850+ return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_txq);
851+}
852+
853+/**
854+ * ice_get_max_rxq - return the maximum number of Rx queues for in a PF
855+ * @pf: PF structure
856+ *
857+ * Return: maximum number of Rx queues
858+ */
859+static inline int ice_get_max_rxq(struct ice_pf *pf)
860+{
861+ return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_rxq);
862+}
863+
842864 /**
843865 * ice_get_main_vsi - Get the PF VSI
844866 * @pf: PF instance
drivers/net/ethernet/intel/ice/ice_ethtool.c+11−21
@@ -1930,6 +1930,17 @@ __ice_get_ethtool_stats(struct net_device *netdev, · 1929 unmodified lines
19301930 int i = 0;
19311931 char *p;
19321932
1933+ if (ice_is_port_repr_netdev(netdev)) {
1934+ ice_update_eth_stats(vsi);
1935+
1936+ for (j = 0; j < ICE_VSI_STATS_LEN; j++) {
1937+ p = (char *)vsi + ice_gstrings_vsi_stats[j].stat_offset;
1938+ data[i++] = (ice_gstrings_vsi_stats[j].sizeof_stat ==
1939+ sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1940+ }
1941+ return;
1942+ }
1943+
19331944 ice_update_pf_stats(pf);
19341945 ice_update_vsi_stats(vsi);
19351946
@@ -1939,9 +1950,6 @@ __ice_get_ethtool_stats(struct net_device *netdev, · 3 unmodified lines
19391950 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
19401951 }
19411952
1942− if (ice_is_port_repr_netdev(netdev))
1943− return;
1944−
19451953 /* populate per queue stats */
19461954 rcu_read_lock();
19471955
@@ -3773,24 +3781,6 @@ ice_get_ts_info(struct net_device *dev, struct kernel_ethtool_ts_info *info) · 1825 unmodified lines
37733781 return 0;
37743782 }
37753783
3776−/**
3777− * ice_get_max_txq - return the maximum number of Tx queues for in a PF
3778− * @pf: PF structure
3779− */
3780−static int ice_get_max_txq(struct ice_pf *pf)
3781−{
3782− return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_txq);
3783−}
3784−
3785−/**
3786− * ice_get_max_rxq - return the maximum number of Rx queues for in a PF
3787− * @pf: PF structure
3788− */
3789−static int ice_get_max_rxq(struct ice_pf *pf)
3790−{
3791− return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_rxq);
3792−}
3793−
37943784 /**
37953785 * ice_get_combined_cnt - return the current number of combined channels
37963786 * @vsi: PF VSI pointer
drivers/net/ethernet/intel/ice/ice_main.c+2−2
@@ -4699,8 +4699,8 @@ static int ice_cfg_netdev(struct ice_vsi *vsi) · 4698 unmodified lines
46994699 struct net_device *netdev;
47004700 u8 mac_addr[ETH_ALEN];
47014701
4702− netdev = alloc_etherdev_mqs(sizeof(*np), vsi->alloc_txq,
4703− vsi->alloc_rxq);
4702+ netdev = alloc_etherdev_mqs(sizeof(*np), ice_get_max_txq(vsi->back),
4703+ ice_get_max_rxq(vsi->back));
47044704 if (!netdev)
47054705 return -ENOMEM;
47064706
drivers/net/ethernet/intel/ice/ice_repr.c+3−2
@@ -2,6 +2,7 @@ · 1 unmodified line
22 /* Copyright (C) 2019-2021, Intel Corporation. */
33
44 #include "ice.h"
5+#include "ice_lib.h"
56 #include "ice_eswitch.h"
67 #include "devlink/devlink.h"
78 #include "devlink/port.h"
@@ -67,7 +68,7 @@ ice_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) · 59 unmodified lines
6768 return;
6869 vsi = repr->src_vsi;
6970
70− ice_update_vsi_stats(vsi);
71+ ice_update_eth_stats(vsi);
7172 eth_stats = &vsi->eth_stats;
7273
7374 stats->tx_packets = eth_stats->tx_unicast + eth_stats->tx_broadcast +
@@ -315,7 +316,7 @@ ice_repr_reg_netdev(struct net_device *netdev, const struct net_device_ops *ops) · 241 unmodified lines
315316
316317 static int ice_repr_ready_vf(struct ice_repr *repr)
317318 {
318− return !ice_check_vf_ready_for_cfg(repr->vf);
319+ return ice_check_vf_ready_for_cfg(repr->vf);
319320 }
320321
321322 static int ice_repr_ready_sf(struct ice_repr *repr)
drivers/net/ethernet/intel/idpf/idpf.h+1−1
@@ -1066,7 +1066,7 @@ bool idpf_vport_set_hsplit(const struct idpf_vport *vport, u8 val); · 1065 unmodified lines
10661066 int idpf_idc_init(struct idpf_adapter *adapter);
10671067 int idpf_idc_init_aux_core_dev(struct idpf_adapter *adapter,
10681068 enum iidc_function_type ftype);
1069−void idpf_idc_deinit_core_aux_device(struct iidc_rdma_core_dev_info *cdev_info);
1069+void idpf_idc_deinit_core_aux_device(struct idpf_adapter *adapter);
10701070 void idpf_idc_deinit_vport_aux_device(struct iidc_rdma_vport_dev_info *vdev_info);
10711071 void idpf_idc_issue_reset_event(struct iidc_rdma_core_dev_info *cdev_info);
10721072 void idpf_idc_vdev_mtu_event(struct iidc_rdma_vport_dev_info *vdev_info,
drivers/net/ethernet/intel/idpf/idpf_idc.c+4−2
@@ -470,10 +470,11 @@ err_privd_alloc: · 469 unmodified lines
470470
471471 /**
472472 * idpf_idc_deinit_core_aux_device - de-initialize Auxiliary Device(s)
473− * @cdev_info: IDC core device info pointer
473+ * @adapter: driver private data structure
474474 */
475−void idpf_idc_deinit_core_aux_device(struct iidc_rdma_core_dev_info *cdev_info)
475+void idpf_idc_deinit_core_aux_device(struct idpf_adapter *adapter)
476476 {
477+ struct iidc_rdma_core_dev_info *cdev_info = adapter->cdev_info;
477478 struct iidc_rdma_priv_dev_info *privd;
478479
479480 if (!cdev_info)
@@ -485,6 +486,7 @@ void idpf_idc_deinit_core_aux_device(struct iidc_rdma_core_dev_info *cdev_info) · 5 unmodified lines
485486 kfree(privd->mapped_mem_regions);
486487 kfree(privd);
487488 kfree(cdev_info);
489+ adapter->cdev_info = NULL;
488490 }
489491
490492 /**
drivers/net/ethernet/intel/idpf/idpf_txrx.c+1−1
@@ -1860,13 +1860,13 @@ static int idpf_rxq_group_alloc(struct idpf_vport *vport, · 1859 unmodified lines
18601860 idpf_queue_assign(HSPLIT_EN, q, hs);
18611861 idpf_queue_assign(RSC_EN, q, rsc);
18621862
1863− bufq_set->num_refillqs = num_rxq;
18641863 bufq_set->refillqs = kcalloc(num_rxq, swq_size,
18651864 GFP_KERNEL);
18661865 if (!bufq_set->refillqs) {
18671866 err = -ENOMEM;
18681867 goto err_alloc;
18691868 }
1869+ bufq_set->num_refillqs = num_rxq;
18701870 for (unsigned int k = 0; k < bufq_set->num_refillqs; k++) {
18711871 struct idpf_sw_queue *refillq =
18721872 &bufq_set->refillqs[k];
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c+1−1
@@ -3668,7 +3668,7 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter) · 3667 unmodified lines
36683668
36693669 idpf_ptp_release(adapter);
36703670 idpf_deinit_task(adapter);
3671− idpf_idc_deinit_core_aux_device(adapter->cdev_info);
3671+ idpf_idc_deinit_core_aux_device(adapter);
36723672 idpf_rel_rx_pt_lkup(adapter);
36733673 idpf_intr_rel(adapter);
36743674
drivers/net/ethernet/microchip/lan743x_main.c+5−0
@@ -3053,6 +3053,11 @@ static void lan743x_phylink_mac_link_up(struct phylink_config *config, · 3052 unmodified lines
30533053 else if (speed == SPEED_100)
30543054 mac_cr |= MAC_CR_CFG_L_;
30553055
3056+ if (duplex == DUPLEX_FULL)
3057+ mac_cr |= MAC_CR_DPX_;
3058+ else
3059+ mac_cr &= ~MAC_CR_DPX_;
3060+
30563061 lan743x_csr_write(adapter, MAC_CR, mac_cr);
30573062
30583063 lan743x_ptp_update_latency(adapter, speed);
drivers/net/ethernet/microsoft/mana/mana_en.c+4−2
@@ -3425,6 +3425,7 @@ static int add_adev(struct gdma_dev *gd, const char *name) · 3424 unmodified lines
34253425 struct auxiliary_device *adev;
34263426 struct mana_adev *madev;
34273427 int ret;
3428+ int id;
34283429
34293430 madev = kzalloc_obj(*madev);
34303431 if (!madev)
@@ -3434,7 +3435,8 @@ static int add_adev(struct gdma_dev *gd, const char *name) · 3 unmodified lines
34343435 ret = mana_adev_idx_alloc();
34353436 if (ret < 0)
34363437 goto idx_fail;
3437− adev->id = ret;
3438+ id = ret;
3439+ adev->id = id;
34383440
34393441 adev->name = name;
34403442 adev->dev.parent = gd->gdma_context->dev;
@@ -3460,7 +3462,7 @@ add_fail: · 19 unmodified lines
34603462 auxiliary_device_uninit(adev);
34613463
34623464 init_fail:
3463− mana_adev_idx_free(adev->id);
3465+ mana_adev_idx_free(id);
34643466
34653467 idx_fail:
34663468 kfree(madev);
drivers/net/ethernet/pensando/ionic/ionic_lif.c+11−6
@@ -1719,13 +1719,18 @@ static int ionic_set_mac_address(struct net_device *netdev, void *sa) · 1718 unmodified lines
17191719 if (ether_addr_equal(netdev->dev_addr, mac))
17201720 return 0;
17211721
1722− err = ionic_program_mac(lif, mac);
1723− if (err < 0)
1724− return err;
1722+ /* Only program macs for virtual functions to avoid losing the permanent
1723+ * Mac across warm reset/reboot.
1724+ */
1725+ if (lif->ionic->pdev->is_virtfn) {
1726+ err = ionic_program_mac(lif, mac);
1727+ if (err < 0)
1728+ return err;
17251729
1726− if (err > 0)
1727− netdev_dbg(netdev, "%s: SET and GET ATTR Mac are not equal-due to old FW running\n",
1728− __func__);
1730+ if (err > 0)
1731+ netdev_dbg(netdev, "%s: SET and GET ATTR Mac are not equal-due to old FW running\n",
1732+ __func__);
1733+ }
17291734
17301735 err = eth_prepare_mac_addr_change(netdev, addr);
17311736 if (err)
drivers/net/ethernet/ti/icssg/icssg_common.c+2−2
@@ -962,7 +962,6 @@ static int emac_rx_packet_zc(struct prueth_emac *emac, u32 flow_id, · 961 unmodified lines
962962 pkt_len -= 4;
963963 cppi5_desc_get_tags_ids(&desc_rx->hdr, &port_id, NULL);
964964 psdata = cppi5_hdesc_get_psdata(desc_rx);
965− k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);
966965 count++;
967966 xsk_buff_set_size(xdp, pkt_len);
968967 xsk_buff_dma_sync_for_cpu(xdp);
@@ -988,6 +987,7 @@ static int emac_rx_packet_zc(struct prueth_emac *emac, u32 flow_id, · 19 unmodified lines
988987 emac_dispatch_skb_zc(emac, xdp, psdata);
989988 xsk_buff_free(xdp);
990989 }
990+ k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);
991991 }
992992
993993 if (xdp_status & ICSSG_XDP_REDIR)
@@ -1057,7 +1057,6 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id, u32 *xdp_state) · 63 unmodified lines
10571057 /* firmware adds 4 CRC bytes, strip them */
10581058 pkt_len -= 4;
10591059 cppi5_desc_get_tags_ids(&desc_rx->hdr, &port_id, NULL);
1060− k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);
10611060
10621061 /* if allocation fails we drop the packet but push the
10631062 * descriptor back to the ring with old page to prevent a stall
@@ -1115,6 +1114,7 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id, u32 *xdp_state) · 51 unmodified lines
11151114 ndev->stats.rx_packets++;
11161115
11171116 requeue:
1117+ k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);
11181118 /* queue another RX DMA */
11191119 ret = prueth_dma_rx_push_mapped(emac, &emac->rx_chns, new_page,
11201120 PRUETH_MAX_PKT_SIZE);
drivers/net/team/team_core.c+64−1
@@ -2058,6 +2058,68 @@ static const struct ethtool_ops team_ethtool_ops = { · 2057 unmodified lines
20582058 * rt netlink interface
20592059 ***********************/
20602060
2061+/* For tx path we need a linkup && enabled port and for parse any port
2062+ * suffices.
2063+ */
2064+static struct team_port *team_header_port_get_rcu(struct team *team,
2065+ bool txable)
2066+{
2067+ struct team_port *port;
2068+
2069+ list_for_each_entry_rcu(port, &team->port_list, list) {
2070+ if (!txable || team_port_txable(port))
2071+ return port;
2072+ }
2073+
2074+ return NULL;
2075+}
2076+
2077+static int team_header_create(struct sk_buff *skb, struct net_device *team_dev,
2078+ unsigned short type, const void *daddr,
2079+ const void *saddr, unsigned int len)
2080+{
2081+ struct team *team = netdev_priv(team_dev);
2082+ const struct header_ops *port_ops;
2083+ struct team_port *port;
2084+ int ret = 0;
2085+
2086+ rcu_read_lock();
2087+ port = team_header_port_get_rcu(team, true);
2088+ if (port) {
2089+ port_ops = READ_ONCE(port->dev->header_ops);
2090+ if (port_ops && port_ops->create)
2091+ ret = port_ops->create(skb, port->dev,
2092+ type, daddr, saddr, len);
2093+ }
2094+ rcu_read_unlock();
2095+ return ret;
2096+}
2097+
2098+static int team_header_parse(const struct sk_buff *skb,
2099+ const struct net_device *team_dev,
2100+ unsigned char *haddr)
2101+{
2102+ struct team *team = netdev_priv(team_dev);
2103+ const struct header_ops *port_ops;
2104+ struct team_port *port;
2105+ int ret = 0;
2106+
2107+ rcu_read_lock();
2108+ port = team_header_port_get_rcu(team, false);
2109+ if (port) {
2110+ port_ops = READ_ONCE(port->dev->header_ops);
2111+ if (port_ops && port_ops->parse)
2112+ ret = port_ops->parse(skb, port->dev, haddr);
2113+ }
2114+ rcu_read_unlock();
2115+ return ret;
2116+}
2117+
2118+static const struct header_ops team_header_ops = {
2119+ .create = team_header_create,
2120+ .parse = team_header_parse,
2121+};
2122+
20612123 static void team_setup_by_port(struct net_device *dev,
20622124 struct net_device *port_dev)
20632125 {
@@ -2066,7 +2128,8 @@ static void team_setup_by_port(struct net_device *dev, · 2 unmodified lines
20662128 if (port_dev->type == ARPHRD_ETHER)
20672129 dev->header_ops = team->header_ops_cache;
20682130 else
2069− dev->header_ops = port_dev->header_ops;
2131+ dev->header_ops = port_dev->header_ops ?
2132+ &team_header_ops : NULL;
20702133 dev->type = port_dev->type;
20712134 dev->hard_header_len = port_dev->hard_header_len;
20722135 dev->needed_headroom = port_dev->needed_headroom;
drivers/net/tun_vnet.h+1−1
@@ -244,7 +244,7 @@ tun_vnet_hdr_tnl_from_skb(unsigned int flags, · 243 unmodified lines
244244
245245 if (virtio_net_hdr_tnl_from_skb(skb, tnl_hdr, has_tnl_offload,
246246 tun_vnet_is_little_endian(flags),
247− vlan_hlen, true)) {
247+ vlan_hlen, true, false)) {
248248 struct virtio_net_hdr_v1 *hdr = &tnl_hdr->hash_hdr.hdr;
249249 struct skb_shared_info *sinfo = skb_shinfo(skb);
250250
drivers/net/virtio_net.c+6−1
@@ -3267,8 +3267,12 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb, bool orphan) · 3266 unmodified lines
32673267 struct virtio_net_hdr_v1_hash_tunnel *hdr;
32683268 int num_sg;
32693269 unsigned hdr_len = vi->hdr_len;
3270+ bool feature_hdrlen;
32703271 bool can_push;
32713272
3273+ feature_hdrlen = virtio_has_feature(vi->vdev,
3274+ VIRTIO_NET_F_GUEST_HDRLEN);
3275+
32723276 pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest);
32733277
32743278 /* Make sure it's safe to cast between formats */
@@ -3288,7 +3292,7 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb, bool orphan) · 13 unmodified lines
32883292
32893293 if (virtio_net_hdr_tnl_from_skb(skb, hdr, vi->tx_tnl,
32903294 virtio_is_little_endian(vi->vdev), 0,
3291− false))
3295+ false, feature_hdrlen))
32923296 return -EPROTO;
32933297
32943298 if (vi->mergeable_rx_bufs)
@@ -3351,6 +3355,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) · 56 unmodified lines
33513355 /* Don't wait up for transmitted skbs to be freed. */
33523356 if (!use_napi) {
33533357 skb_orphan(skb);
3358+ skb_dst_drop(skb);
33543359 nf_reset_ct(skb);
33553360 }
33563361
drivers/pci/pwrctrl/core.c+3−1
@@ -299,8 +299,10 @@ static bool pci_pwrctrl_is_required(struct device_node *np) · 298 unmodified lines
299299 struct device_node *remote __free(device_node) =
300300 of_graph_get_remote_port_parent(endpoint);
301301 if (remote) {
302− if (of_pci_supply_present(remote))
302+ if (of_pci_supply_present(remote)) {
303+ of_node_put(endpoint);
303304 return true;
305+ }
304306 }
305307 }
306308 }
drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c+0−12
@@ -68,13 +68,6 @@ static int pwrseq_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl) · 67 unmodified lines
6868 return pwrseq_power_off(pwrseq->pwrseq);
6969 }
7070
71−static void devm_pwrseq_pwrctrl_power_off(void *data)
72−{
73− struct pwrseq_pwrctrl *pwrseq = data;
74−
75− pwrseq_pwrctrl_power_off(&pwrseq->pwrctrl);
76−}
77−
7871 static int pwrseq_pwrctrl_probe(struct platform_device *pdev)
7972 {
8073 const struct pwrseq_pwrctrl_pdata *pdata;
@@ -101,11 +94,6 @@ static int pwrseq_pwrctrl_probe(struct platform_device *pdev) · 20 unmodified lines
10194 return dev_err_probe(dev, PTR_ERR(pwrseq->pwrseq),
10295 "Failed to get the power sequencer\n");
10396
104− ret = devm_add_action_or_reset(dev, devm_pwrseq_pwrctrl_power_off,
105− pwrseq);
106− if (ret)
107− return ret;
108−
10997 pwrseq->pwrctrl.power_on = pwrseq_pwrctrl_power_on;
11098 pwrseq->pwrctrl.power_off = pwrseq_pwrctrl_power_off;
11199
drivers/pci/pwrctrl/slot.c+0−1
@@ -63,7 +63,6 @@ static void devm_slot_pwrctrl_release(void *data) · 62 unmodified lines
6363 {
6464 struct slot_pwrctrl *slot = data;
6565
66− slot_pwrctrl_power_off(&slot->pwrctrl);
6766 regulator_bulk_free(slot->num_supplies, slot->supplies);
6867 }
6968
drivers/phy/Kconfig+2−3
@@ -6,7 +6,7 @@ · 5 unmodified lines
66 menu "PHY Subsystem"
77
88 config PHY_COMMON_PROPS
9− bool
9+ bool "PHY common properties" if KUNIT_ALL_TESTS
1010 help
1111 This parses properties common between generic PHYs and Ethernet PHYs.
1212
@@ -16,8 +16,7 @@ config PHY_COMMON_PROPS · 3 unmodified lines
1616
1717 config PHY_COMMON_PROPS_TEST
1818 tristate "KUnit tests for PHY common props" if !KUNIT_ALL_TESTS
19− select PHY_COMMON_PROPS
20− depends on KUNIT
19+ depends on KUNIT && PHY_COMMON_PROPS
2120 default KUNIT_ALL_TESTS
2221 help
2322 This builds KUnit tests for the PHY common property API.
drivers/phy/freescale/phy-fsl-lynx-28g.c+2−0
@@ -1069,6 +1069,8 @@ static void lynx_28g_cdr_lock_check(struct work_struct *work) · 1068 unmodified lines
10691069
10701070 for (i = 0; i < LYNX_28G_NUM_LANE; i++) {
10711071 lane = &priv->lane[i];
1072+ if (!lane->phy)
1073+ continue;
10721074
10731075 mutex_lock(&lane->phy->mutex);
10741076
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c+1−2
@@ -990,6 +990,7 @@ static const struct qmp_phy_init_tbl sm8650_ufsphy_pcs[] = { · 989 unmodified lines
990990 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_MULTI_LANE_CTRL1, 0x02),
991991 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_MID_TERM_CTRL1, 0x43),
992992 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_PCS_CTRL1, 0xc1),
993+ QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_PLL_CNTL, 0x33),
993994 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_LARGE_AMP_DRV_LVL, 0x0f),
994995 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_RX_SIGDET_CTRL2, 0x68),
995996 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_POST_EMP_LVL_S4, 0x0e),
@@ -999,13 +1000,11 @@ static const struct qmp_phy_init_tbl sm8650_ufsphy_pcs[] = { · 3 unmodified lines
9991000 };
10001001
10011002 static const struct qmp_phy_init_tbl sm8650_ufsphy_g4_pcs[] = {
1002− QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_PLL_CNTL, 0x13),
10031003 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_HSGEAR_CAPABILITY, 0x04),
10041004 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_RX_HSGEAR_CAPABILITY, 0x04),
10051005 };
10061006
10071007 static const struct qmp_phy_init_tbl sm8650_ufsphy_g5_pcs[] = {
1008− QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_PLL_CNTL, 0x33),
10091008 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_HSGEAR_CAPABILITY, 0x05),
10101009 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_RX_HSGEAR_CAPABILITY, 0x05),
10111010 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_RX_HS_G5_SYNC_LENGTH_CAPABILITY, 0x4d),
drivers/phy/spacemit/phy-k1-usb2.c+14−0
@@ -48,6 +48,9 @@ · 47 unmodified lines
4848 #define PHY_CLK_HSTXP_EN BIT(3) /* clock hstxp enable */
4949 #define PHY_HSTXP_MODE BIT(4) /* 0: force en_txp to be 1; 1: no force */
5050
51+#define PHY_K1_HS_HOST_DISC 0x40
52+#define PHY_K1_HS_HOST_DISC_CLR BIT(0)
53+
5154 #define PHY_PLL_DIV_CFG 0x98
5255 #define PHY_FDIV_FRACT_8_15 GENMASK(7, 0)
5356 #define PHY_FDIV_FRACT_16_19 GENMASK(11, 8)
@@ -142,9 +145,20 @@ static int spacemit_usb2phy_exit(struct phy *phy) · 88 unmodified lines
142145 return 0;
143146 }
144147
148+static int spacemit_usb2phy_disconnect(struct phy *phy, int port)
149+{
150+ struct spacemit_usb2phy *sphy = phy_get_drvdata(phy);
151+
152+ regmap_update_bits(sphy->regmap_base, PHY_K1_HS_HOST_DISC,
153+ PHY_K1_HS_HOST_DISC_CLR, PHY_K1_HS_HOST_DISC_CLR);
154+
155+ return 0;
156+}
157+
145158 static const struct phy_ops spacemit_usb2phy_ops = {
146159 .init = spacemit_usb2phy_init,
147160 .exit = spacemit_usb2phy_exit,
161+ .disconnect = spacemit_usb2phy_disconnect,
148162 .owner = THIS_MODULE,
149163 };
150164
drivers/phy/ti/phy-j721e-wiz.c+2−0
@@ -1425,6 +1425,7 @@ static int wiz_get_lane_phy_types(struct device *dev, struct wiz *wiz) · 1424 unmodified lines
14251425 dev_err(dev,
14261426 "%s: Reading \"reg\" from \"%s\" failed: %d\n",
14271427 __func__, subnode->name, ret);
1428+ of_node_put(serdes);
14281429 return ret;
14291430 }
14301431 of_property_read_u32(subnode, "cdns,num-lanes", &num_lanes);
@@ -1439,6 +1440,7 @@ static int wiz_get_lane_phy_types(struct device *dev, struct wiz *wiz) · 8 unmodified lines
14391440 }
14401441 }
14411442
1443+ of_node_put(serdes);
14421444 return 0;
14431445 }
14441446
drivers/pinctrl/mediatek/pinctrl-mtk-common.c+6−3
@@ -1135,9 +1135,12 @@ int mtk_pctrl_init(struct platform_device *pdev, · 1134 unmodified lines
11351135 goto chip_error;
11361136 }
11371137
1138− ret = mtk_eint_init(pctl, pdev);
1139− if (ret)
1140− goto chip_error;
1138+ /* Only initialize EINT if we have EINT pins */
1139+ if (data->eint_hw.ap_num > 0) {
1140+ ret = mtk_eint_init(pctl, pdev);
1141+ if (ret)
1142+ goto chip_error;
1143+ }
11411144
11421145 return 0;
11431146
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c+16−0
@@ -723,6 +723,21 @@ static const struct pinconf_ops pmic_gpio_pinconf_ops = { · 722 unmodified lines
723723 .pin_config_group_dbg_show = pmic_gpio_config_dbg_show,
724724 };
725725
726+static int pmic_gpio_get_direction(struct gpio_chip *chip, unsigned pin)
727+{
728+ struct pmic_gpio_state *state = gpiochip_get_data(chip);
729+ struct pmic_gpio_pad *pad;
730+
731+ pad = state->ctrl->desc->pins[pin].drv_data;
732+
733+ if (!pad->is_enabled || pad->analog_pass ||
734+ (!pad->input_enabled && !pad->output_enabled))
735+ return -EINVAL;
736+
737+ /* Make sure the state is aligned on what pmic_gpio_get() returns */
738+ return pad->input_enabled ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
739+}
740+
726741 static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
727742 {
728743 struct pmic_gpio_state *state = gpiochip_get_data(chip);
@@ -801,6 +816,7 @@ static void pmic_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) · 72 unmodified lines
801816 }
802817
803818 static const struct gpio_chip pmic_gpio_gpio_template = {
819+ .get_direction = pmic_gpio_get_direction,
804820 .direction_input = pmic_gpio_direction_input,
805821 .direction_output = pmic_gpio_direction_output,
806822 .get = pmic_gpio_get,
drivers/pinctrl/renesas/pinctrl-rza1.c+1−1
@@ -589,7 +589,7 @@ static inline unsigned int rza1_get_bit(struct rza1_port *port, · 588 unmodified lines
589589 {
590590 void __iomem *mem = RZA1_ADDR(port->base, reg, port->id);
591591
592− return ioread16(mem) & BIT(bit);
592+ return !!(ioread16(mem) & BIT(bit));
593593 }
594594
595595 /**
drivers/pinctrl/renesas/pinctrl-rzt2h.c+8−7
@@ -85,7 +85,7 @@ struct rzt2h_pinctrl { · 84 unmodified lines
8585 struct gpio_chip gpio_chip;
8686 struct pinctrl_gpio_range gpio_range;
8787 DECLARE_BITMAP(used_irqs, RZT2H_INTERRUPTS_NUM);
88− spinlock_t lock; /* lock read/write registers */
88+ raw_spinlock_t lock; /* lock read/write registers */
8989 struct mutex mutex; /* serialize adding groups and functions */
9090 bool safety_port_enabled;
9191 atomic_t wakeup_path;
@@ -145,7 +145,7 @@ static void rzt2h_pinctrl_set_pfc_mode(struct rzt2h_pinctrl *pctrl, · 53 unmodified lines
145145 u64 reg64;
146146 u16 reg16;
147147
148− guard(spinlock_irqsave)(&pctrl->lock);
148+ guard(raw_spinlock_irqsave)(&pctrl->lock);
149149
150150 /* Set pin to 'Non-use (Hi-Z input protection)' */
151151 reg16 = rzt2h_pinctrl_readw(pctrl, port, PM(port));
@@ -474,7 +474,7 @@ static int rzt2h_gpio_request(struct gpio_chip *chip, unsigned int offset) · 322 unmodified lines
474474 if (ret)
475475 return ret;
476476
477− guard(spinlock_irqsave)(&pctrl->lock);
477+ guard(raw_spinlock_irqsave)(&pctrl->lock);
478478
479479 /* Select GPIO mode in PMC Register */
480480 rzt2h_pinctrl_set_gpio_en(pctrl, port, bit, true);
@@ -487,7 +487,7 @@ static void rzt2h_gpio_set_direction(struct rzt2h_pinctrl *pctrl, u32 port, · 6 unmodified lines
487487 {
488488 u16 reg;
489489
490− guard(spinlock_irqsave)(&pctrl->lock);
490+ guard(raw_spinlock_irqsave)(&pctrl->lock);
491491
492492 reg = rzt2h_pinctrl_readw(pctrl, port, PM(port));
493493 reg &= ~PM_PIN_MASK(bit);
@@ -509,7 +509,7 @@ static int rzt2h_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) · 15 unmodified lines
509509 if (ret)
510510 return ret;
511511
512− guard(spinlock_irqsave)(&pctrl->lock);
512+ guard(raw_spinlock_irqsave)(&pctrl->lock);
513513
514514 if (rzt2h_pinctrl_readb(pctrl, port, PMC(port)) & BIT(bit)) {
515515 /*
@@ -547,7 +547,7 @@ static int rzt2h_gpio_set(struct gpio_chip *chip, unsigned int offset, · 31 unmodified lines
547547 u8 bit = RZT2H_PIN_ID_TO_PIN(offset);
548548 u8 reg;
549549
550− guard(spinlock_irqsave)(&pctrl->lock);
550+ guard(raw_spinlock_irqsave)(&pctrl->lock);
551551
552552 reg = rzt2h_pinctrl_readb(pctrl, port, P(port));
553553 if (value)
@@ -833,6 +833,7 @@ static int rzt2h_gpio_register(struct rzt2h_pinctrl *pctrl) · 279 unmodified lines
833833 if (ret)
834834 return dev_err_probe(dev, ret, "Unable to parse gpio-ranges\n");
835835
836+ of_node_put(of_args.np);
836837 if (of_args.args[0] != 0 || of_args.args[1] != 0 ||
837838 of_args.args[2] != pctrl->data->n_port_pins)
838839 return dev_err_probe(dev, -EINVAL,
@@ -964,7 +965,7 @@ static int rzt2h_pinctrl_probe(struct platform_device *pdev) · 125 unmodified lines
964965 if (ret)
965966 return ret;
966967
967− spin_lock_init(&pctrl->lock);
968+ raw_spin_lock_init(&pctrl->lock);
968969 mutex_init(&pctrl->mutex);
969970 platform_set_drvdata(pdev, pctrl);
970971
drivers/pinctrl/stm32/Kconfig+1−0
@@ -65,6 +65,7 @@ config PINCTRL_STM32_HDP · 64 unmodified lines
6565 select PINMUX
6666 select GENERIC_PINCONF
6767 select GPIOLIB
68+ select GPIO_GENERIC
6869 help
6970 The Hardware Debug Port allows the observation of internal signals.
7071 It uses configurable multiplexer to route signals in a dedicated observation register.
drivers/pinctrl/sunxi/pinctrl-sunxi.c+32−11
@@ -157,6 +157,7 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl, · 156 unmodified lines
157157 const char *pin_name,
158158 const char *func_name)
159159 {
160+ unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
160161 int i;
161162
162163 for (i = 0; i < pctl->desc->npins; i++) {
@@ -168,7 +169,7 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl, · 5 unmodified lines
168169 while (func->name) {
169170 if (!strcmp(func->name, func_name) &&
170171 (!func->variant ||
171− func->variant & pctl->variant))
172+ func->variant & variant))
172173 return func;
173174
174175 func++;
@@ -209,6 +210,8 @@ sunxi_pinctrl_desc_find_function_by_pin_and_mux(struct sunxi_pinctrl *pctl, · 34 unmodified lines
209210 const u16 pin_num,
210211 const u8 muxval)
211212 {
213+ unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
214+
212215 for (unsigned int i = 0; i < pctl->desc->npins; i++) {
213216 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
214217 struct sunxi_desc_function *func = pin->functions;
@@ -216,7 +219,7 @@ sunxi_pinctrl_desc_find_function_by_pin_and_mux(struct sunxi_pinctrl *pctl, · 1 unmodified line
216219 if (pin->pin.number != pin_num)
217220 continue;
218221
219− if (pin->variant && !(pctl->variant & pin->variant))
222+ if (pin->variant && !(variant & pin->variant))
220223 continue;
221224
222225 while (func->name) {
@@ -1089,6 +1092,9 @@ static int sunxi_pinctrl_irq_request_resources(struct irq_data *d) · 866 unmodified lines
10891092 {
10901093 struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
10911094 struct sunxi_desc_function *func;
1095+ unsigned int offset;
1096+ u32 reg, shift, mask;
1097+ u8 disabled_mux, muxval;
10921098 int ret;
10931099
10941100 func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
@@ -1096,8 +1102,21 @@ static int sunxi_pinctrl_irq_request_resources(struct irq_data *d) · 1 unmodified line
10961102 if (!func)
10971103 return -EINVAL;
10981104
1099− ret = gpiochip_lock_as_irq(pctl->chip,
1100− pctl->irq_array[d->hwirq] - pctl->desc->pin_base);
1105+ offset = pctl->irq_array[d->hwirq] - pctl->desc->pin_base;
1106+ sunxi_mux_reg(pctl, offset, &reg, &shift, &mask);
1107+ muxval = (readl(pctl->membase + reg) & mask) >> shift;
1108+
1109+ /* Change muxing to GPIO INPUT mode if at reset value */
1110+ if (pctl->flags & SUNXI_PINCTRL_NEW_REG_LAYOUT)
1111+ disabled_mux = SUN4I_FUNC_DISABLED_NEW;
1112+ else
1113+ disabled_mux = SUN4I_FUNC_DISABLED_OLD;
1114+
1115+ if (muxval == disabled_mux)
1116+ sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq],
1117+ SUN4I_FUNC_INPUT);
1118+
1119+ ret = gpiochip_lock_as_irq(pctl->chip, offset);
11011120 if (ret) {
11021121 dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n",
11031122 irqd_to_hwirq(d));
@@ -1338,6 +1357,7 @@ static int sunxi_pinctrl_add_function(struct sunxi_pinctrl *pctl, · 234 unmodified lines
13381357 static int sunxi_pinctrl_build_state(struct platform_device *pdev)
13391358 {
13401359 struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);
1360+ unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
13411361 void *ptr;
13421362 int i;
13431363
@@ -1362,7 +1382,7 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) · 18 unmodified lines
13621382 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
13631383 struct sunxi_pinctrl_group *group = pctl->groups + pctl->ngroups;
13641384
1365− if (pin->variant && !(pctl->variant & pin->variant))
1385+ if (pin->variant && !(variant & pin->variant))
13661386 continue;
13671387
13681388 group->name = pin->pin.name;
@@ -1387,11 +1407,11 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) · 18 unmodified lines
13871407 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
13881408 struct sunxi_desc_function *func;
13891409
1390− if (pin->variant && !(pctl->variant & pin->variant))
1410+ if (pin->variant && !(variant & pin->variant))
13911411 continue;
13921412
13931413 for (func = pin->functions; func->name; func++) {
1394− if (func->variant && !(pctl->variant & func->variant))
1414+ if (func->variant && !(variant & func->variant))
13951415 continue;
13961416
13971417 /* Create interrupt mapping while we're at it */
@@ -1419,14 +1439,14 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) · 21 unmodified lines
14191439 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
14201440 struct sunxi_desc_function *func;
14211441
1422− if (pin->variant && !(pctl->variant & pin->variant))
1442+ if (pin->variant && !(variant & pin->variant))
14231443 continue;
14241444
14251445 for (func = pin->functions; func->name; func++) {
14261446 struct sunxi_pinctrl_function *func_item;
14271447 const char **func_grp;
14281448
1429− if (func->variant && !(pctl->variant & func->variant))
1449+ if (func->variant && !(variant & func->variant))
14301450 continue;
14311451
14321452 func_item = sunxi_pinctrl_find_function_by_name(pctl,
@@ -1568,7 +1588,7 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, · 135 unmodified lines
15681588
15691589 pctl->dev = &pdev->dev;
15701590 pctl->desc = desc;
1571− pctl->variant = flags & SUNXI_PINCTRL_VARIANT_MASK;
1591+ pctl->flags = flags;
15721592 if (flags & SUNXI_PINCTRL_NEW_REG_LAYOUT) {
15731593 pctl->bank_mem_size = D1_BANK_MEM_SIZE;
15741594 pctl->pull_regs_offset = D1_PULL_REGS_OFFSET;
@@ -1604,8 +1624,9 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, · 29 unmodified lines
16041624
16051625 for (i = 0, pin_idx = 0; i < pctl->desc->npins; i++) {
16061626 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
1627+ unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
16071628
1608− if (pin->variant && !(pctl->variant & pin->variant))
1629+ if (pin->variant && !(variant & pin->variant))
16091630 continue;
16101631
16111632 pins[pin_idx++] = pin->pin;
drivers/pinctrl/sunxi/pinctrl-sunxi.h+3−1
@@ -86,6 +86,8 @@ · 85 unmodified lines
8686
8787 #define SUN4I_FUNC_INPUT 0
8888 #define SUN4I_FUNC_IRQ 6
89+#define SUN4I_FUNC_DISABLED_OLD 7
90+#define SUN4I_FUNC_DISABLED_NEW 15
8991
9092 #define SUNXI_PINCTRL_VARIANT_MASK GENMASK(7, 0)
9193 #define SUNXI_PINCTRL_NEW_REG_LAYOUT BIT(8)
@@ -174,7 +176,7 @@ struct sunxi_pinctrl { · 82 unmodified lines
174176 unsigned *irq_array;
175177 raw_spinlock_t lock;
176178 struct pinctrl_dev *pctl_dev;
177− unsigned long variant;
179+ unsigned long flags;
178180 u32 bank_mem_size;
179181 u32 pull_regs_offset;
180182 u32 dlevel_field_width;
drivers/platform/olpc/olpc-xo175-ec.c+1−1
@@ -482,7 +482,7 @@ static int olpc_xo175_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *resp, · 481 unmodified lines
482482 dev_dbg(dev, "CMD %x, %zd bytes expected\n", cmd, resp_len);
483483
484484 if (inlen > 5) {
485− dev_err(dev, "command len %zd too big!\n", resp_len);
485+ dev_err(dev, "command len %zd too big!\n", inlen);
486486 return -EOVERFLOW;
487487 }
488488
drivers/platform/x86/amd/hsmp/hsmp.c+1−1
@@ -117,7 +117,7 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms · 116 unmodified lines
117117 }
118118
119119 if (unlikely(mbox_status == HSMP_STATUS_NOT_READY)) {
120− dev_err(sock->dev, "Message ID 0x%X failure : SMU tmeout (status = 0x%X)\n",
120+ dev_err(sock->dev, "Message ID 0x%X failure : SMU timeout (status = 0x%X)\n",
121121 msg->msg_id, mbox_status);
122122 return -ETIMEDOUT;
123123 } else if (unlikely(mbox_status == HSMP_ERR_INVALID_MSG)) {
drivers/platform/x86/asus-armoury.h+77−0
@@ -1080,6 +1080,20 @@ static const struct dmi_system_id power_limits[] = { · 1079 unmodified lines
10801080 .requires_fan_curve = true,
10811081 },
10821082 },
1083+ {
1084+ .matches = {
1085+ DMI_MATCH(DMI_BOARD_NAME, "GA503QM"),
1086+ },
1087+ .driver_data = &(struct power_data) {
1088+ .ac_data = &(struct power_limits) {
1089+ .ppt_pl1_spl_min = 15,
1090+ .ppt_pl1_spl_def = 35,
1091+ .ppt_pl1_spl_max = 80,
1092+ .ppt_pl2_sppt_min = 65,
1093+ .ppt_pl2_sppt_max = 80,
1094+ },
1095+ },
1096+ },
10831097 {
10841098 .matches = {
10851099 DMI_MATCH(DMI_BOARD_NAME, "GA503QR"),
@@ -1518,6 +1532,35 @@ static const struct dmi_system_id power_limits[] = { · 432 unmodified lines
15181532 },
15191533 },
15201534 },
1535+ {
1536+ .matches = {
1537+ DMI_MATCH(DMI_BOARD_NAME, "GZ302EA"),
1538+ },
1539+ .driver_data = &(struct power_data) {
1540+ .ac_data = &(struct power_limits) {
1541+ .ppt_pl1_spl_min = 28,
1542+ .ppt_pl1_spl_def = 60,
1543+ .ppt_pl1_spl_max = 80,
1544+ .ppt_pl2_sppt_min = 32,
1545+ .ppt_pl2_sppt_def = 75,
1546+ .ppt_pl2_sppt_max = 92,
1547+ .ppt_pl3_fppt_min = 45,
1548+ .ppt_pl3_fppt_def = 86,
1549+ .ppt_pl3_fppt_max = 93,
1550+ },
1551+ .dc_data = &(struct power_limits) {
1552+ .ppt_pl1_spl_min = 28,
1553+ .ppt_pl1_spl_def = 45,
1554+ .ppt_pl1_spl_max = 80,
1555+ .ppt_pl2_sppt_min = 32,
1556+ .ppt_pl2_sppt_def = 52,
1557+ .ppt_pl2_sppt_max = 92,
1558+ .ppt_pl3_fppt_min = 45,
1559+ .ppt_pl3_fppt_def = 71,
1560+ .ppt_pl3_fppt_max = 93,
1561+ },
1562+ },
1563+ },
15211564 {
15221565 .matches = {
15231566 DMI_MATCH(DMI_BOARD_NAME, "G513I"),
@@ -1596,6 +1639,40 @@ static const struct dmi_system_id power_limits[] = { · 72 unmodified lines
15961639 .requires_fan_curve = true,
15971640 },
15981641 },
1642+ {
1643+ .matches = {
1644+ DMI_MATCH(DMI_BOARD_NAME, "G614FP"),
1645+ },
1646+ .driver_data = &(struct power_data) {
1647+ .ac_data = &(struct power_limits) {
1648+ .ppt_pl1_spl_min = 30,
1649+ .ppt_pl1_spl_max = 120,
1650+ .ppt_pl2_sppt_min = 65,
1651+ .ppt_pl2_sppt_def = 140,
1652+ .ppt_pl2_sppt_max = 165,
1653+ .ppt_pl3_fppt_min = 65,
1654+ .ppt_pl3_fppt_def = 140,
1655+ .ppt_pl3_fppt_max = 165,
1656+ .nv_temp_target_min = 75,
1657+ .nv_temp_target_max = 87,
1658+ .nv_dynamic_boost_min = 5,
1659+ .nv_dynamic_boost_max = 15,
1660+ .nv_tgp_min = 50,
1661+ .nv_tgp_max = 100,
1662+ },
1663+ .dc_data = &(struct power_limits) {
1664+ .ppt_pl1_spl_min = 25,
1665+ .ppt_pl1_spl_max = 65,
1666+ .ppt_pl2_sppt_min = 25,
1667+ .ppt_pl2_sppt_max = 65,
1668+ .ppt_pl3_fppt_min = 35,
1669+ .ppt_pl3_fppt_max = 75,
1670+ .nv_temp_target_min = 75,
1671+ .nv_temp_target_max = 87,
1672+ },
1673+ .requires_fan_curve = true,
1674+ },
1675+ },
15991676 {
16001677 .matches = {
16011678 DMI_MATCH(DMI_BOARD_NAME, "G614J"),
drivers/platform/x86/asus-nb-wmi.c+1−1
@@ -548,7 +548,7 @@ static const struct dmi_system_id asus_quirks[] = { · 547 unmodified lines
548548 .callback = dmi_matched,
549549 .ident = "ASUS ROG Z13",
550550 .matches = {
551− DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
551+ DMI_MATCH(DMI_SYS_VENDOR, "ASUS"),
552552 DMI_MATCH(DMI_PRODUCT_NAME, "ROG Flow Z13"),
553553 },
554554 .driver_data = &quirk_asus_z13,
drivers/platform/x86/hp/hp-wmi.c+19−0
@@ -120,6 +120,13 @@ static const struct thermal_profile_params omen_v1_thermal_params = { · 119 unmodified lines
120120 .ec_tp_offset = HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET,
121121 };
122122
123+static const struct thermal_profile_params omen_v1_legacy_thermal_params = {
124+ .performance = HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE,
125+ .balanced = HP_OMEN_V1_THERMAL_PROFILE_DEFAULT,
126+ .low_power = HP_OMEN_V1_THERMAL_PROFILE_DEFAULT,
127+ .ec_tp_offset = HP_OMEN_EC_THERMAL_PROFILE_OFFSET,
128+};
129+
123130 /*
124131 * A generic pointer for the currently-active board's thermal profile
125132 * parameters.
@@ -175,6 +182,10 @@ static const char * const victus_thermal_profile_boards[] = { · 49 unmodified lines
175182
176183 /* DMI Board names of Victus 16-r and Victus 16-s laptops */
177184 static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst = {
185+ {
186+ .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A4D") },
187+ .driver_data = (void *)&omen_v1_legacy_thermal_params,
188+ },
178189 {
179190 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BAB") },
180191 .driver_data = (void *)&omen_v1_thermal_params,
@@ -183,6 +194,10 @@ static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst · 2 unmodified lines
183194 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BBE") },
184195 .driver_data = (void *)&victus_s_thermal_params,
185196 },
197+ {
198+ .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCA") },
199+ .driver_data = (void *)&omen_v1_thermal_params,
200+ },
186201 {
187202 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCD") },
188203 .driver_data = (void *)&omen_v1_thermal_params,
@@ -195,6 +210,10 @@ static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst · 6 unmodified lines
195210 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD5") },
196211 .driver_data = (void *)&victus_s_thermal_params,
197212 },
213+ {
214+ .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C76") },
215+ .driver_data = (void *)&omen_v1_thermal_params,
216+ },
198217 {
199218 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") },
200219 .driver_data = (void *)&omen_v1_thermal_params,
drivers/platform/x86/intel/hid.c+9−1
@@ -438,6 +438,14 @@ static int intel_hid_pl_suspend_handler(struct device *device) · 437 unmodified lines
438438 return 0;
439439 }
440440
441+static int intel_hid_pl_freeze_handler(struct device *device)
442+{
443+ struct intel_hid_priv *priv = dev_get_drvdata(device);
444+
445+ priv->wakeup_mode = false;
446+ return intel_hid_pl_suspend_handler(device);
447+}
448+
441449 static int intel_hid_pl_resume_handler(struct device *device)
442450 {
443451 intel_hid_pm_complete(device);
@@ -452,7 +460,7 @@ static int intel_hid_pl_resume_handler(struct device *device) · 8 unmodified lines
452460 static const struct dev_pm_ops intel_hid_pl_pm_ops = {
453461 .prepare = intel_hid_pm_prepare,
454462 .complete = intel_hid_pm_complete,
455− .freeze = intel_hid_pl_suspend_handler,
463+ .freeze = intel_hid_pl_freeze_handler,
456464 .thaw = intel_hid_pl_resume_handler,
457465 .restore = intel_hid_pl_resume_handler,
458466 .suspend = intel_hid_pl_suspend_handler,
drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c+4−1
@@ -558,6 +558,9 @@ static bool disable_dynamic_sst_features(void) · 557 unmodified lines
558558 {
559559 u64 value;
560560
561+ if (!static_cpu_has(X86_FEATURE_HWP))
562+ return true;
563+
561564 rdmsrq(MSR_PM_ENABLE, value);
562565 return !(value & 0x1);
563566 }
@@ -869,7 +872,7 @@ static int isst_if_get_perf_level(void __user *argp) · 305 unmodified lines
869872 _read_pp_info("current_level", perf_level.current_level, SST_PP_STATUS_OFFSET,
870873 SST_PP_LEVEL_START, SST_PP_LEVEL_WIDTH, SST_MUL_FACTOR_NONE)
871874 _read_pp_info("locked", perf_level.locked, SST_PP_STATUS_OFFSET,
872− SST_PP_LOCK_START, SST_PP_LEVEL_WIDTH, SST_MUL_FACTOR_NONE)
875+ SST_PP_LOCK_START, SST_PP_LOCK_WIDTH, SST_MUL_FACTOR_NONE)
873876 _read_pp_info("feature_state", perf_level.feature_state, SST_PP_STATUS_OFFSET,
874877 SST_PP_FEATURE_STATE_START, SST_PP_FEATURE_STATE_WIDTH, SST_MUL_FACTOR_NONE)
875878 perf_level.enabled = !!(power_domain_info->sst_header.cap_mask & BIT(1));
drivers/platform/x86/lenovo/wmi-gamezone.c+0−2
@@ -31,8 +31,6 @@ · 30 unmodified lines
3131 #define LWMI_GZ_METHOD_ID_SMARTFAN_SET 44
3232 #define LWMI_GZ_METHOD_ID_SMARTFAN_GET 45
3333
34−static BLOCKING_NOTIFIER_HEAD(gz_chain_head);
35−
3634 struct lwmi_gz_priv {
3735 enum thermal_mode current_mode;
3836 struct notifier_block event_nb;
drivers/scsi/ibmvscsi/ibmvfc.c+2−1
@@ -4966,7 +4966,8 @@ static void ibmvfc_discover_targets_done(struct ibmvfc_event *evt) · 4965 unmodified lines
49664966 switch (mad_status) {
49674967 case IBMVFC_MAD_SUCCESS:
49684968 ibmvfc_dbg(vhost, "Discover Targets succeeded\n");
4969− vhost->num_targets = be32_to_cpu(rsp->num_written);
4969+ vhost->num_targets = min_t(u32, be32_to_cpu(rsp->num_written),
4970+ max_targets);
49704971 ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_ALLOC_TGTS);
49714972 break;
49724973 case IBMVFC_MAD_FAILED:
drivers/scsi/scsi_transport_sas.c+1−1
@@ -1734,7 +1734,7 @@ static int sas_user_scan(struct Scsi_Host *shost, uint channel, · 1733 unmodified lines
17341734 break;
17351735
17361736 default:
1737− if (channel < shost->max_channel) {
1737+ if (channel <= shost->max_channel) {
17381738 res = scsi_scan_host_selected(shost, channel, id, lun,
17391739 SCSI_SCAN_MANUAL);
17401740 } else {
drivers/scsi/ses.c+1−1
@@ -215,7 +215,7 @@ static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev, · 214 unmodified lines
215215 unsigned char *type_ptr = ses_dev->page1_types;
216216 unsigned char *desc_ptr = ses_dev->page2 + 8;
217217
218− if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len) < 0)
218+ if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len))
219219 return NULL;
220220
221221 for (i = 0; i < ses_dev->page1_num_types; i++, type_ptr += 4) {
drivers/spi/spi-fsl-lpspi.c+2−1
@@ -1009,7 +1009,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev) · 1008 unmodified lines
10091009 enable_irq(irq);
10101010 }
10111011
1012− ret = devm_spi_register_controller(&pdev->dev, controller);
1012+ ret = spi_register_controller(controller);
10131013 if (ret < 0) {
10141014 dev_err_probe(&pdev->dev, ret, "spi_register_controller error\n");
10151015 goto free_dma;
@@ -1035,6 +1035,7 @@ static void fsl_lpspi_remove(struct platform_device *pdev) · 19 unmodified lines
10351035 struct fsl_lpspi_data *fsl_lpspi =
10361036 spi_controller_get_devdata(controller);
10371037
1038+ spi_unregister_controller(controller);
10381039 fsl_lpspi_dma_exit(controller);
10391040
10401041 pm_runtime_dont_use_autosuspend(fsl_lpspi->dev);
drivers/spi/spi-meson-spicc.c+0−2
@@ -1101,8 +1101,6 @@ static void meson_spicc_remove(struct platform_device *pdev) · 1100 unmodified lines
11011101
11021102 /* Disable SPI */
11031103 writel(0, spicc->base + SPICC_CONREG);
1104−
1105− spi_controller_put(spicc->host);
11061104 }
11071105
11081106 static const struct meson_spicc_data meson_spicc_gx_data = {
drivers/spi/spi-sn-f-ospi.c+10−32
@@ -612,7 +612,7 @@ static int f_ospi_probe(struct platform_device *pdev) · 611 unmodified lines
612612 u32 num_cs = OSPI_NUM_CS;
613613 int ret;
614614
615− ctlr = spi_alloc_host(dev, sizeof(*ospi));
615+ ctlr = devm_spi_alloc_host(dev, sizeof(*ospi));
616616 if (!ctlr)
617617 return -ENOMEM;
618618
@@ -635,43 +635,22 @@ static int f_ospi_probe(struct platform_device *pdev) · 16 unmodified lines
635635 platform_set_drvdata(pdev, ospi);
636636
637637 ospi->base = devm_platform_ioremap_resource(pdev, 0);
638− if (IS_ERR(ospi->base)) {
639− ret = PTR_ERR(ospi->base);
640− goto err_put_ctlr;
641− }
638+ if (IS_ERR(ospi->base))
639+ return PTR_ERR(ospi->base);
642640
643641 ospi->clk = devm_clk_get_enabled(dev, NULL);
644− if (IS_ERR(ospi->clk)) {
645− ret = PTR_ERR(ospi->clk);
646− goto err_put_ctlr;
647− }
642+ if (IS_ERR(ospi->clk))
643+ return PTR_ERR(ospi->clk);
648644
649− mutex_init(&ospi->mlock);
650−
651− ret = f_ospi_init(ospi);
645+ ret = devm_mutex_init(dev, &ospi->mlock);
652646 if (ret)
653− goto err_destroy_mutex;
647+ return ret;
654648
655− ret = devm_spi_register_controller(dev, ctlr);
649+ ret = f_ospi_init(ospi);
656650 if (ret)
657− goto err_destroy_mutex;
658−
659− return 0;
660−
661−err_destroy_mutex:
662− mutex_destroy(&ospi->mlock);
663−
664−err_put_ctlr:
665− spi_controller_put(ctlr);
666−
667− return ret;
668−}
669−
670−static void f_ospi_remove(struct platform_device *pdev)
671−{
672− struct f_ospi *ospi = platform_get_drvdata(pdev);
651+ return ret;
673652
674− mutex_destroy(&ospi->mlock);
653+ return devm_spi_register_controller(dev, ctlr);
675654 }
676655
677656 static const struct of_device_id f_ospi_dt_ids[] = {
@@ -686,7 +665,6 @@ static struct platform_driver f_ospi_driver = { · 8 unmodified lines
686665 .of_match_table = f_ospi_dt_ids,
687666 },
688667 .probe = f_ospi_probe,
689− .remove = f_ospi_remove,
690668 };
691669 module_platform_driver(f_ospi_driver);
692670
drivers/spi/spi.c+19−13
@@ -50,7 +50,6 @@ static void spidev_release(struct device *dev) · 49 unmodified lines
5050 struct spi_device *spi = to_spi_device(dev);
5151
5252 spi_controller_put(spi->controller);
53− kfree(spi->driver_override);
5453 free_percpu(spi->pcpu_statistics);
5554 kfree(spi);
5655 }
@@ -73,10 +72,9 @@ static ssize_t driver_override_store(struct device *dev, · 16 unmodified lines
7372 struct device_attribute *a,
7473 const char *buf, size_t count)
7574 {
76− struct spi_device *spi = to_spi_device(dev);
7775 int ret;
7876
79− ret = driver_set_override(dev, &spi->driver_override, buf, count);
77+ ret = __device_set_driver_override(dev, buf, count);
8078 if (ret)
8179 return ret;
8280
@@ -86,13 +84,8 @@ static ssize_t driver_override_store(struct device *dev, · 3 unmodified lines
8684 static ssize_t driver_override_show(struct device *dev,
8785 struct device_attribute *a, char *buf)
8886 {
89− const struct spi_device *spi = to_spi_device(dev);
90− ssize_t len;
91−
92− device_lock(dev);
93− len = sysfs_emit(buf, "%s\n", spi->driver_override ? : "");
94− device_unlock(dev);
95− return len;
87+ guard(spinlock)(&dev->driver_override.lock);
88+ return sysfs_emit(buf, "%s\n", dev->driver_override.name ?: "");
9689 }
9790 static DEVICE_ATTR_RW(driver_override);
9891
@@ -376,10 +369,12 @@ static int spi_match_device(struct device *dev, const struct device_driver *drv) · 277 unmodified lines
376369 {
377370 const struct spi_device *spi = to_spi_device(dev);
378371 const struct spi_driver *sdrv = to_spi_driver(drv);
372+ int ret;
379373
380374 /* Check override first, and if set, only use the named driver */
381− if (spi->driver_override)
382− return strcmp(spi->driver_override, drv->name) == 0;
375+ ret = device_match_driver_override(dev, drv);
376+ if (ret >= 0)
377+ return ret;
383378
384379 /* Attempt an OF style match */
385380 if (of_driver_match_device(dev, drv))
@@ -3539,8 +3534,19 @@ int devm_spi_register_controller(struct device *dev, · 3153 unmodified lines
35393534 if (ret)
35403535 return ret;
35413536
3542− return devm_add_action_or_reset(dev, devm_spi_unregister_controller, ctlr);
3537+ /*
3538+ * Prevent controller from being freed by spi_unregister_controller()
3539+ * if devm_add_action_or_reset() fails for a non-devres allocated
3540+ * controller.
3541+ */
3542+ spi_controller_get(ctlr);
3543+
3544+ ret = devm_add_action_or_reset(dev, devm_spi_unregister_controller, ctlr);
35433545
3546+ if (ret == 0 || ctlr->devm_allocated)
3547+ spi_controller_put(ctlr);
3548+
3549+ return ret;
35443550 }
35453551 EXPORT_SYMBOL_GPL(devm_spi_register_controller);
35463552
drivers/target/loopback/tcm_loop.c+46−6
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include <linux/slab.h>
2727 #include <linux/types.h>
2828 #include <linux/configfs.h>
29+#include <linux/blk-mq.h>
2930 #include <scsi/scsi.h>
3031 #include <scsi/scsi_tcq.h>
3132 #include <scsi/scsi_host.h>
@@ -269,15 +270,27 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) · 237 unmodified lines
269270 return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
270271 }
271272
273+static bool tcm_loop_flush_work_iter(struct request *rq, void *data)
274+{
275+ struct scsi_cmnd *sc = blk_mq_rq_to_pdu(rq);
276+ struct tcm_loop_cmd *tl_cmd = scsi_cmd_priv(sc);
277+ struct se_cmd *se_cmd = &tl_cmd->tl_se_cmd;
278+
279+ flush_work(&se_cmd->work);
280+ return true;
281+}
282+
272283 static int tcm_loop_target_reset(struct scsi_cmnd *sc)
273284 {
274285 struct tcm_loop_hba *tl_hba;
275286 struct tcm_loop_tpg *tl_tpg;
287+ struct Scsi_Host *sh = sc->device->host;
288+ int ret;
276289
277290 /*
278291 * Locate the tcm_loop_hba_t pointer
279292 */
280− tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
293+ tl_hba = *(struct tcm_loop_hba **)shost_priv(sh);
281294 if (!tl_hba) {
282295 pr_err("Unable to perform device reset without active I_T Nexus\n");
283296 return FAILED;
@@ -286,11 +299,38 @@ static int tcm_loop_target_reset(struct scsi_cmnd *sc) · 2 unmodified lines
286299 * Locate the tl_tpg pointer from TargetID in sc->device->id
287300 */
288301 tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
289− if (tl_tpg) {
290− tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE;
291− return SUCCESS;
292− }
293− return FAILED;
302+ if (!tl_tpg)
303+ return FAILED;
304+
305+ /*
306+ * Issue a LUN_RESET to drain all commands that the target core
307+ * knows about. This handles commands not yet marked CMD_T_COMPLETE.
308+ */
309+ ret = tcm_loop_issue_tmr(tl_tpg, sc->device->lun, 0, TMR_LUN_RESET);
310+ if (ret != TMR_FUNCTION_COMPLETE)
311+ return FAILED;
312+
313+ /*
314+ * Flush any deferred target core completion work that may still be
315+ * queued. Commands that already had CMD_T_COMPLETE set before the TMR
316+ * are skipped by the TMR drain, but their async completion work
317+ * (transport_lun_remove_cmd → percpu_ref_put, release_cmd → scsi_done)
318+ * may still be pending in target_completion_wq.
319+ *
320+ * The SCSI EH will reuse in-flight scsi_cmnd structures for recovery
321+ * commands (e.g. TUR) immediately after this handler returns SUCCESS —
322+ * if deferred work is still pending, the memset in queuecommand would
323+ * zero the se_cmd while the work accesses it, leaking the LUN
324+ * percpu_ref and hanging configfs unlink forever.
325+ *
326+ * Use blk_mq_tagset_busy_iter() to find all started requests and
327+ * flush_work() on each — the same pattern used by mpi3mr, scsi_debug,
328+ * and other SCSI drivers to drain outstanding commands during reset.
329+ */
330+ blk_mq_tagset_busy_iter(&sh->tag_set, tcm_loop_flush_work_iter, NULL);
331+
332+ tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE;
333+ return SUCCESS;
294334 }
295335
296336 static const struct scsi_host_template tcm_loop_driver_template = {
drivers/target/target_core_file.c+1−1
@@ -276,7 +276,7 @@ fd_execute_rw_aio(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, · 275 unmodified lines
276276 ssize_t len = 0;
277277 int ret = 0, i;
278278
279− aio_cmd = kmalloc_flex(*aio_cmd, bvecs, sgl_nents);
279+ aio_cmd = kzalloc_flex(*aio_cmd, bvecs, sgl_nents);
280280 if (!aio_cmd)
281281 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
282282
drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c+7−1
@@ -176,15 +176,21 @@ static inline void write_soc_slider(struct proc_thermal_device *proc_priv, u64 v · 175 unmodified lines
176176
177177 static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int slider)
178178 {
179+ u8 offset;
179180 u64 val;
180181
181182 val = read_soc_slider(proc_priv);
182183 val &= ~SLIDER_MASK;
183184 val |= FIELD_PREP(SLIDER_MASK, slider) | BIT(SLIDER_ENABLE_BIT);
184185
186+ if (slider == SOC_SLIDER_VALUE_MINIMUM || slider == SOC_SLIDER_VALUE_MAXIMUM)
187+ offset = 0;
188+ else
189+ offset = slider_offset;
190+
185191 /* Set the slider offset from module params */
186192 val &= ~SLIDER_OFFSET_MASK;
187− val |= FIELD_PREP(SLIDER_OFFSET_MASK, slider_offset);
193+ val |= FIELD_PREP(SLIDER_OFFSET_MASK, offset);
188194
189195 write_soc_slider(proc_priv, val);
190196 }
drivers/vfio/pci/vfio_pci_dmabuf.c+2−3
@@ -301,11 +301,10 @@ int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags, · 300 unmodified lines
301301 */
302302 ret = dma_buf_fd(priv->dmabuf, get_dma_buf.open_flags);
303303 if (ret < 0)
304− goto err_dma_buf;
304+ dma_buf_put(priv->dmabuf);
305+
305306 return ret;
306307
307−err_dma_buf:
308− dma_buf_put(priv->dmabuf);
309308 err_dev_put:
310309 vfio_device_put_registration(&vdev->vdev);
311310 err_free_phys:
drivers/virt/coco/tdx-guest/tdx-guest.c+10−2
@@ -171,6 +171,8 @@ static void tdx_mr_deinit(const struct attribute_group *mr_grp) · 170 unmodified lines
171171 #define GET_QUOTE_SUCCESS 0
172172 #define GET_QUOTE_IN_FLIGHT 0xffffffffffffffff
173173
174+#define TDX_QUOTE_MAX_LEN (GET_QUOTE_BUF_SIZE - sizeof(struct tdx_quote_buf))
175+
174176 /* struct tdx_quote_buf: Format of Quote request buffer.
175177 * @version: Quote format version, filled by TD.
176178 * @status: Status code of Quote request, filled by VMM.
@@ -269,6 +271,7 @@ static int tdx_report_new_locked(struct tsm_report *report, void *data) · 92 unmodified lines
269271 u8 *buf;
270272 struct tdx_quote_buf *quote_buf = quote_data;
271273 struct tsm_report_desc *desc = &report->desc;
274+ u32 out_len;
272275 int ret;
273276 u64 err;
274277
@@ -306,12 +309,17 @@ static int tdx_report_new_locked(struct tsm_report *report, void *data) · 31 unmodified lines
306309 return ret;
307310 }
308311
309− buf = kvmemdup(quote_buf->data, quote_buf->out_len, GFP_KERNEL);
312+ out_len = READ_ONCE(quote_buf->out_len);
313+
314+ if (out_len > TDX_QUOTE_MAX_LEN)
315+ return -EFBIG;
316+
317+ buf = kvmemdup(quote_buf->data, out_len, GFP_KERNEL);
310318 if (!buf)
311319 return -ENOMEM;
312320
313321 report->outblob = buf;
314− report->outblob_len = quote_buf->out_len;
322+ report->outblob_len = out_len;
315323
316324 /*
317325 * TODO: parse the PEM-formatted cert chain out of the quote buffer when
drivers/virtio/virtio_ring.c+5−5
@@ -2912,10 +2912,10 @@ EXPORT_SYMBOL_GPL(virtqueue_add_inbuf); · 2911 unmodified lines
29122912 * @data: the token identifying the buffer.
29132913 * @gfp: how to do memory allocations (if necessary).
29142914 *
2915− * Same as virtqueue_add_inbuf but passes DMA_ATTR_CPU_CACHE_CLEAN to indicate
2916− * that the CPU will not dirty any cacheline overlapping this buffer while it
2917− * is available, and to suppress overlapping cacheline warnings in DMA debug
2918− * builds.
2915+ * Same as virtqueue_add_inbuf but passes DMA_ATTR_DEBUGGING_IGNORE_CACHELINES
2916+ * to indicate that the CPU will not dirty any cacheline overlapping this buffer
2917+ * while it is available, and to suppress overlapping cacheline warnings in DMA
2918+ * debug builds.
29192919 *
29202920 * Caller must ensure we don't call this with other virtqueue operations
29212921 * at the same time (except where noted).
@@ -2928,7 +2928,7 @@ int virtqueue_add_inbuf_cache_clean(struct virtqueue *vq, · 6 unmodified lines
29282928 gfp_t gfp)
29292929 {
29302930 return virtqueue_add(vq, &sg, num, 0, 1, data, NULL, false, gfp,
2931− DMA_ATTR_CPU_CACHE_CLEAN);
2931+ DMA_ATTR_DEBUGGING_IGNORE_CACHELINES);
29322932 }
29332933 EXPORT_SYMBOL_GPL(virtqueue_add_inbuf_cache_clean);
29342934
drivers/xen/privcmd.c+73−3
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/eventfd.h>
1313 #include <linux/file.h>
1414 #include <linux/kernel.h>
15+#include <linux/kstrtox.h>
1516 #include <linux/module.h>
1617 #include <linux/mutex.h>
1718 #include <linux/poll.h>
@@ -30,7 +31,10 @@ · 12 unmodified lines
3031 #include <linux/seq_file.h>
3132 #include <linux/miscdevice.h>
3233 #include <linux/moduleparam.h>
34+#include <linux/notifier.h>
35+#include <linux/security.h>
3336 #include <linux/virtio_mmio.h>
37+#include <linux/wait.h>
3438
3539 #include <asm/xen/hypervisor.h>
3640 #include <asm/xen/hypercall.h>
@@ -46,6 +50,7 @@ · 9 unmodified lines
4650 #include <xen/page.h>
4751 #include <xen/xen-ops.h>
4852 #include <xen/balloon.h>
53+#include <xen/xenbus.h>
4954 #ifdef CONFIG_XEN_ACPI
5055 #include <xen/acpi.h>
5156 #endif
@@ -68,10 +73,20 @@ module_param_named(dm_op_buf_max_size, privcmd_dm_op_buf_max_size, uint, · 16 unmodified lines
6873 MODULE_PARM_DESC(dm_op_buf_max_size,
6974 "Maximum size of a dm_op hypercall buffer");
7075
76+static bool unrestricted;
77+module_param(unrestricted, bool, 0);
78+MODULE_PARM_DESC(unrestricted,
79+ "Don't restrict hypercalls to target domain if running in a domU");
80+
7181 struct privcmd_data {
7282 domid_t domid;
7383 };
7484
85+/* DOMID_INVALID implies no restriction */
86+static domid_t target_domain = DOMID_INVALID;
87+static bool restrict_wait;
88+static DECLARE_WAIT_QUEUE_HEAD(restrict_wait_wq);
89+
7590 static int privcmd_vma_range_is_mapped(
7691 struct vm_area_struct *vma,
7792 unsigned long addr,
@@ -1563,13 +1578,16 @@ static long privcmd_ioctl(struct file *file, · 1485 unmodified lines
15631578
15641579 static int privcmd_open(struct inode *ino, struct file *file)
15651580 {
1566− struct privcmd_data *data = kzalloc_obj(*data);
1581+ struct privcmd_data *data;
15671582
1583+ if (wait_event_interruptible(restrict_wait_wq, !restrict_wait) < 0)
1584+ return -EINTR;
1585+
1586+ data = kzalloc_obj(*data);
15681587 if (!data)
15691588 return -ENOMEM;
15701589
1571− /* DOMID_INVALID implies no restriction */
1572− data->domid = DOMID_INVALID;
1590+ data->domid = target_domain;
15731591
15741592 file->private_data = data;
15751593 return 0;
@@ -1662,6 +1680,52 @@ static struct miscdevice privcmd_dev = { · 86 unmodified lines
16621680 .fops = &xen_privcmd_fops,
16631681 };
16641682
1683+static int init_restrict(struct notifier_block *notifier,
1684+ unsigned long event,
1685+ void *data)
1686+{
1687+ char *target;
1688+ unsigned int domid;
1689+
1690+ /* Default to an guaranteed unused domain-id. */
1691+ target_domain = DOMID_IDLE;
1692+
1693+ target = xenbus_read(XBT_NIL, "target", "", NULL);
1694+ if (IS_ERR(target) || kstrtouint(target, 10, &domid)) {
1695+ pr_err("No target domain found, blocking all hypercalls\n");
1696+ goto out;
1697+ }
1698+
1699+ target_domain = domid;
1700+
1701+ out:
1702+ if (!IS_ERR(target))
1703+ kfree(target);
1704+
1705+ restrict_wait = false;
1706+ wake_up_all(&restrict_wait_wq);
1707+
1708+ return NOTIFY_DONE;
1709+}
1710+
1711+static struct notifier_block xenstore_notifier = {
1712+ .notifier_call = init_restrict,
1713+};
1714+
1715+static void __init restrict_driver(void)
1716+{
1717+ if (unrestricted) {
1718+ if (security_locked_down(LOCKDOWN_XEN_USER_ACTIONS))
1719+ pr_warn("Kernel is locked down, parameter \"unrestricted\" ignored\n");
1720+ else
1721+ return;
1722+ }
1723+
1724+ restrict_wait = true;
1725+
1726+ register_xenstore_notifier(&xenstore_notifier);
1727+}
1728+
16651729 static int __init privcmd_init(void)
16661730 {
16671731 int err;
@@ -1669,6 +1733,9 @@ static int __init privcmd_init(void) · 1 unmodified line
16691733 if (!xen_domain())
16701734 return -ENODEV;
16711735
1736+ if (!xen_initial_domain())
1737+ restrict_driver();
1738+
16721739 err = misc_register(&privcmd_dev);
16731740 if (err != 0) {
16741741 pr_err("Could not register Xen privcmd device\n");
@@ -1698,6 +1765,9 @@ err_privcmdbuf: · 23 unmodified lines
16981765
16991766 static void __exit privcmd_exit(void)
17001767 {
1768+ if (!xen_initial_domain())
1769+ unregister_xenstore_notifier(&xenstore_notifier);
1770+
17011771 privcmd_ioeventfd_exit();
17021772 privcmd_irqfd_exit();
17031773 misc_deregister(&privcmd_dev);
fs/btrfs/block-group.c+1−1
@@ -4583,7 +4583,7 @@ static void check_removing_space_info(struct btrfs_space_info *space_info) · 4582 unmodified lines
45834583 for (int i = 0; i < BTRFS_SPACE_INFO_SUB_GROUP_MAX; i++) {
45844584 if (space_info->sub_group[i]) {
45854585 check_removing_space_info(space_info->sub_group[i]);
4586− kfree(space_info->sub_group[i]);
4586+ btrfs_sysfs_remove_space_info(space_info->sub_group[i]);
45874587 space_info->sub_group[i] = NULL;
45884588 }
45894589 }
fs/btrfs/disk-io.c+2−2
@@ -2531,8 +2531,8 @@ int btrfs_validate_super(const struct btrfs_fs_info *fs_info, · 2530 unmodified lines
25312531
25322532 if (mirror_num >= 0 &&
25332533 btrfs_super_bytenr(sb) != btrfs_sb_offset(mirror_num)) {
2534− btrfs_err(fs_info, "super offset mismatch %llu != %u",
2535− btrfs_super_bytenr(sb), BTRFS_SUPER_INFO_OFFSET);
2534+ btrfs_err(fs_info, "super offset mismatch %llu != %llu",
2535+ btrfs_super_bytenr(sb), btrfs_sb_offset(mirror_num));
25362536 ret = -EINVAL;
25372537 }
25382538
fs/btrfs/tree-log.c+65−33
@@ -4616,21 +4616,32 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, · 4615 unmodified lines
46164616 struct inode *inode, bool log_inode_only,
46174617 u64 logged_isize)
46184618 {
4619+ u64 gen = BTRFS_I(inode)->generation;
46194620 u64 flags;
46204621
46214622 if (log_inode_only) {
4622− /* set the generation to zero so the recover code
4623− * can tell the difference between an logging
4624− * just to say 'this inode exists' and a logging
4625− * to say 'update this inode with these values'
4623+ /*
4624+ * Set the generation to zero so the recover code can tell the
4625+ * difference between a logging just to say 'this inode exists'
4626+ * and a logging to say 'update this inode with these values'.
4627+ * But only if the inode was not already logged before.
4628+ * We access ->logged_trans directly since it was already set
4629+ * up in the call chain by btrfs_log_inode(), and data_race()
4630+ * to avoid false alerts from KCSAN and since it was set already
4631+ * and one can set it to 0 since that only happens on eviction
4632+ * and we are holding a ref on the inode.
46264633 */
4627− btrfs_set_inode_generation(leaf, item, 0);
4634+ ASSERT(data_race(BTRFS_I(inode)->logged_trans) > 0);
4635+ if (data_race(BTRFS_I(inode)->logged_trans) < trans->transid)
4636+ gen = 0;
4637+
46284638 btrfs_set_inode_size(leaf, item, logged_isize);
46294639 } else {
4630− btrfs_set_inode_generation(leaf, item, BTRFS_I(inode)->generation);
46314640 btrfs_set_inode_size(leaf, item, inode->i_size);
46324641 }
46334642
4643+ btrfs_set_inode_generation(leaf, item, gen);
4644+
46344645 btrfs_set_inode_uid(leaf, item, i_uid_read(inode));
46354646 btrfs_set_inode_gid(leaf, item, i_gid_read(inode));
46364647 btrfs_set_inode_mode(leaf, item, inode->i_mode);
@@ -5448,42 +5459,63 @@ process: · 811 unmodified lines
54485459 return 0;
54495460 }
54505461
5451−static int logged_inode_size(struct btrfs_root *log, struct btrfs_inode *inode,
5452− struct btrfs_path *path, u64 *size_ret)
5462+static int get_inode_size_to_log(struct btrfs_trans_handle *trans,
5463+ struct btrfs_inode *inode,
5464+ struct btrfs_path *path, u64 *size_ret)
54535465 {
54545466 struct btrfs_key key;
5467+ struct btrfs_inode_item *item;
54555468 int ret;
54565469
54575470 key.objectid = btrfs_ino(inode);
54585471 key.type = BTRFS_INODE_ITEM_KEY;
54595472 key.offset = 0;
54605473
5461− ret = btrfs_search_slot(NULL, log, &key, path, 0, 0);
5462− if (ret < 0) {
5463− return ret;
5464− } else if (ret > 0) {
5465− *size_ret = 0;
5466− } else {
5467− struct btrfs_inode_item *item;
5474+ /*
5475+ * Our caller called inode_logged(), so logged_trans is up to date.
5476+ * Use data_race() to silence any warning from KCSAN. Once logged_trans
5477+ * is set, it can only be reset to 0 after inode eviction.
5478+ */
5479+ if (data_race(inode->logged_trans) == trans->transid) {
5480+ ret = btrfs_search_slot(NULL, inode->root->log_root, &key, path, 0, 0);
5481+ } else if (inode->generation < trans->transid) {
5482+ path->search_commit_root = true;
5483+ path->skip_locking = true;
5484+ ret = btrfs_search_slot(NULL, inode->root, &key, path, 0, 0);
5485+ path->search_commit_root = false;
5486+ path->skip_locking = false;
54685487
5469− item = btrfs_item_ptr(path->nodes[0], path->slots[0],
5470− struct btrfs_inode_item);
5471− *size_ret = btrfs_inode_size(path->nodes[0], item);
5472− /*
5473− * If the in-memory inode's i_size is smaller then the inode
5474− * size stored in the btree, return the inode's i_size, so
5475− * that we get a correct inode size after replaying the log
5476− * when before a power failure we had a shrinking truncate
5477− * followed by addition of a new name (rename / new hard link).
5478− * Otherwise return the inode size from the btree, to avoid
5479− * data loss when replaying a log due to previously doing a
5480− * write that expands the inode's size and logging a new name
5481− * immediately after.
5482− */
5483− if (*size_ret > inode->vfs_inode.i_size)
5484− *size_ret = inode->vfs_inode.i_size;
5488+ } else {
5489+ *size_ret = 0;
5490+ return 0;
54855491 }
54865492
5493+ /*
5494+ * If the inode was logged before or is from a past transaction, then
5495+ * its inode item must exist in the log root or in the commit root.
5496+ */
5497+ ASSERT(ret <= 0);
5498+ if (WARN_ON_ONCE(ret > 0))
5499+ ret = -ENOENT;
5500+
5501+ if (ret < 0)
5502+ return ret;
5503+
5504+ item = btrfs_item_ptr(path->nodes[0], path->slots[0],
5505+ struct btrfs_inode_item);
5506+ *size_ret = btrfs_inode_size(path->nodes[0], item);
5507+ /*
5508+ * If the in-memory inode's i_size is smaller then the inode size stored
5509+ * in the btree, return the inode's i_size, so that we get a correct
5510+ * inode size after replaying the log when before a power failure we had
5511+ * a shrinking truncate followed by addition of a new name (rename / new
5512+ * hard link). Otherwise return the inode size from the btree, to avoid
5513+ * data loss when replaying a log due to previously doing a write that
5514+ * expands the inode's size and logging a new name immediately after.
5515+ */
5516+ if (*size_ret > inode->vfs_inode.i_size)
5517+ *size_ret = inode->vfs_inode.i_size;
5518+
54875519 btrfs_release_path(path);
54885520 return 0;
54895521 }
@@ -6996,7 +7028,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, · 1506 unmodified lines
69967028 ret = drop_inode_items(trans, log, path, inode,
69977029 BTRFS_XATTR_ITEM_KEY);
69987030 } else {
6999− if (inode_only == LOG_INODE_EXISTS && ctx->logged_before) {
7031+ if (inode_only == LOG_INODE_EXISTS) {
70007032 /*
70017033 * Make sure the new inode item we write to the log has
70027034 * the same isize as the current one (if it exists).
@@ -7010,7 +7042,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, · 7 unmodified lines
70107042 * (zeroes), as if an expanding truncate happened,
70117043 * instead of getting a file of 4Kb only.
70127044 */
7013− ret = logged_inode_size(log, inode, path, &logged_isize);
7045+ ret = get_inode_size_to_log(trans, inode, path, &logged_isize);
70147046 if (ret)
70157047 goto out_unlock;
70167048 }
fs/btrfs/volumes.c+3−2
@@ -8099,8 +8099,9 @@ int btrfs_run_dev_stats(struct btrfs_trans_handle *trans) · 8098 unmodified lines
80998099 smp_rmb();
81008100
81018101 ret = update_dev_stat_item(trans, device);
8102− if (!ret)
8103− atomic_sub(stats_cnt, &device->dev_stats_ccnt);
8102+ if (ret)
8103+ break;
8104+ atomic_sub(stats_cnt, &device->dev_stats_ccnt);
81048105 }
81058106 mutex_unlock(&fs_devices->device_list_mutex);
81068107
fs/btrfs/zlib.c+3−1
@@ -308,7 +308,9 @@ int zlib_compress_bio(struct list_head *ws, struct compressed_bio *cb) · 307 unmodified lines
308308 }
309309 /* Queue the remaining part of the folio. */
310310 if (workspace->strm.total_out > bio->bi_iter.bi_size) {
311− u32 cur_len = offset_in_folio(out_folio, workspace->strm.total_out);
311+ const u32 cur_len = workspace->strm.total_out - bio->bi_iter.bi_size;
312+
313+ ASSERT(cur_len <= folio_size(out_folio));
312314
313315 if (!bio_add_folio(bio, out_folio, cur_len, 0)) {
314316 ret = -E2BIG;
fs/erofs/Kconfig+30−15
@@ -16,22 +16,36 @@ config EROFS_FS · 15 unmodified lines
1616 select ZLIB_INFLATE if EROFS_FS_ZIP_DEFLATE
1717 select ZSTD_DECOMPRESS if EROFS_FS_ZIP_ZSTD
1818 help
19− EROFS (Enhanced Read-Only File System) is a lightweight read-only
20− file system with modern designs (e.g. no buffer heads, inline
21− xattrs/data, chunk-based deduplication, multiple devices, etc.) for
22− scenarios which need high-performance read-only solutions, e.g.
23− smartphones with Android OS, LiveCDs and high-density hosts with
24− numerous containers;
25−
26− It also provides transparent compression and deduplication support to
27− improve storage density and maintain relatively high compression
28− ratios, and it implements in-place decompression to temporarily reuse
29− page cache for compressed data using proper strategies, which is
30− quite useful for ensuring guaranteed end-to-end runtime decompression
19+ EROFS (Enhanced Read-Only File System) is a modern, lightweight,
20+ secure read-only filesystem for various use cases, such as immutable
21+ system images, container images, application sandboxes, and datasets.
22+
23+ EROFS uses a flexible, hierarchical on-disk design so that features
24+ can be enabled on demand: the core on-disk format is block-aligned in
25+ order to perform optimally on all kinds of devices, including block
26+ and memory-backed devices; the format is easy to parse and has zero
27+ metadata redundancy, unlike generic filesystems, making it ideal for
28+ filesystem auditing and remote access; inline data, random-access
29+ friendly directory data, inline/shared extended attributes and
30+ chunk-based deduplication ensure space efficiency while maintaining
31+ high performance.
32+
33+ Optionally, it supports multiple devices to reference external data,
34+ enabling data sharing for container images.
35+
36+ It also has advanced encoded on-disk layouts, particularly for data
37+ compression and fine-grained deduplication. It utilizes fixed-size
38+ output compression to improve storage density while keeping relatively
39+ high compression ratios. Furthermore, it implements in-place
40+ decompression to reuse file pages to keep compressed data temporarily
41+ with proper strategies, which ensures guaranteed end-to-end runtime
3142 performance under extreme memory pressure without extra cost.
3243
33− See the documentation at <file:Documentation/filesystems/erofs.rst>
34− and the web pages at <https://erofs.docs.kernel.org> for more details.
44+ For more details, see the web pages at <https://erofs.docs.kernel.org>
45+ and the documentation at <file:Documentation/filesystems/erofs.rst>.
46+
47+ To compile EROFS filesystem support as a module, choose M here. The
48+ module will be called erofs.
3549
3650 If unsure, say N.
3751
@@ -105,7 +119,8 @@ config EROFS_FS_ZIP · 67 unmodified lines
105119 depends on EROFS_FS
106120 default y
107121 help
108− Enable transparent compression support for EROFS file systems.
122+ Enable EROFS compression layouts so that filesystems containing
123+ compressed files can be parsed by the kernel.
109124
110125 If you don't want to enable compression feature, say N.
111126
fs/erofs/fileio.c+2−4
@@ -25,10 +25,8 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret) · 24 unmodified lines
2525 container_of(iocb, struct erofs_fileio_rq, iocb);
2626 struct folio_iter fi;
2727
28− if (ret >= 0 && ret != rq->bio.bi_iter.bi_size) {
29− bio_advance(&rq->bio, ret);
30− zero_fill_bio(&rq->bio);
31− }
28+ if (ret >= 0 && ret != rq->bio.bi_iter.bi_size)
29+ ret = -EIO;
3230 if (!rq->bio.bi_end_io) {
3331 bio_for_each_folio_all(fi, &rq->bio) {
3432 DBG_BUGON(folio_test_uptodate(fi.folio));
fs/erofs/ishare.c+13−2
@@ -200,8 +200,19 @@ struct inode *erofs_real_inode(struct inode *inode, bool *need_iput) · 199 unmodified lines
200200
201201 int __init erofs_init_ishare(void)
202202 {
203− erofs_ishare_mnt = kern_mount(&erofs_anon_fs_type);
204− return PTR_ERR_OR_ZERO(erofs_ishare_mnt);
203+ struct vfsmount *mnt;
204+ int ret;
205+
206+ mnt = kern_mount(&erofs_anon_fs_type);
207+ if (IS_ERR(mnt))
208+ return PTR_ERR(mnt);
209+ /* generic_fadvise() doesn't work if s_bdi == &noop_backing_dev_info */
210+ ret = super_setup_bdi(mnt->mnt_sb);
211+ if (ret)
212+ kern_unmount(mnt);
213+ else
214+ erofs_ishare_mnt = mnt;
215+ return ret;
205216 }
206217
207218 void erofs_exit_ishare(void)
fs/erofs/zdata.c+3−0
@@ -1445,6 +1445,7 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io, · 1444 unmodified lines
14451445 int bios)
14461446 {
14471447 struct erofs_sb_info *const sbi = EROFS_SB(io->sb);
1448+ int gfp_flag;
14481449
14491450 /* wake up the caller thread for sync decompression */
14501451 if (io->sync) {
@@ -1477,7 +1478,9 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io, · 26 unmodified lines
14771478 sbi->sync_decompress = EROFS_SYNC_DECOMPRESS_FORCE_ON;
14781479 return;
14791480 }
1481+ gfp_flag = memalloc_noio_save();
14801482 z_erofs_decompressqueue_work(&io->u.work);
1483+ memalloc_noio_restore(gfp_flag);
14811484 }
14821485
14831486 static void z_erofs_fill_bio_vec(struct bio_vec *bvec,
fs/ext4/Makefile+3−2
@@ -14,7 +14,8 @@ ext4-y := balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \ · 13 unmodified lines
1414
1515 ext4-$(CONFIG_EXT4_FS_POSIX_ACL) += acl.o
1616 ext4-$(CONFIG_EXT4_FS_SECURITY) += xattr_security.o
17−ext4-inode-test-objs += inode-test.o
18−obj-$(CONFIG_EXT4_KUNIT_TESTS) += ext4-inode-test.o
17+ext4-test-objs += inode-test.o mballoc-test.o \
18+ extents-test.o
19+obj-$(CONFIG_EXT4_KUNIT_TESTS) += ext4-test.o
1920 ext4-$(CONFIG_FS_VERITY) += verity.o
2021 ext4-$(CONFIG_FS_ENCRYPTION) += crypto.o
fs/ext4/crypto.c+8−1
@@ -163,10 +163,17 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, · 162 unmodified lines
163163 */
164164
165165 if (handle) {
166+ /*
167+ * Since the inode is new it is ok to pass the
168+ * XATTR_CREATE flag. This is necessary to match the
169+ * remaining journal credits check in the set_handle
170+ * function with the credits allocated for the new
171+ * inode.
172+ */
166173 res = ext4_xattr_set_handle(handle, inode,
167174 EXT4_XATTR_INDEX_ENCRYPTION,
168175 EXT4_XATTR_NAME_ENCRYPTION_CONTEXT,
169− ctx, len, 0);
176+ ctx, len, XATTR_CREATE);
170177 if (!res) {
171178 ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT);
172179 ext4_clear_inode_state(inode,
fs/ext4/ext4.h+6−0
@@ -1570,6 +1570,7 @@ struct ext4_sb_info { · 1569 unmodified lines
15701570 struct proc_dir_entry *s_proc;
15711571 struct kobject s_kobj;
15721572 struct completion s_kobj_unregister;
1573+ struct mutex s_error_notify_mutex; /* protects sysfs_notify vs kobject_del */
15731574 struct super_block *s_sb;
15741575 struct buffer_head *s_mmp_bh;
15751576
@@ -3944,6 +3945,11 @@ static inline bool ext4_inode_can_atomic_write(struct inode *inode) · 2368 unmodified lines
39443945 extern int ext4_block_write_begin(handle_t *handle, struct folio *folio,
39453946 loff_t pos, unsigned len,
39463947 get_block_t *get_block);
3948+
3949+#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)
3950+#define EXPORT_SYMBOL_FOR_EXT4_TEST(sym) \
3951+ EXPORT_SYMBOL_FOR_MODULES(sym, "ext4-test")
3952+#endif
39473953 #endif /* __KERNEL__ */
39483954
39493955 #endif /* _EXT4_H */
fs/ext4/ext4_extents.h+12−0
@@ -264,5 +264,17 @@ static inline void ext4_idx_store_pblock(struct ext4_extent_idx *ix, · 263 unmodified lines
264264 0xffff);
265265 }
266266
267+extern int __ext4_ext_dirty(const char *where, unsigned int line,
268+ handle_t *handle, struct inode *inode,
269+ struct ext4_ext_path *path);
270+extern int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex);
271+#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)
272+extern int ext4_ext_space_root_idx_test(struct inode *inode, int check);
273+extern struct ext4_ext_path *ext4_split_convert_extents_test(
274+ handle_t *handle, struct inode *inode,
275+ struct ext4_map_blocks *map,
276+ struct ext4_ext_path *path,
277+ int flags, unsigned int *allocated);
278+#endif
267279 #endif /* _EXT4_EXTENTS */
268280
fs/ext4/extents-test.c+7−5
@@ -142,8 +142,10 @@ static struct file_system_type ext_fs_type = { · 141 unmodified lines
142142
143143 static void extents_kunit_exit(struct kunit *test)
144144 {
145− struct ext4_sb_info *sbi = k_ctx.k_ei->vfs_inode.i_sb->s_fs_info;
145+ struct super_block *sb = k_ctx.k_ei->vfs_inode.i_sb;
146+ struct ext4_sb_info *sbi = sb->s_fs_info;
146147
148+ ext4_es_unregister_shrinker(sbi);
147149 kfree(sbi);
148150 kfree(k_ctx.k_ei);
149151 kfree(k_ctx.k_data);
@@ -280,8 +282,8 @@ static int extents_kunit_init(struct kunit *test) · 130 unmodified lines
280282 eh->eh_depth = 0;
281283 eh->eh_entries = cpu_to_le16(1);
282284 eh->eh_magic = EXT4_EXT_MAGIC;
283− eh->eh_max =
284− cpu_to_le16(ext4_ext_space_root_idx(&k_ctx.k_ei->vfs_inode, 0));
285+ eh->eh_max = cpu_to_le16(ext4_ext_space_root_idx_test(
286+ &k_ctx.k_ei->vfs_inode, 0));
285287 eh->eh_generation = 0;
286288
287289 /*
@@ -384,8 +386,8 @@ static void test_split_convert(struct kunit *test) · 96 unmodified lines
384386
385387 switch (param->type) {
386388 case TEST_SPLIT_CONVERT:
387− path = ext4_split_convert_extents(NULL, inode, &map, path,
388− param->split_flags, NULL);
389+ path = ext4_split_convert_extents_test(NULL, inode, &map,
390+ path, param->split_flags, NULL);
389391 break;
390392 case TEST_CREATE_BLOCKS:
391393 ext4_map_create_blocks_helper(test, inode, &map, param->split_flags);
fs/ext4/extents.c+68−12
@@ -184,9 +184,9 @@ static int ext4_ext_get_access(handle_t *handle, struct inode *inode, · 183 unmodified lines
184184 * - ENOMEM
185185 * - EIO
186186 */
187−static int __ext4_ext_dirty(const char *where, unsigned int line,
188− handle_t *handle, struct inode *inode,
189− struct ext4_ext_path *path)
187+int __ext4_ext_dirty(const char *where, unsigned int line,
188+ handle_t *handle, struct inode *inode,
189+ struct ext4_ext_path *path)
190190 {
191191 int err;
192192
@@ -1736,6 +1736,13 @@ static int ext4_ext_correct_indexes(handle_t *handle, struct inode *inode, · 1543 unmodified lines
17361736 err = ext4_ext_get_access(handle, inode, path + k);
17371737 if (err)
17381738 return err;
1739+ if (unlikely(path[k].p_idx > EXT_LAST_INDEX(path[k].p_hdr))) {
1740+ EXT4_ERROR_INODE(inode,
1741+ "path[%d].p_idx %p > EXT_LAST_INDEX %p",
1742+ k, path[k].p_idx,
1743+ EXT_LAST_INDEX(path[k].p_hdr));
1744+ return -EFSCORRUPTED;
1745+ }
17391746 path[k].p_idx->ei_block = border;
17401747 err = ext4_ext_dirty(handle, inode, path + k);
17411748 if (err)
@@ -1748,6 +1755,14 @@ static int ext4_ext_correct_indexes(handle_t *handle, struct inode *inode, · 6 unmodified lines
17481755 err = ext4_ext_get_access(handle, inode, path + k);
17491756 if (err)
17501757 goto clean;
1758+ if (unlikely(path[k].p_idx > EXT_LAST_INDEX(path[k].p_hdr))) {
1759+ EXT4_ERROR_INODE(inode,
1760+ "path[%d].p_idx %p > EXT_LAST_INDEX %p",
1761+ k, path[k].p_idx,
1762+ EXT_LAST_INDEX(path[k].p_hdr));
1763+ err = -EFSCORRUPTED;
1764+ goto clean;
1765+ }
17511766 path[k].p_idx->ei_block = border;
17521767 err = ext4_ext_dirty(handle, inode, path + k);
17531768 if (err)
@@ -3144,7 +3159,7 @@ static void ext4_zeroout_es(struct inode *inode, struct ext4_extent *ex) · 1390 unmodified lines
31443159 }
31453160
31463161 /* FIXME!! we need to try to merge to left or right after zero-out */
3147−static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex)
3162+int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex)
31483163 {
31493164 ext4_fsblk_t ee_pblock;
31503165 unsigned int ee_len;
@@ -3239,6 +3254,9 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle, · 88 unmodified lines
32393254
32403255 insert_err = PTR_ERR(path);
32413256 err = 0;
3257+ if (insert_err != -ENOSPC && insert_err != -EDQUOT &&
3258+ insert_err != -ENOMEM)
3259+ goto out_path;
32423260
32433261 /*
32443262 * Get a new path to try to zeroout or fix the extent length.
@@ -3255,13 +3273,20 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle, · 10 unmodified lines
32553273 goto out_path;
32563274 }
32573275
3276+ depth = ext_depth(inode);
3277+ ex = path[depth].p_ext;
3278+ if (!ex) {
3279+ EXT4_ERROR_INODE(inode,
3280+ "bad extent address lblock: %lu, depth: %d pblock %llu",
3281+ (unsigned long)ee_block, depth, path[depth].p_block);
3282+ err = -EFSCORRUPTED;
3283+ goto out;
3284+ }
3285+
32583286 err = ext4_ext_get_access(handle, inode, path + depth);
32593287 if (err)
32603288 goto out;
32613289
3262− depth = ext_depth(inode);
3263− ex = path[depth].p_ext;
3264−
32653290 fix_extent_len:
32663291 ex->ee_len = orig_ex.ee_len;
32673292 err = ext4_ext_dirty(handle, inode, path + path->p_depth);
@@ -3363,7 +3388,7 @@ static int ext4_split_extent_zeroout(handle_t *handle, struct inode *inode, · 95 unmodified lines
33633388
33643389 ext4_ext_mark_initialized(ex);
33653390
3366− ext4_ext_dirty(handle, inode, path + depth);
3391+ err = ext4_ext_dirty(handle, inode, path + depth);
33673392 if (err)
33683393 return err;
33693394
@@ -4457,9 +4482,13 @@ got_allocated_blocks: · 1087 unmodified lines
44574482 path = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
44584483 if (IS_ERR(path)) {
44594484 err = PTR_ERR(path);
4460− if (allocated_clusters) {
4485+ /*
4486+ * Gracefully handle out of space conditions. If the filesystem
4487+ * is inconsistent, we'll just leak allocated blocks to avoid
4488+ * causing even more damage.
4489+ */
4490+ if (allocated_clusters && (err == -EDQUOT || err == -ENOSPC)) {
44614491 int fb_flags = 0;
4462−
44634492 /*
44644493 * free data blocks we just allocated.
44654494 * not a good idea to call discard here directly,
@@ -6238,6 +6267,33 @@ out: · 1772 unmodified lines
62386267 return 0;
62396268 }
62406269
6241−#ifdef CONFIG_EXT4_KUNIT_TESTS
6242−#include "extents-test.c"
6270+#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)
6271+int ext4_ext_space_root_idx_test(struct inode *inode, int check)
6272+{
6273+ return ext4_ext_space_root_idx(inode, check);
6274+}
6275+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_space_root_idx_test);
6276+
6277+struct ext4_ext_path *ext4_split_convert_extents_test(handle_t *handle,
6278+ struct inode *inode, struct ext4_map_blocks *map,
6279+ struct ext4_ext_path *path, int flags,
6280+ unsigned int *allocated)
6281+{
6282+ return ext4_split_convert_extents(handle, inode, map, path,
6283+ flags, allocated);
6284+}
6285+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_split_convert_extents_test);
6286+
6287+EXPORT_SYMBOL_FOR_EXT4_TEST(__ext4_ext_dirty);
6288+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_zeroout);
6289+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_register_shrinker);
6290+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_unregister_shrinker);
6291+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_map_create_blocks);
6292+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_init_tree);
6293+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_lookup_extent);
6294+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_insert_extent);
6295+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_insert_extent);
6296+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_find_extent);
6297+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_issue_zeroout);
6298+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_map_query_blocks);
62436299 #endif
fs/ext4/fast_commit.c+10−7
@@ -975,13 +975,13 @@ static int ext4_fc_flush_data(journal_t *journal) · 974 unmodified lines
975975 int ret = 0;
976976
977977 list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {
978− ret = jbd2_submit_inode_data(journal, ei->jinode);
978+ ret = jbd2_submit_inode_data(journal, READ_ONCE(ei->jinode));
979979 if (ret)
980980 return ret;
981981 }
982982
983983 list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {
984− ret = jbd2_wait_inode_data(journal, ei->jinode);
984+ ret = jbd2_wait_inode_data(journal, READ_ONCE(ei->jinode));
985985 if (ret)
986986 return ret;
987987 }
@@ -1613,19 +1613,21 @@ static int ext4_fc_replay_inode(struct super_block *sb, · 625 unmodified lines
16131613 /* Immediately update the inode on disk. */
16141614 ret = ext4_handle_dirty_metadata(NULL, NULL, iloc.bh);
16151615 if (ret)
1616− goto out;
1616+ goto out_brelse;
16171617 ret = sync_dirty_buffer(iloc.bh);
16181618 if (ret)
1619− goto out;
1619+ goto out_brelse;
16201620 ret = ext4_mark_inode_used(sb, ino);
16211621 if (ret)
1622− goto out;
1622+ goto out_brelse;
16231623
16241624 /* Given that we just wrote the inode on disk, this SHOULD succeed. */
16251625 inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
16261626 if (IS_ERR(inode)) {
16271627 ext4_debug("Inode not found.");
1628− return -EFSCORRUPTED;
1628+ inode = NULL;
1629+ ret = -EFSCORRUPTED;
1630+ goto out_brelse;
16291631 }
16301632
16311633 /*
@@ -1642,13 +1644,14 @@ static int ext4_fc_replay_inode(struct super_block *sb, · 10 unmodified lines
16421644 ext4_inode_csum_set(inode, ext4_raw_inode(&iloc), EXT4_I(inode));
16431645 ret = ext4_handle_dirty_metadata(NULL, NULL, iloc.bh);
16441646 sync_dirty_buffer(iloc.bh);
1647+out_brelse:
16451648 brelse(iloc.bh);
16461649 out:
16471650 iput(inode);
16481651 if (!ret)
16491652 blkdev_issue_flush(sb->s_bdev);
16501653
1651− return 0;
1654+ return ret;
16521655 }
16531656
16541657 /*
fs/ext4/fsync.c+14−2
@@ -83,11 +83,23 @@ static int ext4_fsync_nojournal(struct file *file, loff_t start, loff_t end, · 82 unmodified lines
8383 int datasync, bool *needs_barrier)
8484 {
8585 struct inode *inode = file->f_inode;
86+ struct writeback_control wbc = {
87+ .sync_mode = WB_SYNC_ALL,
88+ .nr_to_write = 0,
89+ };
8690 int ret;
8791
8892 ret = generic_buffers_fsync_noflush(file, start, end, datasync);
89− if (!ret)
90− ret = ext4_sync_parent(inode);
93+ if (ret)
94+ return ret;
95+
96+ /* Force writeout of inode table buffer to disk */
97+ ret = ext4_write_inode(inode, &wbc);
98+ if (ret)
99+ return ret;
100+
101+ ret = ext4_sync_parent(inode);
102+
91103 if (test_opt(inode->i_sb, BARRIER))
92104 *needs_barrier = true;
93105
fs/ext4/ialloc.c+6−0
@@ -686,6 +686,12 @@ static int recently_deleted(struct super_block *sb, ext4_group_t group, int ino) · 685 unmodified lines
686686 if (unlikely(!gdp))
687687 return 0;
688688
689+ /* Inode was never used in this filesystem? */
690+ if (ext4_has_group_desc_csum(sb) &&
691+ (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
692+ ino >= EXT4_INODES_PER_GROUP(sb) - ext4_itable_unused_count(sb, gdp)))
693+ return 0;
694+
689695 bh = sb_find_get_block(sb, ext4_inode_table(sb, gdp) +
690696 (ino / inodes_per_block));
691697 if (!bh || !buffer_uptodate(bh))
fs/ext4/inline.c+9−1
@@ -522,7 +522,15 @@ static int ext4_read_inline_folio(struct inode *inode, struct folio *folio) · 521 unmodified lines
522522 goto out;
523523
524524 len = min_t(size_t, ext4_get_inline_size(inode), i_size_read(inode));
525− BUG_ON(len > PAGE_SIZE);
525+
526+ if (len > PAGE_SIZE) {
527+ ext4_error_inode(inode, __func__, __LINE__, 0,
528+ "inline size %zu exceeds PAGE_SIZE", len);
529+ ret = -EFSCORRUPTED;
530+ brelse(iloc.bh);
531+ goto out;
532+ }
533+
526534 kaddr = kmap_local_folio(folio, 0);
527535 ret = ext4_read_inline_data(inode, kaddr, len, &iloc);
528536 kaddr = folio_zero_tail(folio, len, kaddr + len);
fs/ext4/inode.c+60−15
@@ -128,6 +128,8 @@ void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw, · 127 unmodified lines
128128 static inline int ext4_begin_ordered_truncate(struct inode *inode,
129129 loff_t new_size)
130130 {
131+ struct jbd2_inode *jinode = READ_ONCE(EXT4_I(inode)->jinode);
132+
131133 trace_ext4_begin_ordered_truncate(inode, new_size);
132134 /*
133135 * If jinode is zero, then we never opened the file for
@@ -135,10 +137,10 @@ static inline int ext4_begin_ordered_truncate(struct inode *inode, · 1 unmodified line
135137 * jbd2_journal_begin_ordered_truncate() since there's no
136138 * outstanding writes we need to flush.
137139 */
138− if (!EXT4_I(inode)->jinode)
140+ if (!jinode)
139141 return 0;
140142 return jbd2_journal_begin_ordered_truncate(EXT4_JOURNAL(inode),
141− EXT4_I(inode)->jinode,
143+ jinode,
142144 new_size);
143145 }
144146
@@ -184,6 +186,14 @@ void ext4_evict_inode(struct inode *inode) · 39 unmodified lines
184186 if (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)
185187 ext4_evict_ea_inode(inode);
186188 if (inode->i_nlink) {
189+ /*
190+ * If there's dirty page will lead to data loss, user
191+ * could see stale data.
192+ */
193+ if (unlikely(!ext4_emergency_state(inode->i_sb) &&
194+ mapping_tagged(&inode->i_data, PAGECACHE_TAG_DIRTY)))
195+ ext4_warning_inode(inode, "data will be lost");
196+
187197 truncate_inode_pages_final(&inode->i_data);
188198
189199 goto no_delete;
@@ -4451,8 +4461,13 @@ int ext4_inode_attach_jinode(struct inode *inode) · 4261 unmodified lines
44514461 spin_unlock(&inode->i_lock);
44524462 return -ENOMEM;
44534463 }
4454− ei->jinode = jinode;
4455− jbd2_journal_init_jbd_inode(ei->jinode, inode);
4464+ jbd2_journal_init_jbd_inode(jinode, inode);
4465+ /*
4466+ * Publish ->jinode only after it is fully initialized so that
4467+ * readers never observe a partially initialized jbd2_inode.
4468+ */
4469+ smp_wmb();
4470+ WRITE_ONCE(ei->jinode, jinode);
44564471 jinode = NULL;
44574472 }
44584473 spin_unlock(&inode->i_lock);
@@ -5401,18 +5416,36 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, · 942 unmodified lines
54015416 inode->i_op = &ext4_encrypted_symlink_inode_operations;
54025417 } else if (ext4_inode_is_fast_symlink(inode)) {
54035418 inode->i_op = &ext4_fast_symlink_inode_operations;
5404− if (inode->i_size == 0 ||
5405− inode->i_size >= sizeof(ei->i_data) ||
5406− strnlen((char *)ei->i_data, inode->i_size + 1) !=
5407− inode->i_size) {
5408− ext4_error_inode(inode, function, line, 0,
5409− "invalid fast symlink length %llu",
5410− (unsigned long long)inode->i_size);
5411− ret = -EFSCORRUPTED;
5412− goto bad_inode;
5419+
5420+ /*
5421+ * Orphan cleanup can see inodes with i_size == 0
5422+ * and i_data uninitialized. Skip size checks in
5423+ * that case. This is safe because the first thing
5424+ * ext4_evict_inode() does for fast symlinks is
5425+ * clearing of i_data and i_size.
5426+ */
5427+ if ((EXT4_SB(sb)->s_mount_state & EXT4_ORPHAN_FS)) {
5428+ if (inode->i_nlink != 0) {
5429+ ext4_error_inode(inode, function, line, 0,
5430+ "invalid orphan symlink nlink %d",
5431+ inode->i_nlink);
5432+ ret = -EFSCORRUPTED;
5433+ goto bad_inode;
5434+ }
5435+ } else {
5436+ if (inode->i_size == 0 ||
5437+ inode->i_size >= sizeof(ei->i_data) ||
5438+ strnlen((char *)ei->i_data, inode->i_size + 1) !=
5439+ inode->i_size) {
5440+ ext4_error_inode(inode, function, line, 0,
5441+ "invalid fast symlink length %llu",
5442+ (unsigned long long)inode->i_size);
5443+ ret = -EFSCORRUPTED;
5444+ goto bad_inode;
5445+ }
5446+ inode_set_cached_link(inode, (char *)ei->i_data,
5447+ inode->i_size);
54135448 }
5414− inode_set_cached_link(inode, (char *)ei->i_data,
5415− inode->i_size);
54165449 } else {
54175450 inode->i_op = &ext4_symlink_inode_operations;
54185451 }
@@ -5849,6 +5882,18 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry, · 430 unmodified lines
58495882 if (attr->ia_size == inode->i_size)
58505883 inc_ivers = false;
58515884
5885+ /*
5886+ * If file has inline data but new size exceeds inline capacity,
5887+ * convert to extent-based storage first to prevent inconsistent
5888+ * state (inline flag set but size exceeds inline capacity).
5889+ */
5890+ if (ext4_has_inline_data(inode) &&
5891+ attr->ia_size > EXT4_I(inode)->i_inline_size) {
5892+ error = ext4_convert_inline_data(inode);
5893+ if (error)
5894+ goto err_out;
5895+ }
5896+
58525897 if (shrink) {
58535898 if (ext4_should_order_data(inode)) {
58545899 error = ext4_begin_ordered_truncate(inode,
fs/ext4/mballoc-test.c+41−40
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include <linux/random.h>
99
1010 #include "ext4.h"
11+#include "mballoc.h"
1112
1213 struct mbt_grp_ctx {
1314 struct buffer_head bitmap_bh;
@@ -336,7 +337,7 @@ ext4_mb_mark_context_stub(handle_t *handle, struct super_block *sb, bool state, · 322 unmodified lines
336337 if (state)
337338 mb_set_bits(bitmap_bh->b_data, blkoff, len);
338339 else
339− mb_clear_bits(bitmap_bh->b_data, blkoff, len);
340+ mb_clear_bits_test(bitmap_bh->b_data, blkoff, len);
340341
341342 return 0;
342343 }
@@ -413,14 +414,14 @@ static void test_new_blocks_simple(struct kunit *test) · 70 unmodified lines
413414
414415 /* get block at goal */
415416 ar.goal = ext4_group_first_block_no(sb, goal_group);
416− found = ext4_mb_new_blocks_simple(&ar, &err);
417+ found = ext4_mb_new_blocks_simple_test(&ar, &err);
417418 KUNIT_ASSERT_EQ_MSG(test, ar.goal, found,
418419 "failed to alloc block at goal, expected %llu found %llu",
419420 ar.goal, found);
420421
421422 /* get block after goal in goal group */
422423 ar.goal = ext4_group_first_block_no(sb, goal_group);
423− found = ext4_mb_new_blocks_simple(&ar, &err);
424+ found = ext4_mb_new_blocks_simple_test(&ar, &err);
424425 KUNIT_ASSERT_EQ_MSG(test, ar.goal + EXT4_C2B(sbi, 1), found,
425426 "failed to alloc block after goal in goal group, expected %llu found %llu",
426427 ar.goal + 1, found);
@@ -428,7 +429,7 @@ static void test_new_blocks_simple(struct kunit *test) · 1 unmodified line
428429 /* get block after goal group */
429430 mbt_ctx_mark_used(sb, goal_group, 0, EXT4_CLUSTERS_PER_GROUP(sb));
430431 ar.goal = ext4_group_first_block_no(sb, goal_group);
431− found = ext4_mb_new_blocks_simple(&ar, &err);
432+ found = ext4_mb_new_blocks_simple_test(&ar, &err);
432433 KUNIT_ASSERT_EQ_MSG(test,
433434 ext4_group_first_block_no(sb, goal_group + 1), found,
434435 "failed to alloc block after goal group, expected %llu found %llu",
@@ -438,7 +439,7 @@ static void test_new_blocks_simple(struct kunit *test) · 3 unmodified lines
438439 for (i = goal_group; i < ext4_get_groups_count(sb); i++)
439440 mbt_ctx_mark_used(sb, i, 0, EXT4_CLUSTERS_PER_GROUP(sb));
440441 ar.goal = ext4_group_first_block_no(sb, goal_group);
441− found = ext4_mb_new_blocks_simple(&ar, &err);
442+ found = ext4_mb_new_blocks_simple_test(&ar, &err);
442443 KUNIT_ASSERT_EQ_MSG(test,
443444 ext4_group_first_block_no(sb, 0) + EXT4_C2B(sbi, 1), found,
444445 "failed to alloc block before goal group, expected %llu found %llu",
@@ -448,7 +449,7 @@ static void test_new_blocks_simple(struct kunit *test) · 3 unmodified lines
448449 for (i = 0; i < ext4_get_groups_count(sb); i++)
449450 mbt_ctx_mark_used(sb, i, 0, EXT4_CLUSTERS_PER_GROUP(sb));
450451 ar.goal = ext4_group_first_block_no(sb, goal_group);
451− found = ext4_mb_new_blocks_simple(&ar, &err);
452+ found = ext4_mb_new_blocks_simple_test(&ar, &err);
452453 KUNIT_ASSERT_NE_MSG(test, err, 0,
453454 "unexpectedly get block when no block is available");
454455 }
@@ -492,16 +493,16 @@ validate_free_blocks_simple(struct kunit *test, struct super_block *sb, · 37 unmodified lines
492493 continue;
493494
494495 bitmap = mbt_ctx_bitmap(sb, i);
495− bit = mb_find_next_zero_bit(bitmap, max, 0);
496+ bit = mb_find_next_zero_bit_test(bitmap, max, 0);
496497 KUNIT_ASSERT_EQ_MSG(test, bit, max,
497498 "free block on unexpected group %d", i);
498499 }
499500
500501 bitmap = mbt_ctx_bitmap(sb, goal_group);
501− bit = mb_find_next_zero_bit(bitmap, max, 0);
502+ bit = mb_find_next_zero_bit_test(bitmap, max, 0);
502503 KUNIT_ASSERT_EQ(test, bit, start);
503504
504− bit = mb_find_next_bit(bitmap, max, bit + 1);
505+ bit = mb_find_next_bit_test(bitmap, max, bit + 1);
505506 KUNIT_ASSERT_EQ(test, bit, start + len);
506507 }
507508
@@ -524,7 +525,7 @@ test_free_blocks_simple_range(struct kunit *test, ext4_group_t goal_group, · 16 unmodified lines
524525
525526 block = ext4_group_first_block_no(sb, goal_group) +
526527 EXT4_C2B(sbi, start);
527− ext4_free_blocks_simple(inode, block, len);
528+ ext4_free_blocks_simple_test(inode, block, len);
528529 validate_free_blocks_simple(test, sb, goal_group, start, len);
529530 mbt_ctx_mark_used(sb, goal_group, 0, EXT4_CLUSTERS_PER_GROUP(sb));
530531 }
@@ -566,15 +567,15 @@ test_mark_diskspace_used_range(struct kunit *test, · 35 unmodified lines
566567
567568 bitmap = mbt_ctx_bitmap(sb, TEST_GOAL_GROUP);
568569 memset(bitmap, 0, sb->s_blocksize);
569− ret = ext4_mb_mark_diskspace_used(ac, NULL);
570+ ret = ext4_mb_mark_diskspace_used_test(ac, NULL);
570571 KUNIT_ASSERT_EQ(test, ret, 0);
571572
572573 max = EXT4_CLUSTERS_PER_GROUP(sb);
573− i = mb_find_next_bit(bitmap, max, 0);
574+ i = mb_find_next_bit_test(bitmap, max, 0);
574575 KUNIT_ASSERT_EQ(test, i, start);
575− i = mb_find_next_zero_bit(bitmap, max, i + 1);
576+ i = mb_find_next_zero_bit_test(bitmap, max, i + 1);
576577 KUNIT_ASSERT_EQ(test, i, start + len);
577− i = mb_find_next_bit(bitmap, max, i + 1);
578+ i = mb_find_next_bit_test(bitmap, max, i + 1);
578579 KUNIT_ASSERT_EQ(test, max, i);
579580 }
580581
@@ -617,54 +618,54 @@ static void mbt_generate_buddy(struct super_block *sb, void *buddy, · 36 unmodified lines
617618 max = EXT4_CLUSTERS_PER_GROUP(sb);
618619 bb_h = buddy + sbi->s_mb_offsets[1];
619620
620− off = mb_find_next_zero_bit(bb, max, 0);
621+ off = mb_find_next_zero_bit_test(bb, max, 0);
621622 grp->bb_first_free = off;
622623 while (off < max) {
623624 grp->bb_counters[0]++;
624625 grp->bb_free++;
625626
626− if (!(off & 1) && !mb_test_bit(off + 1, bb)) {
627+ if (!(off & 1) && !mb_test_bit_test(off + 1, bb)) {
627628 grp->bb_free++;
628629 grp->bb_counters[0]--;
629− mb_clear_bit(off >> 1, bb_h);
630+ mb_clear_bit_test(off >> 1, bb_h);
630631 grp->bb_counters[1]++;
631632 grp->bb_largest_free_order = 1;
632633 off++;
633634 }
634635
635− off = mb_find_next_zero_bit(bb, max, off + 1);
636+ off = mb_find_next_zero_bit_test(bb, max, off + 1);
636637 }
637638
638639 for (order = 1; order < MB_NUM_ORDERS(sb) - 1; order++) {
639640 bb = buddy + sbi->s_mb_offsets[order];
640641 bb_h = buddy + sbi->s_mb_offsets[order + 1];
641642 max = max >> 1;
642− off = mb_find_next_zero_bit(bb, max, 0);
643+ off = mb_find_next_zero_bit_test(bb, max, 0);
643644
644645 while (off < max) {
645− if (!(off & 1) && !mb_test_bit(off + 1, bb)) {
646+ if (!(off & 1) && !mb_test_bit_test(off + 1, bb)) {
646647 mb_set_bits(bb, off, 2);
647648 grp->bb_counters[order] -= 2;
648− mb_clear_bit(off >> 1, bb_h);
649+ mb_clear_bit_test(off >> 1, bb_h);
649650 grp->bb_counters[order + 1]++;
650651 grp->bb_largest_free_order = order + 1;
651652 off++;
652653 }
653654
654− off = mb_find_next_zero_bit(bb, max, off + 1);
655+ off = mb_find_next_zero_bit_test(bb, max, off + 1);
655656 }
656657 }
657658
658659 max = EXT4_CLUSTERS_PER_GROUP(sb);
659− off = mb_find_next_zero_bit(bitmap, max, 0);
660+ off = mb_find_next_zero_bit_test(bitmap, max, 0);
660661 while (off < max) {
661662 grp->bb_fragments++;
662663
663− off = mb_find_next_bit(bitmap, max, off + 1);
664+ off = mb_find_next_bit_test(bitmap, max, off + 1);
664665 if (off + 1 >= max)
665666 break;
666667
667− off = mb_find_next_zero_bit(bitmap, max, off + 1);
668+ off = mb_find_next_zero_bit_test(bitmap, max, off + 1);
668669 }
669670 }
670671
@@ -706,7 +707,7 @@ do_test_generate_buddy(struct kunit *test, struct super_block *sb, void *bitmap, · 35 unmodified lines
706707 /* needed by validation in ext4_mb_generate_buddy */
707708 ext4_grp->bb_free = mbt_grp->bb_free;
708709 memset(ext4_buddy, 0xff, sb->s_blocksize);
709− ext4_mb_generate_buddy(sb, ext4_buddy, bitmap, TEST_GOAL_GROUP,
710+ ext4_mb_generate_buddy_test(sb, ext4_buddy, bitmap, TEST_GOAL_GROUP,
710711 ext4_grp);
711712
712713 KUNIT_ASSERT_EQ(test, memcmp(mbt_buddy, ext4_buddy, sb->s_blocksize),
@@ -760,7 +761,7 @@ test_mb_mark_used_range(struct kunit *test, struct ext4_buddy *e4b, · 47 unmodified lines
760761 ex.fe_group = TEST_GOAL_GROUP;
761762
762763 ext4_lock_group(sb, TEST_GOAL_GROUP);
763− mb_mark_used(e4b, &ex);
764+ mb_mark_used_test(e4b, &ex);
764765 ext4_unlock_group(sb, TEST_GOAL_GROUP);
765766
766767 mb_set_bits(bitmap, start, len);
@@ -769,7 +770,7 @@ test_mb_mark_used_range(struct kunit *test, struct ext4_buddy *e4b, · 2 unmodified lines
769770 memset(buddy, 0xff, sb->s_blocksize);
770771 for (i = 0; i < MB_NUM_ORDERS(sb); i++)
771772 grp->bb_counters[i] = 0;
772− ext4_mb_generate_buddy(sb, buddy, bitmap, 0, grp);
773+ ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp);
773774
774775 KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize),
775776 0);
@@ -798,7 +799,7 @@ static void test_mb_mark_used(struct kunit *test) · 22 unmodified lines
798799 bb_counters[MB_NUM_ORDERS(sb)]), GFP_KERNEL);
799800 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, grp);
800801
801− ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b);
802+ ret = ext4_mb_load_buddy_test(sb, TEST_GOAL_GROUP, &e4b);
802803 KUNIT_ASSERT_EQ(test, ret, 0);
803804
804805 grp->bb_free = EXT4_CLUSTERS_PER_GROUP(sb);
@@ -809,7 +810,7 @@ static void test_mb_mark_used(struct kunit *test) · 4 unmodified lines
809810 test_mb_mark_used_range(test, &e4b, ranges[i].start,
810811 ranges[i].len, bitmap, buddy, grp);
811812
812− ext4_mb_unload_buddy(&e4b);
813+ ext4_mb_unload_buddy_test(&e4b);
813814 }
814815
815816 static void
@@ -825,16 +826,16 @@ test_mb_free_blocks_range(struct kunit *test, struct ext4_buddy *e4b, · 9 unmodified lines
825826 return;
826827
827828 ext4_lock_group(sb, e4b->bd_group);
828− mb_free_blocks(NULL, e4b, start, len);
829+ mb_free_blocks_test(NULL, e4b, start, len);
829830 ext4_unlock_group(sb, e4b->bd_group);
830831
831− mb_clear_bits(bitmap, start, len);
832+ mb_clear_bits_test(bitmap, start, len);
832833 /* bypass bb_free validatoin in ext4_mb_generate_buddy */
833834 grp->bb_free += len;
834835 memset(buddy, 0xff, sb->s_blocksize);
835836 for (i = 0; i < MB_NUM_ORDERS(sb); i++)
836837 grp->bb_counters[i] = 0;
837− ext4_mb_generate_buddy(sb, buddy, bitmap, 0, grp);
838+ ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp);
838839
839840 KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize),
840841 0);
@@ -865,7 +866,7 @@ static void test_mb_free_blocks(struct kunit *test) · 24 unmodified lines
865866 bb_counters[MB_NUM_ORDERS(sb)]), GFP_KERNEL);
866867 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, grp);
867868
868− ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b);
869+ ret = ext4_mb_load_buddy_test(sb, TEST_GOAL_GROUP, &e4b);
869870 KUNIT_ASSERT_EQ(test, ret, 0);
870871
871872 ex.fe_start = 0;
@@ -873,7 +874,7 @@ static void test_mb_free_blocks(struct kunit *test) · 1 unmodified line
873874 ex.fe_group = TEST_GOAL_GROUP;
874875
875876 ext4_lock_group(sb, TEST_GOAL_GROUP);
876− mb_mark_used(&e4b, &ex);
877+ mb_mark_used_test(&e4b, &ex);
877878 ext4_unlock_group(sb, TEST_GOAL_GROUP);
878879
879880 grp->bb_free = 0;
@@ -886,7 +887,7 @@ static void test_mb_free_blocks(struct kunit *test) · 6 unmodified lines
886887 test_mb_free_blocks_range(test, &e4b, ranges[i].start,
887888 ranges[i].len, bitmap, buddy, grp);
888889
889− ext4_mb_unload_buddy(&e4b);
890+ ext4_mb_unload_buddy_test(&e4b);
890891 }
891892
892893 #define COUNT_FOR_ESTIMATE 100000
@@ -904,7 +905,7 @@ static void test_mb_mark_used_cost(struct kunit *test) · 11 unmodified lines
904905 if (sb->s_blocksize > PAGE_SIZE)
905906 kunit_skip(test, "blocksize exceeds pagesize");
906907
907− ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b);
908+ ret = ext4_mb_load_buddy_test(sb, TEST_GOAL_GROUP, &e4b);
908909 KUNIT_ASSERT_EQ(test, ret, 0);
909910
910911 ex.fe_group = TEST_GOAL_GROUP;
@@ -918,7 +919,7 @@ static void test_mb_mark_used_cost(struct kunit *test) · 7 unmodified lines
918919 ex.fe_start = ranges[i].start;
919920 ex.fe_len = ranges[i].len;
920921 ext4_lock_group(sb, TEST_GOAL_GROUP);
921− mb_mark_used(&e4b, &ex);
922+ mb_mark_used_test(&e4b, &ex);
922923 ext4_unlock_group(sb, TEST_GOAL_GROUP);
923924 }
924925 end = jiffies;
@@ -929,14 +930,14 @@ static void test_mb_mark_used_cost(struct kunit *test) · 4 unmodified lines
929930 continue;
930931
931932 ext4_lock_group(sb, TEST_GOAL_GROUP);
932− mb_free_blocks(NULL, &e4b, ranges[i].start,
933+ mb_free_blocks_test(NULL, &e4b, ranges[i].start,
933934 ranges[i].len);
934935 ext4_unlock_group(sb, TEST_GOAL_GROUP);
935936 }
936937 }
937938
938939 kunit_info(test, "costed jiffies %lu\n", all);
939− ext4_mb_unload_buddy(&e4b);
940+ ext4_mb_unload_buddy_test(&e4b);
940941 }
941942
942943 static const struct mbt_ext4_block_layout mbt_test_layouts[] = {
fs/ext4/mballoc.c+114−18
@@ -1199,6 +1199,8 @@ static int ext4_mb_scan_groups(struct ext4_allocation_context *ac) · 1198 unmodified lines
11991199
12001200 /* searching for the right group start from the goal value specified */
12011201 start = ac->ac_g_ex.fe_group;
1202+ if (start >= ngroups)
1203+ start = 0;
12021204 ac->ac_prefetch_grp = start;
12031205 ac->ac_prefetch_nr = 0;
12041206
@@ -2443,8 +2445,12 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, · 1238 unmodified lines
24432445 return 0;
24442446
24452447 err = ext4_mb_load_buddy(ac->ac_sb, group, e4b);
2446− if (err)
2448+ if (err) {
2449+ if (EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info) &&
2450+ !(ac->ac_flags & EXT4_MB_HINT_GOAL_ONLY))
2451+ return 0;
24472452 return err;
2453+ }
24482454
24492455 ext4_lock_group(ac->ac_sb, group);
24502456 if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info)))
@@ -3580,9 +3586,7 @@ err_freebuddy: · 1129 unmodified lines
35803586 rcu_read_unlock();
35813587 iput(sbi->s_buddy_cache);
35823588 err_freesgi:
3583− rcu_read_lock();
3584− kvfree(rcu_dereference(sbi->s_group_info));
3585− rcu_read_unlock();
3589+ kvfree(rcu_access_pointer(sbi->s_group_info));
35863590 return -ENOMEM;
35873591 }
35883592
@@ -3889,15 +3893,14 @@ void ext4_mb_release(struct super_block *sb) · 300 unmodified lines
38893893 struct kmem_cache *cachep = get_groupinfo_cache(sb->s_blocksize_bits);
38903894 int count;
38913895
3892− if (test_opt(sb, DISCARD)) {
3893− /*
3894− * wait the discard work to drain all of ext4_free_data
3895− */
3896− flush_work(&sbi->s_discard_work);
3897− WARN_ON_ONCE(!list_empty(&sbi->s_discard_list));
3898− }
3896+ /*
3897+ * wait the discard work to drain all of ext4_free_data
3898+ */
3899+ flush_work(&sbi->s_discard_work);
3900+ WARN_ON_ONCE(!list_empty(&sbi->s_discard_list));
38993901
3900− if (sbi->s_group_info) {
3902+ group_info = rcu_access_pointer(sbi->s_group_info);
3903+ if (group_info) {
39013904 for (i = 0; i < ngroups; i++) {
39023905 cond_resched();
39033906 grinfo = ext4_get_group_info(sb, i);
@@ -3915,12 +3918,9 @@ void ext4_mb_release(struct super_block *sb) · 11 unmodified lines
39153918 num_meta_group_infos = (ngroups +
39163919 EXT4_DESC_PER_BLOCK(sb) - 1) >>
39173920 EXT4_DESC_PER_BLOCK_BITS(sb);
3918− rcu_read_lock();
3919− group_info = rcu_dereference(sbi->s_group_info);
39203921 for (i = 0; i < num_meta_group_infos; i++)
39213922 kfree(group_info[i]);
39223923 kvfree(group_info);
3923− rcu_read_unlock();
39243924 }
39253925 ext4_mb_avg_fragment_size_destroy(sbi);
39263926 ext4_mb_largest_free_orders_destroy(sbi);
@@ -4084,7 +4084,7 @@ void ext4_exit_mballoc(void) · 157 unmodified lines
40844084
40854085 #define EXT4_MB_BITMAP_MARKED_CHECK 0x0001
40864086 #define EXT4_MB_SYNC_UPDATE 0x0002
4087−static int
4087+int
40884088 ext4_mb_mark_context(handle_t *handle, struct super_block *sb, bool state,
40894089 ext4_group_t group, ext4_grpblk_t blkoff,
40904090 ext4_grpblk_t len, int flags, ext4_grpblk_t *ret_changed)
@@ -7188,6 +7188,102 @@ out_unload: · 3097 unmodified lines
71887188 return error;
71897189 }
71907190
7191−#ifdef CONFIG_EXT4_KUNIT_TESTS
7192−#include "mballoc-test.c"
7191+#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)
7192+void mb_clear_bits_test(void *bm, int cur, int len)
7193+{
7194+ mb_clear_bits(bm, cur, len);
7195+}
7196+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_clear_bits_test);
7197+
7198+ext4_fsblk_t
7199+ext4_mb_new_blocks_simple_test(struct ext4_allocation_request *ar,
7200+ int *errp)
7201+{
7202+ return ext4_mb_new_blocks_simple(ar, errp);
7203+}
7204+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_new_blocks_simple_test);
7205+
7206+int mb_find_next_zero_bit_test(void *addr, int max, int start)
7207+{
7208+ return mb_find_next_zero_bit(addr, max, start);
7209+}
7210+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_find_next_zero_bit_test);
7211+
7212+int mb_find_next_bit_test(void *addr, int max, int start)
7213+{
7214+ return mb_find_next_bit(addr, max, start);
7215+}
7216+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_find_next_bit_test);
7217+
7218+void mb_clear_bit_test(int bit, void *addr)
7219+{
7220+ mb_clear_bit(bit, addr);
7221+}
7222+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_clear_bit_test);
7223+
7224+int mb_test_bit_test(int bit, void *addr)
7225+{
7226+ return mb_test_bit(bit, addr);
7227+}
7228+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_test_bit_test);
7229+
7230+int ext4_mb_mark_diskspace_used_test(struct ext4_allocation_context *ac,
7231+ handle_t *handle)
7232+{
7233+ return ext4_mb_mark_diskspace_used(ac, handle);
7234+}
7235+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_mark_diskspace_used_test);
7236+
7237+int mb_mark_used_test(struct ext4_buddy *e4b, struct ext4_free_extent *ex)
7238+{
7239+ return mb_mark_used(e4b, ex);
7240+}
7241+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_mark_used_test);
7242+
7243+void ext4_mb_generate_buddy_test(struct super_block *sb, void *buddy,
7244+ void *bitmap, ext4_group_t group,
7245+ struct ext4_group_info *grp)
7246+{
7247+ ext4_mb_generate_buddy(sb, buddy, bitmap, group, grp);
7248+}
7249+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_generate_buddy_test);
7250+
7251+int ext4_mb_load_buddy_test(struct super_block *sb, ext4_group_t group,
7252+ struct ext4_buddy *e4b)
7253+{
7254+ return ext4_mb_load_buddy(sb, group, e4b);
7255+}
7256+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_load_buddy_test);
7257+
7258+void ext4_mb_unload_buddy_test(struct ext4_buddy *e4b)
7259+{
7260+ ext4_mb_unload_buddy(e4b);
7261+}
7262+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_unload_buddy_test);
7263+
7264+void mb_free_blocks_test(struct inode *inode, struct ext4_buddy *e4b,
7265+ int first, int count)
7266+{
7267+ mb_free_blocks(inode, e4b, first, count);
7268+}
7269+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_free_blocks_test);
7270+
7271+void ext4_free_blocks_simple_test(struct inode *inode, ext4_fsblk_t block,
7272+ unsigned long count)
7273+{
7274+ return ext4_free_blocks_simple(inode, block, count);
7275+}
7276+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_free_blocks_simple_test);
7277+
7278+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_wait_block_bitmap);
7279+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_init);
7280+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_get_group_desc);
7281+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_count_free_clusters);
7282+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_get_group_info);
7283+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_free_group_clusters_set);
7284+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_release);
7285+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_read_block_bitmap_nowait);
7286+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_set_bits);
7287+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_fc_init_inode);
7288+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_mark_context);
71937289 #endif
fs/ext4/mballoc.h+30−0
@@ -270,4 +270,34 @@ ext4_mballoc_query_range( · 269 unmodified lines
270270 ext4_mballoc_query_range_fn formatter,
271271 void *priv);
272272
273+extern int ext4_mb_mark_context(handle_t *handle,
274+ struct super_block *sb, bool state,
275+ ext4_group_t group, ext4_grpblk_t blkoff,
276+ ext4_grpblk_t len, int flags,
277+ ext4_grpblk_t *ret_changed);
278+#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)
279+extern void mb_clear_bits_test(void *bm, int cur, int len);
280+extern ext4_fsblk_t
281+ext4_mb_new_blocks_simple_test(struct ext4_allocation_request *ar,
282+ int *errp);
283+extern int mb_find_next_zero_bit_test(void *addr, int max, int start);
284+extern int mb_find_next_bit_test(void *addr, int max, int start);
285+extern void mb_clear_bit_test(int bit, void *addr);
286+extern int mb_test_bit_test(int bit, void *addr);
287+extern int
288+ext4_mb_mark_diskspace_used_test(struct ext4_allocation_context *ac,
289+ handle_t *handle);
290+extern int mb_mark_used_test(struct ext4_buddy *e4b,
291+ struct ext4_free_extent *ex);
292+extern void ext4_mb_generate_buddy_test(struct super_block *sb,
293+ void *buddy, void *bitmap, ext4_group_t group,
294+ struct ext4_group_info *grp);
295+extern int ext4_mb_load_buddy_test(struct super_block *sb,
296+ ext4_group_t group, struct ext4_buddy *e4b);
297+extern void ext4_mb_unload_buddy_test(struct ext4_buddy *e4b);
298+extern void mb_free_blocks_test(struct inode *inode,
299+ struct ext4_buddy *e4b, int first, int count);
300+extern void ext4_free_blocks_simple_test(struct inode *inode,
301+ ext4_fsblk_t block, unsigned long count);
302+#endif
273303 #endif
fs/ext4/page-io.c+8−2
@@ -524,9 +524,15 @@ int ext4_bio_write_folio(struct ext4_io_submit *io, struct folio *folio, · 523 unmodified lines
524524 nr_to_submit++;
525525 } while ((bh = bh->b_this_page) != head);
526526
527− /* Nothing to submit? Just unlock the folio... */
528− if (!nr_to_submit)
527+ if (!nr_to_submit) {
528+ /*
529+ * We have nothing to submit. Just cycle the folio through
530+ * writeback state to properly update xarray tags.
531+ */
532+ __folio_start_writeback(folio, keep_towrite);
533+ folio_end_writeback(folio);
529534 return 0;
535+ }
530536
531537 bh = head = folio_buffers(folio);
532538
fs/ext4/super.c+31−6
@@ -1254,12 +1254,10 @@ static void ext4_group_desc_free(struct ext4_sb_info *sbi) · 1253 unmodified lines
12541254 struct buffer_head **group_desc;
12551255 int i;
12561256
1257− rcu_read_lock();
1258− group_desc = rcu_dereference(sbi->s_group_desc);
1257+ group_desc = rcu_access_pointer(sbi->s_group_desc);
12591258 for (i = 0; i < sbi->s_gdb_count; i++)
12601259 brelse(group_desc[i]);
12611260 kvfree(group_desc);
1262− rcu_read_unlock();
12631261 }
12641262
12651263 static void ext4_flex_groups_free(struct ext4_sb_info *sbi)
@@ -1267,14 +1265,12 @@ static void ext4_flex_groups_free(struct ext4_sb_info *sbi) · 1 unmodified line
12671265 struct flex_groups **flex_groups;
12681266 int i;
12691267
1270− rcu_read_lock();
1271− flex_groups = rcu_dereference(sbi->s_flex_groups);
1268+ flex_groups = rcu_access_pointer(sbi->s_flex_groups);
12721269 if (flex_groups) {
12731270 for (i = 0; i < sbi->s_flex_groups_allocated; i++)
12741271 kvfree(flex_groups[i]);
12751272 kvfree(flex_groups);
12761273 }
1277− rcu_read_unlock();
12781274 }
12791275
12801276 static void ext4_put_super(struct super_block *sb)
@@ -1527,6 +1523,27 @@ void ext4_clear_inode(struct inode *inode) · 246 unmodified lines
15271523 invalidate_inode_buffers(inode);
15281524 clear_inode(inode);
15291525 ext4_discard_preallocations(inode);
1526+ /*
1527+ * We must remove the inode from the hash before ext4_free_inode()
1528+ * clears the bit in inode bitmap as otherwise another process reusing
1529+ * the inode will block in insert_inode_hash() waiting for inode
1530+ * eviction to complete while holding transaction handle open, but
1531+ * ext4_evict_inode() still running for that inode could block waiting
1532+ * for transaction commit if the inode is marked as IS_SYNC => deadlock.
1533+ *
1534+ * Removing the inode from the hash here is safe. There are two cases
1535+ * to consider:
1536+ * 1) The inode still has references to it (i_nlink > 0). In that case
1537+ * we are keeping the inode and once we remove the inode from the hash,
1538+ * iget() can create the new inode structure for the same inode number
1539+ * and we are fine with that as all IO on behalf of the inode is
1540+ * finished.
1541+ * 2) We are deleting the inode (i_nlink == 0). In that case inode
1542+ * number cannot be reused until ext4_free_inode() clears the bit in
1543+ * the inode bitmap, at which point all IO is done and reuse is fine
1544+ * again.
1545+ */
1546+ remove_inode_hash(inode);
15301547 ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);
15311548 dquot_drop(inode);
15321549 if (EXT4_I(inode)->jinode) {
@@ -3633,6 +3650,13 @@ int ext4_feature_set_ok(struct super_block *sb, int readonly) · 2100 unmodified lines
36333650 "extents feature\n");
36343651 return 0;
36353652 }
3653+ if (ext4_has_feature_bigalloc(sb) &&
3654+ le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {
3655+ ext4_msg(sb, KERN_WARNING,
3656+ "bad geometry: bigalloc file system with non-zero "
3657+ "first_data_block\n");
3658+ return 0;
3659+ }
36363660
36373661 #if !IS_ENABLED(CONFIG_QUOTA) || !IS_ENABLED(CONFIG_QFMT_V2)
36383662 if (!readonly && (ext4_has_feature_quota(sb) ||
@@ -5403,6 +5427,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) · 1764 unmodified lines
54035427
54045428 timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
54055429 spin_lock_init(&sbi->s_error_lock);
5430+ mutex_init(&sbi->s_error_notify_mutex);
54065431 INIT_WORK(&sbi->s_sb_upd_work, update_super_work);
54075432
54085433 err = ext4_group_desc_init(sb, es, logical_sb_block, &first_not_zeroed);
fs/ext4/sysfs.c+9−1
@@ -597,7 +597,10 @@ static const struct kobj_type ext4_feat_ktype = { · 596 unmodified lines
597597
598598 void ext4_notify_error_sysfs(struct ext4_sb_info *sbi)
599599 {
600− sysfs_notify(&sbi->s_kobj, NULL, "errors_count");
600+ mutex_lock(&sbi->s_error_notify_mutex);
601+ if (sbi->s_kobj.state_in_sysfs)
602+ sysfs_notify(&sbi->s_kobj, NULL, "errors_count");
603+ mutex_unlock(&sbi->s_error_notify_mutex);
601604 }
602605
603606 static struct kobject *ext4_root;
@@ -610,8 +613,10 @@ int ext4_register_sysfs(struct super_block *sb) · 6 unmodified lines
610613 int err;
611614
612615 init_completion(&sbi->s_kobj_unregister);
616+ mutex_lock(&sbi->s_error_notify_mutex);
613617 err = kobject_init_and_add(&sbi->s_kobj, &ext4_sb_ktype, ext4_root,
614618 "%s", sb->s_id);
619+ mutex_unlock(&sbi->s_error_notify_mutex);
615620 if (err) {
616621 kobject_put(&sbi->s_kobj);
617622 wait_for_completion(&sbi->s_kobj_unregister);
@@ -644,7 +649,10 @@ void ext4_unregister_sysfs(struct super_block *sb) · 26 unmodified lines
644649
645650 if (sbi->s_proc)
646651 remove_proc_subtree(sb->s_id, ext4_proc_root);
652+
653+ mutex_lock(&sbi->s_error_notify_mutex);
647654 kobject_del(&sbi->s_kobj);
655+ mutex_unlock(&sbi->s_error_notify_mutex);
648656 }
649657
650658 int __init ext4_init_sysfs(void)
fs/fs-writeback.c+27−9
@@ -1711,6 +1711,19 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb, · 1710 unmodified lines
17111711 }
17121712 }
17131713
1714+static bool __sync_lazytime(struct inode *inode)
1715+{
1716+ spin_lock(&inode->i_lock);
1717+ if (!(inode_state_read(inode) & I_DIRTY_TIME)) {
1718+ spin_unlock(&inode->i_lock);
1719+ return false;
1720+ }
1721+ inode_state_clear(inode, I_DIRTY_TIME);
1722+ spin_unlock(&inode->i_lock);
1723+ inode->i_op->sync_lazytime(inode);
1724+ return true;
1725+}
1726+
17141727 bool sync_lazytime(struct inode *inode)
17151728 {
17161729 if (!(inode_state_read_once(inode) & I_DIRTY_TIME))
@@ -1718,9 +1731,8 @@ bool sync_lazytime(struct inode *inode) · 1 unmodified line
17181731
17191732 trace_writeback_lazytime(inode);
17201733 if (inode->i_op->sync_lazytime)
1721− inode->i_op->sync_lazytime(inode);
1722− else
1723− mark_inode_dirty_sync(inode);
1734+ return __sync_lazytime(inode);
1735+ mark_inode_dirty_sync(inode);
17241736 return true;
17251737 }
17261738
@@ -2775,13 +2787,8 @@ static void wait_sb_inodes(struct super_block *sb) · 1048 unmodified lines
27752787 * The mapping can appear untagged while still on-list since we
27762788 * do not have the mapping lock. Skip it here, wb completion
27772789 * will remove it.
2778− *
2779− * If the mapping does not have data integrity semantics,
2780− * there's no need to wait for the writeout to complete, as the
2781− * mapping cannot guarantee that data is persistently stored.
27822790 */
2783− if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK) ||
2784− mapping_no_data_integrity(mapping))
2791+ if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))
27852792 continue;
27862793
27872794 spin_unlock_irq(&sb->s_inode_wblist_lock);
@@ -2916,6 +2923,17 @@ void sync_inodes_sb(struct super_block *sb) · 128 unmodified lines
29162923 */
29172924 if (bdi == &noop_backing_dev_info)
29182925 return;
2926+
2927+ /*
2928+ * If the superblock has SB_I_NO_DATA_INTEGRITY set, there's no need to
2929+ * wait for the writeout to complete, as the filesystem cannot guarantee
2930+ * data persistence on sync. Just kick off writeback and return.
2931+ */
2932+ if (sb->s_iflags & SB_I_NO_DATA_INTEGRITY) {
2933+ wakeup_flusher_threads_bdi(bdi, WB_REASON_SYNC);
2934+ return;
2935+ }
2936+
29192937 WARN_ON(!rwsem_is_locked(&sb->s_umount));
29202938
29212939 /* protect against inode wb switch, see inode_switch_wbs_work_fn() */
fs/fuse/file.c+1−3
@@ -3201,10 +3201,8 @@ void fuse_init_file_inode(struct inode *inode, unsigned int flags) · 3200 unmodified lines
32013201
32023202 inode->i_fop = &fuse_file_operations;
32033203 inode->i_data.a_ops = &fuse_file_aops;
3204− if (fc->writeback_cache) {
3204+ if (fc->writeback_cache)
32053205 mapping_set_writeback_may_deadlock_on_reclaim(&inode->i_data);
3206− mapping_set_no_data_integrity(&inode->i_data);
3207− }
32083206
32093207 INIT_LIST_HEAD(&fi->write_files);
32103208 INIT_LIST_HEAD(&fi->queued_writes);
fs/fuse/inode.c+1−0
@@ -1709,6 +1709,7 @@ static void fuse_sb_defaults(struct super_block *sb) · 1708 unmodified lines
17091709 sb->s_export_op = &fuse_export_operations;
17101710 sb->s_iflags |= SB_I_IMA_UNVERIFIABLE_SIGNATURE;
17111711 sb->s_iflags |= SB_I_NOIDMAP;
1712+ sb->s_iflags |= SB_I_NO_DATA_INTEGRITY;
17121713 if (sb->s_user_ns != &init_user_ns)
17131714 sb->s_iflags |= SB_I_UNTRUSTED_MOUNTER;
17141715 sb->s_flags &= ~(SB_NOSEC | SB_I_VERSION);
fs/iomap/bio.c+50−1
@@ -8,7 +8,10 @@ · 7 unmodified lines
88 #include "internal.h"
99 #include "trace.h"
1010
11−static void iomap_read_end_io(struct bio *bio)
11+static DEFINE_SPINLOCK(failed_read_lock);
12+static struct bio_list failed_read_list = BIO_EMPTY_LIST;
13+
14+static void __iomap_read_end_io(struct bio *bio)
1215 {
1316 int error = blk_status_to_errno(bio->bi_status);
1417 struct folio_iter fi;
@@ -18,6 +21,52 @@ static void iomap_read_end_io(struct bio *bio) · 3 unmodified lines
1821 bio_put(bio);
1922 }
2023
24+static void
25+iomap_fail_reads(
26+ struct work_struct *work)
27+{
28+ struct bio *bio;
29+ struct bio_list tmp = BIO_EMPTY_LIST;
30+ unsigned long flags;
31+
32+ spin_lock_irqsave(&failed_read_lock, flags);
33+ bio_list_merge_init(&tmp, &failed_read_list);
34+ spin_unlock_irqrestore(&failed_read_lock, flags);
35+
36+ while ((bio = bio_list_pop(&tmp)) != NULL) {
37+ __iomap_read_end_io(bio);
38+ cond_resched();
39+ }
40+}
41+
42+static DECLARE_WORK(failed_read_work, iomap_fail_reads);
43+
44+static void iomap_fail_buffered_read(struct bio *bio)
45+{
46+ unsigned long flags;
47+
48+ /*
49+ * Bounce I/O errors to a workqueue to avoid nested i_lock acquisitions
50+ * in the fserror code. The caller no longer owns the bio reference
51+ * after the spinlock drops.
52+ */
53+ spin_lock_irqsave(&failed_read_lock, flags);
54+ if (bio_list_empty(&failed_read_list))
55+ WARN_ON_ONCE(!schedule_work(&failed_read_work));
56+ bio_list_add(&failed_read_list, bio);
57+ spin_unlock_irqrestore(&failed_read_lock, flags);
58+}
59+
60+static void iomap_read_end_io(struct bio *bio)
61+{
62+ if (bio->bi_status) {
63+ iomap_fail_buffered_read(bio);
64+ return;
65+ }
66+
67+ __iomap_read_end_io(bio);
68+}
69+
2170 static void iomap_bio_submit_read(struct iomap_read_folio_ctx *ctx)
2271 {
2372 struct bio *bio = ctx->read_ctx;
fs/iomap/buffered-io.c+10−5
@@ -514,6 +514,7 @@ static int iomap_read_folio_iter(struct iomap_iter *iter, · 513 unmodified lines
514514 loff_t length = iomap_length(iter);
515515 struct folio *folio = ctx->cur_folio;
516516 size_t folio_len = folio_size(folio);
517+ struct iomap_folio_state *ifs;
517518 size_t poff, plen;
518519 loff_t pos_diff;
519520 int ret;
@@ -525,7 +526,7 @@ static int iomap_read_folio_iter(struct iomap_iter *iter, · 5 unmodified lines
525526 return iomap_iter_advance(iter, length);
526527 }
527528
528− ifs_alloc(iter->inode, folio, iter->flags);
529+ ifs = ifs_alloc(iter->inode, folio, iter->flags);
529530
530531 length = min_t(loff_t, length, folio_len - offset_in_folio(folio, pos));
531532 while (length) {
@@ -560,11 +561,15 @@ static int iomap_read_folio_iter(struct iomap_iter *iter, · 28 unmodified lines
560561
561562 *bytes_submitted += plen;
562563 /*
563− * If the entire folio has been read in by the IO
564− * helper, then the helper owns the folio and will end
565− * the read on it.
564+ * Hand off folio ownership to the IO helper when:
565+ * 1) The entire folio has been submitted for IO, or
566+ * 2) There is no ifs attached to the folio
567+ *
568+ * Case (2) occurs when 1 << i_blkbits matches the folio
569+ * size but the underlying filesystem or block device
570+ * uses a smaller granularity for IO.
566571 */
567− if (*bytes_submitted == folio_len)
572+ if (*bytes_submitted == folio_len || !ifs)
568573 ctx->cur_folio = NULL;
569574 }
570575
fs/jbd2/checkpoint.c+13−2
@@ -267,7 +267,15 @@ restart: · 266 unmodified lines
267267 */
268268 BUFFER_TRACE(bh, "queue");
269269 get_bh(bh);
270− J_ASSERT_BH(bh, !buffer_jwrite(bh));
270+ if (WARN_ON_ONCE(buffer_jwrite(bh))) {
271+ put_bh(bh); /* drop the ref we just took */
272+ spin_unlock(&journal->j_list_lock);
273+ /* Clean up any previously batched buffers */
274+ if (batch_count)
275+ __flush_batch(journal, &batch_count);
276+ jbd2_journal_abort(journal, -EFSCORRUPTED);
277+ return -EFSCORRUPTED;
278+ }
271279 journal->j_chkpt_bhs[batch_count++] = bh;
272280 transaction->t_chp_stats.cs_written++;
273281 transaction->t_checkpoint_list = jh->b_cpnext;
@@ -325,7 +333,10 @@ int jbd2_cleanup_journal_tail(journal_t *journal) · 51 unmodified lines
325333
326334 if (!jbd2_journal_get_log_tail(journal, &first_tid, &blocknr))
327335 return 1;
328− J_ASSERT(blocknr != 0);
336+ if (WARN_ON_ONCE(blocknr == 0)) {
337+ jbd2_journal_abort(journal, -EFSCORRUPTED);
338+ return -EFSCORRUPTED;
339+ }
329340
330341 /*
331342 * We need to make sure that any blocks that were recently written out
fs/namei.c+8−2
@@ -2437,8 +2437,14 @@ inside: · 2436 unmodified lines
24372437 EXPORT_SYMBOL(hashlen_string);
24382438
24392439 /*
2440− * Calculate the length and hash of the path component, and
2441− * return the length as the result.
2440+ * hash_name - Calculate the length and hash of the path component
2441+ * @nd: the path resolution state
2442+ * @name: the pathname to read the component from
2443+ * @lastword: if the component fits in a single word, LAST_WORD_IS_DOT,
2444+ * LAST_WORD_IS_DOTDOT, or some other value depending on whether the
2445+ * component is '.', '..', or something else. Otherwise, @lastword is 0.
2446+ *
2447+ * Returns: a pointer to the terminating '/' or NUL character in @name.
24422448 */
24432449 static inline const char *hash_name(struct nameidata *nd,
24442450 const char *name,
fs/netfs/buffered_read.c+1−2
@@ -171,9 +171,8 @@ static void netfs_queue_read(struct netfs_io_request *rreq, · 170 unmodified lines
171171 spin_lock(&rreq->lock);
172172 list_add_tail(&subreq->rreq_link, &stream->subrequests);
173173 if (list_is_first(&subreq->rreq_link, &stream->subrequests)) {
174− stream->front = subreq;
175174 if (!stream->active) {
176− stream->collected_to = stream->front->start;
175+ stream->collected_to = subreq->start;
177176 /* Store list pointers before active flag */
178177 smp_store_release(&stream->active, true);
179178 }
fs/netfs/direct_read.c+1−2
@@ -71,9 +71,8 @@ static int netfs_dispatch_unbuffered_reads(struct netfs_io_request *rreq) · 70 unmodified lines
7171 spin_lock(&rreq->lock);
7272 list_add_tail(&subreq->rreq_link, &stream->subrequests);
7373 if (list_is_first(&subreq->rreq_link, &stream->subrequests)) {
74− stream->front = subreq;
7574 if (!stream->active) {
76− stream->collected_to = stream->front->start;
75+ stream->collected_to = subreq->start;
7776 /* Store list pointers before active flag */
7877 smp_store_release(&stream->active, true);
7978 }
fs/netfs/direct_write.c+11−4
@@ -111,7 +111,6 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq) · 110 unmodified lines
111111 netfs_prepare_write(wreq, stream, wreq->start + wreq->transferred);
112112 subreq = stream->construct;
113113 stream->construct = NULL;
114− stream->front = NULL;
115114 }
116115
117116 /* Check if (re-)preparation failed. */
@@ -186,10 +185,18 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq) · 68 unmodified lines
186185 stream->sreq_max_segs = INT_MAX;
187186
188187 netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit);
189− stream->prepare_write(subreq);
190188
191− __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags);
192− netfs_stat(&netfs_n_wh_retry_write_subreq);
189+ if (stream->prepare_write) {
190+ stream->prepare_write(subreq);
191+ __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags);
192+ netfs_stat(&netfs_n_wh_retry_write_subreq);
193+ } else {
194+ struct iov_iter source;
195+
196+ netfs_reset_iter(subreq);
197+ source = subreq->io_iter;
198+ netfs_reissue_write(stream, subreq, &source);
199+ }
193200 }
194201
195202 netfs_unbuffered_write_done(wreq);
fs/netfs/iterator.c+43−0
@@ -142,6 +142,47 @@ static size_t netfs_limit_bvec(const struct iov_iter *iter, size_t start_offset, · 141 unmodified lines
142142 return min(span, max_size);
143143 }
144144
145+/*
146+ * Select the span of a kvec iterator we're going to use. Limit it by both
147+ * maximum size and maximum number of segments. Returns the size of the span
148+ * in bytes.
149+ */
150+static size_t netfs_limit_kvec(const struct iov_iter *iter, size_t start_offset,
151+ size_t max_size, size_t max_segs)
152+{
153+ const struct kvec *kvecs = iter->kvec;
154+ unsigned int nkv = iter->nr_segs, ix = 0, nsegs = 0;
155+ size_t len, span = 0, n = iter->count;
156+ size_t skip = iter->iov_offset + start_offset;
157+
158+ if (WARN_ON(!iov_iter_is_kvec(iter)) ||
159+ WARN_ON(start_offset > n) ||
160+ n == 0)
161+ return 0;
162+
163+ while (n && ix < nkv && skip) {
164+ len = kvecs[ix].iov_len;
165+ if (skip < len)
166+ break;
167+ skip -= len;
168+ n -= len;
169+ ix++;
170+ }
171+
172+ while (n && ix < nkv) {
173+ len = min3(n, kvecs[ix].iov_len - skip, max_size);
174+ span += len;
175+ nsegs++;
176+ ix++;
177+ if (span >= max_size || nsegs >= max_segs)
178+ break;
179+ skip = 0;
180+ n -= len;
181+ }
182+
183+ return min(span, max_size);
184+}
185+
145186 /*
146187 * Select the span of an xarray iterator we're going to use. Limit it by both
147188 * maximum size and maximum number of segments. It is assumed that segments
@@ -245,6 +286,8 @@ size_t netfs_limit_iter(const struct iov_iter *iter, size_t start_offset, · 97 unmodified lines
245286 return netfs_limit_bvec(iter, start_offset, max_size, max_segs);
246287 if (iov_iter_is_xarray(iter))
247288 return netfs_limit_xarray(iter, start_offset, max_size, max_segs);
289+ if (iov_iter_is_kvec(iter))
290+ return netfs_limit_kvec(iter, start_offset, max_size, max_segs);
248291 BUG();
249292 }
250293 EXPORT_SYMBOL(netfs_limit_iter);
fs/netfs/read_collect.c+2−2
@@ -205,7 +205,8 @@ reassess: · 204 unmodified lines
205205 * in progress. The issuer thread may be adding stuff to the tail
206206 * whilst we're doing this.
207207 */
208− front = READ_ONCE(stream->front);
208+ front = list_first_entry_or_null(&stream->subrequests,
209+ struct netfs_io_subrequest, rreq_link);
209210 while (front) {
210211 size_t transferred;
211212
@@ -301,7 +302,6 @@ reassess: · 89 unmodified lines
301302 list_del_init(&front->rreq_link);
302303 front = list_first_entry_or_null(&stream->subrequests,
303304 struct netfs_io_subrequest, rreq_link);
304− stream->front = front;
305305 spin_unlock(&rreq->lock);
306306 netfs_put_subrequest(remove,
307307 notes & ABANDON_SREQ ?
fs/netfs/read_retry.c+4−1
@@ -93,8 +93,10 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq) · 92 unmodified lines
9393 from->start, from->transferred, from->len);
9494
9595 if (test_bit(NETFS_SREQ_FAILED, &from->flags) ||
96− !test_bit(NETFS_SREQ_NEED_RETRY, &from->flags))
96+ !test_bit(NETFS_SREQ_NEED_RETRY, &from->flags)) {
97+ subreq = from;
9798 goto abandon;
99+ }
98100
99101 list_for_each_continue(next, &stream->subrequests) {
100102 subreq = list_entry(next, struct netfs_io_subrequest, rreq_link);
@@ -178,6 +180,7 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq) · 77 unmodified lines
178180 if (subreq == to)
179181 break;
180182 }
183+ subreq = NULL;
181184 continue;
182185 }
183186
fs/netfs/read_single.c+0−1
@@ -107,7 +107,6 @@ static int netfs_single_dispatch_read(struct netfs_io_request *rreq) · 106 unmodified lines
107107 spin_lock(&rreq->lock);
108108 list_add_tail(&subreq->rreq_link, &stream->subrequests);
109109 trace_netfs_sreq(subreq, netfs_sreq_trace_added);
110− stream->front = subreq;
111110 /* Store list pointers before active flag */
112111 smp_store_release(&stream->active, true);
113112 spin_unlock(&rreq->lock);
fs/netfs/write_collect.c+2−2
@@ -228,7 +228,8 @@ reassess_streams: · 227 unmodified lines
228228 if (!smp_load_acquire(&stream->active))
229229 continue;
230230
231− front = stream->front;
231+ front = list_first_entry_or_null(&stream->subrequests,
232+ struct netfs_io_subrequest, rreq_link);
232233 while (front) {
233234 trace_netfs_collect_sreq(wreq, front);
234235 //_debug("sreq [%x] %llx %zx/%zx",
@@ -279,7 +280,6 @@ reassess_streams: · 44 unmodified lines
279280 list_del_init(&front->rreq_link);
280281 front = list_first_entry_or_null(&stream->subrequests,
281282 struct netfs_io_subrequest, rreq_link);
282− stream->front = front;
283283 spin_unlock(&wreq->lock);
284284 netfs_put_subrequest(remove,
285285 notes & SAW_FAILURE ?
fs/netfs/write_issue.c+1−2
@@ -206,9 +206,8 @@ void netfs_prepare_write(struct netfs_io_request *wreq, · 205 unmodified lines
206206 spin_lock(&wreq->lock);
207207 list_add_tail(&subreq->rreq_link, &stream->subrequests);
208208 if (list_is_first(&subreq->rreq_link, &stream->subrequests)) {
209− stream->front = subreq;
210209 if (!stream->active) {
211− stream->collected_to = stream->front->start;
210+ stream->collected_to = subreq->start;
212211 /* Write list pointers before active flag */
213212 smp_store_release(&stream->active, true);
214213 }
fs/overlayfs/copy_up.c+3−3
@@ -1146,15 +1146,15 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, · 1145 unmodified lines
11461146 return -EOVERFLOW;
11471147
11481148 /*
1149− * With metacopy disabled, we fsync after final metadata copyup, for
1149+ * With "fsync=strict", we fsync after final metadata copyup, for
11501150 * both regular files and directories to get atomic copyup semantics
11511151 * on filesystems that do not use strict metadata ordering (e.g. ubifs).
11521152 *
1153− * With metacopy enabled we want to avoid fsync on all meta copyup
1153+ * By default, we want to avoid fsync on all meta copyup, because
11541154 * that will hurt performance of workloads such as chown -R, so we
11551155 * only fsync on data copyup as legacy behavior.
11561156 */
1157− ctx.metadata_fsync = !OVL_FS(dentry->d_sb)->config.metacopy &&
1157+ ctx.metadata_fsync = ovl_should_sync_metadata(OVL_FS(dentry->d_sb)) &&
11581158 (S_ISREG(ctx.stat.mode) || S_ISDIR(ctx.stat.mode));
11591159 ctx.metacopy = ovl_need_meta_copy_up(dentry, ctx.stat.mode, flags);
11601160
fs/overlayfs/overlayfs.h+21−0
@@ -99,6 +99,12 @@ enum { · 98 unmodified lines
9999 OVL_VERITY_REQUIRE,
100100 };
101101
102+enum {
103+ OVL_FSYNC_VOLATILE,
104+ OVL_FSYNC_AUTO,
105+ OVL_FSYNC_STRICT,
106+};
107+
102108 /*
103109 * The tuple (fh,uuid) is a universal unique identifier for a copy up origin,
104110 * where:
@@ -656,6 +662,21 @@ static inline bool ovl_xino_warn(struct ovl_fs *ofs) · 551 unmodified lines
656662 return ofs->config.xino == OVL_XINO_ON;
657663 }
658664
665+static inline bool ovl_should_sync(struct ovl_fs *ofs)
666+{
667+ return ofs->config.fsync_mode != OVL_FSYNC_VOLATILE;
668+}
669+
670+static inline bool ovl_should_sync_metadata(struct ovl_fs *ofs)
671+{
672+ return ofs->config.fsync_mode == OVL_FSYNC_STRICT;
673+}
674+
675+static inline bool ovl_is_volatile(struct ovl_config *config)
676+{
677+ return config->fsync_mode == OVL_FSYNC_VOLATILE;
678+}
679+
659680 /*
660681 * To avoid regressions in existing setups with overlay lower offline changes,
661682 * we allow lower changes only if none of the new features are used.
fs/overlayfs/ovl_entry.h+1−6
@@ -18,7 +18,7 @@ struct ovl_config { · 17 unmodified lines
1818 int xino;
1919 bool metacopy;
2020 bool userxattr;
21− bool ovl_volatile;
21+ int fsync_mode;
2222 };
2323
2424 struct ovl_sb {
@@ -120,11 +120,6 @@ static inline struct ovl_fs *OVL_FS(struct super_block *sb) · 95 unmodified lines
120120 return (struct ovl_fs *)sb->s_fs_info;
121121 }
122122
123−static inline bool ovl_should_sync(struct ovl_fs *ofs)
124−{
125− return !ofs->config.ovl_volatile;
126−}
127−
128123 static inline unsigned int ovl_numlower(struct ovl_entry *oe)
129124 {
130125 return oe ? oe->__numlower : 0;
fs/overlayfs/params.c+28−5
@@ -58,6 +58,7 @@ enum ovl_opt { · 57 unmodified lines
5858 Opt_xino,
5959 Opt_metacopy,
6060 Opt_verity,
61+ Opt_fsync,
6162 Opt_volatile,
6263 Opt_override_creds,
6364 };
@@ -140,6 +141,23 @@ static int ovl_verity_mode_def(void) · 76 unmodified lines
140141 return OVL_VERITY_OFF;
141142 }
142143
144+static const struct constant_table ovl_parameter_fsync[] = {
145+ { "volatile", OVL_FSYNC_VOLATILE },
146+ { "auto", OVL_FSYNC_AUTO },
147+ { "strict", OVL_FSYNC_STRICT },
148+ {}
149+};
150+
151+static const char *ovl_fsync_mode(struct ovl_config *config)
152+{
153+ return ovl_parameter_fsync[config->fsync_mode].name;
154+}
155+
156+static int ovl_fsync_mode_def(void)
157+{
158+ return OVL_FSYNC_AUTO;
159+}
160+
143161 const struct fs_parameter_spec ovl_parameter_spec[] = {
144162 fsparam_string_empty("lowerdir", Opt_lowerdir),
145163 fsparam_file_or_string("lowerdir+", Opt_lowerdir_add),
@@ -155,6 +173,7 @@ const struct fs_parameter_spec ovl_parameter_spec[] = { · 9 unmodified lines
155173 fsparam_enum("xino", Opt_xino, ovl_parameter_xino),
156174 fsparam_enum("metacopy", Opt_metacopy, ovl_parameter_bool),
157175 fsparam_enum("verity", Opt_verity, ovl_parameter_verity),
176+ fsparam_enum("fsync", Opt_fsync, ovl_parameter_fsync),
158177 fsparam_flag("volatile", Opt_volatile),
159178 fsparam_flag_no("override_creds", Opt_override_creds),
160179 {}
@@ -665,8 +684,11 @@ static int ovl_parse_param(struct fs_context *fc, struct fs_parameter *param) · 504 unmodified lines
665684 case Opt_verity:
666685 config->verity_mode = result.uint_32;
667686 break;
687+ case Opt_fsync:
688+ config->fsync_mode = result.uint_32;
689+ break;
668690 case Opt_volatile:
669− config->ovl_volatile = true;
691+ config->fsync_mode = OVL_FSYNC_VOLATILE;
670692 break;
671693 case Opt_userxattr:
672694 config->userxattr = true;
@@ -800,6 +822,7 @@ int ovl_init_fs_context(struct fs_context *fc) · 127 unmodified lines
800822 ofs->config.nfs_export = ovl_nfs_export_def;
801823 ofs->config.xino = ovl_xino_def();
802824 ofs->config.metacopy = ovl_metacopy_def;
825+ ofs->config.fsync_mode = ovl_fsync_mode_def();
803826
804827 fc->s_fs_info = ofs;
805828 fc->fs_private = ctx;
@@ -870,9 +893,9 @@ int ovl_fs_params_verify(const struct ovl_fs_context *ctx, · 64 unmodified lines
870893 config->index = false;
871894 }
872895
873− if (!config->upperdir && config->ovl_volatile) {
896+ if (!config->upperdir && ovl_is_volatile(config)) {
874897 pr_info("option \"volatile\" is meaningless in a non-upper mount, ignoring it.\n");
875− config->ovl_volatile = false;
898+ config->fsync_mode = ovl_fsync_mode_def();
876899 }
877900
878901 if (!config->upperdir && config->uuid == OVL_UUID_ON) {
@@ -1070,8 +1093,8 @@ int ovl_show_options(struct seq_file *m, struct dentry *dentry) · 191 unmodified lines
10701093 seq_printf(m, ",xino=%s", ovl_xino_mode(&ofs->config));
10711094 if (ofs->config.metacopy != ovl_metacopy_def)
10721095 seq_printf(m, ",metacopy=%s", str_on_off(ofs->config.metacopy));
1073− if (ofs->config.ovl_volatile)
1074− seq_puts(m, ",volatile");
1096+ if (ofs->config.fsync_mode != ovl_fsync_mode_def())
1097+ seq_printf(m, ",fsync=%s", ovl_fsync_mode(&ofs->config));
10751098 if (ofs->config.userxattr)
10761099 seq_puts(m, ",userxattr");
10771100 if (ofs->config.verity_mode != ovl_verity_mode_def())
fs/overlayfs/super.c+1−1
@@ -776,7 +776,7 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs, · 775 unmodified lines
776776 * For volatile mount, create a incompat/volatile/dirty file to keep
777777 * track of it.
778778 */
779− if (ofs->config.ovl_volatile) {
779+ if (ovl_is_volatile(&ofs->config)) {
780780 err = ovl_create_volatile_dirty(ofs);
781781 if (err < 0) {
782782 pr_err("Failed to create volatile/dirty file.\n");
fs/overlayfs/util.c+4−1
@@ -85,7 +85,10 @@ int ovl_can_decode_fh(struct super_block *sb) · 84 unmodified lines
8585 if (!exportfs_can_decode_fh(sb->s_export_op))
8686 return 0;
8787
88− return sb->s_export_op->encode_fh ? -1 : FILEID_INO32_GEN;
88+ if (sb->s_export_op->encode_fh == generic_encode_ino32_fh)
89+ return FILEID_INO32_GEN;
90+
91+ return -1;
8992 }
9093
9194 struct dentry *ovl_indexdir(struct super_block *sb)
fs/smb/client/Makefile+4−3
@@ -48,8 +48,8 @@ cifs-$(CONFIG_CIFS_COMPRESSION) += compress.o compress/lz77.o · 47 unmodified lines
4848 # Build the SMB2 error mapping table from smb2status.h
4949 #
5050 $(obj)/smb2_mapping_table.c: $(src)/../common/smb2status.h \
51− $(src)/gen_smb2_mapping
52− $(call cmd,gen_smb2_mapping)
51+ $(src)/gen_smb2_mapping FORCE
52+ $(call if_changed,gen_smb2_mapping)
5353
5454 $(obj)/smb2maperror.o: $(obj)/smb2_mapping_table.c
5555
@@ -58,4 +58,5 @@ quiet_cmd_gen_smb2_mapping = GEN $@ · 2 unmodified lines
5858
5959 obj-$(CONFIG_SMB_KUNIT_TESTS) += smb2maperror_test.o
6060
61−clean-files += smb2_mapping_table.c
61+# Let Kbuild handle tracking and cleaning
62+targets += smb2_mapping_table.c
fs/smb/server/oplock.c+45−27
@@ -82,11 +82,19 @@ static void lease_del_list(struct oplock_info *opinfo) · 81 unmodified lines
8282 spin_unlock(&lb->lb_lock);
8383 }
8484
85−static void lb_add(struct lease_table *lb)
85+static struct lease_table *alloc_lease_table(struct oplock_info *opinfo)
8686 {
87− write_lock(&lease_list_lock);
88− list_add(&lb->l_entry, &lease_table_list);
89− write_unlock(&lease_list_lock);
87+ struct lease_table *lb;
88+
89+ lb = kmalloc_obj(struct lease_table, KSMBD_DEFAULT_GFP);
90+ if (!lb)
91+ return NULL;
92+
93+ memcpy(lb->client_guid, opinfo->conn->ClientGUID,
94+ SMB2_CLIENT_GUID_SIZE);
95+ INIT_LIST_HEAD(&lb->lease_list);
96+ spin_lock_init(&lb->lb_lock);
97+ return lb;
9098 }
9199
92100 static int alloc_lease(struct oplock_info *opinfo, struct lease_ctx_info *lctx)
@@ -1042,34 +1050,27 @@ static void copy_lease(struct oplock_info *op1, struct oplock_info *op2) · 949 unmodified lines
10421050 lease2->version = lease1->version;
10431051 }
10441052
1045−static int add_lease_global_list(struct oplock_info *opinfo)
1053+static void add_lease_global_list(struct oplock_info *opinfo,
1054+ struct lease_table *new_lb)
10461055 {
10471056 struct lease_table *lb;
10481057
1049− read_lock(&lease_list_lock);
1058+ write_lock(&lease_list_lock);
10501059 list_for_each_entry(lb, &lease_table_list, l_entry) {
10511060 if (!memcmp(lb->client_guid, opinfo->conn->ClientGUID,
10521061 SMB2_CLIENT_GUID_SIZE)) {
10531062 opinfo->o_lease->l_lb = lb;
10541063 lease_add_list(opinfo);
1055− read_unlock(&lease_list_lock);
1056− return 0;
1064+ write_unlock(&lease_list_lock);
1065+ kfree(new_lb);
1066+ return;
10571067 }
10581068 }
1059− read_unlock(&lease_list_lock);
10601069
1061− lb = kmalloc_obj(struct lease_table, KSMBD_DEFAULT_GFP);
1062− if (!lb)
1063− return -ENOMEM;
1064−
1065− memcpy(lb->client_guid, opinfo->conn->ClientGUID,
1066− SMB2_CLIENT_GUID_SIZE);
1067− INIT_LIST_HEAD(&lb->lease_list);
1068− spin_lock_init(&lb->lb_lock);
1069− opinfo->o_lease->l_lb = lb;
1070+ opinfo->o_lease->l_lb = new_lb;
10701071 lease_add_list(opinfo);
1071− lb_add(lb);
1072− return 0;
1072+ list_add(&new_lb->l_entry, &lease_table_list);
1073+ write_unlock(&lease_list_lock);
10731074 }
10741075
10751076 static void set_oplock_level(struct oplock_info *opinfo, int level,
@@ -1189,6 +1190,7 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid, · 113 unmodified lines
11891190 int err = 0;
11901191 struct oplock_info *opinfo = NULL, *prev_opinfo = NULL;
11911192 struct ksmbd_inode *ci = fp->f_ci;
1193+ struct lease_table *new_lb = NULL;
11921194 bool prev_op_has_lease;
11931195 __le32 prev_op_state = 0;
11941196
@@ -1291,21 +1293,37 @@ set_lev: · 96 unmodified lines
12911293 set_oplock_level(opinfo, req_op_level, lctx);
12921294
12931295 out:
1294− opinfo_count_inc(fp);
1295− opinfo_add(opinfo, fp);
1296−
1296+ /*
1297+ * Set o_fp before any publication so that concurrent readers
1298+ * (e.g. find_same_lease_key() on the lease list) that
1299+ * dereference opinfo->o_fp don't hit a NULL pointer.
1300+ *
1301+ * Keep the original publication order so concurrent opens can
1302+ * still observe the in-flight grant via ci->m_op_list, but make
1303+ * everything after opinfo_add() no-fail by preallocating any new
1304+ * lease_table first.
1305+ */
1306+ opinfo->o_fp = fp;
12971307 if (opinfo->is_lease) {
1298− err = add_lease_global_list(opinfo);
1299− if (err)
1308+ new_lb = alloc_lease_table(opinfo);
1309+ if (!new_lb) {
1310+ err = -ENOMEM;
13001311 goto err_out;
1312+ }
13011313 }
13021314
1315+ opinfo_count_inc(fp);
1316+ opinfo_add(opinfo, fp);
1317+
1318+ if (opinfo->is_lease)
1319+ add_lease_global_list(opinfo, new_lb);
1320+
13031321 rcu_assign_pointer(fp->f_opinfo, opinfo);
1304− opinfo->o_fp = fp;
13051322
13061323 return 0;
13071324 err_out:
1308− __free_opinfo(opinfo);
1325+ kfree(new_lb);
1326+ opinfo_put(opinfo);
13091327 return err;
13101328 }
13111329
fs/smb/server/smb2pdu.c+52−21
@@ -1939,8 +1939,14 @@ out_err: · 1938 unmodified lines
19391939 if (sess->user && sess->user->flags & KSMBD_USER_FLAG_DELAY_SESSION)
19401940 try_delay = true;
19411941
1942− sess->last_active = jiffies;
1943− sess->state = SMB2_SESSION_EXPIRED;
1942+ /*
1943+ * For binding requests, session belongs to another
1944+ * connection. Do not expire it.
1945+ */
1946+ if (!(req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) {
1947+ sess->last_active = jiffies;
1948+ sess->state = SMB2_SESSION_EXPIRED;
1949+ }
19441950 ksmbd_user_session_put(sess);
19451951 work->sess = NULL;
19461952 if (try_delay) {
@@ -4446,8 +4452,9 @@ int smb2_query_dir(struct ksmbd_work *work) · 2499 unmodified lines
44464452 d_info.wptr = (char *)rsp->Buffer;
44474453 d_info.rptr = (char *)rsp->Buffer;
44484454 d_info.out_buf_len =
4449− smb2_calc_max_out_buf_len(work, 8,
4450− le32_to_cpu(req->OutputBufferLength));
4455+ smb2_calc_max_out_buf_len(work,
4456+ offsetof(struct smb2_query_directory_rsp, Buffer),
4457+ le32_to_cpu(req->OutputBufferLength));
44514458 if (d_info.out_buf_len < 0) {
44524459 rc = -EINVAL;
44534460 goto err_out;
@@ -4714,8 +4721,9 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp, · 260 unmodified lines
47144721 }
47154722
47164723 buf_free_len =
4717− smb2_calc_max_out_buf_len(work, 8,
4718− le32_to_cpu(req->OutputBufferLength));
4724+ smb2_calc_max_out_buf_len(work,
4725+ offsetof(struct smb2_query_info_rsp, Buffer),
4726+ le32_to_cpu(req->OutputBufferLength));
47194727 if (buf_free_len < 0)
47204728 return -EINVAL;
47214729
@@ -4932,7 +4940,8 @@ static int get_file_all_info(struct ksmbd_work *work, · 210 unmodified lines
49324940 int conv_len;
49334941 char *filename;
49344942 u64 time;
4935− int ret;
4943+ int ret, buf_free_len, filename_len;
4944+ struct smb2_query_info_req *req = ksmbd_req_buf_next(work);
49364945
49374946 if (!(fp->daccess & FILE_READ_ATTRIBUTES_LE)) {
49384947 ksmbd_debug(SMB, "no right to read the attributes : 0x%x\n",
@@ -4944,6 +4953,16 @@ static int get_file_all_info(struct ksmbd_work *work, · 5 unmodified lines
49444953 if (IS_ERR(filename))
49454954 return PTR_ERR(filename);
49464955
4956+ filename_len = strlen(filename);
4957+ buf_free_len = smb2_calc_max_out_buf_len(work,
4958+ offsetof(struct smb2_query_info_rsp, Buffer) +
4959+ offsetof(struct smb2_file_all_info, FileName),
4960+ le32_to_cpu(req->OutputBufferLength));
4961+ if (buf_free_len < (filename_len + 1) * 2) {
4962+ kfree(filename);
4963+ return -EINVAL;
4964+ }
4965+
49474966 ret = vfs_getattr(&fp->filp->f_path, &stat, STATX_BASIC_STATS,
49484967 AT_STATX_SYNC_AS_STAT);
49494968 if (ret) {
@@ -4987,7 +5006,8 @@ static int get_file_all_info(struct ksmbd_work *work, · 37 unmodified lines
49875006 file_info->Mode = fp->coption;
49885007 file_info->AlignmentRequirement = 0;
49895008 conv_len = smbConvertToUTF16((__le16 *)file_info->FileName, filename,
4990− PATH_MAX, conn->local_nls, 0);
5009+ min(filename_len, PATH_MAX),
5010+ conn->local_nls, 0);
49915011 conv_len *= 2;
49925012 file_info->FileNameLength = cpu_to_le32(conv_len);
49935013 rsp->OutputBufferLength =
@@ -5041,8 +5061,9 @@ static int get_file_stream_info(struct ksmbd_work *work, · 47 unmodified lines
50415061 file_info = (struct smb2_file_stream_info *)rsp->Buffer;
50425062
50435063 buf_free_len =
5044− smb2_calc_max_out_buf_len(work, 8,
5045− le32_to_cpu(req->OutputBufferLength));
5064+ smb2_calc_max_out_buf_len(work,
5065+ offsetof(struct smb2_query_info_rsp, Buffer),
5066+ le32_to_cpu(req->OutputBufferLength));
50465067 if (buf_free_len < 0)
50475068 goto out;
50485069
@@ -7586,14 +7607,15 @@ retry: · 2537 unmodified lines
75867607 rc = vfs_lock_file(filp, smb_lock->cmd, flock, NULL);
75877608 skip:
75887609 if (smb_lock->flags & SMB2_LOCKFLAG_UNLOCK) {
7610+ locks_free_lock(flock);
7611+ kfree(smb_lock);
75897612 if (!rc) {
75907613 ksmbd_debug(SMB, "File unlocked\n");
75917614 } else if (rc == -ENOENT) {
75927615 rsp->hdr.Status = STATUS_NOT_LOCKED;
7616+ err = rc;
75937617 goto out;
75947618 }
7595− locks_free_lock(flock);
7596− kfree(smb_lock);
75977619 } else {
75987620 if (rc == FILE_LOCK_DEFERRED) {
75997621 void **argv;
@@ -7662,6 +7684,9 @@ skip: · 62 unmodified lines
76627684 spin_unlock(&work->conn->llist_lock);
76637685 ksmbd_debug(SMB, "successful in taking lock\n");
76647686 } else {
7687+ locks_free_lock(flock);
7688+ kfree(smb_lock);
7689+ err = rc;
76657690 goto out;
76667691 }
76677692 }
@@ -7692,13 +7717,17 @@ out: · 24 unmodified lines
76927717 struct file_lock *rlock = NULL;
76937718
76947719 rlock = smb_flock_init(filp);
7695− rlock->c.flc_type = F_UNLCK;
7696− rlock->fl_start = smb_lock->start;
7697− rlock->fl_end = smb_lock->end;
7720+ if (rlock) {
7721+ rlock->c.flc_type = F_UNLCK;
7722+ rlock->fl_start = smb_lock->start;
7723+ rlock->fl_end = smb_lock->end;
76987724
7699− rc = vfs_lock_file(filp, F_SETLK, rlock, NULL);
7700− if (rc)
7701− pr_err("rollback unlock fail : %d\n", rc);
7725+ rc = vfs_lock_file(filp, F_SETLK, rlock, NULL);
7726+ if (rc)
7727+ pr_err("rollback unlock fail : %d\n", rc);
7728+ } else {
7729+ pr_err("rollback unlock alloc failed\n");
7730+ }
77027731
77037732 list_del(&smb_lock->llist);
77047733 spin_lock(&work->conn->llist_lock);
@@ -7708,7 +7737,8 @@ out: · 3 unmodified lines
77087737 spin_unlock(&work->conn->llist_lock);
77097738
77107739 locks_free_lock(smb_lock->fl);
7711− locks_free_lock(rlock);
7740+ if (rlock)
7741+ locks_free_lock(rlock);
77127742 kfree(smb_lock);
77137743 }
77147744 out2:
@@ -8191,8 +8221,9 @@ int smb2_ioctl(struct ksmbd_work *work) · 476 unmodified lines
81918221 buffer = (char *)req + le32_to_cpu(req->InputOffset);
81928222
81938223 cnt_code = le32_to_cpu(req->CtlCode);
8194− ret = smb2_calc_max_out_buf_len(work, 48,
8195− le32_to_cpu(req->MaxOutputResponse));
8224+ ret = smb2_calc_max_out_buf_len(work,
8225+ offsetof(struct smb2_ioctl_rsp, Buffer),
8226+ le32_to_cpu(req->MaxOutputResponse));
81968227 if (ret < 0) {
81978228 rsp->hdr.Status = STATUS_INVALID_PARAMETER;
81988229 goto out;
fs/xfs/libxfs/xfs_attr.h+2−1
@@ -55,7 +55,8 @@ struct xfs_attr_list_context { · 54 unmodified lines
5555 struct xfs_trans *tp;
5656 struct xfs_inode *dp; /* inode */
5757 struct xfs_attrlist_cursor_kern cursor; /* position in list */
58− void *buffer; /* output buffer */
58+ /* output buffer */
59+ void *buffer __counted_by_ptr(bufsize);
5960
6061 /*
6162 * Abort attribute list iteration if non-zero. Can be used to pass
fs/xfs/libxfs/xfs_attr_leaf.c+22−0
@@ -1415,6 +1415,28 @@ xfs_attr3_leaf_create( · 1414 unmodified lines
14151415 return 0;
14161416 }
14171417
1418+/*
1419+ * Reinitialize an existing attr fork block as an empty leaf, and attach
1420+ * the buffer to tp.
1421+ */
1422+int
1423+xfs_attr3_leaf_init(
1424+ struct xfs_trans *tp,
1425+ struct xfs_inode *dp,
1426+ xfs_dablk_t blkno)
1427+{
1428+ struct xfs_buf *bp = NULL;
1429+ struct xfs_da_args args = {
1430+ .trans = tp,
1431+ .dp = dp,
1432+ .owner = dp->i_ino,
1433+ .geo = dp->i_mount->m_attr_geo,
1434+ };
1435+
1436+ ASSERT(tp != NULL);
1437+
1438+ return xfs_attr3_leaf_create(&args, blkno, &bp);
1439+}
14181440 /*
14191441 * Split the leaf node, rebalance, then add the new entry.
14201442 *
fs/xfs/libxfs/xfs_attr_leaf.h+3−0
@@ -87,6 +87,9 @@ int xfs_attr3_leaf_list_int(struct xfs_buf *bp, · 86 unmodified lines
8787 /*
8888 * Routines used for shrinking the Btree.
8989 */
90+
91+int xfs_attr3_leaf_init(struct xfs_trans *tp, struct xfs_inode *dp,
92+ xfs_dablk_t blkno);
9093 int xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval);
9194 void xfs_attr3_leaf_unbalance(struct xfs_da_state *state,
9295 struct xfs_da_state_blk *drop_blk,
fs/xfs/libxfs/xfs_da_btree.c+42−11
@@ -1506,21 +1506,20 @@ xfs_da3_fixhashpath( · 1505 unmodified lines
15061506 }
15071507
15081508 /*
1509− * Remove an entry from an intermediate node.
1509+ * Internal implementation to remove an entry from an intermediate node.
15101510 */
15111511 STATIC void
1512−xfs_da3_node_remove(
1513− struct xfs_da_state *state,
1514− struct xfs_da_state_blk *drop_blk)
1512+__xfs_da3_node_remove(
1513+ struct xfs_trans *tp,
1514+ struct xfs_inode *dp,
1515+ struct xfs_da_geometry *geo,
1516+ struct xfs_da_state_blk *drop_blk)
15151517 {
15161518 struct xfs_da_intnode *node;
15171519 struct xfs_da3_icnode_hdr nodehdr;
15181520 struct xfs_da_node_entry *btree;
15191521 int index;
15201522 int tmp;
1521− struct xfs_inode *dp = state->args->dp;
1522−
1523− trace_xfs_da_node_remove(state->args);
15241523
15251524 node = drop_blk->bp->b_addr;
15261525 xfs_da3_node_hdr_from_disk(dp->i_mount, &nodehdr, node);
@@ -1536,17 +1535,17 @@ xfs_da3_node_remove( · 9 unmodified lines
15361535 tmp = nodehdr.count - index - 1;
15371536 tmp *= (uint)sizeof(xfs_da_node_entry_t);
15381537 memmove(&btree[index], &btree[index + 1], tmp);
1539− xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1538+ xfs_trans_log_buf(tp, drop_blk->bp,
15401539 XFS_DA_LOGRANGE(node, &btree[index], tmp));
15411540 index = nodehdr.count - 1;
15421541 }
15431542 memset(&btree[index], 0, sizeof(xfs_da_node_entry_t));
1544− xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1543+ xfs_trans_log_buf(tp, drop_blk->bp,
15451544 XFS_DA_LOGRANGE(node, &btree[index], sizeof(btree[index])));
15461545 nodehdr.count -= 1;
15471546 xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);
1548− xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1549− XFS_DA_LOGRANGE(node, &node->hdr, state->args->geo->node_hdr_size));
1547+ xfs_trans_log_buf(tp, drop_blk->bp,
1548+ XFS_DA_LOGRANGE(node, &node->hdr, geo->node_hdr_size));
15501549
15511550 /*
15521551 * Copy the last hash value from the block to propagate upwards.
@@ -1554,6 +1553,38 @@ xfs_da3_node_remove( · 1 unmodified line
15541553 drop_blk->hashval = be32_to_cpu(btree[index - 1].hashval);
15551554 }
15561555
1556+/*
1557+ * Remove an entry from an intermediate node.
1558+ */
1559+STATIC void
1560+xfs_da3_node_remove(
1561+ struct xfs_da_state *state,
1562+ struct xfs_da_state_blk *drop_blk)
1563+{
1564+ trace_xfs_da_node_remove(state->args);
1565+
1566+ __xfs_da3_node_remove(state->args->trans, state->args->dp,
1567+ state->args->geo, drop_blk);
1568+}
1569+
1570+/*
1571+ * Remove an entry from an intermediate attr node at the specified index.
1572+ */
1573+void
1574+xfs_attr3_node_entry_remove(
1575+ struct xfs_trans *tp,
1576+ struct xfs_inode *dp,
1577+ struct xfs_buf *bp,
1578+ int index)
1579+{
1580+ struct xfs_da_state_blk blk = {
1581+ .index = index,
1582+ .bp = bp,
1583+ };
1584+
1585+ __xfs_da3_node_remove(tp, dp, dp->i_mount->m_attr_geo, &blk);
1586+}
1587+
15571588 /*
15581589 * Unbalance the elements between two intermediate nodes,
15591590 * move all Btree elements from one node into another.
fs/xfs/libxfs/xfs_da_btree.h+2−0
@@ -184,6 +184,8 @@ int xfs_da3_split(xfs_da_state_t *state); · 183 unmodified lines
184184 int xfs_da3_join(xfs_da_state_t *state);
185185 void xfs_da3_fixhashpath(struct xfs_da_state *state,
186186 struct xfs_da_state_path *path_to_to_fix);
187+void xfs_attr3_node_entry_remove(struct xfs_trans *tp, struct xfs_inode *dp,
188+ struct xfs_buf *bp, int index);
187189
188190 /*
189191 * Routines used for finding things in the Btree.
fs/xfs/scrub/quota.c+3−1
@@ -171,8 +171,10 @@ xchk_quota_item( · 170 unmodified lines
171171
172172 error = xchk_quota_item_bmap(sc, dq, offset);
173173 xchk_iunlock(sc, XFS_ILOCK_SHARED);
174− if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, offset, &error))
174+ if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, offset, &error)) {
175+ mutex_unlock(&dq->q_qlock);
175176 return error;
177+ }
176178
177179 /*
178180 * Warn if the hard limits are larger than the fs.
fs/xfs/scrub/trace.h+2−10
@@ -972,20 +972,12 @@ TRACE_EVENT(xfile_create, · 971 unmodified lines
972972 TP_STRUCT__entry(
973973 __field(dev_t, dev)
974974 __field(unsigned long, ino)
975− __array(char, pathname, MAXNAMELEN)
976975 ),
977976 TP_fast_assign(
978− char *path;
979−
980977 __entry->ino = file_inode(xf->file)->i_ino;
981− path = file_path(xf->file, __entry->pathname, MAXNAMELEN);
982− if (IS_ERR(path))
983− strncpy(__entry->pathname, "(unknown)",
984− sizeof(__entry->pathname));
985978 ),
986− TP_printk("xfino 0x%lx path '%s'",
987− __entry->ino,
988− __entry->pathname)
979+ TP_printk("xfino 0x%lx",
980+ __entry->ino)
989981 );
990982
991983 TRACE_EVENT(xfile_destroy,
fs/xfs/xfs_attr_inactive.c+57−38
@@ -140,7 +140,7 @@ xfs_attr3_node_inactive( · 139 unmodified lines
140140 xfs_daddr_t parent_blkno, child_blkno;
141141 struct xfs_buf *child_bp;
142142 struct xfs_da3_icnode_hdr ichdr;
143− int error, i;
143+ int error;
144144
145145 /*
146146 * Since this code is recursive (gasp!) we must protect ourselves.
@@ -152,7 +152,7 @@ xfs_attr3_node_inactive( · 5 unmodified lines
152152 return -EFSCORRUPTED;
153153 }
154154
155− xfs_da3_node_hdr_from_disk(dp->i_mount, &ichdr, bp->b_addr);
155+ xfs_da3_node_hdr_from_disk(mp, &ichdr, bp->b_addr);
156156 parent_blkno = xfs_buf_daddr(bp);
157157 if (!ichdr.count) {
158158 xfs_trans_brelse(*trans, bp);
@@ -167,7 +167,7 @@ xfs_attr3_node_inactive( · 8 unmodified lines
167167 * over the leaves removing all of them. If this is higher up
168168 * in the tree, recurse downward.
169169 */
170− for (i = 0; i < ichdr.count; i++) {
170+ while (ichdr.count > 0) {
171171 /*
172172 * Read the subsidiary block to see what we have to work with.
173173 * Don't do this in a transaction. This is a depth-first
@@ -218,29 +218,32 @@ xfs_attr3_node_inactive( · 44 unmodified lines
218218 xfs_trans_binval(*trans, child_bp);
219219 child_bp = NULL;
220220
221+ error = xfs_da3_node_read_mapped(*trans, dp,
222+ parent_blkno, &bp, XFS_ATTR_FORK);
223+ if (error)
224+ return error;
225+
221226 /*
222− * If we're not done, re-read the parent to get the next
223− * child block number.
227+ * Remove entry from parent node, prevents being indexed to.
224228 */
225− if (i + 1 < ichdr.count) {
226− struct xfs_da3_icnode_hdr phdr;
229+ xfs_attr3_node_entry_remove(*trans, dp, bp, 0);
230+
231+ xfs_da3_node_hdr_from_disk(mp, &ichdr, bp->b_addr);
232+ bp = NULL;
227233
228− error = xfs_da3_node_read_mapped(*trans, dp,
229− parent_blkno, &bp, XFS_ATTR_FORK);
234+ if (ichdr.count > 0) {
235+ /*
236+ * If we're not done, get the next child block number.
237+ */
238+ child_fsb = be32_to_cpu(ichdr.btree[0].before);
239+
240+ /*
241+ * Atomically commit the whole invalidate stuff.
242+ */
243+ error = xfs_trans_roll_inode(trans, dp);
230244 if (error)
231245 return error;
232− xfs_da3_node_hdr_from_disk(dp->i_mount, &phdr,
233− bp->b_addr);
234− child_fsb = be32_to_cpu(phdr.btree[i + 1].before);
235− xfs_trans_brelse(*trans, bp);
236− bp = NULL;
237246 }
238− /*
239− * Atomically commit the whole invalidate stuff.
240− */
241− error = xfs_trans_roll_inode(trans, dp);
242− if (error)
243− return error;
244247 }
245248
246249 return 0;
@@ -257,10 +260,8 @@ xfs_attr3_root_inactive( · 10 unmodified lines
257260 struct xfs_trans **trans,
258261 struct xfs_inode *dp)
259262 {
260− struct xfs_mount *mp = dp->i_mount;
261263 struct xfs_da_blkinfo *info;
262264 struct xfs_buf *bp;
263− xfs_daddr_t blkno;
264265 int error;
265266
266267 /*
@@ -272,7 +273,6 @@ xfs_attr3_root_inactive( · 5 unmodified lines
272273 error = xfs_da3_node_read(*trans, dp, 0, &bp, XFS_ATTR_FORK);
273274 if (error)
274275 return error;
275− blkno = xfs_buf_daddr(bp);
276276
277277 /*
278278 * Invalidate the tree, even if the "tree" is only a single leaf block.
@@ -283,10 +283,26 @@ xfs_attr3_root_inactive( · 4 unmodified lines
283283 case cpu_to_be16(XFS_DA_NODE_MAGIC):
284284 case cpu_to_be16(XFS_DA3_NODE_MAGIC):
285285 error = xfs_attr3_node_inactive(trans, dp, bp, 1);
286+ /*
287+ * Empty root node block are not allowed, convert it to leaf.
288+ */
289+ if (!error)
290+ error = xfs_attr3_leaf_init(*trans, dp, 0);
291+ if (!error)
292+ error = xfs_trans_roll_inode(trans, dp);
286293 break;
287294 case cpu_to_be16(XFS_ATTR_LEAF_MAGIC):
288295 case cpu_to_be16(XFS_ATTR3_LEAF_MAGIC):
289296 error = xfs_attr3_leaf_inactive(trans, dp, bp);
297+ /*
298+ * Reinit the leaf before truncating extents so that a crash
299+ * mid-truncation leaves an empty leaf rather than one with
300+ * entries that may reference freed remote value blocks.
301+ */
302+ if (!error)
303+ error = xfs_attr3_leaf_init(*trans, dp, 0);
304+ if (!error)
305+ error = xfs_trans_roll_inode(trans, dp);
290306 break;
291307 default:
292308 xfs_dirattr_mark_sick(dp, XFS_ATTR_FORK);
@@ -295,21 +311,6 @@ xfs_attr3_root_inactive( · 2 unmodified lines
295311 xfs_trans_brelse(*trans, bp);
296312 break;
297313 }
298− if (error)
299− return error;
300−
301− /*
302− * Invalidate the incore copy of the root block.
303− */
304− error = xfs_trans_get_buf(*trans, mp->m_ddev_targp, blkno,
305− XFS_FSB_TO_BB(mp, mp->m_attr_geo->fsbcount), 0, &bp);
306− if (error)
307− return error;
308− xfs_trans_binval(*trans, bp); /* remove from cache */
309− /*
310− * Commit the invalidate and start the next transaction.
311− */
312− error = xfs_trans_roll_inode(trans, dp);
313314
314315 return error;
315316 }
@@ -328,6 +329,7 @@ xfs_attr_inactive( · 12 unmodified lines
328329 {
329330 struct xfs_trans *trans;
330331 struct xfs_mount *mp;
332+ struct xfs_buf *bp;
331333 int lock_mode = XFS_ILOCK_SHARED;
332334 int error = 0;
333335
@@ -363,10 +365,27 @@ xfs_attr_inactive( · 29 unmodified lines
363365 * removal below.
364366 */
365367 if (dp->i_af.if_nextents > 0) {
368+ /*
369+ * Invalidate and truncate all blocks but leave the root block.
370+ */
366371 error = xfs_attr3_root_inactive(&trans, dp);
367372 if (error)
368373 goto out_cancel;
369374
375+ error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK,
376+ XFS_FSB_TO_B(mp, mp->m_attr_geo->fsbcount));
377+ if (error)
378+ goto out_cancel;
379+
380+ /*
381+ * Invalidate and truncate the root block and ensure that the
382+ * operation is completed within a single transaction.
383+ */
384+ error = xfs_da_get_buf(trans, dp, 0, &bp, XFS_ATTR_FORK);
385+ if (error)
386+ goto out_cancel;
387+
388+ xfs_trans_binval(trans, bp);
370389 error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 0);
371390 if (error)
372391 goto out_cancel;
fs/xfs/xfs_attr_item.c+2−49
@@ -653,7 +653,6 @@ xfs_attri_recover_work( · 652 unmodified lines
653653 break;
654654 }
655655 if (error) {
656− xfs_irele(ip);
657656 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attrp,
658657 sizeof(*attrp));
659658 return ERR_PTR(-EFSCORRUPTED);
@@ -1047,8 +1046,8 @@ xlog_recover_attri_commit_pass2( · 387 unmodified lines
10471046 break;
10481047 case XFS_ATTRI_OP_FLAGS_SET:
10491048 case XFS_ATTRI_OP_FLAGS_REPLACE:
1050− /* Log item, attr name, attr value */
1051− if (item->ri_total != 3) {
1049+ /* Log item, attr name, optional attr value */
1050+ if (item->ri_total != 2 + !!attri_formatp->alfi_value_len) {
10521051 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
10531052 attri_formatp, len);
10541053 return -EFSCORRUPTED;
@@ -1132,52 +1131,6 @@ xlog_recover_attri_commit_pass2( · 77 unmodified lines
11321131 return -EFSCORRUPTED;
11331132 }
11341133
1135− switch (op) {
1136− case XFS_ATTRI_OP_FLAGS_REMOVE:
1137− /* Regular remove operations operate only on names. */
1138− if (attr_value != NULL || value_len != 0) {
1139− XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
1140− attri_formatp, len);
1141− return -EFSCORRUPTED;
1142− }
1143− fallthrough;
1144− case XFS_ATTRI_OP_FLAGS_PPTR_REMOVE:
1145− case XFS_ATTRI_OP_FLAGS_PPTR_SET:
1146− case XFS_ATTRI_OP_FLAGS_SET:
1147− case XFS_ATTRI_OP_FLAGS_REPLACE:
1148− /*
1149− * Regular xattr set/remove/replace operations require a name
1150− * and do not take a newname. Values are optional for set and
1151− * replace.
1152− *
1153− * Name-value set/remove operations must have a name, do not
1154− * take a newname, and can take a value.
1155− */
1156− if (attr_name == NULL || name_len == 0) {
1157− XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
1158− attri_formatp, len);
1159− return -EFSCORRUPTED;
1160− }
1161− break;
1162− case XFS_ATTRI_OP_FLAGS_PPTR_REPLACE:
1163− /*
1164− * Name-value replace operations require the caller to
1165− * specify the old and new names and values explicitly.
1166− * Values are optional.
1167− */
1168− if (attr_name == NULL || name_len == 0) {
1169− XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
1170− attri_formatp, len);
1171− return -EFSCORRUPTED;
1172− }
1173− if (attr_new_name == NULL || new_name_len == 0) {
1174− XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
1175− attri_formatp, len);
1176− return -EFSCORRUPTED;
1177− }
1178− break;
1179− }
1180−
11811134 /*
11821135 * Memory alloc failure will cause replay to abort. We attach the
11831136 * name/value buffer to the recovered incore log item and drop our
fs/xfs/xfs_dquot_item.c+7−2
@@ -125,6 +125,7 @@ xfs_qm_dquot_logitem_push( · 124 unmodified lines
125125 struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip);
126126 struct xfs_dquot *dqp = qlip->qli_dquot;
127127 struct xfs_buf *bp;
128+ struct xfs_ail *ailp = lip->li_ailp;
128129 uint rval = XFS_ITEM_SUCCESS;
129130 int error;
130131
@@ -153,7 +154,7 @@ xfs_qm_dquot_logitem_push( · 22 unmodified lines
153154 goto out_unlock;
154155 }
155156
156− spin_unlock(&lip->li_ailp->ail_lock);
157+ spin_unlock(&ailp->ail_lock);
157158
158159 error = xfs_dquot_use_attached_buf(dqp, &bp);
159160 if (error == -EAGAIN) {
@@ -172,9 +173,13 @@ xfs_qm_dquot_logitem_push( · 12 unmodified lines
172173 rval = XFS_ITEM_FLUSHING;
173174 }
174175 xfs_buf_relse(bp);
176+ /*
177+ * The buffer no longer protects the log item from reclaim, so
178+ * do not reference lip after this point.
179+ */
175180
176181 out_relock_ail:
177− spin_lock(&lip->li_ailp->ail_lock);
182+ spin_lock(&ailp->ail_lock);
178183 out_unlock:
179184 mutex_unlock(&dqp->q_qlock);
180185 return rval;
fs/xfs/xfs_handle.c+1−1
@@ -443,8 +443,8 @@ xfs_ioc_attr_list( · 442 unmodified lines
443443 context.dp = dp;
444444 context.resynch = 1;
445445 context.attr_filter = xfs_attr_filter(flags);
446− context.buffer = buffer;
447446 context.bufsize = round_down(bufsize, sizeof(uint32_t));
447+ context.buffer = buffer;
448448 context.firstu = context.bufsize;
449449 context.put_listent = xfs_ioc_attr_put_listent;
450450
fs/xfs/xfs_inode.c+2−1
@@ -1048,7 +1048,8 @@ xfs_itruncate_extents_flags( · 1047 unmodified lines
10481048 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
10491049 if (icount_read(VFS_I(ip)))
10501050 xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL);
1051− ASSERT(new_size <= XFS_ISIZE(ip));
1051+ if (whichfork == XFS_DATA_FORK)
1052+ ASSERT(new_size <= XFS_ISIZE(ip));
10521053 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
10531054 ASSERT(ip->i_itemp != NULL);
10541055 ASSERT(ip->i_itemp->ili_lock_flags == 0);
fs/xfs/xfs_inode_item.c+7−2
@@ -746,6 +746,7 @@ xfs_inode_item_push( · 745 unmodified lines
746746 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
747747 struct xfs_inode *ip = iip->ili_inode;
748748 struct xfs_buf *bp = lip->li_buf;
749+ struct xfs_ail *ailp = lip->li_ailp;
749750 uint rval = XFS_ITEM_SUCCESS;
750751 int error;
751752
@@ -771,7 +772,7 @@ xfs_inode_item_push( · 19 unmodified lines
771772 if (!xfs_buf_trylock(bp))
772773 return XFS_ITEM_LOCKED;
773774
774− spin_unlock(&lip->li_ailp->ail_lock);
775+ spin_unlock(&ailp->ail_lock);
775776
776777 /*
777778 * We need to hold a reference for flushing the cluster buffer as it may
@@ -795,7 +796,11 @@ xfs_inode_item_push( · 17 unmodified lines
795796 rval = XFS_ITEM_LOCKED;
796797 }
797798
798− spin_lock(&lip->li_ailp->ail_lock);
799+ /*
800+ * The buffer no longer protects the log item from reclaim, so
801+ * do not reference lip after this point.
802+ */
803+ spin_lock(&ailp->ail_lock);
799804 return rval;
800805 }
801806
fs/xfs/xfs_mount.c+4−3
@@ -608,8 +608,9 @@ xfs_unmount_check( · 607 unmodified lines
608608 * have been retrying in the background. This will prevent never-ending
609609 * retries in AIL pushing from hanging the unmount.
610610 *
611− * Finally, we can push the AIL to clean all the remaining dirty objects, then
612− * reclaim the remaining inodes that are still in memory at this point in time.
611+ * Stop inodegc and background reclaim before pushing the AIL so that they
612+ * are not running while the AIL is being flushed. Then push the AIL to
613+ * clean all the remaining dirty objects and reclaim the remaining inodes.
613614 */
614615 static void
615616 xfs_unmount_flush_inodes(
@@ -621,9 +622,9 @@ xfs_unmount_flush_inodes( · 5 unmodified lines
621622
622623 xfs_set_unmounting(mp);
623624
624− xfs_ail_push_all_sync(mp->m_ail);
625625 xfs_inodegc_stop(mp);
626626 cancel_delayed_work_sync(&mp->m_reclaim_work);
627+ xfs_ail_push_all_sync(mp->m_ail);
627628 xfs_reclaim_inodes(mp);
628629 xfs_health_unmount(mp);
629630 xfs_healthmon_unmount(mp);
fs/xfs/xfs_trace.h+34−13
@@ -56,6 +56,7 @@ · 55 unmodified lines
5656 #include <linux/tracepoint.h>
5757
5858 struct xfs_agf;
59+struct xfs_ail;
5960 struct xfs_alloc_arg;
6061 struct xfs_attr_list_context;
6162 struct xfs_buf_log_item;
@@ -1650,16 +1651,43 @@ TRACE_EVENT(xfs_log_force, · 1588 unmodified lines
16501651 DEFINE_EVENT(xfs_log_item_class, name, \
16511652 TP_PROTO(struct xfs_log_item *lip), \
16521653 TP_ARGS(lip))
1653−DEFINE_LOG_ITEM_EVENT(xfs_ail_push);
1654−DEFINE_LOG_ITEM_EVENT(xfs_ail_pinned);
1655−DEFINE_LOG_ITEM_EVENT(xfs_ail_locked);
1656−DEFINE_LOG_ITEM_EVENT(xfs_ail_flushing);
16571654 DEFINE_LOG_ITEM_EVENT(xfs_cil_whiteout_mark);
16581655 DEFINE_LOG_ITEM_EVENT(xfs_cil_whiteout_skip);
16591656 DEFINE_LOG_ITEM_EVENT(xfs_cil_whiteout_unpin);
16601657 DEFINE_LOG_ITEM_EVENT(xlog_ail_insert_abort);
16611658 DEFINE_LOG_ITEM_EVENT(xfs_trans_free_abort);
16621659
1660+DECLARE_EVENT_CLASS(xfs_ail_push_class,
1661+ TP_PROTO(struct xfs_ail *ailp, uint type, unsigned long flags, xfs_lsn_t lsn),
1662+ TP_ARGS(ailp, type, flags, lsn),
1663+ TP_STRUCT__entry(
1664+ __field(dev_t, dev)
1665+ __field(uint, type)
1666+ __field(unsigned long, flags)
1667+ __field(xfs_lsn_t, lsn)
1668+ ),
1669+ TP_fast_assign(
1670+ __entry->dev = ailp->ail_log->l_mp->m_super->s_dev;
1671+ __entry->type = type;
1672+ __entry->flags = flags;
1673+ __entry->lsn = lsn;
1674+ ),
1675+ TP_printk("dev %d:%d lsn %d/%d type %s flags %s",
1676+ MAJOR(__entry->dev), MINOR(__entry->dev),
1677+ CYCLE_LSN(__entry->lsn), BLOCK_LSN(__entry->lsn),
1678+ __print_symbolic(__entry->type, XFS_LI_TYPE_DESC),
1679+ __print_flags(__entry->flags, "|", XFS_LI_FLAGS))
1680+)
1681+
1682+#define DEFINE_AIL_PUSH_EVENT(name) \
1683+DEFINE_EVENT(xfs_ail_push_class, name, \
1684+ TP_PROTO(struct xfs_ail *ailp, uint type, unsigned long flags, xfs_lsn_t lsn), \
1685+ TP_ARGS(ailp, type, flags, lsn))
1686+DEFINE_AIL_PUSH_EVENT(xfs_ail_push);
1687+DEFINE_AIL_PUSH_EVENT(xfs_ail_pinned);
1688+DEFINE_AIL_PUSH_EVENT(xfs_ail_locked);
1689+DEFINE_AIL_PUSH_EVENT(xfs_ail_flushing);
1690+
16631691 DECLARE_EVENT_CLASS(xfs_ail_class,
16641692 TP_PROTO(struct xfs_log_item *lip, xfs_lsn_t old_lsn, xfs_lsn_t new_lsn),
16651693 TP_ARGS(lip, old_lsn, new_lsn),
@@ -5091,23 +5119,16 @@ TRACE_EVENT(xmbuf_create, · 3425 unmodified lines
50915119 TP_STRUCT__entry(
50925120 __field(dev_t, dev)
50935121 __field(unsigned long, ino)
5094− __array(char, pathname, MAXNAMELEN)
50955122 ),
50965123 TP_fast_assign(
5097− char *path;
50985124 struct file *file = btp->bt_file;
50995125
51005126 __entry->dev = btp->bt_mount->m_super->s_dev;
51015127 __entry->ino = file_inode(file)->i_ino;
5102− path = file_path(file, __entry->pathname, MAXNAMELEN);
5103− if (IS_ERR(path))
5104− strncpy(__entry->pathname, "(unknown)",
5105− sizeof(__entry->pathname));
51065128 ),
5107− TP_printk("dev %d:%d xmino 0x%lx path '%s'",
5129+ TP_printk("dev %d:%d xmino 0x%lx",
51085130 MAJOR(__entry->dev), MINOR(__entry->dev),
5109− __entry->ino,
5110− __entry->pathname)
5131+ __entry->ino)
51115132 );
51125133
51135134 TRACE_EVENT(xmbuf_free,
fs/xfs/xfs_trans_ail.c+75−52
@@ -365,6 +365,12 @@ xfsaild_resubmit_item( · 364 unmodified lines
365365 return XFS_ITEM_SUCCESS;
366366 }
367367
368+/*
369+ * Push a single log item from the AIL.
370+ *
371+ * @lip may have been released and freed by the time this function returns,
372+ * so callers must not dereference the log item afterwards.
373+ */
368374 static inline uint
369375 xfsaild_push_item(
370376 struct xfs_ail *ailp,
@@ -458,6 +464,74 @@ xfs_ail_calc_push_target( · 87 unmodified lines
458464 return target_lsn;
459465 }
460466
467+static void
468+xfsaild_process_logitem(
469+ struct xfs_ail *ailp,
470+ struct xfs_log_item *lip,
471+ int *stuck,
472+ int *flushing)
473+{
474+ struct xfs_mount *mp = ailp->ail_log->l_mp;
475+ uint type = lip->li_type;
476+ unsigned long flags = lip->li_flags;
477+ xfs_lsn_t item_lsn = lip->li_lsn;
478+ int lock_result;
479+
480+ /*
481+ * Note that iop_push may unlock and reacquire the AIL lock. We
482+ * rely on the AIL cursor implementation to be able to deal with
483+ * the dropped lock.
484+ *
485+ * The log item may have been freed by the push, so it must not
486+ * be accessed or dereferenced below this line.
487+ */
488+ lock_result = xfsaild_push_item(ailp, lip);
489+ switch (lock_result) {
490+ case XFS_ITEM_SUCCESS:
491+ XFS_STATS_INC(mp, xs_push_ail_success);
492+ trace_xfs_ail_push(ailp, type, flags, item_lsn);
493+
494+ ailp->ail_last_pushed_lsn = item_lsn;
495+ break;
496+
497+ case XFS_ITEM_FLUSHING:
498+ /*
499+ * The item or its backing buffer is already being
500+ * flushed. The typical reason for that is that an
501+ * inode buffer is locked because we already pushed the
502+ * updates to it as part of inode clustering.
503+ *
504+ * We do not want to stop flushing just because lots
505+ * of items are already being flushed, but we need to
506+ * re-try the flushing relatively soon if most of the
507+ * AIL is being flushed.
508+ */
509+ XFS_STATS_INC(mp, xs_push_ail_flushing);
510+ trace_xfs_ail_flushing(ailp, type, flags, item_lsn);
511+
512+ (*flushing)++;
513+ ailp->ail_last_pushed_lsn = item_lsn;
514+ break;
515+
516+ case XFS_ITEM_PINNED:
517+ XFS_STATS_INC(mp, xs_push_ail_pinned);
518+ trace_xfs_ail_pinned(ailp, type, flags, item_lsn);
519+
520+ (*stuck)++;
521+ ailp->ail_log_flush++;
522+ break;
523+ case XFS_ITEM_LOCKED:
524+ XFS_STATS_INC(mp, xs_push_ail_locked);
525+ trace_xfs_ail_locked(ailp, type, flags, item_lsn);
526+
527+ (*stuck)++;
528+ break;
529+ default:
530+ ASSERT(0);
531+ break;
532+ }
533+}
534+
461535 static long
462536 xfsaild_push(
463537 struct xfs_ail *ailp)
@@ -505,62 +579,11 @@ xfsaild_push( · 41 unmodified lines
505579
506580 lsn = lip->li_lsn;
507581 while ((XFS_LSN_CMP(lip->li_lsn, ailp->ail_target) <= 0)) {
508− int lock_result;
509582
510583 if (test_bit(XFS_LI_FLUSHING, &lip->li_flags))
511584 goto next_item;
512585
513− /*
514− * Note that iop_push may unlock and reacquire the AIL lock. We
515− * rely on the AIL cursor implementation to be able to deal with
516− * the dropped lock.
517− */
518− lock_result = xfsaild_push_item(ailp, lip);
519− switch (lock_result) {
520− case XFS_ITEM_SUCCESS:
521− XFS_STATS_INC(mp, xs_push_ail_success);
522− trace_xfs_ail_push(lip);
523−
524− ailp->ail_last_pushed_lsn = lsn;
525− break;
526−
527− case XFS_ITEM_FLUSHING:
528− /*
529− * The item or its backing buffer is already being
530− * flushed. The typical reason for that is that an
531− * inode buffer is locked because we already pushed the
532− * updates to it as part of inode clustering.
533− *
534− * We do not want to stop flushing just because lots
535− * of items are already being flushed, but we need to
536− * re-try the flushing relatively soon if most of the
537− * AIL is being flushed.
538− */
539− XFS_STATS_INC(mp, xs_push_ail_flushing);
540− trace_xfs_ail_flushing(lip);
541−
542− flushing++;
543− ailp->ail_last_pushed_lsn = lsn;
544− break;
545−
546− case XFS_ITEM_PINNED:
547− XFS_STATS_INC(mp, xs_push_ail_pinned);
548− trace_xfs_ail_pinned(lip);
549−
550− stuck++;
551− ailp->ail_log_flush++;
552− break;
553− case XFS_ITEM_LOCKED:
554− XFS_STATS_INC(mp, xs_push_ail_locked);
555− trace_xfs_ail_locked(lip);
556−
557− stuck++;
558− break;
559− default:
560− ASSERT(0);
561− break;
562− }
563−
586+ xfsaild_process_logitem(ailp, lip, &stuck, &flushing);
564587 count++;
565588
566589 /*
fs/xfs/xfs_verify_media.c+8−10
@@ -183,10 +183,9 @@ xfs_verify_iosize( · 182 unmodified lines
183183 min_not_zero(SZ_1M, me->me_max_io_size);
184184
185185 BUILD_BUG_ON(BBSHIFT != SECTOR_SHIFT);
186− ASSERT(BBTOB(bbcount) >= bdev_logical_block_size(btp->bt_bdev));
186+ ASSERT(BBTOB(bbcount) >= btp->bt_logical_sectorsize);
187187
188− return clamp(iosize, bdev_logical_block_size(btp->bt_bdev),
189− BBTOB(bbcount));
188+ return clamp(iosize, btp->bt_logical_sectorsize, BBTOB(bbcount));
190189 }
191190
192191 /* Allocate as much memory as we can get for verification buffer. */
@@ -218,8 +217,8 @@ xfs_verify_media_error( · 25 unmodified lines
218217 unsigned int bio_bbcount,
219218 blk_status_t bio_status)
220219 {
221− trace_xfs_verify_media_error(mp, me, btp->bt_bdev->bd_dev, daddr,
222− bio_bbcount, bio_status);
220+ trace_xfs_verify_media_error(mp, me, btp->bt_dev, daddr, bio_bbcount,
221+ bio_status);
223222
224223 /*
225224 * Pass any error, I/O or otherwise, up to the caller if we didn't
@@ -280,7 +279,7 @@ xfs_verify_media( · 54 unmodified lines
280279 btp = mp->m_ddev_targp;
281280 break;
282281 case XFS_DEV_LOG:
283− if (mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev)
282+ if (mp->m_logdev_targp != mp->m_ddev_targp)
284283 btp = mp->m_logdev_targp;
285284 break;
286285 case XFS_DEV_RT:
@@ -299,7 +298,7 @@ xfs_verify_media( · 12 unmodified lines
299298
300299 /* start and end have to be aligned to the lba size */
301300 if (!IS_ALIGNED(BBTOB(me->me_start_daddr | me->me_end_daddr),
302− bdev_logical_block_size(btp->bt_bdev)))
301+ btp->bt_logical_sectorsize))
303302 return -EINVAL;
304303
305304 /*
@@ -331,8 +330,7 @@ xfs_verify_media( · 25 unmodified lines
331330 if (!folio)
332331 return -ENOMEM;
333332
334− trace_xfs_verify_media(mp, me, btp->bt_bdev->bd_dev, daddr, bbcount,
335− folio);
333+ trace_xfs_verify_media(mp, me, btp->bt_dev, daddr, bbcount, folio);
336334
337335 bio = bio_alloc(btp->bt_bdev, 1, REQ_OP_READ, GFP_KERNEL);
338336 if (!bio) {
@@ -400,7 +398,7 @@ out_folio: · 61 unmodified lines
400398 * an operational error.
401399 */
402400 me->me_start_daddr = daddr;
403− trace_xfs_verify_media_end(mp, me, btp->bt_bdev->bd_dev);
401+ trace_xfs_verify_media_end(mp, me, btp->bt_dev);
404402 return 0;
405403 }
406404
fs/xfs/xfs_xattr.c+1−1
@@ -332,8 +332,8 @@ xfs_vn_listxattr( · 331 unmodified lines
332332 memset(&context, 0, sizeof(context));
333333 context.dp = XFS_I(inode);
334334 context.resynch = 1;
335− context.buffer = size ? data : NULL;
336335 context.bufsize = size;
336+ context.buffer = size ? data : NULL;
337337 context.firstu = context.bufsize;
338338 context.put_listent = xfs_xattr_put_listent;
339339
include/linux/damon.h+6−0
@@ -810,6 +810,12 @@ struct damon_ctx { · 809 unmodified lines
810810 struct damos_walk_control *walk_control;
811811 struct mutex walk_control_lock;
812812
813+ /*
814+ * indicate if this may be corrupted. Currentonly this is set only for
815+ * damon_commit_ctx() failure.
816+ */
817+ bool maybe_corrupted;
818+
813819 /* Working thread of the given DAMON context */
814820 struct task_struct *kdamond;
815821 /* Protects @kdamond field access */
include/linux/dma-mapping.h+13−6
@@ -80,11 +80,18 @@ · 79 unmodified lines
8080 #define DMA_ATTR_MMIO (1UL << 10)
8181
8282 /*
83− * DMA_ATTR_CPU_CACHE_CLEAN: Indicates the CPU will not dirty any cacheline
84− * overlapping this buffer while it is mapped for DMA. All mappings sharing
85− * a cacheline must have this attribute for this to be considered safe.
83+ * DMA_ATTR_DEBUGGING_IGNORE_CACHELINES: Indicates the CPU cache line can be
84+ * overlapped. All mappings sharing a cacheline must have this attribute for
85+ * this to be considered safe.
8686 */
87−#define DMA_ATTR_CPU_CACHE_CLEAN (1UL << 11)
87+#define DMA_ATTR_DEBUGGING_IGNORE_CACHELINES (1UL << 11)
88+
89+/*
90+ * DMA_ATTR_REQUIRE_COHERENT: Indicates that DMA coherency is required.
91+ * All mappings that carry this attribute can't work with SWIOTLB and cache
92+ * flushing.
93+ */
94+#define DMA_ATTR_REQUIRE_COHERENT (1UL << 12)
8895
8996 /*
9097 * A dma_addr_t can hold any valid DMA or bus address for the platform. It can
@@ -248,8 +255,8 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size, · 157 unmodified lines
248255 {
249256 return NULL;
250257 }
251−static void dma_free_attrs(struct device *dev, size_t size, void *cpu_addr,
252− dma_addr_t dma_handle, unsigned long attrs)
258+static inline void dma_free_attrs(struct device *dev, size_t size,
259+ void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs)
253260 {
254261 }
255262 static inline void *dmam_alloc_attrs(struct device *dev, size_t size,
include/linux/fs/super_types.h+1−0
@@ -338,5 +338,6 @@ struct super_block { · 337 unmodified lines
338338 #define SB_I_NOUMASK 0x00001000 /* VFS does not apply umask */
339339 #define SB_I_NOIDMAP 0x00002000 /* No idmapped mounts on this superblock */
340340 #define SB_I_ALLOW_HSM 0x00004000 /* Allow HSM events on this superblock */
341+#define SB_I_NO_DATA_INTEGRITY 0x00008000 /* fs cannot guarantee data persistence on sync */
341342
342343 #endif /* _LINUX_FS_SUPER_TYPES_H */
include/linux/leafops.h+21−11
@@ -363,6 +363,23 @@ static inline unsigned long softleaf_to_pfn(softleaf_t entry) · 362 unmodified lines
363363 return swp_offset(entry) & SWP_PFN_MASK;
364364 }
365365
366+static inline void softleaf_migration_sync(softleaf_t entry,
367+ struct folio *folio)
368+{
369+ /*
370+ * Ensure we do not race with split, which might alter tail pages into new
371+ * folios and thus result in observing an unlocked folio.
372+ * This matches the write barrier in __split_folio_to_order().
373+ */
374+ smp_rmb();
375+
376+ /*
377+ * Any use of migration entries may only occur while the
378+ * corresponding page is locked
379+ */
380+ VM_WARN_ON_ONCE(!folio_test_locked(folio));
381+}
382+
366383 /**
367384 * softleaf_to_page() - Obtains struct page for PFN encoded within leaf entry.
368385 * @entry: Leaf entry, softleaf_has_pfn(@entry) must return true.
@@ -374,11 +391,8 @@ static inline struct page *softleaf_to_page(softleaf_t entry) · 5 unmodified lines
374391 struct page *page = pfn_to_page(softleaf_to_pfn(entry));
375392
376393 VM_WARN_ON_ONCE(!softleaf_has_pfn(entry));
377− /*
378− * Any use of migration entries may only occur while the
379− * corresponding page is locked
380− */
381− VM_WARN_ON_ONCE(softleaf_is_migration(entry) && !PageLocked(page));
394+ if (softleaf_is_migration(entry))
395+ softleaf_migration_sync(entry, page_folio(page));
382396
383397 return page;
384398 }
@@ -394,12 +408,8 @@ static inline struct folio *softleaf_to_folio(softleaf_t entry) · 9 unmodified lines
394408 struct folio *folio = pfn_folio(softleaf_to_pfn(entry));
395409
396410 VM_WARN_ON_ONCE(!softleaf_has_pfn(entry));
397− /*
398− * Any use of migration entries may only occur while the
399− * corresponding folio is locked.
400− */
401− VM_WARN_ON_ONCE(softleaf_is_migration(entry) &&
402− !folio_test_locked(folio));
411+ if (softleaf_is_migration(entry))
412+ softleaf_migration_sync(entry, folio);
403413
404414 return folio;
405415 }
include/linux/mempolicy.h+1−0
@@ -55,6 +55,7 @@ struct mempolicy { · 54 unmodified lines
5555 nodemask_t cpuset_mems_allowed; /* relative to these nodes */
5656 nodemask_t user_nodemask; /* nodemask passed by user */
5757 } w;
58+ struct rcu_head rcu;
5859 };
5960
6061 /*
include/linux/netfs.h+0−1
@@ -140,7 +140,6 @@ struct netfs_io_stream { · 139 unmodified lines
140140 void (*issue_write)(struct netfs_io_subrequest *subreq);
141141 /* Collection tracking */
142142 struct list_head subrequests; /* Contributory I/O operations */
143− struct netfs_io_subrequest *front; /* Op being collected */
144143 unsigned long long collected_to; /* Position we've collected results to */
145144 size_t transferred; /* The amount transferred from this stream */
146145 unsigned short error; /* Aggregate error for the stream */
include/linux/pagemap.h+0−11
@@ -210,7 +210,6 @@ enum mapping_flags { · 209 unmodified lines
210210 AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM = 9,
211211 AS_KERNEL_FILE = 10, /* mapping for a fake kernel file that shouldn't
212212 account usage to user cgroups */
213− AS_NO_DATA_INTEGRITY = 11, /* no data integrity guarantees */
214213 /* Bits 16-25 are used for FOLIO_ORDER */
215214 AS_FOLIO_ORDER_BITS = 5,
216215 AS_FOLIO_ORDER_MIN = 16,
@@ -346,16 +345,6 @@ static inline bool mapping_writeback_may_deadlock_on_reclaim(const struct addres · 129 unmodified lines
346345 return test_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags);
347346 }
348347
349−static inline void mapping_set_no_data_integrity(struct address_space *mapping)
350−{
351− set_bit(AS_NO_DATA_INTEGRITY, &mapping->flags);
352−}
353−
354−static inline bool mapping_no_data_integrity(const struct address_space *mapping)
355−{
356− return test_bit(AS_NO_DATA_INTEGRITY, &mapping->flags);
357−}
358−
359348 static inline gfp_t mapping_gfp_mask(const struct address_space *mapping)
360349 {
361350 return mapping->gfp_mask;
include/linux/security.h+1−0
@@ -145,6 +145,7 @@ enum lockdown_reason { · 144 unmodified lines
145145 LOCKDOWN_BPF_WRITE_USER,
146146 LOCKDOWN_DBG_WRITE_KERNEL,
147147 LOCKDOWN_RTAS_ERROR_INJECTION,
148+ LOCKDOWN_XEN_USER_ACTIONS,
148149 LOCKDOWN_INTEGRITY_MAX,
149150 LOCKDOWN_KCORE,
150151 LOCKDOWN_KPROBES,
include/linux/spi/spi.h+0−5
@@ -159,10 +159,6 @@ extern void spi_transfer_cs_change_delay_exec(struct spi_message *msg, · 158 unmodified lines
159159 * @modalias: Name of the driver to use with this device, or an alias
160160 * for that name. This appears in the sysfs "modalias" attribute
161161 * for driver coldplugging, and in uevents used for hotplugging
162− * @driver_override: If the name of a driver is written to this attribute, then
163− * the device will bind to the named driver and only the named driver.
164− * Do not set directly, because core frees it; use driver_set_override() to
165− * set or clear it.
166162 * @pcpu_statistics: statistics for the spi_device
167163 * @word_delay: delay to be inserted between consecutive
168164 * words of a transfer
@@ -224,7 +220,6 @@ struct spi_device { · 55 unmodified lines
224220 void *controller_state;
225221 void *controller_data;
226222 char modalias[SPI_NAME_SIZE];
227− const char *driver_override;
228223
229224 /* The statistics */
230225 struct spi_statistics __percpu *pcpu_statistics;
include/linux/srcutiny.h+4−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #ifndef _LINUX_SRCU_TINY_H
1212 #define _LINUX_SRCU_TINY_H
1313
14+#include <linux/irq_work_types.h>
1415 #include <linux/swait.h>
1516
1617 struct srcu_struct {
@@ -24,18 +25,21 @@ struct srcu_struct { · 7 unmodified lines
2425 struct rcu_head *srcu_cb_head; /* Pending callbacks: Head. */
2526 struct rcu_head **srcu_cb_tail; /* Pending callbacks: Tail. */
2627 struct work_struct srcu_work; /* For driving grace periods. */
28+ struct irq_work srcu_irq_work; /* Defer schedule_work() to irq work. */
2729 #ifdef CONFIG_DEBUG_LOCK_ALLOC
2830 struct lockdep_map dep_map;
2931 #endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
3032 };
3133
3234 void srcu_drive_gp(struct work_struct *wp);
35+void srcu_tiny_irq_work(struct irq_work *irq_work);
3336
3437 #define __SRCU_STRUCT_INIT(name, __ignored, ___ignored, ____ignored) \
3538 { \
3639 .srcu_wq = __SWAIT_QUEUE_HEAD_INITIALIZER(name.srcu_wq), \
3740 .srcu_cb_tail = &name.srcu_cb_head, \
3841 .srcu_work = __WORK_INITIALIZER(name.srcu_work, srcu_drive_gp), \
42+ .srcu_irq_work = { .func = srcu_tiny_irq_work }, \
3943 __SRCU_DEP_MAP_INIT(name) \
4044 }
4145
include/linux/srcutree.h+5−4
@@ -34,7 +34,7 @@ struct srcu_data { · 33 unmodified lines
3434 /* Values: SRCU_READ_FLAVOR_.* */
3535
3636 /* Update-side state. */
37− spinlock_t __private lock ____cacheline_internodealigned_in_smp;
37+ raw_spinlock_t __private lock ____cacheline_internodealigned_in_smp;
3838 struct rcu_segcblist srcu_cblist; /* List of callbacks.*/
3939 unsigned long srcu_gp_seq_needed; /* Furthest future GP needed. */
4040 unsigned long srcu_gp_seq_needed_exp; /* Furthest future exp GP. */
@@ -55,7 +55,7 @@ struct srcu_data { · 14 unmodified lines
5555 * Node in SRCU combining tree, similar in function to rcu_data.
5656 */
5757 struct srcu_node {
58− spinlock_t __private lock;
58+ raw_spinlock_t __private lock;
5959 unsigned long srcu_have_cbs[4]; /* GP seq for children having CBs, but only */
6060 /* if greater than ->srcu_gp_seq. */
6161 unsigned long srcu_data_have_cbs[4]; /* Which srcu_data structs have CBs for given GP? */
@@ -74,7 +74,7 @@ struct srcu_usage { · 12 unmodified lines
7474 /* First node at each level. */
7575 int srcu_size_state; /* Small-to-big transition state. */
7676 struct mutex srcu_cb_mutex; /* Serialize CB preparation. */
77− spinlock_t __private lock; /* Protect counters and size state. */
77+ raw_spinlock_t __private lock; /* Protect counters and size state. */
7878 struct mutex srcu_gp_mutex; /* Serialize GP work. */
7979 unsigned long srcu_gp_seq; /* Grace-period seq #. */
8080 unsigned long srcu_gp_seq_needed; /* Latest gp_seq needed. */
@@ -95,6 +95,7 @@ struct srcu_usage { · 14 unmodified lines
9595 unsigned long reschedule_jiffies;
9696 unsigned long reschedule_count;
9797 struct delayed_work work;
98+ struct irq_work irq_work;
9899 struct srcu_struct *srcu_ssp;
99100 };
100101
@@ -156,7 +157,7 @@ struct srcu_struct { · 55 unmodified lines
156157
157158 #define __SRCU_USAGE_INIT(name) \
158159 { \
159− .lock = __SPIN_LOCK_UNLOCKED(name.lock), \
160+ .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \
160161 .srcu_gp_seq = SRCU_GP_SEQ_INITIAL_VAL, \
161162 .srcu_gp_seq_needed = SRCU_GP_SEQ_INITIAL_VAL_WITH_STATE, \
162163 .srcu_gp_seq_needed_exp = SRCU_GP_SEQ_INITIAL_VAL, \
include/linux/virtio_net.h+49−4
@@ -207,6 +207,39 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb, · 206 unmodified lines
207207 return __virtio_net_hdr_to_skb(skb, hdr, little_endian, hdr->gso_type);
208208 }
209209
210+/* This function must be called after virtio_net_hdr_from_skb(). */
211+static inline void __virtio_net_set_hdrlen(const struct sk_buff *skb,
212+ struct virtio_net_hdr *hdr,
213+ bool little_endian)
214+{
215+ u16 hdr_len;
216+
217+ hdr_len = skb_transport_offset(skb);
218+
219+ if (hdr->gso_type == VIRTIO_NET_HDR_GSO_UDP_L4)
220+ hdr_len += sizeof(struct udphdr);
221+ else
222+ hdr_len += tcp_hdrlen(skb);
223+
224+ hdr->hdr_len = __cpu_to_virtio16(little_endian, hdr_len);
225+}
226+
227+/* This function must be called after virtio_net_hdr_from_skb(). */
228+static inline void __virtio_net_set_tnl_hdrlen(const struct sk_buff *skb,
229+ struct virtio_net_hdr *hdr)
230+{
231+ u16 hdr_len;
232+
233+ hdr_len = skb_inner_transport_offset(skb);
234+
235+ if (hdr->gso_type == VIRTIO_NET_HDR_GSO_UDP_L4)
236+ hdr_len += sizeof(struct udphdr);
237+ else
238+ hdr_len += inner_tcp_hdrlen(skb);
239+
240+ hdr->hdr_len = __cpu_to_virtio16(true, hdr_len);
241+}
242+
210243 static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
211244 struct virtio_net_hdr *hdr,
212245 bool little_endian,
@@ -385,7 +418,8 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb, · 172 unmodified lines
385418 bool tnl_hdr_negotiated,
386419 bool little_endian,
387420 int vlan_hlen,
388− bool has_data_valid)
421+ bool has_data_valid,
422+ bool feature_hdrlen)
389423 {
390424 struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)vhdr;
391425 unsigned int inner_nh, outer_th;
@@ -394,9 +428,17 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb, · 2 unmodified lines
394428
395429 tnl_gso_type = skb_shinfo(skb)->gso_type & (SKB_GSO_UDP_TUNNEL |
396430 SKB_GSO_UDP_TUNNEL_CSUM);
397− if (!tnl_gso_type)
398− return virtio_net_hdr_from_skb(skb, hdr, little_endian,
399− has_data_valid, vlan_hlen);
431+ if (!tnl_gso_type) {
432+ ret = virtio_net_hdr_from_skb(skb, hdr, little_endian,
433+ has_data_valid, vlan_hlen);
434+ if (ret)
435+ return ret;
436+
437+ if (feature_hdrlen && hdr->hdr_len)
438+ __virtio_net_set_hdrlen(skb, hdr, little_endian);
439+
440+ return ret;
441+ }
400442
401443 /* Tunnel support not negotiated but skb ask for it. */
402444 if (!tnl_hdr_negotiated)
@@ -414,6 +456,9 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb, · 11 unmodified lines
414456 if (ret)
415457 return ret;
416458
459+ if (feature_hdrlen && hdr->hdr_len)
460+ __virtio_net_set_tnl_hdrlen(skb, hdr);
461+
417462 if (skb->protocol == htons(ETH_P_IPV6))
418463 hdr->gso_type |= VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6;
419464 else
include/net/bluetooth/l2cap.h+1−0
@@ -658,6 +658,7 @@ struct l2cap_conn { · 657 unmodified lines
658658 struct sk_buff *rx_skb;
659659 __u32 rx_len;
660660 struct ida tx_ida;
661+ __u8 tx_ident;
661662
662663 struct sk_buff_head pending_rx;
663664 struct work_struct pending_rx_work;
include/net/codel_impl.h+1−0
@@ -158,6 +158,7 @@ static struct sk_buff *codel_dequeue(void *ctx, · 157 unmodified lines
158158 bool drop;
159159
160160 if (!skb) {
161+ vars->first_above_time = 0;
161162 vars->dropping = false;
162163 return skb;
163164 }
include/net/inet_hashtables.h+14−0
@@ -264,6 +264,20 @@ inet_bhashfn_portaddr(const struct inet_hashinfo *hinfo, const struct sock *sk, · 263 unmodified lines
264264 return &hinfo->bhash2[hash & (hinfo->bhash_size - 1)];
265265 }
266266
267+static inline bool inet_use_hash2_on_bind(const struct sock *sk)
268+{
269+#if IS_ENABLED(CONFIG_IPV6)
270+ if (sk->sk_family == AF_INET6) {
271+ if (ipv6_addr_any(&sk->sk_v6_rcv_saddr))
272+ return false;
273+
274+ if (!ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))
275+ return true;
276+ }
277+#endif
278+ return sk->sk_rcv_saddr != htonl(INADDR_ANY);
279+}
280+
267281 struct inet_bind_hashbucket *
268282 inet_bhash2_addr_any_hashbucket(const struct sock *sk, const struct net *net, int port);
269283
include/net/ip6_fib.h+20−1
@@ -507,12 +507,14 @@ void fib6_rt_update(struct net *net, struct fib6_info *rt, · 506 unmodified lines
507507 void inet6_rt_notify(int event, struct fib6_info *rt, struct nl_info *info,
508508 unsigned int flags);
509509
510+void fib6_age_exceptions(struct fib6_info *rt, struct fib6_gc_args *gc_args,
511+ unsigned long now);
510512 void fib6_run_gc(unsigned long expires, struct net *net, bool force);
511−
512513 void fib6_gc_cleanup(void);
513514
514515 int fib6_init(void);
515516
517+#if IS_ENABLED(CONFIG_IPV6)
516518 /* Add the route to the gc list if it is not already there
517519 *
518520 * The callers should hold f6i->fib6_table->tb6_lock.
@@ -545,6 +547,23 @@ static inline void fib6_remove_gc_list(struct fib6_info *f6i) · 26 unmodified lines
545547 hlist_del_init(&f6i->gc_link);
546548 }
547549
550+static inline void fib6_may_remove_gc_list(struct net *net,
551+ struct fib6_info *f6i)
552+{
553+ struct fib6_gc_args gc_args;
554+
555+ if (hlist_unhashed(&f6i->gc_link))
556+ return;
557+
558+ gc_args.timeout = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_interval);
559+ gc_args.more = 0;
560+
561+ rcu_read_lock();
562+ fib6_age_exceptions(f6i, &gc_args, jiffies);
563+ rcu_read_unlock();
564+}
565+#endif
566+
548567 struct ipv6_route_iter {
549568 struct seq_net_private p;
550569 struct fib6_walker w;
include/net/netfilter/nf_conntrack_core.h+5−0
@@ -83,6 +83,11 @@ void nf_conntrack_lock(spinlock_t *lock); · 82 unmodified lines
8383
8484 extern spinlock_t nf_conntrack_expect_lock;
8585
86+static inline void lockdep_nfct_expect_lock_held(void)
87+{
88+ lockdep_assert_held(&nf_conntrack_expect_lock);
89+}
90+
8691 /* ctnetlink code shared by both ctnetlink and nf_conntrack_bpf */
8792
8893 static inline void __nf_ct_set_timeout(struct nf_conn *ct, u64 timeout)
include/net/netfilter/nf_conntrack_expect.h+18−2
@@ -22,10 +22,16 @@ struct nf_conntrack_expect { · 21 unmodified lines
2222 /* Hash member */
2323 struct hlist_node hnode;
2424
25+ /* Network namespace */
26+ possible_net_t net;
27+
2528 /* We expect this tuple, with the following mask */
2629 struct nf_conntrack_tuple tuple;
2730 struct nf_conntrack_tuple_mask mask;
2831
32+#ifdef CONFIG_NF_CONNTRACK_ZONES
33+ struct nf_conntrack_zone zone;
34+#endif
2935 /* Usage count. */
3036 refcount_t use;
3137
@@ -40,7 +46,7 @@ struct nf_conntrack_expect { · 8 unmodified lines
4046 struct nf_conntrack_expect *this);
4147
4248 /* Helper to assign to new connection */
43− struct nf_conntrack_helper *helper;
49+ struct nf_conntrack_helper __rcu *helper;
4450
4551 /* The conntrack of the master connection */
4652 struct nf_conn *master;
@@ -62,7 +68,17 @@ struct nf_conntrack_expect { · 15 unmodified lines
6268
6369 static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
6470 {
65− return nf_ct_net(exp->master);
71+ return read_pnet(&exp->net);
72+}
73+
74+static inline bool nf_ct_exp_zone_equal_any(const struct nf_conntrack_expect *a,
75+ const struct nf_conntrack_zone *b)
76+{
77+#ifdef CONFIG_NF_CONNTRACK_ZONES
78+ return a->zone.id == b->id;
79+#else
80+ return true;
81+#endif
6682 }
6783
6884 #define NF_CT_EXP_POLICY_NAME_LEN 16
include/net/netns/xfrm.h+1−1
@@ -59,7 +59,7 @@ struct netns_xfrm { · 58 unmodified lines
5959 struct list_head inexact_bins;
6060
6161
62− struct sock *nlsk;
62+ struct sock __rcu *nlsk;
6363 struct sock *nlsk_stash;
6464
6565 u32 sysctl_aevent_etime;
include/sound/sdca_function.h+0−5
@@ -26,11 +26,6 @@ struct sdca_function_desc; · 25 unmodified lines
2626 */
2727 #define SDCA_MAX_ENTITY_COUNT 128
2828
29−/*
30− * Sanity check on number of initialization writes, can be expanded if needed.
31− */
32−#define SDCA_MAX_INIT_COUNT 2048
33−
3429 /*
3530 * The Cluster IDs are 16-bit, so a maximum of 65535 Clusters per
3631 * function can be represented, however limit this to a slightly
include/trace/events/btrfs.h+7−4
@@ -769,12 +769,15 @@ TRACE_EVENT(btrfs_sync_file, · 768 unmodified lines
769769 ),
770770
771771 TP_fast_assign(
772− const struct dentry *dentry = file->f_path.dentry;
773− const struct inode *inode = d_inode(dentry);
772+ struct dentry *dentry = file_dentry(file);
773+ struct inode *inode = file_inode(file);
774+ struct dentry *parent = dget_parent(dentry);
775+ struct inode *parent_inode = d_inode(parent);
774776
775− TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
777+ dput(parent);
778+ TP_fast_assign_fsid(btrfs_sb(inode->i_sb));
776779 __entry->ino = btrfs_ino(BTRFS_I(inode));
777− __entry->parent = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
780+ __entry->parent = btrfs_ino(BTRFS_I(parent_inode));
778781 __entry->datasync = datasync;
779782 __entry->root_objectid = btrfs_root_id(BTRFS_I(inode)->root);
780783 ),
include/trace/events/dma.h+3−1
@@ -32,7 +32,9 @@ TRACE_DEFINE_ENUM(DMA_NONE); · 31 unmodified lines
3232 { DMA_ATTR_ALLOC_SINGLE_PAGES, "ALLOC_SINGLE_PAGES" }, \
3333 { DMA_ATTR_NO_WARN, "NO_WARN" }, \
3434 { DMA_ATTR_PRIVILEGED, "PRIVILEGED" }, \
35− { DMA_ATTR_MMIO, "MMIO" })
35+ { DMA_ATTR_MMIO, "MMIO" }, \
36+ { DMA_ATTR_DEBUGGING_IGNORE_CACHELINES, "CACHELINES_OVERLAP" }, \
37+ { DMA_ATTR_REQUIRE_COHERENT, "REQUIRE_COHERENT" })
3638
3739 DECLARE_EVENT_CLASS(dma_map,
3840 TP_PROTO(struct device *dev, phys_addr_t phys_addr, dma_addr_t dma_addr,
include/trace/events/netfs.h+4−4
@@ -740,19 +740,19 @@ TRACE_EVENT(netfs_collect_stream, · 739 unmodified lines
740740 __field(unsigned int, wreq)
741741 __field(unsigned char, stream)
742742 __field(unsigned long long, collected_to)
743− __field(unsigned long long, front)
743+ __field(unsigned long long, issued_to)
744744 ),
745745
746746 TP_fast_assign(
747747 __entry->wreq = wreq->debug_id;
748748 __entry->stream = stream->stream_nr;
749749 __entry->collected_to = stream->collected_to;
750− __entry->front = stream->front ? stream->front->start : UINT_MAX;
750+ __entry->issued_to = atomic64_read(&wreq->issued_to);
751751 ),
752752
753− TP_printk("R=%08x[%x:] cto=%llx frn=%llx",
753+ TP_printk("R=%08x[%x:] cto=%llx ito=%llx",
754754 __entry->wreq, __entry->stream,
755− __entry->collected_to, __entry->front)
755+ __entry->collected_to, __entry->issued_to)
756756 );
757757
758758 TRACE_EVENT(netfs_folioq,
include/uapi/linux/netfilter/nf_conntrack_common.h+4−0
@@ -159,5 +159,9 @@ enum ip_conntrack_expect_events { · 158 unmodified lines
159159 #define NF_CT_EXPECT_INACTIVE 0x2
160160 #define NF_CT_EXPECT_USERSPACE 0x4
161161
162+#ifdef __KERNEL__
163+#define NF_CT_EXPECT_MASK (NF_CT_EXPECT_PERMANENT | NF_CT_EXPECT_INACTIVE | \
164+ NF_CT_EXPECT_USERSPACE)
165+#endif
162166
163167 #endif /* _UAPI_NF_CONNTRACK_COMMON_H */
init/Kconfig+1−1
@@ -146,7 +146,7 @@ config CC_HAS_COUNTED_BY · 145 unmodified lines
146146 config CC_HAS_COUNTED_BY_PTR
147147 bool
148148 # supported since clang 22
149− default y if CC_IS_CLANG && CLANG_VERSION >= 220000
149+ default y if CC_IS_CLANG && CLANG_VERSION >= 220100
150150 # supported since gcc 16.0.0
151151 default y if CC_IS_GCC && GCC_VERSION >= 160000
152152
io_uring/fdinfo.c+3−1
@@ -119,12 +119,14 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) · 118 unmodified lines
119119 sq_idx);
120120 break;
121121 }
122− if ((++sq_head & sq_mask) == 0) {
122+ if (sq_idx == sq_mask) {
123123 seq_printf(m,
124124 "%5u: corrupted sqe, wrapping 128B entry\n",
125125 sq_idx);
126126 break;
127127 }
128+ sq_head++;
129+ i++;
128130 sqe128 = true;
129131 }
130132 seq_printf(m, "%5u: opcode:%s, fd:%d, flags:%x, off:%llu, "
kernel/dma/debug.c+5−4
@@ -453,7 +453,7 @@ static int active_cacheline_set_overlap(phys_addr_t cln, int overlap) · 452 unmodified lines
453453 return overlap;
454454 }
455455
456−static void active_cacheline_inc_overlap(phys_addr_t cln)
456+static void active_cacheline_inc_overlap(phys_addr_t cln, bool is_cache_clean)
457457 {
458458 int overlap = active_cacheline_read_overlap(cln);
459459
@@ -462,7 +462,7 @@ static void active_cacheline_inc_overlap(phys_addr_t cln) · 2 unmodified lines
462462 /* If we overflowed the overlap counter then we're potentially
463463 * leaking dma-mappings.
464464 */
465− WARN_ONCE(overlap > ACTIVE_CACHELINE_MAX_OVERLAP,
465+ WARN_ONCE(!is_cache_clean && overlap > ACTIVE_CACHELINE_MAX_OVERLAP,
466466 pr_fmt("exceeded %d overlapping mappings of cacheline %pa\n"),
467467 ACTIVE_CACHELINE_MAX_OVERLAP, &cln);
468468 }
@@ -495,7 +495,7 @@ static int active_cacheline_insert(struct dma_debug_entry *entry, · 26 unmodified lines
495495 if (rc == -EEXIST) {
496496 struct dma_debug_entry *existing;
497497
498− active_cacheline_inc_overlap(cln);
498+ active_cacheline_inc_overlap(cln, entry->is_cache_clean);
499499 existing = radix_tree_lookup(&dma_active_cacheline, cln);
500500 /* A lookup failure here after we got -EEXIST is unexpected. */
501501 WARN_ON(!existing);
@@ -601,7 +601,8 @@ static void add_dma_entry(struct dma_debug_entry *entry, unsigned long attrs) · 99 unmodified lines
601601 unsigned long flags;
602602 int rc;
603603
604− entry->is_cache_clean = !!(attrs & DMA_ATTR_CPU_CACHE_CLEAN);
604+ entry->is_cache_clean = attrs & (DMA_ATTR_DEBUGGING_IGNORE_CACHELINES |
605+ DMA_ATTR_REQUIRE_COHERENT);
605606
606607 bucket = get_hash_bucket(entry, &flags);
607608 hash_bucket_add(bucket, entry);
kernel/dma/direct.h+4−3
@@ -84,7 +84,7 @@ static inline dma_addr_t dma_direct_map_phys(struct device *dev, · 83 unmodified lines
8484 dma_addr_t dma_addr;
8585
8686 if (is_swiotlb_force_bounce(dev)) {
87− if (attrs & DMA_ATTR_MMIO)
87+ if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))
8888 return DMA_MAPPING_ERROR;
8989
9090 return swiotlb_map(dev, phys, size, dir, attrs);
@@ -98,7 +98,8 @@ static inline dma_addr_t dma_direct_map_phys(struct device *dev, · 7 unmodified lines
9898 dma_addr = phys_to_dma(dev, phys);
9999 if (unlikely(!dma_capable(dev, dma_addr, size, true)) ||
100100 dma_kmalloc_needs_bounce(dev, size, dir)) {
101− if (is_swiotlb_active(dev))
101+ if (is_swiotlb_active(dev) &&
102+ !(attrs & DMA_ATTR_REQUIRE_COHERENT))
102103 return swiotlb_map(dev, phys, size, dir, attrs);
103104
104105 goto err_overflow;
@@ -123,7 +124,7 @@ static inline void dma_direct_unmap_phys(struct device *dev, dma_addr_t addr, · 18 unmodified lines
123124 {
124125 phys_addr_t phys;
125126
126− if (attrs & DMA_ATTR_MMIO)
127+ if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))
127128 /* nothing to do: uncached and no swiotlb */
128129 return;
129130
kernel/dma/mapping.c+6−0
@@ -164,6 +164,9 @@ dma_addr_t dma_map_phys(struct device *dev, phys_addr_t phys, size_t size, · 163 unmodified lines
164164 if (WARN_ON_ONCE(!dev->dma_mask))
165165 return DMA_MAPPING_ERROR;
166166
167+ if (!dev_is_dma_coherent(dev) && (attrs & DMA_ATTR_REQUIRE_COHERENT))
168+ return DMA_MAPPING_ERROR;
169+
167170 if (dma_map_direct(dev, ops) ||
168171 (!is_mmio && arch_dma_map_phys_direct(dev, phys + size)))
169172 addr = dma_direct_map_phys(dev, phys, size, dir, attrs);
@@ -235,6 +238,9 @@ static int __dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, · 65 unmodified lines
235238
236239 BUG_ON(!valid_dma_direction(dir));
237240
241+ if (!dev_is_dma_coherent(dev) && (attrs & DMA_ATTR_REQUIRE_COHERENT))
242+ return -EOPNOTSUPP;
243+
238244 if (WARN_ON_ONCE(!dev->dma_mask))
239245 return 0;
240246
kernel/dma/swiotlb.c+19−2
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 #include <linux/gfp.h>
3131 #include <linux/highmem.h>
3232 #include <linux/io.h>
33+#include <linux/kmsan-checks.h>
3334 #include <linux/iommu-helper.h>
3435 #include <linux/init.h>
3536 #include <linux/memblock.h>
@@ -901,10 +902,19 @@ static void swiotlb_bounce(struct device *dev, phys_addr_t tlb_addr, size_t size · 865 unmodified lines
901902
902903 local_irq_save(flags);
903904 page = pfn_to_page(pfn);
904− if (dir == DMA_TO_DEVICE)
905+ if (dir == DMA_TO_DEVICE) {
906+ /*
907+ * Ideally, kmsan_check_highmem_page()
908+ * could be used here to detect infoleaks,
909+ * but callers may map uninitialized buffers
910+ * that will be written by the device,
911+ * causing false positives.
912+ */
905913 memcpy_from_page(vaddr, page, offset, sz);
906− else
914+ } else {
915+ kmsan_unpoison_memory(vaddr, sz);
907916 memcpy_to_page(page, offset, vaddr, sz);
917+ }
908918 local_irq_restore(flags);
909919
910920 size -= sz;
@@ -913,8 +923,15 @@ static void swiotlb_bounce(struct device *dev, phys_addr_t tlb_addr, size_t size · 2 unmodified lines
913923 offset = 0;
914924 }
915925 } else if (dir == DMA_TO_DEVICE) {
926+ /*
927+ * Ideally, kmsan_check_memory() could be used here to detect
928+ * infoleaks (uninitialized data being sent to device), but
929+ * callers may map uninitialized buffers that will be written
930+ * by the device, causing false positives.
931+ */
916932 memcpy(vaddr, phys_to_virt(orig_addr), size);
917933 } else {
934+ kmsan_unpoison_memory(vaddr, size);
918935 memcpy(phys_to_virt(orig_addr), vaddr, size);
919936 }
920937 }
kernel/futex/core.c+1−1
@@ -342,7 +342,7 @@ static int __futex_key_to_node(struct mm_struct *mm, unsigned long addr) · 341 unmodified lines
342342 if (!vma)
343343 return FUTEX_NO_NODE;
344344
345− mpol = vma_policy(vma);
345+ mpol = READ_ONCE(vma->vm_policy);
346346 if (!mpol)
347347 return FUTEX_NO_NODE;
348348
kernel/futex/pi.c+2−1
@@ -918,7 +918,7 @@ int fixup_pi_owner(u32 __user *uaddr, struct futex_q *q, int locked) · 917 unmodified lines
918918 int futex_lock_pi(u32 __user *uaddr, unsigned int flags, ktime_t *time, int trylock)
919919 {
920920 struct hrtimer_sleeper timeout, *to;
921− struct task_struct *exiting = NULL;
921+ struct task_struct *exiting;
922922 struct rt_mutex_waiter rt_waiter;
923923 struct futex_q q = futex_q_init;
924924 DEFINE_WAKE_Q(wake_q);
@@ -933,6 +933,7 @@ int futex_lock_pi(u32 __user *uaddr, unsigned int flags, ktime_t *time, int tryl · 8 unmodified lines
933933 to = futex_setup_timer(time, &timeout, flags, 0);
934934
935935 retry:
936+ exiting = NULL;
936937 ret = get_futex_key(uaddr, flags, &q.key, FUTEX_WRITE);
937938 if (unlikely(ret != 0))
938939 goto out;
kernel/futex/syscalls.c+8−0
@@ -459,6 +459,14 @@ SYSCALL_DEFINE4(futex_requeue, · 458 unmodified lines
459459 if (ret)
460460 return ret;
461461
462+ /*
463+ * For now mandate both flags are identical, like the sys_futex()
464+ * interface has. If/when we merge the variable sized futex support,
465+ * that patch can modify this test to allow a difference in size.
466+ */
467+ if (futexes[0].w.flags != futexes[1].w.flags)
468+ return -EINVAL;
469+
462470 cmpval = futexes[0].w.val;
463471
464472 return futex_requeue(u64_to_user_ptr(futexes[0].w.uaddr), futexes[0].w.flags,
kernel/power/main.c+1−1
@@ -40,7 +40,7 @@ void pm_restore_gfp_mask(void) · 39 unmodified lines
4040 {
4141 WARN_ON(!mutex_is_locked(&system_transition_mutex));
4242
43− if (WARN_ON(!saved_gfp_count) || --saved_gfp_count)
43+ if (!saved_gfp_count || --saved_gfp_count)
4444 return;
4545
4646 gfp_allowed_mask = saved_gfp_mask;
kernel/power/snapshot.c+11−0
@@ -2855,6 +2855,17 @@ int snapshot_write_finalize(struct snapshot_handle *handle) · 2854 unmodified lines
28552855 {
28562856 int error;
28572857
2858+ /*
2859+ * Call snapshot_write_next() to drain any trailing zero pages,
2860+ * but make sure we're in the data page region first.
2861+ * This function can return PAGE_SIZE if the kernel was expecting
2862+ * another copy page. Return -ENODATA in that situation.
2863+ */
2864+ if (handle->cur > nr_meta_pages + 1) {
2865+ error = snapshot_write_next(handle);
2866+ if (error)
2867+ return error > 0 ? -ENODATA : error;
2868+ }
28582869 copy_last_highmem_page();
28592870 error = hibernate_restore_protect_page(handle->buffer);
28602871 /* Do that only if we have loaded the image entirely */
kernel/rcu/rcu.h+9−0
@@ -502,6 +502,15 @@ do { \ · 501 unmodified lines
502502 ___locked; \
503503 })
504504
505+#define raw_spin_trylock_irqsave_rcu_node(p, flags) \
506+({ \
507+ bool ___locked = raw_spin_trylock_irqsave(&ACCESS_PRIVATE(p, lock), flags); \
508+ \
509+ if (___locked) \
510+ smp_mb__after_unlock_lock(); \
511+ ___locked; \
512+})
513+
505514 #define raw_lockdep_assert_held_rcu_node(p) \
506515 lockdep_assert_held(&ACCESS_PRIVATE(p, lock))
507516
kernel/rcu/srcutiny.c+18−1
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 */
1010
1111 #include <linux/export.h>
12+#include <linux/irq_work.h>
1213 #include <linux/mutex.h>
1314 #include <linux/preempt.h>
1415 #include <linux/rcupdate_wait.h>
@@ -41,6 +42,7 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp) · 26 unmodified lines
4142 ssp->srcu_idx_max = 0;
4243 INIT_WORK(&ssp->srcu_work, srcu_drive_gp);
4344 INIT_LIST_HEAD(&ssp->srcu_work.entry);
45+ init_irq_work(&ssp->srcu_irq_work, srcu_tiny_irq_work);
4446 return 0;
4547 }
4648
@@ -84,6 +86,7 @@ EXPORT_SYMBOL_GPL(init_srcu_struct); · 37 unmodified lines
8486 void cleanup_srcu_struct(struct srcu_struct *ssp)
8587 {
8688 WARN_ON(ssp->srcu_lock_nesting[0] || ssp->srcu_lock_nesting[1]);
89+ irq_work_sync(&ssp->srcu_irq_work);
8790 flush_work(&ssp->srcu_work);
8891 WARN_ON(ssp->srcu_gp_running);
8992 WARN_ON(ssp->srcu_gp_waiting);
@@ -177,6 +180,20 @@ void srcu_drive_gp(struct work_struct *wp) · 87 unmodified lines
177180 }
178181 EXPORT_SYMBOL_GPL(srcu_drive_gp);
179182
183+/*
184+ * Use an irq_work to defer schedule_work() to avoid acquiring the workqueue
185+ * pool->lock while the caller might hold scheduler locks, causing lockdep
186+ * splats due to workqueue_init() doing a wakeup.
187+ */
188+void srcu_tiny_irq_work(struct irq_work *irq_work)
189+{
190+ struct srcu_struct *ssp;
191+
192+ ssp = container_of(irq_work, struct srcu_struct, srcu_irq_work);
193+ schedule_work(&ssp->srcu_work);
194+}
195+EXPORT_SYMBOL_GPL(srcu_tiny_irq_work);
196+
180197 static void srcu_gp_start_if_needed(struct srcu_struct *ssp)
181198 {
182199 unsigned long cookie;
@@ -189,7 +206,7 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) · 6 unmodified lines
189206 WRITE_ONCE(ssp->srcu_idx_max, cookie);
190207 if (!READ_ONCE(ssp->srcu_gp_running)) {
191208 if (likely(srcu_init_done))
192− schedule_work(&ssp->srcu_work);
209+ irq_work_queue(&ssp->srcu_irq_work);
193210 else if (list_empty(&ssp->srcu_work.entry))
194211 list_add(&ssp->srcu_work.entry, &srcu_boot_list);
195212 }
kernel/rcu/srcutree.c+102−109
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <linux/mutex.h>
2020 #include <linux/percpu.h>
2121 #include <linux/preempt.h>
22+#include <linux/irq_work.h>
2223 #include <linux/rcupdate_wait.h>
2324 #include <linux/sched.h>
2425 #include <linux/smp.h>
@@ -75,44 +76,9 @@ static bool __read_mostly srcu_init_done; · 50 unmodified lines
7576 static void srcu_invoke_callbacks(struct work_struct *work);
7677 static void srcu_reschedule(struct srcu_struct *ssp, unsigned long delay);
7778 static void process_srcu(struct work_struct *work);
79+static void srcu_irq_work(struct irq_work *work);
7880 static void srcu_delay_timer(struct timer_list *t);
7981
80−/* Wrappers for lock acquisition and release, see raw_spin_lock_rcu_node(). */
81−#define spin_lock_rcu_node(p) \
82−do { \
83− spin_lock(&ACCESS_PRIVATE(p, lock)); \
84− smp_mb__after_unlock_lock(); \
85−} while (0)
86−
87−#define spin_unlock_rcu_node(p) spin_unlock(&ACCESS_PRIVATE(p, lock))
88−
89−#define spin_lock_irq_rcu_node(p) \
90−do { \
91− spin_lock_irq(&ACCESS_PRIVATE(p, lock)); \
92− smp_mb__after_unlock_lock(); \
93−} while (0)
94−
95−#define spin_unlock_irq_rcu_node(p) \
96− spin_unlock_irq(&ACCESS_PRIVATE(p, lock))
97−
98−#define spin_lock_irqsave_rcu_node(p, flags) \
99−do { \
100− spin_lock_irqsave(&ACCESS_PRIVATE(p, lock), flags); \
101− smp_mb__after_unlock_lock(); \
102−} while (0)
103−
104−#define spin_trylock_irqsave_rcu_node(p, flags) \
105−({ \
106− bool ___locked = spin_trylock_irqsave(&ACCESS_PRIVATE(p, lock), flags); \
107− \
108− if (___locked) \
109− smp_mb__after_unlock_lock(); \
110− ___locked; \
111−})
112−
113−#define spin_unlock_irqrestore_rcu_node(p, flags) \
114− spin_unlock_irqrestore(&ACCESS_PRIVATE(p, lock), flags) \
115−
11682 /*
11783 * Initialize SRCU per-CPU data. Note that statically allocated
11884 * srcu_struct structures might already have srcu_read_lock() and
@@ -131,7 +97,7 @@ static void init_srcu_struct_data(struct srcu_struct *ssp) · 12 unmodified lines
13197 */
13298 for_each_possible_cpu(cpu) {
13399 sdp = per_cpu_ptr(ssp->sda, cpu);
134− spin_lock_init(&ACCESS_PRIVATE(sdp, lock));
100+ raw_spin_lock_init(&ACCESS_PRIVATE(sdp, lock));
135101 rcu_segcblist_init(&sdp->srcu_cblist);
136102 sdp->srcu_cblist_invoking = false;
137103 sdp->srcu_gp_seq_needed = ssp->srcu_sup->srcu_gp_seq;
@@ -186,7 +152,7 @@ static bool init_srcu_struct_nodes(struct srcu_struct *ssp, gfp_t gfp_flags) · 48 unmodified lines
186152
187153 /* Each pass through this loop initializes one srcu_node structure. */
188154 srcu_for_each_node_breadth_first(ssp, snp) {
189− spin_lock_init(&ACCESS_PRIVATE(snp, lock));
155+ raw_spin_lock_init(&ACCESS_PRIVATE(snp, lock));
190156 BUILD_BUG_ON(ARRAY_SIZE(snp->srcu_have_cbs) !=
191157 ARRAY_SIZE(snp->srcu_data_have_cbs));
192158 for (i = 0; i < ARRAY_SIZE(snp->srcu_have_cbs); i++) {
@@ -242,7 +208,7 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static) · 49 unmodified lines
242208 if (!ssp->srcu_sup)
243209 return -ENOMEM;
244210 if (!is_static)
245− spin_lock_init(&ACCESS_PRIVATE(ssp->srcu_sup, lock));
211+ raw_spin_lock_init(&ACCESS_PRIVATE(ssp->srcu_sup, lock));
246212 ssp->srcu_sup->srcu_size_state = SRCU_SIZE_SMALL;
247213 ssp->srcu_sup->node = NULL;
248214 mutex_init(&ssp->srcu_sup->srcu_cb_mutex);
@@ -252,6 +218,7 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static) · 3 unmodified lines
252218 mutex_init(&ssp->srcu_sup->srcu_barrier_mutex);
253219 atomic_set(&ssp->srcu_sup->srcu_barrier_cpu_cnt, 0);
254220 INIT_DELAYED_WORK(&ssp->srcu_sup->work, process_srcu);
221+ init_irq_work(&ssp->srcu_sup->irq_work, srcu_irq_work);
255222 ssp->srcu_sup->sda_is_static = is_static;
256223 if (!is_static) {
257224 ssp->sda = alloc_percpu(struct srcu_data);
@@ -263,9 +230,12 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static) · 5 unmodified lines
263230 ssp->srcu_sup->srcu_gp_seq_needed_exp = SRCU_GP_SEQ_INITIAL_VAL;
264231 ssp->srcu_sup->srcu_last_gp_end = ktime_get_mono_fast_ns();
265232 if (READ_ONCE(ssp->srcu_sup->srcu_size_state) == SRCU_SIZE_SMALL && SRCU_SIZING_IS_INIT()) {
266− if (!init_srcu_struct_nodes(ssp, is_static ? GFP_ATOMIC : GFP_KERNEL))
233+ if (!preemptible())
234+ WRITE_ONCE(ssp->srcu_sup->srcu_size_state, SRCU_SIZE_ALLOC);
235+ else if (init_srcu_struct_nodes(ssp, GFP_KERNEL))
236+ WRITE_ONCE(ssp->srcu_sup->srcu_size_state, SRCU_SIZE_BIG);
237+ else
267238 goto err_free_sda;
268− WRITE_ONCE(ssp->srcu_sup->srcu_size_state, SRCU_SIZE_BIG);
269239 }
270240 ssp->srcu_sup->srcu_ssp = ssp;
271241 smp_store_release(&ssp->srcu_sup->srcu_gp_seq_needed,
@@ -394,20 +364,20 @@ static void srcu_transition_to_big(struct srcu_struct *ssp) · 122 unmodified lines
394364 /* Double-checked locking on ->srcu_size-state. */
395365 if (smp_load_acquire(&ssp->srcu_sup->srcu_size_state) != SRCU_SIZE_SMALL)
396366 return;
397− spin_lock_irqsave_rcu_node(ssp->srcu_sup, flags);
367+ raw_spin_lock_irqsave_rcu_node(ssp->srcu_sup, flags);
398368 if (smp_load_acquire(&ssp->srcu_sup->srcu_size_state) != SRCU_SIZE_SMALL) {
399− spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
369+ raw_spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
400370 return;
401371 }
402372 __srcu_transition_to_big(ssp);
403− spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
373+ raw_spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
404374 }
405375
406376 /*
407377 * Check to see if the just-encountered contention event justifies
408378 * a transition to SRCU_SIZE_BIG.
409379 */
410−static void spin_lock_irqsave_check_contention(struct srcu_struct *ssp)
380+static void raw_spin_lock_irqsave_check_contention(struct srcu_struct *ssp)
411381 {
412382 unsigned long j;
413383
@@ -429,16 +399,16 @@ static void spin_lock_irqsave_check_contention(struct srcu_struct *ssp) · 15 unmodified lines
429399 * to SRCU_SIZE_BIG. But only if the srcutree.convert_to_big module
430400 * parameter permits this.
431401 */
432−static void spin_lock_irqsave_sdp_contention(struct srcu_data *sdp, unsigned long *flags)
402+static void raw_spin_lock_irqsave_sdp_contention(struct srcu_data *sdp, unsigned long *flags)
433403 {
434404 struct srcu_struct *ssp = sdp->ssp;
435405
436− if (spin_trylock_irqsave_rcu_node(sdp, *flags))
406+ if (raw_spin_trylock_irqsave_rcu_node(sdp, *flags))
437407 return;
438− spin_lock_irqsave_rcu_node(ssp->srcu_sup, *flags);
439− spin_lock_irqsave_check_contention(ssp);
440− spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, *flags);
441− spin_lock_irqsave_rcu_node(sdp, *flags);
408+ raw_spin_lock_irqsave_rcu_node(ssp->srcu_sup, *flags);
409+ raw_spin_lock_irqsave_check_contention(ssp);
410+ raw_spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, *flags);
411+ raw_spin_lock_irqsave_rcu_node(sdp, *flags);
442412 }
443413
444414 /*
@@ -447,12 +417,12 @@ static void spin_lock_irqsave_sdp_contention(struct srcu_data *sdp, unsigned lon · 2 unmodified lines
447417 * to SRCU_SIZE_BIG. But only if the srcutree.convert_to_big module
448418 * parameter permits this.
449419 */
450−static void spin_lock_irqsave_ssp_contention(struct srcu_struct *ssp, unsigned long *flags)
420+static void raw_spin_lock_irqsave_ssp_contention(struct srcu_struct *ssp, unsigned long *flags)
451421 {
452− if (spin_trylock_irqsave_rcu_node(ssp->srcu_sup, *flags))
422+ if (raw_spin_trylock_irqsave_rcu_node(ssp->srcu_sup, *flags))
453423 return;
454− spin_lock_irqsave_rcu_node(ssp->srcu_sup, *flags);
455− spin_lock_irqsave_check_contention(ssp);
424+ raw_spin_lock_irqsave_rcu_node(ssp->srcu_sup, *flags);
425+ raw_spin_lock_irqsave_check_contention(ssp);
456426 }
457427
458428 /*
@@ -470,13 +440,13 @@ static void check_init_srcu_struct(struct srcu_struct *ssp) · 11 unmodified lines
470440 /* The smp_load_acquire() pairs with the smp_store_release(). */
471441 if (!rcu_seq_state(smp_load_acquire(&ssp->srcu_sup->srcu_gp_seq_needed))) /*^^^*/
472442 return; /* Already initialized. */
473− spin_lock_irqsave_rcu_node(ssp->srcu_sup, flags);
443+ raw_spin_lock_irqsave_rcu_node(ssp->srcu_sup, flags);
474444 if (!rcu_seq_state(ssp->srcu_sup->srcu_gp_seq_needed)) {
475− spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
445+ raw_spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
476446 return;
477447 }
478448 init_srcu_struct_fields(ssp, true);
479− spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
449+ raw_spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
480450 }
481451
482452 /*
@@ -742,13 +712,15 @@ void cleanup_srcu_struct(struct srcu_struct *ssp) · 259 unmodified lines
742712 unsigned long delay;
743713 struct srcu_usage *sup = ssp->srcu_sup;
744714
745− spin_lock_irq_rcu_node(ssp->srcu_sup);
715+ raw_spin_lock_irq_rcu_node(ssp->srcu_sup);
746716 delay = srcu_get_delay(ssp);
747− spin_unlock_irq_rcu_node(ssp->srcu_sup);
717+ raw_spin_unlock_irq_rcu_node(ssp->srcu_sup);
748718 if (WARN_ON(!delay))
749719 return; /* Just leak it! */
750720 if (WARN_ON(srcu_readers_active(ssp)))
751721 return; /* Just leak it! */
722+ /* Wait for irq_work to finish first as it may queue a new work. */
723+ irq_work_sync(&sup->irq_work);
752724 flush_delayed_work(&sup->work);
753725 for_each_possible_cpu(cpu) {
754726 struct srcu_data *sdp = per_cpu_ptr(ssp->sda, cpu);
@@ -960,7 +932,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) · 205 unmodified lines
960932 mutex_lock(&sup->srcu_cb_mutex);
961933
962934 /* End the current grace period. */
963− spin_lock_irq_rcu_node(sup);
935+ raw_spin_lock_irq_rcu_node(sup);
964936 idx = rcu_seq_state(sup->srcu_gp_seq);
965937 WARN_ON_ONCE(idx != SRCU_STATE_SCAN2);
966938 if (srcu_gp_is_expedited(ssp))
@@ -971,7 +943,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) · 4 unmodified lines
971943 gpseq = rcu_seq_current(&sup->srcu_gp_seq);
972944 if (ULONG_CMP_LT(sup->srcu_gp_seq_needed_exp, gpseq))
973945 WRITE_ONCE(sup->srcu_gp_seq_needed_exp, gpseq);
974− spin_unlock_irq_rcu_node(sup);
946+ raw_spin_unlock_irq_rcu_node(sup);
975947 mutex_unlock(&sup->srcu_gp_mutex);
976948 /* A new grace period can start at this point. But only one. */
977949
@@ -983,7 +955,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) · 5 unmodified lines
983955 } else {
984956 idx = rcu_seq_ctr(gpseq) % ARRAY_SIZE(snp->srcu_have_cbs);
985957 srcu_for_each_node_breadth_first(ssp, snp) {
986− spin_lock_irq_rcu_node(snp);
958+ raw_spin_lock_irq_rcu_node(snp);
987959 cbs = false;
988960 last_lvl = snp >= sup->level[rcu_num_lvls - 1];
989961 if (last_lvl)
@@ -998,7 +970,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) · 8 unmodified lines
998970 else
999971 mask = snp->srcu_data_have_cbs[idx];
1000972 snp->srcu_data_have_cbs[idx] = 0;
1001− spin_unlock_irq_rcu_node(snp);
973+ raw_spin_unlock_irq_rcu_node(snp);
1002974 if (cbs)
1003975 srcu_schedule_cbs_snp(ssp, snp, mask, cbdelay);
1004976 }
@@ -1008,27 +980,27 @@ static void srcu_gp_end(struct srcu_struct *ssp) · 3 unmodified lines
1008980 if (!(gpseq & counter_wrap_check))
1009981 for_each_possible_cpu(cpu) {
1010982 sdp = per_cpu_ptr(ssp->sda, cpu);
1011− spin_lock_irq_rcu_node(sdp);
983+ raw_spin_lock_irq_rcu_node(sdp);
1012984 if (ULONG_CMP_GE(gpseq, sdp->srcu_gp_seq_needed + 100))
1013985 sdp->srcu_gp_seq_needed = gpseq;
1014986 if (ULONG_CMP_GE(gpseq, sdp->srcu_gp_seq_needed_exp + 100))
1015987 sdp->srcu_gp_seq_needed_exp = gpseq;
1016− spin_unlock_irq_rcu_node(sdp);
988+ raw_spin_unlock_irq_rcu_node(sdp);
1017989 }
1018990
1019991 /* Callback initiation done, allow grace periods after next. */
1020992 mutex_unlock(&sup->srcu_cb_mutex);
1021993
1022994 /* Start a new grace period if needed. */
1023− spin_lock_irq_rcu_node(sup);
995+ raw_spin_lock_irq_rcu_node(sup);
1024996 gpseq = rcu_seq_current(&sup->srcu_gp_seq);
1025997 if (!rcu_seq_state(gpseq) &&
1026998 ULONG_CMP_LT(gpseq, sup->srcu_gp_seq_needed)) {
1027999 srcu_gp_start(ssp);
1028− spin_unlock_irq_rcu_node(sup);
1000+ raw_spin_unlock_irq_rcu_node(sup);
10291001 srcu_reschedule(ssp, 0);
10301002 } else {
1031− spin_unlock_irq_rcu_node(sup);
1003+ raw_spin_unlock_irq_rcu_node(sup);
10321004 }
10331005
10341006 /* Transition to big if needed. */
@@ -1059,19 +1031,19 @@ static void srcu_funnel_exp_start(struct srcu_struct *ssp, struct srcu_node *snp · 24 unmodified lines
10591031 if (WARN_ON_ONCE(rcu_seq_done(&ssp->srcu_sup->srcu_gp_seq, s)) ||
10601032 (!srcu_invl_snp_seq(sgsne) && ULONG_CMP_GE(sgsne, s)))
10611033 return;
1062− spin_lock_irqsave_rcu_node(snp, flags);
1034+ raw_spin_lock_irqsave_rcu_node(snp, flags);
10631035 sgsne = snp->srcu_gp_seq_needed_exp;
10641036 if (!srcu_invl_snp_seq(sgsne) && ULONG_CMP_GE(sgsne, s)) {
1065− spin_unlock_irqrestore_rcu_node(snp, flags);
1037+ raw_spin_unlock_irqrestore_rcu_node(snp, flags);
10661038 return;
10671039 }
10681040 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, s);
1069− spin_unlock_irqrestore_rcu_node(snp, flags);
1041+ raw_spin_unlock_irqrestore_rcu_node(snp, flags);
10701042 }
1071− spin_lock_irqsave_ssp_contention(ssp, &flags);
1043+ raw_spin_lock_irqsave_ssp_contention(ssp, &flags);
10721044 if (ULONG_CMP_LT(ssp->srcu_sup->srcu_gp_seq_needed_exp, s))
10731045 WRITE_ONCE(ssp->srcu_sup->srcu_gp_seq_needed_exp, s);
1074− spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
1046+ raw_spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
10751047 }
10761048
10771049 /*
@@ -1109,12 +1081,12 @@ static void srcu_funnel_gp_start(struct srcu_struct *ssp, struct srcu_data *sdp, · 31 unmodified lines
11091081 for (snp = snp_leaf; snp != NULL; snp = snp->srcu_parent) {
11101082 if (WARN_ON_ONCE(rcu_seq_done(&sup->srcu_gp_seq, s)) && snp != snp_leaf)
11111083 return; /* GP already done and CBs recorded. */
1112− spin_lock_irqsave_rcu_node(snp, flags);
1084+ raw_spin_lock_irqsave_rcu_node(snp, flags);
11131085 snp_seq = snp->srcu_have_cbs[idx];
11141086 if (!srcu_invl_snp_seq(snp_seq) && ULONG_CMP_GE(snp_seq, s)) {
11151087 if (snp == snp_leaf && snp_seq == s)
11161088 snp->srcu_data_have_cbs[idx] |= sdp->grpmask;
1117− spin_unlock_irqrestore_rcu_node(snp, flags);
1089+ raw_spin_unlock_irqrestore_rcu_node(snp, flags);
11181090 if (snp == snp_leaf && snp_seq != s) {
11191091 srcu_schedule_cbs_sdp(sdp, do_norm ? SRCU_INTERVAL : 0);
11201092 return;
@@ -1129,11 +1101,11 @@ static void srcu_funnel_gp_start(struct srcu_struct *ssp, struct srcu_data *sdp, · 8 unmodified lines
11291101 sgsne = snp->srcu_gp_seq_needed_exp;
11301102 if (!do_norm && (srcu_invl_snp_seq(sgsne) || ULONG_CMP_LT(sgsne, s)))
11311103 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, s);
1132− spin_unlock_irqrestore_rcu_node(snp, flags);
1104+ raw_spin_unlock_irqrestore_rcu_node(snp, flags);
11331105 }
11341106
11351107 /* Top of tree, must ensure the grace period will be started. */
1136− spin_lock_irqsave_ssp_contention(ssp, &flags);
1108+ raw_spin_lock_irqsave_ssp_contention(ssp, &flags);
11371109 if (ULONG_CMP_LT(sup->srcu_gp_seq_needed, s)) {
11381110 /*
11391111 * Record need for grace period s. Pair with load
@@ -1154,13 +1126,17 @@ static void srcu_funnel_gp_start(struct srcu_struct *ssp, struct srcu_data *sdp, · 14 unmodified lines
11541126 // it isn't. And it does not have to be. After all, it
11551127 // can only be executed during early boot when there is only
11561128 // the one boot CPU running with interrupts still disabled.
1129+ //
1130+ // Use an irq_work here to avoid acquiring runqueue lock with
1131+ // srcu rcu_node::lock held. BPF instrument could introduce the
1132+ // opposite dependency, hence we need to break the possible
1133+ // locking dependency here.
11571134 if (likely(srcu_init_done))
1158− queue_delayed_work(rcu_gp_wq, &sup->work,
1159− !!srcu_get_delay(ssp));
1135+ irq_work_queue(&sup->irq_work);
11601136 else if (list_empty(&sup->work.work.entry))
11611137 list_add(&sup->work.work.entry, &srcu_boot_list);
11621138 }
1163− spin_unlock_irqrestore_rcu_node(sup, flags);
1139+ raw_spin_unlock_irqrestore_rcu_node(sup, flags);
11641140 }
11651141
11661142 /*
@@ -1172,9 +1148,9 @@ static bool try_check_zero(struct srcu_struct *ssp, int idx, int trycount) · 5 unmodified lines
11721148 {
11731149 unsigned long curdelay;
11741150
1175− spin_lock_irq_rcu_node(ssp->srcu_sup);
1151+ raw_spin_lock_irq_rcu_node(ssp->srcu_sup);
11761152 curdelay = !srcu_get_delay(ssp);
1177− spin_unlock_irq_rcu_node(ssp->srcu_sup);
1153+ raw_spin_unlock_irq_rcu_node(ssp->srcu_sup);
11781154
11791155 for (;;) {
11801156 if (srcu_readers_active_idx_check(ssp, idx))
@@ -1285,12 +1261,12 @@ static bool srcu_should_expedite(struct srcu_struct *ssp) · 104 unmodified lines
12851261 return false;
12861262 /* If the local srcu_data structure has callbacks, not idle. */
12871263 sdp = raw_cpu_ptr(ssp->sda);
1288− spin_lock_irqsave_rcu_node(sdp, flags);
1264+ raw_spin_lock_irqsave_rcu_node(sdp, flags);
12891265 if (rcu_segcblist_pend_cbs(&sdp->srcu_cblist)) {
1290− spin_unlock_irqrestore_rcu_node(sdp, flags);
1266+ raw_spin_unlock_irqrestore_rcu_node(sdp, flags);
12911267 return false; /* Callbacks already present, so not idle. */
12921268 }
1293− spin_unlock_irqrestore_rcu_node(sdp, flags);
1269+ raw_spin_unlock_irqrestore_rcu_node(sdp, flags);
12941270
12951271 /*
12961272 * No local callbacks, so probabilistically probe global state.
@@ -1350,7 +1326,7 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp, · 53 unmodified lines
13501326 sdp = per_cpu_ptr(ssp->sda, get_boot_cpu_id());
13511327 else
13521328 sdp = raw_cpu_ptr(ssp->sda);
1353− spin_lock_irqsave_sdp_contention(sdp, &flags);
1329+ raw_spin_lock_irqsave_sdp_contention(sdp, &flags);
13541330 if (rhp)
13551331 rcu_segcblist_enqueue(&sdp->srcu_cblist, rhp);
13561332 /*
@@ -1410,7 +1386,7 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp, · 53 unmodified lines
14101386 sdp->srcu_gp_seq_needed_exp = s;
14111387 needexp = true;
14121388 }
1413− spin_unlock_irqrestore_rcu_node(sdp, flags);
1389+ raw_spin_unlock_irqrestore_rcu_node(sdp, flags);
14141390
14151391 /* Ensure that snp node tree is fully initialized before traversing it */
14161392 if (ss_state < SRCU_SIZE_WAIT_BARRIER)
@@ -1522,7 +1498,7 @@ static void __synchronize_srcu(struct srcu_struct *ssp, bool do_norm) · 105 unmodified lines
15221498
15231499 /*
15241500 * Make sure that later code is ordered after the SRCU grace
1525− * period. This pairs with the spin_lock_irq_rcu_node()
1501+ * period. This pairs with the raw_spin_lock_irq_rcu_node()
15261502 * in srcu_invoke_callbacks(). Unlike Tree RCU, this is needed
15271503 * because the current CPU might have been totally uninvolved with
15281504 * (and thus unordered against) that grace period.
@@ -1701,7 +1677,7 @@ static void srcu_barrier_cb(struct rcu_head *rhp) · 172 unmodified lines
17011677 */
17021678 static void srcu_barrier_one_cpu(struct srcu_struct *ssp, struct srcu_data *sdp)
17031679 {
1704− spin_lock_irq_rcu_node(sdp);
1680+ raw_spin_lock_irq_rcu_node(sdp);
17051681 atomic_inc(&ssp->srcu_sup->srcu_barrier_cpu_cnt);
17061682 sdp->srcu_barrier_head.func = srcu_barrier_cb;
17071683 debug_rcu_head_queue(&sdp->srcu_barrier_head);
@@ -1710,7 +1686,7 @@ static void srcu_barrier_one_cpu(struct srcu_struct *ssp, struct srcu_data *sdp) · 2 unmodified lines
17101686 debug_rcu_head_unqueue(&sdp->srcu_barrier_head);
17111687 atomic_dec(&ssp->srcu_sup->srcu_barrier_cpu_cnt);
17121688 }
1713− spin_unlock_irq_rcu_node(sdp);
1689+ raw_spin_unlock_irq_rcu_node(sdp);
17141690 }
17151691
17161692 /**
@@ -1761,7 +1737,7 @@ static void srcu_expedite_current_cb(struct rcu_head *rhp) · 44 unmodified lines
17611737 bool needcb = false;
17621738 struct srcu_data *sdp = container_of(rhp, struct srcu_data, srcu_ec_head);
17631739
1764− spin_lock_irqsave_sdp_contention(sdp, &flags);
1740+ raw_spin_lock_irqsave_sdp_contention(sdp, &flags);
17651741 if (sdp->srcu_ec_state == SRCU_EC_IDLE) {
17661742 WARN_ON_ONCE(1);
17671743 } else if (sdp->srcu_ec_state == SRCU_EC_PENDING) {
@@ -1771,7 +1747,7 @@ static void srcu_expedite_current_cb(struct rcu_head *rhp) · 3 unmodified lines
17711747 sdp->srcu_ec_state = SRCU_EC_PENDING;
17721748 needcb = true;
17731749 }
1774− spin_unlock_irqrestore_rcu_node(sdp, flags);
1750+ raw_spin_unlock_irqrestore_rcu_node(sdp, flags);
17751751 // If needed, requeue ourselves as an expedited SRCU callback.
17761752 if (needcb)
17771753 __call_srcu(sdp->ssp, &sdp->srcu_ec_head, srcu_expedite_current_cb, false);
@@ -1795,7 +1771,7 @@ void srcu_expedite_current(struct srcu_struct *ssp) · 17 unmodified lines
17951771
17961772 migrate_disable();
17971773 sdp = this_cpu_ptr(ssp->sda);
1798− spin_lock_irqsave_sdp_contention(sdp, &flags);
1774+ raw_spin_lock_irqsave_sdp_contention(sdp, &flags);
17991775 if (sdp->srcu_ec_state == SRCU_EC_IDLE) {
18001776 sdp->srcu_ec_state = SRCU_EC_PENDING;
18011777 needcb = true;
@@ -1804,7 +1780,7 @@ void srcu_expedite_current(struct srcu_struct *ssp) · 2 unmodified lines
18041780 } else {
18051781 WARN_ON_ONCE(sdp->srcu_ec_state != SRCU_EC_REPOST);
18061782 }
1807− spin_unlock_irqrestore_rcu_node(sdp, flags);
1783+ raw_spin_unlock_irqrestore_rcu_node(sdp, flags);
18081784 // If needed, queue an expedited SRCU callback.
18091785 if (needcb)
18101786 __call_srcu(ssp, &sdp->srcu_ec_head, srcu_expedite_current_cb, false);
@@ -1848,17 +1824,17 @@ static void srcu_advance_state(struct srcu_struct *ssp) · 37 unmodified lines
18481824 */
18491825 idx = rcu_seq_state(smp_load_acquire(&ssp->srcu_sup->srcu_gp_seq)); /* ^^^ */
18501826 if (idx == SRCU_STATE_IDLE) {
1851− spin_lock_irq_rcu_node(ssp->srcu_sup);
1827+ raw_spin_lock_irq_rcu_node(ssp->srcu_sup);
18521828 if (ULONG_CMP_GE(ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_needed)) {
18531829 WARN_ON_ONCE(rcu_seq_state(ssp->srcu_sup->srcu_gp_seq));
1854− spin_unlock_irq_rcu_node(ssp->srcu_sup);
1830+ raw_spin_unlock_irq_rcu_node(ssp->srcu_sup);
18551831 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex);
18561832 return;
18571833 }
18581834 idx = rcu_seq_state(READ_ONCE(ssp->srcu_sup->srcu_gp_seq));
18591835 if (idx == SRCU_STATE_IDLE)
18601836 srcu_gp_start(ssp);
1861− spin_unlock_irq_rcu_node(ssp->srcu_sup);
1837+ raw_spin_unlock_irq_rcu_node(ssp->srcu_sup);
18621838 if (idx != SRCU_STATE_IDLE) {
18631839 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex);
18641840 return; /* Someone else started the grace period. */
@@ -1872,10 +1848,10 @@ static void srcu_advance_state(struct srcu_struct *ssp) · 7 unmodified lines
18721848 return; /* readers present, retry later. */
18731849 }
18741850 srcu_flip(ssp);
1875− spin_lock_irq_rcu_node(ssp->srcu_sup);
1851+ raw_spin_lock_irq_rcu_node(ssp->srcu_sup);
18761852 rcu_seq_set_state(&ssp->srcu_sup->srcu_gp_seq, SRCU_STATE_SCAN2);
18771853 ssp->srcu_sup->srcu_n_exp_nodelay = 0;
1878− spin_unlock_irq_rcu_node(ssp->srcu_sup);
1854+ raw_spin_unlock_irq_rcu_node(ssp->srcu_sup);
18791855 }
18801856
18811857 if (rcu_seq_state(READ_ONCE(ssp->srcu_sup->srcu_gp_seq)) == SRCU_STATE_SCAN2) {
@@ -1913,7 +1889,7 @@ static void srcu_invoke_callbacks(struct work_struct *work) · 31 unmodified lines
19131889
19141890 ssp = sdp->ssp;
19151891 rcu_cblist_init(&ready_cbs);
1916− spin_lock_irq_rcu_node(sdp);
1892+ raw_spin_lock_irq_rcu_node(sdp);
19171893 WARN_ON_ONCE(!rcu_segcblist_segempty(&sdp->srcu_cblist, RCU_NEXT_TAIL));
19181894 rcu_segcblist_advance(&sdp->srcu_cblist,
19191895 rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq));
@@ -1924,7 +1900,7 @@ static void srcu_invoke_callbacks(struct work_struct *work) · 4 unmodified lines
19241900 */
19251901 if (sdp->srcu_cblist_invoking ||
19261902 !rcu_segcblist_ready_cbs(&sdp->srcu_cblist)) {
1927− spin_unlock_irq_rcu_node(sdp);
1903+ raw_spin_unlock_irq_rcu_node(sdp);
19281904 return; /* Someone else on the job or nothing to do. */
19291905 }
19301906
@@ -1932,7 +1908,7 @@ static void srcu_invoke_callbacks(struct work_struct *work) · 1 unmodified line
19321908 sdp->srcu_cblist_invoking = true;
19331909 rcu_segcblist_extract_done_cbs(&sdp->srcu_cblist, &ready_cbs);
19341910 len = ready_cbs.len;
1935− spin_unlock_irq_rcu_node(sdp);
1911+ raw_spin_unlock_irq_rcu_node(sdp);
19361912 rhp = rcu_cblist_dequeue(&ready_cbs);
19371913 for (; rhp != NULL; rhp = rcu_cblist_dequeue(&ready_cbs)) {
19381914 debug_rcu_head_unqueue(rhp);
@@ -1947,11 +1923,11 @@ static void srcu_invoke_callbacks(struct work_struct *work) · 8 unmodified lines
19471923 * Update counts, accelerate new callbacks, and if needed,
19481924 * schedule another round of callback invocation.
19491925 */
1950− spin_lock_irq_rcu_node(sdp);
1926+ raw_spin_lock_irq_rcu_node(sdp);
19511927 rcu_segcblist_add_len(&sdp->srcu_cblist, -len);
19521928 sdp->srcu_cblist_invoking = false;
19531929 more = rcu_segcblist_ready_cbs(&sdp->srcu_cblist);
1954− spin_unlock_irq_rcu_node(sdp);
1930+ raw_spin_unlock_irq_rcu_node(sdp);
19551931 /* An SRCU barrier or callbacks from previous nesting work pending */
19561932 if (more)
19571933 srcu_schedule_cbs_sdp(sdp, 0);
@@ -1965,7 +1941,7 @@ static void srcu_reschedule(struct srcu_struct *ssp, unsigned long delay) · 7 unmodified lines
19651941 {
19661942 bool pushgp = true;
19671943
1968− spin_lock_irq_rcu_node(ssp->srcu_sup);
1944+ raw_spin_lock_irq_rcu_node(ssp->srcu_sup);
19691945 if (ULONG_CMP_GE(ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_needed)) {
19701946 if (!WARN_ON_ONCE(rcu_seq_state(ssp->srcu_sup->srcu_gp_seq))) {
19711947 /* All requests fulfilled, time to go idle. */
@@ -1975,7 +1951,7 @@ static void srcu_reschedule(struct srcu_struct *ssp, unsigned long delay) · 3 unmodified lines
19751951 /* Outstanding request and no GP. Start one. */
19761952 srcu_gp_start(ssp);
19771953 }
1978− spin_unlock_irq_rcu_node(ssp->srcu_sup);
1954+ raw_spin_unlock_irq_rcu_node(ssp->srcu_sup);
19791955
19801956 if (pushgp)
19811957 queue_delayed_work(rcu_gp_wq, &ssp->srcu_sup->work, delay);
@@ -1995,9 +1971,9 @@ static void process_srcu(struct work_struct *work) · 13 unmodified lines
19951971 ssp = sup->srcu_ssp;
19961972
19971973 srcu_advance_state(ssp);
1998− spin_lock_irq_rcu_node(ssp->srcu_sup);
1974+ raw_spin_lock_irq_rcu_node(ssp->srcu_sup);
19991975 curdelay = srcu_get_delay(ssp);
2000− spin_unlock_irq_rcu_node(ssp->srcu_sup);
1976+ raw_spin_unlock_irq_rcu_node(ssp->srcu_sup);
20011977 if (curdelay) {
20021978 WRITE_ONCE(sup->reschedule_count, 0);
20031979 } else {
@@ -2015,6 +1991,23 @@ static void process_srcu(struct work_struct *work) · 11 unmodified lines
20151991 srcu_reschedule(ssp, curdelay);
20161992 }
20171993
1994+static void srcu_irq_work(struct irq_work *work)
1995+{
1996+ struct srcu_struct *ssp;
1997+ struct srcu_usage *sup;
1998+ unsigned long delay;
1999+ unsigned long flags;
2000+
2001+ sup = container_of(work, struct srcu_usage, irq_work);
2002+ ssp = sup->srcu_ssp;
2003+
2004+ raw_spin_lock_irqsave_rcu_node(ssp->srcu_sup, flags);
2005+ delay = srcu_get_delay(ssp);
2006+ raw_spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
2007+
2008+ queue_delayed_work(rcu_gp_wq, &sup->work, !!delay);
2009+}
2010+
20182011 void srcutorture_get_gp_data(struct srcu_struct *ssp, int *flags,
20192012 unsigned long *gp_seq)
20202013 {
kernel/sysctl.c+1−1
@@ -1118,7 +1118,7 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir, · 1117 unmodified lines
11181118 unsigned long bitmap_len = table->maxlen;
11191119 unsigned long *bitmap = *(unsigned long **) table->data;
11201120 unsigned long *tmp_bitmap = NULL;
1121− char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1121+ char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c = 0;
11221122
11231123 if (!bitmap || !bitmap_len || !left || (*ppos && SYSCTL_KERN_TO_USER(dir))) {
11241124 *lenp = 0;
kernel/time/alarmtimer.c+1−1
@@ -540,7 +540,7 @@ static s64 alarm_timer_forward(struct k_itimer *timr, ktime_t now) · 539 unmodified lines
540540 {
541541 struct alarm *alarm = &timr->it.alarm.alarmtimer;
542542
543− return alarm_forward(alarm, timr->it_interval, now);
543+ return alarm_forward(alarm, now, timr->it_interval);
544544 }
545545
546546 /**
kernel/trace/trace_events_trigger.c+66−13
@@ -22,6 +22,39 @@ static struct task_struct *trigger_kthread; · 21 unmodified lines
2222 static struct llist_head trigger_data_free_list;
2323 static DEFINE_MUTEX(trigger_data_kthread_mutex);
2424
25+static int trigger_kthread_fn(void *ignore);
26+
27+static void trigger_create_kthread_locked(void)
28+{
29+ lockdep_assert_held(&trigger_data_kthread_mutex);
30+
31+ if (!trigger_kthread) {
32+ struct task_struct *kthread;
33+
34+ kthread = kthread_create(trigger_kthread_fn, NULL,
35+ "trigger_data_free");
36+ if (!IS_ERR(kthread))
37+ WRITE_ONCE(trigger_kthread, kthread);
38+ }
39+}
40+
41+static void trigger_data_free_queued_locked(void)
42+{
43+ struct event_trigger_data *data, *tmp;
44+ struct llist_node *llnodes;
45+
46+ lockdep_assert_held(&trigger_data_kthread_mutex);
47+
48+ llnodes = llist_del_all(&trigger_data_free_list);
49+ if (!llnodes)
50+ return;
51+
52+ tracepoint_synchronize_unregister();
53+
54+ llist_for_each_entry_safe(data, tmp, llnodes, llist)
55+ kfree(data);
56+}
57+
2558 /* Bulk garbage collection of event_trigger_data elements */
2659 static int trigger_kthread_fn(void *ignore)
2760 {
@@ -56,30 +89,50 @@ void trigger_data_free(struct event_trigger_data *data) · 28 unmodified lines
5689 if (data->cmd_ops->set_filter)
5790 data->cmd_ops->set_filter(NULL, data, NULL);
5891
92+ /*
93+ * Boot-time trigger registration can fail before kthread creation
94+ * works. Keep the deferred-free semantics during boot and let late
95+ * init start the kthread to drain the list.
96+ */
97+ if (system_state == SYSTEM_BOOTING && !trigger_kthread) {
98+ llist_add(&data->llist, &trigger_data_free_list);
99+ return;
100+ }
101+
59102 if (unlikely(!trigger_kthread)) {
60103 guard(mutex)(&trigger_data_kthread_mutex);
104+
105+ trigger_create_kthread_locked();
61106 /* Check again after taking mutex */
62107 if (!trigger_kthread) {
63− struct task_struct *kthread;
64−
65− kthread = kthread_create(trigger_kthread_fn, NULL,
66− "trigger_data_free");
67− if (!IS_ERR(kthread))
68− WRITE_ONCE(trigger_kthread, kthread);
108+ llist_add(&data->llist, &trigger_data_free_list);
109+ /* Drain the queued frees synchronously if creation failed. */
110+ trigger_data_free_queued_locked();
111+ return;
69112 }
70113 }
71114
72− if (!trigger_kthread) {
73− /* Do it the slow way */
74− tracepoint_synchronize_unregister();
75− kfree(data);
76− return;
77− }
78−
79115 llist_add(&data->llist, &trigger_data_free_list);
80116 wake_up_process(trigger_kthread);
81117 }
82118
119+static int __init trigger_data_free_init(void)
120+{
121+ guard(mutex)(&trigger_data_kthread_mutex);
122+
123+ if (llist_empty(&trigger_data_free_list))
124+ return 0;
125+
126+ trigger_create_kthread_locked();
127+ if (trigger_kthread)
128+ wake_up_process(trigger_kthread);
129+ else
130+ trigger_data_free_queued_locked();
131+
132+ return 0;
133+}
134+late_initcall(trigger_data_free_init);
135+
83136 static inline void data_ops_trigger(struct event_trigger_data *data,
84137 struct trace_buffer *buffer, void *rec,
85138 struct ring_buffer_event *event)
kernel/trace/trace_osnoise.c+5−5
@@ -2073,8 +2073,8 @@ static void osnoise_hotplug_workfn(struct work_struct *dummy) · 2072 unmodified lines
20732073 if (!osnoise_has_registered_instances())
20742074 return;
20752075
2076− guard(mutex)(&interface_lock);
20772076 guard(cpus_read_lock)();
2077+ guard(mutex)(&interface_lock);
20782078
20792079 if (!cpu_online(cpu))
20802080 return;
@@ -2237,11 +2237,11 @@ static ssize_t osnoise_options_write(struct file *filp, const char __user *ubuf, · 156 unmodified lines
22372237 if (running)
22382238 stop_per_cpu_kthreads();
22392239
2240− mutex_lock(&interface_lock);
22412240 /*
22422241 * avoid CPU hotplug operations that might read options.
22432242 */
22442243 cpus_read_lock();
2244+ mutex_lock(&interface_lock);
22452245
22462246 retval = cnt;
22472247
@@ -2257,8 +2257,8 @@ static ssize_t osnoise_options_write(struct file *filp, const char __user *ubuf, · 9 unmodified lines
22572257 clear_bit(option, &osnoise_options);
22582258 }
22592259
2260− cpus_read_unlock();
22612260 mutex_unlock(&interface_lock);
2261+ cpus_read_unlock();
22622262
22632263 if (running)
22642264 start_per_cpu_kthreads();
@@ -2345,16 +2345,16 @@ osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count, · 80 unmodified lines
23452345 if (running)
23462346 stop_per_cpu_kthreads();
23472347
2348− mutex_lock(&interface_lock);
23492348 /*
23502349 * osnoise_cpumask is read by CPU hotplug operations.
23512350 */
23522351 cpus_read_lock();
2352+ mutex_lock(&interface_lock);
23532353
23542354 cpumask_copy(&osnoise_cpumask, osnoise_cpumask_new);
23552355
2356− cpus_read_unlock();
23572356 mutex_unlock(&interface_lock);
2357+ cpus_read_unlock();
23582358
23592359 if (running)
23602360 start_per_cpu_kthreads();
lib/bug.c+2−5
@@ -173,10 +173,8 @@ struct bug_entry *find_bug(unsigned long bugaddr) · 172 unmodified lines
173173 return module_find_bug(bugaddr);
174174 }
175175
176−__diag_push();
177−__diag_ignore(GCC, all, "-Wsuggest-attribute=format",
178− "Not a valid __printf() conversion candidate.");
179−static void __warn_printf(const char *fmt, struct pt_regs *regs)
176+static __printf(1, 0)
177+void __warn_printf(const char *fmt, struct pt_regs *regs)
180178 {
181179 if (!fmt)
182180 return;
@@ -195,7 +193,6 @@ static void __warn_printf(const char *fmt, struct pt_regs *regs) · 12 unmodified lines
195193
196194 printk("%s", fmt);
197195 }
198−__diag_pop();
199196
200197 static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long bugaddr, struct pt_regs *regs)
201198 {
mm/damon/core.c+8−0
@@ -1252,6 +1252,7 @@ int damon_commit_ctx(struct damon_ctx *dst, struct damon_ctx *src) · 1251 unmodified lines
12521252 {
12531253 int err;
12541254
1255+ dst->maybe_corrupted = true;
12551256 if (!is_power_of_2(src->min_region_sz))
12561257 return -EINVAL;
12571258
@@ -1277,6 +1278,7 @@ int damon_commit_ctx(struct damon_ctx *dst, struct damon_ctx *src) · 19 unmodified lines
12771278 dst->addr_unit = src->addr_unit;
12781279 dst->min_region_sz = src->min_region_sz;
12791280
1281+ dst->maybe_corrupted = false;
12801282 return 0;
12811283 }
12821284
@@ -2678,6 +2680,8 @@ static void kdamond_call(struct damon_ctx *ctx, bool cancel) · 1395 unmodified lines
26782680 complete(&control->completion);
26792681 else if (control->canceled && control->dealloc_on_cancel)
26802682 kfree(control);
2683+ if (!cancel && ctx->maybe_corrupted)
2684+ break;
26812685 }
26822686
26832687 mutex_lock(&ctx->call_controls_lock);
@@ -2707,6 +2711,8 @@ static int kdamond_wait_activation(struct damon_ctx *ctx) · 23 unmodified lines
27072711 kdamond_usleep(min_wait_time);
27082712
27092713 kdamond_call(ctx, false);
2714+ if (ctx->maybe_corrupted)
2715+ return -EINVAL;
27102716 damos_walk_cancel(ctx);
27112717 }
27122718 return -EBUSY;
@@ -2790,6 +2796,8 @@ static int kdamond_fn(void *data) · 77 unmodified lines
27902796 * kdamond_merge_regions() if possible, to reduce overhead
27912797 */
27922798 kdamond_call(ctx, false);
2799+ if (ctx->maybe_corrupted)
2800+ break;
27932801 if (!list_empty(&ctx->schemes))
27942802 kdamond_apply_schemes(ctx);
27952803 else
mm/damon/stat.c+50−3
@@ -145,12 +145,59 @@ static int damon_stat_damon_call_fn(void *data) · 144 unmodified lines
145145 return 0;
146146 }
147147
148+struct damon_stat_system_ram_range_walk_arg {
149+ bool walked;
150+ struct resource res;
151+};
152+
153+static int damon_stat_system_ram_walk_fn(struct resource *res, void *arg)
154+{
155+ struct damon_stat_system_ram_range_walk_arg *a = arg;
156+
157+ if (!a->walked) {
158+ a->walked = true;
159+ a->res.start = res->start;
160+ }
161+ a->res.end = res->end;
162+ return 0;
163+}
164+
165+static unsigned long damon_stat_res_to_core_addr(resource_size_t ra,
166+ unsigned long addr_unit)
167+{
168+ /*
169+ * Use div_u64() for avoiding linking errors related with __udivdi3,
170+ * __aeabi_uldivmod, or similar problems. This should also improve the
171+ * performance optimization (read div_u64() comment for the detail).
172+ */
173+ if (sizeof(ra) == 8 && sizeof(addr_unit) == 4)
174+ return div_u64(ra, addr_unit);
175+ return ra / addr_unit;
176+}
177+
178+static int damon_stat_set_monitoring_region(struct damon_target *t,
179+ unsigned long addr_unit, unsigned long min_region_sz)
180+{
181+ struct damon_addr_range addr_range;
182+ struct damon_stat_system_ram_range_walk_arg arg = {};
183+
184+ walk_system_ram_res(0, -1, &arg, damon_stat_system_ram_walk_fn);
185+ if (!arg.walked)
186+ return -EINVAL;
187+ addr_range.start = damon_stat_res_to_core_addr(
188+ arg.res.start, addr_unit);
189+ addr_range.end = damon_stat_res_to_core_addr(
190+ arg.res.end + 1, addr_unit);
191+ if (addr_range.end <= addr_range.start)
192+ return -EINVAL;
193+ return damon_set_regions(t, &addr_range, 1, min_region_sz);
194+}
195+
148196 static struct damon_ctx *damon_stat_build_ctx(void)
149197 {
150198 struct damon_ctx *ctx;
151199 struct damon_attrs attrs;
152200 struct damon_target *target;
153− unsigned long start = 0, end = 0;
154201
155202 ctx = damon_new_ctx();
156203 if (!ctx)
@@ -180,8 +227,8 @@ static struct damon_ctx *damon_stat_build_ctx(void) · 23 unmodified lines
180227 if (!target)
181228 goto free_out;
182229 damon_add_target(ctx, target);
183− if (damon_set_region_biggest_system_ram_default(target, &start, &end,
184− ctx->min_region_sz))
230+ if (damon_stat_set_monitoring_region(target, ctx->addr_unit,
231+ ctx->min_region_sz))
185232 goto free_out;
186233 return ctx;
187234 free_out:
mm/damon/sysfs.c+9−1
@@ -1524,8 +1524,10 @@ static int damon_sysfs_commit_input(void *data) · 1523 unmodified lines
15241524 if (IS_ERR(param_ctx))
15251525 return PTR_ERR(param_ctx);
15261526 test_ctx = damon_sysfs_new_test_ctx(kdamond->damon_ctx);
1527− if (!test_ctx)
1527+ if (!test_ctx) {
1528+ damon_destroy_ctx(param_ctx);
15281529 return -ENOMEM;
1530+ }
15291531 err = damon_commit_ctx(test_ctx, param_ctx);
15301532 if (err)
15311533 goto out;
@@ -1618,9 +1620,12 @@ static int damon_sysfs_repeat_call_fn(void *data) · 86 unmodified lines
16181620
16191621 if (!mutex_trylock(&damon_sysfs_lock))
16201622 return 0;
1623+ if (sysfs_kdamond->contexts->nr != 1)
1624+ goto out;
16211625 damon_sysfs_upd_tuned_intervals(sysfs_kdamond);
16221626 damon_sysfs_upd_schemes_stats(sysfs_kdamond);
16231627 damon_sysfs_upd_schemes_effective_quotas(sysfs_kdamond);
1628+out:
16241629 mutex_unlock(&damon_sysfs_lock);
16251630 return 0;
16261631 }
@@ -1747,6 +1752,9 @@ static int damon_sysfs_update_schemes_tried_regions( · 120 unmodified lines
17471752 static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd,
17481753 struct damon_sysfs_kdamond *kdamond)
17491754 {
1755+ if (cmd != DAMON_SYSFS_CMD_OFF && kdamond->contexts->nr != 1)
1756+ return -EINVAL;
1757+
17501758 switch (cmd) {
17511759 case DAMON_SYSFS_CMD_ON:
17521760 return damon_sysfs_turn_damon_on(kdamond);
mm/hmm.c+2−2
@@ -778,7 +778,7 @@ dma_addr_t hmm_dma_map_pfn(struct device *dev, struct hmm_dma_map *map, · 777 unmodified lines
778778 struct page *page = hmm_pfn_to_page(pfns[idx]);
779779 phys_addr_t paddr = hmm_pfn_to_phys(pfns[idx]);
780780 size_t offset = idx * map->dma_entry_size;
781− unsigned long attrs = 0;
781+ unsigned long attrs = DMA_ATTR_REQUIRE_COHERENT;
782782 dma_addr_t dma_addr;
783783 int ret;
784784
@@ -871,7 +871,7 @@ bool hmm_dma_unmap_pfn(struct device *dev, struct hmm_dma_map *map, size_t idx) · 86 unmodified lines
871871 struct dma_iova_state *state = &map->state;
872872 dma_addr_t *dma_addrs = map->dma_list;
873873 unsigned long *pfns = map->pfn_list;
874− unsigned long attrs = 0;
874+ unsigned long attrs = DMA_ATTR_REQUIRE_COHERENT;
875875
876876 if ((pfns[idx] & valid_dma) != valid_dma)
877877 return false;
mm/memory.c+15−3
@@ -6815,11 +6815,16 @@ retry: · 6814 unmodified lines
68156815
68166816 pudp = pud_offset(p4dp, address);
68176817 pud = pudp_get(pudp);
6818− if (pud_none(pud))
6818+ if (!pud_present(pud))
68196819 goto out;
68206820 if (pud_leaf(pud)) {
68216821 lock = pud_lock(mm, pudp);
6822− if (!unlikely(pud_leaf(pud))) {
6822+ pud = pudp_get(pudp);
6823+
6824+ if (unlikely(!pud_present(pud))) {
6825+ spin_unlock(lock);
6826+ goto out;
6827+ } else if (unlikely(!pud_leaf(pud))) {
68236828 spin_unlock(lock);
68246829 goto retry;
68256830 }
@@ -6831,9 +6836,16 @@ retry: · 5 unmodified lines
68316836
68326837 pmdp = pmd_offset(pudp, address);
68336838 pmd = pmdp_get_lockless(pmdp);
6839+ if (!pmd_present(pmd))
6840+ goto out;
68346841 if (pmd_leaf(pmd)) {
68356842 lock = pmd_lock(mm, pmdp);
6836− if (!unlikely(pmd_leaf(pmd))) {
6843+ pmd = pmdp_get(pmdp);
6844+
6845+ if (unlikely(!pmd_present(pmd))) {
6846+ spin_unlock(lock);
6847+ goto out;
6848+ } else if (unlikely(!pmd_leaf(pmd))) {
68376849 spin_unlock(lock);
68386850 goto retry;
68396851 }
mm/mempolicy.c+8−2
@@ -487,7 +487,13 @@ void __mpol_put(struct mempolicy *pol) · 486 unmodified lines
487487 {
488488 if (!atomic_dec_and_test(&pol->refcnt))
489489 return;
490− kmem_cache_free(policy_cache, pol);
490+ /*
491+ * Required to allow mmap_lock_speculative*() access, see for example
492+ * futex_key_to_node_opt(). All accesses are serialized by mmap_lock,
493+ * however the speculative lock section unbound by the normal lock
494+ * boundaries, requiring RCU freeing.
495+ */
496+ kfree_rcu(pol, rcu);
491497 }
492498 EXPORT_SYMBOL_FOR_MODULES(__mpol_put, "kvm");
493499
@@ -1020,7 +1026,7 @@ static int vma_replace_policy(struct vm_area_struct *vma, · 526 unmodified lines
10201026 }
10211027
10221028 old = vma->vm_policy;
1023− vma->vm_policy = new; /* protected by mmap_lock */
1029+ WRITE_ONCE(vma->vm_policy, new); /* protected by mmap_lock */
10241030 mpol_put(old);
10251031
10261032 return 0;
mm/mseal.c+1−2
@@ -56,7 +56,6 @@ static int mseal_apply(struct mm_struct *mm, · 55 unmodified lines
5656 unsigned long start, unsigned long end)
5757 {
5858 struct vm_area_struct *vma, *prev;
59− unsigned long curr_start = start;
6059 VMA_ITERATOR(vmi, mm, start);
6160
6261 /* We know there are no gaps so this will be non-NULL. */
@@ -66,6 +65,7 @@ static int mseal_apply(struct mm_struct *mm, · 3 unmodified lines
6665 prev = vma;
6766
6867 for_each_vma_range(vmi, vma, end) {
68+ const unsigned long curr_start = MAX(vma->vm_start, start);
6969 const unsigned long curr_end = MIN(vma->vm_end, end);
7070
7171 if (!(vma->vm_flags & VM_SEALED)) {
@@ -79,7 +79,6 @@ static int mseal_apply(struct mm_struct *mm, · 7 unmodified lines
7979 }
8080
8181 prev = vma;
82− curr_start = curr_end;
8382 }
8483
8584 return 0;
mm/pagewalk.c+22−3
@@ -97,6 +97,7 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, · 96 unmodified lines
9797 static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
9898 struct mm_walk *walk)
9999 {
100+ pud_t pudval = pudp_get(pud);
100101 pmd_t *pmd;
101102 unsigned long next;
102103 const struct mm_walk_ops *ops = walk->ops;
@@ -105,6 +106,24 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, · 2 unmodified lines
105106 int err = 0;
106107 int depth = real_depth(3);
107108
109+ /*
110+ * For PTE handling, pte_offset_map_lock() takes care of checking
111+ * whether there actually is a page table. But it also has to be
112+ * very careful about concurrent page table reclaim.
113+ *
114+ * Similarly, we have to be careful here - a PUD entry that points
115+ * to a PMD table cannot go away, so we can just walk it. But if
116+ * it's something else, we need to ensure we didn't race something,
117+ * so need to retry.
118+ *
119+ * A pertinent example of this is a PUD refault after PUD split -
120+ * we will need to split again or risk accessing invalid memory.
121+ */
122+ if (!pud_present(pudval) || pud_leaf(pudval)) {
123+ walk->action = ACTION_AGAIN;
124+ return 0;
125+ }
126+
108127 pmd = pmd_offset(pud, addr);
109128 do {
110129 again:
@@ -218,12 +237,12 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, · 107 unmodified lines
218237 else if (pud_leaf(*pud) || !pud_present(*pud))
219238 continue; /* Nothing to do. */
220239
221− if (pud_none(*pud))
222− goto again;
223−
224240 err = walk_pmd_range(pud, addr, next, walk);
225241 if (err)
226242 break;
243+
244+ if (walk->action == ACTION_AGAIN)
245+ goto again;
227246 } while (pud++, addr = next, addr != end);
228247
229248 return err;
mm/rmap.c+7−0
@@ -457,6 +457,13 @@ static void cleanup_partial_anon_vmas(struct vm_area_struct *vma) · 456 unmodified lines
457457 list_del(&avc->same_vma);
458458 anon_vma_chain_free(avc);
459459 }
460+
461+ /*
462+ * The anon_vma assigned to this VMA is no longer valid, as we were not
463+ * able to correctly clone AVC state. Avoid inconsistent anon_vma tree
464+ * state by resetting.
465+ */
466+ vma->anon_vma = NULL;
460467 }
461468
462469 /**
mm/swap_state.c+4−5
@@ -494,6 +494,10 @@ static struct folio *__swap_cache_prepare_and_add(swp_entry_t entry, · 493 unmodified lines
494494
495495 __folio_set_locked(folio);
496496 __folio_set_swapbacked(folio);
497+
498+ if (!charged && mem_cgroup_swapin_charge_folio(folio, NULL, gfp, entry))
499+ goto failed;
500+
497501 for (;;) {
498502 ret = swap_cache_add_folio(folio, entry, &shadow);
499503 if (!ret)
@@ -514,11 +518,6 @@ static struct folio *__swap_cache_prepare_and_add(swp_entry_t entry, · 14 unmodified lines
514518 goto failed;
515519 }
516520
517− if (!charged && mem_cgroup_swapin_charge_folio(folio, NULL, gfp, entry)) {
518− swap_cache_del_folio(folio);
519− goto failed;
520− }
521−
522521 memcg1_swapin(entry, folio_nr_pages(folio));
523522 if (shadow)
524523 workingset_refault(folio, shadow);
mm/zswap.c+7−1
@@ -942,9 +942,15 @@ static bool zswap_decompress(struct zswap_entry *entry, struct folio *folio) · 941 unmodified lines
942942
943943 /* zswap entries of length PAGE_SIZE are not compressed. */
944944 if (entry->length == PAGE_SIZE) {
945+ void *dst;
946+
945947 WARN_ON_ONCE(input->length != PAGE_SIZE);
946− memcpy_from_sglist(kmap_local_folio(folio, 0), input, 0, PAGE_SIZE);
948+
949+ dst = kmap_local_folio(folio, 0);
950+ memcpy_from_sglist(dst, input, 0, PAGE_SIZE);
947951 dlen = PAGE_SIZE;
952+ kunmap_local(dst);
953+ flush_dcache_folio(folio);
948954 } else {
949955 sg_init_table(&output, 1);
950956 sg_set_folio(&output, folio, PAGE_SIZE, 0);
net/bluetooth/hci_conn.c+1−1
@@ -3095,7 +3095,7 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason) · 3094 unmodified lines
30953095 * hci_connect_le serializes the connection attempts so only one
30963096 * connection can be in BT_CONNECT at time.
30973097 */
3098− if (conn->state == BT_CONNECT && hdev->req_status == HCI_REQ_PEND) {
3098+ if (conn->state == BT_CONNECT && READ_ONCE(hdev->req_status) == HCI_REQ_PEND) {
30993099 switch (hci_skb_event(hdev->sent_cmd)) {
31003100 case HCI_EV_CONN_COMPLETE:
31013101 case HCI_EV_LE_CONN_COMPLETE:
net/bluetooth/hci_core.c+1−1
@@ -4126,7 +4126,7 @@ static int hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb) · 4125 unmodified lines
41264126 kfree_skb(skb);
41274127 }
41284128
4129− if (hdev->req_status == HCI_REQ_PEND &&
4129+ if (READ_ONCE(hdev->req_status) == HCI_REQ_PEND &&
41304130 !hci_dev_test_and_set_flag(hdev, HCI_CMD_PENDING)) {
41314131 kfree_skb(hdev->req_skb);
41324132 hdev->req_skb = skb_clone(hdev->sent_cmd, GFP_KERNEL);
net/bluetooth/hci_sync.c+10−10
@@ -25,11 +25,11 @@ static void hci_cmd_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode, · 24 unmodified lines
2525 {
2626 bt_dev_dbg(hdev, "result 0x%2.2x", result);
2727
28− if (hdev->req_status != HCI_REQ_PEND)
28+ if (READ_ONCE(hdev->req_status) != HCI_REQ_PEND)
2929 return;
3030
3131 hdev->req_result = result;
32− hdev->req_status = HCI_REQ_DONE;
32+ WRITE_ONCE(hdev->req_status, HCI_REQ_DONE);
3333
3434 /* Free the request command so it is not used as response */
3535 kfree_skb(hdev->req_skb);
@@ -167,20 +167,20 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen, · 131 unmodified lines
167167
168168 hci_cmd_sync_add(&req, opcode, plen, param, event, sk);
169169
170− hdev->req_status = HCI_REQ_PEND;
170+ WRITE_ONCE(hdev->req_status, HCI_REQ_PEND);
171171
172172 err = hci_req_sync_run(&req);
173173 if (err < 0)
174174 return ERR_PTR(err);
175175
176176 err = wait_event_interruptible_timeout(hdev->req_wait_q,
177− hdev->req_status != HCI_REQ_PEND,
177+ READ_ONCE(hdev->req_status) != HCI_REQ_PEND,
178178 timeout);
179179
180180 if (err == -ERESTARTSYS)
181181 return ERR_PTR(-EINTR);
182182
183− switch (hdev->req_status) {
183+ switch (READ_ONCE(hdev->req_status)) {
184184 case HCI_REQ_DONE:
185185 err = -bt_to_errno(hdev->req_result);
186186 break;
@@ -194,7 +194,7 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen, · 7 unmodified lines
194194 break;
195195 }
196196
197− hdev->req_status = 0;
197+ WRITE_ONCE(hdev->req_status, 0);
198198 hdev->req_result = 0;
199199 skb = hdev->req_rsp;
200200 hdev->req_rsp = NULL;
@@ -665,9 +665,9 @@ void hci_cmd_sync_cancel(struct hci_dev *hdev, int err) · 464 unmodified lines
665665 {
666666 bt_dev_dbg(hdev, "err 0x%2.2x", err);
667667
668− if (hdev->req_status == HCI_REQ_PEND) {
668+ if (READ_ONCE(hdev->req_status) == HCI_REQ_PEND) {
669669 hdev->req_result = err;
670− hdev->req_status = HCI_REQ_CANCELED;
670+ WRITE_ONCE(hdev->req_status, HCI_REQ_CANCELED);
671671
672672 queue_work(hdev->workqueue, &hdev->cmd_sync_cancel_work);
673673 }
@@ -683,12 +683,12 @@ void hci_cmd_sync_cancel_sync(struct hci_dev *hdev, int err) · 9 unmodified lines
683683 {
684684 bt_dev_dbg(hdev, "err 0x%2.2x", err);
685685
686− if (hdev->req_status == HCI_REQ_PEND) {
686+ if (READ_ONCE(hdev->req_status) == HCI_REQ_PEND) {
687687 /* req_result is __u32 so error must be positive to be properly
688688 * propagated.
689689 */
690690 hdev->req_result = err < 0 ? -err : err;
691− hdev->req_status = HCI_REQ_CANCELED;
691+ WRITE_ONCE(hdev->req_status, HCI_REQ_CANCELED);
692692
693693 wake_up_interruptible(&hdev->req_wait_q);
694694 }
net/bluetooth/l2cap_core.c+53−18
@@ -926,16 +926,39 @@ int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator) · 925 unmodified lines
926926
927927 static int l2cap_get_ident(struct l2cap_conn *conn)
928928 {
929+ u8 max;
930+ int ident;
931+
929932 /* LE link does not support tools like l2ping so use the full range */
930933 if (conn->hcon->type == LE_LINK)
931− return ida_alloc_range(&conn->tx_ida, 1, 255, GFP_ATOMIC);
932−
934+ max = 255;
933935 /* Get next available identificator.
934936 * 1 - 128 are used by kernel.
935937 * 129 - 199 are reserved.
936938 * 200 - 254 are used by utilities like l2ping, etc.
937939 */
938− return ida_alloc_range(&conn->tx_ida, 1, 128, GFP_ATOMIC);
940+ else
941+ max = 128;
942+
943+ /* Allocate ident using min as last used + 1 (cyclic) */
944+ ident = ida_alloc_range(&conn->tx_ida, READ_ONCE(conn->tx_ident) + 1,
945+ max, GFP_ATOMIC);
946+ /* Force min 1 to start over */
947+ if (ident <= 0) {
948+ ident = ida_alloc_range(&conn->tx_ida, 1, max, GFP_ATOMIC);
949+ if (ident <= 0) {
950+ /* If all idents are in use, log an error, this is
951+ * extremely unlikely to happen and would indicate a bug
952+ * in the code that idents are not being freed properly.
953+ */
954+ BT_ERR("Unable to allocate ident: %d", ident);
955+ return 0;
956+ }
957+ }
958+
959+ WRITE_ONCE(conn->tx_ident, ident);
960+
961+ return ident;
939962 }
940963
941964 static void l2cap_send_acl(struct l2cap_conn *conn, struct sk_buff *skb,
@@ -1748,6 +1771,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) · 806 unmodified lines
17481771
17491772 BT_DBG("hcon %p conn %p, err %d", hcon, conn, err);
17501773
1774+ disable_delayed_work_sync(&conn->info_timer);
1775+ disable_delayed_work_sync(&conn->id_addr_timer);
1776+
17511777 mutex_lock(&conn->lock);
17521778
17531779 kfree_skb(conn->rx_skb);
@@ -1763,8 +1789,6 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) · 9 unmodified lines
17631789
17641790 ida_destroy(&conn->tx_ida);
17651791
1766− cancel_delayed_work_sync(&conn->id_addr_timer);
1767−
17681792 l2cap_unregister_all_users(conn);
17691793
17701794 /* Force the connection to be immediately dropped */
@@ -1783,9 +1807,6 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) · 12 unmodified lines
17831807 l2cap_chan_put(chan);
17841808 }
17851809
1786− if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT)
1787− cancel_delayed_work_sync(&conn->info_timer);
1788−
17891810 hci_chan_del(conn->hchan);
17901811 conn->hchan = NULL;
17911812
@@ -2377,6 +2398,9 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan, · 585 unmodified lines
23772398 /* Remote device may have requested smaller PDUs */
23782399 pdu_len = min_t(size_t, pdu_len, chan->remote_mps);
23792400
2401+ if (!pdu_len)
2402+ return -EINVAL;
2403+
23802404 if (len <= pdu_len) {
23812405 sar = L2CAP_SAR_UNSEGMENTED;
23822406 sdu_len = 0;
@@ -4312,14 +4336,16 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, · 1929 unmodified lines
43124336 if (test_bit(CONF_INPUT_DONE, &chan->conf_state)) {
43134337 set_default_fcs(chan);
43144338
4315− if (chan->mode == L2CAP_MODE_ERTM ||
4316− chan->mode == L2CAP_MODE_STREAMING)
4317− err = l2cap_ertm_init(chan);
4339+ if (chan->state != BT_CONNECTED) {
4340+ if (chan->mode == L2CAP_MODE_ERTM ||
4341+ chan->mode == L2CAP_MODE_STREAMING)
4342+ err = l2cap_ertm_init(chan);
43184343
4319− if (err < 0)
4320− l2cap_send_disconn_req(chan, -err);
4321− else
4322− l2cap_chan_ready(chan);
4344+ if (err < 0)
4345+ l2cap_send_disconn_req(chan, -err);
4346+ else
4347+ l2cap_chan_ready(chan);
4348+ }
43234349
43244350 goto unlock;
43254351 }
@@ -5081,14 +5107,14 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, · 755 unmodified lines
50815107 cmd_len -= sizeof(*req);
50825108 num_scid = cmd_len / sizeof(u16);
50835109
5084− /* Always respond with the same number of scids as in the request */
5085− rsp_len = cmd_len;
5086−
50875110 if (num_scid > L2CAP_ECRED_MAX_CID) {
50885111 result = L2CAP_CR_LE_INVALID_PARAMS;
50895112 goto response;
50905113 }
50915114
5115+ /* Always respond with the same number of scids as in the request */
5116+ rsp_len = cmd_len;
5117+
50925118 mtu = __le16_to_cpu(req->mtu);
50935119 mps = __le16_to_cpu(req->mps);
50945120
@@ -6607,6 +6633,10 @@ static void l2cap_chan_le_send_credits(struct l2cap_chan *chan) · 1512 unmodified lines
66076633 struct l2cap_le_credits pkt;
66086634 u16 return_credits = l2cap_le_rx_credits(chan);
66096635
6636+ if (chan->mode != L2CAP_MODE_LE_FLOWCTL &&
6637+ chan->mode != L2CAP_MODE_EXT_FLOWCTL)
6638+ return;
6639+
66106640 if (chan->rx_credits >= return_credits)
66116641 return;
66126642
@@ -6690,6 +6720,11 @@ static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) · 77 unmodified lines
66906720 if (!chan->sdu) {
66916721 u16 sdu_len;
66926722
6723+ if (!pskb_may_pull(skb, L2CAP_SDULEN_SIZE)) {
6724+ err = -EINVAL;
6725+ goto failed;
6726+ }
6727+
66936728 sdu_len = get_unaligned_le16(skb->data);
66946729 skb_pull(skb, L2CAP_SDULEN_SIZE);
66956730
net/bluetooth/l2cap_sock.c+3−0
@@ -1698,6 +1698,9 @@ static void l2cap_sock_ready_cb(struct l2cap_chan *chan) · 1697 unmodified lines
16981698 struct sock *sk = chan->data;
16991699 struct sock *parent;
17001700
1701+ if (!sk)
1702+ return;
1703+
17011704 lock_sock(sk);
17021705
17031706 parent = bt_sk(sk)->parent;
net/bluetooth/mgmt.c+1−1
@@ -5355,7 +5355,7 @@ static void mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev, · 5354 unmodified lines
53555355 * hci_adv_monitors_clear is about to be called which will take care of
53565356 * freeing the adv_monitor instances.
53575357 */
5358− if (status == -ECANCELED && !mgmt_pending_valid(hdev, cmd))
5358+ if (status == -ECANCELED || !mgmt_pending_valid(hdev, cmd))
53595359 return;
53605360
53615361 monitor = cmd->user_data;
net/bluetooth/sco.c+7−3
@@ -401,7 +401,7 @@ static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb) · 400 unmodified lines
401401 struct sock *sk;
402402
403403 sco_conn_lock(conn);
404− sk = conn->sk;
404+ sk = sco_sock_hold(conn);
405405 sco_conn_unlock(conn);
406406
407407 if (!sk)
@@ -410,11 +410,15 @@ static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb) · 2 unmodified lines
410410 BT_DBG("sk %p len %u", sk, skb->len);
411411
412412 if (sk->sk_state != BT_CONNECTED)
413− goto drop;
413+ goto drop_put;
414414
415− if (!sock_queue_rcv_skb(sk, skb))
415+ if (!sock_queue_rcv_skb(sk, skb)) {
416+ sock_put(sk);
416417 return;
418+ }
417419
420+drop_put:
421+ sock_put(sk);
418422 drop:
419423 kfree_skb(skb);
420424 }
net/can/af_can.c+2−2
@@ -469,7 +469,7 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id, · 468 unmodified lines
469469
470470 rcv->can_id = can_id;
471471 rcv->mask = mask;
472− rcv->matches = 0;
472+ atomic_long_set(&rcv->matches, 0);
473473 rcv->func = func;
474474 rcv->data = data;
475475 rcv->ident = ident;
@@ -573,7 +573,7 @@ EXPORT_SYMBOL(can_rx_unregister); · 97 unmodified lines
573573 static inline void deliver(struct sk_buff *skb, struct receiver *rcv)
574574 {
575575 rcv->func(skb, rcv->data);
576− rcv->matches++;
576+ atomic_long_inc(&rcv->matches);
577577 }
578578
579579 static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buff *skb)
net/can/af_can.h+1−1
@@ -52,7 +52,7 @@ struct receiver { · 51 unmodified lines
5252 struct hlist_node list;
5353 canid_t can_id;
5454 canid_t mask;
55− unsigned long matches;
55+ atomic_long_t matches;
5656 void (*func)(struct sk_buff *skb, void *data);
5757 void *data;
5858 char *ident;
net/can/gw.c+3−3
@@ -375,10 +375,10 @@ static void cgw_csum_crc8_rel(struct canfd_frame *cf, · 374 unmodified lines
375375 return;
376376
377377 if (from <= to) {
378− for (i = crc8->from_idx; i <= crc8->to_idx; i++)
378+ for (i = from; i <= to; i++)
379379 crc = crc8->crctab[crc ^ cf->data[i]];
380380 } else {
381− for (i = crc8->from_idx; i >= crc8->to_idx; i--)
381+ for (i = from; i >= to; i--)
382382 crc = crc8->crctab[crc ^ cf->data[i]];
383383 }
384384
@@ -397,7 +397,7 @@ static void cgw_csum_crc8_rel(struct canfd_frame *cf, · 12 unmodified lines
397397 break;
398398 }
399399
400− cf->data[crc8->result_idx] = crc ^ crc8->final_xor_val;
400+ cf->data[res] = crc ^ crc8->final_xor_val;
401401 }
402402
403403 static void cgw_csum_crc8_pos(struct canfd_frame *cf,
net/can/isotp.c+18−6
@@ -1248,12 +1248,6 @@ static int isotp_release(struct socket *sock) · 1247 unmodified lines
12481248 so->ifindex = 0;
12491249 so->bound = 0;
12501250
1251− if (so->rx.buf != so->rx.sbuf)
1252− kfree(so->rx.buf);
1253−
1254− if (so->tx.buf != so->tx.sbuf)
1255− kfree(so->tx.buf);
1256−
12571251 sock_orphan(sk);
12581252 sock->sk = NULL;
12591253
@@ -1622,6 +1616,21 @@ static int isotp_notifier(struct notifier_block *nb, unsigned long msg, · 362 unmodified lines
16221616 return NOTIFY_DONE;
16231617 }
16241618
1619+static void isotp_sock_destruct(struct sock *sk)
1620+{
1621+ struct isotp_sock *so = isotp_sk(sk);
1622+
1623+ /* do the standard CAN sock destruct work */
1624+ can_sock_destruct(sk);
1625+
1626+ /* free potential extended PDU buffers */
1627+ if (so->rx.buf != so->rx.sbuf)
1628+ kfree(so->rx.buf);
1629+
1630+ if (so->tx.buf != so->tx.sbuf)
1631+ kfree(so->tx.buf);
1632+}
1633+
16251634 static int isotp_init(struct sock *sk)
16261635 {
16271636 struct isotp_sock *so = isotp_sk(sk);
@@ -1666,6 +1675,9 @@ static int isotp_init(struct sock *sk) · 38 unmodified lines
16661675 list_add_tail(&so->notifier, &isotp_notifier_list);
16671676 spin_unlock(&isotp_notifier_lock);
16681677
1678+ /* re-assign default can_sock_destruct() reference */
1679+ sk->sk_destruct = isotp_sock_destruct;
1680+
16691681 return 0;
16701682 }
16711683
net/can/proc.c+2−1
@@ -196,7 +196,8 @@ static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list, · 195 unmodified lines
196196 " %-5s %03x %08x %pK %pK %8ld %s\n";
197197
198198 seq_printf(m, fmt, DNAME(dev), r->can_id, r->mask,
199− r->func, r->data, r->matches, r->ident);
199+ r->func, r->data, atomic_long_read(&r->matches),
200+ r->ident);
200201 }
201202 }
202203
net/core/dev.c+17−5
@@ -3769,6 +3769,22 @@ static netdev_features_t dflt_features_check(struct sk_buff *skb, · 3768 unmodified lines
37693769 return vlan_features_check(skb, features);
37703770 }
37713771
3772+static bool skb_gso_has_extension_hdr(const struct sk_buff *skb)
3773+{
3774+ if (!skb->encapsulation)
3775+ return ((skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6 ||
3776+ (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 &&
3777+ vlan_get_protocol(skb) == htons(ETH_P_IPV6))) &&
3778+ skb_transport_header_was_set(skb) &&
3779+ skb_network_header_len(skb) != sizeof(struct ipv6hdr));
3780+ else
3781+ return (!skb_inner_network_header_was_set(skb) ||
3782+ ((skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6 ||
3783+ (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 &&
3784+ inner_ip_hdr(skb)->version == 6)) &&
3785+ skb_inner_network_header_len(skb) != sizeof(struct ipv6hdr)));
3786+}
3787+
37723788 static netdev_features_t gso_features_check(const struct sk_buff *skb,
37733789 struct net_device *dev,
37743790 netdev_features_t features)
@@ -3816,11 +3832,7 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb, · 41 unmodified lines
38163832 * so neither does TSO that depends on it.
38173833 */
38183834 if (features & NETIF_F_IPV6_CSUM &&
3819− (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6 ||
3820− (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 &&
3821− vlan_get_protocol(skb) == htons(ETH_P_IPV6))) &&
3822− skb_transport_header_was_set(skb) &&
3823− skb_network_header_len(skb) != sizeof(struct ipv6hdr))
3835+ skb_gso_has_extension_hdr(skb))
38243836 features &= ~(NETIF_F_IPV6_CSUM | NETIF_F_TSO6 | NETIF_F_GSO_UDP_L4);
38253837
38263838 return features;
net/core/rtnetlink.c+25−3
@@ -629,6 +629,9 @@ int rtnl_link_register(struct rtnl_link_ops *ops) · 628 unmodified lines
629629 unlock:
630630 mutex_unlock(&link_ops_mutex);
631631
632+ if (err)
633+ cleanup_srcu_struct(&ops->srcu);
634+
632635 return err;
633636 }
634637 EXPORT_SYMBOL_GPL(rtnl_link_register);
@@ -707,11 +710,14 @@ static size_t rtnl_link_get_slave_info_data_size(const struct net_device *dev) · 72 unmodified lines
707710 goto out;
708711
709712 ops = master_dev->rtnl_link_ops;
710− if (!ops || !ops->get_slave_size)
713+ if (!ops)
714+ goto out;
715+ size += nla_total_size(strlen(ops->kind) + 1); /* IFLA_INFO_SLAVE_KIND */
716+ if (!ops->get_slave_size)
711717 goto out;
712718 /* IFLA_INFO_SLAVE_DATA + nested data */
713− size = nla_total_size(sizeof(struct nlattr)) +
714− ops->get_slave_size(master_dev, dev);
719+ size += nla_total_size(sizeof(struct nlattr)) +
720+ ops->get_slave_size(master_dev, dev);
715721
716722 out:
717723 rcu_read_unlock();
@@ -1267,6 +1273,21 @@ static size_t rtnl_dpll_pin_size(const struct net_device *dev) · 549 unmodified lines
12671273 return size;
12681274 }
12691275
1276+static size_t rtnl_dev_parent_size(const struct net_device *dev)
1277+{
1278+ size_t size = 0;
1279+
1280+ /* IFLA_PARENT_DEV_NAME */
1281+ if (dev->dev.parent)
1282+ size += nla_total_size(strlen(dev_name(dev->dev.parent)) + 1);
1283+
1284+ /* IFLA_PARENT_DEV_BUS_NAME */
1285+ if (dev->dev.parent && dev->dev.parent->bus)
1286+ size += nla_total_size(strlen(dev->dev.parent->bus->name) + 1);
1287+
1288+ return size;
1289+}
1290+
12701291 static noinline size_t if_nlmsg_size(const struct net_device *dev,
12711292 u32 ext_filter_mask)
12721293 {
@@ -1328,6 +1349,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, · 55 unmodified lines
13281349 + nla_total_size(8) /* IFLA_MAX_PACING_OFFLOAD_HORIZON */
13291350 + nla_total_size(2) /* IFLA_HEADROOM */
13301351 + nla_total_size(2) /* IFLA_TAILROOM */
1352+ + rtnl_dev_parent_size(dev)
13311353 + 0;
13321354
13331355 if (!(ext_filter_mask & RTEXT_FILTER_SKIP_STATS))
net/ipv4/esp4.c+6−3
@@ -235,10 +235,13 @@ static void esp_output_done(void *data, int err) · 234 unmodified lines
235235 xfrm_dev_resume(skb);
236236 } else {
237237 if (!err &&
238− x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP)
239− esp_output_tail_tcp(x, skb);
240− else
238+ x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) {
239+ err = esp_output_tail_tcp(x, skb);
240+ if (err != -EINPROGRESS)
241+ kfree_skb(skb);
242+ } else {
241243 xfrm_output_resume(skb_to_full_sk(skb), skb, err);
244+ }
242245 }
243246 }
244247
net/ipv4/inet_connection_sock.c+3−17
@@ -154,20 +154,6 @@ bool inet_sk_get_local_port_range(const struct sock *sk, int *low, int *high) · 153 unmodified lines
154154 }
155155 EXPORT_SYMBOL(inet_sk_get_local_port_range);
156156
157−static bool inet_use_bhash2_on_bind(const struct sock *sk)
158−{
159−#if IS_ENABLED(CONFIG_IPV6)
160− if (sk->sk_family == AF_INET6) {
161− if (ipv6_addr_any(&sk->sk_v6_rcv_saddr))
162− return false;
163−
164− if (!ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))
165− return true;
166− }
167−#endif
168− return sk->sk_rcv_saddr != htonl(INADDR_ANY);
169−}
170−
171157 static bool inet_bind_conflict(const struct sock *sk, struct sock *sk2,
172158 kuid_t uid, bool relax,
173159 bool reuseport_cb_ok, bool reuseport_ok)
@@ -259,7 +245,7 @@ static int inet_csk_bind_conflict(const struct sock *sk, · 85 unmodified lines
259245 * checks separately because their spinlocks have to be acquired/released
260246 * independently of each other, to prevent possible deadlocks
261247 */
262− if (inet_use_bhash2_on_bind(sk))
248+ if (inet_use_hash2_on_bind(sk))
263249 return tb2 && inet_bhash2_conflict(sk, tb2, uid, relax,
264250 reuseport_cb_ok, reuseport_ok);
265251
@@ -376,7 +362,7 @@ other_parity_scan: · 110 unmodified lines
376362 head = &hinfo->bhash[inet_bhashfn(net, port,
377363 hinfo->bhash_size)];
378364 spin_lock_bh(&head->lock);
379− if (inet_use_bhash2_on_bind(sk)) {
365+ if (inet_use_hash2_on_bind(sk)) {
380366 if (inet_bhash2_addr_any_conflict(sk, port, l3mdev, relax, false))
381367 goto next_port;
382368 }
@@ -562,7 +548,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum) · 179 unmodified lines
562548 check_bind_conflict = false;
563549 }
564550
565− if (check_bind_conflict && inet_use_bhash2_on_bind(sk)) {
551+ if (check_bind_conflict && inet_use_hash2_on_bind(sk)) {
566552 if (inet_bhash2_addr_any_conflict(sk, port, l3mdev, true, true))
567553 goto fail_unlock;
568554 }
net/ipv4/udp.c+1−1
@@ -287,7 +287,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum, · 286 unmodified lines
287287 } else {
288288 hslot = udp_hashslot(udptable, net, snum);
289289 spin_lock_bh(&hslot->lock);
290− if (hslot->count > 10) {
290+ if (inet_use_hash2_on_bind(sk) && hslot->count > 10) {
291291 int exist;
292292 unsigned int slot2 = udp_sk(sk)->udp_portaddr_hash ^ snum;
293293
net/ipv6/addrconf.c+2−2
@@ -2862,7 +2862,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao) · 2861 unmodified lines
28622862 fib6_add_gc_list(rt);
28632863 } else {
28642864 fib6_clean_expires(rt);
2865− fib6_remove_gc_list(rt);
2865+ fib6_may_remove_gc_list(net, rt);
28662866 }
28672867
28682868 spin_unlock_bh(&table->tb6_lock);
@@ -4840,7 +4840,7 @@ static int modify_prefix_route(struct net *net, struct inet6_ifaddr *ifp, · 1971 unmodified lines
48404840
48414841 if (!(flags & RTF_EXPIRES)) {
48424842 fib6_clean_expires(f6i);
4843− fib6_remove_gc_list(f6i);
4843+ fib6_may_remove_gc_list(net, f6i);
48444844 } else {
48454845 fib6_set_expires(f6i, expires);
48464846 fib6_add_gc_list(f6i);
net/ipv6/esp6.c+6−3
@@ -271,10 +271,13 @@ static void esp_output_done(void *data, int err) · 270 unmodified lines
271271 xfrm_dev_resume(skb);
272272 } else {
273273 if (!err &&
274− x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP)
275− esp_output_tail_tcp(x, skb);
276− else
274+ x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) {
275+ err = esp_output_tail_tcp(x, skb);
276+ if (err != -EINPROGRESS)
277+ kfree_skb(skb);
278+ } else {
277279 xfrm_output_resume(skb_to_full_sk(skb), skb, err);
280+ }
278281 }
279282 }
280283
net/ipv6/ip6_fib.c+13−2
@@ -1133,7 +1133,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt, · 1132 unmodified lines
11331133 return -EEXIST;
11341134 if (!(rt->fib6_flags & RTF_EXPIRES)) {
11351135 fib6_clean_expires(iter);
1136− fib6_remove_gc_list(iter);
1136+ fib6_may_remove_gc_list(info->nl_net, iter);
11371137 } else {
11381138 fib6_set_expires(iter, rt->expires);
11391139 fib6_add_gc_list(iter);
@@ -2348,6 +2348,17 @@ static void fib6_flush_trees(struct net *net) · 1208 unmodified lines
23482348 /*
23492349 * Garbage collection
23502350 */
2351+void fib6_age_exceptions(struct fib6_info *rt, struct fib6_gc_args *gc_args,
2352+ unsigned long now)
2353+{
2354+ bool may_expire = rt->fib6_flags & RTF_EXPIRES && rt->expires;
2355+ int old_more = gc_args->more;
2356+
2357+ rt6_age_exceptions(rt, gc_args, now);
2358+
2359+ if (!may_expire && old_more == gc_args->more)
2360+ fib6_remove_gc_list(rt);
2361+}
23512362
23522363 static int fib6_age(struct fib6_info *rt, struct fib6_gc_args *gc_args)
23532364 {
@@ -2370,7 +2381,7 @@ static int fib6_age(struct fib6_info *rt, struct fib6_gc_args *gc_args) · 16 unmodified lines
23702381 * Note, that clones are aged out
23712382 * only if they are not in use now.
23722383 */
2373− rt6_age_exceptions(rt, gc_args, now);
2384+ fib6_age_exceptions(rt, gc_args, now);
23742385
23752386 return 0;
23762387 }
net/ipv6/netfilter/ip6t_rt.c+4−0
@@ -157,6 +157,10 @@ static int rt_mt6_check(const struct xt_mtchk_param *par) · 156 unmodified lines
157157 pr_debug("unknown flags %X\n", rtinfo->invflags);
158158 return -EINVAL;
159159 }
160+ if (rtinfo->addrnr > IP6T_RT_HOPS) {
161+ pr_debug("too many addresses specified\n");
162+ return -EINVAL;
163+ }
160164 if ((rtinfo->flags & (IP6T_RT_RES | IP6T_RT_FST_MASK)) &&
161165 (!(rtinfo->flags & IP6T_RT_TYP) ||
162166 (rtinfo->rt_type != 0) ||
net/ipv6/route.c+1−1
@@ -1033,7 +1033,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, · 1032 unmodified lines
10331033
10341034 if (!addrconf_finite_timeout(lifetime)) {
10351035 fib6_clean_expires(rt);
1036− fib6_remove_gc_list(rt);
1036+ fib6_may_remove_gc_list(net, rt);
10371037 } else {
10381038 fib6_set_expires(rt, jiffies + HZ * lifetime);
10391039 fib6_add_gc_list(rt);
net/key/af_key.c+12−7
@@ -3518,7 +3518,7 @@ static int set_sadb_kmaddress(struct sk_buff *skb, const struct xfrm_kmaddress * · 3517 unmodified lines
35183518
35193519 static int set_ipsecrequest(struct sk_buff *skb,
35203520 uint8_t proto, uint8_t mode, int level,
3521− uint32_t reqid, uint8_t family,
3521+ uint32_t reqid, sa_family_t family,
35223522 const xfrm_address_t *src, const xfrm_address_t *dst)
35233523 {
35243524 struct sadb_x_ipsecrequest *rq;
@@ -3583,12 +3583,17 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, · 58 unmodified lines
35833583
35843584 /* ipsecrequests */
35853585 for (i = 0, mp = m; i < num_bundles; i++, mp++) {
3586− /* old locator pair */
3587− size_pol += sizeof(struct sadb_x_ipsecrequest) +
3588− pfkey_sockaddr_pair_size(mp->old_family);
3589− /* new locator pair */
3590− size_pol += sizeof(struct sadb_x_ipsecrequest) +
3591− pfkey_sockaddr_pair_size(mp->new_family);
3586+ int pair_size;
3587+
3588+ pair_size = pfkey_sockaddr_pair_size(mp->old_family);
3589+ if (!pair_size)
3590+ return -EINVAL;
3591+ size_pol += sizeof(struct sadb_x_ipsecrequest) + pair_size;
3592+
3593+ pair_size = pfkey_sockaddr_pair_size(mp->new_family);
3594+ if (!pair_size)
3595+ return -EINVAL;
3596+ size_pol += sizeof(struct sadb_x_ipsecrequest) + pair_size;
35923597 }
35933598
35943599 size += sizeof(struct sadb_msg) + size_pol;
net/netfilter/nf_conntrack_broadcast.c+6−2
@@ -21,6 +21,7 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb, · 20 unmodified lines
2121 unsigned int timeout)
2222 {
2323 const struct nf_conntrack_helper *helper;
24+ struct net *net = read_pnet(&ct->ct_net);
2425 struct nf_conntrack_expect *exp;
2526 struct iphdr *iph = ip_hdr(skb);
2627 struct rtable *rt = skb_rtable(skb);
@@ -70,8 +71,11 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb, · 43 unmodified lines
7071 exp->expectfn = NULL;
7172 exp->flags = NF_CT_EXPECT_PERMANENT;
7273 exp->class = NF_CT_EXPECT_CLASS_DEFAULT;
73− exp->helper = NULL;
74−
74+ rcu_assign_pointer(exp->helper, helper);
75+ write_pnet(&exp->net, net);
76+#ifdef CONFIG_NF_CONNTRACK_ZONES
77+ exp->zone = ct->zone;
78+#endif
7579 nf_ct_expect_related(exp, 0);
7680 nf_ct_expect_put(exp);
7781
net/netfilter/nf_conntrack_ecache.c+2−0
@@ -247,6 +247,8 @@ void nf_ct_expect_event_report(enum ip_conntrack_expect_events event, · 246 unmodified lines
247247 struct nf_ct_event_notifier *notify;
248248 struct nf_conntrack_ecache *e;
249249
250+ lockdep_nfct_expect_lock_held();
251+
250252 rcu_read_lock();
251253 notify = rcu_dereference(net->ct.nf_conntrack_event_cb);
252254 if (!notify)
net/netfilter/nf_conntrack_expect.c+34−5
@@ -51,6 +51,7 @@ void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp, · 50 unmodified lines
5151 struct net *net = nf_ct_exp_net(exp);
5252 struct nf_conntrack_net *cnet;
5353
54+ lockdep_nfct_expect_lock_held();
5455 WARN_ON(!master_help);
5556 WARN_ON(timer_pending(&exp->timeout));
5657
@@ -112,12 +113,14 @@ nf_ct_exp_equal(const struct nf_conntrack_tuple *tuple, · 55 unmodified lines
112113 const struct net *net)
113114 {
114115 return nf_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask) &&
115− net_eq(net, nf_ct_net(i->master)) &&
116− nf_ct_zone_equal_any(i->master, zone);
116+ net_eq(net, read_pnet(&i->net)) &&
117+ nf_ct_exp_zone_equal_any(i, zone);
117118 }
118119
119120 bool nf_ct_remove_expect(struct nf_conntrack_expect *exp)
120121 {
122+ lockdep_nfct_expect_lock_held();
123+
121124 if (timer_delete(&exp->timeout)) {
122125 nf_ct_unlink_expect(exp);
123126 nf_ct_expect_put(exp);
@@ -177,6 +180,8 @@ nf_ct_find_expectation(struct net *net, · 53 unmodified lines
177180 struct nf_conntrack_expect *i, *exp = NULL;
178181 unsigned int h;
179182
183+ lockdep_nfct_expect_lock_held();
184+
180185 if (!cnet->expect_count)
181186 return NULL;
182187
@@ -309,12 +314,20 @@ struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me) · 126 unmodified lines
309314 }
310315 EXPORT_SYMBOL_GPL(nf_ct_expect_alloc);
311316
317+/* This function can only be used from packet path, where accessing
318+ * master's helper is safe, because the packet holds a reference on
319+ * the conntrack object. Never use it from control plane.
320+ */
312321 void nf_ct_expect_init(struct nf_conntrack_expect *exp, unsigned int class,
313322 u_int8_t family,
314323 const union nf_inet_addr *saddr,
315324 const union nf_inet_addr *daddr,
316325 u_int8_t proto, const __be16 *src, const __be16 *dst)
317326 {
327+ struct nf_conntrack_helper *helper = NULL;
328+ struct nf_conn *ct = exp->master;
329+ struct net *net = read_pnet(&ct->ct_net);
330+ struct nf_conn_help *help;
318331 int len;
319332
320333 if (family == AF_INET)
@@ -325,7 +338,16 @@ void nf_ct_expect_init(struct nf_conntrack_expect *exp, unsigned int class, · 4 unmodified lines
325338 exp->flags = 0;
326339 exp->class = class;
327340 exp->expectfn = NULL;
328− exp->helper = NULL;
341+
342+ help = nfct_help(ct);
343+ if (help)
344+ helper = rcu_dereference(help->helper);
345+
346+ rcu_assign_pointer(exp->helper, helper);
347+ write_pnet(&exp->net, net);
348+#ifdef CONFIG_NF_CONNTRACK_ZONES
349+ exp->zone = ct->zone;
350+#endif
329351 exp->tuple.src.l3num = family;
330352 exp->tuple.dst.protonum = proto;
331353
@@ -442,6 +464,8 @@ static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect, · 110 unmodified lines
442464 unsigned int h;
443465 int ret = 0;
444466
467+ lockdep_nfct_expect_lock_held();
468+
445469 if (!master_help) {
446470 ret = -ESHUTDOWN;
447471 goto out;
@@ -498,8 +522,9 @@ int nf_ct_expect_related_report(struct nf_conntrack_expect *expect, · 50 unmodified lines
498522
499523 nf_ct_expect_insert(expect);
500524
501− spin_unlock_bh(&nf_conntrack_expect_lock);
502525 nf_ct_expect_event_report(IPEXP_NEW, expect, portid, report);
526+ spin_unlock_bh(&nf_conntrack_expect_lock);
527+
503528 return 0;
504529 out:
505530 spin_unlock_bh(&nf_conntrack_expect_lock);
@@ -627,11 +652,15 @@ static int exp_seq_show(struct seq_file *s, void *v) · 121 unmodified lines
627652 {
628653 struct nf_conntrack_expect *expect;
629654 struct nf_conntrack_helper *helper;
655+ struct net *net = seq_file_net(s);
630656 struct hlist_node *n = v;
631657 char *delim = "";
632658
633659 expect = hlist_entry(n, struct nf_conntrack_expect, hnode);
634660
661+ if (!net_eq(nf_ct_exp_net(expect), net))
662+ return 0;
663+
635664 if (expect->timeout.function)
636665 seq_printf(s, "%ld ", timer_pending(&expect->timeout)
637666 ? (long)(expect->timeout.expires - jiffies)/HZ : 0);
@@ -654,7 +683,7 @@ static int exp_seq_show(struct seq_file *s, void *v) · 16 unmodified lines
654683 if (expect->flags & NF_CT_EXPECT_USERSPACE)
655684 seq_printf(s, "%sUSERSPACE", delim);
656685
657− helper = rcu_dereference(nfct_help(expect->master)->helper);
686+ helper = rcu_dereference(expect->helper);
658687 if (helper) {
659688 seq_printf(s, "%s%s", expect->flags ? " " : "", helper->name);
660689 if (helper->expect_policy[expect->class].name[0])
net/netfilter/nf_conntrack_h323_main.c+6−6
@@ -643,7 +643,7 @@ static int expect_h245(struct sk_buff *skb, struct nf_conn *ct, · 642 unmodified lines
643643 &ct->tuplehash[!dir].tuple.src.u3,
644644 &ct->tuplehash[!dir].tuple.dst.u3,
645645 IPPROTO_TCP, NULL, &port);
646− exp->helper = &nf_conntrack_helper_h245;
646+ rcu_assign_pointer(exp->helper, &nf_conntrack_helper_h245);
647647
648648 nathook = rcu_dereference(nfct_h323_nat_hook);
649649 if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
@@ -767,7 +767,7 @@ static int expect_callforwarding(struct sk_buff *skb, · 117 unmodified lines
767767 nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
768768 &ct->tuplehash[!dir].tuple.src.u3, &addr,
769769 IPPROTO_TCP, NULL, &port);
770− exp->helper = nf_conntrack_helper_q931;
770+ rcu_assign_pointer(exp->helper, nf_conntrack_helper_q931);
771771
772772 nathook = rcu_dereference(nfct_h323_nat_hook);
773773 if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
@@ -1234,7 +1234,7 @@ static int expect_q931(struct sk_buff *skb, struct nf_conn *ct, · 460 unmodified lines
12341234 &ct->tuplehash[!dir].tuple.src.u3 : NULL,
12351235 &ct->tuplehash[!dir].tuple.dst.u3,
12361236 IPPROTO_TCP, NULL, &port);
1237− exp->helper = nf_conntrack_helper_q931;
1237+ rcu_assign_pointer(exp->helper, nf_conntrack_helper_q931);
12381238 exp->flags = NF_CT_EXPECT_PERMANENT; /* Accept multiple calls */
12391239
12401240 nathook = rcu_dereference(nfct_h323_nat_hook);
@@ -1306,7 +1306,7 @@ static int process_gcf(struct sk_buff *skb, struct nf_conn *ct, · 65 unmodified lines
13061306 nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
13071307 &ct->tuplehash[!dir].tuple.src.u3, &addr,
13081308 IPPROTO_UDP, NULL, &port);
1309− exp->helper = nf_conntrack_helper_ras;
1309+ rcu_assign_pointer(exp->helper, nf_conntrack_helper_ras);
13101310
13111311 if (nf_ct_expect_related(exp, 0) == 0) {
13121312 pr_debug("nf_ct_ras: expect RAS ");
@@ -1523,7 +1523,7 @@ static int process_acf(struct sk_buff *skb, struct nf_conn *ct, · 210 unmodified lines
15231523 &ct->tuplehash[!dir].tuple.src.u3, &addr,
15241524 IPPROTO_TCP, NULL, &port);
15251525 exp->flags = NF_CT_EXPECT_PERMANENT;
1526− exp->helper = nf_conntrack_helper_q931;
1526+ rcu_assign_pointer(exp->helper, nf_conntrack_helper_q931);
15271527
15281528 if (nf_ct_expect_related(exp, 0) == 0) {
15291529 pr_debug("nf_ct_ras: expect Q.931 ");
@@ -1577,7 +1577,7 @@ static int process_lcf(struct sk_buff *skb, struct nf_conn *ct, · 47 unmodified lines
15771577 &ct->tuplehash[!dir].tuple.src.u3, &addr,
15781578 IPPROTO_TCP, NULL, &port);
15791579 exp->flags = NF_CT_EXPECT_PERMANENT;
1580− exp->helper = nf_conntrack_helper_q931;
1580+ rcu_assign_pointer(exp->helper, nf_conntrack_helper_q931);
15811581
15821582 if (nf_ct_expect_related(exp, 0) == 0) {
15831583 pr_debug("nf_ct_ras: expect Q.931 ");
net/netfilter/nf_conntrack_helper.c+6−5
@@ -395,14 +395,10 @@ EXPORT_SYMBOL_GPL(nf_conntrack_helper_register); · 394 unmodified lines
395395
396396 static bool expect_iter_me(struct nf_conntrack_expect *exp, void *data)
397397 {
398− struct nf_conn_help *help = nfct_help(exp->master);
399398 const struct nf_conntrack_helper *me = data;
400399 const struct nf_conntrack_helper *this;
401400
402− if (exp->helper == me)
403− return true;
404−
405− this = rcu_dereference_protected(help->helper,
401+ this = rcu_dereference_protected(exp->helper,
406402 lockdep_is_held(&nf_conntrack_expect_lock));
407403 return this == me;
408404 }
@@ -421,6 +417,11 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me) · 12 unmodified lines
421417
422418 nf_ct_expect_iterate_destroy(expect_iter_me, NULL);
423419 nf_ct_iterate_destroy(unhelp, me);
420+
421+ /* nf_ct_iterate_destroy() does an unconditional synchronize_rcu() as
422+ * last step, this ensures rcu readers of exp->helper are done.
423+ * No need for another synchronize_rcu() here.
424+ */
424425 }
425426 EXPORT_SYMBOL_GPL(nf_conntrack_helper_unregister);
426427
net/netfilter/nf_conntrack_netlink.c+40−35
@@ -910,8 +910,8 @@ struct ctnetlink_filter { · 909 unmodified lines
910910 };
911911
912912 static const struct nla_policy cta_filter_nla_policy[CTA_FILTER_MAX + 1] = {
913− [CTA_FILTER_ORIG_FLAGS] = { .type = NLA_U32 },
914− [CTA_FILTER_REPLY_FLAGS] = { .type = NLA_U32 },
913+ [CTA_FILTER_ORIG_FLAGS] = NLA_POLICY_MASK(NLA_U32, CTA_FILTER_F_ALL),
914+ [CTA_FILTER_REPLY_FLAGS] = NLA_POLICY_MASK(NLA_U32, CTA_FILTER_F_ALL),
915915 };
916916
917917 static int ctnetlink_parse_filter(const struct nlattr *attr,
@@ -925,17 +925,11 @@ static int ctnetlink_parse_filter(const struct nlattr *attr, · 7 unmodified lines
925925 if (ret)
926926 return ret;
927927
928− if (tb[CTA_FILTER_ORIG_FLAGS]) {
928+ if (tb[CTA_FILTER_ORIG_FLAGS])
929929 filter->orig_flags = nla_get_u32(tb[CTA_FILTER_ORIG_FLAGS]);
930− if (filter->orig_flags & ~CTA_FILTER_F_ALL)
931− return -EOPNOTSUPP;
932− }
933930
934− if (tb[CTA_FILTER_REPLY_FLAGS]) {
931+ if (tb[CTA_FILTER_REPLY_FLAGS])
935932 filter->reply_flags = nla_get_u32(tb[CTA_FILTER_REPLY_FLAGS]);
936− if (filter->reply_flags & ~CTA_FILTER_F_ALL)
937− return -EOPNOTSUPP;
938− }
939933
940934 return 0;
941935 }
@@ -2634,7 +2628,7 @@ static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { · 1692 unmodified lines
26342628 [CTA_EXPECT_HELP_NAME] = { .type = NLA_NUL_STRING,
26352629 .len = NF_CT_HELPER_NAME_LEN - 1 },
26362630 [CTA_EXPECT_ZONE] = { .type = NLA_U16 },
2637− [CTA_EXPECT_FLAGS] = { .type = NLA_U32 },
2631+ [CTA_EXPECT_FLAGS] = NLA_POLICY_MASK(NLA_BE32, NF_CT_EXPECT_MASK),
26382632 [CTA_EXPECT_CLASS] = { .type = NLA_U32 },
26392633 [CTA_EXPECT_NAT] = { .type = NLA_NESTED },
26402634 [CTA_EXPECT_FN] = { .type = NLA_NUL_STRING },
@@ -3012,7 +3006,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, · 371 unmodified lines
30123006 {
30133007 struct nf_conn *master = exp->master;
30143008 long timeout = ((long)exp->timeout.expires - (long)jiffies) / HZ;
3015− struct nf_conn_help *help;
3009+ struct nf_conntrack_helper *helper;
30163010 #if IS_ENABLED(CONFIG_NF_NAT)
30173011 struct nlattr *nest_parms;
30183012 struct nf_conntrack_tuple nat_tuple = {};
@@ -3057,15 +3051,12 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, · 38 unmodified lines
30573051 nla_put_be32(skb, CTA_EXPECT_FLAGS, htonl(exp->flags)) ||
30583052 nla_put_be32(skb, CTA_EXPECT_CLASS, htonl(exp->class)))
30593053 goto nla_put_failure;
3060− help = nfct_help(master);
3061− if (help) {
3062− struct nf_conntrack_helper *helper;
30633054
3064− helper = rcu_dereference(help->helper);
3065− if (helper &&
3066− nla_put_string(skb, CTA_EXPECT_HELP_NAME, helper->name))
3067− goto nla_put_failure;
3068− }
3055+ helper = rcu_dereference(exp->helper);
3056+ if (helper &&
3057+ nla_put_string(skb, CTA_EXPECT_HELP_NAME, helper->name))
3058+ goto nla_put_failure;
3059+
30693060 expfn = nf_ct_helper_expectfn_find_by_symbol(exp->expectfn);
30703061 if (expfn != NULL &&
30713062 nla_put_string(skb, CTA_EXPECT_FN, expfn->name))
@@ -3358,31 +3349,37 @@ static int ctnetlink_get_expect(struct sk_buff *skb, · 286 unmodified lines
33583349 if (err < 0)
33593350 return err;
33603351
3352+ skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
3353+ if (!skb2)
3354+ return -ENOMEM;
3355+
3356+ spin_lock_bh(&nf_conntrack_expect_lock);
33613357 exp = nf_ct_expect_find_get(info->net, &zone, &tuple);
3362− if (!exp)
3358+ if (!exp) {
3359+ spin_unlock_bh(&nf_conntrack_expect_lock);
3360+ kfree_skb(skb2);
33633361 return -ENOENT;
3362+ }
33643363
33653364 if (cda[CTA_EXPECT_ID]) {
33663365 __be32 id = nla_get_be32(cda[CTA_EXPECT_ID]);
33673366
33683367 if (id != nf_expect_get_id(exp)) {
33693368 nf_ct_expect_put(exp);
3369+ spin_unlock_bh(&nf_conntrack_expect_lock);
3370+ kfree_skb(skb2);
33703371 return -ENOENT;
33713372 }
33723373 }
33733374
3374− skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
3375− if (!skb2) {
3376− nf_ct_expect_put(exp);
3377− return -ENOMEM;
3378− }
3379−
33803375 rcu_read_lock();
33813376 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).portid,
33823377 info->nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW,
33833378 exp);
33843379 rcu_read_unlock();
33853380 nf_ct_expect_put(exp);
3381+ spin_unlock_bh(&nf_conntrack_expect_lock);
3382+
33863383 if (err <= 0) {
33873384 kfree_skb(skb2);
33883385 return -ENOMEM;
@@ -3394,12 +3391,9 @@ static int ctnetlink_get_expect(struct sk_buff *skb, · 5 unmodified lines
33943391 static bool expect_iter_name(struct nf_conntrack_expect *exp, void *data)
33953392 {
33963393 struct nf_conntrack_helper *helper;
3397− const struct nf_conn_help *m_help;
33983394 const char *name = data;
33993395
3400− m_help = nfct_help(exp->master);
3401−
3402− helper = rcu_dereference(m_help->helper);
3396+ helper = rcu_dereference(exp->helper);
34033397 if (!helper)
34043398 return false;
34053399
@@ -3432,22 +3426,26 @@ static int ctnetlink_del_expect(struct sk_buff *skb, · 26 unmodified lines
34323426 if (err < 0)
34333427 return err;
34343428
3429+ spin_lock_bh(&nf_conntrack_expect_lock);
3430+
34353431 /* bump usage count to 2 */
34363432 exp = nf_ct_expect_find_get(info->net, &zone, &tuple);
3437− if (!exp)
3433+ if (!exp) {
3434+ spin_unlock_bh(&nf_conntrack_expect_lock);
34383435 return -ENOENT;
3436+ }
34393437
34403438 if (cda[CTA_EXPECT_ID]) {
34413439 __be32 id = nla_get_be32(cda[CTA_EXPECT_ID]);
34423440
34433441 if (id != nf_expect_get_id(exp)) {
34443442 nf_ct_expect_put(exp);
3443+ spin_unlock_bh(&nf_conntrack_expect_lock);
34453444 return -ENOENT;
34463445 }
34473446 }
34483447
34493448 /* after list removal, usage count == 1 */
3450− spin_lock_bh(&nf_conntrack_expect_lock);
34513449 if (timer_delete(&exp->timeout)) {
34523450 nf_ct_unlink_expect_report(exp, NETLINK_CB(skb).portid,
34533451 nlmsg_report(info->nlh));
@@ -3534,9 +3532,10 @@ ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct, · 80 unmodified lines
35343532 struct nf_conntrack_tuple *tuple,
35353533 struct nf_conntrack_tuple *mask)
35363534 {
3537− u_int32_t class = 0;
3535+ struct net *net = read_pnet(&ct->ct_net);
35383536 struct nf_conntrack_expect *exp;
35393537 struct nf_conn_help *help;
3538+ u32 class = 0;
35403539 int err;
35413540
35423541 help = nfct_help(ct);
@@ -3573,7 +3572,13 @@ ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct, · 30 unmodified lines
35733572
35743573 exp->class = class;
35753574 exp->master = ct;
3576− exp->helper = helper;
3575+ write_pnet(&exp->net, net);
3576+#ifdef CONFIG_NF_CONNTRACK_ZONES
3577+ exp->zone = ct->zone;
3578+#endif
3579+ if (!helper)
3580+ helper = rcu_dereference(help->helper);
3581+ rcu_assign_pointer(exp->helper, helper);
35773582 exp->tuple = *tuple;
35783583 exp->mask.src.u3 = mask->src.u3;
35793584 exp->mask.src.u.all = mask->src.u.all;
net/netfilter/nf_conntrack_proto_tcp.c+3−7
@@ -1385,9 +1385,9 @@ nla_put_failure: · 1384 unmodified lines
13851385 }
13861386
13871387 static const struct nla_policy tcp_nla_policy[CTA_PROTOINFO_TCP_MAX+1] = {
1388− [CTA_PROTOINFO_TCP_STATE] = { .type = NLA_U8 },
1389− [CTA_PROTOINFO_TCP_WSCALE_ORIGINAL] = { .type = NLA_U8 },
1390− [CTA_PROTOINFO_TCP_WSCALE_REPLY] = { .type = NLA_U8 },
1388+ [CTA_PROTOINFO_TCP_STATE] = NLA_POLICY_MAX(NLA_U8, TCP_CONNTRACK_SYN_SENT2),
1389+ [CTA_PROTOINFO_TCP_WSCALE_ORIGINAL] = NLA_POLICY_MAX(NLA_U8, TCP_MAX_WSCALE),
1390+ [CTA_PROTOINFO_TCP_WSCALE_REPLY] = NLA_POLICY_MAX(NLA_U8, TCP_MAX_WSCALE),
13911391 [CTA_PROTOINFO_TCP_FLAGS_ORIGINAL] = { .len = sizeof(struct nf_ct_tcp_flags) },
13921392 [CTA_PROTOINFO_TCP_FLAGS_REPLY] = { .len = sizeof(struct nf_ct_tcp_flags) },
13931393 };
@@ -1414,10 +1414,6 @@ static int nlattr_to_tcp(struct nlattr *cda[], struct nf_conn *ct) · 20 unmodified lines
14141414 if (err < 0)
14151415 return err;
14161416
1417− if (tb[CTA_PROTOINFO_TCP_STATE] &&
1418− nla_get_u8(tb[CTA_PROTOINFO_TCP_STATE]) >= TCP_CONNTRACK_MAX)
1419− return -EINVAL;
1420−
14211417 spin_lock_bh(&ct->lock);
14221418 if (tb[CTA_PROTOINFO_TCP_STATE])
14231419 ct->proto.tcp.state = nla_get_u8(tb[CTA_PROTOINFO_TCP_STATE]);
net/netfilter/nf_conntrack_sip.c+12−6
@@ -924,7 +924,7 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff, · 923 unmodified lines
924924 exp = __nf_ct_expect_find(net, nf_ct_zone(ct), &tuple);
925925
926926 if (!exp || exp->master == ct ||
927− nfct_help(exp->master)->helper != nfct_help(ct)->helper ||
927+ exp->helper != nfct_help(ct)->helper ||
928928 exp->class != class)
929929 break;
930930 #if IS_ENABLED(CONFIG_NF_NAT)
@@ -1040,6 +1040,7 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff, · 109 unmodified lines
10401040 unsigned int port;
10411041 const struct sdp_media_type *t;
10421042 int ret = NF_ACCEPT;
1043+ bool have_rtp_addr = false;
10431044
10441045 hooks = rcu_dereference(nf_nat_sip_hooks);
10451046
@@ -1056,8 +1057,11 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff, · 10 unmodified lines
10561057 caddr_len = 0;
10571058 if (ct_sip_parse_sdp_addr(ct, *dptr, sdpoff, *datalen,
10581059 SDP_HDR_CONNECTION, SDP_HDR_MEDIA,
1059− &matchoff, &matchlen, &caddr) > 0)
1060+ &matchoff, &matchlen, &caddr) > 0) {
10601061 caddr_len = matchlen;
1062+ memcpy(&rtp_addr, &caddr, sizeof(rtp_addr));
1063+ have_rtp_addr = true;
1064+ }
10611065
10621066 mediaoff = sdpoff;
10631067 for (i = 0; i < ARRAY_SIZE(sdp_media_types); ) {
@@ -1091,9 +1095,11 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff, · 27 unmodified lines
10911095 &matchoff, &matchlen, &maddr) > 0) {
10921096 maddr_len = matchlen;
10931097 memcpy(&rtp_addr, &maddr, sizeof(rtp_addr));
1094− } else if (caddr_len)
1098+ have_rtp_addr = true;
1099+ } else if (caddr_len) {
10951100 memcpy(&rtp_addr, &caddr, sizeof(rtp_addr));
1096− else {
1101+ have_rtp_addr = true;
1102+ } else {
10971103 nf_ct_helper_log(skb, ct, "cannot parse SDP message");
10981104 return NF_DROP;
10991105 }
@@ -1125,7 +1131,7 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff, · 25 unmodified lines
11251131
11261132 /* Update session connection and owner addresses */
11271133 hooks = rcu_dereference(nf_nat_sip_hooks);
1128− if (hooks && ct->status & IPS_NAT_MASK)
1134+ if (hooks && ct->status & IPS_NAT_MASK && have_rtp_addr)
11291135 ret = hooks->sdp_session(skb, protoff, dataoff,
11301136 dptr, datalen, sdpoff,
11311137 &rtp_addr);
@@ -1297,7 +1303,7 @@ static int process_register_request(struct sk_buff *skb, unsigned int protoff, · 165 unmodified lines
12971303 nf_ct_expect_init(exp, SIP_EXPECT_SIGNALLING, nf_ct_l3num(ct),
12981304 saddr, &daddr, proto, NULL, &port);
12991305 exp->timeout.expires = sip_timeout * HZ;
1300− exp->helper = helper;
1306+ rcu_assign_pointer(exp->helper, helper);
13011307 exp->flags = NF_CT_EXPECT_PERMANENT | NF_CT_EXPECT_INACTIVE;
13021308
13031309 hooks = rcu_dereference(nf_nat_sip_hooks);
net/netfilter/nfnetlink_log.c+2−6
@@ -647,15 +647,11 @@ __build_packet_message(struct nfnl_log_net *log, · 646 unmodified lines
647647
648648 if (data_len) {
649649 struct nlattr *nla;
650− int size = nla_attr_size(data_len);
651650
652− if (skb_tailroom(inst->skb) < nla_total_size(data_len))
651+ nla = nla_reserve(inst->skb, NFULA_PAYLOAD, data_len);
652+ if (!nla)
653653 goto nla_put_failure;
654654
655− nla = skb_put(inst->skb, nla_total_size(data_len));
656− nla->nla_type = NFULA_PAYLOAD;
657− nla->nla_len = size;
658−
659655 if (skb_copy_bits(skb, 0, nla_data(nla), data_len))
660656 BUG();
661657 }
net/netfilter/nft_set_pipapo_avx2.c+10−10
@@ -242,7 +242,7 @@ static int nft_pipapo_avx2_lookup_4b_2(unsigned long *map, unsigned long *fill, · 241 unmodified lines
242242
243243 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
244244 if (last)
245− return b;
245+ ret = b;
246246
247247 if (unlikely(ret == -1))
248248 ret = b / XSAVE_YMM_SIZE;
@@ -319,7 +319,7 @@ static int nft_pipapo_avx2_lookup_4b_4(unsigned long *map, unsigned long *fill, · 70 unmodified lines
319319
320320 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
321321 if (last)
322− return b;
322+ ret = b;
323323
324324 if (unlikely(ret == -1))
325325 ret = b / XSAVE_YMM_SIZE;
@@ -414,7 +414,7 @@ static int nft_pipapo_avx2_lookup_4b_8(unsigned long *map, unsigned long *fill, · 88 unmodified lines
414414
415415 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
416416 if (last)
417− return b;
417+ ret = b;
418418
419419 if (unlikely(ret == -1))
420420 ret = b / XSAVE_YMM_SIZE;
@@ -505,7 +505,7 @@ static int nft_pipapo_avx2_lookup_4b_12(unsigned long *map, unsigned long *fill, · 84 unmodified lines
505505
506506 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
507507 if (last)
508− return b;
508+ ret = b;
509509
510510 if (unlikely(ret == -1))
511511 ret = b / XSAVE_YMM_SIZE;
@@ -641,7 +641,7 @@ static int nft_pipapo_avx2_lookup_4b_32(unsigned long *map, unsigned long *fill, · 129 unmodified lines
641641
642642 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
643643 if (last)
644− return b;
644+ ret = b;
645645
646646 if (unlikely(ret == -1))
647647 ret = b / XSAVE_YMM_SIZE;
@@ -699,7 +699,7 @@ static int nft_pipapo_avx2_lookup_8b_1(unsigned long *map, unsigned long *fill, · 51 unmodified lines
699699
700700 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
701701 if (last)
702− return b;
702+ ret = b;
703703
704704 if (unlikely(ret == -1))
705705 ret = b / XSAVE_YMM_SIZE;
@@ -764,7 +764,7 @@ static int nft_pipapo_avx2_lookup_8b_2(unsigned long *map, unsigned long *fill, · 58 unmodified lines
764764
765765 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
766766 if (last)
767− return b;
767+ ret = b;
768768
769769 if (unlikely(ret == -1))
770770 ret = b / XSAVE_YMM_SIZE;
@@ -839,7 +839,7 @@ static int nft_pipapo_avx2_lookup_8b_4(unsigned long *map, unsigned long *fill, · 68 unmodified lines
839839
840840 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
841841 if (last)
842− return b;
842+ ret = b;
843843
844844 if (unlikely(ret == -1))
845845 ret = b / XSAVE_YMM_SIZE;
@@ -925,7 +925,7 @@ static int nft_pipapo_avx2_lookup_8b_6(unsigned long *map, unsigned long *fill, · 79 unmodified lines
925925
926926 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
927927 if (last)
928− return b;
928+ ret = b;
929929
930930 if (unlikely(ret == -1))
931931 ret = b / XSAVE_YMM_SIZE;
@@ -1019,7 +1019,7 @@ static int nft_pipapo_avx2_lookup_8b_16(unsigned long *map, unsigned long *fill, · 87 unmodified lines
10191019
10201020 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);
10211021 if (last)
1022− return b;
1022+ ret = b;
10231023
10241024 if (unlikely(ret == -1))
10251025 ret = b / XSAVE_YMM_SIZE;
net/netfilter/nft_set_rbtree.c+75−17
@@ -572,14 +572,12 @@ static struct nft_array *nft_array_alloc(u32 max_intervals) · 571 unmodified lines
572572 return array;
573573 }
574574
575−#define NFT_ARRAY_EXTRA_SIZE 10240
576−
577575 /* Similar to nft_rbtree_{u,k}size to hide details to userspace, but consider
578576 * packed representation coming from userspace for anonymous sets too.
579577 */
580578 static u32 nft_array_elems(const struct nft_set *set)
581579 {
582− u32 nelems = atomic_read(&set->nelems);
580+ u32 nelems = atomic_read(&set->nelems) - set->ndeact;
583581
584582 /* Adjacent intervals are represented with a single start element in
585583 * anonymous sets, use the current element counter as is.
@@ -595,27 +593,87 @@ static u32 nft_array_elems(const struct nft_set *set) · 9 unmodified lines
595593 return (nelems / 2) + 2;
596594 }
597595
598−static int nft_array_may_resize(const struct nft_set *set)
596+#define NFT_ARRAY_INITIAL_SIZE 1024
597+#define NFT_ARRAY_INITIAL_ANON_SIZE 16
598+#define NFT_ARRAY_INITIAL_ANON_THRESH (8192U / sizeof(struct nft_array_interval))
599+
600+static int nft_array_may_resize(const struct nft_set *set, bool flush)
599601 {
600− u32 nelems = nft_array_elems(set), new_max_intervals;
602+ u32 initial_intervals, max_intervals, new_max_intervals, delta;
603+ u32 shrinked_max_intervals, nelems = nft_array_elems(set);
601604 struct nft_rbtree *priv = nft_set_priv(set);
602605 struct nft_array *array;
603606
604− if (!priv->array_next) {
605− array = nft_array_alloc(nelems + NFT_ARRAY_EXTRA_SIZE);
606− if (!array)
607− return -ENOMEM;
607+ if (nft_set_is_anonymous(set))
608+ initial_intervals = NFT_ARRAY_INITIAL_ANON_SIZE;
609+ else
610+ initial_intervals = NFT_ARRAY_INITIAL_SIZE;
611+
612+ if (priv->array_next) {
613+ max_intervals = priv->array_next->max_intervals;
614+ new_max_intervals = priv->array_next->max_intervals;
615+ } else {
616+ if (priv->array) {
617+ max_intervals = priv->array->max_intervals;
618+ new_max_intervals = priv->array->max_intervals;
619+ } else {
620+ max_intervals = 0;
621+ new_max_intervals = initial_intervals;
622+ }
623+ }
608624
609− priv->array_next = array;
625+ if (nft_set_is_anonymous(set))
626+ goto maybe_grow;
627+
628+ if (flush) {
629+ /* Set flush just started, nelems still report elements.*/
630+ nelems = 0;
631+ new_max_intervals = NFT_ARRAY_INITIAL_SIZE;
632+ goto realloc_array;
610633 }
611634
612− if (nelems < priv->array_next->max_intervals)
613− return 0;
635+ if (check_add_overflow(new_max_intervals, new_max_intervals,
636+ &shrinked_max_intervals))
637+ return -EOVERFLOW;
638+
639+ shrinked_max_intervals = DIV_ROUND_UP(shrinked_max_intervals, 3);
614640
615− new_max_intervals = priv->array_next->max_intervals + NFT_ARRAY_EXTRA_SIZE;
616− if (nft_array_intervals_alloc(priv->array_next, new_max_intervals) < 0)
641+ if (shrinked_max_intervals > NFT_ARRAY_INITIAL_SIZE &&
642+ nelems < shrinked_max_intervals) {
643+ new_max_intervals = shrinked_max_intervals;
644+ goto realloc_array;
645+ }
646+maybe_grow:
647+ if (nelems > new_max_intervals) {
648+ if (nft_set_is_anonymous(set) &&
649+ new_max_intervals < NFT_ARRAY_INITIAL_ANON_THRESH) {
650+ new_max_intervals <<= 1;
651+ } else {
652+ delta = new_max_intervals >> 1;
653+ if (check_add_overflow(new_max_intervals, delta,
654+ &new_max_intervals))
655+ return -EOVERFLOW;
656+ }
657+ }
658+
659+realloc_array:
660+ if (WARN_ON_ONCE(nelems > new_max_intervals))
617661 return -ENOMEM;
618662
663+ if (priv->array_next) {
664+ if (max_intervals == new_max_intervals)
665+ return 0;
666+
667+ if (nft_array_intervals_alloc(priv->array_next, new_max_intervals) < 0)
668+ return -ENOMEM;
669+ } else {
670+ array = nft_array_alloc(new_max_intervals);
671+ if (!array)
672+ return -ENOMEM;
673+
674+ priv->array_next = array;
675+ }
676+
619677 return 0;
620678 }
621679
@@ -630,7 +688,7 @@ static int nft_rbtree_insert(const struct net *net, const struct nft_set *set, · 8 unmodified lines
630688
631689 nft_rbtree_maybe_reset_start_cookie(priv, tstamp);
632690
633− if (nft_array_may_resize(set) < 0)
691+ if (nft_array_may_resize(set, false) < 0)
634692 return -ENOMEM;
635693
636694 do {
@@ -741,7 +799,7 @@ nft_rbtree_deactivate(const struct net *net, const struct nft_set *set, · 104 unmodified lines
741799 nft_rbtree_interval_null(set, this))
742800 priv->start_rbe_cookie = 0;
743801
744− if (nft_array_may_resize(set) < 0)
802+ if (nft_array_may_resize(set, false) < 0)
745803 return NULL;
746804
747805 while (parent != NULL) {
@@ -811,7 +869,7 @@ static void nft_rbtree_walk(const struct nft_ctx *ctx, · 63 unmodified lines
811869
812870 switch (iter->type) {
813871 case NFT_ITER_UPDATE_CLONE:
814− if (nft_array_may_resize(set) < 0) {
872+ if (nft_array_may_resize(set, true) < 0) {
815873 iter->err = -ENOMEM;
816874 break;
817875 }
net/nfc/nci/core.c+6−4
@@ -579,8 +579,7 @@ static int nci_close_device(struct nci_dev *ndev) · 578 unmodified lines
579579 skb_queue_purge(&ndev->rx_q);
580580 skb_queue_purge(&ndev->tx_q);
581581
582− /* Flush RX and TX wq */
583− flush_workqueue(ndev->rx_wq);
582+ /* Flush TX wq, RX wq flush can't be under the lock */
584583 flush_workqueue(ndev->tx_wq);
585584
586585 /* Reset device */
@@ -592,13 +591,13 @@ static int nci_close_device(struct nci_dev *ndev) · 5 unmodified lines
592591 msecs_to_jiffies(NCI_RESET_TIMEOUT));
593592
594593 /* After this point our queues are empty
595− * and no works are scheduled.
594+ * rx work may be running but will see that NCI_UP was cleared
596595 */
597596 ndev->ops->close(ndev);
598597
599598 clear_bit(NCI_INIT, &ndev->flags);
600599
601− /* Flush cmd wq */
600+ /* Flush cmd and tx wq */
602601 flush_workqueue(ndev->cmd_wq);
603602
604603 timer_delete_sync(&ndev->cmd_timer);
@@ -613,6 +612,9 @@ static int nci_close_device(struct nci_dev *ndev) · 8 unmodified lines
613612
614613 mutex_unlock(&ndev->req_lock);
615614
615+ /* rx_work may take req_lock via nci_deactivate_target */
616+ flush_workqueue(ndev->rx_wq);
617+
616618 return 0;
617619 }
618620
net/openvswitch/flow_netlink.c+2−0
@@ -2953,6 +2953,8 @@ static int validate_set(const struct nlattr *a, · 2952 unmodified lines
29532953 case OVS_KEY_ATTR_MPLS:
29542954 if (!eth_p_mpls(eth_type))
29552955 return -EINVAL;
2956+ if (key_len != sizeof(struct ovs_key_mpls))
2957+ return -EINVAL;
29562958 break;
29572959
29582960 case OVS_KEY_ATTR_SCTP:
net/openvswitch/vport-netdev.c+8−3
@@ -151,11 +151,15 @@ static void vport_netdev_free(struct rcu_head *rcu) · 150 unmodified lines
151151 void ovs_netdev_detach_dev(struct vport *vport)
152152 {
153153 ASSERT_RTNL();
154− vport->dev->priv_flags &= ~IFF_OVS_DATAPATH;
155154 netdev_rx_handler_unregister(vport->dev);
156155 netdev_upper_dev_unlink(vport->dev,
157156 netdev_master_upper_dev_get(vport->dev));
158157 dev_set_promiscuity(vport->dev, -1);
158+
159+ /* paired with smp_mb() in netdev_destroy() */
160+ smp_wmb();
161+
162+ vport->dev->priv_flags &= ~IFF_OVS_DATAPATH;
159163 }
160164
161165 static void netdev_destroy(struct vport *vport)
@@ -174,6 +178,9 @@ static void netdev_destroy(struct vport *vport) · 12 unmodified lines
174178 rtnl_unlock();
175179 }
176180
181+ /* paired with smp_wmb() in ovs_netdev_detach_dev() */
182+ smp_mb();
183+
177184 call_rcu(&vport->rcu, vport_netdev_free);
178185 }
179186
@@ -189,8 +196,6 @@ void ovs_netdev_tunnel_destroy(struct vport *vport) · 9 unmodified lines
189196 */
190197 if (vport->dev->reg_state == NETREG_REGISTERED)
191198 rtnl_delete_link(vport->dev, 0, NULL);
192− netdev_put(vport->dev, &vport->dev_tracker);
193− vport->dev = NULL;
194199 rtnl_unlock();
195200
196201 call_rcu(&vport->rcu, vport_netdev_free);
net/packet/af_packet.c+1−0
@@ -3135,6 +3135,7 @@ static int packet_release(struct socket *sock) · 3134 unmodified lines
31353135
31363136 spin_lock(&po->bind_lock);
31373137 unregister_prot_hook(sk, false);
3138+ WRITE_ONCE(po->num, 0);
31383139 packet_cached_dev_reset(po);
31393140
31403141 if (po->prot_hook.dev) {
net/smc/smc_rx.c+8−1
@@ -135,9 +135,16 @@ out: · 134 unmodified lines
135135 sock_put(sk);
136136 }
137137
138+static bool smc_rx_pipe_buf_get(struct pipe_inode_info *pipe,
139+ struct pipe_buffer *buf)
140+{
141+ /* smc_spd_priv in buf->private is not shareable; disallow cloning. */
142+ return false;
143+}
144+
138145 static const struct pipe_buf_operations smc_pipe_ops = {
139146 .release = smc_rx_pipe_buf_release,
140− .get = generic_pipe_buf_get
147+ .get = smc_rx_pipe_buf_get,
141148 };
142149
143150 static void smc_rx_spd_release(struct splice_pipe_desc *spd,
net/tls/tls_sw.c+1−1
@@ -246,6 +246,7 @@ static int tls_decrypt_async_wait(struct tls_sw_context_rx *ctx) · 245 unmodified lines
246246 crypto_wait_req(-EINPROGRESS, &ctx->async_wait);
247247 atomic_inc(&ctx->decrypt_pending);
248248
249+ __skb_queue_purge(&ctx->async_hold);
249250 return ctx->async_wait.err;
250251 }
251252
@@ -2225,7 +2226,6 @@ recv_end: · 1973 unmodified lines
22252226
22262227 /* Wait for all previously submitted records to be decrypted */
22272228 ret = tls_decrypt_async_wait(ctx);
2228− __skb_queue_purge(&ctx->async_hold);
22292229
22302230 if (ret) {
22312231 if (err >= 0 || err == -EINPROGRESS)
net/xfrm/xfrm_input.c+4−1
@@ -75,7 +75,10 @@ int xfrm_input_unregister_afinfo(const struct xfrm_input_afinfo *afinfo) · 74 unmodified lines
7575
7676 spin_lock_bh(&xfrm_input_afinfo_lock);
7777 if (likely(xfrm_input_afinfo[afinfo->is_ipip][afinfo->family])) {
78− if (unlikely(xfrm_input_afinfo[afinfo->is_ipip][afinfo->family] != afinfo))
78+ const struct xfrm_input_afinfo *cur;
79+
80+ cur = rcu_access_pointer(xfrm_input_afinfo[afinfo->is_ipip][afinfo->family]);
81+ if (unlikely(cur != afinfo))
7982 err = -EINVAL;
8083 else
8184 RCU_INIT_POINTER(xfrm_input_afinfo[afinfo->is_ipip][afinfo->family], NULL);
net/xfrm/xfrm_iptfs.c+14−3
@@ -901,6 +901,12 @@ static u32 iptfs_reassem_cont(struct xfrm_iptfs_data *xtfs, u64 seq, · 900 unmodified lines
901901 iptfs_skb_can_add_frags(newskb, fragwalk, data, copylen)) {
902902 iptfs_skb_add_frags(newskb, fragwalk, data, copylen);
903903 } else {
904+ if (skb_linearize(newskb)) {
905+ XFRM_INC_STATS(xs_net(xtfs->x),
906+ LINUX_MIB_XFRMINBUFFERERROR);
907+ goto abandon;
908+ }
909+
904910 /* copy fragment data into newskb */
905911 if (skb_copy_seq_read(st, data, skb_put(newskb, copylen),
906912 copylen)) {
@@ -991,6 +997,11 @@ static bool __input_process_payload(struct xfrm_state *x, u32 data, · 84 unmodified lines
991997
992998 iplen = be16_to_cpu(iph->tot_len);
993999 iphlen = iph->ihl << 2;
1000+ if (iplen < iphlen || iphlen < sizeof(*iph)) {
1001+ XFRM_INC_STATS(net,
1002+ LINUX_MIB_XFRMINHDRERROR);
1003+ goto done;
1004+ }
9941005 protocol = cpu_to_be16(ETH_P_IP);
9951006 XFRM_MODE_SKB_CB(skbseq->root_skb)->tos = iph->tos;
9961007 } else if (iph->version == 0x6) {
@@ -2653,9 +2664,6 @@ static int iptfs_clone_state(struct xfrm_state *x, struct xfrm_state *orig) · 1656 unmodified lines
26532664 if (!xtfs)
26542665 return -ENOMEM;
26552666
2656− x->mode_data = xtfs;
2657− xtfs->x = x;
2658−
26592667 xtfs->ra_newskb = NULL;
26602668 if (xtfs->cfg.reorder_win_size) {
26612669 xtfs->w_saved = kzalloc_objs(*xtfs->w_saved,
@@ -2666,6 +2674,9 @@ static int iptfs_clone_state(struct xfrm_state *x, struct xfrm_state *orig) · 4 unmodified lines
26662674 }
26672675 }
26682676
2677+ x->mode_data = xtfs;
2678+ xtfs->x = x;
2679+
26692680 return 0;
26702681 }
26712682
net/xfrm/xfrm_nat_keepalive.c+1−1
@@ -261,7 +261,7 @@ int __net_init xfrm_nat_keepalive_net_init(struct net *net) · 260 unmodified lines
261261
262262 int xfrm_nat_keepalive_net_fini(struct net *net)
263263 {
264− cancel_delayed_work_sync(&net->xfrm.nat_keepalive_work);
264+ disable_delayed_work_sync(&net->xfrm.nat_keepalive_work);
265265 return 0;
266266 }
267267
net/xfrm/xfrm_policy.c+7−5
@@ -4156,7 +4156,7 @@ void xfrm_policy_unregister_afinfo(const struct xfrm_policy_afinfo *afinfo) · 4155 unmodified lines
41564156 int i;
41574157
41584158 for (i = 0; i < ARRAY_SIZE(xfrm_policy_afinfo); i++) {
4159− if (xfrm_policy_afinfo[i] != afinfo)
4159+ if (rcu_access_pointer(xfrm_policy_afinfo[i]) != afinfo)
41604160 continue;
41614161 RCU_INIT_POINTER(xfrm_policy_afinfo[i], NULL);
41624162 break;
@@ -4242,7 +4242,7 @@ static int __net_init xfrm_policy_init(struct net *net) · 79 unmodified lines
42424242 net->xfrm.policy_count[XFRM_POLICY_MAX + dir] = 0;
42434243
42444244 htab = &net->xfrm.policy_bydst[dir];
4245− htab->table = xfrm_hash_alloc(sz);
4245+ rcu_assign_pointer(htab->table, xfrm_hash_alloc(sz));
42464246 if (!htab->table)
42474247 goto out_bydst;
42484248 htab->hmask = hmask;
@@ -4269,7 +4269,7 @@ out_bydst: · 20 unmodified lines
42694269 struct xfrm_policy_hash *htab;
42704270
42714271 htab = &net->xfrm.policy_bydst[dir];
4272− xfrm_hash_free(htab->table, sz);
4272+ xfrm_hash_free(rcu_dereference_protected(htab->table, true), sz);
42734273 }
42744274 xfrm_hash_free(net->xfrm.policy_byidx, sz);
42754275 out_byidx:
@@ -4282,6 +4282,8 @@ static void xfrm_policy_fini(struct net *net) · 6 unmodified lines
42824282 unsigned int sz;
42834283 int dir;
42844284
4285+ disable_work_sync(&net->xfrm.policy_hthresh.work);
4286+
42854287 flush_work(&net->xfrm.policy_hash_work);
42864288 #ifdef CONFIG_XFRM_SUB_POLICY
42874289 xfrm_policy_flush(net, XFRM_POLICY_TYPE_SUB, false);
@@ -4295,8 +4297,8 @@ static void xfrm_policy_fini(struct net *net) · 7 unmodified lines
42954297
42964298 htab = &net->xfrm.policy_bydst[dir];
42974299 sz = (htab->hmask + 1) * sizeof(struct hlist_head);
4298− WARN_ON(!hlist_empty(htab->table));
4299− xfrm_hash_free(htab->table, sz);
4300+ WARN_ON(!hlist_empty(rcu_dereference_protected(htab->table, true)));
4301+ xfrm_hash_free(rcu_dereference_protected(htab->table, true), sz);
43004302 }
43014303
43024304 sz = (net->xfrm.policy_idx_hmask + 1) * sizeof(struct hlist_head);
net/xfrm/xfrm_state.c+64−52
@@ -53,7 +53,7 @@ static DECLARE_WORK(xfrm_state_gc_work, xfrm_state_gc_task); · 52 unmodified lines
5353 static HLIST_HEAD(xfrm_state_gc_list);
5454 static HLIST_HEAD(xfrm_state_dev_gc_list);
5555
56−static inline bool xfrm_state_hold_rcu(struct xfrm_state __rcu *x)
56+static inline bool xfrm_state_hold_rcu(struct xfrm_state *x)
5757 {
5858 return refcount_inc_not_zero(&x->refcnt);
5959 }
@@ -870,7 +870,7 @@ xfrm_state_flush_secctx_check(struct net *net, u8 proto, bool task_valid) · 810 unmodified lines
870870 for (i = 0; i <= net->xfrm.state_hmask; i++) {
871871 struct xfrm_state *x;
872872
873− hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
873+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst) {
874874 if (xfrm_id_proto_match(x->id.proto, proto) &&
875875 (err = security_xfrm_state_delete(x)) != 0) {
876876 xfrm_audit_state_delete(x, 0, task_valid);
@@ -891,7 +891,7 @@ xfrm_dev_state_flush_secctx_check(struct net *net, struct net_device *dev, bool · 14 unmodified lines
891891 struct xfrm_state *x;
892892 struct xfrm_dev_offload *xso;
893893
894− hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
894+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst) {
895895 xso = &x->xso;
896896
897897 if (xso->dev == dev &&
@@ -931,7 +931,7 @@ int xfrm_state_flush(struct net *net, u8 proto, bool task_valid) · 33 unmodified lines
931931 for (i = 0; i <= net->xfrm.state_hmask; i++) {
932932 struct xfrm_state *x;
933933 restart:
934− hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
934+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst) {
935935 if (!xfrm_state_kern(x) &&
936936 xfrm_id_proto_match(x->id.proto, proto)) {
937937 xfrm_state_hold(x);
@@ -973,7 +973,7 @@ int xfrm_dev_state_flush(struct net *net, struct net_device *dev, bool task_vali · 35 unmodified lines
973973 err = -ESRCH;
974974 for (i = 0; i <= net->xfrm.state_hmask; i++) {
975975 restart:
976− hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
976+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst) {
977977 xso = &x->xso;
978978
979979 if (!xfrm_state_kern(x) && xso->dev == dev) {
@@ -1563,23 +1563,23 @@ found: · 583 unmodified lines
15631563 list_add(&x->km.all, &net->xfrm.state_all);
15641564 h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family);
15651565 XFRM_STATE_INSERT(bydst, &x->bydst,
1566− net->xfrm.state_bydst + h,
1566+ xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h,
15671567 x->xso.type);
15681568 h = xfrm_src_hash(net, daddr, saddr, encap_family);
15691569 XFRM_STATE_INSERT(bysrc, &x->bysrc,
1570− net->xfrm.state_bysrc + h,
1570+ xfrm_state_deref_prot(net->xfrm.state_bysrc, net) + h,
15711571 x->xso.type);
15721572 INIT_HLIST_NODE(&x->state_cache);
15731573 if (x->id.spi) {
15741574 h = xfrm_spi_hash(net, &x->id.daddr, x->id.spi, x->id.proto, encap_family);
15751575 XFRM_STATE_INSERT(byspi, &x->byspi,
1576− net->xfrm.state_byspi + h,
1576+ xfrm_state_deref_prot(net->xfrm.state_byspi, net) + h,
15771577 x->xso.type);
15781578 }
15791579 if (x->km.seq) {
15801580 h = xfrm_seq_hash(net, x->km.seq);
15811581 XFRM_STATE_INSERT(byseq, &x->byseq,
1582− net->xfrm.state_byseq + h,
1582+ xfrm_state_deref_prot(net->xfrm.state_byseq, net) + h,
15831583 x->xso.type);
15841584 }
15851585 x->lft.hard_add_expires_seconds = net->xfrm.sysctl_acq_expires;
@@ -1652,7 +1652,7 @@ xfrm_stateonly_find(struct net *net, u32 mark, u32 if_id, · 66 unmodified lines
16521652
16531653 spin_lock_bh(&net->xfrm.xfrm_state_lock);
16541654 h = xfrm_dst_hash(net, daddr, saddr, reqid, family);
1655− hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
1655+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h, bydst) {
16561656 if (x->props.family == family &&
16571657 x->props.reqid == reqid &&
16581658 (mark & x->mark.m) == x->mark.v &&
@@ -1703,18 +1703,12 @@ static struct xfrm_state *xfrm_state_lookup_spi_proto(struct net *net, __be32 sp · 44 unmodified lines
17031703 struct xfrm_state *x;
17041704 unsigned int i;
17051705
1706− rcu_read_lock();
17071706 for (i = 0; i <= net->xfrm.state_hmask; i++) {
1708− hlist_for_each_entry_rcu(x, &net->xfrm.state_byspi[i], byspi) {
1709− if (x->id.spi == spi && x->id.proto == proto) {
1710− if (!xfrm_state_hold_rcu(x))
1711− continue;
1712− rcu_read_unlock();
1707+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_byspi, net) + i, byspi) {
1708+ if (x->id.spi == spi && x->id.proto == proto)
17131709 return x;
1714− }
17151710 }
17161711 }
1717− rcu_read_unlock();
17181712 return NULL;
17191713 }
17201714
@@ -1730,25 +1724,29 @@ static void __xfrm_state_insert(struct xfrm_state *x) · 9 unmodified lines
17301724
17311725 h = xfrm_dst_hash(net, &x->id.daddr, &x->props.saddr,
17321726 x->props.reqid, x->props.family);
1733− XFRM_STATE_INSERT(bydst, &x->bydst, net->xfrm.state_bydst + h,
1727+ XFRM_STATE_INSERT(bydst, &x->bydst,
1728+ xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h,
17341729 x->xso.type);
17351730
17361731 h = xfrm_src_hash(net, &x->id.daddr, &x->props.saddr, x->props.family);
1737− XFRM_STATE_INSERT(bysrc, &x->bysrc, net->xfrm.state_bysrc + h,
1732+ XFRM_STATE_INSERT(bysrc, &x->bysrc,
1733+ xfrm_state_deref_prot(net->xfrm.state_bysrc, net) + h,
17381734 x->xso.type);
17391735
17401736 if (x->id.spi) {
17411737 h = xfrm_spi_hash(net, &x->id.daddr, x->id.spi, x->id.proto,
17421738 x->props.family);
17431739
1744− XFRM_STATE_INSERT(byspi, &x->byspi, net->xfrm.state_byspi + h,
1740+ XFRM_STATE_INSERT(byspi, &x->byspi,
1741+ xfrm_state_deref_prot(net->xfrm.state_byspi, net) + h,
17451742 x->xso.type);
17461743 }
17471744
17481745 if (x->km.seq) {
17491746 h = xfrm_seq_hash(net, x->km.seq);
17501747
1751− XFRM_STATE_INSERT(byseq, &x->byseq, net->xfrm.state_byseq + h,
1748+ XFRM_STATE_INSERT(byseq, &x->byseq,
1749+ xfrm_state_deref_prot(net->xfrm.state_byseq, net) + h,
17521750 x->xso.type);
17531751 }
17541752
@@ -1775,7 +1773,7 @@ static void __xfrm_state_bump_genids(struct xfrm_state *xnew) · 20 unmodified lines
17751773 u32 cpu_id = xnew->pcpu_num;
17761774
17771775 h = xfrm_dst_hash(net, &xnew->id.daddr, &xnew->props.saddr, reqid, family);
1778− hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
1776+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h, bydst) {
17791777 if (x->props.family == family &&
17801778 x->props.reqid == reqid &&
17811779 x->if_id == if_id &&
@@ -1811,7 +1809,7 @@ static struct xfrm_state *__find_acq_core(struct net *net, · 29 unmodified lines
18111809 struct xfrm_state *x;
18121810 u32 mark = m->v & m->m;
18131811
1814− hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
1812+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h, bydst) {
18151813 if (x->props.reqid != reqid ||
18161814 x->props.mode != mode ||
18171815 x->props.family != family ||
@@ -1868,10 +1866,12 @@ static struct xfrm_state *__find_acq_core(struct net *net, · 50 unmodified lines
18681866 ktime_set(net->xfrm.sysctl_acq_expires, 0),
18691867 HRTIMER_MODE_REL_SOFT);
18701868 list_add(&x->km.all, &net->xfrm.state_all);
1871− XFRM_STATE_INSERT(bydst, &x->bydst, net->xfrm.state_bydst + h,
1869+ XFRM_STATE_INSERT(bydst, &x->bydst,
1870+ xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h,
18721871 x->xso.type);
18731872 h = xfrm_src_hash(net, daddr, saddr, family);
1874− XFRM_STATE_INSERT(bysrc, &x->bysrc, net->xfrm.state_bysrc + h,
1873+ XFRM_STATE_INSERT(bysrc, &x->bysrc,
1874+ xfrm_state_deref_prot(net->xfrm.state_bysrc, net) + h,
18751875 x->xso.type);
18761876
18771877 net->xfrm.state_num++;
@@ -2091,7 +2091,7 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n · 213 unmodified lines
20912091 if (m->reqid) {
20922092 h = xfrm_dst_hash(net, &m->old_daddr, &m->old_saddr,
20932093 m->reqid, m->old_family);
2094− hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
2094+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h, bydst) {
20952095 if (x->props.mode != m->mode ||
20962096 x->id.proto != m->proto)
20972097 continue;
@@ -2110,7 +2110,7 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n · 12 unmodified lines
21102110 } else {
21112111 h = xfrm_src_hash(net, &m->old_daddr, &m->old_saddr,
21122112 m->old_family);
2113− hlist_for_each_entry(x, net->xfrm.state_bysrc+h, bysrc) {
2113+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bysrc, net) + h, bysrc) {
21142114 if (x->props.mode != m->mode ||
21152115 x->id.proto != m->proto)
21162116 continue;
@@ -2264,6 +2264,7 @@ out: · 147 unmodified lines
22642264
22652265 err = 0;
22662266 x->km.state = XFRM_STATE_DEAD;
2267+ xfrm_dev_state_delete(x);
22672268 __xfrm_state_put(x);
22682269 }
22692270
@@ -2312,7 +2313,7 @@ void xfrm_state_update_stats(struct net *net) · 42 unmodified lines
23122313
23132314 spin_lock_bh(&net->xfrm.xfrm_state_lock);
23142315 for (i = 0; i <= net->xfrm.state_hmask; i++) {
2315− hlist_for_each_entry(x, net->xfrm.state_bydst + i, bydst)
2316+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst)
23162317 xfrm_dev_state_update_stats(x);
23172318 }
23182319 spin_unlock_bh(&net->xfrm.xfrm_state_lock);
@@ -2503,7 +2504,7 @@ static struct xfrm_state *__xfrm_find_acq_byseq(struct net *net, u32 mark, u32 s · 184 unmodified lines
25032504 unsigned int h = xfrm_seq_hash(net, seq);
25042505 struct xfrm_state *x;
25052506
2506− hlist_for_each_entry_rcu(x, net->xfrm.state_byseq + h, byseq) {
2507+ hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_byseq, net) + h, byseq) {
25072508 if (x->km.seq == seq &&
25082509 (mark & x->mark.m) == x->mark.v &&
25092510 x->pcpu_num == pcpu_num &&
@@ -2602,12 +2603,13 @@ int xfrm_alloc_spi(struct xfrm_state *x, u32 low, u32 high, · 92 unmodified lines
26022603 if (!x0) {
26032604 x->id.spi = newspi;
26042605 h = xfrm_spi_hash(net, &x->id.daddr, newspi, x->id.proto, x->props.family);
2605− XFRM_STATE_INSERT(byspi, &x->byspi, net->xfrm.state_byspi + h, x->xso.type);
2606+ XFRM_STATE_INSERT(byspi, &x->byspi,
2607+ xfrm_state_deref_prot(net->xfrm.state_byspi, net) + h,
2608+ x->xso.type);
26062609 spin_unlock_bh(&net->xfrm.xfrm_state_lock);
26072610 err = 0;
26082611 goto unlock;
26092612 }
2610− xfrm_state_put(x0);
26112613 spin_unlock_bh(&net->xfrm.xfrm_state_lock);
26122614
26132615 next:
@@ -3258,6 +3260,7 @@ EXPORT_SYMBOL(xfrm_init_state); · 644 unmodified lines
32583260
32593261 int __net_init xfrm_state_init(struct net *net)
32603262 {
3263+ struct hlist_head *ndst, *nsrc, *nspi, *nseq;
32613264 unsigned int sz;
32623265
32633266 if (net_eq(net, &init_net))
@@ -3268,18 +3271,25 @@ int __net_init xfrm_state_init(struct net *net) · 4 unmodified lines
32683271
32693272 sz = sizeof(struct hlist_head) * 8;
32703273
3271− net->xfrm.state_bydst = xfrm_hash_alloc(sz);
3272− if (!net->xfrm.state_bydst)
3274+ ndst = xfrm_hash_alloc(sz);
3275+ if (!ndst)
32733276 goto out_bydst;
3274− net->xfrm.state_bysrc = xfrm_hash_alloc(sz);
3275− if (!net->xfrm.state_bysrc)
3277+ rcu_assign_pointer(net->xfrm.state_bydst, ndst);
3278+
3279+ nsrc = xfrm_hash_alloc(sz);
3280+ if (!nsrc)
32763281 goto out_bysrc;
3277− net->xfrm.state_byspi = xfrm_hash_alloc(sz);
3278− if (!net->xfrm.state_byspi)
3282+ rcu_assign_pointer(net->xfrm.state_bysrc, nsrc);
3283+
3284+ nspi = xfrm_hash_alloc(sz);
3285+ if (!nspi)
32793286 goto out_byspi;
3280− net->xfrm.state_byseq = xfrm_hash_alloc(sz);
3281− if (!net->xfrm.state_byseq)
3287+ rcu_assign_pointer(net->xfrm.state_byspi, nspi);
3288+
3289+ nseq = xfrm_hash_alloc(sz);
3290+ if (!nseq)
32823291 goto out_byseq;
3292+ rcu_assign_pointer(net->xfrm.state_byseq, nseq);
32833293
32843294 net->xfrm.state_cache_input = alloc_percpu(struct hlist_head);
32853295 if (!net->xfrm.state_cache_input)
@@ -3295,17 +3305,19 @@ int __net_init xfrm_state_init(struct net *net) · 9 unmodified lines
32953305 return 0;
32963306
32973307 out_state_cache_input:
3298− xfrm_hash_free(net->xfrm.state_byseq, sz);
3308+ xfrm_hash_free(nseq, sz);
32993309 out_byseq:
3300− xfrm_hash_free(net->xfrm.state_byspi, sz);
3310+ xfrm_hash_free(nspi, sz);
33013311 out_byspi:
3302− xfrm_hash_free(net->xfrm.state_bysrc, sz);
3312+ xfrm_hash_free(nsrc, sz);
33033313 out_bysrc:
3304− xfrm_hash_free(net->xfrm.state_bydst, sz);
3314+ xfrm_hash_free(ndst, sz);
33053315 out_bydst:
33063316 return -ENOMEM;
33073317 }
33083318
3319+#define xfrm_state_deref_netexit(table) \
3320+ rcu_dereference_protected((table), true /* netns is going away */)
33093321 void xfrm_state_fini(struct net *net)
33103322 {
33113323 unsigned int sz;
@@ -3318,17 +3330,17 @@ void xfrm_state_fini(struct net *net) · 6 unmodified lines
33183330 WARN_ON(!list_empty(&net->xfrm.state_all));
33193331
33203332 for (i = 0; i <= net->xfrm.state_hmask; i++) {
3321− WARN_ON(!hlist_empty(net->xfrm.state_byseq + i));
3322− WARN_ON(!hlist_empty(net->xfrm.state_byspi + i));
3323− WARN_ON(!hlist_empty(net->xfrm.state_bysrc + i));
3324− WARN_ON(!hlist_empty(net->xfrm.state_bydst + i));
3333+ WARN_ON(!hlist_empty(xfrm_state_deref_netexit(net->xfrm.state_byseq) + i));
3334+ WARN_ON(!hlist_empty(xfrm_state_deref_netexit(net->xfrm.state_byspi) + i));
3335+ WARN_ON(!hlist_empty(xfrm_state_deref_netexit(net->xfrm.state_bysrc) + i));
3336+ WARN_ON(!hlist_empty(xfrm_state_deref_netexit(net->xfrm.state_bydst) + i));
33253337 }
33263338
33273339 sz = (net->xfrm.state_hmask + 1) * sizeof(struct hlist_head);
3328− xfrm_hash_free(net->xfrm.state_byseq, sz);
3329− xfrm_hash_free(net->xfrm.state_byspi, sz);
3330− xfrm_hash_free(net->xfrm.state_bysrc, sz);
3331− xfrm_hash_free(net->xfrm.state_bydst, sz);
3340+ xfrm_hash_free(xfrm_state_deref_netexit(net->xfrm.state_byseq), sz);
3341+ xfrm_hash_free(xfrm_state_deref_netexit(net->xfrm.state_byspi), sz);
3342+ xfrm_hash_free(xfrm_state_deref_netexit(net->xfrm.state_bysrc), sz);
3343+ xfrm_hash_free(xfrm_state_deref_netexit(net->xfrm.state_bydst), sz);
33323344 free_percpu(net->xfrm.state_cache_input);
33333345 }
33343346
net/xfrm/xfrm_user.c+22−10
@@ -35,6 +35,15 @@ · 34 unmodified lines
3535 #endif
3636 #include <linux/unaligned.h>
3737
38+static struct sock *xfrm_net_nlsk(const struct net *net, const struct sk_buff *skb)
39+{
40+ /* get the source of this request, see netlink_unicast_kernel */
41+ const struct sock *sk = NETLINK_CB(skb).sk;
42+
43+ /* sk is refcounted, the netns stays alive and nlsk with it */
44+ return rcu_dereference_protected(net->xfrm.nlsk, sk->sk_net_refcnt);
45+}
46+
3847 static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type,
3948 struct netlink_ext_ack *extack)
4049 {
@@ -1727,7 +1736,7 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, · 1686 unmodified lines
17271736 err = build_spdinfo(r_skb, net, sportid, seq, *flags);
17281737 BUG_ON(err < 0);
17291738
1730− return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid);
1739+ return nlmsg_unicast(xfrm_net_nlsk(net, skb), r_skb, sportid);
17311740 }
17321741
17331742 static inline unsigned int xfrm_sadinfo_msgsize(void)
@@ -1787,7 +1796,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, · 53 unmodified lines
17871796 err = build_sadinfo(r_skb, net, sportid, seq, *flags);
17881797 BUG_ON(err < 0);
17891798
1790− return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid);
1799+ return nlmsg_unicast(xfrm_net_nlsk(net, skb), r_skb, sportid);
17911800 }
17921801
17931802 static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -1807,7 +1816,7 @@ static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh, · 13 unmodified lines
18071816 if (IS_ERR(resp_skb)) {
18081817 err = PTR_ERR(resp_skb);
18091818 } else {
1810− err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid);
1819+ err = nlmsg_unicast(xfrm_net_nlsk(net, skb), resp_skb, NETLINK_CB(skb).portid);
18111820 }
18121821 xfrm_state_put(x);
18131822 out_noput:
@@ -1850,6 +1859,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, · 36 unmodified lines
18501859 pcpu_num = nla_get_u32(attrs[XFRMA_SA_PCPU]);
18511860 if (pcpu_num >= num_possible_cpus()) {
18521861 err = -EINVAL;
1862+ NL_SET_ERR_MSG(extack, "pCPU number too big");
18531863 goto out_noput;
18541864 }
18551865 }
@@ -1897,7 +1907,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, · 41 unmodified lines
18971907 }
18981908 }
18991909
1900− err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid);
1910+ err = nlmsg_unicast(xfrm_net_nlsk(net, skb), resp_skb, NETLINK_CB(skb).portid);
19011911
19021912 out:
19031913 xfrm_state_put(x);
@@ -2542,7 +2552,7 @@ static int xfrm_get_default(struct sk_buff *skb, struct nlmsghdr *nlh, · 638 unmodified lines
25422552 r_up->out = net->xfrm.policy_default[XFRM_POLICY_OUT];
25432553 nlmsg_end(r_skb, r_nlh);
25442554
2545− return nlmsg_unicast(net->xfrm.nlsk, r_skb, portid);
2555+ return nlmsg_unicast(xfrm_net_nlsk(net, skb), r_skb, portid);
25462556 }
25472557
25482558 static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -2608,7 +2618,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, · 59 unmodified lines
26082618 if (IS_ERR(resp_skb)) {
26092619 err = PTR_ERR(resp_skb);
26102620 } else {
2611− err = nlmsg_unicast(net->xfrm.nlsk, resp_skb,
2621+ err = nlmsg_unicast(xfrm_net_nlsk(net, skb), resp_skb,
26122622 NETLINK_CB(skb).portid);
26132623 }
26142624 } else {
@@ -2781,7 +2791,7 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh, · 166 unmodified lines
27812791 err = build_aevent(r_skb, x, &c);
27822792 BUG_ON(err < 0);
27832793
2784− err = nlmsg_unicast(net->xfrm.nlsk, r_skb, NETLINK_CB(skb).portid);
2794+ err = nlmsg_unicast(xfrm_net_nlsk(net, skb), r_skb, NETLINK_CB(skb).portid);
27852795 spin_unlock_bh(&x->lock);
27862796 xfrm_state_put(x);
27872797 return err;
@@ -3001,8 +3011,10 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh, · 213 unmodified lines
30013011 if (attrs[XFRMA_SA_PCPU]) {
30023012 x->pcpu_num = nla_get_u32(attrs[XFRMA_SA_PCPU]);
30033013 err = -EINVAL;
3004− if (x->pcpu_num >= num_possible_cpus())
3014+ if (x->pcpu_num >= num_possible_cpus()) {
3015+ NL_SET_ERR_MSG(extack, "pCPU number too big");
30053016 goto free_state;
3017+ }
30063018 }
30073019
30083020 err = verify_newpolicy_info(&ua->policy, extack);
@@ -3483,7 +3495,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, · 474 unmodified lines
34833495 goto err;
34843496 }
34853497
3486− err = netlink_dump_start(net->xfrm.nlsk, skb, nlh, &c);
3498+ err = netlink_dump_start(xfrm_net_nlsk(net, skb), skb, nlh, &c);
34873499 goto err;
34883500 }
34893501
@@ -3673,7 +3685,7 @@ static inline unsigned int xfrm_sa_len(struct xfrm_state *x) · 183 unmodified lines
36733685 }
36743686 if (x->if_id)
36753687 l += nla_total_size(sizeof(x->if_id));
3676− if (x->pcpu_num)
3688+ if (x->pcpu_num != UINT_MAX)
36773689 l += nla_total_size(sizeof(x->pcpu_num));
36783690
36793691 /* Must count x->lastused as it may become non-zero behind our back. */
rust/kernel/regulator.rs+18−15
@@ -23,7 +23,10 @@ use crate::{ · 22 unmodified lines
2323 prelude::*,
2424 };
2525
26−use core::{marker::PhantomData, mem::ManuallyDrop, ptr::NonNull};
26+use core::{
27+ marker::PhantomData,
28+ mem::ManuallyDrop, //
29+};
2730
2831 mod private {
2932 pub trait Sealed {}
@@ -229,15 +232,17 @@ pub fn devm_enable_optional(dev: &Device<Bound>, name: &CStr) -> Result { · 199 unmodified lines
229232 ///
230233 /// # Invariants
231234 ///
232−/// - `inner` is a non-null wrapper over a pointer to a `struct
233−/// regulator` obtained from [`regulator_get()`].
235+/// - `inner` is a pointer obtained from a successful call to
236+/// [`regulator_get()`]. It is treated as an opaque token that may only be
237+/// accessed using C API methods (e.g., it may be `NULL` if the C API returns
238+/// `NULL`).
234239 ///
235240 /// [`regulator_get()`]: https://docs.kernel.org/driver-api/regulator.html#c.regulator_get
236241 pub struct Regulator<State>
237242 where
238243 State: RegulatorState,
239244 {
240− inner: NonNull<bindings::regulator>,
245+ inner: *mut bindings::regulator,
241246 _phantom: PhantomData<State>,
242247 }
243248
@@ -249,7 +254,7 @@ impl<T: RegulatorState> Regulator<T> { · 5 unmodified lines
249254 // SAFETY: Safe as per the type invariants of `Regulator`.
250255 to_result(unsafe {
251256 bindings::regulator_set_voltage(
252− self.inner.as_ptr(),
257+ self.inner,
253258 min_voltage.as_microvolts(),
254259 max_voltage.as_microvolts(),
255260 )
@@ -259,7 +264,7 @@ impl<T: RegulatorState> Regulator<T> { · 3 unmodified lines
259264 /// Gets the current voltage of the regulator.
260265 pub fn get_voltage(&self) -> Result<Voltage> {
261266 // SAFETY: Safe as per the type invariants of `Regulator`.
262− let voltage = unsafe { bindings::regulator_get_voltage(self.inner.as_ptr()) };
267+ let voltage = unsafe { bindings::regulator_get_voltage(self.inner) };
263268
264269 to_result(voltage).map(|()| Voltage::from_microvolts(voltage))
265270 }
@@ -270,10 +275,8 @@ impl<T: RegulatorState> Regulator<T> { · 4 unmodified lines
270275 // received from the C code.
271276 from_err_ptr(unsafe { bindings::regulator_get(dev.as_raw(), name.as_char_ptr()) })?;
272277
273− // SAFETY: We can safely trust `inner` to be a pointer to a valid
274− // regulator if `ERR_PTR` was not returned.
275− let inner = unsafe { NonNull::new_unchecked(inner) };
276−
278+ // INVARIANT: `inner` is a pointer obtained from `regulator_get()`, and
279+ // the call was successful.
277280 Ok(Self {
278281 inner,
279282 _phantom: PhantomData,
@@ -282,12 +285,12 @@ impl<T: RegulatorState> Regulator<T> { · 2 unmodified lines
282285
283286 fn enable_internal(&self) -> Result {
284287 // SAFETY: Safe as per the type invariants of `Regulator`.
285− to_result(unsafe { bindings::regulator_enable(self.inner.as_ptr()) })
288+ to_result(unsafe { bindings::regulator_enable(self.inner) })
286289 }
287290
288291 fn disable_internal(&self) -> Result {
289292 // SAFETY: Safe as per the type invariants of `Regulator`.
290− to_result(unsafe { bindings::regulator_disable(self.inner.as_ptr()) })
293+ to_result(unsafe { bindings::regulator_disable(self.inner) })
291294 }
292295 }
293296
@@ -349,7 +352,7 @@ impl<T: IsEnabled> Regulator<T> { · 55 unmodified lines
349352 /// Checks if the regulator is enabled.
350353 pub fn is_enabled(&self) -> bool {
351354 // SAFETY: Safe as per the type invariants of `Regulator`.
352− unsafe { bindings::regulator_is_enabled(self.inner.as_ptr()) != 0 }
355+ unsafe { bindings::regulator_is_enabled(self.inner) != 0 }
353356 }
354357 }
355358
@@ -359,11 +362,11 @@ impl<T: RegulatorState> Drop for Regulator<T> { · 3 unmodified lines
359362 // SAFETY: By the type invariants, we know that `self` owns a
360363 // reference on the enabled refcount, so it is safe to relinquish it
361364 // now.
362− unsafe { bindings::regulator_disable(self.inner.as_ptr()) };
365+ unsafe { bindings::regulator_disable(self.inner) };
363366 }
364367 // SAFETY: By the type invariants, we know that `self` owns a reference,
365368 // so it is safe to relinquish it now.
366− unsafe { bindings::regulator_put(self.inner.as_ptr()) };
369+ unsafe { bindings::regulator_put(self.inner) };
367370 }
368371 }
369372
samples/landlock/sandboxer.c+3−2
@@ -299,7 +299,7 @@ out_unset: · 298 unmodified lines
299299
300300 /* clang-format on */
301301
302−#define LANDLOCK_ABI_LAST 7
302+#define LANDLOCK_ABI_LAST 8
303303
304304 #define XSTR(s) #s
305305 #define STR(s) XSTR(s)
@@ -436,7 +436,8 @@ int main(const int argc, char *const argv[], char *const *const envp) · 130 unmodified lines
436436 /* Removes LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON for ABI < 7 */
437437 supported_restrict_flags &=
438438 ~LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON;
439−
439+ __attribute__((fallthrough));
440+ case 7:
440441 /* Must be printed for any ABI < LANDLOCK_ABI_LAST. */
441442 fprintf(stderr,
442443 "Hint: You should update the running kernel "
scripts/coccinelle/api/kmalloc_objs.cocci+11−0
@@ -122,3 +122,14 @@ fresh identifier ALLOC_OBJS = script:python(ALLOC_ARRAY) { alloc_array(ALLOC_ARR · 121 unmodified lines
122122 - ALLOC(struct_size_t(TYPE, FLEX, COUNT), GFP)
123123 + ALLOC_FLEX(TYPE, FLEX, COUNT, GFP)
124124 )
125+
126+@drop_gfp_kernel depends on patch && !(file in "tools") && !(file in "samples")@
127+identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex,
128+ kzalloc_obj,kzalloc_objs,kzalloc_flex,
129+ kvmalloc_obj,kvmalloc_objs,kvmalloc_flex,
130+ kvzalloc_obj,kvzalloc_objs,kvzalloc_flex};
131+@@
132+
133+ ALLOC(...
134+- , GFP_KERNEL
135+ )
scripts/kconfig/merge_config.sh+10−14
@@ -151,6 +151,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do · 150 unmodified lines
151151 if ! "$AWK" -v prefix="$CONFIG_PREFIX" \
152152 -v warnoverride="$WARNOVERRIDE" \
153153 -v strict="$STRICT" \
154+ -v outfile="$TMP_FILE.new" \
154155 -v builtin="$BUILTIN" \
155156 -v warnredun="$WARNREDUN" '
156157 BEGIN {
@@ -195,7 +196,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do · 38 unmodified lines
195196
196197 # First pass: read merge file, store all lines and index
197198 FILENAME == ARGV[1] {
198− mergefile = FILENAME
199+ mergefile = FILENAME
199200 merge_lines[FNR] = $0
200201 merge_total = FNR
201202 cfg = get_cfg($0)
@@ -212,17 +213,17 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do · 10 unmodified lines
212213
213214 # Not a config or not in merge file - keep it
214215 if (cfg == "" || !(cfg in merge_cfg)) {
215− print $0 >> ARGV[3]
216+ print $0 >> outfile
216217 next
217218 }
218219
219− prev_val = $0
220+ prev_val = $0
220221 new_val = merge_cfg[cfg]
221222
222223 # BUILTIN: do not demote y to m
223224 if (builtin == "true" && new_val ~ /=m$/ && prev_val ~ /=y$/) {
224225 warn_builtin(cfg, prev_val, new_val)
225− print $0 >> ARGV[3]
226+ print $0 >> outfile
226227 skip_merge[merge_cfg_line[cfg]] = 1
227228 next
228229 }
@@ -235,7 +236,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do · 6 unmodified lines
235236
236237 # "=n" is the same as "is not set"
237238 if (prev_val ~ /=n$/ && new_val ~ / is not set$/) {
238− print $0 >> ARGV[3]
239+ print $0 >> outfile
239240 next
240241 }
241242
@@ -246,25 +247,20 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do · 4 unmodified lines
246247 }
247248 }
248249
249− # output file, skip all lines
250− FILENAME == ARGV[3] {
251− nextfile
252− }
253−
254250 END {
255251 # Newline in case base file lacks trailing newline
256− print "" >> ARGV[3]
252+ print "" >> outfile
257253 # Append merge file, skipping lines marked for builtin preservation
258254 for (i = 1; i <= merge_total; i++) {
259255 if (!(i in skip_merge)) {
260− print merge_lines[i] >> ARGV[3]
256+ print merge_lines[i] >> outfile
261257 }
262258 }
263259 if (strict_violated) {
264260 exit 1
265261 }
266262 }' \
267− "$ORIG_MERGE_FILE" "$TMP_FILE" "$TMP_FILE.new"; then
263+ "$ORIG_MERGE_FILE" "$TMP_FILE"; then
268264 # awk exited non-zero, strict mode was violated
269265 STRICT_MODE_VIOLATED=true
270266 fi
@@ -381,7 +377,7 @@ END { · 110 unmodified lines
381377 STRICT_MODE_VIOLATED=true
382378 fi
383379
384−if [ "$STRICT" == "true" ] && [ "$STRICT_MODE_VIOLATED" == "true" ]; then
380+if [ "$STRICT" = "true" ] && [ "$STRICT_MODE_VIOLATED" = "true" ]; then
385381 echo "Requested and effective config differ"
386382 exit 1
387383 fi
security/landlock/domain.c+1−2
@@ -94,8 +94,7 @@ static struct landlock_details *get_current_details(void) · 93 unmodified lines
9494 * allocate with GFP_KERNEL_ACCOUNT because it is independent from the
9595 * caller.
9696 */
97− details =
98− kzalloc_flex(*details, exe_path, path_size);
97+ details = kzalloc_flex(*details, exe_path, path_size);
9998 if (!details)
10099 return ERR_PTR(-ENOMEM);
101100
security/landlock/ruleset.c+4−5
@@ -32,9 +32,8 @@ static struct landlock_ruleset *create_ruleset(const u32 num_layers) · 31 unmodified lines
3232 {
3333 struct landlock_ruleset *new_ruleset;
3434
35− new_ruleset =
36− kzalloc_flex(*new_ruleset, access_masks, num_layers,
37− GFP_KERNEL_ACCOUNT);
35+ new_ruleset = kzalloc_flex(*new_ruleset, access_masks, num_layers,
36+ GFP_KERNEL_ACCOUNT);
3837 if (!new_ruleset)
3938 return ERR_PTR(-ENOMEM);
4039 refcount_set(&new_ruleset->usage, 1);
@@ -559,8 +558,8 @@ landlock_merge_ruleset(struct landlock_ruleset *const parent, · 518 unmodified lines
559558 if (IS_ERR(new_dom))
560559 return new_dom;
561560
562− new_dom->hierarchy = kzalloc_obj(*new_dom->hierarchy,
563− GFP_KERNEL_ACCOUNT);
561+ new_dom->hierarchy =
562+ kzalloc_obj(*new_dom->hierarchy, GFP_KERNEL_ACCOUNT);
564563 if (!new_dom->hierarchy)
565564 return ERR_PTR(-ENOMEM);
566565
security/landlock/tsync.c+73−19
@@ -203,6 +203,40 @@ static struct tsync_work *tsync_works_provide(struct tsync_works *s, · 202 unmodified lines
203203 return ctx;
204204 }
205205
206+/**
207+ * tsync_works_trim - Put the last tsync_work element
208+ *
209+ * @s: TSYNC works to trim.
210+ *
211+ * Put the last task and decrement the size of @s.
212+ *
213+ * This helper does not cancel a running task, but just reset the last element
214+ * to zero.
215+ */
216+static void tsync_works_trim(struct tsync_works *s)
217+{
218+ struct tsync_work *ctx;
219+
220+ if (WARN_ON_ONCE(s->size <= 0))
221+ return;
222+
223+ ctx = s->works[s->size - 1];
224+
225+ /*
226+ * For consistency, remove the task from ctx so that it does not look like
227+ * we handed it a task_work.
228+ */
229+ put_task_struct(ctx->task);
230+ *ctx = (typeof(*ctx)){};
231+
232+ /*
233+ * Cancel the tsync_works_provide() change to recycle the reserved memory
234+ * for the next thread, if any. This also ensures that cancel_tsync_works()
235+ * and tsync_works_release() do not see any NULL task pointers.
236+ */
237+ s->size--;
238+}
239+
206240 /*
207241 * tsync_works_grow_by - preallocates space for n more contexts in s
208242 *
@@ -256,13 +290,14 @@ static int tsync_works_grow_by(struct tsync_works *s, size_t n, gfp_t flags) · 47 unmodified lines
256290 * tsync_works_contains - checks for presence of task in s
257291 */
258292 static bool tsync_works_contains_task(const struct tsync_works *s,
259− struct task_struct *task)
293+ const struct task_struct *task)
260294 {
261295 size_t i;
262296
263297 for (i = 0; i < s->size; i++)
264298 if (s->works[i]->task == task)
265299 return true;
300+
266301 return false;
267302 }
268303
@@ -276,7 +311,7 @@ static void tsync_works_release(struct tsync_works *s) · 7 unmodified lines
276311 size_t i;
277312
278313 for (i = 0; i < s->size; i++) {
279− if (!s->works[i]->task)
314+ if (WARN_ON_ONCE(!s->works[i]->task))
280315 continue;
281316
282317 put_task_struct(s->works[i]->task);
@@ -284,6 +319,7 @@ static void tsync_works_release(struct tsync_works *s) · 1 unmodified line
284319
285320 for (i = 0; i < s->capacity; i++)
286321 kfree(s->works[i]);
322+
287323 kfree(s->works);
288324 s->works = NULL;
289325 s->size = 0;
@@ -295,7 +331,7 @@ static void tsync_works_release(struct tsync_works *s) · 5 unmodified lines
295331 */
296332 static size_t count_additional_threads(const struct tsync_works *works)
297333 {
298− struct task_struct *thread, *caller;
334+ const struct task_struct *caller, *thread;
299335 size_t n = 0;
300336
301337 caller = current;
@@ -334,7 +370,8 @@ static bool schedule_task_work(struct tsync_works *works, · 32 unmodified lines
334370 struct tsync_shared_context *shared_ctx)
335371 {
336372 int err;
337− struct task_struct *thread, *caller;
373+ const struct task_struct *caller;
374+ struct task_struct *thread;
338375 struct tsync_work *ctx;
339376 bool found_more_threads = false;
340377
@@ -379,16 +416,14 @@ static bool schedule_task_work(struct tsync_works *works, · 38 unmodified lines
379416
380417 init_task_work(&ctx->work, restrict_one_thread_callback);
381418 err = task_work_add(thread, &ctx->work, TWA_SIGNAL);
382− if (err) {
419+ if (unlikely(err)) {
383420 /*
384421 * task_work_add() only fails if the task is about to exit. We
385422 * checked that earlier, but it can happen as a race. Resume
386423 * without setting an error, as the task is probably gone in the
387− * next loop iteration. For consistency, remove the task from ctx
388− * so that it does not look like we handed it a task_work.
424+ * next loop iteration.
389425 */
390− put_task_struct(ctx->task);
391− ctx->task = NULL;
426+ tsync_works_trim(works);
392427
393428 atomic_dec(&shared_ctx->num_preparing);
394429 atomic_dec(&shared_ctx->num_unfinished);
@@ -406,12 +441,15 @@ static bool schedule_task_work(struct tsync_works *works, · 11 unmodified lines
406441 * shared_ctx->num_preparing and shared_ctx->num_unfished and mark the two
407442 * completions if needed, as if the task was never scheduled.
408443 */
409−static void cancel_tsync_works(struct tsync_works *works,
444+static void cancel_tsync_works(const struct tsync_works *works,
410445 struct tsync_shared_context *shared_ctx)
411446 {
412− int i;
447+ size_t i;
413448
414449 for (i = 0; i < works->size; i++) {
450+ if (WARN_ON_ONCE(!works->works[i]->task))
451+ continue;
452+
415453 if (!task_work_cancel(works->works[i]->task,
416454 &works->works[i]->work))
417455 continue;
@@ -447,6 +485,16 @@ int landlock_restrict_sibling_threads(const struct cred *old_cred, · 29 unmodified lines
447485 shared_ctx.new_cred = new_cred;
448486 shared_ctx.set_no_new_privs = task_no_new_privs(current);
449487
488+ /*
489+ * Serialize concurrent TSYNC operations to prevent deadlocks when
490+ * multiple threads call landlock_restrict_self() simultaneously.
491+ * If the lock is already held, we gracefully yield by restarting the
492+ * syscall. This allows the current thread to process pending
493+ * task_works before retrying.
494+ */
495+ if (!down_write_trylock(&current->signal->exec_update_lock))
496+ return restart_syscall();
497+
450498 /*
451499 * We schedule a pseudo-signal task_work for each of the calling task's
452500 * sibling threads. In the task work, each thread:
@@ -527,24 +575,30 @@ int landlock_restrict_sibling_threads(const struct cred *old_cred, · 74 unmodified lines
527575 -ERESTARTNOINTR);
528576
529577 /*
530− * Cancel task works for tasks that did not start running yet,
531− * and decrement all_prepared and num_unfinished accordingly.
578+ * Opportunistic improvement: try to cancel task
579+ * works for tasks that did not start running
580+ * yet. We do not have a guarantee that it
581+ * cancels any of the enqueued task works
582+ * because task_work_run() might already have
583+ * dequeued them.
532584 */
533585 cancel_tsync_works(&works, &shared_ctx);
534586
535587 /*
536− * The remaining task works have started running, so waiting for
537− * their completion will finish.
588+ * Break the loop with error. The cleanup code
589+ * after the loop unblocks the remaining
590+ * task_works.
538591 */
539− wait_for_completion(&shared_ctx.all_prepared);
592+ break;
540593 }
541594 }
542595 } while (found_more_threads &&
543596 !atomic_read(&shared_ctx.preparation_error));
544597
545598 /*
546− * We now have all sibling threads blocking and in "prepared" state in the
547− * task work. Ask all threads to commit.
599+ * We now have either (a) all sibling threads blocking and in "prepared"
600+ * state in the task work, or (b) the preparation error is set. Ask all
601+ * threads to commit (or abort).
548602 */
549603 complete_all(&shared_ctx.ready_to_commit);
550604
@@ -556,6 +610,6 @@ int landlock_restrict_sibling_threads(const struct cred *old_cred, · 5 unmodified lines
556610 wait_for_completion(&shared_ctx.all_finished);
557611
558612 tsync_works_release(&works);
559−
613+ up_write(&current->signal->exec_update_lock);
560614 return atomic_read(&shared_ctx.preparation_error);
561615 }
security/security.c+1−0
@@ -61,6 +61,7 @@ const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX + 1] = { · 60 unmodified lines
6161 [LOCKDOWN_BPF_WRITE_USER] = "use of bpf to write user RAM",
6262 [LOCKDOWN_DBG_WRITE_KERNEL] = "use of kgdb/kdb to write kernel RAM",
6363 [LOCKDOWN_RTAS_ERROR_INJECTION] = "RTAS error injection",
64+ [LOCKDOWN_XEN_USER_ACTIONS] = "Xen guest user action",
6465 [LOCKDOWN_INTEGRITY_MAX] = "integrity",
6566 [LOCKDOWN_KCORE] = "/proc/kcore access",
6667 [LOCKDOWN_KPROBES] = "use of kprobes",
sound/firewire/amdtp-stream.c+1−1
@@ -1164,7 +1164,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ · 1163 unmodified lines
11641164 struct pkt_desc *desc = s->packet_descs_cursor;
11651165 unsigned int pkt_header_length;
11661166 unsigned int packets;
1167− u32 curr_cycle_time;
1167+ u32 curr_cycle_time = 0;
11681168 bool need_hw_irq;
11691169 int i;
11701170
sound/hda/codecs/realtek/alc269.c+59−7
@@ -1017,12 +1017,30 @@ static int alc269_resume(struct hda_codec *codec) · 1016 unmodified lines
10171017 return 0;
10181018 }
10191019
1020−#define STARLABS_STARFIGHTER_SHUTUP_DELAY_MS 30
1020+#define ALC233_STARFIGHTER_SPK_PIN 0x1b
1021+#define ALC233_STARFIGHTER_GPIO2 0x04
10211022
1022−static void starlabs_starfighter_shutup(struct hda_codec *codec)
1023+static void alc233_starfighter_update_amp(struct hda_codec *codec, bool on)
10231024 {
1024− if (snd_hda_gen_shutup_speakers(codec))
1025− msleep(STARLABS_STARFIGHTER_SHUTUP_DELAY_MS);
1025+ snd_hda_codec_write(codec, ALC233_STARFIGHTER_SPK_PIN, 0,
1026+ AC_VERB_SET_EAPD_BTLENABLE,
1027+ on ? AC_EAPDBTL_EAPD : 0);
1028+ alc_update_gpio_data(codec, ALC233_STARFIGHTER_GPIO2, on);
1029+}
1030+
1031+static void alc233_starfighter_pcm_hook(struct hda_pcm_stream *hinfo,
1032+ struct hda_codec *codec,
1033+ struct snd_pcm_substream *substream,
1034+ int action)
1035+{
1036+ switch (action) {
1037+ case HDA_GEN_PCM_ACT_PREPARE:
1038+ alc233_starfighter_update_amp(codec, true);
1039+ break;
1040+ case HDA_GEN_PCM_ACT_CLEANUP:
1041+ alc233_starfighter_update_amp(codec, false);
1042+ break;
1043+ }
10261044 }
10271045
10281046 static void alc233_fixup_starlabs_starfighter(struct hda_codec *codec,
@@ -1031,8 +1049,16 @@ static void alc233_fixup_starlabs_starfighter(struct hda_codec *codec, · 2 unmodified lines
10311049 {
10321050 struct alc_spec *spec = codec->spec;
10331051
1034− if (action == HDA_FIXUP_ACT_PRE_PROBE)
1035− spec->shutup = starlabs_starfighter_shutup;
1052+ switch (action) {
1053+ case HDA_FIXUP_ACT_PRE_PROBE:
1054+ spec->gpio_mask |= ALC233_STARFIGHTER_GPIO2;
1055+ spec->gpio_dir |= ALC233_STARFIGHTER_GPIO2;
1056+ spec->gpio_data &= ~ALC233_STARFIGHTER_GPIO2;
1057+ break;
1058+ case HDA_FIXUP_ACT_PROBE:
1059+ spec->gen.pcm_playback_hook = alc233_starfighter_pcm_hook;
1060+ break;
1061+ }
10361062 }
10371063
10381064 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
@@ -3699,22 +3725,42 @@ static void alc245_tas2781_spi_hp_fixup_muteled(struct hda_codec *codec, · 2660 unmodified lines
36993725 alc_fixup_hp_gpio_led(codec, action, 0x04, 0x0);
37003726 alc285_fixup_hp_coef_micmute_led(codec, fix, action);
37013727 }
3728+
3729+static void alc245_hp_spk_mute_led_update(void *private_data, int enabled)
3730+{
3731+ struct hda_codec *codec = private_data;
3732+ unsigned int val;
3733+
3734+ val = enabled ? 0x08 : 0x04; /* 0x08 led on, 0x04 led off */
3735+ alc_update_coef_idx(codec, 0x0b, 0x0c, val);
3736+}
3737+
37023738 /* JD2: mute led GPIO3: micmute led */
37033739 static void alc245_tas2781_i2c_hp_fixup_muteled(struct hda_codec *codec,
37043740 const struct hda_fixup *fix, int action)
37053741 {
37063742 struct alc_spec *spec = codec->spec;
3743+ hda_nid_t hp_pin = alc_get_hp_pin(spec);
37073744 static const hda_nid_t conn[] = { 0x02 };
37083745
37093746 switch (action) {
37103747 case HDA_FIXUP_ACT_PRE_PROBE:
3748+ if (!hp_pin) {
3749+ spec->gen.vmaster_mute.hook = alc245_hp_spk_mute_led_update;
3750+ spec->gen.vmaster_mute_led = 1;
3751+ }
37113752 spec->gen.auto_mute_via_amp = 1;
37123753 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
37133754 break;
3755+ case HDA_FIXUP_ACT_INIT:
3756+ if (!hp_pin)
3757+ alc245_hp_spk_mute_led_update(codec, !spec->gen.master_mute);
3758+ break;
37143759 }
37153760
37163761 tas2781_fixup_txnw_i2c(codec, fix, action);
3717− alc245_fixup_hp_mute_led_coefbit(codec, fix, action);
3762+ if (hp_pin)
3763+ alc245_fixup_hp_mute_led_coefbit(codec, fix, action);
37183764 alc285_fixup_hp_coef_micmute_led(codec, fix, action);
37193765 }
37203766 /*
@@ -6854,6 +6900,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = { · 3133 unmodified lines
68546900 SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
68556901 SND_PCI_QUIRK(0x103c, 0x8735, "HP ProBook 435 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
68566902 SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT),
6903+ SND_PCI_QUIRK(0x103c, 0x8756, "HP ENVY Laptop 13-ba0xxx", ALC245_FIXUP_HP_X360_MUTE_LEDS),
68576904 SND_PCI_QUIRK(0x103c, 0x8760, "HP EliteBook 8{4,5}5 G7", ALC285_FIXUP_HP_BEEP_MICMUTE_LED),
68586905 SND_PCI_QUIRK(0x103c, 0x876e, "HP ENVY x360 Convertible 13-ay0xxx", ALC245_FIXUP_HP_X360_MUTE_LEDS),
68596906 SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED),
@@ -6867,6 +6914,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = { · 7 unmodified lines
68676914 SND_PCI_QUIRK(0x103c, 0x8788, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
68686915 SND_PCI_QUIRK(0x103c, 0x87b7, "HP Laptop 14-fq0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
68696916 SND_PCI_QUIRK(0x103c, 0x87c8, "HP", ALC287_FIXUP_HP_GPIO_LED),
6917+ SND_PCI_QUIRK(0x103c, 0x87cb, "HP Pavilion 15-eg0xxx", ALC287_FIXUP_HP_GPIO_LED),
68706918 SND_PCI_QUIRK(0x103c, 0x87cc, "HP Pavilion 15-eg0xxx", ALC287_FIXUP_HP_GPIO_LED),
68716919 SND_PCI_QUIRK(0x103c, 0x87d3, "HP Laptop 15-gw0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
68726920 SND_PCI_QUIRK(0x103c, 0x87df, "HP ProBook 430 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
@@ -7098,6 +7146,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = { · 225 unmodified lines
70987146 SND_PCI_QUIRK(0x103c, 0x8da7, "HP 14 Enstrom OmniBook X", ALC287_FIXUP_CS35L41_I2C_2),
70997147 SND_PCI_QUIRK(0x103c, 0x8da8, "HP 16 Piston OmniBook X", ALC287_FIXUP_CS35L41_I2C_2),
71007148 SND_PCI_QUIRK(0x103c, 0x8dd4, "HP EliteStudio 8 AIO", ALC274_FIXUP_HP_AIO_BIND_DACS),
7149+ SND_PCI_QUIRK(0x103c, 0x8dd7, "HP Laptop 15-fd0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
71017150 SND_PCI_QUIRK(0x103c, 0x8de8, "HP Gemtree", ALC245_FIXUP_TAS2781_SPI_2),
71027151 SND_PCI_QUIRK(0x103c, 0x8de9, "HP Gemtree", ALC245_FIXUP_TAS2781_SPI_2),
71037152 SND_PCI_QUIRK(0x103c, 0x8dec, "HP EliteBook 640 G12", ALC236_FIXUP_HP_GPIO_LED),
@@ -7177,6 +7226,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = { · 73 unmodified lines
71777226 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
71787227 SND_PCI_QUIRK(0x1043, 0x1194, "ASUS UM3406KA", ALC287_FIXUP_CS35L41_I2C_2),
71797228 SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
7229+ HDA_CODEC_QUIRK(0x1043, 0x1204, "ASUS Strix G16 G615JMR", ALC287_FIXUP_TXNW2781_I2C_ASUS),
71807230 SND_PCI_QUIRK(0x1043, 0x1204, "ASUS Strix G615JHR_JMR_JPR", ALC287_FIXUP_TAS2781_I2C),
71817231 SND_PCI_QUIRK(0x1043, 0x1214, "ASUS Strix G615LH_LM_LP", ALC287_FIXUP_TAS2781_I2C),
71827232 SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
@@ -7206,6 +7256,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = { · 23 unmodified lines
72067256 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS G513PI/PU/PV", ALC287_FIXUP_CS35L41_I2C_2),
72077257 SND_PCI_QUIRK(0x1043, 0x14f2, "ASUS VivoBook X515JA", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
72087258 SND_PCI_QUIRK(0x1043, 0x1503, "ASUS G733PY/PZ/PZV/PYV", ALC287_FIXUP_CS35L41_I2C_2),
7259+ SND_PCI_QUIRK(0x1043, 0x1514, "ASUS ROG Flow Z13 GZ302EAC", ALC287_FIXUP_CS35L41_I2C_2),
72097260 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
72107261 SND_PCI_QUIRK(0x1043, 0x1533, "ASUS GV302XA/XJ/XQ/XU/XV/XI", ALC287_FIXUP_CS35L41_I2C_2),
72117262 SND_PCI_QUIRK(0x1043, 0x1573, "ASUS GZ301VV/VQ/VU/VJ/VA/VC/VE/VVC/VQC/VUC/VJC/VEC/VCC", ALC285_FIXUP_ASUS_HEADSET_MIC),
@@ -7575,6 +7626,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = { · 363 unmodified lines
75757626 SND_PCI_QUIRK(0x17aa, 0x38ab, "Thinkbook 16P", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD),
75767627 SND_PCI_QUIRK(0x17aa, 0x38b4, "Legion Slim 7 16IRH8", ALC287_FIXUP_CS35L41_I2C_2),
75777628 HDA_CODEC_QUIRK(0x17aa, 0x391c, "Lenovo Yoga 7 2-in-1 14AKP10", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN),
7629+ HDA_CODEC_QUIRK(0x17aa, 0x391d, "Lenovo Yoga 7 2-in-1 16AKP10", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN),
75787630 SND_PCI_QUIRK(0x17aa, 0x38b5, "Legion Slim 7 16IRH8", ALC287_FIXUP_CS35L41_I2C_2),
75797631 SND_PCI_QUIRK(0x17aa, 0x38b6, "Legion Slim 7 16APH8", ALC287_FIXUP_CS35L41_I2C_2),
75807632 SND_PCI_QUIRK(0x17aa, 0x38b7, "Legion Slim 7 16APH8", ALC287_FIXUP_CS35L41_I2C_2),
sound/hda/controllers/intel.c+0−1
@@ -2077,7 +2077,6 @@ static const struct pci_device_id driver_denylist[] = { · 2076 unmodified lines
20772077 { PCI_DEVICE_SUB(0x1022, 0x1487, 0x1043, 0x874f) }, /* ASUS ROG Zenith II / Strix */
20782078 { PCI_DEVICE_SUB(0x1022, 0x1487, 0x1462, 0xcb59) }, /* MSI TRX40 Creator */
20792079 { PCI_DEVICE_SUB(0x1022, 0x1487, 0x1462, 0xcb60) }, /* MSI TRX40 */
2080− { PCI_DEVICE_SUB(0x1022, 0x15e3, 0x1462, 0xee59) }, /* MSI X870E Tomahawk WiFi */
20812080 {}
20822081 };
20832082
sound/pci/asihpi/hpimsgx.c+4−2
@@ -581,8 +581,10 @@ static u16 adapter_prepare(u16 adapter) · 580 unmodified lines
581581 HPI_ADAPTER_OPEN);
582582 hm.adapter_index = adapter;
583583 hw_entry_point(&hm, &hr);
584− memcpy(&rESP_HPI_ADAPTER_OPEN[adapter], &hr,
585− sizeof(rESP_HPI_ADAPTER_OPEN[0]));
584+ memcpy(&rESP_HPI_ADAPTER_OPEN[adapter].h, &hr,
585+ sizeof(rESP_HPI_ADAPTER_OPEN[adapter].h));
586+ memcpy(&rESP_HPI_ADAPTER_OPEN[adapter].a, &hr.u.ax.info,
587+ sizeof(rESP_HPI_ADAPTER_OPEN[adapter].a));
586588 if (hr.error)
587589 return hr.error;
588590
sound/soc/amd/yc/acp6x-mach.c+14−0
@@ -52,6 +52,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { · 51 unmodified lines
5252 DMI_MATCH(DMI_PRODUCT_NAME, "Bellator N176"),
5353 }
5454 },
55+ {
56+ .driver_data = &acp6x_card,
57+ .matches = {
58+ DMI_MATCH(DMI_BOARD_VENDOR, "HP"),
59+ DMI_MATCH(DMI_PRODUCT_NAME, "HP Laptop 15-fc0xxx"),
60+ }
61+ },
5562 {
5663 .driver_data = &acp6x_card,
5764 .matches = {
@@ -752,6 +759,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { · 694 unmodified lines
752759 DMI_MATCH(DMI_PRODUCT_NAME, "Thin A15 B7VE"),
753760 }
754761 },
762+ {
763+ .driver_data = &acp6x_card,
764+ .matches = {
765+ DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."),
766+ DMI_MATCH(DMI_PRODUCT_NAME, "M7601RM"),
767+ }
768+ },
755769 {}
756770 };
757771
sound/soc/codecs/adau1372.c+24−10
@@ -762,7 +762,7 @@ static int adau1372_startup(struct snd_pcm_substream *substream, struct snd_soc_ · 761 unmodified lines
762762 return 0;
763763 }
764764
765−static void adau1372_enable_pll(struct adau1372 *adau1372)
765+static int adau1372_enable_pll(struct adau1372 *adau1372)
766766 {
767767 unsigned int val, timeout = 0;
768768 int ret;
@@ -778,19 +778,26 @@ static void adau1372_enable_pll(struct adau1372 *adau1372) · 9 unmodified lines
778778 timeout++;
779779 } while (!(val & 1) && timeout < 3);
780780
781− if (ret < 0 || !(val & 1))
781+ if (ret < 0 || !(val & 1)) {
782782 dev_err(adau1372->dev, "Failed to lock PLL\n");
783+ return ret < 0 ? ret : -ETIMEDOUT;
784+ }
785+
786+ return 0;
783787 }
784788
785−static void adau1372_set_power(struct adau1372 *adau1372, bool enable)
789+static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
786790 {
787791 if (adau1372->enabled == enable)
788− return;
792+ return 0;
789793
790794 if (enable) {
791795 unsigned int clk_ctrl = ADAU1372_CLK_CTRL_MCLK_EN;
796+ int ret;
792797
793− clk_prepare_enable(adau1372->mclk);
798+ ret = clk_prepare_enable(adau1372->mclk);
799+ if (ret)
800+ return ret;
794801 if (adau1372->pd_gpio)
795802 gpiod_set_value(adau1372->pd_gpio, 0);
796803
@@ -804,7 +811,14 @@ static void adau1372_set_power(struct adau1372 *adau1372, bool enable) · 7 unmodified lines
804811 * accessed.
805812 */
806813 if (adau1372->use_pll) {
807− adau1372_enable_pll(adau1372);
814+ ret = adau1372_enable_pll(adau1372);
815+ if (ret) {
816+ regcache_cache_only(adau1372->regmap, true);
817+ if (adau1372->pd_gpio)
818+ gpiod_set_value(adau1372->pd_gpio, 1);
819+ clk_disable_unprepare(adau1372->mclk);
820+ return ret;
821+ }
808822 clk_ctrl |= ADAU1372_CLK_CTRL_CLKSRC;
809823 }
810824
@@ -829,6 +843,8 @@ static void adau1372_set_power(struct adau1372 *adau1372, bool enable) · 18 unmodified lines
829843 }
830844
831845 adau1372->enabled = enable;
846+
847+ return 0;
832848 }
833849
834850 static int adau1372_set_bias_level(struct snd_soc_component *component,
@@ -842,11 +858,9 @@ static int adau1372_set_bias_level(struct snd_soc_component *component, · 7 unmodified lines
842858 case SND_SOC_BIAS_PREPARE:
843859 break;
844860 case SND_SOC_BIAS_STANDBY:
845− adau1372_set_power(adau1372, true);
846− break;
861+ return adau1372_set_power(adau1372, true);
847862 case SND_SOC_BIAS_OFF:
848− adau1372_set_power(adau1372, false);
849− break;
863+ return adau1372_set_power(adau1372, false);
850864 }
851865
852866 return 0;
sound/soc/sdca/sdca_functions.c+10−4
@@ -216,9 +216,6 @@ static int find_sdca_init_table(struct device *dev, · 215 unmodified lines
216216 } else if (num_init_writes % sizeof(*raw) != 0) {
217217 dev_err(dev, "%pfwP: init table size invalid\n", function_node);
218218 return -EINVAL;
219− } else if ((num_init_writes / sizeof(*raw)) > SDCA_MAX_INIT_COUNT) {
220− dev_err(dev, "%pfwP: maximum init table size exceeded\n", function_node);
221− return -EINVAL;
222219 }
223220
224221 raw = kzalloc(num_init_writes, GFP_KERNEL);
@@ -1604,10 +1601,19 @@ static int find_sdca_entities(struct device *dev, struct sdw_slave *sdw, · 1379 unmodified lines
16041601 static struct sdca_entity *find_sdca_entity_by_label(struct sdca_function_data *function,
16051602 const char *entity_label)
16061603 {
1604+ struct sdca_entity *entity = NULL;
16071605 int i;
16081606
16091607 for (i = 0; i < function->num_entities; i++) {
1610− struct sdca_entity *entity = &function->entities[i];
1608+ entity = &function->entities[i];
1609+
1610+ /* check whole string first*/
1611+ if (!strcmp(entity->label, entity_label))
1612+ return entity;
1613+ }
1614+
1615+ for (i = 0; i < function->num_entities; i++) {
1616+ entity = &function->entities[i];
16111617
16121618 if (!strncmp(entity->label, entity_label, strlen(entity_label)))
16131619 return entity;
sound/soc/sof/ipc4-topology.c+1−1
@@ -2951,7 +2951,7 @@ static int sof_ipc4_control_load_bytes(struct snd_sof_dev *sdev, struct snd_sof_ · 2950 unmodified lines
29512951 return -EINVAL;
29522952 }
29532953
2954− if (scontrol->priv_size < sizeof(struct sof_abi_hdr)) {
2954+ if (scontrol->priv_size && scontrol->priv_size < sizeof(struct sof_abi_hdr)) {
29552955 dev_err(sdev->dev,
29562956 "bytes control %s initial data size %zu is insufficient.\n",
29572957 scontrol->name, scontrol->priv_size);
sound/usb/Kconfig+1−0
@@ -192,6 +192,7 @@ config SND_USB_AUDIO_QMI · 191 unmodified lines
192192 tristate "Qualcomm Audio Offload driver"
193193 depends on QCOM_QMI_HELPERS && SND_USB_AUDIO && SND_SOC_USB
194194 depends on USB_XHCI_HCD && USB_XHCI_SIDEBAND
195+ select AUXILIARY_BUS
195196 help
196197 Say Y here to enable the Qualcomm USB audio offloading feature.
197198
sound/usb/qcom/qc_audio_offload.c+1−1
@@ -1,6 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0
22 /*
3− * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
3+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
44 */
55
66 #include <linux/auxiliary_bus.h>
sound/usb/quirks.c+4−0
@@ -2148,6 +2148,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { · 2147 unmodified lines
21482148 /* Device matches */
21492149 DEVICE_FLG(0x001f, 0x0b21, /* AB13X USB Audio */
21502150 QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY),
2151+ DEVICE_FLG(0x001f, 0x0b23, /* AB17X USB Audio */
2152+ QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY),
21512153 DEVICE_FLG(0x0020, 0x0b21, /* GHW-123P */
21522154 QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY),
21532155 DEVICE_FLG(0x03f0, 0x654a, /* HP 320 FHD Webcam */
@@ -2429,6 +2431,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { · 275 unmodified lines
24292431 QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY),
24302432 VENDOR_FLG(0x07fd, /* MOTU */
24312433 QUIRK_FLAG_VALIDATE_RATES),
2434+ DEVICE_FLG(0x1235, 0x8006, 0), /* Focusrite Scarlett 2i2 1st Gen */
2435+ DEVICE_FLG(0x1235, 0x800a, 0), /* Focusrite Scarlett 2i4 1st Gen */
24322436 VENDOR_FLG(0x1235, /* Focusrite Novation */
24332437 QUIRK_FLAG_SKIP_CLOCK_SELECTOR |
24342438 QUIRK_FLAG_SKIP_IFACE_SETUP),
tools/arch/x86/include/asm/msr-index.h+4−1
@@ -740,7 +740,10 @@ · 739 unmodified lines
740740 #define MSR_AMD64_SNP_SMT_PROT BIT_ULL(MSR_AMD64_SNP_SMT_PROT_BIT)
741741 #define MSR_AMD64_SNP_SECURE_AVIC_BIT 18
742742 #define MSR_AMD64_SNP_SECURE_AVIC BIT_ULL(MSR_AMD64_SNP_SECURE_AVIC_BIT)
743−#define MSR_AMD64_SNP_RESV_BIT 19
743+#define MSR_AMD64_SNP_RESERVED_BITS19_22 GENMASK_ULL(22, 19)
744+#define MSR_AMD64_SNP_IBPB_ON_ENTRY_BIT 23
745+#define MSR_AMD64_SNP_IBPB_ON_ENTRY BIT_ULL(MSR_AMD64_SNP_IBPB_ON_ENTRY_BIT)
746+#define MSR_AMD64_SNP_RESV_BIT 24
744747 #define MSR_AMD64_SNP_RESERVED_MASK GENMASK_ULL(63, MSR_AMD64_SNP_RESV_BIT)
745748 #define MSR_AMD64_SAVIC_CONTROL 0xc0010138
746749 #define MSR_AMD64_SAVIC_EN_BIT 0
tools/arch/x86/include/uapi/asm/kvm.h+1−0
@@ -476,6 +476,7 @@ struct kvm_sync_regs { · 475 unmodified lines
476476 #define KVM_X86_QUIRK_SLOT_ZAP_ALL (1 << 7)
477477 #define KVM_X86_QUIRK_STUFF_FEATURE_MSRS (1 << 8)
478478 #define KVM_X86_QUIRK_IGNORE_GUEST_PAT (1 << 9)
479+#define KVM_X86_QUIRK_VMCS12_ALLOW_FREEZE_IN_SMM (1 << 10)
479480
480481 #define KVM_STATE_NESTED_FORMAT_VMX 0
481482 #define KVM_STATE_NESTED_FORMAT_SVM 1
tools/include/linux/build_bug.h+3−1
@@ -32,7 +32,8 @@ · 31 unmodified lines
3232 /**
3333 * BUILD_BUG_ON_MSG - break compile if a condition is true & emit supplied
3434 * error message.
35− * @condition: the condition which the compiler should know is false.
35+ * @cond: the condition which the compiler should know is false.
36+ * @msg: build-time error message
3637 *
3738 * See BUILD_BUG_ON for description.
3839 */
@@ -60,6 +61,7 @@ · 21 unmodified lines
6061
6162 /**
6263 * static_assert - check integer constant expression at build time
64+ * @expr: expression to be checked
6365 *
6466 * static_assert() is a wrapper for the C11 _Static_assert, with a
6567 * little macro magic to make the message optional (defaulting to the
tools/include/uapi/linux/kvm.h+8−0
@@ -14,6 +14,10 @@ · 13 unmodified lines
1414 #include <linux/ioctl.h>
1515 #include <asm/kvm.h>
1616
17+#ifdef __KERNEL__
18+#include <linux/kvm_types.h>
19+#endif
20+
1721 #define KVM_API_VERSION 12
1822
1923 /*
@@ -1601,7 +1605,11 @@ struct kvm_stats_desc { · 1581 unmodified lines
16011605 __u16 size;
16021606 __u32 offset;
16031607 __u32 bucket_size;
1608+#ifdef __KERNEL__
1609+ char name[KVM_STATS_NAME_SIZE];
1610+#else
16041611 char name[];
1612+#endif
16051613 };
16061614
16071615 #define KVM_GET_STATS_FD _IO(KVMIO, 0xce)
tools/perf/check-headers.sh+0−1
@@ -187,7 +187,6 @@ done · 186 unmodified lines
187187 check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memcpy_\(erms\|orig\))" -I"^#include <linux/cfi_types.h>"'
188188 check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memset_\(erms\|orig\))"'
189189 check arch/x86/include/asm/amd/ibs.h '-I "^#include .*/msr-index.h"'
190−check arch/arm64/include/asm/cputype.h '-I "^#include [<\"]\(asm/\)*sysreg.h"'
191190 check include/linux/unaligned.h '-I "^#include <linux/unaligned/packed_struct.h>" -I "^#include <asm/byteorder.h>" -I "^#pragma GCC diagnostic"'
192191 check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"'
193192 check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"'
tools/perf/util/kvm-stat-arch/kvm-stat-x86.c+3−3
@@ -4,9 +4,9 @@ · 3 unmodified lines
44 #include "../kvm-stat.h"
55 #include "../evsel.h"
66 #include "../env.h"
7−#include "../../arch/x86/include/uapi/asm/svm.h"
8−#include "../../arch/x86/include/uapi/asm/vmx.h"
9−#include "../../arch/x86/include/uapi/asm/kvm.h"
7+#include "../../../arch/x86/include/uapi/asm/svm.h"
8+#include "../../../arch/x86/include/uapi/asm/vmx.h"
9+#include "../../../arch/x86/include/uapi/asm/kvm.h"
1010 #include <subcmd/parse-options.h>
1111
1212 define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS);
tools/perf/util/metricgroup.c+3−3
@@ -1605,9 +1605,9 @@ bool metricgroup__has_metric_or_groups(const char *pmu, const char *metric_or_gr · 1604 unmodified lines
16051605 .metric_or_groups = metric_or_groups,
16061606 };
16071607
1608− return pmu_metrics_table__for_each_metric(table,
1609− metricgroup__has_metric_or_groups_callback,
1610− &data)
1608+ return metricgroup__for_each_metric(table,
1609+ metricgroup__has_metric_or_groups_callback,
1610+ &data)
16111611 ? true : false;
16121612 }
16131613
tools/perf/util/parse-events.c+65−17
@@ -1117,7 +1117,7 @@ static int config_attr(struct perf_event_attr *attr, · 1116 unmodified lines
11171117
11181118 static struct evsel_config_term *add_config_term(enum evsel_term_type type,
11191119 struct list_head *head_terms,
1120− bool weak)
1120+ bool weak, char *str, u64 val)
11211121 {
11221122 struct evsel_config_term *t;
11231123
@@ -1128,8 +1128,62 @@ static struct evsel_config_term *add_config_term(enum evsel_term_type type, · 4 unmodified lines
11281128 INIT_LIST_HEAD(&t->list);
11291129 t->type = type;
11301130 t->weak = weak;
1131− list_add_tail(&t->list, head_terms);
11321131
1132+ switch (type) {
1133+ case EVSEL__CONFIG_TERM_PERIOD:
1134+ case EVSEL__CONFIG_TERM_FREQ:
1135+ case EVSEL__CONFIG_TERM_STACK_USER:
1136+ case EVSEL__CONFIG_TERM_USR_CHG_CONFIG:
1137+ case EVSEL__CONFIG_TERM_USR_CHG_CONFIG1:
1138+ case EVSEL__CONFIG_TERM_USR_CHG_CONFIG2:
1139+ case EVSEL__CONFIG_TERM_USR_CHG_CONFIG3:
1140+ case EVSEL__CONFIG_TERM_USR_CHG_CONFIG4:
1141+ t->val.val = val;
1142+ break;
1143+ case EVSEL__CONFIG_TERM_TIME:
1144+ t->val.time = val;
1145+ break;
1146+ case EVSEL__CONFIG_TERM_INHERIT:
1147+ t->val.inherit = val;
1148+ break;
1149+ case EVSEL__CONFIG_TERM_OVERWRITE:
1150+ t->val.overwrite = val;
1151+ break;
1152+ case EVSEL__CONFIG_TERM_MAX_STACK:
1153+ t->val.max_stack = val;
1154+ break;
1155+ case EVSEL__CONFIG_TERM_MAX_EVENTS:
1156+ t->val.max_events = val;
1157+ break;
1158+ case EVSEL__CONFIG_TERM_PERCORE:
1159+ t->val.percore = val;
1160+ break;
1161+ case EVSEL__CONFIG_TERM_AUX_OUTPUT:
1162+ t->val.aux_output = val;
1163+ break;
1164+ case EVSEL__CONFIG_TERM_AUX_SAMPLE_SIZE:
1165+ t->val.aux_sample_size = val;
1166+ break;
1167+ case EVSEL__CONFIG_TERM_CALLGRAPH:
1168+ case EVSEL__CONFIG_TERM_BRANCH:
1169+ case EVSEL__CONFIG_TERM_DRV_CFG:
1170+ case EVSEL__CONFIG_TERM_RATIO_TO_PREV:
1171+ case EVSEL__CONFIG_TERM_AUX_ACTION:
1172+ if (str) {
1173+ t->val.str = strdup(str);
1174+ if (!t->val.str) {
1175+ zfree(&t);
1176+ return NULL;
1177+ }
1178+ t->free_str = true;
1179+ }
1180+ break;
1181+ default:
1182+ t->val.val = val;
1183+ break;
1184+ }
1185+
1186+ list_add_tail(&t->list, head_terms);
11331187 return t;
11341188 }
11351189
@@ -1142,7 +1196,7 @@ static int get_config_terms(const struct parse_events_terms *head_config, · 6 unmodified lines
11421196 struct evsel_config_term *new_term;
11431197 enum evsel_term_type new_type;
11441198 bool str_type = false;
1145− u64 val;
1199+ u64 val = 0;
11461200
11471201 switch (term->type_term) {
11481202 case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
@@ -1234,20 +1288,15 @@ static int get_config_terms(const struct parse_events_terms *head_config, · 85 unmodified lines
12341288 continue;
12351289 }
12361290
1237− new_term = add_config_term(new_type, head_terms, term->weak);
1291+ /*
1292+ * Note: Members evsel_config_term::val and
1293+ * parse_events_term::val are unions and endianness needs
1294+ * to be taken into account when changing such union members.
1295+ */
1296+ new_term = add_config_term(new_type, head_terms, term->weak,
1297+ str_type ? term->val.str : NULL, val);
12381298 if (!new_term)
12391299 return -ENOMEM;
1240−
1241− if (str_type) {
1242− new_term->val.str = strdup(term->val.str);
1243− if (!new_term->val.str) {
1244− zfree(&new_term);
1245− return -ENOMEM;
1246− }
1247− new_term->free_str = true;
1248− } else {
1249− new_term->val.val = val;
1250− }
12511300 }
12521301 return 0;
12531302 }
@@ -1277,10 +1326,9 @@ static int add_cfg_chg(const struct perf_pmu *pmu, · 23 unmodified lines
12771326 if (bits) {
12781327 struct evsel_config_term *new_term;
12791328
1280− new_term = add_config_term(new_term_type, head_terms, false);
1329+ new_term = add_config_term(new_term_type, head_terms, false, NULL, bits);
12811330 if (!new_term)
12821331 return -ENOMEM;
1283− new_term->val.cfg_chg = bits;
12841332 }
12851333
12861334 return 0;
tools/testing/selftests/drivers/net/team/Makefile+1−0
@@ -3,6 +3,7 @@ · 2 unmodified lines
33
44 TEST_PROGS := \
55 dev_addr_lists.sh \
6+ non_ether_header_ops.sh \
67 options.sh \
78 propagation.sh \
89 refleak.sh \
tools/testing/selftests/drivers/net/team/config+2−0
@@ -1,7 +1,9 @@
1+CONFIG_BONDING=y
12 CONFIG_DUMMY=y
23 CONFIG_IPV6=y
34 CONFIG_MACVLAN=y
45 CONFIG_NETDEVSIM=m
6+CONFIG_NET_IPGRE=y
57 CONFIG_NET_TEAM=y
68 CONFIG_NET_TEAM_MODE_ACTIVEBACKUP=y
79 CONFIG_NET_TEAM_MODE_LOADBALANCE=y
tools/testing/selftests/drivers/net/team/non_ether_header_ops.sh+41−0
@@ -0,0 +1,41 @@
1+#!/bin/bash
2+# SPDX-License-Identifier: GPL-2.0
3+# shellcheck disable=SC2154
4+#
5+# Reproduce the non-Ethernet header_ops confusion scenario with:
6+# g0 (gre) -> b0 (bond) -> t0 (team)
7+#
8+# Before the fix, direct header_ops inheritance in this stack could call
9+# callbacks with the wrong net_device context and crash.
10+
11+lib_dir=$(dirname "$0")
12+source "$lib_dir"/../../../net/lib.sh
13+
14+trap cleanup_all_ns EXIT
15+
16+setup_ns ns1
17+
18+ip -n "$ns1" link add d0 type dummy
19+ip -n "$ns1" addr add 10.10.10.1/24 dev d0
20+ip -n "$ns1" link set d0 up
21+
22+ip -n "$ns1" link add g0 type gre local 10.10.10.1
23+ip -n "$ns1" link add b0 type bond mode active-backup
24+ip -n "$ns1" link add t0 type team
25+
26+ip -n "$ns1" link set g0 master b0
27+ip -n "$ns1" link set b0 master t0
28+
29+ip -n "$ns1" link set g0 up
30+ip -n "$ns1" link set b0 up
31+ip -n "$ns1" link set t0 up
32+
33+# IPv6 address assignment triggers MLD join reports that call
34+# dev_hard_header() on t0, exercising the inherited header_ops path.
35+ip -n "$ns1" -6 addr add 2001:db8:1::1/64 dev t0 nodad
36+for i in $(seq 1 20); do
37+ ip netns exec "$ns1" ping -6 -I t0 ff02::1 -c1 -W1 &>/dev/null || true
38+done
39+
40+echo "PASS: non-Ethernet header_ops stacking did not crash"
41+exit "$EXIT_STATUS"
tools/testing/selftests/kvm/Makefile.kvm+1−0
@@ -206,6 +206,7 @@ TEST_GEN_PROGS_s390 += s390/ucontrol_test · 205 unmodified lines
206206 TEST_GEN_PROGS_s390 += s390/user_operexec
207207 TEST_GEN_PROGS_s390 += s390/keyop
208208 TEST_GEN_PROGS_s390 += rseq_test
209+TEST_GEN_PROGS_s390 += s390/irq_routing
209210
210211 TEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON)
211212 TEST_GEN_PROGS_riscv += riscv/sbi_pmu_test
tools/testing/selftests/kvm/s390/irq_routing.c+75−0
@@ -0,0 +1,75 @@
1+// SPDX-License-Identifier: GPL-2.0-only
2+/*
3+ * IRQ routing offset tests.
4+ *
5+ * Copyright IBM Corp. 2026
6+ *
7+ * Authors:
8+ * Janosch Frank <frankja@linux.ibm.com>
9+ */
10+#include <stdio.h>
11+#include <stdlib.h>
12+#include <string.h>
13+#include <sys/ioctl.h>
14+
15+#include "test_util.h"
16+#include "kvm_util.h"
17+#include "kselftest.h"
18+#include "ucall_common.h"
19+
20+extern char guest_code[];
21+asm("guest_code:\n"
22+ "diag %r0,%r0,0\n"
23+ "j .\n");
24+
25+static void test(void)
26+{
27+ struct kvm_irq_routing *routing;
28+ struct kvm_vcpu *vcpu;
29+ struct kvm_vm *vm;
30+ vm_paddr_t mem;
31+ int ret;
32+
33+ struct kvm_irq_routing_entry ue = {
34+ .type = KVM_IRQ_ROUTING_S390_ADAPTER,
35+ .gsi = 1,
36+ };
37+
38+ vm = vm_create_with_one_vcpu(&vcpu, guest_code);
39+ mem = vm_phy_pages_alloc(vm, 2, 4096 * 42, 0);
40+
41+ routing = kvm_gsi_routing_create();
42+ routing->nr = 1;
43+ routing->entries[0] = ue;
44+ routing->entries[0].u.adapter.summary_addr = (uintptr_t)mem;
45+ routing->entries[0].u.adapter.ind_addr = (uintptr_t)mem;
46+
47+ routing->entries[0].u.adapter.summary_offset = 4096 * 8;
48+ ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
49+ ksft_test_result(ret == -1 && errno == EINVAL, "summary offset outside of page\n");
50+
51+ routing->entries[0].u.adapter.summary_offset -= 4;
52+ ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
53+ ksft_test_result(ret == 0, "summary offset inside of page\n");
54+
55+ routing->entries[0].u.adapter.ind_offset = 4096 * 8;
56+ ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
57+ ksft_test_result(ret == -1 && errno == EINVAL, "ind offset outside of page\n");
58+
59+ routing->entries[0].u.adapter.ind_offset -= 4;
60+ ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
61+ ksft_test_result(ret == 0, "ind offset inside of page\n");
62+
63+ kvm_vm_free(vm);
64+}
65+
66+int main(int argc, char *argv[])
67+{
68+ TEST_REQUIRE(kvm_has_cap(KVM_CAP_IRQ_ROUTING));
69+
70+ ksft_print_header();
71+ ksft_set_plan(4);
72+ test();
73+
74+ ksft_finished(); /* Print results and exit() accordingly */
75+}
tools/testing/selftests/landlock/tsync_test.c+90−1
@@ -6,9 +6,10 @@ · 5 unmodified lines
66 */
77
88 #define _GNU_SOURCE
9+#include <linux/landlock.h>
910 #include <pthread.h>
11+#include <signal.h>
1012 #include <sys/prctl.h>
11−#include <linux/landlock.h>
1213
1314 #include "common.h"
1415
@@ -158,4 +159,92 @@ TEST(competing_enablement) · 143 unmodified lines
158159 EXPECT_EQ(0, close(ruleset_fd));
159160 }
160161
162+static void signal_nop_handler(int sig)
163+{
164+}
165+
166+struct signaler_data {
167+ pthread_t target;
168+ volatile bool stop;
169+};
170+
171+static void *signaler_thread(void *data)
172+{
173+ struct signaler_data *sd = data;
174+
175+ while (!sd->stop)
176+ pthread_kill(sd->target, SIGUSR1);
177+
178+ return NULL;
179+}
180+
181+/*
182+ * Number of idle sibling threads. This must be large enough that even on
183+ * machines with many cores, the sibling threads cannot all complete their
184+ * credential preparation in a single parallel wave, otherwise the signaler
185+ * thread has no window to interrupt wait_for_completion_interruptible().
186+ * 200 threads on a 64-core machine yields ~3 serialized waves, giving the
187+ * tight signal loop enough time to land an interruption.
188+ */
189+#define NUM_IDLE_THREADS 200
190+
191+/*
192+ * Exercises the tsync interruption and cancellation paths in tsync.c.
193+ *
194+ * When a signal interrupts the calling thread while it waits for sibling
195+ * threads to finish their credential preparation
196+ * (wait_for_completion_interruptible in landlock_restrict_sibling_threads),
197+ * the kernel sets ERESTARTNOINTR, cancels queued task works that have not
198+ * started yet (cancel_tsync_works), then waits for the remaining works to
199+ * finish. On the error return, syscalls.c aborts the prepared credentials.
200+ * The kernel automatically restarts the syscall, so userspace sees success.
201+ */
202+TEST(tsync_interrupt)
203+{
204+ size_t i;
205+ pthread_t threads[NUM_IDLE_THREADS];
206+ pthread_t signaler;
207+ struct signaler_data sd;
208+ struct sigaction sa = {};
209+ const int ruleset_fd = create_ruleset(_metadata);
210+
211+ disable_caps(_metadata);
212+
213+ /* Install a no-op SIGUSR1 handler so the signal does not kill us. */
214+ sa.sa_handler = signal_nop_handler;
215+ sigemptyset(&sa.sa_mask);
216+ ASSERT_EQ(0, sigaction(SIGUSR1, &sa, NULL));
217+
218+ ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0));
219+
220+ for (i = 0; i < NUM_IDLE_THREADS; i++)
221+ ASSERT_EQ(0, pthread_create(&threads[i], NULL, idle, NULL));
222+
223+ /*
224+ * Start a signaler thread that continuously sends SIGUSR1 to the
225+ * calling thread. This maximizes the chance of interrupting
226+ * wait_for_completion_interruptible() in the kernel's tsync path.
227+ */
228+ sd.target = pthread_self();
229+ sd.stop = false;
230+ ASSERT_EQ(0, pthread_create(&signaler, NULL, signaler_thread, &sd));
231+
232+ /*
233+ * The syscall may be interrupted and transparently restarted by the
234+ * kernel (ERESTARTNOINTR). From userspace, it should always succeed.
235+ */
236+ EXPECT_EQ(0, landlock_restrict_self(ruleset_fd,
237+ LANDLOCK_RESTRICT_SELF_TSYNC));
238+
239+ sd.stop = true;
240+ ASSERT_EQ(0, pthread_join(signaler, NULL));
241+
242+ for (i = 0; i < NUM_IDLE_THREADS; i++) {
243+ ASSERT_EQ(0, pthread_cancel(threads[i]));
244+ ASSERT_EQ(0, pthread_join(threads[i], NULL));
245+ }
246+
247+ EXPECT_EQ(0, close(ruleset_fd));
248+}
249+
161250 TEST_HARNESS_MAIN
tools/testing/selftests/mount_setattr/mount_setattr_test.c+1−1
@@ -1020,7 +1020,7 @@ FIXTURE_SETUP(mount_setattr_idmapped) · 1019 unmodified lines
10201020 "size=100000,mode=700"), 0);
10211021
10221022 ASSERT_EQ(mount("testing", "/mnt", "tmpfs", MS_NOATIME | MS_NODEV,
1023− "size=2m,mode=700"), 0);
1023+ "size=256m,mode=700"), 0);
10241024
10251025 ASSERT_EQ(mkdir("/mnt/A", 0777), 0);
10261026
tools/testing/selftests/net/fib_tests.sh+58−3
@@ -868,6 +868,64 @@ fib6_gc_test() · 867 unmodified lines
868868 check_rt_num 5 $($IP -6 route list |grep -v expires|grep 2001:20::|wc -l)
869869 log_test $ret 0 "ipv6 route garbage collection (replace with permanent)"
870870
871+ # Delete dummy_10 and remove all routes
872+ $IP link del dev dummy_10
873+
874+ # rd6 is required for the next test. (ipv6toolkit)
875+ if [ ! -x "$(command -v rd6)" ]; then
876+ echo "SKIP: rd6 not found."
877+ set +e
878+ cleanup &> /dev/null
879+ return
880+ fi
881+
882+ setup_ns ns2
883+ $IP link add veth1 type veth peer veth2 netns $ns2
884+ $IP link set veth1 up
885+ ip -netns $ns2 link set veth2 up
886+ $IP addr add fe80:dead::1/64 dev veth1
887+ ip -netns $ns2 addr add fe80:dead::2/64 dev veth2
888+
889+ # Add NTF_ROUTER neighbour to prevent rt6_age_examine_exception()
890+ # from removing not-yet-expired exceptions.
891+ ip -netns $ns2 link set veth2 address 00:11:22:33:44:55
892+ $IP neigh add fe80:dead::3 lladdr 00:11:22:33:44:55 dev veth1 router
893+
894+ $NS_EXEC sysctl -wq net.ipv6.conf.veth1.accept_redirects=1
895+ $NS_EXEC sysctl -wq net.ipv6.conf.veth1.forwarding=0
896+
897+ # Temporary routes
898+ for i in $(seq 1 5); do
899+ # Expire route after $EXPIRE seconds
900+ $IP -6 route add 2001:10::$i \
901+ via fe80:dead::2 dev veth1 expires $EXPIRE
902+
903+ ip netns exec $ns2 rd6 -i veth2 \
904+ -s fe80:dead::2 -d fe80:dead::1 \
905+ -r 2001:10::$i -t fe80:dead::3 -p ICMP6
906+ done
907+
908+ check_rt_num 5 $($IP -6 route list | grep expires | grep 2001:10:: | wc -l)
909+
910+ # Promote to permanent routes by "prepend" (w/o NLM_F_EXCL and NLM_F_REPLACE)
911+ for i in $(seq 1 5); do
912+ # -EEXIST, but the temporary route becomes the permanent route.
913+ $IP -6 route append 2001:10::$i \
914+ via fe80:dead::2 dev veth1 2>/dev/null || true
915+ done
916+
917+ check_rt_num 5 $($IP -6 route list | grep -v expires | grep 2001:10:: | wc -l)
918+ check_rt_num 5 $($IP -6 route list cache | grep 2001:10:: | wc -l)
919+
920+ # Trigger GC instead of waiting $GC_WAIT_TIME.
921+ # rt6_nh_dump_exceptions() just skips expired exceptions.
922+ $NS_EXEC sysctl -wq net.ipv6.route.flush=1
923+ check_rt_num 0 $($IP -6 route list cache | grep 2001:10:: | wc -l)
924+ log_test $ret 0 "ipv6 route garbage collection (promote to permanent routes)"
925+
926+ $IP neigh del fe80:dead::3 lladdr 00:11:22:33:44:55 dev veth1 router
927+ $IP link del veth1
928+
871929 # ra6 is required for the next test. (ipv6toolkit)
872930 if [ ! -x "$(command -v ra6)" ]; then
873931 echo "SKIP: ra6 not found."
@@ -876,9 +934,6 @@ fib6_gc_test() · 2 unmodified lines
876934 return
877935 fi
878936
879− # Delete dummy_10 and remove all routes
880− $IP link del dev dummy_10
881−
882937 # Create a pair of veth devices to send a RA message from one
883938 # device to another.
884939 $IP link add veth1 type veth peer name veth2
tools/testing/selftests/net/netfilter/nft_concat_range.sh+69−1
@@ -29,7 +29,8 @@ TYPES="net_port port_net net6_port port_proto net6_port_mac net6_port_mac_proto · 28 unmodified lines
2929 net6_port_net6_port net_port_mac_proto_net"
3030
3131 # Reported bugs, also described by TYPE_ variables below
32−BUGS="flush_remove_add reload net_port_proto_match avx2_mismatch doublecreate insert_overlap"
32+BUGS="flush_remove_add reload net_port_proto_match avx2_mismatch doublecreate
33+ insert_overlap load_flush_load4 load_flush_load8"
3334
3435 # List of possible paths to pktgen script from kernel tree for performance tests
3536 PKTGEN_SCRIPT_PATHS="
@@ -432,6 +433,30 @@ race_repeat 0 · 396 unmodified lines
432433 perf_duration 0
433434 "
434435
436+TYPE_load_flush_load4="
437+display reload with flush, 4bit groups
438+type_spec ipv4_addr . ipv4_addr
439+chain_spec ip saddr . ip daddr
440+dst addr4
441+proto icmp
442+
443+race_repeat 0
444+
445+perf_duration 0
446+"
447+
448+TYPE_load_flush_load8="
449+display reload with flush, 8bit groups
450+type_spec ipv4_addr . ipv4_addr
451+chain_spec ip saddr . ip daddr
452+dst addr4
453+proto icmp
454+
455+race_repeat 0
456+
457+perf_duration 0
458+"
459+
435460 # Set template for all tests, types and rules are filled in depending on test
436461 set_template='
437462 flush ruleset
@@ -1997,6 +2022,49 @@ test_bug_insert_overlap() · 1559 unmodified lines
19972022 return 0
19982023 }
19992024
2025+test_bug_load_flush_load4()
2026+{
2027+ local i
2028+
2029+ setup veth send_"${proto}" set || return ${ksft_skip}
2030+
2031+ for i in $(seq 0 255); do
2032+ local addelem="add element inet filter test"
2033+ local j
2034+
2035+ for j in $(seq 0 20); do
2036+ echo "$addelem { 10.$j.0.$i . 10.$j.1.$i }"
2037+ echo "$addelem { 10.$j.0.$i . 10.$j.2.$i }"
2038+ done
2039+ done > "$tmp"
2040+
2041+ nft -f "$tmp" || return 1
2042+
2043+ ( echo "flush set inet filter test";cat "$tmp") | nft -f -
2044+ [ $? -eq 0 ] || return 1
2045+
2046+ return 0
2047+}
2048+
2049+test_bug_load_flush_load8()
2050+{
2051+ local i
2052+
2053+ setup veth send_"${proto}" set || return ${ksft_skip}
2054+
2055+ for i in $(seq 1 100); do
2056+ echo "add element inet filter test { 10.0.0.$i . 10.0.1.$i }"
2057+ echo "add element inet filter test { 10.0.0.$i . 10.0.2.$i }"
2058+ done > "$tmp"
2059+
2060+ nft -f "$tmp" || return 1
2061+
2062+ ( echo "flush set inet filter test";cat "$tmp") | nft -f -
2063+ [ $? -eq 0 ] || return 1
2064+
2065+ return 0
2066+}
2067+
20002068 test_reported_issues() {
20012069 eval test_bug_"${subtest}"
20022070 }

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